Metal: Silence Console Output

This PR silences console output during statup phase of blender. During
startup logging isn't yet initialized and print statements where used.
Logging is initialized during the first construction of a Metal Context.

The console prints are now hidden by behind the '--debug-gpu' command
line option.

Pull Request: https://projects.blender.org/blender/blender/pulls/108593
This commit is contained in:
Jeroen Bakker
2023-06-05 09:28:19 +02:00
parent c1ac3621a9
commit 6a1aead6d1

View File

@@ -189,7 +189,9 @@ void MTLBackend::platform_init(MTLContext *ctx)
const char *vendor = [gpu_name UTF8String];
const char *renderer = "Metal API";
const char *version = "1.2";
printf("METAL API - DETECTED GPU: %s\n", vendor);
if (G.debug & G_DEBUG_GPU) {
printf("METAL API - DETECTED GPU: %s\n", vendor);
}
/* macOS is the only supported platform, but check to ensure we are not building with Metal
* enablement on another platform. */
@@ -229,7 +231,7 @@ void MTLBackend::platform_init(MTLContext *ctx)
device = GPU_DEVICE_SOFTWARE;
driver = GPU_DRIVER_SOFTWARE;
}
else {
else if (G.debug & G_DEBUG_GPU) {
printf("Warning: Could not find a matching GPU name. Things may not behave as expected.\n");
printf("Detected configuration:\n");
printf("Vendor: %s\n", vendor);
@@ -325,19 +327,21 @@ bool MTLBackend::metal_is_supported()
bool result = supports_argument_buffers_tier2 && supports_barycentrics &&
supported_os_version && supported_metal_version;
if (!supports_argument_buffers_tier2) {
printf("[Metal] Device does not support argument buffers tier 2\n");
}
if (!supports_barycentrics) {
printf("[Metal] Device does not support barycentrics coordinates\n");
}
if (!supported_metal_version) {
printf("[Metal] Device does not support metal 2.2 or higher\n");
}
if (G.debug & G_DEBUG_GPU) {
if (!supports_argument_buffers_tier2) {
printf("[Metal] Device does not support argument buffers tier 2\n");
}
if (!supports_barycentrics) {
printf("[Metal] Device does not support barycentrics coordinates\n");
}
if (!supported_metal_version) {
printf("[Metal] Device does not support metal 2.2 or higher\n");
}
if (result) {
printf("Device with name %s supports metal minimum requirements\n",
[[device name] UTF8String]);
if (result) {
printf("Device with name %s supports metal minimum requirements\n",
[[device name] UTF8String]);
}
}
return result;