summaryrefslogtreecommitdiff
path: root/pipeline.cpp
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2024-12-27 11:33:28 +1100
committerquou <quou@disroot.org>2024-12-27 11:33:28 +1100
commitedc84213fadc9bbd30030a57600550bde562b24e (patch)
tree7a2aa3869a1e00f8e8841ae60ed8fc186a3e6df9 /pipeline.cpp
parent7fa078995b3ed62925788ce2460441bc3d373392 (diff)
allow renderpasses to specify a clear mode and pipelines to specify their viewport and scissor
Diffstat (limited to 'pipeline.cpp')
-rw-r--r--pipeline.cpp45
1 files changed, 44 insertions, 1 deletions
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) {