feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef RENDERING_DEVICE_H
|
||||
#define RENDERING_DEVICE_H
|
||||
#pragma once
|
||||
|
||||
#include "core/object/worker_thread_pool.h"
|
||||
#include "core/os/condition_variable.h"
|
||||
|
|
@ -171,7 +170,7 @@ private:
|
|||
int current = 0;
|
||||
uint32_t block_size = 0;
|
||||
uint64_t max_size = 0;
|
||||
BitField<RDD::BufferUsageBits> usage_bits;
|
||||
BitField<RDD::BufferUsageBits> usage_bits = {};
|
||||
bool used = false;
|
||||
};
|
||||
|
||||
|
|
@ -185,7 +184,7 @@ private:
|
|||
struct Buffer {
|
||||
RDD::BufferID driver_id;
|
||||
uint32_t size = 0;
|
||||
BitField<RDD::BufferUsageBits> usage;
|
||||
BitField<RDD::BufferUsageBits> usage = {};
|
||||
RDG::ResourceTracker *draw_tracker = nullptr;
|
||||
int32_t transfer_worker_index = -1;
|
||||
uint64_t transfer_worker_operation = 0;
|
||||
|
|
@ -203,7 +202,8 @@ private:
|
|||
bool split_swapchain_into_its_own_cmd_buffer = true;
|
||||
uint32_t gpu_copy_count = 0;
|
||||
uint32_t copy_bytes_count = 0;
|
||||
String perf_report_text;
|
||||
uint32_t prev_gpu_copy_count = 0;
|
||||
uint32_t prev_copy_bytes_count = 0;
|
||||
|
||||
RID_Owner<Buffer, true> uniform_buffer_owner;
|
||||
RID_Owner<Buffer, true> storage_buffer_owner;
|
||||
|
|
@ -254,6 +254,8 @@ public:
|
|||
CALLBACK_RESOURCE_USAGE_STORAGE_IMAGE_READ_WRITE,
|
||||
CALLBACK_RESOURCE_USAGE_ATTACHMENT_COLOR_READ_WRITE,
|
||||
CALLBACK_RESOURCE_USAGE_ATTACHMENT_DEPTH_STENCIL_READ_WRITE,
|
||||
CALLBACK_RESOURCE_USAGE_ATTACHMENT_FRAGMENT_SHADING_RATE_READ,
|
||||
CALLBACK_RESOURCE_USAGE_ATTACHMENT_FRAGMENT_DENSITY_MAP_READ,
|
||||
CALLBACK_RESOURCE_USAGE_MAX
|
||||
};
|
||||
|
||||
|
|
@ -313,8 +315,8 @@ public:
|
|||
bool is_discardable = false;
|
||||
bool has_initial_data = false;
|
||||
|
||||
BitField<RDD::TextureAspectBits> read_aspect_flags;
|
||||
BitField<RDD::TextureAspectBits> barrier_aspect_flags;
|
||||
BitField<RDD::TextureAspectBits> read_aspect_flags = {};
|
||||
BitField<RDD::TextureAspectBits> barrier_aspect_flags = {};
|
||||
bool bound = false; // Bound to framebuffer.
|
||||
RID owner;
|
||||
|
||||
|
|
@ -359,12 +361,13 @@ public:
|
|||
Vector<uint8_t> _texture_get_data(Texture *tex, uint32_t p_layer, bool p_2d = false);
|
||||
uint32_t _texture_layer_count(Texture *p_texture) const;
|
||||
uint32_t _texture_alignment(Texture *p_texture) const;
|
||||
Error _texture_initialize(RID p_texture, uint32_t p_layer, const Vector<uint8_t> &p_data);
|
||||
Error _texture_initialize(RID p_texture, uint32_t p_layer, const Vector<uint8_t> &p_data, bool p_immediate_flush = false);
|
||||
void _texture_check_shared_fallback(Texture *p_texture);
|
||||
void _texture_update_shared_fallback(RID p_texture_rid, Texture *p_texture, bool p_for_writing);
|
||||
void _texture_free_shared_fallback(Texture *p_texture);
|
||||
void _texture_copy_shared(RID p_src_texture_rid, Texture *p_src_texture, RID p_dst_texture_rid, Texture *p_dst_texture);
|
||||
void _texture_create_reinterpret_buffer(Texture *p_texture);
|
||||
uint32_t _texture_vrs_method_to_usage_bits() const;
|
||||
|
||||
struct TextureGetDataRequest {
|
||||
uint32_t frame_local_index = 0;
|
||||
|
|
@ -426,6 +429,30 @@ public:
|
|||
void texture_set_discardable(RID p_texture, bool p_discardable);
|
||||
bool texture_is_discardable(RID p_texture);
|
||||
|
||||
private:
|
||||
/*************/
|
||||
/**** VRS ****/
|
||||
/*************/
|
||||
|
||||
enum VRSMethod {
|
||||
VRS_METHOD_NONE,
|
||||
VRS_METHOD_FRAGMENT_SHADING_RATE,
|
||||
VRS_METHOD_FRAGMENT_DENSITY_MAP,
|
||||
};
|
||||
|
||||
VRSMethod vrs_method = VRS_METHOD_NONE;
|
||||
DataFormat vrs_format = DATA_FORMAT_MAX;
|
||||
Size2i vrs_texel_size;
|
||||
|
||||
static RDG::ResourceUsage _vrs_usage_from_method(VRSMethod p_method);
|
||||
static RDD::PipelineStageBits _vrs_stages_from_method(VRSMethod p_method);
|
||||
static RDD::TextureLayout _vrs_layout_from_method(VRSMethod p_method);
|
||||
void _vrs_detect_method();
|
||||
|
||||
public:
|
||||
DataFormat vrs_get_format() const;
|
||||
Size2i vrs_get_texel_size() const;
|
||||
|
||||
/*********************/
|
||||
/**** FRAMEBUFFER ****/
|
||||
/*********************/
|
||||
|
|
@ -456,7 +483,6 @@ public:
|
|||
Vector<int32_t> resolve_attachments;
|
||||
Vector<int32_t> preserve_attachments;
|
||||
int32_t depth_attachment = ATTACHMENT_UNUSED;
|
||||
int32_t vrs_attachment = ATTACHMENT_UNUSED; // density map for VRS, only used if supported
|
||||
};
|
||||
|
||||
typedef int64_t FramebufferFormatID;
|
||||
|
|
@ -466,8 +492,23 @@ private:
|
|||
Vector<AttachmentFormat> attachments;
|
||||
Vector<FramebufferPass> passes;
|
||||
uint32_t view_count = 1;
|
||||
VRSMethod vrs_method = VRS_METHOD_NONE;
|
||||
int32_t vrs_attachment = ATTACHMENT_UNUSED;
|
||||
Size2i vrs_texel_size;
|
||||
|
||||
bool operator<(const FramebufferFormatKey &p_key) const {
|
||||
if (vrs_texel_size != p_key.vrs_texel_size) {
|
||||
return vrs_texel_size < p_key.vrs_texel_size;
|
||||
}
|
||||
|
||||
if (vrs_attachment != p_key.vrs_attachment) {
|
||||
return vrs_attachment < p_key.vrs_attachment;
|
||||
}
|
||||
|
||||
if (vrs_method != p_key.vrs_method) {
|
||||
return vrs_method < p_key.vrs_method;
|
||||
}
|
||||
|
||||
if (view_count != p_key.view_count) {
|
||||
return view_count < p_key.view_count;
|
||||
}
|
||||
|
|
@ -572,7 +613,7 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
static RDD::RenderPassID _render_pass_create(RenderingDeviceDriver *p_driver, const Vector<AttachmentFormat> &p_attachments, const Vector<FramebufferPass> &p_passes, VectorView<RDD::AttachmentLoadOp> p_load_ops, VectorView<RDD::AttachmentStoreOp> p_store_ops, uint32_t p_view_count = 1, Vector<TextureSamples> *r_samples = nullptr);
|
||||
static RDD::RenderPassID _render_pass_create(RenderingDeviceDriver *p_driver, const Vector<AttachmentFormat> &p_attachments, const Vector<FramebufferPass> &p_passes, VectorView<RDD::AttachmentLoadOp> p_load_ops, VectorView<RDD::AttachmentStoreOp> p_store_ops, uint32_t p_view_count = 1, VRSMethod p_vrs_method = VRS_METHOD_NONE, int32_t p_vrs_attachment = -1, Size2i p_vrs_texel_size = Size2i(), Vector<TextureSamples> *r_samples = nullptr);
|
||||
static RDD::RenderPassID _render_pass_create_from_graph(RenderingDeviceDriver *p_driver, VectorView<RDD::AttachmentLoadOp> p_load_ops, VectorView<RDD::AttachmentStoreOp> p_store_ops, void *p_user_data);
|
||||
|
||||
// This is a cache and it's never freed, it ensures
|
||||
|
|
@ -603,8 +644,8 @@ private:
|
|||
|
||||
public:
|
||||
// This ID is warranted to be unique for the same formats, does not need to be freed
|
||||
FramebufferFormatID framebuffer_format_create(const Vector<AttachmentFormat> &p_format, uint32_t p_view_count = 1);
|
||||
FramebufferFormatID framebuffer_format_create_multipass(const Vector<AttachmentFormat> &p_attachments, const Vector<FramebufferPass> &p_passes, uint32_t p_view_count = 1);
|
||||
FramebufferFormatID framebuffer_format_create(const Vector<AttachmentFormat> &p_format, uint32_t p_view_count = 1, int32_t p_vrs_attachment = -1);
|
||||
FramebufferFormatID framebuffer_format_create_multipass(const Vector<AttachmentFormat> &p_attachments, const Vector<FramebufferPass> &p_passes, uint32_t p_view_count = 1, int32_t p_vrs_attachment = -1);
|
||||
FramebufferFormatID framebuffer_format_create_empty(TextureSamples p_samples = TEXTURE_SAMPLES_1);
|
||||
TextureSamples framebuffer_format_get_texture_samples(FramebufferFormatID p_format, uint32_t p_pass = 0);
|
||||
|
||||
|
|
@ -831,7 +872,7 @@ private:
|
|||
String name; // Used for debug.
|
||||
RDD::ShaderID driver_id;
|
||||
uint32_t layout_hash = 0;
|
||||
BitField<RDD::PipelineStageBits> stage_bits;
|
||||
BitField<RDD::PipelineStageBits> stage_bits = {};
|
||||
Vector<uint32_t> set_formats;
|
||||
};
|
||||
|
||||
|
|
@ -1068,8 +1109,7 @@ public:
|
|||
* If you plan on keeping the return value around for more than one frame (e.g. Sets that are created once and reused forever) you MUST set it to false.
|
||||
* @return Baked descriptor set.
|
||||
*/
|
||||
template <typename Collection>
|
||||
RID uniform_set_create(const Collection &p_uniforms, RID p_shader, uint32_t p_shader_set, bool p_linear_pool = false);
|
||||
RID uniform_set_create(const VectorView<Uniform> &p_uniforms, RID p_shader, uint32_t p_shader_set, bool p_linear_pool = false);
|
||||
bool uniform_set_is_valid(RID p_uniform_set);
|
||||
void uniform_set_set_invalidation_callback(RID p_uniform_set, InvalidationCallback p_callback, void *p_userdata);
|
||||
|
||||
|
|
@ -1109,7 +1149,7 @@ private:
|
|||
uint32_t shader_layout_hash = 0;
|
||||
Vector<uint32_t> set_formats;
|
||||
RDD::PipelineID driver_id;
|
||||
BitField<RDD::PipelineStageBits> stage_bits;
|
||||
BitField<RDD::PipelineStageBits> stage_bits = {};
|
||||
uint32_t push_constant_size = 0;
|
||||
};
|
||||
|
||||
|
|
@ -1174,7 +1214,7 @@ private:
|
|||
|
||||
struct DrawList {
|
||||
Rect2i viewport;
|
||||
bool viewport_set = false;
|
||||
bool active = false;
|
||||
|
||||
struct SetState {
|
||||
uint32_t pipeline_expected_format = 0;
|
||||
|
|
@ -1199,7 +1239,6 @@ private:
|
|||
|
||||
#ifdef DEBUG_ENABLED
|
||||
struct Validation {
|
||||
bool active = true; // Means command buffer was not closed, so you can keep adding things.
|
||||
// Actual render pass values.
|
||||
uint32_t dynamic_state = 0;
|
||||
VertexFormatID vertex_format = INVALID_ID;
|
||||
|
|
@ -1230,18 +1269,17 @@ private:
|
|||
#endif
|
||||
};
|
||||
|
||||
DrawList *draw_list = nullptr;
|
||||
DrawList draw_list;
|
||||
uint32_t draw_list_subpass_count = 0;
|
||||
#ifdef DEBUG_ENABLED
|
||||
FramebufferFormatID draw_list_framebuffer_format = INVALID_ID;
|
||||
#endif
|
||||
uint32_t draw_list_current_subpass = 0;
|
||||
|
||||
Vector<RID> draw_list_bound_textures;
|
||||
LocalVector<RID> draw_list_bound_textures;
|
||||
|
||||
_FORCE_INLINE_ DrawList *_get_draw_list_ptr(DrawListID p_id);
|
||||
Error _draw_list_allocate(const Rect2i &p_viewport, uint32_t p_subpass);
|
||||
void _draw_list_free(Rect2i *r_last_viewport = nullptr);
|
||||
void _draw_list_start(const Rect2i &p_viewport);
|
||||
void _draw_list_end(Rect2i *r_last_viewport = nullptr);
|
||||
|
||||
public:
|
||||
enum DrawFlags {
|
||||
|
|
@ -1275,7 +1313,8 @@ public:
|
|||
};
|
||||
|
||||
DrawListID draw_list_begin_for_screen(DisplayServer::WindowID p_screen = 0, const Color &p_clear_color = Color());
|
||||
DrawListID draw_list_begin(RID p_framebuffer, BitField<DrawFlags> p_draw_flags = DRAW_DEFAULT_ALL, const Vector<Color> &p_clear_color_values = Vector<Color>(), float p_clear_depth_value = 1.0f, uint32_t p_clear_stencil_value = 0, const Rect2 &p_region = Rect2(), uint32_t p_breadcrumb = 0);
|
||||
DrawListID draw_list_begin(RID p_framebuffer, BitField<DrawFlags> p_draw_flags = DRAW_DEFAULT_ALL, VectorView<Color> p_clear_color_values = VectorView<Color>(), float p_clear_depth_value = 1.0f, uint32_t p_clear_stencil_value = 0, const Rect2 &p_region = Rect2(), uint32_t p_breadcrumb = 0);
|
||||
DrawListID _draw_list_begin_bind(RID p_framebuffer, BitField<DrawFlags> p_draw_flags = DRAW_DEFAULT_ALL, const Vector<Color> &p_clear_color_values = Vector<Color>(), float p_clear_depth_value = 1.0f, uint32_t p_clear_stencil_value = 0, const Rect2 &p_region = Rect2(), uint32_t p_breadcrumb = 0);
|
||||
|
||||
void draw_list_set_blend_constants(DrawListID p_list, const Color &p_color);
|
||||
void draw_list_bind_render_pipeline(DrawListID p_list, RID p_render_pipeline);
|
||||
|
|
@ -1303,6 +1342,7 @@ private:
|
|||
/***********************/
|
||||
|
||||
struct ComputeList {
|
||||
bool active = false;
|
||||
struct SetState {
|
||||
uint32_t pipeline_expected_format = 0;
|
||||
uint32_t uniform_set_format = 0;
|
||||
|
|
@ -1326,7 +1366,6 @@ private:
|
|||
|
||||
#ifdef DEBUG_ENABLED
|
||||
struct Validation {
|
||||
bool active = true; // Means command buffer was not closed, so you can keep adding things.
|
||||
Vector<uint32_t> set_formats;
|
||||
Vector<bool> set_bound;
|
||||
Vector<RID> set_rids;
|
||||
|
|
@ -1340,7 +1379,7 @@ private:
|
|||
#endif
|
||||
};
|
||||
|
||||
ComputeList *compute_list = nullptr;
|
||||
ComputeList compute_list;
|
||||
ComputeList::State compute_list_barrier_state;
|
||||
|
||||
public:
|
||||
|
|
@ -1713,5 +1752,3 @@ VARIANT_ENUM_CAST(RenderingDevice::FinalAction)
|
|||
#endif
|
||||
|
||||
typedef RenderingDevice RD;
|
||||
|
||||
#endif // RENDERING_DEVICE_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue