Work on passes/pipeline, render targets

This commit is contained in:
2026-01-26 20:45:29 +01:00
parent 6b2d76bd8a
commit bd4b81d434
7 changed files with 764 additions and 160 deletions

View File

@@ -3,45 +3,92 @@ package renderer
import "core:mem"
import "core:log"
MAX_PASSES_IN_PIPELINE :: 8
PIPELINE_MAX_SCENE_PASSES :: 8
PIPELINE_MAX_POST_PROCESSING_PASSES :: 8
Pipeline :: struct {
passes: [MAX_PASSES_IN_PIPELINE]^Pass,
amount_of_passes: u8,
scene_passes: [PIPELINE_MAX_SCENE_PASSES]^Scene_Pass,
amount_of_scene_passes: u8,
post_processing_passes: [PIPELINE_MAX_POST_PROCESSING_PASSES]^Post_Processing_Pass,
amount_of_post_processing_passes: u8,
fullscreen_material: ^Material,
fullscreen_mesh: ^Mesh,
}
clear_pipeline :: proc(renderer: ^Renderer) {
assert(renderer != nil)
pipeline := &renderer.pipeline
p := &renderer.pipeline
pipeline.amount_of_passes = 0;
mem.set(&pipeline.passes[0], 0, MAX_PASSES_IN_PIPELINE * size_of(^Pass))
p.amount_of_scene_passes = 0;
mem.set(&p.scene_passes[0], 0, PIPELINE_MAX_SCENE_PASSES * size_of(^Scene_Pass))
p.amount_of_post_processing_passes = 0;
mem.set(&p.post_processing_passes[0], 0, PIPELINE_MAX_POST_PROCESSING_PASSES * size_of(^Post_Processing_Pass))
}
set_pipeline :: proc(renderer: ^Renderer, passes: []^Pass) {
set_pipeline :: proc(
renderer: ^Renderer,
fullscreen_material: ^Material, fullscreen_mesh: ^Mesh,
scene_passes: []^Scene_Pass,
post_processing_passes: []^Post_Processing_Pass,
){
assert(renderer != nil)
clear_pipeline(renderer)
for p in passes {
renderer.pipeline.fullscreen_material = fullscreen_material
renderer.pipeline.fullscreen_mesh = fullscreen_mesh
for p in scene_passes {
if !add_pass_to_pipeline(renderer, p) {
return
break
}
}
for p in post_processing_passes {
if !add_pass_to_pipeline(renderer, p) {
break
}
}
}
@(private="file") add_pass_to_pipeline :: proc(renderer: ^Renderer, pass: ^Pass) -> bool {
add_pass_to_pipeline :: proc {
add_scene_pass_to_pipeline,
add_post_processing_pass_to_pipeline,
}
@(private="file") add_scene_pass_to_pipeline :: proc(renderer: ^Renderer, scene_pass: ^Scene_Pass) -> bool {
assert(renderer != nil)
assert(pass != nil)
assert(scene_pass != nil)
pipeline := &renderer.pipeline
if pipeline.amount_of_passes == MAX_PASSES_IN_PIPELINE {
log.warnf("Failed to add pass '%v' to renderer's pipeline; hit max capacity (%v).", pass.name, MAX_PASSES_IN_PIPELINE)
if pipeline.amount_of_scene_passes == PIPELINE_MAX_SCENE_PASSES {
log.warnf("Failed to add scene-pass '%v' to renderer's pipeline; hit max capacity (%v).", scene_pass.name, PIPELINE_MAX_SCENE_PASSES)
return false
}
pipeline.passes[pipeline.amount_of_passes] = pass
pipeline.amount_of_passes += 1
pipeline.scene_passes[pipeline.amount_of_scene_passes] = scene_pass
pipeline.amount_of_scene_passes += 1
// log.infof("Successfully added pass '%v' to pipeline.", pass.name)
return true
}
@(private="file") add_post_processing_pass_to_pipeline :: proc(renderer: ^Renderer, post_processing_pass: ^Post_Processing_Pass) -> bool {
assert(renderer != nil)
assert(post_processing_pass != nil)
pipeline := &renderer.pipeline
if pipeline.amount_of_post_processing_passes == PIPELINE_MAX_POST_PROCESSING_PASSES {
log.warnf("Failed to add post-processing pass '%v' to renderer's pipeline; hit max capacity (%v).", post_processing_pass.name, PIPELINE_MAX_POST_PROCESSING_PASSES)
return false
}
pipeline.post_processing_passes[pipeline.amount_of_post_processing_passes] = post_processing_pass
pipeline.amount_of_post_processing_passes += 1
return true
}