Skip to content

Commit

Permalink
layers: Fix ImageRangeGenerator depth sliced check
Browse files Browse the repository at this point in the history
  • Loading branch information
aitor-lunarg committed Jun 9, 2022
1 parent b5ff36f commit 9ea67a7
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 65 deletions.
37 changes: 19 additions & 18 deletions layers/subresource_adapter.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Copyright (c) 2019-2021 The Khronos Group Inc.
* Copyright (c) 2019-2021 Valve Corporation
* Copyright (c) 2019-2021 LunarG, Inc.
* Copyright (C) 2019-2021 Google Inc.
/* Copyright (c) 2019-2022 The Khronos Group Inc.
* Copyright (c) 2019-2022 Valve Corporation
* Copyright (c) 2019-2022 LunarG, Inc.
* Copyright (C) 2019-2022 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -498,26 +498,25 @@ void ImageRangeGenerator::SetInitialPosAllSubres(uint32_t layer, uint32_t aspect
}

bool ImageRangeGenerator::Convert2DCompatibleTo3D() {
if (encoder_->Is3D()) {
if ((subres_range_.levelCount == 1) && ((subres_range_.baseArrayLayer > 0) || (subres_range_.layerCount > 1))) {
// This only valid for 2D compatible 3D images
// Touch up the extent and the subres to make this look like a depth extent
offset_.z = subres_range_.baseArrayLayer;
subres_range_.baseArrayLayer = 0;
extent_.depth = subres_range_.layerCount;
subres_range_.layerCount = 1;
return true;
}
if (encoder_->Is3D() && is_depth_sliced_) {
// This only valid for 2D compatible 3D images
// Touch up the extent and the subres to make this look like a depth extent
offset_.z = subres_range_.baseArrayLayer;
subres_range_.baseArrayLayer = 0;
extent_.depth = subres_range_.layerCount;
subres_range_.layerCount = 1;
return true;
}
return false;
}
ImageRangeGenerator::ImageRangeGenerator(const ImageRangeEncoder& encoder, const VkImageSubresourceRange& subres_range,
VkDeviceSize base_address)
VkDeviceSize base_address, bool is_depth_sliced)
: encoder_(&encoder),
subres_range_(GetRemaining(encoder.FullRange(), subres_range)),
offset_(),
extent_(),
base_address_(base_address) {
base_address_(base_address),
is_depth_sliced_(is_depth_sliced) {
#ifndef NDEBUG
assert(IsValid(*encoder_, subres_range_));
#endif
Expand All @@ -541,12 +540,14 @@ ImageRangeGenerator::ImageRangeGenerator(const ImageRangeEncoder& encoder, const
}

ImageRangeGenerator::ImageRangeGenerator(const ImageRangeEncoder& encoder, const VkImageSubresourceRange& subres_range,
const VkOffset3D& offset, const VkExtent3D& extent, VkDeviceSize base_address)
const VkOffset3D& offset, const VkExtent3D& extent, VkDeviceSize base_address,
bool is_depth_sliced)
: encoder_(&encoder),
subres_range_(GetRemaining(encoder.FullRange(), subres_range)),
offset_(offset),
extent_(extent),
base_address_(base_address) {
base_address_(base_address),
is_depth_sliced_(is_depth_sliced) {
#ifndef NDEBUG
assert(IsValid(*encoder_, subres_range_));
#endif
Expand Down
8 changes: 5 additions & 3 deletions layers/subresource_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ class ImageRangeGenerator {
ImageRangeGenerator() : encoder_(nullptr), subres_range_(), offset_(), extent_(), base_address_(), pos_() {}
bool operator!=(const ImageRangeGenerator& rhs) { return (pos_ != rhs.pos_) || (&encoder_ != &rhs.encoder_); }
ImageRangeGenerator(const ImageRangeEncoder& encoder, const VkImageSubresourceRange& subres_range, const VkOffset3D& offset,
const VkExtent3D& extent, VkDeviceSize base_address);
const VkExtent3D& extent, VkDeviceSize base_address, bool is_depth_sliced);
void SetInitialPosFullOffset(uint32_t layer, uint32_t aspect_index);
void SetInitialPosFullWidth(uint32_t layer, uint32_t aspect_index);
void SetInitialPosFullHeight(uint32_t layer, uint32_t aspect_index);
Expand All @@ -413,7 +413,8 @@ class ImageRangeGenerator {
void SetInitialPosOneAspect(uint32_t layer, uint32_t aspect_index);
void SetInitialPosAllSubres(uint32_t layer, uint32_t aspect_index);
void SetInitialPosSomeLayers(uint32_t layer, uint32_t aspect_index);
ImageRangeGenerator(const ImageRangeEncoder& encoder, const VkImageSubresourceRange& subres_range, VkDeviceSize base_address);
ImageRangeGenerator(const ImageRangeEncoder& encoder, const VkImageSubresourceRange& subres_range, VkDeviceSize base_address,
bool is_depth_sliced);
inline const IndexRange& operator*() const { return pos_; }
inline const IndexRange* operator->() const { return &pos_; }
ImageRangeGenerator& operator++();
Expand All @@ -435,7 +436,6 @@ class ImageRangeGenerator {

uint32_t mip_index_;
uint32_t incr_mip_;
bool single_full_size_range_;
uint32_t aspect_index_;
uint32_t subres_index_;
const ImageRangeEncoder::SubresInfo* subres_info_;
Expand All @@ -460,6 +460,8 @@ class ImageRangeGenerator {
void Set(uint32_t y_count_, uint32_t layer_z_count_, IndexType base, IndexType span, IndexType y_step, IndexType z_step);
};
IncrementerState incr_state_;
bool single_full_size_range_;
bool is_depth_sliced_ = false;
};

// Designed for use with RangeMap of MappedType
Expand Down
Loading

0 comments on commit 9ea67a7

Please sign in to comment.