From 9bad0c5ec0bed1fe88d19d5f483e56e2b9bb3096 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 6 Jun 2025 12:16:45 +0100 Subject: [PATCH] Remove some memset calls on non-POD types --- qrenderdoc/Windows/BufferViewer.cpp | 2 +- .../Windows/Dialogs/VirtualFileDialog.cpp | 2 +- qrenderdoc/Windows/StatisticsViewer.cpp | 8 --- renderdoc/api/replay/data_types.h | 68 +++++++++---------- 4 files changed, 36 insertions(+), 44 deletions(-) diff --git a/qrenderdoc/Windows/BufferViewer.cpp b/qrenderdoc/Windows/BufferViewer.cpp index d32d94ac5..37c3a661a 100644 --- a/qrenderdoc/Windows/BufferViewer.cpp +++ b/qrenderdoc/Windows/BufferViewer.cpp @@ -2416,7 +2416,7 @@ BufferViewer::BufferViewer(ICaptureContext &ctx, bool meshview, QWidget *parent) m_Output = NULL; - memset(&m_Config, 0, sizeof(m_Config)); + m_Config = MeshDisplay(); m_Config.type = MeshDataStage::VSIn; m_Config.wireframeDraw = true; m_Config.exploderScale = 1.0f; diff --git a/qrenderdoc/Windows/Dialogs/VirtualFileDialog.cpp b/qrenderdoc/Windows/Dialogs/VirtualFileDialog.cpp index 2ad6ff3f1..1e334977c 100644 --- a/qrenderdoc/Windows/Dialogs/VirtualFileDialog.cpp +++ b/qrenderdoc/Windows/Dialogs/VirtualFileDialog.cpp @@ -401,7 +401,7 @@ private: struct FSNode { - FSNode() { memset(&file, 0, sizeof(file)); } + FSNode() {} ~FSNode() { for(FSNode *n : children) diff --git a/qrenderdoc/Windows/StatisticsViewer.cpp b/qrenderdoc/Windows/StatisticsViewer.cpp index d788fe12a..7661a2935 100644 --- a/qrenderdoc/Windows/StatisticsViewer.cpp +++ b/qrenderdoc/Windows/StatisticsViewer.cpp @@ -178,7 +178,6 @@ void StatisticsViewer::AppendShaderStatistics() const rdcarray &shaders = frameInfo.stats.shaders; ShaderChangeStats totalShadersPerStage; - memset(&totalShadersPerStage, 0, sizeof(totalShadersPerStage)); for(auto s : indices()) { totalShadersPerStage.calls += shaders[s].calls; @@ -222,7 +221,6 @@ void StatisticsViewer::AppendConstantBindStatistics() // thereof), but given we're heading for a Qt/C++ rewrite of the UI // perhaps best not to dwell too long on that ConstantBindStats totalConstantsPerStage[arraydim()]; - memset(&totalConstantsPerStage, 0, sizeof(totalConstantsPerStage)); for(auto s : indices()) { totalConstantsPerStage[s].bindslots.resize(reference.bindslots.size()); @@ -246,7 +244,6 @@ void StatisticsViewer::AppendConstantBindStatistics() } ConstantBindStats totalConstantsForAllStages; - memset(&totalConstantsForAllStages, 0, sizeof(totalConstantsForAllStages)); totalConstantsForAllStages.bindslots.resize(totalConstantsPerStage[0].bindslots.size()); totalConstantsForAllStages.sizes.resize(totalConstantsPerStage[0].sizes.size()); @@ -314,7 +311,6 @@ void StatisticsViewer::AppendSamplerBindStatistics() const SamplerBindStats &reference = frameInfo.stats.samplers[0]; SamplerBindStats totalSamplersPerStage[arraydim()]; - memset(&totalSamplersPerStage, 0, sizeof(totalSamplersPerStage)); for(auto s : indices()) { totalSamplersPerStage[s].bindslots.resize(reference.bindslots.size()); @@ -336,7 +332,6 @@ void StatisticsViewer::AppendSamplerBindStatistics() } SamplerBindStats totalSamplersForAllStages; - memset(&totalSamplersForAllStages, 0, sizeof(totalSamplersForAllStages)); totalSamplersForAllStages.bindslots.resize(totalSamplersPerStage[0].bindslots.size()); for(auto s : indices()) @@ -380,7 +375,6 @@ void StatisticsViewer::AppendResourceBindStatistics() const ResourceBindStats &reference = frameInfo.stats.resources[0]; ResourceBindStats totalResourcesPerStage[arraydim()]; - memset(&totalResourcesPerStage, 0, sizeof(totalResourcesPerStage)); for(auto s : indices()) { totalResourcesPerStage[s].types.resize(reference.types.size()); @@ -408,7 +402,6 @@ void StatisticsViewer::AppendResourceBindStatistics() } ResourceBindStats totalResourcesForAllStages; - memset(&totalResourcesForAllStages, 0, sizeof(totalResourcesForAllStages)); totalResourcesForAllStages.types.resize(totalResourcesPerStage[0].types.size()); totalResourcesForAllStages.bindslots.resize(totalResourcesPerStage[0].bindslots.size()); @@ -478,7 +471,6 @@ void StatisticsViewer::AppendUpdateStatistics() const ResourceUpdateStats &reference = frameInfo.stats.updates; ResourceUpdateStats totalUpdates; - memset(&totalUpdates, 0, sizeof(totalUpdates)); totalUpdates.types.resize(reference.types.size()); totalUpdates.sizes.resize(reference.sizes.size()); diff --git a/renderdoc/api/replay/data_types.h b/renderdoc/api/replay/data_types.h index b3bf69422..12738fa6f 100644 --- a/renderdoc/api/replay/data_types.h +++ b/renderdoc/api/replay/data_types.h @@ -934,13 +934,13 @@ struct ConstantBindStats static const size_t BucketCount = 31; DOCUMENT("How many function calls were made."); - uint32_t calls; + uint32_t calls = 0; DOCUMENT("How many objects were bound."); - uint32_t sets; + uint32_t sets = 0; DOCUMENT("How many objects were unbound."); - uint32_t nulls; + uint32_t nulls = 0; DOCUMENT(R"(A list where the Nth element contains the number of calls that bound N buffers. @@ -981,13 +981,13 @@ struct SamplerBindStats } DOCUMENT("How many function calls were made."); - uint32_t calls; + uint32_t calls = 0; DOCUMENT("How many objects were bound."); - uint32_t sets; + uint32_t sets = 0; DOCUMENT("How many objects were unbound."); - uint32_t nulls; + uint32_t nulls = 0; DOCUMENT(R"(A list where the Nth element contains the number of calls that bound N samplers. @@ -1025,13 +1025,13 @@ struct ResourceBindStats } DOCUMENT("How many function calls were made."); - uint32_t calls; + uint32_t calls = 0; DOCUMENT("How many objects were bound."); - uint32_t sets; + uint32_t sets = 0; DOCUMENT("How many objects were unbound."); - uint32_t nulls; + uint32_t nulls = 0; DOCUMENT(R"(A list with one element for each type in :class:`TextureType`. @@ -1071,13 +1071,13 @@ struct ResourceUpdateStats static const size_t BucketCount = 31; DOCUMENT("How many function calls were made."); - uint32_t calls; + uint32_t calls = 0; DOCUMENT("How many of :data:`calls` were mapped pointers written by the CPU."); - uint32_t clients; + uint32_t clients = 0; DOCUMENT("How many of :data:`calls` were batched updates written in the command queue."); - uint32_t servers; + uint32_t servers = 0; DOCUMENT(R"(A list with one element for each type in :class:`TextureType`. @@ -1122,11 +1122,11 @@ struct DrawcallStats static const size_t BucketCount = 16; DOCUMENT("How many draw calls were made."); - uint32_t calls; + uint32_t calls = 0; DOCUMENT("How many of :data:`calls` were instanced."); - uint32_t instanced; + uint32_t instanced = 0; DOCUMENT("How many of :data:`calls` were indirect."); - uint32_t indirect; + uint32_t indirect = 0; DOCUMENT(R"(A :class:`bucketed ` list over the number of instances in the draw. @@ -1244,16 +1244,16 @@ struct ShaderChangeStats } DOCUMENT("How many function calls were made."); - uint32_t calls; + uint32_t calls = 0; DOCUMENT("How many objects were bound."); - uint32_t sets; + uint32_t sets = 0; DOCUMENT("How many objects were unbound."); - uint32_t nulls; + uint32_t nulls = 0; DOCUMENT("How many calls made no change due to the existing bind being identical."); - uint32_t redundants; + uint32_t redundants = 0; }; DECLARE_REFLECTION_STRUCT(ShaderChangeStats); @@ -1267,16 +1267,16 @@ struct BlendStats BlendStats &operator=(const BlendStats &) = default; DOCUMENT("How many function calls were made."); - uint32_t calls; + uint32_t calls = 0; DOCUMENT("How many objects were bound."); - uint32_t sets; + uint32_t sets = 0; DOCUMENT("How many objects were unbound."); - uint32_t nulls; + uint32_t nulls = 0; DOCUMENT("How many calls made no change due to the existing bind being identical."); - uint32_t redundants; + uint32_t redundants = 0; }; DECLARE_REFLECTION_STRUCT(BlendStats); @@ -1290,16 +1290,16 @@ struct DepthStencilStats DepthStencilStats &operator=(const DepthStencilStats &) = default; DOCUMENT("How many function calls were made."); - uint32_t calls; + uint32_t calls = 0; DOCUMENT("How many objects were bound."); - uint32_t sets; + uint32_t sets = 0; DOCUMENT("How many objects were unbound."); - uint32_t nulls; + uint32_t nulls = 0; DOCUMENT("How many calls made no change due to the existing bind being identical."); - uint32_t redundants; + uint32_t redundants = 0; }; DECLARE_REFLECTION_STRUCT(DepthStencilStats); @@ -1313,16 +1313,16 @@ struct RasterizationStats RasterizationStats &operator=(const RasterizationStats &) = default; DOCUMENT("How many function calls were made."); - uint32_t calls; + uint32_t calls = 0; DOCUMENT("How many objects were bound."); - uint32_t sets; + uint32_t sets = 0; DOCUMENT("How many objects were unbound."); - uint32_t nulls; + uint32_t nulls = 0; DOCUMENT("How many calls made no change due to the existing bind being identical."); - uint32_t redundants; + uint32_t redundants = 0; DOCUMENT(R"(A list where the Nth element contains the number of calls that bound N viewports. @@ -1348,13 +1348,13 @@ struct OutputTargetStats OutputTargetStats &operator=(const OutputTargetStats &) = default; DOCUMENT("How many function calls were made."); - uint32_t calls; + uint32_t calls = 0; DOCUMENT("How many objects were bound."); - uint32_t sets; + uint32_t sets = 0; DOCUMENT("How many objects were unbound."); - uint32_t nulls; + uint32_t nulls = 0; DOCUMENT(R"(A list where the Nth element contains the number of calls that bound N targets.