const VkComponentMapping *mapping, unsigned first_level,
unsigned last_level, unsigned first_layer, unsigned last_layer,
unsigned width, unsigned height, unsigned depth, float min_lod,
- uint32_t *state, uint32_t *fmask_state)
+ uint32_t *state, uint32_t *fmask_state,
+ VkImageCreateFlags img_create_flags)
{
const struct util_format_description *desc;
enum pipe_swizzle swizzle[4];
radv_compose_swizzle(desc, mapping, swizzle);
- type = radv_tex_dim(image->type, view_type, image->info.array_size, image->info.samples,
- is_storage_image, device->physical_device->rad_info.chip_class == GFX9);
+ if (img_create_flags & VK_IMAGE_CREATE_2D_VIEW_COMPATIBLE_BIT_EXT) {
+ assert(image->type == VK_IMAGE_TYPE_3D);
+ type = V_008F1C_SQ_RSRC_IMG_3D;
+ } else {
+ type = radv_tex_dim(image->type, view_type, image->info.array_size, image->info.samples,
+ is_storage_image, device->physical_device->rad_info.chip_class == GFX9);
+ }
+
if (type == V_008F1C_SQ_RSRC_IMG_1D_ARRAY) {
height = 1;
depth = image->info.array_size;
state[6] = 0;
state[7] = 0;
+ if (img_create_flags & VK_IMAGE_CREATE_2D_VIEW_COMPATIBLE_BIT_EXT) {
+ assert(type == V_008F1C_SQ_RSRC_IMG_3D);
+
+ /* ARRAY_PITCH is only meaningful for 3D images, 0 means SRV, 1 means UAV.
+ * In SRV mode, BASE_ARRAY is ignored and DEPTH is the last slice of mipmap level 0.
+ * In UAV mode, BASE_ARRAY is the first slice and DEPTH is the last slice of the bound level.
+ */
+ state[4] &= C_00A010_DEPTH;
+ state[4] |= S_00A010_DEPTH(!is_storage_image ? depth - 1 : u_minify(depth, first_level) - 1);
+ state[5] |= S_00A014_ARRAY_PITCH(is_storage_image);
+ }
+
if (radv_dcc_enabled(image, first_level)) {
state[6] |= S_00A018_MAX_UNCOMPRESSED_BLOCK_SIZE(V_028C78_MAX_BLOCK_SIZE_256B) |
S_00A018_MAX_COMPRESSED_BLOCK_SIZE(
const VkComponentMapping *mapping, unsigned first_level,
unsigned last_level, unsigned first_layer, unsigned last_layer,
unsigned width, unsigned height, unsigned depth, float min_lod,
- uint32_t *state, uint32_t *fmask_state)
+ uint32_t *state, uint32_t *fmask_state,
+ VkImageCreateFlags img_create_flags)
{
const struct util_format_description *desc;
enum pipe_swizzle swizzle[4];
else if (image->vk_format == VK_FORMAT_D16_UNORM_S8_UINT)
data_format = V_008F14_IMG_DATA_FORMAT_S8_16;
}
- type = radv_tex_dim(image->type, view_type, image->info.array_size, image->info.samples,
- is_storage_image, device->physical_device->rad_info.chip_class == GFX9);
+
+ if (device->physical_device->rad_info.chip_class == GFX9 &&
+ img_create_flags & VK_IMAGE_CREATE_2D_VIEW_COMPATIBLE_BIT_EXT) {
+ assert(image->type == VK_IMAGE_TYPE_3D);
+ type = V_008F1C_SQ_RSRC_IMG_3D;
+ } else {
+ type = radv_tex_dim(image->type, view_type, image->info.array_size, image->info.samples,
+ is_storage_image, device->physical_device->rad_info.chip_class == GFX9);
+ }
+
if (type == V_008F1C_SQ_RSRC_IMG_1D_ARRAY) {
height = 1;
depth = image->info.array_size;
const VkComponentMapping *mapping, unsigned first_level,
unsigned last_level, unsigned first_layer, unsigned last_layer,
unsigned width, unsigned height, unsigned depth, float min_lod, uint32_t *state,
- uint32_t *fmask_state)
+ uint32_t *fmask_state, VkImageCreateFlags img_create_flags)
{
if (device->physical_device->rad_info.chip_class >= GFX10) {
gfx10_make_texture_descriptor(device, image, is_storage_image, view_type, vk_format, mapping,
first_level, last_level, first_layer, last_layer, width, height,
- depth, min_lod, state, fmask_state);
+ depth, min_lod, state, fmask_state, img_create_flags);
} else {
si_make_texture_descriptor(device, image, is_storage_image, view_type, vk_format, mapping,
first_level, last_level, first_layer, last_layer, width, height,
- depth, min_lod, state, fmask_state);
+ depth, min_lod, state, fmask_state, img_create_flags);
}
}
radv_make_texture_descriptor(device, image, false, (VkImageViewType)image->type,
image->vk_format, &fixedmapping, 0, image->info.levels - 1, 0,
image->info.array_size - 1, image->info.width, image->info.height,
- image->info.depth, 0.0f, desc, NULL);
+ image->info.depth, 0.0f, desc, NULL, 0);
si_set_mutable_tex_desc_fields(device, image, &image->planes[0].surface.u.legacy.level[0], 0, 0,
0, image->planes[0].surface.blk_w, false, false, false, false,
float min_lod,
bool is_storage_image, bool disable_compression,
bool enable_compression, unsigned plane_id,
- unsigned descriptor_plane_id)
+ unsigned descriptor_plane_id, VkImageCreateFlags img_create_flags)
{
struct radv_image *image = iview->image;
struct radv_image_plane *plane = &image->planes[plane_id];
vk_format_get_plane_width(image->vk_format, plane_id, iview->extent.width),
vk_format_get_plane_height(image->vk_format, plane_id, iview->extent.height),
iview->extent.depth, min_lod, descriptor->plane_descriptors[descriptor_plane_id],
- descriptor_plane_id || is_storage_image ? NULL : descriptor->fmask_descriptor);
+ descriptor_plane_id || is_storage_image ? NULL : descriptor->fmask_descriptor,
+ img_create_flags);
const struct legacy_surf_level *base_level_info = NULL;
if (device->physical_device->rad_info.chip_class <= GFX9) {
void
radv_image_view_init(struct radv_image_view *iview, struct radv_device *device,
const VkImageViewCreateInfo *pCreateInfo,
+ VkImageCreateFlags img_create_flags,
const struct radv_image_view_extra_create_info *extra_create_info)
{
RADV_FROM_HANDLE(radv_image, image, pCreateInfo->image);
VkFormat format = vk_format_get_plane_format(iview->vk_format, i);
radv_image_view_make_descriptor(iview, device, format, &pCreateInfo->components, min_lod, false,
disable_compression, enable_compression, iview->plane_id + i,
- i);
+ i, img_create_flags);
radv_image_view_make_descriptor(iview, device, format, &pCreateInfo->components, min_lod, true,
disable_compression, enable_compression, iview->plane_id + i,
- i);
+ i, img_create_flags);
}
}
radv_CreateImageView(VkDevice _device, const VkImageViewCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkImageView *pView)
{
+ RADV_FROM_HANDLE(radv_image, image, pCreateInfo->image);
RADV_FROM_HANDLE(radv_device, device, _device);
struct radv_image_view *view;
if (view == NULL)
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
- radv_image_view_init(view, device, pCreateInfo, NULL);
+ radv_image_view_init(view, device, pCreateInfo, image->flags, NULL);
*pView = radv_image_view_to_handle(view);