Increase maxStorageBufferRange to MAX_MEMORY_ALLOCATION_SIZE (1 GiB)
Bug: b/201061610
Change-Id: Iecfa37754cf06f86ed0923049ec87fa0e1c77580
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/57448
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/Pipeline/SpirvShaderImage.cpp b/src/Pipeline/SpirvShaderImage.cpp
index 245d110..d195ac0 100644
--- a/src/Pipeline/SpirvShaderImage.cpp
+++ b/src/Pipeline/SpirvShaderImage.cpp
@@ -598,7 +598,7 @@
}
constexpr int32_t OOB_OFFSET = 0x7FFFFFFF - 16; // SIMD pointer offsets are signed 32-bit, so this is the largest offset (for 16-byte texels).
- static_assert(OOB_OFFSET >= MAX_MEMORY_ALLOCATION_SIZE, "the largest offset must be guaranteed to be out-of-bounds");
+ static_assert(OOB_OFFSET >= vk::MAX_MEMORY_ALLOCATION_SIZE, "the largest offset must be guaranteed to be out-of-bounds");
ptrOffset = (ptrOffset & ~oobMask) | (oobMask & SIMD::Int(OOB_OFFSET)); // oob ? OOB_OFFSET : ptrOffset // TODO: IfThenElse()
}
diff --git a/src/Vulkan/VkConfig.hpp b/src/Vulkan/VkConfig.hpp
index 9317549..43dae96 100644
--- a/src/Vulkan/VkConfig.hpp
+++ b/src/Vulkan/VkConfig.hpp
@@ -86,6 +86,12 @@
constexpr float SUBPIXEL_PRECISION_FACTOR = static_cast<float>(1 << SUBPIXEL_PRECISION_BITS);
constexpr int SUBPIXEL_PRECISION_MASK = 0xFFFFFFFF >> (32 - SUBPIXEL_PRECISION_BITS);
+constexpr VkDeviceSize MAX_MEMORY_ALLOCATION_SIZE = 0x40000000ull; // 0x40000000 = 1 GiB
+
+// Memory offset calculations in 32-bit SIMD elements limit us to addressing at most 4 GiB.
+// Signed arithmetic further restricts it to 2 GiB.
+static_assert(MAX_MEMORY_ALLOCATION_SIZE <= 0x80000000ull, "maxMemoryAllocationSize must not exceed 2 GiB");
+
} // namespace vk
#if defined(__linux__) && !defined(__ANDROID__)
@@ -98,10 +104,4 @@
# define SWIFTSHADER_EXTERNAL_MEMORY_OPAQUE_FD 1
#endif
-constexpr VkDeviceSize MAX_MEMORY_ALLOCATION_SIZE = 0x40000000ull; // 0x40000000 = 1 GiB
-
-// Memory offset calculations in 32-bit SIMD elements limit us to addressing at most 4 GiB.
-// Signed arithmetic further restricts it to 2 GiB.
-static_assert(MAX_MEMORY_ALLOCATION_SIZE <= 0x80000000ull, "maxMemoryAllocationSize must not exceed 2 GiB");
-
#endif // VK_CONFIG_HPP_
diff --git a/src/Vulkan/VkPhysicalDevice.cpp b/src/Vulkan/VkPhysicalDevice.cpp
index 88891fe..4751cf2 100644
--- a/src/Vulkan/VkPhysicalDevice.cpp
+++ b/src/Vulkan/VkPhysicalDevice.cpp
@@ -449,7 +449,7 @@
vk::MAX_IMAGE_ARRAY_LAYERS, // maxImageArrayLayers
65536, // maxTexelBufferElements
16384, // maxUniformBufferRange
- (1ul << 27), // maxStorageBufferRange
+ vk::MAX_MEMORY_ALLOCATION_SIZE, // maxStorageBufferRange
vk::MAX_PUSH_CONSTANT_SIZE, // maxPushConstantsSize
4096, // maxMemoryAllocationCount
vk::MAX_SAMPLER_ALLOCATION_COUNT, // maxSamplerAllocationCount