Class GorgonTexture1DView
A shader view for textures.
Implements
Inherited Members
Namespace: Gorgon.Graphics.Core
Assembly: Gorgon.Graphics.Core.dll
Syntax
public sealed class GorgonTexture1DView : GorgonShaderResourceView, IDisposable, IGorgonGraphicsObject, IEquatable<GorgonResourceView>, IEquatable<GorgonShaderResourceView>, IGorgonTexture1DInfo, IGorgonNamedObject, IGorgonImageInfo
Remarks
This is a texture shader view to allow a GorgonTexture1D to be bound to the GPU pipeline as a shader resource.
Use a resource view to allow a shader access to the contents of a resource (or sub resource). When the resource is created with a typeless format, this will allow the resource to be cast to any format within the same group.
Properties
| Edit this page View SourceArrayCount
Property to return the number of array indices to use in the view.
Declaration
public int ArrayCount { get; }
Property Value
Type | Description |
---|---|
int |
ArrayIndex
Property to return the first array index to use in the view.
Declaration
public int ArrayIndex { get; }
Property Value
Type | Description |
---|---|
int |
Binding
Property to return the flags to determine how the texture will be bound with the pipeline when rendering.
Declaration
public TextureBinding Binding { get; }
Property Value
Type | Description |
---|---|
TextureBinding |
Bounds
Property to return the bounding range for the view.
Declaration
public GorgonRange Bounds { get; }
Property Value
Type | Description |
---|---|
GorgonRange |
Remarks
This value is the full bounding range of the first mip map level for the texture associated with the view.
Format
Property to return the format for the view.
Declaration
public BufferFormat Format { get; }
Property Value
Type | Description |
---|---|
BufferFormat |
FormatInformation
Property to return information about the Format used by this view.
Declaration
public GorgonFormatInfo FormatInformation { get; }
Property Value
Type | Description |
---|---|
GorgonFormatInfo |
MipCount
Property to return the number of mip maps in the resource to view.
Declaration
public int MipCount { get; }
Property Value
Type | Description |
---|---|
int |
MipSlice
Property to return the index of the first mip map in the resource to view.
Declaration
public int MipSlice { get; }
Property Value
Type | Description |
---|---|
int |
Texture
Property to return the texture that is bound to this view.
Declaration
public GorgonTexture1D Texture { get; }
Property Value
Type | Description |
---|---|
GorgonTexture1D |
Width
Property to return the width of the texture in pixels.
Declaration
public int Width { get; }
Property Value
Type | Description |
---|---|
int |
Remarks
This value is the full width of the first mip map level for the texture associated with the view.
Methods
| Edit this page View SourceCreateTexture(GorgonGraphics, IGorgonTexture1DInfo, IGorgonImage)
Function to create a new texture that is bindable to the GPU.
Declaration
public static GorgonTexture1DView CreateTexture(GorgonGraphics graphics, IGorgonTexture1DInfo info, IGorgonImage initialData = null)
Parameters
Type | Name | Description |
---|---|---|
GorgonGraphics | graphics | The graphics interface to use when creating the target. |
IGorgonTexture1DInfo | info | The information about the texture. |
IGorgonImage | initialData | [Optional] Initial data used to populate the texture. |
Returns
Type | Description |
---|---|
GorgonTexture1DView | A new GorgonTexture1DView. |
Remarks
This is a convenience method that will create a GorgonTexture1D and a GorgonTexture1DView as a single object that users can use to apply a texture as a shader resource. This helps simplify creation of a texture by executing some prerequisite steps on behalf of the user.
Since the GorgonTexture1D created by this method is linked to the GorgonTexture1DView returned, disposal of either one will dispose of the other on your behalf. If the user created a GorgonTexture1DView from the GetShaderResourceView(BufferFormat, int, int, int, int) method on the GorgonTexture1D, then it's assumed the user knows what they are doing and will handle the disposal of the texture and view on their own.
If an initialData
image is provided, and the width/height/depth is not the same as the values in the info
parameter, then the image data will be cropped to
match the values in the info
parameter. Things like array count, and mip levels will still be taken from the initialData
image parameter.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
See Also
| Edit this page View SourceDispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public override void Dispose()
Overrides
| Edit this page View SourceFromFile(GorgonGraphics, string, IGorgonImageCodec, GorgonTextureLoadOptions)
Function to load a texture from a file.
Declaration
public static GorgonTexture1DView FromFile(GorgonGraphics graphics, string filePath, IGorgonImageCodec codec, GorgonTextureLoadOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
GorgonGraphics | graphics | The graphics interface that will own the texture. |
string | filePath | The path to the file. |
IGorgonImageCodec | codec | The codec that is used to decode the the data in the stream. |
GorgonTextureLoadOptions | options | [Optional] Options used to further define the texture. |
Returns
Type | Description |
---|---|
GorgonTexture1DView | A new GorgonTexture1DView |
Remarks
This will load an IGorgonImage from a file on disk and put it into a GorgonTexture1D object and return a GorgonTexture1DView.
If specified, the options
parameter will define how Gorgon and shaders should handle the texture. The GorgonTextureLoadOptions type contains the following:
- BindingWhen defined, will indicate the TextureBinding that defines how the texture will be bound to the graphics pipeline. If it is omitted, then the binding will be ShaderResource.
- UsageWhen defined, will indicate the preferred usage for the texture. If it is omitted, then the usage will be set to Default.
- Multisample infoWhen defined (i.e. not null), defines the multisampling to apply to the texture. If omitted, then the default is NoMultiSampling.
- ConvertToPremultipliedAlphaConverts the image to premultiplied alpha before uploading the image data to the texture.
Since the GorgonTexture1D created by this method is linked to the GorgonTexture1DView returned, disposal of either one will dispose of the other on your behalf. If the user created a GorgonTexture1DView from the GetShaderResourceView(BufferFormat, int, int, int, int) method on the GorgonTexture1D, then it's assumed the user knows what they are doing and will handle the disposal of the texture and view on their own.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentEmptyException | Thrown when the |
FromStream(GorgonGraphics, Stream, IGorgonImageCodec, long?, GorgonTextureLoadOptions)
Function to load a texture from a Stream.
Declaration
public static GorgonTexture1DView FromStream(GorgonGraphics graphics, Stream stream, IGorgonImageCodec codec, long? size = null, GorgonTextureLoadOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
GorgonGraphics | graphics | The graphics interface that will own the texture. |
Stream | stream | The stream containing the texture image data. |
IGorgonImageCodec | codec | The codec that is used to decode the the data in the stream. |
long? | size | [Optional] The size of the image in the stream, in bytes. |
GorgonTextureLoadOptions | options | [Optional] Options used to further define the texture. |
Returns
Type | Description |
---|---|
GorgonTexture1DView | A new GorgonTexture1DView |
Remarks
This will load an IGorgonImage from a stream
and put it into a GorgonTexture1D object and return a GorgonTexture1DView.
If the size
option is specified, then the method will read from the stream up to that number of bytes, so it is up to the user to provide an accurate size. If it is omitted
then the stream length - stream position
is used as the total size.
If specified, the options
parameter will define how Gorgon and shaders should handle the texture. The GorgonTextureLoadOptions type contains the following:
- BindingWhen defined, will indicate the TextureBinding that defines how the texture will be bound to the graphics pipeline. If it is omitted, then the binding will be ShaderResource.
- UsageWhen defined, will indicate the preferred usage for the texture. If it is omitted, then the usage will be set to Default.
- Multisample infoWhen defined (i.e. not null), defines the multisampling to apply to the texture. If omitted, then the default is NoMultiSampling.
- ConvertToPremultipliedAlphaConverts the image to premultiplied alpha before uploading the image data to the texture.
Since the GorgonTexture1D created by this method is linked to the GorgonTexture1DView returned, disposal of either one will dispose of the other on your behalf. If the user created a GorgonTexture1DView from the GetShaderResourceView(BufferFormat, int, int, int, int) method on the GorgonTexture1D, then it's assumed the user knows what they are doing and will handle the disposal of the texture and view on their own.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
IOException | Thrown if the |
EndOfStreamException | Thrown if reading the image would move beyond the end of the |
GetMipWidth(int)
Function to return the width of the render target at the current MipSlice in pixels.
Declaration
public int GetMipWidth(int mipLevel)
Parameters
Type | Name | Description |
---|---|---|
int | mipLevel | The mip level to evaluate. |
Returns
Type | Description |
---|---|
int | The width of the mip map level assigned to MipSlice for the texture associated with the render target. |
ToPixel(GorgonRangeF, int?)
Function to convert a GorgonRangeF of texel coordinates to pixel space.
Declaration
public GorgonRange ToPixel(GorgonRangeF texelCoordinates, int? mipLevel = null)
Parameters
Type | Name | Description |
---|---|---|
GorgonRangeF | texelCoordinates | The texel coordinates to convert. |
int? | mipLevel | [Optional] The mip level to use. |
Returns
Type | Description |
---|---|
GorgonRange | A GorgonRange containing the pixel space coordinates. |
Remarks
If specified, the mipLevel
only applies to the MipSlice and MipCount for this view, it will be constrained if it falls outside of that range.
Because of this, the coordinates returned may not be the exact size of the texture bound to the view at mip level 0. If the mipLevel
is omitted, then the first mip level
for the underlying Texture is used.
ToPixel(float, int?)
Function to convert a floating point value from texel coordinates to pixel space.
Declaration
public int ToPixel(float texelOffset, int? mipLevel = null)
Parameters
Type | Name | Description |
---|---|---|
float | texelOffset | The floating point texel to convert. |
int? | mipLevel | [Optional] The mip level to use. |
Returns
Type | Description |
---|---|
int | An integer value containing the pixel space coordinates. |
Remarks
If specified, the mipLevel
only applies to the MipSlice and MipCount for this view, it will be constrained if it falls outside of that range.
Because of this, the coordinates returned may not be the exact size of the texture bound to the view at mip level 0. If the mipLevel
is omitted, then the first mip level
for the underlying Texture is used.
ToTexel(GorgonRange, int?)
Function to convert a GorgonRange of pixel coordinates to texel space.
Declaration
public GorgonRangeF ToTexel(GorgonRange pixelCoordinates, int? mipLevel = null)
Parameters
Type | Name | Description |
---|---|---|
GorgonRange | pixelCoordinates | The pixel coordinates to convert. |
int? | mipLevel | [Optional] The mip level to use. |
Returns
Type | Description |
---|---|
GorgonRangeF | A GorgonRangeF containing the texel space coordinates. |
Remarks
If specified, the mipLevel
only applies to the MipSlice and MipCount for this view, it will be constrained if it falls outside of that range.
Because of this, the coordinates returned may not be the exact size of the texture bound to the view at mip level 0. If the mipLevel
is omitted, then the first mip level
for the underlying Texture is used.
ToTexel(int, int?)
Function to convert an integer value from pixel coordinates to texel space.
Declaration
public float ToTexel(int pixelOffset, int? mipLevel = null)
Parameters
Type | Name | Description |
---|---|---|
int | pixelOffset | The pixel offset to convert. |
int? | mipLevel | [Optional] The mip level to use. |
Returns
Type | Description |
---|---|
float | A floating point value containing the texel space coordinates. |
Remarks
If specified, the mipLevel
only applies to the MipSlice and MipCount for this view, it will be constrained if it falls outside of that range.
Because of this, the coordinates returned may not be the exact size of the texture bound to the view at mip level 0. If the mipLevel
is omitted, then the first mip level
for the underlying Texture is used.