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
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)
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. */
+}
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;
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);
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()
{
if (INTEL_DEBUG & DEBUG_SHADER_TIME)
emit_shader_time_begin();
- assign_binding_table_offsets();
+ assign_common_binding_table_offsets(0);
emit_prolog();
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);
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,