diff --git a/src/amd/vulkan/meta/radv_meta_bufimage.c b/src/amd/vulkan/meta/radv_meta_bufimage.c index 34af76c1194..65e781be6b4 100644 --- a/src/amd/vulkan/meta/radv_meta_bufimage.c +++ b/src/amd/vulkan/meta/radv_meta_bufimage.c @@ -1235,9 +1235,10 @@ fixup_gfx9_cs_copy(struct radv_cmd_buffer *cmd_buffer, const unsigned mip_level = img_bsurf->level; const struct radv_image *image = img_bsurf->image; const struct radeon_surf *surf = &image->planes[0].surface; - const struct radv_device *device = cmd_buffer->device; + struct radv_device *device = cmd_buffer->device; const struct radeon_info *rad_info = &device->physical_device->rad_info; struct ac_addrlib *addrlib = device->ws->get_addrlib(device->ws); + struct ac_surf_info surf_info = radv_get_ac_surf_info(device, image); /* GFX10 will use a different workaround unless this is not a 2D image */ if (rad_info->gfx_level < GFX9 || @@ -1283,7 +1284,7 @@ fixup_gfx9_cs_copy(struct radv_cmd_buffer *cmd_buffer, uint32_t x = (coordY < hw_mip_extent.height) ? hw_mip_extent.width : 0; for (; x < mip_extent.width; x++) { uint32_t coordX = x + mip_offset.x; - uint64_t addr = ac_surface_addr_from_coord(addrlib, rad_info, surf, &image->info, + uint64_t addr = ac_surface_addr_from_coord(addrlib, rad_info, surf, &surf_info, mip_level, coordX, coordY, img_bsurf->layer, image->vk.image_type == VK_IMAGE_TYPE_3D); struct radeon_winsys_bo *img_bo = image->bindings[0].bo; diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c index 49b633f34e2..c8564628b4d 100644 --- a/src/amd/vulkan/radv_image.c +++ b/src/amd/vulkan/radv_image.c @@ -539,7 +539,7 @@ radv_patch_image_from_extra_info(struct radv_device *device, struct radv_image * if (device->instance->debug_flags & RADV_DEBUG_NO_DISPLAY_DCC) image->planes[plane].surface.flags |= RADEON_SURF_DISABLE_DCC; - image->info.surf_index = NULL; + image_info->surf_index = NULL; } if (create_info->prime_blit_src && device->physical_device->rad_info.gfx_level == GFX9) { @@ -1721,6 +1721,31 @@ radv_image_reset_layout(const struct radv_physical_device *pdev, struct radv_ima } } +struct ac_surf_info +radv_get_ac_surf_info(struct radv_device *device, const struct radv_image *image) +{ + struct ac_surf_info info; + + memset(&info, 0, sizeof(info)); + + info.width = image->vk.extent.width; + info.height = image->vk.extent.height; + info.depth = image->vk.extent.depth; + info.samples = image->vk.samples; + info.storage_samples = image->vk.samples; + info.array_size = image->vk.array_layers; + info.levels = image->vk.mip_levels; + info.num_channels = vk_format_get_nr_components(image->vk.format); + + if (!vk_format_is_depth_or_stencil(image->vk.format) && !image->shareable && + !(image->vk.create_flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && + image->vk.tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { + info.surf_index = &device->image_mrt_offset_counter; + } + + return info; +} + VkResult radv_image_create_layout(struct radv_device *device, struct radv_image_create_info create_info, const struct VkImageDrmFormatModifierExplicitCreateInfoEXT *mod_info, @@ -1730,7 +1755,7 @@ radv_image_create_layout(struct radv_device *device, struct radv_image_create_in * common internal case. */ create_info.vk_info = NULL; - struct ac_surf_info image_info = image->info; + struct ac_surf_info image_info = radv_get_ac_surf_info(device, image); VkResult result = radv_patch_image_from_extra_info(device, image, &create_info, &image_info); if (result != VK_SUCCESS) return result; @@ -1939,15 +1964,6 @@ radv_image_create(VkDevice _device, const struct radv_image_create_info *create_ vk_image_init(&device->vk, &image->vk, pCreateInfo); - image->info.width = pCreateInfo->extent.width; - image->info.height = pCreateInfo->extent.height; - image->info.depth = pCreateInfo->extent.depth; - image->info.samples = pCreateInfo->samples; - image->info.storage_samples = pCreateInfo->samples; - image->info.array_size = pCreateInfo->arrayLayers; - image->info.levels = pCreateInfo->mipLevels; - image->info.num_channels = vk_format_get_nr_components(format); - image->plane_count = vk_format_get_plane_count(format); image->disjoint = image->plane_count > 1 && pCreateInfo->flags & VK_IMAGE_CREATE_DISJOINT_BIT; @@ -1966,11 +1982,6 @@ radv_image_create(VkDevice _device, const struct radv_image_create_info *create_ vk_find_struct_const(pCreateInfo->pNext, EXTERNAL_MEMORY_IMAGE_CREATE_INFO); image->shareable = external_info; - if (!vk_format_is_depth_or_stencil(format) && !image->shareable && - !(image->vk.create_flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && - pCreateInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { - image->info.surf_index = &device->image_mrt_offset_counter; - } if (mod_list) modifier = radv_select_modifier(device, format, mod_list); @@ -2030,15 +2041,16 @@ radv_image_create(VkDevice _device, const struct radv_image_create_info *create_ } static inline void -compute_non_block_compressed_view(const struct radv_device *device, +compute_non_block_compressed_view(struct radv_device *device, const struct radv_image_view *iview, struct ac_surf_nbc_view *nbc_view) { const struct radv_image *image = iview->image; const struct radeon_surf *surf = &image->planes[0].surface; struct ac_addrlib *addrlib = device->ws->get_addrlib(device->ws); + struct ac_surf_info surf_info = radv_get_ac_surf_info(device, image); - ac_surface_compute_nbc_view(addrlib, &device->physical_device->rad_info, surf, &image->info, + ac_surface_compute_nbc_view(addrlib, &device->physical_device->rad_info, surf, &surf_info, iview->vk.base_mip_level, iview->vk.base_array_layer, nbc_view); } diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index 32580996407..c12786da17a 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -2515,8 +2515,6 @@ struct radv_image_binding { struct radv_image { struct vk_image vk; - struct ac_surf_info info; - VkDeviceSize size; uint32_t alignment; @@ -2550,6 +2548,9 @@ struct radv_image { struct radv_image_plane planes[0]; }; +struct ac_surf_info radv_get_ac_surf_info(struct radv_device *device, + const struct radv_image *image); + /* Whether the image has a htile that is known consistent with the contents of * the image and is allowed to be in compressed form. *