summaryrefslogtreecommitdiff
path: root/servers/visual/rasterizer/rasterizer_rd.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <juan@godotengine.org>2019-06-19 17:03:19 -0300
committerJuan Linietsky <reduzio@gmail.com>2020-02-11 11:53:27 +0100
commit42b44f43ee52eb664d3610d0fdae0eff14c00f0a (patch)
tree3125054b1d86f9eb1b10dd760b12010c3d6a1e89 /servers/visual/rasterizer/rasterizer_rd.cpp
parent9b0dd4f571ff431e23b9097e7f29746f4157be12 (diff)
Basic 2D engine is more or less working, needs more work for editor to be usable.
Diffstat (limited to 'servers/visual/rasterizer/rasterizer_rd.cpp')
-rw-r--r--servers/visual/rasterizer/rasterizer_rd.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/servers/visual/rasterizer/rasterizer_rd.cpp b/servers/visual/rasterizer/rasterizer_rd.cpp
index c740ce61ef..83c722b5d2 100644
--- a/servers/visual/rasterizer/rasterizer_rd.cpp
+++ b/servers/visual/rasterizer/rasterizer_rd.cpp
@@ -3,6 +3,7 @@
void RasterizerRD::blit_render_targets_to_screen(int p_screen, const BlitToScreen *p_render_targets, int p_amount) {
RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin_for_screen(p_screen);
+
for (int i = 0; i < p_amount; i++) {
RID texture = storage->render_target_get_texture(p_render_targets[i].render_target);
ERR_CONTINUE(texture.is_null());
@@ -15,6 +16,7 @@ void RasterizerRD::blit_render_targets_to_screen(int p_screen, const BlitToScree
u.binding = 0;
u.ids.push_back(copy_viewports_sampler);
u.ids.push_back(rd_texture);
+ uniforms.push_back(u);
RID uniform_set = RD::get_singleton()->uniform_set_create(uniforms, copy_viewports_rd_shader, 0);
render_target_descriptors[rd_texture] = uniform_set;
@@ -35,6 +37,8 @@ void RasterizerRD::blit_render_targets_to_screen(int p_screen, const BlitToScree
RD::get_singleton()->draw_list_set_push_constant(draw_list, push_constant, 4 * sizeof(float));
RD::get_singleton()->draw_list_draw(draw_list, true);
}
+
+ RD::get_singleton()->draw_list_end();
}
void RasterizerRD::begin_frame(double frame_step) {
@@ -48,9 +52,6 @@ void RasterizerRD::end_frame(bool p_swap_buffers) {
}
void RasterizerRD::initialize() {
- storage = memnew(RasterizerStorageRD);
- canvas = memnew(RasterizerCanvasRD(storage));
- scene = memnew(RasterizerSceneForwardRD);
{ //create framebuffer copy shader
RenderingDevice::ShaderStageSource vert;
@@ -60,9 +61,10 @@ void RasterizerRD::initialize() {
"layout(push_constant, binding = 0, std140) uniform Pos { vec4 dst_rect; } pos;\n"
"layout(location =0) out vec2 uv;\n"
"void main() { \n"
- " vec2 base_arr[4] = float[](vec2(0.0,0.0),vec2(0.0,1.0),vec2(1.0,1.0),vec2(1.0,0.0));\n"
+ " vec2 base_arr[4] = vec2[](vec2(0.0,0.0),vec2(0.0,1.0),vec2(1.0,1.0),vec2(1.0,0.0));\n"
" uv = base_arr[gl_VertexIndex];\n"
- " gl_Position = vec4(dst_rect.xy,uv*dst_rect.zw);\n"
+ " vec2 vtx = pos.dst_rect.xy+uv*pos.dst_rect.zw;\n"
+ " gl_Position = vec4(vtx * 2.0 - 1.0,0.0,1.0);\n"
"}\n";
RenderingDevice::ShaderStageSource frag;
@@ -124,4 +126,7 @@ void RasterizerRD::finalize() {
}
RasterizerRD::RasterizerRD() {
+ storage = memnew(RasterizerStorageRD);
+ canvas = memnew(RasterizerCanvasRD(storage));
+ scene = memnew(RasterizerSceneForwardRD);
}