LiteFX 0.4.1.2025
Computer Graphics Engine
Loading...
Searching...
No Matches
rendering.hpp
1#pragma once
2
3#include <litefx/rendering_api.hpp>
4#include <litefx/rendering_formatters.hpp>
5
6namespace LiteFX::Rendering {
7 using namespace LiteFX;
8 using namespace LiteFX::Math;
9
14 template <typename TBuffer, typename TImage> requires
15 std::derived_from<TBuffer, IBuffer> &&
16 std::derived_from<TImage, IImage>
17 class Barrier : public IBarrier {
18 public:
20
21 using buffer_type = TBuffer;
22 using image_type = TImage;
23
24 protected:
25 Barrier() noexcept = default;
26 Barrier(const Barrier&) = default;
27 Barrier(Barrier&&) noexcept = default;
28 Barrier& operator=(const Barrier&) = default;
29 Barrier& operator=(Barrier&&) noexcept = default;
30
31 public:
32 constexpr ~Barrier() noexcept override = default;
33
34 public:
36 constexpr virtual void transition(const buffer_type& buffer, ResourceAccess accessBefore, ResourceAccess accessAfter) = 0;
37
39 constexpr virtual void transition(const buffer_type& buffer, UInt32 element, ResourceAccess accessBefore, ResourceAccess accessAfter) = 0;
40
42 constexpr virtual void transition(const image_type& image, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout layout) = 0;
43
45 constexpr virtual void transition(const image_type& image, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout fromLayout, ImageLayout toLayout) = 0;
46
48 constexpr virtual void transition(const image_type& image, UInt32 level, UInt32 levels, UInt32 layer, UInt32 layers, UInt32 plane, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout layout) = 0;
49
51 constexpr virtual void transition(const image_type& image, UInt32 level, UInt32 levels, UInt32 layer, UInt32 layers, UInt32 plane, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout fromLayout, ImageLayout toLayout) = 0;
52
53 private:
54 constexpr void doTransition(const IBuffer& buffer, ResourceAccess accessBefore, ResourceAccess accessAfter) override {
55 this->transition(dynamic_cast<const buffer_type&>(buffer), accessBefore, accessAfter);
56 }
57
58 constexpr void doTransition(const IBuffer& buffer, UInt32 element, ResourceAccess accessBefore, ResourceAccess accessAfter) override {
59 this->transition(dynamic_cast<const buffer_type&>(buffer), element, accessBefore, accessAfter);
60 }
61
62 constexpr void doTransition(const IImage& image, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout layout) override {
63 this->transition(dynamic_cast<const image_type&>(image), accessBefore, accessAfter, layout);
64 }
65
66 constexpr void doTransition(const IImage& image, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout fromLayout, ImageLayout toLayout) override {
67 this->transition(dynamic_cast<const image_type&>(image), accessBefore, accessAfter, fromLayout, toLayout);
68 }
69
70 constexpr void doTransition(const IImage& image, UInt32 level, UInt32 levels, UInt32 layer, UInt32 layers, UInt32 plane, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout layout) override {
71 this->transition(dynamic_cast<const image_type&>(image), level, levels, layer, layers, plane, accessBefore, accessAfter, layout);
72 }
73
74 constexpr void doTransition(const IImage& image, UInt32 level, UInt32 levels, UInt32 layer, UInt32 layers, UInt32 plane, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout fromLayout, ImageLayout toLayout) override {
75 this->transition(dynamic_cast<const image_type&>(image), level, levels, layer, layers, plane, accessBefore, accessAfter, fromLayout, toLayout);
76 }
77 };
78
145 template <typename TBuffer, typename TImage, typename TSampler, typename TAccelerationStructure> requires
146 std::derived_from<TBuffer, IBuffer> &&
147 std::derived_from<TSampler, ISampler> &&
148 std::derived_from<TImage, IImage> &&
149 std::derived_from<TAccelerationStructure, IAccelerationStructure>
151 public:
153
154 using buffer_type = TBuffer;
155 using sampler_type = TSampler;
156 using image_type = TImage;
157 using acceleration_structure_type = TAccelerationStructure;
158
159 protected:
160 DescriptorSet() noexcept = default;
161 DescriptorSet(const DescriptorSet&) = default;
162 DescriptorSet(DescriptorSet&&) noexcept = default;
163 DescriptorSet& operator=(const DescriptorSet&) = default;
164 DescriptorSet& operator=(DescriptorSet&&) noexcept = default;
165
166 public:
167 ~DescriptorSet() noexcept override = default;
168
169 public:
171 virtual void update(UInt32 binding, const buffer_type& buffer, UInt32 bufferElement = 0, UInt32 elements = 0, UInt32 firstDescriptor = 0) const = 0;
172
174 virtual void update(UInt32 binding, const image_type& texture, UInt32 descriptor = 0, UInt32 firstLevel = 0, UInt32 levels = 0, UInt32 firstLayer = 0, UInt32 layers = 0) const = 0;
175
177 virtual void update(UInt32 binding, const sampler_type& sampler, UInt32 descriptor = 0) const = 0;
178
180 virtual void update(UInt32 binding, const acceleration_structure_type& accelerationStructure, UInt32 descriptor = 0) const = 0;
181
182 private:
183 void doUpdate(UInt32 binding, const IBuffer& buffer, UInt32 bufferElement, UInt32 elements, UInt32 firstDescriptor) const override {
184 this->update(binding, dynamic_cast<const buffer_type&>(buffer), bufferElement, elements, firstDescriptor);
185 }
186
187 void doUpdate(UInt32 binding, const IImage& texture, UInt32 descriptor, UInt32 firstLevel, UInt32 levels, UInt32 firstLayer, UInt32 layers) const override {
188 this->update(binding, dynamic_cast<const image_type&>(texture), descriptor, firstLevel, levels, firstLayer, layers);
189 }
190
191 void doUpdate(UInt32 binding, const ISampler& sampler, UInt32 descriptor) const override {
192 this->update(binding, dynamic_cast<const sampler_type&>(sampler), descriptor);
193 }
194
195 void doUpdate(UInt32 binding, const IAccelerationStructure& accelerationStructure, UInt32 descriptor) const override {
196 this->update(binding, dynamic_cast<const acceleration_structure_type&>(accelerationStructure), descriptor);
197 }
198 };
199
212 template <typename TDescriptorLayout, typename TDescriptorSet> requires
213 meta::implements<TDescriptorLayout, IDescriptorLayout> &&
214 meta::implements<TDescriptorSet, DescriptorSet<typename TDescriptorSet::buffer_type, typename TDescriptorSet::image_type, typename TDescriptorSet::sampler_type, typename TDescriptorSet::acceleration_structure_type>>
216 public:
218
219 using descriptor_layout_type = TDescriptorLayout;
220 using descriptor_set_type = TDescriptorSet;
221
222 protected:
223 DescriptorSetLayout() noexcept = default;
226 DescriptorSetLayout& operator=(const DescriptorSetLayout&) = default;
227 DescriptorSetLayout& operator=(DescriptorSetLayout&&) noexcept = default;
228
229 public:
230 ~DescriptorSetLayout() noexcept override = default;
231
232 public:
234 virtual const Array<descriptor_layout_type>& descriptors() const noexcept = 0;
235
237 const descriptor_layout_type& descriptor(UInt32 binding) const override = 0;
238
240 virtual inline UniquePtr<descriptor_set_type> allocate(std::initializer_list<DescriptorBinding> bindings = { }) const {
241 return this->allocate(0, bindings);
242 }
243
246 return this->allocate(0, bindings);
247 }
248
251 return this->allocate(0, std::move(bindings));
252 }
253
255 virtual UniquePtr<descriptor_set_type> allocate(UInt32 descriptors, std::initializer_list<DescriptorBinding> bindings) const = 0;
256
259
262
264 virtual inline Generator<UniquePtr<descriptor_set_type>> allocate(UInt32 descriptorSets, std::initializer_list<std::initializer_list<DescriptorBinding>> bindings = { }) const {
265 return this->allocate(descriptorSets, 0, bindings);
266 }
267
268#ifdef __cpp_lib_mdspan
270 virtual inline Generator<UniquePtr<descriptor_set_type>> allocate(UInt32 descriptorSets, std::mdspan<DescriptorBinding, std::dextents<size_t, 2>> bindings) const {
271 return this->allocate(descriptorSets, 0, bindings);
272 }
273#endif
274
276 virtual inline Generator<UniquePtr<descriptor_set_type>> allocate(UInt32 descriptorSets, std::function<Generator<DescriptorBinding>(UInt32)> bindings) const {
277 return this->allocate(descriptorSets, 0, std::move(bindings));
278 }
279
281 virtual Generator<UniquePtr<descriptor_set_type>> allocate(UInt32 descriptorSets, UInt32 descriptors, std::initializer_list<std::initializer_list<DescriptorBinding>> bindings = { }) const = 0;
282
283#ifdef __cpp_lib_mdspan
285 virtual Generator<UniquePtr<descriptor_set_type>> allocate(UInt32 descriptorSets, UInt32 descriptors, std::mdspan<DescriptorBinding, std::dextents<size_t, 2>> bindings) const = 0;
286#endif
287
289 virtual Generator<UniquePtr<descriptor_set_type>> allocate(UInt32 descriptorSets, UInt32 descriptors, std::function<Generator<DescriptorBinding>(UInt32)> bindingFactory) const = 0;
290
292 virtual void free(const descriptor_set_type& descriptorSet) const = 0;
293
294 private:
295 inline Enumerable<const IDescriptorLayout&> getDescriptors() const noexcept override {
296 return this->descriptors();
297 }
298
299 inline UniquePtr<IDescriptorSet> getDescriptorSet(UInt32 descriptors, std::initializer_list<DescriptorBinding> bindings) const override {
300 return this->allocate(descriptors, bindings);
301 }
302
303 inline UniquePtr<IDescriptorSet> getDescriptorSet(UInt32 descriptors, Span<DescriptorBinding> bindings) const override {
304 return this->allocate(descriptors, bindings);
305 }
306
307 inline UniquePtr<IDescriptorSet> getDescriptorSet(UInt32 descriptors, Generator<DescriptorBinding> bindings) const override {
308 return this->allocate(descriptors, std::move(bindings));
309 }
310
311 inline Generator<UniquePtr<IDescriptorSet>> getDescriptorSets(UInt32 descriptorSets, UInt32 descriptors, std::initializer_list<std::initializer_list<DescriptorBinding>> bindings) const override {
312 co_yield std::ranges::elements_of(this->allocate(descriptorSets, descriptors, bindings) | std::views::transform([](auto set) -> UniquePtr<IDescriptorSet> { return set; }));
313 }
314
315#ifdef __cpp_lib_mdspan
316 inline Generator<UniquePtr<IDescriptorSet>> getDescriptorSets(UInt32 descriptorSets, UInt32 descriptors, std::mdspan<DescriptorBinding, std::dextents<size_t, 2>> bindings) const override {
317 co_yield std::ranges::elements_of(this->allocate(descriptorSets, descriptors, bindings) | std::views::transform([](auto set) -> UniquePtr<IDescriptorSet> { return set; }));
318 }
319#endif
320
321 inline Generator<UniquePtr<IDescriptorSet>> getDescriptorSets(UInt32 descriptorSets, UInt32 descriptors, std::function<Generator<DescriptorBinding>(UInt32)> bindingFactory) const override {
322 co_yield std::ranges::elements_of(this->allocate(descriptorSets, descriptors, std::move(bindingFactory)) | std::views::transform([](auto set) -> UniquePtr<IDescriptorSet> { return set; }));
323 }
324
325 inline void releaseDescriptorSet(const IDescriptorSet& descriptorSet) const override {
326 this->free(dynamic_cast<const descriptor_set_type&>(descriptorSet));
327 }
328 };
329
353 template <typename TPushConstantsRange> requires
354 meta::implements<TPushConstantsRange, IPushConstantsRange>
356 public:
357 using push_constants_range_type = TPushConstantsRange;
358
359 protected:
360 PushConstantsLayout() noexcept = default;
363 PushConstantsLayout& operator=(const PushConstantsLayout&) = default;
364 PushConstantsLayout& operator=(PushConstantsLayout&&) noexcept = default;
365
366 public:
367 ~PushConstantsLayout() noexcept override = default;
368
369 public:
371 virtual const Array<UniquePtr<push_constants_range_type>>& ranges() const = 0;
372
373 private:
374 inline Enumerable<const IPushConstantsRange&> getRanges() const override {
375 return this->ranges() | std::views::transform([](auto& ptr) -> const IPushConstantsRange& { return *ptr; });
376 }
377 };
378
384 template <typename TShaderModule> requires
387 public:
388 using shader_module_type = TShaderModule;
389
390 protected:
391 ShaderProgram() noexcept = default;
392 ShaderProgram(const ShaderProgram&) = default;
393 ShaderProgram(ShaderProgram&&) noexcept = default;
394 ShaderProgram& operator=(const ShaderProgram&) = default;
395 ShaderProgram& operator=(ShaderProgram&&) noexcept = default;
396
397 public:
398 ~ShaderProgram() noexcept override = default;
399
400 public:
402 virtual const Array<UniquePtr<const shader_module_type>>& modules() const noexcept = 0;
403
404 private:
405 inline Enumerable<const IShaderModule&> getModules() const override {
406 return this->modules() | std::views::transform([](const auto& m) -> const IShaderModule& { return *m; });
407 }
408 };
409
415 template <typename TDescriptorSetLayout, typename TPushConstantsLayout> requires
419 public:
420 using descriptor_set_layout_type = TDescriptorSetLayout;
421 using push_constants_layout_type = TPushConstantsLayout;
422
423 protected:
424 PipelineLayout() noexcept = default;
426 PipelineLayout(PipelineLayout&&) noexcept = default;
427 PipelineLayout& operator=(const PipelineLayout&) = default;
428 PipelineLayout& operator=(PipelineLayout&&) noexcept = default;
429
430 public:
431 ~PipelineLayout() noexcept override = default;
432
433 public:
435 const descriptor_set_layout_type& descriptorSet(UInt32 space) const override = 0;
436
438 virtual const Array<SharedPtr<const descriptor_set_layout_type>>& descriptorSets() const = 0;
439
441 const push_constants_layout_type* pushConstants() const noexcept override = 0;
442
443 private:
444 inline Enumerable<SharedPtr<const IDescriptorSetLayout>> getDescriptorSets() const override {
445 return this->descriptorSets();
446 }
447 };
448
453 template <typename TVertexBufferLayout> requires
455 class VertexBuffer : public virtual IVertexBuffer {
456 public:
457 using vertex_buffer_layout_type = TVertexBufferLayout;
458 protected:
459 VertexBuffer() noexcept = default;
460 VertexBuffer(const VertexBuffer&) = default;
461 VertexBuffer(VertexBuffer&&) noexcept = default;
462 VertexBuffer& operator=(const VertexBuffer&) = default;
463 VertexBuffer& operator=(VertexBuffer&&) noexcept = default;
464
465 public:
466 ~VertexBuffer() noexcept override = default;
467
468 public:
470 const vertex_buffer_layout_type& layout() const noexcept override = 0;
471 };
472
477 template <typename TIndexBufferLayout> requires
478 meta::implements<TIndexBufferLayout, IIndexBufferLayout>
479 class IndexBuffer : public virtual IIndexBuffer {
480 public:
481 using index_buffer_layout_type = TIndexBufferLayout;
482
483 protected:
484 IndexBuffer() noexcept = default;
485 IndexBuffer(const IndexBuffer&) = default;
486 IndexBuffer(IndexBuffer&&) noexcept = default;
487 IndexBuffer& operator=(const IndexBuffer&) = default;
488 IndexBuffer& operator=(IndexBuffer&&) noexcept = default;
489
490 public:
491 ~IndexBuffer() noexcept override = default;
492
493 public:
495 const index_buffer_layout_type& layout() const noexcept override = 0;
496 };
497
503 template <typename TVertexBufferLayout, typename TIndexBufferLayout> requires
504 meta::implements<TVertexBufferLayout, IVertexBufferLayout> &&
505 meta::implements<TIndexBufferLayout, IIndexBufferLayout>
507 public:
508 using vertex_buffer_layout_type = TVertexBufferLayout;
509 using index_buffer_layout_type = TIndexBufferLayout;
510
511 protected:
512 InputAssembler() noexcept = default;
514 InputAssembler(InputAssembler&&) noexcept = default;
515 InputAssembler& operator=(const InputAssembler&) = default;
516 InputAssembler& operator=(InputAssembler&&) noexcept = default;
517
518 public:
519 ~InputAssembler() noexcept override = default;
520
521 public:
523 virtual Enumerable<const vertex_buffer_layout_type&> vertexBufferLayouts() const = 0;
524
526 const vertex_buffer_layout_type& vertexBufferLayout(UInt32 binding) const override = 0;
527
529 const index_buffer_layout_type* indexBufferLayout() const noexcept override = 0;
530
531 private:
532 inline Enumerable<const IVertexBufferLayout&> getVertexBufferLayouts() const override {
533 return this->vertexBufferLayouts();
534 }
535 };
536
544 template <typename TPipelineLayout, typename TShaderProgram> requires
547 class Pipeline : public virtual IPipeline, public virtual StateResource {
548 public:
549 using shader_program_type = TShaderProgram;
550 using pipeline_layout_type = TPipelineLayout;
551
552 protected:
553 Pipeline() noexcept = default;
554 Pipeline(const Pipeline&) = default;
555 Pipeline(Pipeline&&) noexcept = default;
556 Pipeline& operator=(const Pipeline&) = default;
557 Pipeline& operator=(Pipeline&&) noexcept = default;
558
559 public:
560 ~Pipeline() noexcept override = default;
561
562 public:
564 virtual SharedPtr<const shader_program_type> program() const noexcept = 0;
565
567 virtual SharedPtr<const pipeline_layout_type> layout() const noexcept = 0;
568
569 private:
570 inline SharedPtr<const IShaderProgram> getProgram() const noexcept override {
571 return std::static_pointer_cast<const IShaderProgram>(this->program());
572 }
573
574 inline SharedPtr<const IPipelineLayout> getLayout() const noexcept override {
575 return std::static_pointer_cast<const IPipelineLayout>(this->layout());
576 }
577 };
578
591 template <typename TCommandBuffer, typename TBuffer, typename TVertexBuffer, typename TIndexBuffer, typename TImage, typename TBarrier, typename TPipeline, typename TBLAS, typename TTLAS> requires
592 meta::implements<TBarrier, Barrier<TBuffer, TImage>> &&
593 //std::derived_from<TCommandBuffer, ICommandBuffer> &&
594 std::derived_from<TPipeline, Pipeline<typename TPipeline::pipeline_layout_type, typename TPipeline::shader_program_type>> &&
595 std::derived_from<TBLAS, IBottomLevelAccelerationStructure> &&
596 std::derived_from<TTLAS, ITopLevelAccelerationStructure>
598 public:
602
616
618
619 public:
620 using command_buffer_type = TCommandBuffer;
621 using buffer_type = TBuffer;
622 using vertex_buffer_type = TVertexBuffer;
623 using index_buffer_type = TIndexBuffer;
624 using image_type = TImage;
625 using barrier_type = TBarrier;
626 using pipeline_type = TPipeline;
627 using pipeline_layout_type = pipeline_type::pipeline_layout_type;
628 using descriptor_set_layout_type = pipeline_layout_type::descriptor_set_layout_type;
629 using push_constants_layout_type = pipeline_layout_type::push_constants_layout_type;
630 using descriptor_set_type = descriptor_set_layout_type::descriptor_set_type;
633
634 private:
635 CommandBuffer() noexcept = default;
636 CommandBuffer(CommandBuffer&&) noexcept = default;
637 CommandBuffer(const CommandBuffer&) = default;
638 CommandBuffer& operator=(const CommandBuffer&) = default;
639 CommandBuffer& operator=(CommandBuffer&&) noexcept = default;
640
641 public:
642 ~CommandBuffer() noexcept override = default;
643
644 public:
646 virtual UniquePtr<barrier_type> makeBarrier(PipelineStage syncBefore, PipelineStage syncAfter) const = 0;
647
649 virtual void barrier(const barrier_type& barrier) const noexcept = 0;
650
652 virtual void transfer(const buffer_type& source, const buffer_type& target, UInt32 sourceElement = 0, UInt32 targetElement = 0, UInt32 elements = 1) const = 0;
653
655 virtual void transfer(const void* const data, size_t size, const buffer_type& target, UInt32 targetElement = 0, UInt32 elements = 1) const = 0;
656
658 virtual void transfer(Span<const void* const> data, size_t elementSize, const buffer_type& target, UInt32 firstElement = 0) const = 0;
659
661 virtual void transfer(const buffer_type& source, const image_type& target, UInt32 sourceElement = 0, UInt32 firstSubresource = 0, UInt32 elements = 1) const = 0;
662
664 virtual void transfer(const void* const data, size_t size, const image_type& target, UInt32 subresource = 0) const = 0;
665
667 virtual void transfer(Span<const void* const> data, size_t elementSize, const image_type& target, UInt32 firstSubresource = 0, UInt32 subresources = 1) const = 0;
668
670 virtual void transfer(const image_type& source, const image_type& target, UInt32 sourceSubresource = 0, UInt32 targetSubresource = 0, UInt32 subresources = 1) const = 0;
671
673 virtual void transfer(const image_type& source, const buffer_type& target, UInt32 firstSubresource = 0, UInt32 targetElement = 0, UInt32 subresources = 1) const = 0;
674
676 virtual void transfer(const SharedPtr<const buffer_type>& source, const buffer_type& target, UInt32 sourceElement = 0, UInt32 targetElement = 0, UInt32 elements = 1) const = 0;
677
679 virtual void transfer(const SharedPtr<const buffer_type>& source, const image_type& target, UInt32 sourceElement = 0, UInt32 firstSubresource = 0, UInt32 elements = 1) const = 0;
680
682 virtual void transfer(const SharedPtr<const image_type>& source, const image_type& target, UInt32 sourceSubresource = 0, UInt32 targetSubresource = 0, UInt32 subresources = 1) const = 0;
683
685 virtual void transfer(const SharedPtr<const image_type>& source, const buffer_type& target, UInt32 firstSubresource = 0, UInt32 targetElement = 0, UInt32 subresources = 1) const = 0;
686
688 virtual void use(const pipeline_type& pipeline) const noexcept = 0;
689
691 virtual void bind(const descriptor_set_type& descriptorSet) const = 0;
692
694 virtual void bind(Span<const descriptor_set_type*> descriptorSets) const = 0;
695
697 virtual void bind(const descriptor_set_type& descriptorSet, const pipeline_type& pipeline) const = 0;
698
700 virtual void bind(Span<const descriptor_set_type*> descriptorSets, const pipeline_type& pipeline) const = 0;
701
703 virtual void bind(const vertex_buffer_type& buffer) const noexcept = 0;
704
706 virtual void bind(const index_buffer_type& buffer) const noexcept = 0;
707
709 virtual void pushConstants(const push_constants_layout_type& layout, const void* const memory) const = 0;
710
712 virtual void dispatchIndirect(const buffer_type& batchBuffer, UInt32 batchCount, UInt64 offset = 0) const noexcept = 0;
713
715 virtual void dispatchMeshIndirect(const buffer_type& batchBuffer, UInt32 batchCount, UInt64 offset = 0) const noexcept = 0;
716
718 virtual void dispatchMeshIndirect(const buffer_type& batchBuffer, const buffer_type& countBuffer, UInt64 offset = 0, UInt64 countOffset = 0, UInt32 maxBatches = std::numeric_limits<UInt32>::max()) const noexcept = 0;
719
721 virtual void drawIndirect(const buffer_type& batchBuffer, UInt32 batchCount, UInt64 offset = 0) const noexcept = 0;
722
724 virtual void drawIndirect(const buffer_type& batchBuffer, const buffer_type& countBuffer, UInt64 offset = 0, UInt64 countOffset = 0, UInt32 maxBatches = std::numeric_limits<UInt32>::max()) const noexcept = 0;
725
727 virtual void drawIndexedIndirect(const buffer_type& batchBuffer, UInt32 batchCount, UInt64 offset = 0) const noexcept = 0;
728
730 virtual void drawIndexedIndirect(const buffer_type& batchBuffer, const buffer_type& countBuffer, UInt64 offset = 0, UInt64 countOffset = 0, UInt32 maxBatches = std::numeric_limits<UInt32>::max()) const noexcept = 0;
731
733 virtual inline void draw(const vertex_buffer_type& vertexBuffer, UInt32 instances = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0) const {
734 this->bind(vertexBuffer);
735 this->draw(vertexBuffer.elements(), instances, firstVertex, firstInstance);
736 }
737
739 virtual inline void drawIndexed(const index_buffer_type& indexBuffer, UInt32 instances = 1, UInt32 firstIndex = 0, Int32 vertexOffset = 0, UInt32 firstInstance = 0) const {
740 this->bind(indexBuffer);
741 this->drawIndexed(indexBuffer.elements(), instances, firstIndex, vertexOffset, firstInstance);
742 }
743
745 virtual inline void drawIndexed(const vertex_buffer_type& vertexBuffer, const index_buffer_type& indexBuffer, UInt32 instances = 1, UInt32 firstIndex = 0, Int32 vertexOffset = 0, UInt32 firstInstance = 0) const {
746 this->bind(vertexBuffer);
747 this->bind(indexBuffer);
748 this->drawIndexed(indexBuffer.elements(), instances, firstIndex, vertexOffset, firstInstance);
749 }
750
752 virtual void execute(const SharedPtr<const command_buffer_type>& commandBuffer) const = 0;
753
755 virtual void execute(Enumerable<SharedPtr<const command_buffer_type>> commandBuffers) const = 0;
756
758 virtual void buildAccelerationStructure(bottom_level_acceleration_structure_type& blas, const SharedPtr<const buffer_type>& scratchBuffer, const buffer_type& buffer, UInt64 offset = 0) const = 0;
759
761 virtual void buildAccelerationStructure(top_level_acceleration_structure_type& tlas, const SharedPtr<const buffer_type>& scratchBuffer, const buffer_type& buffer, UInt64 offset = 0) const = 0;
762
764 virtual void updateAccelerationStructure(bottom_level_acceleration_structure_type& blas, const SharedPtr<const buffer_type>& scratchBuffer, const buffer_type& buffer, UInt64 offset = 0) const = 0;
765
767 virtual void updateAccelerationStructure(top_level_acceleration_structure_type& tlas, const SharedPtr<const buffer_type>& scratchBuffer, const buffer_type& buffer, UInt64 offset = 0) const = 0;
768
770 virtual void copyAccelerationStructure(const bottom_level_acceleration_structure_type& from, const bottom_level_acceleration_structure_type& to, bool compress = false) const noexcept = 0;
771
773 virtual void copyAccelerationStructure(const top_level_acceleration_structure_type& from, const top_level_acceleration_structure_type& to, bool compress = false) const noexcept = 0;
774
776 virtual void traceRays(UInt32 width, UInt32 height, UInt32 depth, const ShaderBindingTableOffsets& offsets, const buffer_type& rayGenerationShaderBindingTable, const buffer_type* missShaderBindingTable, const buffer_type* hitShaderBindingTable, const buffer_type* callableShaderBindingTable) const noexcept = 0;
777
779 inline void traceRays(const Vector3u& dimensions, const ShaderBindingTableOffsets& offsets, const buffer_type& rayGenerationShaderBindingTable, const buffer_type* missShaderBindingTable, const buffer_type* hitShaderBindingTable, const buffer_type* callableShaderBindingTable) const noexcept {
780 this->traceRays(dimensions.x(), dimensions.y(), dimensions.z(), offsets, rayGenerationShaderBindingTable, missShaderBindingTable, hitShaderBindingTable, callableShaderBindingTable);
781 }
782
783 private:
784 inline UniquePtr<IBarrier> getBarrier(PipelineStage syncBefore, PipelineStage syncAfter) const override {
785 return this->makeBarrier(syncBefore, syncAfter);
786 }
787
788 inline void cmdBarrier(const IBarrier& barrier) const noexcept override {
789 this->barrier(dynamic_cast<const barrier_type&>(barrier));
790 }
791
792 inline void cmdTransfer(const IBuffer& source, const IBuffer& target, UInt32 sourceElement, UInt32 targetElement, UInt32 elements) const override {
793 this->transfer(dynamic_cast<const buffer_type&>(source), dynamic_cast<const buffer_type&>(target), sourceElement, targetElement, elements);
794 }
795
796 inline void cmdTransfer(const IBuffer& source, const IImage& target, UInt32 sourceElement, UInt32 firstSubresource, UInt32 elements) const override {
797 this->transfer(dynamic_cast<const buffer_type&>(source), dynamic_cast<const image_type&>(target), sourceElement, firstSubresource, elements);
798 }
799
800 inline void cmdTransfer(const IImage& source, const IImage& target, UInt32 sourceSubresource, UInt32 targetSubresource, UInt32 subresources) const override {
801 this->transfer(dynamic_cast<const image_type&>(source), dynamic_cast<const image_type&>(target), sourceSubresource, targetSubresource, subresources);
802 }
803
804 inline void cmdTransfer(const IImage& source, const IBuffer& target, UInt32 firstSubresource, UInt32 targetElement, UInt32 subresources) const override {
805 this->transfer(dynamic_cast<const image_type&>(source), dynamic_cast<const buffer_type&>(target), firstSubresource, targetElement, subresources);
806 }
807
808 inline void cmdTransfer(const SharedPtr<const IBuffer>& source, const IBuffer& target, UInt32 sourceElement, UInt32 targetElement, UInt32 elements) const override {
809 this->transfer(std::dynamic_pointer_cast<const buffer_type>(source), dynamic_cast<const buffer_type&>(target), sourceElement, targetElement, elements);
810 }
811
812 inline void cmdTransfer(const SharedPtr<const IBuffer>& source, const IImage& target, UInt32 sourceElement, UInt32 firstSubresource, UInt32 elements) const override {
813 this->transfer(std::dynamic_pointer_cast<const buffer_type>(source), dynamic_cast<const image_type&>(target), sourceElement, firstSubresource, elements);
814 }
815
816 inline void cmdTransfer(const SharedPtr<const IImage>& source, const IImage& target, UInt32 sourceSubresource, UInt32 targetSubresource, UInt32 subresources) const override {
817 this->transfer(std::dynamic_pointer_cast<const image_type>(source), dynamic_cast<const image_type&>(target), sourceSubresource, targetSubresource, subresources);
818 }
819
820 inline void cmdTransfer(const SharedPtr<const IImage>& source, const IBuffer& target, UInt32 firstSubresource, UInt32 targetElement, UInt32 subresources) const override {
821 this->transfer(std::dynamic_pointer_cast<const image_type>(source), dynamic_cast<const buffer_type&>(target), firstSubresource, targetElement, subresources);
822 }
823
824 inline void cmdTransfer(const void* const data, size_t size, const IBuffer& target, UInt32 targetElement, UInt32 elements) const override {
825 this->transfer(data, size, dynamic_cast<const buffer_type&>(target), targetElement, elements);
826 }
827
828 inline void cmdTransfer(Span<const void* const> data, size_t elementSize, const IBuffer& target, UInt32 targetElement) const override {
829 this->transfer(data, elementSize, dynamic_cast<const buffer_type&>(target), targetElement);
830 }
831
832 inline void cmdTransfer(const void* const data, size_t size, const IImage& target, UInt32 subresource) const override {
833 this->transfer(data, size, dynamic_cast<const image_type&>(target), subresource);
834 }
835
836 inline void cmdTransfer(Span<const void* const> data, size_t elementSize, const IImage& target, UInt32 firstSubresource, UInt32 elements) const override {
837 this->transfer(data, elementSize, dynamic_cast<const image_type&>(target), firstSubresource, elements);
838 }
839
840 inline void cmdUse(const IPipeline& pipeline) const noexcept override {
841 this->use(dynamic_cast<const pipeline_type&>(pipeline));
842 }
843
844 inline void cmdBind(const IDescriptorSet& descriptorSet) const override {
845 this->bind(dynamic_cast<const descriptor_set_type&>(descriptorSet));
846 }
847
848 inline void cmdBind(Span<const IDescriptorSet*> descriptorSets) const override {
849 auto sets = descriptorSets | std::views::transform([](auto set) { return dynamic_cast<const descriptor_set_type*>(set); }) | std::ranges::to<Array<const descriptor_set_type*>>();
850 this->bind(Span<const descriptor_set_type*>(sets));
851 }
852
853 inline void cmdBind(const IDescriptorSet& descriptorSet, const IPipeline& pipeline) const override {
854 this->bind(dynamic_cast<const descriptor_set_type&>(descriptorSet), dynamic_cast<const pipeline_type&>(pipeline));
855 }
856
857 inline void cmdBind(Span<const IDescriptorSet*> descriptorSets, const IPipeline& pipeline) const override {
858 auto sets = descriptorSets | std::views::transform([](auto set) { return dynamic_cast<const descriptor_set_type*>(set); }) | std::ranges::to<Array<const descriptor_set_type*>>();
859 this->bind(Span<const descriptor_set_type*>(sets), dynamic_cast<const pipeline_type&>(pipeline));
860 }
861
862 inline void cmdBind(const IVertexBuffer& buffer) const override {
863 this->bind(dynamic_cast<const vertex_buffer_type&>(buffer));
864 }
865
866 inline void cmdBind(const IIndexBuffer& buffer) const override {
867 this->bind(dynamic_cast<const index_buffer_type&>(buffer));
868 }
869
870 inline void cmdPushConstants(const IPushConstantsLayout& layout, const void* const memory) const override {
871 this->pushConstants(dynamic_cast<const push_constants_layout_type&>(layout), memory);
872 }
873
874 inline void cmdDispatchIndirect(const IBuffer& batchBuffer, UInt32 batchCount, UInt64 offset) const noexcept override {
875 this->dispatchIndirect(dynamic_cast<const buffer_type&>(batchBuffer), batchCount, offset);
876 }
877
878 inline void cmdDispatchMeshIndirect(const IBuffer& batchBuffer, UInt32 batchCount, UInt64 offset) const noexcept override {
879 this->dispatchMeshIndirect(dynamic_cast<const buffer_type&>(batchBuffer), batchCount, offset);
880 }
881
882 inline void cmdDispatchMeshIndirect(const IBuffer& batchBuffer, const IBuffer& countBuffer, UInt64 offset, UInt64 countOffset, UInt32 maxBatches) const noexcept override {
883 this->dispatchMeshIndirect(dynamic_cast<const buffer_type&>(batchBuffer), dynamic_cast<const buffer_type&>(countBuffer), offset, countOffset, maxBatches);
884 }
885
886 inline void cmdDraw(const IVertexBuffer& vertexBuffer, UInt32 instances, UInt32 firstVertex, UInt32 firstInstance) const override {
887 this->draw(dynamic_cast<const vertex_buffer_type&>(vertexBuffer), instances, firstVertex, firstInstance);
888 }
889
890 inline void cmdDrawIndirect(const IBuffer& batchBuffer, UInt32 batchCount, UInt64 offset) const noexcept override {
891 this->drawIndirect(dynamic_cast<const buffer_type&>(batchBuffer), batchCount, offset);
892 }
893
894 inline void cmdDrawIndirect(const IBuffer& batchBuffer, const IBuffer& countBuffer, UInt64 offset, UInt64 countOffset, UInt32 maxBatches) const noexcept override {
895 this->drawIndirect(dynamic_cast<const buffer_type&>(batchBuffer), dynamic_cast<const buffer_type&>(countBuffer), offset, countOffset, maxBatches);
896 }
897
898 inline void cmdDrawIndexed(const IIndexBuffer& indexBuffer, UInt32 instances, UInt32 firstIndex, Int32 vertexOffset, UInt32 firstInstance) const override {
899 this->drawIndexed(dynamic_cast<const index_buffer_type&>(indexBuffer), instances, firstIndex, vertexOffset, firstInstance);
900 }
901
902 inline void cmdDrawIndexed(const IVertexBuffer& vertexBuffer, const IIndexBuffer& indexBuffer, UInt32 instances, UInt32 firstIndex, Int32 vertexOffset, UInt32 firstInstance) const override {
903 this->drawIndexed(dynamic_cast<const vertex_buffer_type&>(vertexBuffer), dynamic_cast<const index_buffer_type&>(indexBuffer), instances, firstIndex, vertexOffset, firstInstance);
904 }
905
906 inline void cmdDrawIndexedIndirect(const IBuffer& batchBuffer, UInt32 batchCount, UInt64 offset) const noexcept override {
907 this->drawIndexedIndirect(dynamic_cast<const buffer_type&>(batchBuffer), batchCount, offset);
908 }
909
910 inline void cmdDrawIndexedIndirect(const IBuffer& batchBuffer, const IBuffer& countBuffer, UInt64 offset, UInt64 countOffset, UInt32 maxBatches) const noexcept override {
911 this->drawIndexedIndirect(dynamic_cast<const buffer_type&>(batchBuffer), dynamic_cast<const buffer_type&>(countBuffer), offset, countOffset, maxBatches);
912 }
913
914 inline void cmdExecute(const SharedPtr<const ICommandBuffer>& commandBuffer) const override {
915 this->execute(std::dynamic_pointer_cast<const command_buffer_type>(commandBuffer));
916 }
917
918 inline void cmdExecute(Enumerable<SharedPtr<const ICommandBuffer>> commandBuffers) const override {
919 return this->execute(commandBuffers | std::views::transform([](const SharedPtr<const ICommandBuffer>& buffer) { return std::dynamic_pointer_cast<const command_buffer_type>(buffer); }));
920 }
921
922 void cmdBuildAccelerationStructure(IBottomLevelAccelerationStructure& blas, const SharedPtr<const IBuffer>& scratchBuffer, const IBuffer& buffer, UInt64 offset) const override {
923 this->buildAccelerationStructure(dynamic_cast<bottom_level_acceleration_structure_type&>(blas), std::dynamic_pointer_cast<const buffer_type>(scratchBuffer), dynamic_cast<const buffer_type&>(buffer), offset);
924 }
925
926 void cmdBuildAccelerationStructure(ITopLevelAccelerationStructure& tlas, const SharedPtr<const IBuffer>& scratchBuffer, const IBuffer& buffer, UInt64 offset) const override {
927 this->buildAccelerationStructure(dynamic_cast<top_level_acceleration_structure_type&>(tlas), std::dynamic_pointer_cast<const buffer_type>(scratchBuffer), dynamic_cast<const buffer_type&>(buffer), offset);
928 }
929
930 void cmdUpdateAccelerationStructure(IBottomLevelAccelerationStructure& blas, const SharedPtr<const IBuffer>& scratchBuffer, const IBuffer& buffer, UInt64 offset) const override {
931 this->updateAccelerationStructure(dynamic_cast<bottom_level_acceleration_structure_type&>(blas), std::dynamic_pointer_cast<const buffer_type>(scratchBuffer), dynamic_cast<const buffer_type&>(buffer), offset);
932 }
933
934 void cmdUpdateAccelerationStructure(ITopLevelAccelerationStructure& tlas, const SharedPtr<const IBuffer>& scratchBuffer, const IBuffer& buffer, UInt64 offset) const override {
935 this->updateAccelerationStructure(dynamic_cast<top_level_acceleration_structure_type&>(tlas), std::dynamic_pointer_cast<const buffer_type>(scratchBuffer), dynamic_cast<const buffer_type&>(buffer), offset);
936 }
937
938 void cmdCopyAccelerationStructure(const IBottomLevelAccelerationStructure& from, const IBottomLevelAccelerationStructure& to, bool compress) const noexcept override {
939 this->copyAccelerationStructure(dynamic_cast<const bottom_level_acceleration_structure_type&>(from), dynamic_cast<const bottom_level_acceleration_structure_type&>(to), compress);
940 }
941
942 void cmdCopyAccelerationStructure(const ITopLevelAccelerationStructure& from, const ITopLevelAccelerationStructure& to, bool compress) const noexcept override {
943 this->copyAccelerationStructure(dynamic_cast<const top_level_acceleration_structure_type&>(from), dynamic_cast<const top_level_acceleration_structure_type&>(to), compress);
944 }
945
946 void cmdTraceRays(UInt32 width, UInt32 height, UInt32 depth, const ShaderBindingTableOffsets& offsets, const IBuffer& rayGenerationShaderBindingTable, const IBuffer* missShaderBindingTable, const IBuffer* hitShaderBindingTable, const IBuffer* callableShaderBindingTable) const noexcept override {
947 this->traceRays(width, height, depth, offsets, dynamic_cast<const buffer_type&>(rayGenerationShaderBindingTable), dynamic_cast<const buffer_type*>(missShaderBindingTable), dynamic_cast<const buffer_type*>(hitShaderBindingTable), dynamic_cast<const buffer_type*>(callableShaderBindingTable));
948 }
949 };
950
959 template <typename TPipelineLayout, typename TShaderProgram, typename TInputAssembler, typename TRasterizer> requires
960 meta::implements<TInputAssembler, InputAssembler<typename TInputAssembler::vertex_buffer_layout_type, typename TInputAssembler::index_buffer_layout_type>> &&
961 meta::implements<TRasterizer, Rasterizer>
962 class RenderPipeline : public IRenderPipeline, public virtual Pipeline<TPipelineLayout, TShaderProgram> {
963 public:
964 using input_assembler_type = TInputAssembler;
965 using rasterizer_type = TRasterizer;
966
967 protected:
968 RenderPipeline() noexcept = default;
969 RenderPipeline(RenderPipeline&&) noexcept = default;
971 RenderPipeline& operator=(RenderPipeline&&) noexcept = default;
972 RenderPipeline& operator=(const RenderPipeline&) = default;
973
974 public:
975 ~RenderPipeline() noexcept override = default;
976
977 public:
979 virtual SharedPtr<input_assembler_type> inputAssembler() const noexcept = 0;
980
982 virtual SharedPtr<rasterizer_type> rasterizer() const noexcept = 0;
983
984 private:
985 inline SharedPtr<IInputAssembler> getInputAssembler() const noexcept override {
986 return this->inputAssembler();
987 }
988
989 inline SharedPtr<IRasterizer> getRasterizer() const noexcept override {
990 return this->rasterizer();
991 }
992 };
993
1000 template <typename TPipelineLayout, typename TShaderProgram>
1001 class ComputePipeline : public IComputePipeline, public virtual Pipeline<TPipelineLayout, TShaderProgram> {
1002 protected:
1003 ComputePipeline() noexcept = default;
1004 ComputePipeline(ComputePipeline&&) noexcept = default;
1006 ComputePipeline& operator=(ComputePipeline&&) noexcept = default;
1007 ComputePipeline& operator=(const ComputePipeline&) = default;
1008
1009 public:
1010 ~ComputePipeline() noexcept override = default;
1011 };
1012
1019 template <typename TPipelineLayout, typename TShaderProgram>
1020 class RayTracingPipeline : public IRayTracingPipeline, public virtual Pipeline<TPipelineLayout, TShaderProgram> {
1021 public:
1023 using descriptor_set_layout_type = base_type::pipeline_layout_type::descriptor_set_layout_type;
1024 using descriptor_set_type = descriptor_set_layout_type::descriptor_set_type;
1025 using descriptor_layout_type = descriptor_set_layout_type::descriptor_layout_type;
1026 using buffer_type = descriptor_set_type::buffer_type;
1027 using image_type = descriptor_set_type::image_type;
1028 using sampler_type = descriptor_set_type::sampler_type;
1029
1030 protected:
1031 RayTracingPipeline() noexcept = default;
1034 RayTracingPipeline& operator=(RayTracingPipeline&&) noexcept = default;
1035 RayTracingPipeline& operator=(const RayTracingPipeline&) = default;
1036
1037 public:
1038 ~RayTracingPipeline() noexcept override = default;
1039
1040 public:
1042 virtual SharedPtr<buffer_type> allocateShaderBindingTable(ShaderBindingTableOffsets& offsets, ShaderBindingGroup groups = ShaderBindingGroup::All) const = 0;
1043
1044 private:
1045 inline SharedPtr<IBuffer> getShaderBindingTable(ShaderBindingTableOffsets& offsets, ShaderBindingGroup groups) const override {
1046 return this->allocateShaderBindingTable(offsets, groups);
1047 }
1048 };
1049
1055 template <typename TImage> requires
1056 std::derived_from<TImage, IImage>
1057 class FrameBuffer : public virtual StateResource, public IFrameBuffer {
1058 public:
1059 using image_type = TImage;
1060
1061 public:
1063
1064 protected:
1065 FrameBuffer() noexcept = default;
1066 FrameBuffer(FrameBuffer&&) noexcept = default;
1067 FrameBuffer(const FrameBuffer&) = default;
1068 FrameBuffer& operator=(FrameBuffer&&) noexcept = default;
1069 FrameBuffer& operator=(const FrameBuffer&) = default;
1070
1071 public:
1072 ~FrameBuffer() noexcept override = default;
1073
1074 public:
1076 virtual const Array<SharedPtr<const image_type>>& images() const = 0;
1077
1078 private:
1079 inline Enumerable<const IImage&> getImages() const override {
1080 return this->images() | std::views::transform([](auto& image) -> const IImage& { return *image; });
1081 }
1082 };
1083
1088 template <typename TCommandBuffer> requires
1091 public:
1093
1094 using command_buffer_type = TCommandBuffer;
1095
1096 protected:
1097 CommandQueue() noexcept = default;
1098 CommandQueue(CommandQueue&&) noexcept = default;
1099 CommandQueue(const CommandQueue&) = default;
1100 CommandQueue& operator=(CommandQueue&&) noexcept = default;
1101 CommandQueue& operator=(const CommandQueue&) = default;
1102
1103 public:
1104 ~CommandQueue() noexcept override = default;
1105
1106 public:
1108 virtual SharedPtr<command_buffer_type> createCommandBuffer(bool beginRecording = false, bool secondary = false) const = 0;
1109
1111 virtual inline UInt64 submit(const SharedPtr<command_buffer_type>& commandBuffer) const {
1112 return this->submit(std::static_pointer_cast<const command_buffer_type>(commandBuffer));
1113 }
1114
1116 virtual UInt64 submit(const SharedPtr<const command_buffer_type>& commandBuffer) const = 0;
1117
1120
1121 private:
1122 inline SharedPtr<ICommandBuffer> getCommandBuffer(bool beginRecording, bool secondary) const override {
1123 return this->createCommandBuffer(beginRecording, secondary);
1124 }
1125
1126 inline UInt64 submitCommandBuffer(const SharedPtr<const ICommandBuffer>& commandBuffer) const override {
1127 return this->submit(std::dynamic_pointer_cast<const command_buffer_type>(commandBuffer));
1128 }
1129
1130 inline UInt64 submitCommandBuffers(Enumerable<SharedPtr<const ICommandBuffer>> commandBuffers) const override {
1131 return this->submit(Enumerable<SharedPtr<const command_buffer_type>> {
1132 commandBuffers | std::views::transform([](const SharedPtr<const ICommandBuffer>& buffer) { return std::dynamic_pointer_cast<const command_buffer_type>(buffer); })
1133 });
1134 }
1135 };
1136
1147 template <typename TCommandQueue, typename TFrameBuffer> requires
1148 meta::implements<TCommandQueue, CommandQueue<typename TCommandQueue::command_buffer_type>> &&
1149 meta::implements<TFrameBuffer, FrameBuffer<typename TFrameBuffer::image_type>>
1150 class RenderPass : public virtual StateResource, public IRenderPass {
1151 public:
1152 using command_queue_type = TCommandQueue;
1153 using command_buffer_type = TCommandQueue::command_buffer_type;
1154 using frame_buffer_type = TFrameBuffer;
1155
1156 protected:
1157 RenderPass() noexcept = default;
1158 RenderPass(RenderPass&&) noexcept = default;
1159 RenderPass(const RenderPass&) = default;
1160 RenderPass& operator=(RenderPass&&) noexcept = default;
1161 RenderPass& operator=(const RenderPass&) = default;
1162
1163 public:
1164 ~RenderPass() noexcept override = default;
1165
1166 public:
1168 virtual SharedPtr<const frame_buffer_type> activeFrameBuffer() const noexcept = 0;
1169
1171 virtual Enumerable<SharedPtr<const command_buffer_type>> commandBuffers() const = 0;
1172
1174 virtual const command_queue_type& commandQueue() const noexcept = 0;
1175
1177 virtual SharedPtr<const command_buffer_type> commandBuffer(UInt32 index) const = 0;
1178
1180 virtual void begin(const frame_buffer_type& frameBuffer) const = 0;
1181
1182 private:
1183 inline SharedPtr<const IFrameBuffer> getActiveFrameBuffer() const noexcept override {
1184 return this->activeFrameBuffer();
1185 }
1186
1187 inline SharedPtr<const ICommandBuffer> getCommandBuffer(UInt32 index) const noexcept override {
1188 return this->commandBuffer(index);
1189 }
1190
1191 inline const ICommandQueue& getCommandQueue() const noexcept override {
1192 return this->commandQueue();
1193 }
1194
1195 inline Enumerable<SharedPtr<const ICommandBuffer>> getCommandBuffers() const override {
1196 return this->commandBuffers();
1197 }
1198
1199 inline void beginRenderPass(const IFrameBuffer& frameBuffer) const override {
1200 this->begin(dynamic_cast<const frame_buffer_type&>(frameBuffer));
1201 }
1202 };
1203
1208 template <typename TImageInterface> requires
1209 std::derived_from<TImageInterface, IImage>
1210 class SwapChain : public ISwapChain {
1211 public:
1212 using image_interface_type = TImageInterface;
1213
1214 protected:
1215 SwapChain() noexcept = default;
1216 SwapChain(SwapChain&&) noexcept = default;
1217 SwapChain(const SwapChain&) = default;
1218 SwapChain& operator=(SwapChain&&) noexcept = default;
1219 SwapChain& operator=(const SwapChain&) = default;
1220
1221 public:
1222 ~SwapChain() noexcept override = default;
1223
1224 public:
1226 virtual const Array<SharedPtr<image_interface_type>>& images() const noexcept = 0;
1227
1228 private:
1229 inline Enumerable<IImage&> getImages() const override {
1230 return this->images() | std::views::transform([](auto& image) -> IImage& { return *image; });
1231 }
1232 };
1233
1245 template <typename TDescriptorLayout, typename TBuffer, typename TVertexBuffer, typename TIndexBuffer, typename TImage, typename TSampler, typename TBLAS, typename TTLAS> requires
1247 std::derived_from<TVertexBuffer, VertexBuffer<typename TVertexBuffer::vertex_buffer_layout_type>> &&
1248 std::derived_from<TIndexBuffer, IndexBuffer<typename TIndexBuffer::index_buffer_layout_type>> &&
1249 std::derived_from<TImage, IImage> &&
1250 std::derived_from<TBuffer, IBuffer> &&
1251 std::derived_from<TSampler, ISampler> &&
1252 std::derived_from<TBLAS, IBottomLevelAccelerationStructure> &&
1253 std::derived_from<TTLAS, ITopLevelAccelerationStructure>
1255 public:
1263
1264 using descriptor_layout_type = TDescriptorLayout;
1265 using vertex_buffer_type = TVertexBuffer;
1266 using vertex_buffer_layout_type = vertex_buffer_type::vertex_buffer_layout_type;
1267 using index_buffer_type = TIndexBuffer;
1268 using index_buffer_layout_type = index_buffer_type::index_buffer_layout_type;
1269 using buffer_type = TBuffer;
1270 using image_type = TImage;
1271 using sampler_type = TSampler;
1274
1275 protected:
1276 GraphicsFactory() noexcept = default;
1277 GraphicsFactory(GraphicsFactory&&) noexcept = default;
1279 GraphicsFactory& operator=(GraphicsFactory&&) noexcept = default;
1280 GraphicsFactory& operator=(const GraphicsFactory&) = default;
1281
1282 public:
1283 ~GraphicsFactory() noexcept override = default;
1284
1285 public:
1287 virtual SharedPtr<TBuffer> createBuffer(BufferType type, ResourceHeap heap, size_t elementSize, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default) const = 0;
1288
1290 virtual SharedPtr<TBuffer> createBuffer(const String& name, BufferType type, ResourceHeap heap, size_t elementSize, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default) const = 0;
1291
1293 virtual SharedPtr<TVertexBuffer> createVertexBuffer(const vertex_buffer_layout_type& layout, ResourceHeap heap, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default) const = 0;
1294
1296 virtual SharedPtr<TVertexBuffer> createVertexBuffer(const String& name, const vertex_buffer_layout_type& layout, ResourceHeap heap, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default) const = 0;
1297
1299 virtual SharedPtr<TIndexBuffer> createIndexBuffer(const index_buffer_layout_type& layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage = ResourceUsage::Default) const = 0;
1300
1302 virtual SharedPtr<TIndexBuffer> createIndexBuffer(const String& name, const index_buffer_layout_type& layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage = ResourceUsage::Default) const = 0;
1303
1305 virtual SharedPtr<TImage> createTexture(Format format, const Size3d& size, ImageDimensions dimension = ImageDimensions::DIM_2, UInt32 levels = 1, UInt32 layers = 1, MultiSamplingLevel samples = MultiSamplingLevel::x1, ResourceUsage usage = ResourceUsage::Default) const = 0;
1306
1308 virtual SharedPtr<TImage> createTexture(const String& name, Format format, const Size3d& size, ImageDimensions dimension = ImageDimensions::DIM_2, UInt32 levels = 1, UInt32 layers = 1, MultiSamplingLevel samples = MultiSamplingLevel::x1, ResourceUsage usage = ResourceUsage::Default) const = 0;
1309
1311 virtual Generator<SharedPtr<TImage>> createTextures(Format format, const Size3d& size, ImageDimensions dimension = ImageDimensions::DIM_2, UInt32 layers = 1, UInt32 levels = 1, MultiSamplingLevel samples = MultiSamplingLevel::x1, ResourceUsage usage = ResourceUsage::Default) const = 0;
1312
1314 virtual SharedPtr<TSampler> createSampler(FilterMode magFilter = FilterMode::Nearest, FilterMode minFilter = FilterMode::Nearest, BorderMode borderU = BorderMode::Repeat, BorderMode borderV = BorderMode::Repeat, BorderMode borderW = BorderMode::Repeat, MipMapMode mipMapMode = MipMapMode::Nearest, Float mipMapBias = 0.f, Float maxLod = std::numeric_limits<Float>::max(), Float minLod = 0.f, Float anisotropy = 0.f) const = 0;
1315
1317 virtual SharedPtr<TSampler> createSampler(const String& name, FilterMode magFilter = FilterMode::Nearest, FilterMode minFilter = FilterMode::Nearest, BorderMode borderU = BorderMode::Repeat, BorderMode borderV = BorderMode::Repeat, BorderMode borderW = BorderMode::Repeat, MipMapMode mipMapMode = MipMapMode::Nearest, Float mipMapBias = 0.f, Float maxLod = std::numeric_limits<Float>::max(), Float minLod = 0.f, Float anisotropy = 0.f) const = 0;
1318
1320 virtual Generator<SharedPtr<TSampler>> createSamplers(FilterMode magFilter = FilterMode::Nearest, FilterMode minFilter = FilterMode::Nearest, BorderMode borderU = BorderMode::Repeat, BorderMode borderV = BorderMode::Repeat, BorderMode borderW = BorderMode::Repeat, MipMapMode mipMapMode = MipMapMode::Nearest, Float mipMapBias = 0.f, Float maxLod = std::numeric_limits<Float>::max(), Float minLod = 0.f, Float anisotropy = 0.f) const = 0;
1321
1323 inline UniquePtr<TBLAS> createBottomLevelAccelerationStructure(AccelerationStructureFlags flags) const {
1324 return this->createBottomLevelAccelerationStructure("", flags);
1325 }
1326
1329
1332 return this->createTopLevelAccelerationStructure("", flags);
1333 }
1334
1337
1338 private:
1339 inline SharedPtr<IBuffer> getBuffer(BufferType type, ResourceHeap heap, size_t elementSize, UInt32 elements, ResourceUsage usage) const override {
1340 return this->createBuffer(type, heap, elementSize, elements, usage);
1341 }
1342
1343 inline SharedPtr<IBuffer> getBuffer(const String& name, BufferType type, ResourceHeap heap, size_t elementSize, UInt32 elements, ResourceUsage usage) const override {
1344 return this->createBuffer(name, type, heap, elementSize, elements, usage);
1345 }
1346
1347 inline SharedPtr<IVertexBuffer> getVertexBuffer(const IVertexBufferLayout& layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage) const override {
1348 return this->createVertexBuffer(dynamic_cast<const vertex_buffer_layout_type&>(layout), heap, elements, usage);
1349 }
1350
1351 inline SharedPtr<IVertexBuffer> getVertexBuffer(const String& name, const IVertexBufferLayout& layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage) const override {
1352 return this->createVertexBuffer(name, dynamic_cast<const vertex_buffer_layout_type&>(layout), heap, elements, usage);
1353 }
1354
1355 inline SharedPtr<IIndexBuffer> getIndexBuffer(const IIndexBufferLayout& layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage) const override {
1356 return this->createIndexBuffer(dynamic_cast<const index_buffer_layout_type&>(layout), heap, elements, usage);
1357 }
1358
1359 inline SharedPtr<IIndexBuffer> getIndexBuffer(const String& name, const IIndexBufferLayout& layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage) const override {
1360 return this->createIndexBuffer(name, dynamic_cast<const index_buffer_layout_type&>(layout), heap, elements, usage);
1361 }
1362
1363 inline SharedPtr<IImage> getTexture(Format format, const Size3d& size, ImageDimensions dimension, UInt32 levels, UInt32 layers, MultiSamplingLevel samples, ResourceUsage usage) const override {
1364 return this->createTexture(format, size, dimension, levels, layers, samples, usage);
1365 }
1366
1367 inline SharedPtr<IImage> getTexture(const String& name, Format format, const Size3d& size, ImageDimensions dimension, UInt32 levels, UInt32 layers, MultiSamplingLevel samples, ResourceUsage usage) const override {
1368 return this->createTexture(name, format, size, dimension, levels, layers, samples, usage);
1369 }
1370
1371 inline Generator<SharedPtr<IImage>> getTextures(Format format, const Size3d& size, ImageDimensions dimension, UInt32 layers, UInt32 levels, MultiSamplingLevel samples, ResourceUsage usage) const override {
1373 for (auto texture : gen)
1374 co_yield std::move(texture);
1375 }(this->createTextures(format, size, dimension, layers, levels, samples, usage));
1376 }
1377
1378 inline SharedPtr<ISampler> getSampler(FilterMode magFilter, FilterMode minFilter, BorderMode borderU, BorderMode borderV, BorderMode borderW, MipMapMode mipMapMode, Float mipMapBias, Float maxLod, Float minLod, Float anisotropy) const override {
1379 return this->createSampler(magFilter, minFilter, borderU, borderV, borderW, mipMapMode, mipMapBias, maxLod, minLod, anisotropy);
1380 }
1381
1382 inline SharedPtr<ISampler> getSampler(const String& name, FilterMode magFilter, FilterMode minFilter, BorderMode borderU, BorderMode borderV, BorderMode borderW, MipMapMode mipMapMode, Float mipMapBias, Float maxLod, Float minLod, Float anisotropy) const override {
1383 return this->createSampler(name, magFilter, minFilter, borderU, borderV, borderW, mipMapMode, mipMapBias, maxLod, minLod, anisotropy);
1384 }
1385
1386 inline Generator<SharedPtr<ISampler>> getSamplers(FilterMode magFilter, FilterMode minFilter, BorderMode borderU, BorderMode borderV, BorderMode borderW, MipMapMode mipMapMode, Float mipMapBias, Float maxLod, Float minLod, Float anisotropy) const override {
1388 for (auto sampler : gen)
1389 co_yield std::move(sampler);
1390 }(this->createSamplers(magFilter, minFilter, borderU, borderV, borderW, mipMapMode, mipMapBias, maxLod, minLod, anisotropy));
1391 }
1392
1394 return this->createBottomLevelAccelerationStructure(name, flags);
1395 }
1396
1397 inline UniquePtr<ITopLevelAccelerationStructure> getTlas(StringView name, AccelerationStructureFlags flags) const override {
1398 return this->createTopLevelAccelerationStructure(name, flags);
1399 }
1400 };
1401
1420 template <typename TFactory, typename TSurface, typename TGraphicsAdapter, typename TSwapChain, typename TCommandQueue, typename TRenderPass, typename TRenderPipeline, typename TComputePipeline, typename TRayTracingPipeline, typename TBarrier> requires
1421 meta::implements<TSurface, ISurface> &&
1422 meta::implements<TGraphicsAdapter, IGraphicsAdapter> &&
1423 meta::implements<TSwapChain, SwapChain<typename TFactory::image_type>> &&
1424 meta::implements<TCommandQueue, CommandQueue<typename TCommandQueue::command_buffer_type>> &&
1425 meta::implements<TFactory, GraphicsFactory<typename TFactory::descriptor_layout_type, typename TFactory::buffer_type, typename TFactory::vertex_buffer_type, typename TFactory::index_buffer_type, typename TFactory::image_type, typename TFactory::sampler_type, typename TFactory::bottom_level_acceleration_structure_type, typename TFactory::top_level_acceleration_structure_type>> &&
1426 meta::implements<TRenderPass, RenderPass<TCommandQueue, typename TRenderPass::frame_buffer_type>> &&
1427 meta::implements<TRenderPipeline, RenderPipeline<typename TRenderPipeline::pipeline_layout_type, typename TRenderPipeline::shader_program_type, typename TRenderPipeline::input_assembler_type, typename TRenderPipeline::rasterizer_type>> &&
1428 meta::implements<TComputePipeline, ComputePipeline<typename TComputePipeline::pipeline_layout_type, typename TComputePipeline::shader_program_type>> &&
1429 meta::implements<TRayTracingPipeline, RayTracingPipeline<typename TRayTracingPipeline::pipeline_layout_type, typename TRayTracingPipeline::shader_program_type>> &&
1430 meta::implements<TBarrier, Barrier<typename TFactory::buffer_type, typename TFactory::image_type>>
1432 public:
1433 using surface_type = TSurface;
1434 using adapter_type = TGraphicsAdapter;
1435 using swap_chain_type = TSwapChain;
1436 using command_queue_type = TCommandQueue;
1437 using command_buffer_type = command_queue_type::command_buffer_type;
1438 using factory_type = TFactory;
1439 using barrier_type = TBarrier;
1440 using descriptor_layout_type = factory_type::descriptor_layout_type;
1441 using vertex_buffer_type = factory_type::vertex_buffer_type;
1442 using index_buffer_type = factory_type::index_buffer_type;
1443 using buffer_type = factory_type::buffer_type;
1444 using image_type = factory_type::image_type;
1445 using sampler_type = factory_type::sampler_type;
1446 using bottom_level_acceleration_structure_type = factory_type::bottom_level_acceleration_structure_type;
1447 using top_level_acceleration_structure_type = factory_type::top_level_acceleration_structure_type;
1448 using render_pass_type = TRenderPass;
1449 using frame_buffer_type = render_pass_type::frame_buffer_type;
1450 using render_pipeline_type = TRenderPipeline;
1451 using compute_pipeline_type = TComputePipeline;
1452 using ray_tracing_pipeline_type = TRayTracingPipeline;
1453 using pipeline_layout_type = render_pipeline_type::pipeline_layout_type;
1454 using shader_program_type = render_pipeline_type::shader_program_type;
1455 using input_assembler_type = render_pipeline_type::input_assembler_type;
1456 using rasterizer_type = render_pipeline_type::rasterizer_type;
1457
1458 protected:
1459 GraphicsDevice() noexcept = default;
1460 GraphicsDevice(GraphicsDevice&&) noexcept = default;
1462 GraphicsDevice& operator=(GraphicsDevice&&) noexcept = default;
1463 GraphicsDevice& operator=(const GraphicsDevice&) = default;
1464
1465 public:
1466 ~GraphicsDevice() noexcept override = default;
1467
1468 public:
1470 const surface_type& surface() const noexcept override = 0;
1471
1473 const adapter_type& adapter() const noexcept override = 0;
1474
1476 const swap_chain_type& swapChain() const noexcept override = 0;
1477
1479 swap_chain_type& swapChain() noexcept override = 0;
1480
1482 const factory_type& factory() const noexcept override = 0;
1483
1485 virtual const command_queue_type& defaultQueue(QueueType type) const = 0;
1486
1488 virtual SharedPtr<const command_queue_type> createQueue(QueueType type, QueuePriority priority = QueuePriority::Normal) = 0;
1489
1491 [[nodiscard]] virtual UniquePtr<barrier_type> makeBarrier(PipelineStage syncBefore, PipelineStage syncAfter) const = 0;
1492
1494 [[nodiscard]] inline SharedPtr<frame_buffer_type> makeFrameBuffer(const Size2d& renderArea) const {
1495 return this->makeFrameBuffer("", renderArea);
1496 }
1497
1499 [[nodiscard]] virtual SharedPtr<frame_buffer_type> makeFrameBuffer(StringView name, const Size2d& renderArea) const = 0;
1500
1501 private:
1502 inline UniquePtr<IBarrier> getNewBarrier(PipelineStage syncBefore, PipelineStage syncAfter) const override {
1503 return this->makeBarrier(syncBefore, syncAfter);
1504 }
1505
1506 inline SharedPtr<IFrameBuffer> getNewFrameBuffer(StringView name, const Size2d& renderArea) const override {
1507 return this->makeFrameBuffer(name, renderArea);
1508 }
1509
1510 inline const ICommandQueue& getDefaultQueue(QueueType type) const override {
1511 return this->defaultQueue(type);
1512 }
1513
1514 inline SharedPtr<const ICommandQueue> getNewQueue(QueueType type, QueuePriority priority) override {
1515 return std::static_pointer_cast<const ICommandQueue>(this->createQueue(type, priority));
1516 }
1517
1518 public:
1520 virtual void computeAccelerationStructureSizes(const bottom_level_acceleration_structure_type& blas, UInt64& bufferSize, UInt64& scratchSize, bool forUpdate = false) const = 0;
1521
1523 virtual void computeAccelerationStructureSizes(const top_level_acceleration_structure_type& tlas, UInt64 & bufferSize, UInt64 & scratchSize, bool forUpdate = false) const = 0;
1524
1525 private:
1526 inline void getAccelerationStructureSizes(const IBottomLevelAccelerationStructure& blas, UInt64& bufferSize, UInt64& scratchSize, bool forUpdate) const override {
1527 this->computeAccelerationStructureSizes(dynamic_cast<const bottom_level_acceleration_structure_type&>(blas), bufferSize, scratchSize, forUpdate);
1528 }
1529
1530 inline void getAccelerationStructureSizes(const ITopLevelAccelerationStructure& tlas, UInt64& bufferSize, UInt64& scratchSize, bool forUpdate) const override {
1531 this->computeAccelerationStructureSizes(dynamic_cast<const top_level_acceleration_structure_type&>(tlas), bufferSize, scratchSize, forUpdate);
1532 }
1533
1534#if defined(LITEFX_BUILD_DEFINE_BUILDERS)
1535 public:
1536 using render_pass_builder_type = render_pass_type::builder_type;
1537 using render_pipeline_builder_type = render_pipeline_type::builder_type;
1538 using compute_pipeline_builder_type = compute_pipeline_type::builder_type;
1539 using ray_tracing_pipeline_builder_type = ray_tracing_pipeline_type::builder_type;
1540 using pipeline_layout_builder_type = pipeline_layout_type::builder_type;
1541 using input_assembler_builder_type = input_assembler_type::builder_type;
1542 using rasterizer_builder_type = rasterizer_type::builder_type;
1543 using shader_program_builder_type = shader_program_type::builder_type;
1544 using barrier_builder_Type = barrier_type::builder_type;
1545
1551 [[nodiscard]] virtual render_pass_builder_type buildRenderPass(UInt32 commandBuffers = 1) const = 0;
1552
1559 [[nodiscard]] virtual render_pass_builder_type buildRenderPass(const String& name, UInt32 commandBuffers = 1) const = 0;
1560
1566 [[nodiscard]] virtual compute_pipeline_builder_type buildComputePipeline(const String& name) const = 0;
1567
1573 //[[nodiscard]] virtual render_pipeline_builder_type buildRenderPipeline(const String& name) const = 0;
1574
1581 [[nodiscard]] virtual render_pipeline_builder_type buildRenderPipeline(const render_pass_type& renderPass, const String& name) const = 0;
1582
1591 [[nodiscard]] virtual ray_tracing_pipeline_builder_type buildRayTracingPipeline(ShaderRecordCollection&& shaderRecords) const = 0;
1592
1602 [[nodiscard]] virtual ray_tracing_pipeline_builder_type buildRayTracingPipeline(const String& name, ShaderRecordCollection&& shaderRecords) const = 0;
1603
1608 [[nodiscard]] virtual pipeline_layout_builder_type buildPipelineLayout() const = 0;
1609
1614 [[nodiscard]] virtual input_assembler_builder_type buildInputAssembler() const = 0;
1615
1620 [[nodiscard]] virtual rasterizer_builder_type buildRasterizer() const = 0;
1621
1626 [[nodiscard]] virtual shader_program_builder_type buildShaderProgram() const = 0;
1627
1632 [[nodiscard]] virtual barrier_builder_Type buildBarrier() const = 0;
1633#endif // defined(LITEFX_BUILD_DEFINE_BUILDERS)
1634 };
1635
1640 template <typename TGraphicsDevice> requires
1641 meta::implements<TGraphicsDevice, GraphicsDevice<typename TGraphicsDevice::factory_type, typename TGraphicsDevice::surface_type, typename TGraphicsDevice::adapter_type, typename TGraphicsDevice::swap_chain_type, typename TGraphicsDevice::command_queue_type, typename TGraphicsDevice::render_pass_type, typename TGraphicsDevice::render_pipeline_type, typename TGraphicsDevice::compute_pipeline_type, typename TGraphicsDevice::ray_tracing_pipeline_type, typename TGraphicsDevice::barrier_type>>
1643 public:
1644 using device_type = TGraphicsDevice;
1645 using surface_type = device_type::surface_type;
1646 using adapter_type = device_type::adapter_type;
1647 using swap_chain_type = device_type::swap_chain_type;
1648 using command_queue_type = device_type::command_queue_type;
1649 using command_buffer_type = device_type::command_buffer_type;
1650 using factory_type = device_type::factory_type;
1651 using barrier_type = device_type::barrier_type;
1652 using descriptor_layout_type = factory_type::descriptor_layout_type;
1653 using vertex_buffer_type = factory_type::vertex_buffer_type;
1654 using index_buffer_type = factory_type::index_buffer_type;
1655 using buffer_type = factory_type::buffer_type;
1656 using image_type = factory_type::image_type;
1657 using sampler_type = factory_type::sampler_type;
1658 using frame_buffer_type = device_type::frame_buffer_type;
1659 using render_pass_type = device_type::render_pass_type;
1660 using pipeline_layout_type = device_type::pipeline_layout_type;
1661 using render_pipeline_type = device_type::render_pipeline_type;
1662 using compute_pipeline_type = device_type::compute_pipeline_type;
1663 using ray_tracing_pipeline_type = device_type::ray_tracing_pipeline_type;
1664 using shader_program_type = device_type::shader_program_type;
1665 using input_assembler_type = device_type::input_assembler_type;
1666 using rasterizer_type = device_type::rasterizer_type;
1667
1668 protected:
1669 RenderBackend() noexcept = default;
1670 RenderBackend(RenderBackend&&) noexcept = default;
1671 RenderBackend(const RenderBackend&) = default;
1672 RenderBackend& operator=(RenderBackend&&) noexcept = default;
1673 RenderBackend& operator=(const RenderBackend&) = default;
1674
1675 public:
1676 ~RenderBackend() noexcept override = default;
1677
1678 public:
1680 virtual const Array<SharedPtr<const adapter_type>>& adapters() const = 0;
1681
1683 const adapter_type* findAdapter(const Optional<UInt64>& adapterId = std::nullopt) const noexcept override = 0;
1684
1686 virtual void registerDevice(const String& name, SharedPtr<device_type>&& device) = 0;
1687
1693 template <typename TSelf, typename ...TArgs>
1694 inline device_type& createDevice(this TSelf& self, const String& name, const adapter_type& adapter, UniquePtr<surface_type>&& surface, TArgs&&... _args) {
1695 auto devicePtr = device_type::create(self, adapter, std::move(surface), std::forward<TArgs>(_args)...);
1696 auto& device = *devicePtr;
1697 self.registerDevice(name, std::move(devicePtr));
1698 return device;
1699 }
1700
1705 virtual void releaseDevice(const String& name) = 0;
1706
1708 device_type* device(const String& name) noexcept override = 0;
1709
1711 const device_type* device(const String& name) const noexcept override = 0;
1712
1714 inline const device_type* operator[](const String& name) const noexcept override {
1715 return this->device(name);
1716 };
1717
1719 inline device_type* operator[](const String& name) noexcept override {
1720 return this->device(name);
1721 };
1722
1723 // IRenderBackend interface
1724 private:
1725 inline Enumerable<SharedPtr<const IGraphicsAdapter>> getAdapters() const override {
1726 return this->adapters();
1727 }
1728 };
1729}
Definition math.hpp:850
Definition math.hpp:819
Definition math.hpp:490
A barrier used for GPU resource synchronization.
Definition rendering.hpp:17
TImage image_type
Definition rendering.hpp:22
virtual constexpr void transition(const buffer_type &buffer, ResourceAccess accessBefore, ResourceAccess accessAfter)=0
TBuffer buffer_type
Definition rendering.hpp:21
Barrier() noexcept=default
Represents a command buffer, that buffers commands that should be submitted to a CommandQueue.
Definition rendering.hpp:597
virtual void execute(const SharedPtr< const command_buffer_type > &commandBuffer) const =0
pipeline_type::pipeline_layout_type pipeline_layout_type
Definition rendering.hpp:627
virtual void buildAccelerationStructure(bottom_level_acceleration_structure_type &blas, const SharedPtr< const buffer_type > &scratchBuffer, const buffer_type &buffer, UInt64 offset=0) const =0
TBuffer buffer_type
Definition rendering.hpp:621
virtual void updateAccelerationStructure(bottom_level_acceleration_structure_type &blas, const SharedPtr< const buffer_type > &scratchBuffer, const buffer_type &buffer, UInt64 offset=0) const =0
TBLAS bottom_level_acceleration_structure_type
Definition rendering.hpp:631
pipeline_layout_type::push_constants_layout_type push_constants_layout_type
Definition rendering.hpp:629
TBarrier barrier_type
Definition rendering.hpp:625
virtual void drawIndexed(const vertex_buffer_type &vertexBuffer, const index_buffer_type &indexBuffer, UInt32 instances=1, UInt32 firstIndex=0, Int32 vertexOffset=0, UInt32 firstInstance=0) const
Definition rendering.hpp:745
virtual void execute(Enumerable< SharedPtr< const command_buffer_type > > commandBuffers) const =0
TVertexBuffer vertex_buffer_type
Definition rendering.hpp:622
TIndexBuffer index_buffer_type
Definition rendering.hpp:623
descriptor_set_layout_type::descriptor_set_type descriptor_set_type
Definition rendering.hpp:630
pipeline_layout_type::descriptor_set_layout_type descriptor_set_layout_type
Definition rendering.hpp:628
virtual void copyAccelerationStructure(const bottom_level_acceleration_structure_type &from, const bottom_level_acceleration_structure_type &to, bool compress=false) const noexcept=0
virtual void buildAccelerationStructure(top_level_acceleration_structure_type &tlas, const SharedPtr< const buffer_type > &scratchBuffer, const buffer_type &buffer, UInt64 offset=0) const =0
TCommandBuffer command_buffer_type
Definition rendering.hpp:620
TImage image_type
Definition rendering.hpp:624
TPipeline pipeline_type
Definition rendering.hpp:626
virtual void updateAccelerationStructure(top_level_acceleration_structure_type &tlas, const SharedPtr< const buffer_type > &scratchBuffer, const buffer_type &buffer, UInt64 offset=0) const =0
virtual void drawIndexed(const index_buffer_type &indexBuffer, UInt32 instances=1, UInt32 firstIndex=0, Int32 vertexOffset=0, UInt32 firstInstance=0) const
Definition rendering.hpp:739
TTLAS top_level_acceleration_structure_type
Definition rendering.hpp:632
friend TCommandBuffer
Definition rendering.hpp:617
Represents a command queue.
Definition rendering.hpp:1090
TCommandBuffer command_buffer_type
Definition rendering.hpp:1094
virtual UInt64 submit(const SharedPtr< const command_buffer_type > &commandBuffer) const =0
virtual UInt64 submit(Enumerable< SharedPtr< const command_buffer_type > > commandBuffers) const =0
CommandQueue() noexcept=default
Represents a compute Pipeline.
Definition rendering.hpp:1001
ComputePipeline() noexcept=default
Defines a set of descriptors.
Definition rendering.hpp:150
TSampler sampler_type
Definition rendering.hpp:155
TAccelerationStructure acceleration_structure_type
Definition rendering.hpp:157
TImage image_type
Definition rendering.hpp:156
virtual void update(UInt32 binding, const buffer_type &buffer, UInt32 bufferElement=0, UInt32 elements=0, UInt32 firstDescriptor=0) const =0
DescriptorSet() noexcept=default
TBuffer buffer_type
Definition rendering.hpp:154
Describes the layout of a descriptor set.
Definition rendering.hpp:215
virtual const Array< descriptor_layout_type > & descriptors() const noexcept=0
virtual UniquePtr< descriptor_set_type > allocate(UInt32 descriptors, Generator< DescriptorBinding > bindings) const =0
virtual UniquePtr< descriptor_set_type > allocate(Generator< DescriptorBinding > bindings) const
Definition rendering.hpp:250
virtual UniquePtr< descriptor_set_type > allocate(UInt32 descriptors, Span< DescriptorBinding > bindings) const =0
virtual Generator< UniquePtr< descriptor_set_type > > allocate(UInt32 descriptorSets, UInt32 descriptors, std::function< Generator< DescriptorBinding >(UInt32)> bindingFactory) const =0
virtual Generator< UniquePtr< descriptor_set_type > > allocate(UInt32 descriptorSets, std::function< Generator< DescriptorBinding >(UInt32)> bindings) const
Definition rendering.hpp:276
virtual Generator< UniquePtr< descriptor_set_type > > allocate(UInt32 descriptorSets, UInt32 descriptors, std::initializer_list< std::initializer_list< DescriptorBinding > > bindings={ }) const =0
virtual UniquePtr< descriptor_set_type > allocate(UInt32 descriptors, std::initializer_list< DescriptorBinding > bindings) const =0
const descriptor_layout_type & descriptor(UInt32 binding) const override=0
Returns the descriptor layout for the descriptor bound to the binding point provided with binding ....
virtual Generator< UniquePtr< descriptor_set_type > > allocate(UInt32 descriptorSets, std::initializer_list< std::initializer_list< DescriptorBinding > > bindings={ }) const
Definition rendering.hpp:264
TDescriptorSet descriptor_set_type
Definition rendering.hpp:220
virtual void free(const descriptor_set_type &descriptorSet) const =0
virtual UniquePtr< descriptor_set_type > allocate(Span< DescriptorBinding > bindings) const
Definition rendering.hpp:245
TDescriptorLayout descriptor_layout_type
Definition rendering.hpp:219
virtual UniquePtr< descriptor_set_type > allocate(std::initializer_list< DescriptorBinding > bindings={ }) const
Definition rendering.hpp:240
Stores the images used by a RenderPass to either read from using input attachments or write to using ...
Definition rendering.hpp:1057
TImage image_type
Definition rendering.hpp:1059
FrameBuffer() noexcept=default
Represents the graphics device that a rendering back-end is doing work on.
Definition rendering.hpp:1431
TFactory factory_type
Definition rendering.hpp:1438
factory_type::top_level_acceleration_structure_type top_level_acceleration_structure_type
Definition rendering.hpp:1447
TRayTracingPipeline ray_tracing_pipeline_type
Definition rendering.hpp:1452
factory_type::vertex_buffer_type vertex_buffer_type
Definition rendering.hpp:1441
virtual void computeAccelerationStructureSizes(const bottom_level_acceleration_structure_type &blas, UInt64 &bufferSize, UInt64 &scratchSize, bool forUpdate=false) const =0
render_pipeline_type::pipeline_layout_type pipeline_layout_type
Definition rendering.hpp:1453
TGraphicsAdapter adapter_type
Definition rendering.hpp:1434
render_pipeline_type::shader_program_type shader_program_type
Definition rendering.hpp:1454
TComputePipeline compute_pipeline_type
Definition rendering.hpp:1451
render_pipeline_type::input_assembler_type input_assembler_type
Definition rendering.hpp:1455
factory_type::bottom_level_acceleration_structure_type bottom_level_acceleration_structure_type
Definition rendering.hpp:1446
TBarrier barrier_type
Definition rendering.hpp:1439
TSwapChain swap_chain_type
Definition rendering.hpp:1435
virtual SharedPtr< frame_buffer_type > makeFrameBuffer(StringView name, const Size2d &renderArea) const =0
factory_type::buffer_type buffer_type
Definition rendering.hpp:1443
command_queue_type::command_buffer_type command_buffer_type
Definition rendering.hpp:1437
TRenderPass render_pass_type
Definition rendering.hpp:1448
TRenderPipeline render_pipeline_type
Definition rendering.hpp:1450
virtual void computeAccelerationStructureSizes(const top_level_acceleration_structure_type &tlas, UInt64 &bufferSize, UInt64 &scratchSize, bool forUpdate=false) const =0
factory_type::descriptor_layout_type descriptor_layout_type
Definition rendering.hpp:1440
render_pass_type::frame_buffer_type frame_buffer_type
Definition rendering.hpp:1449
GraphicsDevice() noexcept=default
factory_type::image_type image_type
Definition rendering.hpp:1444
TSurface surface_type
Definition rendering.hpp:1433
render_pipeline_type::rasterizer_type rasterizer_type
Definition rendering.hpp:1456
factory_type::sampler_type sampler_type
Definition rendering.hpp:1445
TCommandQueue command_queue_type
Definition rendering.hpp:1436
factory_type::index_buffer_type index_buffer_type
Definition rendering.hpp:1442
Describes a factory that creates objects for a GraphicsDevice.
Definition rendering.hpp:1254
TVertexBuffer vertex_buffer_type
Definition rendering.hpp:1265
vertex_buffer_type::vertex_buffer_layout_type vertex_buffer_layout_type
Definition rendering.hpp:1266
virtual UniquePtr< TBLAS > createBottomLevelAccelerationStructure(StringView name, AccelerationStructureFlags flags) const =0
TTLAS top_level_acceleration_structure_type
Definition rendering.hpp:1273
GraphicsFactory() noexcept=default
virtual UniquePtr< TTLAS > createTopLevelAccelerationStructure(StringView name, AccelerationStructureFlags flags) const =0
TIndexBuffer index_buffer_type
Definition rendering.hpp:1267
TImage image_type
Definition rendering.hpp:1270
TSampler sampler_type
Definition rendering.hpp:1271
index_buffer_type::index_buffer_layout_type index_buffer_layout_type
Definition rendering.hpp:1268
TDescriptorLayout descriptor_layout_type
Definition rendering.hpp:1264
TBLAS bottom_level_acceleration_structure_type
Definition rendering.hpp:1272
TBuffer buffer_type
Definition rendering.hpp:1269
UniquePtr< TTLAS > createTopLevelAccelerationStructure(AccelerationStructureFlags flags) const
Definition rendering.hpp:1331
Base interface for a ray tracing acceleration structure.
Definition rendering_api.hpp:4449
The interface for a barrier.
Definition rendering_api.hpp:5110
constexpr void transition(const IBuffer &buffer, ResourceAccess accessBefore, ResourceAccess accessAfter)
Inserts a buffer barrier that blocks access to buffer of types contained in accessAfter for subsequ...
Definition rendering_api.hpp:5149
A structure that holds a singular entity of geometry for hardware ray-tracing.
Definition rendering_api.hpp:4588
Base interface for buffer objects.
Definition rendering_api.hpp:4186
The interface for a command buffer.
Definition rendering_api.hpp:6517
void barrier(const IBarrier &barrier) const noexcept
Executes the transitions that have been added to barrier .
Definition rendering_api.hpp:6620
void bind(const IDescriptorSet &descriptorSet) const
Binds the provided descriptor to the last pipeline that was used by the command buffer.
Definition rendering_api.hpp:6957
void pushConstants(const IPushConstantsLayout &layout, const void *const memory) const
Pushes a block of memory into the push constants backing memory.
Definition rendering_api.hpp:7317
void transfer(const IBuffer &source, const IBuffer &target, UInt32 sourceElement=0, UInt32 targetElement=0, UInt32 elements=1) const
Performs a buffer-to-buffer transfer from source to target .
Definition rendering_api.hpp:6638
virtual void drawIndexed(UInt32 indices, UInt32 instances=1, UInt32 firstIndex=0, Int32 vertexOffset=0, UInt32 firstInstance=0) const noexcept=0
Draws the currently bound vertex buffer with a set of indices from the currently bound index buffer.
virtual void dispatchMesh(const Vector3u &threadGroupCount) const noexcept=0
Executes a mesh shader pipeline.
void updateAccelerationStructure(IBottomLevelAccelerationStructure &blas, const SharedPtr< const IBuffer > &scratchBuffer, const IBuffer &buffer, UInt64 offset=0) const
Updates a bottom-level acceleration structure.
Definition rendering_api.hpp:7433
void use(const IPipeline &pipeline) const noexcept
Sets the active pipeline state.
Definition rendering_api.hpp:6947
SharedPtr< const ICommandQueue > queue() const noexcept
Gets a pointer to the command queue that this command buffer was allocated from or nullptr,...
Definition rendering_api.hpp:6597
void copyAccelerationStructure(const IBottomLevelAccelerationStructure &from, const IBottomLevelAccelerationStructure &to, bool compress=false) const noexcept
Copies the acceleration structure from into the acceleration structure to .
Definition rendering_api.hpp:7466
virtual void dispatch(const Vector3u &threadGroupCount) const noexcept=0
Executes a compute shader.
void drawIndexedIndirect(const IBuffer &batchBuffer, UInt32 batchCount, UInt64 offset=0) const noexcept
Executes a set of indirect indexed draw calls.
Definition rendering_api.hpp:7295
void dispatchIndirect(const IBuffer &batchBuffer, UInt32 batchCount, UInt64 offset=0) const noexcept
Executes a set of indirect dispatches.
Definition rendering_api.hpp:7114
void drawIndirect(const IBuffer &batchBuffer, UInt32 batchCount, UInt64 offset=0) const noexcept
Executes a set of indirect non-indexed draw calls.
Definition rendering_api.hpp:7229
void buildAccelerationStructure(IBottomLevelAccelerationStructure &blas, const SharedPtr< const IBuffer > &scratchBuffer, const IBuffer &buffer, UInt64 offset=0) const
Builds a bottom-level acceleration structure.
Definition rendering_api.hpp:7401
virtual void draw(UInt32 vertices, UInt32 instances=1, UInt32 firstVertex=0, UInt32 firstInstance=0) const noexcept=0
Draws a number of vertices from the currently bound vertex buffer.
The interface for a command queue.
Definition rendering_api.hpp:8481
UInt64 submit(const SharedPtr< const ICommandBuffer > &commandBuffer) const
Submits a single command buffer with shared ownership and inserts a fence to wait for it.
Definition rendering_api.hpp:8635
The interface for a compute pipeline.
Definition rendering_api.hpp:7611
The interface for a descriptor set.
Definition rendering_api.hpp:5253
void update(UInt32 binding, const IBuffer &buffer, UInt32 bufferElement=0, UInt32 elements=0, UInt32 firstDescriptor=0) const
Updates one or more buffer descriptors within the current descriptor set.
Definition rendering_api.hpp:5273
The interface for a descriptor set layout.
Definition rendering_api.hpp:5406
void free(const IDescriptorSet &descriptorSet) const
Marks a descriptor set as unused, so that it can be handed out again instead of allocating a new one.
Definition rendering_api.hpp:5625
The interface for a frame buffer.
Definition rendering_api.hpp:7709
auto addImage(this TSelf &&self, Format format, MultiSamplingLevel samples=MultiSamplingLevel::x1, ResourceUsage usage=ResourceUsage::FrameBufferImage) -> TSelf &&
Adds an image to the frame buffer.
Definition rendering_api.hpp:7955
The interface for a graphics device that.
Definition rendering_api.hpp:9164
The interface for a graphics factory.
Definition rendering_api.hpp:8716
SharedPtr< IIndexBuffer > createIndexBuffer(const IIndexBufferLayout &layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage=ResourceUsage::Default) const
Creates an index buffer, based on the layout .
Definition rendering_api.hpp:8921
Generator< SharedPtr< IImage > > createTextures(Format format, const Size3d &size, ImageDimensions dimension=ImageDimensions::DIM_2, UInt32 layers=1, UInt32 levels=1, MultiSamplingLevel samples=MultiSamplingLevel::x1, ResourceUsage usage=ResourceUsage::Default) const
Creates a series of textures.
Definition rendering_api.hpp:8995
SharedPtr< IImage > createTexture(Format format, const Size3d &size, ImageDimensions dimension=ImageDimensions::DIM_2, UInt32 levels=1, UInt32 layers=1, MultiSamplingLevel samples=MultiSamplingLevel::x1, ResourceUsage usage=ResourceUsage::Default) const
Creates a texture.
Definition rendering_api.hpp:8959
SharedPtr< IVertexBuffer > createVertexBuffer(const IVertexBufferLayout &layout, ResourceHeap heap, UInt32 elements=1, ResourceUsage usage=ResourceUsage::Default) const
Creates a vertex buffer, based on the layout
Definition rendering_api.hpp:8886
Generator< SharedPtr< ISampler > > createSamplers(FilterMode magFilter=FilterMode::Nearest, FilterMode minFilter=FilterMode::Nearest, BorderMode borderU=BorderMode::Repeat, BorderMode borderV=BorderMode::Repeat, BorderMode borderW=BorderMode::Repeat, MipMapMode mipMapMode=MipMapMode::Nearest, Float mipMapBias=0.f, Float maxLod=std::numeric_limits< Float >::max(), Float minLod=0.f, Float anisotropy=0.f) const
Creates a series of texture samplers.
Definition rendering_api.hpp:9053
SharedPtr< ISampler > createSampler(FilterMode magFilter=FilterMode::Nearest, FilterMode minFilter=FilterMode::Nearest, BorderMode borderU=BorderMode::Repeat, BorderMode borderV=BorderMode::Repeat, BorderMode borderW=BorderMode::Repeat, MipMapMode mipMapMode=MipMapMode::Nearest, Float mipMapBias=0.f, Float maxLod=std::numeric_limits< Float >::max(), Float minLod=0.f, Float anisotropy=0.f) const
Creates a texture sampler.
Definition rendering_api.hpp:9014
SharedPtr< IBuffer > createBuffer(BufferType type, ResourceHeap heap, size_t elementSize, UInt32 elements=1, ResourceUsage usage=ResourceUsage::Default) const
Creates a buffer of type type .
Definition rendering_api.hpp:8737
Describes a generic image.
Definition rendering_api.hpp:4208
The interface for an index buffer.
Definition rendering_api.hpp:4425
Describes a index buffer layout.
Definition rendering_api.hpp:3952
The interface for an input assembler state.
Definition rendering_api.hpp:6431
The interface for a pipeline.
Definition rendering_api.hpp:6481
The interface for a pipeline layout.
Definition rendering_api.hpp:6385
The interface for a push constants layout.
Definition rendering_api.hpp:5693
Describes a range within a IPushConstantsLayout.
Definition rendering_api.hpp:5645
The interface for a ray tracing pipeline.
Definition rendering_api.hpp:7626
The interface to access a render backend.
Definition rendering_api.hpp:9358
The interface for a render pass.
Definition rendering_api.hpp:8065
The interface for a render pipeline.
Definition rendering_api.hpp:7541
Describes a texture sampler.
Definition rendering_api.hpp:4324
Represents a single shader module, i.e. a part of a IShaderProgram.
Definition rendering_api.hpp:2755
The interface for a shader program.
Definition rendering_api.hpp:6286
Interface for a swap chain.
Definition rendering_api.hpp:8250
A structure that stores the instance data for a IBottomLevelAccelerationStructure.
Definition rendering_api.hpp:4870
The interface for a vertex buffer.
Definition rendering_api.hpp:4403
Describes a vertex buffer layout.
Definition rendering_api.hpp:3929
Describes an index buffer.
Definition rendering.hpp:479
IndexBuffer() noexcept=default
TIndexBufferLayout index_buffer_layout_type
Definition rendering.hpp:481
Represents a the input assembler state of a RenderPipeline.
Definition rendering.hpp:506
TIndexBufferLayout index_buffer_layout_type
Definition rendering.hpp:509
InputAssembler() noexcept=default
TVertexBufferLayout vertex_buffer_layout_type
Definition rendering.hpp:508
Represents a pipeline state.
Definition rendering.hpp:547
Pipeline() noexcept=default
TShaderProgram shader_program_type
Definition rendering.hpp:549
TPipelineLayout pipeline_layout_type
Definition rendering.hpp:550
Represents a the layout of a RenderPipeline, ComputePipeline or RayTracingPipeline.
Definition rendering.hpp:418
PipelineLayout() noexcept=default
TPushConstantsLayout push_constants_layout_type
Definition rendering.hpp:421
const push_constants_layout_type * pushConstants() const noexcept override=0
Returns the push constants layout, or nullptr, if the pipeline does not use any push constants....
virtual const Array< SharedPtr< const descriptor_set_layout_type > > & descriptorSets() const =0
const descriptor_set_layout_type & descriptorSet(UInt32 space) const override=0
Returns the descriptor set layout for the descriptor set that is bound to the space provided by space...
TDescriptorSetLayout descriptor_set_layout_type
Definition rendering.hpp:420
Describes the layout of the pipelines push constant ranges.
Definition rendering.hpp:355
virtual const Array< UniquePtr< push_constants_range_type > > & ranges() const =0
TPushConstantsRange push_constants_range_type
Definition rendering.hpp:357
Represents a ray-tracing Pipeline.
Definition rendering.hpp:1020
descriptor_set_layout_type::descriptor_layout_type descriptor_layout_type
Definition rendering.hpp:1025
base_type::pipeline_layout_type::descriptor_set_layout_type descriptor_set_layout_type
Definition rendering.hpp:1023
descriptor_set_type::image_type image_type
Definition rendering.hpp:1027
descriptor_set_type::sampler_type sampler_type
Definition rendering.hpp:1028
descriptor_set_layout_type::descriptor_set_type descriptor_set_type
Definition rendering.hpp:1024
descriptor_set_type::buffer_type buffer_type
Definition rendering.hpp:1026
Defines a back-end, that provides a device instance for a certain surface and graphics adapter.
Definition rendering.hpp:1642
device_type::render_pipeline_type render_pipeline_type
Definition rendering.hpp:1661
factory_type::sampler_type sampler_type
Definition rendering.hpp:1657
const device_type * operator[](const String &name) const noexcept override
Looks up a device and returns a pointer to it, or nullptr, if no device with the provided name could...
Definition rendering.hpp:1714
device_type::surface_type surface_type
Definition rendering.hpp:1645
factory_type::index_buffer_type index_buffer_type
Definition rendering.hpp:1654
device_type::barrier_type barrier_type
Definition rendering.hpp:1651
const device_type * device(const String &name) const noexcept override=0
Looks up a device and returns a pointer to it, or nullptr, if no device with the provided name could...
TGraphicsDevice device_type
Definition rendering.hpp:1644
device_type::input_assembler_type input_assembler_type
Definition rendering.hpp:1665
device_type::command_queue_type command_queue_type
Definition rendering.hpp:1648
device_type::factory_type factory_type
Definition rendering.hpp:1650
device_type * device(const String &name) noexcept override=0
Looks up a device and returns a pointer to it, or nullptr, if no device with the provided name could...
factory_type::buffer_type buffer_type
Definition rendering.hpp:1655
device_type::compute_pipeline_type compute_pipeline_type
Definition rendering.hpp:1662
device_type::frame_buffer_type frame_buffer_type
Definition rendering.hpp:1658
virtual void releaseDevice(const String &name)=0
Destroys and removes a device from the backend.
factory_type::image_type image_type
Definition rendering.hpp:1656
device_type * operator[](const String &name) noexcept override
Looks up a device and returns a pointer to it, or nullptr, if no device with the provided name could...
Definition rendering.hpp:1719
device_type::render_pass_type render_pass_type
Definition rendering.hpp:1659
device_type::pipeline_layout_type pipeline_layout_type
Definition rendering.hpp:1660
device_type::swap_chain_type swap_chain_type
Definition rendering.hpp:1647
device_type::rasterizer_type rasterizer_type
Definition rendering.hpp:1666
RenderBackend() noexcept=default
device_type::shader_program_type shader_program_type
Definition rendering.hpp:1664
device_type::adapter_type adapter_type
Definition rendering.hpp:1646
factory_type::vertex_buffer_type vertex_buffer_type
Definition rendering.hpp:1653
factory_type::descriptor_layout_type descriptor_layout_type
Definition rendering.hpp:1652
device_type::command_buffer_type command_buffer_type
Definition rendering.hpp:1649
device_type::ray_tracing_pipeline_type ray_tracing_pipeline_type
Definition rendering.hpp:1663
Represents a render pass.
Definition rendering.hpp:1150
TCommandQueue command_queue_type
Definition rendering.hpp:1152
TCommandQueue::command_buffer_type command_buffer_type
Definition rendering.hpp:1153
RenderPass() noexcept=default
TFrameBuffer frame_buffer_type
Definition rendering.hpp:1154
Represents a graphics Pipeline.
Definition rendering.hpp:962
TInputAssembler input_assembler_type
Definition rendering.hpp:964
RenderPipeline() noexcept=default
TRasterizer rasterizer_type
Definition rendering.hpp:965
Represents a shader program, consisting of multiple IShaderModules.
Definition rendering.hpp:386
ShaderProgram() noexcept=default
TShaderModule shader_module_type
Definition rendering.hpp:388
virtual const Array< UniquePtr< const shader_module_type > > & modules() const noexcept=0
Stores a set of IShaderRecords in that later form a shader binding table used for ray-tracing.
Definition rendering_api.hpp:6007
Base class for a resource that can be identified by a name string within a DeviceState.
Definition rendering_api.hpp:2265
Represents a swap chain, i.e. a chain of multiple IImage instances, that can be presented to a ISurfa...
Definition rendering.hpp:1210
SwapChain() noexcept=default
TImageInterface image_interface_type
Definition rendering.hpp:1212
Describes a vertex buffer.
Definition rendering.hpp:455
const vertex_buffer_layout_type & layout() const noexcept override=0
Gets the layout of the vertex buffer.The layout of the vertex buffer.
VertexBuffer() noexcept=default
TVertexBufferLayout vertex_buffer_layout_type
Definition rendering.hpp:457
Checks if a type TDerived is derived from another type TBase and is non-abstract.
Definition traits.hpp:118
Definition math.hpp:30
uint64_t UInt64
A type for an unsigned 64 bit integer.
Definition math.hpp:66
float_t Float
A type for a floating point value with single precision.
Definition math.hpp:71
uint32_t UInt32
A type for an unsigned 32 bit integer.
Definition math.hpp:56
int32_t Int32
A type for a signed 32 bit integer.
Definition math.hpp:51
Definition dx12.hpp:11
BorderMode
Describes how to treat texture coordinates that are outside the domain [0..1].
Definition rendering_api.hpp:1184
@ Repeat
Repeat the texture.
ImageLayout
Specifies the layout of an IImage resource.
Definition rendering_api.hpp:1686
MipMapMode
Describes the filter operation between two mip-map levels.
Definition rendering_api.hpp:1169
ShaderBindingGroup
Describes a group or combination of groups of a shader binding table.
Definition rendering_api.hpp:939
@ All
Refers to a combination of all possible groups that can be stored in a shader binding table.
BufferType
Describes the type of a IBuffer.
Definition rendering_api.hpp:540
ResourceUsage
Describes the intended usage for a resource.
Definition rendering_api.hpp:690
@ Default
Shortcut for commonly used TransferSource | TransferDestination combination.
ImageDimensions
Describes the dimensions of a image resource, i.e. the dimensions that are required to access a texel...
Definition rendering_api.hpp:1086
@ DIM_2
Represents a 2D image.
QueuePriority
Specifies the priority with which a queue is scheduled on the GPU.
Definition rendering_api.hpp:159
@ Normal
The default queue priority.
QueueType
Represents the type of a CommandQueue.
Definition rendering_api.hpp:113
ResourceHeap
Defines where a resource (buffer or image) memory is located and from where it can be accessed.
Definition rendering_api.hpp:649
AccelerationStructureFlags
Controls how an acceleration structure should be built.
Definition rendering_api.hpp:1816
FilterMode
Describes the filter operation when accessing a pixel from a texture coordinate.
Definition rendering_api.hpp:1152
@ Nearest
Take the nearest texel with respect to the texture coordinate.
PipelineStage
Defines pipeline stages as points where synchronization may occur.
Definition rendering_api.hpp:1373
ResourceAccess
Defines how a IBuffer or IImage resource is accessed.
Definition rendering_api.hpp:1537
Format
Describes a texel format.
Definition rendering_api.hpp:182
MultiSamplingLevel
Describes the number of samples with which a IImage is sampled.
Definition rendering_api.hpp:1111
@ x1
The default number of samples. Multi-sampling will be deactivated, if this sampling level is used.
Definition app.hpp:6
std::generator< T, TVal > Generator
Describes an intermediate container for elements of type T .
Definition containers.hpp:206
std::vector< T > Array
Represents a dynamic array.
Definition containers.hpp:73
std::optional< T > Optional
Represents an optional value.
Definition containers.hpp:94
std::shared_ptr< T > SharedPtr
Represents a shared pointer, that expresses non-exclusive ownership.
Definition containers.hpp:109
std::unique_ptr< T, TDeleter > UniquePtr
Represents a unique pointer, that expresses exclusive ownership.
Definition containers.hpp:102
std::string String
Definition string.hpp:24
std::string_view StringView
Definition string.hpp:26
std::span< T > Span
Represents a view of an array.
Definition containers.hpp:87
An input range over another range, where the returned values of type T are covariants of the values ...
Definition containers.hpp:529
Describes a resource binding to a descriptor or descriptor set.
Definition rendering_api.hpp:5334
Describes the offsets and sizes of a shader group within a shader binding table buffer.
Definition rendering_api.hpp:3646