From 35eea96b1c99bb88cfa58e6f1a43e91e058a702f Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 10 Oct 2022 12:25:13 +0300 Subject: [PATCH] Ensure that render targets are writable when clearing --- source/core/pipelinestate.h | 3 +++ source/render/renderer.cpp | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/source/core/pipelinestate.h b/source/core/pipelinestate.h index a836c407..16fd5bc8 100644 --- a/source/core/pipelinestate.h +++ b/source/core/pipelinestate.h @@ -120,6 +120,9 @@ public: const VertexSetup *get_vertex_setup() const { return vertex_setup; } FaceWinding get_front_face() const { return front_face; } CullMode get_face_cull() const { return face_cull; } + const DepthTest &get_depth_test() const { return depth_test; } + const StencilTest &get_stencil_test() const { return stencil_test; } + const Blend &get_blend() const { return blend; } private: void check_bound_resources() const; diff --git a/source/render/renderer.cpp b/source/render/renderer.cpp index b74b0773..97c492eb 100644 --- a/source/render/renderer.cpp +++ b/source/render/renderer.cpp @@ -272,7 +272,12 @@ void Renderer::set_object_lod_bias(unsigned b) void Renderer::clear(const ClearValue *values) { apply_framebuffer(); - commands.use_pipeline(&get_pipeline_state()); + PipelineState &ps = get_pipeline_state(); + if(!ps.get_depth_test().write) + ps.set_depth_test(DepthTest()); + if(!ps.get_blend().write_mask) + ps.set_blend(Blend()); + commands.use_pipeline(&ps); commands.clear(values); } -- 2.45.2