X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fpipelinestate.h;h=965bc15f16f11e5dbcfef30068dad621cee0a3a3;hb=fcc065736e303088ef121c554318e0cc028a0666;hp=28624ed7ca64a5a0e5bba111cf45b27477bb11e5;hpb=016f0f0dd51511f98d0bf398d99199d7dec1543c;p=libs%2Fgl.git diff --git a/source/core/pipelinestate.h b/source/core/pipelinestate.h index 28624ed7..965bc15f 100644 --- a/source/core/pipelinestate.h +++ b/source/core/pipelinestate.h @@ -32,27 +32,33 @@ class PipelineState: public PipelineStateBackend 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, + SAMPLED_TEXTURE, + STORAGE_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 @@ -61,8 +67,7 @@ private: VIEWPORT = 2, SCISSOR = 4, SHPROG = 8, - UNIFORMS = 16, - TEXTURES = 32, + RESOURCES = 16, VERTEX_SETUP = 64, FACE_CULL = 128, DEPTH_TEST = 256, @@ -75,8 +80,7 @@ private: Rect viewport = Rect::max(); Rect scissor = Rect::max(); const Program *shprog = 0; - std::vector uniform_blocks; - std::vector textures; + std::vector resources; const VertexSetup *vertex_setup = 0; PrimitiveType primitive_type = TRIANGLES; FaceWinding front_face = COUNTERCLOCKWISE; @@ -95,6 +99,10 @@ public: void set_uniform_block(int, const UniformBlock *); void set_texture(unsigned, const Texture *, const Sampler *); void set_texture(unsigned, const Texture *, int, const Sampler *); + void set_storage_texture(unsigned, const Texture *); +private: + void set_texture_resource(unsigned, const Texture *, int, const Sampler *); +public: void set_vertex_setup(const VertexSetup *); void set_primitive_type(PrimitiveType); void set_front_face(FaceWinding);