[Mesa-dev] [PATCH 4/4] i965: Assert on the number of combined UBO and SSBO binding table entries

Iago Toral Quiroga itoral at igalia.com
Wed Sep 30 03:06:42 PDT 2015


In theory we can't break this assertion since the compiler frontend checks
that we don't exceed any of the individual limits, but it does not hurt to
be extra safe.
---
 src/mesa/drivers/dri/i965/brw_context.h  | 3 +++
 src/mesa/drivers/dri/i965/brw_shader.cpp | 1 +
 2 files changed, 4 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 53ed36f..103233b 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -736,6 +736,9 @@ struct brw_vs_prog_data {
 /** Max number of SSBOs in a shader */
 #define BRW_MAX_SSBO 12
 
+/** Max number of combined UBOs and SSBOs in a shader */
+#define BRW_MAX_COMBINED_UBO_SSBO (BRW_MAX_UBO + BRW_MAX_SSBO)
+
 /** Max number of atomic counter buffer objects in a shader */
 #define BRW_MAX_ABO 16
 
diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp
index 785cb27..ab2f9eb 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -1379,6 +1379,7 @@ backend_shader::assign_common_binding_table_offsets(uint32_t next_binding_table_
    next_binding_table_offset += num_textures;
 
    if (shader) {
+      assert(shader->base.NumUniformBlocks <= BRW_MAX_COMBINED_UBO_SSBO);
       stage_prog_data->binding_table.ubo_start = next_binding_table_offset;
       next_binding_table_offset += shader->base.NumUniformBlocks;
    } else {
-- 
1.9.1



More information about the mesa-dev mailing list