radeonsi: Flesh out shader interpolation related code.
authorMichel Dänzer <michel.daenzer@amd.com>
Mon, 14 May 2012 14:26:19 +0000 (16:26 +0200)
committerMichel Dänzer <michel@daenzer.net>
Mon, 14 May 2012 15:56:03 +0000 (17:56 +0200)
Handle perspective interpolation and ceontroid vs. center.

src/gallium/drivers/radeon/SIInstructions.td
src/gallium/drivers/radeon/SIIntrinsics.td
src/gallium/drivers/radeonsi/radeonsi_shader.c

index 57bbc7a5d5aa3d3e1fd7ab3b27a6a4d1e830d267..313728f044fefb67c00830c78466c1fb60511d88 100644 (file)
@@ -934,6 +934,24 @@ def : Pat <
              imm:$attr, SReg_32:$params)
 >;
 
+def : Pat <
+  (int_SI_fs_interp_linear_centroid imm:$attr_chan, imm:$attr, SReg_32:$params),
+  (SI_INTERP (f32 LINEAR_CENTROID_I), (f32 LINEAR_CENTROID_J), imm:$attr_chan,
+             imm:$attr, SReg_32:$params)
+>;
+
+def : Pat <
+  (int_SI_fs_interp_persp_center imm:$attr_chan, imm:$attr, SReg_32:$params),
+  (SI_INTERP (f32 PERSP_CENTER_I), (f32 PERSP_CENTER_J), imm:$attr_chan,
+             imm:$attr, SReg_32:$params)
+>;
+
+def : Pat <
+  (int_SI_fs_interp_persp_centroid imm:$attr_chan, imm:$attr, SReg_32:$params),
+  (SI_INTERP (f32 PERSP_CENTROID_I), (f32 PERSP_CENTROID_J), imm:$attr_chan,
+             imm:$attr, SReg_32:$params)
+>;
+
 /********** ================== **********/
 /********** Intrinsic Patterns **********/
 /********** ================== **********/
index 4d23072d4f1e2e70b46a2863ce64fcc9c0cd659c..4e718355428a4a4b777f70f4e1636af47d700018 100644 (file)
@@ -30,5 +30,8 @@ let TargetPrefix = "SI", isTarget = 1 in {
   class Interp : Intrinsic <[llvm_float_ty], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty], []>;
 
   def int_SI_fs_interp_linear_center : Interp;
+  def int_SI_fs_interp_linear_centroid : Interp;
+  def int_SI_fs_interp_persp_center : Interp;
+  def int_SI_fs_interp_persp_centroid : Interp;
   def int_SI_fs_interp_constant : Interp;
 }
index 0e1a97bba3e88beab3659bd7cefee7428a465185..396b94ad357b1f546b29afac26657ddbaa1f3b99 100644 (file)
@@ -201,16 +201,29 @@ static void declare_input_fs(
        /* XXX: Handle all possible interpolation modes */
        switch (decl->Interp.Interpolate) {
        case TGSI_INTERPOLATE_COLOR:
-               if (si_shader_ctx->rctx->rasterizer->flatshade)
+               if (si_shader_ctx->rctx->rasterizer->flatshade) {
                        intr_name = "llvm.SI.fs.interp.constant";
-               else
-                       intr_name = "llvm.SI.fs.interp.linear.center";
+               } else {
+                       if (decl->Interp.Centroid)
+                               intr_name = "llvm.SI.fs.interp.persp.centroid";
+                       else
+                               intr_name = "llvm.SI.fs.interp.persp.center";
+               }
                break;
        case TGSI_INTERPOLATE_CONSTANT:
                intr_name = "llvm.SI.fs.interp.constant";
                break;
        case TGSI_INTERPOLATE_LINEAR:
-               intr_name = "llvm.SI.fs.interp.linear.center";
+               if (decl->Interp.Centroid)
+                       intr_name = "llvm.SI.fs.interp.linear.centroid";
+               else
+                       intr_name = "llvm.SI.fs.interp.linear.center";
+               break;
+       case TGSI_INTERPOLATE_PERSPECTIVE:
+               if (decl->Interp.Centroid)
+                       intr_name = "llvm.SI.fs.interp.persp.centroid";
+               else
+                       intr_name = "llvm.SI.fs.interp.persp.center";
                break;
        default:
                fprintf(stderr, "Warning: Unhandled interpolation mode.\n");