Gorgon
Show / Hide Table of Contents

Class GorgonStructuredReadWriteView

Provides a read/write (unordered access) view for a GorgonBuffer containing structured data.

Inheritance
object
GorgonResourceView
GorgonReadWriteView
GorgonBufferReadWriteViewCommon<GorgonBuffer>
GorgonStructuredReadWriteView
Implements
IDisposable
IGorgonGraphicsObject
IEquatable<GorgonResourceView>
IGorgonBufferInfo
IGorgonNamedObject
Inherited Members
GorgonBufferReadWriteViewCommon<GorgonBuffer>.Buffer
GorgonBufferReadWriteViewCommon<GorgonBuffer>.StartElement
GorgonBufferReadWriteViewCommon<GorgonBuffer>.ElementCount
GorgonBufferReadWriteViewCommon<GorgonBuffer>.TotalElementCount
GorgonReadWriteView.Clear(int, int, int, int)
GorgonReadWriteView.Clear(int)
GorgonReadWriteView.Clear(float, float, float, float)
GorgonReadWriteView.Clear(float)
GorgonReadWriteView.Clear(Vector4)
GorgonReadWriteView.Dispose()
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 GorgonStructuredReadWriteView : GorgonBufferReadWriteViewCommon<GorgonBuffer>, IDisposable, IGorgonGraphicsObject, IEquatable<GorgonResourceView>, IGorgonBufferInfo, IGorgonNamedObject
Remarks

This type of view allows for unordered access to a GorgonBuffer. The buffer must have been created with the ReadWrite flag in its Binding property, and have a StructureSize greater than 0.

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.

warning

Unordered access views do not support multisampled GorgonTexture2Ds.

Properties

| Edit this page View Source

AllowCpuRead

Property to set or return whether to allow the CPU read access to the buffer.

Declaration
public bool AllowCpuRead { get; }
Property Value
Type Description
bool
Remarks

This value indicates whether or not the CPU can directly access the buffer for reading. If this value is false, the buffer still can be read, but will be done through an intermediate staging buffer, which is obviously less performant.

This value is treated as false if the buffer does not have a Binding containing the Shader flag, and does not have a Usage of Default. This means any reads will be done through an intermediate staging buffer, impacting performance.

If the Usage property is set to Staging, then this value is treated as true because staging buffers are CPU only and as such, can be read directly by the CPU regardless of this value.

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

Binding

Property to return the type of binding for the GPU.

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

ElementSize

Property to return the size of an element, in bytes.

Declaration
public override int ElementSize { get; }
Property Value
Type Description
int
Overrides
GorgonBufferReadWriteViewCommon<GorgonBuffer>.ElementSize
See Also
GorgonGraphicsResource
GorgonComputeShader
GorgonPixelShader
GorgonDrawCallCommon
| Edit this page View Source

IndirectArgs

Property to return whether the buffer will contain indirect argument data.

Declaration
public bool IndirectArgs { get; }
Property Value
Type Description
bool
Remarks

This flag only applies to buffers with a Binding of ReadWrite, and/or Shader. If the binding is set to anything else, then this flag is treated as being set to false.

The default value is false.

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

ReadWriteViewType

Property to return the type of view.

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

StructureSize

Property to return the size, in bytes, of an individual structure in a structured buffer.

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

This value will be rounded to the nearest multiple of 4.

See Also
GorgonGraphicsResource
GorgonComputeShader
GorgonPixelShader
GorgonDrawCallCommon

Methods

| Edit this page View Source

CopyStructureCount(GorgonBufferCommon, int)

Function to copy the structure count from this view into a buffer.

Declaration
public void CopyStructureCount(GorgonBufferCommon buffer, int offset = 0)
Parameters
Type Name Description
GorgonBufferCommon buffer

The buffer that will receive the data.

int offset

[Optional] The offset, in bytes, within the buffer attached to this view to start reading from.

Remarks

When the structure unordered access view is set up with a Append, or Counter, the values updated by these flags are not readily accessible from the CPU. To retrieve these values, this method must be called to retrieve the values. These values are copied into the buffer provided to the method so that applications can make use of data generated on the GPU. Note that this value will be written out as a 32 bit unsigned integer.

If the unordered access view does not specify the appropriate values on the ReadWriteViewType, then this method will do nothing.

important

For performance reasons, exceptions will only be thrown from this method when Gorgon is compiled as DEBUG.

See Also
GorgonGraphicsResource
GorgonComputeShader
GorgonPixelShader
GorgonDrawCallCommon

Implements

IDisposable
IGorgonGraphicsObject
IEquatable<T>
IGorgonBufferInfo
IGorgonNamedObject

Extension Methods

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

See Also

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