feat: updated engine version to 4.4-rc1
This commit is contained in:
parent
ee00efde1f
commit
21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions
|
|
@ -48,7 +48,6 @@
|
|||
|
||||
#include "core/object/object.h"
|
||||
#include "core/variant/type_info.h"
|
||||
#include "servers/display_server.h"
|
||||
#include "servers/rendering/rendering_context_driver.h"
|
||||
#include "servers/rendering/rendering_device_commons.h"
|
||||
|
||||
|
|
@ -104,14 +103,14 @@ struct VersatileResourceTemplate {
|
|||
uint8_t data[MAX_RESOURCE_SIZE];
|
||||
|
||||
template <typename T>
|
||||
static T *allocate(PagedAllocator<VersatileResourceTemplate> &p_allocator) {
|
||||
static T *allocate(PagedAllocator<VersatileResourceTemplate, true> &p_allocator) {
|
||||
T *obj = (T *)p_allocator.alloc();
|
||||
memnew_placement(obj, T);
|
||||
return obj;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static void free(PagedAllocator<VersatileResourceTemplate> &p_allocator, T *p_object) {
|
||||
static void free(PagedAllocator<VersatileResourceTemplate, true> &p_allocator, T *p_object) {
|
||||
p_object->~T();
|
||||
p_allocator.free((VersatileResourceTemplate *)p_object);
|
||||
}
|
||||
|
|
@ -120,29 +119,35 @@ struct VersatileResourceTemplate {
|
|||
class RenderingDeviceDriver : public RenderingDeviceCommons {
|
||||
public:
|
||||
struct ID {
|
||||
size_t id = 0;
|
||||
uint64_t id = 0;
|
||||
_ALWAYS_INLINE_ ID() = default;
|
||||
_ALWAYS_INLINE_ ID(size_t p_id) :
|
||||
_ALWAYS_INLINE_ ID(uint64_t p_id) :
|
||||
id(p_id) {}
|
||||
};
|
||||
|
||||
#define DEFINE_ID(m_name) \
|
||||
struct m_name##ID : public ID { \
|
||||
_ALWAYS_INLINE_ explicit operator bool() const { return id != 0; } \
|
||||
_ALWAYS_INLINE_ m_name##ID &operator=(m_name##ID p_other) { \
|
||||
id = p_other.id; \
|
||||
return *this; \
|
||||
} \
|
||||
_ALWAYS_INLINE_ bool operator<(const m_name##ID &p_other) const { return id < p_other.id; } \
|
||||
_ALWAYS_INLINE_ bool operator==(const m_name##ID &p_other) const { return id == p_other.id; } \
|
||||
_ALWAYS_INLINE_ bool operator!=(const m_name##ID &p_other) const { return id != p_other.id; } \
|
||||
_ALWAYS_INLINE_ m_name##ID(const m_name##ID &p_other) : ID(p_other.id) {} \
|
||||
_ALWAYS_INLINE_ explicit m_name##ID(uint64_t p_int) : ID(p_int) {} \
|
||||
_ALWAYS_INLINE_ explicit m_name##ID(void *p_ptr) : ID((size_t)p_ptr) {} \
|
||||
_ALWAYS_INLINE_ m_name##ID() = default; \
|
||||
}; \
|
||||
/* Ensure type-punnable to pointer. Makes some things easier.*/ \
|
||||
static_assert(sizeof(m_name##ID) == sizeof(void *));
|
||||
#define DEFINE_ID(m_name) \
|
||||
struct m_name##ID : public ID { \
|
||||
_ALWAYS_INLINE_ explicit operator bool() const { \
|
||||
return id != 0; \
|
||||
} \
|
||||
_ALWAYS_INLINE_ m_name##ID &operator=(m_name##ID p_other) { \
|
||||
id = p_other.id; \
|
||||
return *this; \
|
||||
} \
|
||||
_ALWAYS_INLINE_ bool operator<(const m_name##ID &p_other) const { \
|
||||
return id < p_other.id; \
|
||||
} \
|
||||
_ALWAYS_INLINE_ bool operator==(const m_name##ID &p_other) const { \
|
||||
return id == p_other.id; \
|
||||
} \
|
||||
_ALWAYS_INLINE_ bool operator!=(const m_name##ID &p_other) const { \
|
||||
return id != p_other.id; \
|
||||
} \
|
||||
_ALWAYS_INLINE_ m_name##ID(const m_name##ID &p_other) : ID(p_other.id) {} \
|
||||
_ALWAYS_INLINE_ explicit m_name##ID(uint64_t p_int) : ID(p_int) {} \
|
||||
_ALWAYS_INLINE_ explicit m_name##ID(void *p_ptr) : ID((uint64_t)p_ptr) {} \
|
||||
_ALWAYS_INLINE_ m_name##ID() = default; \
|
||||
};
|
||||
|
||||
// Id types declared before anything else to prevent cyclic dependencies between the different concerns.
|
||||
DEFINE_ID(Buffer);
|
||||
|
|
@ -192,6 +197,7 @@ public:
|
|||
BUFFER_USAGE_INDEX_BIT = (1 << 6),
|
||||
BUFFER_USAGE_VERTEX_BIT = (1 << 7),
|
||||
BUFFER_USAGE_INDIRECT_BIT = (1 << 8),
|
||||
BUFFER_USAGE_DEVICE_ADDRESS_BIT = (1 << 17),
|
||||
};
|
||||
|
||||
enum {
|
||||
|
|
@ -205,6 +211,8 @@ public:
|
|||
virtual uint64_t buffer_get_allocation_size(BufferID p_buffer) = 0;
|
||||
virtual uint8_t *buffer_map(BufferID p_buffer) = 0;
|
||||
virtual void buffer_unmap(BufferID p_buffer) = 0;
|
||||
// Only for a buffer with BUFFER_USAGE_DEVICE_ADDRESS_BIT.
|
||||
virtual uint64_t buffer_get_device_address(BufferID p_buffer) = 0;
|
||||
|
||||
/*****************/
|
||||
/**** TEXTURE ****/
|
||||
|
|
@ -220,6 +228,7 @@ public:
|
|||
|
||||
enum TextureLayout {
|
||||
TEXTURE_LAYOUT_UNDEFINED,
|
||||
TEXTURE_LAYOUT_GENERAL,
|
||||
TEXTURE_LAYOUT_STORAGE_OPTIMAL,
|
||||
TEXTURE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||
TEXTURE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
|
||||
|
|
@ -427,6 +436,7 @@ public:
|
|||
};
|
||||
|
||||
virtual CommandPoolID command_pool_create(CommandQueueFamilyID p_cmd_queue_family, CommandBufferType p_cmd_buffer_type) = 0;
|
||||
virtual bool command_pool_reset(CommandPoolID p_cmd_pool) = 0;
|
||||
virtual void command_pool_free(CommandPoolID p_cmd_pool) = 0;
|
||||
|
||||
// ----- BUFFER -----
|
||||
|
|
@ -453,9 +463,16 @@ public:
|
|||
// Retrieve the render pass that can be used to draw on the swap chain's framebuffers.
|
||||
virtual RenderPassID swap_chain_get_render_pass(SwapChainID p_swap_chain) = 0;
|
||||
|
||||
// Retrieve the rotation in degrees to apply as a pre-transform. Usually 0 on PC. May be 0, 90, 180 & 270 on Android.
|
||||
virtual int swap_chain_get_pre_rotation_degrees(SwapChainID p_swap_chain) { return 0; }
|
||||
|
||||
// Retrieve the format used by the swap chain's framebuffers.
|
||||
virtual DataFormat swap_chain_get_format(SwapChainID p_swap_chain) = 0;
|
||||
|
||||
// Tells the swapchain the max_fps so it can use the proper frame pacing.
|
||||
// Android uses this with Swappy library. Some implementations or platforms may ignore this hint.
|
||||
virtual void swap_chain_set_max_fps(SwapChainID p_swap_chain, int p_max_fps) {}
|
||||
|
||||
// Wait until all rendering associated to the swap chain is finished before deleting it.
|
||||
virtual void swap_chain_free(SwapChainID p_swap_chain) = 0;
|
||||
|
||||
|
|
@ -472,10 +489,25 @@ public:
|
|||
|
||||
virtual String shader_get_binary_cache_key() = 0;
|
||||
virtual Vector<uint8_t> shader_compile_binary_from_spirv(VectorView<ShaderStageSPIRVData> p_spirv, const String &p_shader_name) = 0;
|
||||
virtual ShaderID shader_create_from_bytecode(const Vector<uint8_t> &p_shader_binary, ShaderDescription &r_shader_desc, String &r_name) = 0;
|
||||
|
||||
struct ImmutableSampler {
|
||||
UniformType type = UNIFORM_TYPE_MAX;
|
||||
uint32_t binding = 0xffffffff; // Binding index as specified in shader.
|
||||
LocalVector<ID> ids;
|
||||
};
|
||||
/** Creates a Pipeline State Object (PSO) out of the shader and all the input data it needs.
|
||||
@param p_shader_binary Shader binary bytecode (e.g. SPIR-V).
|
||||
@param r_shader_desc TBD.
|
||||
@param r_name TBD.
|
||||
@param p_immutable_samplers Immutable samplers can be embedded when creating the pipeline layout on the condition they
|
||||
remain valid and unchanged, so they don't need to be specified when creating uniform sets.
|
||||
@return PSO resource for binding.
|
||||
*/
|
||||
virtual ShaderID shader_create_from_bytecode(const Vector<uint8_t> &p_shader_binary, ShaderDescription &r_shader_desc, String &r_name, const Vector<ImmutableSampler> &p_immutable_samplers) = 0;
|
||||
// Only meaningful if API_TRAIT_SHADER_CHANGE_INVALIDATION is SHADER_CHANGE_INVALIDATION_ALL_OR_NONE_ACCORDING_TO_LAYOUT_HASH.
|
||||
virtual uint32_t shader_get_layout_hash(ShaderID p_shader) { return 0; }
|
||||
virtual void shader_free(ShaderID p_shader) = 0;
|
||||
virtual void shader_destroy_modules(ShaderID p_shader) = 0;
|
||||
|
||||
protected:
|
||||
// An optional service to implementations.
|
||||
|
|
@ -490,10 +522,15 @@ public:
|
|||
UniformType type = UNIFORM_TYPE_MAX;
|
||||
uint32_t binding = 0xffffffff; // Binding index as specified in shader.
|
||||
LocalVector<ID> ids;
|
||||
// Flag to indicate that this is an immutable sampler so it is skipped when creating uniform
|
||||
// sets, as it would be set previously when creating the pipeline layout.
|
||||
bool immutable_sampler = false;
|
||||
};
|
||||
|
||||
virtual UniformSetID uniform_set_create(VectorView<BoundUniform> p_uniforms, ShaderID p_shader, uint32_t p_set_index) = 0;
|
||||
virtual UniformSetID uniform_set_create(VectorView<BoundUniform> p_uniforms, ShaderID p_shader, uint32_t p_set_index, int p_linear_pool_index) = 0;
|
||||
virtual void linear_uniform_set_pools_reset(int p_linear_pool_index) {}
|
||||
virtual void uniform_set_free(UniformSetID p_uniform_set) = 0;
|
||||
virtual bool uniform_sets_have_linear_pools() const { return false; }
|
||||
|
||||
// ----- COMMANDS -----
|
||||
|
||||
|
|
@ -635,6 +672,7 @@ public:
|
|||
// Binding.
|
||||
virtual void command_bind_render_pipeline(CommandBufferID p_cmd_buffer, PipelineID p_pipeline) = 0;
|
||||
virtual void command_bind_render_uniform_set(CommandBufferID p_cmd_buffer, UniformSetID p_uniform_set, ShaderID p_shader, uint32_t p_set_index) = 0;
|
||||
virtual void command_bind_render_uniform_sets(CommandBufferID p_cmd_buffer, VectorView<UniformSetID> p_uniform_sets, ShaderID p_shader, uint32_t p_first_set_index, uint32_t p_set_count) = 0;
|
||||
|
||||
// Drawing.
|
||||
virtual void command_render_draw(CommandBufferID p_cmd_buffer, uint32_t p_vertex_count, uint32_t p_instance_count, uint32_t p_base_vertex, uint32_t p_first_instance) = 0;
|
||||
|
|
@ -677,6 +715,7 @@ public:
|
|||
// Binding.
|
||||
virtual void command_bind_compute_pipeline(CommandBufferID p_cmd_buffer, PipelineID p_pipeline) = 0;
|
||||
virtual void command_bind_compute_uniform_set(CommandBufferID p_cmd_buffer, UniformSetID p_uniform_set, ShaderID p_shader, uint32_t p_set_index) = 0;
|
||||
virtual void command_bind_compute_uniform_sets(CommandBufferID p_cmd_buffer, VectorView<UniformSetID> p_uniform_sets, ShaderID p_shader, uint32_t p_first_set_index, uint32_t p_set_count) = 0;
|
||||
|
||||
// Dispatching.
|
||||
virtual void command_compute_dispatch(CommandBufferID p_cmd_buffer, uint32_t p_x_groups, uint32_t p_y_groups, uint32_t p_z_groups) = 0;
|
||||
|
|
@ -686,6 +725,12 @@ public:
|
|||
|
||||
virtual PipelineID compute_pipeline_create(ShaderID p_shader, VectorView<PipelineSpecializationConstant> p_specialization_constants) = 0;
|
||||
|
||||
/******************/
|
||||
/**** CALLBACK ****/
|
||||
/******************/
|
||||
|
||||
typedef void (*DriverCallback)(RenderingDeviceDriver *p_driver, CommandBufferID p_command_buffer, void *p_userdata);
|
||||
|
||||
/*****************/
|
||||
/**** QUERIES ****/
|
||||
/*****************/
|
||||
|
|
@ -709,6 +754,11 @@ public:
|
|||
virtual void command_begin_label(CommandBufferID p_cmd_buffer, const char *p_label_name, const Color &p_color) = 0;
|
||||
virtual void command_end_label(CommandBufferID p_cmd_buffer) = 0;
|
||||
|
||||
/****************/
|
||||
/**** DEBUG *****/
|
||||
/****************/
|
||||
virtual void command_insert_breadcrumb(CommandBufferID p_cmd_buffer, uint32_t p_data) = 0;
|
||||
|
||||
/********************/
|
||||
/**** SUBMISSION ****/
|
||||
/********************/
|
||||
|
|
@ -744,6 +794,8 @@ public:
|
|||
API_TRAIT_TEXTURE_DATA_ROW_PITCH_STEP,
|
||||
API_TRAIT_SECONDARY_VIEWPORT_SCISSOR,
|
||||
API_TRAIT_CLEARS_WITH_COPY_ENGINE,
|
||||
API_TRAIT_USE_GENERAL_IN_COPY_QUEUES,
|
||||
API_TRAIT_BUFFERS_REQUIRE_TRANSITIONS,
|
||||
};
|
||||
|
||||
enum ShaderChangeInvalidation {
|
||||
|
|
@ -759,6 +811,7 @@ public:
|
|||
DEVICE_OPENGL,
|
||||
DEVICE_VULKAN,
|
||||
DEVICE_DIRECTX,
|
||||
DEVICE_METAL,
|
||||
};
|
||||
|
||||
struct Capabilities {
|
||||
|
|
@ -770,6 +823,7 @@ public:
|
|||
virtual void set_object_name(ObjectType p_type, ID p_driver_id, const String &p_name) = 0;
|
||||
virtual uint64_t get_resource_native_handle(DriverResource p_type, ID p_driver_id) = 0;
|
||||
virtual uint64_t get_total_memory_used() = 0;
|
||||
virtual uint64_t get_lazily_memory_used() = 0;
|
||||
virtual uint64_t limit_get(Limit p_limit) = 0;
|
||||
virtual uint64_t api_trait_get(ApiTrait p_trait);
|
||||
virtual bool has_feature(Features p_feature) = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue