summaryrefslogtreecommitdiff
path: root/servers/visual/rendering_device.h
diff options
context:
space:
mode:
Diffstat (limited to 'servers/visual/rendering_device.h')
-rw-r--r--servers/visual/rendering_device.h127
1 files changed, 60 insertions, 67 deletions
diff --git a/servers/visual/rendering_device.h b/servers/visual/rendering_device.h
index a1143a5f0d..d30af9a7cb 100644
--- a/servers/visual/rendering_device.h
+++ b/servers/visual/rendering_device.h
@@ -7,13 +7,13 @@ class RenderingDevice : public Object {
GDCLASS(RenderingDevice, Object)
static RenderingDevice *singleton;
+
public:
//base numeric ID for all types
enum {
INVALID_ID = -1
};
-
/*****************/
/**** GENERIC ****/
/*****************/
@@ -264,7 +264,6 @@ public:
/**** TEXTURE ****/
/*****************/
-
enum TextureType {
TEXTURE_TYPE_1D,
TEXTURE_TYPE_2D,
@@ -319,7 +318,7 @@ public:
TextureType type;
TextureSamples samples;
uint32_t usage_bits;
-
+ Vector<DataFormat> shareable_formats;
TextureFormat() {
format = DATA_FORMAT_R8_UNORM;
@@ -342,7 +341,7 @@ public:
TextureSwizzle swizzle_a;
TextureView() {
- format_override=DATA_FORMAT_MAX; //means, use same as format
+ format_override = DATA_FORMAT_MAX; //means, use same as format
swizzle_r = TEXTURE_SWIZZLE_R;
swizzle_g = TEXTURE_SWIZZLE_G;
swizzle_b = TEXTURE_SWIZZLE_B;
@@ -350,12 +349,11 @@ public:
}
};
- virtual RID texture_create(const TextureFormat &p_format,const TextureView& p_view, const Vector<PoolVector<uint8_t> >&p_data = Vector<PoolVector<uint8_t> >()) = 0;
- virtual RID texture_create_shared(const TextureView& p_view, RID p_with_texture) = 0;
- virtual Error texture_update(RID p_texture,uint32_t p_layer,const PoolVector<uint8_t>&p_data, bool p_sync_with_draw = false) =0; //this function can be used from any thread and it takes effect at the begining of the frame, unless sync with draw is used, which is used to mix updates with draw calls
-
- virtual bool texture_is_format_supported_for_usage(DataFormat p_format,uint32_t p_usage) const = 0;
+ virtual RID texture_create(const TextureFormat &p_format, const TextureView &p_view, const Vector<PoolVector<uint8_t> > &p_data = Vector<PoolVector<uint8_t> >()) = 0;
+ virtual RID texture_create_shared(const TextureView &p_view, RID p_with_texture) = 0;
+ virtual Error texture_update(RID p_texture, uint32_t p_layer, const PoolVector<uint8_t> &p_data, bool p_sync_with_draw = false) = 0; //this function can be used from any thread and it takes effect at the begining of the frame, unless sync with draw is used, which is used to mix updates with draw calls
+ virtual bool texture_is_format_supported_for_usage(DataFormat p_format, uint32_t p_usage) const = 0;
/*********************/
/**** FRAMEBUFFER ****/
@@ -370,9 +368,9 @@ public:
typedef int64_t FramebufferFormatID;
// This ID is warranted to be unique for the same formats, does not need to be freed
- virtual FramebufferFormatID framebuffer_format_create(const Vector<AttachmentFormat>& p_format) =0;
+ virtual FramebufferFormatID framebuffer_format_create(const Vector<AttachmentFormat> &p_format) = 0;
- virtual RID framebuffer_create(const Vector<RID> &p_texture_attachments,FramebufferFormatID p_format_check=INVALID_ID) = 0;
+ virtual RID framebuffer_create(const Vector<RID> &p_texture_attachments, FramebufferFormatID p_format_check = INVALID_ID) = 0;
virtual FramebufferFormatID framebuffer_get_format(RID p_framebuffer) = 0;
@@ -422,21 +420,21 @@ public:
bool unnormalized_uvw;
SamplerState() {
- mag_filter=SAMPLER_FILTER_NEAREST;
- min_filter=SAMPLER_FILTER_NEAREST;
- mip_filter=SAMPLER_FILTER_NEAREST;
- repeat_u=SAMPLER_REPEAT_MODE_CLAMP_TO_EDGE;
- repeat_v=SAMPLER_REPEAT_MODE_CLAMP_TO_EDGE;
- repeat_w=SAMPLER_REPEAT_MODE_CLAMP_TO_EDGE;
- lod_bias=0;
- use_anisotropy=false;
- anisotropy_max=1.0;
- enable_compare=false;
- compare_op=COMPARE_OP_ALWAYS;
- min_lod=0;
- max_lod=1e20; //something very large should do
- border_color=SAMPLER_BORDER_COLOR_FLOAT_OPAQUE_BLACK;
- unnormalized_uvw=false;
+ mag_filter = SAMPLER_FILTER_NEAREST;
+ min_filter = SAMPLER_FILTER_NEAREST;
+ mip_filter = SAMPLER_FILTER_NEAREST;
+ repeat_u = SAMPLER_REPEAT_MODE_CLAMP_TO_EDGE;
+ repeat_v = SAMPLER_REPEAT_MODE_CLAMP_TO_EDGE;
+ repeat_w = SAMPLER_REPEAT_MODE_CLAMP_TO_EDGE;
+ lod_bias = 0;
+ use_anisotropy = false;
+ anisotropy_max = 1.0;
+ enable_compare = false;
+ compare_op = COMPARE_OP_ALWAYS;
+ min_lod = 0;
+ max_lod = 1e20; //something very large should do
+ border_color = SAMPLER_BORDER_COLOR_FLOAT_OPAQUE_BLACK;
+ unnormalized_uvw = false;
}
};
@@ -458,11 +456,11 @@ public:
uint32_t stride;
VertexFrequency frequency;
VertexDescription() {
- location=0;
- offset=0;
- stride=0;
- format=DATA_FORMAT_MAX;
- frequency=VERTEX_FREQUENCY_VERTEX;
+ location = 0;
+ offset = 0;
+ stride = 0;
+ format = DATA_FORMAT_MAX;
+ frequency = VERTEX_FREQUENCY_VERTEX;
}
};
virtual RID vertex_buffer_create(uint32_t p_size_bytes, const PoolVector<uint8_t> &p_data = PoolVector<uint8_t>()) = 0;
@@ -471,15 +469,15 @@ public:
// This ID is warranted to be unique for the same formats, does not need to be freed
virtual VertexFormatID vertex_format_create(const Vector<VertexDescription> &p_vertex_formats) = 0;
- virtual RID vertex_array_create(uint32_t p_vertex_count, VertexFormatID p_vertex_format,const Vector<RID>& p_src_buffers) = 0;
+ virtual RID vertex_array_create(uint32_t p_vertex_count, VertexFormatID p_vertex_format, const Vector<RID> &p_src_buffers) = 0;
enum IndexBufferFormat {
INDEX_BUFFER_FORMAT_UINT16,
INDEX_BUFFER_FORMAT_UINT32,
};
- 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) = 0;
- virtual RID index_array_create(RID p_index_buffer, uint32_t p_index_offset, uint32_t p_index_count) =0;
+ 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) = 0;
+ virtual RID index_array_create(RID p_index_buffer, uint32_t p_index_offset, uint32_t p_index_count) = 0;
/****************/
/**** SHADER ****/
@@ -503,14 +501,13 @@ public:
ShaderStage shader_stage;
String shader_source;
ShaderStageSource() {
- shader_stage=SHADER_STAGE_VERTEX;
+ shader_stage = SHADER_STAGE_VERTEX;
}
};
- virtual RID shader_create_from_source(const Vector<ShaderStageSource> &p_stages,String *r_error=NULL,ShaderStage *r_error_stage=NULL,bool p_allow_cache=true) = 0;
+ virtual RID shader_create_from_source(const Vector<ShaderStageSource> &p_stages, String *r_error = NULL, ShaderStage *r_error_stage = NULL, bool p_allow_cache = true) = 0;
virtual Vector<int> shader_get_vertex_input_locations_used(RID p_shader) = 0;
-
/******************/
/**** UNIFORMS ****/
/******************/
@@ -529,9 +526,9 @@ public:
UNIFORM_TYPE_MAX
};
- virtual RID uniform_buffer_create(uint32_t p_size_bytes,const PoolVector<uint8_t>& p_data=PoolVector<uint8_t>()) =0;
- virtual RID storage_buffer_create(uint32_t p_size,const PoolVector<uint8_t>& p_data=PoolVector<uint8_t>()) =0;
- virtual RID texture_buffer_create(uint32_t p_size_elements,DataFormat p_format,const PoolVector<uint8_t>& p_data=PoolVector<uint8_t>()) =0;
+ virtual RID uniform_buffer_create(uint32_t p_size_bytes, const PoolVector<uint8_t> &p_data = PoolVector<uint8_t>()) = 0;
+ virtual RID storage_buffer_create(uint32_t p_size, const PoolVector<uint8_t> &p_data = PoolVector<uint8_t>()) = 0;
+ virtual RID texture_buffer_create(uint32_t p_size_elements, DataFormat p_format, const PoolVector<uint8_t> &p_data = PoolVector<uint8_t>()) = 0;
struct Uniform {
UniformType type;
@@ -545,16 +542,15 @@ public:
Vector<RID> ids;
Uniform() {
- type=UNIFORM_TYPE_IMAGE;
- binding=0;
+ type = UNIFORM_TYPE_IMAGE;
+ binding = 0;
}
};
- virtual RID uniform_set_create(const Vector<Uniform>& p_uniforms,RID p_shader,uint32_t p_shader_set) = 0;
- virtual bool uniform_set_is_valid(RID p_uniform_set) =0;
-
+ virtual RID uniform_set_create(const Vector<Uniform> &p_uniforms, RID p_shader, uint32_t p_shader_set) = 0;
+ virtual bool uniform_set_is_valid(RID p_uniform_set) = 0;
- virtual Error buffer_update(RID p_buffer, uint32_t p_offset, uint32_t p_size, void *p_data,bool p_sync_with_draw=false) =0; //this function can be used from any thread and it takes effect at the begining of the frame, unless sync with draw is used, which is used to mix updates with draw calls
+ virtual Error buffer_update(RID p_buffer, uint32_t p_offset, uint32_t p_size, void *p_data, bool p_sync_with_draw = false) = 0; //this function can be used from any thread and it takes effect at the begining of the frame, unless sync with draw is used, which is used to mix updates with draw calls
/*************************/
/**** RENDER PIPELINE ****/
@@ -675,7 +671,7 @@ public:
depth_bias_clamp = 0;
depth_bias_slope_factor = 0;
line_width = 1.0;
- patch_control_points=1;
+ patch_control_points = 1;
}
};
@@ -771,20 +767,20 @@ public:
}
};
- static PipelineColorBlendState create_disabled(int p_attachments=1) {
+ static PipelineColorBlendState create_disabled(int p_attachments = 1) {
PipelineColorBlendState bs;
- for(int i=0;i<p_attachments;i++) {
+ for (int i = 0; i < p_attachments; i++) {
bs.attachments.push_back(Attachment());
}
return bs;
}
- static PipelineColorBlendState create_blend(int p_attachments=1) {
+ static PipelineColorBlendState create_blend(int p_attachments = 1) {
PipelineColorBlendState bs;
- for(int i=0;i<p_attachments;i++) {
+ for (int i = 0; i < p_attachments; i++) {
Attachment ba;
- ba.enable_blend=true;
+ ba.enable_blend = true;
ba.src_color_blend_factor = BLEND_FACTOR_SRC_ALPHA;
ba.dst_color_blend_factor = BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
ba.src_alpha_blend_factor = BLEND_FACTOR_SRC_ALPHA;
@@ -814,7 +810,7 @@ public:
DYNAMIC_STATE_STENCIL_REFERENCE = (1 << 6),
};
- virtual RID render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format,RenderPrimitive p_render_primitive, const PipelineRasterizationState &p_rasterization_state, const PipelineMultisampleState &p_multisample_state, const PipelineDepthStencilState &p_depth_stencil_state, const PipelineColorBlendState &p_blend_state, int p_dynamic_state_flags=0) = 0;
+ virtual RID render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const PipelineRasterizationState &p_rasterization_state, const PipelineMultisampleState &p_multisample_state, const PipelineDepthStencilState &p_depth_stencil_state, const PipelineColorBlendState &p_blend_state, int p_dynamic_state_flags = 0) = 0;
/****************/
/**** SCREEN ****/
@@ -828,7 +824,6 @@ public:
/**** DRAW LISTS ****/
/********************/
-
enum InitialAction {
INITIAL_ACTION_CLEAR, //start rendering and clear the framebuffer (supply params)
INITIAL_ACTION_KEEP_COLOR, //start rendering, but keep attached color texture contents (depth will be cleared)
@@ -847,40 +842,38 @@ public:
typedef int64_t DrawListID;
-
- virtual DrawListID draw_list_begin_for_screen(int p_screen = 0, const Color &p_clear_color = Color()) =0;
- virtual DrawListID draw_list_begin(RID p_framebuffer, InitialAction p_initial_action, FinalAction p_final_action, const Vector<Color> &p_clear_color_values = Vector<Color>(),const Rect2& p_region=Rect2()) =0;
- virtual Error draw_list_begin_split(RID p_framebuffer, uint32_t p_splits,DrawListID *r_split_ids, InitialAction p_initial_action, FinalAction p_final_action, const Vector<Color> &p_clear_color_values = Vector<Color>(),const Rect2& p_region=Rect2()) =0;
+ virtual DrawListID draw_list_begin_for_screen(int p_screen = 0, const Color &p_clear_color = Color()) = 0;
+ virtual DrawListID draw_list_begin(RID p_framebuffer, InitialAction p_initial_action, FinalAction p_final_action, const Vector<Color> &p_clear_color_values = Vector<Color>(), const Rect2 &p_region = Rect2()) = 0;
+ virtual Error draw_list_begin_split(RID p_framebuffer, uint32_t p_splits, DrawListID *r_split_ids, InitialAction p_initial_action, FinalAction p_final_action, const Vector<Color> &p_clear_color_values = Vector<Color>(), const Rect2 &p_region = Rect2()) = 0;
virtual void draw_list_bind_render_pipeline(DrawListID p_list, RID p_render_pipeline) = 0;
- virtual void draw_list_bind_uniform_set(DrawListID p_list, RID p_uniform_set, uint32_t p_index) =0;
+ virtual void draw_list_bind_uniform_set(DrawListID p_list, RID p_uniform_set, uint32_t p_index) = 0;
virtual void draw_list_bind_vertex_array(DrawListID p_list, RID p_vertex_array) = 0;
virtual void draw_list_bind_index_array(DrawListID p_list, RID p_index_array) = 0;
- virtual void draw_list_set_push_constant(DrawListID p_list, void *p_data,uint32_t p_data_size) =0;
+ virtual void draw_list_set_push_constant(DrawListID p_list, void *p_data, uint32_t p_data_size) = 0;
- virtual void draw_list_draw(DrawListID p_list, bool p_use_indices, uint32_t p_instances=1) = 0;
+ virtual void draw_list_draw(DrawListID p_list, bool p_use_indices, uint32_t p_instances = 1) = 0;
- virtual void draw_list_enable_scissor(DrawListID p_list, const Rect2& p_rect) = 0;
+ virtual void draw_list_enable_scissor(DrawListID p_list, const Rect2 &p_rect) = 0;
virtual void draw_list_disable_scissor(DrawListID p_list) = 0;
- virtual void draw_list_end() =0;
+ virtual void draw_list_end() = 0;
/***************/
/**** FREE! ****/
/***************/
- virtual void free(RID p_id) =0;
+ virtual void free(RID p_id) = 0;
//methods below not exposed, used by RenderingDeviceRD
- virtual void finalize_frame() =0;
- virtual void advance_frame() =0;
+ virtual void finalize_frame() = 0;
+ virtual void advance_frame() = 0;
static RenderingDevice *get_singleton();
RenderingDevice();
};
-
typedef RenderingDevice RD;
#endif // RENDERING_DEVICE_H