i965: Move the common binding table offset code to brw_shader.cpp.
Now that both vec4 and fs are dynamically assigning offsets, a lot of the code is the same. v2: Avoid passing around the next offset through the class. (Review by Paul) Reviewed-by: Paul Berry <stereotype441@gmail.com>
This commit is contained in:
parent
d395485e1d
commit
705a90e304
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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. */
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue