diff options
| author | Léo Lam <leo@leolam.fr> | 2023-04-14 01:29:46 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-14 01:29:46 +0100 |
| commit | ae18aa0639bdf2d51c8bf738bd7f794d89aa22e4 (patch) | |
| tree | 1dc008a5333267aea8e48c20f5a59029b9aba27e /Source/Core/VideoCommon | |
| parent | 5c03b8af88e80e9502dcb0b20e17d9debf2617b3 (diff) | |
| parent | f29019180f12e8287661ebde19f0b1baed966bc9 (diff) | |
Merge pull request #11687 from Minty-Meeo/warnings
Resolve GCC/Clang Warnings
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/CPMemory.cpp | 12 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/ShaderCache.cpp | 24 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/TextureCacheBase.cpp | 4 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/VertexLoaderManager.cpp | 11 |
4 files changed, 17 insertions, 34 deletions
diff --git a/Source/Core/VideoCommon/CPMemory.cpp b/Source/Core/VideoCommon/CPMemory.cpp index 3d72a6f70b..a42ee8fc2e 100644 --- a/Source/Core/VideoCommon/CPMemory.cpp +++ b/Source/Core/VideoCommon/CPMemory.cpp @@ -4,6 +4,7 @@ #include "VideoCommon/CPMemory.h" #include <cstring> +#include <type_traits> #include "Common/ChunkFile.h" #include "Common/Logging/Log.h" @@ -17,14 +18,9 @@ CPState g_preprocess_cp_state; void CopyPreprocessCPStateFromMain() { -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wclass-memaccess" -#endif - std::memcpy(&g_preprocess_cp_state, &g_main_cp_state, sizeof(CPState)); -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + static_assert(std::is_trivially_copyable_v<CPState>); + std::memcpy(static_cast<void*>(&g_preprocess_cp_state), + static_cast<const void*>(&g_main_cp_state), sizeof(CPState)); } std::pair<std::string, std::string> GetCPRegInfo(u8 cmd, u32 value) diff --git a/Source/Core/VideoCommon/ShaderCache.cpp b/Source/Core/VideoCommon/ShaderCache.cpp index 1c01356c99..150f38b307 100644 --- a/Source/Core/VideoCommon/ShaderCache.cpp +++ b/Source/Core/VideoCommon/ShaderCache.cpp @@ -608,14 +608,10 @@ AbstractPipelineConfig ShaderCache::GetGXPipelineConfig( static GXPipelineUid ApplyDriverBugs(const GXPipelineUid& in) { GXPipelineUid out; -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wclass-memaccess" -#endif - memcpy(&out, &in, sizeof(out)); // copy padding -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + // TODO: static_assert(std::is_trivially_copyable_v<GXPipelineUid>); + // GXPipelineUid is not trivially copyable because RasterizationState and BlendingState aren't + // either, but we can pretend it is for now. This will be improved after PR #10848 is finished. + memcpy(static_cast<void*>(&out), static_cast<const void*>(&in), sizeof(out)); // copy padding pixel_shader_uid_data* ps = out.ps_uid.GetUidData(); BlendingState& blend = out.blending_state; @@ -785,14 +781,10 @@ ShaderCache::GetGXPipelineConfig(const GXPipelineUid& config_in) static GXUberPipelineUid ApplyDriverBugs(const GXUberPipelineUid& in) { GXUberPipelineUid out; -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wclass-memaccess" -#endif - memcpy(&out, &in, sizeof(out)); // Copy padding -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + // TODO: static_assert(std::is_trivially_copyable_v<GXUberPipelineUid>); + // GXUberPipelineUid is not trivially copyable because RasterizationState and BlendingState aren't + // either, but we can pretend it is for now. This will be improved after PR #10848 is finished. + memcpy(static_cast<void*>(&out), static_cast<const void*>(&in), sizeof(out)); // Copy padding if (g_ActiveConfig.backend_info.bSupportsDynamicVertexLoader) out.vertex_format = nullptr; diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 15f79f99bd..bcffe8e4ca 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -657,8 +657,8 @@ void TextureCacheBase::DoSaveState(PointerWrap& p) } auto doList = [&p](auto list) { - u32 size = static_cast<u32>(list.size()); - p.Do(size); + u32 list_size = static_cast<u32>(list.size()); + p.Do(list_size); for (const auto& it : list) { p.Do(it.first); diff --git a/Source/Core/VideoCommon/VertexLoaderManager.cpp b/Source/Core/VideoCommon/VertexLoaderManager.cpp index 0236201001..fb24803f1c 100644 --- a/Source/Core/VideoCommon/VertexLoaderManager.cpp +++ b/Source/Core/VideoCommon/VertexLoaderManager.cpp @@ -8,6 +8,7 @@ #include <memory> #include <mutex> #include <string> +#include <type_traits> #include <unordered_map> #include <utility> #include <vector> @@ -153,14 +154,8 @@ NativeVertexFormat* GetUberVertexFormat(const PortableVertexDeclaration& decl) // The padding in the structs can cause the memcmp() in the map to create duplicates. // Avoid this by initializing the padding to zero. PortableVertexDeclaration new_decl; -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wclass-memaccess" -#endif - std::memset(&new_decl, 0, sizeof(new_decl)); -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + static_assert(std::is_trivially_copyable_v<PortableVertexDeclaration>); + std::memset(static_cast<void*>(&new_decl), 0, sizeof(new_decl)); new_decl.stride = decl.stride; auto MakeDummyAttribute = [](AttributeFormat& attr, ComponentFormat type, int components, |
