Foundation
Loading...
Searching...
No Matches
Common.hpp
Go to the documentation of this file.
1#pragma once
2#include <Core/Container.hpp>
3#include <Core/Enums.hpp>
4#include <Math/Math.hpp>
5#include "Details.hpp"
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
93
95 uint32_t location; // Index into shader input
96 uint32_t offset; // In bytes
97 RHIResourceFormat format{ RHIResourceFormat::Undefined }; // Format on the GPU
98 uint32_t binding = 0; // 0-indexed index into bindings
99 };
100
102 // The command pool is persistent, meaning command buffers can be reused
104 // The command pool is meant to be used once
105 Transient,
106 };
108 Undefined = ~0u,
109 Graphics = 0,
110 Compute = 1,
111 Transfer = 2,
112 Present = 3
113 };
121
123 Graphics = 1u << 0,
124 Compute = 1u << 1,
125 Transfer = 1u << 2,
126 Present = 1u << 3
128
130 Graphics,
131 Compute,
132 };
137
143
144 enum class RHITextureLayout {
145 Undefined,
146 General,
149 Present,
153 };
154
156 {
159 };
160
162 {
163 Triangles,
165 };
166
168 Invisible,
169 ReadWrite, // r/w are possible
170 WriteOnly // write only, reads are undefined
171 };
172
180
188
193 E1D, E2D, E3D
194 };
195
197 // Vertex Shader
198 Vertex = 1 << 0,
199 // Fragment Shader (aka Pixel)
200 Fragment = 1 << 1,
201 // Compute Shader
202 Compute = 1 << 2,
203 // Ray Tracing Ray Generation
205 // Ray Tracing Ray Any Hit
206 RayAnyHit = 1 << 4,
207 // Ray Tracing Ray Closest Hit
209 // Ray Tracing Ray Miss
210 RayMiss = 1 << 6,
211 // Ray Tracing Ray Intersection
213 // Mesh Shading (aka Amplification)
214 Task = 1 << 8,
215 // Mesh Shading
216 Mesh = 1 << 9,
217 All = ~0u
219
221 case Vertex: return "Vertex Shader";
222 case Fragment: return "Fragment Shader";
223 case Compute: return "Compute Shader";
229 case Task: return "Task Shader";
230 case Mesh: return "Mesh Shader";
232
239 TransferRead = 1 << 5,
240 ShaderWrite = 1 << 6,
241 ShaderRead = 1 << 7,
242 UniformRead = 1 << 8,
243 HostWrite = 1 << 9,
244 HostRead = 1 << 10
246
247 // https://gpuopen.com/learn/vulkan-barriers-explained/
248 // https://docs.vulkan.org/spec/latest/chapters/synchronization.html#synchronization-pipeline-barriers
250 DrawIndirect = 1 << 1,
251 VertexShader = 1 << 2,
255 MeshShader = 1 << 6,
256 TaskShader = 1 << 7,
258 Transfer = 1 << 9,
261 // ---
262 Host = 1 << 27,
263 AllGraphics = 1 << 28,
264 TopOfPipe = 1 << 29,
265 BottomOfPipe = 1 << 30,
267
269 VertexBuffer = 1 << 0,
270 IndexBuffer = 1 << 1,
271 // i.e. Uniform Buffer
273 // i.e. Structured Buffer
279
281 RenderTarget = 1 << 0,
282 DepthStencil = 1 << 1,
283 SampledImage = 1 << 2,
284 StorageImage = 1 << 3,
285 TransferSource = 1 << 4,
286 TransferDestination = 1 << 5
288
290 Color = 1 << 0,
291 Depth = 1 << 1,
292 Stencil = 1 << 2
294}
#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:82
#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:47
#define ENUM_NAME(E)
Definition Enums.hpp:93
std::pair< First, Second > Pair
Alias for std::pair
Definition Container.hpp:32
T * Construct(Allocator *resource, Args &&...args)
Convenience placement new with object of type T using a Foundation::Core::Allocator.
Definition Allocator.hpp:149
Low-level Rendering Hardware Interface (RHI) abstractions.
Definition Application.hpp:4
MeshShader
Definition Common.hpp:255
RayTracingShader
Definition Common.hpp:254
glm::vec< 2, int32_t > RHIOffset2D
Definition Common.hpp:13
IndexBuffer
Definition Common.hpp:270
FragmentShader
Definition Common.hpp:252
glm::vec< 3, int32_t > RHIOffset3D
Definition Common.hpp:14
RHITextureLayout
Definition Common.hpp:144
Task
Definition Common.hpp:214
Depth
Definition Common.hpp:291
UniformRead
Definition Common.hpp:242
VertexShader
Definition Common.hpp:251
RayGeneration
Definition Common.hpp:204
TopOfPipe
Definition Common.hpp:264
Present
Definition Common.hpp:126
RenderTargetOutput
Definition Common.hpp:257
All
Definition Common.hpp:217
Compute
Definition Common.hpp:124
Host
Definition Common.hpp:262
RenderTargetRead
Definition Common.hpp:235
ComputeShader
Definition Common.hpp:253
RHIDeviceHeapType
Definition Common.hpp:138
RHIAccelerationStructureType
Definition Common.hpp:156
Color
Definition Common.hpp:290
glm::vec< 4, float > RHIClearColor
Definition Common.hpp:16
glm::vec< 3, uint32_t > RHIExtent3D
Definition Common.hpp:11
EarlyFragmentTests
Definition Common.hpp:259
TransferRead
Definition Common.hpp:239
TransferSource
Definition Common.hpp:276
UniformBuffer
Definition Common.hpp:272
ShaderRead
Definition Common.hpp:241
RHIDeviceQueueType
Definition Common.hpp:107
RHIAccelerationGeometryType
Definition Common.hpp:162
TaskShader
Definition Common.hpp:256
VertexBuffer
Definition Common.hpp:269
HostRead
Definition Common.hpp:244
StorageBuffer
Definition Common.hpp:274
DepthStencil
Definition Common.hpp:282
Pair< float, uint32_t > RHIClearDepthStencil
Definition Common.hpp:18
Transfer
Definition Common.hpp:125
RHITextureDimension
Definition Common.hpp:192
RayAnyHit
Definition Common.hpp:206
RHIDescriptorType
Definition Common.hpp:173
LateFragmentTests
Definition Common.hpp:260
RayClosestHit
Definition Common.hpp:208
HostWrite
Definition Common.hpp:243
RHIResourceFormat
Definition Common.hpp:20
static constexpr size_t kFullSize
Definition Common.hpp:8
BottomOfPipe
Definition Common.hpp:265
RenderTargetWrite
Definition Common.hpp:234
DepthStencilWrite
Definition Common.hpp:236
Mesh
Definition Common.hpp:216
glm::vec< 1, uint32_t > RHIExtent1D
Definition Common.hpp:9
RHICommandPoolType
Definition Common.hpp:101
Stencil
Definition Common.hpp:292
TransferDestination
Definition Common.hpp:277
ShaderWrite
Definition Common.hpp:240
TransferWrite
Definition Common.hpp:238
RayMiss
Definition Common.hpp:210
RHIMultisampleCount
Definition Common.hpp:189
DepthStencilRead
Definition Common.hpp:237
RHIResourceHostAccess
Definition Common.hpp:167
SampledImage
Definition Common.hpp:283
Graphics
Definition Common.hpp:123
glm::vec< 2, uint32_t > RHIExtent2D
Definition Common.hpp:10
Fragment
Definition Common.hpp:200
DrawIndirect
Definition Common.hpp:250
IndirectBuffer
Definition Common.hpp:275
glm::vec< 1, int32_t > RHIOffset1D
Definition Common.hpp:12
RenderTarget
Definition Common.hpp:281
StorageImage
Definition Common.hpp:284
Vertex
Definition Common.hpp:198
AllGraphics
Definition Common.hpp:263
RayIntersection
Definition Common.hpp:212
Definition Common.hpp:94
uint32_t location
Definition Common.hpp:95
uint32_t offset
Definition Common.hpp:96