svga: add new svga_check_sampler_framebuffer_resource_collision()
authorBrian Paul <brianp@vmware.com>
Fri, 26 Aug 2016 00:01:57 +0000 (18:01 -0600)
committerBrian Paul <brianp@vmware.com>
Fri, 26 Aug 2016 20:20:19 +0000 (14:20 -0600)
Reviewed-by: Neha Bhende <bhenden@vmware.com>
src/gallium/drivers/svga/svga_sampler_view.h
src/gallium/drivers/svga/svga_state_sampler.c

index 15f2313c4c9d7e912d731f81d28e39f60f529e1f..b36f089263a2705a2eee416b6e7837b18a0d3f19 100644 (file)
@@ -104,6 +104,10 @@ svga_check_sampler_view_resource_collision(struct svga_context *svga,
                                            struct svga_winsys_surface *res,
                                            unsigned shader);
 
+boolean
+svga_check_sampler_framebuffer_resource_collision(struct svga_context *svga,
+                                                  enum pipe_shader_type shader);
+
 enum pipe_error
 svga_validate_pipe_sampler_view(struct svga_context *svga,
                                 struct svga_pipe_sampler_view *sv);
index 420a5667efb0fb929bd1b11fd4829831d4979191..55bed027b57d95130bcd611d040b4241d4244443 100644 (file)
 #include "svga_format.h"
 #include "svga_resource_buffer.h"
 #include "svga_resource_texture.h"
+#include "svga_sampler_view.h"
 #include "svga_shader.h"
 #include "svga_state.h"
-#include "svga_sampler_view.h"
+#include "svga_surface.h"
 
 
 /** Get resource handle for a texture or buffer */
@@ -87,6 +88,36 @@ svga_check_sampler_view_resource_collision(struct svga_context *svga,
 }
 
 
+/**
+ * Check if there are any resources that are both bound to a render target
+ * and bound as a shader resource for the given type of shader.
+ */
+boolean
+svga_check_sampler_framebuffer_resource_collision(struct svga_context *svga,
+                                                  enum pipe_shader_type shader)
+{
+   struct svga_surface *surf;
+   unsigned i;
+
+   for (i = 0; i < svga->curr.framebuffer.nr_cbufs; i++) {
+      surf = svga_surface(svga->curr.framebuffer.cbufs[i]);
+      if (surf &&
+          svga_check_sampler_view_resource_collision(svga, surf->handle,
+                                                     shader)) {
+         return TRUE;
+      }
+   }
+
+   surf = svga_surface(svga->curr.framebuffer.zsbuf);
+   if (surf &&
+       svga_check_sampler_view_resource_collision(svga, surf->handle, shader)) {
+      return TRUE;
+   }
+
+   return FALSE;
+}
+
+
 /**
  * Create a DX ShaderResourceSamplerView for the given pipe_sampler_view,
  * if needed.