GFXShader

Engine/source/gfx/gfxShader.h

More...

Public Friends

Protected Static Attributes

These are system wide shader macros which are merged with shader specific macros at creation.

bool

If true the shader errors are spewed to the console.

bool

If true the shader warnings are spewed to the console.

Protected Attributes

Vector of buffers that reference this shader.

The macros to be passed to the shader.

The pixel shader file.

The pixel version this is compiled for.

Counter that is incremented each time this shader is reloaded.

Ordered SamplerNames We need to store a list of sampler for allow OpenGL to assign correct location for each sampler.

The vertex shader file.

Protected Functions

A protected constructor so it cannot be instantiated.

bool

Internal initialization function overloaded for each GFX device type.

Called when the shader files change on disk.

Buffers call this from their destructor (so we don't have to ref count them).

Called to update the description string after init.

Public Static Functions

Adds a global shader macro which will be merged with the script defined macros on every shader reload.

bool

Removes an existing global macro by name.

setLogging(bool logErrors, bool logWarning)

Toggle logging for shader errors.

Public Functions

The destructor.

Allocate a constant buffer.

The resource should put a description of itself (number of vertices, size/width of texture, etc.) in buffer.

Returns a shader constant handle for the name constant, if the variable doesn't exist NULL is returned.

Returns the alignment value for constType.

bool

Device specific shaders can override this method to return the shader disassembly.

Returns the pixel shader file path.

Returns the required vertex format for this shader.

Returns a counter which is incremented each time this shader is reloaded.

Returns our list of shader constants, the material can get this and just set the constants it knows about.

Returns a shader constant handle for the name constant.

Returns the vertex shader file path.

bool
init(const Torque::Path & vertFile, const Torque::Path & pixFile, F32 pixVersion, const Vector< GFXShaderMacro > & macros)

Deprecated. Remove on T3D 4.0.

bool
init(const Torque::Path & vertFile, const Torque::Path & pixFile, F32 pixVersion, const Vector< GFXShaderMacro > & macros, const Vector< String > & samplerNames, GFXVertexFormat * instanceFormat)
bool

Reloads the shader from disk.

Detailed Description

Public Friends

Protected Static Attributes

Vector< GFXShaderMacro > smGlobalMacros 

These are system wide shader macros which are merged with shader specific macros at creation.

bool smLogErrors 

If true the shader errors are spewed to the console.

bool smLogWarnings 

If true the shader warnings are spewed to the console.

Protected Attributes

Vector< GFXShaderConstBuffer * > mActiveBuffers 

Vector of buffers that reference this shader.

It is the responsibility of the derived shader class to populate this vector and to notify them when this shader is reloaded. Classes derived from GFXShaderConstBuffer should call _unlinkBuffer from their destructor.

String mDescription 
GFXVertexFormat * mInstancingFormat 
Vector< GFXShaderMacro > mMacros 

The macros to be passed to the shader.

Torque::Path mPixelFile 

The pixel shader file.

F32 mPixVersion 

The pixel version this is compiled for.

U32 mReloadKey 

Counter that is incremented each time this shader is reloaded.

Signal< void()> mReloadSignal 
Vector< String > mSamplerNamesOrdered 

Ordered SamplerNames We need to store a list of sampler for allow OpenGL to assign correct location for each sampler.

GLSL 150 not allow explicit uniform location. Only used on OpenGL

Torque::Path mVertexFile 

The vertex shader file.

Protected Functions

GFXShader()

A protected constructor so it cannot be instantiated.

_init()

Internal initialization function overloaded for each GFX device type.

Reimplemented by: GFXD3D11Shader, GFXGLShader

_onFileChanged(const Torque::Path & path)

Called when the shader files change on disk.

_unlinkBuffer(GFXShaderConstBuffer * buf)

Buffers call this from their destructor (so we don't have to ref count them).

_updateDesc()

Called to update the description string after init.

Public Static Functions

addGlobalMacro(const String & name, const String & value)

Adds a global shader macro which will be merged with the script defined macros on every shader reload.

The macro will replace the value of an existing macro of the same name.

For the new macro to take effect all the shaders/materials in the system need to be reloaded.

see:

ShaderData::reloadAll

removeGlobalMacro(const String & name)

Removes an existing global macro by name.

setLogging(bool logErrors, bool logWarning)

Toggle logging for shader errors.

Public Functions

~GFXShader()

The destructor.

allocConstBuffer()

Allocate a constant buffer.

Reimplemented by: GFXD3D11Shader, GFXGLShader

describeSelf()

Reimplemented from: GFXResource

Reimplemented by: GFXGLShader

findShaderConstHandle(const String & name)

Returns a shader constant handle for the name constant, if the variable doesn't exist NULL is returned.

Reimplemented by: GFXD3D11Shader, GFXGLShader

getAlignmentValue(const GFXShaderConstType constType)

Returns the alignment value for constType.

Reimplemented by: GFXD3D11Shader, GFXGLShader

getDisassembly(String & outStr)

Device specific shaders can override this method to return the shader disassembly.

Reimplemented by: GFXD3D11Shader

getInstancingFormat()

getPixelShaderFile()

Returns the pixel shader file path.

getPixVersion()

Returns the required vertex format for this shader.

Returns the pixel shader version.

getReloadKey()

Returns a counter which is incremented each time this shader is reloaded.

getReloadSignal()

getShaderConstDesc()

Returns our list of shader constants, the material can get this and just set the constants it knows about.

Reimplemented by: GFXD3D11Shader, GFXGLShader

getShaderConstHandle(const String & name)

Returns a shader constant handle for the name constant.

Since shaders can reload and later have handles that didn't exist originally this will return a handle in an invalid state if the constant doesn't exist at this time.

Reimplemented by: GFXD3D11Shader, GFXGLShader

getVertexShaderFile()

Returns the vertex shader file path.

init(const Torque::Path & vertFile, const Torque::Path & pixFile, F32 pixVersion, const Vector< GFXShaderMacro > & macros)

Deprecated. Remove on T3D 4.0.

init(const Torque::Path & vertFile, const Torque::Path & pixFile, F32 pixVersion, const Vector< GFXShaderMacro > & macros, const Vector< String > & samplerNames, GFXVertexFormat * instanceFormat)

reload()

Reloads the shader from disk.