Gorgon
Show / Hide Table of Contents

Class GorgonTexture3DReadWriteView

Provides a read/write (unordered access) view for a GorgonTexture3D.

Inheritance
object
GorgonResourceView
GorgonReadWriteView
GorgonTexture3DReadWriteView
Implements
IDisposable
IGorgonGraphicsObject
IEquatable<GorgonResourceView>
IGorgonTexture3DInfo
IGorgonNamedObject
IGorgonImageInfo
Inherited Members
GorgonReadWriteView.Clear(int, int, int, int)
GorgonReadWriteView.Clear(int)
GorgonReadWriteView.Clear(float, float, float, float)
GorgonReadWriteView.Clear(float)
GorgonReadWriteView.Clear(Vector4)
GorgonResourceView.IsDisposed
GorgonResourceView.Resource
GorgonResourceView.Usage
GorgonResourceView.Graphics
GorgonResourceView.Equals(GorgonResourceView)
GorgonResourceView.Equals(object)
GorgonResourceView.GetHashCode()
object.ToString()
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetType()
Namespace: Gorgon.Graphics.Core
Assembly: Gorgon.Graphics.Core.dll
Syntax
public sealed class GorgonTexture3DReadWriteView : GorgonReadWriteView, IDisposable, IGorgonGraphicsObject, IEquatable<GorgonResourceView>, IGorgonTexture3DInfo, IGorgonNamedObject, IGorgonImageInfo
Remarks

This type of view allows for unordered access to a GorgonTexture3D. The texture must have been created with the ReadWriteView flag in its Binding property.

The unordered access allows a shader to read/write any part of a GorgonGraphicsResource by multiple threads without memory contention. This is done through the use of atomic functions.

These types of views are most useful for GorgonComputeShader shaders, but can also be used by a GorgonPixelShader by passing a list of these views in to a draw call.

Properties

| Edit this page View Source

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
See Also
GorgonGraphicsResource
GorgonTexture3D
GorgonComputeShader
GorgonPixelShader
GorgonDrawCallCommon
GorgonMultisampleInfo
| Edit this page View Source

Bounds

Property to return the bounding rectangle for the view.

Declaration
public Rectangle Bounds { get; }
Property Value
Type Description
Rectangle
Remarks

This value is the full bounding rectangle of the first mip map level for the texture associated with the view.

See Also
GorgonGraphicsResource
GorgonTexture3D
GorgonComputeShader
GorgonPixelShader
GorgonDrawCallCommon
GorgonMultisampleInfo
| Edit this page View Source

Depth

Property to return the depth of the texture, in slices.

Declaration
public int Depth { get; }
Property Value
Type Description
int
See Also
GorgonGraphicsResource
GorgonTexture3D
GorgonComputeShader
GorgonPixelShader
GorgonDrawCallCommon
GorgonMultisampleInfo
| Edit this page View Source

DepthSliceCount

Property to return the number of array indices to use in the view.

Declaration
public int DepthSliceCount { get; }
Property Value
Type Description
int
See Also
GorgonGraphicsResource
GorgonTexture3D
GorgonComputeShader
GorgonPixelShader
GorgonDrawCallCommon
GorgonMultisampleInfo
| Edit this page View Source

Format

Property to return the format used to interpret this view.

Declaration
public BufferFormat Format { get; }
Property Value
Type Description
BufferFormat
See Also
GorgonGraphicsResource
GorgonTexture3D
GorgonComputeShader
GorgonPixelShader
GorgonDrawCallCommon
GorgonMultisampleInfo
| Edit this page View Source

FormatInformation

Property to return information about the Format used by this view.

Declaration
public GorgonFormatInfo FormatInformation { get; }
Property Value
Type Description
GorgonFormatInfo
See Also
GorgonGraphicsResource
GorgonTexture3D
GorgonComputeShader
GorgonPixelShader
GorgonDrawCallCommon
GorgonMultisampleInfo
| Edit this page View Source

Height

Property to return the height of the texture in pixels.

Declaration
public int Height { get; }
Property Value
Type Description
int
Remarks

This value is the full height of the first mip map level for the texture associated with the view.

See Also
GorgonGraphicsResource
GorgonTexture3D
GorgonComputeShader
GorgonPixelShader
GorgonDrawCallCommon
GorgonMultisampleInfo
| Edit this page View Source

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
See Also
GorgonGraphicsResource
GorgonTexture3D
GorgonComputeShader
GorgonPixelShader
GorgonDrawCallCommon
GorgonMultisampleInfo
| Edit this page View Source

StartDepthSlice

Property to return the first depth slice to use in the view.

Declaration
public int StartDepthSlice { get; }
Property Value
Type Description
int
See Also
GorgonGraphicsResource
GorgonTexture3D
GorgonComputeShader
GorgonPixelShader
GorgonDrawCallCommon
GorgonMultisampleInfo
| Edit this page View Source

Texture

Property to return the texture that is bound to this view.

Declaration
public GorgonTexture3D Texture { get; }
Property Value
Type Description
GorgonTexture3D
See Also
GorgonGraphicsResource
GorgonTexture3D
GorgonComputeShader
GorgonPixelShader
GorgonDrawCallCommon
GorgonMultisampleInfo
| Edit this page View Source

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.

See Also
GorgonGraphicsResource
GorgonTexture3D
GorgonComputeShader
GorgonPixelShader
GorgonDrawCallCommon
GorgonMultisampleInfo

Methods

| Edit this page View Source

CreateTexture(GorgonGraphics, IGorgonTexture3DInfo, IGorgonImage)

Function to create a new texture that is bindable to the GPU as an unordered access resource.

Declaration
public static GorgonTexture3DReadWriteView CreateTexture(GorgonGraphics graphics, IGorgonTexture3DInfo info, IGorgonImage initialData = null)
Parameters
Type Name Description
GorgonGraphics graphics

The graphics interface to use when creating the target.

IGorgonTexture3DInfo info

The information about the texture.

IGorgonImage initialData

[Optional] Initial data used to populate the texture.

Returns
Type Description
GorgonTexture3DReadWriteView

A new GorgonTexture3DReadWriteView.

Remarks

This is a convenience method that will create a GorgonTexture3D and a GorgonTexture3DReadWriteView as a single object that users can use to apply a texture as an unordered access resource. This helps simplify creation of a texture by executing some prerequisite steps on behalf of the user.

Since the GorgonTexture3D created by this method is linked to the GorgonTexture3DReadWriteView returned, disposal of either one will dispose of the other on your behalf. If the user created a GorgonTexture3DReadWriteView from the GetReadWriteView(BufferFormat, int, int, int) method on the GorgonTexture3D, 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 graphics, or info parameter is null.

See Also
GorgonTexture3D
| Edit this page View Source

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Declaration
public override void Dispose()
Overrides
GorgonReadWriteView.Dispose()
See Also
GorgonGraphicsResource
GorgonTexture3D
GorgonComputeShader
GorgonPixelShader
GorgonDrawCallCommon
GorgonMultisampleInfo
| Edit this page View Source

FromFile(GorgonGraphics, string, IGorgonImageCodec, GorgonTextureLoadOptions)

Function to load a texture from a file.

Declaration
public static GorgonTexture3DReadWriteView 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
GorgonTexture3DReadWriteView

A new GorgonTexture3DReadWriteView

Remarks

This will load an IGorgonImage from a file on disk and put it into a GorgonTexture3D object and return a GorgonTexture3DReadWriteView.

If specified, the optionsparameter 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 GorgonTexture3D created by this method is linked to the GorgonTexture3DReadWriteView returned, disposal of either one will dispose of the other on your behalf. If the user created a GorgonTexture3DReadWriteView from the GetShaderResourceView(BufferFormat, int, int) method on the GorgonTexture3D, 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 graphics, filePath, or the codec parameter is null.

ArgumentEmptyException

Thrown when the filePath parameter is empty.

See Also
GorgonGraphicsResource
GorgonTexture3D
GorgonComputeShader
GorgonPixelShader
GorgonDrawCallCommon
GorgonMultisampleInfo
| Edit this page View Source

FromStream(GorgonGraphics, Stream, IGorgonImageCodec, long?, GorgonTextureLoadOptions)

Function to load a texture from a Stream.

Declaration
public static GorgonTexture3DReadWriteView 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
GorgonTexture3DReadWriteView

A new GorgonTexture3DReadWriteView

Remarks

This will load an IGorgonImage from a stream and put it into a GorgonTexture3D object and return a GorgonTexture3DReadWriteView.

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 optionsparameter 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 GorgonTexture3D created by this method is linked to the GorgonTexture3DReadWriteView returned, disposal of either one will dispose of the other on your behalf. If the user created a GorgonTexture3DReadWriteView from the GetShaderResourceView(BufferFormat, int, int) method on the GorgonTexture3D, 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 graphics, stream, or the codec parameter is null.

IOException

Thrown if the stream is write only.

EndOfStreamException

Thrown if reading the image would move beyond the end of the stream.

See Also
GorgonGraphicsResource
GorgonTexture3D
GorgonComputeShader
GorgonPixelShader
GorgonDrawCallCommon
GorgonMultisampleInfo
| Edit this page View Source

GetMipDepth(int)

Function to return the depth of the texture at the current MipSlice in slices.

Declaration
public int GetMipDepth(int mipLevel)
Parameters
Type Name Description
int mipLevel

The mip level to evaluate.

Returns
Type Description
int

The height of the mip map level assigned to MipSlice for the texture associated with the texture.

See Also
GorgonGraphicsResource
GorgonTexture3D
GorgonComputeShader
GorgonPixelShader
GorgonDrawCallCommon
GorgonMultisampleInfo
| Edit this page View Source

GetMipHeight(int)

Function to return the height of the texture at the current MipSlice in pixels.

Declaration
public int GetMipHeight(int mipLevel)
Parameters
Type Name Description
int mipLevel

The mip level to evaluate.

Returns
Type Description
int

The height of the mip map level assigned to MipSlice for the texture associated with the view.

See Also
GorgonGraphicsResource
GorgonTexture3D
GorgonComputeShader
GorgonPixelShader
GorgonDrawCallCommon
GorgonMultisampleInfo
| Edit this page View Source

GetMipWidth(int)

Function to return the width of the texture 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 view.

See Also
GorgonGraphicsResource
GorgonTexture3D
GorgonComputeShader
GorgonPixelShader
GorgonDrawCallCommon
GorgonMultisampleInfo
| Edit this page View Source

ToPixel(Size2F, int?)

Function to convert a texel size into a pixel size.

Declaration
public Size2 ToPixel(Size2F texelCoordinates, int? mipLevel = null)
Parameters
Type Name Description
Size2F texelCoordinates

The texel size to convert.

int? mipLevel

[Optional] The mip level to use.

Returns
Type Description
Size2

The pixel size.

Remarks

If specified, the mipLevel only applies to the MipSlice 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.

See Also
GorgonGraphicsResource
GorgonTexture3D
GorgonComputeShader
GorgonPixelShader
GorgonDrawCallCommon
GorgonMultisampleInfo
| Edit this page View Source

ToPixel(Vector3, int?)

Function to convert a texel coordinate into a pixel coordinate and a depth slice.

Declaration
public (Point, int) ToPixel(Vector3 texelCoordinates, int? mipLevel = null)
Parameters
Type Name Description
Vector3 texelCoordinates

The texel coordinates to convert.

int? mipLevel

[Optional] The mip level to use.

Returns
Type Description
(Point, int)

The pixel coordinates.

Remarks

If specified, the mipLevel only applies to the MipSlice 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.

See Also
GorgonGraphicsResource
GorgonTexture3D
GorgonComputeShader
GorgonPixelShader
GorgonDrawCallCommon
GorgonMultisampleInfo
| Edit this page View Source

ToTexel(Point, int?, int?)

Function to convert a pixel coordinate into a texel coordinate.

Declaration
public Vector3 ToTexel(Point pixelCoordinates, int? mipLevel = null, int? depthSlice = null)
Parameters
Type Name Description
Point pixelCoordinates

The pixel coordinate to convert.

int? mipLevel

[Optional] The mip level to use.

int? depthSlice

[Optional] The depth slice to use.

Returns
Type Description
Vector3

The texel coordinates.

Remarks

If specified, the mipLevel only applies to the MipSlice 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.

If specified, the depthSlice only applies to the StartDepthSlice and DepthSliceCount 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 depth slice is used.

See Also
GorgonGraphicsResource
GorgonTexture3D
GorgonComputeShader
GorgonPixelShader
GorgonDrawCallCommon
GorgonMultisampleInfo
| Edit this page View Source

ToTexel(Size2, int?)

Function to convert a pixel size into a texel size.

Declaration
public Size2F ToTexel(Size2 pixelCoordinates, int? mipLevel = null)
Parameters
Type Name Description
Size2 pixelCoordinates

The pixel size to convert.

int? mipLevel

[Optional] The mip level to use.

Returns
Type Description
Size2F

The texel size.

Remarks

If specified, the mipLevel only applies to the MipSlice 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.

See Also
GorgonGraphicsResource
GorgonTexture3D
GorgonComputeShader
GorgonPixelShader
GorgonDrawCallCommon
GorgonMultisampleInfo

Implements

IDisposable
IGorgonGraphicsObject
IEquatable<T>
IGorgonTexture3DInfo
IGorgonNamedObject
IGorgonImageInfo

Extension Methods

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

See Also

GorgonGraphicsResource
GorgonTexture3D
GorgonComputeShader
GorgonPixelShader
GorgonDrawCallCommon
GorgonMultisampleInfo
  • 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