glsl: use reproducible name for lowered const arrays
Otherwise we can end up with mismatching names between the cached binary and the cached metadata. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
@@ -126,7 +126,7 @@ bool lower_variable_index_to_cond_assign(gl_shader_stage stage,
|
|||||||
exec_list *instructions, bool lower_input, bool lower_output,
|
exec_list *instructions, bool lower_input, bool lower_output,
|
||||||
bool lower_temp, bool lower_uniform);
|
bool lower_temp, bool lower_uniform);
|
||||||
bool lower_quadop_vector(exec_list *instructions, bool dont_lower_swz);
|
bool lower_quadop_vector(exec_list *instructions, bool dont_lower_swz);
|
||||||
bool lower_const_arrays_to_uniforms(exec_list *instructions);
|
bool lower_const_arrays_to_uniforms(exec_list *instructions, unsigned stage);
|
||||||
bool lower_clip_cull_distance(struct gl_shader_program *prog,
|
bool lower_clip_cull_distance(struct gl_shader_program *prog,
|
||||||
gl_linked_shader *shader);
|
gl_linked_shader *shader);
|
||||||
void lower_output_reads(unsigned stage, exec_list *instructions);
|
void lower_output_reads(unsigned stage, exec_list *instructions);
|
||||||
|
@@ -4899,7 +4899,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||||||
ctx->Const.NativeIntegers))
|
ctx->Const.NativeIntegers))
|
||||||
;
|
;
|
||||||
|
|
||||||
lower_const_arrays_to_uniforms(prog->_LinkedShaders[i]->ir);
|
lower_const_arrays_to_uniforms(prog->_LinkedShaders[i]->ir, i);
|
||||||
propagate_invariance(prog->_LinkedShaders[i]->ir);
|
propagate_invariance(prog->_LinkedShaders[i]->ir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -45,9 +45,11 @@
|
|||||||
namespace {
|
namespace {
|
||||||
class lower_const_array_visitor : public ir_rvalue_visitor {
|
class lower_const_array_visitor : public ir_rvalue_visitor {
|
||||||
public:
|
public:
|
||||||
lower_const_array_visitor(exec_list *insts)
|
lower_const_array_visitor(exec_list *insts, unsigned s)
|
||||||
{
|
{
|
||||||
instructions = insts;
|
instructions = insts;
|
||||||
|
stage = s;
|
||||||
|
const_count = 0;
|
||||||
progress = false;
|
progress = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,6 +64,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
exec_list *instructions;
|
exec_list *instructions;
|
||||||
|
unsigned stage;
|
||||||
|
unsigned const_count;
|
||||||
bool progress;
|
bool progress;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -83,7 +87,16 @@ lower_const_array_visitor::handle_rvalue(ir_rvalue **rvalue)
|
|||||||
|
|
||||||
void *mem_ctx = ralloc_parent(con);
|
void *mem_ctx = ralloc_parent(con);
|
||||||
|
|
||||||
char *uniform_name = ralloc_asprintf(mem_ctx, "constarray__%p", con);
|
/* In the very unlikely event of 4294967295 constant arrays in a single
|
||||||
|
* shader, don't promote this to a uniform.
|
||||||
|
*/
|
||||||
|
unsigned limit = ~0;
|
||||||
|
if (const_count == limit)
|
||||||
|
return;
|
||||||
|
|
||||||
|
char *uniform_name = ralloc_asprintf(mem_ctx, "constarray_%x_%u",
|
||||||
|
const_count, stage);
|
||||||
|
const_count++;
|
||||||
|
|
||||||
ir_variable *uni =
|
ir_variable *uni =
|
||||||
new(mem_ctx) ir_variable(con->type, uniform_name, ir_var_uniform);
|
new(mem_ctx) ir_variable(con->type, uniform_name, ir_var_uniform);
|
||||||
@@ -104,8 +117,8 @@ lower_const_array_visitor::handle_rvalue(ir_rvalue **rvalue)
|
|||||||
} /* anonymous namespace */
|
} /* anonymous namespace */
|
||||||
|
|
||||||
bool
|
bool
|
||||||
lower_const_arrays_to_uniforms(exec_list *instructions)
|
lower_const_arrays_to_uniforms(exec_list *instructions, unsigned stage)
|
||||||
{
|
{
|
||||||
lower_const_array_visitor v(instructions);
|
lower_const_array_visitor v(instructions, stage);
|
||||||
return v.run();
|
return v.run();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user