92 if (rhi->backend() == QRhi::Metal) {
93 const auto *metal =
static_cast<
const QRhiMetalNativeHandles *>(rhi->nativeHandles());
96 Q_ASSERT(!cvMetalTextureCache);
97 if (CVMetalTextureCacheCreate(
100 (id<MTLDevice>)metal->dev,
102 &cvMetalTextureCache) != kCVReturnSuccess) {
103 qWarning() <<
"Metal texture cache creation failed";
106 }
else if (rhi->backend() == QRhi::OpenGLES2) {
109 const auto *gl =
static_cast<
const QRhiGles2NativeHandles *>(rhi->nativeHandles());
111 auto nsGLContext = gl->context->nativeInterface<QNativeInterface::QCocoaGLContext>()->nativeContext();
112 auto nsGLPixelFormat = nsGLContext.pixelFormat.CGLPixelFormatObj;
115 if (CVOpenGLTextureCacheCreate(
118 reinterpret_cast<CGLContextObj>(nsGLContext.CGLContextObj),
121 &cvOpenGLTextureCache)) {
122 qWarning() <<
"OpenGL texture cache creation failed";
128 if (CVOpenGLESTextureCacheCreate(
131 [EAGLContext currentContext],
133 &cvOpenGLESTextureCache)) {
134 qWarning() <<
"OpenGL texture cache creation failed";
162 if (m_outputSettings)
163 [m_outputSettings release];
164 m_outputSettings = nil;
167 NSDictionary *dictionary = nil;
168 if (m_rhi && m_rhi->backend() == QRhi::OpenGLES2) {
170 dictionary = @{(NSString *)kCVPixelBufferPixelFormatTypeKey:
171 @(kCVPixelFormatType_32BGRA)
173 , (NSString *)kCVPixelBufferOpenGLCompatibilityKey: @
true
178 dictionary = @{(NSString *)kCVPixelBufferPixelFormatTypeKey:
180 @(kCVPixelFormatType_32BGRA),
181 @(kCVPixelFormatType_32RGBA),
182 @(kCVPixelFormatType_422YpCbCr8),
183 @(kCVPixelFormatType_422YpCbCr8_yuvs),
184 @(kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange),
185 @(kCVPixelFormatType_420YpCbCr8BiPlanarFullRange),
186 @(kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange),
187 @(kCVPixelFormatType_420YpCbCr10BiPlanarFullRange),
188 @(kCVPixelFormatType_OneComponent8),
189 @(kCVPixelFormatType_OneComponent16),
190 @(kCVPixelFormatType_420YpCbCr8Planar),
191 @(kCVPixelFormatType_420YpCbCr8PlanarFullRange)
194 , (NSString *)kCVPixelBufferMetalCompatibilityKey: @
true
199 m_outputSettings = [[NSDictionary alloc] initWithDictionary:dictionary];