anv: Replace anv_format::depth_format with ::has_depth
authorChad Versace <chad.versace@intel.com>
Tue, 9 Feb 2016 03:07:10 +0000 (19:07 -0800)
committerChad Versace <chad.versace@intel.com>
Tue, 9 Feb 2016 18:02:50 +0000 (10:02 -0800)
isl now understands depth formats. We no longer need depth formats in
the anv_format table.

src/vulkan/anv_cmd_buffer.c
src/vulkan/anv_formats.c
src/vulkan/anv_image.c
src/vulkan/anv_private.h
src/vulkan/gen7_cmd_buffer.c
src/vulkan/gen8_cmd_buffer.c

index 6b1c31f0e2ef988f3fcff4b2a28c637bfff4150d..bc6b3925cd2ac360b38da50f1fec0880cf774ac5 100644 (file)
@@ -177,7 +177,7 @@ anv_cmd_state_setup_attachments(struct anv_cmd_buffer *cmd_buffer,
          }
       } else {
          /* depthstencil attachment */
-         if (att->format->depth_format &&
+         if (att->format->has_depth &&
              att->load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) {
             clear_aspects |= VK_IMAGE_ASPECT_DEPTH_BIT;
          }
index d96d730d3780e94e4109fdadd99fdd90c11904dc..09cd8b9ddf9fe35e38cd2175403efff2df2cb360 100644 (file)
@@ -159,13 +159,13 @@ static const struct anv_format anv_formats[] = {
    fmt(VK_FORMAT_B10G11R11_UFLOAT_PACK32, ISL_FORMAT_R11G11B10_FLOAT),
    fmt(VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,  ISL_FORMAT_R9G9B9E5_SHAREDEXP),
 
-   fmt(VK_FORMAT_D16_UNORM,               ISL_FORMAT_R16_UNORM,               .depth_format = D16_UNORM),
-   fmt(VK_FORMAT_X8_D24_UNORM_PACK32,     ISL_FORMAT_R24_UNORM_X8_TYPELESS,   .depth_format = D24_UNORM_X8_UINT),
-   fmt(VK_FORMAT_D32_SFLOAT,              ISL_FORMAT_R32_FLOAT,               .depth_format = D32_FLOAT),
-   fmt(VK_FORMAT_S8_UINT,                 ISL_FORMAT_R8_UINT,                                                       .has_stencil = true),
-   fmt(VK_FORMAT_D16_UNORM_S8_UINT,       ISL_FORMAT_R16_UNORM,               .depth_format = D16_UNORM,            .has_stencil = true),
-   fmt(VK_FORMAT_D24_UNORM_S8_UINT,       ISL_FORMAT_R24_UNORM_X8_TYPELESS,   .depth_format = D24_UNORM_X8_UINT,    .has_stencil = true),
-   fmt(VK_FORMAT_D32_SFLOAT_S8_UINT,      ISL_FORMAT_R32_FLOAT,               .depth_format = D32_FLOAT,            .has_stencil = true),
+   fmt(VK_FORMAT_D16_UNORM,               ISL_FORMAT_R16_UNORM,               .has_depth = true),
+   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_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),
 
    fmt(VK_FORMAT_BC1_RGB_UNORM_BLOCK,     ISL_FORMAT_DXT1_RGB),
    fmt(VK_FORMAT_BC1_RGB_SRGB_BLOCK,      ISL_FORMAT_DXT1_RGB_SRGB),
@@ -279,7 +279,7 @@ anv_get_isl_format(VkFormat format, VkImageAspectFlags aspect,
 
    case VK_IMAGE_ASPECT_DEPTH_BIT:
    case (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT):
-      assert(anv_fmt->depth_format != 0);
+      assert(anv_fmt->has_depth);
       return anv_fmt->isl_format;
 
    case VK_IMAGE_ASPECT_STENCIL_BIT:
@@ -387,7 +387,7 @@ anv_physical_device_get_format_properties(struct anv_physical_device *physical_d
          tiled |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT;
          tiled |= VK_FORMAT_FEATURE_BLIT_SRC_BIT;
       }
-      if (anv_formats[format].depth_format) {
+      if (anv_formats[format].has_depth) {
          tiled |= VK_FORMAT_FEATURE_BLIT_DST_BIT;
       }
    } else {
index 2ed654feee2e6a6d1fa51c26790d5f05d1be1594..9e7f236f85172850dd9fee929b639da23413ea02 100644 (file)
@@ -221,7 +221,7 @@ anv_image_create(VkDevice _device,
       if (r != VK_SUCCESS)
          goto fail;
    } else {
-      if (image->format->depth_format) {
+      if (image->format->has_depth) {
          r = make_surface(device, image, create_info,
                           VK_IMAGE_ASPECT_DEPTH_BIT);
          if (r != VK_SUCCESS)
@@ -368,9 +368,9 @@ anv_validate_CreateImageView(VkDevice _device,
    /* Validate format. */
    if (subresource->aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) {
       assert(subresource->aspectMask == VK_IMAGE_ASPECT_COLOR_BIT);
-      assert(!image->format->depth_format);
+      assert(!image->format->has_depth);
       assert(!image->format->has_stencil);
-      assert(!view_format_info->depth_format);
+      assert(!view_format_info->has_depth);
       assert(!view_format_info->has_stencil);
       assert(view_format_info->isl_layout->bs ==
              image->format->isl_layout->bs);
@@ -378,8 +378,8 @@ anv_validate_CreateImageView(VkDevice _device,
       assert((subresource->aspectMask & ~ds_flags) == 0);
 
       if (subresource->aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) {
-         assert(image->format->depth_format);
-         assert(view_format_info->depth_format);
+         assert(image->format->has_depth);
+         assert(view_format_info->has_depth);
          assert(view_format_info->isl_layout->bs ==
                 image->format->isl_layout->bs);
       }
@@ -730,9 +730,9 @@ anv_image_get_surface_for_aspect_mask(struct anv_image *image, VkImageAspectFlag
        * Meta attaches all destination surfaces as color render targets. Guess
        * what surface the Meta Dragons really want.
        */
-      if (image->format->depth_format && image->format->has_stencil) {
+      if (image->format->has_depth && image->format->has_stencil) {
          return &image->depth_surface;
-      } else if (image->format->depth_format) {
+      } else if (image->format->has_depth) {
          return &image->depth_surface;
       } else if (image->format->has_stencil) {
          return &image->stencil_surface;
@@ -741,13 +741,13 @@ anv_image_get_surface_for_aspect_mask(struct anv_image *image, VkImageAspectFlag
       }
       break;
    case VK_IMAGE_ASPECT_DEPTH_BIT:
-      assert(image->format->depth_format);
+      assert(image->format->has_depth);
       return &image->depth_surface;
    case VK_IMAGE_ASPECT_STENCIL_BIT:
       assert(image->format->has_stencil);
       return &image->stencil_surface;
    case VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT:
-      if (image->format->depth_format && image->format->has_stencil) {
+      if (image->format->has_depth && image->format->has_stencil) {
          /* FINISHME: The Vulkan spec (git a511ba2) requires support for
           * combined depth stencil formats. Specifically, it states:
           *
@@ -760,7 +760,7 @@ anv_image_get_surface_for_aspect_mask(struct anv_image *image, VkImageAspectFlag
           * stencil surfaces from the underlying surface.
           */
          return &image->depth_surface;
-      } else if (image->format->depth_format) {
+      } else if (image->format->has_depth) {
          return &image->depth_surface;
       } else if (image->format->has_stencil) {
          return &image->stencil_surface;
index 769f81c609b316e2e689d01d7460d31114fd03b6..b7d35f88ef0f1d32efc0c1bf97fb03b445bffd87 100644 (file)
@@ -1512,8 +1512,8 @@ struct anv_format {
    const char *name;
    enum isl_format isl_format; /**< RENDER_SURFACE_STATE.SurfaceFormat */
    const struct isl_format_layout *isl_layout;
-   uint16_t depth_format; /**< 3DSTATE_DEPTH_BUFFER.SurfaceFormat */
    struct anv_format_swizzle swizzle;
+   bool has_depth;
    bool has_stencil;
 };
 
@@ -1527,13 +1527,13 @@ anv_get_isl_format(VkFormat format, VkImageAspectFlags aspect,
 static inline bool
 anv_format_is_color(const struct anv_format *format)
 {
-   return !format->depth_format && !format->has_stencil;
+   return !format->has_depth && !format->has_stencil;
 }
 
 static inline bool
 anv_format_is_depth_or_stencil(const struct anv_format *format)
 {
-   return format->depth_format || format->has_stencil;
+   return format->has_depth || format->has_stencil;
 }
 
 /**
index e843b942b1d0fbf985c7f9f9597eab5d8824080a..4bec8a620c5a9419cfe0f351f4ef9cf15ee554f0 100644 (file)
@@ -554,16 +554,14 @@ genX(cmd_buffer_flush_state)(struct anv_cmd_buffer *cmd_buffer)
 static void
 cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
 {
+   struct anv_device *device = cmd_buffer->device;
    const struct anv_framebuffer *fb = cmd_buffer->state.framebuffer;
    const struct anv_image_view *iview =
       anv_cmd_buffer_get_depth_stencil_view(cmd_buffer);
    const struct anv_image *image = iview ? iview->image : NULL;
-
-   /* XXX: isl needs to grow depth format support */
    const struct anv_format *anv_format =
       iview ? anv_format_for_vk_format(iview->vk_format) : NULL;
-
-   const bool has_depth = iview && anv_format->depth_format;
+   const bool has_depth = iview && anv_format->has_depth;
    const bool has_stencil = iview && anv_format->has_stencil;
 
    /* Emit 3DSTATE_DEPTH_BUFFER */
@@ -573,7 +571,8 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
          .DepthWriteEnable = true,
          .StencilWriteEnable = has_stencil,
          .HierarchicalDepthBufferEnable = false,
-         .SurfaceFormat = anv_format->depth_format,
+         .SurfaceFormat = isl_surf_get_depth_format(&device->isl_dev,
+                                                    &image->depth_surface.isl),
          .SurfacePitch = image->depth_surface.isl.row_pitch - 1,
          .SurfaceBaseAddress = {
             .bo = image->bo,
index 3ba5bbcf4a52c7b04391df4b14b2377098dc605e..b81944c2156c66ebcda8a0f601157615c047aca5 100644 (file)
@@ -618,16 +618,14 @@ genX(cmd_buffer_flush_compute_state)(struct anv_cmd_buffer *cmd_buffer)
 static void
 cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
 {
+   struct anv_device *device = cmd_buffer->device;
    const struct anv_framebuffer *fb = cmd_buffer->state.framebuffer;
    const struct anv_image_view *iview =
       anv_cmd_buffer_get_depth_stencil_view(cmd_buffer);
    const struct anv_image *image = iview ? iview->image : NULL;
-
-   /* XXX: isl needs to grow depth format support */
    const struct anv_format *anv_format =
       iview ? anv_format_for_vk_format(iview->vk_format) : NULL;
-
-   const bool has_depth = iview && anv_format->depth_format;
+   const bool has_depth = iview && anv_format->has_depth;
    const bool has_stencil = iview && anv_format->has_stencil;
 
    /* FIXME: Implement the PMA stall W/A */
@@ -637,10 +635,11 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
    if (has_depth) {
       anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_DEPTH_BUFFER),
          .SurfaceType = SURFTYPE_2D,
-         .DepthWriteEnable = anv_format->depth_format,
+         .DepthWriteEnable = true,
          .StencilWriteEnable = has_stencil,
          .HierarchicalDepthBufferEnable = false,
-         .SurfaceFormat = anv_format->depth_format,
+         .SurfaceFormat = isl_surf_get_depth_format(&device->isl_dev,
+                                                    &image->depth_surface.isl),
          .SurfacePitch = image->depth_surface.isl.row_pitch - 1,
          .SurfaceBaseAddress = {
             .bo = image->bo,