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
cdf7a85b
Unverified
Commit
cdf7a85b
authored
Nov 02, 2018
by
John Kessenich
Committed by
GitHub
Nov 02, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1557 from nicebyte/spec-const-decorations
Add names for composite spec constants in SPIR-V
parents
a440fbb0
4c9876b3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
115 additions
and
58 deletions
+115
-58
GlslangToSpv.cpp
SPIRV/GlslangToSpv.cpp
+6
-5
spv.float16.frag.out
Test/baseResults/spv.float16.frag.out
+8
-4
spv.float32.frag.out
Test/baseResults/spv.float32.frag.out
+8
-4
spv.float64.frag.out
Test/baseResults/spv.float64.frag.out
+8
-4
spv.int16.amd.frag.out
Test/baseResults/spv.int16.amd.frag.out
+44
-22
spv.int64.frag.out
Test/baseResults/spv.int64.frag.out
+40
-19
spv.specConstantOperations.vert.out
Test/baseResults/spv.specConstantOperations.vert.out
+0
-0
spv.int64.frag
Test/spv.int64.frag
+1
-0
No files found.
SPIRV/GlslangToSpv.cpp
View file @
cdf7a85b
...
@@ -7292,18 +7292,19 @@ spv::Id TGlslangToSpvTraverser::createSpvConstant(const glslang::TIntermTyped& n
...
@@ -7292,18 +7292,19 @@ spv::Id TGlslangToSpvTraverser::createSpvConstant(const glslang::TIntermTyped& n
// An AST node labelled as specialization constant should be a symbol node.
// An AST node labelled as specialization constant should be a symbol node.
// Its initializer should either be a sub tree with constant nodes, or a constant union array.
// Its initializer should either be a sub tree with constant nodes, or a constant union array.
if
(
auto
*
sn
=
node
.
getAsSymbolNode
())
{
if
(
auto
*
sn
=
node
.
getAsSymbolNode
())
{
spv
::
Id
result
;
if
(
auto
*
sub_tree
=
sn
->
getConstSubtree
())
{
if
(
auto
*
sub_tree
=
sn
->
getConstSubtree
())
{
// Traverse the constant constructor sub tree like generating normal run-time instructions.
// Traverse the constant constructor sub tree like generating normal run-time instructions.
// During the AST traversal, if the node is marked as 'specConstant', SpecConstantOpModeGuard
// During the AST traversal, if the node is marked as 'specConstant', SpecConstantOpModeGuard
// will set the builder into spec constant op instruction generating mode.
// will set the builder into spec constant op instruction generating mode.
sub_tree
->
traverse
(
this
);
sub_tree
->
traverse
(
this
);
re
turn
accessChainLoad
(
sub_tree
->
getType
());
re
sult
=
accessChainLoad
(
sub_tree
->
getType
());
}
else
if
(
auto
*
const_union_array
=
&
sn
->
getConstArray
()){
}
else
if
(
auto
*
const_union_array
=
&
sn
->
getConstArray
())
{
int
nextConst
=
0
;
int
nextConst
=
0
;
spv
::
Id
id
=
createSpvConstantFromConstUnionArray
(
sn
->
getType
(),
*
const_union_array
,
nextConst
,
true
);
result
=
createSpvConstantFromConstUnionArray
(
sn
->
getType
(),
*
const_union_array
,
nextConst
,
true
);
builder
.
addName
(
id
,
sn
->
getName
().
c_str
());
return
id
;
}
}
builder
.
addName
(
result
,
sn
->
getName
().
c_str
());
return
result
;
}
}
// Neither a front-end constant node, nor a specialization constant node with constant union array or
// Neither a front-end constant node, nor a specialization constant node with constant union array or
...
...
Test/baseResults/spv.float16.frag.out
View file @
cdf7a85b
...
@@ -114,6 +114,10 @@ error: Capability Float16 is not allowed by Vulkan 1.0 specification (or require
...
@@ -114,6 +114,10 @@ error: Capability Float16 is not allowed by Vulkan 1.0 specification (or require
Name 526 "sf16"
Name 526 "sf16"
Name 527 "sf"
Name 527 "sf"
Name 528 "sd"
Name 528 "sd"
Name 529 "f16_to_f"
Name 531 "f16_to_d"
Name 532 "f_to_f16"
Name 533 "d_to_f16"
Decorate 512 ArrayStride 16
Decorate 512 ArrayStride 16
Decorate 513 ArrayStride 32
Decorate 513 ArrayStride 32
MemberDecorate 514(S) 0 Offset 0
MemberDecorate 514(S) 0 Offset 0
...
@@ -235,11 +239,11 @@ error: Capability Float16 is not allowed by Vulkan 1.0 specification (or require
...
@@ -235,11 +239,11 @@ error: Capability Float16 is not allowed by Vulkan 1.0 specification (or require
526(sf16):28(float16_t) SpecConstant 12288
526(sf16):28(float16_t) SpecConstant 12288
527(sf): 164(float) SpecConstant 1048576000
527(sf): 164(float) SpecConstant 1048576000
528(sd):172(float64_t) SpecConstant 0 1071644672
528(sd):172(float64_t) SpecConstant 0 1071644672
529
: 164(float) SpecConstantOp 115 526(sf16)
529(f16_to_f)
: 164(float) SpecConstantOp 115 526(sf16)
530: 164(float) SpecConstantOp 115 526(sf16)
530: 164(float) SpecConstantOp 115 526(sf16)
531
:172(float64_t) SpecConstantOp 115 530
531(f16_to_d)
:172(float64_t) SpecConstantOp 115 530
532
:28(float16_t) SpecConstantOp 115 527(sf)
532(f_to_f16)
:28(float16_t) SpecConstantOp 115 527(sf)
533
:28(float16_t) SpecConstantOp 115 528(sd)
533(d_to_f16)
:28(float16_t) SpecConstantOp 115 528(sd)
4(main): 2 Function None 3
4(main): 2 Function None 3
5: Label
5: Label
Return
Return
...
...
Test/baseResults/spv.float32.frag.out
View file @
cdf7a85b
...
@@ -104,6 +104,10 @@ error: Capability Float16 is not allowed by Vulkan 1.1 specification (or require
...
@@ -104,6 +104,10 @@ error: Capability Float16 is not allowed by Vulkan 1.1 specification (or require
Name 525 "sf16"
Name 525 "sf16"
Name 526 "sf"
Name 526 "sf"
Name 527 "sd"
Name 527 "sd"
Name 528 "f16_to_f"
Name 530 "f16_to_d"
Name 531 "f_to_f16"
Name 532 "d_to_f16"
Decorate 518 ArrayStride 16
Decorate 518 ArrayStride 16
Decorate 519 ArrayStride 32
Decorate 519 ArrayStride 32
MemberDecorate 520(S) 0 Offset 0
MemberDecorate 520(S) 0 Offset 0
...
@@ -209,11 +213,11 @@ error: Capability Float16 is not allowed by Vulkan 1.1 specification (or require
...
@@ -209,11 +213,11 @@ error: Capability Float16 is not allowed by Vulkan 1.1 specification (or require
525(sf16):172(float16_t) SpecConstant 12288
525(sf16):172(float16_t) SpecConstant 12288
526(sf): 26(float) SpecConstant 1048576000
526(sf): 26(float) SpecConstant 1048576000
527(sd):149(float64_t) SpecConstant 0 1071644672
527(sd):149(float64_t) SpecConstant 0 1071644672
528
: 26(float) SpecConstantOp 115 525(sf16)
528(f16_to_f)
: 26(float) SpecConstantOp 115 525(sf16)
529: 26(float) SpecConstantOp 115 525(sf16)
529: 26(float) SpecConstantOp 115 525(sf16)
530
:149(float64_t) SpecConstantOp 115 529
530(f16_to_d)
:149(float64_t) SpecConstantOp 115 529
531
:172(float16_t) SpecConstantOp 115 526(sf)
531(f_to_f16)
:172(float16_t) SpecConstantOp 115 526(sf)
532
:172(float16_t) SpecConstantOp 115 527(sd)
532(d_to_f16)
:172(float16_t) SpecConstantOp 115 527(sd)
4(main): 2 Function None 3
4(main): 2 Function None 3
5: Label
5: Label
Return
Return
...
...
Test/baseResults/spv.float64.frag.out
View file @
cdf7a85b
...
@@ -103,6 +103,10 @@ error: Capability Float16 is not allowed by Vulkan 1.1 specification (or require
...
@@ -103,6 +103,10 @@ error: Capability Float16 is not allowed by Vulkan 1.1 specification (or require
Name 515 "sf16"
Name 515 "sf16"
Name 517 "sf"
Name 517 "sf"
Name 518 "sd"
Name 518 "sd"
Name 519 "f16_to_f"
Name 521 "f16_to_d"
Name 522 "f_to_f16"
Name 523 "d_to_f16"
Decorate 461(if64v) Flat
Decorate 461(if64v) Flat
Decorate 508 ArrayStride 16
Decorate 508 ArrayStride 16
Decorate 509 ArrayStride 64
Decorate 509 ArrayStride 64
...
@@ -207,11 +211,11 @@ error: Capability Float16 is not allowed by Vulkan 1.1 specification (or require
...
@@ -207,11 +211,11 @@ error: Capability Float16 is not allowed by Vulkan 1.1 specification (or require
516: TypeFloat 32
516: TypeFloat 32
517(sf): 516(float) SpecConstant 1048576000
517(sf): 516(float) SpecConstant 1048576000
518(sd):26(float64_t) SpecConstant 0 1071644672
518(sd):26(float64_t) SpecConstant 0 1071644672
519
: 516(float) SpecConstantOp 115 515(sf16)
519(f16_to_f)
: 516(float) SpecConstantOp 115 515(sf16)
520: 516(float) SpecConstantOp 115 515(sf16)
520: 516(float) SpecConstantOp 115 515(sf16)
521
:26(float64_t) SpecConstantOp 115 520
521(f16_to_d)
:26(float64_t) SpecConstantOp 115 520
522
:162(float16_t) SpecConstantOp 115 517(sf)
522(f_to_f16)
:162(float16_t) SpecConstantOp 115 517(sf)
523
:162(float16_t) SpecConstantOp 115 518(sd)
523(d_to_f16)
:162(float16_t) SpecConstantOp 115 518(sd)
4(main): 2 Function None 3
4(main): 2 Function None 3
5: Label
5: Label
Return
Return
...
...
Test/baseResults/spv.int16.amd.frag.out
View file @
cdf7a85b
...
@@ -76,6 +76,28 @@ error: Capability Float16 is not allowed by Vulkan 1.0 specification (or require
...
@@ -76,6 +76,28 @@ error: Capability Float16 is not allowed by Vulkan 1.0 specification (or require
Name 526 "sb"
Name 526 "sb"
Name 527 "si16"
Name 527 "si16"
Name 528 "su16"
Name 528 "su16"
Name 529 "i16_to_b"
Name 530 "u16_to_b"
Name 531 "b_to_i16"
Name 532 "b_to_u16"
Name 533 "i16_to_i"
Name 535 "u16_to_i"
Name 536 "i_to_i16"
Name 538 "i_to_u16"
Name 540 "i16_to_u"
Name 541 "u16_to_u"
Name 543 "u_to_i16"
Name 544 "u_to_u16"
Name 545 "i16_to_i64"
Name 548 "u16_to_i64"
Name 549 "i64_to_i16"
Name 551 "i64_to_u16"
Name 553 "i16_to_u64"
Name 554 "u16_to_u64"
Name 556 "u64_to_i16"
Name 557 "u64_to_u16"
Name 558 "i16_to_u16"
Name 559 "u16_to_i16"
MemberDecorate 25(Uniforms) 0 Offset 0
MemberDecorate 25(Uniforms) 0 Offset 0
Decorate 25(Uniforms) Block
Decorate 25(Uniforms) Block
Decorate 27 DescriptorSet 0
Decorate 27 DescriptorSet 0
...
@@ -195,37 +217,37 @@ error: Capability Float16 is not allowed by Vulkan 1.0 specification (or require
...
@@ -195,37 +217,37 @@ error: Capability Float16 is not allowed by Vulkan 1.0 specification (or require
526(sb): 125(bool) SpecConstantTrue
526(sb): 125(bool) SpecConstantTrue
527(si16): 17(int16_t) SpecConstant 4294967291
527(si16): 17(int16_t) SpecConstant 4294967291
528(su16): 14(int16_t) SpecConstant 4
528(su16): 14(int16_t) SpecConstant 4
529
: 125(bool) SpecConstantOp 171 527(si16) 202
529(i16_to_b)
: 125(bool) SpecConstantOp 171 527(si16) 202
530
: 125(bool) SpecConstantOp 171 528(su16) 202
530(u16_to_b)
: 125(bool) SpecConstantOp 171 528(su16) 202
531
: 17(int16_t) SpecConstantOp 169 526(sb) 53 194
531(b_to_i16)
: 17(int16_t) SpecConstantOp 169 526(sb) 53 194
532
: 14(int16_t) SpecConstantOp 169 526(sb) 203 202
532(b_to_u16)
: 14(int16_t) SpecConstantOp 169 526(sb) 203 202
533
: 28(int) SpecConstantOp 114 527(si16)
533(i16_to_i)
: 28(int) SpecConstantOp 114 527(si16)
534: 18(int) SpecConstantOp 113 528(su16)
534: 18(int) SpecConstantOp 113 528(su16)
535
: 28(int) SpecConstantOp 128 534 128
535(u16_to_i)
: 28(int) SpecConstantOp 128 534 128
536
: 17(int16_t) SpecConstantOp 114 524(si)
536(i_to_i16)
: 17(int16_t) SpecConstantOp 114 524(si)
537: 17(int16_t) SpecConstantOp 114 524(si)
537: 17(int16_t) SpecConstantOp 114 524(si)
538
: 14(int16_t) SpecConstantOp 128 537 202
538(i_to_u16)
: 14(int16_t) SpecConstantOp 128 537 202
539: 28(int) SpecConstantOp 114 527(si16)
539: 28(int) SpecConstantOp 114 527(si16)
540
: 18(int) SpecConstantOp 128 539 128
540(i16_to_u)
: 18(int) SpecConstantOp 128 539 128
541
: 18(int) SpecConstantOp 113 528(su16)
541(u16_to_u)
: 18(int) SpecConstantOp 113 528(su16)
542: 14(int16_t) SpecConstantOp 113 525(su)
542: 14(int16_t) SpecConstantOp 113 525(su)
543
: 17(int16_t) SpecConstantOp 128 542 202
543(u_to_i16)
: 17(int16_t) SpecConstantOp 128 542 202
544
: 14(int16_t) SpecConstantOp 113 525(su)
544(u_to_u16)
: 14(int16_t) SpecConstantOp 113 525(su)
545
:273(int64_t) SpecConstantOp 114 527(si16)
545(i16_to_i64)
:273(int64_t) SpecConstantOp 114 527(si16)
546:285(int64_t) SpecConstantOp 113 528(su16)
546:285(int64_t) SpecConstantOp 113 528(su16)
547:285(int64_t) Constant 0 0
547:285(int64_t) Constant 0 0
548
:273(int64_t) SpecConstantOp 128 546 547
548(u16_to_i64)
:273(int64_t) SpecConstantOp 128 546 547
549
: 17(int16_t) SpecConstantOp 114 522(si64)
549(i64_to_i16)
: 17(int16_t) SpecConstantOp 114 522(si64)
550: 17(int16_t) SpecConstantOp 114 522(si64)
550: 17(int16_t) SpecConstantOp 114 522(si64)
551
: 14(int16_t) SpecConstantOp 128 550 202
551(i64_to_u16)
: 14(int16_t) SpecConstantOp 128 550 202
552:273(int64_t) SpecConstantOp 114 527(si16)
552:273(int64_t) SpecConstantOp 114 527(si16)
553
:285(int64_t) SpecConstantOp 128 552 547
553(i16_to_u64)
:285(int64_t) SpecConstantOp 128 552 547
554
:285(int64_t) SpecConstantOp 113 528(su16)
554(u16_to_u64)
:285(int64_t) SpecConstantOp 113 528(su16)
555: 14(int16_t) SpecConstantOp 113 523(su64)
555: 14(int16_t) SpecConstantOp 113 523(su64)
556
: 17(int16_t) SpecConstantOp 128 555 202
556(u64_to_i16)
: 17(int16_t) SpecConstantOp 128 555 202
557
: 14(int16_t) SpecConstantOp 113 523(su64)
557(u64_to_u16)
: 14(int16_t) SpecConstantOp 113 523(su64)
558
: 14(int16_t) SpecConstantOp 128 527(si16) 202
558(i16_to_u16)
: 14(int16_t) SpecConstantOp 128 527(si16) 202
559
: 17(int16_t) SpecConstantOp 128 528(su16) 202
559(u16_to_i16)
: 17(int16_t) SpecConstantOp 128 528(su16) 202
4(main): 2 Function None 3
4(main): 2 Function None 3
5: Label
5: Label
511: 2 FunctionCall 6(literal()
511: 2 FunctionCall 6(literal()
...
...
Test/baseResults/spv.int64.frag.out
View file @
cdf7a85b
spv.int64.frag
spv.int64.frag
error: SPIRV-Tools Validation Errors
error: OpDecorate SpecId decoration target <id> '1' is not a scalar specialization constant.
OpDecorate %su64inc SpecId 105
// Module Version 10000
// Module Version 10000
// Generated by (magic number): 80007
// Generated by (magic number): 80007
// Id's are bound by 48
8
// Id's are bound by 48
9
Capability Shader
Capability Shader
Capability Float64
Capability Float64
...
@@ -55,6 +59,21 @@ spv.int64.frag
...
@@ -55,6 +59,21 @@ spv.int64.frag
Name 467 "si"
Name 467 "si"
Name 468 "su"
Name 468 "su"
Name 469 "sb"
Name 469 "sb"
Name 470 "su64inc"
Name 471 "i64_to_b"
Name 472 "u64_to_b"
Name 473 "b_to_i64"
Name 474 "b_to_u64"
Name 475 "i64_to_i"
Name 476 "i_to_i64"
Name 477 "u64_to_u"
Name 478 "u_to_u64"
Name 479 "u64_to_i64"
Name 480 "i64_to_u64"
Name 482 "u64_to_i"
Name 484 "i_to_u64"
Name 486 "i64_to_u"
Name 488 "u_to_i64"
MemberDecorate 28(Uniforms) 0 Offset 0
MemberDecorate 28(Uniforms) 0 Offset 0
Decorate 28(Uniforms) Block
Decorate 28(Uniforms) Block
Decorate 30 DescriptorSet 0
Decorate 30 DescriptorSet 0
...
@@ -69,6 +88,7 @@ spv.int64.frag
...
@@ -69,6 +88,7 @@ spv.int64.frag
Decorate 467(si) SpecId 102
Decorate 467(si) SpecId 102
Decorate 468(su) SpecId 103
Decorate 468(su) SpecId 103
Decorate 469(sb) SpecId 104
Decorate 469(sb) SpecId 104
Decorate 470(su64inc) SpecId 105
2: TypeVoid
2: TypeVoid
3: TypeFunction 2
3: TypeFunction 2
14: TypeInt 64 0
14: TypeInt 64 0
...
@@ -157,24 +177,25 @@ spv.int64.frag
...
@@ -157,24 +177,25 @@ spv.int64.frag
467(si): 31(int) SpecConstant 4294967291
467(si): 31(int) SpecConstant 4294967291
468(su): 21(int) SpecConstant 4
468(su): 21(int) SpecConstant 4
469(sb): 55(bool) SpecConstantTrue
469(sb): 55(bool) SpecConstantTrue
470: 55(bool) SpecConstantOp 171 465(si64) 69
470(su64inc): 14(int64_t) SpecConstantOp 128 466(su64) 70
471: 55(bool) SpecConstantOp 171 466(su64) 69
471(i64_to_b): 55(bool) SpecConstantOp 171 465(si64) 69
472: 18(int64_t) SpecConstantOp 169 469(sb) 61 60
472(u64_to_b): 55(bool) SpecConstantOp 171 466(su64) 69
473: 14(int64_t) SpecConstantOp 169 469(sb) 70 69
473(b_to_i64): 18(int64_t) SpecConstantOp 169 469(sb) 61 60
474: 31(int) SpecConstantOp 114 465(si64)
474(b_to_u64): 14(int64_t) SpecConstantOp 169 469(sb) 70 69
475: 18(int64_t) SpecConstantOp 114 467(si)
475(i64_to_i): 31(int) SpecConstantOp 114 465(si64)
476: 21(int) SpecConstantOp 113 466(su64)
476(i_to_i64): 18(int64_t) SpecConstantOp 114 467(si)
477: 14(int64_t) SpecConstantOp 113 468(su)
477(u64_to_u): 21(int) SpecConstantOp 113 466(su64)
478: 18(int64_t) SpecConstantOp 128 466(su64) 69
478(u_to_u64): 14(int64_t) SpecConstantOp 113 468(su)
479: 14(int64_t) SpecConstantOp 128 465(si64) 69
479(u64_to_i64): 18(int64_t) SpecConstantOp 128 466(su64) 69
480: 21(int) SpecConstantOp 113 466(su64)
480(i64_to_u64): 14(int64_t) SpecConstantOp 128 465(si64) 69
481: 31(int) SpecConstantOp 128 480 227
481: 21(int) SpecConstantOp 113 466(su64)
482: 18(int64_t) SpecConstantOp 114 467(si)
482(u64_to_i): 31(int) SpecConstantOp 128 481 227
483: 14(int64_t) SpecConstantOp 128 482 69
483: 18(int64_t) SpecConstantOp 114 467(si)
484: 31(int) SpecConstantOp 114 465(si64)
484(i_to_u64): 14(int64_t) SpecConstantOp 128 483 69
485: 21(int) SpecConstantOp 128 484 227
485: 31(int) SpecConstantOp 114 465(si64)
486: 14(int64_t) SpecConstantOp 113 468(su)
486(i64_to_u): 21(int) SpecConstantOp 128 485 227
487: 18(int64_t) SpecConstantOp 128 486 69
487: 14(int64_t) SpecConstantOp 113 468(su)
488(u_to_i64): 18(int64_t) SpecConstantOp 128 487 69
4(main): 2 Function None 3
4(main): 2 Function None 3
5: Label
5: Label
Store 16(u64Max) 17
Store 16(u64Max) 17
...
...
Test/baseResults/spv.specConstantOperations.vert.out
View file @
cdf7a85b
This diff is collapsed.
Click to expand it.
Test/spv.int64.frag
View file @
cdf7a85b
...
@@ -236,6 +236,7 @@ layout(constant_id = 101) const uint64_t su64 = 20UL;
...
@@ -236,6 +236,7 @@ layout(constant_id = 101) const uint64_t su64 = 20UL;
layout
(
constant_id
=
102
)
const
int
si
=
-
5
;
layout
(
constant_id
=
102
)
const
int
si
=
-
5
;
layout
(
constant_id
=
103
)
const
uint
su
=
4
;
layout
(
constant_id
=
103
)
const
uint
su
=
4
;
layout
(
constant_id
=
104
)
const
bool
sb
=
true
;
layout
(
constant_id
=
104
)
const
bool
sb
=
true
;
layout
(
constant_id
=
105
)
const
uint64_t
su64inc
=
su64
+
1UL
;
// bool <-> int64/uint64
// bool <-> int64/uint64
const
bool
i64_to_b
=
bool
(
si64
);
const
bool
i64_to_b
=
bool
(
si64
);
...
...
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