1 #ifndef MSP_GL_PIPELINESTATE_H_
2 #define MSP_GL_PIPELINESTATE_H_
5 #include <msp/core/noncopyable.h>
12 class BufferBackedUniformBlock;
13 class DefaultUniformBlock;
24 class PipelineState: public NonCopyable
31 const Texture *texture;
32 const Sampler *sampler;
34 BoundTexture(unsigned);
37 struct BoundUniformBlock
41 const UniformBlock *block;
43 BoundUniformBlock(int);
62 const Framebuffer *framebuffer;
65 const Program *shprog;
66 const VertexSetup *vertex_setup;
67 FaceWinding front_face;
69 unsigned enabled_clip_planes;
70 std::vector<BoundTexture> textures;
71 std::vector<BoundUniformBlock> uniform_blocks;
72 const DepthTest *depth_test;
73 const StencilTest *stencil_test;
75 mutable unsigned changes;
77 static const PipelineState *last_applied;
78 static std::vector<int> bound_tex_targets;
79 static std::vector<char> bound_uniform_blocks;
80 static unsigned restart_index;
88 void set(T &, T, unsigned);
90 void set_framebuffer(const Framebuffer *);
91 void set_viewport(const Rect *);
92 void set_scissor(const Rect *);
93 void set_shader_program(const Program *);
94 void set_vertex_setup(const VertexSetup *);
95 void set_front_face(FaceWinding);
96 void set_face_cull(CullMode);
97 void set_enabled_clip_planes(unsigned);
98 void set_texture(unsigned, const Texture *, const Sampler *);
99 void set_uniforms(const DefaultUniformBlock *);
100 void set_uniform_block(unsigned, const BufferBackedUniformBlock *);
102 void set_uniform_block_(int, const UniformBlock *);
104 void set_depth_test(const DepthTest *);
105 void set_stencil_test(const StencilTest *);
106 void set_blend(const Blend *);
108 const Framebuffer *get_framebuffer() const { return framebuffer; }
109 const Program *get_shader_program() const { return shprog; }
110 const VertexSetup *get_vertex_setup() const { return vertex_setup; }
111 FaceWinding get_front_face() const { return front_face; }
112 CullMode get_face_cull() const { return face_cull; }
116 void apply(unsigned) const;