From 770323e33e62169827454af74e9f90f09997f962 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 11 Dec 2009 12:09:02 +0000 Subject: svga: Fix mixed signed comparisons. --- src/gallium/drivers/svga/svga_screen_texture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium/drivers/svga') diff --git a/src/gallium/drivers/svga/svga_screen_texture.c b/src/gallium/drivers/svga/svga_screen_texture.c index e7301aba84..ed83ba48f0 100644 --- a/src/gallium/drivers/svga/svga_screen_texture.c +++ b/src/gallium/drivers/svga/svga_screen_texture.c @@ -528,7 +528,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, -- cgit v1.2.3 From 16876b8328059446b6fa0951f7848e5d500244ab Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 11 Dec 2009 12:29:02 +0000 Subject: svga: Keep tight control of texture handle ownership. The texture owns the surface handle. All derivatives need to keep a reference to texture. This fixes several assertions failures starting up Jedi Knight 2. Should cause no change for DRM surface sharing -- reference count still done as before there. --- src/gallium/drivers/svga/svga_screen_texture.c | 35 ++++++++++++++------------ src/gallium/drivers/svga/svga_screen_texture.h | 9 ++++++- 2 files changed, 27 insertions(+), 17 deletions(-) (limited to 'src/gallium/drivers/svga') diff --git a/src/gallium/drivers/svga/svga_screen_texture.c b/src/gallium/drivers/svga/svga_screen_texture.c index ed83ba48f0..1eb03db280 100644 --- a/src/gallium/drivers/svga/svga_screen_texture.c +++ b/src/gallium/drivers/svga/svga_screen_texture.c @@ -657,13 +657,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 +675,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); } @@ -910,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); @@ -961,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; @@ -976,7 +976,7 @@ svga_get_tex_sampler_view(struct pipe_context *pipe, struct pipe_texture *pt, pt->depth[0], pt->last_level); sv->key.cachable = 0; - sws->surface_reference(sws, &sv->handle, tex->handle); + sv->handle = tex->handle; return sv; } @@ -999,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; } @@ -1013,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; @@ -1048,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); } diff --git a/src/gallium/drivers/svga/svga_screen_texture.h b/src/gallium/drivers/svga/svga_screen_texture.h index 1cc4063e65..8cfdfea693 100644 --- a/src/gallium/drivers/svga/svga_screen_texture.h +++ b/src/gallium/drivers/svga/svga_screen_texture.h @@ -61,7 +61,7 @@ struct svga_sampler_view { struct pipe_reference reference; - struct svga_texture *texture; + struct pipe_texture *texture; int min_lod; int max_lod; @@ -94,6 +94,13 @@ struct svga_texture * operation. */ struct svga_host_surface_cache_key key; + + /** + * Handle for the host side surface. + * + * This handle is owned by this texture. Views should hold on to a reference + * to this texture and never destroy this handle directly. + */ struct svga_winsys_surface *handle; }; -- cgit v1.2.3 From 8469baf41bd4775eab2403ecf08ed013343943a5 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 11 Dec 2009 13:15:12 +0000 Subject: svga: Always pass SVGA3D_SURFACE_HINT_DYNAMIC. Since we're reusing buffers we're effectively transforming all of them into dynamic buffers. It would be nice to not cache long lived static buffers. But there is no way to detect the long lived from short lived ones yet. A good heuristic would be buffer size. --- src/gallium/drivers/svga/svga_screen_cache.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/gallium/drivers/svga') diff --git a/src/gallium/drivers/svga/svga_screen_cache.c b/src/gallium/drivers/svga/svga_screen_cache.c index 8a06383f61..eff36e0bcc 100644 --- a/src/gallium/drivers/svga/svga_screen_cache.c +++ b/src/gallium/drivers/svga/svga_screen_cache.c @@ -277,6 +277,15 @@ svga_screen_surface_create(struct svga_screen *svgascreen, while(size < key->size.width) size <<= 1; key->size.width = size; + /* Since we're reusing buffers we're effectively transforming all + * of them into dynamic buffers. + * + * It would be nice to not cache long lived static buffers. But there + * is no way to detect the long lived from short lived ones yet. A + * good heuristic would be buffer size. + */ + key->flags &= ~SVGA3D_SURFACE_HINT_STATIC; + key->flags |= SVGA3D_SURFACE_HINT_DYNAMIC; } handle = svga_screen_cache_lookup(svgascreen, key); -- cgit v1.2.3 From ffae1f938d61165fce620bfd76ea7ae74dc63289 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 11 Dec 2009 14:14:03 +0000 Subject: svga: Add a missing dependency from the prescale state. Thanks for Keith to finding this. Fixes Jedi Knight 2 menus. --- src/gallium/drivers/svga/svga_state_constants.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gallium/drivers/svga') diff --git a/src/gallium/drivers/svga/svga_state_constants.c b/src/gallium/drivers/svga/svga_state_constants.c index 18cce7dde1..a5777d4fbd 100644 --- a/src/gallium/drivers/svga/svga_state_constants.c +++ b/src/gallium/drivers/svga/svga_state_constants.c @@ -231,7 +231,8 @@ static int emit_vs_consts( struct svga_context *svga, struct svga_tracked_state svga_hw_vs_parameters = { "hw vs params", - (SVGA_NEW_VS_CONST_BUFFER | + (SVGA_NEW_PRESCALE | + SVGA_NEW_VS_CONST_BUFFER | SVGA_NEW_ZERO_STRIDE | SVGA_NEW_VS_RESULT), emit_vs_consts -- cgit v1.2.3