CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
ReflectionAnalyzer.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
10#include "Visitor.hpp"
11
13
15
19
23
25
28 class ReflectionAnalyzer : private Visitor {
29 private:
31
33 Program* mProgram = nullptr;
34
36
37 bool mEnableWarnings = false;
38
40
41 public:
43
44 // Collect all reflection data from the program AST.
45 void reflect(Program& program, const ShaderTarget shaderTarget, Reflection::ReflectionData& reflectionData, bool enableWarnings);
46
47 private:
48 void warning(const String& msg, const AST* ast = nullptr);
49
50 [[nodiscard]] Int32 getBindingPoint(const Vector<RegisterPtr>& slotRegisters) const;
51
54
55 private: // Visitor implementation
57
60
64
66
67 private: // Helper functions for code reflection
69 void reflectSamplerValueFilter(const String& value, Reflection::Filter& filter, const AST* ast = nullptr);
71 void reflectSamplerValueComparisonFunc(const String& value, Reflection::ComparisonFunc& comparisonFunc, const AST* ast = nullptr);
72
75
78
79 // Returns the index of the record that is associated with the specified structure declaration object, or -1 on failure.
80 Int32 findRecordIndex(const StructDeclaration* structDeclaration) const;
81 };
82
83} // namespace CeresEngine::ShaderCompiler
#define DECLARATION_VISIT_PROC(CLASS_NAME)
Definition Visitor.hpp:88
Log base class.
Definition Log.hpp:19
Code reflection analyzer.
Definition ReflectionAnalyzer.hpp:28
void reflectFieldType(Reflection::Field &field, const TypeDenoter &typeDen)
void reflect(Program &program, const ShaderTarget shaderTarget, Reflection::ReflectionData &reflectionData, bool enableWarnings)
bool mEnableWarnings
Definition ReflectionAnalyzer.hpp:37
void reflectSamplerValueComparisonFunc(const String &value, Reflection::ComparisonFunc &comparisonFunc, const AST *ast=nullptr)
Int32 getBindingPoint(const Vector< RegisterPtr > &slotRegisters) const
Int32 evaluateConstExpressionInt(Expression &expression)
Int32 findRecordIndex(const StructDeclaration *structDeclaration) const
float evaluateConstExpressionFloat(Expression &expression)
void reflectSamplerValue(const SamplerValue *ast, Reflection::SamplerStateDesc &desc)
void reflectSamplerValueFilter(const String &value, Reflection::Filter &filter, const AST *ast=nullptr)
Map< const StructDeclaration *, std::size_t > mRecordIndicesMap
Definition ReflectionAnalyzer.hpp:39
void reflectField(VarDeclaration *ast, Reflection::Field &field, UInt32 &accumSize, UInt32 &accumPadding)
Program * mProgram
Definition ReflectionAnalyzer.hpp:33
ShaderTarget mShaderTarget
Definition ReflectionAnalyzer.hpp:32
Reflection::ReflectionData * mData
Definition ReflectionAnalyzer.hpp:35
void warning(const String &msg, const AST *ast=nullptr)
void reflectSamplerValueTextureAddressMode(const String &value, Reflection::TextureAddressMode &addressMode, const AST *ast=nullptr)
ReportHandler mReportHandler
Definition ReflectionAnalyzer.hpp:30
void reflectAttributes(const Vector< AttributePtr > &attribs)
void reflectAttributesNumThreads(const Attribute *ast)
Definition ReportHandler.hpp:31
Definition Visitor.hpp:92
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
Definition AST.hpp:33
ShaderTarget
Shader target enumeration.
Definition Targets.hpp:16
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
std::map< Key, T, Compare, ScopedAllocatorAdaptor< StdAllocator< Pair< const Key, T >, RawAllocator > > > Map
Map is a sorted associative container that contains key-value pairs with unique keys.
Definition Map.hpp:24
auto filter(Container &container, Predicate &&predicate)
Returns an iterable object that iterates over the values of the container and applies transform to ev...
Definition Iterator.hpp:451
A field denotes a data member of a record or constant buffer.
Definition Reflection.hpp:298
Structure for shader output statistics (e.g. texture/buffer binding points).
Definition Reflection.hpp:418
Static sampler state descriptor structure (D3D11_SAMPLER_DESC).
Definition Reflection.hpp:246
Definition TypeDenoter.hpp:82