From bc2e8d99e5ae0dbd69e712cc71da3033f5f30139 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 25 Nov 2017 00:07:54 -0300 Subject: [PATCH] Made Vector::ptrw explicit for writing, compiler was sometimes using the wrong function, leading to unnecesary copy on writes and reduced performance. --- core/array.cpp | 2 +- core/compressed_translation.cpp | 2 +- core/io/file_access_compressed.cpp | 24 +++++++++---------- core/io/file_access_encrypted.cpp | 12 +++++----- core/io/file_access_network.cpp | 6 ++--- core/io/stream_peer.cpp | 6 ++--- core/object.cpp | 4 ++-- core/os/file_access.cpp | 2 +- core/project_settings.cpp | 2 +- core/script_debugger_local.cpp | 4 ++-- core/script_debugger_remote.cpp | 2 +- core/string_buffer.cpp | 2 +- core/string_buffer.h | 2 +- core/ustring.cpp | 4 ++-- core/variant_call.cpp | 2 +- core/vector.h | 4 ++-- drivers/gles3/rasterizer_canvas_gles3.cpp | 6 ++--- drivers/gles3/rasterizer_scene_gles3.cpp | 6 ++--- drivers/gles3/rasterizer_storage_gles3.cpp | 12 +++++----- drivers/gles3/rasterizer_storage_gles3.h | 2 +- .../pulseaudio/audio_driver_pulseaudio.cpp | 2 +- editor/doc/doc_data.cpp | 2 +- editor/editor_asset_installer.cpp | 2 +- editor/editor_profiler.cpp | 2 +- editor/editor_settings.cpp | 2 +- editor/export_template_manager.cpp | 4 ++-- editor/fileserver/editor_file_server.cpp | 3 +-- editor/import/editor_scene_importer_gltf.cpp | 18 +++++++------- editor/plugins/navigation_mesh_generator.cpp | 4 ++-- editor/project_manager.cpp | 2 +- modules/enet/networked_multiplayer_enet.cpp | 2 +- modules/gdscript/gdscript.cpp | 6 ++--- modules/gdscript/gdscript_editor.cpp | 6 ++--- modules/visual_script/visual_script.cpp | 10 ++++---- .../visual_script/visual_script_editor.cpp | 2 +- .../visual_script_expression.cpp | 6 ++--- platform/android/export/export.cpp | 8 +++---- platform/iphone/export/export.cpp | 2 +- platform/javascript/export/export.cpp | 4 ++-- platform/osx/export/export.cpp | 2 +- platform/uwp/export/export.cpp | 24 +++++++++---------- scene/2d/audio_stream_player_2d.cpp | 2 +- scene/2d/navigation2d.cpp | 2 +- scene/3d/audio_stream_player_3d.cpp | 2 +- scene/3d/navigation.cpp | 2 +- scene/audio/audio_player.cpp | 2 +- scene/gui/video_player.cpp | 2 +- scene/main/node.cpp | 2 +- scene/main/scene_tree.cpp | 8 +++---- scene/resources/bit_mask.cpp | 6 ++--- scene/resources/dynamic_font.cpp | 2 +- scene/resources/world.cpp | 4 ++-- servers/audio/effects/audio_effect_chorus.cpp | 2 +- servers/audio/effects/audio_effect_delay.cpp | 4 ++-- servers/audio/effects/audio_effect_eq.cpp | 6 ++--- servers/audio_server.cpp | 10 ++++---- servers/physics_2d_server.cpp | 6 ++--- servers/physics_server.cpp | 4 ++-- servers/visual/shader_language.cpp | 2 +- servers/visual/visual_server_canvas.cpp | 2 +- servers/visual/visual_server_scene.cpp | 4 ++-- servers/visual_server.cpp | 2 +- 62 files changed, 148 insertions(+), 147 deletions(-) diff --git a/core/array.cpp b/core/array.cpp index b7d4ae413a3..1ccbbae1479 100644 --- a/core/array.cpp +++ b/core/array.cpp @@ -261,7 +261,7 @@ Array &Array::sort_custom(Object *p_obj, const StringName &p_function) { SortArray avs; avs.compare.obj = p_obj; avs.compare.func = p_function; - avs.sort(_p->array.ptr(), _p->array.size()); + avs.sort(_p->array.ptrw(), _p->array.size()); return *this; } diff --git a/core/compressed_translation.cpp b/core/compressed_translation.cpp index 74565d2e324..5c7b7935902 100644 --- a/core/compressed_translation.cpp +++ b/core/compressed_translation.cpp @@ -288,7 +288,7 @@ StringName PHashTranslation::get_message(const StringName &p_src_text) const { CharString uncomp; uncomp.resize(bucket.elem[idx].uncomp_size + 1); - smaz_decompress(&sptr[bucket.elem[idx].str_offset], bucket.elem[idx].comp_size, uncomp.ptr(), bucket.elem[idx].uncomp_size); + smaz_decompress(&sptr[bucket.elem[idx].str_offset], bucket.elem[idx].comp_size, uncomp.ptrw(), bucket.elem[idx].uncomp_size); String rstr; rstr.parse_utf8(uncomp.get_data()); //print_line("Compressed, size: "+itos(bucket.elem[idx].comp_size)); diff --git a/core/io/file_access_compressed.cpp b/core/io/file_access_compressed.cpp index 514e3c65f01..c6f31dc8f07 100644 --- a/core/io/file_access_compressed.cpp +++ b/core/io/file_access_compressed.cpp @@ -51,7 +51,7 @@ void FileAccessCompressed::configure(const String &p_magic, Compression::Mode p_ if (write_max > write_buffer_size) { \ write_buffer_size = next_power_of_2(write_max); \ buffer.resize(write_buffer_size); \ - write_ptr = buffer.ptr(); \ + write_ptr = buffer.ptrw(); \ } \ } @@ -76,14 +76,14 @@ Error FileAccessCompressed::open_after_magic(FileAccess *p_base) { comp_buffer.resize(max_bs); buffer.resize(block_size); - read_ptr = buffer.ptr(); - f->get_buffer(comp_buffer.ptr(), read_blocks[0].csize); + read_ptr = buffer.ptrw(); + f->get_buffer(comp_buffer.ptrw(), read_blocks[0].csize); at_end = false; read_eof = false; read_block_count = bc; read_block_size = read_blocks.size() == 1 ? read_total : block_size; - Compression::decompress(buffer.ptr(), read_block_size, comp_buffer.ptr(), read_blocks[0].csize, cmode); + Compression::decompress(buffer.ptrw(), read_block_size, comp_buffer.ptr(), read_blocks[0].csize, cmode); read_block = 0; read_pos = 0; @@ -114,7 +114,7 @@ Error FileAccessCompressed::_open(const String &p_path, int p_mode_flags) { write_buffer_size = 256; buffer.resize(256); write_max = 0; - write_ptr = buffer.ptr(); + write_ptr = buffer.ptrw(); //don't store anything else unless it's done saving! } else { @@ -160,7 +160,7 @@ void FileAccessCompressed::close() { Vector cblock; cblock.resize(Compression::get_max_compressed_buffer_size(bl, cmode)); - int s = Compression::compress(cblock.ptr(), bp, bl, cmode); + int s = Compression::compress(cblock.ptrw(), bp, bl, cmode); f->store_buffer(cblock.ptr(), s); block_sizes.push_back(s); @@ -211,8 +211,8 @@ void FileAccessCompressed::seek(size_t p_position) { read_block = block_idx; f->seek(read_blocks[read_block].offset); - f->get_buffer(comp_buffer.ptr(), read_blocks[read_block].csize); - Compression::decompress(buffer.ptr(), read_blocks.size() == 1 ? read_total : block_size, comp_buffer.ptr(), read_blocks[read_block].csize, cmode); + f->get_buffer(comp_buffer.ptrw(), read_blocks[read_block].csize); + Compression::decompress(buffer.ptrw(), read_blocks.size() == 1 ? read_total : block_size, comp_buffer.ptr(), read_blocks[read_block].csize, cmode); read_block_size = read_block == read_block_count - 1 ? read_total % block_size : block_size; } @@ -282,8 +282,8 @@ uint8_t FileAccessCompressed::get_8() const { if (read_block < read_block_count) { //read another block of compressed data - f->get_buffer(comp_buffer.ptr(), read_blocks[read_block].csize); - Compression::decompress(buffer.ptr(), read_blocks.size() == 1 ? read_total : block_size, comp_buffer.ptr(), read_blocks[read_block].csize, cmode); + f->get_buffer(comp_buffer.ptrw(), read_blocks[read_block].csize); + Compression::decompress(buffer.ptrw(), read_blocks.size() == 1 ? read_total : block_size, comp_buffer.ptr(), read_blocks[read_block].csize, cmode); read_block_size = read_block == read_block_count - 1 ? read_total % block_size : block_size; read_pos = 0; @@ -315,8 +315,8 @@ int FileAccessCompressed::get_buffer(uint8_t *p_dst, int p_length) const { if (read_block < read_block_count) { //read another block of compressed data - f->get_buffer(comp_buffer.ptr(), read_blocks[read_block].csize); - Compression::decompress(buffer.ptr(), read_blocks.size() == 1 ? read_total : block_size, comp_buffer.ptr(), read_blocks[read_block].csize, cmode); + f->get_buffer(comp_buffer.ptrw(), read_blocks[read_block].csize); + Compression::decompress(buffer.ptrw(), read_blocks.size() == 1 ? read_total : block_size, comp_buffer.ptr(), read_blocks[read_block].csize, cmode); read_block_size = read_block == read_block_count - 1 ? read_total % block_size : block_size; read_pos = 0; diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp index e5da307153d..71ebf575084 100644 --- a/core/io/file_access_encrypted.cpp +++ b/core/io/file_access_encrypted.cpp @@ -80,11 +80,11 @@ Error FileAccessEncrypted::open_and_parse(FileAccess *p_base, const Vectorget_buffer(data.ptr(), ds); + uint32_t blen = p_base->get_buffer(data.ptrw(), ds); ERR_FAIL_COND_V(blen != ds, ERR_FILE_CORRUPT); aes256_context ctx; - aes256_init(&ctx, key.ptr()); + aes256_init(&ctx, key.ptrw()); for (size_t i = 0; i < ds; i += 16) { @@ -97,7 +97,7 @@ Error FileAccessEncrypted::open_and_parse(FileAccess *p_base, const Vector block; block.resize(len); - client->get_data(block.ptr(), len); + client->get_data(block.ptrw(), len); if (fa) //may have been queued fa->_set_block(offset, block); @@ -434,12 +434,12 @@ int FileAccessNetwork::get_buffer(uint8_t *p_dst, int p_length) const { _queue_page(page + j); } - buff = pages[page].buffer.ptr(); + buff = pages[page].buffer.ptrw(); //queue pages buffer_mutex->unlock(); } - buff = pages[page].buffer.ptr(); + buff = pages[page].buffer.ptrw(); last_page_buff = buff; last_page = page; } diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp index 2583eb369d1..42a258a10d6 100644 --- a/core/io/stream_peer.cpp +++ b/core/io/stream_peer.cpp @@ -220,7 +220,7 @@ void StreamPeer::put_var(const Variant &p_variant) { encode_variant(p_variant, NULL, len); buf.resize(len); put_32(len); - encode_variant(p_variant, buf.ptr(), len); + encode_variant(p_variant, buf.ptrw(), len); put_data(buf.ptr(), buf.size()); } @@ -340,7 +340,7 @@ String StreamPeer::get_utf8_string(int p_bytes) { Vector buf; Error err = buf.resize(p_bytes); ERR_FAIL_COND_V(err != OK, String()); - err = get_data(buf.ptr(), p_bytes); + err = get_data(buf.ptrw(), p_bytes); ERR_FAIL_COND_V(err != OK, String()); String ret; @@ -353,7 +353,7 @@ Variant StreamPeer::get_var() { Vector var; Error err = var.resize(len); ERR_FAIL_COND_V(err != OK, Variant()); - err = get_data(var.ptr(), len); + err = get_data(var.ptrw(), len); ERR_FAIL_COND_V(err != OK, Variant()); Variant ret; diff --git a/core/object.cpp b/core/object.cpp index cb6ecefa9d0..1be7337d96d 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -818,7 +818,7 @@ Variant Object::callv(const StringName &p_method, const Array &p_args) { } Variant::CallError ce; - return call(p_method, argptrs.ptr(), p_args.size(), ce); + return call(p_method, (const Variant **)argptrs.ptr(), p_args.size(), ce); } Variant Object::call(const StringName &p_name, VARIANT_ARG_DECLARE) { @@ -1183,7 +1183,7 @@ Error Object::emit_signal(const StringName &p_name, const Variant **p_args, int bind_mem[p_argcount + j] = &c.binds[j]; } - args = bind_mem.ptr(); + args = (const Variant **)bind_mem.ptr(); argc = bind_mem.size(); } diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index 5fdd2b9135f..7b2062936b4 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -481,7 +481,7 @@ Vector FileAccess::get_file_as_array(const String &p_path) { ERR_FAIL_COND_V(!f, Vector()); Vector data; data.resize(f->get_len()); - f->get_buffer(data.ptr(), data.size()); + f->get_buffer(data.ptrw(), data.size()); memdelete(f); return data; } diff --git a/core/project_settings.cpp b/core/project_settings.cpp index 361464ee1fa..13340535b52 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -429,7 +429,7 @@ Error ProjectSettings::_load_settings_binary(const String p_path) { uint32_t vlen = f->get_32(); Vector d; d.resize(vlen); - f->get_buffer(d.ptr(), vlen); + f->get_buffer(d.ptrw(), vlen); Variant value; Error err = decode_variant(value, d.ptr(), d.size()); ERR_EXPLAIN("Error decoding property: " + key); diff --git a/core/script_debugger_local.cpp b/core/script_debugger_local.cpp index 8d2600e52dd..94c48f1c8f0 100644 --- a/core/script_debugger_local.cpp +++ b/core/script_debugger_local.cpp @@ -212,7 +212,7 @@ void ScriptDebuggerLocal::idle_poll() { } SortArray sort; - sort.sort(pinfo.ptr(), ofs); + sort.sort(pinfo.ptrw(), ofs); //falta el frame time @@ -264,7 +264,7 @@ void ScriptDebuggerLocal::profiling_end() { } SortArray sort; - sort.sort(pinfo.ptr(), ofs); + sort.sort(pinfo.ptrw(), ofs); uint64_t total_us = 0; for (int i = 0; i < ofs; i++) { diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index 5e06339b9eb..495c99c122d 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -749,7 +749,7 @@ void ScriptDebuggerRemote::_send_profiling_data(bool p_for_frame) { } SortArray sa; - sa.sort(profile_info_ptrs.ptr(), ofs); + sa.sort(profile_info_ptrs.ptrw(), ofs); int to_send = MIN(ofs, max_frame_functions); diff --git a/core/string_buffer.cpp b/core/string_buffer.cpp index 195068f8870..8489df2599e 100644 --- a/core/string_buffer.cpp +++ b/core/string_buffer.cpp @@ -71,7 +71,7 @@ StringBuffer &StringBuffer::reserve(int p_size) { bool need_copy = string_length > 0 && buffer.empty(); buffer.resize(next_power_of_2(p_size)); if (need_copy) { - memcpy(buffer.ptr(), short_buffer, string_length * sizeof(CharType)); + memcpy(buffer.ptrw(), short_buffer, string_length * sizeof(CharType)); } return *this; diff --git a/core/string_buffer.h b/core/string_buffer.h index 3f362491489..b6ccd4af20d 100644 --- a/core/string_buffer.h +++ b/core/string_buffer.h @@ -40,7 +40,7 @@ class StringBuffer { int string_length = 0; _FORCE_INLINE_ CharType *current_buffer_ptr() { - return static_cast &>(buffer).empty() ? short_buffer : buffer.ptr(); + return static_cast &>(buffer).empty() ? short_buffer : buffer.ptrw(); } public: diff --git a/core/ustring.cpp b/core/ustring.cpp index 8d40f563865..a86fb46c8a9 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -115,7 +115,7 @@ void String::copy_from(const char *p_cstr) { resize(len + 1); // include 0 - CharType *dst = this->ptr(); + CharType *dst = this->ptrw(); for (int i = 0; i < len + 1; i++) { @@ -1119,7 +1119,7 @@ String String::num_int64(int64_t p_num, int base, bool capitalize_hex) { chars++; String s; s.resize(chars + 1); - CharType *c = s.ptr(); + CharType *c = s.ptrw(); c[chars] = 0; n = num; do { diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 4a140bdb99c..10f5ca0ce15 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -499,7 +499,7 @@ struct _VariantCall { PoolByteArray::Read r = ba->read(); CharString cs; cs.resize(ba->size() + 1); - copymem(cs.ptr(), r.ptr(), ba->size()); + copymem(cs.ptrw(), r.ptr(), ba->size()); cs[ba->size()] = 0; s = cs.get_data(); diff --git a/core/vector.h b/core/vector.h index 03eaf65099f..a5c4b3b155d 100644 --- a/core/vector.h +++ b/core/vector.h @@ -96,7 +96,7 @@ class Vector { void _copy_on_write(); public: - _FORCE_INLINE_ T *ptr() { + _FORCE_INLINE_ T *ptrw() { if (!_ptr) return NULL; _copy_on_write(); return (T *)_get_data(); @@ -361,7 +361,7 @@ template void Vector::remove(int p_index) { ERR_FAIL_INDEX(p_index, size()); - T *p = ptr(); + T *p = ptrw(); int len = size(); for (int i = p_index; i < len - 1; i++) { diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index 308a18aa9d0..5b3e43fc43c 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -449,7 +449,7 @@ void RasterizerCanvasGLES3::_draw_gui_primitive(int p_points, const Vector2 *p_v void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item, Item *current_clip, bool &reclip) { int cc = p_item->commands.size(); - Item::Command **commands = p_item->commands.ptr(); + Item::Command **commands = p_item->commands.ptrw(); for (int i = 0; i < cc; i++) { @@ -1084,8 +1084,8 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons } int tc = material_ptr->textures.size(); - RID *textures = material_ptr->textures.ptr(); - ShaderLanguage::ShaderNode::Uniform::Hint *texture_hints = shader_ptr->texture_hints.ptr(); + RID *textures = material_ptr->textures.ptrw(); + ShaderLanguage::ShaderNode::Uniform::Hint *texture_hints = shader_ptr->texture_hints.ptrw(); for (int i = 0; i < tc; i++) { diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 0c57e4e9cf7..02df170da13 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -254,7 +254,7 @@ bool RasterizerSceneGLES3::_shadow_atlas_find_shadow(ShadowAtlas *shadow_atlas, //look for an empty space int sc = shadow_atlas->quadrants[qidx].shadows.size(); - ShadowAtlas::Quadrant::Shadow *sarr = shadow_atlas->quadrants[qidx].shadows.ptr(); + ShadowAtlas::Quadrant::Shadow *sarr = shadow_atlas->quadrants[qidx].shadows.ptrw(); int found_free_idx = -1; //found a free one int found_used_idx = -1; //found existing one, must steal it @@ -1198,8 +1198,8 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material *p_m } int tc = p_material->textures.size(); - RID *textures = p_material->textures.ptr(); - ShaderLanguage::ShaderNode::Uniform::Hint *texture_hints = p_material->shader->texture_hints.ptr(); + RID *textures = p_material->textures.ptrw(); + ShaderLanguage::ShaderNode::Uniform::Hint *texture_hints = p_material->shader->texture_hints.ptrw(); state.current_main_tex = 0; diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index a41d84a2aa8..89d3d7ff757 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -3477,7 +3477,7 @@ void RasterizerStorageGLES3::mesh_clear(RID p_mesh) { } } -void RasterizerStorageGLES3::mesh_render_blend_shapes(Surface *s, float *p_weights) { +void RasterizerStorageGLES3::mesh_render_blend_shapes(Surface *s, const float *p_weights) { glBindVertexArray(s->array_id); @@ -4063,7 +4063,7 @@ void RasterizerStorageGLES3::update_dirty_multimeshes() { int stride = multimesh->color_floats + multimesh->xform_floats; int count = multimesh->data.size(); - float *data = multimesh->data.ptr(); + float *data = multimesh->data.ptrw(); AABB aabb; @@ -4327,7 +4327,7 @@ void RasterizerStorageGLES3::skeleton_bone_set_transform(RID p_skeleton, int p_b ERR_FAIL_INDEX(p_bone, skeleton->size); ERR_FAIL_COND(skeleton->use_2d); - float *texture = skeleton->skel_texture.ptr(); + float *texture = skeleton->skel_texture.ptrw(); int base_ofs = ((p_bone / 256) * 256) * 3 * 4 + (p_bone % 256) * 4; @@ -4390,7 +4390,7 @@ void RasterizerStorageGLES3::skeleton_bone_set_transform_2d(RID p_skeleton, int ERR_FAIL_INDEX(p_bone, skeleton->size); ERR_FAIL_COND(!skeleton->use_2d); - float *texture = skeleton->skel_texture.ptr(); + float *texture = skeleton->skel_texture.ptrw(); int base_ofs = ((p_bone / 256) * 256) * 2 * 4 + (p_bone % 256) * 4; @@ -5632,8 +5632,8 @@ void RasterizerStorageGLES3::update_particles() { } int tc = material->textures.size(); - RID *textures = material->textures.ptr(); - ShaderLanguage::ShaderNode::Uniform::Hint *texture_hints = material->shader->texture_hints.ptr(); + RID *textures = material->textures.ptrw(); + ShaderLanguage::ShaderNode::Uniform::Hint *texture_hints = material->shader->texture_hints.ptrw(); for (int i = 0; i < tc; i++) { diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h index 8aa8235b421..0ec110ab87f 100644 --- a/drivers/gles3/rasterizer_storage_gles3.h +++ b/drivers/gles3/rasterizer_storage_gles3.h @@ -719,7 +719,7 @@ public: virtual AABB mesh_get_aabb(RID p_mesh, RID p_skeleton) const; virtual void mesh_clear(RID p_mesh); - void mesh_render_blend_shapes(Surface *s, float *p_weights); + void mesh_render_blend_shapes(Surface *s, const float *p_weights); /* MULTIMESH API */ diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp index e4c8641a3b8..49ac9e6e22f 100644 --- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp +++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp @@ -241,7 +241,7 @@ void AudioDriverPulseAudio::thread_func(void *p_udata) { } else { ad->lock(); - ad->audio_server_process(ad->buffer_frames, ad->samples_in.ptr()); + ad->audio_server_process(ad->buffer_frames, ad->samples_in.ptrw()); ad->unlock(); diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp index a44830ef80e..3a72f8e569d 100644 --- a/editor/doc/doc_data.cpp +++ b/editor/doc/doc_data.cpp @@ -1115,7 +1115,7 @@ Error DocData::load_compressed(const uint8_t *p_data, int p_compressed_size, int Vector data; data.resize(p_uncompressed_size); - Compression::decompress(data.ptr(), p_uncompressed_size, p_data, p_compressed_size, Compression::MODE_DEFLATE); + Compression::decompress(data.ptrw(), p_uncompressed_size, p_data, p_compressed_size, Compression::MODE_DEFLATE); class_list.clear(); Ref parser = memnew(XMLParser); diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index 1aac697ffd7..94108a52fca 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -268,7 +268,7 @@ void EditorAssetInstaller::ok_pressed() { //read unzOpenCurrentFile(pkg); - unzReadCurrentFile(pkg, data.ptr(), data.size()); + unzReadCurrentFile(pkg, data.ptrw(), data.size()); unzCloseCurrentFile(pkg); FileAccess *f = FileAccess::open(path, FileAccess::WRITE); diff --git a/editor/editor_profiler.cpp b/editor/editor_profiler.cpp index faf49ffd418..5d81fc6ea46 100644 --- a/editor/editor_profiler.cpp +++ b/editor/editor_profiler.cpp @@ -221,7 +221,7 @@ void EditorProfiler::_update_plot() { Vector columnv; columnv.resize(h * 4); - int *column = columnv.ptr(); + int *column = columnv.ptrw(); Map plot_prev; //Map plot_max; diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 582bb977b85..8bec8854ca1 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -1388,7 +1388,7 @@ EditorSettings::EditorSettings() { Vector data; data.resize(etl->uncomp_size); - Compression::decompress(data.ptr(), etl->uncomp_size, etl->data, etl->comp_size, Compression::MODE_DEFLATE); + Compression::decompress(data.ptrw(), etl->uncomp_size, etl->data, etl->comp_size, Compression::MODE_DEFLATE); FileAccessMemory *fa = memnew(FileAccessMemory); fa->open_custom(data.ptr(), data.size()); diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index d208bbe662e..2aad4774b0f 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -207,7 +207,7 @@ void ExportTemplateManager::_install_from_file(const String &p_file) { //read unzOpenCurrentFile(pkg); - ret = unzReadCurrentFile(pkg, data.ptr(), data.size()); + ret = unzReadCurrentFile(pkg, data.ptrw(), data.size()); unzCloseCurrentFile(pkg); String data_str; @@ -277,7 +277,7 @@ void ExportTemplateManager::_install_from_file(const String &p_file) { //read unzOpenCurrentFile(pkg); - unzReadCurrentFile(pkg, data.ptr(), data.size()); + unzReadCurrentFile(pkg, data.ptrw(), data.size()); unzCloseCurrentFile(pkg); print_line(fname); diff --git a/editor/fileserver/editor_file_server.cpp b/editor/fileserver/editor_file_server.cpp index fccf7c323ce..ad035b48f34 100644 --- a/editor/fileserver/editor_file_server.cpp +++ b/editor/fileserver/editor_file_server.cpp @@ -31,7 +31,6 @@ #include "../editor_settings.h" #include "io/marshalls.h" -#include "io/marshalls.h" //#define DEBUG_PRINT(m_p) print_line(m_p) #define DEBUG_TIME(m_what) printf("MS: %s - %lu\n", m_what, OS::get_singleton()->get_ticks_usec()); @@ -240,7 +239,7 @@ void EditorFileServer::_subthread_start(void *s) { cd->files[id]->seek(offset); Vector buf; buf.resize(blocklen); - int read = cd->files[id]->get_buffer(buf.ptr(), blocklen); + int read = cd->files[id]->get_buffer(buf.ptrw(), blocklen); ERR_CONTINUE(read < 0); print_line("GET BLOCK - offset: " + itos(offset) + ", blocklen: " + itos(blocklen)); diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index 397bb6ad68b..f704d973735 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -29,7 +29,7 @@ Error EditorSceneImporterGLTF::_parse_json(const String &p_path, GLTFState &stat Vector array; array.resize(f->get_len()); - f->get_buffer(array.ptr(), array.size()); + f->get_buffer(array.ptrw(), array.size()); String text; text.parse_utf8((const char *)array.ptr(), array.size()); @@ -65,7 +65,7 @@ Error EditorSceneImporterGLTF::_parse_glb(const String &p_path, GLTFState &state ERR_FAIL_COND_V(chunk_type != 0x4E4F534A, ERR_PARSE_ERROR); //JSON Vector json_data; json_data.resize(chunk_length); - uint32_t len = f->get_buffer(json_data.ptr(), chunk_length); + uint32_t len = f->get_buffer(json_data.ptrw(), chunk_length); ERR_FAIL_COND_V(len != chunk_length, ERR_FILE_CORRUPT); String text; @@ -94,7 +94,7 @@ Error EditorSceneImporterGLTF::_parse_glb(const String &p_path, GLTFState &state ERR_FAIL_COND_V(chunk_type != 0x004E4942, ERR_PARSE_ERROR); //BIN state.glb_data.resize(chunk_length); - len = f->get_buffer(state.glb_data.ptr(), chunk_length); + len = f->get_buffer(state.glb_data.ptrw(), chunk_length); ERR_FAIL_COND_V(len != chunk_length, ERR_FILE_CORRUPT); return OK; @@ -467,9 +467,10 @@ Error EditorSceneImporterGLTF::_decode_buffer_view(GLTFState &state, int p_buffe uint32_t offset = bv.byte_offset + byte_offset; Vector buffer = state.buffers[bv.buffer]; //copy on write, so no performance hit + const uint8_t *bufptr = buffer.ptr(); //use to debug - print_line("type " + _get_type_name(type) + " component type: " + _get_component_type_name(component_type) + " stride: " + itos(stride) + " amount " + itos(count)); + //print_line("type " + _get_type_name(type) + " component type: " + _get_component_type_name(component_type) + " stride: " + itos(stride) + " amount " + itos(count)); print_line("accessor offset" + itos(byte_offset) + " view offset: " + itos(bv.byte_offset) + " total buffer len: " + itos(buffer.size()) + " view len " + itos(bv.byte_length)); int buffer_end = (stride * (count - 1)) + element_size; @@ -481,7 +482,7 @@ Error EditorSceneImporterGLTF::_decode_buffer_view(GLTFState &state, int p_buffe for (int i = 0; i < count; i++) { - const uint8_t *src = &buffer[offset + i * stride]; + const uint8_t *src = &bufptr[offset + i * stride]; for (int j = 0; j < component_count; j++) { @@ -605,7 +606,7 @@ Vector EditorSceneImporterGLTF::_decode_accessor(GLTFState &state, int p Vector dst_buffer; dst_buffer.resize(component_count * a.count); - double *dst = dst_buffer.ptr(); + double *dst = dst_buffer.ptrw(); if (a.buffer_view >= 0) { @@ -628,13 +629,13 @@ Vector EditorSceneImporterGLTF::_decode_accessor(GLTFState &state, int p indices.resize(a.sparse_count); int indices_component_size = _get_component_type_size(a.sparse_indices_component_type); - Error err = _decode_buffer_view(state, a.sparse_indices_buffer_view, indices.ptr(), 0, 0, indices_component_size, a.sparse_count, TYPE_SCALAR, 1, a.sparse_indices_component_type, indices_component_size, false, a.sparse_indices_byte_offset, false); + Error err = _decode_buffer_view(state, a.sparse_indices_buffer_view, indices.ptrw(), 0, 0, indices_component_size, a.sparse_count, TYPE_SCALAR, 1, a.sparse_indices_component_type, indices_component_size, false, a.sparse_indices_byte_offset, false); if (err != OK) return Vector(); Vector data; data.resize(component_count * a.sparse_count); - err = _decode_buffer_view(state, a.sparse_values_buffer_view, data.ptr(), skip_every, skip_bytes, element_size, a.sparse_count, a.type, component_count, a.component_type, component_size, a.normalized, a.sparse_values_byte_offset, p_for_vertex); + err = _decode_buffer_view(state, a.sparse_values_buffer_view, data.ptrw(), skip_every, skip_bytes, element_size, a.sparse_count, a.type, component_count, a.component_type, component_size, a.normalized, a.sparse_values_byte_offset, p_for_vertex); if (err != OK) return Vector(); @@ -813,6 +814,7 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { Array meshes = state.json["meshes"]; for (int i = 0; i < meshes.size(); i++) { + print_line("on mesh: " + itos(i)); Dictionary d = meshes[i]; GLTFMesh mesh; diff --git a/editor/plugins/navigation_mesh_generator.cpp b/editor/plugins/navigation_mesh_generator.cpp index 5d50e9c8558..005a132e229 100644 --- a/editor/plugins/navigation_mesh_generator.cpp +++ b/editor/plugins/navigation_mesh_generator.cpp @@ -189,8 +189,8 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh(Ref ERR_FAIL_COND(tri_areas.size() == 0); - memset(tri_areas.ptr(), 0, ntris * sizeof(unsigned char)); - rcMarkWalkableTriangles(&ctx, cfg.walkableSlopeAngle, verts, nverts, tris, ntris, tri_areas.ptr()); + memset(tri_areas.ptrw(), 0, ntris * sizeof(unsigned char)); + rcMarkWalkableTriangles(&ctx, cfg.walkableSlopeAngle, verts, nverts, tris, ntris, tri_areas.ptrw()); ERR_FAIL_COND(!rcRasterizeTriangles(&ctx, verts, nverts, tris, tri_areas.ptr(), ntris, *hf, cfg.walkableClimb)); } diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 16b85121ef9..46c47d86564 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -383,7 +383,7 @@ private: //read unzOpenCurrentFile(pkg); - unzReadCurrentFile(pkg, data.ptr(), data.size()); + unzReadCurrentFile(pkg, data.ptrw(), data.size()); unzCloseCurrentFile(pkg); FileAccess *f = FileAccess::open(dir.plus_file(path), FileAccess::WRITE); diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp index 1e18ec0d184..ce485956b4c 100644 --- a/modules/enet/networked_multiplayer_enet.cpp +++ b/modules/enet/networked_multiplayer_enet.cpp @@ -585,7 +585,7 @@ size_t NetworkedMultiplayerENet::enet_compress(void *context, const ENetBuffer * if (enet->dst_compressor_mem.size() < req_size) { enet->dst_compressor_mem.resize(req_size); } - int ret = Compression::compress(enet->dst_compressor_mem.ptr(), enet->src_compressor_mem.ptr(), ofs, mode); + int ret = Compression::compress(enet->dst_compressor_mem.ptrw(), enet->src_compressor_mem.ptr(), ofs, mode); if (ret < 0) return 0; diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 41a810ff004..9496d0b3103 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -100,7 +100,7 @@ GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argco #endif instance->owner->set_script_instance(instance); - /* STEP 2, INITIALIZE AND CONSRTUCT */ +/* STEP 2, INITIALIZE AND CONSRTUCT */ #ifndef NO_THREADS GDScriptLanguage::singleton->lock->lock(); @@ -738,7 +738,7 @@ Error GDScript::load_byte_code(const String &p_path) { Error err = fae->open_and_parse(fa, key, FileAccessEncrypted::MODE_READ); ERR_FAIL_COND_V(err, err); bytecode.resize(fae->get_len()); - fae->get_buffer(bytecode.ptr(), bytecode.size()); + fae->get_buffer(bytecode.ptrw(), bytecode.size()); memdelete(fae); } else { @@ -1324,7 +1324,7 @@ void GDScriptLanguage::_add_global(const StringName &p_name, const Variant &p_va } globals[p_name] = global_array.size(); global_array.push_back(p_value); - _global_array = global_array.ptr(); + _global_array = global_array.ptrw(); } void GDScriptLanguage::add_global_constant(const StringName &p_variable, const Variant &p_value) { diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 5a76acea6e4..e7100d835c2 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -29,11 +29,11 @@ /*************************************************************************/ #include "gdscript.h" +#include "core/engine.h" #include "editor/editor_settings.h" #include "gdscript_compiler.h" #include "global_constants.h" #include "os/file_access.h" -#include "core/engine.h" #ifdef TOOLS_ENABLED #include "editor/editor_file_system.h" @@ -791,7 +791,7 @@ static bool _guess_expression_type(GDScriptCompletionContext &context, const GDS } Variant::CallError ce; - Variant ret = mb->call(baseptr, argptr.ptr(), argptr.size(), ce); + Variant ret = mb->call(baseptr, (const Variant **)argptr.ptr(), argptr.size(), ce); if (ce.error == Variant::CallError::CALL_OK && ret.get_type() != Variant::NIL) { @@ -1795,7 +1795,7 @@ static void _find_type_arguments(GDScriptCompletionContext &context, const GDScr } } else { - //regular method +//regular method #if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED) if (p_argidx < m->get_argument_count()) { diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index 0834bc81d9e..26f2d687d85 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -1434,7 +1434,7 @@ void VisualScriptInstance::_dependency_step(VisualScriptNodeInstance *node, int if (!node->dependencies.empty()) { int dc = node->dependencies.size(); - VisualScriptNodeInstance **deps = node->dependencies.ptr(); + VisualScriptNodeInstance **deps = node->dependencies.ptrw(); for (int i = 0; i < dc; i++) { @@ -1526,7 +1526,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p if (!node->dependencies.empty()) { int dc = node->dependencies.size(); - VisualScriptNodeInstance **deps = node->dependencies.ptr(); + VisualScriptNodeInstance **deps = node->dependencies.ptrw(); for (int i = 0; i < dc; i++) { @@ -1626,7 +1626,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p state->flow_stack_pos = flow_stack_pos; state->stack.resize(p_stack_size); state->pass = p_pass; - copymem(state->stack.ptr(), p_stack, p_stack_size); + copymem(state->stack.ptrw(), p_stack, p_stack_size); //step 2, run away, return directly r_error.error = Variant::CallError::CALL_OK; @@ -2277,7 +2277,7 @@ Variant VisualScriptFunctionState::_signal_callback(const Variant **p_args, int *working_mem = args; //arguments go to working mem. - Variant ret = instance->_call_internal(function, stack.ptr(), stack.size(), node, flow_stack_pos, pass, true, r_error); + Variant ret = instance->_call_internal(function, stack.ptrw(), stack.size(), node, flow_stack_pos, pass, true, r_error); function = StringName(); //invalidate return ret; } @@ -2319,7 +2319,7 @@ Variant VisualScriptFunctionState::resume(Array p_args) { *working_mem = p_args; //arguments go to working mem. - Variant ret = instance->_call_internal(function, stack.ptr(), stack.size(), node, flow_stack_pos, pass, true, r_error); + Variant ret = instance->_call_internal(function, stack.ptrw(), stack.size(), node, flow_stack_pos, pass, true, r_error); function = StringName(); //invalidate return ret; } diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 2318149ca59..6c58de8a5a2 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -2466,7 +2466,7 @@ VisualScriptNode::TypeGuess VisualScriptEditor::_guess_output_type(int p_port_ac in_guesses.push_back(g); } - return node->guess_output_type(in_guesses.ptr(), p_port_action_output); + return node->guess_output_type(in_guesses.ptrw(), p_port_action_output); } void VisualScriptEditor::_port_action_menu(int p_option) { diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp index 07dca4b904a..ba58a8e1c04 100644 --- a/modules/visual_script/visual_script_expression.cpp +++ b/modules/visual_script/visual_script_expression.cpp @@ -1378,7 +1378,7 @@ public: argp[i] = &arr[i]; } - r_ret = Variant::construct(constructor->data_type, argp.ptr(), argp.size(), ce); + r_ret = Variant::construct(constructor->data_type, (const Variant **)argp.ptr(), argp.size(), ce); if (ce.error != Variant::CallError::CALL_OK) { r_error_str = "Invalid arguments to construct '" + Variant::get_type_name(constructor->data_type) + "'."; @@ -1405,7 +1405,7 @@ public: argp[i] = &arr[i]; } - VisualScriptBuiltinFunc::exec_func(bifunc->func, argp.ptr(), &r_ret, ce, r_error_str); + VisualScriptBuiltinFunc::exec_func(bifunc->func, (const Variant **)argp.ptr(), &r_ret, ce, r_error_str); if (ce.error != Variant::CallError::CALL_OK) { r_error_str = "Builtin Call Failed. " + r_error_str; @@ -1437,7 +1437,7 @@ public: argp[i] = &arr[i]; } - r_ret = base.call(call->method, argp.ptr(), argp.size(), ce); + r_ret = base.call(call->method, (const Variant **)argp.ptr(), argp.size(), ce); if (ce.error != Variant::CallError::CALL_OK) { r_error_str = "On call to '" + String(call->method) + "':"; diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 3df52f16351..67e00f49526 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -1391,7 +1391,7 @@ public: //read unzOpenCurrentFile(pkg); - unzReadCurrentFile(pkg, data.ptr(), data.size()); + unzReadCurrentFile(pkg, data.ptrw(), data.size()); unzCloseCurrentFile(pkg); //write @@ -1414,7 +1414,7 @@ public: FileAccess *f = FileAccess::open(icon_path, FileAccess::READ); if (f) { data.resize(f->get_len()); - f->get_buffer(data.ptr(), data.size()); + f->get_buffer(data.ptrw(), data.size()); memdelete(f); found = true; break; @@ -1428,7 +1428,7 @@ public: FileAccess *f = FileAccess::open(appicon, FileAccess::READ); if (f) { data.resize(f->get_len()); - f->get_buffer(data.ptr(), data.size()); + f->get_buffer(data.ptrw(), data.size()); memdelete(f); } } @@ -1703,7 +1703,7 @@ public: int method, level; unzOpenCurrentFile2(tmp_unaligned, &method, &level, 1); // raw read long file_offset = unzGetCurrentFileZStreamPos64(tmp_unaligned); - unzReadCurrentFile(tmp_unaligned, data.ptr(), data.size()); + unzReadCurrentFile(tmp_unaligned, data.ptrw(), data.size()); unzCloseCurrentFile(tmp_unaligned); // align diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp index 6aa1ed9f8d6..8ab1cbc435c 100644 --- a/platform/iphone/export/export.cpp +++ b/platform/iphone/export/export.cpp @@ -793,7 +793,7 @@ Error EditorExportPlatformIOS::export_project(const Ref &p_p //read unzOpenCurrentFile(src_pkg_zip); - unzReadCurrentFile(src_pkg_zip, data.ptr(), data.size()); + unzReadCurrentFile(src_pkg_zip, data.ptrw(), data.size()); unzCloseCurrentFile(src_pkg_zip); //write diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp index 05b0fb3fbc6..775e9c7ee0c 100644 --- a/platform/javascript/export/export.cpp +++ b/platform/javascript/export/export.cpp @@ -214,7 +214,7 @@ Error EditorExportPlatformJavaScript::export_project(const Ref buf; buf.resize(f->get_len()); - f->get_buffer(buf.ptr(), buf.size()); + f->get_buffer(buf.ptrw(), buf.size()); memdelete(f); _fix_html(buf, p_preset, p_path.get_file().get_basename(), p_debug); diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index 689b79b8265..8091a38adb2 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -390,7 +390,7 @@ Error EditorExportPlatformOSX::export_project(const Ref &p_p //read unzOpenCurrentFile(src_pkg_zip); - unzReadCurrentFile(src_pkg_zip, data.ptr(), data.size()); + unzReadCurrentFile(src_pkg_zip, data.ptrw(), data.size()); unzCloseCurrentFile(src_pkg_zip); //write diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp index 120df9bc3f8..7f86b4ae53b 100644 --- a/platform/uwp/export/export.cpp +++ b/platform/uwp/export/export.cpp @@ -137,7 +137,7 @@ class AppxPackager { ZPOS64_T end_of_central_dir_offset; Vector central_dir_data; - String hash_block(uint8_t *p_block_data, size_t p_block_len); + String hash_block(const uint8_t *p_block_data, size_t p_block_len); void make_block_map(); void make_content_types(); @@ -188,14 +188,14 @@ public: /////////////////////////////////////////////////////////////////////////// -String AppxPackager::hash_block(uint8_t *p_block_data, size_t p_block_len) { +String AppxPackager::hash_block(const uint8_t *p_block_data, size_t p_block_len) { char hash[32]; char base64[45]; sha256_context ctx; sha256_init(&ctx); - sha256_hash(&ctx, p_block_data, p_block_len); + sha256_hash(&ctx, (uint8_t *)p_block_data, p_block_len); sha256_done(&ctx, (uint8_t *)hash); base64_encode(base64, hash, 32); @@ -510,8 +510,8 @@ void AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t strm.avail_in = block_size; strm.avail_out = strm_out.size(); - strm.next_in = strm_in.ptr(); - strm.next_out = strm_out.ptr(); + strm.next_in = (uint8_t *)strm_in.ptr(); + strm.next_out = strm_out.ptrw(); int total_out_before = strm.total_out; @@ -541,8 +541,8 @@ void AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t strm.avail_in = 0; strm.avail_out = strm_out.size(); - strm.next_in = strm_in.ptr(); - strm.next_out = strm_out.ptr(); + strm.next_in = (uint8_t *)strm_in.ptr(); + strm.next_out = strm_out.ptrw(); int total_out_before = strm.total_out; @@ -588,7 +588,7 @@ void AppxPackager::finish() { Vector blockmap_buffer; blockmap_buffer.resize(blockmap_file->get_len()); - blockmap_file->get_buffer(blockmap_buffer.ptr(), blockmap_buffer.size()); + blockmap_file->get_buffer(blockmap_buffer.ptrw(), blockmap_buffer.size()); add_file("AppxBlockMap.xml", blockmap_buffer.ptr(), blockmap_buffer.size(), -1, -1, true); @@ -604,7 +604,7 @@ void AppxPackager::finish() { Vector types_buffer; types_buffer.resize(types_file->get_len()); - types_file->get_buffer(types_buffer.ptr(), types_buffer.size()); + types_file->get_buffer(types_buffer.ptrw(), types_buffer.size()); add_file("[Content_Types].xml", types_buffer.ptr(), types_buffer.size(), -1, -1, true); @@ -911,7 +911,7 @@ class EditorExportUWP : public EditorExportPlatform { } data.resize(f->get_len()); - f->get_buffer(data.ptr(), data.size()); + f->get_buffer(data.ptrw(), data.size()); f->close(); memdelete(f); @@ -1301,7 +1301,7 @@ public: if (do_read) { data.resize(info.uncompressed_size); unzOpenCurrentFile(pkg); - unzReadCurrentFile(pkg, data.ptr(), data.size()); + unzReadCurrentFile(pkg, data.ptrw(), data.size()); unzCloseCurrentFile(pkg); } @@ -1341,7 +1341,7 @@ public: // Argc clf.resize(4); - encode_uint32(cl.size(), clf.ptr()); + encode_uint32(cl.size(), clf.ptrw()); for (int i = 0; i < cl.size(); i++) { diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp index 7d5044d97a1..937a026e347 100644 --- a/scene/2d/audio_stream_player_2d.cpp +++ b/scene/2d/audio_stream_player_2d.cpp @@ -21,7 +21,7 @@ void AudioStreamPlayer2D::_mix_audio() { } //get data - AudioFrame *buffer = mix_buffer.ptr(); + AudioFrame *buffer = mix_buffer.ptrw(); int buffer_size = mix_buffer.size(); //mix diff --git a/scene/2d/navigation2d.cpp b/scene/2d/navigation2d.cpp index 74d835dfb2d..9eff1078271 100644 --- a/scene/2d/navigation2d.cpp +++ b/scene/2d/navigation2d.cpp @@ -150,7 +150,7 @@ void Navigation2D::_navpoly_unlink(int p_id) { Polygon &p = E->get(); int ec = p.edges.size(); - Polygon::Edge *edges = p.edges.ptr(); + Polygon::Edge *edges = p.edges.ptrw(); for (int i = 0; i < ec; i++) { int next = (i + 1) % ec; diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index 30b7f363528..6c102e4027b 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -21,7 +21,7 @@ void AudioStreamPlayer3D::_mix_audio() { } //get data - AudioFrame *buffer = mix_buffer.ptr(); + AudioFrame *buffer = mix_buffer.ptrw(); int buffer_size = mix_buffer.size(); //mix diff --git a/scene/3d/navigation.cpp b/scene/3d/navigation.cpp index b226cca02be..b6507aedb37 100644 --- a/scene/3d/navigation.cpp +++ b/scene/3d/navigation.cpp @@ -147,7 +147,7 @@ void Navigation::_navmesh_unlink(int p_id) { Polygon &p = E->get(); int ec = p.edges.size(); - Polygon::Edge *edges = p.edges.ptr(); + Polygon::Edge *edges = p.edges.ptrw(); for (int i = 0; i < ec; i++) { int next = (i + 1) % ec; diff --git a/scene/audio/audio_player.cpp b/scene/audio/audio_player.cpp index 08b01c6a4c9..81962901d97 100644 --- a/scene/audio/audio_player.cpp +++ b/scene/audio/audio_player.cpp @@ -36,7 +36,7 @@ void AudioStreamPlayer::_mix_internal(bool p_fadeout) { int bus_index = AudioServer::get_singleton()->thread_find_bus_index(bus); //get data - AudioFrame *buffer = mix_buffer.ptr(); + AudioFrame *buffer = mix_buffer.ptrw(); int buffer_size = mix_buffer.size(); if (p_fadeout) { diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp index 1b6bd30b585..c7157d539de 100644 --- a/scene/gui/video_player.cpp +++ b/scene/gui/video_player.cpp @@ -84,7 +84,7 @@ void VideoPlayer::_mix_audio() { return; } - AudioFrame *buffer = mix_buffer.ptr(); + AudioFrame *buffer = mix_buffer.ptrw(); int buffer_size = mix_buffer.size(); // Resample diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 31d423c8083..506dc85475c 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1198,7 +1198,7 @@ void Node::_validate_child_name(Node *p_child, bool p_force_human_readable) { unique = false; } else { //check if exists - Node **childs = data.children.ptr(); + Node **childs = data.children.ptrw(); int cc = data.children.size(); for (int i = 0; i < cc; i++) { diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index d4be683a2b0..17abf2425ac 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -1001,7 +1001,7 @@ Array SceneTree::_get_nodes_in_group(const StringName &p_group) { ret.resize(nc); - Node **ptr = E->get().nodes.ptr(); + Node **ptr = E->get().nodes.ptrw(); for (int i = 0; i < nc; i++) { ret[i] = ptr[i]; @@ -1024,7 +1024,7 @@ void SceneTree::get_nodes_in_group(const StringName &p_group, List *p_li int nc = E->get().nodes.size(); if (nc == 0) return; - Node **ptr = E->get().nodes.ptr(); + Node **ptr = E->get().nodes.ptrw(); for (int i = 0; i < nc; i++) { p_list->push_back(ptr[i]); @@ -1997,9 +1997,9 @@ void SceneTree::_network_process_packet(int p_from, const uint8_t *p_packet, int Variant::CallError ce; - node->call(name, argp.ptr(), argc, ce); + node->call(name, (const Variant **)argp.ptr(), argc, ce); if (ce.error != Variant::CallError::CALL_OK) { - String error = Variant::get_call_error_text(node, name, argp.ptr(), argc, ce); + String error = Variant::get_call_error_text(node, name, (const Variant **)argp.ptr(), argc, ce); error = "RPC - " + error; ERR_PRINTS(error); } diff --git a/scene/resources/bit_mask.cpp b/scene/resources/bit_mask.cpp index 029a9ef0e8f..eebc872dfb5 100644 --- a/scene/resources/bit_mask.cpp +++ b/scene/resources/bit_mask.cpp @@ -38,7 +38,7 @@ void BitMap::create(const Size2 &p_size) { width = p_size.width; height = p_size.height; bitmask.resize(((width * height) / 8) + 1); - zeromem(bitmask.ptr(), bitmask.size()); + zeromem(bitmask.ptrw(), bitmask.size()); } void BitMap::create_from_image_alpha(const Ref &p_image) { @@ -51,7 +51,7 @@ void BitMap::create_from_image_alpha(const Ref &p_image) { create(Size2(img->get_width(), img->get_height())); PoolVector::Read r = img->get_data().read(); - uint8_t *w = bitmask.ptr(); + uint8_t *w = bitmask.ptrw(); for (int i = 0; i < width * height; i++) { @@ -65,7 +65,7 @@ void BitMap::create_from_image_alpha(const Ref &p_image) { void BitMap::set_bit_rect(const Rect2 &p_rect, bool p_value) { Rect2i current = Rect2i(0, 0, width, height).clip(p_rect); - uint8_t *data = bitmask.ptr(); + uint8_t *data = bitmask.ptrw(); for (int i = current.position.x; i < current.position.x + current.size.x; i++) { diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index 48c6add586d..a40417f24de 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -125,7 +125,7 @@ Error DynamicFontAtSize::_load() { _fontdata[font->font_path] = Vector(); Vector &fontdata = _fontdata[font->font_path]; fontdata.resize(len); - f->get_buffer(fontdata.ptr(), len); + f->get_buffer(fontdata.ptrw(), len); font->set_font_ptr(fontdata.ptr(), len); f->close(); } diff --git a/scene/resources/world.cpp b/scene/resources/world.cpp index 86b32a5cdd5..c63ba24cbd9 100644 --- a/scene/resources/world.cpp +++ b/scene/resources/world.cpp @@ -159,9 +159,9 @@ struct SpatialIndexer { Vector planes = c->get_frustum(); - int culled = octree.cull_convex(planes, cull.ptr(), cull.size()); + int culled = octree.cull_convex(planes, cull.ptrw(), cull.size()); - VisibilityNotifier **ptr = cull.ptr(); + VisibilityNotifier **ptr = cull.ptrw(); List added; List removed; diff --git a/servers/audio/effects/audio_effect_chorus.cpp b/servers/audio/effects/audio_effect_chorus.cpp index 32631beb2c2..cfcad24bb37 100644 --- a/servers/audio/effects/audio_effect_chorus.cpp +++ b/servers/audio/effects/audio_effect_chorus.cpp @@ -68,7 +68,7 @@ void AudioEffectChorusInstance::_process_chunk(const AudioFrame *p_src_frames, A unsigned int local_rb_pos = buffer_pos; AudioFrame *dst_buff = p_dst_frames; - AudioFrame *rb_buff = audio_buffer.ptr(); + AudioFrame *rb_buff = audio_buffer.ptrw(); double delay_msec = v.delay; unsigned int delay_frames = Math::fast_ftoi((delay_msec / 1000.0) * mix_rate); diff --git a/servers/audio/effects/audio_effect_delay.cpp b/servers/audio/effects/audio_effect_delay.cpp index b8a86035460..59b6a8da2a1 100644 --- a/servers/audio/effects/audio_effect_delay.cpp +++ b/servers/audio/effects/audio_effect_delay.cpp @@ -82,8 +82,8 @@ void AudioEffectDelayInstance::_process_chunk(const AudioFrame *p_src_frames, Au const AudioFrame *src = p_src_frames; AudioFrame *dst = p_dst_frames; - AudioFrame *rb_buf = ring_buffer.ptr(); - AudioFrame *fb_buf = feedback_buffer.ptr(); + AudioFrame *rb_buf = ring_buffer.ptrw(); + AudioFrame *fb_buf = feedback_buffer.ptrw(); for (int i = 0; i < p_frame_count; i++) { diff --git a/servers/audio/effects/audio_effect_eq.cpp b/servers/audio/effects/audio_effect_eq.cpp index 15905e3e0ee..dc0e00e9a3c 100644 --- a/servers/audio/effects/audio_effect_eq.cpp +++ b/servers/audio/effects/audio_effect_eq.cpp @@ -33,9 +33,9 @@ void AudioEffectEQInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) { int band_count = bands[0].size(); - EQ::BandProcess *proc_l = bands[0].ptr(); - EQ::BandProcess *proc_r = bands[1].ptr(); - float *bgain = gains.ptr(); + EQ::BandProcess *proc_l = bands[0].ptrw(); + EQ::BandProcess *proc_r = bands[1].ptrw(); + float *bgain = gains.ptrw(); for (int i = 0; i < band_count; i++) { bgain[i] = Math::db2linear(base->gain[i]); } diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index 6a10d7539db..a08733de879 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -191,7 +191,7 @@ void AudioServer::_driver_process(int p_frames, int32_t *p_buffer) { if (master->channels[k].active) { - AudioFrame *buf = master->channels[k].buffer.ptr(); + const AudioFrame *buf = master->channels[k].buffer.ptr(); for (int j = 0; j < to_copy; j++) { @@ -296,7 +296,7 @@ void AudioServer::_mix_step() { if (bus->channels[k].active && !bus->channels[k].used) { //buffer was not used, but it's still active, so it must be cleaned - AudioFrame *buf = bus->channels[k].buffer.ptr(); + AudioFrame *buf = bus->channels[k].buffer.ptrw(); for (uint32_t j = 0; j < buffer_size; j++) { @@ -316,7 +316,7 @@ void AudioServer::_mix_step() { if (!bus->channels[k].active) continue; - bus->channels[k].effect_instances[j]->process(bus->channels[k].buffer.ptr(), temp_buffer[k].ptr(), buffer_size); + bus->channels[k].effect_instances[j]->process(bus->channels[k].buffer.ptr(), temp_buffer[k].ptrw(), buffer_size); } //swap buffers, so internal buffer always has the right data @@ -350,7 +350,7 @@ void AudioServer::_mix_step() { if (!bus->channels[k].active) continue; - AudioFrame *buf = bus->channels[k].buffer.ptr(); + AudioFrame *buf = bus->channels[k].buffer.ptrw(); AudioFrame peak = AudioFrame(0, 0); @@ -414,7 +414,7 @@ AudioFrame *AudioServer::thread_get_channel_mix_buffer(int p_bus, int p_buffer) ERR_FAIL_INDEX_V(p_bus, buses.size(), NULL); ERR_FAIL_INDEX_V(p_buffer, buses[p_bus]->channels.size(), NULL); - AudioFrame *data = buses[p_bus]->channels[p_buffer].buffer.ptr(); + AudioFrame *data = buses[p_bus]->channels[p_buffer].buffer.ptrw(); if (!buses[p_bus]->channels[p_buffer].used) { buses[p_bus]->channels[p_buffer].used = true; diff --git a/servers/physics_2d_server.cpp b/servers/physics_2d_server.cpp index 829f894b87a..dc58cd36dd9 100644 --- a/servers/physics_2d_server.cpp +++ b/servers/physics_2d_server.cpp @@ -239,7 +239,7 @@ Array Physics2DDirectSpaceState::_intersect_shape(const Ref sr; sr.resize(p_max_results); - int rc = intersect_shape(p_shape_query->shape, p_shape_query->transform, p_shape_query->motion, p_shape_query->margin, sr.ptr(), sr.size(), p_shape_query->exclude, p_shape_query->collision_mask); + int rc = intersect_shape(p_shape_query->shape, p_shape_query->transform, p_shape_query->motion, p_shape_query->margin, sr.ptrw(), sr.size(), p_shape_query->exclude, p_shape_query->collision_mask); Array ret; ret.resize(rc); for (int i = 0; i < rc; i++) { @@ -278,7 +278,7 @@ Array Physics2DDirectSpaceState::_intersect_point(const Vector2 &p_point, int p_ Vector ret; ret.resize(p_max_results); - int rc = intersect_point(p_point, ret.ptr(), ret.size(), exclude, p_layers); + int rc = intersect_point(p_point, ret.ptrw(), ret.size(), exclude, p_layers); if (rc == 0) return Array(); @@ -302,7 +302,7 @@ Array Physics2DDirectSpaceState::_collide_shape(const Ref ret; ret.resize(p_max_results * 2); int rc = 0; - bool res = collide_shape(p_shape_query->shape, p_shape_query->transform, p_shape_query->motion, p_shape_query->margin, ret.ptr(), p_max_results, rc, p_shape_query->exclude, p_shape_query->collision_mask); + bool res = collide_shape(p_shape_query->shape, p_shape_query->transform, p_shape_query->motion, p_shape_query->margin, ret.ptrw(), p_max_results, rc, p_shape_query->exclude, p_shape_query->collision_mask); if (!res) return Array(); Array r; diff --git a/servers/physics_server.cpp b/servers/physics_server.cpp index 5cd90be3b71..f693622ede0 100644 --- a/servers/physics_server.cpp +++ b/servers/physics_server.cpp @@ -264,7 +264,7 @@ Array PhysicsDirectSpaceState::_intersect_shape(const Ref sr; sr.resize(p_max_results); - int rc = intersect_shape(p_shape_query->shape, p_shape_query->transform, p_shape_query->margin, sr.ptr(), sr.size(), p_shape_query->exclude, p_shape_query->collision_mask); + int rc = intersect_shape(p_shape_query->shape, p_shape_query->transform, p_shape_query->margin, sr.ptrw(), sr.size(), p_shape_query->exclude, p_shape_query->collision_mask); Array ret; ret.resize(rc); for (int i = 0; i < rc; i++) { @@ -297,7 +297,7 @@ Array PhysicsDirectSpaceState::_collide_shape(const Ref ret; ret.resize(p_max_results * 2); int rc = 0; - bool res = collide_shape(p_shape_query->shape, p_shape_query->transform, p_shape_query->margin, ret.ptr(), p_max_results, rc, p_shape_query->exclude, p_shape_query->collision_mask); + bool res = collide_shape(p_shape_query->shape, p_shape_query->transform, p_shape_query->margin, ret.ptrw(), p_max_results, rc, p_shape_query->exclude, p_shape_query->collision_mask); if (!res) return Array(); Array r; diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index 0ea32fe99ba..246a80280e4 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -3606,7 +3606,7 @@ Error ShaderLanguage::_parse_shader(const Map &p_funct uniform.default_value.resize(cn->values.size()); - if (!convert_constant(cn, uniform.type, uniform.default_value.ptr())) { + if (!convert_constant(cn, uniform.type, uniform.default_value.ptrw())) { _set_error("Can't convert constant to " + get_datatype_name(uniform.type)); return ERR_PARSE_ERROR; } diff --git a/servers/visual/visual_server_canvas.cpp b/servers/visual/visual_server_canvas.cpp index 25724981eb6..31c09dc23d5 100644 --- a/servers/visual/visual_server_canvas.cpp +++ b/servers/visual/visual_server_canvas.cpp @@ -182,7 +182,7 @@ void VisualServerCanvas::render_canvas(Canvas *p_canvas, const Transform2D &p_tr } int l = p_canvas->child_items.size(); - Canvas::ChildItem *ci = p_canvas->child_items.ptr(); + Canvas::ChildItem *ci = p_canvas->child_items.ptrw(); bool has_mirror = false; for (int i = 0; i < l; i++) { diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index 5b1eb8357dc..2f47a0ca142 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -597,7 +597,7 @@ void VisualServerScene::instance_set_custom_aabb(RID p_instance, AABB p_aabb) { ERR_FAIL_COND(!instance); ERR_FAIL_COND(!is_geometry_instance(instance->base_type)); - if(p_aabb != AABB()) { + if (p_aabb != AABB()) { // Set custom AABB if (instance->custom_aabb == NULL) @@ -1855,7 +1855,7 @@ void VisualServerScene::_setup_gi_probe(Instance *p_instance) { probe->dynamic.level_cell_lists.resize(header->cell_subdiv); - _gi_probe_fill_local_data(0, 0, 0, 0, 0, cells, header, ldw.ptr(), probe->dynamic.level_cell_lists.ptr()); + _gi_probe_fill_local_data(0, 0, 0, 0, 0, cells, header, ldw.ptr(), probe->dynamic.level_cell_lists.ptrw()); bool compress = VSG::storage->gi_probe_is_compressed(p_instance->base); diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 10f350d6671..c2b5a9a9050 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -728,7 +728,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ PoolVector::Read rb = bones.read(); PoolVector::Read rw = weights.read(); - AABB *bptr = r_bone_aabb.ptr(); + AABB *bptr = r_bone_aabb.ptrw(); for (int i = 0; i < vs; i++) {