diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-05-02 16:28:25 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-05-02 16:28:25 +0200 |
commit | c273ddc3eefce78f8eed86dbc71fffd1b0443e2a (patch) | |
tree | c3f86b1b345720b6e0a56db4fbb75a20a0bf82ee /servers/rendering/renderer_rd | |
parent | dd06cb90c541b39de764ac7bbafd61fb2b9abb48 (diff) |
Style: Partially apply clang-tidy's `cppcoreguidelines-pro-type-member-init`
Didn't commit all the changes where it wants to initialize a struct
with `{}`. Should be reviewed in a separate PR.
Option `IgnoreArrays` enabled for now to be conservative, can be
disabled to see if it proposes more useful changes.
Also fixed manually a handful of other missing initializations / moved
some from constructors.
Diffstat (limited to 'servers/rendering/renderer_rd')
15 files changed, 97 insertions, 127 deletions
diff --git a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp index 3c115c942b..e60651f092 100644 --- a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp +++ b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp @@ -452,8 +452,6 @@ RS::ShaderNativeSourceCode SceneShaderForwardClustered::ShaderData::get_native_s SceneShaderForwardClustered::ShaderData::ShaderData() : shader_list_element(this) { - valid = false; - uses_screen_texture = false; } SceneShaderForwardClustered::ShaderData::~ShaderData() { diff --git a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h index 6185fa7413..0b2df983ff 100644 --- a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h +++ b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h @@ -130,9 +130,9 @@ public: ALPHA_ANTIALIASING_ALPHA_TO_COVERAGE_AND_TO_ONE }; - bool valid; + bool valid = false; RID version; - uint32_t vertex_input_mask; + uint32_t vertex_input_mask = 0; PipelineCacheRD pipelines[CULL_VARIANT_MAX][RS::PRIMITIVE_MAX][PIPELINE_VERSION_MAX]; PipelineCacheRD color_pipelines[CULL_VARIANT_MAX][RS::PRIMITIVE_MAX][PIPELINE_COLOR_PASS_FLAG_COUNT]; @@ -142,7 +142,7 @@ public: Vector<ShaderCompiler::GeneratedCode::Texture> texture_uniforms; Vector<uint32_t> ubo_offsets; - uint32_t ubo_size; + uint32_t ubo_size = 0; String code; Map<StringName, Map<int, RID>> default_texture_params; @@ -150,28 +150,28 @@ public: DepthDraw depth_draw; DepthTest depth_test; - bool uses_point_size; - bool uses_alpha; - bool uses_blend_alpha; - bool uses_alpha_clip; - bool uses_depth_pre_pass; - bool uses_discard; - bool uses_roughness; - bool uses_normal; - bool uses_particle_trails; - - bool unshaded; - bool uses_vertex; - bool uses_position; - bool uses_sss; - bool uses_transmittance; - bool uses_screen_texture; - bool uses_depth_texture; - bool uses_normal_texture; - bool uses_time; - bool writes_modelview_or_projection; - bool uses_world_coordinates; - Cull cull_mode; + bool uses_point_size = false; + bool uses_alpha = false; + bool uses_blend_alpha = false; + bool uses_alpha_clip = false; + bool uses_depth_pre_pass = false; + bool uses_discard = false; + bool uses_roughness = false; + bool uses_normal = false; + bool uses_particle_trails = false; + + bool unshaded = false; + bool uses_vertex = false; + bool uses_position = false; + bool uses_sss = false; + bool uses_transmittance = false; + bool uses_screen_texture = false; + bool uses_depth_texture = false; + bool uses_normal_texture = false; + bool uses_time = false; + bool writes_modelview_or_projection = false; + bool uses_world_coordinates = false; + Cull cull_mode = CULL_DISABLED; uint64_t last_pass = 0; uint32_t index = 0; diff --git a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp index 60badbdfee..cdddc35579 100644 --- a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp +++ b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp @@ -415,8 +415,6 @@ RS::ShaderNativeSourceCode SceneShaderForwardMobile::ShaderData::get_native_sour SceneShaderForwardMobile::ShaderData::ShaderData() : shader_list_element(this) { - valid = false; - uses_screen_texture = false; } SceneShaderForwardMobile::ShaderData::~ShaderData() { diff --git a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h index b89fe908d3..50b5fb26ec 100644 --- a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h +++ b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h @@ -97,9 +97,9 @@ public: ALPHA_ANTIALIASING_ALPHA_TO_COVERAGE_AND_TO_ONE }; - bool valid; + bool valid = false; RID version; - uint32_t vertex_input_mask; + uint32_t vertex_input_mask = 0; PipelineCacheRD pipelines[CULL_VARIANT_MAX][RS::PRIMITIVE_MAX][SHADER_VERSION_MAX]; String path; @@ -108,7 +108,7 @@ public: Vector<ShaderCompiler::GeneratedCode::Texture> texture_uniforms; Vector<uint32_t> ubo_offsets; - uint32_t ubo_size; + uint32_t ubo_size = 0; String code; Map<StringName, Map<int, RID>> default_texture_params; @@ -116,26 +116,26 @@ public: DepthDraw depth_draw; DepthTest depth_test; - bool uses_point_size; - bool uses_alpha; - bool uses_blend_alpha; - bool uses_alpha_clip; - bool uses_depth_pre_pass; - bool uses_discard; - bool uses_roughness; - bool uses_normal; - bool uses_particle_trails; - - bool unshaded; - bool uses_vertex; - bool uses_sss; - bool uses_transmittance; - bool uses_screen_texture; - bool uses_depth_texture; - bool uses_normal_texture; - bool uses_time; - bool writes_modelview_or_projection; - bool uses_world_coordinates; + bool uses_point_size = false; + bool uses_alpha = false; + bool uses_blend_alpha = false; + bool uses_alpha_clip = false; + bool uses_depth_pre_pass = false; + bool uses_discard = false; + bool uses_roughness = false; + bool uses_normal = false; + bool uses_particle_trails = false; + + bool unshaded = false; + bool uses_vertex = false; + bool uses_sss = false; + bool uses_transmittance = false; + bool uses_screen_texture = false; + bool uses_depth_texture = false; + bool uses_normal_texture = false; + bool uses_time = false; + bool writes_modelview_or_projection = false; + bool uses_world_coordinates = false; uint64_t last_pass = 0; uint32_t index = 0; diff --git a/servers/rendering/renderer_rd/pipeline_cache_rd.h b/servers/rendering/renderer_rd/pipeline_cache_rd.h index 1e80381d88..ad83fc76b7 100644 --- a/servers/rendering/renderer_rd/pipeline_cache_rd.h +++ b/servers/rendering/renderer_rd/pipeline_cache_rd.h @@ -45,7 +45,7 @@ class PipelineCacheRD { RD::PipelineMultisampleState multisample_state; RD::PipelineDepthStencilState depth_stencil_state; RD::PipelineColorBlendState blend_state; - int dynamic_state_flags; + int dynamic_state_flags = 0; Vector<RD::PipelineSpecializationConstant> base_specialization_constants; struct Version { diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp index 8c727b2512..506fc3b2ab 100644 --- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp @@ -2232,12 +2232,6 @@ RS::ShaderNativeSourceCode RendererCanvasRenderRD::CanvasShaderData::get_native_ return canvas_singleton->shader.canvas_shader.version_get_native_source_code(version); } -RendererCanvasRenderRD::CanvasShaderData::CanvasShaderData() { - valid = false; - uses_screen_texture = false; - uses_sdf = false; -} - RendererCanvasRenderRD::CanvasShaderData::~CanvasShaderData() { RendererCanvasRenderRD *canvas_singleton = static_cast<RendererCanvasRenderRD *>(RendererCanvasRender::singleton); ERR_FAIL_COND(!canvas_singleton); diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.h b/servers/rendering/renderer_rd/renderer_canvas_render_rd.h index 6448e1a664..06970acca6 100644 --- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.h +++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.h @@ -161,7 +161,7 @@ class RendererCanvasRenderRD : public RendererCanvasRender { BLEND_MODE_DISABLED, }; - bool valid; + bool valid = false; RID version; PipelineVariants pipeline_variants; String path; @@ -170,7 +170,7 @@ class RendererCanvasRenderRD : public RendererCanvasRender { Vector<ShaderCompiler::GeneratedCode::Texture> texture_uniforms; Vector<uint32_t> ubo_offsets; - uint32_t ubo_size; + uint32_t ubo_size = 0; String code; Map<StringName, Map<int, RID>> default_texture_params; @@ -190,7 +190,7 @@ class RendererCanvasRenderRD : public RendererCanvasRender { virtual Variant get_default_parameter(const StringName &p_parameter) const; virtual RS::ShaderNativeSourceCode get_native_source_code() const; - CanvasShaderData(); + CanvasShaderData() {} virtual ~CanvasShaderData(); }; diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp index fd56de845f..759b8690eb 100644 --- a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp @@ -286,7 +286,6 @@ RendererCompositorRD::RendererCompositorRD() { } singleton = this; - time = 0; texture_storage = memnew(RendererRD::TextureStorage); material_storage = memnew(RendererRD::MaterialStorage); diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.h b/servers/rendering/renderer_rd/renderer_compositor_rd.h index 768e9e0947..26bd28286b 100644 --- a/servers/rendering/renderer_rd/renderer_compositor_rd.h +++ b/servers/rendering/renderer_rd/renderer_compositor_rd.h @@ -50,11 +50,11 @@ class RendererCompositorRD : public RendererCompositor { protected: UniformSetCacheRD *uniform_set_cache = nullptr; RendererCanvasRenderRD *canvas = nullptr; - RendererRD::LightStorage *light_storage; - RendererRD::MaterialStorage *material_storage; - RendererRD::MeshStorage *mesh_storage; - RendererRD::ParticlesStorage *particles_storage; - RendererRD::TextureStorage *texture_storage; + RendererRD::LightStorage *light_storage = nullptr; + RendererRD::MaterialStorage *material_storage = nullptr; + RendererRD::MeshStorage *mesh_storage = nullptr; + RendererRD::ParticlesStorage *particles_storage = nullptr; + RendererRD::TextureStorage *texture_storage = nullptr; RendererStorageRD *storage = nullptr; RendererSceneRenderRD *scene = nullptr; @@ -92,8 +92,8 @@ protected: Map<RID, RID> render_target_descriptors; - double time; - double delta; + double time = 0.0; + double delta = 0.0; static uint64_t frame; diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp index 26365aafc4..3bfcf18f12 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp @@ -3976,10 +3976,6 @@ RS::ShaderNativeSourceCode RendererSceneRenderRD::FogShaderData::get_native_sour return scene_singleton->volumetric_fog.shader.version_get_native_source_code(version); } -RendererSceneRenderRD::FogShaderData::FogShaderData() { - valid = false; -} - RendererSceneRenderRD::FogShaderData::~FogShaderData() { RendererSceneRenderRD *scene_singleton = static_cast<RendererSceneRenderRD *>(RendererSceneRenderRD::singleton); ERR_FAIL_COND(!scene_singleton); diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.h b/servers/rendering/renderer_rd/renderer_scene_render_rd.h index 2b79d8997f..6bf3a95dd0 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.h +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.h @@ -47,10 +47,10 @@ #include "servers/rendering/rendering_device.h" struct RenderDataRD { - RID render_buffers = RID(); + RID render_buffers; - Transform3D cam_transform = Transform3D(); - CameraMatrix cam_projection = CameraMatrix(); + Transform3D cam_transform; + CameraMatrix cam_projection; bool cam_orthogonal = false; // For stereo rendering @@ -67,18 +67,18 @@ struct RenderDataRD { const PagedArray<RID> *decals = nullptr; const PagedArray<RID> *lightmaps = nullptr; const PagedArray<RID> *fog_volumes = nullptr; - RID environment = RID(); - RID camera_effects = RID(); - RID shadow_atlas = RID(); - RID reflection_atlas = RID(); - RID reflection_probe = RID(); + RID environment; + RID camera_effects; + RID shadow_atlas; + RID reflection_atlas; + RID reflection_probe; int reflection_probe_pass = 0; float lod_distance_multiplier = 0.0; - Plane lod_camera_plane = Plane(); + Plane lod_camera_plane; float screen_mesh_lod_threshold = 0.0; - RID cluster_buffer = RID(); + RID cluster_buffer; uint32_t cluster_size = 0; uint32_t cluster_max_elements = 0; @@ -95,8 +95,8 @@ class RendererSceneRenderRD : public RendererSceneRender { protected: RendererStorageRD *storage = nullptr; RendererRD::ToneMapper *tone_mapper = nullptr; - double time; - double time_step = 0; + double time = 0.0; + double time_step = 0.0; struct RenderBufferData { virtual void configure(RID p_color_buffer, RID p_depth_buffer, RID p_target_buffer, int p_width, int p_height, RS::ViewportMSAA p_msaa, uint32_t p_view_count) = 0; @@ -236,7 +236,7 @@ private: struct DecalInstance { RID decal; Transform3D transform; - uint32_t cull_mask; + uint32_t cull_mask = 0; ForwardID forward_id = -1; }; @@ -256,7 +256,7 @@ private: struct ShadowShrinkStage { RID texture; RID filter_texture; - uint32_t size; + uint32_t size = 0; }; struct ShadowAtlas { @@ -268,27 +268,20 @@ private: }; struct Quadrant { - uint32_t subdivision; + uint32_t subdivision = 0; struct Shadow { RID owner; - uint64_t version; - uint64_t fog_version; // used for fog - uint64_t alloc_tick; - - Shadow() { - version = 0; - fog_version = 0; - alloc_tick = 0; - } + uint64_t version = 0; + uint64_t fog_version = 0; // used for fog + uint64_t alloc_tick = 0; + + Shadow() {} }; Vector<Shadow> shadows; - Quadrant() { - subdivision = 0; //not in use - } - + Quadrant() {} } quadrants[4]; int size_order[4] = { 0, 1, 2, 3 }; @@ -337,7 +330,6 @@ private: int size = 0; bool use_16_bits = true; int current_light = 0; - } directional_shadow; void _update_directional_shadow_atlas(); @@ -910,7 +902,7 @@ private: void _update_volumetric_fog(RID p_render_buffers, RID p_environment, const CameraMatrix &p_cam_projection, const Transform3D &p_cam_transform, RID p_shadow_atlas, int p_directional_light_count, bool p_use_directional_shadows, int p_positional_light_count, int p_voxel_gi_count, const PagedArray<RID> &p_fog_volumes); struct FogShaderData : public RendererRD::ShaderData { - bool valid; + bool valid = false; RID version; RID pipeline; @@ -918,13 +910,13 @@ private: Vector<ShaderCompiler::GeneratedCode::Texture> texture_uniforms; Vector<uint32_t> ubo_offsets; - uint32_t ubo_size; + uint32_t ubo_size = 0; String path; String code; Map<StringName, Map<int, RID>> default_texture_params; - bool uses_time; + bool uses_time = false; virtual void set_code(const String &p_Code); virtual void set_default_texture_param(const StringName &p_name, RID p_texture, int p_index); @@ -935,7 +927,8 @@ private: virtual bool casts_shadows() const; virtual Variant get_default_parameter(const StringName &p_parameter) const; virtual RS::ShaderNativeSourceCode get_native_source_code() const; - FogShaderData(); + + FogShaderData() {} virtual ~FogShaderData(); }; diff --git a/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp index db7a5250b6..a3d53e00af 100644 --- a/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp @@ -224,10 +224,6 @@ RS::ShaderNativeSourceCode RendererSceneSkyRD::SkyShaderData::get_native_source_ return scene_singleton->sky.sky_shader.shader.version_get_native_source_code(version); } -RendererSceneSkyRD::SkyShaderData::SkyShaderData() { - valid = false; -} - RendererSceneSkyRD::SkyShaderData::~SkyShaderData() { RendererSceneRenderRD *scene_singleton = static_cast<RendererSceneRenderRD *>(RendererSceneRenderRD::singleton); ERR_FAIL_COND(!scene_singleton); diff --git a/servers/rendering/renderer_rd/renderer_scene_sky_rd.h b/servers/rendering/renderer_rd/renderer_scene_sky_rd.h index 010e2178a9..497d27ec26 100644 --- a/servers/rendering/renderer_rd/renderer_scene_sky_rd.h +++ b/servers/rendering/renderer_rd/renderer_scene_sky_rd.h @@ -106,7 +106,7 @@ private: }; struct SkyShaderData : public RendererRD::ShaderData { - bool valid; + bool valid = false; RID version; PipelineCacheRD pipelines[SKY_VERSION_MAX]; @@ -114,17 +114,17 @@ private: Vector<ShaderCompiler::GeneratedCode::Texture> texture_uniforms; Vector<uint32_t> ubo_offsets; - uint32_t ubo_size; + uint32_t ubo_size = 0; String path; String code; Map<StringName, Map<int, RID>> default_texture_params; - bool uses_time; - bool uses_position; - bool uses_half_res; - bool uses_quarter_res; - bool uses_light; + bool uses_time = false; + bool uses_position = false; + bool uses_half_res = false; + bool uses_quarter_res = false; + bool uses_light = false; virtual void set_code(const String &p_Code); virtual void set_default_texture_param(const StringName &p_name, RID p_texture, int p_index); @@ -135,7 +135,8 @@ private: virtual bool casts_shadows() const; virtual Variant get_default_parameter(const StringName &p_parameter) const; virtual RS::ShaderNativeSourceCode get_native_source_code() const; - SkyShaderData(); + + SkyShaderData() {} virtual ~SkyShaderData(); }; diff --git a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp index 402536de88..13b171979a 100644 --- a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp @@ -1664,10 +1664,6 @@ RS::ShaderNativeSourceCode ParticlesStorage::ParticlesShaderData::get_native_sou return ParticlesStorage::get_singleton()->particles_shader.shader.version_get_native_source_code(version); } -ParticlesStorage::ParticlesShaderData::ParticlesShaderData() { - valid = false; -} - ParticlesStorage::ParticlesShaderData::~ParticlesShaderData() { //pipeline variants will clear themselves if shader is gone if (version.is_valid()) { diff --git a/servers/rendering/renderer_rd/storage_rd/particles_storage.h b/servers/rendering/renderer_rd/storage_rd/particles_storage.h index 7764af08f2..c6480794c1 100644 --- a/servers/rendering/renderer_rd/storage_rd/particles_storage.h +++ b/servers/rendering/renderer_rd/storage_rd/particles_storage.h @@ -341,16 +341,15 @@ private: /* Particle Shader */ struct ParticlesShaderData : public ShaderData { - bool valid; + bool valid = false; RID version; bool uses_collision = false; - //PipelineCacheRD pipelines[SKY_VERSION_MAX]; Map<StringName, ShaderLanguage::ShaderNode::Uniform> uniforms; Vector<ShaderCompiler::GeneratedCode::Texture> texture_uniforms; Vector<uint32_t> ubo_offsets; - uint32_t ubo_size; + uint32_t ubo_size = 0; String path; String code; @@ -373,7 +372,7 @@ private: virtual Variant get_default_parameter(const StringName &p_parameter) const; virtual RS::ShaderNativeSourceCode get_native_source_code() const; - ParticlesShaderData(); + ParticlesShaderData() {} virtual ~ParticlesShaderData(); }; |