[graphite] Fix creation of command buffer for different SDK/OS versions
Bug: skia:12466 Change-Id: I9828c59f0406e457e723f78940b1f42ff343fa2e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/455500 Auto-Submit: Jim Van Verth <jvanverth@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
This commit is contained in:
parent
6bc9626530
commit
4008c5a3b0
@ -10,14 +10,23 @@
|
||||
namespace skgpu::mtl {
|
||||
|
||||
std::unique_ptr<CommandBuffer> CommandBuffer::Make(id<MTLCommandQueue> queue) {
|
||||
sk_cfp<MTLCommandBufferDescriptor*> desc([[MTLCommandBufferDescriptor alloc] init]);
|
||||
(*desc).retainedReferences = NO;
|
||||
sk_cfp<id<MTLCommandBuffer>> cmdBuffer;
|
||||
#if GR_METAL_SDK_VERSION >= 230
|
||||
if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
|
||||
sk_cfp<MTLCommandBufferDescriptor*> desc([[MTLCommandBufferDescriptor alloc] init]);
|
||||
(*desc).retainedReferences = NO;
|
||||
#ifdef SK_ENABLE_MTL_DEBUG_INFO
|
||||
(*desc).errorOptions = MTLCommandBufferErrorOptionEncoderExecutionStatus;
|
||||
(*desc).errorOptions = MTLCommandBufferErrorOptionEncoderExecutionStatus;
|
||||
#endif
|
||||
// We add a retain here because the command buffer is set to autorelease (not alloc or copy)
|
||||
cmdBuffer.reset([[queue commandBufferWithDescriptor:desc.get()] retain]);
|
||||
} else {
|
||||
#endif
|
||||
// We add a retain here because the command buffer is set to autorelease (not alloc or copy)
|
||||
cmdBuffer.reset([[queue commandBufferWithUnretainedReferences] retain]);
|
||||
#if GR_METAL_SDK_VERSION >= 230
|
||||
}
|
||||
#endif
|
||||
|
||||
// We add a retain here because the command buffer is set to autorelease (not alloc or copy)
|
||||
sk_cfp<id<MTLCommandBuffer>> cmdBuffer([[queue commandBufferWithDescriptor:desc.get()] retain]);
|
||||
if (cmdBuffer == nil) {
|
||||
return nullptr;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user