mirror of
https://github.com/izzy2lost/shinobu.git
synced 2026-03-26 16:50:24 -07:00
Made Vector::ptrw explicit for writing, compiler was sometimes using the wrong function,
leading to unnecesary copy on writes and reduced performance.
This commit is contained in:
+1
-1
@@ -261,7 +261,7 @@ Array &Array::sort_custom(Object *p_obj, const StringName &p_function) {
|
||||
SortArray<Variant, _ArrayVariantSortCustom> 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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<uint8_t> 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;
|
||||
|
||||
|
||||
@@ -80,11 +80,11 @@ Error FileAccessEncrypted::open_and_parse(FileAccess *p_base, const Vector<uint8
|
||||
|
||||
data.resize(ds);
|
||||
|
||||
uint32_t blen = p_base->get_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<uint8
|
||||
|
||||
MD5_CTX md5;
|
||||
MD5Init(&md5);
|
||||
MD5Update(&md5, data.ptr(), data.size());
|
||||
MD5Update(&md5, (uint8_t *)data.ptr(), data.size());
|
||||
MD5Final(&md5);
|
||||
|
||||
ERR_FAIL_COND_V(String::md5(md5.digest) != String::md5(md5d), ERR_FILE_CORRUPT);
|
||||
@@ -141,17 +141,17 @@ void FileAccessEncrypted::close() {
|
||||
|
||||
MD5_CTX md5;
|
||||
MD5Init(&md5);
|
||||
MD5Update(&md5, data.ptr(), data.size());
|
||||
MD5Update(&md5, (uint8_t *)data.ptr(), data.size());
|
||||
MD5Final(&md5);
|
||||
|
||||
compressed.resize(len);
|
||||
zeromem(compressed.ptr(), len);
|
||||
zeromem(compressed.ptrw(), len);
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
compressed[i] = data[i];
|
||||
}
|
||||
|
||||
aes256_context ctx;
|
||||
aes256_init(&ctx, key.ptr());
|
||||
aes256_init(&ctx, key.ptrw());
|
||||
|
||||
for (size_t i = 0; i < len; i += 16) {
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ void FileAccessNetworkClient::_thread_func() {
|
||||
|
||||
Vector<uint8_t> 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;
|
||||
}
|
||||
|
||||
@@ -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<uint8_t> 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<uint8_t> 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;
|
||||
|
||||
+2
-2
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -481,7 +481,7 @@ Vector<uint8_t> FileAccess::get_file_as_array(const String &p_path) {
|
||||
ERR_FAIL_COND_V(!f, Vector<uint8_t>());
|
||||
Vector<uint8_t> data;
|
||||
data.resize(f->get_len());
|
||||
f->get_buffer(data.ptr(), data.size());
|
||||
f->get_buffer(data.ptrw(), data.size());
|
||||
memdelete(f);
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -429,7 +429,7 @@ Error ProjectSettings::_load_settings_binary(const String p_path) {
|
||||
uint32_t vlen = f->get_32();
|
||||
Vector<uint8_t> 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);
|
||||
|
||||
@@ -212,7 +212,7 @@ void ScriptDebuggerLocal::idle_poll() {
|
||||
}
|
||||
|
||||
SortArray<ScriptLanguage::ProfilingInfo, _ScriptDebuggerLocalProfileInfoSort> sort;
|
||||
sort.sort(pinfo.ptr(), ofs);
|
||||
sort.sort(pinfo.ptrw(), ofs);
|
||||
|
||||
//falta el frame time
|
||||
|
||||
@@ -264,7 +264,7 @@ void ScriptDebuggerLocal::profiling_end() {
|
||||
}
|
||||
|
||||
SortArray<ScriptLanguage::ProfilingInfo, _ScriptDebuggerLocalProfileInfoSort> sort;
|
||||
sort.sort(pinfo.ptr(), ofs);
|
||||
sort.sort(pinfo.ptrw(), ofs);
|
||||
|
||||
uint64_t total_us = 0;
|
||||
for (int i = 0; i < ofs; i++) {
|
||||
|
||||
@@ -749,7 +749,7 @@ void ScriptDebuggerRemote::_send_profiling_data(bool p_for_frame) {
|
||||
}
|
||||
|
||||
SortArray<ScriptLanguage::ProfilingInfo *, ProfileInfoSort> sa;
|
||||
sa.sort(profile_info_ptrs.ptr(), ofs);
|
||||
sa.sort(profile_info_ptrs.ptrw(), ofs);
|
||||
|
||||
int to_send = MIN(ofs, max_frame_functions);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -40,7 +40,7 @@ class StringBuffer {
|
||||
int string_length = 0;
|
||||
|
||||
_FORCE_INLINE_ CharType *current_buffer_ptr() {
|
||||
return static_cast<Vector<CharType> &>(buffer).empty() ? short_buffer : buffer.ptr();
|
||||
return static_cast<Vector<CharType> &>(buffer).empty() ? short_buffer : buffer.ptrw();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
+2
-2
@@ -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 {
|
||||
|
||||
@@ -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();
|
||||
|
||||
+2
-2
@@ -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 <class T>
|
||||
void Vector<T>::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++) {
|
||||
|
||||
|
||||
@@ -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++) {
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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++) {
|
||||
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user