Gorgon
Show / Hide Table of Contents

Struct GorgonShaderInclude

An include file for a shader.

Implements
IGorgonNamedObject
IEquatable<GorgonShaderInclude>
Inherited Members
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetType()
Namespace: Gorgon.Graphics.Core
Assembly: Gorgon.Graphics.Core.dll
Syntax
public readonly struct GorgonShaderInclude : IGorgonNamedObject, IEquatable<GorgonShaderInclude>
Remarks

Use this object to load in included external functions for a shader. If the shader source contains an HLSL #include directive, the shader compiler will try to locate that include file on the file system. However, this does not work when the files are loaded from a Stream (it wouldn't know where to find the include file). So to facilitate this, this object will contain the source for the include file and will be looked up before the file system is checked for the include file.

Gorgon uses a special keyword in shaders to allow shader files to include other files as part of the source. This keyword is named #GorgonInclude and is similar to the HLSL #include keyword. The difference is that this keyword allows users to include shader source from memory instead of a separate source file. This is done by assigning a name to the included source code in the #GorgonInclude keyword, and adding the GorgonShaderInclude containing the source to the Includes property on the GorgonShaderFactory class. When the include is loaded from a file, then it will automatically be added to the Includes property.

The parameters for the #GorgonIncludekeyword are:

  • NameThe path name of the included source. This must be unique, and assigned to the Includes property.
  • (Optional) PathThe path to the shader source file to include. This may be omitted if the include is assigned from memory in the Includes property.

These include objects are ignored with binary shader data loaded from a Stream or file as those will aready contain the included source compiled into bytecode.

Constructors

| Edit this page View Source

GorgonShaderInclude(string, string)

Initializes a new instance of the GorgonShaderInclude struct.

Declaration
public GorgonShaderInclude(string includeName, string includeSourceFile)
Parameters
Type Name Description
string includeName

Name of the include file.

string includeSourceFile

The include source code file.

Remarks

The includeSourceFile can be set to null or empty if the include line is pointing to a file.

Exceptions
Type Condition
ArgumentNullException

Thrown when the includeName parameters is null.

ArgumentException

Thrown when the includeName parameter is empty.

See Also
GorgonShaderFactory

Fields

| Edit this page View Source

Name

The name of the shader include file.

Declaration
public readonly string Name
Field Value
Type Description
string
See Also
GorgonShaderFactory
| Edit this page View Source

SourceCodeFile

The source code for the shader include file.

Declaration
public readonly string SourceCodeFile
Field Value
Type Description
string
See Also
GorgonShaderFactory

Methods

| Edit this page View Source

Equals(GorgonShaderInclude)

Indicates whether the current object is equal to another object of the same type.

Declaration
public bool Equals(GorgonShaderInclude other)
Parameters
Type Name Description
GorgonShaderInclude other

An object to compare with this object.

Returns
Type Description
bool

true if the current object is equal to the other parameter; otherwise, false.

See Also
GorgonShaderFactory
| Edit this page View Source

Equals(in GorgonShaderInclude, in GorgonShaderInclude)

Function to evaluate two instances for equality.

Declaration
public static bool Equals(in GorgonShaderInclude left, in GorgonShaderInclude right)
Parameters
Type Name Description
GorgonShaderInclude left

The left instance to compare.

GorgonShaderInclude right

The right instance to compare.

Returns
Type Description
bool

true if equal, false if not.

See Also
GorgonShaderFactory
| Edit this page View Source

Equals(object)

Determines whether the specified object is equal to this instance.

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
object obj

The object to compare with this instance.

Returns
Type Description
bool

true if the specified object is equal to this instance; otherwise, false.

Overrides
ValueType.Equals(object)
See Also
GorgonShaderFactory
| Edit this page View Source

GetHashCode()

Returns a hash code for this instance.

Declaration
public override int GetHashCode()
Returns
Type Description
int

A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.

Overrides
ValueType.GetHashCode()
See Also
GorgonShaderFactory
| Edit this page View Source

ToString()

Returns a string that represents this instance.

Declaration
public override string ToString()
Returns
Type Description
string

A string that represents this instance.

Overrides
ValueType.ToString()
See Also
GorgonShaderFactory

Operators

| Edit this page View Source

operator ==(GorgonShaderInclude, GorgonShaderInclude)

Equality operator.

Declaration
public static bool operator ==(GorgonShaderInclude left, GorgonShaderInclude right)
Parameters
Type Name Description
GorgonShaderInclude left

Left instance to compare.

GorgonShaderInclude right

Right instance to compare.

Returns
Type Description
bool

true if equal, false if not.

See Also
GorgonShaderFactory
| Edit this page View Source

operator !=(GorgonShaderInclude, GorgonShaderInclude)

Inequality operator.

Declaration
public static bool operator !=(GorgonShaderInclude left, GorgonShaderInclude right)
Parameters
Type Name Description
GorgonShaderInclude left

Left instance to compare.

GorgonShaderInclude right

Right instance to compare.

Returns
Type Description
bool

true if not equal, false if equal.

See Also
GorgonShaderFactory

Implements

IGorgonNamedObject
IEquatable<T>

Extension Methods

GorgonNullExtensions.AsNullable<T>(object)
GorgonNullExtensions.IfNull<T>(object, T)
GorgonNullExtensions.IsNull(object)

See Also

GorgonShaderFactory
  • Edit this page
  • View Source
In this article
Back to top Copyright 2023 - Licensed under the MIT license by Michael Winsor (Tape_Worm).
Send comments on this topic to the author