This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
FAQ
编程
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
应用程序接口
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
CIGI Client Plugin
Rendering-Related Classes
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

UUSL Compute Shaders

UUSL supports compute shaders: there are special functions, semantics and parameters for compute shaders.

In Unigine, compute shaders have a *.comp extension.

A compute shader is a special part of the graphics pipeline. It allows to execute code on the GPU, read and write buffer data.

Prior Knowledge
This article assumes you have prior knowledge of the compute shaders. Also, read the following topics on UUSL before proceeding:

Main Function

To start and end the void Main function of the compute shader, use the following instructions:

UUSL
MAIN_COMPUTE_BEGIN(WIDTH_GROUP,HEIGHT_GROUP)
	<your code here>
END_COMPUTE
Warning
You should add a new line (press Enter) after closing the instruction.

This code is equivalent to:

OpenGL
layout (local_size_x = WIDTH_GROUP, local_size_y = HEIGHT_GROUP) in;
void main() {
	<your code here>
}
Direct3D
[numthreads(WIDTH_GROUP, HEIGHT_GROUP, 1)]
void main(DISPATCH_INFO dispatch_info) {
	<your code here>
}

Semantics

UUSL OpenGL Direct3D Description
GROUP_ID gl_WorkGroupID SV_GroupID Contains the index of the workgroup currently being operated on by a compute shader
GROUP_THREAD_ID gl_LocalInvocationID SV_GroupThreadID Contains the index of work item currently being operated on by a compute shader
DISPATCH_THREAD_ID gl_GlobalInvocationID SV_DispatchThreadID Contains the global index of work item currently being operated on by a compute shader
GROUP_INDEX gl_LocalInvocationIndex SV_GroupIndex Contains the local linear index of work item currently being operated on by a compute shader
Last update: 2018-08-10
Build: ()