UUSL计算着色器
UUSL supports compute shaders: there are special functions, semantics and parameters for compute shaders. UUSL支持计算着色器:计算着色器具有特殊的功能,语义和参数。
In UNIGINE, compute shaders have a *.comp extension.在Unigine中,计算着色器的扩展名为*.comp。
A compute shader is a special part of the graphics pipeline. It allows to execute code on the GPU, read and write buffer data.计算着色器是图形管道的特殊部分。它允许在GPU上执行代码,读取和写入缓冲区数据。
This article assumes you have prior knowledge of the compute shaders. Also, read the following topics on UUSL before proceeding:
- UUSL Data Types and Common Intrinsic FunctionsUUSL Data Types and Common Intrinsic Functions
- UUSL TexturesUUSL Textures
- UUSL SemanticsUUSL Semantics
- UUSL ParametersUUSL Parameters
Main Function主功能#
To start and end the void Main function of the compute shader, use the following instructions:要开始和结束计算着色器的void Main函数,请使用以下指令:
#include <core/materials/shaders/render/common.h>
MAIN_COMPUTE_BEGIN(WIDTH_GROUP,HEIGHT_GROUP)
<your code here>
MAIN_COMPUTE_END
This code is equivalent to:此代码等效于:
#include <core/materials/shaders/render/common.h>
[numthreads(WIDTH_GROUP, HEIGHT_GROUP, 1)]
void main(DISPATCH_INFO dispatch_info) {
<your code here>
}
Semantics语义学#
UUSL | Direct3D | Description |
---|---|---|
GROUP_ID GROUP_ID | SV_GroupID SV_GroupID | Contains the index of the workgroup currently being operated on by a compute shader包含当前由计算着色器操作的工作组的索引 |
GROUP_THREAD_ID GROUP_THREAD_ID | SV_GroupThreadID SV_GroupThreadID | Contains the index of work item currently being operated on by a compute shader包含计算着色器当前正在操作的工作项的索引 |
DISPATCH_THREAD_ID DISPATCH_THREAD_ID | SV_DispatchThreadID SV_DispatchThreadID | Contains the global index of work item currently being operated on by a compute shader包含当前由计算着色器操作的工作项的全局索引 |
GROUP_INDEX GROUP_INDEX | SV_GroupIndex SV_GroupIndex | Contains the local linear index of work item currently being operated on by a compute shader包含当前由计算着色器操作的工作项的本地线性索引。 |
Keywords关键字#
UUSL | Direct3D | 描述 |
---|---|---|
SHARED | groupshared | Mark a variable for thread-group-shared memory for compute shaders为计算着色器标记线程组共享内存的变量 |
MEMORY_BARRIER_SHARED | GroupMemoryBarrier() | Blocks execution of all threads in a group until all group shared accesses have been completed阻塞组中所有线程的执行,直到所有组共享访问完成 |
MEMORY_BARRIER_SHARED_SYNC | GroupMemoryBarrierWithGroupSync() | Blocks execution of all threads in a group until all group shared accesses have been completed and all threads in the group have reached this call阻塞组中所有线程的执行,直到所有组共享访问完成并且组中的所有线程都到达此调用 |
最新更新:
2024-08-16
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)