diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp index f66d9ecf73..fc129e9734 100644 --- a/tools/viewer/Viewer.cpp +++ b/tools/viewer/Viewer.cpp @@ -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),