GPU: Add --gpu-compilation-subprocesses cmd setting
Allow overriding the `max_parallel_compilations` from the command line. Disable compilation subprocesses on RenderDoc sessions. Pull Request: https://projects.blender.org/blender/blender/pulls/123995
This commit is contained in:
parent
2b248d2720
commit
4c314f9a78
@ -65,3 +65,6 @@ bool GPU_stereo_quadbuffer_support();
|
||||
|
||||
int GPU_minimum_per_vertex_stride();
|
||||
bool GPU_transform_feedback_support();
|
||||
|
||||
/** WARNING: Should only be called at startup from creator_args. Never call it at runtime. */
|
||||
void GPU_compilation_subprocess_override_set(int count);
|
||||
|
@ -239,3 +239,15 @@ bool GPU_stereo_quadbuffer_support()
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Creator arguments overrides
|
||||
* \{ */
|
||||
|
||||
void GPU_compilation_subprocess_override_set(int count)
|
||||
{
|
||||
BLI_assert(GCaps.max_parallel_compilations == -1);
|
||||
GCaps.max_parallel_compilations = count;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
@ -51,7 +51,7 @@ struct GPUCapabilities {
|
||||
bool texture_view_support = true;
|
||||
bool stencil_export_support = false;
|
||||
|
||||
int max_parallel_compilations = 0;
|
||||
int max_parallel_compilations = -1;
|
||||
|
||||
/* OpenGL related workarounds. */
|
||||
bool mip_render_workaround = false;
|
||||
|
@ -599,8 +599,14 @@ void GLBackend::capabilities_init()
|
||||
detect_workarounds();
|
||||
|
||||
#if BLI_SUBPROCESS_SUPPORT
|
||||
if (GCaps.max_parallel_compilations == -1) {
|
||||
GCaps.max_parallel_compilations = std::min(int(U.max_shader_compilation_subprocesses),
|
||||
BLI_system_thread_count());
|
||||
}
|
||||
if (G.debug & G_DEBUG_GPU_RENDERDOC) {
|
||||
/* Avoid crashes on RenderDoc sessions. */
|
||||
GCaps.max_parallel_compilations = 0;
|
||||
}
|
||||
#else
|
||||
GCaps.max_parallel_compilations = 0;
|
||||
#endif
|
||||
|
@ -48,6 +48,7 @@
|
||||
# include "BKE_scene.hh"
|
||||
# include "BKE_sound.h"
|
||||
|
||||
# include "GPU_capabilities.hh"
|
||||
# include "GPU_context.hh"
|
||||
|
||||
# ifdef WITH_PYTHON
|
||||
@ -777,6 +778,9 @@ static void print_help(bArgs *ba, bool all)
|
||||
PRINT("\n");
|
||||
PRINT("GPU Options:\n");
|
||||
BLI_args_print_arg_doc(ba, "--gpu-backend");
|
||||
# ifdef WITH_OPENGL_BACKEND
|
||||
BLI_args_print_arg_doc(ba, "--gpu-compilation-subprocesses");
|
||||
# endif
|
||||
|
||||
PRINT("\n");
|
||||
PRINT("Misc Options:\n");
|
||||
@ -1484,6 +1488,42 @@ static int arg_handle_gpu_backend_set(int argc, const char **argv, void * /*data
|
||||
return 1;
|
||||
}
|
||||
|
||||
# ifdef WITH_OPENGL_BACKEND
|
||||
static const char arg_handle_gpu_compilation_subprocesses_set_doc[] =
|
||||
"\n"
|
||||
"\tOverride the Max Compilation Subprocesses setting (OpenGL only).";
|
||||
static int arg_handle_gpu_compilation_subprocesses_set(int argc,
|
||||
const char **argv,
|
||||
void * /*data*/)
|
||||
{
|
||||
const char *arg_id = "--gpu-compilation-subprocesses";
|
||||
const int min = 0, max = BLI_system_thread_count();
|
||||
if (argc > 1) {
|
||||
const char *err_msg = nullptr;
|
||||
int subprocesses;
|
||||
if (!parse_int_strict_range(argv[1], nullptr, min, max, &subprocesses, &err_msg)) {
|
||||
fprintf(stderr,
|
||||
"\nError: %s '%s %s', expected number in [%d..%d].\n",
|
||||
err_msg,
|
||||
arg_id,
|
||||
argv[1],
|
||||
min,
|
||||
max);
|
||||
return 0;
|
||||
}
|
||||
|
||||
GPU_compilation_subprocess_override_set(subprocesses);
|
||||
return 1;
|
||||
}
|
||||
fprintf(stderr,
|
||||
"\nError: you must specify a number of subprocesses in [%d..%d] '%s'.\n",
|
||||
min,
|
||||
max,
|
||||
arg_id);
|
||||
return 0;
|
||||
}
|
||||
# endif
|
||||
|
||||
static const char arg_handle_debug_fpe_set_doc[] =
|
||||
"\n\t"
|
||||
"Enable floating-point exceptions.";
|
||||
@ -2565,6 +2605,13 @@ void main_args_setup(bContext *C, bArgs *ba, bool all)
|
||||
/* GPU backend selection should be part of #ARG_PASS_ENVIRONMENT for correct GPU context
|
||||
* selection for animation player. */
|
||||
BLI_args_add(ba, nullptr, "--gpu-backend", CB_ALL(arg_handle_gpu_backend_set), nullptr);
|
||||
# ifdef WITH_OPENGL_BACKEND
|
||||
BLI_args_add(ba,
|
||||
nullptr,
|
||||
"--gpu-compilation-subprocesses",
|
||||
CB(arg_handle_gpu_compilation_subprocesses_set),
|
||||
nullptr);
|
||||
# endif
|
||||
|
||||
/* Pass: Background Mode & Settings
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user