Commit a8456415 by steve-lunarg

WIP: SPV Remapper: add remapper test framework

parent 4c3a7fd1
...@@ -98,7 +98,7 @@ options. See REMAPPING AND OPTIMIZATION OPTIONS. ...@@ -98,7 +98,7 @@ options. See REMAPPING AND OPTIMIZATION OPTIONS.
On error, the function supplied to registerErrorHandler() will be invoked. On error, the function supplied to registerErrorHandler() will be invoked.
This can be a standard C/C++ function, a lambda function, or a functor. This can be a standard C/C++ function, a lambda function, or a functor.
The default handler simply calls exit(5); The error handler is a static The default handler simply calls exit(5); The error handler is a static
members, so need only be set up once, not once per spirvbin_t instance. member, so need only be set up once, not once per spirvbin_t instance.
Log messages are supplied to registerLogHandler(). By default, log Log messages are supplied to registerLogHandler(). By default, log
messages are eaten silently. The log handler is also a static member. messages are eaten silently. The log handler is also a static member.
......
...@@ -3,21 +3,27 @@ set(SOURCES ...@@ -3,21 +3,27 @@ set(SOURCES
InReadableOrder.cpp InReadableOrder.cpp
Logger.cpp Logger.cpp
SpvBuilder.cpp SpvBuilder.cpp
SPVRemapper.cpp
doc.cpp doc.cpp
disassemble.cpp) disassemble.cpp)
set(SPVREMAP_SOURCES
SPVRemapper.cpp
doc.cpp)
set(HEADERS set(HEADERS
spirv.hpp spirv.hpp
GLSL.std.450.h GLSL.std.450.h
GlslangToSpv.h GlslangToSpv.h
Logger.h Logger.h
SpvBuilder.h SpvBuilder.h
SPVRemapper.h
spvIR.h spvIR.h
doc.h doc.h
disassemble.h) disassemble.h)
set(SPVREMAP_HEADERS
SPVRemapper.h
doc.h)
if(ENABLE_AMD_EXTENSIONS) if(ENABLE_AMD_EXTENSIONS)
set(HEADERS set(HEADERS
GLSL.ext.AMD.h) GLSL.ext.AMD.h)
...@@ -26,9 +32,13 @@ endif(ENABLE_AMD_EXTENSIONS) ...@@ -26,9 +32,13 @@ endif(ENABLE_AMD_EXTENSIONS)
add_library(SPIRV STATIC ${SOURCES} ${HEADERS}) add_library(SPIRV STATIC ${SOURCES} ${HEADERS})
set_property(TARGET SPIRV PROPERTY FOLDER glslang) set_property(TARGET SPIRV PROPERTY FOLDER glslang)
add_library(SPVRemapper STATIC ${SPVREMAP_SOURCES} ${SPVREMAP_HEADERS})
set_property(TARGET SPVRemapper PROPERTY FOLDER glslang)
if(WIN32) if(WIN32)
source_group("Source" FILES ${SOURCES} ${HEADERS}) source_group("Source" FILES ${SOURCES} ${HEADERS})
source_group("Source" FILES ${SPVREMAP_SOURCES} ${SPVREMAP_HEADERS})
endif(WIN32) endif(WIN32)
install(TARGETS SPIRV install(TARGETS SPIRV SPVRemapper
ARCHIVE DESTINATION lib) ARCHIVE DESTINATION lib)
...@@ -82,7 +82,7 @@ class spirvbin_t : public spirvbin_base_t ...@@ -82,7 +82,7 @@ class spirvbin_t : public spirvbin_base_t
public: public:
spirvbin_t(int /*verbose = 0*/) { } spirvbin_t(int /*verbose = 0*/) { }
void remap(std::vector<unsigned int>& /*spv*/, unsigned int /*opts = 0*/) void remap(std::vector<std::uint32_t>& /*spv*/, unsigned int /*opts = 0*/)
{ {
printf("Tool not compiled for C++11, which is required for SPIR-V remapping.\n"); printf("Tool not compiled for C++11, which is required for SPIR-V remapping.\n");
exit(5); exit(5);
......
...@@ -217,10 +217,12 @@ void SpirvStream::outputIndent() ...@@ -217,10 +217,12 @@ void SpirvStream::outputIndent()
void SpirvStream::formatId(Id id, std::stringstream& idStream) void SpirvStream::formatId(Id id, std::stringstream& idStream)
{ {
if (id != 0) {
// On instructions with no IDs, this is called with "0", which does not
// have to be within ID bounds on null shaders.
if (id >= bound) if (id >= bound)
Kill(out, "Bad <id>"); Kill(out, "Bad <id>");
if (id != 0) {
idStream << id; idStream << id;
if (idDescriptor[id].size() > 0) if (idDescriptor[id].size() > 0)
idStream << "(" << idDescriptor[id] << ")"; idStream << "(" << idDescriptor[id] << ")";
...@@ -334,7 +336,7 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode, ...@@ -334,7 +336,7 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode,
idDescriptor[resultId] = (const char*)(&stream[word]); idDescriptor[resultId] = (const char*)(&stream[word]);
} }
else { else {
if (idDescriptor[resultId].size() == 0) { if (resultId != 0 && idDescriptor[resultId].size() == 0) {
switch (opCode) { switch (opCode) {
case OpTypeInt: case OpTypeInt:
idDescriptor[resultId] = "int"; idDescriptor[resultId] = "int";
......
...@@ -24,6 +24,7 @@ set(LIBRARIES ...@@ -24,6 +24,7 @@ set(LIBRARIES
OSDependent OSDependent
HLSL HLSL
SPIRV SPIRV
SPVRemapper
glslang-default-resource-limits) glslang-default-resource-limits)
if(WIN32) if(WIN32)
......
remap.basic.dcefunc.frag
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 19
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 14 16
ExecutionMode 4 OriginUpperLeft
Source GLSL 450
Name 4 "main"
Name 9 "dead_fn("
Name 14 "outf4"
Name 16 "inf"
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 3
8: TypeFunction 7(fvec3)
10: 6(float) Constant 0
11: 7(fvec3) ConstantComposite 10 10 10
12: TypeVector 6(float) 4
13: TypePointer Output 12(fvec4)
14(outf4): 13(ptr) Variable Output
15: TypePointer Input 6(float)
16(inf): 15(ptr) Variable Input
4(main): 2 Function None 3
5: Label
17: 6(float) Load 16(inf)
18: 12(fvec4) CompositeConstruct 17 17 17 17
Store 14(outf4) 18
Return
FunctionEnd
remap.basic.dcevartype.frag
ERROR: #version: ES shaders for Vulkan SPIR-V require version 310 or higher
Warning, version 310 is not yet complete; most version-specific features are present, but some are missing.
ERROR: 1 compilation errors. No code generated.
Linked fragment stage:
ERROR: Linking fragment stage: Missing entry point: Each stage requires one "void main()" entry point
SPIR-V is not generated for failed compile or link
remap.basic.everything.frag
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 24969
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 5663 "main" 4539 3773
ExecutionMode 5663 OriginUpperLeft
8: TypeVoid
1282: TypeFunction 8
13: TypeFloat 32
29: TypeVector 13(float) 4
666: TypePointer Output 29(fvec4)
4539: 666(ptr) Variable Output
650: TypePointer Input 13(float)
3773: 650(ptr) Variable Input
5663: 8 Function None 1282
24968: Label
17486: 13(float) Load 3773
17691: 29(fvec4) CompositeConstruct 17486 17486 17486 17486
Store 4539 17691
Return
FunctionEnd
remap.basic.none.frag
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 20
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 15 17
ExecutionMode 4 OriginUpperLeft
Source GLSL 450
Name 4 "main"
Name 9 "dead_fn("
Name 15 "outf4"
Name 17 "inf"
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 3
8: TypeFunction 7(fvec3)
11: 6(float) Constant 0
12: 7(fvec3) ConstantComposite 11 11 11
13: TypeVector 6(float) 4
14: TypePointer Output 13(fvec4)
15(outf4): 14(ptr) Variable Output
16: TypePointer Input 6(float)
17(inf): 16(ptr) Variable Input
4(main): 2 Function None 3
5: Label
18: 6(float) Load 17(inf)
19: 13(fvec4) CompositeConstruct 18 18 18 18
Store 15(outf4) 19
Return
FunctionEnd
9(dead_fn(): 7(fvec3) Function None 8
10: Label
ReturnValue 12
FunctionEnd
remap.basic.strip.frag
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 20
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 15 17
ExecutionMode 4 OriginUpperLeft
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 3
8: TypeFunction 7(fvec3)
11: 6(float) Constant 0
12: 7(fvec3) ConstantComposite 11 11 11
13: TypeVector 6(float) 4
14: TypePointer Output 13(fvec4)
15: 14(ptr) Variable Output
16: TypePointer Input 6(float)
17: 16(ptr) Variable Input
4: 2 Function None 3
5: Label
18: 6(float) Load 17
19: 13(fvec4) CompositeConstruct 18 18 18 18
Store 15 19
Return
FunctionEnd
9: 7(fvec3) Function None 8
10: Label
ReturnValue 12
FunctionEnd
remap.hlsl.templatetypes.everything.frag
Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 16123
Capability Shader
Capability Float64
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 5663 "main"
ExecutionMode 5663 OriginUpperLeft
8: TypeVoid
1282: TypeFunction 8
13: TypeFloat 32
2572: 13(float) Constant 0
5663: 8 Function None 1282
16122: Label
ReturnValue 2572
FunctionEnd
remap.if.everything.frag
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 22855
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 5663 "main" 3773 4539
ExecutionMode 5663 OriginUpperLeft
8: TypeVoid
1282: TypeFunction 8
13: TypeFloat 32
650: TypePointer Input 13(float)
3773: 650(ptr) Variable Input
24: 13(float) Constant 1073741824
9: TypeBool
29: TypeVector 13(float) 4
666: TypePointer Output 29(fvec4)
4539: 666(ptr) Variable Output
947: 13(float) Constant 3204448256
5663: 8 Function None 1282
7911: Label
21734: 13(float) Load 3773
13508: 9(bool) FOrdGreaterThan 21734 24
SelectionMerge 19578 None
BranchConditional 13508 13182 10142
13182: Label
9496: 13(float) Load 3773
17615: 29(fvec4) CompositeConstruct 9496 9496 9496 9496
Store 4539 17615
Branch 19578
10142: Label
22854: 13(float) Load 3773
9982: 13(float) FAdd 22854 947
12421: 29(fvec4) CompositeConstruct 9982 9982 9982 9982
Store 4539 12421
Branch 19578
19578: Label
Return
FunctionEnd
remap.if.none.frag
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 25
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 8 17
ExecutionMode 4 OriginUpperLeft
Source GLSL 450
Name 4 "main"
Name 8 "inf"
Name 17 "outf4"
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypePointer Input 6(float)
8(inf): 7(ptr) Variable Input
10: 6(float) Constant 1073741824
11: TypeBool
15: TypeVector 6(float) 4
16: TypePointer Output 15(fvec4)
17(outf4): 16(ptr) Variable Output
22: 6(float) Constant 3204448256
4(main): 2 Function None 3
5: Label
9: 6(float) Load 8(inf)
12: 11(bool) FOrdGreaterThan 9 10
SelectionMerge 14 None
BranchConditional 12 13 20
13: Label
18: 6(float) Load 8(inf)
19: 15(fvec4) CompositeConstruct 18 18 18 18
Store 17(outf4) 19
Branch 14
20: Label
21: 6(float) Load 8(inf)
23: 6(float) FAdd 21 22
24: 15(fvec4) CompositeConstruct 23 23 23 23
Store 17(outf4) 24
Branch 14
14: Label
Return
FunctionEnd
remap.literal64.everything.spv
// Module Version 10100
// Generated by (magic number): 70000
// Id's are bound by 0
Capability Shader
MemoryModel Logical GLSL450
remap.literal64.none.spv
// Module Version 10100
// Generated by (magic number): 70000
// Id's are bound by 10
Capability Shader
MemoryModel Logical GLSL450
1: TypeVoid
2: TypeInt 64 1
3: TypeFunction 1
4: 2(int) Constant 0 0
5: 1 Function None 3
6: Label
SelectionMerge 7 None
Switch 4 7
case 0: 0
case 8: 1
case 0: 9
8: Label
Branch 7
9: Label
Branch 7
7: Label
Return
FunctionEnd
remap.similar_1a.everything.frag
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 24916
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 5663 "main" 4201 4539 3773
ExecutionMode 5663 OriginUpperLeft
Decorate 4201 Flat
8: TypeVoid
1282: TypeFunction 8
12: TypeInt 32 1
649: TypePointer Function 12(int)
13: TypeFloat 32
204: TypeFunction 13(float) 649(ptr)
650: TypePointer Function 13(float)
2572: 13(float) Constant 0
2571: 12(int) Constant 0
9: TypeBool
252: 13(float) Constant 1056964608
2574: 12(int) Constant 1
2577: 12(int) Constant 2
26: TypeVector 12(int) 4
663: TypePointer Input 26(ivec4)
4201: 663(ptr) Variable Input
11: TypeInt 32 0
2573: 11(int) Constant 1
651: TypePointer Input 12(int)
2576: 11(int) Constant 2
2570: 11(int) Constant 0
29: TypeVector 13(float) 4
666: TypePointer Output 29(fvec4)
4539: 666(ptr) Variable Output
652: TypePointer Input 13(float)
3773: 652(ptr) Variable Input
5663: 8 Function None 1282
24915: Label
18415: 649(ptr) Variable Function
5786: 649(ptr) Variable Function
8366: 13(float) Load 3773
8654: 12(int) ConvertFToS 8366
Store 18415 8654
17256: 13(float) FunctionCall 3782 18415
14512: 13(float) Load 3773
7041: 12(int) ConvertFToS 14512
Store 5786 7041
23993: 13(float) FunctionCall 3836 5786
9180: 13(float) FAdd 17256 23993
15728: 29(fvec4) CompositeConstruct 9180 9180 9180 9180
Store 4539 15728
Return
FunctionEnd
3782: 13(float) Function None 204
6931: 649(ptr) FunctionParameter
12220: Label
4292: 650(ptr) Variable Function
4298: 649(ptr) Variable Function
Store 4292 2572
Store 4298 2571
Branch 14924
14924: Label
LoopMerge 8882 6488 None
Branch 11857
11857: Label
13755: 12(int) Load 4298
22731: 12(int) Load 6931
20007: 9(bool) SLessThan 13755 22731
BranchConditional 20007 24750 8882
24750: Label
22912: 13(float) Load 4292
19471: 13(float) FAdd 22912 252
Store 4292 19471
Branch 6488
6488: Label
19050: 12(int) Load 4298
8593: 12(int) IAdd 19050 2574
Store 4298 8593
Branch 14924
8882: Label
11601: 13(float) Load 4292
ReturnValue 11601
FunctionEnd
3836: 13(float) Function None 204
4408: 649(ptr) FunctionParameter
12143: Label
22102: 649(ptr) Variable Function
24151: 12(int) Load 4408
13868: 9(bool) SGreaterThan 24151 2577
SelectionMerge 22309 None
BranchConditional 13868 9492 17416
9492: Label
15624: 12(int) Load 4408
Store 22102 15624
17278: 13(float) FunctionCall 3782 22102
ReturnValue 17278
17416: Label
19506: 12(int) Load 4408
22773: 12(int) IMul 19506 2577
13472: 651(ptr) AccessChain 4201 2573
15280: 12(int) Load 13472
18079: 651(ptr) AccessChain 4201 2576
15199: 12(int) Load 18079
9343: 12(int) IMul 15280 15199
11462: 12(int) IAdd 22773 9343
11885: 651(ptr) AccessChain 4201 2570
21176: 12(int) Load 11885
10505: 12(int) IAdd 11462 21176
14626: 13(float) ConvertSToF 10505
ReturnValue 14626
22309: Label
6429: 13(float) Undef
ReturnValue 6429
FunctionEnd
remap.similar_1a.none.frag
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 82
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 50 69 71
ExecutionMode 4 OriginUpperLeft
Source GLSL 450
Name 4 "main"
Name 11 "Test1(i1;"
Name 10 "bound"
Name 14 "Test2(i1;"
Name 13 "bound"
Name 17 "r"
Name 19 "x"
Name 42 "param"
Name 50 "ini4"
Name 69 "outf4"
Name 71 "inf"
Name 74 "param"
Name 78 "param"
Decorate 50(ini4) Flat
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 1
7: TypePointer Function 6(int)
8: TypeFloat 32
9: TypeFunction 8(float) 7(ptr)
16: TypePointer Function 8(float)
18: 8(float) Constant 0
20: 6(int) Constant 0
28: TypeBool
30: 8(float) Constant 1056964608
34: 6(int) Constant 1
38: 6(int) Constant 2
48: TypeVector 6(int) 4
49: TypePointer Input 48(ivec4)
50(ini4): 49(ptr) Variable Input
51: TypeInt 32 0
52: 51(int) Constant 1
53: TypePointer Input 6(int)
56: 51(int) Constant 2
61: 51(int) Constant 0
67: TypeVector 8(float) 4
68: TypePointer Output 67(fvec4)
69(outf4): 68(ptr) Variable Output
70: TypePointer Input 8(float)
71(inf): 70(ptr) Variable Input
4(main): 2 Function None 3
5: Label
74(param): 7(ptr) Variable Function
78(param): 7(ptr) Variable Function
72: 8(float) Load 71(inf)
73: 6(int) ConvertFToS 72
Store 74(param) 73
75: 8(float) FunctionCall 11(Test1(i1;) 74(param)
76: 8(float) Load 71(inf)
77: 6(int) ConvertFToS 76
Store 78(param) 77
79: 8(float) FunctionCall 14(Test2(i1;) 78(param)
80: 8(float) FAdd 75 79
81: 67(fvec4) CompositeConstruct 80 80 80 80
Store 69(outf4) 81
Return
FunctionEnd
11(Test1(i1;): 8(float) Function None 9
10(bound): 7(ptr) FunctionParameter
12: Label
17(r): 16(ptr) Variable Function
19(x): 7(ptr) Variable Function
Store 17(r) 18
Store 19(x) 20
Branch 21
21: Label
LoopMerge 23 24 None
Branch 25
25: Label
26: 6(int) Load 19(x)
27: 6(int) Load 10(bound)
29: 28(bool) SLessThan 26 27
BranchConditional 29 22 23
22: Label
31: 8(float) Load 17(r)
32: 8(float) FAdd 31 30
Store 17(r) 32
Branch 24
24: Label
33: 6(int) Load 19(x)
35: 6(int) IAdd 33 34
Store 19(x) 35
Branch 21
23: Label
36: 8(float) Load 17(r)
ReturnValue 36
FunctionEnd
14(Test2(i1;): 8(float) Function None 9
13(bound): 7(ptr) FunctionParameter
15: Label
42(param): 7(ptr) Variable Function
37: 6(int) Load 13(bound)
39: 28(bool) SGreaterThan 37 38
SelectionMerge 41 None
BranchConditional 39 40 45
40: Label
43: 6(int) Load 13(bound)
Store 42(param) 43
44: 8(float) FunctionCall 11(Test1(i1;) 42(param)
ReturnValue 44
45: Label
46: 6(int) Load 13(bound)
47: 6(int) IMul 46 38
54: 53(ptr) AccessChain 50(ini4) 52
55: 6(int) Load 54
57: 53(ptr) AccessChain 50(ini4) 56
58: 6(int) Load 57
59: 6(int) IMul 55 58
60: 6(int) IAdd 47 59
62: 53(ptr) AccessChain 50(ini4) 61
63: 6(int) Load 62
64: 6(int) IAdd 60 63
65: 8(float) ConvertSToF 64
ReturnValue 65
41: Label
66: 8(float) Undef
ReturnValue 66
FunctionEnd
remap.similar_1b.everything.frag
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 24916
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 5663 "main" 4201 4539 3773
ExecutionMode 5663 OriginUpperLeft
Decorate 4201 Flat
8: TypeVoid
1282: TypeFunction 8
12: TypeInt 32 1
649: TypePointer Function 12(int)
13: TypeFloat 32
204: TypeFunction 13(float) 649(ptr)
650: TypePointer Function 13(float)
2572: 13(float) Constant 0
2571: 12(int) Constant 0
9: TypeBool
252: 13(float) Constant 1056964608
2574: 12(int) Constant 1
2821: 13(float) Constant 1045220557
2577: 12(int) Constant 2
2583: 12(int) Constant 4
26: TypeVector 12(int) 4
663: TypePointer Input 26(ivec4)
4201: 663(ptr) Variable Input
11: TypeInt 32 0
2573: 11(int) Constant 1
651: TypePointer Input 12(int)
2576: 11(int) Constant 2
2570: 11(int) Constant 0
29: TypeVector 13(float) 4
666: TypePointer Output 29(fvec4)
4539: 666(ptr) Variable Output
652: TypePointer Input 13(float)
3773: 652(ptr) Variable Input
5663: 8 Function None 1282
24915: Label
18415: 649(ptr) Variable Function
5786: 649(ptr) Variable Function
8366: 13(float) Load 3773
8654: 12(int) ConvertFToS 8366
Store 18415 8654
17256: 13(float) FunctionCall 3782 18415
14512: 13(float) Load 3773
7041: 12(int) ConvertFToS 14512
Store 5786 7041
23993: 13(float) FunctionCall 3836 5786
9180: 13(float) FAdd 17256 23993
15728: 29(fvec4) CompositeConstruct 9180 9180 9180 9180
Store 4539 15728
Return
FunctionEnd
3782: 13(float) Function None 204
6931: 649(ptr) FunctionParameter
12220: Label
4292: 650(ptr) Variable Function
4298: 649(ptr) Variable Function
Store 4292 2572
Store 4298 2571
Branch 14924
14924: Label
LoopMerge 6507 6488 None
Branch 11857
11857: Label
13755: 12(int) Load 4298
22731: 12(int) Load 6931
20007: 9(bool) SLessThan 13755 22731
BranchConditional 20007 24750 6507
24750: Label
22912: 13(float) Load 4292
19471: 13(float) FAdd 22912 252
Store 4292 19471
Branch 6488
6488: Label
19050: 12(int) Load 4298
8593: 12(int) IAdd 19050 2574
Store 4298 8593
Branch 14924
6507: Label
18877: 13(float) Load 4292
15899: 13(float) FAdd 18877 2821
Store 4292 15899
20342: 13(float) Load 4292
ReturnValue 20342
FunctionEnd
3836: 13(float) Function None 204
4408: 649(ptr) FunctionParameter
12143: Label
22102: 649(ptr) Variable Function
24151: 12(int) Load 4408
13868: 9(bool) SGreaterThan 24151 2577
SelectionMerge 22309 None
BranchConditional 13868 10822 17416
10822: Label
22680: 12(int) Load 4408
23216: 12(int) IMul 22680 2577
Store 22102 23216
7042: 13(float) FunctionCall 3782 22102
ReturnValue 7042
17416: Label
19506: 12(int) Load 4408
22773: 12(int) IMul 19506 2583
13472: 651(ptr) AccessChain 4201 2573
15280: 12(int) Load 13472
18079: 651(ptr) AccessChain 4201 2576
15199: 12(int) Load 18079
9343: 12(int) IMul 15280 15199
11462: 12(int) IAdd 22773 9343
11885: 651(ptr) AccessChain 4201 2570
21176: 12(int) Load 11885
10505: 12(int) IAdd 11462 21176
14626: 13(float) ConvertSToF 10505
ReturnValue 14626
22309: Label
6429: 13(float) Undef
ReturnValue 6429
FunctionEnd
remap.similar_1b.none.frag
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 87
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 55 74 76
ExecutionMode 4 OriginUpperLeft
Source GLSL 450
Name 4 "main"
Name 11 "Test1(i1;"
Name 10 "bound"
Name 14 "Test2(i1;"
Name 13 "bound"
Name 17 "r"
Name 19 "x"
Name 47 "param"
Name 55 "ini4"
Name 74 "outf4"
Name 76 "inf"
Name 79 "param"
Name 83 "param"
Decorate 55(ini4) Flat
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 1
7: TypePointer Function 6(int)
8: TypeFloat 32
9: TypeFunction 8(float) 7(ptr)
16: TypePointer Function 8(float)
18: 8(float) Constant 0
20: 6(int) Constant 0
28: TypeBool
30: 8(float) Constant 1056964608
34: 6(int) Constant 1
36: 8(float) Constant 1045220557
41: 6(int) Constant 2
51: 6(int) Constant 4
53: TypeVector 6(int) 4
54: TypePointer Input 53(ivec4)
55(ini4): 54(ptr) Variable Input
56: TypeInt 32 0
57: 56(int) Constant 1
58: TypePointer Input 6(int)
61: 56(int) Constant 2
66: 56(int) Constant 0
72: TypeVector 8(float) 4
73: TypePointer Output 72(fvec4)
74(outf4): 73(ptr) Variable Output
75: TypePointer Input 8(float)
76(inf): 75(ptr) Variable Input
4(main): 2 Function None 3
5: Label
79(param): 7(ptr) Variable Function
83(param): 7(ptr) Variable Function
77: 8(float) Load 76(inf)
78: 6(int) ConvertFToS 77
Store 79(param) 78
80: 8(float) FunctionCall 11(Test1(i1;) 79(param)
81: 8(float) Load 76(inf)
82: 6(int) ConvertFToS 81
Store 83(param) 82
84: 8(float) FunctionCall 14(Test2(i1;) 83(param)
85: 8(float) FAdd 80 84
86: 72(fvec4) CompositeConstruct 85 85 85 85
Store 74(outf4) 86
Return
FunctionEnd
11(Test1(i1;): 8(float) Function None 9
10(bound): 7(ptr) FunctionParameter
12: Label
17(r): 16(ptr) Variable Function
19(x): 7(ptr) Variable Function
Store 17(r) 18
Store 19(x) 20
Branch 21
21: Label
LoopMerge 23 24 None
Branch 25
25: Label
26: 6(int) Load 19(x)
27: 6(int) Load 10(bound)
29: 28(bool) SLessThan 26 27
BranchConditional 29 22 23
22: Label
31: 8(float) Load 17(r)
32: 8(float) FAdd 31 30
Store 17(r) 32
Branch 24
24: Label
33: 6(int) Load 19(x)
35: 6(int) IAdd 33 34
Store 19(x) 35
Branch 21
23: Label
37: 8(float) Load 17(r)
38: 8(float) FAdd 37 36
Store 17(r) 38
39: 8(float) Load 17(r)
ReturnValue 39
FunctionEnd
14(Test2(i1;): 8(float) Function None 9
13(bound): 7(ptr) FunctionParameter
15: Label
47(param): 7(ptr) Variable Function
40: 6(int) Load 13(bound)
42: 28(bool) SGreaterThan 40 41
SelectionMerge 44 None
BranchConditional 42 43 49
43: Label
45: 6(int) Load 13(bound)
46: 6(int) IMul 45 41
Store 47(param) 46
48: 8(float) FunctionCall 11(Test1(i1;) 47(param)
ReturnValue 48
49: Label
50: 6(int) Load 13(bound)
52: 6(int) IMul 50 51
59: 58(ptr) AccessChain 55(ini4) 57
60: 6(int) Load 59
62: 58(ptr) AccessChain 55(ini4) 61
63: 6(int) Load 62
64: 6(int) IMul 60 63
65: 6(int) IAdd 52 64
67: 58(ptr) AccessChain 55(ini4) 66
68: 6(int) Load 67
69: 6(int) IAdd 65 68
70: 8(float) ConvertSToF 69
ReturnValue 70
44: Label
71: 8(float) Undef
ReturnValue 71
FunctionEnd
remap.switch.everything.frag
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
WARNING: 0:5: '' : all default precisions are highp; use precision statements to quiet warning, e.g.:
"precision mediump int; precision highp float;"
Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 23990
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 5663 "main" 3719 3994
ExecutionMode 5663 OriginUpperLeft
Decorate 3719 Location 0
Decorate 3994 RelaxedPrecision
Decorate 3994 Location 0
Decorate 12421 RelaxedPrecision
Decorate 12422 RelaxedPrecision
Decorate 12423 RelaxedPrecision
8: TypeVoid
1282: TypeFunction 8
13: TypeFloat 32
29: TypeVector 13(float) 4
666: TypePointer Input 29(fvec4)
3719: 666(ptr) Variable Input
11: TypeInt 32 0
2579: 11(int) Constant 3
650: TypePointer Input 13(float)
12: TypeInt 32 1
667: TypePointer Output 29(fvec4)
3994: 667(ptr) Variable Output
2570: 11(int) Constant 0
2572: 13(float) Constant 0
2573: 11(int) Constant 1
138: 13(float) Constant 1065353216
2576: 11(int) Constant 2
24: 13(float) Constant 1073741824
833: 13(float) Constant 3212836864
1284: 29(fvec4) ConstantComposite 833 833 833 833
5663: 8 Function None 1282
23915: Label
7984: 650(ptr) AccessChain 3719 2579
11376: 13(float) Load 7984
16859: 12(int) ConvertFToS 11376
SelectionMerge 19578 None
Switch 16859 15971
case 0: 8158
case 1: 8159
case 2: 8160
15971: Label
Store 3994 1284
Branch 19578
8158: Label
21848: 650(ptr) AccessChain 3719 2570
23987: 13(float) Load 21848
19989: 13(float) FAdd 23987 2572
12421: 29(fvec4) CompositeConstruct 19989 19989 19989 19989
Store 3994 12421
Branch 19578
8159: Label
21849: 650(ptr) AccessChain 3719 2573
23988: 13(float) Load 21849
19990: 13(float) FAdd 23988 138
12422: 29(fvec4) CompositeConstruct 19990 19990 19990 19990
Store 3994 12422
Branch 19578
8160: Label
21850: 650(ptr) AccessChain 3719 2576
23989: 13(float) Load 21850
19991: 13(float) FAdd 23989 24
12423: 29(fvec4) CompositeConstruct 19991 19991 19991 19991
Store 3994 12423
Branch 19578
19578: Label
Return
FunctionEnd
remap.switch.none.frag
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
WARNING: 0:5: '' : all default precisions are highp; use precision statements to quiet warning, e.g.:
"precision mediump int; precision highp float;"
Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 44
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 9 23
ExecutionMode 4 OriginUpperLeft
Source GLSL 450
Name 4 "main"
Name 9 "in0"
Name 23 "FragColor"
Decorate 9(in0) Location 0
Decorate 23(FragColor) RelaxedPrecision
Decorate 23(FragColor) Location 0
Decorate 29 RelaxedPrecision
Decorate 35 RelaxedPrecision
Decorate 41 RelaxedPrecision
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Input 7(fvec4)
9(in0): 8(ptr) Variable Input
10: TypeInt 32 0
11: 10(int) Constant 3
12: TypePointer Input 6(float)
15: TypeInt 32 1
22: TypePointer Output 7(fvec4)
23(FragColor): 22(ptr) Variable Output
24: 10(int) Constant 0
27: 6(float) Constant 0
30: 10(int) Constant 1
33: 6(float) Constant 1065353216
36: 10(int) Constant 2
39: 6(float) Constant 1073741824
42: 6(float) Constant 3212836864
43: 7(fvec4) ConstantComposite 42 42 42 42
4(main): 2 Function None 3
5: Label
13: 12(ptr) AccessChain 9(in0) 11
14: 6(float) Load 13
16: 15(int) ConvertFToS 14
SelectionMerge 21 None
Switch 16 20
case 0: 17
case 1: 18
case 2: 19
20: Label
Store 23(FragColor) 43
Branch 21
17: Label
25: 12(ptr) AccessChain 9(in0) 24
26: 6(float) Load 25
28: 6(float) FAdd 26 27
29: 7(fvec4) CompositeConstruct 28 28 28 28
Store 23(FragColor) 29
Branch 21
18: Label
31: 12(ptr) AccessChain 9(in0) 30
32: 6(float) Load 31
34: 6(float) FAdd 32 33
35: 7(fvec4) CompositeConstruct 34 34 34 34
Store 23(FragColor) 35
Branch 21
19: Label
37: 12(ptr) AccessChain 9(in0) 36
38: 6(float) Load 37
40: 6(float) FAdd 38 39
41: 7(fvec4) CompositeConstruct 40 40 40 40
Store 23(FragColor) 41
Branch 21
21: Label
Return
FunctionEnd
remap.uniformarray.everything.frag
Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 25030
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 5663 "main" 3608 4957 4339 5139
ExecutionMode 5663 OriginUpperLeft
8: TypeVoid
1282: TypeFunction 8
13: TypeFloat 32
29: TypeVector 13(float) 4
666: TypePointer Function 29(fvec4)
11: TypeInt 32 0
2588: 11(int) Constant 6
740: TypeArray 29(fvec4) 2588
1377: TypePointer Input 740
3608: 1377(ptr) Variable Input
12: TypeInt 32 1
2574: 12(int) Constant 1
667: TypePointer Input 29(fvec4)
24: TypeVector 13(float) 3
661: TypePointer Input 24(fvec3)
4957: 661(ptr) Variable Input
2618: 11(int) Constant 16
669: TypeArray 13(float) 2618
1306: TypePointer Input 669
4339: 1306(ptr) Variable Input
2607: 12(int) Constant 12
650: TypePointer Input 13(float)
2579: 11(int) Constant 3
651: TypePointer Function 13(float)
668: TypePointer Output 29(fvec4)
5139: 668(ptr) Variable Output
5663: 8 Function None 1282
25029: Label
4902: 666(ptr) Variable Function
10645: 667(ptr) AccessChain 3608 2574
8181: 29(fvec4) Load 10645
21370: 667(ptr) AccessChain 3608 2574
11355: 29(fvec4) Load 21370
23084: 29(fvec4) FAdd 8181 11355
Store 4902 23084
21218: 24(fvec3) Load 4957
13695: 29(fvec4) Load 4902
23883: 24(fvec3) VectorShuffle 13695 13695 0 1 2
15591: 24(fvec3) FAdd 23883 21218
17086: 29(fvec4) Load 4902
7051: 29(fvec4) VectorShuffle 17086 15591 4 5 6 3
Store 4902 7051
18282: 650(ptr) AccessChain 4339 2607
7372: 13(float) Load 18282
21371: 651(ptr) AccessChain 4902 2579
11412: 13(float) Load 21371
22584: 13(float) FAdd 11412 7372
17318: 651(ptr) AccessChain 4902 2579
Store 17318 22584
17934: 29(fvec4) Load 4902
Store 5139 17934
Return
FunctionEnd
remap.uniformarray.none.frag
Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 53
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 14 25 35 47
ExecutionMode 4 OriginUpperLeft
Source GLSL 140
Name 4 "main"
Name 9 "texColor"
Name 14 "color"
Name 25 "inColor"
Name 35 "alpha"
Name 47 "gl_FragColor"
Name 52 "texSampler2D"
Decorate 52(texSampler2D) DescriptorSet 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Function 7(fvec4)
10: TypeInt 32 0
11: 10(int) Constant 6
12: TypeArray 7(fvec4) 11
13: TypePointer Input 12
14(color): 13(ptr) Variable Input
15: TypeInt 32 1
16: 15(int) Constant 1
17: TypePointer Input 7(fvec4)
23: TypeVector 6(float) 3
24: TypePointer Input 23(fvec3)
25(inColor): 24(ptr) Variable Input
32: 10(int) Constant 16
33: TypeArray 6(float) 32
34: TypePointer Input 33
35(alpha): 34(ptr) Variable Input
36: 15(int) Constant 12
37: TypePointer Input 6(float)
40: 10(int) Constant 3
41: TypePointer Function 6(float)
46: TypePointer Output 7(fvec4)
47(gl_FragColor): 46(ptr) Variable Output
49: TypeImage 6(float) 2D sampled format:Unknown
50: TypeSampledImage 49
51: TypePointer UniformConstant 50
52(texSampler2D): 51(ptr) Variable UniformConstant
4(main): 2 Function None 3
5: Label
9(texColor): 8(ptr) Variable Function
18: 17(ptr) AccessChain 14(color) 16
19: 7(fvec4) Load 18
20: 17(ptr) AccessChain 14(color) 16
21: 7(fvec4) Load 20
22: 7(fvec4) FAdd 19 21
Store 9(texColor) 22
26: 23(fvec3) Load 25(inColor)
27: 7(fvec4) Load 9(texColor)
28: 23(fvec3) VectorShuffle 27 27 0 1 2
29: 23(fvec3) FAdd 28 26
30: 7(fvec4) Load 9(texColor)
31: 7(fvec4) VectorShuffle 30 29 4 5 6 3
Store 9(texColor) 31
38: 37(ptr) AccessChain 35(alpha) 36
39: 6(float) Load 38
42: 41(ptr) AccessChain 9(texColor) 40
43: 6(float) Load 42
44: 6(float) FAdd 43 39
45: 41(ptr) AccessChain 9(texColor) 40
Store 45 44
48: 7(fvec4) Load 9(texColor)
Store 47(gl_FragColor) 48
Return
FunctionEnd
#version 450
in float inf;
out vec4 outf4;
vec3 dead_fn() { return vec3(0); }
void main()
{
outf4 = vec4(inf);
}
#version 450
in float inf;
out vec4 outf4;
vec3 dead_fn() { return vec3(0); }
void main()
{
outf4 = vec4(inf);
}
#version 450
in float inf;
out vec4 outf4;
vec3 dead_fn() { return vec3(0); }
void main()
{
outf4 = vec4(inf);
}
#version 450
in float inf;
out vec4 outf4;
vec3 dead_fn() { return vec3(0); }
void main()
{
outf4 = vec4(inf);
}
SamplerState g_sSamp : register(s0);
uniform sampler2D g_sSamp2d
{
AddressU = MIRROR;
AddressV = WRAP;
MinLOD = 0;
MaxLOD = 10;
MaxAnisotropy = 2;
MipLodBias = 0.2;
}, g_sSamp2D_b;
Texture1D g_tTex1df4a : register(t1);
uniform Texture1D <float4> g_tTex1df4 : register(t0);
Texture1D <int4> g_tTex1di4;
Texture1D <uint4> g_tTex1du4;
Texture2D <float4> g_tTex2df4;
Texture2D <int4> g_tTex2di4;
Texture2D <uint4> g_tTex2du4;
Texture3D <float4> g_tTex3df4;
Texture3D <int4> g_tTex3di4;
Texture3D <uint4> g_tTex3du4;
TextureCube <float4> g_tTexcdf4;
TextureCube <int4> g_tTexcdi4;
TextureCube <uint4> g_tTexcdu4;
struct MemberTest
{
int Sample; // in HLSL, method names are valid struct members.
int CalculateLevelOfDetail; // ...
int CalculateLevelOfDetailUnclamped; // ...
int Gather; // ...
int GetDimensions; // ...
int GetSamplePosition; // ...
int Load; // ...
int SampleBias; // ...
int SampleCmp; // ...
int SampleCmpLevelZero; // ...
int SampleGrad; // ...
int SampleLevel; // ...
};
struct PS_OUTPUT
{
float4 Color : SV_Target0;
float Depth : SV_Depth;
};
PS_OUTPUT main()
{
PS_OUTPUT psout;
MemberTest mtest;
mtest.CalculateLevelOfDetail = 1; // in HLSL, method names are valid struct members.
mtest.CalculateLevelOfDetailUnclamped = 1; // ...
mtest.Gather = 1; // ...
mtest.GetDimensions = 1; // ...
mtest.GetSamplePosition = 1; // ...
mtest.Load = 1; // ...
mtest.Sample = 1; // ...
mtest.SampleBias = 1; // ...
mtest.SampleCmp = 1; // ...
mtest.SampleCmpLevelZero = 1; // ...
mtest.SampleGrad = 1; // ...
mtest.SampleLevel = 1; // ...
float4 txval10 = g_tTex1df4 . Sample(g_sSamp, 0.1);
int4 txval11 = g_tTex1di4 . Sample(g_sSamp, 0.2);
uint4 txval12 = g_tTex1du4 . Sample(g_sSamp, 0.3);
float4 txval20 = g_tTex2df4 . Sample(g_sSamp, float2(0.1, 0.2));
int4 txval21 = g_tTex2di4 . Sample(g_sSamp, float2(0.3, 0.4));
uint4 txval22 = g_tTex2du4 . Sample(g_sSamp, float2(0.5, 0.6));
float4 txval30 = g_tTex3df4 . Sample(g_sSamp, float3(0.1, 0.2, 0.3));
int4 txval31 = g_tTex3di4 . Sample(g_sSamp, float3(0.4, 0.5, 0.6));
uint4 txval32 = g_tTex3du4 . Sample(g_sSamp, float3(0.7, 0.8, 0.9));
float4 txval40 = g_tTexcdf4 . Sample(g_sSamp, float3(0.1, 0.2, 0.3));
int4 txval41 = g_tTexcdi4 . Sample(g_sSamp, float3(0.4, 0.5, 0.6));
uint4 txval42 = g_tTexcdu4 . Sample(g_sSamp, float3(0.7, 0.8, 0.9));
psout.Color = 1.0;
psout.Depth = 1.0;
return psout;
}
SamplerState g_sSamp : register(s0);
uniform sampler2D g_sSamp2d
{
AddressU = MIRROR;
AddressV = WRAP;
MinLOD = 0;
MaxLOD = 10;
MaxAnisotropy = 2;
MipLodBias = 0.2;
}, g_sSamp2D_b;
Texture1D g_tTex1df4a : register(t1);
uniform Texture1D <float4> g_tTex1df4 : register(t0);
Texture1D <int4> g_tTex1di4;
Texture1D <uint4> g_tTex1du4;
Texture2D <float4> g_tTex2df4;
Texture2D <int4> g_tTex2di4;
Texture2D <uint4> g_tTex2du4;
Texture3D <float4> g_tTex3df4;
Texture3D <int4> g_tTex3di4;
Texture3D <uint4> g_tTex3du4;
TextureCube <float4> g_tTexcdf4;
TextureCube <int4> g_tTexcdi4;
TextureCube <uint4> g_tTexcdu4;
struct MemberTest
{
int Sample; // in HLSL, method names are valid struct members.
int CalculateLevelOfDetail; // ...
int CalculateLevelOfDetailUnclamped; // ...
int Gather; // ...
int GetDimensions; // ...
int GetSamplePosition; // ...
int Load; // ...
int SampleBias; // ...
int SampleCmp; // ...
int SampleCmpLevelZero; // ...
int SampleGrad; // ...
int SampleLevel; // ...
};
struct PS_OUTPUT
{
float4 Color : SV_Target0;
float Depth : SV_Depth;
};
PS_OUTPUT main()
{
PS_OUTPUT psout;
MemberTest mtest;
mtest.CalculateLevelOfDetail = 1; // in HLSL, method names are valid struct members.
mtest.CalculateLevelOfDetailUnclamped = 1; // ...
mtest.Gather = 1; // ...
mtest.GetDimensions = 1; // ...
mtest.GetSamplePosition = 1; // ...
mtest.Load = 1; // ...
mtest.Sample = 1; // ...
mtest.SampleBias = 1; // ...
mtest.SampleCmp = 1; // ...
mtest.SampleCmpLevelZero = 1; // ...
mtest.SampleGrad = 1; // ...
mtest.SampleLevel = 1; // ...
float4 txval10 = g_tTex1df4 . Sample(g_sSamp, 0.1);
int4 txval11 = g_tTex1di4 . Sample(g_sSamp, 0.2);
uint4 txval12 = g_tTex1du4 . Sample(g_sSamp, 0.3);
float4 txval20 = g_tTex2df4 . Sample(g_sSamp, float2(0.1, 0.2));
int4 txval21 = g_tTex2di4 . Sample(g_sSamp, float2(0.3, 0.4));
uint4 txval22 = g_tTex2du4 . Sample(g_sSamp, float2(0.5, 0.6));
float4 txval30 = g_tTex3df4 . Sample(g_sSamp, float3(0.1, 0.2, 0.3));
int4 txval31 = g_tTex3di4 . Sample(g_sSamp, float3(0.4, 0.5, 0.6));
uint4 txval32 = g_tTex3du4 . Sample(g_sSamp, float3(0.7, 0.8, 0.9));
float4 txval40 = g_tTexcdf4 . Sample(g_sSamp, float3(0.1, 0.2, 0.3));
int4 txval41 = g_tTexcdi4 . Sample(g_sSamp, float3(0.4, 0.5, 0.6));
uint4 txval42 = g_tTexcdu4 . Sample(g_sSamp, float3(0.7, 0.8, 0.9));
psout.Color = 1.0;
psout.Depth = 1.0;
return psout;
}
SamplerState g_sSamp : register(s0);
uniform sampler2D g_sSamp2d
{
AddressU = MIRROR;
AddressV = WRAP;
MinLOD = 0;
MaxLOD = 10;
MaxAnisotropy = 2;
MipLodBias = 0.2;
}, g_sSamp2D_b;
Texture1D g_tTex1df4a : register(t1);
uniform Texture1D <float4> g_tTex1df4 : register(t0);
Texture1D <int4> g_tTex1di4;
Texture1D <uint4> g_tTex1du4;
Texture2D <float4> g_tTex2df4;
Texture2D <int4> g_tTex2di4;
Texture2D <uint4> g_tTex2du4;
Texture3D <float4> g_tTex3df4;
Texture3D <int4> g_tTex3di4;
Texture3D <uint4> g_tTex3du4;
TextureCube <float4> g_tTexcdf4;
TextureCube <int4> g_tTexcdi4;
TextureCube <uint4> g_tTexcdu4;
struct MemberTest
{
int Sample; // in HLSL, method names are valid struct members.
int CalculateLevelOfDetail; // ...
int CalculateLevelOfDetailUnclamped; // ...
int Gather; // ...
int GetDimensions; // ...
int GetSamplePosition; // ...
int Load; // ...
int SampleBias; // ...
int SampleCmp; // ...
int SampleCmpLevelZero; // ...
int SampleGrad; // ...
int SampleLevel; // ...
};
struct PS_OUTPUT
{
float4 Color : SV_Target0;
float Depth : SV_Depth;
};
PS_OUTPUT main()
{
PS_OUTPUT psout;
MemberTest mtest;
mtest.CalculateLevelOfDetail = 1; // in HLSL, method names are valid struct members.
mtest.CalculateLevelOfDetailUnclamped = 1; // ...
mtest.Gather = 1; // ...
mtest.GetDimensions = 1; // ...
mtest.GetSamplePosition = 1; // ...
mtest.Load = 1; // ...
mtest.Sample = 1; // ...
mtest.SampleBias = 1; // ...
mtest.SampleCmp = 1; // ...
mtest.SampleCmpLevelZero = 1; // ...
mtest.SampleGrad = 1; // ...
mtest.SampleLevel = 1; // ...
float4 txval10 = g_tTex1df4 . Sample(g_sSamp, 0.1);
int4 txval11 = g_tTex1di4 . Sample(g_sSamp, 0.2);
uint4 txval12 = g_tTex1du4 . Sample(g_sSamp, 0.3);
float4 txval20 = g_tTex2df4 . Sample(g_sSamp, float2(0.1, 0.2));
int4 txval21 = g_tTex2di4 . Sample(g_sSamp, float2(0.3, 0.4));
uint4 txval22 = g_tTex2du4 . Sample(g_sSamp, float2(0.5, 0.6));
float4 txval30 = g_tTex3df4 . Sample(g_sSamp, float3(0.1, 0.2, 0.3));
int4 txval31 = g_tTex3di4 . Sample(g_sSamp, float3(0.4, 0.5, 0.6));
uint4 txval32 = g_tTex3du4 . Sample(g_sSamp, float3(0.7, 0.8, 0.9));
float4 txval40 = g_tTexcdf4 . Sample(g_sSamp, float3(0.1, 0.2, 0.3));
int4 txval41 = g_tTexcdi4 . Sample(g_sSamp, float3(0.4, 0.5, 0.6));
uint4 txval42 = g_tTexcdu4 . Sample(g_sSamp, float3(0.7, 0.8, 0.9));
psout.Color = 1.0;
psout.Depth = 1.0;
return psout;
}
float4 main(float4 input) : COLOR0
{
vector r00 = float4(1,2,3,4); // vector means float4
float4 r01 = vector(2,3,4,5); // vector means float4
vector<bool, 1> r12 = bool1(false);
vector<int, 1> r13 = int1(1);
vector<float, 1> r14 = float1(1);
vector<double, 1> r15 = double1(1);
vector<uint, 1> r16 = uint1(1);
vector<bool, 2> r20 = bool2(false, true);
vector<int, 2> r21 = int2(1,2);
vector<float, 2> r22 = float2(1,2);
vector<double, 2> r23 = double2(1,2);
vector<uint, 2> r24 = uint2(1,2);
vector<bool, 3> r30 = bool3(false, true, true);
vector<int, 3> r31 = int3(1,2,3);
vector<float, 3> r32 = float3(1,2,3);
vector<double, 3> r33 = double3(1,2,3);
vector<uint, 3> r34 = uint3(1,2,3);
vector<bool, 4> r40 = bool4(false, true, true, false);
vector<int, 4> r41 = int4(1,2,3,4);
vector<float, 4> r42 = float4(1,2,3,4);
vector<double, 4> r43 = double4(1,2,3,4);
vector<uint, 4> r44 = uint4(1,2,3,4);
matrix r50 = float4x4(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); // matrix means float4x4
float4x4 r51 = matrix(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); // matrix means float4x4
// matrix<bool, 2, 3> r60 = bool2x3(false, true, false, true, false, true); // TODO:
matrix<float, 2, 3> r61 = float2x3(1,2,3,4,5,6);
matrix<float, 3, 2> r62 = float3x2(1,2,3,4,5,6);
// matrix<float, 4, 1> r63 = float4x1(1,2,3,4); // TODO:
// matrix<float, 1, 4> r64 = float1x4(1,2,3,4); // TODO:
matrix<float, 4, 2> r65 = float4x2(1,2,3,4,5,6,7,8);
matrix<float, 4, 3> r66 = float4x3(1,2,3,4,5,6,7,8,9,10,11,12);
// TODO: bool mats
// TODO: int mats
return 0.0;
}
float4 main(float4 input) : COLOR0
{
vector r00 = float4(1,2,3,4); // vector means float4
float4 r01 = vector(2,3,4,5); // vector means float4
vector<bool, 1> r12 = bool1(false);
vector<int, 1> r13 = int1(1);
vector<float, 1> r14 = float1(1);
vector<double, 1> r15 = double1(1);
vector<uint, 1> r16 = uint1(1);
vector<bool, 2> r20 = bool2(false, true);
vector<int, 2> r21 = int2(1,2);
vector<float, 2> r22 = float2(1,2);
vector<double, 2> r23 = double2(1,2);
vector<uint, 2> r24 = uint2(1,2);
vector<bool, 3> r30 = bool3(false, true, true);
vector<int, 3> r31 = int3(1,2,3);
vector<float, 3> r32 = float3(1,2,3);
vector<double, 3> r33 = double3(1,2,3);
vector<uint, 3> r34 = uint3(1,2,3);
vector<bool, 4> r40 = bool4(false, true, true, false);
vector<int, 4> r41 = int4(1,2,3,4);
vector<float, 4> r42 = float4(1,2,3,4);
vector<double, 4> r43 = double4(1,2,3,4);
vector<uint, 4> r44 = uint4(1,2,3,4);
matrix r50 = float4x4(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); // matrix means float4x4
float4x4 r51 = matrix(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); // matrix means float4x4
// matrix<bool, 2, 3> r60 = bool2x3(false, true, false, true, false, true); // TODO:
matrix<float, 2, 3> r61 = float2x3(1,2,3,4,5,6);
matrix<float, 3, 2> r62 = float3x2(1,2,3,4,5,6);
// matrix<float, 4, 1> r63 = float4x1(1,2,3,4); // TODO:
// matrix<float, 1, 4> r64 = float1x4(1,2,3,4); // TODO:
matrix<float, 4, 2> r65 = float4x2(1,2,3,4,5,6,7,8);
matrix<float, 4, 3> r66 = float4x3(1,2,3,4,5,6,7,8,9,10,11,12);
// TODO: bool mats
// TODO: int mats
return 0.0;
}
#version 450
in float inf;
out vec4 outf4;
void main()
{
if (inf > 2.0)
outf4 = vec4(inf);
else
outf4 = vec4(inf + -.5);
}
#version 450
in float inf;
out vec4 outf4;
void main()
{
if (inf > 2.0)
outf4 = vec4(inf);
else
outf4 = vec4(inf + -.5);
}
#version 450
in float inf;
in flat ivec4 ini4;
out vec4 outf4;
float Test1(int bound)
{
float r = 0;
for (int x=0; x<bound; ++x)
r += 0.5;
return r;
}
float Test2(int bound)
{
if (bound > 2)
return Test1(bound);
else
return float(bound * 2 +
ini4.y * ini4.z +
ini4.x);
}
void main()
{
outf4 = vec4(Test1(int(inf)) +
Test2(int(inf)));
}
#version 450
in float inf;
in flat ivec4 ini4;
out vec4 outf4;
float Test1(int bound)
{
float r = 0;
for (int x=0; x<bound; ++x)
r += 0.5;
return r;
}
float Test2(int bound)
{
if (bound > 2)
return Test1(bound);
else
return float(bound * 2 +
ini4.y * ini4.z +
ini4.x);
}
void main()
{
outf4 = vec4(Test1(int(inf)) +
Test2(int(inf)));
}
#version 450
out vec4 outf4;
in flat ivec4 ini4;
in float inf;
float Test1(int bound)
{
float r = 0;
for (int x=0; x<bound; ++x)
r += 0.5;
r += 0.2;
return r;
}
float Test2(int bound)
{
if (bound > 2) {
return Test1(bound * 2);
} else
return float(bound * 4 +
ini4.y * ini4.z +
ini4.x);
}
void main()
{
outf4 = vec4(Test1(int(inf)) +
Test2(int(inf)));
}
#version 450
out vec4 outf4;
in flat ivec4 ini4;
in float inf;
float Test1(int bound)
{
float r = 0;
for (int x=0; x<bound; ++x)
r += 0.5;
r += 0.2;
return r;
}
float Test2(int bound)
{
if (bound > 2) {
return Test1(bound * 2);
} else
return float(bound * 4 +
ini4.y * ini4.z +
ini4.x);
}
void main()
{
outf4 = vec4(Test1(int(inf)) +
Test2(int(inf)));
}
#version 450
precision highp float;
layout(location = 0) out mediump vec4 FragColor;
layout(location = 0) in vec4 in0;
void main()
{
switch(int(in0.w)) {
case 0: FragColor = vec4(in0.x + 0); break;
case 1: FragColor = vec4(in0.y + 1); break;
case 2: FragColor = vec4(in0.z + 2); break;
default: FragColor = vec4(-1);
}
}
#version 450
precision highp float;
layout(location = 0) out mediump vec4 FragColor;
layout(location = 0) in vec4 in0;
void main()
{
switch(int(in0.w)) {
case 0: FragColor = vec4(in0.x + 0); break;
case 1: FragColor = vec4(in0.y + 1); break;
case 2: FragColor = vec4(in0.z + 2); break;
default: FragColor = vec4(-1);
}
}
#version 140
uniform sampler2D texSampler2D;
in vec3 inColor;
in vec4 color[6];
in float alpha[16];
void main()
{
vec4 texColor = color[1] + color[1];
texColor.xyz += inColor;
texColor.a += alpha[12];
gl_FragColor = texColor;
}
#version 140
uniform sampler2D texSampler2D;
in vec3 inColor;
in vec4 color[6];
in float alpha[16];
void main()
{
vec4 texColor = color[1] + color[1];
texColor.xyz += inColor;
texColor.a += alpha[12];
gl_FragColor = texColor;
}
...@@ -37,4 +37,37 @@ if (TARGET gmock) ...@@ -37,4 +37,37 @@ if (TARGET gmock)
glslang OSDependent OGLCompiler HLSL glslang glslang OSDependent OGLCompiler HLSL glslang
SPIRV glslang-default-resource-limits gmock) SPIRV glslang-default-resource-limits gmock)
add_test(NAME glslang-gtests COMMAND glslangtests) add_test(NAME glslang-gtests COMMAND glslangtests)
# -- Remapper tests
set(REMAPPER_TEST_SOURCES
# Framework related source files
${CMAKE_CURRENT_SOURCE_DIR}/Initializer.h
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Settings.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Settings.h
${CMAKE_CURRENT_SOURCE_DIR}/TestFixture.cpp
${CMAKE_CURRENT_SOURCE_DIR}/TestFixture.h
# Test related source files
${CMAKE_CURRENT_SOURCE_DIR}/Remap.FromFile.cpp
)
add_executable(remappertests ${REMAPPER_TEST_SOURCES})
set_property(TARGET remappertests PROPERTY FOLDER tests)
glslang_set_link_args(remappertests)
install(TARGETS remappertests
RUNTIME DESTINATION bin)
target_compile_definitions(remappertests
PRIVATE GLSLANG_TEST_DIRECTORY="${CMAKE_CURRENT_SOURCE_DIR}/../Test")
target_include_directories(remappertests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}
${gmock_SOURCE_DIR}/include
${gtest_SOURCE_DIR}/include)
target_link_libraries(remappertests PRIVATE
SPVRemapper
glslang OSDependent OGLCompiler HLSL glslang
SPIRV glslang-default-resource-limits gmock)
add_test(NAME remapper-gtests COMMAND remappertests)
endif() endif()
//
// Copyright (C) 2016 LunarG, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
#include <gtest/gtest.h>
#include "TestFixture.h"
namespace glslangtest {
namespace {
struct RemapTestArgs {
const char* fileName;
const char* entryPoint;
Source sourceLanguage;
unsigned int remapOpts;
};
// We are using FileNameEntryPointPair objects as parameters for instantiating
// the template, so the global FileNameAsCustomTestSuffix() won't work since
// it assumes std::string as parameters. Thus, an overriding one here.
std::string FileNameAsCustomTestSuffix(
const ::testing::TestParamInfo<RemapTestArgs>& info) {
std::string name = info.param.fileName;
// A valid test case suffix cannot have '.' and '-' inside.
std::replace(name.begin(), name.end(), '.', '_');
std::replace(name.begin(), name.end(), '-', '_');
return name;
}
using RemapTest = GlslangTest<::testing::TestWithParam<RemapTestArgs>>;
// Remapping SPIR-V modules.
TEST_P(RemapTest, FromFile)
{
if (GetSuffix(GetParam().fileName) == "spv") {
loadFileRemapAndCheck(GLSLANG_TEST_DIRECTORY, GetParam().fileName,
GetParam().sourceLanguage,
Semantics::Vulkan,
Target::Spv,
GetParam().remapOpts);
} else {
loadFileCompileRemapAndCheck(GLSLANG_TEST_DIRECTORY, GetParam().fileName,
GetParam().sourceLanguage,
Semantics::Vulkan,
Target::Spv,
GetParam().entryPoint,
GetParam().remapOpts);
}
}
// clang-format off
INSTANTIATE_TEST_CASE_P(
ToSpirv, RemapTest,
::testing::ValuesIn(std::vector<RemapTestArgs>{
// GLSL remapper tests
// testname entry language remapper_options
{ "remap.basic.none.frag", "main", Source::GLSL, spv::spirvbin_t::NONE },
{ "remap.basic.everything.frag", "main", Source::GLSL, spv::spirvbin_t::DO_EVERYTHING },
{ "remap.basic.dcefunc.frag", "main", Source::GLSL, spv::spirvbin_t::DCE_FUNCS },
{ "remap.basic.strip.frag", "main", Source::GLSL, spv::spirvbin_t::STRIP },
{ "remap.switch.none.frag", "main", Source::GLSL, spv::spirvbin_t::NONE },
{ "remap.switch.everything.frag", "main", Source::GLSL, spv::spirvbin_t::DO_EVERYTHING },
{ "remap.literal64.none.spv", "main", Source::GLSL, spv::spirvbin_t::NONE },
{ "remap.literal64.everything.spv", "main", Source::GLSL, spv::spirvbin_t::DO_EVERYTHING },
{ "remap.if.none.frag", "main", Source::GLSL, spv::spirvbin_t::NONE },
{ "remap.if.everything.frag", "main", Source::GLSL, spv::spirvbin_t::DO_EVERYTHING },
{ "remap.similar_1a.none.frag", "main", Source::GLSL, spv::spirvbin_t::NONE },
{ "remap.similar_1b.none.frag", "main", Source::GLSL, spv::spirvbin_t::NONE },
{ "remap.similar_1a.everything.frag", "main", Source::GLSL, spv::spirvbin_t::DO_EVERYTHING },
{ "remap.similar_1b.everything.frag", "main", Source::GLSL, spv::spirvbin_t::DO_EVERYTHING },
{ "remap.uniformarray.none.frag", "main", Source::GLSL, spv::spirvbin_t::NONE },
{ "remap.uniformarray.everything.frag", "main", Source::GLSL, spv::spirvbin_t::DO_EVERYTHING },
// HLSL remapper tests
{ "remap.hlsl.sample.basic.strip.frag", "main", Source::HLSL, spv::spirvbin_t::STRIP },
{ "remap.hlsl.sample.basic.everything.frag", "main", Source::HLSL, spv::spirvbin_t::DO_EVERYTHING },
{ "remap.hlsl.sample.basic.none.frag", "main", Source::HLSL, spv::spirvbin_t::NONE },
{ "remap.hlsl.templatetypes.none.frag", "main", Source::HLSL, spv::spirvbin_t::NONE },
{ "remap.hlsl.templatetypes.everything.frag", "main", Source::HLSL, spv::spirvbin_t::DO_EVERYTHING },
}),
FileNameAsCustomTestSuffix
);
// clang-format on
} // anonymous namespace
} // namespace glslangtest
...@@ -116,6 +116,32 @@ std::pair<bool, std::string> ReadFile(const std::string& path) ...@@ -116,6 +116,32 @@ std::pair<bool, std::string> ReadFile(const std::string& path)
return std::make_pair(false, ""); return std::make_pair(false, "");
} }
std::pair<bool, std::vector<std::uint32_t> > ReadSpvBinaryFile(const std::string& path)
{
std::ifstream fstream(path, std::fstream::in | std::fstream::binary);
if (!fstream)
return std::make_pair(false, std::vector<std::uint32_t>());
std::vector<std::uint32_t> contents;
// Reserve space (for efficiency, not for correctness)
fstream.seekg(0, fstream.end);
contents.reserve(size_t(fstream.tellg()) / sizeof(std::uint32_t));
fstream.seekg(0, fstream.beg);
// There is no istream iterator traversing by uint32_t, so we must loop.
while (!fstream.eof()) {
std::uint32_t inWord;
fstream.read((char *)&inWord, sizeof(inWord));
if (!fstream.eof())
contents.push_back(inWord);
}
return std::make_pair(true, contents); // hopefully, c++11 move semantics optimizes the copy away.
}
bool WriteFile(const std::string& path, const std::string& contents) bool WriteFile(const std::string& path, const std::string& contents)
{ {
std::ofstream fstream(path, std::ios::out); std::ofstream fstream(path, std::ios::out);
......
...@@ -40,12 +40,14 @@ ...@@ -40,12 +40,14 @@
#include <sstream> #include <sstream>
#include <streambuf> #include <streambuf>
#include <tuple> #include <tuple>
#include <string>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "SPIRV/GlslangToSpv.h" #include "SPIRV/GlslangToSpv.h"
#include "SPIRV/disassemble.h" #include "SPIRV/disassemble.h"
#include "SPIRV/doc.h" #include "SPIRV/doc.h"
#include "SPIRV/SPVRemapper.h"
#include "StandAlone/ResourceLimits.h" #include "StandAlone/ResourceLimits.h"
#include "glslang/Public/ShaderLang.h" #include "glslang/Public/ShaderLang.h"
...@@ -93,6 +95,7 @@ EShMessages DeriveOptions(Source, Semantics, Target); ...@@ -93,6 +95,7 @@ EShMessages DeriveOptions(Source, Semantics, Target);
// Reads the content of the file at the given |path|. On success, returns true // Reads the content of the file at the given |path|. On success, returns true
// and the contents; otherwise, returns false and an empty string. // and the contents; otherwise, returns false and an empty string.
std::pair<bool, std::string> ReadFile(const std::string& path); std::pair<bool, std::string> ReadFile(const std::string& path);
std::pair<bool, std::vector<std::uint32_t> > ReadSpvBinaryFile(const std::string& path);
// Writes the given |contents| into the file at the given |path|. Returns true // Writes the given |contents| into the file at the given |path|. Returns true
// on successful output. // on successful output.
...@@ -128,6 +131,16 @@ public: ...@@ -128,6 +131,16 @@ public:
ASSERT_TRUE(fileReadOk) << "Cannot open " << tag << " file: " << path; ASSERT_TRUE(fileReadOk) << "Cannot open " << tag << " file: " << path;
} }
// Tries to load the contents from the file at the given |path|. On success,
// writes the contents into |contents|. On failure, errors out.
void tryLoadSpvFile(const std::string& path, const std::string& tag,
std::vector<uint32_t>& contents)
{
bool fileReadOk;
std::tie(fileReadOk, contents) = ReadSpvBinaryFile(path);
ASSERT_TRUE(fileReadOk) << "Cannot open " << tag << " file: " << path;
}
// Checks the equality of |expected| and |real|. If they are not equal, // Checks the equality of |expected| and |real|. If they are not equal,
// write |real| to the given file named as |fname| if update mode is on. // write |real| to the given file named as |fname| if update mode is on.
void checkEqAndUpdateIfRequested(const std::string& expected, void checkEqAndUpdateIfRequested(const std::string& expected,
...@@ -221,6 +234,68 @@ public: ...@@ -221,6 +234,68 @@ public:
} }
} }
// This is like compileAndLink but with remapping of the SPV binary
// through spirvbin_t::remap(). While technically this could be merged
// with compileAndLink() above (with the remap step optionally being a no-op)
// it is given separately here for ease of future extraction.
GlslangResult compileLinkRemap(
const std::string shaderName, const std::string& code,
const std::string& entryPointName, EShMessages controls,
const unsigned int remapOptions = spv::spirvbin_t::NONE)
{
const EShLanguage kind = GetShaderStage(GetSuffix(shaderName));
glslang::TShader shader(kind);
bool success = compile(&shader, code, entryPointName, controls);
glslang::TProgram program;
program.addShader(&shader);
success &= program.link(controls);
spv::SpvBuildLogger logger;
if (success && (controls & EShMsgSpvRules)) {
std::vector<uint32_t> spirv_binary;
glslang::GlslangToSpv(*program.getIntermediate(kind),
spirv_binary, &logger);
spv::spirvbin_t(0 /*verbosity*/).remap(spirv_binary, remapOptions);
std::ostringstream disassembly_stream;
spv::Parameterize();
spv::Disassemble(disassembly_stream, spirv_binary);
return {{{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},},
program.getInfoLog(), program.getInfoDebugLog(),
logger.getAllMessages(), disassembly_stream.str()};
} else {
return {{{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},},
program.getInfoLog(), program.getInfoDebugLog(), "", ""};
}
}
// remap the binary in 'code' with the options in remapOptions
GlslangResult remap(
const std::string shaderName, const std::vector<uint32_t>& code,
EShMessages controls,
const unsigned int remapOptions = spv::spirvbin_t::NONE)
{
if ((controls & EShMsgSpvRules)) {
std::vector<uint32_t> spirv_binary(code); // scratch copy
spv::spirvbin_t(0 /*verbosity*/).remap(spirv_binary, remapOptions);
std::ostringstream disassembly_stream;
spv::Parameterize();
spv::Disassemble(disassembly_stream, spirv_binary);
return {{{shaderName, "", ""},},
"", "",
"", disassembly_stream.str()};
} else {
return {{{shaderName, "", ""},}, "", "", "", ""};
}
}
void outputResultToStream(std::ostringstream* stream, void outputResultToStream(std::ostringstream* stream,
const GlslangResult& result, const GlslangResult& result,
EShMessages controls) EShMessages controls)
...@@ -272,6 +347,60 @@ public: ...@@ -272,6 +347,60 @@ public:
expectedOutputFname); expectedOutputFname);
} }
void loadFileCompileRemapAndCheck(const std::string& testDir,
const std::string& testName,
Source source,
Semantics semantics,
Target target,
const std::string& entryPointName="",
const unsigned int remapOptions = spv::spirvbin_t::NONE)
{
const std::string inputFname = testDir + "/" + testName;
const std::string expectedOutputFname =
testDir + "/baseResults/" + testName + ".out";
std::string input, expectedOutput;
tryLoadFile(inputFname, "input", &input);
tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
const EShMessages controls = DeriveOptions(source, semantics, target);
GlslangResult result = compileLinkRemap(testName, input, entryPointName, controls, remapOptions);
// Generate the hybrid output in the way of glslangValidator.
std::ostringstream stream;
outputResultToStream(&stream, result, controls);
checkEqAndUpdateIfRequested(expectedOutput, stream.str(),
expectedOutputFname);
}
void loadFileRemapAndCheck(const std::string& testDir,
const std::string& testName,
Source source,
Semantics semantics,
Target target,
const unsigned int remapOptions = spv::spirvbin_t::NONE)
{
const std::string inputFname = testDir + "/" + testName;
const std::string expectedOutputFname =
testDir + "/baseResults/" + testName + ".out";
std::vector<std::uint32_t> input;
std::string expectedOutput;
tryLoadSpvFile(inputFname, "input", input);
tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
const EShMessages controls = DeriveOptions(source, semantics, target);
GlslangResult result = remap(testName, input, controls, remapOptions);
// Generate the hybrid output in the way of glslangValidator.
std::ostringstream stream;
outputResultToStream(&stream, result, controls);
checkEqAndUpdateIfRequested(expectedOutput, stream.str(),
expectedOutputFname);
}
// Preprocesses the given |source| code. On success, returns true, the // Preprocesses the given |source| code. On success, returns true, the
// preprocessed shader, and warning messages. Otherwise, returns false, an // preprocessed shader, and warning messages. Otherwise, returns false, an
// empty string, and error messages. // empty string, and error messages.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment