From 28956cc6c26227636f8ddc8e6db8b5fcddf99e6a Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Sat, 25 Feb 2023 23:26:27 -0800 Subject: [PATCH] workaround msvc optimizer bug --- Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp index 42e16cb687..076aa1fb1f 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp @@ -1354,7 +1354,9 @@ void ZeldaAudioRenderer::FetchVPB(u16 voice_id, VPB* vpb) void ZeldaAudioRenderer::StoreVPB(u16 voice_id, VPB* vpb) { u16* vpb_words = (u16*)vpb; - u16* ram_vpbs = (u16*)HLEMemory_Get_Pointer(m_vpb_base_addr); + // volatile is a workaround for msvc optimizer bug, see + // https://developercommunity.visualstudio.com/t/VS-175-bad-codegen-optimizing-loop-with/10291620 + volatile u16* ram_vpbs = (u16*)HLEMemory_Get_Pointer(m_vpb_base_addr); size_t vpb_size = (m_flags & TINY_VPB) ? 0x80 : 0xC0; size_t base_idx = voice_id * vpb_size;