diff options
author | Neil Roberts <[email protected]> | 2014-08-11 12:21:44 +0100 |
---|---|---|
committer | Neil Roberts <[email protected]> | 2014-08-14 11:54:48 +0100 |
commit | 2c50212b14da27de4e3da62488ae4e35c069d84e (patch) | |
tree | c0cadda73f6d4db2549277cd393d650894c7481d /src/mesa/drivers/dri/i965/brw_vec4.cpp | |
parent | 6fb42ee7a632e181160ac4be234b30e50a1b91d5 (diff) |
i965: Store uniform constant values in a gl_constant_value instead of float
The brw_stage_prog_data struct previously contained an array of float pointers
to the values of parameters. These were then copied into a batch buffer to
upload the values using a regular assignment. However the float values were
also being overloaded to store integer values for integer uniforms. This can
break if x87 floating-point registers are used to do the assignment because
the fst instruction tries to fix up invalid float values. If an integer
constant happened to look like an invalid float value then it would get
altered when it was copied into the batch buffer.
This patch changes the pointers to be gl_constant_value instead so that the
assignment should end up copying without any alteration. This also makes it
more obvious that the values being stored here are overloaded for multiple
types.
There are some static asserts where the values are uploaded to ensure that the
size of gl_constant_value is the same as a float.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=81150
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_vec4.cpp')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vec4.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp index b572b611fd6..5f8f39971b9 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp @@ -667,7 +667,7 @@ vec4_visitor::move_push_constants_to_pull_constants() pull_constant_loc[i / 4] = -1; if (i >= max_uniform_components) { - const float **values = &stage_prog_data->param[i]; + const gl_constant_value **values = &stage_prog_data->param[i]; /* Try to find an existing copy of this uniform in the pull * constants if it was part of an array access already. @@ -1490,10 +1490,10 @@ vec4_visitor::setup_uniforms(int reg) this->uniform_vector_size[this->uniforms] = 1; stage_prog_data->param = - reralloc(NULL, stage_prog_data->param, const float *, 4); + reralloc(NULL, stage_prog_data->param, const gl_constant_value *, 4); for (unsigned int i = 0; i < 4; i++) { unsigned int slot = this->uniforms * 4 + i; - static float zero = 0.0; + static gl_constant_value zero = { .f = 0.0 }; stage_prog_data->param[slot] = &zero; } |