diff options
Diffstat (limited to 'servers/rendering')
8 files changed, 40 insertions, 40 deletions
diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp index 93baa9a96f..a03fb968f5 100644 --- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp +++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp @@ -210,7 +210,7 @@ void RenderForwardClustered::RenderBufferDataForwardClustered::configure(RID p_c tf.array_layers = view_count; // create a layer for every view tf.usage_bits = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_CAN_COPY_FROM_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT; - RD::TextureSamples ts[RS::VIEWPORT_MSAA_MAX] = { + const RD::TextureSamples ts[RS::VIEWPORT_MSAA_MAX] = { RD::TEXTURE_SAMPLES_1, RD::TEXTURE_SAMPLES_2, RD::TEXTURE_SAMPLES_4, diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h index 37366d3e14..d5fc941492 100644 --- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h +++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h @@ -218,7 +218,7 @@ class RenderForwardClustered : public RendererSceneRenderRD { INSTANCE_DATA_FLAGS_PARTICLE_TRAIL_SHIFT = 16, INSTANCE_DATA_FLAGS_PARTICLE_TRAIL_MASK = 0xFF, INSTANCE_DATA_FLAGS_FADE_SHIFT = 24, - INSTANCE_DATA_FLAGS_FADE_MASK = 0xFF << INSTANCE_DATA_FLAGS_FADE_SHIFT + INSTANCE_DATA_FLAGS_FADE_MASK = 0xFFUL << INSTANCE_DATA_FLAGS_FADE_SHIFT }; struct SceneState { diff --git a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp index ade2b976c8..f39ba81284 100644 --- a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp +++ b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp @@ -158,7 +158,7 @@ void RenderForwardMobile::RenderBufferDataForwardMobile::configure(RID p_color_b tf.array_layers = view_count; // create a layer for every view tf.usage_bits = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_CAN_COPY_FROM_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT; - RD::TextureSamples ts[RS::VIEWPORT_MSAA_MAX] = { + const RD::TextureSamples ts[RS::VIEWPORT_MSAA_MAX] = { RD::TEXTURE_SAMPLES_1, RD::TEXTURE_SAMPLES_2, RD::TEXTURE_SAMPLES_4, diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp index fce798e3df..134b82da4a 100644 --- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp @@ -132,9 +132,9 @@ RendererCanvasRender::PolygonID RendererCanvasRenderRD::request_polygon(const Ve buffers.resize(5); { - const uint8_t *r = polygon_buffer.ptr(); - float *fptr = (float *)r; - uint32_t *uptr = (uint32_t *)r; + uint8_t *r = polygon_buffer.ptrw(); + float *fptr = reinterpret_cast<float *>(r); + uint32_t *uptr = reinterpret_cast<uint32_t *>(r); uint32_t base_offset = 0; { //vertices RD::VertexAttribute vd; @@ -1833,7 +1833,7 @@ void RendererCanvasRenderRD::occluder_polygon_set_shape(RID p_occluder, const Ve { uint8_t *vw = geometry.ptrw(); - float *vwptr = (float *)vw; + float *vwptr = reinterpret_cast<float *>(vw); uint8_t *iw = indices.ptrw(); uint16_t *iwptr = (uint16_t *)iw; diff --git a/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp index d8b7d5384e..0a16bf4bd1 100644 --- a/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp @@ -879,7 +879,7 @@ void RendererSceneGIRD::SDFGI::update_light() { push_constant.process_offset = 0; push_constant.process_increment = 1; } else { - static uint32_t frames_to_update_table[RS::ENV_SDFGI_UPDATE_LIGHT_MAX] = { + static const uint32_t frames_to_update_table[RS::ENV_SDFGI_UPDATE_LIGHT_MAX] = { 1, 2, 4, 8, 16 }; diff --git a/servers/rendering/renderer_rd/storage_rd/material_storage.cpp b/servers/rendering/renderer_rd/storage_rd/material_storage.cpp index 75c502c666..d939a0d641 100644 --- a/servers/rendering/renderer_rd/storage_rd/material_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/material_storage.cpp @@ -339,7 +339,7 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy } } break; case ShaderLanguage::TYPE_FLOAT: { - float *gui = (float *)data; + float *gui = reinterpret_cast<float *>(data); if (p_array_size > 0) { const PackedFloat32Array &a = value; @@ -361,7 +361,7 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy } } break; case ShaderLanguage::TYPE_VEC2: { - float *gui = (float *)data; + float *gui = reinterpret_cast<float *>(data); if (p_array_size > 0) { const PackedVector2Array &a = value; @@ -385,7 +385,7 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy } } break; case ShaderLanguage::TYPE_VEC3: { - float *gui = (float *)data; + float *gui = reinterpret_cast<float *>(data); if (p_array_size > 0) { const PackedVector3Array &a = value; @@ -411,7 +411,7 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy } } break; case ShaderLanguage::TYPE_VEC4: { - float *gui = (float *)data; + float *gui = reinterpret_cast<float *>(data); if (p_array_size > 0) { if (value.get_type() == Variant::PACKED_COLOR_ARRAY) { @@ -491,7 +491,7 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy } } break; case ShaderLanguage::TYPE_MAT2: { - float *gui = (float *)data; + float *gui = reinterpret_cast<float *>(data); if (p_array_size > 0) { const PackedFloat32Array &a = value; @@ -532,7 +532,7 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy } } break; case ShaderLanguage::TYPE_MAT3: { - float *gui = (float *)data; + float *gui = reinterpret_cast<float *>(data); if (p_array_size > 0) { const PackedFloat32Array &a = value; @@ -587,7 +587,7 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy } } break; case ShaderLanguage::TYPE_MAT4: { - float *gui = (float *)data; + float *gui = reinterpret_cast<float *>(data); if (p_array_size > 0) { const PackedFloat32Array &a = value; @@ -748,12 +748,12 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type, } } break; case ShaderLanguage::TYPE_FLOAT: { - float *gui = (float *)data; + float *gui = reinterpret_cast<float *>(data); gui[0] = value[0].real; } break; case ShaderLanguage::TYPE_VEC2: { - float *gui = (float *)data; + float *gui = reinterpret_cast<float *>(data); for (int i = 0; i < 2; i++) { gui[i] = value[i].real; @@ -761,7 +761,7 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type, } break; case ShaderLanguage::TYPE_VEC3: { - float *gui = (float *)data; + float *gui = reinterpret_cast<float *>(data); for (int i = 0; i < 3; i++) { gui[i] = value[i].real; @@ -769,14 +769,14 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type, } break; case ShaderLanguage::TYPE_VEC4: { - float *gui = (float *)data; + float *gui = reinterpret_cast<float *>(data); for (int i = 0; i < 4; i++) { gui[i] = value[i].real; } } break; case ShaderLanguage::TYPE_MAT2: { - float *gui = (float *)data; + float *gui = reinterpret_cast<float *>(data); //in std140 members of mat2 are treated as vec4s gui[0] = value[0].real; @@ -789,7 +789,7 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type, gui[7] = 0; } break; case ShaderLanguage::TYPE_MAT3: { - float *gui = (float *)data; + float *gui = reinterpret_cast<float *>(data); gui[0] = value[0].real; gui[1] = value[1].real; @@ -805,7 +805,7 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type, gui[11] = 0; } break; case ShaderLanguage::TYPE_MAT4: { - float *gui = (float *)data; + float *gui = reinterpret_cast<float *>(data); for (int i = 0; i < 16; i++) { gui[i] = value[i].real; @@ -1885,7 +1885,7 @@ void MaterialStorage::global_variable_remove(const StringName &p_name) { if (!global_variables.variables.has(p_name)) { return; } - GlobalVariables::Variable &gv = global_variables.variables[p_name]; + const GlobalVariables::Variable &gv = global_variables.variables[p_name]; if (gv.buffer_index >= 0) { global_variables.buffer_usage[gv.buffer_index].elements = 0; @@ -2110,7 +2110,7 @@ void MaterialStorage::global_variables_instance_update(RID p_instance, int p_ind ERR_FAIL_INDEX(p_index, ShaderLanguage::MAX_INSTANCE_UNIFORM_INDICES); ERR_FAIL_COND_MSG(p_value.get_type() > Variant::COLOR, "Unsupported variant type for instance parameter: " + Variant::get_type_name(p_value.get_type())); //anything greater not supported - ShaderLanguage::DataType datatype_from_value[Variant::COLOR + 1] = { + const ShaderLanguage::DataType datatype_from_value[Variant::COLOR + 1] = { ShaderLanguage::TYPE_MAX, //nil ShaderLanguage::TYPE_BOOL, //bool ShaderLanguage::TYPE_INT, //int diff --git a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp index 8c60264ce3..0f74c591c6 100644 --- a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp @@ -50,7 +50,7 @@ MeshStorage::MeshStorage() { buffer.resize(sizeof(float) * 3); { uint8_t *w = buffer.ptrw(); - float *fptr = (float *)w; + float *fptr = reinterpret_cast<float *>(w); fptr[0] = 0.0; fptr[1] = 0.0; fptr[2] = 0.0; @@ -62,7 +62,7 @@ MeshStorage::MeshStorage() { buffer.resize(sizeof(float) * 3); { uint8_t *w = buffer.ptrw(); - float *fptr = (float *)w; + float *fptr = reinterpret_cast<float *>(w); fptr[0] = 1.0; fptr[1] = 0.0; fptr[2] = 0.0; @@ -74,7 +74,7 @@ MeshStorage::MeshStorage() { buffer.resize(sizeof(float) * 4); { uint8_t *w = buffer.ptrw(); - float *fptr = (float *)w; + float *fptr = reinterpret_cast<float *>(w); fptr[0] = 1.0; fptr[1] = 0.0; fptr[2] = 0.0; @@ -87,7 +87,7 @@ MeshStorage::MeshStorage() { buffer.resize(sizeof(float) * 4); { uint8_t *w = buffer.ptrw(); - float *fptr = (float *)w; + float *fptr = reinterpret_cast<float *>(w); fptr[0] = 1.0; fptr[1] = 1.0; fptr[2] = 1.0; @@ -100,7 +100,7 @@ MeshStorage::MeshStorage() { buffer.resize(sizeof(float) * 2); { uint8_t *w = buffer.ptrw(); - float *fptr = (float *)w; + float *fptr = reinterpret_cast<float *>(w); fptr[0] = 0.0; fptr[1] = 0.0; } @@ -110,7 +110,7 @@ MeshStorage::MeshStorage() { buffer.resize(sizeof(float) * 2); { uint8_t *w = buffer.ptrw(); - float *fptr = (float *)w; + float *fptr = reinterpret_cast<float *>(w); fptr[0] = 0.0; fptr[1] = 0.0; } @@ -121,7 +121,7 @@ MeshStorage::MeshStorage() { buffer.resize(sizeof(float) * 4); { uint8_t *w = buffer.ptrw(); - float *fptr = (float *)w; + float *fptr = reinterpret_cast<float *>(w); fptr[0] = 0.0; fptr[1] = 0.0; fptr[2] = 0.0; @@ -134,7 +134,7 @@ MeshStorage::MeshStorage() { buffer.resize(sizeof(uint32_t) * 4); { uint8_t *w = buffer.ptrw(); - uint32_t *fptr = (uint32_t *)w; + uint32_t *fptr = reinterpret_cast<uint32_t *>(w); fptr[0] = 0; fptr[1] = 0; fptr[2] = 0; @@ -147,7 +147,7 @@ MeshStorage::MeshStorage() { buffer.resize(sizeof(float) * 4); { uint8_t *w = buffer.ptrw(); - float *fptr = (float *)w; + float *fptr = reinterpret_cast<float *>(w); fptr[0] = 0.0; fptr[1] = 0.0; fptr[2] = 0.0; @@ -284,9 +284,9 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) case RS::ARRAY_CUSTOM2: case RS::ARRAY_CUSTOM3: { int idx = i - RS::ARRAY_CUSTOM0; - uint32_t fmt_shift[RS::ARRAY_CUSTOM_COUNT] = { RS::ARRAY_FORMAT_CUSTOM0_SHIFT, RS::ARRAY_FORMAT_CUSTOM1_SHIFT, RS::ARRAY_FORMAT_CUSTOM2_SHIFT, RS::ARRAY_FORMAT_CUSTOM3_SHIFT }; + const uint32_t fmt_shift[RS::ARRAY_CUSTOM_COUNT] = { RS::ARRAY_FORMAT_CUSTOM0_SHIFT, RS::ARRAY_FORMAT_CUSTOM1_SHIFT, RS::ARRAY_FORMAT_CUSTOM2_SHIFT, RS::ARRAY_FORMAT_CUSTOM3_SHIFT }; uint32_t fmt = (p_surface.format >> fmt_shift[idx]) & RS::ARRAY_FORMAT_CUSTOM_MASK; - uint32_t fmtsize[RS::ARRAY_CUSTOM_MAX] = { 4, 4, 4, 8, 4, 8, 12, 16 }; + const uint32_t fmtsize[RS::ARRAY_CUSTOM_MAX] = { 4, 4, 4, 8, 4, 8, 12, 16 }; attrib_stride += fmtsize[fmt]; } break; @@ -1098,10 +1098,10 @@ void MeshStorage::_mesh_surface_generate_version_for_input_mask(Mesh::Surface::V vd.offset = attribute_stride; int idx = i - RS::ARRAY_CUSTOM0; - uint32_t fmt_shift[RS::ARRAY_CUSTOM_COUNT] = { RS::ARRAY_FORMAT_CUSTOM0_SHIFT, RS::ARRAY_FORMAT_CUSTOM1_SHIFT, RS::ARRAY_FORMAT_CUSTOM2_SHIFT, RS::ARRAY_FORMAT_CUSTOM3_SHIFT }; + const uint32_t fmt_shift[RS::ARRAY_CUSTOM_COUNT] = { RS::ARRAY_FORMAT_CUSTOM0_SHIFT, RS::ARRAY_FORMAT_CUSTOM1_SHIFT, RS::ARRAY_FORMAT_CUSTOM2_SHIFT, RS::ARRAY_FORMAT_CUSTOM3_SHIFT }; uint32_t fmt = (s->format >> fmt_shift[idx]) & RS::ARRAY_FORMAT_CUSTOM_MASK; - uint32_t fmtsize[RS::ARRAY_CUSTOM_MAX] = { 4, 4, 4, 8, 4, 8, 12, 16 }; - RD::DataFormat fmtrd[RS::ARRAY_CUSTOM_MAX] = { RD::DATA_FORMAT_R8G8B8A8_UNORM, RD::DATA_FORMAT_R8G8B8A8_SNORM, RD::DATA_FORMAT_R16G16_SFLOAT, RD::DATA_FORMAT_R16G16B16A16_SFLOAT, RD::DATA_FORMAT_R32_SFLOAT, RD::DATA_FORMAT_R32G32_SFLOAT, RD::DATA_FORMAT_R32G32B32_SFLOAT, RD::DATA_FORMAT_R32G32B32A32_SFLOAT }; + const uint32_t fmtsize[RS::ARRAY_CUSTOM_MAX] = { 4, 4, 4, 8, 4, 8, 12, 16 }; + const RD::DataFormat fmtrd[RS::ARRAY_CUSTOM_MAX] = { RD::DATA_FORMAT_R8G8B8A8_UNORM, RD::DATA_FORMAT_R8G8B8A8_SNORM, RD::DATA_FORMAT_R16G16_SFLOAT, RD::DATA_FORMAT_R16G16B16A16_SFLOAT, RD::DATA_FORMAT_R32_SFLOAT, RD::DATA_FORMAT_R32G32_SFLOAT, RD::DATA_FORMAT_R32G32B32_SFLOAT, RD::DATA_FORMAT_R32G32B32A32_SFLOAT }; vd.format = fmtrd[fmt]; attribute_stride += fmtsize[fmt]; buffer = s->attribute_buffer; @@ -1238,7 +1238,7 @@ void MeshStorage::multimesh_set_mesh(RID p_multimesh, RID p_mesh) { if (multimesh->buffer_set) { Vector<uint8_t> buffer = RD::get_singleton()->buffer_get_data(multimesh->buffer); const uint8_t *r = buffer.ptr(); - const float *data = (const float *)r; + const float *data = reinterpret_cast<const float *>(r); _multimesh_re_create_aabb(multimesh, data, multimesh->instances); } } diff --git a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp index 75dd20bdbd..402536de88 100644 --- a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp @@ -1722,7 +1722,7 @@ RID ParticlesStorage::particles_collision_get_heightfield_framebuffer(RID p_part if (particles_collision->heightfield_texture == RID()) { //create - int resolutions[RS::PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_MAX] = { 256, 512, 1024, 2048, 4096, 8192 }; + const int resolutions[RS::PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_MAX] = { 256, 512, 1024, 2048, 4096, 8192 }; Size2i size; if (particles_collision->extents.x > particles_collision->extents.z) { size.x = resolutions[particles_collision->heightfield_resolution]; |