[Mesa-dev] [PATCH] i965: do not emit empty sampler state

Erik Faye-Lund erik.faye-lund at collabora.com
Mon Aug 6 13:27:10 UTC 2018


If called with an empty size, brw_emit_buffer_surface_state asserts.
And since doing a zero-size upload is really just a lot of work for
no gain, let's just avoid the call in the first place.

Signed-off-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
---
This fixes an assert that triggers for me when running
dEQP-GLES31.functional.shaders.opaque_type_indexing.ssbo.const_literal_vertex
on top of a debug-build of mesa on top of i965. Since setting up a virgl
setup is rather convoluted, here's a piglit shader-test that reproduce it
directly on top of a debug-build of mesa on i965:

https://gitlab.freedesktop.org/kusma/piglit/tree/ssbo-zero-size

 .../drivers/dri/i965/brw_wm_surface_state.c    | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 9397b637c7..0da7f97218 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -1322,14 +1322,16 @@ upload_buffer_surface(struct brw_context *brw,
       if (!binding->AutomaticSize)
          size = MIN2(size, binding->Size);
 
-      struct intel_buffer_object *iobj =
-         intel_buffer_object(binding->BufferObject);
-      struct brw_bo *bo =
-         intel_bufferobj_buffer(brw, iobj, binding->Offset, size,
-                                (reloc_flags & RELOC_WRITE) != 0);
-
-      brw_emit_buffer_surface_state(brw, out_offset, bo, binding->Offset,
-                                    format, size, 1, reloc_flags);
+      if (size > 0) {
+         struct intel_buffer_object *iobj =
+            intel_buffer_object(binding->BufferObject);
+         struct brw_bo *bo =
+            intel_bufferobj_buffer(brw, iobj, binding->Offset, size,
+                                   (reloc_flags & RELOC_WRITE) != 0);
+
+         brw_emit_buffer_surface_state(brw, out_offset, bo, binding->Offset,
+                                       format, size, 1, reloc_flags);
+      }
    }
 }
 
-- 
2.18.0



More information about the mesa-dev mailing list