diff options
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs.cpp | 33 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_shader.cpp | 47 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_shader.h | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vec4.cpp | 33 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vec4.h | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 1 |
7 files changed, 58 insertions, 62 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 4d83c079c98..aec6fc7f38e 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -2981,37 +2981,12 @@ fs_visitor::setup_payload_gen6() void fs_visitor::assign_binding_table_offsets() { - int num_textures = _mesa_fls(fp->Base.SamplersUsed); - int next = 0; + uint32_t next_binding_table_offset = 0; - c->prog_data.binding_table.render_target_start = next; - next += c->key.nr_color_regions; + c->prog_data.binding_table.render_target_start = next_binding_table_offset; + next_binding_table_offset += c->key.nr_color_regions; - c->prog_data.base.binding_table.texture_start = next; - next += num_textures; - - if (shader) { - c->prog_data.base.binding_table.ubo_start = next; - next += shader->base.NumUniformBlocks; - } - - if (INTEL_DEBUG & DEBUG_SHADER_TIME) { - c->prog_data.base.binding_table.shader_time_start = next; - next++; - } - - if (fp->Base.UsesGather) { - c->prog_data.base.binding_table.gather_texture_start = next; - next += num_textures; - } - - /* This may or may not be used depending on how the compile goes. */ - c->prog_data.base.binding_table.pull_constants_start = next; - next++; - - assert(next < BRW_MAX_SURFACES); - - /* c->prog_data.base.binding_table.size will be set by mark_surface_used. */ + assign_common_binding_table_offsets(next_binding_table_offset); } bool diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index b4fff50139f..9f37013bddf 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -2669,8 +2669,10 @@ fs_visitor::fs_visitor(struct brw_context *brw, this->c = c; this->brw = brw; this->fp = fp; + this->prog = &fp->Base; this->shader_prog = shader_prog; this->prog = &fp->Base; + this->stage_prog_data = &c->prog_data.base; this->ctx = &brw->ctx; this->mem_ctx = ralloc_context(NULL); if (shader_prog) diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp index 256f9b21e4c..5992a1c33b5 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.cpp +++ b/src/mesa/drivers/dri/i965/brw_shader.cpp @@ -597,3 +597,50 @@ backend_visitor::dump_instructions() dump_instruction(inst); } } + + +/** + * Sets up the starting offsets for the groups of binding table entries + * commong to all pipeline stages. + * + * Unused groups are initialized to 0xd0d0d0d0 to make it obvious that they're + * unused but also make sure that addition of small offsets to them will + * trigger some of our asserts that surface indices are < BRW_MAX_SURFACES. + */ +void +backend_visitor::assign_common_binding_table_offsets(uint32_t next_binding_table_offset) +{ + int num_textures = _mesa_fls(prog->SamplersUsed); + + stage_prog_data->binding_table.texture_start = next_binding_table_offset; + next_binding_table_offset += num_textures; + + if (shader) { + stage_prog_data->binding_table.ubo_start = next_binding_table_offset; + next_binding_table_offset += shader->base.NumUniformBlocks; + } else { + stage_prog_data->binding_table.ubo_start = 0xd0d0d0d0; + } + + if (INTEL_DEBUG & DEBUG_SHADER_TIME) { + stage_prog_data->binding_table.shader_time_start = next_binding_table_offset; + next_binding_table_offset++; + } else { + stage_prog_data->binding_table.shader_time_start = 0xd0d0d0d0; + } + + if (prog->UsesGather) { + stage_prog_data->binding_table.gather_texture_start = next_binding_table_offset; + next_binding_table_offset += num_textures; + } else { + stage_prog_data->binding_table.gather_texture_start = 0xd0d0d0d0; + } + + /* This may or may not be used depending on how the compile goes. */ + stage_prog_data->binding_table.pull_constants_start = next_binding_table_offset; + next_binding_table_offset++; + + assert(next_binding_table_offset <= BRW_MAX_SURFACES); + + /* prog_data->base.binding_table.size will be set by mark_surface_used. */ +} diff --git a/src/mesa/drivers/dri/i965/brw_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h index 8b2d7a7ad17..7cebf1ffdd1 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.h +++ b/src/mesa/drivers/dri/i965/brw_shader.h @@ -60,6 +60,7 @@ public: struct brw_shader *shader; struct gl_shader_program *shader_prog; struct gl_program *prog; + struct brw_stage_prog_data *stage_prog_data; /** ralloc context for temporary data used during compile */ void *mem_ctx; @@ -72,6 +73,8 @@ public: virtual void dump_instruction(backend_instruction *inst) = 0; void dump_instructions(); + + void assign_common_binding_table_offsets(uint32_t next_binding_table_offset); }; uint32_t brw_texture_offset(ir_constant *offset); diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp index 6689a3d3c01..d3ee9a1f4c9 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp @@ -1421,37 +1421,6 @@ vec4_visitor::emit_shader_time_write(enum shader_time_shader_type type, emit(SHADER_OPCODE_SHADER_TIME_ADD, dst_reg(), src_reg(dst)); } -void -vec4_visitor::assign_binding_table_offsets() -{ - int num_textures = _mesa_fls(prog->SamplersUsed); - int next = 0; - - prog_data->base.binding_table.texture_start = next; - next += num_textures; - - if (shader) { - prog_data->base.binding_table.ubo_start = next; - next += shader->base.NumUniformBlocks; - } - - if (INTEL_DEBUG & DEBUG_SHADER_TIME) { - prog_data->base.binding_table.shader_time_start = next; - next++; - } - - if (prog->UsesGather) { - prog_data->base.binding_table.gather_texture_start = next; - next += num_textures; - } - - /* This may or may not be used depending on how the compile goes. */ - prog_data->base.binding_table.pull_constants_start = next; - next++; - - /* prog_data->base.binding_table.size will be set by mark_surface_used. */ -} - bool vec4_visitor::run() { @@ -1460,7 +1429,7 @@ vec4_visitor::run() if (INTEL_DEBUG & DEBUG_SHADER_TIME) emit_shader_time_begin(); - assign_binding_table_offsets(); + assign_common_binding_table_offsets(0); emit_prolog(); diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h index 647ebe126a5..41d91e5c49d 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.h +++ b/src/mesa/drivers/dri/i965/brw_vec4.h @@ -337,7 +337,6 @@ public: bool run(void); void fail(const char *msg, ...); - void assign_binding_table_offsets(); int virtual_grf_alloc(int size); void setup_uniform_clipplane_values(); void setup_uniform_values(ir_variable *ir); diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index 4b9e7879a2c..231815f12d4 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -3162,6 +3162,7 @@ vec4_visitor::vec4_visitor(struct brw_context *brw, this->prog = prog; this->key = key; this->prog_data = prog_data; + this->stage_prog_data = &prog_data->base; this->variable_ht = hash_table_ctor(0, hash_table_pointer_hash, |