]> git.tdb.fi Git - libs/gl.git/blob - source/core/pipelinestate.h
Fix reflection of image types from Spir-V modules
[libs/gl.git] / source / core / pipelinestate.h
1 #ifndef MSP_GL_PIPELINESTATE_H_
2 #define MSP_GL_PIPELINESTATE_H_
3
4 #include <vector>
5 #include <msp/core/noncopyable.h>
6 #include "cullface.h"
7 #include "pipelinestate_backend.h"
8
9 namespace Msp {
10 namespace GL {
11
12 class Blend;
13 class DepthTest;
14 class Framebuffer;
15 class Program;
16 class Rect;
17 class Sampler;
18 class StencilTest;
19 class Texture;
20 class UniformBlock;
21 class VertexSetup;
22
23 /**
24 Stores state for the entire GPU pipeline.
25
26 Applications normally use the higher-level Renderer class rather than this.
27 */
28 class PipelineState: public PipelineStateBackend
29 {
30         friend PipelineStateBackend;
31
32 private:
33         struct BoundTexture
34         {
35                 unsigned binding;
36                 mutable bool changed;
37                 const Texture *texture;
38                 const Sampler *sampler;
39
40                 BoundTexture(unsigned);
41         };
42
43         struct BoundUniformBlock
44         {
45                 int binding;
46                 mutable bool changed;
47                 const UniformBlock *block;
48
49                 BoundUniformBlock(int);
50         };
51
52         enum ChangeMask
53         {
54                 FRAMEBUFFER = 1,
55                 VIEWPORT = 2,
56                 SCISSOR = 4,
57                 SHPROG = 8,
58                 UNIFORMS = 16,
59                 TEXTURES = 32,
60                 VERTEX_SETUP = 64,
61                 FACE_CULL = 128,
62                 DEPTH_TEST = 256,
63                 STENCIL_TEST = 512,
64                 BLEND = 1024
65         };
66
67         const Framebuffer *framebuffer = 0;
68         const Rect *viewport = 0;
69         const Rect *scissor = 0;
70         const Program *shprog = 0;
71         std::vector<BoundUniformBlock> uniform_blocks;
72         std::vector<BoundTexture> textures;
73         const VertexSetup *vertex_setup = 0;
74         FaceWinding front_face = COUNTERCLOCKWISE;
75         CullMode face_cull = NO_CULL;
76         const DepthTest *depth_test = 0;
77         const StencilTest *stencil_test = 0;
78         const Blend *blend = 0;
79         mutable unsigned changes = 0;
80
81         template<typename T>
82         void set(T &, T, unsigned);
83 public:
84         void set_framebuffer(const Framebuffer *);
85         void set_viewport(const Rect *);
86         void set_scissor(const Rect *);
87         void set_shader_program(const Program *);
88         void set_uniform_block(int, const UniformBlock *);
89         void set_texture(unsigned, const Texture *, const Sampler *);
90         void set_vertex_setup(const VertexSetup *);
91         void set_front_face(FaceWinding);
92         void set_face_cull(CullMode);
93         void set_depth_test(const DepthTest *);
94         void set_stencil_test(const StencilTest *);
95         void set_blend(const Blend *);
96
97         const Framebuffer *get_framebuffer() const { return framebuffer; }
98         const Program *get_shader_program() const { return shprog; }
99         const VertexSetup *get_vertex_setup() const { return vertex_setup; }
100         FaceWinding get_front_face() const { return front_face; }
101         CullMode get_face_cull() const { return face_cull; }
102 };
103
104 } // namespace GL
105 } // namespace Msp
106
107 #endif