Fix Shader compile-mode radio buttons in Viewer.

Originally, these radio buttons would allow the user to immediately
switch between different compile stages and view the change in output.
At some point, this broke, and clicking the radio buttons would clear
the shader list, so that the user would need to click View again to see
the shaders. This made it much harder to visualize the difference in
compilation stages at a glance.

Now the radio buttons work normally again.

Change-Id: I234c305817909c4345dd12318df3cbe4505121a8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/524936
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
John Stiles 2022-03-27 12:01:04 -04:00 committed by SkCQ
parent 99b7434daf
commit 30d3d1ab19

View File

@ -2563,6 +2563,7 @@ void Viewer::drawImGui() {
// If we are changing the compile mode, we want to reset the cache and redo
// everything.
static bool sDoDeferredView = false;
if (doDump || newOptLevel != fOptLevel) {
sksl = doDump || (newOptLevel == kShaderOptLevel_Source);
fOptLevel = (ShaderOptLevel)newOptLevel;
@ -2589,11 +2590,12 @@ void Viewer::drawImGui() {
sksl ? GrContextOptions::ShaderCacheStrategy::kSkSL
: GrContextOptions::ShaderCacheStrategy::kBackendSource;
displayParamsChanged = true;
doView = true;
fDeferredActions.push_back([=]() {
// Reset the cache.
fPersistentCache.reset();
sDoDeferredView = true;
// Dump the cache once we have drawn a frame with it.
if (doDump) {
fDeferredActions.push_back([this]() {
@ -2630,10 +2632,11 @@ void Viewer::drawImGui() {
}
ImGui::EndChild();
if (doView) {
if (doView || sDoDeferredView) {
fPersistentCache.reset();
ctx->priv().getGpu()->resetShaderCacheForTesting();
gLoadPending = true;
sDoDeferredView = false;
}
// We don't support updating SPIRV shaders. We could re-assemble them (with edits),