Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
glslang
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
glslang
Commits
338b185a
Commit
338b185a
authored
May 05, 2016
by
Rex Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement the extension GL_ARB_shader_group_vote.
parent
97f4e0fe
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
159 additions
and
3 deletions
+159
-3
GlslangToSpv.cpp
SPIRV/GlslangToSpv.cpp
+33
-2
spv.shaderGroupVote.comp.out
Test/baseResults/spv.shaderGroupVote.comp.out
+71
-0
spv.shaderGroupVote.comp
Test/spv.shaderGroupVote.comp
+21
-0
test-spirv-list
Test/test-spirv-list
+1
-0
intermediate.h
glslang/Include/intermediate.h
+4
-0
Initialize.cpp
glslang/MachineIndependent/Initialize.cpp
+21
-1
Versions.cpp
glslang/MachineIndependent/Versions.cpp
+2
-0
Versions.h
glslang/MachineIndependent/Versions.h
+1
-0
intermOut.cpp
glslang/MachineIndependent/intermOut.cpp
+4
-0
Spv.FromFile.cpp
gtests/Spv.FromFile.cpp
+1
-0
No files found.
SPIRV/GlslangToSpv.cpp
View file @
338b185a
...
@@ -3234,6 +3234,18 @@ spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, spv:
...
@@ -3234,6 +3234,18 @@ spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, spv:
libCall
=
spv
::
GLSLstd450FindSMsb
;
libCall
=
spv
::
GLSLstd450FindSMsb
;
break
;
break
;
case
glslang
:
:
EOpAnyInvocation
:
builder
.
addCapability
(
spv
::
CapabilityGroups
);
unaryOp
=
spv
::
OpGroupAny
;
break
;
case
glslang
:
:
EOpAllInvocations
:
builder
.
addCapability
(
spv
::
CapabilityGroups
);
unaryOp
=
spv
::
OpGroupAll
;
break
;
case
glslang
:
:
EOpAllInvocationsEqual
:
builder
.
addCapability
(
spv
::
CapabilityGroups
);
break
;
default
:
default
:
return
0
;
return
0
;
}
}
...
@@ -3243,8 +3255,27 @@ spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, spv:
...
@@ -3243,8 +3255,27 @@ spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, spv:
std
::
vector
<
spv
::
Id
>
args
;
std
::
vector
<
spv
::
Id
>
args
;
args
.
push_back
(
operand
);
args
.
push_back
(
operand
);
id
=
builder
.
createBuiltinCall
(
typeId
,
stdBuiltins
,
libCall
,
args
);
id
=
builder
.
createBuiltinCall
(
typeId
,
stdBuiltins
,
libCall
,
args
);
}
else
}
else
{
id
=
builder
.
createUnaryOp
(
unaryOp
,
typeId
,
operand
);
if
(
op
==
glslang
::
EOpAnyInvocation
||
op
==
glslang
::
EOpAllInvocations
||
op
==
glslang
::
EOpAllInvocationsEqual
)
{
std
::
vector
<
spv
::
Id
>
operands
;
operands
.
push_back
(
builder
.
makeUintConstant
(
spv
::
ScopeSubgroup
));
operands
.
push_back
(
operand
);
if
(
op
==
glslang
::
EOpAnyInvocation
||
op
==
glslang
::
EOpAllInvocations
)
id
=
builder
.
createOp
(
unaryOp
,
typeId
,
operands
);
else
if
(
op
==
glslang
::
EOpAllInvocationsEqual
)
{
spv
::
Id
groupAll
=
builder
.
createOp
(
spv
::
OpGroupAll
,
typeId
,
operands
);
spv
::
Id
groupAny
=
builder
.
createOp
(
spv
::
OpGroupAny
,
typeId
,
operands
);
id
=
builder
.
createBinOp
(
spv
::
OpLogicalOr
,
typeId
,
groupAll
,
builder
.
createUnaryOp
(
spv
::
OpLogicalNot
,
typeId
,
groupAny
));
}
}
else
id
=
builder
.
createUnaryOp
(
unaryOp
,
typeId
,
operand
);
}
return
builder
.
setPrecision
(
id
,
precision
);
return
builder
.
setPrecision
(
id
,
precision
);
}
}
...
...
Test/baseResults/spv.shaderGroupVote.comp.out
0 → 100644
View file @
338b185a
spv.shaderGroupVote.comp
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
Linked compute stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 37
Capability Shader
Capability Groups
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint GLCompute 4 "main"
ExecutionMode 4 LocalSize 4 4 1
Source GLSL 450
SourceExtension "GL_ARB_shader_group_vote"
Name 4 "main"
Name 8 "b1"
Name 10 "Buffers"
MemberName 10(Buffers) 0 "b"
Name 12 ""
MemberDecorate 10(Buffers) 0 Offset 0
Decorate 10(Buffers) BufferBlock
Decorate 12 DescriptorSet 0
Decorate 12 Binding 0
Decorate 36 BuiltIn WorkgroupSize
2: TypeVoid
3: TypeFunction 2
6: TypeBool
7: TypePointer Function 6(bool)
9: TypeInt 32 0
10(Buffers): TypeStruct 9(int)
11: TypePointer Uniform 10(Buffers)
12: 11(ptr) Variable Uniform
13: TypeInt 32 1
14: 13(int) Constant 0
15: TypePointer Uniform 9(int)
18: 9(int) Constant 0
21: 9(int) Constant 3
31: 9(int) Constant 1
34: TypeVector 9(int) 3
35: 9(int) Constant 4
36: 34(ivec3) ConstantComposite 35 35 31
4(main): 2 Function None 3
5: Label
8(b1): 7(ptr) Variable Function
16: 15(ptr) AccessChain 12 14
17: 9(int) Load 16
19: 6(bool) INotEqual 17 18
Store 8(b1) 19
20: 6(bool) Load 8(b1)
22: 6(bool) GroupAny 21 20
Store 8(b1) 22
23: 6(bool) Load 8(b1)
24: 6(bool) GroupAll 21 23
Store 8(b1) 24
25: 6(bool) Load 8(b1)
26: 6(bool) GroupAll 21 25
27: 6(bool) GroupAny 21 25
28: 6(bool) LogicalNot 27
29: 6(bool) LogicalOr 26 28
Store 8(b1) 29
30: 6(bool) Load 8(b1)
32: 9(int) Select 30 31 18
33: 15(ptr) AccessChain 12 14
Store 33 32
Return
FunctionEnd
Test/spv.shaderGroupVote.comp
0 → 100644
View file @
338b185a
#version 450
#extension GL_ARB_shader_group_vote : enable
layout(local_size_x = 4, local_size_y = 4) in;
layout(std430, binding = 0) buffer Buffers
{
bool b;
};
void main()
{
bool b1 = b;
b1 = anyInvocationARB(b1);
b1 = allInvocationsARB(b1);
b1 = allInvocationsEqualARB(b1);
b = b1;
}
Test/test-spirv-list
View file @
338b185a
...
@@ -72,6 +72,7 @@ spv.intOps.vert
...
@@ -72,6 +72,7 @@ spv.intOps.vert
spv.precision.frag
spv.precision.frag
spv.prepost.frag
spv.prepost.frag
spv.qualifiers.vert
spv.qualifiers.vert
spv.shaderGroupVote.comp
spv.shiftOps.frag
spv.shiftOps.frag
spv.simpleFunctionCall.frag
spv.simpleFunctionCall.frag
spv.simpleMat.vert
spv.simpleMat.vert
...
...
glslang/Include/intermediate.h
View file @
338b185a
...
@@ -283,6 +283,10 @@ enum TOperator {
...
@@ -283,6 +283,10 @@ enum TOperator {
EOpMemoryBarrierShared
,
// compute only
EOpMemoryBarrierShared
,
// compute only
EOpGroupMemoryBarrier
,
// compute only
EOpGroupMemoryBarrier
,
// compute only
EOpAnyInvocation
,
EOpAllInvocations
,
EOpAllInvocationsEqual
,
EOpAtomicAdd
,
EOpAtomicAdd
,
EOpAtomicMin
,
EOpAtomicMin
,
EOpAtomicMax
,
EOpAtomicMax
,
...
...
glslang/MachineIndependent/Initialize.cpp
View file @
338b185a
...
@@ -1325,6 +1325,16 @@ void TBuiltIns::initialize(int version, EProfile profile, int spv, int vulkan)
...
@@ -1325,6 +1325,16 @@ void TBuiltIns::initialize(int version, EProfile profile, int spv, int vulkan)
"
\n
"
);
"
\n
"
);
}
}
// GL_ARB_shader_group_vote
if
(
profile
!=
EEsProfile
&&
version
>=
430
)
{
commonBuiltins
.
append
(
"bool anyInvocationARB(bool);"
"bool allInvocationsARB(bool);"
"bool allInvocationsEqualARB(bool);"
"
\n
"
);
}
//============================================================================
//============================================================================
//
//
// Prototypes for built-in functions seen by vertex shaders only.
// Prototypes for built-in functions seen by vertex shaders only.
...
@@ -3394,7 +3404,7 @@ void IdentifyBuiltIns(int version, EProfile profile, int spv, int vulkan, EShLan
...
@@ -3394,7 +3404,7 @@ void IdentifyBuiltIns(int version, EProfile profile, int spv, int vulkan, EShLan
switch
(
language
)
{
switch
(
language
)
{
case
EShLangVertex
:
case
EShLangVertex
:
if
(
profile
!=
EEsProfile
&&
version
>=
440
)
{
if
(
profile
!=
EEsProfile
)
{
symbolTable
.
setVariableExtensions
(
"gl_BaseVertexARB"
,
1
,
&
E_GL_ARB_shader_draw_parameters
);
symbolTable
.
setVariableExtensions
(
"gl_BaseVertexARB"
,
1
,
&
E_GL_ARB_shader_draw_parameters
);
symbolTable
.
setVariableExtensions
(
"gl_BaseInstanceARB"
,
1
,
&
E_GL_ARB_shader_draw_parameters
);
symbolTable
.
setVariableExtensions
(
"gl_BaseInstanceARB"
,
1
,
&
E_GL_ARB_shader_draw_parameters
);
symbolTable
.
setVariableExtensions
(
"gl_DrawIDARB"
,
1
,
&
E_GL_ARB_shader_draw_parameters
);
symbolTable
.
setVariableExtensions
(
"gl_DrawIDARB"
,
1
,
&
E_GL_ARB_shader_draw_parameters
);
...
@@ -3404,6 +3414,12 @@ void IdentifyBuiltIns(int version, EProfile profile, int spv, int vulkan, EShLan
...
@@ -3404,6 +3414,12 @@ void IdentifyBuiltIns(int version, EProfile profile, int spv, int vulkan, EShLan
BuiltInVariable
(
"gl_DrawIDARB"
,
EbvDrawId
,
symbolTable
);
BuiltInVariable
(
"gl_DrawIDARB"
,
EbvDrawId
,
symbolTable
);
}
}
if
(
profile
!=
EEsProfile
)
{
symbolTable
.
setFunctionExtensions
(
"anyInvocationARB"
,
1
,
&
E_GL_ARB_shader_group_vote
);
symbolTable
.
setFunctionExtensions
(
"allInvocationsARB"
,
1
,
&
E_GL_ARB_shader_group_vote
);
symbolTable
.
setFunctionExtensions
(
"allInvocationsEqualARB"
,
1
,
&
E_GL_ARB_shader_group_vote
);
}
// Compatibility variables, vertex only
// Compatibility variables, vertex only
if
(
spv
==
0
)
{
if
(
spv
==
0
)
{
BuiltInVariable
(
"gl_Color"
,
EbvColor
,
symbolTable
);
BuiltInVariable
(
"gl_Color"
,
EbvColor
,
symbolTable
);
...
@@ -3987,6 +4003,10 @@ void IdentifyBuiltIns(int version, EProfile profile, int spv, int vulkan, EShLan
...
@@ -3987,6 +4003,10 @@ void IdentifyBuiltIns(int version, EProfile profile, int spv, int vulkan, EShLan
symbolTable
.
relateToOperator
(
"textureOffsetClampARB"
,
EOpTextureOffsetClamp
);
symbolTable
.
relateToOperator
(
"textureOffsetClampARB"
,
EOpTextureOffsetClamp
);
symbolTable
.
relateToOperator
(
"textureGradClampARB"
,
EOpTextureGradClamp
);
symbolTable
.
relateToOperator
(
"textureGradClampARB"
,
EOpTextureGradClamp
);
symbolTable
.
relateToOperator
(
"textureGradOffsetClampARB"
,
EOpTextureGradOffsetClamp
);
symbolTable
.
relateToOperator
(
"textureGradOffsetClampARB"
,
EOpTextureGradOffsetClamp
);
symbolTable
.
relateToOperator
(
"anyInvocationARB"
,
EOpAnyInvocation
);
symbolTable
.
relateToOperator
(
"allInvocationsARB"
,
EOpAllInvocations
);
symbolTable
.
relateToOperator
(
"allInvocationsEqualARB"
,
EOpAllInvocationsEqual
);
}
}
}
}
...
...
glslang/MachineIndependent/Versions.cpp
View file @
338b185a
...
@@ -171,6 +171,7 @@ void TParseVersions::initializeExtensionBehavior()
...
@@ -171,6 +171,7 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior
[
E_GL_ARB_shader_image_load_store
]
=
EBhDisable
;
extensionBehavior
[
E_GL_ARB_shader_image_load_store
]
=
EBhDisable
;
extensionBehavior
[
E_GL_ARB_shader_atomic_counters
]
=
EBhDisable
;
extensionBehavior
[
E_GL_ARB_shader_atomic_counters
]
=
EBhDisable
;
extensionBehavior
[
E_GL_ARB_shader_draw_parameters
]
=
EBhDisable
;
extensionBehavior
[
E_GL_ARB_shader_draw_parameters
]
=
EBhDisable
;
extensionBehavior
[
E_GL_ARB_shader_group_vote
]
=
EBhDisable
;
extensionBehavior
[
E_GL_ARB_derivative_control
]
=
EBhDisable
;
extensionBehavior
[
E_GL_ARB_derivative_control
]
=
EBhDisable
;
extensionBehavior
[
E_GL_ARB_shader_texture_image_samples
]
=
EBhDisable
;
extensionBehavior
[
E_GL_ARB_shader_texture_image_samples
]
=
EBhDisable
;
extensionBehavior
[
E_GL_ARB_viewport_array
]
=
EBhDisable
;
extensionBehavior
[
E_GL_ARB_viewport_array
]
=
EBhDisable
;
...
@@ -272,6 +273,7 @@ void TParseVersions::getPreamble(std::string& preamble)
...
@@ -272,6 +273,7 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_ARB_shader_image_load_store 1
\n
"
"#define GL_ARB_shader_image_load_store 1
\n
"
"#define GL_ARB_shader_atomic_counters 1
\n
"
"#define GL_ARB_shader_atomic_counters 1
\n
"
"#define GL_ARB_shader_draw_parameters 1
\n
"
"#define GL_ARB_shader_draw_parameters 1
\n
"
"#define GL_ARB_shader_group_vote 1
\n
"
"#define GL_ARB_derivative_control 1
\n
"
"#define GL_ARB_derivative_control 1
\n
"
"#define GL_ARB_shader_texture_image_samples 1
\n
"
"#define GL_ARB_shader_texture_image_samples 1
\n
"
"#define GL_ARB_viewport_array 1
\n
"
"#define GL_ARB_viewport_array 1
\n
"
...
...
glslang/MachineIndependent/Versions.h
View file @
338b185a
...
@@ -108,6 +108,7 @@ const char* const E_GL_ARB_explicit_attrib_location = "GL_ARB_explicit_attri
...
@@ -108,6 +108,7 @@ const char* const E_GL_ARB_explicit_attrib_location = "GL_ARB_explicit_attri
const
char
*
const
E_GL_ARB_shader_image_load_store
=
"GL_ARB_shader_image_load_store"
;
const
char
*
const
E_GL_ARB_shader_image_load_store
=
"GL_ARB_shader_image_load_store"
;
const
char
*
const
E_GL_ARB_shader_atomic_counters
=
"GL_ARB_shader_atomic_counters"
;
const
char
*
const
E_GL_ARB_shader_atomic_counters
=
"GL_ARB_shader_atomic_counters"
;
const
char
*
const
E_GL_ARB_shader_draw_parameters
=
"GL_ARB_shader_draw_parameters"
;
const
char
*
const
E_GL_ARB_shader_draw_parameters
=
"GL_ARB_shader_draw_parameters"
;
const
char
*
const
E_GL_ARB_shader_group_vote
=
"GL_ARB_shader_group_vote"
;
const
char
*
const
E_GL_ARB_derivative_control
=
"GL_ARB_derivative_control"
;
const
char
*
const
E_GL_ARB_derivative_control
=
"GL_ARB_derivative_control"
;
const
char
*
const
E_GL_ARB_shader_texture_image_samples
=
"GL_ARB_shader_texture_image_samples"
;
const
char
*
const
E_GL_ARB_shader_texture_image_samples
=
"GL_ARB_shader_texture_image_samples"
;
const
char
*
const
E_GL_ARB_viewport_array
=
"GL_ARB_viewport_array"
;
const
char
*
const
E_GL_ARB_viewport_array
=
"GL_ARB_viewport_array"
;
...
...
glslang/MachineIndependent/intermOut.cpp
View file @
338b185a
...
@@ -351,6 +351,10 @@ bool TOutputTraverser::visitUnary(TVisit /* visit */, TIntermUnary* node)
...
@@ -351,6 +351,10 @@ bool TOutputTraverser::visitUnary(TVisit /* visit */, TIntermUnary* node)
case
EOpNoise
:
out
.
debug
<<
"noise"
;
break
;
case
EOpNoise
:
out
.
debug
<<
"noise"
;
break
;
case
EOpAnyInvocation
:
out
.
debug
<<
"anyInvocation"
;
break
;
case
EOpAllInvocations
:
out
.
debug
<<
"allInvocations"
;
break
;
case
EOpAllInvocationsEqual
:
out
.
debug
<<
"allInvocationsEqual"
;
break
;
default
:
out
.
debug
.
message
(
EPrefixError
,
"Bad unary op"
);
default
:
out
.
debug
.
message
(
EPrefixError
,
"Bad unary op"
);
}
}
...
...
gtests/Spv.FromFile.cpp
View file @
338b185a
...
@@ -138,6 +138,7 @@ INSTANTIATE_TEST_CASE_P(
...
@@ -138,6 +138,7 @@ INSTANTIATE_TEST_CASE_P(
"spv.precision.frag"
,
"spv.precision.frag"
,
"spv.prepost.frag"
,
"spv.prepost.frag"
,
"spv.qualifiers.vert"
,
"spv.qualifiers.vert"
,
"spv.shaderGroupVote.comp"
,
"spv.shiftOps.frag"
,
"spv.shiftOps.frag"
,
"spv.simpleFunctionCall.frag"
,
"spv.simpleFunctionCall.frag"
,
"spv.simpleMat.vert"
,
"spv.simpleMat.vert"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment