Berserk
RHIResourceSet.hpp
Go to the documentation of this file.
1 /**********************************************************************************/
2 /* This file is part of Berserk Engine project */
3 /* https://github.com/EgorOrachyov/Berserk */
4 /**********************************************************************************/
5 /* MIT License */
6 /* */
7 /* Copyright (c) 2018 - 2021 Egor Orachyov */
8 /* */
9 /* Permission is hereby granted, free of charge, to any person obtaining a copy */
10 /* of this software and associated documentation files (the "Software"), to deal */
11 /* in the Software without restriction, including without limitation the rights */
12 /* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell */
13 /* copies of the Software, and to permit persons to whom the Software is */
14 /* furnished to do so, subject to the following conditions: */
15 /* */
16 /* The above copyright notice and this permission notice shall be included in all */
17 /* copies or substantial portions of the Software. */
18 /* */
19 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
20 /* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
21 /* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
22 /* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
23 /* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
24 /* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */
25 /* SOFTWARE. */
26 /**********************************************************************************/
27 
28 #ifndef BERSERK_RHIRESOURCESET_HPP
29 #define BERSERK_RHIRESOURCESET_HPP
30 
31 #include <core/Config.hpp>
32 #include <core/Data.hpp>
33 #include <core/Typedefs.hpp>
34 #include <rhi/RHIBuffer.hpp>
35 #include <rhi/RHIResource.hpp>
36 #include <rhi/RHISampler.hpp>
37 #include <rhi/RHITexture.hpp>
38 
39 #include <vector>
40 
42 
53 public:
54  struct TextureBinding {
58  };
59 
60  struct SamplerBinding {
64  };
65 
66  struct BufferBinding {
71  };
72 
75 
77  BRK_API void AddTexture(Ref<RHITexture> texture, uint32 location, uint32 arrayIndex = 0);
79  BRK_API void AddSampler(Ref<RHISampler> sampler, uint32 location, uint32 arrayIndex = 0);
81  BRK_API void AddBuffer(Ref<RHIUniformBuffer> buffer, uint32 location, uint32 offset, uint32 range);
82 
83 
85  BRK_API bool SetTexture(Ref<RHITexture> texture, uint32 location, uint32 arrayIndex = 0);
87  BRK_API bool SetSampler(Ref<RHISampler> sampler, uint32 location, uint32 arrayIndex = 0);
89  BRK_API bool SetBuffer(Ref<RHIUniformBuffer> buffer, uint32 location, uint32 offset, uint32 range);
90 
92  BRK_API void Clear();
93 
95  BRK_API const std::vector<TextureBinding> &GetTextures() const { return mTextures; }
97  BRK_API const std::vector<SamplerBinding> &GetSamplers() const { return mSamplers; };
99  BRK_API const std::vector<BufferBinding> &GetBuffers() const { return mBuffers; };
100 
101 private:
102  std::vector<TextureBinding> mTextures;
103  std::vector<SamplerBinding> mSamplers;
104  std::vector<BufferBinding> mBuffers;
105 };
106 
111 class RHIResourceSet : public RHIResource {
112 public:
113  BRK_API ~RHIResourceSet() override = default;
114 };
115 
121 
122 #endif//BERSERK_RHIRESOURCESET_HPP
#define BRK_NS_END
Definition: Config.hpp:48
#define BRK_API
Definition: Config.hpp:32
std::uint32_t uint32
Definition: Typedefs.hpp:44
Describes single set of GPU resource for shader.
Definition: RHIResourceSet.hpp:52
BRK_API bool SetTexture(Ref< RHITexture > texture, uint32 location, uint32 arrayIndex=0)
Definition: RHIResourceSet.cpp:59
BRK_API const std::vector< SamplerBinding > & GetSamplers() const
Definition: RHIResourceSet.hpp:97
BRK_API void AddBuffer(Ref< RHIUniformBuffer > buffer, uint32 location, uint32 offset, uint32 range)
Definition: RHIResourceSet.cpp:50
BRK_API void Clear()
Definition: RHIResourceSet.cpp:91
BRK_API const std::vector< TextureBinding > & GetTextures() const
Definition: RHIResourceSet.hpp:95
BRK_API ~RHIResourceSetDesc()=default
BRK_API void AddSampler(Ref< RHISampler > sampler, uint32 location, uint32 arrayIndex=0)
Definition: RHIResourceSet.cpp:42
BRK_API void AddTexture(Ref< RHITexture > texture, uint32 location, uint32 arrayIndex=0)
Definition: RHIResourceSet.cpp:34
BRK_API RHIResourceSetDesc()=default
BRK_API bool SetBuffer(Ref< RHIUniformBuffer > buffer, uint32 location, uint32 offset, uint32 range)
Definition: RHIResourceSet.cpp:81
BRK_API bool SetSampler(Ref< RHISampler > sampler, uint32 location, uint32 arrayIndex=0)
Definition: RHIResourceSet.cpp:70
BRK_API const std::vector< BufferBinding > & GetBuffers() const
Definition: RHIResourceSet.hpp:99
Set of resource ready to be bound to the pipeline.
Definition: RHIResourceSet.hpp:111
BRK_API ~RHIResourceSet() override=default
Base class for RHI resource.
Definition: RHIResource.hpp:55
Definition: GLDevice.cpp:46
Definition: RHIResourceSet.hpp:66
uint32 range
Definition: RHIResourceSet.hpp:70
uint32 offset
Definition: RHIResourceSet.hpp:69
uint32 location
Definition: RHIResourceSet.hpp:68
Ref< RHIUniformBuffer > buffer
Definition: RHIResourceSet.hpp:67
Definition: RHIResourceSet.hpp:60
uint32 location
Definition: RHIResourceSet.hpp:62
uint32 arrayIndex
Definition: RHIResourceSet.hpp:63
Ref< RHISampler > sampler
Definition: RHIResourceSet.hpp:61
Definition: RHIResourceSet.hpp:54
uint32 location
Definition: RHIResourceSet.hpp:56
Ref< RHITexture > texture
Definition: RHIResourceSet.hpp:55
uint32 arrayIndex
Definition: RHIResourceSet.hpp:57