Foundation
Loading...
Searching...
No Matches
Common.hpp
Go to the documentation of this file.
1#pragma once
2#include <Bits/Enums.hpp>
3#include <Math/Math.hpp>
4#include "Details.hpp"
5
6namespace Foundation::RHI {
7 using namespace Core;
8 constexpr static size_t kFullSize = -1;
9 using RHIExtent1D = glm::vec<1, uint32_t>;
10 using RHIExtent2D = glm::vec<2, uint32_t>;
11 using RHIExtent3D = glm::vec<3, uint32_t>;
12 using RHIOffset1D = glm::vec<1, int32_t>;
13 using RHIOffset2D = glm::vec<2, int32_t>;
14 using RHIOffset3D = glm::vec<3, int32_t>;
15 // [RGBA]
16 using RHIClearColor = glm::vec<4, float>;
17 // [Depth Clear Value, Stencil Clear Value]
19
55
57 uint32_t location; // Index into shader input
58 uint32_t offset; // In bytes
59 RHIResourceFormat format{ RHIResourceFormat::Undefined }; // Format on the GPU
60 uint32_t binding = 0; // 0-indexed index into bindings
61 };
62
63 enum class RHICommandPoolType {
64 // The command pool is persistent, meaning command buffers can be reused
66 // The command pool is meant to be used once
68 };
69 enum class RHIDeviceQueueType {
72 Compute,
75 };
83
92
98
99 enum class RHITextureLayout {
100 Undefined,
101 General,
104 Present,
108 };
109
111 Invisible,
112 ReadWrite, // r/w are possible
113 WriteOnly // write only, reads are undefined
114 };
115
123
131
136 E1D, E2D, E3D
137 };
138
140 // Vertex Shader
141 Vertex = 1 << 0,
142 // Fragment Shader (aka Pixel)
143 Fragment = 1 << 1,
144 // Compute Shader
145 Compute = 1 << 2,
146 // Ray Tracing Ray Generation
148 // Ray Tracing Ray Any Hit
149 RayAnyHit = 1 << 4,
150 // Ray Tracing Ray Closest Hit
152 // Ray Tracing Ray Miss
153 RayMiss = 1 << 6,
154 // Ray Tracing Ray Intersection
156 // Mesh Shading (aka Amplification)
157 Task = 1 << 8,
158 // Mesh Shading
159 Mesh = 1 << 9,
160 All = ~0u
162
164 case Vertex: return "Vertex Shader";
165 case Fragment: return "Fragment Shader";
166 case Compute: return "Compute Shader";
172 case Task: return "Task Shader";
173 case Mesh: return "Mesh Shader";
175
182 TransferRead = 1 << 5,
183 ShaderWrite = 1 << 6,
184 ShaderRead = 1 << 7,
185 UniformRead = 1 << 8,
186 HostWrite = 1 << 9,
187 HostRead = 1 << 10
189
190 // https://gpuopen.com/learn/vulkan-barriers-explained/
191 // https://docs.vulkan.org/spec/latest/chapters/synchronization.html#synchronization-pipeline-barriers
193 DrawIndirect = 1 << 1,
194 VertexShader = 1 << 2,
198 MeshShader = 1 << 6,
199 TaskShader = 1 << 7,
201 Transfer = 1 << 9,
204 // ---
205 Host = 1 << 27,
206 AllGraphics = 1 << 28,
207 TopOfPipe = 1 << 29,
208 BottomOfPipe = 1 << 30,
210
212 VertexBuffer = 1 << 0,
213 IndexBuffer = 1 << 1,
214 // i.e. Uniform Buffer
216 // i.e. Structured Buffer
222
224 RenderTarget = 1 << 0,
225 DepthStencil = 1 << 1,
226 SampledImage = 1 << 2,
227 StorageImage = 1 << 3,
228 TransferSource = 1 << 4,
229 TransferDestination = 1 << 5
231
233 Color = 1 << 0,
234 Depth = 1 << 1,
235 Stencil = 1 << 2
237}
#define ENUM_NAME_CONV_BEGIN(T)
Defines convince to_string() method and format_as() [fmt] for the respective enum class Example usage...
Definition Enums.hpp:84
#define BITMASK_ENUM_BEGIN(T, INT_T)
Defines a bitmask enum type {T}Bits with underlying integer type INT_T whilst defining a wrapper clas...
Definition Enums.hpp:49
#define ENUM_NAME(E)
Definition Enums.hpp:95
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
MeshShader
Definition Common.hpp:198
RayTracingShader
Definition Common.hpp:197
glm::vec< 2, int32_t > RHIOffset2D
Definition Common.hpp:13
IndexBuffer
Definition Common.hpp:213
FragmentShader
Definition Common.hpp:195
glm::vec< 3, int32_t > RHIOffset3D
Definition Common.hpp:14
RHIDevicePipelineType
Definition Common.hpp:84
RHITextureLayout
Definition Common.hpp:99
Task
Definition Common.hpp:157
Depth
Definition Common.hpp:234
UniformRead
Definition Common.hpp:185
VertexShader
Definition Common.hpp:194
RayGeneration
Definition Common.hpp:147
TopOfPipe
Definition Common.hpp:207
RenderTargetOutput
Definition Common.hpp:200
All
Definition Common.hpp:160
Compute
Definition Common.hpp:145
Host
Definition Common.hpp:205
RenderTargetRead
Definition Common.hpp:178
ComputeShader
Definition Common.hpp:196
RHIDeviceHeapType
Definition Common.hpp:93
Color
Definition Common.hpp:233
glm::vec< 4, float > RHIClearColor
Definition Common.hpp:16
glm::vec< 3, uint32_t > RHIExtent3D
Definition Common.hpp:11
EarlyFragmentTests
Definition Common.hpp:202
TransferRead
Definition Common.hpp:182
TransferSource
Definition Common.hpp:219
UniformBuffer
Definition Common.hpp:215
ShaderRead
Definition Common.hpp:184
TaskShader
Definition Common.hpp:199
VertexBuffer
Definition Common.hpp:212
HostRead
Definition Common.hpp:187
StorageBuffer
Definition Common.hpp:217
DepthStencil
Definition Common.hpp:225
Pair< float, uint32_t > RHIClearDepthStencil
Definition Common.hpp:18
Transfer
Definition Common.hpp:201
RHITextureDimension
Definition Common.hpp:135
RayAnyHit
Definition Common.hpp:149
RHIDescriptorType
Definition Common.hpp:116
LateFragmentTests
Definition Common.hpp:203
RayClosestHit
Definition Common.hpp:151
RHIDeviceQueueType
Definition Common.hpp:69
HostWrite
Definition Common.hpp:186
RHIResourceFormat
Definition Common.hpp:20
static constexpr size_t kFullSize
Definition Common.hpp:8
BottomOfPipe
Definition Common.hpp:208
RenderTargetWrite
Definition Common.hpp:177
DepthStencilWrite
Definition Common.hpp:179
Mesh
Definition Common.hpp:159
glm::vec< 1, uint32_t > RHIExtent1D
Definition Common.hpp:9
RHICommandPoolType
Definition Common.hpp:63
Stencil
Definition Common.hpp:235
TransferDestination
Definition Common.hpp:220
ShaderWrite
Definition Common.hpp:183
TransferWrite
Definition Common.hpp:181
RayMiss
Definition Common.hpp:153
RHIMultisampleCount
Definition Common.hpp:132
DepthStencilRead
Definition Common.hpp:180
RHIResourceHostAccess
Definition Common.hpp:110
SampledImage
Definition Common.hpp:226
glm::vec< 2, uint32_t > RHIExtent2D
Definition Common.hpp:10
Fragment
Definition Common.hpp:143
DrawIndirect
Definition Common.hpp:193
IndirectBuffer
Definition Common.hpp:218
glm::vec< 1, int32_t > RHIOffset1D
Definition Common.hpp:12
RenderTarget
Definition Common.hpp:224
StorageImage
Definition Common.hpp:227
Vertex
Definition Common.hpp:141
AllGraphics
Definition Common.hpp:206
RayIntersection
Definition Common.hpp:155
Definition Common.hpp:56
uint32_t location
Definition Common.hpp:57
uint32_t offset
Definition Common.hpp:58