Set value of VkPhysicalDeviceLimits::maxTexelBufferElements to more realistic value.
diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKBuffer.mm b/MoltenVK/MoltenVK/GPUObjects/MVKBuffer.mm
index b2d18e3..15ba867 100644
--- a/MoltenVK/MoltenVK/GPUObjects/MVKBuffer.mm
+++ b/MoltenVK/MoltenVK/GPUObjects/MVKBuffer.mm
@@ -175,7 +175,7 @@
#pragma mark Metal
id<MTLTexture> MVKBufferView::getMTLTexture() {
- if ( !_mtlTexture && _mtlPixelFormat && _device->_pMetalFeatures->texelBuffers) {
+ if ( !_mtlTexture && _mtlPixelFormat && _device->_pMetalFeatures->texelBuffers) {
// Lock and check again in case another thread has created the texture.
lock_guard<mutex> lock(_lock);
@@ -201,9 +201,9 @@
mtlTexDesc.cpuCacheMode = mtlBuff.cpuCacheMode;
mtlTexDesc.usage = usage;
}
- _mtlTexture = [_buffer->getMTLBuffer() newTextureWithDescriptor: mtlTexDesc
- offset: _mtlBufferOffset
- bytesPerRow: _mtlBytesPerRow];
+ _mtlTexture = [mtlBuff newTextureWithDescriptor: mtlTexDesc
+ offset: _mtlBufferOffset
+ bytesPerRow: _mtlBytesPerRow];
propogateDebugName();
}
return _mtlTexture;
diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
index b116ae6..41a279e 100644
--- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
+++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
@@ -1197,11 +1197,9 @@
_properties.limits.maxDescriptorSetStorageImages = (_properties.limits.maxPerStageDescriptorStorageImages * 4);
_properties.limits.maxDescriptorSetInputAttachments = (_properties.limits.maxPerStageDescriptorInputAttachments * 4);
- if (_metalFeatures.textureBuffers) {
- _properties.limits.maxTexelBufferElements = (uint32_t)_metalFeatures.maxMTLBufferSize;
- } else {
- _properties.limits.maxTexelBufferElements = _properties.limits.maxImageDimension2D * _properties.limits.maxImageDimension2D;
- }
+ // Whether handled as a real texture buffer or a 2D texture, this value is likely nowhere near the size of a buffer,
+ // needs to fit in 32 bits, and some apps (I'm looking at you, CTS), assume it is low when doing 32-bit math.
+ _properties.limits.maxTexelBufferElements = _properties.limits.maxImageDimension2D * (4 * KIBI);
#if MVK_MACOS
_properties.limits.maxUniformBufferRange = (64 * KIBI);
#endif