gpu_hw: trigger shader recompile on runtime swanstation_GPU_ShaderPrecompile change
Reported bug: flipping the swanstation_GPU_ShaderPrecompile core
option between Lazy / Enabled / Disabled at runtime had no
immediate effect. The new mode wouldn't take effect until the
user changed some OTHER shader-affecting setting (texture filter,
resolution scale, multisampling, etc.) that triggered the existing
destroy/recompile path.
Root cause: GPU_HW::UpdateHWSettings's shaders_changed predicate
checked 11 fields (resolution_scale, multisamples, true_color,
per_sample_shading, scaled_dithering, texture_filter, uv_limits,
chroma_smoothing, downsample_mode, pgxp_depth_buffer,
disable_color_perspective) but NOT g_settings.gpu_shader_precompile_mode.
So a pure precompile-mode flip computed shaders_changed = false,
the per-backend UpdateSettings skipped the DestroyPipelines /
CompilePipelines round-trip, and:
- Lazy -> Disabled: the background worker that was already
spawned just kept running until it naturally finished filling
the matrix (~30 seconds on heavy filters). The user-visible
'Disabled' semantics didn't apply until then.
- Disabled -> Lazy: no worker spawn happened. Each draw kept
paying first-use compile cost on the runloop. The user got
Disabled behaviour while the setting said Lazy.
- {Lazy, Disabled} -> Enabled: no synchronous full precompile
happened. The user expected 'block until done' and got
whatever state the matrix was in.
- Enabled -> {Lazy, Disabled}: the matrix was already fully
populated from the Enabled-mode sync pass, so this only had
bearing on FUTURE recompile cycles. Still wrong but the
least-visible case.
Fix: add m_shader_precompile_mode as the cached previous value
(seeded in GPU_HW::Initialize from g_settings.gpu_shader_precompile_mode,
re-stored every UpdateHWSettings call alongside the other field
copies). Include it in the shaders_changed predicate.
After this patch a runtime flip triggers shaders_changed = true,
which calls into the per-backend UpdateSettings's normal
destroy/recompile path:
- Lazy -> Disabled: DestroyPipelines calls StopShaderCompileThread
which joins the worker; CompilePipelines runs in Disabled
mode (skips the precompile matrix, doesn't spawn a worker).
The worker is gone within at most one in-flight cell's
compile worth of latency.
- Disabled -> Lazy: DestroyPipelines is a no-op for the worker
(none running); CompilePipelines runs in Lazy mode (skips
the precompile matrix, spawns a worker that fills the matrix
asynchronously).
- Disabled -> Enabled: full sync precompile on the calling
thread - the documented Enabled-mode behaviour. The frontend
blocks for tens of seconds on cold disk cache; cached, it's
a few seconds.
- Enabled -> Lazy / Disabled: matrix destroyed, recompiled
according to the new mode. Symmetric with the other cases.
- Lazy -> Enabled or vice versa with an in-flight worker:
DestroyPipelines joins the in-flight worker first, then
CompilePipelines starts fresh in the new mode.
Cost is one full destroy/recompile cycle on each precompile-mode
flip - same cost path the existing 11 settings already pay. For
Lazy and Disabled this is roughly 100-300 ms of teardown plus
non-batch shader rebuild. For Enabled it's that plus the actual
sync precompile of the batch matrix, dominated by driver compile
time (10-40s cold, sub-second from disk cache). The cell-fill
work hits the disk shader cache so it's only expensive on the
first time any given (filter, scale, ...) tuple is seen.
We could have written more precise handling - 'on Lazy ->
Disabled just stop the worker, keep the populated matrix' - but
that's a more complex patch and the simple destroy/recompile path
is well-trodden, well-tested, and the user already pays this cost
for any other shader-affecting setting change. Symmetry trumps
the small redundant work in the Lazy <-> Disabled case.
Files touched:
- src/core/gpu_hw.h: m_shader_precompile_mode member added.
- src/core/gpu_hw.cpp: Initialize seeds it from g_settings;
UpdateHWSettings includes it in shaders_changed predicate
and writes the latest value back.
Build verification: linux platform=unix clean, zero warnings,
zero errors. .so size 8040152 unchanged (one u8-sized field and
one extra comparison, well within an existing structure-padding
slot). 25 retro_* exports unchanged.
This commit is contained in:
parent
7db7d2527d
commit
5d73da3896
2 changed files with 14 additions and 1 deletions
|
|
@ -61,6 +61,7 @@ bool GPU_HW::Initialize(HostDisplay* host_display)
|
|||
m_chroma_smoothing = g_settings.gpu_24bit_chroma_smoothing;
|
||||
m_downsample_mode = GetDownsampleMode(m_resolution_scale);
|
||||
m_disable_color_perspective = m_supports_disable_color_perspective && ShouldDisableColorPerspective();
|
||||
m_shader_precompile_mode = g_settings.gpu_shader_precompile_mode;
|
||||
|
||||
if (m_multisamples != g_settings.gpu_multisamples)
|
||||
{
|
||||
|
|
@ -144,7 +145,8 @@ void GPU_HW::UpdateHWSettings(bool* framebuffer_changed, bool* shaders_changed)
|
|||
m_scaled_dithering != g_settings.gpu_scaled_dithering || m_texture_filtering != g_settings.gpu_texture_filter ||
|
||||
m_using_uv_limits != use_uv_limits || m_chroma_smoothing != g_settings.gpu_24bit_chroma_smoothing ||
|
||||
m_downsample_mode != downsample_mode || m_pgxp_depth_buffer != g_settings.UsingPGXPDepthBuffer() ||
|
||||
m_disable_color_perspective != disable_color_perspective);
|
||||
m_disable_color_perspective != disable_color_perspective ||
|
||||
m_shader_precompile_mode != g_settings.gpu_shader_precompile_mode);
|
||||
|
||||
m_resolution_scale = resolution_scale;
|
||||
m_multisamples = multisamples;
|
||||
|
|
@ -156,6 +158,7 @@ void GPU_HW::UpdateHWSettings(bool* framebuffer_changed, bool* shaders_changed)
|
|||
m_chroma_smoothing = g_settings.gpu_24bit_chroma_smoothing;
|
||||
m_downsample_mode = downsample_mode;
|
||||
m_disable_color_perspective = disable_color_perspective;
|
||||
m_shader_precompile_mode = g_settings.gpu_shader_precompile_mode;
|
||||
|
||||
if (!m_supports_dual_source_blend && TextureFilterRequiresDualSourceBlend(m_texture_filtering))
|
||||
m_texture_filtering = GPUTextureFilter::Nearest;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue