diff options
Diffstat (limited to 'drivers')
25 files changed, 303 insertions, 330 deletions
diff --git a/drivers/alsamidi/midi_driver_alsamidi.cpp b/drivers/alsamidi/midi_driver_alsamidi.cpp index 6121a44b36..670d7e0a4a 100644 --- a/drivers/alsamidi/midi_driver_alsamidi.cpp +++ b/drivers/alsamidi/midi_driver_alsamidi.cpp @@ -189,9 +189,9 @@ void MIDIDriverALSAMidi::unlock() const { mutex->unlock(); } -PoolStringArray MIDIDriverALSAMidi::get_connected_inputs() { +PackedStringArray MIDIDriverALSAMidi::get_connected_inputs() { - PoolStringArray list; + PackedStringArray list; lock(); for (int i = 0; i < connected_inputs.size(); i++) { diff --git a/drivers/alsamidi/midi_driver_alsamidi.h b/drivers/alsamidi/midi_driver_alsamidi.h index 354fcce147..9900d90553 100644 --- a/drivers/alsamidi/midi_driver_alsamidi.h +++ b/drivers/alsamidi/midi_driver_alsamidi.h @@ -59,7 +59,7 @@ public: virtual Error open(); virtual void close(); - virtual PoolStringArray get_connected_inputs(); + virtual PackedStringArray get_connected_inputs(); MIDIDriverALSAMidi(); virtual ~MIDIDriverALSAMidi(); diff --git a/drivers/coremidi/midi_driver_coremidi.cpp b/drivers/coremidi/midi_driver_coremidi.cpp index 99628c7fe3..d807896e61 100644 --- a/drivers/coremidi/midi_driver_coremidi.cpp +++ b/drivers/coremidi/midi_driver_coremidi.cpp @@ -93,9 +93,9 @@ void MIDIDriverCoreMidi::close() { } } -PoolStringArray MIDIDriverCoreMidi::get_connected_inputs() { +PackedStringArray MIDIDriverCoreMidi::get_connected_inputs() { - PoolStringArray list; + PackedStringArray list; for (int i = 0; i < connected_sources.size(); i++) { MIDIEndpointRef source = connected_sources[i]; diff --git a/drivers/coremidi/midi_driver_coremidi.h b/drivers/coremidi/midi_driver_coremidi.h index f32644e80c..e8b4481c20 100644 --- a/drivers/coremidi/midi_driver_coremidi.h +++ b/drivers/coremidi/midi_driver_coremidi.h @@ -52,7 +52,7 @@ public: virtual Error open(); virtual void close(); - PoolStringArray get_connected_inputs(); + PackedStringArray get_connected_inputs(); MIDIDriverCoreMidi(); virtual ~MIDIDriverCoreMidi(); diff --git a/drivers/dummy/audio_driver_dummy.h b/drivers/dummy/audio_driver_dummy.h deleted file mode 100644 index 6e39df9e2f..0000000000 --- a/drivers/dummy/audio_driver_dummy.h +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************/ -/* audio_driver_dummy.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef AUDIO_DRIVER_DUMMY_H -#define AUDIO_DRIVER_DUMMY_H - -#include "core/os/mutex.h" -#include "core/os/thread.h" -#include "servers/audio_server.h" - -class AudioDriverDummy : public AudioDriver { -public: - const char *get_name() const { - return "Dummy"; - }; - - virtual Error init() { return OK; } - virtual void start(){}; - virtual int get_mix_rate() const { return DEFAULT_MIX_RATE; }; - virtual SpeakerMode get_speaker_mode() const { return SPEAKER_MODE_STEREO; }; - virtual void lock(){}; - virtual void unlock(){}; - virtual void finish(){}; - - virtual float get_latency() { return 0; }; - - AudioDriverDummy(){}; - ~AudioDriverDummy(){}; -}; - -#endif // AUDIO_DRIVER_DUMMY_H diff --git a/drivers/dummy/rasterizer_dummy.h b/drivers/dummy/rasterizer_dummy.h index 990a0dc455..fb23370863 100644 --- a/drivers/dummy/rasterizer_dummy.h +++ b/drivers/dummy/rasterizer_dummy.h @@ -134,12 +134,12 @@ public: struct DummySurface { uint32_t format; VS::PrimitiveType primitive; - PoolVector<uint8_t> array; + Vector<uint8_t> array; int vertex_count; - PoolVector<uint8_t> index_array; + Vector<uint8_t> index_array; int index_count; AABB aabb; - Vector<PoolVector<uint8_t> > blend_shapes; + Vector<Vector<uint8_t> > blend_shapes; Vector<AABB> bone_aabbs; }; @@ -295,7 +295,7 @@ public: return mesh_owner.make_rid(mesh); } - void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()) { + void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t> > &p_blend_shapes = Vector<Vector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()) { DummyMesh *m = mesh_owner.getornull(p_mesh); ERR_FAIL_COND(!m); @@ -334,7 +334,7 @@ public: return m->blend_shape_mode; } - void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data) {} + void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data) {} void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) {} RID mesh_surface_get_material(RID p_mesh, int p_surface) const { return RID(); } @@ -352,15 +352,15 @@ public: return m->surfaces[p_surface].index_count; } - PoolVector<uint8_t> mesh_surface_get_array(RID p_mesh, int p_surface) const { + Vector<uint8_t> mesh_surface_get_array(RID p_mesh, int p_surface) const { DummyMesh *m = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!m, PoolVector<uint8_t>()); + ERR_FAIL_COND_V(!m, Vector<uint8_t>()); return m->surfaces[p_surface].array; } - PoolVector<uint8_t> mesh_surface_get_index_array(RID p_mesh, int p_surface) const { + Vector<uint8_t> mesh_surface_get_index_array(RID p_mesh, int p_surface) const { DummyMesh *m = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!m, PoolVector<uint8_t>()); + ERR_FAIL_COND_V(!m, Vector<uint8_t>()); return m->surfaces[p_surface].index_array; } @@ -384,9 +384,9 @@ public: return m->surfaces[p_surface].aabb; } - Vector<PoolVector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const { + Vector<Vector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const { DummyMesh *m = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!m, Vector<PoolVector<uint8_t> >()); + ERR_FAIL_COND_V(!m, Vector<Vector<uint8_t> >()); return m->surfaces[p_surface].blend_shapes; } @@ -436,7 +436,7 @@ public: Color multimesh_instance_get_color(RID p_multimesh, int p_index) const { return Color(); } Color multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const { return Color(); } - void multimesh_set_as_bulk_array(RID p_multimesh, const PoolVector<float> &p_array) {} + void multimesh_set_as_bulk_array(RID p_multimesh, const Vector<float> &p_array) {} void multimesh_set_visible_instances(RID p_multimesh, int p_visible) {} int multimesh_get_visible_instances(RID p_multimesh) const { return 0; } @@ -555,9 +555,9 @@ public: void gi_probe_set_to_cell_xform(RID p_probe, const Transform &p_xform) {} Transform gi_probe_get_to_cell_xform(RID p_probe) const { return Transform(); } - void gi_probe_set_dynamic_data(RID p_probe, const PoolVector<int> &p_data) {} - PoolVector<int> gi_probe_get_dynamic_data(RID p_probe) const { - PoolVector<int> p; + void gi_probe_set_dynamic_data(RID p_probe, const Vector<int> &p_data) {} + Vector<int> gi_probe_get_dynamic_data(RID p_probe) const { + Vector<int> p; return p; } @@ -620,7 +620,7 @@ public: struct LightmapCapture : public Instantiable { - PoolVector<LightmapCaptureOctree> octree; + Vector<LightmapCaptureOctree> octree; AABB bounds; Transform cell_xform; int cell_subdiv; @@ -634,15 +634,15 @@ public: mutable RID_PtrOwner<LightmapCapture> lightmap_capture_data_owner; void lightmap_capture_set_bounds(RID p_capture, const AABB &p_bounds) {} AABB lightmap_capture_get_bounds(RID p_capture) const { return AABB(); } - void lightmap_capture_set_octree(RID p_capture, const PoolVector<uint8_t> &p_octree) {} + void lightmap_capture_set_octree(RID p_capture, const Vector<uint8_t> &p_octree) {} RID lightmap_capture_create() { LightmapCapture *capture = memnew(LightmapCapture); return lightmap_capture_data_owner.make_rid(capture); } - PoolVector<uint8_t> lightmap_capture_get_octree(RID p_capture) const { + Vector<uint8_t> lightmap_capture_get_octree(RID p_capture) const { const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture); - ERR_FAIL_COND_V(!capture, PoolVector<uint8_t>()); - return PoolVector<uint8_t>(); + ERR_FAIL_COND_V(!capture, Vector<uint8_t>()); + return Vector<uint8_t>(); } void lightmap_capture_set_octree_cell_transform(RID p_capture, const Transform &p_xform) {} Transform lightmap_capture_get_octree_cell_transform(RID p_capture) const { return Transform(); } @@ -650,7 +650,7 @@ public: int lightmap_capture_get_octree_cell_subdiv(RID p_capture) const { return 0; } void lightmap_capture_set_energy(RID p_capture, float p_energy) {} float lightmap_capture_get_energy(RID p_capture) const { return 0.0; } - const PoolVector<LightmapCaptureOctree> *lightmap_capture_get_octree_ptr(RID p_capture) const { + const Vector<LightmapCaptureOctree> *lightmap_capture_get_octree_ptr(RID p_capture) const { const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture); ERR_FAIL_COND_V(!capture, NULL); return &capture->octree; @@ -711,7 +711,7 @@ public: /* LIGHT SHADOW MAPPING */ RID canvas_light_occluder_create() { return RID(); } - void canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2> &p_lines) {} + void canvas_light_occluder_set_polylines(RID p_occluder, const Vector<Vector2> &p_lines) {} VS::InstanceType get_base_type(RID p_rid) const { if (mesh_owner.owns(p_rid)) { diff --git a/drivers/dummy/texture_loader_dummy.cpp b/drivers/dummy/texture_loader_dummy.cpp index bf51d76527..aff7bbd1bc 100644 --- a/drivers/dummy/texture_loader_dummy.cpp +++ b/drivers/dummy/texture_loader_dummy.cpp @@ -43,7 +43,7 @@ RES ResourceFormatDummyTexture::load(const String &p_path, const String &p_origi Image::Format fmt = Image::FORMAT_RGB8; int rowsize = 3 * width; - PoolVector<uint8_t> dstbuff; + Vector<uint8_t> dstbuff; dstbuff.resize(rowsize * height); diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp index 2e35bd0ccf..c433886545 100644 --- a/drivers/gles2/rasterizer_scene_gles2.cpp +++ b/drivers/gles2/rasterizer_scene_gles2.cpp @@ -1500,7 +1500,7 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste //use transform buffer workflow ERR_FAIL_COND(p_skeleton->use_2d); - PoolVector<float> &transform_buffer = storage->resources.skeleton_transform_cpu_buffer; + Vector<float> &transform_buffer = storage->resources.skeleton_transform_cpu_buffer; if (!s->attribs[VS::ARRAY_BONES].enabled || !s->attribs[VS::ARRAY_WEIGHTS].enabled) { break; // the whole instance has a skeleton, but this surface is not affected by it. @@ -1517,10 +1517,10 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste const size_t bone_weight_stride = s->attribs[VS::ARRAY_WEIGHTS].stride; { - PoolVector<float>::Write write = transform_buffer.write(); + float *write = transform_buffer.ptrw(); float *buffer = write.ptr(); - PoolVector<uint8_t>::Read vertex_array_read = s->data.read(); + const uint8_t *vertex_array_read = s->data.ptr(); const uint8_t *vertex_data = vertex_array_read.ptr(); for (int i = 0; i < s->array_len; i++) { diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp index 245531a935..55b1c7e560 100644 --- a/drivers/gles2/rasterizer_storage_gles2.cpp +++ b/drivers/gles2/rasterizer_storage_gles2.cpp @@ -750,7 +750,7 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p } texture->data_size = img->get_data().size(); - PoolVector<uint8_t>::Read read = img->get_data().read(); + const uint8_t *read = img->get_data().ptr(); ERR_FAIL_COND(!read.ptr()); glActiveTexture(GL_TEXTURE0); @@ -888,12 +888,12 @@ Ref<Image> RasterizerStorageGLES2::texture_get_data(RID p_texture, int p_layer) bool compressed; _get_gl_image_and_format(Ref<Image>(), texture->format, texture->flags, real_format, gl_format, gl_internal_format, gl_type, compressed, false); - PoolVector<uint8_t> data; + Vector<uint8_t> data; int data_size = Image::get_image_data_size(texture->alloc_width, texture->alloc_height, real_format, texture->mipmaps > 1); data.resize(data_size * 2); //add some memory at the end, just in case for buggy drivers - PoolVector<uint8_t>::Write wb = data.write(); + uint8_t *wb = data.ptrw(); glActiveTexture(GL_TEXTURE0); @@ -930,12 +930,12 @@ Ref<Image> RasterizerStorageGLES2::texture_get_data(RID p_texture, int p_layer) bool compressed; _get_gl_image_and_format(Ref<Image>(), texture->format, texture->flags, real_format, gl_format, gl_internal_format, gl_type, compressed, texture->resize_to_po2); - PoolVector<uint8_t> data; + Vector<uint8_t> data; int data_size = Image::get_image_data_size(texture->alloc_width, texture->alloc_height, Image::FORMAT_RGBA8, false); data.resize(data_size * 2); //add some memory at the end, just in case for buggy drivers - PoolVector<uint8_t>::Write wb = data.write(); + uint8_t *wb = data.ptrw(); GLuint temp_framebuffer; glGenFramebuffers(1, &temp_framebuffer); @@ -1681,11 +1681,11 @@ void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, List<PropertyIn case ShaderLanguage::TYPE_UVEC3: case ShaderLanguage::TYPE_IVEC4: case ShaderLanguage::TYPE_UVEC4: { - pi.type = Variant::POOL_INT_ARRAY; + pi.type = Variant::PACKED_INT32_ARRAY; } break; case ShaderLanguage::TYPE_FLOAT: { - pi.type = Variant::REAL; + pi.type = Variant::FLOAT; if (u.hint == ShaderLanguage::ShaderNode::Uniform::HINT_RANGE) { pi.hint = PROPERTY_HINT_RANGE; pi.hint_string = rtos(u.hint_range[0]) + "," + rtos(u.hint_range[1]) + "," + rtos(u.hint_range[2]); @@ -2081,7 +2081,7 @@ RID RasterizerStorageGLES2::mesh_create() { return mesh_owner.make_rid(mesh); } -static PoolVector<uint8_t> _unpack_half_floats(const PoolVector<uint8_t> &array, uint32_t &format, int p_vertices) { +static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_t &format, int p_vertices) { uint32_t p_format = format; @@ -2223,11 +2223,11 @@ static PoolVector<uint8_t> _unpack_half_floats(const PoolVector<uint8_t> &array, dst_stride += dst_size[i]; } - PoolVector<uint8_t> ret; + Vector<uint8_t> ret; ret.resize(p_vertices * dst_stride); - PoolVector<uint8_t>::Read r = array.read(); - PoolVector<uint8_t>::Write w = ret.write(); + const uint8_t *r = array.ptr(); + uint8_t *w = ret.ptrw(); int src_offset = 0; int dst_offset = 0; @@ -2270,7 +2270,7 @@ static PoolVector<uint8_t> _unpack_half_floats(const PoolVector<uint8_t> &array, return ret; } -void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes, const Vector<AABB> &p_bone_aabbs) { +void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t> > &p_blend_shapes, const Vector<AABB> &p_bone_aabbs) { Mesh *mesh = mesh_owner.getornull(p_mesh); ERR_FAIL_COND(!mesh); @@ -2457,18 +2457,18 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS: } //validate sizes - PoolVector<uint8_t> array = p_array; + Vector<uint8_t> array = p_array; int array_size = stride * p_vertex_count; int index_array_size = 0; if (array.size() != array_size && array.size() + p_vertex_count * 2 == array_size) { //old format, convert - array = PoolVector<uint8_t>(); + array = Vector<uint8_t>(); array.resize(p_array.size() + p_vertex_count * 2); - PoolVector<uint8_t>::Write w = array.write(); - PoolVector<uint8_t>::Read r = p_array.read(); + uint8_t *w = array.ptrw(); + const uint8_t *r = p_array.ptr(); uint16_t *w16 = (uint16_t *)w.ptr(); const uint16_t *r16 = (uint16_t *)r.ptr(); @@ -2492,7 +2492,7 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS: if (!config.support_half_float_vertices && uses_half_float) { uint32_t new_format = p_format; - PoolVector<uint8_t> unpacked_array = _unpack_half_floats(array, new_format, p_vertex_count); + Vector<uint8_t> unpacked_array = _unpack_half_floats(array, new_format, p_vertex_count); mesh_add_surface(p_mesh, new_format, p_primitive, unpacked_array, p_vertex_count, p_index_array, p_index_count, p_aabb, p_blend_shapes, p_bone_aabbs); return; //do not go any further, above function used unpacked stuff will be used instead. @@ -2549,7 +2549,7 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS: // Okay, now the OpenGL stuff, wheeeeey \o/ { - PoolVector<uint8_t>::Read vr = array.read(); + const uint8_t *vr = array.ptr(); glGenBuffers(1, &surface->vertex_id); glBindBuffer(GL_ARRAY_BUFFER, surface->vertex_id); @@ -2558,7 +2558,7 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS: glBindBuffer(GL_ARRAY_BUFFER, 0); if (p_format & VS::ARRAY_FORMAT_INDEX) { - PoolVector<uint8_t>::Read ir = p_index_array.read(); + const uint8_t *ir = p_index_array.ptr(); glGenBuffers(1, &surface->index_id); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, surface->index_id); @@ -2578,7 +2578,7 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS: Surface::BlendShape mt; - PoolVector<uint8_t>::Read vr = p_blend_shapes[i].read(); + const uint8_t *vr = p_blend_shapes[i].ptr(); surface->total_data_size += array_size; @@ -2628,7 +2628,7 @@ VS::BlendShapeMode RasterizerStorageGLES2::mesh_get_blend_shape_mode(RID p_mesh) return mesh->blend_shape_mode; } -void RasterizerStorageGLES2::mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data) { +void RasterizerStorageGLES2::mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data) { Mesh *mesh = mesh_owner.getornull(p_mesh); ERR_FAIL_COND(!mesh); @@ -2637,7 +2637,7 @@ void RasterizerStorageGLES2::mesh_surface_update_region(RID p_mesh, int p_surfac int total_size = p_data.size(); ERR_FAIL_COND(p_offset + total_size > mesh->surfaces[p_surface]->array_byte_size); - PoolVector<uint8_t>::Read r = p_data.read(); + const uint8_t *r = p_data.ptr(); glBindBuffer(GL_ARRAY_BUFFER, mesh->surfaces[p_surface]->vertex_id); glBufferSubData(GL_ARRAY_BUFFER, p_offset, total_size, r.ptr()); @@ -2689,11 +2689,11 @@ int RasterizerStorageGLES2::mesh_surface_get_array_index_len(RID p_mesh, int p_s return mesh->surfaces[p_surface]->index_array_len; } -PoolVector<uint8_t> RasterizerStorageGLES2::mesh_surface_get_array(RID p_mesh, int p_surface) const { +Vector<uint8_t> RasterizerStorageGLES2::mesh_surface_get_array(RID p_mesh, int p_surface) const { const Mesh *mesh = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!mesh, PoolVector<uint8_t>()); - ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), PoolVector<uint8_t>()); + ERR_FAIL_COND_V(!mesh, Vector<uint8_t>()); + ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Vector<uint8_t>()); Surface *surface = mesh->surfaces[p_surface]; #ifndef TOOLS_ENABLED @@ -2702,10 +2702,10 @@ PoolVector<uint8_t> RasterizerStorageGLES2::mesh_surface_get_array(RID p_mesh, i return surface->data; } -PoolVector<uint8_t> RasterizerStorageGLES2::mesh_surface_get_index_array(RID p_mesh, int p_surface) const { +Vector<uint8_t> RasterizerStorageGLES2::mesh_surface_get_index_array(RID p_mesh, int p_surface) const { const Mesh *mesh = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!mesh, PoolVector<uint8_t>()); - ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), PoolVector<uint8_t>()); + ERR_FAIL_COND_V(!mesh, Vector<uint8_t>()); + ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Vector<uint8_t>()); Surface *surface = mesh->surfaces[p_surface]; @@ -2737,10 +2737,10 @@ AABB RasterizerStorageGLES2::mesh_surface_get_aabb(RID p_mesh, int p_surface) co return mesh->surfaces[p_surface]->aabb; } -Vector<PoolVector<uint8_t> > RasterizerStorageGLES2::mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const { +Vector<Vector<uint8_t> > RasterizerStorageGLES2::mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const { const Mesh *mesh = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!mesh, Vector<PoolVector<uint8_t> >()); - ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Vector<PoolVector<uint8_t> >()); + ERR_FAIL_COND_V(!mesh, Vector<Vector<uint8_t> >()); + ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Vector<Vector<uint8_t> >()); #ifndef TOOLS_ENABLED ERR_PRINT("OpenGL ES 2.0 does not allow retrieving mesh array data"); #endif @@ -3332,7 +3332,7 @@ Color RasterizerStorageGLES2::multimesh_instance_get_custom_data(RID p_multimesh return Color(); } -void RasterizerStorageGLES2::multimesh_set_as_bulk_array(RID p_multimesh, const PoolVector<float> &p_array) { +void RasterizerStorageGLES2::multimesh_set_as_bulk_array(RID p_multimesh, const Vector<float> &p_array) { MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh); ERR_FAIL_COND(!multimesh); ERR_FAIL_COND(!multimesh->data.ptr()); @@ -3341,7 +3341,7 @@ void RasterizerStorageGLES2::multimesh_set_as_bulk_array(RID p_multimesh, const ERR_FAIL_COND(dsize != p_array.size()); - PoolVector<float>::Read r = p_array.read(); + const float *r = p_array.ptr(); ERR_FAIL_COND(!r.ptr()); copymem(multimesh->data.ptrw(), r.ptr(), dsize * sizeof(float)); @@ -3767,7 +3767,7 @@ void RasterizerStorageGLES2::skeleton_set_base_transform_2d(RID p_skeleton, cons skeleton->base_transform_2d = p_base_transform; } -void RasterizerStorageGLES2::_update_skeleton_transform_buffer(const PoolVector<float> &p_data, size_t p_size) { +void RasterizerStorageGLES2::_update_skeleton_transform_buffer(const Vector<float> &p_data, size_t p_size) { glBindBuffer(GL_ARRAY_BUFFER, resources.skeleton_transform_buffer); @@ -3776,9 +3776,9 @@ void RasterizerStorageGLES2::_update_skeleton_transform_buffer(const PoolVector< resources.skeleton_transform_buffer_size = p_size; - glBufferData(GL_ARRAY_BUFFER, p_size * sizeof(float), p_data.read().ptr(), GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, p_size * sizeof(float), p_data.ptr(), GL_DYNAMIC_DRAW); } else { - glBufferSubData(GL_ARRAY_BUFFER, 0, p_size * sizeof(float), p_data.read().ptr()); + glBufferSubData(GL_ARRAY_BUFFER, 0, p_size * sizeof(float), p_data.ptr()); } glBindBuffer(GL_ARRAY_BUFFER, 0); @@ -4298,11 +4298,11 @@ Transform RasterizerStorageGLES2::gi_probe_get_to_cell_xform(RID p_probe) const return Transform(); } -void RasterizerStorageGLES2::gi_probe_set_dynamic_data(RID p_probe, const PoolVector<int> &p_data) { +void RasterizerStorageGLES2::gi_probe_set_dynamic_data(RID p_probe, const Vector<int> &p_data) { } -PoolVector<int> RasterizerStorageGLES2::gi_probe_get_dynamic_data(RID p_probe) const { - return PoolVector<int>(); +Vector<int> RasterizerStorageGLES2::gi_probe_get_dynamic_data(RID p_probe) const { + return Vector<int>(); } void RasterizerStorageGLES2::gi_probe_set_dynamic_range(RID p_probe, int p_range) { @@ -4389,7 +4389,7 @@ AABB RasterizerStorageGLES2::lightmap_capture_get_bounds(RID p_capture) const { ERR_FAIL_COND_V(!capture, AABB()); return capture->bounds; } -void RasterizerStorageGLES2::lightmap_capture_set_octree(RID p_capture, const PoolVector<uint8_t> &p_octree) { +void RasterizerStorageGLES2::lightmap_capture_set_octree(RID p_capture, const Vector<uint8_t> &p_octree) { LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture); ERR_FAIL_COND(!capture); @@ -4398,25 +4398,25 @@ void RasterizerStorageGLES2::lightmap_capture_set_octree(RID p_capture, const Po capture->octree.resize(p_octree.size() / sizeof(LightmapCaptureOctree)); if (p_octree.size()) { - PoolVector<LightmapCaptureOctree>::Write w = capture->octree.write(); - PoolVector<uint8_t>::Read r = p_octree.read(); + LightmapCaptureOctree *w = capture->octree.ptrw(); + const uint8_t *r = p_octree.ptr(); copymem(w.ptr(), r.ptr(), p_octree.size()); } capture->instance_change_notify(true, false); } -PoolVector<uint8_t> RasterizerStorageGLES2::lightmap_capture_get_octree(RID p_capture) const { +Vector<uint8_t> RasterizerStorageGLES2::lightmap_capture_get_octree(RID p_capture) const { const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture); - ERR_FAIL_COND_V(!capture, PoolVector<uint8_t>()); + ERR_FAIL_COND_V(!capture, Vector<uint8_t>()); if (capture->octree.size() == 0) - return PoolVector<uint8_t>(); + return Vector<uint8_t>(); - PoolVector<uint8_t> ret; + Vector<uint8_t> ret; ret.resize(capture->octree.size() * sizeof(LightmapCaptureOctree)); { - PoolVector<LightmapCaptureOctree>::Read r = capture->octree.read(); - PoolVector<uint8_t>::Write w = ret.write(); + const LightmapCaptureOctree *r = capture->octree.ptr(); + uint8_t *w = ret.ptrw(); copymem(w.ptr(), r.ptr(), ret.size()); } @@ -4461,7 +4461,7 @@ float RasterizerStorageGLES2::lightmap_capture_get_energy(RID p_capture) const { return capture->energy; } -const PoolVector<RasterizerStorage::LightmapCaptureOctree> *RasterizerStorageGLES2::lightmap_capture_get_octree_ptr(RID p_capture) const { +const Vector<RasterizerStorage::LightmapCaptureOctree> *RasterizerStorageGLES2::lightmap_capture_get_octree_ptr(RID p_capture) const { const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture); ERR_FAIL_COND_V(!capture, NULL); return &capture->octree; @@ -5449,7 +5449,7 @@ RID RasterizerStorageGLES2::canvas_light_occluder_create() { return canvas_occluder_owner.make_rid(co); } -void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2> &p_lines) { +void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder, const Vector<Vector2> &p_lines) { CanvasOccluder *co = canvas_occluder_owner.getornull(p_occluder); ERR_FAIL_COND(!co); @@ -5470,17 +5470,17 @@ void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder, if (p_lines.size()) { - PoolVector<float> geometry; - PoolVector<uint16_t> indices; + Vector<float> geometry; + Vector<uint16_t> indices; int lc = p_lines.size(); geometry.resize(lc * 6); indices.resize(lc * 3); - PoolVector<float>::Write vw = geometry.write(); - PoolVector<uint16_t>::Write iw = indices.write(); + float *vw = geometry.ptrw(); + uint16_t *iw = indices.ptrw(); - PoolVector<Vector2>::Read lr = p_lines.read(); + const Vector2 *lr = p_lines.ptr(); const int POLY_HEIGHT = 16384; diff --git a/drivers/gles2/rasterizer_storage_gles2.h b/drivers/gles2/rasterizer_storage_gles2.h index a6aae400ca..6fbfe57778 100644 --- a/drivers/gles2/rasterizer_storage_gles2.h +++ b/drivers/gles2/rasterizer_storage_gles2.h @@ -31,7 +31,6 @@ #ifndef RASTERIZERSTORAGEGLES2_H #define RASTERIZERSTORAGEGLES2_H -#include "core/pool_vector.h" #include "core/self_list.h" #include "servers/visual/rasterizer.h" #include "servers/visual/shader_language.h" @@ -125,7 +124,7 @@ public: size_t skeleton_transform_buffer_size; GLuint skeleton_transform_buffer; - PoolVector<float> skeleton_transform_cpu_buffer; + Vector<float> skeleton_transform_cpu_buffer; } resources; @@ -649,9 +648,9 @@ public: bool active; - PoolVector<uint8_t> data; - PoolVector<uint8_t> index_data; - Vector<PoolVector<uint8_t> > blend_shape_data; + Vector<uint8_t> data; + Vector<uint8_t> index_data; + Vector<Vector<uint8_t> > blend_shape_data; int total_data_size; @@ -703,7 +702,7 @@ public: virtual RID mesh_create(); - virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()); + virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t> > &p_blend_shapes = Vector<Vector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()); virtual void mesh_set_blend_shape_count(RID p_mesh, int p_amount); virtual int mesh_get_blend_shape_count(RID p_mesh) const; @@ -711,7 +710,7 @@ public: virtual void mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode); virtual VS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const; - virtual void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data); + virtual void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data); virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material); virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const; @@ -719,14 +718,14 @@ public: virtual int mesh_surface_get_array_len(RID p_mesh, int p_surface) const; virtual int mesh_surface_get_array_index_len(RID p_mesh, int p_surface) const; - virtual PoolVector<uint8_t> mesh_surface_get_array(RID p_mesh, int p_surface) const; - virtual PoolVector<uint8_t> mesh_surface_get_index_array(RID p_mesh, int p_surface) const; + virtual Vector<uint8_t> mesh_surface_get_array(RID p_mesh, int p_surface) const; + virtual Vector<uint8_t> mesh_surface_get_index_array(RID p_mesh, int p_surface) const; virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const; virtual VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const; virtual AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const; - virtual Vector<PoolVector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const; + virtual Vector<Vector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const; virtual Vector<AABB> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const; virtual void mesh_remove_surface(RID p_mesh, int p_surface); @@ -803,7 +802,7 @@ public: virtual Color multimesh_instance_get_color(RID p_multimesh, int p_index) const; virtual Color multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const; - virtual void multimesh_set_as_bulk_array(RID p_multimesh, const PoolVector<float> &p_array); + virtual void multimesh_set_as_bulk_array(RID p_multimesh, const Vector<float> &p_array); virtual void multimesh_set_visible_instances(RID p_multimesh, int p_visible); virtual int multimesh_get_visible_instances(RID p_multimesh) const; @@ -902,7 +901,7 @@ public: virtual Transform2D skeleton_bone_get_transform_2d(RID p_skeleton, int p_bone) const; virtual void skeleton_set_base_transform_2d(RID p_skeleton, const Transform2D &p_base_transform); - void _update_skeleton_transform_buffer(const PoolVector<float> &p_data, size_t p_size); + void _update_skeleton_transform_buffer(const Vector<float> &p_data, size_t p_size); /* Light API */ @@ -1030,8 +1029,8 @@ public: virtual void gi_probe_set_to_cell_xform(RID p_probe, const Transform &p_xform); virtual Transform gi_probe_get_to_cell_xform(RID p_probe) const; - virtual void gi_probe_set_dynamic_data(RID p_probe, const PoolVector<int> &p_data); - virtual PoolVector<int> gi_probe_get_dynamic_data(RID p_probe) const; + virtual void gi_probe_set_dynamic_data(RID p_probe, const Vector<int> &p_data); + virtual Vector<int> gi_probe_get_dynamic_data(RID p_probe) const; virtual void gi_probe_set_dynamic_range(RID p_probe, int p_range); virtual int gi_probe_get_dynamic_range(RID p_probe) const; @@ -1064,7 +1063,7 @@ public: struct LightmapCapture : public Instantiable { - PoolVector<LightmapCaptureOctree> octree; + Vector<LightmapCaptureOctree> octree; AABB bounds; Transform cell_xform; int cell_subdiv; @@ -1080,15 +1079,15 @@ public: virtual RID lightmap_capture_create(); virtual void lightmap_capture_set_bounds(RID p_capture, const AABB &p_bounds); virtual AABB lightmap_capture_get_bounds(RID p_capture) const; - virtual void lightmap_capture_set_octree(RID p_capture, const PoolVector<uint8_t> &p_octree); - virtual PoolVector<uint8_t> lightmap_capture_get_octree(RID p_capture) const; + virtual void lightmap_capture_set_octree(RID p_capture, const Vector<uint8_t> &p_octree); + virtual Vector<uint8_t> lightmap_capture_get_octree(RID p_capture) const; virtual void lightmap_capture_set_octree_cell_transform(RID p_capture, const Transform &p_xform); virtual Transform lightmap_capture_get_octree_cell_transform(RID p_capture) const; virtual void lightmap_capture_set_octree_cell_subdiv(RID p_capture, int p_subdiv); virtual int lightmap_capture_get_octree_cell_subdiv(RID p_capture) const; virtual void lightmap_capture_set_energy(RID p_capture, float p_energy); virtual float lightmap_capture_get_energy(RID p_capture) const; - virtual const PoolVector<LightmapCaptureOctree> *lightmap_capture_get_octree_ptr(RID p_capture) const; + virtual const Vector<LightmapCaptureOctree> *lightmap_capture_get_octree_ptr(RID p_capture) const; /* PARTICLES */ void update_particles(); @@ -1271,14 +1270,14 @@ public: GLuint vertex_id; // 0 means, unconfigured GLuint index_id; // 0 means, unconfigured - PoolVector<Vector2> lines; + Vector<Vector2> lines; int len; }; RID_PtrOwner<CanvasOccluder> canvas_occluder_owner; virtual RID canvas_light_occluder_create(); - virtual void canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2> &p_lines); + virtual void canvas_light_occluder_set_polylines(RID p_occluder, const Vector<Vector2> &p_lines); virtual VS::InstanceType get_base_type(RID p_rid) const; diff --git a/drivers/png/image_loader_png.cpp b/drivers/png/image_loader_png.cpp index eb7d196e1d..4cb93a821c 100644 --- a/drivers/png/image_loader_png.cpp +++ b/drivers/png/image_loader_png.cpp @@ -39,19 +39,19 @@ Error ImageLoaderPNG::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) { const size_t buffer_size = f->get_len(); - PoolVector<uint8_t> file_buffer; + Vector<uint8_t> file_buffer; Error err = file_buffer.resize(buffer_size); if (err) { f->close(); return err; } { - PoolVector<uint8_t>::Write writer = file_buffer.write(); - f->get_buffer(writer.ptr(), buffer_size); + uint8_t *writer = file_buffer.ptrw(); + f->get_buffer(writer, buffer_size); f->close(); } - PoolVector<uint8_t>::Read reader = file_buffer.read(); - return PNGDriverCommon::png_to_image(reader.ptr(), buffer_size, p_image); + const uint8_t *reader = file_buffer.ptr(); + return PNGDriverCommon::png_to_image(reader, buffer_size, p_image); } void ImageLoaderPNG::get_recognized_extensions(List<String> *p_extensions) const { @@ -70,34 +70,34 @@ Ref<Image> ImageLoaderPNG::load_mem_png(const uint8_t *p_png, int p_size) { return img; } -Ref<Image> ImageLoaderPNG::lossless_unpack_png(const PoolVector<uint8_t> &p_data) { +Ref<Image> ImageLoaderPNG::lossless_unpack_png(const Vector<uint8_t> &p_data) { const int len = p_data.size(); ERR_FAIL_COND_V(len < 4, Ref<Image>()); - PoolVector<uint8_t>::Read r = p_data.read(); + const uint8_t *r = p_data.ptr(); ERR_FAIL_COND_V(r[0] != 'P' || r[1] != 'N' || r[2] != 'G' || r[3] != ' ', Ref<Image>()); return load_mem_png(&r[4], len - 4); } -PoolVector<uint8_t> ImageLoaderPNG::lossless_pack_png(const Ref<Image> &p_image) { +Vector<uint8_t> ImageLoaderPNG::lossless_pack_png(const Ref<Image> &p_image) { - PoolVector<uint8_t> out_buffer; + Vector<uint8_t> out_buffer; // add Godot's own "PNG " prefix if (out_buffer.resize(4) != OK) { - ERR_FAIL_V(PoolVector<uint8_t>()); + ERR_FAIL_V(Vector<uint8_t>()); } // scope for writer lifetime { // must be closed before call to image_to_png - PoolVector<uint8_t>::Write writer = out_buffer.write(); - copymem(writer.ptr(), "PNG ", 4); + uint8_t *writer = out_buffer.ptrw(); + copymem(writer, "PNG ", 4); } Error err = PNGDriverCommon::image_to_png(p_image, out_buffer); if (err) { - ERR_FAIL_V(PoolVector<uint8_t>()); + ERR_FAIL_V(Vector<uint8_t>()); } return out_buffer; diff --git a/drivers/png/image_loader_png.h b/drivers/png/image_loader_png.h index 57f8aa314d..0154be0398 100644 --- a/drivers/png/image_loader_png.h +++ b/drivers/png/image_loader_png.h @@ -35,8 +35,8 @@ class ImageLoaderPNG : public ImageFormatLoader { private: - static PoolVector<uint8_t> lossless_pack_png(const Ref<Image> &p_image); - static Ref<Image> lossless_unpack_png(const PoolVector<uint8_t> &p_data); + static Vector<uint8_t> lossless_pack_png(const Ref<Image> &p_image); + static Ref<Image> lossless_unpack_png(const Vector<uint8_t> &p_data); static Ref<Image> load_mem_png(const uint8_t *p_png, int p_size); public: diff --git a/drivers/png/png_driver_common.cpp b/drivers/png/png_driver_common.cpp index 750d00eb59..efd488fd5c 100644 --- a/drivers/png/png_driver_common.cpp +++ b/drivers/png/png_driver_common.cpp @@ -101,16 +101,16 @@ Error png_to_image(const uint8_t *p_source, size_t p_size, Ref<Image> p_image) { } const png_uint_32 stride = PNG_IMAGE_ROW_STRIDE(png_img); - PoolVector<uint8_t> buffer; + Vector<uint8_t> buffer; Error err = buffer.resize(PNG_IMAGE_BUFFER_SIZE(png_img, stride)); if (err) { png_image_free(&png_img); // only required when we return before finish_read return err; } - PoolVector<uint8_t>::Write writer = buffer.write(); + uint8_t *writer = buffer.ptrw(); // read image data to buffer and release libpng resources - success = png_image_finish_read(&png_img, NULL, writer.ptr(), stride, NULL); + success = png_image_finish_read(&png_img, NULL, writer, stride, NULL); ERR_FAIL_COND_V_MSG(check_error(png_img), ERR_FILE_CORRUPT, png_img.message); ERR_FAIL_COND_V(!success, ERR_FILE_CORRUPT); @@ -120,7 +120,7 @@ Error png_to_image(const uint8_t *p_source, size_t p_size, Ref<Image> p_image) { return OK; } -Error image_to_png(const Ref<Image> &p_image, PoolVector<uint8_t> &p_buffer) { +Error image_to_png(const Ref<Image> &p_image, Vector<uint8_t> &p_buffer) { Ref<Image> source_image = p_image->duplicate(); @@ -158,8 +158,8 @@ Error image_to_png(const Ref<Image> &p_image, PoolVector<uint8_t> &p_buffer) { } } - const PoolVector<uint8_t> image_data = source_image->get_data(); - const PoolVector<uint8_t>::Read reader = image_data.read(); + const Vector<uint8_t> image_data = source_image->get_data(); + const uint8_t *reader = image_data.ptr(); // we may be passed a buffer with existing content we're expected to append to const int buffer_offset = p_buffer.size(); @@ -173,9 +173,9 @@ Error image_to_png(const Ref<Image> &p_image, PoolVector<uint8_t> &p_buffer) { Error err = p_buffer.resize(buffer_offset + png_size_estimate); ERR_FAIL_COND_V(err, err); - PoolVector<uint8_t>::Write writer = p_buffer.write(); + uint8_t *writer = p_buffer.ptrw(); success = png_image_write_to_memory(&png_img, &writer[buffer_offset], - &compressed_size, 0, reader.ptr(), 0, NULL); + &compressed_size, 0, reader, 0, NULL); ERR_FAIL_COND_V_MSG(check_error(png_img), FAILED, png_img.message); } if (!success) { @@ -187,9 +187,9 @@ Error image_to_png(const Ref<Image> &p_image, PoolVector<uint8_t> &p_buffer) { Error err = p_buffer.resize(buffer_offset + compressed_size); ERR_FAIL_COND_V(err, err); - PoolVector<uint8_t>::Write writer = p_buffer.write(); + uint8_t *writer = p_buffer.ptrw(); success = png_image_write_to_memory(&png_img, &writer[buffer_offset], - &compressed_size, 0, reader.ptr(), 0, NULL); + &compressed_size, 0, reader, 0, NULL); ERR_FAIL_COND_V_MSG(check_error(png_img), FAILED, png_img.message); ERR_FAIL_COND_V(!success, FAILED); } diff --git a/drivers/png/png_driver_common.h b/drivers/png/png_driver_common.h index ee1d32ce68..12129f034e 100644 --- a/drivers/png/png_driver_common.h +++ b/drivers/png/png_driver_common.h @@ -32,7 +32,6 @@ #define PNG_DRIVER_COMMON_H #include "core/image.h" -#include "core/pool_vector.h" namespace PNGDriverCommon { @@ -41,7 +40,7 @@ Error png_to_image(const uint8_t *p_source, size_t p_size, Ref<Image> p_image); // Append p_image, as a png, to p_buffer. // Contents of p_buffer is unspecified if error returned. -Error image_to_png(const Ref<Image> &p_image, PoolVector<uint8_t> &p_buffer); +Error image_to_png(const Ref<Image> &p_image, Vector<uint8_t> &p_buffer); } // namespace PNGDriverCommon diff --git a/drivers/png/resource_saver_png.cpp b/drivers/png/resource_saver_png.cpp index 566bfbcc1d..2380c2685f 100644 --- a/drivers/png/resource_saver_png.cpp +++ b/drivers/png/resource_saver_png.cpp @@ -51,15 +51,15 @@ Error ResourceSaverPNG::save(const String &p_path, const RES &p_resource, uint32 Error ResourceSaverPNG::save_image(const String &p_path, const Ref<Image> &p_img) { - PoolVector<uint8_t> buffer; + Vector<uint8_t> buffer; Error err = PNGDriverCommon::image_to_png(p_img, buffer); ERR_FAIL_COND_V_MSG(err, err, "Can't convert image to PNG."); FileAccess *file = FileAccess::open(p_path, FileAccess::WRITE, &err); ERR_FAIL_COND_V_MSG(err, err, vformat("Can't save PNG at path: '%s'.", p_path)); - PoolVector<uint8_t>::Read reader = buffer.read(); + const uint8_t *reader = buffer.ptr(); - file->store_buffer(reader.ptr(), buffer.size()); + file->store_buffer(reader, buffer.size()); if (file->get_error() != OK && file->get_error() != ERR_FILE_EOF) { memdelete(file); return ERR_CANT_CREATE; @@ -71,11 +71,11 @@ Error ResourceSaverPNG::save_image(const String &p_path, const Ref<Image> &p_img return OK; } -PoolVector<uint8_t> ResourceSaverPNG::save_image_to_buffer(const Ref<Image> &p_img) { +Vector<uint8_t> ResourceSaverPNG::save_image_to_buffer(const Ref<Image> &p_img) { - PoolVector<uint8_t> buffer; + Vector<uint8_t> buffer; Error err = PNGDriverCommon::image_to_png(p_img, buffer); - ERR_FAIL_COND_V_MSG(err, PoolVector<uint8_t>(), "Can't convert image to PNG."); + ERR_FAIL_COND_V_MSG(err, Vector<uint8_t>(), "Can't convert image to PNG."); return buffer; } diff --git a/drivers/png/resource_saver_png.h b/drivers/png/resource_saver_png.h index 2cac20991a..c32b383521 100644 --- a/drivers/png/resource_saver_png.h +++ b/drivers/png/resource_saver_png.h @@ -37,7 +37,7 @@ class ResourceSaverPNG : public ResourceFormatSaver { public: static Error save_image(const String &p_path, const Ref<Image> &p_img); - static PoolVector<uint8_t> save_image_to_buffer(const Ref<Image> &p_img); + static Vector<uint8_t> save_image_to_buffer(const Ref<Image> &p_img); virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0); virtual bool recognize(const RES &p_resource) const; diff --git a/drivers/spirv-reflect/SCsub b/drivers/spirv-reflect/SCsub index f6b40ac433..8ff27da114 100644 --- a/drivers/spirv-reflect/SCsub +++ b/drivers/spirv-reflect/SCsub @@ -3,12 +3,13 @@ Import('env') env_spirv_reflect = env.Clone() +env_spirv_reflect.disable_warnings() thirdparty_dir = "#thirdparty/spirv-reflect/" thirdparty_sources = [ "spirv_reflect.c" ] - + thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] env_spirv_reflect.add_source_files(env.drivers_sources, thirdparty_sources) diff --git a/drivers/unix/net_socket_posix.cpp b/drivers/unix/net_socket_posix.cpp index cab5513e0a..4adeeb1d9b 100644 --- a/drivers/unix/net_socket_posix.cpp +++ b/drivers/unix/net_socket_posix.cpp @@ -544,14 +544,14 @@ Error NetSocketPosix::recv(uint8_t *p_buffer, int p_len, int &r_read) { return OK; } -Error NetSocketPosix::recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port) { +Error NetSocketPosix::recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port, bool p_peek) { ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED); struct sockaddr_storage from; socklen_t len = sizeof(struct sockaddr_storage); memset(&from, 0, len); - r_read = ::recvfrom(_sock, SOCK_BUF(p_buffer), p_len, 0, (struct sockaddr *)&from, &len); + r_read = ::recvfrom(_sock, SOCK_BUF(p_buffer), p_len, p_peek ? MSG_PEEK : 0, (struct sockaddr *)&from, &len); if (r_read < 0) { NetError err = _get_socket_error(); @@ -673,22 +673,27 @@ void NetSocketPosix::set_tcp_no_delay_enabled(bool p_enabled) { void NetSocketPosix::set_reuse_address_enabled(bool p_enabled) { ERR_FAIL_COND(!is_open()); +// On Windows, enabling SO_REUSEADDR actually would also enable reuse port, very bad on TCP. Denying... +// Windows does not have this option, SO_REUSEADDR in this magical world means SO_REUSEPORT +#ifndef WINDOWS_ENABLED int par = p_enabled ? 1 : 0; if (setsockopt(_sock, SOL_SOCKET, SO_REUSEADDR, SOCK_CBUF(&par), sizeof(int)) < 0) { WARN_PRINT("Unable to set socket REUSEADDR option!"); } +#endif } void NetSocketPosix::set_reuse_port_enabled(bool p_enabled) { -// Windows does not have this option, as it is always ON when setting REUSEADDR. -#ifndef WINDOWS_ENABLED ERR_FAIL_COND(!is_open()); +// See comment above... +#ifdef WINDOWS_ENABLED +#define SO_REUSEPORT SO_REUSEADDR +#endif int par = p_enabled ? 1 : 0; if (setsockopt(_sock, SOL_SOCKET, SO_REUSEPORT, SOCK_CBUF(&par), sizeof(int)) < 0) { WARN_PRINT("Unable to set socket REUSEPORT option!"); } -#endif } bool NetSocketPosix::is_open() const { diff --git a/drivers/unix/net_socket_posix.h b/drivers/unix/net_socket_posix.h index 25ac6e2e56..0a19967265 100644 --- a/drivers/unix/net_socket_posix.h +++ b/drivers/unix/net_socket_posix.h @@ -81,7 +81,7 @@ public: virtual Error connect_to_host(IP_Address p_host, uint16_t p_port); virtual Error poll(PollType p_type, int timeout) const; virtual Error recv(uint8_t *p_buffer, int p_len, int &r_read); - virtual Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port); + virtual Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port, bool p_peek = false); virtual Error send(const uint8_t *p_buffer, int p_len, int &r_sent); virtual Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP_Address p_ip, uint16_t p_port); virtual Ref<NetSocket> accept(IP_Address &r_ip, uint16_t &r_port); diff --git a/drivers/vulkan/SCsub b/drivers/vulkan/SCsub index 8d6eb6b199..85a5ae8d26 100644 --- a/drivers/vulkan/SCsub +++ b/drivers/vulkan/SCsub @@ -49,6 +49,14 @@ if env['builtin_vulkan']: 'FALLBACK_DATA_DIRS=\\"%s\\"' % '/usr/local/share:/usr/share', 'FALLBACK_CONFIG_DIRS=\\"%s\\"' % '/etc/xdg' ]) + elif env['platform'] == "iphone": + env_thirdparty.AppendUnique(CPPDEFINES=[ + 'VK_USE_PLATFORM_IOS_MVK', + 'VULKAN_NON_CMAKE_BUILD', + 'SYSCONFDIR=\\"%s\\"' % '/etc', + 'FALLBACK_DATA_DIRS=\\"%s\\"' % '/usr/local/share:/usr/share', + 'FALLBACK_CONFIG_DIRS=\\"%s\\"' % '/etc/xdg' + ]) elif env['platform'] == "x11": env_thirdparty.AppendUnique(CPPDEFINES=[ 'VK_USE_PLATFORM_XLIB_KHR', @@ -57,6 +65,10 @@ if env['builtin_vulkan']: 'FALLBACK_DATA_DIRS=\\"%s\\"' % '/usr/local/share:/usr/share', 'FALLBACK_CONFIG_DIRS=\\"%s\\"' % '/etc/xdg' ]) + import platform + if (platform.system() == "Linux"): + # In glibc since 2.17 and musl libc since 1.1.24. Used by loader.c. + env_thirdparty.AppendUnique(CPPDEFINES=['HAVE_SECURE_GETENV']) loader_sources = [thirdparty_dir + "/loader/" + file for file in loader_sources] env_thirdparty.add_source_files(env.drivers_sources, loader_sources) diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index 4582f1c2c1..2bf8a16091 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -1557,7 +1557,7 @@ void RenderingDeviceVulkan::_buffer_memory_barrier(VkBuffer buffer, uint64_t p_f /**** TEXTURE ****/ /*****************/ -RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const TextureView &p_view, const Vector<PoolVector<uint8_t> > &p_data) { +RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const TextureView &p_view, const Vector<Vector<uint8_t> > &p_data) { _THREAD_SAFE_METHOD_ @@ -1997,8 +1997,8 @@ RID RenderingDeviceVulkan::texture_create_shared_from_slice(const TextureView &p //create view - ERR_FAIL_INDEX_V(p_mipmap, src_texture->mipmaps, RID()); - ERR_FAIL_INDEX_V(p_layer, src_texture->layers, RID()); + ERR_FAIL_UNSIGNED_INDEX_V(p_mipmap, src_texture->mipmaps, RID()); + ERR_FAIL_UNSIGNED_INDEX_V(p_layer, src_texture->layers, RID()); Texture texture = *src_texture; get_image_format_required_size(texture.format, texture.width, texture.height, texture.depth, p_mipmap + 1, &texture.width, &texture.height); @@ -2077,7 +2077,7 @@ RID RenderingDeviceVulkan::texture_create_shared_from_slice(const TextureView &p return id; } -Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, const PoolVector<uint8_t> &p_data, bool p_sync_with_draw) { +Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, const Vector<uint8_t> &p_data, bool p_sync_with_draw) { _THREAD_SAFE_METHOD_ @@ -2121,7 +2121,7 @@ Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, con uint32_t region_size = texture_upload_region_size_px; - PoolVector<uint8_t>::Read r = p_data.read(); + const uint8_t *r = p_data.ptr(); VkCommandBuffer command_buffer = p_sync_with_draw ? frames[frame].draw_command_buffer : frames[frame].setup_command_buffer; @@ -2153,7 +2153,7 @@ Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, con uint32_t depth; uint32_t image_total = get_image_format_required_size(texture->format, texture->width, texture->height, texture->depth, mm_i + 1, &width, &height, &depth); - const uint8_t *read_ptr_mipmap = r.ptr() + mipmap_offset; + const uint8_t *read_ptr_mipmap = r + mipmap_offset; image_size = image_total - mipmap_offset; for (uint32_t z = 0; z < depth; z++) { //for 3D textures, depth may be > 0 @@ -2288,12 +2288,12 @@ Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, con return OK; } -PoolVector<uint8_t> RenderingDeviceVulkan::_texture_get_data_from_image(Texture *tex, VkImage p_image, VmaAllocation p_allocation, uint32_t p_layer, bool p_2d) { +Vector<uint8_t> RenderingDeviceVulkan::_texture_get_data_from_image(Texture *tex, VkImage p_image, VmaAllocation p_allocation, uint32_t p_layer, bool p_2d) { uint32_t width, height, depth; uint32_t image_size = get_image_format_required_size(tex->format, tex->width, tex->height, p_2d ? 1 : tex->depth, tex->mipmaps, &width, &height, &depth); - PoolVector<uint8_t> image_data; + Vector<uint8_t> image_data; image_data.resize(image_size); void *img_mem; @@ -2305,14 +2305,14 @@ PoolVector<uint8_t> RenderingDeviceVulkan::_texture_get_data_from_image(Texture uint32_t pixel_size = get_image_format_pixel_size(tex->format); { - PoolVector<uint8_t>::Write w = image_data.write(); + uint8_t *w = image_data.ptrw(); uint32_t mipmap_offset = 0; for (uint32_t mm_i = 0; mm_i < tex->mipmaps; mm_i++) { uint32_t image_total = get_image_format_required_size(tex->format, tex->width, tex->height, p_2d ? 1 : tex->depth, mm_i + 1, &width, &height, &depth); - uint8_t *write_ptr_mipmap = w.ptr() + mipmap_offset; + uint8_t *write_ptr_mipmap = w + mipmap_offset; image_size = image_total - mipmap_offset; VkImageSubresource image_sub_resorce; @@ -2355,23 +2355,23 @@ PoolVector<uint8_t> RenderingDeviceVulkan::_texture_get_data_from_image(Texture return image_data; } -PoolVector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint32_t p_layer) { +Vector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint32_t p_layer) { _THREAD_SAFE_METHOD_ Texture *tex = texture_owner.getornull(p_texture); - ERR_FAIL_COND_V(!tex, PoolVector<uint8_t>()); + ERR_FAIL_COND_V(!tex, Vector<uint8_t>()); - ERR_FAIL_COND_V_MSG(tex->bound, PoolVector<uint8_t>(), + ERR_FAIL_COND_V_MSG(tex->bound, Vector<uint8_t>(), "Texture can't be retrieved while a render pass that uses it is being created. Ensure render pass is finalized (and that it was created with RENDER_PASS_CONTENTS_FINISH) to unbind this texture."); - ERR_FAIL_COND_V_MSG(!(tex->usage_flags & TEXTURE_USAGE_CAN_COPY_FROM_BIT), PoolVector<uint8_t>(), + ERR_FAIL_COND_V_MSG(!(tex->usage_flags & TEXTURE_USAGE_CAN_COPY_FROM_BIT), Vector<uint8_t>(), "Texture requires the TEXTURE_USAGE_CAN_COPY_FROM_BIT in order to be retrieved."); uint32_t layer_count = tex->layers; if (tex->type == TEXTURE_TYPE_CUBE || tex->type == TEXTURE_TYPE_CUBE_ARRAY) { layer_count *= 6; } - ERR_FAIL_COND_V(p_layer >= layer_count, PoolVector<uint8_t>()); + ERR_FAIL_COND_V(p_layer >= layer_count, Vector<uint8_t>()); if (tex->usage_flags & TEXTURE_USAGE_CPU_READ_BIT) { //does not need anything fancy, map and read. @@ -2469,15 +2469,15 @@ PoolVector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint3 void *buffer_mem; VkResult vkerr = vmaMapMemory(allocator, tmp_buffer.allocation, &buffer_mem); if (vkerr) { - ERR_FAIL_V(PoolVector<uint8_t>()); + ERR_FAIL_V(Vector<uint8_t>()); } - PoolVector<uint8_t> buffer_data; + Vector<uint8_t> buffer_data; { buffer_data.resize(buffer_size); - PoolVector<uint8_t>::Write w = buffer_data.write(); - copymem(w.ptr(), buffer_mem, buffer_size); + uint8_t *w = buffer_data.ptrw(); + copymem(w, buffer_mem, buffer_size); } vmaUnmapMemory(allocator, tmp_buffer.allocation); @@ -3135,7 +3135,7 @@ RID RenderingDeviceVulkan::sampler_create(const SamplerState &p_state) { /**** VERTEX ARRAY ****/ /**********************/ -RID RenderingDeviceVulkan::vertex_buffer_create(uint32_t p_size_bytes, const PoolVector<uint8_t> &p_data) { +RID RenderingDeviceVulkan::vertex_buffer_create(uint32_t p_size_bytes, const Vector<uint8_t> &p_data) { _THREAD_SAFE_METHOD_ @@ -3145,8 +3145,8 @@ RID RenderingDeviceVulkan::vertex_buffer_create(uint32_t p_size_bytes, const Poo _buffer_allocate(&buffer, p_size_bytes, VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, VMA_MEMORY_USAGE_GPU_ONLY); if (p_data.size()) { uint64_t data_size = p_data.size(); - PoolVector<uint8_t>::Read r = p_data.read(); - _buffer_update(&buffer, 0, r.ptr(), data_size); + const uint8_t *r = p_data.ptr(); + _buffer_update(&buffer, 0, r, data_size); _buffer_memory_barrier(buffer.buffer, 0, data_size, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_VERTEX_INPUT_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT, false); } @@ -3263,7 +3263,7 @@ RID RenderingDeviceVulkan::vertex_array_create(uint32_t p_vertex_count, VertexFo return id; } -RID RenderingDeviceVulkan::index_buffer_create(uint32_t p_index_count, IndexBufferFormat p_format, const PoolVector<uint8_t> &p_data, bool p_use_restart_indices) { +RID RenderingDeviceVulkan::index_buffer_create(uint32_t p_index_count, IndexBufferFormat p_format, const Vector<uint8_t> &p_data, bool p_use_restart_indices) { _THREAD_SAFE_METHOD_ @@ -3279,9 +3279,9 @@ RID RenderingDeviceVulkan::index_buffer_create(uint32_t p_index_count, IndexBuff index_buffer.max_index = 0; ERR_FAIL_COND_V_MSG((uint32_t)p_data.size() != size_bytes, RID(), "Default index buffer initializer array size (" + itos(p_data.size()) + ") does not match format required size (" + itos(size_bytes) + ")."); - PoolVector<uint8_t>::Read r = p_data.read(); + const uint8_t *r = p_data.ptr(); if (p_format == INDEX_BUFFER_FORMAT_UINT16) { - const uint16_t *index16 = (const uint16_t *)r.ptr(); + const uint16_t *index16 = (const uint16_t *)r; for (uint32_t i = 0; i < p_index_count; i++) { if (p_use_restart_indices && index16[i] == 0xFFFF) { continue; //restart index, ingnore @@ -3289,7 +3289,7 @@ RID RenderingDeviceVulkan::index_buffer_create(uint32_t p_index_count, IndexBuff index_buffer.max_index = MAX(index16[i], index_buffer.max_index); } } else { - const uint32_t *index32 = (const uint32_t *)r.ptr(); + const uint32_t *index32 = (const uint32_t *)r; for (uint32_t i = 0; i < p_index_count; i++) { if (p_use_restart_indices && index32[i] == 0xFFFFFFFF) { continue; //restart index, ingnore @@ -3306,8 +3306,8 @@ RID RenderingDeviceVulkan::index_buffer_create(uint32_t p_index_count, IndexBuff _buffer_allocate(&index_buffer, size_bytes, VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT, VMA_MEMORY_USAGE_GPU_ONLY); if (p_data.size()) { uint64_t data_size = p_data.size(); - PoolVector<uint8_t>::Read r = p_data.read(); - _buffer_update(&index_buffer, 0, r.ptr(), data_size); + const uint8_t *r = p_data.ptr(); + _buffer_update(&index_buffer, 0, r, data_size); _buffer_memory_barrier(index_buffer.buffer, 0, data_size, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_VERTEX_INPUT_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_INDEX_READ_BIT, false); } return index_buffer_owner.make_rid(index_buffer); @@ -3606,8 +3606,8 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages { SpvReflectShaderModule module; - PoolVector<uint8_t>::Read spirv = p_stages[i].spir_v.read(); - SpvReflectResult result = spvReflectCreateShaderModule(p_stages[i].spir_v.size(), spirv.ptr(), &module); + const uint8_t *spirv = p_stages[i].spir_v.ptr(); + SpvReflectResult result = spvReflectCreateShaderModule(p_stages[i].spir_v.size(), spirv, &module); ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, RID(), "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_stages[i].shader_stage]) + "' failed parsing shader."); @@ -3872,9 +3872,9 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages shader_module_create_info.pNext = NULL; shader_module_create_info.flags = 0; shader_module_create_info.codeSize = p_stages[i].spir_v.size(); - PoolVector<uint8_t>::Read r = p_stages[i].spir_v.read(); + const uint8_t *r = p_stages[i].spir_v.ptr(); - shader_module_create_info.pCode = (const uint32_t *)r.ptr(); + shader_module_create_info.pCode = (const uint32_t *)r; VkShaderModule module; VkResult res = vkCreateShaderModule(device, &shader_module_create_info, NULL, &module); @@ -4016,7 +4016,7 @@ uint32_t RenderingDeviceVulkan::shader_get_vertex_input_attribute_mask(RID p_sha /**** UNIFORMS ****/ /******************/ -RID RenderingDeviceVulkan::uniform_buffer_create(uint32_t p_size_bytes, const PoolVector<uint8_t> &p_data) { +RID RenderingDeviceVulkan::uniform_buffer_create(uint32_t p_size_bytes, const Vector<uint8_t> &p_data) { _THREAD_SAFE_METHOD_ @@ -4027,14 +4027,14 @@ RID RenderingDeviceVulkan::uniform_buffer_create(uint32_t p_size_bytes, const Po ERR_FAIL_COND_V(err != OK, RID()); if (p_data.size()) { uint64_t data_size = p_data.size(); - PoolVector<uint8_t>::Read r = p_data.read(); - _buffer_update(&buffer, 0, r.ptr(), data_size); + const uint8_t *r = p_data.ptr(); + _buffer_update(&buffer, 0, r, data_size); _buffer_memory_barrier(buffer.buffer, 0, data_size, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_UNIFORM_READ_BIT, false); } return uniform_buffer_owner.make_rid(buffer); } -RID RenderingDeviceVulkan::storage_buffer_create(uint32_t p_size_bytes, const PoolVector<uint8_t> &p_data) { +RID RenderingDeviceVulkan::storage_buffer_create(uint32_t p_size_bytes, const Vector<uint8_t> &p_data) { _THREAD_SAFE_METHOD_ @@ -4046,14 +4046,14 @@ RID RenderingDeviceVulkan::storage_buffer_create(uint32_t p_size_bytes, const Po if (p_data.size()) { uint64_t data_size = p_data.size(); - PoolVector<uint8_t>::Read r = p_data.read(); - _buffer_update(&buffer, 0, r.ptr(), data_size); + const uint8_t *r = p_data.ptr(); + _buffer_update(&buffer, 0, r, data_size); _buffer_memory_barrier(buffer.buffer, 0, data_size, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT, false); } return storage_buffer_owner.make_rid(buffer); } -RID RenderingDeviceVulkan::texture_buffer_create(uint32_t p_size_elements, DataFormat p_format, const PoolVector<uint8_t> &p_data) { +RID RenderingDeviceVulkan::texture_buffer_create(uint32_t p_size_elements, DataFormat p_format, const Vector<uint8_t> &p_data) { _THREAD_SAFE_METHOD_ @@ -4069,8 +4069,8 @@ RID RenderingDeviceVulkan::texture_buffer_create(uint32_t p_size_elements, DataF if (p_data.size()) { uint64_t data_size = p_data.size(); - PoolVector<uint8_t>::Read r = p_data.read(); - _buffer_update(&texture_buffer.buffer, 0, r.ptr(), data_size); + const uint8_t *r = p_data.ptr(); + _buffer_update(&texture_buffer.buffer, 0, r, data_size); _buffer_memory_barrier(texture_buffer.buffer.buffer, 0, data_size, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT, false); } @@ -4689,7 +4689,7 @@ Error RenderingDeviceVulkan::buffer_update(RID p_buffer, uint32_t p_offset, uint return err; } -PoolVector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) { +Vector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) { _THREAD_SAFE_METHOD_ @@ -4703,7 +4703,7 @@ PoolVector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) { } else if (storage_buffer_owner.owns(p_buffer)) { buffer = storage_buffer_owner.getornull(p_buffer); } else { - ERR_FAIL_V_MSG(PoolVector<uint8_t>(), "Buffer is either invalid or this type of buffer can't be retrieved. Only Index and Vertex buffers allow retrieving."); + ERR_FAIL_V_MSG(Vector<uint8_t>(), "Buffer is either invalid or this type of buffer can't be retrieved. Only Index and Vertex buffers allow retrieving."); } VkCommandBuffer command_buffer = frames[frame].setup_command_buffer; @@ -4720,15 +4720,15 @@ PoolVector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) { void *buffer_mem; VkResult vkerr = vmaMapMemory(allocator, tmp_buffer.allocation, &buffer_mem); if (vkerr) { - ERR_FAIL_V(PoolVector<uint8_t>()); + ERR_FAIL_V(Vector<uint8_t>()); } - PoolVector<uint8_t> buffer_data; + Vector<uint8_t> buffer_data; { buffer_data.resize(buffer->size); - PoolVector<uint8_t>::Write w = buffer_data.write(); - copymem(w.ptr(), buffer_mem, buffer->size); + uint8_t *w = buffer_data.ptrw(); + copymem(w, buffer_mem, buffer->size); } vmaUnmapMemory(allocator, tmp_buffer.allocation); @@ -5977,7 +5977,7 @@ void RenderingDeviceVulkan::draw_list_draw(DrawListID p_list, bool p_use_indices if (p_procedural_vertices > 0) { #ifdef DEBUG_ENABLED - ERR_FAIL_COND_MSG(dl->validation.pipeline_vertex_format == INVALID_ID, + ERR_FAIL_COND_MSG(dl->validation.pipeline_vertex_format != INVALID_ID, "Procedural vertices requested, but pipeline expects a vertex array."); #endif to_draw = p_procedural_vertices; @@ -6940,15 +6940,15 @@ uint64_t RenderingDeviceVulkan::get_captured_timestamps_frame() const { } uint64_t RenderingDeviceVulkan::get_captured_timestamp_gpu_time(uint32_t p_index) const { - ERR_FAIL_INDEX_V(p_index, frames[frame].timestamp_result_count, 0); + ERR_FAIL_UNSIGNED_INDEX_V(p_index, frames[frame].timestamp_result_count, 0); return frames[frame].timestamp_result_values[p_index] * limits.timestampPeriod; } uint64_t RenderingDeviceVulkan::get_captured_timestamp_cpu_time(uint32_t p_index) const { - ERR_FAIL_INDEX_V(p_index, frames[frame].timestamp_result_count, 0); + ERR_FAIL_UNSIGNED_INDEX_V(p_index, frames[frame].timestamp_result_count, 0); return frames[frame].timestamp_cpu_result_values[p_index]; } String RenderingDeviceVulkan::get_captured_timestamp_name(uint32_t p_index) const { - ERR_FAIL_INDEX_V(p_index, frames[frame].timestamp_result_count, String()); + ERR_FAIL_UNSIGNED_INDEX_V(p_index, frames[frame].timestamp_result_count, String()); return frames[frame].timestamp_result_names[p_index]; } diff --git a/drivers/vulkan/rendering_device_vulkan.h b/drivers/vulkan/rendering_device_vulkan.h index 8ef24d319b..30c10e922e 100644 --- a/drivers/vulkan/rendering_device_vulkan.h +++ b/drivers/vulkan/rendering_device_vulkan.h @@ -150,7 +150,7 @@ class RenderingDeviceVulkan : public RenderingDevice { RID_Owner<Texture, true> texture_owner; uint32_t texture_upload_region_size_px; - PoolVector<uint8_t> _texture_get_data_from_image(Texture *tex, VkImage p_image, VmaAllocation p_allocation, uint32_t p_layer, bool p_2d = false); + Vector<uint8_t> _texture_get_data_from_image(Texture *tex, VkImage p_image, VmaAllocation p_allocation, uint32_t p_layer, bool p_2d = false); /*****************/ /**** SAMPLER ****/ @@ -354,7 +354,9 @@ class RenderingDeviceVulkan : public RenderingDevice { if (a.stride != b.stride) { return false; } - return a.frequency != b.frequency; + if (a.frequency != b.frequency) { + return false; + } } return true; //they are equal } @@ -966,12 +968,12 @@ class RenderingDeviceVulkan : public RenderingDevice { void _free_rids(T &p_owner, const char *p_type); public: - virtual RID texture_create(const TextureFormat &p_format, const TextureView &p_view, const Vector<PoolVector<uint8_t> > &p_data = Vector<PoolVector<uint8_t> >()); + virtual RID texture_create(const TextureFormat &p_format, const TextureView &p_view, const Vector<Vector<uint8_t> > &p_data = Vector<Vector<uint8_t> >()); virtual RID texture_create_shared(const TextureView &p_view, RID p_with_texture); virtual RID texture_create_shared_from_slice(const TextureView &p_view, RID p_with_texture, uint32_t p_layer, uint32_t p_mipmap, TextureSliceType p_slice_type = TEXTURE_SLICE_2D); - virtual Error texture_update(RID p_texture, uint32_t p_layer, const PoolVector<uint8_t> &p_data, bool p_sync_with_draw = false); - virtual PoolVector<uint8_t> texture_get_data(RID p_texture, uint32_t p_layer); + virtual Error texture_update(RID p_texture, uint32_t p_layer, const Vector<uint8_t> &p_data, bool p_sync_with_draw = false); + virtual Vector<uint8_t> texture_get_data(RID p_texture, uint32_t p_layer); virtual bool texture_is_format_supported_for_usage(DataFormat p_format, uint32_t p_usage) const; virtual bool texture_is_shared(RID p_texture); @@ -1001,13 +1003,13 @@ public: /**** VERTEX ARRAY ****/ /**********************/ - virtual RID vertex_buffer_create(uint32_t p_size_bytes, const PoolVector<uint8_t> &p_data = PoolVector<uint8_t>()); + virtual RID vertex_buffer_create(uint32_t p_size_bytes, const Vector<uint8_t> &p_data = Vector<uint8_t>()); // Internally reference counted, this ID is warranted to be unique for the same description, but needs to be freed as many times as it was allocated virtual VertexFormatID vertex_format_create(const Vector<VertexDescription> &p_vertex_formats); virtual RID vertex_array_create(uint32_t p_vertex_count, VertexFormatID p_vertex_format, const Vector<RID> &p_src_buffers); - virtual RID index_buffer_create(uint32_t p_size_indices, IndexBufferFormat p_format, const PoolVector<uint8_t> &p_data = PoolVector<uint8_t>(), bool p_use_restart_indices = false); + virtual RID index_buffer_create(uint32_t p_size_indices, IndexBufferFormat p_format, const Vector<uint8_t> &p_data = Vector<uint8_t>(), bool p_use_restart_indices = false); virtual RID index_array_create(RID p_index_buffer, uint32_t p_index_offset, uint32_t p_index_count); @@ -1022,15 +1024,15 @@ public: /**** UNIFORM ****/ /*****************/ - virtual RID uniform_buffer_create(uint32_t p_size_bytes, const PoolVector<uint8_t> &p_data = PoolVector<uint8_t>()); - virtual RID storage_buffer_create(uint32_t p_size_bytes, const PoolVector<uint8_t> &p_data = PoolVector<uint8_t>()); - virtual RID texture_buffer_create(uint32_t p_size_elements, DataFormat p_format, const PoolVector<uint8_t> &p_data = PoolVector<uint8_t>()); + virtual RID uniform_buffer_create(uint32_t p_size_bytes, const Vector<uint8_t> &p_data = Vector<uint8_t>()); + virtual RID storage_buffer_create(uint32_t p_size_bytes, const Vector<uint8_t> &p_data = Vector<uint8_t>()); + virtual RID texture_buffer_create(uint32_t p_size_elements, DataFormat p_format, const Vector<uint8_t> &p_data = Vector<uint8_t>()); virtual RID uniform_set_create(const Vector<Uniform> &p_uniforms, RID p_shader, uint32_t p_shader_set); virtual bool uniform_set_is_valid(RID p_uniform_set); virtual Error buffer_update(RID p_buffer, uint32_t p_offset, uint32_t p_size, const void *p_data, bool p_sync_with_draw = false); //works for any buffer - virtual PoolVector<uint8_t> buffer_get_data(RID p_buffer); + virtual Vector<uint8_t> buffer_get_data(RID p_buffer); /*************************/ /**** RENDER PIPELINE ****/ diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp index 98464bc8d1..7c691340ca 100644 --- a/drivers/vulkan/vulkan_context.cpp +++ b/drivers/vulkan/vulkan_context.cpp @@ -29,11 +29,14 @@ /*************************************************************************/ #include "vulkan_context.h" + #include "core/engine.h" -#include "core/print_string.h" #include "core/project_settings.h" +#include "core/ustring.h" #include "core/version.h" + #include "vk_enum_string_helper.h" + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -45,94 +48,103 @@ VKAPI_ATTR VkBool32 VKAPI_CALL VulkanContext::_debug_messenger_callback(VkDebugU VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData, void *pUserData) { - char prefix[64] = ""; - char *message = (char *)malloc(strlen(pCallbackData->pMessage) + 5000); - ERR_FAIL_COND_V(!message, false); - //This error needs to be ignored because the AMD allocator will mix up memory types on IGP processors + // This error needs to be ignored because the AMD allocator will mix up memory types on IGP processors. if (strstr(pCallbackData->pMessage, "Mapping an image with layout") != NULL && strstr(pCallbackData->pMessage, "can result in undefined behavior if this memory is used by the device") != NULL) { - free(message); return VK_FALSE; } - // This needs to be ignored because Validator is wrong here + // This needs to be ignored because Validator is wrong here. if (strstr(pCallbackData->pMessage, "SPIR-V module not valid: Pointer operand") != NULL && strstr(pCallbackData->pMessage, "must be a memory object") != NULL) { - free(message); + return VK_FALSE; + } + // Workaround for Vulkan-Loader usability bug: https://github.com/KhronosGroup/Vulkan-Loader/issues/262. + if (strstr(pCallbackData->pMessage, "wrong ELF class: ELFCLASS32") != NULL) { return VK_FALSE; } if (strstr(pCallbackData->pMessageIdName, "UNASSIGNED-CoreValidation-DrawState-ClearCmdBeforeDraw") != NULL) { - free(message); return VK_FALSE; } - if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT) { - strcat(prefix, "VERBOSE : "); - } else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT) { - strcat(prefix, "INFO : "); - } else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) { - strcat(prefix, "WARNING : "); - } else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) { - strcat(prefix, "ERROR : "); + String severity_string; + switch (messageSeverity) { + case VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT: + severity_string = "VERBOSE : "; + break; + case VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT: + severity_string = "INFO : "; + break; + case VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT: + severity_string = "WARNING : "; + break; + case VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT: + severity_string = "ERROR : "; + break; + case VK_DEBUG_UTILS_MESSAGE_SEVERITY_FLAG_BITS_MAX_ENUM_EXT: + break; } - if (messageType & VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT) { - strcat(prefix, "GENERAL"); - } else { - if (messageType & VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT) { - strcat(prefix, "VALIDATION"); - //validation_error = 1; - } - if (messageType & VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT) { - if (messageType & VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT) { - strcat(prefix, "|"); - } - strcat(prefix, "PERFORMANCE"); - } + String type_string; + switch (messageType) { + case (VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT): + type_string = "GENERAL"; + break; + case (VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT): + type_string = "VALIDATION"; + break; + case (VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT): + type_string = "PERFORMANCE"; + break; + case (VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT & VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT): + type_string = "VALIDATION|PERFORMANCE"; + break; } - sprintf(message, "%s - Message Id Number: %d | Message Id Name: %s\n\t%s\n", prefix, pCallbackData->messageIdNumber, - pCallbackData->pMessageIdName, pCallbackData->pMessage); - + String objects_string; if (pCallbackData->objectCount > 0) { - char tmp_message[500]; - sprintf(tmp_message, "\n\tObjects - %d\n", pCallbackData->objectCount); - strcat(message, tmp_message); + objects_string = "\n\tObjects - " + String::num_int64(pCallbackData->objectCount); for (uint32_t object = 0; object < pCallbackData->objectCount; ++object) { + objects_string += + "\n\t\tObject[" + String::num_int64(object) + "]" + + " - " + string_VkObjectType(pCallbackData->pObjects[object].objectType) + + ", Handle " + String::num_int64(pCallbackData->pObjects[object].objectHandle); if (NULL != pCallbackData->pObjects[object].pObjectName && strlen(pCallbackData->pObjects[object].pObjectName) > 0) { - sprintf(tmp_message, "\t\tObject[%d] - %s, Handle %p, Name \"%s\"\n", object, - string_VkObjectType(pCallbackData->pObjects[object].objectType), - (void *)(pCallbackData->pObjects[object].objectHandle), pCallbackData->pObjects[object].pObjectName); - } else { - sprintf(tmp_message, "\t\tObject[%d] - %s, Handle %p\n", object, - string_VkObjectType(pCallbackData->pObjects[object].objectType), - (void *)(pCallbackData->pObjects[object].objectHandle)); + objects_string += ", Name \"" + String(pCallbackData->pObjects[object].pObjectName) + "\""; } - strcat(message, tmp_message); } } + + String labels_string; if (pCallbackData->cmdBufLabelCount > 0) { - char tmp_message[500]; - sprintf(tmp_message, "\n\tCommand Buffer Labels - %d\n", pCallbackData->cmdBufLabelCount); - strcat(message, tmp_message); + labels_string = "\n\tCommand Buffer Labels - " + String::num_int64(pCallbackData->cmdBufLabelCount); for (uint32_t cmd_buf_label = 0; cmd_buf_label < pCallbackData->cmdBufLabelCount; ++cmd_buf_label) { - sprintf(tmp_message, "\t\tLabel[%d] - %s { %f, %f, %f, %f}\n", cmd_buf_label, - pCallbackData->pCmdBufLabels[cmd_buf_label].pLabelName, pCallbackData->pCmdBufLabels[cmd_buf_label].color[0], - pCallbackData->pCmdBufLabels[cmd_buf_label].color[1], pCallbackData->pCmdBufLabels[cmd_buf_label].color[2], - pCallbackData->pCmdBufLabels[cmd_buf_label].color[3]); - strcat(message, tmp_message); + labels_string += + "\n\t\tLabel[" + String::num_int64(cmd_buf_label) + "]" + + " - " + pCallbackData->pCmdBufLabels[cmd_buf_label].pLabelName + + "{ "; + for (int color_idx = 0; color_idx < 4; ++color_idx) { + labels_string += String::num(pCallbackData->pCmdBufLabels[cmd_buf_label].color[color_idx]); + if (color_idx < 3) { + labels_string += ", "; + } + } + labels_string += " }"; } } - ERR_PRINT(message); + String error_message(severity_string + type_string + + " - Message Id Number: " + String::num_int64(pCallbackData->messageIdNumber) + + " | Message Id Name: " + pCallbackData->pMessageIdName + + "\n\t" + pCallbackData->pMessage + + objects_string + labels_string); - free(message); + ERR_PRINT(error_message); - if (Engine::get_singleton()->is_abort_on_gpu_errors_enabled()) { - abort(); - } - // Don't bail out, but keep going. - return false; + CRASH_COND_MSG(Engine::get_singleton()->is_abort_on_gpu_errors_enabled(), + "Crashing, because abort on GPU errors is enabled."); + + return VK_FALSE; } VkBool32 VulkanContext::_check_layers(uint32_t check_count, const char **check_names, uint32_t layer_count, VkLayerProperties *layers) { @@ -1335,6 +1347,7 @@ Error VulkanContext::swap_buffers() { /*swapchainCount*/ 0, /*pSwapchain*/ NULL, /*pImageIndices*/ NULL, + /*pResults*/ NULL, }; VkSwapchainKHR *pSwapchains = (VkSwapchainKHR *)alloca(sizeof(VkSwapchainKHR *) * windows.size()); diff --git a/drivers/winmidi/midi_driver_winmidi.cpp b/drivers/winmidi/midi_driver_winmidi.cpp index 01c194b7d8..57fb9b0e57 100644 --- a/drivers/winmidi/midi_driver_winmidi.cpp +++ b/drivers/winmidi/midi_driver_winmidi.cpp @@ -66,9 +66,9 @@ Error MIDIDriverWinMidi::open() { return OK; } -PoolStringArray MIDIDriverWinMidi::get_connected_inputs() { +PackedStringArray MIDIDriverWinMidi::get_connected_inputs() { - PoolStringArray list; + PackedStringArray list; for (int i = 0; i < connected_sources.size(); i++) { HMIDIIN midi_in = connected_sources[i]; diff --git a/drivers/winmidi/midi_driver_winmidi.h b/drivers/winmidi/midi_driver_winmidi.h index a689d3a500..c240c8c7aa 100644 --- a/drivers/winmidi/midi_driver_winmidi.h +++ b/drivers/winmidi/midi_driver_winmidi.h @@ -51,7 +51,7 @@ public: virtual Error open(); virtual void close(); - virtual PoolStringArray get_connected_inputs(); + virtual PackedStringArray get_connected_inputs(); MIDIDriverWinMidi(); virtual ~MIDIDriverWinMidi(); |