nvk: Use 2D array views for 3D storage images
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
This commit is contained in:

committed by
Marge Bot

parent
1fd3e5ff1d
commit
640783513b
@@ -54,7 +54,6 @@ write_image_view_desc(struct nvk_descriptor_set *set,
|
||||
* that our descriptor index is at most 11 bits.
|
||||
*/
|
||||
assert(view->storage_desc_index < (1 << 11));
|
||||
assert(view->vk.image->image_type != VK_IMAGE_TYPE_3D);
|
||||
|
||||
desc.image_index = view->storage_desc_index;
|
||||
} else {
|
||||
|
@@ -230,6 +230,12 @@ nvk_image_init(struct nvk_device *device,
|
||||
if (pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT)
|
||||
usage |= NIL_IMAGE_USAGE_2D_VIEW_BIT;
|
||||
|
||||
/* We treat 3D storage images as 2D arrays. One day, we may wire up actual
|
||||
* 3D storage image support but baseArrayLayer gets tricky.
|
||||
*/
|
||||
if (image->vk.usage & VK_IMAGE_USAGE_STORAGE_BIT)
|
||||
usage |= NIL_IMAGE_USAGE_2D_VIEW_BIT;
|
||||
|
||||
struct nil_image_init_info nil_info = {
|
||||
.dim = vk_image_type_to_nil_dim(pCreateInfo->imageType),
|
||||
.format = vk_format_to_pipe_format(pCreateInfo->format),
|
||||
|
@@ -108,6 +108,19 @@ nvk_image_view_init(struct nvk_device *device,
|
||||
view->vk.view_type == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY)
|
||||
nil_view.type = NIL_VIEW_TYPE_2D_ARRAY;
|
||||
|
||||
if (view->vk.view_type == VK_IMAGE_VIEW_TYPE_3D) {
|
||||
/* Without VK_AMD_shader_image_load_store_lod, the client can only
|
||||
* get at the first LOD from the shader anyway.
|
||||
*/
|
||||
assert(view->vk.base_array_layer == 0);
|
||||
assert(view->vk.layer_count = 1);
|
||||
nil_view.type = NIL_VIEW_TYPE_2D_ARRAY;
|
||||
nil_view.num_levels = 1;
|
||||
nil_view.base_array_layer = 0;
|
||||
nil_view.array_len = view->vk.extent.depth;
|
||||
image_3d_view_as_2d_array(&nil_image, &nil_view, &base_addr);
|
||||
}
|
||||
|
||||
uint32_t tic[8];
|
||||
nil_image_fill_tic(nvk_device_physical(device)->dev,
|
||||
&nil_image, &nil_view, base_addr, tic);
|
||||
|
@@ -190,6 +190,13 @@ lower_image_intrin(nir_builder *b, nir_intrinsic_instr *intrin,
|
||||
nir_ssa_def *desc = load_resource_deref_desc(b, deref, 0, 1, 32, ctx);
|
||||
nir_rewrite_image_intrinsic(intrin, desc, true);
|
||||
|
||||
/* We treat 3D images as 2D arrays */
|
||||
if (nir_intrinsic_image_dim(intrin) == GLSL_SAMPLER_DIM_3D) {
|
||||
assert(!nir_intrinsic_image_array(intrin));
|
||||
nir_intrinsic_set_image_dim(intrin, GLSL_SAMPLER_DIM_2D);
|
||||
nir_intrinsic_set_image_array(intrin, true);
|
||||
}
|
||||
|
||||
/* We don't support ReadWithoutFormat yet */
|
||||
if (intrin->intrinsic == nir_intrinsic_image_deref_load)
|
||||
assert(nir_intrinsic_format(intrin) != PIPE_FORMAT_NONE);
|
||||
|
Reference in New Issue
Block a user