From: Mikko Rasa Date: Sat, 25 Sep 2021 11:34:20 +0000 (+0300) Subject: Clear the pipeline state through Commands X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=0d5406c66549a2cfc2fca701cc1c4972e7fd493a;p=libs%2Fgl.git Clear the pipeline state through Commands --- diff --git a/source/core/commands.cpp b/source/core/commands.cpp index 2eb4659a..f2c27372 100644 --- a/source/core/commands.cpp +++ b/source/core/commands.cpp @@ -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) diff --git a/source/core/commands.h b/source/core/commands.h index 08fdbffd..2dc66cfa 100644 --- a/source/core/commands.h +++ b/source/core/commands.h @@ -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); diff --git a/source/render/renderer.cpp b/source/render/renderer.cpp index aa6c9b55..4320ef30 100644 --- a/source/render/renderer.cpp +++ b/source/render/renderer.cpp @@ -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); }