Fix invalid attributes passed to CVMetalTextureCache

This commit is contained in:
Cameron Gutman committed 2026-11-15 00:30:52 -06:00
1 parent bbfcf53f85
commit 2d600c4e6b
2 files changed
+25 -10

No files matched your search

@@ -38,11 +38,19 @@ MetalVulkanTextureFactory::MetalVulkanTextureFactory(pl_vulkan vulkan) :
return;
}
CFStringRef keys[1] = { kCVMetalTextureUsage };
NSUInteger values[1] = { MTLTextureUsageShaderRead };
auto cacheAttributes = CFDictionaryCreate(kCFAllocatorDefault, (const void**)keys, (const void**)values, 1, nullptr, nullptr);
int err = CVMetalTextureCacheCreate(kCFAllocatorDefault, cacheAttributes, device, nullptr, (CVMetalTextureCacheRef*)&m_TextureCache);
CFRelease(cacheAttributes);
// Create the Metal texture cache for our CVPixelBuffers
NSDictionary *textureAttributes = @{
// NB: kCVMetalTextureUsage is documented as if it's a key used in the
// cacheAttributes dictionary, but it is actually for textureAttributes
// (as confirmed by Metal Validation failures for incorrect usages).
(__bridge NSString *)kCVMetalTextureUsage: @(MTLTextureUsageShaderRead)
};
int err = CVMetalTextureCacheCreate(kCFAllocatorDefault,
nullptr,
device,
(__bridge CFDictionaryRef)textureAttributes,
(CVMetalTextureCacheRef*)&m_TextureCache);
if (err != kCVReturnSuccess) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
@@ -692,11 +692,18 @@ public:
}
// Create the Metal texture cache for our CVPixelBuffers
CFStringRef keys[1] = { kCVMetalTextureUsage };
NSUInteger values[1] = { MTLTextureUsageShaderRead };
auto cacheAttributes = CFDictionaryCreate(kCFAllocatorDefault, (const void**)keys, (const void**)values, 1, nullptr, nullptr);
err = CVMetalTextureCacheCreate(kCFAllocatorDefault, cacheAttributes, device, nullptr, &m_TextureCache);
CFRelease(cacheAttributes);
NSDictionary *textureAttributes = @{
// NB: kCVMetalTextureUsage is documented as if it's a key used in the
// cacheAttributes dictionary, but it is actually for textureAttributes
// (as confirmed by Metal Validation failures for incorrect usages).
(__bridge NSString *)kCVMetalTextureUsage: @(MTLTextureUsageShaderRead)
};
err = CVMetalTextureCacheCreate(kCFAllocatorDefault,
nullptr,
device,
(__bridge CFDictionaryRef)textureAttributes,
&m_TextureCache);
if (err != kCVReturnSuccess) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,