i965: Fix dead pointers to fp->Parameters->ParameterValues[] after realloc.
Fixes texrect-many regression with ff_fragment_shader -- as we added refs to the subsequent texcoord scaling paramters, the array got realloced to a new address while our params[] still pointed at the old location.
This commit is contained in:
@@ -316,7 +316,6 @@ int
|
|||||||
fs_visitor::setup_uniform_values(int loc, const glsl_type *type)
|
fs_visitor::setup_uniform_values(int loc, const glsl_type *type)
|
||||||
{
|
{
|
||||||
unsigned int offset = 0;
|
unsigned int offset = 0;
|
||||||
float *vec_values;
|
|
||||||
|
|
||||||
if (type->is_matrix()) {
|
if (type->is_matrix()) {
|
||||||
const glsl_type *column = glsl_type::get_instance(GLSL_TYPE_FLOAT,
|
const glsl_type *column = glsl_type::get_instance(GLSL_TYPE_FLOAT,
|
||||||
@@ -335,7 +334,6 @@ fs_visitor::setup_uniform_values(int loc, const glsl_type *type)
|
|||||||
case GLSL_TYPE_UINT:
|
case GLSL_TYPE_UINT:
|
||||||
case GLSL_TYPE_INT:
|
case GLSL_TYPE_INT:
|
||||||
case GLSL_TYPE_BOOL:
|
case GLSL_TYPE_BOOL:
|
||||||
vec_values = fp->Base.Parameters->ParameterValues[loc];
|
|
||||||
for (unsigned int i = 0; i < type->vector_elements; i++) {
|
for (unsigned int i = 0; i < type->vector_elements; i++) {
|
||||||
unsigned int param = c->prog_data.nr_params++;
|
unsigned int param = c->prog_data.nr_params++;
|
||||||
|
|
||||||
@@ -359,8 +357,8 @@ fs_visitor::setup_uniform_values(int loc, const glsl_type *type)
|
|||||||
c->prog_data.param_convert[param] = PARAM_NO_CONVERT;
|
c->prog_data.param_convert[param] = PARAM_NO_CONVERT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
this->param_index[param] = loc;
|
||||||
c->prog_data.param[param] = &vec_values[i];
|
this->param_offset[param] = i;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@@ -431,7 +429,6 @@ fs_visitor::setup_builtin_uniform_values(ir_variable *ir)
|
|||||||
*/
|
*/
|
||||||
int index = _mesa_add_state_reference(this->fp->Base.Parameters,
|
int index = _mesa_add_state_reference(this->fp->Base.Parameters,
|
||||||
(gl_state_index *)tokens);
|
(gl_state_index *)tokens);
|
||||||
float *vec_values = this->fp->Base.Parameters->ParameterValues[index];
|
|
||||||
|
|
||||||
/* Add each of the unique swizzles of the element as a
|
/* Add each of the unique swizzles of the element as a
|
||||||
* parameter. This'll end up matching the expected layout of
|
* parameter. This'll end up matching the expected layout of
|
||||||
@@ -446,7 +443,9 @@ fs_visitor::setup_builtin_uniform_values(ir_variable *ir)
|
|||||||
|
|
||||||
c->prog_data.param_convert[c->prog_data.nr_params] =
|
c->prog_data.param_convert[c->prog_data.nr_params] =
|
||||||
PARAM_NO_CONVERT;
|
PARAM_NO_CONVERT;
|
||||||
c->prog_data.param[c->prog_data.nr_params++] = &vec_values[swiz];
|
this->param_index[c->prog_data.nr_params] = index;
|
||||||
|
this->param_offset[c->prog_data.nr_params] = swiz;
|
||||||
|
c->prog_data.nr_params++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1370,10 +1369,13 @@ fs_visitor::visit(ir_texture *ir)
|
|||||||
fs_reg scale_y = fs_reg(UNIFORM, c->prog_data.nr_params + 1);
|
fs_reg scale_y = fs_reg(UNIFORM, c->prog_data.nr_params + 1);
|
||||||
GLuint index = _mesa_add_state_reference(params,
|
GLuint index = _mesa_add_state_reference(params,
|
||||||
(gl_state_index *)tokens);
|
(gl_state_index *)tokens);
|
||||||
float *vec_values = this->fp->Base.Parameters->ParameterValues[index];
|
|
||||||
|
|
||||||
c->prog_data.param[c->prog_data.nr_params++] = &vec_values[0];
|
this->param_index[c->prog_data.nr_params] = index;
|
||||||
c->prog_data.param[c->prog_data.nr_params++] = &vec_values[1];
|
this->param_offset[c->prog_data.nr_params] = 0;
|
||||||
|
c->prog_data.nr_params++;
|
||||||
|
this->param_index[c->prog_data.nr_params] = index;
|
||||||
|
this->param_offset[c->prog_data.nr_params] = 1;
|
||||||
|
c->prog_data.nr_params++;
|
||||||
|
|
||||||
fs_reg dst = fs_reg(this, ir->coordinate->type);
|
fs_reg dst = fs_reg(this, ir->coordinate->type);
|
||||||
fs_reg src = coordinate;
|
fs_reg src = coordinate;
|
||||||
@@ -2500,6 +2502,22 @@ fs_visitor::generate_pull_constant_load(fs_inst *inst, struct brw_reg dst)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To be called after the last _mesa_add_state_reference() call, to
|
||||||
|
* set up prog_data.param[] for assign_curb_setup() and
|
||||||
|
* setup_pull_constants().
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
fs_visitor::setup_paramvalues_refs()
|
||||||
|
{
|
||||||
|
/* Set up the pointers to ParamValues now that that array is finalized. */
|
||||||
|
for (unsigned int i = 0; i < c->prog_data.nr_params; i++) {
|
||||||
|
c->prog_data.param[i] =
|
||||||
|
fp->Base.Parameters->ParameterValues[this->param_index[i]] +
|
||||||
|
this->param_offset[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
fs_visitor::assign_curb_setup()
|
fs_visitor::assign_curb_setup()
|
||||||
{
|
{
|
||||||
@@ -3662,8 +3680,9 @@ brw_wm_fs_emit(struct brw_context *brw, struct brw_wm_compile *c)
|
|||||||
v.emit_fb_writes();
|
v.emit_fb_writes();
|
||||||
|
|
||||||
v.split_virtual_grfs();
|
v.split_virtual_grfs();
|
||||||
v.setup_pull_constants();
|
|
||||||
|
|
||||||
|
v.setup_paramvalues_refs();
|
||||||
|
v.setup_pull_constants();
|
||||||
v.assign_curb_setup();
|
v.assign_curb_setup();
|
||||||
v.assign_urb_setup();
|
v.assign_urb_setup();
|
||||||
|
|
||||||
|
@@ -412,6 +412,7 @@ public:
|
|||||||
void visit(ir_function_signature *ir);
|
void visit(ir_function_signature *ir);
|
||||||
|
|
||||||
fs_inst *emit(fs_inst inst);
|
fs_inst *emit(fs_inst inst);
|
||||||
|
void setup_paramvalues_refs();
|
||||||
void assign_curb_setup();
|
void assign_curb_setup();
|
||||||
void calculate_urb_setup();
|
void calculate_urb_setup();
|
||||||
void assign_urb_setup();
|
void assign_urb_setup();
|
||||||
@@ -476,6 +477,12 @@ public:
|
|||||||
void *mem_ctx;
|
void *mem_ctx;
|
||||||
exec_list instructions;
|
exec_list instructions;
|
||||||
|
|
||||||
|
/* Delayed setup of c->prog_data.params[] due to realloc of
|
||||||
|
* ParamValues[] during compile.
|
||||||
|
*/
|
||||||
|
int param_index[MAX_UNIFORMS * 4];
|
||||||
|
int param_offset[MAX_UNIFORMS * 4];
|
||||||
|
|
||||||
int *virtual_grf_sizes;
|
int *virtual_grf_sizes;
|
||||||
int virtual_grf_next;
|
int virtual_grf_next;
|
||||||
int virtual_grf_array_size;
|
int virtual_grf_array_size;
|
||||||
|
Reference in New Issue
Block a user