summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/i965/brw_curbe.c
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2014-08-11 12:21:44 +0100
committerNeil Roberts <neil@linux.intel.com>2014-08-14 11:54:48 +0100
commit2c50212b14da27de4e3da62488ae4e35c069d84e (patch)
treec0cadda73f6d4db2549277cd393d650894c7481d /src/mesa/drivers/dri/i965/brw_curbe.c
parent6fb42ee7a632e181160ac4be234b30e50a1b91d5 (diff)
downloadexternal_mesa3d-2c50212b14da27de4e3da62488ae4e35c069d84e.zip
external_mesa3d-2c50212b14da27de4e3da62488ae4e35c069d84e.tar.gz
external_mesa3d-2c50212b14da27de4e3da62488ae4e35c069d84e.tar.bz2
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 <kenneth@whitecape.org>
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_curbe.c')
-rw-r--r--src/mesa/drivers/dri/i965/brw_curbe.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_curbe.c b/src/mesa/drivers/dri/i965/brw_curbe.c
index 02eda5f..1a828ed 100644
--- a/src/mesa/drivers/dri/i965/brw_curbe.c
+++ b/src/mesa/drivers/dri/i965/brw_curbe.c
@@ -196,7 +196,7 @@ brw_upload_constant_buffer(struct brw_context *brw)
/* BRW_NEW_CURBE_OFFSETS */
const GLuint sz = brw->curbe.total_size;
const GLuint bufsz = sz * 16 * sizeof(GLfloat);
- GLfloat *buf;
+ gl_constant_value *buf;
GLuint i;
gl_clip_plane *clip_planes;
@@ -207,6 +207,8 @@ brw_upload_constant_buffer(struct brw_context *brw)
buf = intel_upload_space(brw, bufsz, 64,
&brw->curbe.curbe_bo, &brw->curbe.curbe_offset);
+ STATIC_ASSERT(sizeof(gl_constant_value) == sizeof(float));
+
/* fragment shader constants */
if (brw->curbe.wm_size) {
/* BRW_NEW_CURBE_OFFSETS */
@@ -226,10 +228,10 @@ brw_upload_constant_buffer(struct brw_context *brw)
/* If any planes are going this way, send them all this way:
*/
for (i = 0; i < 6; i++) {
- buf[offset + i * 4 + 0] = fixed_plane[i][0];
- buf[offset + i * 4 + 1] = fixed_plane[i][1];
- buf[offset + i * 4 + 2] = fixed_plane[i][2];
- buf[offset + i * 4 + 3] = fixed_plane[i][3];
+ buf[offset + i * 4 + 0].f = fixed_plane[i][0];
+ buf[offset + i * 4 + 1].f = fixed_plane[i][1];
+ buf[offset + i * 4 + 2].f = fixed_plane[i][2];
+ buf[offset + i * 4 + 3].f = fixed_plane[i][3];
}
/* Clip planes: _NEW_TRANSFORM plus _NEW_PROJECTION to get to
@@ -238,10 +240,10 @@ brw_upload_constant_buffer(struct brw_context *brw)
clip_planes = brw_select_clip_planes(ctx);
for (j = 0; j < MAX_CLIP_PLANES; j++) {
if (ctx->Transform.ClipPlanesEnabled & (1<<j)) {
- buf[offset + i * 4 + 0] = clip_planes[j][0];
- buf[offset + i * 4 + 1] = clip_planes[j][1];
- buf[offset + i * 4 + 2] = clip_planes[j][2];
- buf[offset + i * 4 + 3] = clip_planes[j][3];
+ buf[offset + i * 4 + 0].f = clip_planes[j][0];
+ buf[offset + i * 4 + 1].f = clip_planes[j][1];
+ buf[offset + i * 4 + 2].f = clip_planes[j][2];
+ buf[offset + i * 4 + 3].f = clip_planes[j][3];
i++;
}
}
@@ -260,7 +262,7 @@ brw_upload_constant_buffer(struct brw_context *brw)
if (0) {
for (i = 0; i < sz*16; i+=4)
fprintf(stderr, "curbe %d.%d: %f %f %f %f\n", i/8, i&4,
- buf[i+0], buf[i+1], buf[i+2], buf[i+3]);
+ buf[i+0].f, buf[i+1].f, buf[i+2].f, buf[i+3].f);
}
/* Because this provokes an action (ie copy the constants into the