100 if (rhi->backend() == QRhi::Metal) {
101 const auto *metal =
static_cast<
const QRhiMetalNativeHandles *>(rhi->nativeHandles());
104 Q_ASSERT(!cvMetalTextureCache);
105 if (CVMetalTextureCacheCreate(
108 (id<MTLDevice>)metal->dev,
110 &cvMetalTextureCache) != kCVReturnSuccess) {
111 qWarning() <<
"Metal texture cache creation failed";
114 }
else if (rhi->backend() == QRhi::OpenGLES2) {
117 const auto *gl =
static_cast<
const QRhiGles2NativeHandles *>(rhi->nativeHandles());
119 auto nsGLContext = gl->context->nativeInterface<QNativeInterface::QCocoaGLContext>()->nativeContext();
120 auto nsGLPixelFormat = nsGLContext.pixelFormat.CGLPixelFormatObj;
123 if (CVOpenGLTextureCacheCreate(
126 reinterpret_cast<CGLContextObj>(nsGLContext.CGLContextObj),
129 &cvOpenGLTextureCache)) {
130 qWarning() <<
"OpenGL texture cache creation failed";
136 if (CVOpenGLESTextureCacheCreate(
139 [EAGLContext currentContext],
141 &cvOpenGLESTextureCache)) {
142 qWarning() <<
"OpenGL texture cache creation failed";
170 if (m_outputSettings)
171 [m_outputSettings release];
172 m_outputSettings = nil;
175 NSDictionary *dictionary = nil;
176 if (m_rhi && m_rhi->backend() == QRhi::OpenGLES2) {
178 dictionary = @{(NSString *)kCVPixelBufferPixelFormatTypeKey:
179 @(kCVPixelFormatType_32BGRA)
181 , (NSString *)kCVPixelBufferOpenGLCompatibilityKey: @
true
186 dictionary = @{(NSString *)kCVPixelBufferPixelFormatTypeKey:
188 @(kCVPixelFormatType_32BGRA),
189 @(kCVPixelFormatType_32RGBA),
190 @(kCVPixelFormatType_422YpCbCr8),
191 @(kCVPixelFormatType_422YpCbCr8_yuvs),
192 @(kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange),
193 @(kCVPixelFormatType_420YpCbCr8BiPlanarFullRange),
194 @(kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange),
195 @(kCVPixelFormatType_420YpCbCr10BiPlanarFullRange),
196 @(kCVPixelFormatType_OneComponent8),
197 @(kCVPixelFormatType_OneComponent16),
198 @(kCVPixelFormatType_420YpCbCr8Planar),
199 @(kCVPixelFormatType_420YpCbCr8PlanarFullRange)
202 , (NSString *)kCVPixelBufferMetalCompatibilityKey: @
true
207 m_outputSettings = [[NSDictionary alloc] initWithDictionary:dictionary];