friend PipelineStateBackend;
private:
- struct BoundTexture
+ enum ResourceType: std::uint8_t
{
- unsigned binding = 0;
- mutable bool changed = false;
- mutable bool used = false;
- const Texture *texture = 0;
- const Sampler *sampler = 0;
- int level = -1;
-
- BoundTexture(unsigned b): binding(b) { }
+ NO_RESOURCE,
+ UNIFORM_BLOCK,
+ TEXTURE
};
- struct BoundUniformBlock
+ struct BoundResource
{
int binding = 0;
+ ResourceType type = NO_RESOURCE;
mutable bool changed = false;
mutable bool used = false;
- const UniformBlock *block = 0;
- const Buffer *buffer = 0;
+ union
+ {
+ const UniformBlock *block;
+ const Texture *texture;
+ };
+ union
+ {
+ const Buffer *buffer;
+ const Sampler *sampler;
+ };
+ int mip_level = -1;
- BoundUniformBlock(int b): binding(b) { }
+ BoundResource(int b): binding(b), texture(0), sampler(0) { }
};
enum ChangeMask
VIEWPORT = 2,
SCISSOR = 4,
SHPROG = 8,
- UNIFORMS = 16,
- TEXTURES = 32,
+ RESOURCES = 16,
VERTEX_SETUP = 64,
FACE_CULL = 128,
DEPTH_TEST = 256,
Rect viewport = Rect::max();
Rect scissor = Rect::max();
const Program *shprog = 0;
- std::vector<BoundUniformBlock> uniform_blocks;
- std::vector<BoundTexture> textures;
+ std::vector<BoundResource> resources;
const VertexSetup *vertex_setup = 0;
PrimitiveType primitive_type = TRIANGLES;
FaceWinding front_face = COUNTERCLOCKWISE;