Commit 22fbf8fc by Nicolas Capens Committed by Nicolas Capens

Resolve remaining levels/layers at VkImageView creation time

Bug: b/119620767 Test: dEQP-VK.pipeline.image_view.view_type.1d.format.r8g8b8a8_unorm.subresource_range.lod_base_mip_level_remaining_levels Change-Id: I977598ee0513928e6a6ce6ba5d0b698653c74fdc Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/29968 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com>
parent 548e366a
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#include "Types.hpp" #include "Types.hpp"
#include "Half.hpp" #include "Half.hpp"
#include "Vulkan/VkDebug.hpp"
#include <cmath> #include <cmath>
#if defined(_MSC_VER) #if defined(_MSC_VER)
#include <intrin.h> #include <intrin.h>
...@@ -177,6 +179,7 @@ namespace sw ...@@ -177,6 +179,7 @@ namespace sw
template<class T> template<class T>
inline T clamp(T x, T a, T b) inline T clamp(T x, T a, T b)
{ {
ASSERT(a <= b);
if(x < a) x = a; if(x < a) x = a;
if(x > b) x = b; if(x > b) x = b;
......
...@@ -26,6 +26,17 @@ namespace ...@@ -26,6 +26,17 @@ namespace
(m.a == VK_COMPONENT_SWIZZLE_IDENTITY) ? VK_COMPONENT_SWIZZLE_A : m.a, (m.a == VK_COMPONENT_SWIZZLE_IDENTITY) ? VK_COMPONENT_SWIZZLE_A : m.a,
}; };
} }
VkImageSubresourceRange ResolveRemainingLevelsLayers(VkImageSubresourceRange range, const vk::Image *image)
{
return {
range.aspectMask,
range.baseMipLevel,
(range.levelCount == VK_REMAINING_MIP_LEVELS) ? (image->getMipLevels() - range.baseMipLevel) : range.levelCount,
range.baseArrayLayer,
(range.layerCount == VK_REMAINING_ARRAY_LAYERS) ? (image->getArrayLayers() - range.baseArrayLayer) : range.layerCount,
};
}
} }
namespace vk namespace vk
...@@ -33,7 +44,8 @@ namespace vk ...@@ -33,7 +44,8 @@ namespace vk
ImageView::ImageView(const VkImageViewCreateInfo* pCreateInfo, void* mem) : ImageView::ImageView(const VkImageViewCreateInfo* pCreateInfo, void* mem) :
image(Cast(pCreateInfo->image)), viewType(pCreateInfo->viewType), format(pCreateInfo->format), image(Cast(pCreateInfo->image)), viewType(pCreateInfo->viewType), format(pCreateInfo->format),
components(ResolveIdentityMapping(pCreateInfo->components)), subresourceRange(pCreateInfo->subresourceRange) components(ResolveIdentityMapping(pCreateInfo->components)),
subresourceRange(ResolveRemainingLevelsLayers(pCreateInfo->subresourceRange, image))
{ {
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment