Started on the render-pipeline/pass architecture.
This commit is contained in:
47
pipeline.odin
Normal file
47
pipeline.odin
Normal file
@@ -0,0 +1,47 @@
|
||||
package renderer
|
||||
|
||||
import "core:mem"
|
||||
import "core:log"
|
||||
|
||||
MAX_PASSES_IN_PIPELINE :: 8
|
||||
|
||||
Pipeline :: struct {
|
||||
passes: [MAX_PASSES_IN_PIPELINE]^Pass,
|
||||
amount_of_passes: u8,
|
||||
}
|
||||
|
||||
clear_pipeline :: proc(renderer: ^Renderer) {
|
||||
assert(renderer != nil)
|
||||
pipeline := &renderer.pipeline
|
||||
|
||||
pipeline.amount_of_passes = 0;
|
||||
mem.set(&pipeline.passes[0], 0, MAX_PASSES_IN_PIPELINE * size_of(Pass))
|
||||
}
|
||||
|
||||
set_pipeline :: proc(renderer: ^Renderer, passes: []^Pass) {
|
||||
clear_pipeline(renderer)
|
||||
for p in passes {
|
||||
if !add_pass_to_pipeline(renderer, p) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@(private="file") add_pass_to_pipeline :: proc(renderer: ^Renderer, pass: ^Pass) -> bool {
|
||||
assert(renderer != nil)
|
||||
assert(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)
|
||||
return false
|
||||
}
|
||||
|
||||
pipeline.passes[pipeline.amount_of_passes] = pass
|
||||
pipeline.amount_of_passes += 1
|
||||
|
||||
log.infof("Successfully added pass '%v' to pipeline.", pass.name)
|
||||
|
||||
return true
|
||||
}
|
||||
Reference in New Issue
Block a user