radeonsi: interpolate varyings at sample when full sample shading is enabled
authorMarek Olšák <marek.olsak@amd.com>
Tue, 6 May 2014 17:10:52 +0000 (19:10 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 2 Jun 2014 10:58:22 +0000 (12:58 +0200)
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader.h
src/gallium/drivers/radeonsi/si_state.c

index 6818106ece7b6463f1fabe0ad543627c9d467a82..5f9abe3face946334ef11f1024f89a955c8578b2 100644 (file)
@@ -421,27 +421,27 @@ static void declare_input_fs(
                                           shader->input[input_index].param_offset);
 
        switch (decl->Interp.Interpolate) {
-       case TGSI_INTERPOLATE_COLOR:
-               if (si_shader_ctx->shader->key.ps.flatshade) {
-                       interp_param = 0;
-               } else {
-                       if (decl->Interp.Centroid)
-                               interp_param = LLVMGetParam(main_fn, SI_PARAM_PERSP_CENTROID);
-                       else
-                               interp_param = LLVMGetParam(main_fn, SI_PARAM_PERSP_CENTER);
-               }
-               break;
        case TGSI_INTERPOLATE_CONSTANT:
                interp_param = 0;
                break;
        case TGSI_INTERPOLATE_LINEAR:
-               if (decl->Interp.Centroid)
+               if (si_shader_ctx->shader->key.ps.interp_at_sample)
+                       interp_param = LLVMGetParam(main_fn, SI_PARAM_LINEAR_SAMPLE);
+               else if (decl->Interp.Centroid)
                        interp_param = LLVMGetParam(main_fn, SI_PARAM_LINEAR_CENTROID);
                else
                        interp_param = LLVMGetParam(main_fn, SI_PARAM_LINEAR_CENTER);
                break;
+       case TGSI_INTERPOLATE_COLOR:
+               if (si_shader_ctx->shader->key.ps.flatshade) {
+                       interp_param = 0;
+                       break;
+               }
+               /* fall through to perspective */
        case TGSI_INTERPOLATE_PERSPECTIVE:
-               if (decl->Interp.Centroid)
+               if (si_shader_ctx->shader->key.ps.interp_at_sample)
+                       interp_param = LLVMGetParam(main_fn, SI_PARAM_PERSP_SAMPLE);
+               else if (decl->Interp.Centroid)
                        interp_param = LLVMGetParam(main_fn, SI_PARAM_PERSP_CENTROID);
                else
                        interp_param = LLVMGetParam(main_fn, SI_PARAM_PERSP_CENTER);
index 5e0db92a98d6ef9fde20219260949193408dc48f..660978882375ceb11df289046b56c4dd09e7dd1d 100644 (file)
@@ -158,6 +158,7 @@ union si_shader_key {
                unsigned        color_two_side:1;
                unsigned        alpha_func:3;
                unsigned        flatshade:1;
+               unsigned        interp_at_sample:1;
                unsigned        alpha_to_one:1;
        } ps;
        struct {
index b85a4594156992d552eeb18fa063f396415198ba..19d2b553a22f437d1694c828ecda585f2a2a16e2 100644 (file)
@@ -2115,6 +2115,8 @@ static INLINE void si_shader_selector_key(struct pipe_context *ctx,
                if (sctx->queued.named.rasterizer) {
                        key->ps.color_two_side = sctx->queued.named.rasterizer->two_side;
                        key->ps.flatshade = sctx->queued.named.rasterizer->flatshade;
+                       key->ps.interp_at_sample = sctx->framebuffer.nr_samples > 1 &&
+                                                  sctx->ps_iter_samples == sctx->framebuffer.nr_samples;
 
                        if (sctx->queued.named.blend) {
                                key->ps.alpha_to_one = sctx->queued.named.blend->alpha_to_one &&