From: Chad Versace Date: Tue, 9 Feb 2016 03:07:10 +0000 (-0800) Subject: anv: Replace anv_format::depth_format with ::has_depth X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e6d3432c810fdc474c1a0e76eb27621568fd4f39;p=mesa.git anv: Replace anv_format::depth_format with ::has_depth isl now understands depth formats. We no longer need depth formats in the anv_format table. --- diff --git a/src/vulkan/anv_cmd_buffer.c b/src/vulkan/anv_cmd_buffer.c index 6b1c31f0e2e..bc6b3925cd2 100644 --- a/src/vulkan/anv_cmd_buffer.c +++ b/src/vulkan/anv_cmd_buffer.c @@ -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; } diff --git a/src/vulkan/anv_formats.c b/src/vulkan/anv_formats.c index d96d730d378..09cd8b9ddf9 100644 --- a/src/vulkan/anv_formats.c +++ b/src/vulkan/anv_formats.c @@ -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 { diff --git a/src/vulkan/anv_image.c b/src/vulkan/anv_image.c index 2ed654feee2..9e7f236f851 100644 --- a/src/vulkan/anv_image.c +++ b/src/vulkan/anv_image.c @@ -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; diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index 769f81c609b..b7d35f88ef0 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -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; } /** diff --git a/src/vulkan/gen7_cmd_buffer.c b/src/vulkan/gen7_cmd_buffer.c index e843b942b1d..4bec8a620c5 100644 --- a/src/vulkan/gen7_cmd_buffer.c +++ b/src/vulkan/gen7_cmd_buffer.c @@ -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, diff --git a/src/vulkan/gen8_cmd_buffer.c b/src/vulkan/gen8_cmd_buffer.c index 3ba5bbcf4a5..b81944c2156 100644 --- a/src/vulkan/gen8_cmd_buffer.c +++ b/src/vulkan/gen8_cmd_buffer.c @@ -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,