Merge pull request #43730 from qarmin/core_drivers_default_values

Initialize class/struct variables with default values in core/ and drivers/
This commit is contained in:
Rémi Verschelde 2020-11-24 13:00:27 +01:00 committed by GitHub
commit 32b31a5fa4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 221 additions and 228 deletions

View file

@ -542,9 +542,9 @@ void _OS::dump_memory_to_file(const String &p_file) {
struct _OSCoreBindImg { struct _OSCoreBindImg {
String path; String path;
Size2 size; Size2 size;
int fmt; int fmt = 0;
ObjectID id; ObjectID id;
int vram; int vram = 0;
bool operator<(const _OSCoreBindImg &p_img) const { return vram == p_img.vram ? id < p_img.id : vram > p_img.vram; } bool operator<(const _OSCoreBindImg &p_img) const { return vram == p_img.vram ? id < p_img.id : vram > p_img.vram; }
}; };

View file

@ -492,8 +492,8 @@ public:
virtual ~_Directory(); virtual ~_Directory();
private: private:
bool _list_skip_navigational; bool _list_skip_navigational = false;
bool _list_skip_hidden; bool _list_skip_hidden = false;
}; };
class _Marshalls : public Object { class _Marshalls : public Object {

View file

@ -38,10 +38,10 @@
struct _CoreConstant { struct _CoreConstant {
#ifdef DEBUG_METHODS_ENABLED #ifdef DEBUG_METHODS_ENABLED
StringName enum_name; StringName enum_name;
bool ignore_value_in_docs; bool ignore_value_in_docs = false;
#endif #endif
const char *name; const char *name;
int value; int value = 0;
_CoreConstant() {} _CoreConstant() {}

View file

@ -112,5 +112,4 @@ void AESContext::_bind_methods() {
} }
AESContext::AESContext() { AESContext::AESContext() {
mode = MODE_MAX;
} }

View file

@ -47,7 +47,7 @@ public:
}; };
private: private:
Mode mode; Mode mode = MODE_MAX;
CryptoCore::AESContext ctx; CryptoCore::AESContext ctx;
PackedByteArray iv; PackedByteArray iv;

View file

@ -37,7 +37,7 @@ class CryptoCore {
public: public:
class MD5Context { class MD5Context {
private: private:
void *ctx; // To include, or not to include... void *ctx = nullptr; // To include, or not to include...
public: public:
MD5Context(); MD5Context();
@ -50,7 +50,7 @@ public:
class SHA1Context { class SHA1Context {
private: private:
void *ctx; // To include, or not to include... void *ctx = nullptr; // To include, or not to include...
public: public:
SHA1Context(); SHA1Context();
@ -63,7 +63,7 @@ public:
class SHA256Context { class SHA256Context {
private: private:
void *ctx; // To include, or not to include... void *ctx = nullptr; // To include, or not to include...
public: public:
SHA256Context(); SHA256Context();
@ -76,7 +76,7 @@ public:
class AESContext { class AESContext {
private: private:
void *ctx; // To include, or not to include... void *ctx = nullptr; // To include, or not to include...
public: public:
AESContext(); AESContext();

View file

@ -45,7 +45,7 @@ public:
private: private:
void *ctx = nullptr; void *ctx = nullptr;
HashType type; HashType type = HASH_MD5;
protected: protected:
static void _bind_methods(); static void _bind_methods();

View file

@ -148,7 +148,7 @@ struct DebuggerMarshalls {
// Visual Profiler // Visual Profiler
struct VisualProfilerFrame { struct VisualProfilerFrame {
uint64_t frame_number; uint64_t frame_number = 0;
Vector<RS::FrameProfileArea> areas; Vector<RS::FrameProfileArea> areas;
Array serialize(); Array serialize();

View file

@ -47,8 +47,8 @@ private:
Vector<uint8_t> key; Vector<uint8_t> key;
bool writing = false; bool writing = false;
FileAccess *file = nullptr; FileAccess *file = nullptr;
size_t base; size_t base = 0;
size_t length; size_t length = 0;
Vector<uint8_t> data; Vector<uint8_t> data;
mutable int pos = 0; mutable int pos = 0;
mutable bool eofed = false; mutable bool eofed = false;

View file

@ -35,8 +35,8 @@
class FileAccessMemory : public FileAccess { class FileAccessMemory : public FileAccess {
uint8_t *data = nullptr; uint8_t *data = nullptr;
int length; int length = 0;
mutable int pos; mutable int pos = 0;
static FileAccess *create(); static FileAccess *create();

View file

@ -84,7 +84,7 @@ class PackedDataContainerRef : public Reference {
GDCLASS(PackedDataContainerRef, Reference); GDCLASS(PackedDataContainerRef, Reference);
friend class PackedDataContainer; friend class PackedDataContainer;
uint32_t offset; uint32_t offset = 0;
Ref<PackedDataContainer> from; Ref<PackedDataContainer> from;
protected: protected:

View file

@ -39,7 +39,7 @@ class PCKPacker : public Reference {
GDCLASS(PCKPacker, Reference); GDCLASS(PCKPacker, Reference);
FileAccess *file = nullptr; FileAccess *file = nullptr;
int alignment; int alignment = 0;
uint64_t ofs = 0; uint64_t ofs = 0;
Vector<uint8_t> key; Vector<uint8_t> key;
@ -50,9 +50,9 @@ class PCKPacker : public Reference {
struct File { struct File {
String path; String path;
String src_path; String src_path;
uint64_t ofs; uint64_t ofs = 0;
uint64_t size; uint64_t size = 0;
bool encrypted; bool encrypted = false;
Vector<uint8_t> md5; Vector<uint8_t> md5;
}; };
Vector<File> files; Vector<File> files;

View file

@ -47,20 +47,20 @@ class AStar : public Reference {
struct Point { struct Point {
Point() {} Point() {}
int id; int id = 0;
Vector3 pos; Vector3 pos;
real_t weight_scale; real_t weight_scale = 0;
bool enabled; bool enabled = false;
OAHashMap<int, Point *> neighbours = 4u; OAHashMap<int, Point *> neighbours = 4u;
OAHashMap<int, Point *> unlinked_neighbours = 4u; OAHashMap<int, Point *> unlinked_neighbours = 4u;
// Used for pathfinding. // Used for pathfinding.
Point *prev_point; Point *prev_point = nullptr;
real_t g_score; real_t g_score = 0;
real_t f_score; real_t f_score = 0;
uint64_t open_pass; uint64_t open_pass = 0;
uint64_t closed_pass; uint64_t closed_pass = 0;
}; };
struct SortPoints { struct SortPoints {

View file

@ -133,7 +133,7 @@ private:
ENode *next = nullptr; ENode *next = nullptr;
Type type; Type type = TYPE_INPUT;
ENode() {} ENode() {}
virtual ~ENode() { virtual ~ENode() {
@ -144,7 +144,7 @@ private:
}; };
struct ExpressionNode { struct ExpressionNode {
bool is_op; bool is_op = false;
union { union {
Variant::Operator op; Variant::Operator op;
ENode *node; ENode *node;
@ -154,23 +154,23 @@ private:
ENode *_parse_expression(); ENode *_parse_expression();
struct InputNode : public ENode { struct InputNode : public ENode {
int index; int index = 0;
InputNode() { InputNode() {
type = TYPE_INPUT; type = TYPE_INPUT;
} }
}; };
struct ConstantNode : public ENode { struct ConstantNode : public ENode {
Variant value; Variant value = Variant::NIL;
ConstantNode() { ConstantNode() {
type = TYPE_CONSTANT; type = TYPE_CONSTANT;
} }
}; };
struct OperatorNode : public ENode { struct OperatorNode : public ENode {
Variant::Operator op; Variant::Operator op = Variant::Operator::OP_ADD;
ENode *nodes[2]; ENode *nodes[2] = { nullptr, nullptr };
OperatorNode() { OperatorNode() {
type = TYPE_OPERATOR; type = TYPE_OPERATOR;
@ -184,8 +184,8 @@ private:
}; };
struct IndexNode : public ENode { struct IndexNode : public ENode {
ENode *base; ENode *base = nullptr;
ENode *index; ENode *index = nullptr;
IndexNode() { IndexNode() {
type = TYPE_INDEX; type = TYPE_INDEX;
@ -193,7 +193,7 @@ private:
}; };
struct NamedIndexNode : public ENode { struct NamedIndexNode : public ENode {
ENode *base; ENode *base = nullptr;
StringName name; StringName name;
NamedIndexNode() { NamedIndexNode() {
@ -202,7 +202,7 @@ private:
}; };
struct ConstructorNode : public ENode { struct ConstructorNode : public ENode {
Variant::Type data_type; Variant::Type data_type = Variant::Type::NIL;
Vector<ENode *> arguments; Vector<ENode *> arguments;
ConstructorNode() { ConstructorNode() {
@ -211,7 +211,7 @@ private:
}; };
struct CallNode : public ENode { struct CallNode : public ENode {
ENode *base; ENode *base = nullptr;
StringName method; StringName method;
Vector<ENode *> arguments; Vector<ENode *> arguments;

View file

@ -41,7 +41,7 @@ public:
struct Edge { struct Edge {
union { union {
uint32_t vertices[2]; uint32_t vertices[2];
uint64_t id; uint64_t id = 0;
}; };
bool operator<(const Edge &p_edge) const { bool operator<(const Edge &p_edge) const {
@ -60,7 +60,7 @@ public:
struct Face { struct Face {
Plane plane; Plane plane;
uint32_t vertices[3]; uint32_t vertices[3] = { 0 };
Vector<int> points_over; Vector<int> points_over;
bool operator<(const Face &p_face) const { bool operator<(const Face &p_face) const {
@ -70,11 +70,13 @@ public:
private: private:
struct FaceConnect { struct FaceConnect {
List<Face>::Element *left, *right = nullptr; List<Face>::Element *left = nullptr;
List<Face>::Element *right = nullptr;
FaceConnect() {} FaceConnect() {}
}; };
struct RetFaceConnect { struct RetFaceConnect {
List<Geometry3D::MeshData::Face>::Element *left, *right = nullptr; List<Geometry3D::MeshData::Face>::Element *left = nullptr;
List<Geometry3D::MeshData::Face>::Element *right = nullptr;
RetFaceConnect() {} RetFaceConnect() {}
}; };

View file

@ -57,7 +57,6 @@ protected:
String _get_root_string() const; String _get_root_string() const;
String fix_path(String p_path) const; String fix_path(String p_path) const;
bool next_is_dir;
template <class T> template <class T>
static DirAccess *_create_builtin() { static DirAccess *_create_builtin() {

View file

@ -254,8 +254,8 @@ class CharBuffer {
Vector<char> vector; Vector<char> vector;
char stack_buffer[256]; char stack_buffer[256];
char *buffer; char *buffer = nullptr;
int capacity; int capacity = 0;
int written = 0; int written = 0;
bool grow() { bool grow() {

View file

@ -73,7 +73,7 @@ public:
private: private:
friend class HashMap; friend class HashMap;
uint32_t hash; uint32_t hash = 0;
Element *next = nullptr; Element *next = nullptr;
Element() {} Element() {}
Pair pair; Pair pair;

View file

@ -137,9 +137,9 @@ public:
private: private:
struct _Data { struct _Data {
Element *first; Element *first = nullptr;
Element *last; Element *last = nullptr;
int size_cache; int size_cache = 0;
bool erase(const Element *p_I) { bool erase(const Element *p_I) {
ERR_FAIL_COND_V(!p_I, false); ERR_FAIL_COND_V(!p_I, false);

View file

@ -165,7 +165,7 @@ uint64_t atomic_exchange_if_greater(volatile uint64_t *pw, volatile uint64_t val
#endif #endif
struct SafeRefCount { struct SafeRefCount {
uint32_t count; uint32_t count = 0;
public: public:
// destroy() is called when weak_count_ drops to zero. // destroy() is called when weak_count_ drops to zero.

View file

@ -80,7 +80,7 @@ public:
private: private:
struct _Data { struct _Data {
Element *_root = nullptr; Element *_root = nullptr;
Element *_nil; Element *_nil = nullptr;
int size_cache = 0; int size_cache = 0;
_FORCE_INLINE_ _Data() { _FORCE_INLINE_ _Data() {

View file

@ -41,8 +41,8 @@ class ThreadWorkPool {
std::atomic<uint32_t> index; std::atomic<uint32_t> index;
struct BaseWork { struct BaseWork {
std::atomic<uint32_t> *index; std::atomic<uint32_t> *index = nullptr;
uint32_t max_elements; uint32_t max_elements = 0;
virtual void work() = 0; virtual void work() = 0;
virtual ~BaseWork() = default; virtual ~BaseWork() = default;
}; };

View file

@ -371,7 +371,7 @@ void Array::sort() {
} }
struct _ArrayVariantSortCustom { struct _ArrayVariantSortCustom {
Object *obj; Object *obj = nullptr;
StringName func; StringName func;
_FORCE_INLINE_ bool operator()(const Variant &p_l, const Variant &p_r) const { _FORCE_INLINE_ bool operator()(const Variant &p_l, const Variant &p_r) const {

View file

@ -62,9 +62,9 @@ public:
CALL_ERROR_TOO_FEW_ARGUMENTS, // expected is number of arguments CALL_ERROR_TOO_FEW_ARGUMENTS, // expected is number of arguments
CALL_ERROR_INSTANCE_IS_NULL, CALL_ERROR_INSTANCE_IS_NULL,
}; };
Error error; Error error = Error::CALL_OK;
int argument; int argument = 0;
int expected; int expected = 0;
}; };
void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, CallError &r_call_error) const; void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, CallError &r_call_error) const;

View file

@ -128,7 +128,7 @@ private:
struct ObjData { struct ObjData {
ObjectID id; ObjectID id;
Object *obj; Object *obj = nullptr;
}; };
/* array helpers */ /* array helpers */

View file

@ -56,17 +56,17 @@ class AudioDriverALSA : public AudioDriver {
static void thread_func(void *p_udata); static void thread_func(void *p_udata);
unsigned int mix_rate; unsigned int mix_rate = 0;
SpeakerMode speaker_mode; SpeakerMode speaker_mode;
snd_pcm_uframes_t buffer_frames; snd_pcm_uframes_t buffer_frames;
snd_pcm_uframes_t buffer_size; snd_pcm_uframes_t buffer_size;
snd_pcm_uframes_t period_size; snd_pcm_uframes_t period_size;
int channels; int channels = 0;
bool active; bool active = false;
bool thread_exited; bool thread_exited = false;
mutable bool exit_thread; mutable bool exit_thread = false;
public: public:
const char *get_name() const { const char *get_name() const {

View file

@ -183,21 +183,21 @@ class RasterizerStorageDummy : public RasterizerStorage {
public: public:
/* TEXTURE API */ /* TEXTURE API */
struct DummyTexture { struct DummyTexture {
int width; int width = 0;
int height; int height = 0;
uint32_t flags; uint32_t flags = 0;
Image::Format format; Image::Format format = Image::Format::FORMAT_MAX;
Ref<Image> image; Ref<Image> image;
String path; String path;
}; };
struct DummySurface { struct DummySurface {
uint32_t format; uint32_t format = 0;
RS::PrimitiveType primitive; RS::PrimitiveType primitive = RS::PrimitiveType::PRIMITIVE_MAX;
Vector<uint8_t> array; Vector<uint8_t> array;
int vertex_count; int vertex_count = 0;
Vector<uint8_t> index_array; Vector<uint8_t> index_array;
int index_count; int index_count = 0;
AABB aabb; AABB aabb;
Vector<Vector<uint8_t>> blend_shapes; Vector<Vector<uint8_t>> blend_shapes;
Vector<AABB> bone_aabbs; Vector<AABB> bone_aabbs;
@ -205,8 +205,8 @@ public:
struct DummyMesh { struct DummyMesh {
Vector<DummySurface> surfaces; Vector<DummySurface> surfaces;
int blend_shape_count; int blend_shape_count = 0;
RS::BlendShapeMode blend_shape_mode; RS::BlendShapeMode blend_shape_mode = RS::BlendShapeMode::BLEND_SHAPE_MODE_NORMALIZED;
}; };
mutable RID_PtrOwner<DummyTexture> texture_owner; mutable RID_PtrOwner<DummyTexture> texture_owner;

View file

@ -91,7 +91,7 @@ static IP_Address _sockaddr2ip(struct sockaddr *p_addr) {
IP_Address IP_Unix::_resolve_hostname(const String &p_hostname, Type p_type) { IP_Address IP_Unix::_resolve_hostname(const String &p_hostname, Type p_type) {
struct addrinfo hints; struct addrinfo hints;
struct addrinfo *result; struct addrinfo *result = nullptr;
memset(&hints, 0, sizeof(struct addrinfo)); memset(&hints, 0, sizeof(struct addrinfo));
if (p_type == TYPE_IPV4) { if (p_type == TYPE_IPV4) {

View file

@ -7645,7 +7645,6 @@ RenderingDevice *RenderingDeviceVulkan::create_local_device() {
} }
RenderingDeviceVulkan::RenderingDeviceVulkan() { RenderingDeviceVulkan::RenderingDeviceVulkan() {
screen_prepared = false;
} }
RenderingDeviceVulkan::~RenderingDeviceVulkan() { RenderingDeviceVulkan::~RenderingDeviceVulkan() {

View file

@ -99,7 +99,7 @@ class RenderingDeviceVulkan : public RenderingDevice {
ID_BASE_SHIFT = 58 //5 bits for ID types ID_BASE_SHIFT = 58 //5 bits for ID types
}; };
VkDevice device; VkDevice device = VK_NULL_HANDLE;
Map<RID, Set<RID>> dependency_map; //IDs to IDs that depend on it Map<RID, Set<RID>> dependency_map; //IDs to IDs that depend on it
Map<RID, Set<RID>> reverse_dependency_map; //same as above, but in reverse Map<RID, Set<RID>> reverse_dependency_map; //same as above, but in reverse
@ -124,35 +124,35 @@ class RenderingDeviceVulkan : public RenderingDevice {
// for a framebuffer to render into it. // for a framebuffer to render into it.
struct Texture { struct Texture {
VkImage image; VkImage image = VK_NULL_HANDLE;
VmaAllocation allocation; VmaAllocation allocation = nullptr;
VmaAllocationInfo allocation_info; VmaAllocationInfo allocation_info;
VkImageView view; VkImageView view = VK_NULL_HANDLE;
TextureType type; TextureType type;
DataFormat format; DataFormat format;
TextureSamples samples; TextureSamples samples;
uint32_t width; uint32_t width = 0;
uint32_t height; uint32_t height = 0;
uint32_t depth; uint32_t depth = 0;
uint32_t layers; uint32_t layers = 0;
uint32_t mipmaps; uint32_t mipmaps = 0;
uint32_t usage_flags; uint32_t usage_flags = 0;
uint32_t base_mipmap; uint32_t base_mipmap = 0;
uint32_t base_layer; uint32_t base_layer = 0;
Vector<DataFormat> allowed_shared_formats; Vector<DataFormat> allowed_shared_formats;
VkImageLayout layout; VkImageLayout layout;
uint32_t read_aspect_mask; uint32_t read_aspect_mask = 0;
uint32_t barrier_aspect_mask; uint32_t barrier_aspect_mask = 0;
bool bound; //bound to framebffer bool bound = false; //bound to framebffer
RID owner; RID owner;
}; };
RID_Owner<Texture, true> texture_owner; RID_Owner<Texture, true> texture_owner;
uint32_t texture_upload_region_size_px; uint32_t texture_upload_region_size_px = 0;
Vector<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);
@ -188,32 +188,28 @@ class RenderingDeviceVulkan : public RenderingDevice {
// See the comments in the code to understand better how it works. // See the comments in the code to understand better how it works.
struct StagingBufferBlock { struct StagingBufferBlock {
VkBuffer buffer; VkBuffer buffer = VK_NULL_HANDLE;
VmaAllocation allocation; VmaAllocation allocation = nullptr;
uint64_t frame_used; uint64_t frame_used = 0;
uint32_t fill_amount; uint32_t fill_amount = 0;
}; };
Vector<StagingBufferBlock> staging_buffer_blocks; Vector<StagingBufferBlock> staging_buffer_blocks;
int staging_buffer_current; int staging_buffer_current = 0;
uint32_t staging_buffer_block_size; uint32_t staging_buffer_block_size = 0;
uint64_t staging_buffer_max_size; uint64_t staging_buffer_max_size = 0;
bool staging_buffer_used; bool staging_buffer_used = false;
Error _staging_buffer_allocate(uint32_t p_amount, uint32_t p_required_align, uint32_t &r_alloc_offset, uint32_t &r_alloc_size, bool p_can_segment = true, bool p_on_draw_command_buffer = false); Error _staging_buffer_allocate(uint32_t p_amount, uint32_t p_required_align, uint32_t &r_alloc_offset, uint32_t &r_alloc_size, bool p_can_segment = true, bool p_on_draw_command_buffer = false);
Error _insert_staging_block(); Error _insert_staging_block();
struct Buffer { struct Buffer {
uint32_t size; uint32_t size = 0;
uint32_t usage; uint32_t usage = 0;
VkBuffer buffer; VkBuffer buffer = VK_NULL_HANDLE;
VmaAllocation allocation; VmaAllocation allocation = nullptr;
VkDescriptorBufferInfo buffer_info; //used for binding VkDescriptorBufferInfo buffer_info; //used for binding
Buffer() { Buffer() {
size = 0;
usage = 0;
buffer = VK_NULL_HANDLE;
allocation = nullptr;
} }
}; };
@ -276,15 +272,15 @@ class RenderingDeviceVulkan : public RenderingDevice {
Map<FramebufferFormatKey, FramebufferFormatID> framebuffer_format_cache; Map<FramebufferFormatKey, FramebufferFormatID> framebuffer_format_cache;
struct FramebufferFormat { struct FramebufferFormat {
const Map<FramebufferFormatKey, FramebufferFormatID>::Element *E; const Map<FramebufferFormatKey, FramebufferFormatID>::Element *E;
VkRenderPass render_pass; //here for constructing shaders, never used, see section (7.2. Render Pass Compatibility from Vulkan spec) VkRenderPass render_pass = VK_NULL_HANDLE; //here for constructing shaders, never used, see section (7.2. Render Pass Compatibility from Vulkan spec)
int color_attachments; //used for pipeline validation int color_attachments = 0; //used for pipeline validation
TextureSamples samples; TextureSamples samples;
}; };
Map<FramebufferFormatID, FramebufferFormat> framebuffer_formats; Map<FramebufferFormatID, FramebufferFormat> framebuffer_formats;
struct Framebuffer { struct Framebuffer {
FramebufferFormatID format_id; FramebufferFormatID format_id = 0;
struct VersionKey { struct VersionKey {
InitialAction initial_color_action; InitialAction initial_color_action;
FinalAction final_color_action; FinalAction final_color_action;
@ -307,12 +303,12 @@ class RenderingDeviceVulkan : public RenderingDevice {
} }
}; };
uint32_t storage_mask; uint32_t storage_mask = 0;
Vector<RID> texture_ids; Vector<RID> texture_ids;
struct Version { struct Version {
VkFramebuffer framebuffer; VkFramebuffer framebuffer = VK_NULL_HANDLE;
VkRenderPass render_pass; //this one is owned VkRenderPass render_pass = VK_NULL_HANDLE; //this one is owned
}; };
Map<VersionKey, Version> framebuffers; Map<VersionKey, Version> framebuffers;
@ -399,8 +395,8 @@ class RenderingDeviceVulkan : public RenderingDevice {
struct VertexDescriptionCache { struct VertexDescriptionCache {
Vector<VertexAttribute> vertex_formats; Vector<VertexAttribute> vertex_formats;
VkVertexInputBindingDescription *bindings; VkVertexInputBindingDescription *bindings = nullptr;
VkVertexInputAttributeDescription *attributes; VkVertexInputAttributeDescription *attributes = nullptr;
VkPipelineVertexInputStateCreateInfo create_info; VkPipelineVertexInputStateCreateInfo create_info;
}; };
@ -408,9 +404,9 @@ class RenderingDeviceVulkan : public RenderingDevice {
struct VertexArray { struct VertexArray {
RID buffer; RID buffer;
VertexFormatID description; VertexFormatID description = 0;
int vertex_count; int vertex_count = 0;
uint32_t max_instances_allowed; uint32_t max_instances_allowed = 0;
Vector<VkBuffer> buffers; //not owned, just referenced Vector<VkBuffer> buffers; //not owned, just referenced
Vector<VkDeviceSize> offsets; Vector<VkDeviceSize> offsets;
@ -419,21 +415,21 @@ class RenderingDeviceVulkan : public RenderingDevice {
RID_Owner<VertexArray, true> vertex_array_owner; RID_Owner<VertexArray, true> vertex_array_owner;
struct IndexBuffer : public Buffer { struct IndexBuffer : public Buffer {
uint32_t max_index; //used for validation uint32_t max_index = 0; //used for validation
uint32_t index_count; uint32_t index_count = 0;
VkIndexType index_type; VkIndexType index_type = VK_INDEX_TYPE_NONE_NV;
bool supports_restart_indices; bool supports_restart_indices = false;
}; };
RID_Owner<IndexBuffer, true> index_buffer_owner; RID_Owner<IndexBuffer, true> index_buffer_owner;
struct IndexArray { struct IndexArray {
uint32_t max_index; //remember the maximum index here too, for validation uint32_t max_index = 0; //remember the maximum index here too, for validation
VkBuffer buffer; //not owned, inherited from index buffer VkBuffer buffer; //not owned, inherited from index buffer
uint32_t offset; uint32_t offset = 0;
uint32_t indices; uint32_t indices = 0;
VkIndexType index_type; VkIndexType index_type = VK_INDEX_TYPE_NONE_NV;
bool supports_restart_indices; bool supports_restart_indices = false;
}; };
RID_Owner<IndexArray, true> index_array_owner; RID_Owner<IndexArray, true> index_array_owner;
@ -459,10 +455,10 @@ class RenderingDeviceVulkan : public RenderingDevice {
}; };
struct UniformInfo { struct UniformInfo {
UniformType type; UniformType type = UniformType::UNIFORM_TYPE_MAX;
int binding; int binding = 0;
uint32_t stages; uint32_t stages = 0;
int length; //size of arrays (in total elements), or ubos (in bytes * total elements) int length = 0; //size of arrays (in total elements), or ubos (in bytes * total elements)
bool operator!=(const UniformInfo &p_info) const { bool operator!=(const UniformInfo &p_info) const {
return (binding != p_info.binding || type != p_info.type || stages != p_info.stages || length != p_info.length); return (binding != p_info.binding || type != p_info.type || stages != p_info.stages || length != p_info.length);
@ -528,25 +524,25 @@ class RenderingDeviceVulkan : public RenderingDevice {
struct Shader { struct Shader {
struct Set { struct Set {
Vector<UniformInfo> uniform_info; Vector<UniformInfo> uniform_info;
VkDescriptorSetLayout descriptor_set_layout; VkDescriptorSetLayout descriptor_set_layout = VK_NULL_HANDLE;
}; };
uint32_t vertex_input_mask; //inputs used, this is mostly for validation uint32_t vertex_input_mask = 0; //inputs used, this is mostly for validation
int fragment_outputs; int fragment_outputs = 0;
struct PushConstant { struct PushConstant {
uint32_t push_constant_size; uint32_t push_constant_size = 0;
uint32_t push_constants_vk_stage; uint32_t push_constants_vk_stage = 0;
}; };
PushConstant push_constant; PushConstant push_constant;
bool is_compute = false; bool is_compute = false;
int max_output; int max_output = 0;
Vector<Set> sets; Vector<Set> sets;
Vector<uint32_t> set_formats; Vector<uint32_t> set_formats;
Vector<VkPipelineShaderStageCreateInfo> pipeline_stages; Vector<VkPipelineShaderStageCreateInfo> pipeline_stages;
VkPipelineLayout pipeline_layout; VkPipelineLayout pipeline_layout = VK_NULL_HANDLE;
}; };
String _shader_uniform_debug(RID p_shader, int p_set = -1); String _shader_uniform_debug(RID p_shader, int p_set = -1);
@ -610,7 +606,7 @@ class RenderingDeviceVulkan : public RenderingDevice {
}; };
Map<DescriptorPoolKey, Set<DescriptorPool *>> descriptor_pools; Map<DescriptorPoolKey, Set<DescriptorPool *>> descriptor_pools;
uint32_t max_descriptors_per_pool; uint32_t max_descriptors_per_pool = 0;
DescriptorPool *_descriptor_pool_allocate(const DescriptorPoolKey &p_key); DescriptorPool *_descriptor_pool_allocate(const DescriptorPoolKey &p_key);
void _descriptor_pool_free(const DescriptorPoolKey &p_key, DescriptorPool *p_pool); void _descriptor_pool_free(const DescriptorPoolKey &p_key, DescriptorPool *p_pool);
@ -621,7 +617,7 @@ class RenderingDeviceVulkan : public RenderingDevice {
//texture buffer needs a view //texture buffer needs a view
struct TextureBuffer { struct TextureBuffer {
Buffer buffer; Buffer buffer;
VkBufferView view; VkBufferView view = VK_NULL_HANDLE;
}; };
RID_Owner<TextureBuffer, true> texture_buffer_owner; RID_Owner<TextureBuffer, true> texture_buffer_owner;
@ -635,12 +631,12 @@ class RenderingDeviceVulkan : public RenderingDevice {
// the above restriction is not too serious. // the above restriction is not too serious.
struct UniformSet { struct UniformSet {
uint32_t format; uint32_t format = 0;
RID shader_id; RID shader_id;
uint32_t shader_set; uint32_t shader_set = 0;
DescriptorPool *pool; DescriptorPool *pool = nullptr;
DescriptorPoolKey pool_key; DescriptorPoolKey pool_key;
VkDescriptorSet descriptor_set; VkDescriptorSet descriptor_set = VK_NULL_HANDLE;
//VkPipelineLayout pipeline_layout; //not owned, inherited from shader //VkPipelineLayout pipeline_layout; //not owned, inherited from shader
Vector<RID> attachable_textures; //used for validation Vector<RID> attachable_textures; //used for validation
Vector<Texture *> mutable_sampled_textures; //used for layout change Vector<Texture *> mutable_sampled_textures; //used for layout change
@ -668,21 +664,21 @@ class RenderingDeviceVulkan : public RenderingDevice {
//Cached values for validation //Cached values for validation
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
struct Validation { struct Validation {
FramebufferFormatID framebuffer_format; FramebufferFormatID framebuffer_format = 0;
uint32_t dynamic_state; uint32_t dynamic_state = 0;
VertexFormatID vertex_format; VertexFormatID vertex_format = 0;
bool uses_restart_indices; bool uses_restart_indices = false;
uint32_t primitive_minimum; uint32_t primitive_minimum = 0;
uint32_t primitive_divisor; uint32_t primitive_divisor = 0;
} validation; } validation;
#endif #endif
//Actual pipeline //Actual pipeline
RID shader; RID shader;
Vector<uint32_t> set_formats; Vector<uint32_t> set_formats;
VkPipelineLayout pipeline_layout; // not owned, needed for push constants VkPipelineLayout pipeline_layout = VK_NULL_HANDLE; // not owned, needed for push constants
VkPipeline pipeline; VkPipeline pipeline = VK_NULL_HANDLE;
uint32_t push_constant_size; uint32_t push_constant_size = 0;
uint32_t push_constant_stages; uint32_t push_constant_stages = 0;
}; };
RID_Owner<RenderPipeline, true> render_pipeline_owner; RID_Owner<RenderPipeline, true> render_pipeline_owner;
@ -690,10 +686,10 @@ class RenderingDeviceVulkan : public RenderingDevice {
struct ComputePipeline { struct ComputePipeline {
RID shader; RID shader;
Vector<uint32_t> set_formats; Vector<uint32_t> set_formats;
VkPipelineLayout pipeline_layout; // not owned, needed for push constants VkPipelineLayout pipeline_layout = VK_NULL_HANDLE; // not owned, needed for push constants
VkPipeline pipeline; VkPipeline pipeline = VK_NULL_HANDLE;
uint32_t push_constant_size; uint32_t push_constant_size = 0;
uint32_t push_constant_stages; uint32_t push_constant_stages = 0;
}; };
RID_Owner<ComputePipeline, true> compute_pipeline_owner; RID_Owner<ComputePipeline, true> compute_pipeline_owner;
@ -714,14 +710,14 @@ class RenderingDeviceVulkan : public RenderingDevice {
// each needs it's own command pool. // each needs it's own command pool.
struct SplitDrawListAllocator { struct SplitDrawListAllocator {
VkCommandPool command_pool; VkCommandPool command_pool = VK_NULL_HANDLE;
Vector<VkCommandBuffer> command_buffers; //one for each frame Vector<VkCommandBuffer> command_buffers; //one for each frame
}; };
Vector<SplitDrawListAllocator> split_draw_list_allocators; Vector<SplitDrawListAllocator> split_draw_list_allocators;
struct DrawList { struct DrawList {
VkCommandBuffer command_buffer; // If persistent, this is owned, otherwise it's shared with the ringbuffer. VkCommandBuffer command_buffer = VK_NULL_HANDLE; // If persistent, this is owned, otherwise it's shared with the ringbuffer.
Rect2i viewport; Rect2i viewport;
struct SetState { struct SetState {
@ -755,7 +751,7 @@ class RenderingDeviceVulkan : public RenderingDevice {
bool index_buffer_uses_restart_indices = false; bool index_buffer_uses_restart_indices = false;
uint32_t index_array_size = 0; uint32_t index_array_size = 0;
uint32_t index_array_max_index = 0; uint32_t index_array_max_index = 0;
uint32_t index_array_offset; uint32_t index_array_offset = 0;
Vector<uint32_t> set_formats; Vector<uint32_t> set_formats;
Vector<bool> set_bound; Vector<bool> set_bound;
Vector<RID> set_rids; Vector<RID> set_rids;
@ -766,8 +762,8 @@ class RenderingDeviceVulkan : public RenderingDevice {
RID pipeline_shader; RID pipeline_shader;
uint32_t invalid_set_from = 0; uint32_t invalid_set_from = 0;
bool pipeline_uses_restart_indices = false; bool pipeline_uses_restart_indices = false;
uint32_t pipeline_primitive_divisor; uint32_t pipeline_primitive_divisor = 0;
uint32_t pipeline_primitive_minimum; uint32_t pipeline_primitive_minimum = 0;
Vector<uint32_t> pipeline_set_formats; Vector<uint32_t> pipeline_set_formats;
uint32_t pipeline_push_constant_size = 0; uint32_t pipeline_push_constant_size = 0;
bool pipeline_push_constant_supplied = false; bool pipeline_push_constant_supplied = false;
@ -781,13 +777,13 @@ class RenderingDeviceVulkan : public RenderingDevice {
#endif #endif
}; };
DrawList *draw_list; // One for regular draw lists, multiple for split. DrawList *draw_list = nullptr; // One for regular draw lists, multiple for split.
uint32_t draw_list_count; uint32_t draw_list_count = 0;
bool draw_list_split; bool draw_list_split = false;
Vector<RID> draw_list_bound_textures; Vector<RID> draw_list_bound_textures;
Vector<RID> draw_list_storage_textures; Vector<RID> draw_list_storage_textures;
bool draw_list_unbind_color_textures; bool draw_list_unbind_color_textures = false;
bool draw_list_unbind_depth_textures; bool draw_list_unbind_depth_textures = false;
void _draw_list_insert_clear_region(DrawList *draw_list, Framebuffer *framebuffer, Point2i viewport_offset, Point2i viewport_size, bool p_clear_color, const Vector<Color> &p_clear_colors, bool p_clear_depth, float p_depth, uint32_t p_stencil); void _draw_list_insert_clear_region(DrawList *draw_list, Framebuffer *framebuffer, Point2i viewport_offset, Point2i viewport_size, bool p_clear_color, const Vector<Color> &p_clear_colors, bool p_clear_depth, float p_depth, uint32_t p_stencil);
Error _draw_list_setup_framebuffer(Framebuffer *p_framebuffer, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, VkFramebuffer *r_framebuffer, VkRenderPass *r_render_pass); Error _draw_list_setup_framebuffer(Framebuffer *p_framebuffer, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, VkFramebuffer *r_framebuffer, VkRenderPass *r_render_pass);
@ -800,7 +796,7 @@ class RenderingDeviceVulkan : public RenderingDevice {
/**********************/ /**********************/
struct ComputeList { struct ComputeList {
VkCommandBuffer command_buffer; // If persistent, this is owned, otherwise it's shared with the ringbuffer. VkCommandBuffer command_buffer = VK_NULL_HANDLE; // If persistent, this is owned, otherwise it's shared with the ringbuffer.
struct SetState { struct SetState {
uint32_t pipeline_expected_format = 0; uint32_t pipeline_expected_format = 0;
@ -837,7 +833,7 @@ class RenderingDeviceVulkan : public RenderingDevice {
#endif #endif
}; };
ComputeList *compute_list; ComputeList *compute_list = nullptr;
/**************************/ /**************************/
/**** FRAME MANAGEMENT ****/ /**** FRAME MANAGEMENT ****/
@ -869,46 +865,46 @@ class RenderingDeviceVulkan : public RenderingDevice {
List<RenderPipeline> render_pipelines_to_dispose_of; List<RenderPipeline> render_pipelines_to_dispose_of;
List<ComputePipeline> compute_pipelines_to_dispose_of; List<ComputePipeline> compute_pipelines_to_dispose_of;
VkCommandPool command_pool; VkCommandPool command_pool = VK_NULL_HANDLE;
VkCommandBuffer setup_command_buffer; //used at the beginning of every frame for set-up VkCommandBuffer setup_command_buffer = VK_NULL_HANDLE; //used at the beginning of every frame for set-up
VkCommandBuffer draw_command_buffer; //used at the beginning of every frame for set-up VkCommandBuffer draw_command_buffer = VK_NULL_HANDLE; //used at the beginning of every frame for set-up
struct Timestamp { struct Timestamp {
String description; String description;
uint64_t value; uint64_t value = 0;
}; };
VkQueryPool timestamp_pool; VkQueryPool timestamp_pool;
String *timestamp_names; String *timestamp_names = nullptr;
uint64_t *timestamp_cpu_values; uint64_t *timestamp_cpu_values = nullptr;
uint32_t timestamp_count; uint32_t timestamp_count = 0;
String *timestamp_result_names; String *timestamp_result_names = nullptr;
uint64_t *timestamp_cpu_result_values; uint64_t *timestamp_cpu_result_values = nullptr;
uint64_t *timestamp_result_values; uint64_t *timestamp_result_values = nullptr;
uint32_t timestamp_result_count; uint32_t timestamp_result_count = 0;
uint64_t index; uint64_t index = 0;
}; };
uint32_t max_timestamp_query_elements; uint32_t max_timestamp_query_elements = 0;
Frame *frames; //frames available, for main device they are cycled (usually 3), for local devices only 1 Frame *frames = nullptr; //frames available, for main device they are cycled (usually 3), for local devices only 1
int frame; //current frame int frame = 0; //current frame
int frame_count; //total amount of frames int frame_count = 0; //total amount of frames
uint64_t frames_drawn; uint64_t frames_drawn = 0;
RID local_device; RID local_device;
bool local_device_processing = false; bool local_device_processing = false;
void _free_pending_resources(int p_frame); void _free_pending_resources(int p_frame);
VmaAllocator allocator; VmaAllocator allocator = nullptr;
VulkanContext *context; VulkanContext *context = nullptr;
void _free_internal(RID p_id); void _free_internal(RID p_id);
void _flush(bool p_current_frame); void _flush(bool p_current_frame);
bool screen_prepared; bool screen_prepared = false;
template <class T> template <class T>
void _free_rids(T &p_owner, const char *p_type); void _free_rids(T &p_owner, const char *p_type);

View file

@ -47,13 +47,13 @@ class VulkanContext {
FRAME_LAG = 2 FRAME_LAG = 2
}; };
VkInstance inst; VkInstance inst = VK_NULL_HANDLE;
VkSurfaceKHR surface; VkSurfaceKHR surface = VK_NULL_HANDLE;
VkPhysicalDevice gpu; VkPhysicalDevice gpu = VK_NULL_HANDLE;
VkPhysicalDeviceProperties gpu_props; VkPhysicalDeviceProperties gpu_props;
uint32_t queue_family_count; uint32_t queue_family_count = 0;
VkQueueFamilyProperties *queue_props = nullptr; VkQueueFamilyProperties *queue_props = nullptr;
VkDevice device; VkDevice device = VK_NULL_HANDLE;
bool device_initialized = false; bool device_initialized = false;
bool inst_initialized = false; bool inst_initialized = false;
@ -61,17 +61,17 @@ class VulkanContext {
// Present queue. // Present queue.
bool queues_initialized = false; bool queues_initialized = false;
uint32_t graphics_queue_family_index; uint32_t graphics_queue_family_index = 0;
uint32_t present_queue_family_index; uint32_t present_queue_family_index = 0;
bool separate_present_queue; bool separate_present_queue = false;
VkQueue graphics_queue; VkQueue graphics_queue = VK_NULL_HANDLE;
VkQueue present_queue; VkQueue present_queue = VK_NULL_HANDLE;
VkColorSpaceKHR color_space; VkColorSpaceKHR color_space;
VkFormat format; VkFormat format;
VkSemaphore image_acquired_semaphores[FRAME_LAG]; VkSemaphore image_acquired_semaphores[FRAME_LAG];
VkSemaphore draw_complete_semaphores[FRAME_LAG]; VkSemaphore draw_complete_semaphores[FRAME_LAG];
VkSemaphore image_ownership_semaphores[FRAME_LAG]; VkSemaphore image_ownership_semaphores[FRAME_LAG];
int frame_index; int frame_index = 0;
VkFence fences[FRAME_LAG]; VkFence fences[FRAME_LAG];
VkPhysicalDeviceMemoryProperties memory_properties; VkPhysicalDeviceMemoryProperties memory_properties;
VkPhysicalDeviceFeatures physical_device_features; VkPhysicalDeviceFeatures physical_device_features;
@ -91,14 +91,14 @@ class VulkanContext {
uint32_t current_buffer = 0; uint32_t current_buffer = 0;
int width = 0; int width = 0;
int height = 0; int height = 0;
VkCommandPool present_cmd_pool; // For separate present queue. VkCommandPool present_cmd_pool = VK_NULL_HANDLE; // For separate present queue.
VkRenderPass render_pass = VK_NULL_HANDLE; VkRenderPass render_pass = VK_NULL_HANDLE;
}; };
struct LocalDevice { struct LocalDevice {
bool waiting = false; bool waiting = false;
VkDevice device; VkDevice device = VK_NULL_HANDLE;
VkQueue queue; VkQueue queue = VK_NULL_HANDLE;
}; };
RID_Owner<LocalDevice, true> local_device_owner; RID_Owner<LocalDevice, true> local_device_owner;
@ -108,7 +108,7 @@ class VulkanContext {
// Commands. // Commands.
bool prepared; bool prepared = false;
Vector<VkCommandBuffer> command_buffer_queue; Vector<VkCommandBuffer> command_buffer_queue;
int command_buffer_count = 1; int command_buffer_count = 1;
@ -142,7 +142,7 @@ class VulkanContext {
PFN_vkGetRefreshCycleDurationGOOGLE fpGetRefreshCycleDurationGOOGLE; PFN_vkGetRefreshCycleDurationGOOGLE fpGetRefreshCycleDurationGOOGLE;
PFN_vkGetPastPresentationTimingGOOGLE fpGetPastPresentationTimingGOOGLE; PFN_vkGetPastPresentationTimingGOOGLE fpGetPastPresentationTimingGOOGLE;
VkDebugUtilsMessengerEXT dbg_messenger; VkDebugUtilsMessengerEXT dbg_messenger = VK_NULL_HANDLE;
Error _create_validation_layers(); Error _create_validation_layers();
Error _initialize_extensions(); Error _initialize_extensions();

View file

@ -367,8 +367,6 @@ DirAccessWindows::DirAccessWindows() {
p->h = INVALID_HANDLE_VALUE; p->h = INVALID_HANDLE_VALUE;
current_dir = "."; current_dir = ".";
drive_count = 0;
#ifdef UWP_ENABLED #ifdef UWP_ENABLED
Windows::Storage::StorageFolder ^ install_folder = Windows::ApplicationModel::Package::Current->InstalledLocation; Windows::Storage::StorageFolder ^ install_folder = Windows::ApplicationModel::Package::Current->InstalledLocation;
change_dir(install_folder->Path->Data()); change_dir(install_folder->Path->Data());

View file

@ -46,16 +46,16 @@ class DirAccessWindows : public DirAccess {
MAX_DRIVES = 26 MAX_DRIVES = 26
}; };
DirAccessWindowsPrivate *p; DirAccessWindowsPrivate *p = nullptr;
/* Windows stuff */ /* Windows stuff */
char drives[MAX_DRIVES]; // a-z: char drives[MAX_DRIVES] = { 0 }; // a-z:
int drive_count; int drive_count = 0;
String current_dir; String current_dir;
bool _cisdir; bool _cisdir = false;
bool _cishidden; bool _cishidden = false;
public: public:
virtual Error list_dir_begin(); ///< This starts dir listing virtual Error list_dir_begin(); ///< This starts dir listing

View file

@ -65,28 +65,28 @@ class AudioDriverXAudio2 : public AudioDriver {
Thread *thread = nullptr; Thread *thread = nullptr;
Mutex mutex; Mutex mutex;
int32_t *samples_in; int32_t *samples_in = nullptr;
int16_t *samples_out[AUDIO_BUFFERS]; int16_t *samples_out[AUDIO_BUFFERS];
static void thread_func(void *p_udata); static void thread_func(void *p_udata);
int buffer_size; int buffer_size = 0;
unsigned int mix_rate; unsigned int mix_rate = 0;
SpeakerMode speaker_mode; SpeakerMode speaker_mode = SpeakerMode::SPEAKER_MODE_STEREO;
int channels; int channels = 0;
bool active; bool active = false;
bool thread_exited; bool thread_exited = false;
mutable bool exit_thread; mutable bool exit_thread = false;
bool pcm_open; bool pcm_open = false;
WAVEFORMATEX wave_format = { 0 }; WAVEFORMATEX wave_format = { 0 };
Microsoft::WRL::ComPtr<IXAudio2> xaudio; Microsoft::WRL::ComPtr<IXAudio2> xaudio;
int current_buffer = 0; int current_buffer = 0;
IXAudio2MasteringVoice *mastering_voice; IXAudio2MasteringVoice *mastering_voice = nullptr;
XAUDIO2_BUFFER xaudio_buffer[AUDIO_BUFFERS]; XAUDIO2_BUFFER xaudio_buffer[AUDIO_BUFFERS];
IXAudio2SourceVoice *source_voice; IXAudio2SourceVoice *source_voice = nullptr;
XAudio2DriverVoiceCallback voice_callback; XAudio2DriverVoiceCallback voice_callback;
public: public: