diff --git a/src/common/binary_reader_writer.h b/src/common/binary_reader_writer.h index 9c0c667a1..a8ff2c153 100644 --- a/src/common/binary_reader_writer.h +++ b/src/common/binary_reader_writer.h @@ -90,7 +90,7 @@ public: ALWAYS_INLINE BinarySpanReader& operator>>(s64& val) { val = ReadT(); return *this; } ALWAYS_INLINE BinarySpanReader& operator>>(u64& val) { val = ReadT(); return *this; } ALWAYS_INLINE BinarySpanReader& operator>>(float& val) { val = ReadT(); return *this; } - ALWAYS_INLINE BinarySpanReader& operator>>(std::string_view val) { val = ReadCString(); return *this; } + ALWAYS_INLINE BinarySpanReader& operator>>(std::string_view& val) { val = ReadCString(); return *this; } // clang-format on template @@ -272,7 +272,7 @@ public: ALWAYS_INLINE BinaryFileReader& operator>>(s64& val) { val = ReadT(); return *this; } ALWAYS_INLINE BinaryFileReader& operator>>(u64& val) { val = ReadT(); return *this; } ALWAYS_INLINE BinaryFileReader& operator>>(float& val) { val = ReadT(); return *this; } - ALWAYS_INLINE BinaryFileReader& operator>>(std::string_view val) { val = ReadCString(); return *this; } + ALWAYS_INLINE BinaryFileReader& operator>>(std::string_view& val) { val = ReadCString(); return *this; } // clang-format on template diff --git a/src/common/file_system.cpp b/src/common/file_system.cpp index f77ebaac4..43b19d566 100644 --- a/src/common/file_system.cpp +++ b/src/common/file_system.cpp @@ -505,7 +505,7 @@ std::string Path::Canonicalize(std::string_view path) { // current directory, so it can be skipped, unless it's the only component if (components.size() == 1) - new_components.push_back(std::move(component)); + new_components.push_back(component); } else if (component == "..") { @@ -513,12 +513,12 @@ std::string Path::Canonicalize(std::string_view path) if (!new_components.empty()) new_components.pop_back(); else - new_components.push_back(std::move(component)); + new_components.push_back(component); } else { // anything else, preserve - new_components.push_back(std::move(component)); + new_components.push_back(component); } } diff --git a/src/common/log.cpp b/src/common/log.cpp index a825eb008..0dbe50cce 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -233,11 +233,11 @@ ALWAYS_INLINE_RELEASE void Log::FormatLogMessageAndPrintW(const char* channelNam wmessage_buflen = MultiByteToWideChar(CP_UTF8, 0, buffer.data(), static_cast(buffer.size()), wmessage_buf, wmessage_buflen); - if (wmessage_buflen <= 0) - return; - - wmessage_buf[wmessage_buflen] = '\0'; - callback(std::wstring_view(wmessage_buf, wmessage_buflen)); + if (wmessage_buflen > 0) [[likely]] + { + wmessage_buf[wmessage_buflen] = '\0'; + callback(std::wstring_view(wmessage_buf, wmessage_buflen)); + } if (wmessage_buf != wbuf) std::free(wmessage_buf); diff --git a/src/common/memmap.cpp b/src/common/memmap.cpp index a89c72826..d6e63699c 100644 --- a/src/common/memmap.cpp +++ b/src/common/memmap.cpp @@ -67,12 +67,12 @@ std::string MemMap::GetFileMappingName(const char* prefix) void* MemMap::CreateSharedMemory(const char* name, size_t size, Error* error) { const HANDLE mapping = - static_cast(CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, static_cast(size >> 32), - static_cast(size), StringUtil::UTF8StringToWideString(name).c_str())); + CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, static_cast(size >> 32), + static_cast(size), StringUtil::UTF8StringToWideString(name).c_str()); if (!mapping) Error::SetWin32(error, "CreateFileMappingW() failed: ", GetLastError()); - return mapping; + return static_cast(mapping); } void MemMap::DestroySharedMemory(void* ptr) diff --git a/src/common/small_string.cpp b/src/common/small_string.cpp index 0dc55acba..0eb837474 100644 --- a/src/common/small_string.cpp +++ b/src/common/small_string.cpp @@ -248,10 +248,12 @@ void SmallStringBase::append_vsprintf(const char* format, va_list ap) va_copy(ap_copy, ap); const int ret = std::vsnprintf(buffer, buffer_size, format, ap_copy); va_end(ap_copy); - if (ret < 0 || ((u32)ret >= (buffer_size - 1))) + if (ret < 0 || (static_cast(ret) >= (buffer_size - 1))) { buffer_size *= 2; buffer = heap_buffer = reinterpret_cast(std::realloc(heap_buffer, buffer_size)); + if (!buffer) [[unlikely]] + Panic("Memory allocation failed."); continue; } @@ -303,7 +305,7 @@ void SmallStringBase::prepend_vsprintf(const char* format, va_list ArgPtr) // We have a 1KB byte buffer on the stack here. If this is too little, we'll grow it via the heap, // but 1KB should be enough for most strings. char stack_buffer[1024]; - char* heap_buffer = NULL; + char* heap_buffer = nullptr; char* buffer = stack_buffer; u32 buffer_size = static_cast(std::size(stack_buffer)); u32 written; @@ -315,6 +317,8 @@ void SmallStringBase::prepend_vsprintf(const char* format, va_list ArgPtr) { buffer_size *= 2; buffer = heap_buffer = reinterpret_cast(std::realloc(heap_buffer, buffer_size)); + if (!buffer) [[unlikely]] + Panic("Memory allocation failed."); continue; } diff --git a/src/core/bios.cpp b/src/core/bios.cpp index 2a9a2a180..c8f900c1d 100644 --- a/src/core/bios.cpp +++ b/src/core/bios.cpp @@ -351,7 +351,7 @@ std::optional BIOS::FindBIOSImageInDirectory(ConsoleRegion region, std::string full_path(Path::Combine(directory, fd.FileName)); std::optional found_image = LoadImageFromFile(full_path.c_str(), nullptr); - if (!found_image) + if (!found_image.has_value()) continue; if (found_image->info && IsValidBIOSForRegion(region, found_image->info->region)) diff --git a/src/core/bus.cpp b/src/core/bus.cpp index f08c9255a..3299eb532 100644 --- a/src/core/bus.cpp +++ b/src/core/bus.cpp @@ -1399,8 +1399,11 @@ template u32 Bus::HWHandlers::MemCtrlRead(PhysicalMemoryAddress address) { const u32 offset = address & MEMCTRL_MASK; + const u32 index = FIXUP_WORD_OFFSET(size, offset) / 4; + if (index >= std::size(s_MEMCTRL.regs)) [[unlikely]] + return 0; - u32 value = s_MEMCTRL.regs[FIXUP_WORD_OFFSET(size, offset) / 4]; + u32 value = s_MEMCTRL.regs[index]; value = FIXUP_WORD_READ_VALUE(size, offset, value); BUS_CYCLES(2); return value; @@ -1411,6 +1414,9 @@ void Bus::HWHandlers::MemCtrlWrite(PhysicalMemoryAddress address, u32 value) { const u32 offset = address & MEMCTRL_MASK; const u32 index = FIXUP_WORD_OFFSET(size, offset) / 4; + if (index >= std::size(s_MEMCTRL.regs)) [[unlikely]] + return; + value = FIXUP_WORD_WRITE_VALUE(size, offset, value); const u32 write_mask = (index == 8) ? COMDELAY::WRITE_MASK : MEMDELAY::WRITE_MASK; @@ -1516,6 +1522,7 @@ u32 Bus::HWHandlers::CDROMRead(PhysicalMemoryAddress address) const u32 b3 = ZeroExtend32(CDROM::ReadRegister(offset + 3u)); value = b0 | (b1 << 8) | (b2 << 16) | (b3 << 24); } + break; case MemoryAccessSize::HalfWord: { @@ -1523,10 +1530,12 @@ u32 Bus::HWHandlers::CDROMRead(PhysicalMemoryAddress address) const u32 msb = ZeroExtend32(CDROM::ReadRegister(offset + 1u)); value = lsb | (msb << 8); } + break; case MemoryAccessSize::Byte: default: value = ZeroExtend32(CDROM::ReadRegister(offset)); + break; } BUS_CYCLES(Bus::g_cdrom_access_time[static_cast(size)]); diff --git a/src/core/cheats.cpp b/src/core/cheats.cpp index 9d9d99a47..82cd56d9c 100644 --- a/src/core/cheats.cpp +++ b/src/core/cheats.cpp @@ -661,8 +661,10 @@ bool CheatList::LoadFromString(const std::string& str, Format format) return LoadFromPCSXRString(str); else if (format == Format::Libretro) return LoadFromLibretroString(str); - format = Format::EPSXe; - return LoadFromEPSXeString(str); + else if (format == Format::EPSXe) + return LoadFromEPSXeString(str); + else + return false; } bool CheatList::SaveToPCSXRFile(const char* filename) @@ -2782,7 +2784,7 @@ const char* CheatCode::GetTypeDisplayName(Type type) std::optional CheatCode::ParseTypeName(const char* str) { - for (u32 i = 0; i < static_cast(s_cheat_code_type_names.size()); i++) + for (size_t i = 0; i < s_cheat_code_type_names.size(); i++) { if (std::strcmp(s_cheat_code_type_names[i], str) == 0) return static_cast(i); diff --git a/src/core/fullscreen_ui.cpp b/src/core/fullscreen_ui.cpp index 3f54b0548..6cfb383fb 100644 --- a/src/core/fullscreen_ui.cpp +++ b/src/core/fullscreen_ui.cpp @@ -1172,7 +1172,7 @@ void FullscreenUI::DoChangeDisc() if (const GameDatabase::Entry* entry = System::GetGameDatabaseEntry(); entry && !entry->disc_set_serials.empty()) { const auto lock = GameList::GetLock(); - const auto matches = GameList::GetMatchingEntriesForSerial(entry->disc_set_serials); + auto matches = GameList::GetMatchingEntriesForSerial(entry->disc_set_serials); if (matches.size() > 1) { options.reserve(matches.size() + 1); @@ -5759,7 +5759,7 @@ void FullscreenUI::DrawSaveStateSelector(bool is_loading) if (i == 0) ResetFocusHere(); - const SaveStateListEntry& entry = s_save_state_selector_slots[i]; + SaveStateListEntry& entry = s_save_state_selector_slots[i]; if (static_cast(i) == s_save_state_selector_submenu_index) { // can't use a choice dialog here, because we're already in a modal... @@ -6021,7 +6021,7 @@ void FullscreenUI::DrawResumeStateSelector() if (ImGui::BeginPopupModal(FSUI_CSTR("Load Resume State"), &is_open, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize)) { - const SaveStateListEntry& entry = s_save_state_selector_slots.front(); + SaveStateListEntry& entry = s_save_state_selector_slots.front(); SmallString time; TimeToPrintableString(&time, entry.timestamp); ImGui::TextWrapped( diff --git a/src/core/game_list.cpp b/src/core/game_list.cpp index 37ef86839..0c109dca8 100644 --- a/src/core/game_list.cpp +++ b/src/core/game_list.cpp @@ -1736,10 +1736,10 @@ std::string GameList::GetGameIconPath(std::string_view serial, std::string_view // Try extracting an icon. Error error; - MemoryCardImage::DataArray data; - if (MemoryCardImage::LoadFromFile(&data, memcard_path.c_str(), &error)) + std::unique_ptr data = std::make_unique(); + if (MemoryCardImage::LoadFromFile(data.get(), memcard_path.c_str(), &error)) { - std::vector files = MemoryCardImage::EnumerateFiles(data, false); + std::vector files = MemoryCardImage::EnumerateFiles(*data.get(), false); if (!files.empty()) { const MemoryCardImage::FileInfo& fi = files.front(); diff --git a/src/core/gpu_hw.cpp b/src/core/gpu_hw.cpp index 62f44dcf8..7b19ba065 100644 --- a/src/core/gpu_hw.cpp +++ b/src/core/gpu_hw.cpp @@ -2253,7 +2253,6 @@ void GPU_HW::DrawLine(const GSVector4 bounds, u32 col0, u32 col1, float depth) const float abs_dx = std::fabs(dx); const float abs_dy = std::fabs(dy); float fill_dx, fill_dy; - float dxdk, dydk; float pad_x0 = 0.0f; float pad_x1 = 0.0f; float pad_y0 = 0.0f; @@ -2268,8 +2267,7 @@ void GPU_HW::DrawLine(const GSVector4 bounds, u32 col0, u32 col1, float depth) { fill_dx = 0.0f; fill_dy = 1.0f; - dxdk = 1.0f; - dydk = dy / abs_dx; + const float dydk = dy / abs_dx; if (dx > 0.0f) { @@ -2288,8 +2286,7 @@ void GPU_HW::DrawLine(const GSVector4 bounds, u32 col0, u32 col1, float depth) { fill_dx = 1.0f; fill_dy = 0.0f; - dydk = 1.0f; - dxdk = dx / abs_dy; + const float dxdk = dx / abs_dy; if (dy > 0.0f) { diff --git a/src/core/imgui_overlays.cpp b/src/core/imgui_overlays.cpp index fdde62a26..b8b7ca360 100644 --- a/src/core/imgui_overlays.cpp +++ b/src/core/imgui_overlays.cpp @@ -239,7 +239,6 @@ void ImGuiManager::DrawPerformanceOverlay() ImDrawList* dl = ImGui::GetBackgroundDrawList(); SmallString text; ImVec2 text_size; - bool first = true; #define DRAW_LINE(font, text, color) \ do \ @@ -260,21 +259,16 @@ void ImGuiManager::DrawPerformanceOverlay() { const float speed = System::GetEmulationSpeed(); if (g_settings.display_show_fps) - { text.append_format("G: {:.2f} | V: {:.2f}", System::GetFPS(), System::GetVPS()); - first = false; - } if (g_settings.display_show_speed) { - text.append_format("{}{}%", first ? "" : " | ", static_cast(std::round(speed))); + text.append_format("{}{}%", text.empty() ? "" : " | ", static_cast(std::round(speed))); const float target_speed = System::GetTargetSpeed(); if (target_speed <= 0.0f) text.append(" (Max)"); else text.append_format(" ({:.0f}%)", target_speed * 100.0f); - - first = false; } if (!text.empty()) { @@ -325,7 +319,7 @@ void ImGuiManager::DrawPerformanceOverlay() g_settings.cpu_execution_mode != CPUExecutionMode::Recompiler || g_settings.cpu_recompiler_icache || g_settings.cpu_recompiler_memory_exceptions) { - first = true; + bool first = true; text.assign("CPU["); if (g_settings.cpu_overclock_active) { diff --git a/src/core/system.cpp b/src/core/system.cpp index 2cf57ecca..4677f0950 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -962,11 +962,11 @@ bool System::ReadExecutableFromImage(CDImage* cdi, std::string* out_executable_n bool System::ReadExecutableFromImage(IsoReader& iso, std::string* out_executable_name, std::vector* out_executable_data) { - const std::string executable_path = GetExecutableNameForImage(iso, false); + std::string executable_path = GetExecutableNameForImage(iso, false); DEV_LOG("Executable path: '{}'", executable_path); if (!executable_path.empty() && out_executable_data) { - if (!iso.ReadFile(executable_path.c_str(), out_executable_data)) + if (!iso.ReadFile(executable_path, out_executable_data)) { ERROR_LOG("Failed to read executable '{}' from disc", executable_path); return false; @@ -993,26 +993,31 @@ System::GameHash System::GetGameHashFromBuffer(std::string_view exe_name, std::s return hash; } -DiscRegion System::GetRegionForSerial(std::string_view serial) +DiscRegion System::GetRegionForSerial(const std::string_view serial) { - std::string prefix; - for (size_t pos = 0; pos < serial.length(); pos++) - { - const int ch = std::tolower(serial[pos]); - if (ch < 'a' || ch > 'z') - break; + static constexpr const std::pair region_prefixes[] = { + {"sces", DiscRegion::PAL}, + {"sced", DiscRegion::PAL}, + {"sles", DiscRegion::PAL}, + {"sled", DiscRegion::PAL}, - prefix.push_back(static_cast(ch)); + {"scps", DiscRegion::NTSC_J}, + {"slps", DiscRegion::NTSC_J}, + {"slpm", DiscRegion::NTSC_J}, + {"sczs", DiscRegion::NTSC_J}, + {"papx", DiscRegion::NTSC_J}, + + {"scus", DiscRegion::NTSC_U}, + {"slus", DiscRegion::NTSC_U}, + }; + + for (const auto& [prefix, region] : region_prefixes) + { + if (StringUtil::StartsWithNoCase(serial, prefix)) + return region; } - if (prefix == "sces" || prefix == "sced" || prefix == "sles" || prefix == "sled") - return DiscRegion::PAL; - else if (prefix == "scps" || prefix == "slps" || prefix == "slpm" || prefix == "sczs" || prefix == "papx") - return DiscRegion::NTSC_J; - else if (prefix == "scus" || prefix == "slus") - return DiscRegion::NTSC_U; - else - return DiscRegion::Other; + return DiscRegion::Other; } DiscRegion System::GetRegionFromSystemArea(CDImage* cdi) @@ -1311,7 +1316,7 @@ bool System::UpdateGameSettingsLayer() std::unique_ptr input_interface; if (!input_profile_name.empty()) { - const std::string filename(GetInputProfilePath(input_profile_name)); + std::string filename = GetInputProfilePath(input_profile_name); if (FileSystem::FileExists(filename.c_str())) { INFO_LOG("Loading input profile from '{}'...", Path::GetFileName(filename)); diff --git a/src/core/system.h b/src/core/system.h index 7779a746c..1d68478c2 100644 --- a/src/core/system.h +++ b/src/core/system.h @@ -142,7 +142,7 @@ bool ReadExecutableFromImage(CDImage* cdi, std::string* out_executable_name, std std::string GetGameHashId(GameHash hash); bool GetGameDetailsFromImage(CDImage* cdi, std::string* out_id, GameHash* out_hash); GameHash GetGameHashFromFile(const char* path); -DiscRegion GetRegionForSerial(std::string_view serial); +DiscRegion GetRegionForSerial(const std::string_view serial); DiscRegion GetRegionFromSystemArea(CDImage* cdi); DiscRegion GetRegionForImage(CDImage* cdi); DiscRegion GetRegionForExe(const char* path); diff --git a/src/core/texture_replacements.cpp b/src/core/texture_replacements.cpp index f88a317cc..57fa07540 100644 --- a/src/core/texture_replacements.cpp +++ b/src/core/texture_replacements.cpp @@ -215,6 +215,8 @@ void TextureReplacements::Reload() void TextureReplacements::PurgeUnreferencedTexturesFromCache() { TextureCache old_map = std::move(s_texture_cache); + s_texture_cache = {}; + for (const auto& it : s_vram_write_replacements) { auto it2 = old_map.find(it.second); diff --git a/src/util/audio_stream.cpp b/src/util/audio_stream.cpp index fb3639696..3af43f061 100644 --- a/src/util/audio_stream.cpp +++ b/src/util/audio_stream.cpp @@ -55,6 +55,7 @@ AudioStream::AudioStream(u32 sample_rate, const AudioStreamParameters& parameter AudioStream::~AudioStream() { + StretchDestroy(); DestroyBuffer(); } diff --git a/src/util/cd_image_cue.cpp b/src/util/cd_image_cue.cpp index 17629c9c1..121dacc4f 100644 --- a/src/util/cd_image_cue.cpp +++ b/src/util/cd_image_cue.cpp @@ -86,7 +86,7 @@ bool CDImageCueSheet::OpenAndParse(const char* filename, Error* error) if (!track) break; - const std::string track_filename(track->file); + const std::string& track_filename = track->file; LBA track_start = track->start.ToLBA(); u32 track_file_index = 0; @@ -124,7 +124,7 @@ bool CDImageCueSheet::OpenAndParse(const char* filename, Error* error) return false; } - m_files.push_back(TrackFile{std::move(track_filename), track_fp, 0}); + m_files.push_back(TrackFile{track_filename, track_fp, 0}); } // data type determines the sector size diff --git a/src/util/cd_subchannel_replacement.cpp b/src/util/cd_subchannel_replacement.cpp index b191d255a..e2b9accd0 100644 --- a/src/util/cd_subchannel_replacement.cpp +++ b/src/util/cd_subchannel_replacement.cpp @@ -83,7 +83,7 @@ bool CDSubChannelReplacement::LoadSBI(const std::string& path) const u32 lba = MSFToLBA(entry.minute_bcd, entry.second_bcd, entry.frame_bcd); CDImage::SubChannelQ subq; - std::copy_n(entry.data, countof(entry.data), subq.data.data()); + std::memcpy(subq.data.data(), entry.data, sizeof(entry.data)); // generate an invalid crc by flipping all bits from the valid crc (will never collide) const u16 crc = subq.ComputeCRC(subq.data) ^ 0xFFFF; @@ -119,7 +119,7 @@ bool CDSubChannelReplacement::LoadLSD(const std::string& path) const u32 lba = MSFToLBA(entry.minute_bcd, entry.second_bcd, entry.frame_bcd); CDImage::SubChannelQ subq; - std::copy_n(entry.data, countof(entry.data), subq.data.data()); + std::memcpy(subq.data.data(), entry.data, sizeof(entry.data)); DEBUG_LOG("{:02x}:{:02x}:{:02x}: CRC {}", entry.minute_bcd, entry.second_bcd, entry.frame_bcd, subq.IsCRCValid() ? "VALID" : "INVALID"); diff --git a/src/util/cue_parser.cpp b/src/util/cue_parser.cpp index 2f4db5ebf..95a3bcc39 100644 --- a/src/util/cue_parser.cpp +++ b/src/util/cue_parser.cpp @@ -365,7 +365,7 @@ bool CueParser::File::HandlePregapCommand(const char* line, u32 line_number, Err return false; } - m_current_track->zero_pregap = std::move(msf); + m_current_track->zero_pregap = msf; return true; } diff --git a/src/util/d3d11_stream_buffer.cpp b/src/util/d3d11_stream_buffer.cpp index 1d359cfae..772d3296d 100644 --- a/src/util/d3d11_stream_buffer.cpp +++ b/src/util/d3d11_stream_buffer.cpp @@ -11,11 +11,11 @@ Log_SetChannel(D3D11Device); -D3D11StreamBuffer::D3D11StreamBuffer() : m_size(0), m_position(0) +D3D11StreamBuffer::D3D11StreamBuffer() { } -D3D11StreamBuffer::D3D11StreamBuffer(ComPtr buffer) : m_buffer(std::move(buffer)), m_position(0) +D3D11StreamBuffer::D3D11StreamBuffer(ComPtr buffer) : m_buffer(std::move(buffer)) { D3D11_BUFFER_DESC desc; m_buffer->GetDesc(&desc); diff --git a/src/util/d3d11_stream_buffer.h b/src/util/d3d11_stream_buffer.h index 7b5c7263d..29e1ef403 100644 --- a/src/util/d3d11_stream_buffer.h +++ b/src/util/d3d11_stream_buffer.h @@ -42,9 +42,9 @@ public: private: ComPtr m_buffer; - u32 m_size; - u32 m_max_size; - u32 m_position; + u32 m_size = 0; + u32 m_max_size = 0; + u32 m_position = 0; bool m_use_map_no_overwrite = false; bool m_mapped = false; }; diff --git a/src/util/d3d12_texture.cpp b/src/util/d3d12_texture.cpp index c5f7b8c6c..6c33a3044 100644 --- a/src/util/d3d12_texture.cpp +++ b/src/util/d3d12_texture.cpp @@ -753,7 +753,7 @@ std::unique_ptr D3D12Device::CreateSampler(const GPUSampler::Config& if (!handle) return {}; - return std::unique_ptr(new D3D12Sampler(std::move(handle))); + return std::unique_ptr(new D3D12Sampler(handle)); } D3D12TextureBuffer::D3D12TextureBuffer(Format format, u32 size_in_elements) : GPUTextureBuffer(format, size_in_elements) diff --git a/src/util/gpu_device.cpp b/src/util/gpu_device.cpp index acc898c42..5b6829cac 100644 --- a/src/util/gpu_device.cpp +++ b/src/util/gpu_device.cpp @@ -415,7 +415,7 @@ void GPUDevice::OpenShaderCache(std::string_view base_path, u32 version) if (m_features.pipeline_cache && !base_path.empty()) { const std::string basename = GetShaderCacheBaseName("pipelines"); - const std::string filename = Path::Combine(base_path, TinyString::from_format("{}.bin", basename)); + std::string filename = Path::Combine(base_path, TinyString::from_format("{}.bin", basename)); if (ReadPipelineCache(filename)) s_pipeline_cache_path = std::move(filename); else diff --git a/src/util/gpu_device.h b/src/util/gpu_device.h index b3dbc6691..d76d54614 100644 --- a/src/util/gpu_device.h +++ b/src/util/gpu_device.h @@ -449,7 +449,7 @@ public: protected: Format m_format; u32 m_size_in_elements; - u32 m_current_position; + u32 m_current_position = 0; }; class GPUDevice diff --git a/src/util/gpu_framebuffer_manager.h b/src/util/gpu_framebuffer_manager.h index 9b4d199d2..ec522cf8a 100644 --- a/src/util/gpu_framebuffer_manager.h +++ b/src/util/gpu_framebuffer_manager.h @@ -136,7 +136,7 @@ template void GPUFramebufferManager::Clear() { - for (auto it : m_map) + for (const auto& it : m_map) DestroyFunc(it.second); m_map.clear(); } diff --git a/src/util/gpu_shader_cache.h b/src/util/gpu_shader_cache.h index 2b833a1c6..85bfcd8f3 100644 --- a/src/util/gpu_shader_cache.h +++ b/src/util/gpu_shader_cache.h @@ -76,7 +76,7 @@ private: CacheIndex m_index; std::string m_base_filename; - u32 m_version; + u32 m_version = 0; std::FILE* m_index_file = nullptr; std::FILE* m_blob_file = nullptr; diff --git a/src/util/input_source.cpp b/src/util/input_source.cpp index 73047ea9d..4282e17d7 100644 --- a/src/util/input_source.cpp +++ b/src/util/input_source.cpp @@ -75,7 +75,7 @@ std::optional InputSource::ParseGenericControllerKey(InputSourc return std::nullopt; const std::optional source_index = StringUtil::FromChars(source.substr(pos)); - if (source_index.has_value() || source_index.value() < 0) + if (!source_index.has_value() || source_index.value() < 0) return std::nullopt; InputBindingKey key = {}; diff --git a/src/util/opengl_texture.cpp b/src/util/opengl_texture.cpp index 3ef3ca974..9882ab469 100644 --- a/src/util/opengl_texture.cpp +++ b/src/util/opengl_texture.cpp @@ -554,6 +554,7 @@ void OpenGLDevice::CommitRTClearInFB(OpenGLTexture* tex, u32 idx) glEnable(GL_SCISSOR_TEST); tex->SetState(GPUTexture::State::Dirty); } + break; case GPUTexture::State::Dirty: break; diff --git a/src/util/shadergen.cpp b/src/util/shadergen.cpp index 3a9257f5d..517c637fb 100644 --- a/src/util/shadergen.cpp +++ b/src/util/shadergen.cpp @@ -23,7 +23,7 @@ ShaderGen::ShaderGen(RenderAPI render_api, GPUShaderLanguage shader_language, bo m_glsl(shader_language == GPUShaderLanguage::GLSL || shader_language == GPUShaderLanguage::GLSLES || shader_language == GPUShaderLanguage::GLSLVK), m_spirv(shader_language == GPUShaderLanguage::GLSLVK), m_supports_dual_source_blend(supports_dual_source_blend), - m_supports_framebuffer_fetch(supports_framebuffer_fetch), m_use_glsl_interface_blocks(false) + m_supports_framebuffer_fetch(supports_framebuffer_fetch) { if (m_glsl) { diff --git a/src/util/shadergen.h b/src/util/shadergen.h index 3d38cca49..bc92cc935 100644 --- a/src/util/shadergen.h +++ b/src/util/shadergen.h @@ -72,8 +72,8 @@ protected: bool m_spirv; bool m_supports_dual_source_blend; bool m_supports_framebuffer_fetch; - bool m_use_glsl_interface_blocks; - bool m_use_glsl_binding_layout; + bool m_use_glsl_interface_blocks = false; + bool m_use_glsl_binding_layout = false; bool m_has_uniform_buffer = false; TinyString m_glsl_version_string;