diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index 21dfe283244..a143f0aab7a 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -216,12 +216,13 @@ enum { G_DEBUG_GPU = (1 << 16), /* gpu debug */ G_DEBUG_IO = (1 << 17), /* IO Debugging (for Collada, ...). */ G_DEBUG_GPU_FORCE_WORKAROUNDS = (1 << 18), /* force gpu workarounds bypassing detections. */ - G_DEBUG_GPU_RENDERDOC = (1 << 19), /* Enable RenderDoc integration. */ - G_DEBUG_XR = (1 << 20), /* XR/OpenXR messages */ - G_DEBUG_XR_TIME = (1 << 21), /* XR/OpenXR timing messages */ + G_DEBUG_GPU_COMPILE_SHADERS = (1 << 19), /* Compile all statically defined shaders. . */ + G_DEBUG_GPU_RENDERDOC = (1 << 20), /* Enable RenderDoc integration. */ + G_DEBUG_XR = (1 << 21), /* XR/OpenXR messages */ + G_DEBUG_XR_TIME = (1 << 22), /* XR/OpenXR timing messages */ - G_DEBUG_GHOST = (1 << 22), /* Debug GHOST module. */ - G_DEBUG_WINTAB = (1 << 23), /* Debug Wintab. */ + G_DEBUG_GHOST = (1 << 23), /* Debug GHOST module. */ + G_DEBUG_WINTAB = (1 << 24), /* Debug Wintab. */ }; #define G_DEBUG_ALL \ diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h index 7bf6ac78f4d..1498542a084 100644 --- a/source/blender/gpu/GPU_shader.h +++ b/source/blender/gpu/GPU_shader.h @@ -332,6 +332,13 @@ typedef enum { */ int GPU_shader_get_builtin_uniform(GPUShader *shader, int builtin); +/** + * Compile all staticly defined shaders and print a report to the console. + * + * This is used for platform support, where bug reports can list all failing shaders. + */ +void GPU_shader_compile_static(); + /** DEPRECATED: Use hardcoded buffer location instead. */ typedef enum { GPU_UNIFORM_BLOCK_VIEW = 0, /* viewBlock */ diff --git a/source/blender/gpu/intern/gpu_shader.cc b/source/blender/gpu/intern/gpu_shader.cc index acf655db008..eefba01fe27 100644 --- a/source/blender/gpu/intern/gpu_shader.cc +++ b/source/blender/gpu/intern/gpu_shader.cc @@ -447,6 +447,12 @@ GPUShader *GPU_shader_create_from_python(const char *vertcode, return sh; } +void GPU_shader_compile_static() +{ + printf("Compiling all static GPU shaders. This process takes a while.\n"); + gpu_shader_create_info_compile(""); +} + /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/windowmanager/intern/wm_init_exit.cc b/source/blender/windowmanager/intern/wm_init_exit.cc index cbd2f2cfb61..47b01ca75c0 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.cc +++ b/source/blender/windowmanager/intern/wm_init_exit.cc @@ -167,6 +167,10 @@ void WM_init_gpu() GPU_pass_cache_init(); + if (G.debug & G_DEBUG_GPU_COMPILE_SHADERS) { + GPU_shader_compile_static(); + } + gpu_is_init = true; } diff --git a/source/creator/creator_args.cc b/source/creator/creator_args.cc index c6f2903823b..eec0bc7073c 100644 --- a/source/creator/creator_args.cc +++ b/source/creator/creator_args.cc @@ -664,6 +664,7 @@ static void print_help(bArgs *ba, bool all) BLI_args_print_arg_doc(ba, "--debug-wintab"); BLI_args_print_arg_doc(ba, "--debug-gpu"); BLI_args_print_arg_doc(ba, "--debug-gpu-force-workarounds"); + BLI_args_print_arg_doc(ba, "--debug-gpu-compile-shaders"); if (defs.with_renderdoc) { BLI_args_print_arg_doc(ba, "--debug-gpu-renderdoc"); } @@ -1209,6 +1210,17 @@ static int arg_handle_debug_gpu_set(int /*argc*/, const char ** /*argv*/, void * return 0; } +static const char arg_handle_debug_gpu_compile_shaders_set_doc[] = + "\n" + "\tCompile all staticly defined shaders to test platform compatibility."; +static int arg_handle_debug_gpu_compile_shaders_set(int /*argc*/, + const char ** /*argv*/, + void * /*data*/) +{ + G.debug |= G_DEBUG_GPU_COMPILE_SHADERS; + return 0; +} + static const char arg_handle_debug_gpu_renderdoc_set_doc[] = "\n" "\tEnable Renderdoc integration for GPU frame grabbing and debugging."; @@ -2418,6 +2430,11 @@ void main_args_setup(bContext *C, bArgs *ba, bool all) CB_EX(arg_handle_debug_mode_generic_set, jobs), (void *)G_DEBUG_JOBS); BLI_args_add(ba, nullptr, "--debug-gpu", CB(arg_handle_debug_gpu_set), nullptr); + BLI_args_add(ba, + nullptr, + "--debug-gpu-compile-shaders", + CB(arg_handle_debug_gpu_compile_shaders_set), + nullptr); if (defs.with_renderdoc) { BLI_args_add( ba, nullptr, "--debug-gpu-renderdoc", CB(arg_handle_debug_gpu_renderdoc_set), nullptr);