diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/intel/vulkan/anv_image.c | 12 | ||||
-rw-r--r-- | src/intel/vulkan/anv_meta_clear.c | 4 | ||||
-rw-r--r-- | src/intel/vulkan/anv_private.h | 17 |
3 files changed, 25 insertions, 8 deletions
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index c76a5f6dba9..143a08413f7 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -388,9 +388,9 @@ anv_validate_CreateImageView(VkDevice _device, assert(subresource->levelCount > 0); assert(subresource->layerCount > 0); assert(subresource->baseMipLevel < image->levels); - assert(subresource->baseMipLevel + subresource->levelCount <= image->levels); + assert(subresource->baseMipLevel + anv_get_levelCount(image, subresource) <= image->levels); assert(subresource->baseArrayLayer < image->array_size); - assert(subresource->baseArrayLayer + subresource->layerCount <= image->array_size); + assert(subresource->baseArrayLayer + anv_get_layerCount(image, subresource) <= image->array_size); assert(pView); const VkImageAspectFlags ds_flags = VK_IMAGE_ASPECT_DEPTH_BIT @@ -496,10 +496,10 @@ anv_image_view_init(struct anv_image_view *iview, unreachable("bad VkImageType"); case VK_IMAGE_TYPE_1D: case VK_IMAGE_TYPE_2D: - assert(range->baseArrayLayer + range->layerCount - 1 <= image->array_size); + assert(range->baseArrayLayer + anv_get_layerCount(image, range) - 1 <= image->array_size); break; case VK_IMAGE_TYPE_3D: - assert(range->baseArrayLayer + range->layerCount - 1 + assert(range->baseArrayLayer + anv_get_layerCount(image, range) - 1 <= anv_minify(image->extent.depth, range->baseMipLevel)); break; } @@ -525,9 +525,9 @@ anv_image_view_init(struct anv_image_view *iview, struct isl_view isl_view = { .format = format, .base_level = range->baseMipLevel, - .levels = range->levelCount, + .levels = anv_get_levelCount(image, range), .base_array_layer = range->baseArrayLayer, - .array_len = range->layerCount, + .array_len = anv_get_layerCount(image, range), .channel_select = { remap_swizzle(pCreateInfo->components.r, VK_COMPONENT_SWIZZLE_R, swizzle), diff --git a/src/intel/vulkan/anv_meta_clear.c b/src/intel/vulkan/anv_meta_clear.c index 8f92a9d755c..bce94460844 100644 --- a/src/intel/vulkan/anv_meta_clear.c +++ b/src/intel/vulkan/anv_meta_clear.c @@ -795,8 +795,8 @@ anv_cmd_clear_image(struct anv_cmd_buffer *cmd_buffer, for (uint32_t r = 0; r < range_count; r++) { const VkImageSubresourceRange *range = &ranges[r]; - for (uint32_t l = 0; l < range->levelCount; ++l) { - for (uint32_t s = 0; s < range->layerCount; ++s) { + for (uint32_t l = 0; l < anv_get_levelCount(image, range); ++l) { + for (uint32_t s = 0; s < anv_get_layerCount(image, range); ++s) { struct anv_image_view iview; anv_image_view_init(&iview, cmd_buffer->device, &(VkImageViewCreateInfo) { diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index cb4f9736fdf..f87270466ae 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1641,6 +1641,23 @@ struct anv_image { }; }; +static inline uint32_t +anv_get_layerCount(const struct anv_image *image, + const VkImageSubresourceRange *range) +{ + return range->layerCount == VK_REMAINING_ARRAY_LAYERS ? + image->array_size - range->baseArrayLayer : range->layerCount; +} + +static inline uint32_t +anv_get_levelCount(const struct anv_image *image, + const VkImageSubresourceRange *range) +{ + return range->levelCount == VK_REMAINING_MIP_LEVELS ? + image->levels - range->baseMipLevel : range->levelCount; +} + + struct anv_image_view { const struct anv_image *image; /**< VkImageViewCreateInfo::image */ struct anv_bo *bo; |