summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/i965/gen6_vs_state.c
diff options
context:
space:
mode:
authorPaul Berry <stereotype441@gmail.com>2011-10-07 17:37:32 -0700
committerPaul Berry <stereotype441@gmail.com>2011-10-31 11:24:03 -0700
commitf40c6b2a992f3ca796826a47743c0c80232d7ab2 (patch)
tree3d5628654aa3e69154d0fe236ffb8756a388f881 /src/mesa/drivers/dri/i965/gen6_vs_state.c
parentede60bc4670a8d9c14921c77abee1ac57fc0e6bf (diff)
downloadexternal_mesa3d-f40c6b2a992f3ca796826a47743c0c80232d7ab2.zip
external_mesa3d-f40c6b2a992f3ca796826a47743c0c80232d7ab2.tar.gz
external_mesa3d-f40c6b2a992f3ca796826a47743c0c80232d7ab2.tar.bz2
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/gen6_vs_state.c')
-rw-r--r--src/mesa/drivers/dri/i965/gen6_vs_state.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/mesa/drivers/dri/i965/gen6_vs_state.c b/src/mesa/drivers/dri/i965/gen6_vs_state.c
index e06c7b4..e22fd39 100644
--- a/src/mesa/drivers/dri/i965/gen6_vs_state.c
+++ b/src/mesa/drivers/dri/i965/gen6_vs_state.c
@@ -131,6 +131,7 @@ static void
upload_vs_state(struct brw_context *brw)
{
struct intel_context *intel = &brw->intel;
+ uint32_t floating_point_mode = 0;
if (brw->vs.push_const_size == 0) {
/* Disable the push constant buffers. */
@@ -157,11 +158,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) {