15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci EXT_shader_group_vote 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_EXT_shader_group_vote 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Tobias Hector, Imagination Technologies (tobias.hector 'at' imgtec.com) 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciContributors 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci Contributors to the original ARB_shader_group_vote specification 165bd8deadSopenharmony_ci Daniel Koch, NVIDIA 175bd8deadSopenharmony_ci 185bd8deadSopenharmony_ciStatus 195bd8deadSopenharmony_ci 205bd8deadSopenharmony_ci Complete 215bd8deadSopenharmony_ci 225bd8deadSopenharmony_ciVersion 235bd8deadSopenharmony_ci 245bd8deadSopenharmony_ci Last Modified Date: December 10, 2018 255bd8deadSopenharmony_ci Revision: 3 265bd8deadSopenharmony_ci 275bd8deadSopenharmony_ciNumber 285bd8deadSopenharmony_ci 295bd8deadSopenharmony_ci OpenGL ES Extension #254 305bd8deadSopenharmony_ci 315bd8deadSopenharmony_ciDependencies 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ci This extension is written against the OpenGL ES Shading Language 345bd8deadSopenharmony_ci Specification, Version 3.00.4. 355bd8deadSopenharmony_ci 365bd8deadSopenharmony_ci OpenGL ES 3.0 is required. 375bd8deadSopenharmony_ci 385bd8deadSopenharmony_ciOverview 395bd8deadSopenharmony_ci 405bd8deadSopenharmony_ci This extension provides new built-in functions to compute the composite of 415bd8deadSopenharmony_ci a set of boolean conditions across a group of shader invocations. These 425bd8deadSopenharmony_ci composite results may be used to execute shaders more efficiently on a 435bd8deadSopenharmony_ci single-instruction multiple-data (SIMD) processor. The set of shader 445bd8deadSopenharmony_ci invocations across which boolean conditions are evaluated is 455bd8deadSopenharmony_ci implementation-dependent, and this extension provides no guarantee over 465bd8deadSopenharmony_ci how individual shader invocations are assigned to such sets. In 475bd8deadSopenharmony_ci particular, the set of shader invocations has no necessary relationship 485bd8deadSopenharmony_ci with the compute shader workgroup -- a pair of shader invocations 495bd8deadSopenharmony_ci in a single compute shader workgroup may end up in different sets used by 505bd8deadSopenharmony_ci these built-ins. 515bd8deadSopenharmony_ci 525bd8deadSopenharmony_ci Compute shaders operate on an explicitly specified group of threads (a 535bd8deadSopenharmony_ci workgroup), but many implementations of OpenGL ES 3.0 will even group 545bd8deadSopenharmony_ci non-compute shader invocations and execute them in a SIMD fashion. When 555bd8deadSopenharmony_ci executing code like 565bd8deadSopenharmony_ci 575bd8deadSopenharmony_ci if (condition) { 585bd8deadSopenharmony_ci result = do_fast_path(); 595bd8deadSopenharmony_ci } else { 605bd8deadSopenharmony_ci result = do_general_path(); 615bd8deadSopenharmony_ci } 625bd8deadSopenharmony_ci 635bd8deadSopenharmony_ci where <condition> diverges between invocations, a SIMD implementation 645bd8deadSopenharmony_ci might first call do_fast_path() for the invocations where <condition> is 655bd8deadSopenharmony_ci true and leave the other invocations dormant. Once do_fast_path() 665bd8deadSopenharmony_ci returns, it might call do_general_path() for invocations where <condition> 675bd8deadSopenharmony_ci is false and leave the other invocations dormant. In this case, the 685bd8deadSopenharmony_ci shader executes *both* the fast and the general path and might be better 695bd8deadSopenharmony_ci off just using the general path for all invocations. 705bd8deadSopenharmony_ci 715bd8deadSopenharmony_ci This extension provides the ability to avoid divergent execution by 725bd8deadSopenharmony_ci evaluting a condition across an entire SIMD invocation group using code 735bd8deadSopenharmony_ci like: 745bd8deadSopenharmony_ci 755bd8deadSopenharmony_ci if (allInvocationsEXT(condition)) { 765bd8deadSopenharmony_ci result = do_fast_path(); 775bd8deadSopenharmony_ci } else { 785bd8deadSopenharmony_ci result = do_general_path(); 795bd8deadSopenharmony_ci } 805bd8deadSopenharmony_ci 815bd8deadSopenharmony_ci The built-in function allInvocationsEXT() will return the same value for 825bd8deadSopenharmony_ci all invocations in the group, so the group will either execute 835bd8deadSopenharmony_ci do_fast_path() or do_general_path(), but never both. For example, shader 845bd8deadSopenharmony_ci code might want to evaluate a complex function iteratively by starting 855bd8deadSopenharmony_ci with an approximation of the result and then refining the approximation. 865bd8deadSopenharmony_ci Some input values may require a small number of iterations to generate an 875bd8deadSopenharmony_ci accurate result (do_fast_path) while others require a larger number 885bd8deadSopenharmony_ci (do_general_path). In another example, shader code might want to evaluate 895bd8deadSopenharmony_ci a complex function (do_general_path) that can be greatly simplified when 905bd8deadSopenharmony_ci assuming a specific value for one of its inputs (do_fast_path). 915bd8deadSopenharmony_ci 925bd8deadSopenharmony_ciNew Procedures and Functions 935bd8deadSopenharmony_ci 945bd8deadSopenharmony_ci None. 955bd8deadSopenharmony_ci 965bd8deadSopenharmony_ciNew Tokens 975bd8deadSopenharmony_ci 985bd8deadSopenharmony_ci None. 995bd8deadSopenharmony_ci 1005bd8deadSopenharmony_ciNew Shading Language Functions 1015bd8deadSopenharmony_ci 1025bd8deadSopenharmony_ci bool anyInvocationEXT(bool value); 1035bd8deadSopenharmony_ci bool allInvocationsEXT(bool value); 1045bd8deadSopenharmony_ci bool allInvocationsEqualEXT(bool value); 1055bd8deadSopenharmony_ci 1065bd8deadSopenharmony_ciModifications to the OpenGL Shading Language Specification 1075bd8deadSopenharmony_ci 1085bd8deadSopenharmony_ci Including the following line in a shader can be used to control the 1095bd8deadSopenharmony_ci language features described in this extension: 1105bd8deadSopenharmony_ci 1115bd8deadSopenharmony_ci #extension GL_EXT_shader_group_vote : <behavior> 1125bd8deadSopenharmony_ci 1135bd8deadSopenharmony_ci where <behavior> is as specified in section 3.4. 1145bd8deadSopenharmony_ci 1155bd8deadSopenharmony_ci New preprocessor #defines are added to the OpenGL ES Shading Language: 1165bd8deadSopenharmony_ci 1175bd8deadSopenharmony_ci #define GL_EXT_shader_group_vote 1 1185bd8deadSopenharmony_ci 1195bd8deadSopenharmony_ci Modify Chapter 8, Built-in Functions 1205bd8deadSopenharmony_ci 1215bd8deadSopenharmony_ci (insert a new section at the end of the chapter) 1225bd8deadSopenharmony_ci 1235bd8deadSopenharmony_ci Section 8.10, Shader Invocation Group Functions 1245bd8deadSopenharmony_ci 1255bd8deadSopenharmony_ci Implementations of the OpenGL ES Shading Language may optionally group 1265bd8deadSopenharmony_ci multiple shader invocations for a single shader stage into a single SIMD 1275bd8deadSopenharmony_ci invocation group, where invocations are assigned to groups in an 1285bd8deadSopenharmony_ci undefined, implementation-dependent manner. Shader algorithms on such 1295bd8deadSopenharmony_ci implementations may benefit from being able to evaluate a composite of 1305bd8deadSopenharmony_ci boolean values over all active invocations in a group. 1315bd8deadSopenharmony_ci 1325bd8deadSopenharmony_ci Syntax: 1335bd8deadSopenharmony_ci 1345bd8deadSopenharmony_ci bool anyInvocationEXT(bool value); 1355bd8deadSopenharmony_ci bool allInvocationsEXT(bool value); 1365bd8deadSopenharmony_ci bool allInvocationsEqualEXT(bool value); 1375bd8deadSopenharmony_ci 1385bd8deadSopenharmony_ci The function anyInvocationEXT() returns true if and only if <value> is 1395bd8deadSopenharmony_ci true for at least one active invocation in the group. 1405bd8deadSopenharmony_ci 1415bd8deadSopenharmony_ci The function allInvocationsEXT() returns true if and only if <value> is 1425bd8deadSopenharmony_ci true for all active invocations in the group. 1435bd8deadSopenharmony_ci 1445bd8deadSopenharmony_ci The function allInvocationsEqualEXT() returns true if <value> is the same 1455bd8deadSopenharmony_ci for all active invocations in the group. 1465bd8deadSopenharmony_ci 1475bd8deadSopenharmony_ci For all of these functions, the same value is returned to all active 1485bd8deadSopenharmony_ci invocations in the group. 1495bd8deadSopenharmony_ci 1505bd8deadSopenharmony_ci These functions may be called in conditionally executed code. In groups 1515bd8deadSopenharmony_ci where some invocations do not execute the function call, the value 1525bd8deadSopenharmony_ci returned by the function is not affected by any invocation not calling the 1535bd8deadSopenharmony_ci function, even when <value> is well-defined for that invocation. 1545bd8deadSopenharmony_ci 1555bd8deadSopenharmony_ci Since these functions depend on the values of <value> in an undefined 1565bd8deadSopenharmony_ci group of invocations, the value returned by these functions is largely 1575bd8deadSopenharmony_ci undefined. However, anyInvocationEXT() is guaranteed to return true if 1585bd8deadSopenharmony_ci <value> is true, and allInvocationsEXT() is guaranteed to return false if 1595bd8deadSopenharmony_ci <value> is false. 1605bd8deadSopenharmony_ci 1615bd8deadSopenharmony_ci Since implementations are not required to combine invocations into groups, 1625bd8deadSopenharmony_ci simply returning <value> for anyInvocationEXT() and allInvocationsEXT() 1635bd8deadSopenharmony_ci and returning true for allInvocationsEqualEXT() is a legal implementation 1645bd8deadSopenharmony_ci of these functions. 1655bd8deadSopenharmony_ci 1665bd8deadSopenharmony_ci For fragment shaders, invocations in a SIMD invocation group may include 1675bd8deadSopenharmony_ci invocations corresponding to pixels that are covered by a primitive being 1685bd8deadSopenharmony_ci rasterized, as well as invocations corresponding to neighboring pixels not 1695bd8deadSopenharmony_ci covered by the primitive. The invocations for these neighboring "helper" 1705bd8deadSopenharmony_ci pixels may be created so that differencing can be used to evaluate 1715bd8deadSopenharmony_ci derivative functions like dFdx() and dFdx() (section 8.9) and implicit 1725bd8deadSopenharmony_ci derivatives used by texture() and related functions (section 8.8). The 1735bd8deadSopenharmony_ci value of <value> for such "helper" pixels may affect the value returned by 1745bd8deadSopenharmony_ci anyInvocationEXT(), allInvocationsEXT(), and allInvocationsEqualEXT(). 1755bd8deadSopenharmony_ci 1765bd8deadSopenharmony_ciErrors 1775bd8deadSopenharmony_ci 1785bd8deadSopenharmony_ci None. 1795bd8deadSopenharmony_ci 1805bd8deadSopenharmony_ciNew State 1815bd8deadSopenharmony_ci 1825bd8deadSopenharmony_ci None. 1835bd8deadSopenharmony_ci 1845bd8deadSopenharmony_ciNew Implementation Dependent State 1855bd8deadSopenharmony_ci 1865bd8deadSopenharmony_ci None. 1875bd8deadSopenharmony_ci 1885bd8deadSopenharmony_ciIssues 1895bd8deadSopenharmony_ci 1905bd8deadSopenharmony_ci Note: The EXT_shader_group_vote specification is based on the OpenGL 1915bd8deadSopenharmony_ci extension ARB_shader_group_vote as updated in OpenGL 4.x. Resolved issues 1925bd8deadSopenharmony_ci from ARB_shader_group_vote have been removed, but some remain applicable to 1935bd8deadSopenharmony_ci this extension. ARB_shader_group_vote can be found in the OpenGL Registry. 1945bd8deadSopenharmony_ci 1955bd8deadSopenharmony_ciRevision History 1965bd8deadSopenharmony_ci 1975bd8deadSopenharmony_ci Revision 3, December 10, 2018 (Jon Leech) 1985bd8deadSopenharmony_ci - Use 'workgroup' consistently throughout (Bug 11723, internal API 1995bd8deadSopenharmony_ci issue 87). 2005bd8deadSopenharmony_ci Revision 2, October 21, 2015 2015bd8deadSopenharmony_ci - Promoted to EXT 2025bd8deadSopenharmony_ci Revision 1, October 23, 2014 2035bd8deadSopenharmony_ci - Initial revision. 204