libretro: scope Vulkan case to fix MSVC C2360 (#2267)

MSVC with /permissive- /WX rejects the switch in retro_load_game:
the static vk_negotiation initializer in the Vulkan case is crossed
by the next case label (C2360, initialization skipped by case). Wrap
the Vulkan case body in a block so its scope ends before that label,
and add a comment noting why the braces are required there. The other
cases are wrapped in blocks too for visual consistency, though only
the Vulkan case strictly needs it. GCC/clang and the MXE cross-build
accept the original; this only affects native MSVC builds. No
behaviour change.
This commit is contained in:
Ryan McClelland 2026-07-09 05:44:37 -07:00 committed by GitHub
parent bda4671be6
commit 0c19c33bd3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -552,7 +552,7 @@ bool retro_load_game(const struct retro_game_info* info) {
emu_instance->emu_window->UpdateLayout();
switch (Settings::values.graphics_api.GetValue()) {
case Settings::GraphicsAPI::OpenGL:
case Settings::GraphicsAPI::OpenGL: {
#ifdef ENABLE_OPENGL
LOG_INFO(Frontend, "Using OpenGL hw renderer");
LibRetro::SetHWSharedContext();
@ -576,7 +576,12 @@ bool retro_load_game(const struct retro_game_info* info) {
LibRetro::SetFramebufferCallback(emu_instance->hw_render.get_current_framebuffer);
#endif
break;
case Settings::GraphicsAPI::Vulkan:
}
case Settings::GraphicsAPI::Vulkan: {
// These braces are required (not only for consistency): vk_negotiation
// below is declared with an initializer, so without an explicit scope
// the following case label would jump past that initialization. MSVC
// rejects that as error C2360 under /permissive- /WX.
#ifdef ENABLE_VULKAN
LOG_INFO(Frontend, "Using Vulkan hw renderer");
emu_instance->hw_render.context_type = RETRO_HW_CONTEXT_VULKAN;
@ -601,13 +606,15 @@ bool retro_load_game(const struct retro_game_info* info) {
LibRetro::SetHWRenderContextNegotiationInterface((void**)&vk_negotiation);
#endif
break;
case Settings::GraphicsAPI::Software:
}
case Settings::GraphicsAPI::Software: {
emu_instance->emu_window->CreateContext();
emu_instance->game_loaded = do_load_game();
if (!emu_instance->game_loaded)
return false;
break;
}
}
uint64_t quirks =
RETRO_SERIALIZATION_QUIRK_CORE_VARIABLE_SIZE | RETRO_SERIALIZATION_QUIRK_MUST_INITIALIZE;