CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
GPUResourceSet.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "Forward.hpp"
11
12#include "GPUBuffer.hpp"
13#include "GPUImage.hpp"
14#include "GPUResource.hpp"
15
18
28
29#include <initializer_list>
30
31namespace CeresEngine {
32
33 struct GPUShaderReflectionDescriptor;
34 class GPUBufferObject;
35
39 Undefined = 0,
40
43
46
49
51 Image,
52
54 Sampler,
55
58
61 };
62
63 // ---------------------------------------------------------------------------------------------
64
68
72
73 public: // Reflection
76 template<typename Processor> static constexpr void reflect(Processor&& RTTI) {
79 }
80 };
81
84 GPUImagePtr image = nullptr;
85
90
95 .subresource{
96 .numArrayLayers = 0,
97 .numMipLevels = 0,
98 },
99 };
100
101 public: // Reflection
104 template<typename Processor> static constexpr void reflect(Processor&& RTTI) {
108 }
109 };
110
116
117 public: // Reflection
120 template<typename Processor> static constexpr void reflect(Processor&& RTTI) {
122 }
123 };
124
125 class GPUResourceBinding : public Variant<std::nullptr_t, GPUBufferResourceBinding, GPUImageResourceBinding, GPUSamplerResourceBinding> {
127 template<typename> friend struct std::hash;
128
129 public:
130 using super::super;
131
132 CE_EXPLICIT(false) inline GPUResourceBinding(GPUBufferPtr buffer, const GPUBufferViewDescriptor& bufferView = {})
133 : super(GPUBufferResourceBinding{.buffer = std::move(buffer), .bufferView = bufferView}) {}
134 CE_EXPLICIT(false) inline GPUResourceBinding(GPUBuffer& buffer, const GPUBufferViewDescriptor& bufferView = {}) : GPUResourceBinding(&buffer, bufferView) {}
135
137
138 CE_EXPLICIT(false) inline GPUResourceBinding(GPUImagePtr image, GPUSamplerPtr sampler = nullptr)
139 : super(GPUImageResourceBinding{.image = std::move(image), .sampler = std::move(sampler)}) {}
140 CE_EXPLICIT(false) inline GPUResourceBinding(GPUImage& image, GPUSamplerPtr sampler = nullptr) : GPUResourceBinding(&image, std::move(sampler)) {}
141
142 CE_EXPLICIT(false) inline GPUResourceBinding(GPUImagePtr image, GPUSampler& sampler) : GPUResourceBinding(std::move(image), &sampler) {}
143 CE_EXPLICIT(false) inline GPUResourceBinding(GPUImage& image, GPUSampler& sampler) : GPUResourceBinding(&image, &sampler) {}
144
146 : super(GPUSamplerResourceBinding{.sampler = std::move(sampler)}) {}
147 CE_EXPLICIT(false) inline GPUResourceBinding(GPUSampler& sampler) : GPUResourceBinding(&sampler) {}
148
149 public:
151 [[nodiscard]] bool isEmpty() const noexcept { return super::is<std::nullptr_t>(); }
152
154 explicit operator bool() const noexcept { return isEmpty(); }
155
157 [[nodiscard]] bool isBufferBinding() const noexcept { return super::is<GPUBufferResourceBinding>(); }
158
160 [[nodiscard]] const GPUBufferResourceBinding& asBufferBinding() const {
161 CE_ASSERT(super::is<GPUBufferResourceBinding>());
162 return as<GPUBufferResourceBinding>();
163 }
164
167 CE_ASSERT(super::is<GPUBufferResourceBinding>());
168 return as<GPUBufferResourceBinding>();
169 }
170
172 [[nodiscard]] bool isImageBinding() const noexcept { return super::is<GPUImageResourceBinding>(); }
173
175 [[nodiscard]] const GPUImageResourceBinding& asImageBinding() const {
176 CE_ASSERT(super::is<GPUImageResourceBinding>());
177 return as<GPUImageResourceBinding>();
178 }
179
182 CE_ASSERT(super::is<GPUImageResourceBinding>());
183 return as<GPUImageResourceBinding>();
184 }
185
187 [[nodiscard]] bool isSamplerBinding() const noexcept { return super::is<GPUSamplerResourceBinding>(); }
188
190 [[nodiscard]] const GPUSamplerResourceBinding& asSamplerBinding() const {
191 CE_ASSERT(super::is<GPUSamplerResourceBinding>());
192 return as<GPUSamplerResourceBinding>();
193 }
194
197 CE_ASSERT(super::is<GPUSamplerResourceBinding>());
198 return as<GPUSamplerResourceBinding>();
199 }
200
201 public: // Comparison
202 [[nodiscard]] friend bool operator==(const GPUResourceBinding& lhs, std::nullptr_t) noexcept { return lhs.isEmpty(); }
203 [[nodiscard]] friend bool operator!=(const GPUResourceBinding& lhs, const std::nullptr_t rhs) noexcept { return !(lhs == rhs); }
204
205 // [[nodiscard]] friend bool operator==(const GPUResourceBinding& lhs, const GPUBufferResourceBinding& rhs) noexcept {
206 // return lhs.isBufferBinding() && lhs.asBufferBinding() == rhs;
207 // }
208 // [[nodiscard]] friend bool operator!=(const GPUResourceBinding& lhs, const GPUBufferResourceBinding& rhs) noexcept { return !(lhs == rhs); }
209 //
210 // [[nodiscard]] friend bool operator==(const GPUResourceBinding& lhs, const GPUImageResourceBinding& rhs) noexcept {
211 // return lhs.isImageBinding() && lhs.asImageBinding() == rhs;
212 // }
213 // [[nodiscard]] friend bool operator!=(const GPUResourceBinding& lhs, const GPUImageResourceBinding& rhs) noexcept { return !(lhs == rhs); }
214 //
215 // [[nodiscard]] friend bool operator==(const GPUResourceBinding& lhs, const GPUSamplerResourceBinding& rhs) noexcept {
216 // return lhs.isSamplerBinding() && lhs.asSamplerBinding() == rhs;
217 // }
218 // [[nodiscard]] friend bool operator!=(const GPUResourceBinding& lhs, const GPUSamplerResourceBinding& rhs) noexcept { return !(lhs == rhs); }
219 };
220
221 class GPUResourceSetBindings;
222
224 template<bool Const> class TGPUResourceSetBindingSlot final {
225 using GPUResourceSetBindingsType = std::conditional_t<Const, const GPUResourceSetBindings, GPUResourceSetBindings>;
227
228 public:
232
235
236 private:
238 // `GPUResourceSetBindings` and `slot` index.
242
243 public:
249 [[nodiscard]] const GPUResourceBinding* get(UInt32 index = 0) const { return bindings.get(slot, index); }
250
256 [[nodiscard]] GPUResourceBinding* get(UInt32 index = 0) requires(!Const) { return bindings.get(slot, index); }
257
262 GPUResourceBinding& set(UInt32 index, GPUResourceBinding binding) requires(!Const) { return bindings.set(slot, index, std::move(binding)); }
263
270 GPUResourceBinding& set(GPUResourceBinding binding) requires(!Const) { return bindings.set(slot, std::move(binding)); }
271
273 [[nodiscard]] const GPUResourceBinding& operator[](const UInt32 index) const {
274 GPUResourceBinding* const binding = get(index);
275 CE_ASSERT(binding != nullptr);
276 return *binding;
277 }
278
280 [[nodiscard]] GPUResourceBinding& operator[](const UInt32 index) requires(!Const) {
281 if(GPUResourceBinding* const binding = get(index)) {
282 return *binding;
283 }
284
285 return set(index, GPUResourceBinding(nullptr));
286 }
287
290 {
291 set(binding);
292 return *this;
293 }
294
303 {
304 return bindings.add(slot, std::move(binding));
305 }
306
309 {
310 return add(std::move(binding));
311 }
312
316 void remove(UInt32 index) { bindings.remove(slot, index); }
317
321 void remove() { bindings.remove(slot); }
322
325 [[nodiscard]] UInt32 size() const { return bindings.size(slot); }
326
327 explicit operator bool() const noexcept { return slot != ~0u; }
328 };
329
332
335
336 static constexpr UInt32 kGPUResourceSetBindingsSmallSize = 20u;
337
338 class GPUResourceSetBindings : private SmallFlatIndexedMultimap<UInt32, GPUResourceBinding, kGPUResourceSetBindingsSmallSize> {
340 template<typename> friend struct std::hash;
341
342 public:
344
347
348 public:
349 using super::reserve;
350 using super::resize;
351 using super::clear;
352
359 [[nodiscard]] const GPUResourceBinding* get(const UInt32 slot, const UInt32 index = 0) const {
360 if(!super::contains(slot, index)) {
361 return nullptr;
362 }
363 return &super::at(slot, index);
364 }
365
372 [[nodiscard]] GPUResourceBinding* get(const UInt32 slot, const UInt32 index = 0) { return const_cast<GPUResourceBinding*>(std::as_const(*this).get(slot, index)); }
373
378 GPUResourceBinding& set(const UInt32 slot, const UInt32 index, GPUResourceBinding binding) { return (*this)(slot, index) = std::move(binding); }
379
388 super::erase(slot);
389 return super::emplace_back(slot, std::move(binding));
390 }
391
400 UInt32 add(const UInt32 slot, GPUResourceBinding binding) {
401 super::emplace_back(slot, std::move(binding));
402 return (UInt32)(super::size(slot) - 1);
403 }
404
409 void remove(const UInt32 slot, const UInt32 index) {
410 if(super::contains(slot, index)) {
411 super::erase(super::lower_bound(slot) + index);
412 }
413 }
414
420 void remove(UInt32 slot) { super::erase(slot); }
421
426 [[nodiscard]] UInt32 size(const UInt32 slot) const { return UInt32(super::size(slot)); }
427
430 [[nodiscard]] UInt32 size() const { return UInt32(super::size()); }
431
434 [[nodiscard]] GPUResourceSetBindingSlot operator[](UInt32 slot) { return {*this, slot}; }
435
438 [[nodiscard]] GPUResourceSetConstBindingSlot operator[](UInt32 slot) const { return {*this, slot}; }
439
440 public:
441 using super::begin;
442 using super::end;
443
448
451
452 public: // Interop
455 };
456
459 template<typename> friend struct std::hash;
460
461 private:
464
467 UInt32 mSetIndex = 0;
468
469 public:
473 explicit GPUShaderResourceSetBindings(const GPUShader& shader, UInt32 setIndex = 0);
474
476 explicit GPUShaderResourceSetBindings(const GPUShaderPtr& shader, const UInt32 setIndex = 0) : GPUShaderResourceSetBindings(*shader, setIndex) {}
477
481 explicit GPUShaderResourceSetBindings(const GPUShaderProgram& shaderProgram, UInt32 setIndex = 0);
482
484 explicit GPUShaderResourceSetBindings(const GPUShaderProgramPtr& shaderProgram, const UInt32 setIndex = 0)
485 : GPUShaderResourceSetBindings(*shaderProgram, setIndex) {}
486
490 explicit GPUShaderResourceSetBindings(const GPUGraphicsPipeline& pipeline, UInt32 setIndex = 0);
491
493 explicit GPUShaderResourceSetBindings(const GPUGraphicsPipelinePtr& pipeline, const UInt32 setIndex = 0)
494 : GPUShaderResourceSetBindings(*pipeline, setIndex) {}
495
499 explicit GPUShaderResourceSetBindings(const GPUComputePipeline& pipeline, UInt32 setIndex = 0);
500
502 explicit GPUShaderResourceSetBindings(const GPUComputePipelinePtr& pipeline, const UInt32 setIndex = 0) : GPUShaderResourceSetBindings(*pipeline, setIndex) {}
503
507 explicit GPUShaderResourceSetBindings(const GPUPipelineLayout& pipeline, UInt32 setIndex = 0);
508
510 explicit GPUShaderResourceSetBindings(const GPUPipelineLayoutPtr& pipelineLayout, const UInt32 setIndex = 0)
511 : GPUShaderResourceSetBindings(*pipelineLayout, setIndex) {}
512
513
522 explicit GPUShaderResourceSetBindings(const GPUResourceSetBindings& existingBindings, const GPUShader& shader, UInt32 setIndex = 0);
523
525 explicit GPUShaderResourceSetBindings(const GPUResourceSetBindings& existingBindings, const GPUShaderPtr& shader, const UInt32 setIndex = 0)
526 : GPUShaderResourceSetBindings(*shader, setIndex) {}
527
536 explicit GPUShaderResourceSetBindings(const GPUResourceSetBindings& existingBindings, const GPUShaderProgram& shaderProgram, UInt32 setIndex = 0);
537
539 explicit GPUShaderResourceSetBindings(const GPUResourceSetBindings& existingBindings, const GPUShaderProgramPtr& shaderProgram, const UInt32 setIndex = 0)
540 : GPUShaderResourceSetBindings(existingBindings, *shaderProgram, setIndex) {}
541
550 explicit GPUShaderResourceSetBindings(const GPUResourceSetBindings& existingBindings, const GPUGraphicsPipeline& pipeline, UInt32 setIndex = 0);
551
553 explicit GPUShaderResourceSetBindings(const GPUResourceSetBindings& existingBindings, const GPUGraphicsPipelinePtr& pipeline, const UInt32 setIndex = 0)
554 : GPUShaderResourceSetBindings(existingBindings, *pipeline, setIndex) {}
555
564 explicit GPUShaderResourceSetBindings(const GPUResourceSetBindings& existingBindings, const GPUComputePipeline& pipeline, UInt32 setIndex = 0);
565
567 explicit GPUShaderResourceSetBindings(const GPUResourceSetBindings& existingBindings, const GPUComputePipelinePtr& pipeline, const UInt32 setIndex = 0)
568 : GPUShaderResourceSetBindings(existingBindings, *pipeline, setIndex) {}
569
570 public:
571 using super::get;
572 using super::set;
573 using super::add;
574 using super::remove;
575 using super::size;
576 using super::resize;
577 using super::clear;
578 using super::operator[];
579
584 [[nodiscard]] bool has(const StringView name) const { return findSlotIndex(name) != ~0u; }
585
590 [[nodiscard]] bool has(UInt32 slot) const;
591
598 [[nodiscard]] const GPUResourceBinding* get(const StringView name, const UInt32 index = 0) const {
599 const UInt32 slot = findSlotIndex(name);
600 return super::get(slot, index);
601 }
602
609 [[nodiscard]] GPUResourceBinding* get(const StringView name, const UInt32 index = 0) {
610 const UInt32 slot = findSlotIndex(name);
611 return super::get(slot, index);
612 }
613
618 void set(const StringView name, const UInt32 index, GPUResourceBinding binding) {
619 const UInt32 slot = findSlotIndex(name);
620 super::set(slot, index, std::move(binding));
621 }
622
630 void set(const StringView name, GPUResourceBinding binding) {
631 const UInt32 slot = findSlotIndex(name);
632 super::set(slot, std::move(binding));
633 }
634
644 const UInt32 slot = findSlotIndex(name);
645 return super::add(slot, std::move(binding));
646 }
647
652 void remove(const StringView name, const UInt32 index) {
653 const UInt32 slot = findSlotIndex(name);
654 return super::remove(slot, index);
655 }
656
662 void remove(const StringView name) {
663 const UInt32 slot = findSlotIndex(name);
664 return super::remove(slot);
665 }
666
671 [[nodiscard]] UInt32 size(const StringView name) const {
672 const UInt32 slot = findSlotIndex(name);
673 return super::size(slot);
674 }
675
680 void resize(const StringView name, const UInt32 newSize, const GPUResourceBinding& defaultValue = {}) {
681 const UInt32 slot = findSlotIndex(name);
682 super::resize(slot, newSize, defaultValue);
683 }
684
688 void clear(const StringView name) {
689 const UInt32 slot = findSlotIndex(name);
690 super::clear(slot);
691 }
692
695 [[nodiscard]] auto operator[](const StringView name) {
696 const UInt32 slot = findSlotIndex(name);
697 return super::operator[](slot);
698 }
699
702 [[nodiscard]] auto operator[](const StringView name) const {
703 const UInt32 slot = findSlotIndex(name);
704 return super::operator[](slot);
705 }
706
707 private:
711 [[nodiscard]] UInt32 findSlotIndex(StringView name) const;
712 };
713
714 // ---------------------------------------------------------------------------------------------
715
719
723
724 public: // Reflection
727 template<typename Processor> static constexpr void reflect(Processor&& RTTI) {
728 CE_REFL_DATA(bindings);
729 CE_REFL_DATA(name);
730 }
731 };
732
735 class GPUResourceSet : public TDeviceObject<GPUResourceSetDescriptor> {
736 public:
739
740 public:
742 explicit GPUResourceSet(GPUPipelineLayout& pipelineLayout, const GPUResourceSetDescriptor& descriptor);
743
745 ~GPUResourceSet() override;
746
750
754 };
755} // namespace CeresEngine
756
759
762
765
767template<> struct std::hash<CeresEngine::GPUResourceBinding> : public std::hash<CeresEngine::GPUResourceBinding::super> {};
768
770template<> struct std::hash<CeresEngine::GPUResourceSetBindings> {
771 [[nodiscard]] size_t operator()(const CeresEngine::GPUResourceSetBindings& object) {
773 }
774};
775
777template<> struct std::hash<CeresEngine::GPUShaderResourceSetBindings> : public std::hash<CeresEngine::GPUShaderResourceSetBindings::super> {};
778
#define CE_REFLECT_HASH(T)
Definition Hash.hpp:89
#define CE_ASSERT(...)
Definition Macros.hpp:323
#define CE_REFL_DATA(N)
Definition Macros.hpp:541
#define CE_EXPLICIT(EXPR)
Definition Macros.hpp:413
Definition IndexedMultimap.hpp:12
void clear(const K &key)
Clears all values of the given key.
Definition IndexedMultimap.hpp:156
mapped_type & emplace_back(const K &key, Args &&... args)
Emplaces a new element for key at the end of container.
Definition IndexedMultimap.hpp:200
bool contains(const K &key, size_t index) const
Returns true if the container contains an element at index with key equivalent to key,...
Definition IndexedMultimap.hpp:104
size_type size(const K &key) const
Computes the number of elements for the given key.
Definition IndexedMultimap.hpp:172
mapped_type & at(const K &key, size_t index)
Gets the index-th value for the given key.
Definition IndexedMultimap.hpp:82
void resize(const K &key, size_type newSize, const Value &value=Value())
Resizes the container and ensures that there are exactly newSize items on the given key.
Definition IndexedMultimap.hpp:140
iterator erase(const K &key, size_type index) const
Erases the element at the given index for the given key.
Definition IndexedMultimap.hpp:180
A retain-release type of smart pointer.
Definition SmartPtr.hpp:132
Definition GPUBuffer.hpp:124
Definition GPUBufferObject.hpp:27
Definition GPUComputePipeline.hpp:62
Definition GPUGraphicsPipeline.hpp:790
Definition GPUImage.hpp:331
Definition GPUPipelineLayout.hpp:84
Definition GPUResourceSet.hpp:125
GPUBufferResourceBinding & asBufferBinding()
Gets the binding as a Buffer binding.
Definition GPUResourceSet.hpp:166
GPUSamplerResourceBinding & asSamplerBinding()
Gets the binding as an Sampler binding.
Definition GPUResourceSet.hpp:196
bool isBufferBinding() const noexcept
Determines if the binding is a Buffer binding.
Definition GPUResourceSet.hpp:157
const GPUBufferResourceBinding & asBufferBinding() const
Gets the binding as a Buffer binding.
Definition GPUResourceSet.hpp:160
const GPUSamplerResourceBinding & asSamplerBinding() const
Gets the binding as an Sampler binding.
Definition GPUResourceSet.hpp:190
bool isEmpty() const noexcept
Determines if the binding is empty.
Definition GPUResourceSet.hpp:151
GPUImageResourceBinding & asImageBinding()
Gets the binding as an Image binding.
Definition GPUResourceSet.hpp:181
Variant< std::nullptr_t, GPUBufferResourceBinding, GPUImageResourceBinding, GPUSamplerResourceBinding > super
Definition GPUResourceSet.hpp:126
bool isSamplerBinding() const noexcept
Determines if the binding is an Sampler binding.
Definition GPUResourceSet.hpp:187
friend bool operator!=(const GPUResourceBinding &lhs, const std::nullptr_t rhs) noexcept
Definition GPUResourceSet.hpp:203
friend bool operator==(const GPUResourceBinding &lhs, std::nullptr_t) noexcept
Definition GPUResourceSet.hpp:202
bool isImageBinding() const noexcept
Determines if the binding is an Image binding.
Definition GPUResourceSet.hpp:172
const GPUImageResourceBinding & asImageBinding() const
Gets the binding as an Image binding.
Definition GPUResourceSet.hpp:175
Definition GPUResourceSet.hpp:338
GPUResourceBinding * get(const UInt32 slot, const UInt32 index=0)
Gets a GPUResourceBinding by it's reflection slot and index.
Definition GPUResourceSet.hpp:372
Generator< Pair< Pair< UInt32, UInt32 >, GPUResourceBinding & > > forEach()
Iterates over each of the entries in the GPUResourceSetBindings.
void clear(const K &key)
Clears all values of the given key.
Definition IndexedMultimap.hpp:156
void remove(UInt32 slot)
Removes a GPUResourceBinding for the given binding slot.
Definition GPUResourceSet.hpp:420
GPUResourceBinding & set(UInt32 slot, GPUResourceBinding binding)
Sets the GPUResourceBinding for the given binding slot and index.
Definition GPUResourceSet.hpp:387
void remove(const UInt32 slot, const UInt32 index)
Removes a GPUResourceBinding for the given binding slot and index.
Definition GPUResourceSet.hpp:409
GPUResourceSetConstBindingSlot operator[](UInt32 slot) const
Helper method to have expressive access of the resource bindings.
Definition GPUResourceSet.hpp:438
GPUResourceSetDescriptor createDescriptor() const &
UInt32 add(const UInt32 slot, GPUResourceBinding binding)
Adds a new GPUResourceBinding for the given binding slot.
Definition GPUResourceSet.hpp:400
const GPUResourceBinding * get(const UInt32 slot, const UInt32 index=0) const
Gets a GPUResourceBinding by it's reflection slot and index.
Definition GPUResourceSet.hpp:359
UInt32 size() const
Gets the total number of GPUResourceBinding on the bindings object.
Definition GPUResourceSet.hpp:430
void reserve(size_type newCapacity)
Tries to increase capacity by allocating additional memory.
Definition IndexedMultimap.hpp:120
GPUResourceSetBindingSlot operator[](UInt32 slot)
Helper method to have expressive access of the resource bindings.
Definition GPUResourceSet.hpp:434
GPUResourceBinding & set(const UInt32 slot, const UInt32 index, GPUResourceBinding binding)
Sets the GPUResourceBinding for the given binding slot and index.
Definition GPUResourceSet.hpp:378
void resize(const K &key, size_type newSize, const Value &value=Value())
Resizes the container and ensures that there are exactly newSize items on the given key.
Definition IndexedMultimap.hpp:140
UInt32 size(const UInt32 slot) const
Gets the number of GPUResourceBinding by on the given slot.
Definition GPUResourceSet.hpp:426
Generator< Pair< Pair< UInt32, UInt32 >, const GPUResourceBinding & > > forEach() const
Iterates over each of the entries in the GPUResourceSetBindings.
A RenderAPI object that holds a set of resources that can be bound into shader.
Definition GPUResourceSet.hpp:735
GPUPipelineLayout & pipelineLayout
The owning pipeline layout object this ResourceSet was created from.
Definition GPUResourceSet.hpp:738
GPUResourceSet(GPUPipelineLayout &pipelineLayout, const GPUResourceSetDescriptor &descriptor)
Default initializer.
GPUResourceSet(const GPUResourceSet &)=delete
Deleted copy constructor.
GPUResourceSet & operator=(const GPUResourceSet &)=delete
~GPUResourceSet() override
Destroys the resource set object.
GPUResourceSet(GPUResourceSet &&)=delete
Deleted move constructor.
GPUResourceSet & operator=(GPUResourceSet &&)=delete
Definition GPUSampler.hpp:175
Definition GPUShader.hpp:256
Definition GPUShader.hpp:361
Definition GPUResourceSet.hpp:457
GPUShaderResourceSetBindings(const GPUShaderPtr &shader, const UInt32 setIndex=0)
Constructs a new GPUShaderResourceSetBindings suitable a given GPUShader.
Definition GPUResourceSet.hpp:476
GPUShaderResourceSetBindings(const GPUShader &shader, UInt32 setIndex=0)
Constructs a new GPUShaderResourceSetBindings suitable a given GPUShader.
GPUShaderResourceSetBindings(const GPUGraphicsPipelinePtr &pipeline, const UInt32 setIndex=0)
Constructs a new GPUShaderResourceSetBindings suitable a given GPUGraphicsPipeline.
Definition GPUResourceSet.hpp:493
GPUShaderResourceSetBindings(const GPUGraphicsPipeline &pipeline, UInt32 setIndex=0)
Constructs a new GPUShaderResourceSetBindings suitable a given GPUGraphicsPipeline.
GPUShaderResourceSetBindings(const GPUResourceSetBindings &existingBindings, const GPUShaderProgram &shaderProgram, UInt32 setIndex=0)
Constructs a new GPUShaderResourceSetBindings suitable a given GPUShaderProgram.
UInt32 findSlotIndex(StringView name) const
Finds the binding named name using reflection data.
GPUShaderResourceSetBindings(const GPUResourceSetBindings &existingBindings, const GPUGraphicsPipeline &pipeline, UInt32 setIndex=0)
Constructs a new GPUShaderResourceSetBindings suitable a given GPUGraphicsPipeline.
const GPUResourceBinding * get(const StringView name, const UInt32 index=0) const
Gets a GPUResourceBinding by it's reflection name and index.
Definition GPUResourceSet.hpp:598
void resize(const StringView name, const UInt32 newSize, const GPUResourceBinding &defaultValue={})
Resizes the bindings a for the given binding slot name.
Definition GPUResourceSet.hpp:680
GPUShaderResourceSetBindings(const GPUResourceSetBindings &existingBindings, const GPUComputePipeline &pipeline, UInt32 setIndex=0)
Constructs a new GPUShaderResourceSetBindings suitable a given GPUComputePipeline.
GPUShaderResourceSetBindings(const GPUComputePipelinePtr &pipeline, const UInt32 setIndex=0)
Constructs a new GPUShaderResourceSetBindings suitable a given GPUComputePipeline.
Definition GPUResourceSet.hpp:502
GPUShaderResourceSetBindings(const GPUPipelineLayout &pipeline, UInt32 setIndex=0)
Constructs a new GPUShaderResourceSetBindings suitable a given GPUGraphicsPipeline.
UInt32 size(const StringView name) const
Gets the number of GPUResourceBinding by on the given slot.
Definition GPUResourceSet.hpp:671
GPUShaderResourceSetBindings(const GPUResourceSetBindings &existingBindings, const GPUComputePipelinePtr &pipeline, const UInt32 setIndex=0)
Constructs a new GPUShaderResourceSetBindings suitable a given GPUComputePipeline.
Definition GPUResourceSet.hpp:567
GPUShaderResourceSetBindings(const GPUShaderProgram &shaderProgram, UInt32 setIndex=0)
Constructs a new GPUShaderResourceSetBindings suitable a given GPUShaderProgram.
GPUShaderResourceSetBindings(const GPUPipelineLayoutPtr &pipelineLayout, const UInt32 setIndex=0)
Constructs a new GPUShaderResourceSetBindings suitable a given GPUGraphicsPipeline.
Definition GPUResourceSet.hpp:510
GPUShaderResourceSetBindings(const GPUResourceSetBindings &existingBindings, const GPUGraphicsPipelinePtr &pipeline, const UInt32 setIndex=0)
Constructs a new GPUShaderResourceSetBindings suitable a given GPUGraphicsPipeline.
Definition GPUResourceSet.hpp:553
GPUShaderResourceSetBindings(const GPUComputePipeline &pipeline, UInt32 setIndex=0)
Constructs a new GPUShaderResourceSetBindings suitable a given GPUComputePipeline.
GPUShaderResourceSetBindings(const GPUResourceSetBindings &existingBindings, const GPUShaderPtr &shader, const UInt32 setIndex=0)
Constructs a new GPUShaderResourceSetBindings suitable a given GPUShader.
Definition GPUResourceSet.hpp:525
UInt32 add(const StringView name, GPUResourceBinding binding)
Adds a new GPUResourceBinding for the given binding name.
Definition GPUResourceSet.hpp:643
bool has(UInt32 slot) const
Determines if a binding with the given slot exists on the reflection metadata.
void set(const StringView name, const UInt32 index, GPUResourceBinding binding)
Sets the GPUResourceBinding for the given binding name and index.
Definition GPUResourceSet.hpp:618
bool has(const StringView name) const
Determines if a binding with the given name exists on the reflection metadata.
Definition GPUResourceSet.hpp:584
GPUShaderResourceSetBindings(const GPUResourceSetBindings &existingBindings, const GPUShader &shader, UInt32 setIndex=0)
Constructs a new GPUShaderResourceSetBindings suitable a given GPUShader.
GPUShaderResourceSetBindings(const GPUResourceSetBindings &existingBindings, const GPUShaderProgramPtr &shaderProgram, const UInt32 setIndex=0)
Constructs a new GPUShaderResourceSetBindings suitable a given GPUShaderProgram.
Definition GPUResourceSet.hpp:539
void clear(const StringView name)
Clears all the bindings a for the given binding slot name.
Definition GPUResourceSet.hpp:688
void set(const StringView name, GPUResourceBinding binding)
Sets the GPUResourceBinding for the given binding name and index.
Definition GPUResourceSet.hpp:630
GPUResourceBinding * get(const StringView name, const UInt32 index=0)
Gets a GPUResourceBinding by it's reflection name and index.
Definition GPUResourceSet.hpp:609
auto operator[](const StringView name)
Helper method to have expressive access of the resource bindings.
Definition GPUResourceSet.hpp:695
void remove(const StringView name, const UInt32 index)
Removes a GPUResourceBinding for the given binding slot and index.
Definition GPUResourceSet.hpp:652
const GPUShaderReflectionDescriptor & mReflectionDescriptor
A descriptor that describes the reflection data from the shader.
Definition GPUResourceSet.hpp:463
void remove(const StringView name)
Removes a GPUResourceBinding for the given binding slot.
Definition GPUResourceSet.hpp:662
auto operator[](const StringView name) const
Helper method to have expressive access of the resource bindings.
Definition GPUResourceSet.hpp:702
GPUShaderResourceSetBindings(const GPUShaderProgramPtr &shaderProgram, const UInt32 setIndex=0)
Constructs a new GPUShaderResourceSetBindings suitable a given GPUShaderProgram.
Definition GPUResourceSet.hpp:484
A generator represents a coroutine type that produces a sequence of values of type T,...
Definition Generator.hpp:50
Definition Common.hpp:62
A class that offers high-level access to a GPUResourceSetBindings slot.
Definition GPUResourceSet.hpp:224
UInt32 slot
The slot the TGPUResourceSetBindingSlot object is representing.
Definition GPUResourceSet.hpp:234
void remove(UInt32 index)
Removes a GPUResourceBinding for the given index.
Definition GPUResourceSet.hpp:316
GPUResourceBinding & set(GPUResourceBinding binding)
Sets the GPUResourceBinding for the given index.
Definition GPUResourceSet.hpp:270
std::conditional_t< Const, const GPUResourceSetBindings, GPUResourceSetBindings > GPUResourceSetBindingsType
Definition GPUResourceSet.hpp:225
const GPUResourceBinding * get(UInt32 index=0) const
Gets a GPUResourceBinding at the given index.
Definition GPUResourceSet.hpp:249
TGPUResourceSetBindingSlot & operator=(GPUResourceBinding &&binding)
Sets the GPUResourceBinding for the given index.
Definition GPUResourceSet.hpp:289
const GPUResourceBinding & operator[](const UInt32 index) const
Gets a GPUResourceBinding at the given index.
Definition GPUResourceSet.hpp:273
GPUResourceBinding & operator[](const UInt32 index)
Gets a GPUResourceBinding at the given index.
Definition GPUResourceSet.hpp:280
TGPUResourceSetBindingSlot(GPUResourceSetBindingsType &bindings, const UInt32 slot)
Creates a new TGPUResourceSetBindingSlot from an existing.
Definition GPUResourceSet.hpp:241
GPUResourceBinding * get(UInt32 index=0)
Gets a GPUResourceBinding at the given index.
Definition GPUResourceSet.hpp:256
GPUResourceSetBindingsType & bindings
The bindings object that this TGPUResourceSetBindingSlot was created from.
Definition GPUResourceSet.hpp:231
UInt32 add(GPUResourceBinding binding)
Adds a new GPUResourceBinding.
Definition GPUResourceSet.hpp:302
GPUResourceBinding & set(UInt32 index, GPUResourceBinding binding)
Sets the GPUResourceBinding for the given index.
Definition GPUResourceSet.hpp:262
UInt32 operator+=(GPUResourceBinding binding)
Adds a new GPUResourceBinding.
Definition GPUResourceSet.hpp:308
void remove()
Removes a GPUResourceBinding for the slot.
Definition GPUResourceSet.hpp:321
UInt32 size() const
Gets the number of GPUResourceBinding bound on the slot.
Definition GPUResourceSet.hpp:325
Definition Variant.hpp:15
Definition Application.hpp:19
GPUResourceBindingType
An enumeration of supported resource binding types.
Definition GPUResourceSet.hpp:37
@ Undefined
We don't care about the previous content of the respective render target attachment.
std::initializer_list< T > InitializerList
An object of type InitializerList<T> is a lightweight proxy object that provides access to an array o...
Definition InitializerList.hpp:40
std::pair< First, Second > Pair
Pair is a struct template that provides a way to store two heterogeneous objects as a single unit.
Definition Pair.hpp:18
auto move(Vector3 position)
Moves a entity to the given position.
Definition Helpers.hpp:22
@ StorageBuffer
Storage buffer resource.
@ Sampler
Sampler state resource.
@ CombinedSampler
Combined sampler with a associated image.
@ UniformBuffer
Uniform buffer (or constant buffer) resource.
@ DynamicUniformBuffer
Dynamic uniform buffer (or constant buffer) resource.
@ StorageImage
Storage image resource type.
std::uint32_t UInt32
Definition DataTypes.hpp:23
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Definition Span.hpp:668
Definition GPUResourceSet.hpp:65
static constexpr void reflect(Processor &&RTTI)
Executes the given processor for every field of the struct.
Definition GPUResourceSet.hpp:76
GPUBufferViewDescriptor bufferView
A descriptor that describes the region of the buffer to be bound.
Definition GPUResourceSet.hpp:71
GPUBufferPtr buffer
A pointer to the resource resource to be bound.
Definition GPUResourceSet.hpp:67
Definition GPUBuffer.hpp:230
Definition GPUResourceSet.hpp:82
GPUImagePtr image
A pointer to the resource resource to be bound.
Definition GPUResourceSet.hpp:84
GPUImageViewDescriptor imageView
A descriptor that describes the region of the image to be bound.
Definition GPUResourceSet.hpp:93
static constexpr void reflect(Processor &&RTTI)
Executes the given processor for every field of the struct.
Definition GPUResourceSet.hpp:104
GPUSamplerPtr sampler
An optional sampler to be used when sampling from the image on the shader.
Definition GPUResourceSet.hpp:89
Image view descriptor structure.
Definition GPUImage.hpp:482
GPUImageType type
Hardware image type. By default ImageType::Image2D.
Definition GPUImage.hpp:485
Definition GPUResourceSet.hpp:716
GPUResourceSetBindings bindings
The resource set bindings.
Definition GPUResourceSet.hpp:718
String name
A user-facing name for the ResourceSet.
Definition GPUResourceSet.hpp:722
static constexpr void reflect(Processor &&RTTI)
Executes the given processor for every field of the struct.
Definition GPUResourceSet.hpp:727
Definition GPUResourceSet.hpp:111
static constexpr void reflect(Processor &&RTTI)
Executes the given processor for every field of the struct.
Definition GPUResourceSet.hpp:120
GPUSamplerPtr sampler
A sampler to be used when sampling from the sampler on the shader.
Definition GPUResourceSet.hpp:115
Shader reflection descriptor structure.
Definition GPUShader.hpp:108