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
95
97 uint32_t location; // Index into shader input
98 uint32_t offset; // In bytes
99 RHIResourceFormat format{ RHIResourceFormat::Undefined }; // Format on the GPU
100 uint32_t binding = 0; // 0-indexed index into bindings
101 };
102
104 // The command pool is persistent, meaning command buffers can be reused
106 // The command pool is meant to be used once
107 Transient,
108 };
110 Undefined = ~0u,
111 Graphics = 0,
112 Compute = 1,
113 Transfer = 2,
114 Present = 3
115 };
123
125 Graphics = 1u << 0,
126 Compute = 1u << 1,
127 Transfer = 1u << 2,
141
147
148 enum class RHITextureLayout {
149 Undefined,
150 General,
153 Present,
157 };
158
160 {
163 };
164
166 {
167 Build,
168 Update
169 };
170
172 {
173 Triangles,
175 };
176
178 Invisible,
179 ReadWrite, // r/w are possible
180 WriteOnly // write only, reads are undefined
181 };
182
191
200
205 E1D, E2D, E3D,
207 };
208
210 // Vertex Shader
211 Vertex = 1 << 0,
212 // Fragment Shader (aka Pixel)
213 Fragment = 1 << 1,
214 // Compute Shader
215 Compute = 1 << 2,
216 // Ray Tracing Ray Generation
218 // Ray Tracing Ray Any Hit
219 RayAnyHit = 1 << 4,
220 // Ray Tracing Ray Closest Hit
222 // Ray Tracing Ray Miss
223 RayMiss = 1 << 6,
224 // Ray Tracing Ray Intersection
226 // Mesh Shading (aka Amplification)
227 Task = 1 << 8,
228 // Mesh Shading
229 Mesh = 1 << 9,
230 All = ~0u
232
234 case Vertex: return "Vertex Shader";
235 case Fragment: return "Fragment Shader";
236 case Compute: return "Compute Shader";
242 case Task: return "Task Shader";
243 case Mesh: return "Mesh Shader";
245
252 TransferRead = 1 << 5,
253 ShaderWrite = 1 << 6,
254 ShaderRead = 1 << 7,
255 UniformRead = 1 << 8,
256 HostWrite = 1 << 9,
257 HostRead = 1 << 10,
261
262 // https://gpuopen.com/learn/vulkan-barriers-explained/
263 // https://docs.vulkan.org/spec/latest/chapters/synchronization.html#synchronization-pipeline-barriers
265 DrawIndirect = 1 << 1,
266 VertexShader = 1 << 2,
270 MeshShader = 1 << 6,
271 TaskShader = 1 << 7,
273 Transfer = 1 << 9,
277 // ---
278 Host = 1 << 27,
279 AllGraphics = 1 << 28,
280 TopOfPipe = 1 << 29,
281 BottomOfPipe = 1 << 30,
283
285 VertexBuffer = 1 << 0,
286 IndexBuffer = 1 << 1,
287 // i.e. Uniform Buffer
289 // i.e. Structured Buffer
299
301 RenderTarget = 1 << 0,
302 DepthStencil = 1 << 1,
303 SampledImage = 1 << 2,
304 StorageImage = 1 << 3,
305 TransferSource = 1 << 4,
306 TransferDestination = 1 << 5
308
310 Color = 1 << 0,
311 Depth = 1 << 1,
312 Stencil = 1 << 2
314
316 AllowUpdate = 1 << 0,
320 LowMemory = 1 << 4
322
324 TriangleCullDisable = 1 << 0,
326}
#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
DeviceAddress
Definition Common.hpp:294
MeshShader
Definition Common.hpp:270
RayTracingShader
Definition Common.hpp:269
glm::vec< 2, int32_t > RHIOffset2D
Definition Common.hpp:13
RHIAccelerationStructureBuildOp
Definition Common.hpp:166
IndexBuffer
Definition Common.hpp:286
AccelerationStructureBuildReadOnly
Definition Common.hpp:296
FragmentShader
Definition Common.hpp:267
glm::vec< 3, int32_t > RHIOffset3D
Definition Common.hpp:14
PreferFastBuild
Definition Common.hpp:319
RHITextureLayout
Definition Common.hpp:148
Task
Definition Common.hpp:227
Depth
Definition Common.hpp:311
UniformRead
Definition Common.hpp:255
VertexShader
Definition Common.hpp:266
RayGeneration
Definition Common.hpp:217
ShaderBindingTable
Definition Common.hpp:297
TopOfPipe
Definition Common.hpp:280
Present
Definition Common.hpp:128
RenderTargetOutput
Definition Common.hpp:272
All
Definition Common.hpp:230
Compute
Definition Common.hpp:126
Host
Definition Common.hpp:278
RenderTargetRead
Definition Common.hpp:248
ComputeShader
Definition Common.hpp:268
AccelerationBuild
Definition Common.hpp:276
RHIDeviceHeapType
Definition Common.hpp:142
RHIAccelerationStructureType
Definition Common.hpp:160
Color
Definition Common.hpp:310
glm::vec< 4, float > RHIClearColor
Definition Common.hpp:16
glm::vec< 3, uint32_t > RHIExtent3D
Definition Common.hpp:11
EarlyFragmentTests
Definition Common.hpp:274
TransferRead
Definition Common.hpp:252
AccelerationStructureWrite
Definition Common.hpp:259
TransferSource
Definition Common.hpp:292
UniformBuffer
Definition Common.hpp:288
AccelerationStructureRead
Definition Common.hpp:258
AccelerationStructureStorage
Definition Common.hpp:295
ShaderRead
Definition Common.hpp:254
RHIDeviceQueueType
Definition Common.hpp:109
RHIAccelerationGeometryType
Definition Common.hpp:172
TaskShader
Definition Common.hpp:271
VertexBuffer
Definition Common.hpp:285
HostRead
Definition Common.hpp:257
StorageBuffer
Definition Common.hpp:290
DepthStencil
Definition Common.hpp:302
AllowCompaction
Definition Common.hpp:317
Pair< float, uint32_t > RHIClearDepthStencil
Definition Common.hpp:18
Transfer
Definition Common.hpp:127
RHITextureDimension
Definition Common.hpp:204
RayAnyHit
Definition Common.hpp:219
RHIDescriptorType
Definition Common.hpp:183
LateFragmentTests
Definition Common.hpp:275
RayClosestHit
Definition Common.hpp:221
HostWrite
Definition Common.hpp:256
PreferFastTrace
Definition Common.hpp:318
RHIResourceFormat
Definition Common.hpp:20
static constexpr size_t kFullSize
Definition Common.hpp:8
AllowUpdate
Definition Common.hpp:316
BottomOfPipe
Definition Common.hpp:281
RenderTargetWrite
Definition Common.hpp:247
DepthStencilWrite
Definition Common.hpp:249
Mesh
Definition Common.hpp:229
glm::vec< 1, uint32_t > RHIExtent1D
Definition Common.hpp:9
RHICommandPoolType
Definition Common.hpp:103
Stencil
Definition Common.hpp:312
TransferDestination
Definition Common.hpp:293
ShaderWrite
Definition Common.hpp:253
TransferWrite
Definition Common.hpp:251
RayMiss
Definition Common.hpp:223
RHIMultisampleCount
Definition Common.hpp:201
DepthStencilRead
Definition Common.hpp:250
RHIResourceHostAccess
Definition Common.hpp:177
SampledImage
Definition Common.hpp:303
Graphics
Definition Common.hpp:125
glm::vec< 2, uint32_t > RHIExtent2D
Definition Common.hpp:10
Fragment
Definition Common.hpp:213
DrawIndirect
Definition Common.hpp:265
IndirectBuffer
Definition Common.hpp:291
glm::vec< 1, int32_t > RHIOffset1D
Definition Common.hpp:12
RenderTarget
Definition Common.hpp:301
StorageImage
Definition Common.hpp:304
Vertex
Definition Common.hpp:211
AllGraphics
Definition Common.hpp:279
LowMemory
Definition Common.hpp:320
RayIntersection
Definition Common.hpp:225
Definition Common.hpp:96
uint32_t location
Definition Common.hpp:97
uint32_t offset
Definition Common.hpp:98