106 if (rhi->backend() == QRhi::Metal) {
107 const auto *metal =
static_cast<
const QRhiMetalNativeHandles *>(rhi->nativeHandles());
110 Q_ASSERT(!cvMetalTextureCache);
111 if (CVMetalTextureCacheCreate(
114 (id<MTLDevice>)metal->dev,
116 &cvMetalTextureCache) != kCVReturnSuccess) {
117 qWarning() <<
"Metal texture cache creation failed";
120 }
else if (rhi->backend() == QRhi::OpenGLES2) {
123 const auto *gl =
static_cast<
const QRhiGles2NativeHandles *>(rhi->nativeHandles());
125 auto nsGLContext = gl->context->nativeInterface<QNativeInterface::QCocoaGLContext>()->nativeContext();
126 auto nsGLPixelFormat = nsGLContext.pixelFormat.CGLPixelFormatObj;
129 if (CVOpenGLTextureCacheCreate(
132 reinterpret_cast<CGLContextObj>(nsGLContext.CGLContextObj),
135 &cvOpenGLTextureCache)) {
136 qWarning() <<
"OpenGL texture cache creation failed";
142 if (CVOpenGLESTextureCacheCreate(
145 [EAGLContext currentContext],
147 &cvOpenGLESTextureCache)) {
148 qWarning() <<
"OpenGL texture cache creation failed";
176 if (m_outputSettings)
177 [m_outputSettings release];
178 m_outputSettings = nil;
181 NSDictionary *dictionary = nil;
182 if (m_rhi && m_rhi->backend() == QRhi::OpenGLES2) {
184 dictionary = @{(NSString *)kCVPixelBufferPixelFormatTypeKey:
185 @(kCVPixelFormatType_32BGRA)
187 , (NSString *)kCVPixelBufferOpenGLCompatibilityKey: @
true
192 dictionary = @{(NSString *)kCVPixelBufferPixelFormatTypeKey:
194 @(kCVPixelFormatType_32BGRA),
195 @(kCVPixelFormatType_32RGBA),
196 @(kCVPixelFormatType_422YpCbCr8),
197 @(kCVPixelFormatType_422YpCbCr8_yuvs),
198 @(kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange),
199 @(kCVPixelFormatType_420YpCbCr8BiPlanarFullRange),
200 @(kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange),
201 @(kCVPixelFormatType_420YpCbCr10BiPlanarFullRange),
202 @(kCVPixelFormatType_OneComponent8),
203 @(kCVPixelFormatType_OneComponent16),
204 @(kCVPixelFormatType_420YpCbCr8Planar),
205 @(kCVPixelFormatType_420YpCbCr8PlanarFullRange)
208 , (NSString *)kCVPixelBufferMetalCompatibilityKey: @
true
213 m_outputSettings = [[NSDictionary alloc] initWithDictionary:dictionary];