CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
Reflection.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
11
14
15#include <limits>
16#include <ostream>
17
19
21 namespace Reflection {
62
65 enum class TextureAddressMode {
66 Wrap = 1,
67 Mirror = 2,
68 Clamp = 3,
69 Border = 4,
70 MirrorOnce = 5,
71 };
72
75 enum class ComparisonFunc {
76 Never = 1,
77 Less = 2,
78 Equal = 3,
79 LessEqual = 4,
80 Greater = 5,
81 NotEqual = 6,
82 GreaterEqual = 7,
83 Always = 8,
84 };
85
88 enum class FieldType {
91
93 Bool,
94
96 Int,
97
99 UInt,
100
102 Half,
103
105 Float,
106
108 Double,
109
111 Record,
112 };
113
116 enum class ResourceType {
118 Undefined,
119
121 Texture1D,
122
124 Texture2D,
125
127 Texture3D,
128
131
134
137
140
143
146
149
152
155
158
161
164
167
170
173
175 Sampler1D,
176
178 Sampler2D,
179
181 Sampler3D,
182
185
188
191
194
197
200
203
205 Buffer,
206
209
212
215
218
220 RWBuffer,
221
224
227
230
233
236
239 };
240
258
262 struct Attribute {
264 bool referenced = false;
265
268
271
273 Attribute() = default;
274
276 inline Attribute(const String& name, const Int32 slot) : name{name}, slot{slot} {}
277 };
278
294
327
330 struct Record {
332 bool referenced = false;
333
336
339
342
345
348 };
349
374
390
403
406 struct NumThreads {
408 Int32 x = 0;
409
411 Int32 y = 0;
412
414 Int32 z = 0;
415 };
416
450
451 } // namespace Reflection
452
455
458
461
464
471 void printReflection(std::ostream& stream, const Reflection::ReflectionData& reflectionData, bool referencedOnly = false);
472
473} // namespace CeresEngine::ShaderCompiler
ResourceType
Resource type enumeration.
Definition Reflection.hpp:116
@ RWStructuredBuffer
Structured read-write buffer: RWStructuredBuffer in HLSL, buffer in GLSL and VKSL.
@ TextureCube
Cube texture: TextureCube in HLSL, textureCube in GLSL (Vulkan only).
@ RWTexture2DMS
2D multi-sampled read-write texture: RWTexture2DMS in HLSL, image2DMS in GLSL.
@ Sampler2DMSArray
Combined 2D multi-sampled array texture-sampler: sampler2DMSArray in GLSL.
@ RWTexture2DArray
2D array read-write texture: RWTexture2DArray in HLSL, image2DArray in GLSL.
@ Sampler2DRect
Combined 2D texture-sampler with unnormalized texture coordinates: sampler2DRect in GLSL.
@ Sampler1DArray
Combined 1D array texture-sampler: sampler1DArray in GLSL.
@ SamplerCubeArray
Combined Cube array texture-sampler: samplerCubeArray in GLSL.
@ RWTexture1DArray
1D array read-write texture: RWTexture1DArray in HLSL, image1DArray in GLSL.
@ Sampler2DArray
Combined 2D array texture-sampler: sampler2DArray in GLSL.
@ AppendStructuredBuffer
Append structured buffer: AppendStructuredBuffer in HLSL, buffer in GLSL.
@ Texture2DArray
2D array texture: Texture2DArray in HLSL, texture2DArray in GLSL (Vulkan only).
@ RWTexture1D
1D read-write texture: RWTexture1D in HLSL, image1D in GLSL.
@ SamplerCube
Combined Cube texture-sampler: samplerCube in GLSL.
@ ByteAddressBuffer
Byte addressable buffer: ByteAddressBuffer in HLSL, samplerBuffer in GLSL.
@ Sampler1D
Combined 1D texture-sampler: sampler1D in GLSL.
@ SamplerComparisonState
Sampler comparison state: SamplerComparisonState in HLSL, sampler in GLSL (Vulkan only).
@ Sampler2D
Combined 2D texture-sampler: sampler2D in GLSL.
@ RWTexture2DMSArray
2D multi-sampled array read-write texture: RWTexture2DMSArray in HLSL, image2DMSArray in GLSL.
@ Texture2DMS
2D multi-sampled texture: Texture2DMS in HLSL, texture2DMS in GLSL (Vulkan only).
@ RWByteAddressBuffer
Byte addressable read-write buffer: RWByteAddressBuffer in HLSL, imageBuffer in GLSL.
@ Buffer
Vector buffer: Buffer in HLSL, samplerBuffer in GLSL.
@ Texture3D
3D texture: Texture3D in HLSL, texture3D in GLSL (Vulkan only).
@ RWTexture3D
3D read-write texture: RWTexture3D in HLSL, image3D in GLSL.
@ Texture1DArray
1D array texture: Texture1DArray in HLSL, texture1DArray in GLSL (Vulkan only).
@ ConsumeStructuredBuffer
Consume structured buffer: ConsumeStructuredBuffer in HLSL, buffer in GLSL.
@ RWBuffer
Vector read-write buffer: RWBuffer in HLSL, imageBuffer in GLSL.
@ RWTexture2D
2D read-write texture: RWTexture2D in HLSL, image2D in GLSL.
@ Texture2D
2D texture: Texture2D in HLSL, texture2D in GLSL (Vulkan only).
@ TextureCubeArray
Cube array texture: TextureCubeArray in HLSL, textureCubeArray in GLSL (Vulkan only).
@ StructuredBuffer
Structured buffer: StructuredBuffer in HLSL, buffer in GLSL and VKSL.
@ RWTextureCubeArray
Cube array read-write texture: RWTextureCubeArray in HLSL, imageCubeArray in GLSL.
@ Sampler2DMS
Combined 2D multi-sampled texture-sampler: sampler2DMS in GLSL.
@ Texture2DMSArray
2D multi-sampled array texture: Texture2DMSArray in HLSL, texture2DMSArray in GLSL (Vulkan only).
@ RWTextureCube
Cube read-write texture: RWTextureCube in HLSL, imageCube in GLSL.
@ Sampler3D
Combined 3D texture-sampler: sampler3D in GLSL.
@ Texture1D
1D texture: Texture1D in HLSL, texture1D in GLSL (Vulkan only).
@ TextureBuffer
Texture buffer: tbuffer in HLSL, samplerBuffer in GLSL.
TextureAddressMode
Texture address mode enumeration (compatible to D3D11_TEXTURE_ADDRESS_MODE).
Definition Reflection.hpp:65
ComparisonFunc
Sample comparison function enumeration (compatible to D3D11_COMPARISON_FUNC).
Definition Reflection.hpp:75
Filter
Sampler filter enumeration (compatible to D3D11_FILTER).
Definition Reflection.hpp:24
FieldType
Data field type enumeration.
Definition Reflection.hpp:88
@ Float
Single-precision floating-point type.
@ Half
Half-precision floating-point type.
@ Double
Double-precision floating-point type.
Definition AST.hpp:33
String toString(const CiString &s)
Definition CiString.hpp:20
void printReflection(std::ostream &stream, const Reflection::ReflectionData &reflectionData, bool referencedOnly=false)
Prints the reflection data into the output stream in a human readable format.
std::vector< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > Vector
Vector is a sequence container that encapsulates dynamic size arrays.
Definition Vector.hpp:17
std::int32_t Int32
Definition DataTypes.hpp:21
std::uint32_t UInt32
Definition DataTypes.hpp:23
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Input/output attribute and uniform reflection structure.
Definition Reflection.hpp:262
Int32 slot
Zero-based attribute slot number. If this is -1, the binding slot was not specified....
Definition Reflection.hpp:270
bool referenced
Specifies whether this attribute is referenced in the output shader unit. By default false.
Definition Reflection.hpp:264
Attribute(const String &name, const Int32 slot)
Constructor to initialize all members.
Definition Reflection.hpp:276
String name
Name of the attribute.
Definition Reflection.hpp:267
Constant buffer reflection structure.
Definition Reflection.hpp:352
bool referenced
Specifies whether this constant buffer is referenced in the output shader unit. By default false.
Definition Reflection.hpp:354
String name
Name of the constant buffer.
Definition Reflection.hpp:360
Vector< Field > fields
Collection of all fields within this constant buffer.
Definition Reflection.hpp:366
UInt32 size
Size (in bytes) of the constant buffer with a 16-byte alignment. If this is 0xFFFFFFFF,...
Definition Reflection.hpp:369
UInt32 padding
Size (in bytes) of the padding that is added to the constant buffer. By default 0.
Definition Reflection.hpp:372
ResourceType type
Resource type. By default ResourceType::Undefined.
Definition Reflection.hpp:357
Int32 slot
Zero-based binding slot number. If this is -1, the binding slot was not specified....
Definition Reflection.hpp:363
A field denotes a data member of a record or constant buffer.
Definition Reflection.hpp:298
String name
Name of the field (also called a data member or variable).
Definition Reflection.hpp:303
UInt32 dimensions[2]
Number of matrix dimensions.
Definition Reflection.hpp:313
UInt32 offset
Local offset (in bytes) within the containing record or constant buffer.
Definition Reflection.hpp:322
FieldType type
Base type of the field. Note that this does not include the dimension of a vector type....
Definition Reflection.hpp:306
Vector< UInt32 > arrayElements
Number of array elements. If this container is empty, the field does not denote an array....
Definition Reflection.hpp:325
bool referenced
Specifies whether this field is referenced in the output shader unit. By default false.
Definition Reflection.hpp:300
UInt32 size
Size (in bytes) of the field. If this is 0xFFFFFFFF, the field size could not be determined....
Definition Reflection.hpp:319
Int32 typeRecordIndex
Index to the global record type. If this is -1, the field does not denote a record type....
Definition Reflection.hpp:316
Number of threads within each work group of a compute shader.
Definition Reflection.hpp:406
Int32 x
Number of shader compute threads in X dimension.
Definition Reflection.hpp:408
Int32 z
Number of shader compute threads in Z dimension.
Definition Reflection.hpp:414
Int32 y
Number of shader compute threads in Y dimension.
Definition Reflection.hpp:411
A record denotes a data structure declared in a shader.
Definition Reflection.hpp:330
UInt32 padding
Size (in bytes) of the padding that is added to the record. By default 0.
Definition Reflection.hpp:347
bool referenced
Specifies whether this record is referenced in the output shader unit. By default false.
Definition Reflection.hpp:332
String name
Name of the record (also called a structure, struct, or compound data).
Definition Reflection.hpp:335
UInt32 size
Size (in bytes) of the record. If this is 0xFFFFFFFF, the record size could not be determined....
Definition Reflection.hpp:344
Vector< Field > fields
Collection of all fields within this record.
Definition Reflection.hpp:341
Int32 baseRecordIndex
Optional index to the global base record type from which this record inherits. If this is -1,...
Definition Reflection.hpp:338
Structure for shader output statistics (e.g. texture/buffer binding points).
Definition Reflection.hpp:418
Vector< Attribute > outputAttributes
Shader output attributes.
Definition Reflection.hpp:430
NumThreads numThreads
Number of local threads in a compute shader.
Definition Reflection.hpp:448
Vector< Resource > resources
Texture and buffer resources.
Definition Reflection.hpp:436
Vector< SamplerState > samplerStates
Dynamic sampler states.
Definition Reflection.hpp:442
Vector< Attribute > inputAttributes
Shader input attributes.
Definition Reflection.hpp:427
Vector< Record > records
All records declared both globally and within constant buffers (also called structure,...
Definition Reflection.hpp:424
Vector< ConstantBuffer > constantBuffers
Constant buffers.
Definition Reflection.hpp:439
Vector< StaticSamplerState > staticSamplerStates
Static sampler states.
Definition Reflection.hpp:445
Vector< String > macros
All defined macros after pre-processing.
Definition Reflection.hpp:420
Vector< Attribute > uniforms
Single shader uniforms.
Definition Reflection.hpp:433
Resource reflection structure for textures, combined texture samplers, and buffers.
Definition Reflection.hpp:281
String name
Name of the resource.
Definition Reflection.hpp:289
Int32 slot
Zero-based binding slot number. If this is -1, the binding slot was not specified....
Definition Reflection.hpp:292
ResourceType type
Resource type. By default ResourceType::Undefined.
Definition Reflection.hpp:286
bool referenced
Specifies whether this resource is referenced in the output shader unit. By default false.
Definition Reflection.hpp:283
Static sampler state descriptor structure (D3D11_SAMPLER_DESC).
Definition Reflection.hpp:246
TextureAddressMode addressW
Definition Reflection.hpp:250
TextureAddressMode addressU
Definition Reflection.hpp:248
TextureAddressMode addressV
Definition Reflection.hpp:249
float borderColor[4]
Definition Reflection.hpp:254
UInt32 maxAnisotropy
Definition Reflection.hpp:252
ComparisonFunc comparisonFunc
Definition Reflection.hpp:253
Sampler state reflection structure.
Definition Reflection.hpp:377
ResourceType type
Resource type. By default ResourceType::Undefined.
Definition Reflection.hpp:379
bool referenced
Specifies whether this record is referenced in the output shader unit. By default false.
Definition Reflection.hpp:388
Int32 slot
Zero-based binding slot number. If this is -1, the binding slot was not specified....
Definition Reflection.hpp:385
String name
Name of the sampler state.
Definition Reflection.hpp:382
Static sampler state reflection structure.
Definition Reflection.hpp:393
ResourceType type
Resource type. By default ResourceType::Undefined.
Definition Reflection.hpp:395
String name
Name of the static sampler state.
Definition Reflection.hpp:398
SamplerStateDesc desc
Descriptor of the sampler state.
Definition Reflection.hpp:401