Foundation
Loading...
Searching...
No Matches
Descriptor.hpp
Go to the documentation of this file.
1#pragma once
2#include "Common.hpp"
3namespace Foundation::RHI {
4 class RHIBuffer;
5 class RHITextureView;
6 class RHIDeviceSampler;
7 class RHIDeviceDescriptorPool;
8 class RHIDeviceDescriptorSetLayout;
12 protected:
14 public:
16 struct UpdateDesc {
17 size_t binding{ 0 }; // 0-indexed, first to update in the descriptor set
18 size_t startIndex{ 0 }; // First index in the binding array to update
20 struct Buffer {
21 RHIBuffer* buffer{ nullptr }; // Buffer to bind
22 size_t offset{ 0 }; // Offset in bytes
23 size_t size{ kFullSize }; // Size in bytes
24 };
25 Span<const Buffer> buffers; // Applies to type of UniformBuffer, StorageBuffer
26 struct Image {
27 RHITextureView* imageView{ nullptr }; // Image view to bind, can be null
28 RHIDeviceSampler* sampler{ nullptr }; // Sampler to bind, can be null
29 RHITextureLayout layout{}; // Layout of the image
30 };
31 Span<const Image> images; // Applies to type of Sampler, SampledImage
32 };
33 // NOTE: `desc.type` is used to determine which of the next spans is used
34 // to update the descriptors.
35 // Implementations should guarantee that descriptor type updates within
36 // a single call is homogenous, and throw if type mismatches the spans given,
37 // or some spans are unused.
38 virtual void Update(UpdateDesc const& desc) = 0;
39
40 virtual void DebugSetObjectName(const char* name) = 0;
41 };
42 // XXX: Vulkanism. Not really a thing in other APIs.
44 protected:
46 public:
47 struct PoolDesc {
48 struct Binding {
49 RHIDescriptorType type; // Type of this binding
50 uint32_t maxCount{ 1 }; // Max number of descriptors of this type that can be allocated
51 };
52 // Bindings that make up this pool
54 // Allow updating descriptors after being bound to a command buffer when
55 // they are not used
56 bool updateAfterBind{ false };
57 } const mDesc;
59 : mDevice(device), mDesc(desc) {
60 }
64 virtual void DestroyDescriptorSet(Handle handle) = 0;
65
66 virtual void DebugSetObjectName(const char* name) = 0;
67 };
70 return pool->GetDescriptorSet(handle);
71 }
73 pool->DestroyDescriptorSet(handle);
74 }
75 };
76}
Definition Resource.hpp:30
Definition Descriptor.hpp:43
const RHIDevice & mDevice
Definition Descriptor.hpp:45
RHIDeviceDescriptorPool(RHIDevice const &device, PoolDesc const &desc)
Definition Descriptor.hpp:58
virtual void DestroyDescriptorSet(Handle handle)=0
virtual void DebugSetObjectName(const char *name)=0
virtual RHIDeviceDescriptorSet * GetDescriptorSet(Handle handle) const =0
virtual RHIDeviceDescriptorPoolScopedHandle< RHIDeviceDescriptorSet > CreateDescriptorSet(RHIDeviceObjectHandle< RHIDeviceDescriptorSetLayout >, uint32_t max_variable_count=0)=0
struct Foundation::RHI::RHIDeviceDescriptorPool::PoolDesc mDesc
Definition Descriptor.hpp:11
RHIDeviceDescriptorSet(RHIDeviceDescriptorPool const &pool)
Definition Descriptor.hpp:15
const RHIDeviceDescriptorPool & mPool
Definition Descriptor.hpp:13
virtual void Update(UpdateDesc const &desc)=0
virtual void DebugSetObjectName(const char *name)=0
Definition Device.hpp:88
Definition Device.hpp:131
Base class for all RHI objects.
Definition Details.hpp:16
Definition Resource.hpp:169
std::unique_ptr< T, StlDeleter< T > > UniquePtr
std::unique_ptr with custom deleter that uses a Foundation::Core::Allocator to deallocate memory.
Definition Allocator.hpp:161
Low-level Rendering Hardware Interface (RHI) abstractions.
Definition Application.hpp:5
RHIHandle< RHIDeviceDescriptorPool, T > RHIDeviceDescriptorPoolHandle
Definition Descriptor.hpp:9
RHITextureLayout
Definition Common.hpp:99
uint64_t Handle
Definition Details.hpp:9
RHIDescriptorType
Definition Common.hpp:116
static constexpr size_t kFullSize
Definition Common.hpp:8
RHIScopedHandle< RHIDeviceDescriptorPool, T > RHIDeviceDescriptorPoolScopedHandle
Definition Descriptor.hpp:10
RHIDescriptorType type
Definition Descriptor.hpp:49
Span< const Binding > bindings
Definition Descriptor.hpp:53
bool updateAfterBind
Definition Descriptor.hpp:56
RHIBuffer * buffer
Definition Descriptor.hpp:21
RHITextureLayout layout
Definition Descriptor.hpp:29
RHIDeviceSampler * sampler
Definition Descriptor.hpp:28
RHITextureView * imageView
Definition Descriptor.hpp:27
size_t startIndex
Definition Descriptor.hpp:18
RHIDescriptorType type
Definition Descriptor.hpp:19
Span< const Buffer > buffers
Definition Descriptor.hpp:25
size_t binding
Definition Descriptor.hpp:17
Span< const Image > images
Definition Descriptor.hpp:31
static void Destroy(RHIDeviceDescriptorPool *pool, Handle handle)
Definition Descriptor.hpp:72
static RHIDeviceDescriptorSet * Get(RHIDeviceDescriptorPool const *pool, Handle handle)
Definition Descriptor.hpp:69
Provides type traits for types derived from RHIObject.
Definition Details.hpp:30