}
} 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;
}
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),
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:
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 {
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)
/* 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);
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);
}
* 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;
}
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:
*
* 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;
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;
};
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;
}
/**
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 */
.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,
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 */
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,