You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-02 16:48:55 +00:00
basic 2D engine is more or less working with Vulkan, including editor.
Still a lot to do
This commit is contained in:
@@ -14,8 +14,10 @@ class RasterizerCanvasRD : public RasterizerCanvas {
|
||||
enum ShaderVariant {
|
||||
SHADER_VARIANT_QUAD,
|
||||
SHADER_VARIANT_NINEPATCH,
|
||||
SHADER_VARIANT_VERTICES,
|
||||
SHADER_VARIANT_POINTS,
|
||||
SHADER_VARIANT_PRIMITIVE,
|
||||
SHADER_VARIANT_PRIMITIVE_POINTS,
|
||||
SHADER_VARIANT_ATTRIBUTES,
|
||||
SHADER_VARIANT_ATTRIBUTES_POINTS,
|
||||
SHADER_VARIANT_MAX
|
||||
};
|
||||
|
||||
@@ -51,9 +53,12 @@ class RasterizerCanvasRD : public RasterizerCanvas {
|
||||
enum PipelineVariant {
|
||||
PIPELINE_VARIANT_QUAD,
|
||||
PIPELINE_VARIANT_NINEPATCH,
|
||||
PIPELINE_VARIANT_TRIANGLES,
|
||||
PIPELINE_VARIANT_LINES,
|
||||
PIPELINE_VARIANT_POINTS,
|
||||
PIPELINE_VARIANT_PRIMITIVE_TRIANGLES,
|
||||
PIPELINE_VARIANT_PRIMITIVE_LINES,
|
||||
PIPELINE_VARIANT_PRIMITIVE_POINTS,
|
||||
PIPELINE_VARIANT_ATTRIBUTE_TRIANGLES,
|
||||
PIPELINE_VARIANT_ATTRIBUTE_LINES,
|
||||
PIPELINE_VARIANT_ATTRIBUTE_POINTS,
|
||||
PIPELINE_VARIANT_MAX
|
||||
};
|
||||
struct PipelineVariants {
|
||||
@@ -65,12 +70,13 @@ class RasterizerCanvasRD : public RasterizerCanvas {
|
||||
RD::FramebufferFormatID framebuffer_formats[RENDER_TARGET_FORMAT_MAX];
|
||||
RID default_version;
|
||||
RID default_version_rd_shader;
|
||||
RID quad_index_buffer;
|
||||
RID quad_index_array;
|
||||
PipelineVariants pipeline_variants;
|
||||
|
||||
// default_skeleton uniform set
|
||||
RID default_material_skeleton_uniform;
|
||||
RID default_material_uniform_set;
|
||||
RID default_skeleton_uniform;
|
||||
RID default_skeleton_uniform_set;
|
||||
|
||||
} shader;
|
||||
|
||||
@@ -126,6 +132,7 @@ class RasterizerCanvasRD : public RasterizerCanvas {
|
||||
TextureBindingID default_empty;
|
||||
} bindings;
|
||||
|
||||
RID _create_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat, RID p_multimesh);
|
||||
void _dispose_bindings();
|
||||
struct {
|
||||
RID white_texture;
|
||||
@@ -143,6 +150,31 @@ class RasterizerCanvasRD : public RasterizerCanvas {
|
||||
VS::CanvasItemTextureRepeat default_repeat;
|
||||
} default_samplers;
|
||||
|
||||
/******************/
|
||||
/**** POLYGONS ****/
|
||||
/******************/
|
||||
|
||||
struct PolygonBuffers {
|
||||
RD::VertexFormatID vertex_format_id;
|
||||
RID vertex_buffer;
|
||||
RID vertex_array;
|
||||
RID index_buffer;
|
||||
RID indices;
|
||||
};
|
||||
|
||||
struct {
|
||||
HashMap<PolygonID, PolygonBuffers> polygons;
|
||||
PolygonID last_id;
|
||||
} polygon_buffers;
|
||||
|
||||
/********************/
|
||||
/**** PRIMITIVES ****/
|
||||
/********************/
|
||||
|
||||
struct {
|
||||
RID index_array[4];
|
||||
} primitive_arrays;
|
||||
|
||||
/*******************/
|
||||
/**** MATERIALS ****/
|
||||
/*******************/
|
||||
@@ -171,15 +203,26 @@ class RasterizerCanvasRD : public RasterizerCanvas {
|
||||
} state;
|
||||
|
||||
struct PushConstant {
|
||||
float world[8];
|
||||
float modulation[4];
|
||||
float ninepatch_margins[4];
|
||||
float dst_rect[4];
|
||||
float src_rect[4];
|
||||
float world[6];
|
||||
uint32_t flags;
|
||||
uint32_t specular_shininess;
|
||||
float color_texture_pixel_size[2];
|
||||
uint32_t pad[4];
|
||||
union {
|
||||
//rect
|
||||
struct {
|
||||
float modulation[4];
|
||||
float ninepatch_margins[4];
|
||||
float dst_rect[4];
|
||||
float src_rect[4];
|
||||
float color_texture_pixel_size[2];
|
||||
uint32_t pad[6];
|
||||
};
|
||||
//primitive
|
||||
struct {
|
||||
float points[8]; // vec2 points[4]
|
||||
uint32_t colors[8]; // colors encoded as half
|
||||
float uvs[8]; // vec2 points[4]
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
struct SkeletonUniform {
|
||||
@@ -193,10 +236,12 @@ class RasterizerCanvasRD : public RasterizerCanvas {
|
||||
|
||||
Item *items[MAX_RENDER_ITEMS];
|
||||
|
||||
void _render_item(RenderingDevice::DrawListID p_draw_list, const Item *p_item, RenderTargetFormat p_render_target_format, RenderingDevice::TextureSamples p_samples, const Color &p_modulate, const Transform2D &p_canvas_transform_inverse);
|
||||
void _render_items(RID p_to_render_target, bool p_clear, const Color &p_clear_color, int p_item_count, const Color &p_modulate, const Transform2D &p_transform);
|
||||
Size2i _bind_texture_binding(TextureBindingID p_binding, RenderingDevice::DrawListID p_draw_list);
|
||||
void _render_item(RenderingDevice::DrawListID p_draw_list, const Item *p_item, RenderTargetFormat p_render_target_format, RenderingDevice::TextureSamples p_samples, const Color &p_modulate, const Transform2D &p_canvas_transform_inverse, Item *¤t_clip);
|
||||
void _render_items(RID p_to_render_target, int p_item_count, const Color &p_modulate, const Transform2D &p_transform);
|
||||
|
||||
void _update_transform_2d_to_mat2x4(const Transform2D &p_transform, float *p_mat2x4);
|
||||
void _update_transform_2d_to_mat2x3(const Transform2D &p_transform, float *p_mat2x3);
|
||||
|
||||
void _update_transform_2d_to_mat4(const Transform2D &p_transform, float *p_mat4);
|
||||
void _update_transform_to_mat4(const Transform &p_transform, float *p_mat4);
|
||||
@@ -207,11 +252,14 @@ public:
|
||||
TextureBindingID request_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, VS::CanvasItemTextureFilter p_filter, VS::CanvasItemTextureRepeat p_repeat, RID p_multimesh);
|
||||
void free_texture_binding(TextureBindingID p_binding);
|
||||
|
||||
PolygonID request_polygon(const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), const Vector<int> &p_bones = Vector<int>(), const Vector<float> &p_weights = Vector<float>());
|
||||
void free_polygon(PolygonID p_polygon);
|
||||
|
||||
RID light_internal_create() { return RID(); }
|
||||
void light_internal_update(RID p_rid, Light *p_light) {}
|
||||
void light_internal_free(RID p_rid) {}
|
||||
|
||||
void canvas_render_items(RID p_to_render_target, bool p_clear, const Color &p_clear_color, Item *p_item_list, const Color &p_modulate, Light *p_light_list, const Transform2D &p_canvas_transform);
|
||||
void canvas_render_items(RID p_to_render_target, Item *p_item_list, const Color &p_modulate, Light *p_light_list, const Transform2D &p_canvas_transform);
|
||||
|
||||
void canvas_debug_viewport_shadows(Light *p_lights_with_shadow){};
|
||||
|
||||
@@ -223,7 +271,7 @@ public:
|
||||
|
||||
void update();
|
||||
RasterizerCanvasRD(RasterizerStorageRD *p_storage);
|
||||
~RasterizerCanvasRD() {}
|
||||
~RasterizerCanvasRD();
|
||||
};
|
||||
|
||||
#endif // RASTERIZER_CANVAS_RD_H
|
||||
|
||||
Reference in New Issue
Block a user