]> git.tdb.fi Git - libs/gl.git/commitdiff
Store primitive type in PipelineState
authorMikko Rasa <tdb@tdb.fi>
Wed, 17 Nov 2021 19:51:26 +0000 (21:51 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 18 Nov 2021 00:50:28 +0000 (02:50 +0200)
Vulkan needs it to be here

source/core/pipelinestate.cpp
source/core/pipelinestate.h
source/render/renderer.cpp

index 0306a2626c9c4cbde629e6fc236fb2648431ebc5..742b2ba94c2723ccb917c1f181c10889e9205b16 100644 (file)
@@ -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);
index 31938829ec61186e0cc6863fe7870640e898ebf1..0973bfb5ba16a4c7d04f6f54844ea677149c6c25 100644 (file)
@@ -5,6 +5,7 @@
 #include <msp/core/noncopyable.h>
 #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<BoundUniformBlock> uniform_blocks;
        std::vector<BoundTexture> 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 *);
index 45ad120045397de5848e4cecfe1968f39e83433b..4fb2b0c79bc01dc8dcbf6fbc58b79aea98b0f441 100644 (file)
@@ -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);
 }