Shader
The Shader class represents a shader program, enabling the creation, loading, and management of shaders in various types and formats like native, GLSL, and SPIR-V. It provides functionality to configure and retrieve properties such as shader type, name, macros, and resource offsets for textures, surfaces, and uniforms. The class supports shader creation and compilation, management of global shader caches, and handling global macros and includes.
#include <platform/TellusimShader.h>
Constructors
Shader()
Methods
Shader platform.
Platform getPlatform() const
const char *getPlatformName() const
Shader device index.
uint32_t getIndex() const
Clear shader.
void clear()
Check shader.
bool isCreated() const
Shader parameters.
bool saveState(Stream &stream) const
Shader type.
Type getType() const
static const char *getTypeName(Type type)
const char *getTypeName() const
bool isVertex() const
bool isControl() const
bool isEvaluate() const
bool isGeometry() const
bool isFragment() const
bool isCompute() const
bool isTask() const
bool isMesh() const
bool isRayGen() const
bool isRayMiss() const
bool isClosest() const
bool isFirstHit() const
bool isIntersection() const
bool isCallable() const
bool isGraphicsType() const
bool isTessellationType() const
bool isTracingType() const
bool isMeshType() const
Shader name.
String getName() const
String getMacros() const
Shader samplers.
void setSamplerOffset(int32_t offset)
int32_t getSamplerOffset() const
Shader textures.
void setTextureOffset(int32_t offset)
int32_t getTextureOffset() const
Shader surfaces.
void setSurfaceOffset(int32_t offset)
int32_t getSurfaceOffset() const
Shader uniforms.
void setUniformOffset(int32_t offset)
int32_t getUniformOffset() const
Shader storages.
void setStorageOffset(int32_t offset)
int32_t getStorageOffset() const
Shader tracings.
void setTracingOffset(int32_t offset)
int32_t getTracingOffset() const
Shader texels.
void setTexelOffset(int32_t offset)
int32_t getTexelOffset() const
Shader tables.
void setTableOffset(int32_t offset)
int32_t getTableOffset() const
Shader patch size.
void setPatchSize(uint32_t size)
uint32_t getPatchSize() const
Shader input size.
void setInputSize(uint32_t size)
uint32_t getInputSize() const
Shader output size.
void setOutputSize(uint32_t size)
uint32_t getOutputSize() const
Create native shader.
bool load(Type type, const char *name, const char *format)
bool create(Type type, const char *src, const char *format)
bool load(Type type, const char *name, const String ¯os = String::null, const char **includes = nullptr, uint32_t size = 0)
bool create(Type type, const char *src, const String ¯os = String::null, const char **includes = nullptr, uint32_t size = 0)
Create GLSL shader.
bool loadGLSL(Type type, const char *name, const char *format)
bool createGLSL(Type type, const char *src, const char *format)
bool loadGLSL(Type type, const char *name, const String ¯os = String::null, const char **includes = nullptr, uint32_t size = 0)
bool createGLSL(Type type, const char *src, const String ¯os = String::null, const char **includes = nullptr, uint32_t size = 0)
Create SPIR-V shader.
bool loadSPIRV(Type type, const char *name)
bool createSPIRV(Type type, Array<uint32_t> data)
Global shader cache.
static bool hasCache()
static bool setCache(const char *name)
static bool loadCache(const String &hash, Stream &stream)
static bool saveCache(const String &hash, Stream &stream)
static void clearCache()
Global macro definitions.
static bool isMacro(const char *name)
static bool setMacro(const char *name, int32_t value)
static bool setMacro(const char *name, uint32_t value)
static bool setMacro(const char *name, const char *value = nullptr)
static bool setMacros(const char *macros)
static bool removeMacro(const char *name)
static void clearMacros()
Global include definitions.
static bool isInclude(const char *name)
static bool setInclude(const char *name, const String &src)
static bool removeInclude(const char *name)
static void clearIncludes()
Global macro preprocessor.
static String preprocessor(const char *src, const char *format)
static String preprocessor(const char *src, const String ¯os = String::null, const char **includes = nullptr, uint32_t size = 0)
Enums
Type
Shader types.
Name | Value | Description |
---|---|---|
TypeUnknown | 0 | |
TypeVertex | 1 | Vertex shader. |
TypeControl | 2 | Tessellation control shader. |
TypeEvaluate | 3 | Tessellation evaluate shader. |
TypeGeometry | 4 | Geometry shader. |
TypeFragment | 5 | Fragment shader. |
TypeCompute | 6 | Compute shader. |
TypeTask | 7 | Task shader. |
TypeMesh | 8 | Mesh shader. |
TypeRayGen | 9 | Ray gen shader. |
TypeRayMiss | 10 | Ray miss shader. |
TypeClosest | 11 | Ray closest shader. |
TypeFirstHit | 12 | Ray first hit shader. |
TypeIntersection | 13 | Ray intersection shader. |
TypeCallable | 14 | Ray callable shader. |
NumTypes | 15 |
Mask
Shader masks.
Name | Value | Description |
---|---|---|
MaskNone | 0 | |
MaskVertex | (1 << TypeVertex) | Vertex shader mask. |
MaskControl | (1 << TypeControl) | Tessellation control shader mask. |
MaskEvaluate | (1 << TypeEvaluate) | Tessellation evaluate shader mask. |
MaskGeometry | (1 << TypeGeometry) | Geometry shader mask. |
MaskFragment | (1 << TypeFragment) | Fragment shader mask. |
MaskCompute | (1 << TypeCompute) | Compute shader mask. |
MaskTask | (1 << TypeTask) | Task shader mask. |
MaskMesh | (1 << TypeMesh) | Mesh shader mask. |
MaskRayGen | (1 << TypeRayGen) | Ray gen shader mask. |
MaskRayMiss | (1 << TypeRayMiss) | Ray miss shader mask. |
MaskClosest | (1 << TypeClosest) | Closest shader mask. |
MaskFirstHit | (1 << TypeFirstHit) | First hit shader mask. |
MaskIntersection | (1 << TypeIntersection) | Intersection shader mask. |
MaskCallable | (1 << TypeCallable) | Callable shader mask. |
MaskVertexFragment | (MaskVertex | MaskFragment) | |
MaskGraphics | (MaskVertex | MaskControl | MaskEvaluate | MaskGeometry | MaskFragment) | |
MaskTracing | (MaskRayGen | MaskRayMiss | MaskClosest | MaskFirstHit | MaskIntersection | MaskCallable) | |
MaskAll | (MaskGraphics | MaskCompute | MaskTask | MaskMesh | MaskTracing) |