Rebel Fork Framework
Urho3D::ShaderVariation Class Reference

Vertex or pixel shader on the GPU. More...

#include <Urho3D/Graphics/ShaderVariation.h>

Inheritance diagram for Urho3D::ShaderVariation:
Urho3D::RefCounted Urho3D::GPUObject

Public Types

using ConstantBufferSizes = ea::array< unsigned, MAX_SHADER_PARAMETER_GROUPS >

Public Member Functions

 ShaderVariation (Shader *owner, ShaderType type)
 ~ShaderVariation () override
void OnDeviceLost () override
 Mark the GPU resource destroyed on graphics context destruction.
void Release () override
 Release the shader.
bool Create ()
 Compile the shader. Return true if successful.
void SetName (const ea::string &name)
 Set name.
void SetDefines (const ea::string &defines)
 Set defines.
ShaderGetOwner () const
 Return the owner resource.
ShaderType GetShaderType () const
 Return shader type.
const ea::string & GetName () const
 Return shader name.
ea::string GetFullName () const
 Return full shader name.
bool HasParameter (StringHash param) const
 Return whether uses a parameter. Not applicable on OpenGL, where this information is contained in ShaderProgram instead.
bool HasTextureUnit (TextureUnit unit) const
 Return whether uses a texture unit (only for pixel shaders). Not applicable on OpenGL, where this information is contained in ShaderProgram instead.
const ea::unordered_map< StringHash, ShaderParameter > & GetParameters () const
 Return all parameter definitions. Not applicable on OpenGL, where this information is contained in ShaderProgram instead.
unsigned long long GetElementHash () const
 Return vertex element hash.
const ea::vector< unsigned char > & GetByteCode () const
 Return shader bytecode. Stored persistently on Direct3D11 only.
const ea::string & GetDefines () const
 Return defines.
const ea::string & GetCompilerOutput () const
 Return compile error/warning string.
const ConstantBufferSizes & GetConstantBufferSizes () const
 Return constant buffer data sizes.
- Public Member Functions inherited from Urho3D::RefCounted
 RefCounted ()
 Construct. Allocate the reference count structure and set an initial self weak reference.
virtual ~RefCounted ()
 Destruct. Mark as expired and also delete the reference count structure if no outside weak references exist.
 RefCounted (const RefCounted &rhs)=delete
 Prevent copy construction.
RefCountedoperator= (const RefCounted &rhs)=delete
 Prevent assignment.
int AddRef ()
int ReleaseRef ()
int Refs () const
int WeakRefs () const
RefCountRefCountPtr () const
 Return pointer to the reference count structure.
bool HasScriptObject () const
 Return true if script runtime object wrapping this native object exists.
bool IsScriptStrongRef () const
 Return true if script reference is strong.
- Public Member Functions inherited from Urho3D::GPUObject
 GPUObject (Graphics *graphics)
 Construct with graphics subsystem pointer.
virtual ~GPUObject ()
 Destruct. Remove from the Graphics.
virtual void OnDeviceReset ()
 Recreate the GPU resource and restore data if applicable.
void ClearDataLost ()
 Clear the data lost flag.
GraphicsGetGraphics () const
 Return the graphics subsystem associated with this GPU object.
void * GetGPUObject () const
 Return the object pointer. Applicable only on Direct3D.
unsigned GetGPUObjectName () const
 Return the object name. Applicable only on OpenGL.
bool IsDataLost () const
bool HasPendingData () const
 Return whether has pending data assigned while graphics context was lost.

Static Public Attributes

static const char * elementSemanticNames []
 D3D11 vertex semantic names. Used internally.

Private Member Functions

bool LoadByteCode (const FileIdentifier &binaryShaderName)
 Load bytecode from a file. Return true if successful.
bool Compile ()
 Compile from source. Return true if successful.
void ParseParameters (unsigned char *bufData, unsigned bufSize)
 Inspect the constant parameters and input layout (if applicable) from the shader bytecode.
void SaveByteCode (const FileIdentifier &binaryShaderName)
 Save bytecode to a file.
void CalculateConstantBufferSizes ()
 Calculate constant buffer sizes from parameters.

Private Attributes

WeakPtr< Shaderowner_
 Shader this variation belongs to.
ShaderType type_
 Shader type.
unsigned long long elementHash_ {}
 Vertex element hash for vertex shaders. Zero for pixel shaders. Note that hashing is different than vertex buffers.
ea::unordered_map< StringHash, ShaderParameterparameters_
 Shader parameters.
bool useTextureUnits_ [MAX_TEXTURE_UNITS] {}
 Texture unit use flags.
ConstantBufferSizes constantBufferSizes_ {}
 Constant buffer sizes. 0 if a constant buffer slot is not in use.
ea::vector< unsigned char > byteCode_
 Shader bytecode. Needed for inspecting the input signature and parameters. Not used on OpenGL.
ea::string name_
 Shader name.
ea::string defines_
 Defines to use in compiling.
ea::string compilerOutput_
 Shader compile error string.

Additional Inherited Members

- Protected Attributes inherited from Urho3D::GPUObject
WeakPtr< Graphicsgraphics_
 Graphics subsystem.
GPUObjectHandle object_ {}
 Object pointer or name.
bool dataLost_ {}
 Data lost flag.
bool dataPending_ {}
 Data pending flag.

Detailed Description

Vertex or pixel shader on the GPU.

The documentation for this class was generated from the following files: