From 80e3d29ab848623872b101abdbe1de36c694058e Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 3 Sep 2023 14:30:26 +1000 Subject: [PATCH] Misc: clang-cl warning clean-up --- duckstation.sln | 14 +- src/common/log.cpp | 7 +- src/core/analog_controller.cpp | 4 +- src/core/cdrom.cpp | 4 +- src/core/cpu_code_cache.cpp | 3 +- src/core/cpu_code_cache.h | 4 + src/core/cpu_core.cpp | 4 +- src/core/cpu_recompiler_code_generator.cpp | 5 +- .../cpu_recompiler_code_generator_x64.cpp | 54 ++++- src/core/digital_controller.cpp | 9 +- src/core/dma.cpp | 2 +- src/core/fullscreen_ui.cpp | 25 +-- src/core/gpu.cpp | 19 +- src/core/gpu_sw_backend.cpp | 7 +- src/core/guncon.cpp | 7 +- src/core/pgxp.cpp | 82 ++++--- src/core/pgxp.h | 24 +-- src/core/playstation_mouse.cpp | 5 +- src/core/system.cpp | 10 +- src/core/system.h | 11 +- src/core/timers.cpp | 3 + src/duckstation-nogui/nogui_host.cpp | 2 + .../win32_nogui_platform.cpp | 21 +- src/duckstation-qt/mainwindow.cpp | 3 +- src/duckstation-qt/settingsdialog.cpp | 2 +- src/duckstation-regtest/regtest_host.cpp | 1 - src/util/cd_image.h | 82 +++---- src/util/cd_image_device.cpp | 4 +- src/util/d3d11_device.cpp | 4 +- src/util/d3d11_pipeline.cpp | 3 +- src/util/d3d12_descriptor_heap_manager.cpp | 6 +- src/util/d3d12_device.cpp | 43 ++-- src/util/d3d12_pipeline.cpp | 2 - src/util/d3d12_texture.cpp | 28 +-- src/util/d3d_common.cpp | 2 +- src/util/dinput_source.cpp | 3 +- src/util/gl/context_wgl.cpp | 4 + src/util/gpu_device.cpp | 2 +- src/util/gpu_device.h | 21 +- src/util/imgui_manager.cpp | 200 +++++++++--------- src/util/opengl_pipeline.cpp | 5 +- src/util/postprocessing_shader_fx.cpp | 7 +- src/util/vulkan_device.cpp | 41 ++-- src/util/vulkan_loader.h | 1 + src/util/vulkan_pipeline.cpp | 2 - src/util/vulkan_swap_chain.cpp | 5 +- src/util/vulkan_texture.cpp | 9 +- src/util/win32_raw_input_source.cpp | 10 +- src/util/win32_raw_input_source.h | 1 - src/util/window_info.cpp | 6 +- src/util/xaudio2_audio_stream.cpp | 32 ++- src/util/xinput_source.cpp | 9 +- 52 files changed, 470 insertions(+), 394 deletions(-) diff --git a/duckstation.sln b/duckstation.sln index 2d48ac804..b2f11eab0 100644 --- a/duckstation.sln +++ b/duckstation.sln @@ -1007,34 +1007,32 @@ Global {32EEAF44-57F8-4C6C-A6F0-DE5667123DD5}.ReleaseLTCG-Clang|x86.Build.0 = ReleaseLTCG-Clang|Win32 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.Debug|ARM64.ActiveCfg = Debug|ARM64 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.Debug|ARM64.Build.0 = Debug|ARM64 - {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.Debug|x64.ActiveCfg = Debug|ARM64 + {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.Debug|x64.ActiveCfg = Debug|x64 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.Debug|x86.ActiveCfg = Debug|ARM64 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.Debug-Clang|ARM64.ActiveCfg = Debug-Clang|ARM64 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.Debug-Clang|x64.ActiveCfg = Debug-Clang|x64 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.Debug-Clang|x86.ActiveCfg = Debug-Clang|Win32 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.DebugFast|ARM64.ActiveCfg = DebugFast|ARM64 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.DebugFast|ARM64.Build.0 = DebugFast|ARM64 - {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.DebugFast|x64.ActiveCfg = DebugFast|ARM64 + {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.DebugFast|x64.ActiveCfg = DebugFast|x64 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.DebugFast|x86.ActiveCfg = DebugFast|ARM64 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.DebugFast-Clang|ARM64.ActiveCfg = DebugFast-Clang|ARM64 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.DebugFast-Clang|ARM64.Build.0 = DebugFast-Clang|ARM64 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.DebugFast-Clang|x64.ActiveCfg = DebugFast-Clang|x64 - {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.DebugFast-Clang|x64.Build.0 = DebugFast-Clang|x64 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.DebugFast-Clang|x86.ActiveCfg = DebugFast-Clang|Win32 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.DebugFast-Clang|x86.Build.0 = DebugFast-Clang|Win32 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.Release|ARM64.ActiveCfg = Release|ARM64 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.Release|ARM64.Build.0 = Release|ARM64 - {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.Release|x64.ActiveCfg = Release|ARM64 + {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.Release|x64.ActiveCfg = Release|x64 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.Release|x86.ActiveCfg = Release|ARM64 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.Release-Clang|ARM64.ActiveCfg = Release-Clang|ARM64 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.Release-Clang|ARM64.Build.0 = Release-Clang|ARM64 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.Release-Clang|x64.ActiveCfg = Release-Clang|x64 - {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.Release-Clang|x64.Build.0 = Release-Clang|x64 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.Release-Clang|x86.ActiveCfg = Release-Clang|Win32 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.Release-Clang|x86.Build.0 = Release-Clang|Win32 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.ReleaseLTCG|ARM64.ActiveCfg = ReleaseLTCG|ARM64 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.ReleaseLTCG|ARM64.Build.0 = ReleaseLTCG|ARM64 - {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.ReleaseLTCG|x64.ActiveCfg = ReleaseLTCG|ARM64 + {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.ReleaseLTCG|x64.ActiveCfg = ReleaseLTCG|x64 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.ReleaseLTCG|x86.ActiveCfg = ReleaseLTCG|ARM64 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.ReleaseLTCG-Clang|ARM64.ActiveCfg = ReleaseLTCG-Clang|ARM64 {8906836E-F06E-46E8-B11A-74E5E8C7B8FB}.ReleaseLTCG-Clang|x64.ActiveCfg = ReleaseLTCG-Clang|x64 @@ -1053,7 +1051,6 @@ Global {0A172B2E-DC67-49FC-A4C1-975F93C586C4}.DebugFast-Clang|ARM64.ActiveCfg = DebugFast-Clang|ARM64 {0A172B2E-DC67-49FC-A4C1-975F93C586C4}.DebugFast-Clang|ARM64.Build.0 = DebugFast-Clang|ARM64 {0A172B2E-DC67-49FC-A4C1-975F93C586C4}.DebugFast-Clang|x64.ActiveCfg = DebugFast-Clang|x64 - {0A172B2E-DC67-49FC-A4C1-975F93C586C4}.DebugFast-Clang|x64.Build.0 = DebugFast-Clang|x64 {0A172B2E-DC67-49FC-A4C1-975F93C586C4}.DebugFast-Clang|x86.ActiveCfg = DebugFast-Clang|Win32 {0A172B2E-DC67-49FC-A4C1-975F93C586C4}.DebugFast-Clang|x86.Build.0 = DebugFast-Clang|Win32 {0A172B2E-DC67-49FC-A4C1-975F93C586C4}.Release|ARM64.ActiveCfg = Release|ARM64 @@ -1063,7 +1060,6 @@ Global {0A172B2E-DC67-49FC-A4C1-975F93C586C4}.Release-Clang|ARM64.ActiveCfg = Release-Clang|ARM64 {0A172B2E-DC67-49FC-A4C1-975F93C586C4}.Release-Clang|ARM64.Build.0 = Release-Clang|ARM64 {0A172B2E-DC67-49FC-A4C1-975F93C586C4}.Release-Clang|x64.ActiveCfg = Release-Clang|x64 - {0A172B2E-DC67-49FC-A4C1-975F93C586C4}.Release-Clang|x64.Build.0 = Release-Clang|x64 {0A172B2E-DC67-49FC-A4C1-975F93C586C4}.Release-Clang|x86.ActiveCfg = Release-Clang|Win32 {0A172B2E-DC67-49FC-A4C1-975F93C586C4}.Release-Clang|x86.Build.0 = Release-Clang|Win32 {0A172B2E-DC67-49FC-A4C1-975F93C586C4}.ReleaseLTCG|ARM64.ActiveCfg = ReleaseLTCG|ARM64 @@ -1133,7 +1129,6 @@ Global {3029310E-4211-4C87-801A-72E130A648EF}.DebugFast-Clang|ARM64.ActiveCfg = DebugFast-Clang|ARM64 {3029310E-4211-4C87-801A-72E130A648EF}.DebugFast-Clang|ARM64.Build.0 = DebugFast-Clang|ARM64 {3029310E-4211-4C87-801A-72E130A648EF}.DebugFast-Clang|x64.ActiveCfg = DebugFast-Clang|x64 - {3029310E-4211-4C87-801A-72E130A648EF}.DebugFast-Clang|x64.Build.0 = DebugFast-Clang|x64 {3029310E-4211-4C87-801A-72E130A648EF}.DebugFast-Clang|x86.ActiveCfg = DebugFast-Clang|Win32 {3029310E-4211-4C87-801A-72E130A648EF}.DebugFast-Clang|x86.Build.0 = DebugFast-Clang|Win32 {3029310E-4211-4C87-801A-72E130A648EF}.Release|ARM64.ActiveCfg = Release|ARM64 @@ -1142,7 +1137,6 @@ Global {3029310E-4211-4C87-801A-72E130A648EF}.Release-Clang|ARM64.ActiveCfg = Release-Clang|ARM64 {3029310E-4211-4C87-801A-72E130A648EF}.Release-Clang|ARM64.Build.0 = Release-Clang|ARM64 {3029310E-4211-4C87-801A-72E130A648EF}.Release-Clang|x64.ActiveCfg = Release-Clang|x64 - {3029310E-4211-4C87-801A-72E130A648EF}.Release-Clang|x64.Build.0 = Release-Clang|x64 {3029310E-4211-4C87-801A-72E130A648EF}.Release-Clang|x86.ActiveCfg = Release-Clang|Win32 {3029310E-4211-4C87-801A-72E130A648EF}.Release-Clang|x86.Build.0 = Release-Clang|Win32 {3029310E-4211-4C87-801A-72E130A648EF}.ReleaseLTCG|ARM64.ActiveCfg = ReleaseLTCG|ARM64 diff --git a/src/common/log.cpp b/src/common/log.cpp index a0723a7b2..4e5f18145 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -188,7 +188,8 @@ static ALWAYS_INLINE void FormatLogMessageAndPrintW(const char* channelName, con char* message_buf = buf; int message_len; if ((message_len = FormatLogMessageForDisplay(message_buf, sizeof(buf), channelName, functionName, level, message, - timestamp, ansi_color_code, newline)) > (sizeof(buf) - 1)) + timestamp, ansi_color_code, newline)) > + static_cast(sizeof(buf) - 1)) { message_buf = static_cast(std::malloc(message_len + 1)); message_len = FormatLogMessageForDisplay(message_buf, message_len + 1, channelName, functionName, level, message, @@ -201,8 +202,8 @@ static ALWAYS_INLINE void FormatLogMessageAndPrintW(const char* channelName, con // anyway... wchar_t wbuf[512]; wchar_t* wmessage_buf = wbuf; - int wmessage_buflen = countof(wbuf) - 1; - if (message_len >= countof(wbuf)) + int wmessage_buflen = static_cast(std::size(wbuf) - 1); + if (message_len >= static_cast(std::size(wbuf))) { wmessage_buflen = message_len; wmessage_buf = static_cast(std::malloc((wmessage_buflen + 1) * sizeof(wchar_t))); diff --git a/src/core/analog_controller.cpp b/src/core/analog_controller.cpp index ec09fa215..36d1ab861 100644 --- a/src/core/analog_controller.cpp +++ b/src/core/analog_controller.cpp @@ -839,12 +839,12 @@ static const char* s_invert_settings[] = {TRANSLATE_NOOP("AnalogController", "No static const SettingInfo s_settings[] = { {SettingInfo::Type::Boolean, "ForceAnalogOnReset", TRANSLATE_NOOP("AnalogController", "Force Analog Mode on Reset"), TRANSLATE_NOOP("AnalogController", "Forces the controller to analog mode when the console is reset/powered on."), - "true"}, + "true", nullptr, nullptr, nullptr, nullptr, nullptr, 0.0f}, {SettingInfo::Type::Boolean, "AnalogDPadInDigitalMode", TRANSLATE_NOOP("AnalogController", "Use Analog Sticks for D-Pad in Digital Mode"), TRANSLATE_NOOP("AnalogController", "Allows you to use the analog sticks to control the d-pad in digital mode, as well as the buttons."), - "true"}, + "true", nullptr, nullptr, nullptr, nullptr, nullptr, 0.0f}, {SettingInfo::Type::Float, "AnalogDeadzone", TRANSLATE_NOOP("AnalogController", "Analog Deadzone"), TRANSLATE_NOOP("AnalogController", "Sets the analog stick deadzone, i.e. the fraction of the stick movement which will be ignored."), diff --git a/src/core/cdrom.cpp b/src/core/cdrom.cpp index 404f04c00..656caa7a9 100644 --- a/src/core/cdrom.cpp +++ b/src/core/cdrom.cpp @@ -2099,6 +2099,9 @@ void CDROM::ExecuteCommandSecondResponse(void*, TickCount ticks, TickCount ticks case Command::Stop: DoStatSecondResponse(); break; + + default: + break; } s_command_second_response = Command::None; @@ -2731,7 +2734,6 @@ void CDROM::DoSectorRead() } else { - const CDImage::Position pos(CDImage::Position::FromLBA(s_current_lba)); Log_DevPrintf("Sector %u [%s] has invalid subchannel Q", s_current_lba, LBAToMSFString(s_current_lba).GetCharArray()); } diff --git a/src/core/cpu_code_cache.cpp b/src/core/cpu_code_cache.cpp index 7cf244694..f7e044097 100644 --- a/src/core/cpu_code_cache.cpp +++ b/src/core/cpu_code_cache.cpp @@ -561,7 +561,8 @@ void LogCurrentState() CodeBlockKey GetNextBlockKey() { - CodeBlockKey key = {}; + CodeBlockKey key; + key.bits = 0; key.SetPC(g_state.pc); key.user_mode = InUserMode(); return key; diff --git a/src/core/cpu_code_cache.h b/src/core/cpu_code_cache.h index 026deab1c..62e1783d5 100644 --- a/src/core/cpu_code_cache.h +++ b/src/core/cpu_code_cache.h @@ -31,6 +31,10 @@ union CodeBlockKey ALWAYS_INLINE u32 GetPCPhysicalAddress() const { return (aligned_pc << 2) & PHYSICAL_MEMORY_ADDRESS_MASK; } + ALWAYS_INLINE CodeBlockKey() = default; + + ALWAYS_INLINE CodeBlockKey(const CodeBlockKey& rhs) : bits(rhs.bits) {} + ALWAYS_INLINE CodeBlockKey& operator=(const CodeBlockKey& rhs) { bits = rhs.bits; diff --git a/src/core/cpu_core.cpp b/src/core/cpu_core.cpp index 2c2620565..4102aa33c 100644 --- a/src/core/cpu_core.cpp +++ b/src/core/cpu_core.cpp @@ -1353,7 +1353,7 @@ restart_instruction: WriteRegDelayed(inst.i.rt, sxvalue); if constexpr (pgxp_mode >= PGXPMode::Memory) - PGXP::CPU_LHx(inst.bits, addr, sxvalue); + PGXP::CPU_LH(inst.bits, addr, sxvalue); } break; @@ -1406,7 +1406,7 @@ restart_instruction: WriteRegDelayed(inst.i.rt, zxvalue); if constexpr (pgxp_mode >= PGXPMode::Memory) - PGXP::CPU_LHx(inst.bits, addr, zxvalue); + PGXP::CPU_LHU(inst.bits, addr, zxvalue); } break; diff --git a/src/core/cpu_recompiler_code_generator.cpp b/src/core/cpu_recompiler_code_generator.cpp index cc205e714..361c851a4 100644 --- a/src/core/cpu_recompiler_code_generator.cpp +++ b/src/core/cpu_recompiler_code_generator.cpp @@ -1476,7 +1476,10 @@ bool CodeGenerator::Compile_Load(const CodeBlockInstruction& cbi) ConvertValueSizeInPlace(&result, RegSize_32, (cbi.instruction.op == InstructionOp::lh)); if (g_settings.gpu_pgxp_enable) - EmitFunctionCall(nullptr, PGXP::CPU_LHx, Value::FromConstantU32(cbi.instruction.bits), address, result); + { + EmitFunctionCall(nullptr, (cbi.instruction.op == InstructionOp::lhu) ? &PGXP::CPU_LHU : PGXP::CPU_LH, + Value::FromConstantU32(cbi.instruction.bits), address, result); + } if (address_spec) { diff --git a/src/core/cpu_recompiler_code_generator_x64.cpp b/src/core/cpu_recompiler_code_generator_x64.cpp index 24374d8d7..9c4bc7af2 100644 --- a/src/core/cpu_recompiler_code_generator_x64.cpp +++ b/src/core/cpu_recompiler_code_generator_x64.cpp @@ -303,6 +303,8 @@ void CodeGenerator::EmitSignExtend(HostReg to_reg, RegSize to_size, HostReg from case RegSize_8: m_emit->movsx(GetHostReg16(to_reg), GetHostReg8(from_reg)); return; + default: + break; } } break; @@ -317,14 +319,17 @@ void CodeGenerator::EmitSignExtend(HostReg to_reg, RegSize to_size, HostReg from case RegSize_16: m_emit->movsx(GetHostReg32(to_reg), GetHostReg16(from_reg)); return; + default: + break; } } break; default: - Panic("Unknown sign-extend combination"); break; } + + Panic("Unknown sign-extend combination"); } void CodeGenerator::EmitZeroExtend(HostReg to_reg, RegSize to_size, HostReg from_reg, RegSize from_size) @@ -338,6 +343,8 @@ void CodeGenerator::EmitZeroExtend(HostReg to_reg, RegSize to_size, HostReg from case RegSize_8: m_emit->movzx(GetHostReg16(to_reg), GetHostReg8(from_reg)); return; + default: + break; } } break; @@ -352,9 +359,14 @@ void CodeGenerator::EmitZeroExtend(HostReg to_reg, RegSize to_size, HostReg from case RegSize_16: m_emit->movzx(GetHostReg32(to_reg), GetHostReg16(from_reg)); return; + default: + break; } } break; + + default: + break; } Panic("Unknown sign-extend combination"); @@ -410,6 +422,10 @@ void CodeGenerator::EmitCopyValue(HostReg to_reg, const Value& value) m_emit->mov(GetHostReg64(to_reg), GetHostReg64(value.host_reg)); } break; + + default: + UnreachableCode(); + break; } } @@ -479,6 +495,10 @@ void CodeGenerator::EmitAdd(HostReg to_reg, HostReg from_reg, const Value& value } } break; + + default: + UnreachableCode(); + break; } } @@ -548,6 +568,10 @@ void CodeGenerator::EmitSub(HostReg to_reg, HostReg from_reg, const Value& value } } break; + + default: + UnreachableCode(); + break; } } @@ -605,6 +629,10 @@ void CodeGenerator::EmitCmp(HostReg to_reg, const Value& value) } } break; + + default: + UnreachableCode(); + break; } } @@ -1838,6 +1866,10 @@ void CodeGenerator::EmitLoadGuestRAMFastmem(const Value& address, RegSize size, } } break; + + default: + UnreachableCode(); + break; } } else @@ -1862,6 +1894,10 @@ void CodeGenerator::EmitLoadGuestRAMFastmem(const Value& address, RegSize size, case RegSize_32: m_emit->mov(GetHostReg32(result.host_reg), m_emit->dword[GetHostReg64(RARG1) + GetHostReg64(RARG2)]); break; + + default: + UnreachableCode(); + break; } } } @@ -1936,6 +1972,10 @@ void CodeGenerator::EmitLoadGuestMemoryFastmem(const CodeBlockInstruction& cbi, } } break; + + default: + UnreachableCode(); + break; } } else @@ -1963,6 +2003,10 @@ void CodeGenerator::EmitLoadGuestMemoryFastmem(const CodeBlockInstruction& cbi, case RegSize_32: m_emit->mov(GetHostReg32(result.host_reg), m_emit->dword[GetHostReg64(RARG1) + GetHostReg64(RARG2)]); break; + + default: + UnreachableCode(); + break; } } @@ -2191,6 +2235,10 @@ void CodeGenerator::EmitStoreGuestMemoryFastmem(const CodeBlockInstruction& cbi, } } break; + + default: + UnreachableCode(); + break; } } else @@ -2234,6 +2282,10 @@ void CodeGenerator::EmitStoreGuestMemoryFastmem(const CodeBlockInstruction& cbi, m_emit->mov(m_emit->dword[GetHostReg64(RARG1) + GetHostReg64(RARG2)], GetHostReg32(value.host_reg)); } break; + + default: + UnreachableCode(); + break; } } diff --git a/src/core/digital_controller.cpp b/src/core/digital_controller.cpp index a472982e7..14b16de38 100644 --- a/src/core/digital_controller.cpp +++ b/src/core/digital_controller.cpp @@ -7,7 +7,9 @@ #include "system.h" #include "util/state_wrapper.h" -DigitalController::DigitalController(u32 index) : Controller(index) {} +DigitalController::DigitalController(u32 index) : Controller(index) +{ +} DigitalController::~DigitalController() = default; @@ -164,7 +166,7 @@ static const Controller::ControllerBindingInfo s_binding_info[] = { BUTTON("R1", TRANSLATE_NOOP("DigitalController", "R1"), DigitalController::Button::R1, GenericInputBinding::R1), BUTTON("L2", TRANSLATE_NOOP("DigitalController", "L2"), DigitalController::Button::L2, GenericInputBinding::L2), BUTTON("R2", TRANSLATE_NOOP("DigitalController", "R2"), DigitalController::Button::R2, GenericInputBinding::R2), - // clang-format on +// clang-format on #undef BUTTON }; @@ -172,7 +174,8 @@ static const Controller::ControllerBindingInfo s_binding_info[] = { static const SettingInfo s_settings[] = { {SettingInfo::Type::Boolean, "ForcePopnControllerMode", TRANSLATE_NOOP("DigitalController", "Force Pop'n Controller Mode"), - TRANSLATE_NOOP("DigitalController", "Forces the Digital Controller to act as a Pop'n Controller."), "false"}}; + TRANSLATE_NOOP("DigitalController", "Forces the Digital Controller to act as a Pop'n Controller."), "false", nullptr, + nullptr, nullptr, nullptr, nullptr, 0.0f}}; const Controller::ControllerInfo DigitalController::INFO = {ControllerType::DigitalController, "DigitalController", diff --git a/src/core/dma.cpp b/src/core/dma.cpp index 26f96fe67..e628c5846 100644 --- a/src/core/dma.cpp +++ b/src/core/dma.cpp @@ -38,7 +38,7 @@ enum class SyncMode : u32 }; static constexpr PhysicalMemoryAddress BASE_ADDRESS_MASK = UINT32_C(0x00FFFFFF); -static constexpr PhysicalMemoryAddress ADDRESS_MASK = UINT32_C(0x001FFFFC); +// static constexpr PhysicalMemoryAddress ADDRESS_MASK = UINT32_C(0x001FFFFC); static u32 GetAddressMask(); static void ClearState(); diff --git a/src/core/fullscreen_ui.cpp b/src/core/fullscreen_ui.cpp index 72eb4bfcb..51bafc967 100644 --- a/src/core/fullscreen_ui.cpp +++ b/src/core/fullscreen_ui.cpp @@ -4330,6 +4330,9 @@ void FullscreenUI::DrawPostProcessingSettingsPage() ImGui::PopFont(); } break; + + default: + break; } } @@ -4590,9 +4593,10 @@ void FullscreenUI::DrawAchievementsLoginWindow() if (ImGui::BeginPopupModal("Achievements Login", &is_open, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize)) { - ImGui::TextWrapped(FSUI_CSTR("Please enter your user name and password for retroachievements.org.")); + ImGui::TextWrapped("%s", FSUI_CSTR("Please enter your user name and password for retroachievements.org.")); ImGui::NewLine(); ImGui::TextWrapped( + "%s", FSUI_CSTR("Your password will not be saved in DuckStation, an access token will be generated and used instead.")); ImGui::NewLine(); @@ -4600,11 +4604,11 @@ void FullscreenUI::DrawAchievementsLoginWindow() static char username[256] = {}; static char password[256] = {}; - ImGui::Text(FSUI_CSTR("User Name: ")); + ImGui::TextUnformatted(FSUI_CSTR("User Name: ")); ImGui::SameLine(LayoutScale(200.0f)); ImGui::InputText("##username", username, sizeof(username)); - ImGui::Text(FSUI_CSTR("Password: ")); + ImGui::TextUnformatted(FSUI_CSTR("Password: ")); ImGui::SameLine(LayoutScale(200.0f)); ImGui::InputText("##password", password, sizeof(password), ImGuiInputTextFlags_Password); @@ -5260,7 +5264,6 @@ void FullscreenUI::DrawSaveStateSelector(bool is_loading) 0.5f; u32 grid_x = 0; - u32 grid_y = 0; ImGui::SetCursorPos(ImVec2(start_x, 0.0f)); for (u32 i = 0; i < s_save_state_selector_slots.size(); i++) { @@ -5455,7 +5458,6 @@ void FullscreenUI::DrawSaveStateSelector(bool is_loading) if (grid_x == grid_count_x) { grid_x = 0; - grid_y++; ImGui::SetCursorPosX(start_x); ImGui::SetCursorPosY(ImGui::GetCursorPosY() + item_spacing); } @@ -5996,7 +5998,6 @@ void FullscreenUI::DrawGameGrid(const ImVec2& heading_size) SmallString draw_title; u32 grid_x = 0; - u32 grid_y = 0; ImGui::SetCursorPos(ImVec2(start_x, 0.0f)); for (const GameList::Entry* entry : s_game_list_sorted_entries) { @@ -6060,7 +6061,6 @@ void FullscreenUI::DrawGameGrid(const ImVec2& heading_size) if (grid_x == grid_count_x) { grid_x = 0; - grid_y++; ImGui::SetCursorPosX(start_x); ImGui::SetCursorPosY(ImGui::GetCursorPosY() + item_spacing); } @@ -6452,18 +6452,19 @@ void FullscreenUI::DrawAboutWindow() if (ImGui::BeginPopupModal(FSUI_CSTR("About DuckStation"), &s_about_window_open, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize)) { - ImGui::TextWrapped(FSUI_CSTR("DuckStation is a free and open-source simulator/emulator of the Sony PlayStation(TM) " + ImGui::TextWrapped("%s", + FSUI_CSTR("DuckStation is a free and open-source simulator/emulator of the Sony PlayStation(TM) " "console, focusing on playability, speed, and long-term maintainability.")); ImGui::NewLine(); ImGui::TextWrapped( - FSUI_CSTR("Contributor List: https://github.com/stenzek/duckstation/blob/master/CONTRIBUTORS.md")); + "%s", FSUI_CSTR("Contributor List: https://github.com/stenzek/duckstation/blob/master/CONTRIBUTORS.md")); ImGui::NewLine(); ImGui::TextWrapped( - FSUI_CSTR("Duck icon by icons8 (https://icons8.com/icon/74847/platforms.undefined.short-title)")); + "%s", FSUI_CSTR("Duck icon by icons8 (https://icons8.com/icon/74847/platforms.undefined.short-title)")); ImGui::NewLine(); ImGui::TextWrapped( - FSUI_CSTR("\"PlayStation\" and \"PSX\" are registered trademarks of Sony Interactive Entertainment Europe " - "Limited. This software is not affiliated in any way with Sony Interactive Entertainment.")); + "%s", FSUI_CSTR("\"PlayStation\" and \"PSX\" are registered trademarks of Sony Interactive Entertainment Europe " + "Limited. This software is not affiliated in any way with Sony Interactive Entertainment.")); ImGui::NewLine(); diff --git a/src/core/gpu.cpp b/src/core/gpu.cpp index a3ce829f9..06550446e 100644 --- a/src/core/gpu.cpp +++ b/src/core/gpu.cpp @@ -331,6 +331,15 @@ void GPU::UpdateDMARequest() m_GPUSTAT.ready_to_send_vram = true; m_GPUSTAT.ready_to_recieve_dma = m_fifo.IsEmpty(); break; + + case BlitterState::DrawingPolyLine: + m_GPUSTAT.ready_to_send_vram = false; + m_GPUSTAT.ready_to_recieve_dma = (m_fifo.GetSize() < m_fifo_size); + break; + + default: + UnreachableCode(); + break; } bool dma_request; @@ -375,6 +384,14 @@ void GPU::UpdateGPUIdle() case BlitterState::ReadingVRAM: m_GPUSTAT.gpu_idle = false; break; + + case BlitterState::DrawingPolyLine: + m_GPUSTAT.gpu_idle = false; + break; + + default: + UnreachableCode(); + break; } } @@ -1657,7 +1674,6 @@ bool GPU::RenderDisplay(GPUFramebuffer* target, const Common::Rectangle& dr m_display_texture->MakeReadyForSampling(); bool texture_filter_linear = false; - bool bilinear_adjust = false; struct Uniforms { @@ -1676,7 +1692,6 @@ bool GPU::RenderDisplay(GPUFramebuffer* target, const Common::Rectangle& dr case DisplayScalingMode::BilinearSmooth: texture_filter_linear = true; - bilinear_adjust = true; break; case DisplayScalingMode::BilinearSharp: diff --git a/src/core/gpu_sw_backend.cpp b/src/core/gpu_sw_backend.cpp index 9ab9e2b6c..8d839497d 100644 --- a/src/core/gpu_sw_backend.cpp +++ b/src/core/gpu_sw_backend.cpp @@ -6,11 +6,7 @@ #include "util/gpu_device.h" -#include "common/assert.h" -#include "common/log.h" - #include -Log_SetChannel(GPU_SW_Backend); GPU_SW_Backend::GPU_SW_Backend() : GPUBackend() { @@ -209,6 +205,9 @@ void ALWAYS_INLINE_RELEASE GPU_SW_Backend::ShadePixel(const GPUBackendDrawComman color.bits = Truncate16((sum - carry) | (carry - (carry >> 5))); } break; + + default: + break; } // See above. diff --git a/src/core/guncon.cpp b/src/core/guncon.cpp index e06aec1d2..efd72dfa8 100644 --- a/src/core/guncon.cpp +++ b/src/core/guncon.cpp @@ -10,12 +10,14 @@ #include "util/state_wrapper.h" #include "common/assert.h" -#include "common/log.h" #include "common/path.h" #include +#ifdef _DEBUG +#include "common/log.h" Log_SetChannel(GunCon); +#endif static constexpr std::array(GunCon::Button::Count)> s_button_indices = {{13, 3, 14}}; @@ -230,7 +232,8 @@ static const Controller::ControllerBindingInfo s_binding_info[] = { static const SettingInfo s_settings[] = { {SettingInfo::Type::Path, "CrosshairImagePath", TRANSLATE_NOOP("GunCon", "Crosshair Image Path"), - TRANSLATE_NOOP("GunCon", "Path to an image to use as a crosshair/cursor.")}, + TRANSLATE_NOOP("GunCon", "Path to an image to use as a crosshair/cursor."), nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr, 0.0f}, {SettingInfo::Type::Float, "CrosshairScale", TRANSLATE_NOOP("GunCon", "Crosshair Image Scale"), TRANSLATE_NOOP("GunCon", "Scale of crosshair image on screen."), "1.0", "0.0001", "100.0", "0.10", "%.0f%%", nullptr, 100.0f}, diff --git a/src/core/pgxp.cpp b/src/core/pgxp.cpp index 06935bd95..cee58a4a7 100644 --- a/src/core/pgxp.cpp +++ b/src/core/pgxp.cpp @@ -1,30 +1,16 @@ -/*************************************************************************** - * Original copyright notice from PGXP code from Beetle PSX. * - * Copyright (C) 2016 by iCatButler * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - ***************************************************************************/ +// SPDX-FileCopyrightText: 2016 iCatButler, 2019-2023 Connor McLaughlin +// SPDX-License-Identifier: GPL-2.0+ #include "pgxp.h" #include "bus.h" -#include "common/log.h" #include "cpu_core.h" #include "settings.h" + +#include "common/log.h" + #include #include + Log_SetChannel(PGXP); namespace PGXP { @@ -50,19 +36,19 @@ enum : u32 #define VALID_ALL (VALID_0 | VALID_1 | VALID_2 | VALID_3) #define INV_VALID_ALL (ALL ^ VALID_ALL) -typedef struct PGXP_value_Tag +struct PGXP_value { float x; float y; float z; union { - unsigned int flags; - unsigned char compFlags[4]; - unsigned short halfFlags[2]; + u32 flags; + u8 compFlags[4]; + u16 halfFlags[2]; }; - unsigned int value; -} PGXP_value; + u32 value; +}; typedef union { @@ -184,7 +170,7 @@ ALWAYS_INLINE_RELEASE void ValidateAndCopyMem(PGXP_value* dest, u32 addr, u32 va *dest = PGXP_value_invalid; } -ALWAYS_INLINE_RELEASE static void ValidateAndCopyMem16(PGXP_value* dest, u32 addr, u32 value, int sign) +ALWAYS_INLINE_RELEASE static void ValidateAndCopyMem16(PGXP_value* dest, u32 addr, u32 value, bool sign) { u32 validMask = 0; psx_value val, mask; @@ -333,13 +319,13 @@ void Shutdown() } // Instruction register decoding -#define op(_instr) (_instr >> 26) // The op part of the instruction register -#define func(_instr) ((_instr)&0x3F) // The funct part of the instruction register -#define sa(_instr) ((_instr >> 6) & 0x1F) // The sa part of the instruction register +#define op(_instr) (_instr >> 26) // The op part of the instruction register +#define func(_instr) ((_instr)&0x3F) // The funct part of the instruction register +#define sa(_instr) ((_instr >> 6) & 0x1F) // The sa part of the instruction register #define rd(_instr) ((_instr >> 11) & 0x1F) // The rd part of the instruction register #define rt(_instr) ((_instr >> 16) & 0x1F) // The rt part of the instruction register #define rs(_instr) ((_instr >> 21) & 0x1F) // The rs part of the instruction register -#define imm(_instr) (_instr & 0xFFFF) // The immediate part of the instruction register +#define imm(_instr) (_instr & 0xFFFF) // The immediate part of the instruction register #define cop2idx(_instr) (((_instr >> 11) & 0x1F) | ((_instr >> 17) & 0x20)) #define SX0 (GTE_regs[12].x) @@ -548,13 +534,13 @@ bool GetPreciseVertex(u32 addr, u32 value, int x, int y, int xOffs, int yOffs, f } // Instruction register decoding -#define op(_instr) (_instr >> 26) // The op part of the instruction register -#define func(_instr) ((_instr)&0x3F) // The funct part of the instruction register -#define sa(_instr) ((_instr >> 6) & 0x1F) // The sa part of the instruction register +#define op(_instr) (_instr >> 26) // The op part of the instruction register +#define func(_instr) ((_instr)&0x3F) // The funct part of the instruction register +#define sa(_instr) ((_instr >> 6) & 0x1F) // The sa part of the instruction register #define rd(_instr) ((_instr >> 11) & 0x1F) // The rd part of the instruction register #define rt(_instr) ((_instr >> 16) & 0x1F) // The rt part of the instruction register #define rs(_instr) ((_instr >> 21) & 0x1F) // The rs part of the instruction register -#define imm(_instr) (_instr & 0xFFFF) // The immediate part of the instruction register +#define imm(_instr) (_instr & 0xFFFF) // The immediate part of the instruction register #define imm_sext(_instr) \ static_cast(static_cast(_instr & 0xFFFF)) // The immediate part of the instruction register @@ -569,10 +555,16 @@ void CPU_LBx(u32 instr, u32 addr, u32 rtVal) CPU_reg[rt(instr)] = PGXP_value_invalid; } -void CPU_LHx(u32 instr, u32 addr, u32 rtVal) +void CPU_LH(u32 instr, u32 addr, u32 rtVal) { - // Rt = Mem[Rs + Im] (sign/zero extended) - ValidateAndCopyMem16(&CPU_reg[rt(instr)], addr, rtVal, 1); + // Rt = Mem[Rs + Im] (sign extended) + ValidateAndCopyMem16(&CPU_reg[rt(instr)], addr, rtVal, true); +} + +void CPU_LHU(u32 instr, u32 addr, u32 rtVal) +{ + // Rt = Mem[Rs + Im] (zero extended) + ValidateAndCopyMem16(&CPU_reg[rt(instr)], addr, rtVal, false); } void CPU_SB(u32 instr, u32 addr, u32 rtVal) @@ -782,7 +774,15 @@ void CPU_ADD(u32 instr, u32 rsVal, u32 rtVal) Validate(&CPU_reg[rs(instr)], rsVal); Validate(&CPU_reg[rt(instr)], rtVal); - if (rtVal != 0) + if (rtVal == 0) + { + ret = CPU_reg[rs(instr)]; + } + else if (rsVal == 0) + { + ret = CPU_reg[rt(instr)]; + } + else { // iCB: Only require one valid input if (((CPU_reg[rt(instr)].flags & VALID_01) != VALID_01) != ((CPU_reg[rs(instr)].flags & VALID_01) != VALID_01)) @@ -809,10 +809,6 @@ void CPU_ADD(u32 instr, u32 rsVal, u32 rtVal) ret.halfFlags[0] &= CPU_reg[rt(instr)].halfFlags[0]; } - else - { - ret = CPU_reg[rs(instr)]; - } ret.value = rsVal + rtVal; diff --git a/src/core/pgxp.h b/src/core/pgxp.h index fb7037c8d..f7774e46d 100644 --- a/src/core/pgxp.h +++ b/src/core/pgxp.h @@ -1,22 +1,5 @@ -/*************************************************************************** - * Original copyright notice from PGXP code from Beetle PSX. * - * Copyright (C) 2016 by iCatButler * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - ***************************************************************************/ +// SPDX-FileCopyrightText: 2016 iCatButler, 2019-2023 Connor McLaughlin +// SPDX-License-Identifier: GPL-2.0+ #pragma once #include "types.h" @@ -45,7 +28,8 @@ bool GetPreciseVertex(u32 addr, u32 value, int x, int y, int xOffs, int yOffs, f // -- CPU functions void CPU_LW(u32 instr, u32 addr, u32 rtVal); -void CPU_LHx(u32 instr, u32 addr, u32 rtVal); +void CPU_LH(u32 instr, u32 addr, u32 rtVal); +void CPU_LHU(u32 instr, u32 addr, u32 rtVal); void CPU_LBx(u32 instr, u32 addr, u32 rtVal); void CPU_SB(u32 instr, u32 addr, u32 rtVal); void CPU_SH(u32 instr, u32 addr, u32 rtVal); diff --git a/src/core/playstation_mouse.cpp b/src/core/playstation_mouse.cpp index f01e68b33..68025b12a 100644 --- a/src/core/playstation_mouse.cpp +++ b/src/core/playstation_mouse.cpp @@ -191,14 +191,15 @@ static const Controller::ControllerBindingInfo s_binding_info[] = { // clang-format off BUTTON("Left", TRANSLATE_NOOP("PlayStationMouse", "Left Button"), PlayStationMouse::Button::Left, GenericInputBinding::Cross), BUTTON("Right", TRANSLATE_NOOP("PlayStationMouse", "Right Button"), PlayStationMouse::Button::Right, GenericInputBinding::Circle), - // clang-format on +// clang-format on #undef BUTTON }; static const SettingInfo s_settings[] = { {SettingInfo::Type::Boolean, "RelativeMouseMode", TRANSLATE_NOOP("PlayStationMouse", "Relative Mouse Mode"), - TRANSLATE_NOOP("PlayStationMouse", "Locks the mouse cursor to the window, use for FPS games."), "false"}, + TRANSLATE_NOOP("PlayStationMouse", "Locks the mouse cursor to the window, use for FPS games."), "false", nullptr, + nullptr, nullptr, nullptr, nullptr, 0.0f}, }; const Controller::ControllerInfo PlayStationMouse::INFO = {ControllerType::PlayStationMouse, diff --git a/src/core/system.cpp b/src/core/system.cpp index fb3d1b6b1..5efe29b42 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -101,8 +101,6 @@ static std::string GetExecutableNameForImage(ISOReader& iso, bool strip_subdirec static bool ReadExecutableFromImage(ISOReader& iso, std::string* out_executable_name, std::vector* out_executable_data); -static void StallCPU(TickCount ticks); - static bool LoadBIOS(const std::string& override_bios_path); static void InternalReset(); static void ClearRunningGame(); @@ -2927,10 +2925,6 @@ bool SetExpansionROM(const char* filename) return true; } -void System::StallCPU(TickCount ticks) -{ - CPU::AddPendingTicks(ticks); -} #endif Controller* System::GetController(u32 slot) @@ -3207,6 +3201,10 @@ void System::UpdateMultitaps() Pad::GetMultitap(1)->SetEnable(true, 4); } break; + + default: + UnreachableCode(); + break; } } diff --git a/src/core/system.h b/src/core/system.h index 24c789a03..49b81da7b 100644 --- a/src/core/system.h +++ b/src/core/system.h @@ -27,8 +27,7 @@ struct ImageInfo; struct Hash; } // namespace BIOS -namespace GameDatabase -{ +namespace GameDatabase { struct Entry; } @@ -79,7 +78,10 @@ enum : u32 { // 5 megabytes is sufficient for now, at the moment they're around 4.3MB, or 10.3MB with 8MB RAM enabled. MAX_SAVE_STATE_SIZE = 11 * 1024 * 1024, +}; +enum : s32 +{ PER_GAME_SAVE_STATE_SLOTS = 10, GLOBAL_SAVE_STATE_SLOTS = 10 }; @@ -477,8 +479,7 @@ void UpdateMemorySaveStateSettings(); bool LoadRewindState(u32 skip_saves = 0, bool consume_state = true); void SetRunaheadReplayFlag(); -namespace Internal -{ +namespace Internal { /// Called on process startup. void ProcessStartup(); @@ -487,7 +488,7 @@ void ProcessShutdown(); /// Polls input, updates subsystems which are present while paused/inactive. void IdlePollUpdate(); -} +} // namespace Internal } // namespace System diff --git a/src/core/timers.cpp b/src/core/timers.cpp index 6289f2283..3bef04139 100644 --- a/src/core/timers.cpp +++ b/src/core/timers.cpp @@ -177,6 +177,9 @@ void Timers::SetGate(u32 timer, bool state) case SyncMode::FreeRunOnGate: cs.mode.sync_enable = false; break; + + default: + break; } } diff --git a/src/duckstation-nogui/nogui_host.cpp b/src/duckstation-nogui/nogui_host.cpp index 701c3e1f6..42a5ea10a 100644 --- a/src/duckstation-nogui/nogui_host.cpp +++ b/src/duckstation-nogui/nogui_host.cpp @@ -758,6 +758,7 @@ void Host::OnAchievementsRefreshed() void Host::SetMouseMode(bool relative, bool hide_cursor) { +#if 0 // TODO: Find a better home for this. if (InputManager::HasPointerAxisBinds()) { @@ -766,6 +767,7 @@ void Host::SetMouseMode(bool relative, bool hide_cursor) } // emit g_emu_thread->mouseModeRequested(relative, hide_cursor); +#endif } void Host::PumpMessagesOnCPUThread() diff --git a/src/duckstation-nogui/win32_nogui_platform.cpp b/src/duckstation-nogui/win32_nogui_platform.cpp index 3526d657a..b32da90ce 100644 --- a/src/duckstation-nogui/win32_nogui_platform.cpp +++ b/src/duckstation-nogui/win32_nogui_platform.cpp @@ -2,19 +2,21 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "win32_nogui_platform.h" -#include "common/log.h" -#include "common/scoped_guard.h" -#include "common/string_util.h" -#include "common/threading.h" -#include "core/host.h" -#include "util/imgui_manager.h" #include "nogui_host.h" #include "resource.h" #include "win32_key_names.h" + +#include "core/host.h" + +#include "util/imgui_manager.h" + +#include "common/scoped_guard.h" +#include "common/string_util.h" +#include "common/threading.h" + #include #include #include -Log_SetChannel(Win32HostInterface); static constexpr LPCWSTR WINDOW_CLASS_NAME = L"DuckStationNoGUI"; static constexpr DWORD WINDOWED_STYLE = WS_OVERLAPPEDWINDOW | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU | WS_SIZEBOX; @@ -126,7 +128,8 @@ bool Win32NoGUIPlatform::CreatePlatformWindow(std::string title) SetFullscreen(true); // We use these notifications to detect when a controller is connected or disconnected. - DEV_BROADCAST_DEVICEINTERFACE_W filter = {sizeof(DEV_BROADCAST_DEVICEINTERFACE_W), DBT_DEVTYP_DEVICEINTERFACE}; + DEV_BROADCAST_DEVICEINTERFACE_W filter = { + sizeof(DEV_BROADCAST_DEVICEINTERFACE_W), DBT_DEVTYP_DEVICEINTERFACE, 0, {}, {}}; m_dev_notify_handle = RegisterDeviceNotificationW(hwnd, &filter, DEVICE_NOTIFY_WINDOW_HANDLE | DEVICE_NOTIFY_ALL_INTERFACE_CLASSES); @@ -247,7 +250,7 @@ void Win32NoGUIPlatform::SetFullscreen(bool enabled) if (!monitor) return; - MONITORINFO mi = {sizeof(MONITORINFO)}; + MONITORINFO mi = {sizeof(MONITORINFO), {}, {}, 0u}; if (!GetMonitorInfo(monitor, &mi) || !GetWindowRect(m_hwnd, &m_windowed_rect)) return; diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 8c10dfe09..0401f8ea4 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -174,7 +174,8 @@ void MainWindow::registerForDeviceNotifications() { #ifdef _WIN32 // We use these notifications to detect when a controller is connected or disconnected. - DEV_BROADCAST_DEVICEINTERFACE_W filter = {sizeof(DEV_BROADCAST_DEVICEINTERFACE_W), DBT_DEVTYP_DEVICEINTERFACE}; + DEV_BROADCAST_DEVICEINTERFACE_W filter = { + sizeof(DEV_BROADCAST_DEVICEINTERFACE_W), DBT_DEVTYP_DEVICEINTERFACE, 0u, {}, {}}; m_device_notification_handle = RegisterDeviceNotificationW( (HANDLE)winId(), &filter, DEVICE_NOTIFY_WINDOW_HANDLE | DEVICE_NOTIFY_ALL_INTERFACE_CLASSES); #endif diff --git a/src/duckstation-qt/settingsdialog.cpp b/src/duckstation-qt/settingsdialog.cpp index aa7adebb6..b85a3a45b 100644 --- a/src/duckstation-qt/settingsdialog.cpp +++ b/src/duckstation-qt/settingsdialog.cpp @@ -213,7 +213,7 @@ void SettingsDialog::setCategory(const char* category) void SettingsDialog::onCategoryCurrentRowChanged(int row) { - DebugAssert(row < MAX_SETTINGS_WIDGETS); + DebugAssert(row < static_cast(MAX_SETTINGS_WIDGETS)); m_ui.settingsContainer->setCurrentIndex(row); m_ui.helpText->setText(m_category_help_text[row]); } diff --git a/src/duckstation-regtest/regtest_host.cpp b/src/duckstation-regtest/regtest_host.cpp index 3d3cc5144..164864b07 100644 --- a/src/duckstation-regtest/regtest_host.cpp +++ b/src/duckstation-regtest/regtest_host.cpp @@ -34,7 +34,6 @@ static void PrintCommandLineHelp(const char* progname); static bool InitializeConfig(); static void InitializeEarlyConsole(); static void HookSignals(); -static void SetAppRoot(); static bool SetFolders(); static std::string GetFrameDumpFilename(u32 frame); } // namespace RegTestHost diff --git a/src/util/cd_image.h b/src/util/cd_image.h index 4b7a10beb..fd4a5e6de 100644 --- a/src/util/cd_image.h +++ b/src/util/cd_image.h @@ -144,6 +144,12 @@ public: BitField data; BitField four_channel_audio; + Control() = default; + + Control(u8 bits_) : bits(bits_) {} + + Control(const Control& rhs) : bits(rhs.bits) {} + Control& operator=(const Control& rhs) { bits = rhs.bits; @@ -170,11 +176,15 @@ public: static u16 ComputeCRC(const Data& data); - Control GetControl() const { return Control{control_bits}; } + Control GetControl() const { return Control(control_bits); } bool IsData() const { return GetControl().data; } bool IsCRCValid() const; + SubChannelQ() = default; + + SubChannelQ(const SubChannelQ& q) : data(q.data) {} + SubChannelQ& operator=(const SubChannelQ& q) { data = q.data; @@ -233,42 +243,15 @@ public: ProgressCallback* progress = ProgressCallback::NullProgressCallback); // Accessors. - const std::string& GetFileName() const - { - return m_filename; - } - LBA GetPositionOnDisc() const - { - return m_position_on_disc; - } - Position GetMSFPositionOnDisc() const - { - return Position::FromLBA(m_position_on_disc); - } - LBA GetPositionInTrack() const - { - return m_position_in_track; - } - Position GetMSFPositionInTrack() const - { - return Position::FromLBA(m_position_in_track); - } - LBA GetLBACount() const - { - return m_lba_count; - } - u32 GetIndexNumber() const - { - return m_current_index->index_number; - } - u32 GetTrackNumber() const - { - return m_current_index->track_number; - } - u32 GetTrackCount() const - { - return static_cast(m_tracks.size()); - } + const std::string& GetFileName() const { return m_filename; } + LBA GetPositionOnDisc() const { return m_position_on_disc; } + Position GetMSFPositionOnDisc() const { return Position::FromLBA(m_position_on_disc); } + LBA GetPositionInTrack() const { return m_position_in_track; } + Position GetMSFPositionInTrack() const { return Position::FromLBA(m_position_in_track); } + LBA GetLBACount() const { return m_lba_count; } + u32 GetIndexNumber() const { return m_current_index->index_number; } + u32 GetTrackNumber() const { return m_current_index->track_number; } + u32 GetTrackCount() const { return static_cast(m_tracks.size()); } LBA GetTrackStartPosition(u8 track) const; Position GetTrackStartMSFPosition(u8 track) const; LBA GetTrackLength(u8 track) const; @@ -276,26 +259,11 @@ public: TrackMode GetTrackMode(u8 track) const; LBA GetTrackIndexPosition(u8 track, u8 index) const; LBA GetTrackIndexLength(u8 track, u8 index) const; - u32 GetFirstTrackNumber() const - { - return m_tracks.front().track_number; - } - u32 GetLastTrackNumber() const - { - return m_tracks.back().track_number; - } - u32 GetIndexCount() const - { - return static_cast(m_indices.size()); - } - const std::vector& GetTracks() const - { - return m_tracks; - } - const std::vector& GetIndices() const - { - return m_indices; - } + u32 GetFirstTrackNumber() const { return m_tracks.front().track_number; } + u32 GetLastTrackNumber() const { return m_tracks.back().track_number; } + u32 GetIndexCount() const { return static_cast(m_indices.size()); } + const std::vector& GetTracks() const { return m_tracks; } + const std::vector& GetIndices() const { return m_indices; } const Track& GetTrack(u32 track) const; const Index& GetIndex(u32 i) const; diff --git a/src/util/cd_image_device.cpp b/src/util/cd_image_device.cpp index 2b4363d72..baa360dda 100644 --- a/src/util/cd_image_device.cpp +++ b/src/util/cd_image_device.cpp @@ -135,8 +135,8 @@ bool CDImageDeviceWin32::Open(const char* filename, Error* error) } // Set it to 4x speed. A good balance between readahead and spinning up way too high. - static constexpr u32 READ_SPEED_MULTIPLIER = 4; - static constexpr u32 READ_SPEED_KBS = (DATA_SECTOR_SIZE * FRAMES_PER_SECOND * 8) / 1024; + static constexpr u32 READ_SPEED_MULTIPLIER = 8; + static constexpr u32 READ_SPEED_KBS = (DATA_SECTOR_SIZE * FRAMES_PER_SECOND * READ_SPEED_MULTIPLIER) / 1024; CDROM_SET_SPEED set_speed = {CdromSetSpeed, READ_SPEED_KBS, 0, CdromDefaultRotation}; if (!DeviceIoControl(m_hDevice, IOCTL_CDROM_SET_SPEED, &set_speed, sizeof(set_speed), nullptr, 0, nullptr, nullptr)) Log_WarningPrintf("DeviceIoControl(IOCTL_CDROM_SET_SPEED) failed: %08X", GetLastError()); diff --git a/src/util/d3d11_device.cpp b/src/util/d3d11_device.cpp index 559e86608..a04f7ffd7 100644 --- a/src/util/d3d11_device.cpp +++ b/src/util/d3d11_device.cpp @@ -33,7 +33,7 @@ void SetD3DDebugObjectName(ID3D11DeviceChild* obj, const std::string_view& name) { #ifdef _DEBUG // WKPDID_D3DDebugObjectName - static constexpr GUID guid = {0x429b8c22, 0x9188, 0x4b0c, 0x87, 0x42, 0xac, 0xb0, 0xbf, 0x85, 0xc2, 0x00}; + static constexpr GUID guid = {0x429b8c22, 0x9188, 0x4b0c, {0x87, 0x42, 0xac, 0xb0, 0xbf, 0x85, 0xc2, 0x00}}; UINT existing_data_size; HRESULT hr = obj->GetPrivateData(guid, &existing_data_size, nullptr); @@ -581,7 +581,7 @@ bool D3D11Device::BeginPresent(bool skip_present) { if (skip_present) return false; - + if (!m_swap_chain) { // Note: Really slow on Intel... diff --git a/src/util/d3d11_pipeline.cpp b/src/util/d3d11_pipeline.cpp index 0200e3749..c115366c3 100644 --- a/src/util/d3d11_pipeline.cpp +++ b/src/util/d3d11_pipeline.cpp @@ -82,10 +82,11 @@ std::unique_ptr D3D11Device::CreateShaderFromBinary(GPUShaderStage st default: UnreachableCode(); + hr = S_FALSE; break; } - if (!shader) + if (FAILED(hr) || !shader) return {}; return std::unique_ptr(new D3D11Shader(stage, std::move(shader), std::move(bytecode))); diff --git a/src/util/d3d12_descriptor_heap_manager.cpp b/src/util/d3d12_descriptor_heap_manager.cpp index 8ebb3ed05..3e73823d2 100644 --- a/src/util/d3d12_descriptor_heap_manager.cpp +++ b/src/util/d3d12_descriptor_heap_manager.cpp @@ -16,7 +16,7 @@ bool D3D12DescriptorHeapManager::Create(ID3D12Device* device, D3D12_DESCRIPTOR_H { D3D12_DESCRIPTOR_HEAP_DESC desc = {type, static_cast(num_descriptors), shader_visible ? D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE : - D3D12_DESCRIPTOR_HEAP_FLAG_NONE}; + D3D12_DESCRIPTOR_HEAP_FLAG_NONE, 0u}; HRESULT hr = device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(m_descriptor_heap.ReleaseAndGetAddressOf())); if (FAILED(hr)) @@ -44,10 +44,12 @@ bool D3D12DescriptorHeapManager::Create(ID3D12Device* device, D3D12_DESCRIPTOR_H void D3D12DescriptorHeapManager::Destroy() { +#ifdef _DEBUG for (BitSetType& bs : m_free_slots) { DebugAssert(bs.all()); } +#endif m_shader_visible = false; m_num_descriptors = 0; @@ -111,7 +113,7 @@ D3D12DescriptorAllocator::~D3D12DescriptorAllocator() = default; bool D3D12DescriptorAllocator::Create(ID3D12Device* device, D3D12_DESCRIPTOR_HEAP_TYPE type, u32 num_descriptors) { const D3D12_DESCRIPTOR_HEAP_DESC desc = {type, static_cast(num_descriptors), - D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE}; + D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, 0u}; const HRESULT hr = device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(m_descriptor_heap.ReleaseAndGetAddressOf())); if (FAILED(hr)) { diff --git a/src/util/d3d12_device.cpp b/src/util/d3d12_device.cpp index b96012f20..fe40e9094 100644 --- a/src/util/d3d12_device.cpp +++ b/src/util/d3d12_device.cpp @@ -58,7 +58,7 @@ enum : u32 // We need to synchronize instance creation because of adapter enumeration from the UI thread. static std::mutex s_instance_mutex; -static constexpr D3D12_CLEAR_VALUE s_present_clear_color = {DXGI_FORMAT_R8G8B8A8_UNORM, {0.0f, 0.0f, 0.0f, 1.0f}}; +static constexpr D3D12_CLEAR_VALUE s_present_clear_color = {DXGI_FORMAT_R8G8B8A8_UNORM, {{0.0f, 0.0f, 0.0f, 1.0f}}}; static constexpr GPUTexture::Format s_swap_chain_format = GPUTexture::Format::RGBA8; // We just need to keep this alive, never reference it. @@ -82,19 +82,6 @@ D3D12Device::~D3D12Device() Assert(s_pipeline_cache_data.empty()); } -static constexpr u32 GetActiveTexturesForLayout(GPUPipeline::Layout layout) -{ - constexpr std::array(GPUPipeline::Layout::MaxCount)> counts = { - 1, // SingleTextureAndUBO - 1, // SingleTextureAndPushConstants - 0, // SingleTextureBufferAndPushConstants - GPUDevice::MAX_TEXTURE_SAMPLERS, // MultiTextureAndUBO - GPUDevice::MAX_TEXTURE_SAMPLERS, // MultiTextureAndPushConstants - }; - - return counts[static_cast(layout)]; -} - D3D12Device::ComPtr D3D12Device::SerializeRootSignature(const D3D12_ROOT_SIGNATURE_DESC* desc) { ComPtr blob; @@ -202,7 +189,7 @@ bool D3D12Device::CreateDevice(const std::string_view& adapter, bool threaded_pr } const D3D12_COMMAND_QUEUE_DESC queue_desc = {D3D12_COMMAND_LIST_TYPE_DIRECT, D3D12_COMMAND_QUEUE_PRIORITY_NORMAL, - D3D12_COMMAND_QUEUE_FLAG_NONE}; + D3D12_COMMAND_QUEUE_FLAG_NONE, 0u}; hr = m_device->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&m_command_queue)); if (FAILED(hr)) { @@ -468,8 +455,8 @@ bool D3D12Device::CreateDescriptorHeaps() } // Allocate null SRV descriptor for unbound textures. - constexpr D3D12_SHADER_RESOURCE_VIEW_DESC null_srv_desc = {DXGI_FORMAT_R8G8B8A8_UNORM, D3D12_SRV_DIMENSION_TEXTURE2D, - D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING}; + static constexpr D3D12_SHADER_RESOURCE_VIEW_DESC null_srv_desc = { + DXGI_FORMAT_R8G8B8A8_UNORM, D3D12_SRV_DIMENSION_TEXTURE2D, D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING, {}}; if (!m_descriptor_heap_manager.Allocate(&m_null_srv_descriptor)) { @@ -629,7 +616,7 @@ bool D3D12Device::CreateTimestampQuery() constexpr u32 QUERY_COUNT = NUM_TIMESTAMP_QUERIES_PER_CMDLIST * NUM_COMMAND_LISTS; constexpr u32 BUFFER_SIZE = sizeof(u64) * QUERY_COUNT; - const D3D12_QUERY_HEAP_DESC desc = {D3D12_QUERY_HEAP_TYPE_TIMESTAMP, QUERY_COUNT}; + const D3D12_QUERY_HEAP_DESC desc = {D3D12_QUERY_HEAP_TYPE_TIMESTAMP, QUERY_COUNT, 0u}; HRESULT hr = m_device->CreateQueryHeap(&desc, IID_PPV_ARGS(m_timestamp_query_heap.GetAddressOf())); if (FAILED(hr)) { @@ -638,7 +625,8 @@ bool D3D12Device::CreateTimestampQuery() return false; } - const D3D12MA::ALLOCATION_DESC allocation_desc = {D3D12MA::ALLOCATION_FLAG_NONE, D3D12_HEAP_TYPE_READBACK}; + const D3D12MA::ALLOCATION_DESC allocation_desc = {D3D12MA::ALLOCATION_FLAG_NONE, D3D12_HEAP_TYPE_READBACK, + D3D12_HEAP_FLAG_NONE, nullptr, nullptr}; const D3D12_RESOURCE_DESC resource_desc = {D3D12_RESOURCE_DIMENSION_BUFFER, 0, BUFFER_SIZE, @@ -878,7 +866,7 @@ bool D3D12Device::CreateSwapChainRTV() if (FAILED(hr)) return false; - const D3D12_RENDER_TARGET_VIEW_DESC rtv_desc = {swap_chain_desc.BufferDesc.Format, D3D12_RTV_DIMENSION_TEXTURE2D}; + const D3D12_RENDER_TARGET_VIEW_DESC rtv_desc = {swap_chain_desc.BufferDesc.Format, D3D12_RTV_DIMENSION_TEXTURE2D, {}}; for (u32 i = 0; i < swap_chain_desc.BufferCount; i++) { @@ -1038,7 +1026,7 @@ bool D3D12Device::SupportsTextureFormat(GPUTexture::Format format) const if (dfmt == DXGI_FORMAT_UNKNOWN) return false; - D3D12_FEATURE_DATA_FORMAT_SUPPORT support = {dfmt}; + D3D12_FEATURE_DATA_FORMAT_SUPPORT support = {dfmt, {}, {}}; return SUCCEEDED(m_device->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT, &support, sizeof(support))) && (support.Support1 & required) == required; } @@ -1189,7 +1177,8 @@ void D3D12Device::SetFeatures() m_max_multisamples = 1; for (u32 multisamples = 2; multisamples < D3D12_MAX_MULTISAMPLE_SAMPLE_COUNT; multisamples++) { - D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS fd = {DXGI_FORMAT_R8G8B8A8_UNORM, static_cast(multisamples)}; + D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS fd = {DXGI_FORMAT_R8G8B8A8_UNORM, static_cast(multisamples), + D3D12_MULTISAMPLE_QUALITY_LEVELS_FLAG_NONE, 0u}; if (SUCCEEDED(m_device->CheckFeatureSupport(D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS, &fd, sizeof(fd))) && fd.NumQualityLevels > 0) @@ -1660,8 +1649,8 @@ void D3D12Device::BeginRenderPass() // Re-rendering to swap chain. const auto& swap_chain_buf = m_swap_chain_buffers[m_current_swap_chain_buffer]; rt_desc = {swap_chain_buf.second, - {D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_PRESERVE}, - {D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE}}; + {D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_PRESERVE, {}}, + {D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE, {}}}; rt_desc_p = &rt_desc; } @@ -1705,7 +1694,7 @@ void D3D12Device::BeginSwapChainRenderPass() const D3D12_RENDER_PASS_RENDER_TARGET_DESC rt_desc = { swap_chain_buf.second, {D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_CLEAR, {s_present_clear_color}}, - {D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE}}; + {D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE, {}}}; cmdlist->BeginRenderPass(1, &rt_desc, nullptr, D3D12_RENDER_PASS_FLAG_NONE); m_current_framebuffer = nullptr; @@ -1875,8 +1864,6 @@ void D3D12Device::SetScissor(ID3D12GraphicsCommandList4* cmdlist) void D3D12Device::SetTextureSampler(u32 slot, GPUTexture* texture, GPUSampler* sampler) { - D3D12DescriptorHandle null_handle; - D3D12Texture* T = static_cast(texture); if (m_current_textures[slot] != T) { @@ -1984,7 +1971,7 @@ void D3D12Device::PreDrawCheck() return; } } - else if (dirty & DIRTY_FLAG_CONSTANT_BUFFER | DIRTY_FLAG_TEXTURES | DIRTY_FLAG_SAMPLERS) + else if (dirty & (DIRTY_FLAG_CONSTANT_BUFFER | DIRTY_FLAG_TEXTURES | DIRTY_FLAG_SAMPLERS)) { if (!UpdateRootParameters(dirty)) { diff --git a/src/util/d3d12_pipeline.cpp b/src/util/d3d12_pipeline.cpp index 55fa430a9..47c188a5f 100644 --- a/src/util/d3d12_pipeline.cpp +++ b/src/util/d3d12_pipeline.cpp @@ -15,8 +15,6 @@ Log_SetChannel(D3D12Device); -static u32 s_next_bad_shader_id = 1; - D3D12Shader::D3D12Shader(GPUShaderStage stage, Bytecode bytecode) : GPUShader(stage), m_bytecode(std::move(bytecode)) { } diff --git a/src/util/d3d12_texture.cpp b/src/util/d3d12_texture.cpp index 4417456a0..33af43a40 100644 --- a/src/util/d3d12_texture.cpp +++ b/src/util/d3d12_texture.cpp @@ -160,16 +160,17 @@ std::unique_ptr D3D12Device::CreateTexture(u32 width, u32 height, u3 break; } - if (uav_format != DXGI_FORMAT_UNKNOWN && !CreateUAVDescriptor(resource.Get(), samples, fm.dsv_format, &uav_descriptor)) + if (uav_format != DXGI_FORMAT_UNKNOWN && + !CreateUAVDescriptor(resource.Get(), samples, fm.dsv_format, &uav_descriptor)) { m_descriptor_heap_manager.Free(&write_descriptor); m_descriptor_heap_manager.Free(&srv_descriptor); return {}; } - std::unique_ptr tex(new D3D12Texture(width, height, layers, levels, samples, type, format, fm.resource_format, - std::move(resource), std::move(allocation), srv_descriptor, - write_descriptor, uav_descriptor, write_descriptor_type, state)); + std::unique_ptr tex(new D3D12Texture( + width, height, layers, levels, samples, type, format, fm.resource_format, std::move(resource), + std::move(allocation), srv_descriptor, write_descriptor, uav_descriptor, write_descriptor_type, state)); if (data) { @@ -203,7 +204,7 @@ bool D3D12Device::CreateSRVDescriptor(ID3D12Resource* resource, u32 layers, u32 else { desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY; - desc.Texture2DArray = {0u, levels, 0u, layers}; + desc.Texture2DArray = {0u, levels, 0u, layers, 0u, 0.0f}; } } else @@ -215,7 +216,7 @@ bool D3D12Device::CreateSRVDescriptor(ID3D12Resource* resource, u32 layers, u32 else { desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; - desc.Texture2D = {0u, levels}; + desc.Texture2D = {0u, levels, 0u, 0.0f}; } } @@ -233,7 +234,7 @@ bool D3D12Device::CreateRTVDescriptor(ID3D12Resource* resource, u32 samples, DXG } const D3D12_RENDER_TARGET_VIEW_DESC desc = {format, (samples > 1) ? D3D12_RTV_DIMENSION_TEXTURE2DMS : - D3D12_RTV_DIMENSION_TEXTURE2D}; + D3D12_RTV_DIMENSION_TEXTURE2D, {} }; m_device->CreateRenderTargetView(resource, &desc, dh->cpu_handle); return true; } @@ -248,7 +249,7 @@ bool D3D12Device::CreateDSVDescriptor(ID3D12Resource* resource, u32 samples, DXG } const D3D12_DEPTH_STENCIL_VIEW_DESC desc = { - format, (samples > 1) ? D3D12_DSV_DIMENSION_TEXTURE2DMS : D3D12_DSV_DIMENSION_TEXTURE2D, D3D12_DSV_FLAG_NONE}; + format, (samples > 1) ? D3D12_DSV_DIMENSION_TEXTURE2DMS : D3D12_DSV_DIMENSION_TEXTURE2D, D3D12_DSV_FLAG_NONE, {} }; m_device->CreateDepthStencilView(resource, &desc, dh->cpu_handle); return true; } @@ -263,7 +264,7 @@ bool D3D12Device::CreateUAVDescriptor(ID3D12Resource* resource, u32 samples, DXG } DebugAssert(samples == 1); - const D3D12_UNORDERED_ACCESS_VIEW_DESC desc = {format, D3D12_UAV_DIMENSION_TEXTURE2D}; + const D3D12_UNORDERED_ACCESS_VIEW_DESC desc = { format, D3D12_UAV_DIMENSION_TEXTURE2D, {} }; m_device->CreateUnorderedAccessView(resource, nullptr, &desc, dh->cpu_handle); return true; } @@ -348,7 +349,8 @@ ID3D12Resource* D3D12Texture::AllocateUploadStagingBuffer(const void* data, u32 ComPtr resource; ComPtr allocation; - const D3D12MA::ALLOCATION_DESC allocation_desc = {D3D12MA::ALLOCATION_FLAG_NONE, D3D12_HEAP_TYPE_UPLOAD}; + const D3D12MA::ALLOCATION_DESC allocation_desc = {D3D12MA::ALLOCATION_FLAG_NONE, D3D12_HEAP_TYPE_UPLOAD, + D3D12_HEAP_FLAG_NONE, nullptr, nullptr}; const D3D12_RESOURCE_DESC resource_desc = { D3D12_RESOURCE_DIMENSION_BUFFER, 0, size, 1, 1, 1, DXGI_FORMAT_UNKNOWN, {1, 0}, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, D3D12_RESOURCE_FLAG_NONE}; @@ -901,8 +903,10 @@ bool D3D12TextureBuffer::Create(D3D12Device& dev) if (!dev.GetDescriptorHeapManager().Allocate(&m_descriptor)) return {}; - D3D12_SHADER_RESOURCE_VIEW_DESC desc = {format_mapping[static_cast(m_format)], D3D12_SRV_DIMENSION_BUFFER, - D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING}; + D3D12_SHADER_RESOURCE_VIEW_DESC desc = {format_mapping[static_cast(m_format)], + D3D12_SRV_DIMENSION_BUFFER, + D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING, + {}}; desc.Buffer.NumElements = m_size_in_elements; dev.GetDevice()->CreateShaderResourceView(m_buffer.GetBuffer(), &desc, m_descriptor); return true; diff --git a/src/util/d3d_common.cpp b/src/util/d3d_common.cpp index 66f3d3b22..096c7245d 100644 --- a/src/util/d3d_common.cpp +++ b/src/util/d3d_common.cpp @@ -415,7 +415,7 @@ std::optional> D3DCommon::CompileShader(D3D_FEATURE_LEVEL f if (fp) { std::fwrite(source.data(), source.size(), 1, fp.get()); - std::fprintf(fp.get(), "\n\nCompile as %s failed: %08X\n", target, hr); + std::fprintf(fp.get(), "\n\nCompile as %s failed: %08X\n", target, static_cast(hr)); std::fwrite(error_string.c_str(), error_string.size(), 1, fp.get()); } diff --git a/src/util/dinput_source.cpp b/src/util/dinput_source.cpp index 9a9f3b461..a585e1480 100644 --- a/src/util/dinput_source.cpp +++ b/src/util/dinput_source.cpp @@ -287,7 +287,8 @@ std::vector> DInputSource::EnumerateDevices( std::vector> ret; for (size_t i = 0; i < m_controllers.size(); i++) { - DIDEVICEINSTANCEW dii = {sizeof(DIDEVICEINSTANCEW)}; + DIDEVICEINSTANCEW dii; + dii.dwSize = sizeof(DIDEVICEINSTANCEW); std::string name; if (SUCCEEDED(m_controllers[i].device->GetDeviceInfo(&dii))) name = StringUtil::WideStringToUTF8String(dii.tszProductName); diff --git a/src/util/gl/context_wgl.cpp b/src/util/gl/context_wgl.cpp index e16232ae0..fe4c878b9 100644 --- a/src/util/gl/context_wgl.cpp +++ b/src/util/gl/context_wgl.cpp @@ -10,6 +10,10 @@ Log_SetChannel(GL::ContextWGL); +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wmicrosoft-cast" +#endif + static void* GetProcAddressCallback(const char* name) { void* addr = wglGetProcAddress(name); diff --git a/src/util/gpu_device.cpp b/src/util/gpu_device.cpp index ba080e91e..f41201f11 100644 --- a/src/util/gpu_device.cpp +++ b/src/util/gpu_device.cpp @@ -109,7 +109,7 @@ bool GPUPipeline::InputLayout::operator==(const InputLayout& rhs) const bool GPUPipeline::InputLayout::operator!=(const InputLayout& rhs) const { return (vertex_stride != rhs.vertex_stride || - vertex_attributes.size() != rhs.vertex_attributes.size() && + vertex_attributes.size() != rhs.vertex_attributes.size() || std::memcmp(vertex_attributes.data(), rhs.vertex_attributes.data(), sizeof(VertexAttribute) * rhs.vertex_attributes.size()) != 0); } diff --git a/src/util/gpu_device.h b/src/util/gpu_device.h index ffa9805a2..8bd633487 100644 --- a/src/util/gpu_device.h +++ b/src/util/gpu_device.h @@ -207,6 +207,8 @@ public: u32 key; // clang-format off + ALWAYS_INLINE VertexAttribute() = default; + ALWAYS_INLINE constexpr VertexAttribute(const VertexAttribute& rhs) : key(rhs.key) {} ALWAYS_INLINE VertexAttribute& operator=(const VertexAttribute& rhs) { key = rhs.key; return *this; } ALWAYS_INLINE bool operator==(const VertexAttribute& rhs) const { return key == rhs.key; } ALWAYS_INLINE bool operator!=(const VertexAttribute& rhs) const { return key != rhs.key; } @@ -217,11 +219,14 @@ public: u16 offset) { // Nasty :/ can't access an inactive element of a union here.. - return VertexAttribute{{(static_cast(index) & 0xf) | ((static_cast(semantic) & 0x3) << 4) | - ((static_cast(semantic_index) & 0x3) << 6) | ((static_cast(type) & 0xf) << 8) | - ((static_cast(components) & 0x7) << 12) | - ((static_cast(offset) & 0xffff) << 16)}}; + return VertexAttribute((static_cast(index) & 0xf) | ((static_cast(semantic) & 0x3) << 4) | + ((static_cast(semantic_index) & 0x3) << 6) | ((static_cast(type) & 0xf) << 8) | + ((static_cast(components) & 0x7) << 12) | + ((static_cast(offset) & 0xffff) << 16)); } + + private: + ALWAYS_INLINE constexpr VertexAttribute(u32 key_) : key(key_) {} }; struct InputLayout @@ -298,6 +303,8 @@ public: u8 key; // clang-format off + ALWAYS_INLINE RasterizationState() = default; + ALWAYS_INLINE RasterizationState(const RasterizationState& rhs) : key(rhs.key) {} ALWAYS_INLINE RasterizationState& operator=(const RasterizationState& rhs) { key = rhs.key; return *this; } ALWAYS_INLINE bool operator==(const RasterizationState& rhs) const { return key == rhs.key; } ALWAYS_INLINE bool operator!=(const RasterizationState& rhs) const { return key != rhs.key; } @@ -314,6 +321,8 @@ public: u8 key; // clang-format off + ALWAYS_INLINE DepthState() = default; + ALWAYS_INLINE DepthState(const DepthState& rhs) : key(rhs.key) {} ALWAYS_INLINE DepthState& operator=(const DepthState& rhs) { key = rhs.key; return *this; } ALWAYS_INLINE bool operator==(const DepthState& rhs) const { return key == rhs.key; } ALWAYS_INLINE bool operator!=(const DepthState& rhs) const { return key != rhs.key; } @@ -342,6 +351,8 @@ public: u64 key; // clang-format off + ALWAYS_INLINE BlendState() = default; + ALWAYS_INLINE BlendState(const BlendState& rhs) : key(rhs.key) {} ALWAYS_INLINE BlendState& operator=(const BlendState& rhs) { key = rhs.key; return *this; } ALWAYS_INLINE bool operator==(const BlendState& rhs) const { return key == rhs.key; } ALWAYS_INLINE bool operator!=(const BlendState& rhs) const { return key != rhs.key; } @@ -486,7 +497,7 @@ public: return counts[static_cast(layout)]; } - + #ifdef __APPLE__ // We have to define these in the base class, because they're in Objective C++. static std::unique_ptr WrapNewMetalDevice(); diff --git a/src/util/imgui_manager.cpp b/src/util/imgui_manager.cpp index e48c21d66..0ab37479b 100644 --- a/src/util/imgui_manager.cpp +++ b/src/util/imgui_manager.cpp @@ -315,110 +315,110 @@ void ImGuiManager::SetKeyMap() const char* alt_name; }; - static constexpr KeyMapping mapping[] = {{ImGuiKey_LeftArrow, "Left"}, - {ImGuiKey_RightArrow, "Right"}, - {ImGuiKey_UpArrow, "Up"}, - {ImGuiKey_DownArrow, "Down"}, - {ImGuiKey_PageUp, "PageUp"}, - {ImGuiKey_PageDown, "PageDown"}, - {ImGuiKey_Home, "Home"}, - {ImGuiKey_End, "End"}, - {ImGuiKey_Insert, "Insert"}, - {ImGuiKey_Delete, "Delete"}, - {ImGuiKey_Backspace, "Backspace"}, - {ImGuiKey_Space, "Space"}, - {ImGuiKey_Enter, "Return"}, - {ImGuiKey_Escape, "Escape"}, + static constexpr KeyMapping mapping[] = {{ImGuiKey_LeftArrow, "Left", nullptr}, + {ImGuiKey_RightArrow, "Right", nullptr}, + {ImGuiKey_UpArrow, "Up", nullptr}, + {ImGuiKey_DownArrow, "Down", nullptr}, + {ImGuiKey_PageUp, "PageUp", nullptr}, + {ImGuiKey_PageDown, "PageDown", nullptr}, + {ImGuiKey_Home, "Home", nullptr}, + {ImGuiKey_End, "End", nullptr}, + {ImGuiKey_Insert, "Insert", nullptr}, + {ImGuiKey_Delete, "Delete", nullptr}, + {ImGuiKey_Backspace, "Backspace", nullptr}, + {ImGuiKey_Space, "Space", nullptr}, + {ImGuiKey_Enter, "Return", nullptr}, + {ImGuiKey_Escape, "Escape", nullptr}, {ImGuiKey_LeftCtrl, "LeftCtrl", "Ctrl"}, {ImGuiKey_LeftShift, "LeftShift", "Shift"}, {ImGuiKey_LeftAlt, "LeftAlt", "Alt"}, {ImGuiKey_LeftSuper, "LeftSuper", "Super"}, - {ImGuiKey_RightCtrl, "RightCtrl"}, - {ImGuiKey_RightShift, "RightShift"}, - {ImGuiKey_RightAlt, "RightAlt"}, - {ImGuiKey_RightSuper, "RightSuper"}, - {ImGuiKey_Menu, "Menu"}, - {ImGuiKey_0, "0"}, - {ImGuiKey_1, "1"}, - {ImGuiKey_2, "2"}, - {ImGuiKey_3, "3"}, - {ImGuiKey_4, "4"}, - {ImGuiKey_5, "5"}, - {ImGuiKey_6, "6"}, - {ImGuiKey_7, "7"}, - {ImGuiKey_8, "8"}, - {ImGuiKey_9, "9"}, - {ImGuiKey_A, "A"}, - {ImGuiKey_B, "B"}, - {ImGuiKey_C, "C"}, - {ImGuiKey_D, "D"}, - {ImGuiKey_E, "E"}, - {ImGuiKey_F, "F"}, - {ImGuiKey_G, "G"}, - {ImGuiKey_H, "H"}, - {ImGuiKey_I, "I"}, - {ImGuiKey_J, "J"}, - {ImGuiKey_K, "K"}, - {ImGuiKey_L, "L"}, - {ImGuiKey_M, "M"}, - {ImGuiKey_N, "N"}, - {ImGuiKey_O, "O"}, - {ImGuiKey_P, "P"}, - {ImGuiKey_Q, "Q"}, - {ImGuiKey_R, "R"}, - {ImGuiKey_S, "S"}, - {ImGuiKey_T, "T"}, - {ImGuiKey_U, "U"}, - {ImGuiKey_V, "V"}, - {ImGuiKey_W, "W"}, - {ImGuiKey_X, "X"}, - {ImGuiKey_Y, "Y"}, - {ImGuiKey_Z, "Z"}, - {ImGuiKey_F1, "F1"}, - {ImGuiKey_F2, "F2"}, - {ImGuiKey_F3, "F3"}, - {ImGuiKey_F4, "F4"}, - {ImGuiKey_F5, "F5"}, - {ImGuiKey_F6, "F6"}, - {ImGuiKey_F7, "F7"}, - {ImGuiKey_F8, "F8"}, - {ImGuiKey_F9, "F9"}, - {ImGuiKey_F10, "F10"}, - {ImGuiKey_F11, "F11"}, - {ImGuiKey_F12, "F12"}, - {ImGuiKey_Apostrophe, "Apostrophe"}, - {ImGuiKey_Comma, "Comma"}, - {ImGuiKey_Minus, "Minus"}, - {ImGuiKey_Period, "Period"}, - {ImGuiKey_Slash, "Slash"}, - {ImGuiKey_Semicolon, "Semicolon"}, - {ImGuiKey_Equal, "Equal"}, - {ImGuiKey_LeftBracket, "BracketLeft"}, - {ImGuiKey_Backslash, "Backslash"}, - {ImGuiKey_RightBracket, "BracketRight"}, - {ImGuiKey_GraveAccent, "QuoteLeft"}, - {ImGuiKey_CapsLock, "CapsLock"}, - {ImGuiKey_ScrollLock, "ScrollLock"}, - {ImGuiKey_NumLock, "NumLock"}, - {ImGuiKey_PrintScreen, "PrintScreen"}, - {ImGuiKey_Pause, "Pause"}, - {ImGuiKey_Keypad0, "Keypad0"}, - {ImGuiKey_Keypad1, "Keypad1"}, - {ImGuiKey_Keypad2, "Keypad2"}, - {ImGuiKey_Keypad3, "Keypad3"}, - {ImGuiKey_Keypad4, "Keypad4"}, - {ImGuiKey_Keypad5, "Keypad5"}, - {ImGuiKey_Keypad6, "Keypad6"}, - {ImGuiKey_Keypad7, "Keypad7"}, - {ImGuiKey_Keypad8, "Keypad8"}, - {ImGuiKey_Keypad9, "Keypad9"}, - {ImGuiKey_KeypadDecimal, "KeypadPeriod"}, - {ImGuiKey_KeypadDivide, "KeypadDivide"}, - {ImGuiKey_KeypadMultiply, "KeypadMultiply"}, - {ImGuiKey_KeypadSubtract, "KeypadMinus"}, - {ImGuiKey_KeypadAdd, "KeypadPlus"}, - {ImGuiKey_KeypadEnter, "KeypadReturn"}, - {ImGuiKey_KeypadEqual, "KeypadEqual"}}; + {ImGuiKey_RightCtrl, "RightCtrl", nullptr}, + {ImGuiKey_RightShift, "RightShift", nullptr}, + {ImGuiKey_RightAlt, "RightAlt", nullptr}, + {ImGuiKey_RightSuper, "RightSuper", nullptr}, + {ImGuiKey_Menu, "Menu", nullptr}, + {ImGuiKey_0, "0", nullptr}, + {ImGuiKey_1, "1", nullptr}, + {ImGuiKey_2, "2", nullptr}, + {ImGuiKey_3, "3", nullptr}, + {ImGuiKey_4, "4", nullptr}, + {ImGuiKey_5, "5", nullptr}, + {ImGuiKey_6, "6", nullptr}, + {ImGuiKey_7, "7", nullptr}, + {ImGuiKey_8, "8", nullptr}, + {ImGuiKey_9, "9", nullptr}, + {ImGuiKey_A, "A", nullptr}, + {ImGuiKey_B, "B", nullptr}, + {ImGuiKey_C, "C", nullptr}, + {ImGuiKey_D, "D", nullptr}, + {ImGuiKey_E, "E", nullptr}, + {ImGuiKey_F, "F", nullptr}, + {ImGuiKey_G, "G", nullptr}, + {ImGuiKey_H, "H", nullptr}, + {ImGuiKey_I, "I", nullptr}, + {ImGuiKey_J, "J", nullptr}, + {ImGuiKey_K, "K", nullptr}, + {ImGuiKey_L, "L", nullptr}, + {ImGuiKey_M, "M", nullptr}, + {ImGuiKey_N, "N", nullptr}, + {ImGuiKey_O, "O", nullptr}, + {ImGuiKey_P, "P", nullptr}, + {ImGuiKey_Q, "Q", nullptr}, + {ImGuiKey_R, "R", nullptr}, + {ImGuiKey_S, "S", nullptr}, + {ImGuiKey_T, "T", nullptr}, + {ImGuiKey_U, "U", nullptr}, + {ImGuiKey_V, "V", nullptr}, + {ImGuiKey_W, "W", nullptr}, + {ImGuiKey_X, "X", nullptr}, + {ImGuiKey_Y, "Y", nullptr}, + {ImGuiKey_Z, "Z", nullptr}, + {ImGuiKey_F1, "F1", nullptr}, + {ImGuiKey_F2, "F2", nullptr}, + {ImGuiKey_F3, "F3", nullptr}, + {ImGuiKey_F4, "F4", nullptr}, + {ImGuiKey_F5, "F5", nullptr}, + {ImGuiKey_F6, "F6", nullptr}, + {ImGuiKey_F7, "F7", nullptr}, + {ImGuiKey_F8, "F8", nullptr}, + {ImGuiKey_F9, "F9", nullptr}, + {ImGuiKey_F10, "F10", nullptr}, + {ImGuiKey_F11, "F11", nullptr}, + {ImGuiKey_F12, "F12", nullptr}, + {ImGuiKey_Apostrophe, "Apostrophe", nullptr}, + {ImGuiKey_Comma, "Comma", nullptr}, + {ImGuiKey_Minus, "Minus", nullptr}, + {ImGuiKey_Period, "Period", nullptr}, + {ImGuiKey_Slash, "Slash", nullptr}, + {ImGuiKey_Semicolon, "Semicolon", nullptr}, + {ImGuiKey_Equal, "Equal", nullptr}, + {ImGuiKey_LeftBracket, "BracketLeft", nullptr}, + {ImGuiKey_Backslash, "Backslash", nullptr}, + {ImGuiKey_RightBracket, "BracketRight", nullptr}, + {ImGuiKey_GraveAccent, "QuoteLeft", nullptr}, + {ImGuiKey_CapsLock, "CapsLock", nullptr}, + {ImGuiKey_ScrollLock, "ScrollLock", nullptr}, + {ImGuiKey_NumLock, "NumLock", nullptr}, + {ImGuiKey_PrintScreen, "PrintScreen", nullptr}, + {ImGuiKey_Pause, "Pause", nullptr}, + {ImGuiKey_Keypad0, "Keypad0", nullptr}, + {ImGuiKey_Keypad1, "Keypad1", nullptr}, + {ImGuiKey_Keypad2, "Keypad2", nullptr}, + {ImGuiKey_Keypad3, "Keypad3", nullptr}, + {ImGuiKey_Keypad4, "Keypad4", nullptr}, + {ImGuiKey_Keypad5, "Keypad5", nullptr}, + {ImGuiKey_Keypad6, "Keypad6", nullptr}, + {ImGuiKey_Keypad7, "Keypad7", nullptr}, + {ImGuiKey_Keypad8, "Keypad8", nullptr}, + {ImGuiKey_Keypad9, "Keypad9", nullptr}, + {ImGuiKey_KeypadDecimal, "KeypadPeriod", nullptr}, + {ImGuiKey_KeypadDivide, "KeypadDivide", nullptr}, + {ImGuiKey_KeypadMultiply, "KeypadMultiply", nullptr}, + {ImGuiKey_KeypadSubtract, "KeypadMinus", nullptr}, + {ImGuiKey_KeypadAdd, "KeypadPlus", nullptr }, + {ImGuiKey_KeypadEnter, "KeypadReturn", nullptr }, + {ImGuiKey_KeypadEqual, "KeypadEqual", nullptr}}; s_imgui_key_map.clear(); for (const KeyMapping& km : mapping) diff --git a/src/util/opengl_pipeline.cpp b/src/util/opengl_pipeline.cpp index e67bf797d..995e877ff 100644 --- a/src/util/opengl_pipeline.cpp +++ b/src/util/opengl_pipeline.cpp @@ -729,8 +729,11 @@ bool OpenGLDevice::ReadPipelineCache(const std::string& filename) // Read footer. const s64 size = FileSystem::FSize64(m_pipeline_disk_cache_file); - if (size < sizeof(PipelineDiskCacheFooter) || size >= static_cast(std::numeric_limits::max())) + if (size < static_cast(sizeof(PipelineDiskCacheFooter)) || + size >= static_cast(std::numeric_limits::max())) + { return DiscardPipelineCache(); + } PipelineDiskCacheFooter file_footer; if (FileSystem::FSeek64(m_pipeline_disk_cache_file, size - sizeof(PipelineDiskCacheFooter), SEEK_SET) != 0 || diff --git a/src/util/postprocessing_shader_fx.cpp b/src/util/postprocessing_shader_fx.cpp index e8eac9f2b..736191c0c 100644 --- a/src/util/postprocessing_shader_fx.cpp +++ b/src/util/postprocessing_shader_fx.cpp @@ -805,8 +805,6 @@ bool PostProcessing::ReShadeFXShader::CreatePasses(GPUTexture::Format backbuffer m_textures.push_back(std::move(tex)); } - TextureID last_output = INPUT_COLOR_TEXTURE; - for (reshadefx::technique_info& tech : mod.techniques) { for (reshadefx::pass_info& pi : tech.passes) @@ -915,7 +913,6 @@ bool PostProcessing::ReShadeFXShader::CreatePasses(GPUTexture::Format backbuffer #ifdef _DEBUG pass.name = std::move(pi.name); #endif - last_output = pass.render_target; m_passes.push_back(std::move(pass)); } } @@ -1019,8 +1016,8 @@ bool PostProcessing::ReShadeFXShader::CompilePipeline(GPUTexture::Format format, const std::string_view code(mod.code.data(), mod.code.size()); - auto get_shader = [this, needs_main_defn, &code](const std::string& name, const std::vector& samplers, - GPUShaderStage stage) { + auto get_shader = [needs_main_defn, &code](const std::string& name, const std::vector& samplers, + GPUShaderStage stage) { std::string real_code; if (needs_main_defn) { diff --git a/src/util/vulkan_device.cpp b/src/util/vulkan_device.cpp index 855ee62ab..73be2ecc4 100644 --- a/src/util/vulkan_device.cpp +++ b/src/util/vulkan_device.cpp @@ -485,20 +485,15 @@ bool VulkanDevice::CreateDevice(VkSurfaceKHR surface, bool enable_validation_lay } VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesEXT rasterization_order_access_feature = { - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_EXT}; + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_EXT, nullptr, VK_TRUE, VK_FALSE, + VK_FALSE}; VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT attachment_feedback_loop_feature = { - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_FEATURES_EXT}; + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_FEATURES_EXT, nullptr, VK_TRUE}; if (m_optional_extensions.vk_ext_rasterization_order_attachment_access) - { - rasterization_order_access_feature.rasterizationOrderColorAttachmentAccess = VK_TRUE; Vulkan::AddPointerToChain(&device_info, &rasterization_order_access_feature); - } if (m_optional_extensions.vk_ext_attachment_feedback_loop_layout) - { - attachment_feedback_loop_feature.attachmentFeedbackLoopLayout = VK_TRUE; Vulkan::AddPointerToChain(&device_info, &attachment_feedback_loop_feature); - } VkResult res = vkCreateDevice(m_physical_device, &device_info, nullptr, &m_device); if (res != VK_SUCCESS) @@ -532,11 +527,12 @@ bool VulkanDevice::CreateDevice(VkSurfaceKHR surface, bool enable_validation_lay void VulkanDevice::ProcessDeviceExtensions() { // advanced feature checks - VkPhysicalDeviceFeatures2 features2 = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2}; + VkPhysicalDeviceFeatures2 features2 = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, nullptr, {}}; VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesEXT rasterization_order_access_feature = { - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_EXT}; + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_EXT, nullptr, VK_FALSE, VK_FALSE, + VK_FALSE}; VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT attachment_feedback_loop_feature = { - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_FEATURES_EXT}; + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_FEATURES_EXT, nullptr, VK_FALSE}; // add in optional feature structs if (m_optional_extensions.vk_ext_rasterization_order_attachment_access) @@ -553,9 +549,9 @@ void VulkanDevice::ProcessDeviceExtensions() m_optional_extensions.vk_ext_attachment_feedback_loop_layout &= (attachment_feedback_loop_feature.attachmentFeedbackLoopLayout == VK_TRUE); - VkPhysicalDeviceProperties2 properties2 = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2}; + VkPhysicalDeviceProperties2 properties2 = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, nullptr, {}}; VkPhysicalDevicePushDescriptorPropertiesKHR push_descriptor_properties = { - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PUSH_DESCRIPTOR_PROPERTIES_KHR}; + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PUSH_DESCRIPTOR_PROPERTIES_KHR, nullptr, 0u}; if (m_optional_extensions.vk_khr_driver_properties) { @@ -1046,10 +1042,16 @@ void VulkanDevice::DoSubmitCommandBuffer(u32 index, VulkanSwapChain* present_swa CommandBuffer& resources = m_frame_resources[index]; uint32_t wait_bits = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; - VkSubmitInfo submit_info = {VK_STRUCTURE_TYPE_SUBMIT_INFO}; - submit_info.commandBufferCount = resources.init_buffer_used ? 2u : 1u; - submit_info.pCommandBuffers = - resources.init_buffer_used ? resources.command_buffers.data() : &resources.command_buffers[1]; + VkSubmitInfo submit_info = {VK_STRUCTURE_TYPE_SUBMIT_INFO, + nullptr, + 0u, + nullptr, + nullptr, + resources.init_buffer_used ? 2u : 1u, + resources.init_buffer_used ? resources.command_buffers.data() : + &resources.command_buffers[1], + 0u, + nullptr}; if (present_swap_chain) { @@ -2679,7 +2681,8 @@ void VulkanDevice::BeginRenderPass() { DebugAssert(!InRenderPass()); - VkRenderPassBeginInfo bi = {VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, nullptr}; + VkRenderPassBeginInfo bi = { + VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, nullptr, VK_NULL_HANDLE, VK_NULL_HANDLE, {}, 0u, nullptr}; std::array clear_values; if (LIKELY(m_current_framebuffer)) @@ -2746,7 +2749,7 @@ void VulkanDevice::BeginRenderPass() case GPUTexture::State::Cleared: { const u32 idx = rt ? 1 : 0; - clear_values[idx].depthStencil = {ds->GetClearDepth()}; + clear_values[idx].depthStencil = {ds->GetClearDepth(), 0u}; ds_load_op = VK_ATTACHMENT_LOAD_OP_CLEAR; ds->SetState(GPUTexture::State::Dirty); bi.pClearValues = clear_values.data(); diff --git a/src/util/vulkan_loader.h b/src/util/vulkan_loader.h index 70d4a951e..9146de3de 100644 --- a/src/util/vulkan_loader.h +++ b/src/util/vulkan_loader.h @@ -75,6 +75,7 @@ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnullability-completeness" #pragma clang diagnostic ignored "-Wunused-variable" +#pragma clang diagnostic ignored "-Wmissing-field-initializers" #elif defined(_MSC_VER) #pragma warning(push, 0) #endif diff --git a/src/util/vulkan_pipeline.cpp b/src/util/vulkan_pipeline.cpp index 637d0688c..610ad9991 100644 --- a/src/util/vulkan_pipeline.cpp +++ b/src/util/vulkan_pipeline.cpp @@ -11,8 +11,6 @@ Log_SetChannel(VulkanDevice); -static u32 s_next_bad_shader_id = 1; - VulkanShader::VulkanShader(GPUShaderStage stage, VkShaderModule mod) : GPUShader(stage), m_module(mod) { } diff --git a/src/util/vulkan_swap_chain.cpp b/src/util/vulkan_swap_chain.cpp index 05831244a..4ef90fa93 100644 --- a/src/util/vulkan_swap_chain.cpp +++ b/src/util/vulkan_swap_chain.cpp @@ -413,9 +413,10 @@ bool VulkanSwapChain::CreateSwapChain() } #ifdef _WIN32 - VkSurfaceFullScreenExclusiveInfoEXT exclusive_info = {VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT}; + VkSurfaceFullScreenExclusiveInfoEXT exclusive_info = {VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT, + nullptr, VK_FULL_SCREEN_EXCLUSIVE_DEFAULT_EXT}; VkSurfaceFullScreenExclusiveWin32InfoEXT exclusive_win32_info = { - VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT}; + VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT, nullptr, NULL}; if (m_exclusive_fullscreen_control.has_value()) { if (dev.GetOptionalExtensions().vk_ext_full_screen_exclusive) diff --git a/src/util/vulkan_texture.cpp b/src/util/vulkan_texture.cpp index 85bba8252..781510f33 100644 --- a/src/util/vulkan_texture.cpp +++ b/src/util/vulkan_texture.cpp @@ -75,7 +75,12 @@ std::unique_ptr VulkanTexture::Create(u32 width, u32 height, u32 levels, layers, static_cast(samples), - VK_IMAGE_TILING_OPTIMAL}; + VK_IMAGE_TILING_OPTIMAL, + 0u, + VK_SHARING_MODE_EXCLUSIVE, + 0, + nullptr, + VK_IMAGE_LAYOUT_UNDEFINED}; VmaAllocationCreateInfo aci = {}; aci.usage = VMA_MEMORY_USAGE_GPU_ONLY; @@ -433,7 +438,7 @@ void VulkanTexture::CommitClear(VkCommandBuffer cmdbuf) if (IsDepthStencil()) { - const VkClearDepthStencilValue cv = {m_clear_value.depth}; + const VkClearDepthStencilValue cv = {m_clear_value.depth, 0u}; const VkImageSubresourceRange srr = {VK_IMAGE_ASPECT_DEPTH_BIT, 0u, 1u, 0u, 1u}; vkCmdClearDepthStencilImage(cmdbuf, m_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &cv, 1, &srr); } diff --git a/src/util/win32_raw_input_source.cpp b/src/util/win32_raw_input_source.cpp index 70f04c892..8bdc015ab 100644 --- a/src/util/win32_raw_input_source.cpp +++ b/src/util/win32_raw_input_source.cpp @@ -49,7 +49,9 @@ bool Win32RawInputSource::Initialize(SettingsInterface& si, std::unique_lock& settings_lock) {} +void Win32RawInputSource::UpdateSettings(SettingsInterface& si, std::unique_lock& settings_lock) +{ +} bool Win32RawInputSource::ReloadDevices() { @@ -72,7 +74,9 @@ std::vector> Win32RawInputSource::EnumerateD return {}; } -void Win32RawInputSource::UpdateMotorState(InputBindingKey key, float intensity) {} +void Win32RawInputSource::UpdateMotorState(InputBindingKey key, float intensity) +{ +} void Win32RawInputSource::UpdateMotorState(InputBindingKey large_key, InputBindingKey small_key, float large_intensity, float small_intensity) @@ -171,7 +175,7 @@ bool Win32RawInputSource::OpenDevices() m_num_keyboards++; #endif if (rid.dwType == RIM_TYPEMOUSE) - m_mice.push_back({rid.hDevice}); + m_mice.push_back({rid.hDevice, 0u, 0, 0}); } Log_DevPrintf("(Win32RawInputSource) Found %u keyboards and %zu mice", m_num_keyboards, m_mice.size()); diff --git a/src/util/win32_raw_input_source.h b/src/util/win32_raw_input_source.h index b63a8a575..7cc09cfcb 100644 --- a/src/util/win32_raw_input_source.h +++ b/src/util/win32_raw_input_source.h @@ -55,7 +55,6 @@ private: HWND m_dummy_window = {}; u32 m_num_keyboards = 0; - u32 m_num_mice = 0; std::vector m_mice; }; diff --git a/src/util/window_info.cpp b/src/util/window_info.cpp index 114409775..d73d72cee 100644 --- a/src/util/window_info.cpp +++ b/src/util/window_info.cpp @@ -4,9 +4,6 @@ #include "window_info.h" #include "common/assert.h" -#include "common/log.h" - -Log_SetChannel(WindowInfo); void WindowInfo::SetSurfaceless() { @@ -88,11 +85,14 @@ bool WindowInfo::QueryRefreshRateForWindow(const WindowInfo& wi, float* refresh_ #ifdef USE_X11 #include "common/scoped_guard.h" +#include "common/log.h" #include #include #include +Log_SetChannel(WindowInfo); + // Helper class for managing X errors namespace { class X11InhibitErrors; diff --git a/src/util/xaudio2_audio_stream.cpp b/src/util/xaudio2_audio_stream.cpp index 1ab4f38d1..bb9626515 100644 --- a/src/util/xaudio2_audio_stream.cpp +++ b/src/util/xaudio2_audio_stream.cpp @@ -167,7 +167,13 @@ void XAudio2AudioStream::EnqueueBuffer() const XAUDIO2_BUFFER buf = { static_cast(0), // flags static_cast(sizeof(s16) * m_channels * m_enqueue_buffer_size), // bytes - reinterpret_cast(samples) // data + reinterpret_cast(samples), // data + 0u, + 0u, + 0u, + 0u, + 0u, + nullptr, }; HRESULT hr = m_source_voice->SubmitSourceBuffer(&buf, nullptr); @@ -189,19 +195,31 @@ void XAudio2AudioStream::SetOutputVolume(u32 volume) m_volume = volume; } -void __stdcall XAudio2AudioStream::OnVoiceProcessingPassStart(UINT32 BytesRequired) {} +void __stdcall XAudio2AudioStream::OnVoiceProcessingPassStart(UINT32 BytesRequired) +{ +} -void __stdcall XAudio2AudioStream::OnVoiceProcessingPassEnd(void) {} +void __stdcall XAudio2AudioStream::OnVoiceProcessingPassEnd(void) +{ +} -void __stdcall XAudio2AudioStream::OnStreamEnd(void) {} +void __stdcall XAudio2AudioStream::OnStreamEnd(void) +{ +} -void __stdcall XAudio2AudioStream::OnBufferStart(void* pBufferContext) {} +void __stdcall XAudio2AudioStream::OnBufferStart(void* pBufferContext) +{ +} void __stdcall XAudio2AudioStream::OnBufferEnd(void* pBufferContext) { EnqueueBuffer(); } -void __stdcall XAudio2AudioStream::OnLoopEnd(void* pBufferContext) {} +void __stdcall XAudio2AudioStream::OnLoopEnd(void* pBufferContext) +{ +} -void __stdcall XAudio2AudioStream::OnVoiceError(void* pBufferContext, HRESULT Error) {} +void __stdcall XAudio2AudioStream::OnVoiceError(void* pBufferContext, HRESULT Error) +{ +} diff --git a/src/util/xinput_source.cpp b/src/util/xinput_source.cpp index b461281af..ed2312c2a 100644 --- a/src/util/xinput_source.cpp +++ b/src/util/xinput_source.cpp @@ -106,7 +106,10 @@ bool XInputSource::Initialize(SettingsInterface& si, std::unique_lock(GetProcAddress(m_xinput_module, reinterpret_cast(100))); if (!m_xinput_get_state) - reinterpret_cast(GetProcAddress(m_xinput_module, "XInputGetState")); + { + m_xinput_get_state = + reinterpret_cast(GetProcAddress(m_xinput_module, "XInputGetState")); + } m_xinput_set_state = reinterpret_cast(GetProcAddress(m_xinput_module, "XInputSetState")); m_xinput_get_capabilities = @@ -122,7 +125,9 @@ bool XInputSource::Initialize(SettingsInterface& si, std::unique_lock& settings_lock) {} +void XInputSource::UpdateSettings(SettingsInterface& si, std::unique_lock& settings_lock) +{ +} bool XInputSource::ReloadDevices() {