r600g: add evergreen stencil support.
authorDave Airlie <airlied@redhat.com>
Tue, 5 Oct 2010 23:21:16 +0000 (09:21 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 5 Oct 2010 23:21:16 +0000 (09:21 +1000)
this sets the stencil up for evergreen properly.

src/gallium/drivers/r600/eg_state_inlines.h
src/gallium/drivers/r600/evergreen_state.c

index 810949044856e6da22b3d44b691dd166520575ad..d7a880f5d3a6e4cdcc780ac8bf60eb0b5cff1877 100644 (file)
@@ -276,6 +276,14 @@ static inline uint32_t r600_translate_dbformat(enum pipe_format format)
        }
 }
 
+static inline uint32_t r600_translate_stencilformat(enum pipe_format format)
+{
+       if (format == PIPE_FORMAT_Z24_UNORM_S8_USCALED)
+               return 1;
+       else
+               return 0;
+}
+
 static inline uint32_t r600_translate_colorswap(enum pipe_format format)
 {
        switch (format) {
index 147d4f372e66b2271c5faa453fd9430d4b4d65b6..603a8a7b915766c5f5d5b4942f626b0bcbeeefc1 100644 (file)
@@ -795,7 +795,7 @@ static void evergreen_db(struct r600_pipe_context *rctx, struct r600_pipe_state
        struct r600_resource_texture *rtex;
        struct r600_resource *rbuffer;
        unsigned level;
-       unsigned pitch, slice, format;
+       unsigned pitch, slice, format, stencil_format;
 
        if (state->zsbuf == NULL)
                return;
@@ -811,13 +811,27 @@ static void evergreen_db(struct r600_pipe_context *rctx, struct r600_pipe_state
        pitch = (rtex->pitch[level] / rtex->bpt) / 8 - 1;
        slice = (rtex->pitch[level] / rtex->bpt) * state->zsbuf->height / 64 - 1;
        format = r600_translate_dbformat(state->zsbuf->texture->format);
+       stencil_format = r600_translate_stencilformat(state->zsbuf->texture->format);
 
        r600_pipe_state_add_reg(rstate, R_028048_DB_Z_READ_BASE,
                                (state->zsbuf->offset + r600_bo_offset(rbuffer->bo)) >> 8, 0xFFFFFFFF, rbuffer->bo);
        r600_pipe_state_add_reg(rstate, R_028050_DB_Z_WRITE_BASE,
                                (state->zsbuf->offset  + r600_bo_offset(rbuffer->bo)) >> 8, 0xFFFFFFFF, rbuffer->bo);
-//     r600_pipe_state_add_reg(rstate, R_028014_DB_HTILE_DATA_BASE, state->zsbuf->offset >> 8, 0xFFFFFFFF, rbuffer->bo);
+
+       if (stencil_format) {
+               uint32_t stencil_offset;
+
+               stencil_offset = ((state->zsbuf->height * rtex->pitch[level]) + 255) & ~255;
+               r600_pipe_state_add_reg(rstate, R_02804C_DB_STENCIL_READ_BASE,
+                                       (state->zsbuf->offset + stencil_offset + r600_bo_offset(rbuffer->bo)) >> 8, 0xFFFFFFFF, rbuffer->bo);
+               r600_pipe_state_add_reg(rstate, R_028054_DB_STENCIL_WRITE_BASE,
+                                       (state->zsbuf->offset + stencil_offset + r600_bo_offset(rbuffer->bo)) >> 8, 0xFFFFFFFF, rbuffer->bo);
+       }
+
        r600_pipe_state_add_reg(rstate, R_028008_DB_DEPTH_VIEW, 0x00000000, 0xFFFFFFFF, NULL);
+       r600_pipe_state_add_reg(rstate, R_028044_DB_STENCIL_INFO,
+                               S_028044_FORMAT(stencil_format), 0xFFFFFFFF, rbuffer->bo);
+
        r600_pipe_state_add_reg(rstate, R_028040_DB_Z_INFO,
                                S_028040_ARRAY_MODE(rtex->array_mode) | S_028040_FORMAT(format),
                                0xFFFFFFFF, rbuffer->bo);