diff options
author | Paul Berry <[email protected]> | 2011-10-07 17:37:32 -0700 |
---|---|---|
committer | Paul Berry <[email protected]> | 2011-10-31 11:24:03 -0700 |
commit | f40c6b2a992f3ca796826a47743c0c80232d7ab2 (patch) | |
tree | 3d5628654aa3e69154d0fe236ffb8756a388f881 /src/mesa/drivers/dri/i965/gen7_vs_state.c | |
parent | ede60bc4670a8d9c14921c77abee1ac57fc0e6bf (diff) |
i965/gen6+: Switch GLSL from ALT to IEEE floating point mode
i965 graphics hardware has two floating point modes: ALT and IEEE. In
ALT mode, floating-point operations never generate infinities or NaNs,
and MOV instructions translate infinities and NaNs to finite values.
In IEEE mode, infinities and NaNs behave as specified in the IEEE 754
spec.
Previously, we used ALT mode for all vertex and fragment programs,
whether they were GLSL programs or ARB programs. The GLSL spec is
sufficiently vague about how infs and nans are to be handled that it
was unclear whether this mode was compliant with the GLSL 1.30 spec or
not, and it made it very difficult to test the isinf() and isnan()
functions.
This patch changes i965 GLSL programs to use IEEE floating-point mode,
which is clearly compliant with GLSL 1.30's inf/nan requirements. In
addition to making the Piglit isinf and isnan tests pass, this paves
the way for future support of the ARB_shader_precision extension.
Unfortunately we still have to use ALT floating-point mode when
executing ARB programs, because those programs require 0^0 == 1, and
i965 hardware generates 0^0 == NaN in IEEE mode.
Fixes piglit tests "isinf-and-isnan fs_fbo", "isinf-and-isnan vs_fbo",
and {fs,vs}-{isinf,isnan}-{vec2,vec3,vec4}.
Diffstat (limited to 'src/mesa/drivers/dri/i965/gen7_vs_state.c')
-rw-r--r-- | src/mesa/drivers/dri/i965/gen7_vs_state.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/mesa/drivers/dri/i965/gen7_vs_state.c b/src/mesa/drivers/dri/i965/gen7_vs_state.c index 4ef9c688315..dbf93465e49 100644 --- a/src/mesa/drivers/dri/i965/gen7_vs_state.c +++ b/src/mesa/drivers/dri/i965/gen7_vs_state.c @@ -33,6 +33,7 @@ static void upload_vs_state(struct brw_context *brw) { struct intel_context *intel = &brw->intel; + uint32_t floating_point_mode = 0; BEGIN_BATCH(2); OUT_BATCH(_3DSTATE_BINDING_TABLE_POINTERS_VS << 16 | (2 - 2)); @@ -65,11 +66,17 @@ upload_vs_state(struct brw_context *brw) ADVANCE_BATCH(); } + /* Use ALT floating point mode for ARB vertex programs, because they + * require 0^0 == 1. + */ + if (intel->ctx.Shader.CurrentVertexProgram == NULL) + floating_point_mode = GEN6_VS_FLOATING_POINT_MODE_ALT; + BEGIN_BATCH(6); OUT_BATCH(_3DSTATE_VS << 16 | (6 - 2)); OUT_BATCH(brw->vs.prog_offset); OUT_BATCH((0 << GEN6_VS_SAMPLER_COUNT_SHIFT) | - GEN6_VS_FLOATING_POINT_MODE_ALT | + floating_point_mode | (brw->vs.nr_surfaces << GEN6_VS_BINDING_TABLE_ENTRY_COUNT_SHIFT)); if (brw->vs.prog_data->total_scratch) { |