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
22
33
113
115 {
116 switch (format)
117 {
125 return true;
126 default:
127 return false;
128 }
129 }
130
131 enum class RHIColorSpace {
135 };
141
145
146 bool operator==(const RHISurfaceFormat& other) const {
147 return format == other.format && colorSpace == other.colorSpace;
148 }
149 };
150
152 uint32_t location; // Index into shader input
153 uint32_t offset; // In bytes
155 uint32_t binding = 0; // 0-indexed index into bindings
156 };
157
159 // The command pool is persistent, meaning command buffers can be reused
161 // The command pool is meant to be used once
162 Transient,
163 };
165 Undefined = ~0u,
166 Graphics = 0,
167 Compute = 1,
168 Transfer = 2,
169 Present = 3
170 };
178
180 Graphics = 1u << 0,
181 Compute = 1u << 1,
182 Transfer = 1u << 2,
183 Present = 1u << 3
185
187 Graphics,
188 Compute,
190 };
196
202
203 enum class RHITextureLayout {
204 Undefined,
205 General,
208 Present,
212 };
213
215 {
218 };
219
221 {
222 Build,
223 Update
224 };
225
227 {
228 Triangles,
229 AABBs,
231 };
232
234 Invisible,
235 ReadWrite, // r/w are possible
236 WriteOnly // write only, reads are undefined
237 };
238
247
256
261 E1D, E2D, E3D,
263 };
264
266 // Vertex Shader
267 Vertex = 1 << 0,
268 // Fragment Shader (aka Pixel)
269 Fragment = 1 << 1,
270 // Compute Shader
271 Compute = 1 << 2,
272 // Ray Tracing Ray Generation
274 // Ray Tracing Ray Any Hit
275 RayAnyHit = 1 << 4,
276 // Ray Tracing Ray Closest Hit
278 // Ray Tracing Ray Miss
279 RayMiss = 1 << 6,
280 // Ray Tracing Ray Intersection
282 // Mesh Shading (aka Amplification)
283 Task = 1 << 8,
284 // Mesh Shading
285 Mesh = 1 << 9,
286 All = ~0u
288
290 case Vertex: return "Vertex Shader";
291 case Fragment: return "Fragment Shader";
292 case Compute: return "Compute Shader";
298 case Task: return "Task Shader";
299 case Mesh: return "Mesh Shader";
301
308 TransferRead = 1 << 5,
309 ShaderWrite = 1 << 6,
310 ShaderRead = 1 << 7,
311 UniformRead = 1 << 8,
312 HostWrite = 1 << 9,
313 HostRead = 1 << 10,
318
319 // https://gpuopen.com/learn/vulkan-barriers-explained/
320 // https://docs.vulkan.org/spec/latest/chapters/synchronization.html#synchronization-pipeline-barriers
322 DrawIndirect = 1 << 1,
323 VertexShader = 1 << 2,
327 MeshShader = 1 << 6,
328 TaskShader = 1 << 7,
330 Transfer = 1 << 9,
334 // ---
335 Host = 1 << 27,
336 AllGraphics = 1 << 28,
337 TopOfPipe = 1 << 29,
338 BottomOfPipe = 1 << 30,
340
342 VertexBuffer = 1 << 0,
343 IndexBuffer = 1 << 1,
344 // i.e. Uniform Buffer
346 // i.e. Structured Buffer
356
358 RenderTarget = 1 << 0,
359 DepthStencil = 1 << 1,
360 SampledImage = 1 << 2,
361 StorageImage = 1 << 3,
362 TransferSource = 1 << 4,
363 TransferDestination = 1 << 5
365
367 Color = 1 << 0,
368 Depth = 1 << 1,
369 Stencil = 1 << 2
371
373 AllowUpdate = 1 << 0,
377 LowMemory = 1 << 4
379
381 TriangleCullDisable = 1 << 0,
383}
#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:153
Low-level Rendering Hardware Interface (RHI) abstractions.
Definition Application.hpp:4
constexpr bool IsFormatSRGB(RHIResourceFormat format)
Definition Common.hpp:114
DeviceAddress
Definition Common.hpp:351
MeshShader
Definition Common.hpp:327
RayTracingShader
Definition Common.hpp:326
glm::vec< 2, int32_t > RHIOffset2D
Definition Common.hpp:13
RHIAccelerationStructureBuildOp
Definition Common.hpp:221
IndexBuffer
Definition Common.hpp:343
AccelerationStructureBuildReadOnly
Definition Common.hpp:353
FragmentShader
Definition Common.hpp:324
glm::vec< 3, int32_t > RHIOffset3D
Definition Common.hpp:14
PreferFastBuild
Definition Common.hpp:376
RHITextureLayout
Definition Common.hpp:203
Task
Definition Common.hpp:283
Depth
Definition Common.hpp:368
UniformRead
Definition Common.hpp:311
VertexShader
Definition Common.hpp:323
RayGeneration
Definition Common.hpp:273
RHIAttachmentLoadOp
Definition Common.hpp:20
ShaderBindingTable
Definition Common.hpp:354
TopOfPipe
Definition Common.hpp:337
Present
Definition Common.hpp:183
RenderTargetOutput
Definition Common.hpp:329
All
Definition Common.hpp:286
Compute
Definition Common.hpp:181
Host
Definition Common.hpp:335
RenderTargetRead
Definition Common.hpp:304
ComputeShader
Definition Common.hpp:325
AccelerationBuild
Definition Common.hpp:333
RHIDeviceHeapType
Definition Common.hpp:197
RHIAccelerationStructureType
Definition Common.hpp:215
Color
Definition Common.hpp:367
glm::vec< 4, float > RHIClearColor
Definition Common.hpp:16
glm::vec< 3, uint32_t > RHIExtent3D
Definition Common.hpp:11
EarlyFragmentTests
Definition Common.hpp:331
TransferRead
Definition Common.hpp:308
AccelerationStructureWrite
Definition Common.hpp:315
TransferSource
Definition Common.hpp:349
RHIColorSpace
Definition Common.hpp:131
UniformBuffer
Definition Common.hpp:345
AccelerationStructureRead
Definition Common.hpp:314
AccelerationStructureStorage
Definition Common.hpp:352
ShaderRead
Definition Common.hpp:310
RHIDeviceQueueType
Definition Common.hpp:164
RHIAccelerationGeometryType
Definition Common.hpp:227
TaskShader
Definition Common.hpp:328
VertexBuffer
Definition Common.hpp:342
HostRead
Definition Common.hpp:313
StorageBuffer
Definition Common.hpp:347
IndirectCommandRead
Definition Common.hpp:316
DepthStencil
Definition Common.hpp:359
AllowCompaction
Definition Common.hpp:374
Pair< float, uint32_t > RHIClearDepthStencil
Definition Common.hpp:18
Transfer
Definition Common.hpp:182
RHITextureDimension
Definition Common.hpp:260
RayAnyHit
Definition Common.hpp:275
RHIDescriptorType
Definition Common.hpp:239
LateFragmentTests
Definition Common.hpp:332
RayClosestHit
Definition Common.hpp:277
HostWrite
Definition Common.hpp:312
PreferFastTrace
Definition Common.hpp:375
RHIResourceFormat
Definition Common.hpp:34
static constexpr size_t kFullSize
Definition Common.hpp:8
AllowUpdate
Definition Common.hpp:373
BottomOfPipe
Definition Common.hpp:338
RenderTargetWrite
Definition Common.hpp:303
DepthStencilWrite
Definition Common.hpp:305
Mesh
Definition Common.hpp:285
glm::vec< 1, uint32_t > RHIExtent1D
Definition Common.hpp:9
RHICommandPoolType
Definition Common.hpp:158
Stencil
Definition Common.hpp:369
TransferDestination
Definition Common.hpp:350
ShaderWrite
Definition Common.hpp:309
TransferWrite
Definition Common.hpp:307
RayMiss
Definition Common.hpp:279
RHIMultisampleCount
Definition Common.hpp:257
DepthStencilRead
Definition Common.hpp:306
RHIResourceHostAccess
Definition Common.hpp:233
SampledImage
Definition Common.hpp:360
RHIAttachmentStoreOp
Definition Common.hpp:21
Graphics
Definition Common.hpp:180
glm::vec< 2, uint32_t > RHIExtent2D
Definition Common.hpp:10
Fragment
Definition Common.hpp:269
DrawIndirect
Definition Common.hpp:322
IndirectBuffer
Definition Common.hpp:348
glm::vec< 1, int32_t > RHIOffset1D
Definition Common.hpp:12
RenderTarget
Definition Common.hpp:358
StorageImage
Definition Common.hpp:361
Vertex
Definition Common.hpp:267
AllGraphics
Definition Common.hpp:336
LowMemory
Definition Common.hpp:377
RayIntersection
Definition Common.hpp:281
RHIClearColor clearColor
Definition Common.hpp:26
RHIAttachmentLoadOp loadOp
Definition Common.hpp:25
RHIAttachmentLoadOp loadOp
Definition Common.hpp:30
RHIClearDepthStencil clearValue
Definition Common.hpp:31
Definition Common.hpp:142
bool operator==(const RHISurfaceFormat &other) const
Definition Common.hpp:146
RHIResourceFormat format
Definition Common.hpp:143
RHIColorSpace colorSpace
Definition Common.hpp:144
Definition Common.hpp:151
uint32_t location
Definition Common.hpp:152
uint32_t offset
Definition Common.hpp:153
RHIResourceFormat format
Definition Common.hpp:154
uint32_t binding
Definition Common.hpp:155