r600g: fixup z format translations.
authorDave Airlie <airlied@redhat.com>
Fri, 6 Aug 2010 05:06:25 +0000 (15:06 +1000)
committerDave Airlie <airlied@redhat.com>
Fri, 6 Aug 2010 05:06:25 +0000 (15:06 +1000)
this enables GL_EXT_packed_depth_stencil. fbo-d24s8 passes

src/gallium/drivers/r600/r600_state.c
src/gallium/drivers/r600/r600_state_inlines.h

index e43e4afe55e842fe37f2f4f6701bb4779b2d278c..82145617ca1fb1aa63ef798224c7cd7cd82c4836 100644 (file)
@@ -706,22 +706,6 @@ static int r600_cb0(struct r600_context *rctx, struct radeon_state *rstate)
        return radeon_state_pm4(rstate);
 }
 
-static int r600_db_format(unsigned pformat, unsigned *format)
-{
-       switch (pformat) {
-       case PIPE_FORMAT_Z24X8_UNORM:
-               *format = V_028010_DEPTH_X8_24;
-               return 0;
-       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
-               *format = V_028010_DEPTH_8_24;
-               return 0;
-       default:
-               *format = V_028010_DEPTH_INVALID;
-               R600_ERR("unsupported %d\n", pformat);
-               return -EINVAL;
-       }
-}
-
 static int r600_db(struct r600_context *rctx, struct radeon_state *rstate)
 {
        struct r600_screen *rscreen = rctx->screen;
@@ -746,9 +730,7 @@ static int r600_db(struct r600_context *rctx, struct radeon_state *rstate)
        level = state->zsbuf->level;
        pitch = (rtex->pitch[level] / rtex->bpt) / 8 - 1;
        slice = (rtex->pitch[level] / rtex->bpt) * state->zsbuf->height / 64 - 1;
-       if (r600_db_format(state->zsbuf->texture->format, &format)) {
-               return -EINVAL;
-       }
+       format = r600_translate_dbformat(state->zsbuf->texture->format);
        rstate->states[R600_DB__DB_DEPTH_BASE] = 0x00000000;
        rstate->states[R600_DB__DB_DEPTH_INFO] = 0x00010000 |
                                        S_028010_FORMAT(format);
index b45089dcc18e4232f02d783bb8859f56b2f06aaf..4a955da1c02d7c9ca3d813f4d415067d96cb2763 100644 (file)
@@ -129,6 +129,20 @@ static INLINE uint32_t r600_translate_ds_func(int func)
        return func;
 }
 
+static uint32_t r600_translate_dbformat(enum pipe_format format)
+{
+       switch (format) {
+       case PIPE_FORMAT_Z16_UNORM:
+               return V_028010_DEPTH_16;
+       case PIPE_FORMAT_Z24X8_UNORM:
+               return V_028010_DEPTH_X8_24;
+       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
+               return V_028010_DEPTH_8_24;
+       default:
+               return ~0;
+       }
+}
+
 static uint32_t r600_translate_colorswap(enum pipe_format format)
 {
        switch (format) {
@@ -168,6 +182,10 @@ static uint32_t r600_translate_colorswap(enum pipe_format format)
 //        case PIPE_FORMAT_R8SG8SB8UX8U_NORM:
                return SWAP_STD_REV;
 
+       case PIPE_FORMAT_Z24X8_UNORM:
+       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
+               return SWAP_STD;
+
         case PIPE_FORMAT_R10G10B10A2_UNORM:
         case PIPE_FORMAT_R10G10B10X2_SNORM:
         case PIPE_FORMAT_B10G10R10A2_UNORM:
@@ -234,6 +252,10 @@ static INLINE uint32_t r600_translate_colorformat(enum pipe_format format)
         case PIPE_FORMAT_R10SG10SB10SA2U_NORM:
                return V_0280A0_COLOR_10_10_10_2;
 
+       case PIPE_FORMAT_Z24X8_UNORM:
+       case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
+               return V_0280A0_COLOR_24_8;
+
                /* 64-bit buffers. */
         case PIPE_FORMAT_R16G16B16A16_UNORM:
         case PIPE_FORMAT_R16G16B16A16_SNORM:
@@ -271,7 +293,7 @@ static INLINE boolean r600_is_colorbuffer_format_supported(enum pipe_format form
 
 static INLINE boolean r600_is_zs_format_supported(enum pipe_format format)
 {
-       return TRUE;
+       return r600_translate_dbformat(format) != ~0;
 }
 
 static INLINE boolean r600_is_vertex_format_supported(enum pipe_format format)