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
f3b27471
Commit
f3b27471
authored
Jul 22, 2016
by
Rex Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SPV: Implement extension SPV_KHR_shader_draw_parameters.
parent
dd2fc1f3
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
158 additions
and
24 deletions
+158
-24
GLSL.ext.KHR.h
SPIRV/GLSL.ext.KHR.h
+3
-18
GlslangToSpv.cpp
SPIRV/GlslangToSpv.cpp
+11
-3
doc.cpp
SPIRV/doc.cpp
+5
-1
spirv.hpp
SPIRV/spirv.hpp
+14
-2
spv.shaderDrawParams.vert.out
Test/baseResults/spv.shaderDrawParams.vert.out
+108
-0
spv.shaderDrawParams.vert
Test/spv.shaderDrawParams.vert
+16
-0
Spv.FromFile.cpp
gtests/Spv.FromFile.cpp
+1
-0
No files found.
SPIRV/GLSL.ext.KHR.h
View file @
f3b27471
...
...
@@ -27,25 +27,10 @@
#ifndef GLSLextKHR_H
#define GLSLextKHR_H
enum
BuiltIn
;
enum
Op
;
enum
Capability
;
static
const
int
GLSLextKHRVersion
=
100
;
static
const
int
GLSLextKHRRevision
=
1
;
// SPV_KHR_shader_ballot
static
const
char
*
const
E_SPV_KHR_shader_ballot
=
"SPV_KHR_shader_ballot"
;
static
const
BuiltIn
BuiltInSubgroupEqMaskKHR
=
static_cast
<
BuiltIn
>
(
4416
);
static
const
BuiltIn
BuiltInSubgroupGeMaskKHR
=
static_cast
<
BuiltIn
>
(
4417
);
static
const
BuiltIn
BuiltInSubgroupGtMaskKHR
=
static_cast
<
BuiltIn
>
(
4418
);
static
const
BuiltIn
BuiltInSubgroupLeMaskKHR
=
static_cast
<
BuiltIn
>
(
4419
);
static
const
BuiltIn
BuiltInSubgroupLtMaskKHR
=
static_cast
<
BuiltIn
>
(
4420
);
static
const
Op
OpSubgroupBallotKHR
=
static_cast
<
Op
>
(
4421
);
static
const
Op
OpSubgroupFirstInvocationKHR
=
static_cast
<
Op
>
(
4422
);
static
const
char
*
const
E_SPV_KHR_shader_ballot
=
"SPV_KHR_shader_ballot"
;
static
const
Capability
CapabilitySubgroupBallotKHR
=
static_cast
<
Capability
>
(
4423
);
// SPV_KHR_shader_draw_parameters
static
const
char
*
const
E_SPV_KHR_shader_draw_parameters
=
"SPV_KHR_shader_draw_parameters"
;
#endif // #ifndef GLSLextKHR_H
SPIRV/GlslangToSpv.cpp
View file @
f3b27471
...
...
@@ -498,13 +498,21 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
case
glslang
:
:
EbvInstanceId
:
return
spv
::
BuiltInInstanceId
;
case
glslang
:
:
EbvVertexIndex
:
return
spv
::
BuiltInVertexIndex
;
case
glslang
:
:
EbvInstanceIndex
:
return
spv
::
BuiltInInstanceIndex
;
case
glslang
:
:
EbvBaseVertex
:
builder
.
addExtension
(
spv
::
E_SPV_KHR_shader_draw_parameters
);
builder
.
addCapability
(
spv
::
CapabilityDrawParameters
);
return
spv
::
BuiltInBaseVertex
;
case
glslang
:
:
EbvBaseInstance
:
builder
.
addExtension
(
spv
::
E_SPV_KHR_shader_draw_parameters
);
builder
.
addCapability
(
spv
::
CapabilityDrawParameters
);
return
spv
::
BuiltInBaseInstance
;
case
glslang
:
:
EbvDrawId
:
// TODO: Add SPIR-V builtin ID.
logger
->
missingFunctionality
(
"shader draw parameters"
);
return
spv
::
BuiltIn
Ma
x
;
builder
.
addExtension
(
spv
::
E_SPV_KHR_shader_draw_parameters
);
builder
.
addCapability
(
spv
::
CapabilityDrawParameters
);
return
spv
::
BuiltIn
DrawInde
x
;
case
glslang
:
:
EbvPrimitiveId
:
if
(
glslangIntermediate
->
getStage
()
==
EShLangFragment
)
...
...
SPIRV/doc.cpp
View file @
f3b27471
...
...
@@ -48,7 +48,6 @@
namespace
spv
{
extern
"C"
{
// Include C-based headers that don't have a namespace
#include "GLSL.ext.KHR.h"
#ifdef AMD_EXTENSIONS
#include "GLSL.ext.AMD.h"
#endif
...
...
@@ -319,6 +318,10 @@ const char* BuiltInString(int builtIn)
case
4419
:
return
"SubgroupLeMaskKHR"
;
case
4420
:
return
"SubgroupLtMaskKHR"
;
case
4424
:
return
"BaseVertex"
;
case
4425
:
return
"BaseInstance"
;
case
4426
:
return
"DrawIndex"
;
#ifdef AMD_EXTENSIONS
case
4992
:
return
"BaryCoordNoPerspAMD"
;
case
4993
:
return
"BaryCoordNoPerspCentroidAMD"
;
...
...
@@ -808,6 +811,7 @@ const char* CapabilityString(int info)
default:
return
"Bad"
;
case
4423
:
return
"SubgroupBallotKHR"
;
case
4427
:
return
"DrawParameters"
;
}
}
...
...
SPIRV/spirv.hpp
View file @
f3b27471
...
...
@@ -47,11 +47,11 @@ namespace spv {
typedef
unsigned
int
Id
;
#define SPV_VERSION 0x10000
#define SPV_REVISION
6
#define SPV_REVISION
8
static
const
unsigned
int
MagicNumber
=
0x07230203
;
static
const
unsigned
int
Version
=
0x00010000
;
static
const
unsigned
int
Revision
=
6
;
static
const
unsigned
int
Revision
=
8
;
static
const
unsigned
int
OpCodeMask
=
0xffff
;
static
const
unsigned
int
WordCountShift
=
16
;
...
...
@@ -420,6 +420,14 @@ enum BuiltIn {
BuiltInSubgroupLocalInvocationId
=
41
,
BuiltInVertexIndex
=
42
,
BuiltInInstanceIndex
=
43
,
BuiltInSubgroupEqMaskKHR
=
4416
,
BuiltInSubgroupGeMaskKHR
=
4417
,
BuiltInSubgroupGtMaskKHR
=
4418
,
BuiltInSubgroupLeMaskKHR
=
4419
,
BuiltInSubgroupLtMaskKHR
=
4420
,
BuiltInBaseVertex
=
4424
,
BuiltInBaseInstance
=
4425
,
BuiltInDrawIndex
=
4426
,
BuiltInMax
=
0x7fffffff
,
};
...
...
@@ -595,6 +603,8 @@ enum Capability {
CapabilityStorageImageReadWithoutFormat
=
55
,
CapabilityStorageImageWriteWithoutFormat
=
56
,
CapabilityMultiViewport
=
57
,
CapabilitySubgroupBallotKHR
=
4423
,
CapabilityDrawParameters
=
4427
,
CapabilityMax
=
0x7fffffff
,
};
...
...
@@ -893,6 +903,8 @@ enum Op {
OpAtomicFlagTestAndSet
=
318
,
OpAtomicFlagClear
=
319
,
OpImageSparseRead
=
320
,
OpSubgroupBallotKHR
=
4421
,
OpSubgroupFirstInvocationKHR
=
4422
,
OpMax
=
0x7fffffff
,
};
...
...
Test/baseResults/spv.shaderDrawParams.vert.out
0 → 100644
View file @
f3b27471
spv.shaderDrawParams.vert
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
Linked vertex stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 53
Capability Shader
Capability DrawParameters
Extension "SPV_KHR_shader_draw_parameters"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 9 16 29 37
Source GLSL 450
SourceExtension "GL_ARB_shader_draw_parameters"
Name 4 "main"
Name 9 "gl_BaseVertexARB"
Name 16 "gl_BaseInstanceARB"
Name 27 "gl_PerVertex"
MemberName 27(gl_PerVertex) 0 "gl_Position"
MemberName 27(gl_PerVertex) 1 "gl_PointSize"
MemberName 27(gl_PerVertex) 2 "gl_ClipDistance"
MemberName 27(gl_PerVertex) 3 "gl_CullDistance"
Name 29 ""
Name 34 "Block"
MemberName 34(Block) 0 "pos"
Name 36 "block"
Name 37 "gl_DrawIDARB"
Decorate 9(gl_BaseVertexARB) BuiltIn BaseVertex
Decorate 16(gl_BaseInstanceARB) BuiltIn BaseInstance
MemberDecorate 27(gl_PerVertex) 0 BuiltIn Position
MemberDecorate 27(gl_PerVertex) 1 BuiltIn PointSize
MemberDecorate 27(gl_PerVertex) 2 BuiltIn ClipDistance
MemberDecorate 27(gl_PerVertex) 3 BuiltIn CullDistance
Decorate 27(gl_PerVertex) Block
Decorate 31 ArrayStride 16
Decorate 33 ArrayStride 64
MemberDecorate 34(Block) 0 Offset 0
Decorate 34(Block) Block
Decorate 36(block) DescriptorSet 0
Decorate 36(block) Binding 0
Decorate 37(gl_DrawIDARB) BuiltIn DrawIndex
2: TypeVoid
3: TypeFunction 2
6: TypeBool
7: TypeInt 32 1
8: TypePointer Input 7(int)
9(gl_BaseVertexARB): 8(ptr) Variable Input
11: 7(int) Constant 0
16(gl_BaseInstanceARB): 8(ptr) Variable Input
22: TypeFloat 32
23: TypeVector 22(float) 4
24: TypeInt 32 0
25: 24(int) Constant 1
26: TypeArray 22(float) 25
27(gl_PerVertex): TypeStruct 23(fvec4) 22(float) 26 26
28: TypePointer Output 27(gl_PerVertex)
29: 28(ptr) Variable Output
30: 24(int) Constant 4
31: TypeArray 23(fvec4) 30
32: 24(int) Constant 2
33: TypeArray 31 32
34(Block): TypeStruct 33
35: TypePointer Uniform 34(Block)
36(block): 35(ptr) Variable Uniform
37(gl_DrawIDARB): 8(ptr) Variable Input
39: 7(int) Constant 4
41: TypePointer Uniform 23(fvec4)
44: TypePointer Output 23(fvec4)
47: 7(int) Constant 1
4(main): 2 Function None 3
5: Label
10: 7(int) Load 9(gl_BaseVertexARB)
12: 6(bool) SGreaterThan 10 11
13: 6(bool) LogicalNot 12
SelectionMerge 15 None
BranchConditional 13 14 15
14: Label
17: 7(int) Load 16(gl_BaseInstanceARB)
18: 6(bool) SGreaterThan 17 11
Branch 15
15: Label
19: 6(bool) Phi 12 5 18 14
SelectionMerge 21 None
BranchConditional 19 20 46
20: Label
38: 7(int) Load 37(gl_DrawIDARB)
40: 7(int) SMod 38 39
42: 41(ptr) AccessChain 36(block) 11 11 40
43: 23(fvec4) Load 42
45: 44(ptr) AccessChain 29 11
Store 45 43
Branch 21
46: Label
48: 7(int) Load 37(gl_DrawIDARB)
49: 7(int) SMod 48 39
50: 41(ptr) AccessChain 36(block) 11 47 49
51: 23(fvec4) Load 50
52: 44(ptr) AccessChain 29 11
Store 52 51
Branch 21
21: Label
Return
FunctionEnd
Test/spv.shaderDrawParams.vert
0 → 100644
View file @
f3b27471
#version 450 core
#extension GL_ARB_shader_draw_parameters: enable
layout
(
binding
=
0
)
uniform
Block
{
vec4
pos
[
2
][
4
];
}
block
;
void
main
()
{
if
((
gl_BaseVertexARB
>
0
)
||
(
gl_BaseInstanceARB
>
0
))
gl_Position
=
block
.
pos
[
0
][
gl_DrawIDARB
%
4
];
else
gl_Position
=
block
.
pos
[
1
][
gl_DrawIDARB
%
4
];
}
gtests/Spv.FromFile.cpp
View file @
f3b27471
...
...
@@ -237,6 +237,7 @@ INSTANTIATE_TEST_CASE_P(
"spv.prepost.frag"
,
"spv.qualifiers.vert"
,
"spv.shaderBallot.comp"
,
"spv.shaderDrawParams.vert"
,
"spv.shaderGroupVote.comp"
,
"spv.shiftOps.frag"
,
"spv.simpleFunctionCall.frag"
,
...
...
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