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