r600g: add shader stencil export support.
authorDave Airlie <airlied@redhat.com>
Wed, 6 Oct 2010 00:14:33 +0000 (10:14 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 12 Oct 2010 23:30:05 +0000 (09:30 +1000)
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/r600/r600_shader.c
src/gallium/drivers/r600/r600d.h

index 832a2b2b606b9879c85c66e6f5c371391ae058a6..52fe3c777b3276f6ef776f032f7c0e04c20e10db 100644 (file)
@@ -242,6 +242,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_INDEP_BLEND_ENABLE:
        case PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE:
        case PIPE_CAP_DEPTH_CLAMP:
+       case PIPE_CAP_SHADER_STENCIL_EXPORT:
                return 1;
 
        /* Unsupported features (boolean caps). */
index 341800306d6f7dae3433be2c26b9683e1b46e7e4..8930d4e1831812509aef65fc23991cbd238d9b67 100644 (file)
@@ -137,12 +137,17 @@ static void r600_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shade
                                                R_02880C_DB_SHADER_CONTROL,
                                                S_02880C_Z_EXPORT_ENABLE(1),
                                                S_02880C_Z_EXPORT_ENABLE(1), NULL);
+               if (rshader->output[i].name == TGSI_SEMANTIC_STENCIL)
+                       r600_pipe_state_add_reg(rstate,
+                                               R_02880C_DB_SHADER_CONTROL,
+                                               S_02880C_STENCIL_REF_EXPORT_ENABLE(1),
+                                               S_02880C_STENCIL_REF_EXPORT_ENABLE(1), NULL);
        }
 
        exports_ps = 0;
        num_cout = 0;
        for (i = 0; i < rshader->noutput; i++) {
-               if (rshader->output[i].name == TGSI_SEMANTIC_POSITION)
+               if (rshader->output[i].name == TGSI_SEMANTIC_POSITION || rshader->output[i].name == TGSI_SEMANTIC_STENCIL)
                        exports_ps |= 1;
                else if (rshader->output[i].name == TGSI_SEMANTIC_COLOR) {
                        num_cout++;
@@ -628,7 +633,14 @@ int r600_shader_from_tgsi(const struct tgsi_token *tokens, struct r600_shader *s
                        } else if (shader->output[i].name == TGSI_SEMANTIC_POSITION) {
                                output[i].array_base = 61;
                                output[i].swizzle_x = 2;
-                               output[i].swizzle_y = output[i].swizzle_z = output[i].swizzle_w = 7;
+                               output[i].swizzle_y = 7;
+                               output[i].swizzle_z = output[i].swizzle_w = 7;
+                               output[i].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL;
+                       } else if (shader->output[i].name == TGSI_SEMANTIC_STENCIL) {
+                               output[i].array_base = 61;
+                               output[i].swizzle_x = 7;
+                               output[i].swizzle_y = 1;
+                               output[i].swizzle_z = output[i].swizzle_w = 7;
                                output[i].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL;
                        } else {
                                R600_ERR("unsupported fragment output name %d\n", shader->output[i].name);
index a96d2ce26c1b1dd8b0de3b5f56798edb81939dd3..f32f5286c9564e1fd45d52ce238c14d296760a95 100644 (file)
 #define   S_02880C_Z_EXPORT_ENABLE(x)                  (((x) & 0x1) << 0)
 #define   G_02880C_Z_EXPORT_ENABLE(x)                  (((x) >> 0) & 0x1)
 #define   C_02880C_Z_EXPORT_ENABLE                     0xFFFFFFFE
+#define   S_02880C_STENCIL_REF_EXPORT_ENABLE(x)        (((x) & 0x1) << 1)
+#define   G_02880C_STENCIL_REF_EXPORT_ENABLE(x)        (((x) >> 1) & 0x1)
+#define   C_02880C_STENCIL_REF_EXPORT_ENABLE           0xFFFFFFFD
 #define   S_02880C_Z_ORDER(x)                          (((x) & 0x3) << 4)
 #define   G_02880C_Z_ORDER(x)                          (((x) >> 4) & 0x3)
 #define   C_02880C_Z_ORDER                             0xFFFFFCFF