summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/svga/svga_screen_texture.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/svga/svga_screen_texture.c')
-rw-r--r--src/gallium/drivers/svga/svga_screen_texture.c56
1 files changed, 30 insertions, 26 deletions
diff --git a/src/gallium/drivers/svga/svga_screen_texture.c b/src/gallium/drivers/svga/svga_screen_texture.c
index 3e2cb1a16d..2224c2d394 100644
--- a/src/gallium/drivers/svga/svga_screen_texture.c
+++ b/src/gallium/drivers/svga/svga_screen_texture.c
@@ -29,6 +29,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
#include "pipe/p_thread.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
@@ -158,8 +159,8 @@ svga_transfer_dma_band(struct svga_transfer *st,
st->base.x + st->base.width,
y + h,
st->base.zslice + 1,
- pf_get_blocksize(texture->base.format)*8/
- (pf_get_blockwidth(texture->base.format)*pf_get_blockheight(texture->base.format)));
+ util_format_get_blocksize(texture->base.format)*8/
+ (util_format_get_blockwidth(texture->base.format)*util_format_get_blockheight(texture->base.format)));
box.x = st->base.x;
box.y = y;
@@ -209,7 +210,7 @@ svga_transfer_dma(struct svga_transfer *st,
}
else {
unsigned y, h, srcy;
- unsigned blockheight = pf_get_blockheight(st->base.texture->format);
+ unsigned blockheight = util_format_get_blockheight(st->base.texture->format);
h = st->hw_nblocksy * blockheight;
srcy = 0;
for(y = 0; y < st->base.height; y += h) {
@@ -319,7 +320,7 @@ svga_texture_create(struct pipe_screen *screen,
*/
#if 0
if((templat->tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) &&
- !pf_is_compressed(templat->format))
+ !util_format_is_compressed(templat->format))
tex->key.flags |= SVGA3D_SURFACE_HINT_RENDERTARGET;
#endif
@@ -525,7 +526,7 @@ svga_texture_view_surface(struct pipe_context *pipe,
{
struct svga_screen *ss = svga_screen(tex->base.screen);
struct svga_winsys_surface *handle;
- int i, j;
+ uint32_t i, j;
unsigned z_offset = 0;
SVGA_DBG(DEBUG_PERF,
@@ -657,13 +658,11 @@ svga_get_tex_surface(struct pipe_screen *screen,
s->real_level = 0;
s->real_zslice = 0;
} else {
- struct svga_winsys_screen *sws = svga_winsys_screen(screen);
-
SVGA_DBG(DEBUG_VIEWS, "svga: Surface view: no %p, level %u, face %u, z %u, %p\n",
pt, level, face, zslice, s);
memset(&s->key, 0, sizeof s->key);
- sws->surface_reference(sws, &s->handle, tex->handle);
+ s->handle = tex->handle;
s->real_face = face;
s->real_level = level;
s->real_zslice = zslice;
@@ -677,11 +676,14 @@ static void
svga_tex_surface_destroy(struct pipe_surface *surf)
{
struct svga_surface *s = svga_surface(surf);
+ struct svga_texture *t = svga_texture(surf->texture);
struct svga_screen *ss = svga_screen(surf->texture->screen);
- SVGA_DBG(DEBUG_DMA, "unref sid %p (tex surface)\n", s->handle);
- assert(s->key.cachable == 0);
- svga_screen_surface_destroy(ss, &s->key, &s->handle);
+ if(s->handle != t->handle) {
+ SVGA_DBG(DEBUG_DMA, "unref sid %p (tex surface)\n", s->handle);
+ svga_screen_surface_destroy(ss, &s->key, &s->handle);
+ }
+
pipe_texture_reference(&surf->texture, NULL);
FREE(surf);
}
@@ -770,8 +772,8 @@ svga_get_tex_transfer(struct pipe_screen *screen,
struct svga_screen *ss = svga_screen(screen);
struct svga_winsys_screen *sws = ss->sws;
struct svga_transfer *st;
- unsigned nblocksx = pf_get_nblocksx(texture->format, w);
- unsigned nblocksy = pf_get_nblocksy(texture->format, h);
+ unsigned nblocksx = util_format_get_nblocksx(texture->format, w);
+ unsigned nblocksy = util_format_get_nblocksy(texture->format, h);
/* We can't map texture storage directly */
if (usage & PIPE_TRANSFER_MAP_DIRECTLY)
@@ -785,7 +787,7 @@ svga_get_tex_transfer(struct pipe_screen *screen,
st->base.y = y;
st->base.width = w;
st->base.height = h;
- st->base.stride = nblocksx*pf_get_blocksize(texture->format);
+ st->base.stride = nblocksx*util_format_get_blocksize(texture->format);
st->base.usage = usage;
st->base.face = face;
st->base.level = level;
@@ -909,7 +911,6 @@ svga_get_tex_sampler_view(struct pipe_context *pipe, struct pipe_texture *pt,
unsigned min_lod, unsigned max_lod)
{
struct svga_screen *ss = svga_screen(pt->screen);
- struct svga_winsys_screen *sws = ss->sws;
struct svga_texture *tex = svga_texture(pt);
struct svga_sampler_view *sv = NULL;
SVGA3dSurfaceFormat format = svga_translate_format(pt->format);
@@ -931,7 +932,7 @@ svga_get_tex_sampler_view(struct pipe_context *pipe, struct pipe_texture *pt,
if (min_lod == 0 && max_lod >= pt->last_level)
view = FALSE;
- if (pf_is_compressed(pt->format) && view) {
+ if (util_format_is_compressed(pt->format) && view) {
format = svga_translate_format_render(pt->format);
}
@@ -960,7 +961,7 @@ svga_get_tex_sampler_view(struct pipe_context *pipe, struct pipe_texture *pt,
sv = CALLOC_STRUCT(svga_sampler_view);
pipe_reference_init(&sv->reference, 1);
- sv->texture = tex;
+ pipe_texture_reference(&sv->texture, pt);
sv->min_lod = min_lod;
sv->max_lod = max_lod;
@@ -975,7 +976,7 @@ svga_get_tex_sampler_view(struct pipe_context *pipe, struct pipe_texture *pt,
pt->depth0,
pt->last_level);
sv->key.cachable = 0;
- sws->surface_reference(sws, &sv->handle, tex->handle);
+ sv->handle = tex->handle;
return sv;
}
@@ -998,7 +999,7 @@ svga_get_tex_sampler_view(struct pipe_context *pipe, struct pipe_texture *pt,
if (!sv->handle) {
assert(0);
sv->key.cachable = 0;
- sws->surface_reference(sws, &sv->handle, tex->handle);
+ sv->handle = tex->handle;
return sv;
}
@@ -1012,14 +1013,14 @@ svga_get_tex_sampler_view(struct pipe_context *pipe, struct pipe_texture *pt,
void
svga_validate_sampler_view(struct svga_context *svga, struct svga_sampler_view *v)
{
- struct svga_texture *tex = v->texture;
+ struct svga_texture *tex = svga_texture(v->texture);
unsigned numFaces;
unsigned age = 0;
int i, k;
assert(svga);
- if (v->handle == v->texture->handle)
+ if (v->handle == tex->handle)
return;
age = tex->age;
@@ -1047,11 +1048,14 @@ svga_validate_sampler_view(struct svga_context *svga, struct svga_sampler_view *
void
svga_destroy_sampler_view_priv(struct svga_sampler_view *v)
{
- struct svga_screen *ss = svga_screen(v->texture->base.screen);
-
- SVGA_DBG(DEBUG_DMA, "unref sid %p (sampler view)\n", v->handle);
- svga_screen_surface_destroy(ss, &v->key, &v->handle);
+ struct svga_texture *tex = svga_texture(v->texture);
+ if(v->handle != tex->handle) {
+ struct svga_screen *ss = svga_screen(v->texture->screen);
+ SVGA_DBG(DEBUG_DMA, "unref sid %p (sampler view)\n", v->handle);
+ svga_screen_surface_destroy(ss, &v->key, &v->handle);
+ }
+ pipe_texture_reference(&v->texture, NULL);
FREE(v);
}
@@ -1067,7 +1071,7 @@ svga_screen_buffer_from_texture(struct pipe_texture *texture,
svga_translate_format(texture->format),
stex->handle);
- *stride = pf_get_stride(texture->format, texture->width0);
+ *stride = util_format_get_stride(texture->format, texture->width0);
return *buffer != NULL;
}