diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2016-05-26 19:56:48 -0700 |
---|---|---|
committer | Kenneth Graunke <kenneth@whitecape.org> | 2016-06-14 16:09:57 -0700 |
commit | 8b408972ff5476f1e23ad24a329f89442e6df054 (patch) | |
tree | 914bbbca2bce730ad9f9afc7ee5fc841eb02eb35 | |
parent | 6ef50efc1079e544d7fe912aba219e8907cb0cbd (diff) |
mesa: Pass gl_constant_value union into _mesa_fetch_state().
We've had some trouble in the past with copying integers around via
float pointers, as the C compiler sometimes uses x87 floating point
registers to load values on 32-bit systems. Passing the
gl_constant_value union should be safer.
To avoid churn, this patch creates a "GLfloat *value" variable so
existing uses can stay the same.
Not observed to fix anything, but I was in the area adding more integer
state vars, and thought it'd be wise.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Cc: mesa-stable@lists.freedesktop.org
-rw-r--r-- | src/mesa/program/prog_statevars.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c index 03ece6711c..27ff3339ea 100644 --- a/src/mesa/program/prog_statevars.c +++ b/src/mesa/program/prog_statevars.c @@ -55,8 +55,10 @@ */ static void _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], - GLfloat *value) + gl_constant_value *val) { + GLfloat *value = &val->f; + switch (state[0]) { case STATE_MATERIAL: { @@ -353,7 +355,7 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], } return; case STATE_NUM_SAMPLES: - ((int *)value)[0] = MAX2(1, _mesa_geometric_samples(ctx->DrawBuffer)); + val[0].i = MAX2(1, _mesa_geometric_samples(ctx->DrawBuffer)); return; case STATE_DEPTH_RANGE: value[0] = ctx->ViewportArray[0].Near; /* near */ @@ -1071,7 +1073,7 @@ _mesa_load_state_parameters(struct gl_context *ctx, if (paramList->Parameters[i].Type == PROGRAM_STATE_VAR) { _mesa_fetch_state(ctx, paramList->Parameters[i].StateIndexes, - ¶mList->ParameterValues[i][0].f); + ¶mList->ParameterValues[i][0]); } } } |