Class GorgonDepthStencil2DView
A depth/stencil view for textures.
Implements
Inherited Members
Namespace: Gorgon.Graphics.Core
Assembly: Gorgon.Graphics.Core.dll
Syntax
public sealed class GorgonDepthStencil2DView : GorgonResourceView, IDisposable, IGorgonGraphicsObject, IEquatable<GorgonResourceView>, IGorgonTexture2DInfo, IGorgonNamedObject, IGorgonImageInfo
Remarks
This is a depth/stencil view to allow a GorgonTexture2D to be bound to the GPU pipeline as a depth/stencil 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 |
See Also
| Edit this page View SourceArrayIndex
Property to return the first array index to use in the view.
Declaration
public int ArrayIndex { get; }
Property Value
Type | Description |
---|---|
int |
See Also
| Edit this page View SourceBinding
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
| Edit this page View SourceBounds
Property to return the bounding rectangle for the render target 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 render target.
See Also
| Edit this page View SourceFlags
Property to return the flags for this view.
Declaration
public DepthStencilViewFlags Flags { get; }
Property Value
Type | Description |
---|---|
DepthStencilViewFlags |
Remarks
This will allow the depth/stencil buffer to be read simultaneously from the depth/stencil view and from a shader view. It is not normally possible to bind a view of a resource to 2 parts of the pipeline at the same time. However, with the flags provided, read-only access may be granted to a part of the resource (depth or stencil) or all of it for all parts of the pipline. This would bind the depth/stencil as a read-only view and make it a read-only view accessible to shaders.
This is only valid if the resource allows shader access.
See Also
| Edit this page View SourceFormat
Property to return the format for this view.
Declaration
public BufferFormat Format { get; }
Property Value
Type | Description |
---|---|
BufferFormat |
See Also
| Edit this page View SourceFormatInformation
Property to return the format information for the Format of this view.
Declaration
public GorgonFormatInfo FormatInformation { get; }
Property Value
Type | Description |
---|---|
GorgonFormatInfo |
See Also
| Edit this page View SourceHeight
Property to return the height of the render target in pixels.
Declaration
public int Height { 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 render target.
See Also
| Edit this page View SourceIsCubeMap
Property to return whether the 2D texture is a cube map.
Declaration
public bool IsCubeMap { get; }
Property Value
Type | Description |
---|---|
bool |
See Also
| Edit this page View SourceMipHeight
Property to return the height of the render target at the current MipSlice in pixels.
Declaration
public int MipHeight { get; }
Property Value
Type | Description |
---|---|
int |
Remarks
This value is the height of the mip map level assigned to MipSlice for the texture associated with the render target.
See Also
| Edit this page View SourceMipSlice
Property to return the mip slice to use for the view.
Declaration
public int MipSlice { get; }
Property Value
Type | Description |
---|---|
int |
See Also
| Edit this page View SourceMipWidth
Property to return the width of the render target at the current MipSlice in pixels.
Declaration
public int MipWidth { get; }
Property Value
Type | Description |
---|---|
int |
Remarks
This value is the width of the mip map level assigned to MipSlice for the texture associated with the render target.
See Also
| Edit this page View SourceMultisampleInfo
Property to return the multisample quality and count for the texture.
Declaration
public GorgonMultisampleInfo MultisampleInfo { get; }
Property Value
Type | Description |
---|---|
GorgonMultisampleInfo |
See Also
| Edit this page View SourceShared
Property to return whether the resource used by this view can be shared or not.
Declaration
public TextureSharingOptions Shared { get; }
Property Value
Type | Description |
---|---|
TextureSharingOptions |
See Also
| Edit this page View SourceTexture
Property to return the texture bound to this view.
Declaration
public GorgonTexture2D Texture { get; }
Property Value
Type | Description |
---|---|
GorgonTexture2D |
See Also
| Edit this page View SourceWidth
Property to return the width of the render target 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 render target.
See Also
Methods
| Edit this page View SourceClear(float, byte)
Function to clear the depth and stencil portion of the buffer for this view.
Declaration
public void Clear(float depthValue, byte stencilValue)
Parameters
Type | Name | Description |
---|---|---|
float | depthValue | The depth value to write to the depth portion of the buffer. |
byte | stencilValue | The stencil value to write to the stencil portion of the buffer. |
Remarks
If the view Format does not have a stencil component, then the stencilValue
will be ignored. Likewise, if the Format lacks a depth component,
then the depthValue
will be ignored.
See Also
| Edit this page View SourceClear(float, ReadOnlySpan<Rectangle>)
Function to clear the contents of the depth buffer for this view.
Declaration
public void Clear(float depthValue, ReadOnlySpan<Rectangle> rectangles)
Parameters
Type | Name | Description |
---|---|---|
float | depthValue | Depth value to use when clearing the depth view. |
ReadOnlySpan<Rectangle> | rectangles | [Optional] Specifies which regions on the view to clear. |
Remarks
This will clear the depth view to the specified depthValue
. If a specific region should be cleared, one or more rectangles
should be passed to the
method.
If the rectangles
parameter is null, or has a zero length, the entirety of the view is cleared.
If this method is called with a 3D texture bound to the view, or the view references uses a Buffer with a stencil component, and with regions specified, then the regions are ignored.
See Also
| Edit this page View SourceClearDepth(float)
Function to clear the depth portion of the buffer for this view.
Declaration
public void ClearDepth(float depthValue)
Parameters
Type | Name | Description |
---|---|---|
float | depthValue | The depth value to write to the buffer. |
Remarks
If the view Format does not have a depth component, then this method will do nothing.
See Also
| Edit this page View SourceClearStencil(byte)
Function to clear the stencil portion of the buffer for this view.
Declaration
public void ClearStencil(byte stencilValue)
Parameters
Type | Name | Description |
---|---|---|
byte | stencilValue | The stencil value to write to the buffer. |
Remarks
If the view Format does not have a stencil component, then this method will do nothing.
See Also
| Edit this page View SourceCreateDepthStencil(GorgonGraphics, IGorgonTexture2DInfo, DepthStencilViewFlags)
Function to create a new depth/stencil buffer that is bindable to the GPU.
Declaration
public static GorgonDepthStencil2DView CreateDepthStencil(GorgonGraphics graphics, IGorgonTexture2DInfo info, DepthStencilViewFlags viewFlags = DepthStencilViewFlags.None)
Parameters
Type | Name | Description |
---|---|---|
GorgonGraphics | graphics | The graphics interface to use when creating the target. |
IGorgonTexture2DInfo | info | The information about the depth/stencil texture. |
DepthStencilViewFlags | viewFlags | [Optional] Flags used to determine if the depth buffer/stencil can be read by the GPU or not. |
Returns
Type | Description |
---|---|
GorgonDepthStencil2DView | A new GorgonDepthStencil2DView. |
Remarks
This is a convenience method that will create a GorgonTexture2D and a GorgonDepthStencil2DView as a single object that users can use to apply a depth/stencil texture. This helps simplify creation of a render target by executing some prerequisite steps on behalf of the user.
Since the GorgonTexture2D created by this method is linked to the GorgonDepthStencil2DView returned, disposal of either one will dispose of the other on your behalf. If the user created a GorgonDepthStencil2DView from the GetRenderTargetView(BufferFormat, int, int, int) method on the GorgonTexture2D, then it's assumed the user knows what they are doing and will handle the disposal of the texture and view on their own.
To make the texture bindable on the GPU as a shader resource view, set the Binding to include the ShaderResource flag in the value
and set the viewFlags
to ReadOnlyDepth, ReadOnlyStencil or both.
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
See Also
| Edit this page View SourceGetDepthStencilView(BufferFormat, DepthStencilViewFlags)
Function to create a new GorgonDepthStencil2DView for this texture.
Declaration
public GorgonDepthStencil2DView GetDepthStencilView(BufferFormat format = BufferFormat.Unknown, DepthStencilViewFlags flags = DepthStencilViewFlags.None)
Parameters
Type | Name | Description |
---|---|---|
BufferFormat | format | [Optional] The format for the view. |
DepthStencilViewFlags | flags | [Optional] Flags to define how this view should be accessed by the shader. |
Returns
Type | Description |
---|---|
GorgonDepthStencil2DView | A GorgonDepthStencil2DView used to bind the texture as a depth/stencil buffer. |
Remarks
The depth/stencil views take a DepthStencilViewFlags parameter that determine how a shader can access the depth buffer when it is bound to the pipeline for reading. By specifying a single flag, the depth can write to the opposite plane (e.g. read only depth and write only stencil, write only depth and read only stencil) of the texture. This allows for multiple depth/stencil views to be bound to the pipeline for reading and writing.
If the Binding for the texture includes ShaderResource, then the format
for the view and the Format for the texture
must be specific values. These values are listed below:
Depth Format | Texture Format |
---|---|
D32_Float_S8X24_UInt | R32G8X24_Typeless |
D24_UNorm_S8_UInt | R24G8_Typeless |
D32_Float | R32_Typeless |
D16_UNorm | R16_Typeless |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown when the |
GorgonException | Thrown when this texture does not have a TextureBinding of DepthStencil. -or- Thrown when this texture has a Usage of Staging. -or- Thrown if this texture has a Binding of ShaderResource, but the texture format is not a typeless format. |
See Also
| Edit this page View SourceGetShaderResourceView(BufferFormat)
Function to create a new GorgonTexture2DView for this texture.
Declaration
public GorgonTexture2DView GetShaderResourceView(BufferFormat format = BufferFormat.Unknown)
Parameters
Type | Name | Description |
---|---|---|
BufferFormat | format | [Optional] The format for the view. |
Returns
Type | Description |
---|---|
GorgonTexture2DView | A GorgonTexture2DView used to bind the texture to a shader. |
Remarks
This will create a view that makes a texture accessible to shaders. This allows viewing of the texture data in a different format, or even a subsection of the texture from within the shader.
The format
parameter is used present the texture data as another format type to the shader. If this value is left at the default of Unknown, then
the format from the this texture is used. The format
must be castable to the format of this texture. If it is not, an exception will be thrown.
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the |
GorgonException | Thrown when this texture does not have a TextureBinding of ShaderResource. -or- Thrown when this texture has a usage of Staging. -or- Thrown if the texture Format is not typeless, and the Binding is set to DepthStencil. |
See Also
| Edit this page View SourceToPixel(RectangleF)
Function to convert a rectangle of texel coordinates to pixel space.
Declaration
public Rectangle ToPixel(RectangleF texelCoordinates)
Parameters
Type | Name | Description |
---|---|---|
RectangleF | texelCoordinates | The texel coordinates to convert. |
Returns
Type | Description |
---|---|
Rectangle | A rectangle containing the pixel space coordinates. |
See Also
| Edit this page View SourceToPixel(Size2F)
Function to convert a size value from texel coordinates to pixel space.
Declaration
public Size2 ToPixel(Size2F texelSize)
Parameters
Type | Name | Description |
---|---|---|
Size2F | texelSize | The texel size to convert. |
Returns
Type | Description |
---|---|
Size2 | A size value containing the texel space coordinates. |
See Also
| Edit this page View SourceToPixel(Vector2)
Function to convert a 2D vector value from texel coordinates to pixel space.
Declaration
public Vector2 ToPixel(Vector2 texelVector)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | texelVector | The texel size to convert. |
Returns
Type | Description |
---|---|
Vector2 | A 2D vector containing the pixel space coordinates. |
See Also
| Edit this page View SourceToTexel(Rectangle)
Function to convert a rectangle of pixel coordinates to texel space.
Declaration
public RectangleF ToTexel(Rectangle pixelCoordinates)
Parameters
Type | Name | Description |
---|---|---|
Rectangle | pixelCoordinates | The pixel coordinates to convert. |
Returns
Type | Description |
---|---|
RectangleF | A rectangle containing the texel space coordinates. |
See Also
| Edit this page View SourceToTexel(Size2)
Function to convert a size value from pixel coordinates to texel space.
Declaration
public Size2F ToTexel(Size2 pixelSize)
Parameters
Type | Name | Description |
---|---|---|
Size2 | pixelSize | The pixel size to convert. |
Returns
Type | Description |
---|---|
Size2F | A size value containing the texel space coordinates. |
See Also
| Edit this page View SourceToTexel(Vector2)
Function to convert a 2D vector value from pixel coordinates to texel space.
Declaration
public Vector2 ToTexel(Vector2 pixelVector)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | pixelVector | The pixel size to convert. |
Returns
Type | Description |
---|---|
Vector2 | A 2D vector containing the texel space coordinates. |