From: Mikko Rasa Date: Wed, 17 Nov 2021 19:51:26 +0000 (+0200) Subject: Store primitive type in PipelineState X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=f1e31ee641f0cafdfe2015bff206b9ee2ad85abf;p=libs%2Fgl.git Store primitive type in PipelineState Vulkan needs it to be here --- diff --git a/source/core/pipelinestate.cpp b/source/core/pipelinestate.cpp index 0306a262..742b2ba9 100644 --- a/source/core/pipelinestate.cpp +++ b/source/core/pipelinestate.cpp @@ -72,6 +72,11 @@ void PipelineState::set_vertex_setup(const VertexSetup *s) set(vertex_setup, s, VERTEX_SETUP); } +void PipelineState::set_primitive_type(PrimitiveType t) +{ + set(primitive_type, t, PRIMITIVE_TYPE); +} + void PipelineState::set_front_face(FaceWinding w) { set(front_face, w, FACE_CULL); diff --git a/source/core/pipelinestate.h b/source/core/pipelinestate.h index 31938829..0973bfb5 100644 --- a/source/core/pipelinestate.h +++ b/source/core/pipelinestate.h @@ -5,6 +5,7 @@ #include #include "cullface.h" #include "pipelinestate_backend.h" +#include "primitivetype.h" namespace Msp { namespace GL { @@ -61,7 +62,8 @@ private: FACE_CULL = 128, DEPTH_TEST = 256, STENCIL_TEST = 512, - BLEND = 1024 + BLEND = 1024, + PRIMITIVE_TYPE = 2048 }; const Framebuffer *framebuffer = 0; @@ -71,6 +73,7 @@ private: std::vector uniform_blocks; std::vector textures; const VertexSetup *vertex_setup = 0; + PrimitiveType primitive_type = TRIANGLES; FaceWinding front_face = COUNTERCLOCKWISE; CullMode face_cull = NO_CULL; const DepthTest *depth_test = 0; @@ -88,6 +91,7 @@ public: void set_uniform_block(int, const UniformBlock *); void set_texture(unsigned, const Texture *, const Sampler *); void set_vertex_setup(const VertexSetup *); + void set_primitive_type(PrimitiveType); void set_front_face(FaceWinding); void set_face_cull(CullMode); void set_depth_test(const DepthTest *); diff --git a/source/render/renderer.cpp b/source/render/renderer.cpp index 45ad1200..4fb2b0c7 100644 --- a/source/render/renderer.cpp +++ b/source/render/renderer.cpp @@ -240,6 +240,7 @@ void Renderer::draw(const Batch &batch) { apply_state(); batch.refresh(); + pipeline_state.set_primitive_type(batch.get_type()); commands.use_pipeline(&pipeline_state); commands.draw(batch); } @@ -248,6 +249,7 @@ void Renderer::draw_instanced(const Batch &batch, unsigned count) { apply_state(); batch.refresh(); + pipeline_state.set_primitive_type(batch.get_type()); commands.use_pipeline(&pipeline_state); commands.draw_instanced(batch, count); }