diff --git a/source/blender/gpu/GPU_shader.hh b/source/blender/gpu/GPU_shader.hh index 8f51c3d73d7..d0c41cc58b7 100644 --- a/source/blender/gpu/GPU_shader.hh +++ b/source/blender/gpu/GPU_shader.hh @@ -75,7 +75,7 @@ using BatchHandle = int64_t; * Request the creation of multiple shaders at once, allowing the backend to use multithreaded * compilation. Returns a handle that can be used to poll if all shaders have been compiled, and to * retrieve the compiled shaders. - * NOTE: This function is asynchronous on OpenGL, but it's blocking on Vulkan and Metal. + * NOTE: This function is asynchronous on OpenGL, but it's blocking on Vulkan. * WARNING: The GPUShaderCreateInfo pointers should be valid until `GPU_shader_batch_finalize` has * returned. */ diff --git a/source/blender/gpu/intern/gpu_shader_create_info.cc b/source/blender/gpu/intern/gpu_shader_create_info.cc index 2762a39a9cd..e2453c434f3 100644 --- a/source/blender/gpu/intern/gpu_shader_create_info.cc +++ b/source/blender/gpu/intern/gpu_shader_create_info.cc @@ -607,11 +607,15 @@ void gpu_shader_create_info_exit() bool gpu_shader_create_info_compile(const char *name_starts_with_filter) { + using namespace blender; using namespace blender::gpu; int success = 0; int skipped_filter = 0; int skipped = 0; int total = 0; + + Vector infos; + for (ShaderCreateInfo *info : g_create_infos->values()) { info->finalize(); if (info->do_static_compilation_) { @@ -629,14 +633,29 @@ bool gpu_shader_create_info_compile(const char *name_starts_with_filter) continue; } total++; - GPUShader *shader = GPU_shader_create_from_info( - reinterpret_cast(info)); - if (shader == nullptr) { - std::cerr << "Compilation " << info->name_.c_str() << " Failed\n"; - } - else { - success++; + infos.append(reinterpret_cast(info)); + } + } + + Vector result; + if (GPU_use_parallel_compilation() == false) { + for (const GPUShaderCreateInfo *info : infos) { + result.append(GPU_shader_create_from_info(info)); + } + } + else { + BatchHandle batch = GPU_shader_batch_create_from_infos(infos); + result = GPU_shader_batch_finalize(batch); + } + + for (int i : result.index_range()) { + const ShaderCreateInfo *info = reinterpret_cast(infos[i]); + if (result[i] == nullptr) { + std::cerr << "Compilation " << info->name_.c_str() << " Failed\n"; + } + else { + success++; #if 0 /* TODO(fclem): This is too verbose for now. Make it a cmake option. */ /* Test if any resource is optimized out and print a warning if that's the case. */ /* TODO(fclem): Limit this to OpenGL backend. */ @@ -677,10 +696,10 @@ bool gpu_shader_create_info_compile(const char *name_starts_with_filter) } } #endif - } - GPU_shader_free(shader); + GPU_shader_free(result[i]); } } + printf("Shader Test compilation result: %d / %d passed", success, total); if (skipped_filter > 0) { printf(" (skipped %d when filtering)", skipped_filter);