From c9edfa0eaa0574d5b39e64f871621b6494c651ba Mon Sep 17 00:00:00 2001 From: JosJuice Date: Thu, 25 Jun 2020 13:11:29 +0200 Subject: [PATCH] Replace Windows CMake lambda constexpr capture workaround While manually capturing constexpr variables used in lambda expressions does work, it's really easy to forget doing so since we don't have a Windows CMake builder and the workaround isn't necessary anywhere else. Fortunately, MSVC has a flag that fixes the constexpr capture behavior, so let's use that instead. --- CMakeLists.txt | 2 ++ Source/Core/DolphinQt/Config/VerifyWidget.cpp | 34 +++++++++---------- Source/Core/VideoCommon/CommandProcessor.cpp | 2 +- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 25e06802ae..26484938a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -241,6 +241,8 @@ if(CMAKE_C_COMPILER_ID MATCHES "MSVC") add_compile_options(/Zc:throwingNew) # Enforce strict volatile semantics as per ISO C++ add_compile_options(/volatile:iso) + # Fix non-conformant lambda behavior (constexpr variables shouldn't need capturing) + add_compile_options(/experimental:newLambdaProcessor) string(APPEND CMAKE_EXE_LINKER_FLAGS " /NXCOMPAT") else() diff --git a/Source/Core/DolphinQt/Config/VerifyWidget.cpp b/Source/Core/DolphinQt/Config/VerifyWidget.cpp index e6c320e278..ce221bce8f 100644 --- a/Source/Core/DolphinQt/Config/VerifyWidget.cpp +++ b/Source/Core/DolphinQt/Config/VerifyWidget.cpp @@ -139,26 +139,26 @@ void VerifyWidget::Verify() progress.GetRaw()->setMinimumDuration(500); progress.GetRaw()->setWindowModality(Qt::WindowModal); - auto future = std::async( - std::launch::async, - [&verifier, &progress, DIVISOR]() -> std::optional { - progress.SetValue(0); - verifier.Start(); - while (verifier.GetBytesProcessed() != verifier.GetTotalBytes()) - { - progress.SetValue(static_cast(verifier.GetBytesProcessed() / DIVISOR)); - if (progress.WasCanceled()) - return std::nullopt; + auto future = + std::async(std::launch::async, + [&verifier, &progress]() -> std::optional { + progress.SetValue(0); + verifier.Start(); + while (verifier.GetBytesProcessed() != verifier.GetTotalBytes()) + { + progress.SetValue(static_cast(verifier.GetBytesProcessed() / DIVISOR)); + if (progress.WasCanceled()) + return std::nullopt; - verifier.Process(); - } - verifier.Finish(); + verifier.Process(); + } + verifier.Finish(); - const DiscIO::VolumeVerifier::Result result = verifier.GetResult(); - progress.Reset(); + const DiscIO::VolumeVerifier::Result result = verifier.GetResult(); + progress.Reset(); - return result; - }); + return result; + }); progress.GetRaw()->exec(); std::optional result = future.get(); diff --git a/Source/Core/VideoCommon/CommandProcessor.cpp b/Source/Core/VideoCommon/CommandProcessor.cpp index eb571a4672..59ca391f55 100644 --- a/Source/Core/VideoCommon/CommandProcessor.cpp +++ b/Source/Core/VideoCommon/CommandProcessor.cpp @@ -196,7 +196,7 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base) } mmio->Register(base | FIFO_BP_LO, MMIO::DirectRead(MMIO::Utils::LowPart(&fifo.CPBreakpoint)), - MMIO::ComplexWrite([WMASK_LO_ALIGN_32BIT](u32, u16 val) { + MMIO::ComplexWrite([](u32, u16 val) { WriteLow(fifo.CPBreakpoint, val & WMASK_LO_ALIGN_32BIT); })); mmio->Register(base | FIFO_BP_HI,