anv: deal with isl format swizzles for buffer views
For some formats like VK_FORMAT_B5G6R5_UNORM_PACK16, we have no direct matching HW format. We can support it by swizzling. We already apply those swizzles for image views. We just forgot to deal with buffer views. Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Cc: mesa-stable Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6235 Reviewed-by: Nanley Chery <nanley.g.chery@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17385>
This commit is contained in:

committed by
Marge Bot

parent
a841300384
commit
57a8efa222
@@ -1472,7 +1472,8 @@ anv_cmd_buffer_push_descriptor_set(struct anv_cmd_buffer *cmd_buffer,
|
|||||||
anv_state_stream_alloc(&cmd_buffer->surface_state_stream,
|
anv_state_stream_alloc(&cmd_buffer->surface_state_stream,
|
||||||
isl_dev->ss.size, isl_dev->ss.align);
|
isl_dev->ss.size, isl_dev->ss.align);
|
||||||
anv_fill_buffer_surface_state(cmd_buffer->device,
|
anv_fill_buffer_surface_state(cmd_buffer->device,
|
||||||
set->desc_surface_state, format,
|
set->desc_surface_state,
|
||||||
|
format, ISL_SWIZZLE_IDENTITY,
|
||||||
ISL_SURF_USAGE_CONSTANT_BUFFER_BIT,
|
ISL_SURF_USAGE_CONSTANT_BUFFER_BIT,
|
||||||
set->desc_addr,
|
set->desc_addr,
|
||||||
layout->descriptor_buffer_size, 1);
|
layout->descriptor_buffer_size, 1);
|
||||||
|
@@ -1176,7 +1176,8 @@ anv_descriptor_set_create(struct anv_device *device,
|
|||||||
|
|
||||||
if (!pool->host_only) {
|
if (!pool->host_only) {
|
||||||
set->desc_surface_state = anv_descriptor_pool_alloc_state(pool);
|
set->desc_surface_state = anv_descriptor_pool_alloc_state(pool);
|
||||||
anv_fill_buffer_surface_state(device, set->desc_surface_state, format,
|
anv_fill_buffer_surface_state(device, set->desc_surface_state,
|
||||||
|
format, ISL_SWIZZLE_IDENTITY,
|
||||||
ISL_SURF_USAGE_CONSTANT_BUFFER_BIT,
|
ISL_SURF_USAGE_CONSTANT_BUFFER_BIT,
|
||||||
set->desc_addr,
|
set->desc_addr,
|
||||||
descriptor_buffer_size, 1);
|
descriptor_buffer_size, 1);
|
||||||
@@ -1631,7 +1632,6 @@ anv_descriptor_set_write_buffer(struct anv_device *device,
|
|||||||
struct anv_buffer_view *bview =
|
struct anv_buffer_view *bview =
|
||||||
&set->buffer_views[bind_layout->buffer_view_index + element];
|
&set->buffer_views[bind_layout->buffer_view_index + element];
|
||||||
|
|
||||||
bview->format = anv_isl_format_for_descriptor_type(device, type);
|
|
||||||
bview->range = bind_range;
|
bview->range = bind_range;
|
||||||
bview->address = bind_addr;
|
bview->address = bind_addr;
|
||||||
|
|
||||||
@@ -1651,9 +1651,10 @@ anv_descriptor_set_write_buffer(struct anv_device *device,
|
|||||||
ISL_SURF_USAGE_CONSTANT_BUFFER_BIT :
|
ISL_SURF_USAGE_CONSTANT_BUFFER_BIT :
|
||||||
ISL_SURF_USAGE_STORAGE_BIT;
|
ISL_SURF_USAGE_STORAGE_BIT;
|
||||||
|
|
||||||
|
enum isl_format format = anv_isl_format_for_descriptor_type(device, type);
|
||||||
anv_fill_buffer_surface_state(device, bview->surface_state,
|
anv_fill_buffer_surface_state(device, bview->surface_state,
|
||||||
bview->format, usage,
|
format, ISL_SWIZZLE_IDENTITY,
|
||||||
bind_addr, bind_range, 1);
|
usage, bind_addr, bind_range, 1);
|
||||||
desc->set_buffer_view = bview;
|
desc->set_buffer_view = bview;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4532,6 +4532,7 @@ uint64_t anv_GetDeviceMemoryOpaqueCaptureAddress(
|
|||||||
void
|
void
|
||||||
anv_fill_buffer_surface_state(struct anv_device *device, struct anv_state state,
|
anv_fill_buffer_surface_state(struct anv_device *device, struct anv_state state,
|
||||||
enum isl_format format,
|
enum isl_format format,
|
||||||
|
struct isl_swizzle swizzle,
|
||||||
isl_surf_usage_flags_t usage,
|
isl_surf_usage_flags_t usage,
|
||||||
struct anv_address address,
|
struct anv_address address,
|
||||||
uint32_t range, uint32_t stride)
|
uint32_t range, uint32_t stride)
|
||||||
@@ -4542,7 +4543,7 @@ anv_fill_buffer_surface_state(struct anv_device *device, struct anv_state state,
|
|||||||
address.bo && address.bo->is_external),
|
address.bo && address.bo->is_external),
|
||||||
.size_B = range,
|
.size_B = range,
|
||||||
.format = format,
|
.format = format,
|
||||||
.swizzle = ISL_SWIZZLE_IDENTITY,
|
.swizzle = swizzle,
|
||||||
.stride_B = stride);
|
.stride_B = stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2860,12 +2860,11 @@ anv_CreateBufferView(VkDevice _device,
|
|||||||
if (!view)
|
if (!view)
|
||||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||||
|
|
||||||
/* TODO: Handle the format swizzle? */
|
struct anv_format_plane format;
|
||||||
|
format = anv_get_format_plane(&device->info, pCreateInfo->format,
|
||||||
|
0, VK_IMAGE_TILING_LINEAR);
|
||||||
|
|
||||||
view->format = anv_get_isl_format(&device->info, pCreateInfo->format,
|
const uint32_t format_bs = isl_format_get_layout(format.isl_format)->bpb / 8;
|
||||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
|
||||||
VK_IMAGE_TILING_LINEAR);
|
|
||||||
const uint32_t format_bs = isl_format_get_layout(view->format)->bpb / 8;
|
|
||||||
view->range = vk_buffer_range(&buffer->vk, pCreateInfo->offset,
|
view->range = vk_buffer_range(&buffer->vk, pCreateInfo->offset,
|
||||||
pCreateInfo->range);
|
pCreateInfo->range);
|
||||||
view->range = align_down_npot_u32(view->range, format_bs);
|
view->range = align_down_npot_u32(view->range, format_bs);
|
||||||
@@ -2876,7 +2875,8 @@ anv_CreateBufferView(VkDevice _device,
|
|||||||
view->surface_state = alloc_surface_state(device);
|
view->surface_state = alloc_surface_state(device);
|
||||||
|
|
||||||
anv_fill_buffer_surface_state(device, view->surface_state,
|
anv_fill_buffer_surface_state(device, view->surface_state,
|
||||||
view->format, ISL_SURF_USAGE_TEXTURE_BIT,
|
format.isl_format, format.swizzle,
|
||||||
|
ISL_SURF_USAGE_TEXTURE_BIT,
|
||||||
view->address, view->range, format_bs);
|
view->address, view->range, format_bs);
|
||||||
} else {
|
} else {
|
||||||
view->surface_state = (struct anv_state){ 0 };
|
view->surface_state = (struct anv_state){ 0 };
|
||||||
@@ -2887,25 +2887,34 @@ anv_CreateBufferView(VkDevice _device,
|
|||||||
view->lowered_storage_surface_state = alloc_surface_state(device);
|
view->lowered_storage_surface_state = alloc_surface_state(device);
|
||||||
|
|
||||||
anv_fill_buffer_surface_state(device, view->storage_surface_state,
|
anv_fill_buffer_surface_state(device, view->storage_surface_state,
|
||||||
view->format, ISL_SURF_USAGE_STORAGE_BIT,
|
format.isl_format, format.swizzle,
|
||||||
view->address, view->range,
|
ISL_SURF_USAGE_STORAGE_BIT,
|
||||||
isl_format_get_layout(view->format)->bpb / 8);
|
view->address, view->range, format_bs);
|
||||||
|
|
||||||
enum isl_format lowered_format =
|
enum isl_format lowered_format =
|
||||||
isl_has_matching_typed_storage_image_format(&device->info,
|
isl_has_matching_typed_storage_image_format(&device->info,
|
||||||
view->format) ?
|
format.isl_format) ?
|
||||||
isl_lower_storage_image_format(&device->info, view->format) :
|
isl_lower_storage_image_format(&device->info, format.isl_format) :
|
||||||
ISL_FORMAT_RAW;
|
ISL_FORMAT_RAW;
|
||||||
|
|
||||||
|
/* If we lower the format, we should ensure either they both match in
|
||||||
|
* bits per channel or that there is no swizzle because we can't use
|
||||||
|
* the swizzle for a different bit pattern.
|
||||||
|
*/
|
||||||
|
assert(isl_formats_have_same_bits_per_channel(lowered_format,
|
||||||
|
format.isl_format) ||
|
||||||
|
isl_swizzle_is_identity(format.swizzle));
|
||||||
|
|
||||||
anv_fill_buffer_surface_state(device, view->lowered_storage_surface_state,
|
anv_fill_buffer_surface_state(device, view->lowered_storage_surface_state,
|
||||||
lowered_format, ISL_SURF_USAGE_STORAGE_BIT,
|
lowered_format, format.swizzle,
|
||||||
|
ISL_SURF_USAGE_STORAGE_BIT,
|
||||||
view->address, view->range,
|
view->address, view->range,
|
||||||
(lowered_format == ISL_FORMAT_RAW ? 1 :
|
(lowered_format == ISL_FORMAT_RAW ? 1 :
|
||||||
isl_format_get_layout(lowered_format)->bpb / 8));
|
isl_format_get_layout(lowered_format)->bpb / 8));
|
||||||
|
|
||||||
isl_buffer_fill_image_param(&device->isl_dev,
|
isl_buffer_fill_image_param(&device->isl_dev,
|
||||||
&view->lowered_storage_image_param,
|
&view->lowered_storage_image_param,
|
||||||
view->format, view->range);
|
format.isl_format, view->range);
|
||||||
} else {
|
} else {
|
||||||
view->storage_surface_state = (struct anv_state){ 0 };
|
view->storage_surface_state = (struct anv_state){ 0 };
|
||||||
view->lowered_storage_surface_state = (struct anv_state){ 0 };
|
view->lowered_storage_surface_state = (struct anv_state){ 0 };
|
||||||
|
@@ -1965,7 +1965,6 @@ anv_descriptor_set_is_push(struct anv_descriptor_set *set)
|
|||||||
struct anv_buffer_view {
|
struct anv_buffer_view {
|
||||||
struct vk_object_base base;
|
struct vk_object_base base;
|
||||||
|
|
||||||
enum isl_format format; /**< VkBufferViewCreateInfo::format */
|
|
||||||
uint64_t range; /**< VkBufferViewCreateInfo::range */
|
uint64_t range; /**< VkBufferViewCreateInfo::range */
|
||||||
|
|
||||||
struct anv_address address;
|
struct anv_address address;
|
||||||
@@ -4258,6 +4257,7 @@ anv_get_image_format_features2(const struct intel_device_info *devinfo,
|
|||||||
void anv_fill_buffer_surface_state(struct anv_device *device,
|
void anv_fill_buffer_surface_state(struct anv_device *device,
|
||||||
struct anv_state state,
|
struct anv_state state,
|
||||||
enum isl_format format,
|
enum isl_format format,
|
||||||
|
struct isl_swizzle swizzle,
|
||||||
isl_surf_usage_flags_t usage,
|
isl_surf_usage_flags_t usage,
|
||||||
struct anv_address address,
|
struct anv_address address,
|
||||||
uint32_t range, uint32_t stride);
|
uint32_t range, uint32_t stride);
|
||||||
|
@@ -2568,8 +2568,8 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
|
|||||||
const enum isl_format format =
|
const enum isl_format format =
|
||||||
anv_isl_format_for_descriptor_type(cmd_buffer->device,
|
anv_isl_format_for_descriptor_type(cmd_buffer->device,
|
||||||
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||||
anv_fill_buffer_surface_state(cmd_buffer->device,
|
anv_fill_buffer_surface_state(cmd_buffer->device, surface_state,
|
||||||
surface_state, format,
|
format, ISL_SWIZZLE_IDENTITY,
|
||||||
ISL_SURF_USAGE_CONSTANT_BUFFER_BIT,
|
ISL_SURF_USAGE_CONSTANT_BUFFER_BIT,
|
||||||
constant_data, constant_data_size, 1);
|
constant_data, constant_data_size, 1);
|
||||||
|
|
||||||
@@ -2590,7 +2590,7 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
|
|||||||
anv_isl_format_for_descriptor_type(cmd_buffer->device,
|
anv_isl_format_for_descriptor_type(cmd_buffer->device,
|
||||||
VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||||
anv_fill_buffer_surface_state(cmd_buffer->device, surface_state,
|
anv_fill_buffer_surface_state(cmd_buffer->device, surface_state,
|
||||||
format,
|
format, ISL_SWIZZLE_IDENTITY,
|
||||||
ISL_SURF_USAGE_CONSTANT_BUFFER_BIT,
|
ISL_SURF_USAGE_CONSTANT_BUFFER_BIT,
|
||||||
cmd_buffer->state.compute.num_workgroups,
|
cmd_buffer->state.compute.num_workgroups,
|
||||||
12, 1);
|
12, 1);
|
||||||
@@ -2752,7 +2752,8 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
|
|||||||
ISL_SURF_USAGE_STORAGE_BIT;
|
ISL_SURF_USAGE_STORAGE_BIT;
|
||||||
|
|
||||||
anv_fill_buffer_surface_state(cmd_buffer->device, surface_state,
|
anv_fill_buffer_surface_state(cmd_buffer->device, surface_state,
|
||||||
format, usage, address, range, 1);
|
format, ISL_SWIZZLE_IDENTITY,
|
||||||
|
usage, address, range, 1);
|
||||||
if (need_client_mem_relocs)
|
if (need_client_mem_relocs)
|
||||||
add_surface_reloc(cmd_buffer, surface_state, address);
|
add_surface_reloc(cmd_buffer, surface_state, address);
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user