diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2021-04-27 16:19:21 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2021-04-27 16:26:27 +0200 |
commit | 8247667a3ee0d86f26094e722497b0cbb99cc12b (patch) | |
tree | d03fb75cca2ad4dd63d3c55e1d6ecde074441182 /servers/rendering | |
parent | 288f484d0a034d02fbca3db0a2f14f5a0084a36b (diff) |
Core: Drop custom `copymem`/`zeromem` defines
We've been using standard C library functions `memcpy`/`memset` for these since
2016 with 67f65f66391327b2967a20a89c3627e1dd6e84eb.
There was still the possibility for third-party platform ports to override the
definitions with a custom header, but this doesn't seem useful anymore.
Diffstat (limited to 'servers/rendering')
6 files changed, 42 insertions, 42 deletions
diff --git a/servers/rendering/renderer_rd/cluster_builder_rd.cpp b/servers/rendering/renderer_rd/cluster_builder_rd.cpp index 0fdd864d47..2669a73014 100644 --- a/servers/rendering/renderer_rd/cluster_builder_rd.cpp +++ b/servers/rendering/renderer_rd/cluster_builder_rd.cpp @@ -86,13 +86,13 @@ ClusterBuilderSharedDataRD::ClusterBuilderSharedDataRD() { Vector<uint8_t> vertex_data; vertex_data.resize(sizeof(float) * icosphere_vertex_count * 3); - copymem(vertex_data.ptrw(), icosphere_vertices, vertex_data.size()); + memcpy(vertex_data.ptrw(), icosphere_vertices, vertex_data.size()); sphere_vertex_buffer = RD::get_singleton()->vertex_buffer_create(vertex_data.size(), vertex_data); Vector<uint8_t> index_data; index_data.resize(sizeof(uint32_t) * icosphere_triangle_count * 3); - copymem(index_data.ptrw(), icosphere_triangle_indices, index_data.size()); + memcpy(index_data.ptrw(), icosphere_triangle_indices, index_data.size()); sphere_index_buffer = RD::get_singleton()->index_buffer_create(icosphere_triangle_count * 3, RD::INDEX_BUFFER_FORMAT_UINT32, index_data); @@ -130,13 +130,13 @@ ClusterBuilderSharedDataRD::ClusterBuilderSharedDataRD() { Vector<uint8_t> vertex_data; vertex_data.resize(sizeof(float) * cone_vertex_count * 3); - copymem(vertex_data.ptrw(), cone_vertices, vertex_data.size()); + memcpy(vertex_data.ptrw(), cone_vertices, vertex_data.size()); cone_vertex_buffer = RD::get_singleton()->vertex_buffer_create(vertex_data.size(), vertex_data); Vector<uint8_t> index_data; index_data.resize(sizeof(uint32_t) * cone_triangle_count * 3); - copymem(index_data.ptrw(), cone_triangle_indices, index_data.size()); + memcpy(index_data.ptrw(), cone_triangle_indices, index_data.size()); cone_index_buffer = RD::get_singleton()->index_buffer_create(cone_triangle_count * 3, RD::INDEX_BUFFER_FORMAT_UINT32, index_data); @@ -184,13 +184,13 @@ ClusterBuilderSharedDataRD::ClusterBuilderSharedDataRD() { Vector<uint8_t> vertex_data; vertex_data.resize(sizeof(float) * box_vertex_count * 3); - copymem(vertex_data.ptrw(), box_vertices, vertex_data.size()); + memcpy(vertex_data.ptrw(), box_vertices, vertex_data.size()); box_vertex_buffer = RD::get_singleton()->vertex_buffer_create(vertex_data.size(), vertex_data); Vector<uint8_t> index_data; index_data.resize(sizeof(uint32_t) * box_triangle_count * 3); - copymem(index_data.ptrw(), box_triangle_indices, index_data.size()); + memcpy(index_data.ptrw(), box_triangle_indices, index_data.size()); box_index_buffer = RD::get_singleton()->index_buffer_create(box_triangle_count * 3, RD::INDEX_BUFFER_FORMAT_UINT32, index_data); diff --git a/servers/rendering/renderer_rd/effects_rd.cpp b/servers/rendering/renderer_rd/effects_rd.cpp index bc304aedd8..563e08fdcb 100644 --- a/servers/rendering/renderer_rd/effects_rd.cpp +++ b/servers/rendering/renderer_rd/effects_rd.cpp @@ -226,7 +226,7 @@ RID EffectsRD::_get_compute_uniform_set_from_image_pair(RID p_texture1, RID p_te } void EffectsRD::copy_to_atlas_fb(RID p_source_rd_texture, RID p_dest_framebuffer, const Rect2 &p_uv_rect, RD::DrawListID p_draw_list, bool p_flip_y, bool p_panorama) { - zeromem(©_to_fb.push_constant, sizeof(CopyToFbPushConstant)); + memset(©_to_fb.push_constant, 0, sizeof(CopyToFbPushConstant)); copy_to_fb.push_constant.use_section = true; copy_to_fb.push_constant.section[0] = p_uv_rect.position.x; @@ -247,7 +247,7 @@ void EffectsRD::copy_to_atlas_fb(RID p_source_rd_texture, RID p_dest_framebuffer } void EffectsRD::copy_to_fb_rect(RID p_source_rd_texture, RID p_dest_framebuffer, const Rect2i &p_rect, bool p_flip_y, bool p_force_luminance, bool p_alpha_to_zero, bool p_srgb, RID p_secondary) { - zeromem(©_to_fb.push_constant, sizeof(CopyToFbPushConstant)); + memset(©_to_fb.push_constant, 0, sizeof(CopyToFbPushConstant)); if (p_flip_y) { copy_to_fb.push_constant.flip_y = true; @@ -275,7 +275,7 @@ void EffectsRD::copy_to_fb_rect(RID p_source_rd_texture, RID p_dest_framebuffer, } void EffectsRD::copy_to_rect(RID p_source_rd_texture, RID p_dest_texture, const Rect2i &p_rect, bool p_flip_y, bool p_force_luminance, bool p_all_source, bool p_8_bit_dst, bool p_alpha_to_one) { - zeromem(©.push_constant, sizeof(CopyPushConstant)); + memset(©.push_constant, 0, sizeof(CopyPushConstant)); if (p_flip_y) { copy.push_constant.flags |= COPY_FLAG_FLIP_Y; } @@ -309,7 +309,7 @@ void EffectsRD::copy_to_rect(RID p_source_rd_texture, RID p_dest_texture, const } void EffectsRD::copy_cubemap_to_panorama(RID p_source_cube, RID p_dest_panorama, const Size2i &p_panorama_size, float p_lod, bool p_is_array) { - zeromem(©.push_constant, sizeof(CopyPushConstant)); + memset(©.push_constant, 0, sizeof(CopyPushConstant)); copy.push_constant.section[0] = 0; copy.push_constant.section[1] = 0; @@ -329,7 +329,7 @@ void EffectsRD::copy_cubemap_to_panorama(RID p_source_cube, RID p_dest_panorama, } void EffectsRD::copy_depth_to_rect_and_linearize(RID p_source_rd_texture, RID p_dest_texture, const Rect2i &p_rect, bool p_flip_y, float p_z_near, float p_z_far) { - zeromem(©.push_constant, sizeof(CopyPushConstant)); + memset(©.push_constant, 0, sizeof(CopyPushConstant)); if (p_flip_y) { copy.push_constant.flags |= COPY_FLAG_FLIP_Y; } @@ -353,7 +353,7 @@ void EffectsRD::copy_depth_to_rect_and_linearize(RID p_source_rd_texture, RID p_ } void EffectsRD::copy_depth_to_rect(RID p_source_rd_texture, RID p_dest_texture, const Rect2i &p_rect, bool p_flip_y) { - zeromem(©.push_constant, sizeof(CopyPushConstant)); + memset(©.push_constant, 0, sizeof(CopyPushConstant)); if (p_flip_y) { copy.push_constant.flags |= COPY_FLAG_FLIP_Y; } @@ -375,7 +375,7 @@ void EffectsRD::copy_depth_to_rect(RID p_source_rd_texture, RID p_dest_texture, } void EffectsRD::set_color(RID p_dest_texture, const Color &p_color, const Rect2i &p_region, bool p_8bit_dst) { - zeromem(©.push_constant, sizeof(CopyPushConstant)); + memset(©.push_constant, 0, sizeof(CopyPushConstant)); copy.push_constant.section[0] = 0; copy.push_constant.section[1] = 0; @@ -397,7 +397,7 @@ void EffectsRD::set_color(RID p_dest_texture, const Color &p_color, const Rect2i } void EffectsRD::gaussian_blur(RID p_source_rd_texture, RID p_texture, RID p_back_texture, const Rect2i &p_region, bool p_8bit_dst) { - zeromem(©.push_constant, sizeof(CopyPushConstant)); + memset(©.push_constant, 0, sizeof(CopyPushConstant)); uint32_t base_flags = 0; copy.push_constant.section[0] = p_region.position.x; @@ -430,7 +430,7 @@ void EffectsRD::gaussian_blur(RID p_source_rd_texture, RID p_texture, RID p_back } void EffectsRD::gaussian_glow(RID p_source_rd_texture, RID p_back_texture, const Size2i &p_size, float p_strength, bool p_high_quality, bool p_first_pass, float p_luminance_cap, float p_exposure, float p_bloom, float p_hdr_bleed_treshold, float p_hdr_bleed_scale, RID p_auto_exposure, float p_auto_exposure_grey) { - zeromem(©.push_constant, sizeof(CopyPushConstant)); + memset(©.push_constant, 0, sizeof(CopyPushConstant)); CopyMode copy_mode = p_first_pass && p_auto_exposure.is_valid() ? COPY_MODE_GAUSSIAN_GLOW_AUTO_EXPOSURE : COPY_MODE_GAUSSIAN_GLOW; uint32_t base_flags = 0; @@ -657,7 +657,7 @@ void EffectsRD::merge_specular(RID p_dest_framebuffer, RID p_specular, RID p_bas } void EffectsRD::make_mipmap(RID p_source_rd_texture, RID p_dest_texture, const Size2i &p_size) { - zeromem(©.push_constant, sizeof(CopyPushConstant)); + memset(©.push_constant, 0, sizeof(CopyPushConstant)); copy.push_constant.section[0] = 0; copy.push_constant.section[1] = 0; @@ -694,7 +694,7 @@ void EffectsRD::copy_cubemap_to_dp(RID p_source_rd_texture, RID p_dst_framebuffe } void EffectsRD::tonemapper(RID p_source_color, RID p_dst_framebuffer, const TonemapSettings &p_settings) { - zeromem(&tonemap.push_constant, sizeof(TonemapPushConstant)); + memset(&tonemap.push_constant, 0, sizeof(TonemapPushConstant)); tonemap.push_constant.use_bcs = p_settings.use_bcs; tonemap.push_constant.bcs[0] = p_settings.brightness; @@ -1294,7 +1294,7 @@ void EffectsRD::roughness_limit(RID p_source_normal, RID p_roughness, const Size } void EffectsRD::cubemap_roughness(RID p_source_rd_texture, RID p_dest_framebuffer, uint32_t p_face_id, uint32_t p_sample_count, float p_roughness, float p_size) { - zeromem(&roughness.push_constant, sizeof(CubemapRoughnessPushConstant)); + memset(&roughness.push_constant, 0, sizeof(CubemapRoughnessPushConstant)); roughness.push_constant.face_id = p_face_id > 9 ? 0 : p_face_id; roughness.push_constant.roughness = p_roughness; @@ -1368,7 +1368,7 @@ void EffectsRD::cubemap_filter(RID p_source_cubemap, Vector<RID> p_dest_cubemap, void EffectsRD::render_sky(RD::DrawListID p_list, float p_time, RID p_fb, RID p_samplers, RID p_fog, PipelineCacheRD *p_pipeline, RID p_uniform_set, RID p_texture_set, const CameraMatrix &p_camera, const Basis &p_orientation, float p_multiplier, const Vector3 &p_position) { SkyPushConstant sky_push_constant; - zeromem(&sky_push_constant, sizeof(SkyPushConstant)); + memset(&sky_push_constant, 0, sizeof(SkyPushConstant)); sky_push_constant.proj[0] = p_camera.matrix[2][0]; sky_push_constant.proj[1] = p_camera.matrix[0][0]; @@ -1510,7 +1510,7 @@ EffectsRD::EffectsRD() { copy_modes.push_back("\n#define MODE_CUBEMAP_ARRAY_TO_PANORAMA\n"); copy.shader.initialize(copy_modes); - zeromem(©.push_constant, sizeof(CopyPushConstant)); + memset(©.push_constant, 0, sizeof(CopyPushConstant)); copy.shader_version = copy.shader.version_create(); for (int i = 0; i < COPY_MODE_MAX; i++) { 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 9be0dc0d15..2c63eed4f2 100644 --- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp +++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp @@ -2756,7 +2756,7 @@ void RenderForwardClustered::geometry_instance_set_lightmap_capture(GeometryInst ginstance->lightmap_sh = geometry_instance_lightmap_sh.alloc(); } - copymem(ginstance->lightmap_sh->sh, p_sh9, sizeof(Color) * 9); + memcpy(ginstance->lightmap_sh->sh, p_sh9, sizeof(Color) * 9); } else { if (ginstance->lightmap_sh != nullptr) { geometry_instance_lightmap_sh.free(ginstance->lightmap_sh); diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp index 3c76c91a67..377b0fd72d 100644 --- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp @@ -304,7 +304,7 @@ RendererCanvasRender::PolygonID RendererCanvasRenderRD::request_polygon(const Ve index_buffer.resize(p_indices.size() * sizeof(int32_t)); { uint8_t *w = index_buffer.ptrw(); - copymem(w, p_indices.ptr(), sizeof(int32_t) * p_indices.size()); + memcpy(w, p_indices.ptr(), sizeof(int32_t) * p_indices.size()); } pb.index_buffer = RD::get_singleton()->index_buffer_create(p_indices.size(), RD::INDEX_BUFFER_FORMAT_UINT32, index_buffer); pb.indices = RD::get_singleton()->index_array_create(pb.index_buffer, 0, p_indices.size()); diff --git a/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp index 3856f38457..2b0e93f734 100644 --- a/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp @@ -1564,7 +1564,7 @@ void RendererSceneGIRD::SDFGI::render_region(RID p_render_buffers, int p_region, //clear dispatch indirect data SDFGIShader::PreprocessPushConstant push_constant; - zeromem(&push_constant, sizeof(SDFGIShader::PreprocessPushConstant)); + memset(&push_constant, 0, sizeof(SDFGIShader::PreprocessPushConstant)); RENDER_TIMESTAMP("Scroll SDF"); @@ -2602,7 +2602,7 @@ void RendererSceneGIRD::GIProbeInstance::update(bool p_update_light_instances, c p_scene_render->_render_material(to_world_xform * xform, cm, true, p_scene_render->cull_argument, dynamic_maps[0].fb, Rect2i(Vector2i(), rect.size)); GIProbeDynamicPushConstant push_constant; - zeromem(&push_constant, sizeof(GIProbeDynamicPushConstant)); + memset(&push_constant, 0, sizeof(GIProbeDynamicPushConstant)); push_constant.limits[0] = octree_size.x; push_constant.limits[1] = octree_size.y; push_constant.limits[2] = octree_size.z; diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.cpp b/servers/rendering/renderer_rd/renderer_storage_rd.cpp index 540b32481b..250b694f74 100644 --- a/servers/rendering/renderer_rd/renderer_storage_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_storage_rd.cpp @@ -756,7 +756,7 @@ void RendererStorageRD::texture_3d_initialize(RID p_texture, Image::Format p_for for (int i = 0; i < p_data.size(); i++) { uint32_t s = images[i]->get_data().size(); - copymem(&all_data.write[offset], images[i]->get_data().ptr(), s); + memcpy(&all_data.write[offset], images[i]->get_data().ptr(), s); { Texture::BufferSlice3D slice; slice.size.width = images[i]->get_width(); @@ -919,7 +919,7 @@ void RendererStorageRD::texture_3d_update(RID p_texture, const Vector<Ref<Image> for (int i = 0; i < p_data.size(); i++) { uint32_t s = images[i]->get_data().size(); - copymem(&all_data.write[offset], images[i]->get_data().ptr(), s); + memcpy(&all_data.write[offset], images[i]->get_data().ptr(), s); offset += s; } } @@ -2108,13 +2108,13 @@ _FORCE_INLINE_ static void _fill_std140_ubo_empty(ShaderLanguage::DataType type, case ShaderLanguage::TYPE_INT: case ShaderLanguage::TYPE_UINT: case ShaderLanguage::TYPE_FLOAT: { - zeromem(data, 4); + memset(data, 0, 4); } break; case ShaderLanguage::TYPE_BVEC2: case ShaderLanguage::TYPE_IVEC2: case ShaderLanguage::TYPE_UVEC2: case ShaderLanguage::TYPE_VEC2: { - zeromem(data, 8); + memset(data, 0, 8); } break; case ShaderLanguage::TYPE_BVEC3: case ShaderLanguage::TYPE_IVEC3: @@ -2124,16 +2124,16 @@ _FORCE_INLINE_ static void _fill_std140_ubo_empty(ShaderLanguage::DataType type, case ShaderLanguage::TYPE_IVEC4: case ShaderLanguage::TYPE_UVEC4: case ShaderLanguage::TYPE_VEC4: { - zeromem(data, 16); + memset(data, 0, 16); } break; case ShaderLanguage::TYPE_MAT2: { - zeromem(data, 32); + memset(data, 0, 32); } break; case ShaderLanguage::TYPE_MAT3: { - zeromem(data, 48); + memset(data, 0, 48); } break; case ShaderLanguage::TYPE_MAT4: { - zeromem(data, 64); + memset(data, 0, 64); } break; default: { @@ -3412,10 +3412,10 @@ void RendererStorageRD::_multimesh_make_local(MultiMesh *multimesh) const { Vector<uint8_t> buffer = RD::get_singleton()->buffer_get_data(multimesh->buffer); { const uint8_t *r = buffer.ptr(); - copymem(w, r, buffer.size()); + memcpy(w, r, buffer.size()); } } else { - zeromem(w, multimesh->instances * multimesh->stride_cache * sizeof(float)); + memset(w, 0, multimesh->instances * multimesh->stride_cache * sizeof(float)); } } uint32_t data_cache_dirty_region_count = (multimesh->instances - 1) / MULTIMESH_DIRTY_REGION_SIZE + 1; @@ -3771,7 +3771,7 @@ Vector<float> RendererStorageRD::multimesh_get_buffer(RID p_multimesh) const { { float *w = ret.ptrw(); const uint8_t *r = buffer.ptr(); - copymem(w, r, buffer.size()); + memcpy(w, r, buffer.size()); } return ret; @@ -4068,7 +4068,7 @@ void RendererStorageRD::_particles_allocate_emission_buffer(Particles *particles ERR_FAIL_COND(particles->emission_buffer != nullptr); particles->emission_buffer_data.resize(sizeof(ParticleEmissionBuffer::Data) * particles->amount + sizeof(uint32_t) * 4); - zeromem(particles->emission_buffer_data.ptrw(), particles->emission_buffer_data.size()); + memset(particles->emission_buffer_data.ptrw(), 0, particles->emission_buffer_data.size()); particles->emission_buffer = (ParticleEmissionBuffer *)particles->emission_buffer_data.ptrw(); particles->emission_buffer->particle_max = particles->amount; @@ -5230,7 +5230,7 @@ void RendererStorageRD::skeleton_allocate_data(RID p_skeleton, int p_bones, bool if (skeleton->size) { skeleton->data.resize(skeleton->size * (skeleton->use_2d ? 8 : 12)); skeleton->buffer = RD::get_singleton()->storage_buffer_create(skeleton->data.size() * sizeof(float)); - zeromem(skeleton->data.ptrw(), skeleton->data.size() * sizeof(float)); + memset(skeleton->data.ptrw(), 0, skeleton->data.size() * sizeof(float)); _skeleton_make_dirty(skeleton); @@ -6872,7 +6872,7 @@ RID RendererStorageRD::render_target_get_sdf_texture(RID p_render_target) { Vector<uint8_t> pv; pv.resize(16 * 4); - zeromem(pv.ptrw(), 16 * 4); + memset(pv.ptrw(), 0, 16 * 4); Vector<Vector<uint8_t>> vpv; rt->sdf_buffer_read = RD::get_singleton()->texture_create(tformat, RD::TextureView(), vpv); @@ -7359,7 +7359,7 @@ void RendererStorageRD::_update_decal_atlas() { v_offsetsv.resize(base_size); int *v_offsets = v_offsetsv.ptrw(); - zeromem(v_offsets, sizeof(int) * base_size); + memset(v_offsets, 0, sizeof(int) * base_size); int max_height = 0; @@ -8115,7 +8115,7 @@ void RendererStorageRD::_update_global_variables() { if (total_regions / global_variables.buffer_dirty_region_count <= 4) { // 25% of regions dirty, just update all buffer RD::get_singleton()->buffer_update(global_variables.buffer, 0, sizeof(GlobalVariables::Value) * global_variables.buffer_size, global_variables.buffer_values); - zeromem(global_variables.buffer_dirty_regions, sizeof(bool) * total_regions); + memset(global_variables.buffer_dirty_regions, 0, sizeof(bool) * total_regions); } else { uint32_t region_byte_size = sizeof(GlobalVariables::Value) * GlobalVariables::BUFFER_DIRTY_REGION_SIZE; @@ -8403,10 +8403,10 @@ RendererStorageRD::RendererStorageRD() { global_variables.buffer_size = GLOBAL_GET("rendering/limits/global_shader_variables/buffer_size"); global_variables.buffer_size = MAX(4096, global_variables.buffer_size); global_variables.buffer_values = memnew_arr(GlobalVariables::Value, global_variables.buffer_size); - zeromem(global_variables.buffer_values, sizeof(GlobalVariables::Value) * global_variables.buffer_size); + memset(global_variables.buffer_values, 0, sizeof(GlobalVariables::Value) * global_variables.buffer_size); global_variables.buffer_usage = memnew_arr(GlobalVariables::ValueUsage, global_variables.buffer_size); global_variables.buffer_dirty_regions = memnew_arr(bool, global_variables.buffer_size / GlobalVariables::BUFFER_DIRTY_REGION_SIZE); - zeromem(global_variables.buffer_dirty_regions, sizeof(bool) * global_variables.buffer_size / GlobalVariables::BUFFER_DIRTY_REGION_SIZE); + memset(global_variables.buffer_dirty_regions, 0, sizeof(bool) * global_variables.buffer_size / GlobalVariables::BUFFER_DIRTY_REGION_SIZE); global_variables.buffer = RD::get_singleton()->storage_buffer_create(sizeof(GlobalVariables::Value) * global_variables.buffer_size); material_update_list = nullptr; |