ComputeShader 与 ComputeBuffer 资料

ComputeShader

Description

Compute Shader asset.

Compute shaders are programs that run on the GPU outside of the normal rendering pipeline. They correspond to compute shader assets in the project (.compute files).

Compute shader support can be queried runtime using SystemInfo.supportsComputeShaders. See Compute Shaders overview for more info about platforms supporting compute shaders.

Properties

enabledKeywordsAn array containing the local shader keywords that are currently enabled for this compute shader.
keywordSpaceThe local keyword space of this compute shader.
shaderKeywordsAn array containing names of the local shader keywords that are currently enabled for this compute shader.

Public Methods

DisableKeywordDisables a local shader keyword for this compute shader.
DispatchExecute a compute shader.
DispatchIndirectExecute a compute shader.
EnableKeywordEnables a local shader keyword for this compute shader.
FindKernelFind ComputeShader kernel index.
GetKernelThreadGroupSizesGet kernel thread group sizes.
HasKernelChecks whether a shader contains a given kernel.
IsKeywordEnabledChecks whether a local shader keyword is enabled for this compute shader.
IsSupportedAllows you to check whether the current end user device supports the features required to run the specified compute shader kernel.
SetBoolSet a bool parameter.
SetBufferSets an input or output compute buffer.
SetConstantBufferSets a ComputeBuffer or a GraphicsBuffer as a named constant buffer for the ComputeShader.
SetFloatSet a float parameter.
SetFloatsSet multiple consecutive float parameters at once.
SetIntSet an integer parameter.
SetIntsSet multiple consecutive integer parameters at once.
SetKeywordSets the state of a local shader keyword for this compute shader.
SetMatrixSet a Matrix parameter.
SetMatrixArraySet a Matrix array parameter.
SetTextureSet a texture parameter.
SetTextureFromGlobalSet a texture parameter from a global texture property.
SetVectorSet a vector parameter.
SetVectorArraySet a vector array parameter.

Inherited Members

Properties

hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
nameThe name of the object.

Public Methods

GetInstanceIDGets the instance ID of the object.
ToStringReturns the name of the object.

Static Methods

DestroyRemoves a GameObject, component or asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadDo not destroy the target Object when loading a new Scene.
FindObjectOfTypeReturns the first active loaded object of Type type.
FindObjectsOfTypeGets a list of all loaded objects of Type type.
InstantiateClones the object original and returns the clone.

Operators

boolDoes the object exist?
operator !=Compares if two objects refer to a different object.
operator ==Compares two object references to see if they refer to the same object.

/

ComputeBuffer

Description

GPU data buffer, mostly for use with compute shaders.

ComputeShader programs often need arbitrary data to be read & written into memory buffers. ComputeBuffer class is exactly for that - you can create & fill them from script code, and use them in compute shaders or regular shaders.

Compute buffers are always supported in compute shaders. Compute shader support can be queried runtime using SystemInfo.supportsComputeShaders. See the Compute Shaders Manual page for more information about platforms supporting compute shaders. In regular graphics shaders the compute buffer support requires minimum shader model 4.5.

For a ComputeBuffer that uses a counter, Metal and Vulkan platforms don't have native counters and use separate small buffers that act as counters internally. These small buffers are bound separately from the ComputeBuffer and count towards the limit of possible buffers bound (31 for Metal, based on the device for Vulkan).

On the shader side, ComputeBuffers with default ComputeBufferType map to StructuredBuffer<T> and RWStructuredBuffer<T> in HLSL.

See Also: ComputeShader class, Shader.SetGlobalBufferMaterial.SetBufferCompute Shaders overview.

Properties

countNumber of elements in the buffer (Read Only).
nameThe debug label for the compute buffer (setter only).
strideSize of one element in the buffer (Read Only).

Constructors

ComputeBufferCreate a Compute Buffer.

Public Methods

BeginWriteBegins a write operation to the buffer
EndWriteEnds a write operation to the buffer
GetDataRead data values from the buffer into an array. The array can only use blittable types.
GetNativeBufferPtrRetrieve a native (underlying graphics API) pointer to the buffer.
IsValidReturns true if this compute buffer is valid and false otherwise.
ReleaseRelease a Compute Buffer.
SetCounterValueSets counter value of append/consume buffer.
SetDataSet the buffer with values from an array.

Static Methods

CopyCountCopy counter value of append/consume buffer into another buffer.

//

//

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值