diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-11-25 00:07:54 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-11-25 00:09:40 -0300 |
commit | bc2e8d99e5ae0dbd69e712cc71da3033f5f30139 (patch) | |
tree | d836011e3d5873e3ceea328ea3100f3c7719ab99 /servers | |
parent | 7dfba3cda9f13427f9f10a6eefbec52aef62274c (diff) |
Made Vector::ptrw explicit for writing, compiler was sometimes using the wrong function,
leading to unnecesary copy on writes and reduced performance.
Diffstat (limited to 'servers')
-rw-r--r-- | servers/audio/effects/audio_effect_chorus.cpp | 2 | ||||
-rw-r--r-- | servers/audio/effects/audio_effect_delay.cpp | 4 | ||||
-rw-r--r-- | servers/audio/effects/audio_effect_eq.cpp | 6 | ||||
-rw-r--r-- | servers/audio_server.cpp | 10 | ||||
-rw-r--r-- | servers/physics_2d_server.cpp | 6 | ||||
-rw-r--r-- | servers/physics_server.cpp | 4 | ||||
-rw-r--r-- | servers/visual/shader_language.cpp | 2 | ||||
-rw-r--r-- | servers/visual/visual_server_canvas.cpp | 2 | ||||
-rw-r--r-- | servers/visual/visual_server_scene.cpp | 4 | ||||
-rw-r--r-- | servers/visual_server.cpp | 2 |
10 files changed, 21 insertions, 21 deletions
diff --git a/servers/audio/effects/audio_effect_chorus.cpp b/servers/audio/effects/audio_effect_chorus.cpp index 32631beb2c..cfcad24bb3 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 b8a8603546..59b6a8da2a 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 15905e3e0e..dc0e00e9a3 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 6a10d7539d..a08733de87 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 829f894b87..dc58cd36dd 100644 --- a/servers/physics_2d_server.cpp +++ b/servers/physics_2d_server.cpp @@ -239,7 +239,7 @@ Array Physics2DDirectSpaceState::_intersect_shape(const Ref<Physics2DShapeQueryP Vector<ShapeResult> 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<ShapeResult> 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<Physics2DShapeQueryPar Vector<Vector2> 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 5cd90be3b7..f693622ede 100644 --- a/servers/physics_server.cpp +++ b/servers/physics_server.cpp @@ -264,7 +264,7 @@ Array PhysicsDirectSpaceState::_intersect_shape(const Ref<PhysicsShapeQueryParam Vector<ShapeResult> 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<PhysicsShapeQueryParamet Vector<Vector3> 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 0ea32fe99b..246a80280e 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -3606,7 +3606,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &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 25724981eb..31c09dc23d 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 5b1eb8357d..2f47a0ca14 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 10f350d667..c2b5a9a905 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<int>::Read rb = bones.read(); PoolVector<float>::Read rw = weights.read(); - AABB *bptr = r_bone_aabb.ptr(); + AABB *bptr = r_bone_aabb.ptrw(); for (int i = 0; i < vs; i++) { |