[Bf-blender-cvs] [f1521591017] master: Metal: Guard advanced command buffer debugging behind OS version flag.
Jason Fielder
noreply at git.blender.org
Tue Feb 7 00:57:36 CET 2023
Commit: f1521591017faac334ff78c291ad66bdaf327661
Author: Jason Fielder
Date: Tue Feb 7 00:51:06 2023 +0100
Branches: master
https://developer.blender.org/rBf1521591017faac334ff78c291ad66bdaf327661
Metal: Guard advanced command buffer debugging behind OS version flag.
Authored by Apple: Michael Parkin-White
Ref T96261
Reviewed By: fclem
Maniphest Tasks: T96261
Differential Revision: https://developer.blender.org/D17181
===================================================================
M source/blender/gpu/metal/mtl_command_buffer.mm
===================================================================
diff --git a/source/blender/gpu/metal/mtl_command_buffer.mm b/source/blender/gpu/metal/mtl_command_buffer.mm
index 61b8edda93e..8d295bb0c05 100644
--- a/source/blender/gpu/metal/mtl_command_buffer.mm
+++ b/source/blender/gpu/metal/mtl_command_buffer.mm
@@ -57,17 +57,22 @@ id<MTLCommandBuffer> MTLCommandBufferManager::ensure_begin()
BLI_assert(MTLCommandBufferManager::num_active_cmd_bufs <
GHOST_ContextCGL::max_command_buffer_count);
- if (G.debug & G_DEBUG_GPU) {
- /* Debug: Enable Advanced Errors for GPU work execution. */
- MTLCommandBufferDescriptor *desc = [[MTLCommandBufferDescriptor alloc] init];
- desc.errorOptions = MTLCommandBufferErrorOptionEncoderExecutionStatus;
- desc.retainedReferences = YES;
- BLI_assert(context_.queue != nil);
- active_command_buffer_ = [context_.queue commandBufferWithDescriptor:desc];
+ if (@available(macos 11.0, *)) {
+ if (G.debug & G_DEBUG_GPU) {
+ /* Debug: Enable Advanced Errors for GPU work execution. */
+ MTLCommandBufferDescriptor *desc = [[MTLCommandBufferDescriptor alloc] init];
+ desc.errorOptions = MTLCommandBufferErrorOptionEncoderExecutionStatus;
+ desc.retainedReferences = YES;
+ BLI_assert(context_.queue != nil);
+ active_command_buffer_ = [context_.queue commandBufferWithDescriptor:desc];
+ }
}
- else {
+
+ /* Ensure command buffer is created if debug command buffer unavailable. */
+ if (active_command_buffer_ == nil) {
active_command_buffer_ = [context_.queue commandBuffer];
}
+
[active_command_buffer_ retain];
MTLCommandBufferManager::num_active_cmd_bufs++;
@@ -164,20 +169,22 @@ bool MTLCommandBufferManager::submit(bool wait)
/* Command buffer execution debugging can return an error message if
* execution has failed or encountered GPU-side errors. */
- if (G.debug & G_DEBUG_GPU) {
+ if (@available(macos 11.0, *)) {
+ if (G.debug & G_DEBUG_GPU) {
- NSError *error = [active_command_buffer_ error];
- if (error != nil) {
- NSLog(@"%@", error);
- BLI_assert(false);
+ NSError *error = [active_command_buffer_ error];
+ if (error != nil) {
+ NSLog(@"%@", error);
+ BLI_assert(false);
- @autoreleasepool {
- const char *stringAsChar = [[NSString stringWithFormat:@"%@", error] UTF8String];
+ @autoreleasepool {
+ const char *stringAsChar = [[NSString stringWithFormat:@"%@", error] UTF8String];
- std::ofstream outfile;
- outfile.open("command_buffer_error.txt", std::fstream::out | std::fstream::app);
- outfile << stringAsChar;
- outfile.close();
+ std::ofstream outfile;
+ outfile.open("command_buffer_error.txt", std::fstream::out | std::fstream::app);
+ outfile << stringAsChar;
+ outfile.close();
+ }
}
}
}
More information about the Bf-blender-cvs
mailing list