当前位置:网站首页>Chapter 10 of OpenGL super classic (7th Edition) calculation shader
Chapter 10 of OpenGL super classic (7th Edition) calculation shader
2022-06-30 05:01:00 【Jason_ Chen__】
OpenGL Super treasure ( The first 7 edition ) Chapter 10 calculation shaders
Preface
utilize GPU Of computing power
Unlike other shaders , It can synchronize and share data with each other
No fixed input or output , Do not connect with any other fixed pipeline process , High flexibility , It has functions that other processes do not have
One 、 Use calculation shaders
The calculation shader must be a separate program , You cannot combine other shaders ( The vertices 、 Surface subdivision 、 The geometric 、 fragment )
1. Execute calculation shader
sketch : Calculation shaders are executed in the workgroup , There is and only one global workgroup sent to opengl perform , There are multiple local workgroups under the global workgroup , Each local workgroup has its own work item (3D block ), Each work item can be set in the layout qualifier of the calculation shader
glDispatchCompute() and glDispatchComputeIndirect(): Set the number of local workgroups
glGetIntegeri_v(): Get the working status of the local workgroup , for example : The maximum size of the global workgroup ( Number of local working groups ), The volume of a local working group
glGetIntegeriv(): Get the volume of a local workgroup
Calculate the input and output of the shader :
sketch : No built-in output , It is a single process pipeline , Built in variables can determine the location of local workgroups and work items ( Indexes )
gl_WorkGroupID: The index of the local workgroup in the global workgroup , for example :gl_WorkGroupID.x、gl_WorkGroupID.y、gl_WorkGroupID.z
gl_LocalInvocationID: Index of work items in local workgroups , for example :gl_LocalInvocationID.x、gl_LocalInvocationID.y、gl_LocalInvocationID.z
gl_NumWorkGroups: Total number of calls to local workgroups
gl_WorkGroupSize: Total number of calls to work items
gl_LocalInvocationIndex: Put... In the work item 3D Variable to 1D Indexes
have access to imageStore、atomics As shader output , Write to shader storage block , for example : Image inversion
2. Compute shader communication
sketch : Computational shaders can declare variable communication through a limited number of shared memory qualifiers , The access speed is very fast
Sync : adopt barrier() function , Pay attention to competitive conditions and barrier() Impact on competitive conditions
Example : Parallel prefix and 、 Application of depth of field
Compute shader cluster :
sketch : An individual's behavior is based only on his perception of other members of the group around him , There is no cooperation between the members on a certain decision , for example : There is no leader in the fish school
Example : Clustered paper planes
边栏推荐
- Is the Flink connector JDBC open source? Where can I download it
- How does unity use mapbox to implement real maps in games?
- MySQL query gadget (I) replace a property value of the object in the JSON array in the JSON format string field
- Winter vacation parent-child tour, these new york attractions are not only fun but also knowledge
- LxC and LXD container summary
- Some problems encountered in unity steamvr
- Sailing experience not to be missed in New York Tourism: take you to enjoy the magnificent city scenery from different perspectives
- Unity Logitech steering wheel access
- Writing unityshader with sublimetext
- Force buckle 27 Removing Elements
猜你喜欢

Photon pun refresh hall room list

Universal Studios Singapore: a good place for a one-day parent-child tour in Singapore

Some problems encountered in unity steamvr

Force buckle 27 Removing Elements

Unity lens making

ParticleSystem in the official Manual of unity_ Collision module

一条命令运行rancher

【Paper】2015_ Coordinated cruise control for high-speed train movements based on a multi-agent model

Royal Albert Hall, a popular landmark in London

HTC vive cosmos development - handle button event
随机推荐
Free travel recommendation in Bangkok: introduction to the Mekong River in Bangkok
【Paper】2019_ Distributed Cooperative Control of a High-speed Train
Force buckle 704 Binary search
Unity supports the platform # define instruction of script
ParticleSystem in the official Manual of unity_ Collision module
[control] multi agent system summary. 5. system consolidation.
Universal Studios Singapore: a good place for a one-day parent-child tour in Singapore
UnityEngine. JsonUtility. The pit of fromjason()
Unreal 4 learning notes - data storage using blueprints
Collective system
003-JS-DOM-Attr-innerText
Deep learning ----- different methods to realize inception-10
力扣977. 有序数组的平方
How does unity use mapbox to implement real maps in games?
Solution to Autowired annotation warning
Have a heart beating Valentine's day in Singapore
SCM learning notes: interrupt learning
Pourquoi l'ordinateur n'a - t - il pas de réseau après l'ouverture du Hotspot win10?
Output directory of log files after unity3d packaging
Webots notes day 2