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
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;
}
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),
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) {
};
};
+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;