radeonsi: pass ARB_conservative_depth parameters to the hardware
authorMarek Olšák <marek.olsak@amd.com>
Sat, 14 Jun 2014 15:58:30 +0000 (17:58 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 18 Jun 2014 22:17:36 +0000 (00:17 +0200)
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader.h
src/gallium/drivers/radeonsi/si_state_draw.c
src/gallium/drivers/radeonsi/sid.h

index 4ed5906d178abca50e9148aceea6fba2e15faa85..4c23090e2a0cbb57a52a7f6d482fd2c6d7d1eba0 100644 (file)
@@ -2745,10 +2745,29 @@ int si_pipe_shader_create(
                }
                break;
        }
-       case TGSI_PROCESSOR_FRAGMENT:
+       case TGSI_PROCESSOR_FRAGMENT: {
+               int i;
+
                si_shader_ctx.radeon_bld.load_input = declare_input_fs;
                bld_base->emit_epilogue = si_llvm_emit_fs_epilogue;
+               shader->shader.ps_conservative_z = V_02880C_EXPORT_ANY_Z;
+
+               for (i = 0; i < shader_info.num_properties; i++) {
+                       switch (shader_info.properties[i].name) {
+                       case TGSI_PROPERTY_FS_DEPTH_LAYOUT:
+                               switch (shader_info.properties[i].data[0]) {
+                               case TGSI_FS_DEPTH_LAYOUT_GREATER:
+                                       shader->shader.ps_conservative_z = V_02880C_EXPORT_GREATER_THAN_Z;
+                                       break;
+                               case TGSI_FS_DEPTH_LAYOUT_LESS:
+                                       shader->shader.ps_conservative_z = V_02880C_EXPORT_LESS_THAN_Z;
+                                       break;
+                               }
+                               break;
+                       }
+               }
                break;
+       }
        default:
                assert(!"Unsupported shader type");
                return -1;
index 660978882375ceb11df289046b56c4dd09e7dd1d..81997c0b5867b0ff8981e4858ab6e88633dd3861 100644 (file)
@@ -138,6 +138,7 @@ struct si_shader {
        unsigned                gs_input_prim;
        unsigned                gs_output_prim;
        unsigned                gs_max_out_vertices;
+       unsigned                ps_conservative_z;
 
        unsigned                nparam;
        bool                    uses_kill;
index 52ecf264ecb55317367daf9dbd836af9a249fdd7..01564eba84302542ead504f6e4f11280845b1009 100644 (file)
@@ -269,6 +269,10 @@ static void si_pipe_shader_ps(struct pipe_context *ctx, struct si_pipe_shader *s
        if (shader->shader.uses_kill || shader->key.ps.alpha_func != PIPE_FUNC_ALWAYS)
                db_shader_control |= S_02880C_KILL_ENABLE(1);
 
+       if (sctx->b.chip_class >= CIK)
+               db_shader_control |=
+                       S_02880C_CONSERVATIVE_Z_EXPORT(shader->shader.ps_conservative_z);
+
        spi_ps_in_control = S_0286D8_NUM_INTERP(shader->shader.nparam) |
                S_0286D8_BC_OPTIMIZE_DISABLE(1);
 
index 558da1048dc2a7e306314255a52db4fd9f39d954..e3f788ef6a7085928198e94ecd230419e5e176ea 100644 (file)
 #define   S_02880C_CONSERVATIVE_Z_EXPORT(x)                           (((x) & 0x03) << 13)
 #define   G_02880C_CONSERVATIVE_Z_EXPORT(x)                           (((x) >> 13) & 0x03)
 #define   C_02880C_CONSERVATIVE_Z_EXPORT                              0xFFFF9FFF
+#define     V_02880C_EXPORT_ANY_Z                                   0
+#define     V_02880C_EXPORT_LESS_THAN_Z                             1
+#define     V_02880C_EXPORT_GREATER_THAN_Z                          2
+#define     V_02880C_EXPORT_RESERVED                                3
 /*     */
 #define R_028810_PA_CL_CLIP_CNTL                                        0x028810
 #define   S_028810_UCP_ENA_0(x)                                       (((x) & 0x1) << 0)