From edc84213fadc9bbd30030a57600550bde562b24e Mon Sep 17 00:00:00 2001 From: quou Date: Fri, 27 Dec 2024 11:33:28 +1100 Subject: allow renderpasses to specify a clear mode and pipelines to specify their viewport and scissor --- pipeline.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'pipeline.cpp') diff --git a/pipeline.cpp b/pipeline.cpp index 89f606d..b0a88eb 100644 --- a/pipeline.cpp +++ b/pipeline.cpp @@ -20,6 +20,13 @@ void Pipeline_Builder::begin_rp() { void Pipeline_Builder::rp_target(Texture_Id id, Colour clear) { pass->target = id; pass->clear = clear; + pass->mode = Clear_Mode::clear; +} + +void Pipeline_Builder::rp_target(Texture_Id id, Clear_Mode clear) { + pass->target = id; + assert(clear != Clear_Mode::clear); + pass->mode = clear; } void Pipeline_Builder::validate_rp() { @@ -31,9 +38,45 @@ Render_Pass& Pipeline_Builder::build_rp() { return *pass; } -void Pipeline_Builder::begin() { +void Pipeline_Builder::begin(Device* dev) { pip = (Pipeline*)arena_alloc(arena, sizeof *pip); memset(pip, 0, sizeof *pip); + if (dev) { + Texture_Id backbuffer_id = dev->get_backbuffer(); + Texture& backbuffer = dev->get_texture(backbuffer_id); + pip->scissor[0] = 0; + pip->scissor[1] = 0; + pip->scissor[2] = backbuffer.w; + pip->scissor[3] = backbuffer.h; + pip->viewport[0] = 0; + pip->viewport[1] = 0; + pip->viewport[2] = backbuffer.w; + pip->viewport[3] = backbuffer.h; + } +} + +void Pipeline_Builder::viewport( + float x, + float y, + float w, + float h +) { + pip->viewport[0] = x; + pip->viewport[1] = y; + pip->viewport[2] = w; + pip->viewport[3] = h; +} + +void Pipeline_Builder::scissor( + float x, + float y, + float w, + float h +) { + pip->scissor[0] = x; + pip->scissor[1] = y; + pip->scissor[2] = w; + pip->scissor[3] = h; } void Pipeline_Builder::shader(Shader_Id s) { -- cgit v1.2.3-54-g00ecf