Class GorgonShader
The base shader object.
Inheritance
Inherited Members
Namespace: Gorgon.Graphics.Core
Assembly: Gorgon.Graphics.Core.dll
Syntax
public abstract class GorgonShader : GorgonNamedObject, IGorgonNamedObject, IDisposable, IGorgonGraphicsObject
Remarks
Shaders are used to modify data on the GPU via a program uploaded to the GPU. This allows for a wide range of effects on GPU data. For example, a gaussian blur algorithm can be written using a pixel shader to blur an image.
In Gorgon, shaders can be compiled from a string containing source code via the GorgonShaderFactory, or loaded from a Stream or file for quicker access. The
GorgonShaderFactory is required to compile or read shaders, they cannot be created via the new
keyword.
All shaders in Gorgon will inherit from this type.
Properties
| Edit this page View SourceGraphics
Property to return the graphics interface that built this object.
Declaration
public GorgonGraphics Graphics { get; }
Property Value
Type | Description |
---|---|
GorgonGraphics |
ID
Property to return the ID for the shader.
Declaration
public long ID { get; }
Property Value
Type | Description |
---|---|
long |
IsDebug
Property to set or return whether to include debug information in the shader or not.
Declaration
public bool IsDebug { get; }
Property Value
Type | Description |
---|---|
bool |
ShaderType
Property to return the type of shader.
Declaration
public abstract ShaderType ShaderType { get; }
Property Value
Type | Description |
---|---|
ShaderType |
Methods
| Edit this page View SourceDispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public virtual void Dispose()
Save(Stream)
Function to persist the shader data to a stream as a GorgonChunkFile<T>.
Declaration
public void Save(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write the data into. |
Remarks
This will write the shader data as GorgonChunkFile<T> formatted data into the supplied stream
. Shaders may take some time to compile, saving them to a binary
format in a stream will help cut down on the time it takes to initialize an application.
This makes use of the Gorgon GorgonChunkFile<T> format to allow flexible storage of data. The Gorgon shader format is broken into 2 chunks, both of which are available in the BinaryShaderMetaData, and BinaryShaderByteCode constants. The file header for the format is stored in the BinaryShaderFileHeader constant.
The file format is as follows:
- BinaryShaderFileHeaderThis describes the type of file, and the version.
- BinaryShaderMetaDataShader metadata, such as the ShaderType (int), debug flag (bool), and the entry point name (string) is stored here.
- BinaryShaderByteCodeThe compiled shader byte code is stored here and is loaded as a byte array.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentException | Thrown when the stream is read only. |
See Also
| Edit this page View SourceSave(string)
Function to persist the shader data to a file as a GorgonChunkFile<T>.
Declaration
public void Save(string path)
Parameters
Type | Name | Description |
---|---|---|
string | path | The path to the file where the shader data will eb written. |
Remarks
This will write the shader data as GorgonChunkFile<T> formatted data into the file. Shaders may take some time to compile, saving them to a binary format in a stream will help cut down on the time it takes to initialize an application.
This makes use of the Gorgon GorgonChunkFile<T> format to allow flexible storage of data. The Gorgon shader format is broken into 2 chunks, both of which are available in the BinaryShaderMetaData, and BinaryShaderByteCode constants. The file header for the format is stored in the BinaryShaderFileHeader constant.
The file format is as follows:
- BinaryShaderFileHeaderThis describes the type of file, and the version.
- BinaryShaderMetaDataShader metadata, such as the ShaderType (int), debug flag (bool), and the entry point name (string) is stored here.
- BinaryShaderByteCodeThe compiled shader byte code is stored here and is loaded as a byte array.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentException | Thrown when |
See Also
| Edit this page View SourceSaveToFile(string)
Function to persist the shader data to a file as a GorgonChunkFile<T>.
Declaration
[Obsolete("Use Save(string) instead.")]
public void SaveToFile(string path)
Parameters
Type | Name | Description |
---|---|---|
string | path | The path to the file where the shader data will eb written. |
Remarks
This will write the shader data as GorgonChunkFile<T> formatted data into the file. Shaders may take some time to compile, saving them to a binary format in a stream will help cut down on the time it takes to initialize an application.
This makes use of the Gorgon GorgonChunkFile<T> format to allow flexible storage of data. The Gorgon shader format is broken into 2 chunks, both of which are available in the BinaryShaderMetaData, and BinaryShaderByteCode constants. The file header for the format is stored in the BinaryShaderFileHeader constant.
The file format is as follows:
- BinaryShaderFileHeaderThis describes the type of file, and the version.
- BinaryShaderMetaDataShader metadata, such as the ShaderType (int), debug flag (bool), and the entry point name (string) is stored here.
- BinaryShaderByteCodeThe compiled shader byte code is stored here and is loaded as a byte array.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentException | Thrown when |
See Also
| Edit this page View SourceSaveToStream(Stream)
Function to persist the shader data to a stream as a GorgonChunkFile<T>.
Declaration
[Obsolete("Use Save(Stream) instead.")]
public void SaveToStream(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream to write the data into. |
Remarks
This will write the shader data as GorgonChunkFile<T> formatted data into the supplied stream
. Shaders may take some time to compile, saving them to a binary
format in a stream will help cut down on the time it takes to initialize an application.
This makes use of the Gorgon GorgonChunkFile<T> format to allow flexible storage of data. The Gorgon shader format is broken into 2 chunks, both of which are available in the BinaryShaderMetaData, and BinaryShaderByteCode constants. The file header for the format is stored in the BinaryShaderFileHeader constant.
The file format is as follows:
- BinaryShaderFileHeaderThis describes the type of file, and the version.
- BinaryShaderMetaDataShader metadata, such as the ShaderType (int), debug flag (bool), and the entry point name (string) is stored here.
- BinaryShaderByteCodeThe compiled shader byte code is stored here and is loaded as a byte array.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentException | Thrown when the stream is read only. |