diff options
-rw-r--r-- | src/gallium/drivers/svga/svga_pipe_sampler.c | 28 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_sampler_view.h | 4 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_state_sampler.c | 17 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_surface.c | 14 |
4 files changed, 46 insertions, 17 deletions
diff --git a/src/gallium/drivers/svga/svga_pipe_sampler.c b/src/gallium/drivers/svga/svga_pipe_sampler.c index bb18f5a8247..ab84ed39602 100644 --- a/src/gallium/drivers/svga/svga_pipe_sampler.c +++ b/src/gallium/drivers/svga/svga_pipe_sampler.c @@ -35,6 +35,8 @@ #include "svga_cmd.h" #include "svga_debug.h" #include "svga_resource_texture.h" +#include "svga_surface.h" +#include "svga_sampler_view.h" static inline unsigned @@ -445,7 +447,31 @@ svga_set_sampler_views(struct pipe_context *pipe, svga->dirty |= SVGA_NEW_TEXTURE_FLAGS; svga->curr.tex_flags.flag_1d = flag_1d; svga->curr.tex_flags.flag_srgb = flag_srgb; - } + } + + /* Check if any of the sampler view resources collide with the framebuffer + * color buffers or depth stencil resource. If so, enable the NEW_FRAME_BUFFER + * dirty bit so that emit_framebuffer can be invoked to create backed view + * for the conflicted surface view. + */ + for (i = 0; i < svga->curr.framebuffer.nr_cbufs; i++) { + struct svga_surface *s = svga_surface(svga->curr.framebuffer.cbufs[i]); + if (s) { + if (svga_check_sampler_view_resource_collision(svga, s->handle, shader)) { + svga->dirty |= SVGA_NEW_FRAME_BUFFER; + break; + } + } + } + + if (svga->curr.framebuffer.zsbuf) { + struct svga_surface *s = svga_surface(svga->curr.framebuffer.zsbuf); + if (s) { + if (svga_check_sampler_view_resource_collision(svga, s->handle, shader)) { + svga->dirty |= SVGA_NEW_FRAME_BUFFER; + } + } + } } diff --git a/src/gallium/drivers/svga/svga_sampler_view.h b/src/gallium/drivers/svga/svga_sampler_view.h index acd7ae0ca24..4ca7fb781a9 100644 --- a/src/gallium/drivers/svga/svga_sampler_view.h +++ b/src/gallium/drivers/svga/svga_sampler_view.h @@ -100,6 +100,6 @@ svga_sampler_view_reference(struct svga_sampler_view **ptr, struct svga_sampler_ boolean svga_check_sampler_view_resource_collision(struct svga_context *svga, - struct svga_winsys_surface *res); - + struct svga_winsys_surface *res, + unsigned shader); #endif diff --git a/src/gallium/drivers/svga/svga_state_sampler.c b/src/gallium/drivers/svga/svga_state_sampler.c index 1c6913e4a26..611d2c6102f 100644 --- a/src/gallium/drivers/svga/svga_state_sampler.c +++ b/src/gallium/drivers/svga/svga_state_sampler.c @@ -63,23 +63,22 @@ svga_resource_handle(struct pipe_resource *res) */ boolean svga_check_sampler_view_resource_collision(struct svga_context *svga, - struct svga_winsys_surface *res) + struct svga_winsys_surface *res, + unsigned shader) { struct pipe_screen *screen = svga->pipe.screen; - unsigned shader, i; + unsigned i; if (svga_screen(screen)->debug.no_surface_view) { return FALSE; } - for (shader = PIPE_SHADER_VERTEX; shader <= PIPE_SHADER_GEOMETRY; shader++) { - for (i = 0; i < svga->curr.num_sampler_views[shader]; i++) { - struct svga_pipe_sampler_view *sv = - svga_pipe_sampler_view(svga->curr.sampler_views[shader][i]); + for (i = 0; i < svga->curr.num_sampler_views[shader]; i++) { + struct svga_pipe_sampler_view *sv = + svga_pipe_sampler_view(svga->curr.sampler_views[shader][i]); - if (sv && res == svga_resource_handle(sv->base.texture)) { - return TRUE; - } + if (sv && res == svga_resource_handle(sv->base.texture)) { + return TRUE; } } diff --git a/src/gallium/drivers/svga/svga_surface.c b/src/gallium/drivers/svga/svga_surface.c index 79981dcf5ff..4b0f9417c32 100644 --- a/src/gallium/drivers/svga/svga_surface.c +++ b/src/gallium/drivers/svga/svga_surface.c @@ -377,6 +377,7 @@ svga_validate_surface_view(struct svga_context *svga, struct svga_surface *s) { enum pipe_error ret = PIPE_OK; int try; + unsigned shader; assert(svga_have_vgpu10(svga)); @@ -388,11 +389,14 @@ svga_validate_surface_view(struct svga_context *svga, struct svga_surface *s) * associated resource. We will then use the cloned surface view for * render target. */ - if (svga_check_sampler_view_resource_collision(svga, s->handle)) { - SVGA_DBG(DEBUG_VIEWS, - "same resource used in shaderResource and renderTarget 0x%x\n", - s->handle); - s = create_backed_surface_view(svga, s); + for (shader = PIPE_SHADER_VERTEX; shader <= PIPE_SHADER_GEOMETRY; shader++) { + if (svga_check_sampler_view_resource_collision(svga, s->handle, shader)) { + SVGA_DBG(DEBUG_VIEWS, + "same resource used in shaderResource and renderTarget 0x%x\n", + s->handle); + s = create_backed_surface_view(svga, s); + break; + } } if (s->view_id == SVGA3D_INVALID_ID) { |