diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index 56a539fd3c1..a6a1c6db31b 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -2222,3 +2222,19 @@ radv_ReleaseProfilingLockKHR(VkDevice _device) RADV_FROM_HANDLE(radv_device, device, _device); radv_device_release_performance_counters(device); } + +VKAPI_ATTR void VKAPI_CALL +radv_GetDeviceImageSubresourceLayoutKHR(VkDevice device, const VkDeviceImageSubresourceInfoKHR *pInfo, + VkSubresourceLayout2KHR *pLayout) +{ + UNUSED VkResult result; + VkImage image; + + result = + radv_image_create(device, &(struct radv_image_create_info){.vk_info = pInfo->pCreateInfo}, NULL, &image, true); + assert(result == VK_SUCCESS); + + radv_GetImageSubresourceLayout2KHR(device, image, pInfo->pSubresource, pLayout); + + radv_DestroyImage(device, image, NULL); +} diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c index 07fc590eb20..b6193065c12 100644 --- a/src/amd/vulkan/radv_image.c +++ b/src/amd/vulkan/radv_image.c @@ -2513,38 +2513,38 @@ radv_DestroyImage(VkDevice _device, VkImage _image, const VkAllocationCallbacks } VKAPI_ATTR void VKAPI_CALL -radv_GetImageSubresourceLayout(VkDevice _device, VkImage _image, const VkImageSubresource *pSubresource, - VkSubresourceLayout *pLayout) +radv_GetImageSubresourceLayout2KHR(VkDevice _device, VkImage _image, const VkImageSubresource2KHR *pSubresource, + VkSubresourceLayout2KHR *pLayout) { RADV_FROM_HANDLE(radv_image, image, _image); RADV_FROM_HANDLE(radv_device, device, _device); - int level = pSubresource->mipLevel; - int layer = pSubresource->arrayLayer; + int level = pSubresource->imageSubresource.mipLevel; + int layer = pSubresource->imageSubresource.arrayLayer; unsigned plane_id = 0; if (vk_format_get_plane_count(image->vk.format) > 1) - plane_id = radv_plane_from_aspect(pSubresource->aspectMask); + plane_id = radv_plane_from_aspect(pSubresource->imageSubresource.aspectMask); struct radv_image_plane *plane = &image->planes[plane_id]; struct radeon_surf *surface = &plane->surface; if (image->vk.tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { - unsigned mem_plane_id = radv_plane_from_aspect(pSubresource->aspectMask); + unsigned mem_plane_id = radv_plane_from_aspect(pSubresource->imageSubresource.aspectMask); assert(level == 0); assert(layer == 0); - pLayout->offset = + pLayout->subresourceLayout.offset = ac_surface_get_plane_offset(device->physical_device->rad_info.gfx_level, surface, mem_plane_id, 0); - pLayout->rowPitch = + pLayout->subresourceLayout.rowPitch = ac_surface_get_plane_stride(device->physical_device->rad_info.gfx_level, surface, mem_plane_id, level); - pLayout->arrayPitch = 0; - pLayout->depthPitch = 0; - pLayout->size = ac_surface_get_plane_size(surface, mem_plane_id); + pLayout->subresourceLayout.arrayPitch = 0; + pLayout->subresourceLayout.depthPitch = 0; + pLayout->subresourceLayout.size = ac_surface_get_plane_size(surface, mem_plane_id); } else if (device->physical_device->rad_info.gfx_level >= GFX9) { uint64_t level_offset = surface->is_linear ? surface->u.gfx9.offset[level] : 0; - pLayout->offset = + pLayout->subresourceLayout.offset = ac_surface_get_plane_offset(device->physical_device->rad_info.gfx_level, &plane->surface, 0, layer) + level_offset; if (image->vk.format == VK_FORMAT_R32G32B32_UINT || image->vk.format == VK_FORMAT_R32G32B32_SINT || @@ -2553,28 +2553,28 @@ radv_GetImageSubresourceLayout(VkDevice _device, VkImage _image, const VkImageSu * the pitch is actually the number of components per * row. */ - pLayout->rowPitch = surface->u.gfx9.surf_pitch * surface->bpe / 3; + pLayout->subresourceLayout.rowPitch = surface->u.gfx9.surf_pitch * surface->bpe / 3; } else { uint32_t pitch = surface->is_linear ? surface->u.gfx9.pitch[level] : surface->u.gfx9.surf_pitch; assert(util_is_power_of_two_nonzero(surface->bpe)); - pLayout->rowPitch = pitch * surface->bpe; + pLayout->subresourceLayout.rowPitch = pitch * surface->bpe; } - pLayout->arrayPitch = surface->u.gfx9.surf_slice_size; - pLayout->depthPitch = surface->u.gfx9.surf_slice_size; - pLayout->size = surface->u.gfx9.surf_slice_size; + pLayout->subresourceLayout.arrayPitch = surface->u.gfx9.surf_slice_size; + pLayout->subresourceLayout.depthPitch = surface->u.gfx9.surf_slice_size; + pLayout->subresourceLayout.size = surface->u.gfx9.surf_slice_size; if (image->vk.image_type == VK_IMAGE_TYPE_3D) - pLayout->size *= u_minify(image->vk.extent.depth, level); + pLayout->subresourceLayout.size *= u_minify(image->vk.extent.depth, level); } else { - pLayout->offset = (uint64_t)surface->u.legacy.level[level].offset_256B * 256 + - (uint64_t)surface->u.legacy.level[level].slice_size_dw * 4 * layer; - pLayout->rowPitch = surface->u.legacy.level[level].nblk_x * surface->bpe; - pLayout->arrayPitch = (uint64_t)surface->u.legacy.level[level].slice_size_dw * 4; - pLayout->depthPitch = (uint64_t)surface->u.legacy.level[level].slice_size_dw * 4; - pLayout->size = (uint64_t)surface->u.legacy.level[level].slice_size_dw * 4; + pLayout->subresourceLayout.offset = (uint64_t)surface->u.legacy.level[level].offset_256B * 256 + + (uint64_t)surface->u.legacy.level[level].slice_size_dw * 4 * layer; + pLayout->subresourceLayout.rowPitch = surface->u.legacy.level[level].nblk_x * surface->bpe; + pLayout->subresourceLayout.arrayPitch = (uint64_t)surface->u.legacy.level[level].slice_size_dw * 4; + pLayout->subresourceLayout.depthPitch = (uint64_t)surface->u.legacy.level[level].slice_size_dw * 4; + pLayout->subresourceLayout.size = (uint64_t)surface->u.legacy.level[level].slice_size_dw * 4; if (image->vk.image_type == VK_IMAGE_TYPE_3D) - pLayout->size *= u_minify(image->vk.extent.depth, level); + pLayout->subresourceLayout.size *= u_minify(image->vk.extent.depth, level); } }