97 if (rhi->backend() == QRhi::Metal) {
98 const auto *metal =
static_cast<
const QRhiMetalNativeHandles *>(rhi->nativeHandles());
101 Q_ASSERT(!cvMetalTextureCache);
102 if (CVMetalTextureCacheCreate(
105 (id<MTLDevice>)metal->dev,
107 &cvMetalTextureCache) != kCVReturnSuccess) {
108 qWarning() <<
"Metal texture cache creation failed";
111 }
else if (rhi->backend() == QRhi::OpenGLES2) {
114 const auto *gl =
static_cast<
const QRhiGles2NativeHandles *>(rhi->nativeHandles());
116 auto nsGLContext = gl->context->nativeInterface<QNativeInterface::QCocoaGLContext>()->nativeContext();
117 auto nsGLPixelFormat = nsGLContext.pixelFormat.CGLPixelFormatObj;
120 if (CVOpenGLTextureCacheCreate(
123 reinterpret_cast<CGLContextObj>(nsGLContext.CGLContextObj),
126 &cvOpenGLTextureCache)) {
127 qWarning() <<
"OpenGL texture cache creation failed";
133 if (CVOpenGLESTextureCacheCreate(
136 [EAGLContext currentContext],
138 &cvOpenGLESTextureCache)) {
139 qWarning() <<
"OpenGL texture cache creation failed";
167 if (m_outputSettings)
168 [m_outputSettings release];
169 m_outputSettings = nil;
172 NSDictionary *dictionary = nil;
173 if (m_rhi && m_rhi->backend() == QRhi::OpenGLES2) {
175 dictionary = @{(NSString *)kCVPixelBufferPixelFormatTypeKey:
176 @(kCVPixelFormatType_32BGRA)
178 , (NSString *)kCVPixelBufferOpenGLCompatibilityKey: @
true
183 dictionary = @{(NSString *)kCVPixelBufferPixelFormatTypeKey:
185 @(kCVPixelFormatType_32BGRA),
186 @(kCVPixelFormatType_32RGBA),
187 @(kCVPixelFormatType_422YpCbCr8),
188 @(kCVPixelFormatType_422YpCbCr8_yuvs),
189 @(kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange),
190 @(kCVPixelFormatType_420YpCbCr8BiPlanarFullRange),
191 @(kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange),
192 @(kCVPixelFormatType_420YpCbCr10BiPlanarFullRange),
193 @(kCVPixelFormatType_OneComponent8),
194 @(kCVPixelFormatType_OneComponent16),
195 @(kCVPixelFormatType_420YpCbCr8Planar),
196 @(kCVPixelFormatType_420YpCbCr8PlanarFullRange)
199 , (NSString *)kCVPixelBufferMetalCompatibilityKey: @
true
204 m_outputSettings = [[NSDictionary alloc] initWithDictionary:dictionary];