]> git.tdb.fi Git - libs/gl.git/commitdiff
Clear the pipeline state through Commands
authorMikko Rasa <tdb@tdb.fi>
Sat, 25 Sep 2021 11:34:20 +0000 (14:34 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 25 Sep 2021 11:35:28 +0000 (14:35 +0300)
source/core/commands.cpp
source/core/commands.h
source/render/renderer.cpp

index 2eb4659ad8e6ae0f62ecb2ec2e9aed362dc6afc3..f2c273727c7d2b5fcd7037b77f8df51c1b1f7a1e 100644 (file)
@@ -19,9 +19,11 @@ Commands::Commands():
        pipeline_state(0)
 { }
 
-void Commands::use_pipeline(const PipelineState &ps)
+void Commands::use_pipeline(const PipelineState *ps)
 {
-       pipeline_state = &ps;
+       pipeline_state = ps;
+       if(!pipeline_state)
+               PipelineState::clear();
 }
 
 void Commands::clear(const ClearValue *values)
index 08fdbffd89223a7cda3648a18f2e8a97c85138cf..2dc66cfa5232c8ea409162f0d09b829ccb9012a0 100644 (file)
@@ -17,7 +17,7 @@ private:
 public:
        Commands();
 
-       void use_pipeline(const PipelineState &);
+       void use_pipeline(const PipelineState *);
        void clear(const ClearValue *);
        void draw(const Batch &);
        void draw_instanced(const Batch &, unsigned);
index aa6c9b55a4d4206ef458012e280efdacb3e9aba5..4320ef30e4e2e87815e0e1ab24212cf8d0eb2c2b 100644 (file)
@@ -29,7 +29,6 @@ Renderer::Renderer():
        shdata_stack.reserve(32);
        state = &state_stack.back();
        add_shader_data(standard_shdata);
-       commands.use_pipeline(pipeline_state);
 }
 
 Renderer::~Renderer()
@@ -224,7 +223,7 @@ void Renderer::end()
        add_shader_data(standard_shdata);
        excluded.clear();
 
-       PipelineState::clear();
+       commands.use_pipeline(0);
 }
 
 void Renderer::exclude(const Renderable &renderable)
@@ -246,6 +245,7 @@ void Renderer::render(const Renderable &renderable, Tag tag)
 void Renderer::clear(const ClearValue *values)
 {
        pipeline_state.set_framebuffer(state->framebuffer);
+       commands.use_pipeline(&pipeline_state);
        commands.clear(values);
 }
 
@@ -253,6 +253,7 @@ void Renderer::draw(const Batch &batch)
 {
        apply_state();
        batch.refresh();
+       commands.use_pipeline(&pipeline_state);
        commands.draw(batch);
 }
 
@@ -260,6 +261,7 @@ void Renderer::draw_instanced(const Batch &batch, unsigned count)
 {
        apply_state();
        batch.refresh();
+       commands.use_pipeline(&pipeline_state);
        commands.draw_instanced(batch, count);
 }
 
@@ -274,6 +276,7 @@ void Renderer::resolve_multisample(Framebuffer &target, BufferBits buffers)
                throw incompatible_data("Renderer::resolve_multisample");
 
        pipeline_state.set_framebuffer(state->framebuffer);
+       commands.use_pipeline(&pipeline_state);
        commands.resolve_multisample(target, buffers);
 }