From e3d8d708fc1f0f6d457744f7c8a781cc48e72bff Mon Sep 17 00:00:00 2001 From: vmobilis <75476228+vmobilis@users.noreply.github.com> Date: Tue, 18 Aug 2026 11:24:12 +0300 Subject: [PATCH 1/4] stable-diffusion.cpp: guard against missing names --- src/stable-diffusion.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/stable-diffusion.cpp b/src/stable-diffusion.cpp index b74d981aa..6c59dffa3 100644 --- a/src/stable-diffusion.cpp +++ b/src/stable-diffusion.cpp @@ -150,6 +150,9 @@ const char* sampling_methods_str[] = { "LMS", }; +static_assert(SAMPLE_METHOD_COUNT == sizeof(sampling_methods_str) / sizeof(sampling_methods_str[0]), + "\nnumber of elements in sampling_methods_str[] != SAMPLE_METHOD_COUNT"); + /*================================================== Helper Functions ================================================*/ static bool sd_version_supports_ref_latent_img_cfg(SDVersion version) { @@ -3306,6 +3309,9 @@ const char* sample_method_to_str[] = { "lms", }; +static_assert(SAMPLE_METHOD_COUNT == sizeof(sample_method_to_str) / sizeof(sample_method_to_str[0]), + "\nnumber of elements in sample_method_to_str[] != SAMPLE_METHOD_COUNT"); + const char* sd_sample_method_name(enum sample_method_t sample_method) { if (sample_method < SAMPLE_METHOD_COUNT) { return sample_method_to_str[sample_method]; @@ -3341,6 +3347,9 @@ const char* scheduler_to_str[] = { "beta", }; +static_assert(SCHEDULER_COUNT == sizeof(scheduler_to_str) / sizeof(scheduler_to_str[0]), + "\nnumber of elements in scheduler_to_str[] != SCHEDULER_COUNT"); + const char* sd_scheduler_name(enum scheduler_t scheduler) { if (scheduler < SCHEDULER_COUNT) { return scheduler_to_str[scheduler]; From 4267b59fed7e4f619d8bad86c11f0824402fd5d3 Mon Sep 17 00:00:00 2001 From: vmobilis <75476228+vmobilis@users.noreply.github.com> Date: Tue, 18 Aug 2026 11:29:11 +0300 Subject: [PATCH 2/4] stable-diffusion.h: declare option names globally --- include/stable-diffusion.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/stable-diffusion.h b/include/stable-diffusion.h index 57e41171d..285021419 100644 --- a/include/stable-diffusion.h +++ b/include/stable-diffusion.h @@ -60,6 +60,8 @@ enum sample_method_t { SAMPLE_METHOD_COUNT }; +extern const char* sample_method_to_str[]; + enum scheduler_t { DISCRETE_SCHEDULER, KARRAS_SCHEDULER, @@ -80,6 +82,8 @@ enum scheduler_t { SCHEDULER_COUNT }; +extern const char* scheduler_to_str[]; + enum prediction_t { EPS_PRED, V_PRED, From 3f47c88c76467e2197ab28dbb964cfadd6cb64c4 Mon Sep 17 00:00:00 2001 From: vmobilis <75476228+vmobilis@users.noreply.github.com> Date: Tue, 18 Aug 2026 11:32:48 +0300 Subject: [PATCH 3/4] common.cpp: add smplers and schedulers dynamically --- examples/common/common.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/examples/common/common.cpp b/examples/common/common.cpp index 28f18d9e6..6d852c53e 100644 --- a/examples/common/common.cpp +++ b/examples/common/common.cpp @@ -1555,6 +1555,18 @@ ArgOptions SDGenerationParams::get_options() { return 1; }; + std::string sample_methods = sample_method_to_str[0]; + for (int i = 1; i < SAMPLE_METHOD_COUNT; i++) + { + sample_methods += ", " + std::string(sample_method_to_str[i]); + } + + std::string schedulers = scheduler_to_str[0]; + for (int i = 1; i < SCHEDULER_COUNT; i++) + { + schedulers += ", " + std::string(scheduler_to_str[i]); + } + options.manual_options = { {"-s", "--seed", @@ -1562,17 +1574,18 @@ ArgOptions SDGenerationParams::get_options() { on_seed_arg}, {"", "--sampling-method", - "sampling method, one of [euler, euler_a, heun, dpm2, dpm++2s_a, dpm++2m, dpm++2mv2, dpm++2m_sde, dpm++2m_sde_bt, ipndm, ipndm_v, lcm, ddim_trailing, tcd, res_multistep, res_2s, er_sde, euler_cfg_pp, euler_a_cfg_pp, lms]" - "(default: euler for Flux/SD3/Wan, euler_a otherwise)", + "sampling method, one of [" + sample_methods + "], " + "default: euler for Flux/SD3/Wan, euler_a otherwise", on_sample_method_arg}, {"", "--high-noise-sampling-method", - "(high noise) sampling method, one of [euler, euler_a, heun, dpm2, dpm++2s_a, dpm++2m, dpm++2mv2, dpm++2m_sde, dpm++2m_sde_bt, ipndm, ipndm_v, lcm, ddim_trailing, tcd, res_multistep, res_2s, er_sde, euler_cfg_pp, euler_a_cfg_pp, lms]" - " default: euler for Flux/SD3/Wan, euler_a otherwise", + "(high noise) sampling method, one of [" + sample_methods + "], " + "default: euler for Flux/SD3/Wan, euler_a otherwise", on_high_noise_sample_method_arg}, {"", "--scheduler", - "denoiser sigma scheduler, one of [discrete, karras, exponential, ays, gits, smoothstep, sgm_uniform, simple, kl_optimal, lcm, bong_tangent, ltx2, logit_normal, flux2, flux, beta], alias: normal=discrete, default: model-specific", + "denoiser sigma scheduler, one of [" + schedulers + "], " + "alias: normal=discrete, default: model-specific", on_scheduler_arg}, {"", "--sigmas", From e2bb06e0d718a0b1e99786d8ccfb13a7d45f0af5 Mon Sep 17 00:00:00 2001 From: vmobilis <75476228+vmobilis@users.noreply.github.com> Date: Tue, 18 Aug 2026 12:52:56 +0300 Subject: [PATCH 4/4] stable-diffusion.h: visibility of names --- include/stable-diffusion.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/stable-diffusion.h b/include/stable-diffusion.h index 285021419..bab62bac9 100644 --- a/include/stable-diffusion.h +++ b/include/stable-diffusion.h @@ -60,7 +60,7 @@ enum sample_method_t { SAMPLE_METHOD_COUNT }; -extern const char* sample_method_to_str[]; +extern SD_API const char* sample_method_to_str[]; enum scheduler_t { DISCRETE_SCHEDULER, @@ -82,7 +82,7 @@ enum scheduler_t { SCHEDULER_COUNT }; -extern const char* scheduler_to_str[]; +extern SD_API const char* scheduler_to_str[]; enum prediction_t { EPS_PRED,