96 if (rhi->backend() == QRhi::Metal) {
97 const auto *metal =
static_cast<
const QRhiMetalNativeHandles *>(rhi->nativeHandles());
100 Q_ASSERT(!cvMetalTextureCache);
101 if (CVMetalTextureCacheCreate(
104 (id<MTLDevice>)metal->dev,
106 &cvMetalTextureCache) != kCVReturnSuccess) {
107 qWarning() <<
"Metal texture cache creation failed";
110 }
else if (rhi->backend() == QRhi::OpenGLES2) {
113 const auto *gl =
static_cast<
const QRhiGles2NativeHandles *>(rhi->nativeHandles());
115 auto nsGLContext = gl->context->nativeInterface<QNativeInterface::QCocoaGLContext>()->nativeContext();
116 auto nsGLPixelFormat = nsGLContext.pixelFormat.CGLPixelFormatObj;
119 if (CVOpenGLTextureCacheCreate(
122 reinterpret_cast<CGLContextObj>(nsGLContext.CGLContextObj),
125 &cvOpenGLTextureCache)) {
126 qWarning() <<
"OpenGL texture cache creation failed";
132 if (CVOpenGLESTextureCacheCreate(
135 [EAGLContext currentContext],
137 &cvOpenGLESTextureCache)) {
138 qWarning() <<
"OpenGL texture cache creation failed";
166 if (m_outputSettings)
167 [m_outputSettings release];
168 m_outputSettings = nil;
171 NSDictionary *dictionary = nil;
172 if (m_rhi && m_rhi->backend() == QRhi::OpenGLES2) {
174 dictionary = @{(NSString *)kCVPixelBufferPixelFormatTypeKey:
175 @(kCVPixelFormatType_32BGRA)
177 , (NSString *)kCVPixelBufferOpenGLCompatibilityKey: @
true
182 dictionary = @{(NSString *)kCVPixelBufferPixelFormatTypeKey:
184 @(kCVPixelFormatType_32BGRA),
185 @(kCVPixelFormatType_32RGBA),
186 @(kCVPixelFormatType_422YpCbCr8),
187 @(kCVPixelFormatType_422YpCbCr8_yuvs),
188 @(kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange),
189 @(kCVPixelFormatType_420YpCbCr8BiPlanarFullRange),
190 @(kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange),
191 @(kCVPixelFormatType_420YpCbCr10BiPlanarFullRange),
192 @(kCVPixelFormatType_OneComponent8),
193 @(kCVPixelFormatType_OneComponent16),
194 @(kCVPixelFormatType_420YpCbCr8Planar),
195 @(kCVPixelFormatType_420YpCbCr8PlanarFullRange)
198 , (NSString *)kCVPixelBufferMetalCompatibilityKey: @
true
203 m_outputSettings = [[NSDictionary alloc] initWithDictionary:dictionary];