Fix all uninitialized variable warnings (C26495)

This commit is contained in:
Pokechu22
2021-09-03 21:43:19 -07:00
parent 525e6b2194
commit 78bfd25964
111 changed files with 638 additions and 651 deletions

View File

@ -607,19 +607,19 @@ class VertexLoaderBase;
// STATE_TO_SAVE
struct CPState final
{
u32 array_bases[CP_NUM_ARRAYS];
u32 array_strides[CP_NUM_ARRAYS];
TMatrixIndexA matrix_index_a;
TMatrixIndexB matrix_index_b;
u32 array_bases[CP_NUM_ARRAYS]{};
u32 array_strides[CP_NUM_ARRAYS]{};
TMatrixIndexA matrix_index_a{};
TMatrixIndexB matrix_index_b{};
TVtxDesc vtx_desc;
// Most games only use the first VtxAttr and simply reconfigure it all the time as needed.
VAT vtx_attr[CP_NUM_VAT_REG];
VAT vtx_attr[CP_NUM_VAT_REG]{};
// Attributes that actually belong to VertexLoaderManager:
BitSet32 attr_dirty;
bool bases_dirty;
VertexLoaderBase* vertex_loaders[CP_NUM_VAT_REG];
int last_id;
BitSet32 attr_dirty{};
bool bases_dirty = false;
VertexLoaderBase* vertex_loaders[CP_NUM_VAT_REG]{};
int last_id = 0;
};
class PointerWrap;

View File

@ -20,8 +20,8 @@ struct SCPFifoStruct
// fifo registers
std::atomic<u32> CPBase;
std::atomic<u32> CPEnd;
u32 CPHiWatermark;
u32 CPLoWatermark;
u32 CPHiWatermark = 0;
u32 CPLoWatermark = 0;
std::atomic<u32> CPReadWriteDistance;
std::atomic<u32> CPWritePointer;
std::atomic<u32> CPReadPointer;

View File

@ -30,10 +30,10 @@ public:
struct FrameData
{
const u8* data;
int width;
int height;
int stride;
const u8* data = nullptr;
int width = 0;
int height = 0;
int stride = 0;
FrameState state;
};

View File

@ -35,10 +35,19 @@ struct GXPipelineUid
// and this map lookup can happen every draw call. However, as using memcmp() will also compare
// any padding bytes, we have to ensure these are zeroed out.
GXPipelineUid() { std::memset(static_cast<void*>(this), 0, sizeof(*this)); }
#ifdef _MSC_VER
#pragma warning(push)
// Disable warning for uninitialized member variables, as MSVC doesn't recognise that memcpy
// performs this initialization.
#pragma warning(disable : 26495)
#endif
GXPipelineUid(const GXPipelineUid& rhs)
{
std::memcpy(static_cast<void*>(this), &rhs, sizeof(*this));
}
#ifdef _MSC_VER
#pragma warning(pop)
#endif
GXPipelineUid& operator=(const GXPipelineUid& rhs)
{
std::memcpy(static_cast<void*>(this), &rhs, sizeof(*this));
@ -65,10 +74,18 @@ struct GXUberPipelineUid
BlendingState blending_state;
GXUberPipelineUid() { std::memset(static_cast<void*>(this), 0, sizeof(*this)); }
#ifdef _MSC_VER
#pragma warning(push)
// Disable warning for uninitialized member variables
#pragma warning(disable : 26495)
#endif
GXUberPipelineUid(const GXUberPipelineUid& rhs)
{
std::memcpy(static_cast<void*>(this), &rhs, sizeof(*this));
}
#ifdef _MSC_VER
#pragma warning(pop)
#endif
GXUberPipelineUid& operator=(const GXUberPipelineUid& rhs)
{
std::memcpy(static_cast<void*>(this), &rhs, sizeof(*this));
@ -90,23 +107,23 @@ struct GXUberPipelineUid
#pragma pack(push, 1)
struct SerializedGXPipelineUid
{
PortableVertexDeclaration vertex_decl;
PortableVertexDeclaration vertex_decl{};
VertexShaderUid vs_uid;
GeometryShaderUid gs_uid;
PixelShaderUid ps_uid;
u32 rasterization_state_bits;
u32 depth_state_bits;
u32 blending_state_bits;
u32 rasterization_state_bits = 0;
u32 depth_state_bits = 0;
u32 blending_state_bits = 0;
};
struct SerializedGXUberPipelineUid
{
PortableVertexDeclaration vertex_decl;
PortableVertexDeclaration vertex_decl{};
UberShader::VertexShaderUid vs_uid;
GeometryShaderUid gs_uid;
UberShader::PixelShaderUid ps_uid;
u32 rasterization_state_bits;
u32 depth_state_bits;
u32 blending_state_bits;
u32 rasterization_state_bits = 0;
u32 depth_state_bits = 0;
u32 blending_state_bits = 0;
};
#pragma pack(pop)

View File

@ -54,6 +54,6 @@ private:
static bool LoadTexture(Level& level, const std::vector<u8>& buffer);
static void Prefetch();
HiresTexture() {}
bool m_has_arbitrary_mipmaps;
HiresTexture() = default;
bool m_has_arbitrary_mipmaps = false;
};

View File

@ -31,7 +31,7 @@ public:
OPTION_INTEGER,
};
bool m_bool_value;
bool m_bool_value = false;
std::vector<float> m_float_values;
std::vector<s32> m_integer_values;
@ -45,12 +45,12 @@ public:
std::vector<float> m_float_step_values;
std::vector<s32> m_integer_step_values;
OptionType m_type;
OptionType m_type = OptionType::OPTION_BOOL;
std::string m_gui_name;
std::string m_option_name;
std::string m_dependent_option;
bool m_dirty;
bool m_dirty = false;
};
using ConfigMap = std::map<std::string, ConfigurationOption>;

View File

@ -211,7 +211,7 @@ private:
struct Shader
{
std::unique_ptr<AbstractShader> shader;
bool pending;
bool pending = false;
};
std::map<Uid, Shader> shader_map;
LinearDiskCache<Uid, u8> disk_cache;

View File

@ -90,14 +90,14 @@ public:
// common members
std::unique_ptr<AbstractTexture> texture;
std::unique_ptr<AbstractFramebuffer> framebuffer;
u32 addr;
u32 size_in_bytes;
u64 base_hash;
u64 hash; // for paletted textures, hash = base_hash ^ palette_hash
u32 addr = 0;
u32 size_in_bytes = 0;
u64 base_hash = 0;
u64 hash = 0; // for paletted textures, hash = base_hash ^ palette_hash
TextureAndTLUTFormat format;
u32 memory_stride;
bool is_efb_copy;
bool is_custom_tex;
u32 memory_stride = 0;
bool is_efb_copy = false;
bool is_custom_tex = false;
bool may_have_overlapping_textures = true;
bool tmem_only = false; // indicates that this texture only exists in the tmem cache
bool has_arbitrary_mips = false; // indicates that the mips in this texture are arbitrary
@ -105,13 +105,14 @@ public:
bool should_force_safe_hashing = false; // for XFB
bool is_xfb_copy = false;
bool is_xfb_container = false;
u64 id;
u64 id = 0;
bool reference_changed = false; // used by xfb to determine when a reference xfb changed
unsigned int native_width,
native_height; // Texture dimensions from the GameCube's point of view
unsigned int native_levels;
// Texture dimensions from the GameCube's point of view
u32 native_width = 0;
u32 native_height = 0;
u32 native_levels = 0;
// used to delete textures which haven't been used for TEXTURE_KILL_THRESHOLD frames
int frameCount = FRAMECOUNT_INVALID;

View File

@ -16,8 +16,8 @@ class DataReader;
class VertexLoaderUID
{
std::array<u32, 5> vid;
size_t hash;
std::array<u32, 5> vid{};
size_t hash = 0;
public:
VertexLoaderUID() {}

View File

@ -33,29 +33,6 @@ void UpdateActiveConfig()
g_ActiveConfig.bVSyncActive = IsVSyncActive(g_ActiveConfig.bVSync);
}
VideoConfig::VideoConfig()
{
// Needed for the first frame, I think
fAspectRatioHackW = 1;
fAspectRatioHackH = 1;
// disable all features by default
backend_info.api_type = APIType::Nothing;
backend_info.MaxTextureSize = 16384;
backend_info.bSupportsExclusiveFullscreen = false;
backend_info.bSupportsMultithreading = false;
backend_info.bSupportsST3CTextures = false;
backend_info.bSupportsBPTCTextures = false;
bEnableValidationLayer = false;
#if defined(ANDROID)
bBackendMultithreading = false;
#else
bBackendMultithreading = true;
#endif
}
void VideoConfig::Refresh()
{
if (!s_has_registered_callback)

View File

@ -13,8 +13,7 @@
#include <vector>
#include "Common/CommonTypes.h"
enum class APIType;
#include "VideoCommon/VideoCommon.h"
// Log in two categories, and save three other options in the same byte
#define CONF_LOG 1
@ -53,135 +52,140 @@ enum class ShaderCompilationMode : int
// NEVER inherit from this class.
struct VideoConfig final
{
VideoConfig();
VideoConfig() = default;
void Refresh();
void VerifyValidity();
// General
bool bVSync;
bool bVSyncActive;
bool bWidescreenHack;
AspectMode aspect_mode;
AspectMode suggested_aspect_mode;
bool bCrop; // Aspect ratio controls.
bool bShaderCache;
bool bVSync = false;
bool bVSyncActive = false;
bool bWidescreenHack = false;
AspectMode aspect_mode{};
AspectMode suggested_aspect_mode{};
bool bCrop = false; // Aspect ratio controls.
bool bShaderCache = false;
// Enhancements
u32 iMultisamples;
bool bSSAA;
int iEFBScale;
bool bForceFiltering;
int iMaxAnisotropy;
u32 iMultisamples = 0;
bool bSSAA = false;
int iEFBScale = 0;
bool bForceFiltering = false;
int iMaxAnisotropy = 0;
std::string sPostProcessingShader;
bool bForceTrueColor;
bool bDisableCopyFilter;
bool bArbitraryMipmapDetection;
float fArbitraryMipmapDetectionThreshold;
bool bForceTrueColor = false;
bool bDisableCopyFilter = false;
bool bArbitraryMipmapDetection = false;
float fArbitraryMipmapDetectionThreshold = 0;
// Information
bool bShowFPS;
bool bShowNetPlayPing;
bool bShowNetPlayMessages;
bool bOverlayStats;
bool bOverlayProjStats;
bool bTexFmtOverlayEnable;
bool bTexFmtOverlayCenter;
bool bLogRenderTimeToFile;
bool bShowFPS = false;
bool bShowNetPlayPing = false;
bool bShowNetPlayMessages = false;
bool bOverlayStats = false;
bool bOverlayProjStats = false;
bool bTexFmtOverlayEnable = false;
bool bTexFmtOverlayCenter = false;
bool bLogRenderTimeToFile = false;
// Render
bool bWireFrame;
bool bDisableFog;
bool bWireFrame = false;
bool bDisableFog = false;
// Utility
bool bDumpTextures;
bool bDumpMipmapTextures;
bool bDumpBaseTextures;
bool bHiresTextures;
bool bCacheHiresTextures;
bool bDumpEFBTarget;
bool bDumpXFBTarget;
bool bDumpFramesAsImages;
bool bUseFFV1;
bool bDumpTextures = false;
bool bDumpMipmapTextures = false;
bool bDumpBaseTextures = false;
bool bHiresTextures = false;
bool bCacheHiresTextures = false;
bool bDumpEFBTarget = false;
bool bDumpXFBTarget = false;
bool bDumpFramesAsImages = false;
bool bUseFFV1 = false;
std::string sDumpCodec;
std::string sDumpEncoder;
std::string sDumpFormat;
std::string sDumpPath;
bool bInternalResolutionFrameDumps;
bool bBorderlessFullscreen;
bool bEnableGPUTextureDecoding;
int iBitrateKbps;
bool bInternalResolutionFrameDumps = false;
bool bBorderlessFullscreen = false;
bool bEnableGPUTextureDecoding = false;
int iBitrateKbps = 0;
// Hacks
bool bEFBAccessEnable;
bool bEFBAccessDeferInvalidation;
bool bPerfQueriesEnable;
bool bBBoxEnable;
bool bForceProgressive;
bool bEFBAccessEnable = false;
bool bEFBAccessDeferInvalidation = false;
bool bPerfQueriesEnable = false;
bool bBBoxEnable = false;
bool bForceProgressive = false;
bool bEFBEmulateFormatChanges;
bool bSkipEFBCopyToRam;
bool bSkipXFBCopyToRam;
bool bDisableCopyToVRAM;
bool bDeferEFBCopies;
bool bImmediateXFB;
bool bSkipPresentingDuplicateXFBs;
bool bCopyEFBScaled;
int iSafeTextureCache_ColorSamples;
float fAspectRatioHackW, fAspectRatioHackH;
bool bEnablePixelLighting;
bool bFastDepthCalc;
bool bVertexRounding;
int iEFBAccessTileSize;
int iLog; // CONF_ bits
int iSaveTargetId; // TODO: Should be dropped
u32 iMissingColorValue;
bool bEFBEmulateFormatChanges = false;
bool bSkipEFBCopyToRam = false;
bool bSkipXFBCopyToRam = false;
bool bDisableCopyToVRAM = false;
bool bDeferEFBCopies = false;
bool bImmediateXFB = false;
bool bSkipPresentingDuplicateXFBs = false;
bool bCopyEFBScaled = false;
int iSafeTextureCache_ColorSamples = 0;
float fAspectRatioHackW = 1; // Initial value needed for the first frame
float fAspectRatioHackH = 1;
bool bEnablePixelLighting = false;
bool bFastDepthCalc = false;
bool bVertexRounding = false;
int iEFBAccessTileSize = 0;
int iLog = 0; // CONF_ bits
int iSaveTargetId = 0; // TODO: Should be dropped
u32 iMissingColorValue = 0;
// Stereoscopy
StereoMode stereo_mode;
int iStereoDepth;
int iStereoConvergence;
int iStereoConvergencePercentage;
bool bStereoSwapEyes;
bool bStereoEFBMonoDepth;
int iStereoDepthPercentage;
StereoMode stereo_mode{};
int iStereoDepth = 0;
int iStereoConvergence = 0;
int iStereoConvergencePercentage = 0;
bool bStereoSwapEyes = false;
bool bStereoEFBMonoDepth = false;
int iStereoDepthPercentage = 0;
// D3D only config, mostly to be merged into the above
int iAdapter;
int iAdapter = 0;
// VideoSW Debugging
int drawStart;
int drawEnd;
bool bZComploc;
bool bZFreeze;
bool bDumpObjects;
bool bDumpTevStages;
bool bDumpTevTextureFetches;
int drawStart = 0;
int drawEnd = 0;
bool bZComploc = false;
bool bZFreeze = false;
bool bDumpObjects = false;
bool bDumpTevStages = false;
bool bDumpTevTextureFetches = false;
// Enable API validation layers, currently only supported with Vulkan.
bool bEnableValidationLayer;
bool bEnableValidationLayer = false;
// Multithreaded submission, currently only supported with Vulkan.
bool bBackendMultithreading;
#if defined(ANDROID)
bool bBackendMultithreading = false;
#else
bool bBackendMultithreading = true;
#endif
// Early command buffer execution interval in number of draws.
// Currently only supported with Vulkan.
int iCommandBufferExecuteInterval;
int iCommandBufferExecuteInterval = 0;
// Shader compilation settings.
bool bWaitForShadersBeforeStarting;
ShaderCompilationMode iShaderCompilationMode;
bool bWaitForShadersBeforeStarting = false;
ShaderCompilationMode iShaderCompilationMode{};
// Number of shader compiler threads.
// 0 disables background compilation.
// -1 uses an automatic number based on the CPU threads.
int iShaderCompilerThreads;
int iShaderPrecompilerThreads;
int iShaderCompilerThreads = 0;
int iShaderPrecompilerThreads = 0;
// Static config per API
// TODO: Move this out of VideoConfig
struct
{
APIType api_type;
APIType api_type = APIType::Nothing;
std::vector<std::string> Adapters; // for D3D
std::vector<u32> AAModes;
@ -189,42 +193,43 @@ struct VideoConfig final
// TODO: merge AdapterName and Adapters array
std::string AdapterName; // for OpenGL
u32 MaxTextureSize;
bool bUsesLowerLeftOrigin;
u32 MaxTextureSize = 16384;
bool bUsesLowerLeftOrigin = false;
bool bSupportsExclusiveFullscreen;
bool bSupportsDualSourceBlend;
bool bSupportsPrimitiveRestart;
bool bSupportsOversizedViewports;
bool bSupportsGeometryShaders;
bool bSupportsComputeShaders;
bool bSupports3DVision;
bool bSupportsEarlyZ; // needed by PixelShaderGen, so must stay in VideoCommon
bool bSupportsBindingLayout; // Needed by ShaderGen, so must stay in VideoCommon
bool bSupportsBBox;
bool bSupportsGSInstancing; // Needed by GeometryShaderGen, so must stay in VideoCommon
bool bSupportsPostProcessing;
bool bSupportsPaletteConversion;
bool bSupportsClipControl; // Needed by VertexShaderGen, so must stay in VideoCommon
bool bSupportsSSAA;
bool bSupportsFragmentStoresAndAtomics; // a.k.a. OpenGL SSBOs a.k.a. Direct3D UAVs
bool bSupportsDepthClamp; // Needed by VertexShaderGen, so must stay in VideoCommon
bool bSupportsReversedDepthRange;
bool bSupportsLogicOp;
bool bSupportsMultithreading;
bool bSupportsGPUTextureDecoding;
bool bSupportsST3CTextures;
bool bSupportsCopyToVram;
bool bSupportsBitfield; // Needed by UberShaders, so must stay in VideoCommon
bool bSupportsDynamicSamplerIndexing; // Needed by UberShaders, so must stay in VideoCommon
bool bSupportsBPTCTextures;
bool bSupportsFramebufferFetch; // Used as an alternative to dual-source blend on GLES
bool bSupportsBackgroundCompiling;
bool bSupportsLargePoints;
bool bSupportsPartialDepthCopies;
bool bSupportsDepthReadback;
bool bSupportsShaderBinaries;
bool bSupportsPipelineCacheData;
bool bSupportsExclusiveFullscreen = false;
bool bSupportsDualSourceBlend = false;
bool bSupportsPrimitiveRestart = false;
bool bSupportsOversizedViewports = false;
bool bSupportsGeometryShaders = false;
bool bSupportsComputeShaders = false;
bool bSupports3DVision = false;
bool bSupportsEarlyZ = false; // needed by PixelShaderGen, so must stay in VideoCommon
bool bSupportsBindingLayout = false; // Needed by ShaderGen, so must stay in VideoCommon
bool bSupportsBBox = false;
bool bSupportsGSInstancing = false; // Needed by GeometryShaderGen, so must stay in VideoCommon
bool bSupportsPostProcessing = false;
bool bSupportsPaletteConversion = false;
bool bSupportsClipControl = false; // Needed by VertexShaderGen, so must stay in VideoCommon
bool bSupportsSSAA = false;
bool bSupportsFragmentStoresAndAtomics = false; // a.k.a. OpenGL SSBOs a.k.a. Direct3D UAVs
bool bSupportsDepthClamp = false; // Needed by VertexShaderGen, so must stay in VideoCommon
bool bSupportsReversedDepthRange = false;
bool bSupportsLogicOp = false;
bool bSupportsMultithreading = false;
bool bSupportsGPUTextureDecoding = false;
bool bSupportsST3CTextures = false;
bool bSupportsCopyToVram = false;
bool bSupportsBitfield = false; // Needed by UberShaders, so must stay in VideoCommon
// Needed by UberShaders, so must stay in VideoCommon
bool bSupportsDynamicSamplerIndexing = false;
bool bSupportsBPTCTextures = false;
bool bSupportsFramebufferFetch = false; // Used as an alternative to dual-source blend on GLES
bool bSupportsBackgroundCompiling = false;
bool bSupportsLargePoints = false;
bool bSupportsPartialDepthCopies = false;
bool bSupportsDepthReadback = false;
bool bSupportsShaderBinaries = false;
bool bSupportsPipelineCacheData = false;
} backend_info;
// Utility