1 #ifndef MSP_GL_PIPELINESTATE_H_
2 #define MSP_GL_PIPELINESTATE_H_
5 #include <msp/core/noncopyable.h>
9 #include "pipelinestate_backend.h"
10 #include "primitivetype.h"
12 #include "stenciltest.h"
26 Stores state for the entire GPU pipeline.
28 Applications normally use the higher-level Renderer class rather than this.
30 class PipelineState: public PipelineStateBackend
32 friend PipelineStateBackend;
35 enum ResourceType: std::uint8_t
46 ResourceType type = NO_RESOURCE;
47 mutable bool changed = false;
48 mutable bool used = false;
51 const UniformBlock *block;
52 const Texture *texture;
57 const Sampler *sampler;
61 BoundResource(int b): binding(b), texture(0), sampler(0) { }
76 PRIMITIVE_TYPE = 2048,
80 const Framebuffer *framebuffer = 0;
81 Rect viewport = Rect::max();
82 Rect scissor = Rect::max();
83 const Program *shprog = 0;
84 std::vector<BoundResource> resources;
85 const VertexSetup *vertex_setup = 0;
86 PrimitiveType primitive_type = TRIANGLES;
87 unsigned patch_size = 0;
88 FaceWinding front_face = COUNTERCLOCKWISE;
89 CullMode face_cull = NO_CULL;
91 StencilTest stencil_test;
95 void set(T &, const T &, unsigned);
97 void set_framebuffer(const Framebuffer *);
98 void set_viewport(const Rect &);
99 void set_scissor(const Rect &);
100 void set_shader_program(const Program *);
101 void set_uniform_block(int, const UniformBlock *);
102 void set_texture(unsigned, const Texture *, const Sampler *);
103 void set_texture(unsigned, const Texture *, int, const Sampler *);
104 void set_storage_texture(unsigned, const Texture *);
106 void set_texture_resource(unsigned, const Texture *, int, const Sampler *);
108 void set_vertex_setup(const VertexSetup *);
109 void set_primitive_type(PrimitiveType);
110 void set_patch_size(unsigned);
111 void set_front_face(FaceWinding);
112 void set_face_cull(CullMode);
113 void set_depth_test(const DepthTest &);
114 void set_stencil_test(const StencilTest &);
115 void set_blend(const Blend &);
117 const Framebuffer *get_framebuffer() const { return framebuffer; }
118 const Rect &get_viewport() const { return viewport; }
119 const Program *get_shader_program() const { return shprog; }
120 const VertexSetup *get_vertex_setup() const { return vertex_setup; }
121 FaceWinding get_front_face() const { return front_face; }
122 CullMode get_face_cull() const { return face_cull; }
125 void check_bound_resources() const;