This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
UnigineEditor
界面概述
资产工作流程
设置和首选项
项目开发
调整节点参数
Setting Up Materials
Setting Up Properties
照明
Landscape Tool
Sandworm
使用编辑器工具执行特定任务
Extending Editor Functionality
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
Usage Examples
C++
C#
UnigineScript
Plugins
File Formats
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
创建内容
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

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上执行代码,读取和写入缓冲区数据。

Main Function主功能#

To start and end the void Main function of the compute shader, use the following instructions:要开始和结束计算着色器的void Main函数,请使用以下指令:

UUSL
#include <core/materials/shaders/render/common.h>

MAIN_COMPUTE_BEGIN(WIDTH_GROUP,HEIGHT_GROUP)
	<your code here>
MAIN_COMPUTE_END
警告
You should add a new line (press Enter) after closing the instruction.您应在关闭指令后添加新行(按Enter)。

This code is equivalent to:此代码等效于:

OpenGL
#include <core/materials/shaders/render/common.h>

layout (local_size_x = WIDTH_GROUP, local_size_y = HEIGHT_GROUP) in;
void main() {
	<your code here>
}
Direct3D
#include <core/materials/shaders/render/common.h>

[numthreads(WIDTH_GROUP, HEIGHT_GROUP, 1)]
void main(DISPATCH_INFO dispatch_info) {
	<your code here>
}

Semantics语义学#

UUSL OpenGL Direct3D Description
GROUP_ID SHARED GROUP_ID gl_WorkGroupID shared gl_WorkGroupID SV_GroupID groupshared SV_GroupID Contains the index of the workgroup currently being operated on by a compute shaderMark a variable for thread-group-shared memory for compute shaders包含当前由计算着色器操作的工作组的索引
GROUP_THREAD_ID MEMORY_BARRIER_SHARED GROUP_THREAD_ID gl_LocalInvocationID memoryBarrierShared() gl_LocalInvocationID SV_GroupThreadID GroupMemoryBarrier() SV_GroupThreadID Contains the index of work item currently being operated on by a compute shaderBlocks execution of all threads in a group until all group shared accesses have been completed包含计算着色器当前正在操作的工作项的索引
DISPATCH_THREAD_ID MEMORY_BARRIER_SHARED_SYNC DISPATCH_THREAD_ID gl_GlobalInvocationID memoryBarrierShared() barrier() gl_GlobalInvocationID SV_DispatchThreadID GroupMemoryBarrierWithGroupSync() SV_DispatchThreadID Contains the global index of work item currently being operated on by a compute shaderBlocks 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包含当前由计算着色器操作的工作项的全局索引
GROUP_INDEX GROUP_INDEX gl_LocalInvocationIndex gl_LocalInvocationIndex SV_GroupIndex SV_GroupIndex Contains the local linear index of work item currently being operated on by a compute shader包含当前由计算着色器操作的工作项的本地线性索引。
最新更新: 2022-02-18
Build: ()