Merge branch 'blender-v3.6-release'
This commit is contained in:
commit
5a44922937
|
@ -345,7 +345,9 @@ string MetalDevice::preprocess_source(MetalPipelineType pso_type,
|
||||||
case METAL_GPU_APPLE:
|
case METAL_GPU_APPLE:
|
||||||
global_defines += "#define __KERNEL_METAL_APPLE__\n";
|
global_defines += "#define __KERNEL_METAL_APPLE__\n";
|
||||||
# ifdef WITH_NANOVDB
|
# ifdef WITH_NANOVDB
|
||||||
global_defines += "#define WITH_NANOVDB\n";
|
if (DebugFlags().metal.use_nanovdb) {
|
||||||
|
global_defines += "#define WITH_NANOVDB\n";
|
||||||
|
}
|
||||||
# endif
|
# endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -681,7 +681,7 @@ void MetalKernelPipeline::compile()
|
||||||
__block bool compilation_finished = false;
|
__block bool compilation_finished = false;
|
||||||
__block string error_str;
|
__block string error_str;
|
||||||
|
|
||||||
if (loading_existing_archive) {
|
if (loading_existing_archive || !DebugFlags().metal.use_async_pso_creation) {
|
||||||
/* Use the blocking variant of newComputePipelineStateWithDescriptor if an archive exists on
|
/* Use the blocking variant of newComputePipelineStateWithDescriptor if an archive exists on
|
||||||
* disk. It should load almost instantaneously, and will fail gracefully when loading a
|
* disk. It should load almost instantaneously, and will fail gracefully when loading a
|
||||||
* corrupt archive (unlike the async variant). */
|
* corrupt archive (unlike the async variant). */
|
||||||
|
@ -694,29 +694,6 @@ void MetalKernelPipeline::compile()
|
||||||
error_str = err ? err : "nil";
|
error_str = err ? err : "nil";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* TODO / MetalRT workaround:
|
|
||||||
* Workaround for a crash when addComputePipelineFunctionsWithDescriptor is called *after*
|
|
||||||
* newComputePipelineStateWithDescriptor with linked functions (i.e. with MetalRT enabled).
|
|
||||||
* Ideally we would like to call newComputePipelineStateWithDescriptor (async) first so we
|
|
||||||
* can bail out if needed, but we can stop the crash by flipping the order when there are
|
|
||||||
* linked functions. However when addComputePipelineFunctionsWithDescriptor is called first
|
|
||||||
* it will block while it builds the pipeline, offering no way of bailing out. */
|
|
||||||
auto addComputePipelineFunctionsWithDescriptor = [&]() {
|
|
||||||
if (creating_new_archive && ShaderCache::running) {
|
|
||||||
NSError *error;
|
|
||||||
if (![archive addComputePipelineFunctionsWithDescriptor:computePipelineStateDescriptor
|
|
||||||
error:&error])
|
|
||||||
{
|
|
||||||
NSString *errStr = [error localizedDescription];
|
|
||||||
metal_printf("Failed to add PSO to archive:\n%s\n",
|
|
||||||
errStr ? [errStr UTF8String] : "nil");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if (linked_functions) {
|
|
||||||
addComputePipelineFunctionsWithDescriptor();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Use the async variant of newComputePipelineStateWithDescriptor if no archive exists on
|
/* Use the async variant of newComputePipelineStateWithDescriptor if no archive exists on
|
||||||
* disk. This allows us to respond to app shutdown. */
|
* disk. This allows us to respond to app shutdown. */
|
||||||
[mtlDevice
|
[mtlDevice
|
||||||
|
@ -744,10 +721,16 @@ void MetalKernelPipeline::compile()
|
||||||
while (ShaderCache::running && !compilation_finished) {
|
while (ShaderCache::running && !compilation_finished) {
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Add pipeline into the new archive (unless we did it earlier). */
|
if (creating_new_archive && pipeline) {
|
||||||
if (pipeline && !linked_functions) {
|
/* Add pipeline into the new archive. */
|
||||||
addComputePipelineFunctionsWithDescriptor();
|
NSError *error;
|
||||||
|
if (![archive addComputePipelineFunctionsWithDescriptor:computePipelineStateDescriptor
|
||||||
|
error:&error])
|
||||||
|
{
|
||||||
|
NSString *errStr = [error localizedDescription];
|
||||||
|
metal_printf("Failed to add PSO to archive:\n%s\n", errStr ? [errStr UTF8String] : "nil");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,12 @@ void DebugFlags::Metal::reset()
|
||||||
|
|
||||||
if (auto str = getenv("CYCLES_METAL_LOCAL_ATOMIC_SORT"))
|
if (auto str = getenv("CYCLES_METAL_LOCAL_ATOMIC_SORT"))
|
||||||
use_local_atomic_sort = (atoi(str) != 0);
|
use_local_atomic_sort = (atoi(str) != 0);
|
||||||
|
|
||||||
|
if (auto str = getenv("CYCLES_METAL_NANOVDB"))
|
||||||
|
use_nanovdb = (atoi(str) != 0);
|
||||||
|
|
||||||
|
if (auto str = getenv("CYCLES_METAL_ASYNC_PSO_CREATION"))
|
||||||
|
use_async_pso_creation = (atoi(str) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugFlags::OptiX::OptiX()
|
DebugFlags::OptiX::OptiX()
|
||||||
|
|
|
@ -100,6 +100,12 @@ class DebugFlags {
|
||||||
|
|
||||||
/* Whether local atomic sorting is enabled or not. */
|
/* Whether local atomic sorting is enabled or not. */
|
||||||
bool use_local_atomic_sort = true;
|
bool use_local_atomic_sort = true;
|
||||||
|
|
||||||
|
/* Whether nanovdb is enabled or not. */
|
||||||
|
bool use_nanovdb = true;
|
||||||
|
|
||||||
|
/* Whether async PSO creation is enabled or not. */
|
||||||
|
bool use_async_pso_creation = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Get instance of debug flags registry. */
|
/* Get instance of debug flags registry. */
|
||||||
|
|
Loading…
Reference in New Issue