anv: Don't allow D16_UNORM to be combined with stencil
authorJason Ekstrand <jason.ekstrand@intel.com>
Sat, 5 Mar 2016 17:13:44 +0000 (09:13 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Sat, 5 Mar 2016 17:59:28 +0000 (09:59 -0800)
Among other things, this can cause the depth or stencil test to spurriously
fail when the fragment shader uses discard.

src/intel/vulkan/anv_formats.c
src/intel/vulkan/genX_cmd_buffer.c

index b4b52aa60534b5f81835f278e5d83888678aef50..4d279a8fb72f885b07a6a46bc0582e1c61661e31 100644 (file)
@@ -161,7 +161,7 @@ static const struct anv_format anv_formats[] = {
    fmt(VK_FORMAT_X8_D24_UNORM_PACK32,     ISL_FORMAT_R24_UNORM_X8_TYPELESS,   .has_depth = true),
    fmt(VK_FORMAT_D32_SFLOAT,              ISL_FORMAT_R32_FLOAT,               .has_depth = true),
    fmt(VK_FORMAT_S8_UINT,                 ISL_FORMAT_R8_UINT,                                      .has_stencil = true),
-   fmt(VK_FORMAT_D16_UNORM_S8_UINT,       ISL_FORMAT_R16_UNORM,               .has_depth = true,   .has_stencil = true),
+   fmt(VK_FORMAT_D16_UNORM_S8_UINT,       ISL_FORMAT_UNSUPPORTED),
    fmt(VK_FORMAT_D24_UNORM_S8_UINT,       ISL_FORMAT_R24_UNORM_X8_TYPELESS,   .has_depth = true,   .has_stencil = true),
    fmt(VK_FORMAT_D32_SFLOAT_S8_UINT,      ISL_FORMAT_R32_FLOAT,               .has_depth = true,   .has_stencil = true),
 
index 82959f3abf6850c98766f36577f24313217f60eb..88cc13b580a9afdbd285e821ae62c7649af99793 100644 (file)
@@ -646,11 +646,12 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
        *
        * The PRM is wrong, though. The width and height must be programmed to
        * actual framebuffer's width and height, even when neither depth buffer
-       * nor stencil buffer is present.
+       * nor stencil buffer is present.  Also, D16_UNORM is not allowed to
+       * be combined with a stencil buffer so we use D32_FLOAT instead.
        */
       anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_DEPTH_BUFFER),
          .SurfaceType = SURFTYPE_2D,
-         .SurfaceFormat = D16_UNORM,
+         .SurfaceFormat = D32_FLOAT,
          .Width = fb->width - 1,
          .Height = fb->height - 1,
          .StencilWriteEnable = has_stencil);