radeonsi: Fix w component of TGSI_SEMANTIC_POSITION fragment shader inputs.
authorMichel Dänzer <michel.daenzer@amd.com>
Wed, 13 Feb 2013 14:57:23 +0000 (15:57 +0100)
committerMichel Dänzer <michel@daenzer.net>
Thu, 21 Feb 2013 09:06:52 +0000 (10:06 +0100)
It's the reciprocal of the register value.

Fixes piglit fragcoord_w and glsl-fs-fragcoord-zw-perspective.

NOTE: This is a candidate for the 9.1 branch.

src/gallium/drivers/radeonsi/radeonsi_shader.c

index 704f859efd7d8e79e0fe6f8eebbd2ea1649a52f2..7922928043f48339a178b3184b11e400195f874b 100644 (file)
@@ -263,6 +263,14 @@ static void declare_input_fs(
                                build_intrinsic(base->gallivm->builder,
                                        "llvm.SI.fs.read.pos", input_type,
                                        args, 1, LLVMReadNoneAttribute);
+
+                       if (chan == 3)
+                               /* RCP for fragcoord.w */
+                               si_shader_ctx->radeon_bld.inputs[soa_index] =
+                                       LLVMBuildFDiv(gallivm->builder,
+                                                     lp_build_const_float(gallivm, 1.0f),
+                                                     si_shader_ctx->radeon_bld.inputs[soa_index],
+                                                     "");
                }
                return;
        }