isl now understands depth formats. We no longer need depth formats in the anv_format table.tags/12.0-branchpoint
@@ -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; | |||
} |
@@ -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 { |
@@ -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; |
@@ -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; | |||
} | |||
/** |
@@ -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, |
@@ -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, |