]> git.tdb.fi Git - libs/gl.git/blob - source/core/pipelinestate.h
Mark the start of a SPIR-V function as reachable
[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                 SHPROG = 1,
55                 VERTEX_SETUP = 2,
56                 FACE_CULL = 4,
57                 TEXTURES = 16,
58                 UNIFORMS = 32,
59                 DEPTH_TEST = 64,
60                 STENCIL_TEST = 128,
61                 BLEND = 256,
62                 FRAMEBUFFER = 512,
63                 VIEWPORT = 1024,
64                 SCISSOR = 2048
65         };
66
67         const Framebuffer *framebuffer = 0;
68         const Rect *viewport = 0;
69         const Rect *scissor = 0;
70         const Program *shprog = 0;
71         const VertexSetup *vertex_setup = 0;
72         FaceWinding front_face = COUNTERCLOCKWISE;
73         CullMode face_cull = NO_CULL;
74         std::vector<BoundTexture> textures;
75         std::vector<BoundUniformBlock> uniform_blocks;
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_vertex_setup(const VertexSetup *);
89         void set_front_face(FaceWinding);
90         void set_face_cull(CullMode);
91         void set_texture(unsigned, const Texture *, const Sampler *);
92         void set_uniform_block(int, const UniformBlock *);
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