Merge branch 'master' of github.com:bkaradzic/bgfx

This commit is contained in:
Branimir Karadžić 2017-05-13 22:21:14 -07:00
commit 0c04ae9c52
32 changed files with 562 additions and 36 deletions

View File

@ -32,6 +32,8 @@
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
#pragma once
#if _MSC_VER >= 1900
#pragma warning(disable : 4464) // relative include path contains '..'
#endif

View File

@ -51,7 +51,7 @@
#include "spvIR.h"
#include <cassert>
#include <unordered_map>
#include <unordered_set>
using spv::Block;
using spv::Id;
@ -69,33 +69,33 @@ public:
void visit(Block* block)
{
assert(block);
if (visited_[block] || delayed_[block])
if (visited_.count(block) || delayed_.count(block))
return;
callback_(block);
visited_[block] = true;
visited_.insert(block);
Block* mergeBlock = nullptr;
Block* continueBlock = nullptr;
auto mergeInst = block->getMergeInstruction();
if (mergeInst) {
Id mergeId = mergeInst->getIdOperand(0);
mergeBlock = block->getParent().getParent().getInstruction(mergeId)->getBlock();
delayed_[mergeBlock] = true;
delayed_.insert(mergeBlock);
if (mergeInst->getOpCode() == spv::OpLoopMerge) {
Id continueId = mergeInst->getIdOperand(1);
continueBlock =
block->getParent().getParent().getInstruction(continueId)->getBlock();
delayed_[continueBlock] = true;
delayed_.insert(continueBlock);
}
}
const auto successors = block->getSuccessors();
for (auto it = successors.cbegin(); it != successors.cend(); ++it)
visit(*it);
if (continueBlock) {
delayed_[continueBlock] = false;
delayed_.erase(continueBlock);
visit(continueBlock);
}
if (mergeBlock) {
delayed_[mergeBlock] = false;
delayed_.erase(mergeBlock);
visit(mergeBlock);
}
}
@ -103,7 +103,7 @@ public:
private:
std::function<void(Block*)> callback_;
// Whether a block has already been visited or is being delayed.
std::unordered_map<Block *, bool> visited_, delayed_;
std::unordered_set<Block *> visited_, delayed_;
};
}

View File

@ -36,6 +36,8 @@
// Parameterize the SPIR-V enumerants.
//
#pragma once
#include "spirv.hpp"
#include <vector>

View File

@ -35,7 +35,9 @@
//
// this only applies to the standalone wrapper, not the front end in general
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#include "ResourceLimits.h"
#include "Worklist.h"
@ -168,6 +170,7 @@ std::array<unsigned int, EShLangCount> baseImageBinding;
std::array<unsigned int, EShLangCount> baseUboBinding;
std::array<unsigned int, EShLangCount> baseSsboBinding;
std::array<unsigned int, EShLangCount> baseUavBinding;
std::array<std::vector<std::string>, EShLangCount> baseResourceSetBinding;
//
// Create the default name for saving a binary if -o is not provided.
@ -245,6 +248,45 @@ void ProcessBindingBase(int& argc, char**& argv, std::array<unsigned int, EShLan
}
}
void ProcessResourceSetBindingBase(int& argc, char**& argv, std::array<std::vector<std::string>, EShLangCount>& base)
{
if (argc < 2)
usage();
if (!isdigit(argv[1][0])) {
if (argc < 5) // this form needs one more argument
usage();
// Parse form: --argname stage base
const EShLanguage lang = FindLanguage(argv[1], false);
base[lang].push_back(argv[2]);
base[lang].push_back(argv[3]);
base[lang].push_back(argv[4]);
argc-= 4;
argv+= 4;
while(argv[1] != NULL) {
if(argv[1][0] != '-') {
base[lang].push_back(argv[1]);
base[lang].push_back(argv[2]);
base[lang].push_back(argv[3]);
argc-= 3;
argv+= 3;
}
else {
break;
}
}
} else {
// Parse form: --argname base
for (int lang=0; lang<EShLangCount; ++lang)
base[lang].push_back(argv[1]);
argc--;
argv++;
}
}
//
// Do all command-line argument parsing. This includes building up the work-items
// to be processed later, and saving all the command-line options.
@ -297,6 +339,10 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
lowerword == "shift-ssbo-binding" ||
lowerword == "sbb") {
ProcessBindingBase(argc, argv, baseSsboBinding);
} else if (lowerword == "resource-set-bindings" || // synonyms
lowerword == "resource-set-binding" ||
lowerword == "rsb") {
ProcessResourceSetBindingBase(argc, argv, baseResourceSetBinding);
} else if (lowerword == "shift-uav-bindings" || // synonyms
lowerword == "shift-uav-binding" ||
lowerword == "suavb") {
@ -594,6 +640,7 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
shader->setShiftUavBinding(baseUavBinding[compUnit.stage]);
shader->setFlattenUniformArrays((Options & EOptionFlattenUniformArrays) != 0);
shader->setNoStorageFormat((Options & EOptionNoStorageFormat) != 0);
shader->setResourceSetBinding(baseResourceSetBinding[compUnit.stage]);
if (Options & EOptionHlslIoMapping)
shader->setHlslIoMapping(true);
@ -1006,6 +1053,9 @@ void usage()
" --shift-ssbo-binding [stage] num set base binding number for SSBOs\n"
" --sbb [stage] num synonym for --shift-ssbo-binding\n"
"\n"
" --resource-set-binding [stage] num set descriptor set and binding number for resources\n"
" --rsb [stage] type set binding synonym for --resource-set-binding\n"
"\n"
" --shift-uav-binding [stage] num set base binding number for UAVs\n"
" --suavb [stage] num synonym for --shift-uav-binding\n"
"\n"

View File

@ -71,6 +71,50 @@ gl_FragCoord origin is upper left
0:14 0.000000
0:14 0.000000
0:14 0.000000
0:15 Test condition and select ( temp void)
0:15 Condition
0:15 Constant:
0:15 true (const bool)
0:15 true case
0:16 Branch: Return with expression
0:16 Constant:
0:16 0.000000
0:16 0.000000
0:16 0.000000
0:16 0.000000
0:17 Test condition and select ( temp void)
0:17 Condition
0:17 Constant:
0:17 false (const bool)
0:17 true case
0:18 Branch: Return with expression
0:18 Constant:
0:18 0.000000
0:18 0.000000
0:18 0.000000
0:18 0.000000
0:19 Test condition and select ( temp void)
0:19 Condition
0:19 Constant:
0:19 true (const bool)
0:19 true case
0:20 Branch: Return with expression
0:20 Constant:
0:20 0.000000
0:20 0.000000
0:20 0.000000
0:20 0.000000
0:21 Test condition and select ( temp void)
0:21 Condition
0:21 Constant:
0:21 true (const bool)
0:21 true case
0:22 Branch: Return with expression
0:22 Constant:
0:22 0.000000
0:22 0.000000
0:22 0.000000
0:22 0.000000
0:2 Function Definition: main( ( temp void)
0:2 Function Parameters:
0:? Sequence
@ -156,6 +200,50 @@ gl_FragCoord origin is upper left
0:14 0.000000
0:14 0.000000
0:14 0.000000
0:15 Test condition and select ( temp void)
0:15 Condition
0:15 Constant:
0:15 true (const bool)
0:15 true case
0:16 Branch: Return with expression
0:16 Constant:
0:16 0.000000
0:16 0.000000
0:16 0.000000
0:16 0.000000
0:17 Test condition and select ( temp void)
0:17 Condition
0:17 Constant:
0:17 false (const bool)
0:17 true case
0:18 Branch: Return with expression
0:18 Constant:
0:18 0.000000
0:18 0.000000
0:18 0.000000
0:18 0.000000
0:19 Test condition and select ( temp void)
0:19 Condition
0:19 Constant:
0:19 true (const bool)
0:19 true case
0:20 Branch: Return with expression
0:20 Constant:
0:20 0.000000
0:20 0.000000
0:20 0.000000
0:20 0.000000
0:21 Test condition and select ( temp void)
0:21 Condition
0:21 Constant:
0:21 true (const bool)
0:21 true case
0:22 Branch: Return with expression
0:22 Constant:
0:22 0.000000
0:22 0.000000
0:22 0.000000
0:22 0.000000
0:2 Function Definition: main( ( temp void)
0:2 Function Parameters:
0:? Sequence
@ -167,18 +255,18 @@ gl_FragCoord origin is upper left
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 38
// Id's are bound by 50
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 36
EntryPoint Fragment 4 "main" 48
ExecutionMode 4 OriginUpperLeft
Source HLSL 500
Name 4 "main"
Name 9 "@main("
Name 36 "@entryPointOutput"
Decorate 36(@entryPointOutput) Location 0
Name 48 "@entryPointOutput"
Decorate 48(@entryPointOutput) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@ -189,12 +277,12 @@ gl_FragCoord origin is upper left
15: 6(float) Constant 0
16: 7(fvec4) ConstantComposite 15 15 15 15
21: 11(bool) ConstantTrue
35: TypePointer Output 7(fvec4)
36(@entryPointOutput): 35(ptr) Variable Output
47: TypePointer Output 7(fvec4)
48(@entryPointOutput): 47(ptr) Variable Output
4(main): 2 Function None 3
5: Label
37: 7(fvec4) FunctionCall 9(@main()
Store 36(@entryPointOutput) 37
49: 7(fvec4) FunctionCall 9(@main()
Store 48(@entryPointOutput) 49
Return
FunctionEnd
9(@main(): 7(fvec4) Function None 8
@ -229,6 +317,26 @@ gl_FragCoord origin is upper left
31: Label
ReturnValue 16
32: Label
34: 7(fvec4) Undef
ReturnValue 34
SelectionMerge 35 None
BranchConditional 21 34 35
34: Label
ReturnValue 16
35: Label
SelectionMerge 38 None
BranchConditional 12 37 38
37: Label
ReturnValue 16
38: Label
SelectionMerge 41 None
BranchConditional 21 40 41
40: Label
ReturnValue 16
41: Label
SelectionMerge 44 None
BranchConditional 21 43 44
43: Label
ReturnValue 16
44: Label
46: 7(fvec4) Undef
ReturnValue 46
FunctionEnd

View File

@ -0,0 +1,173 @@
hlsl.multiDescriptorSet.frag
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 95
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 78 83 89
ExecutionMode 4 OriginUpperLeft
Source HLSL 500
Name 4 "main"
Name 9 "PS_INPUT"
MemberName 9(PS_INPUT) 0 "Pos"
MemberName 9(PS_INPUT) 1 "Tex"
Name 13 "@main(struct-PS_INPUT-vf4-vf21;"
Name 12 "input"
Name 15 "output"
Name 23 "cbChangesEveryFrame"
MemberName 23(cbChangesEveryFrame) 0 "World"
MemberName 23(cbChangesEveryFrame) 1 "vMeshColor"
Name 25 ""
Name 34 "cbNeverChanges"
MemberName 34(cbNeverChanges) 0 "View"
Name 36 ""
Name 43 "cbChangeOnResize"
MemberName 43(cbChangeOnResize) 0 "Projection"
Name 45 ""
Name 59 "txDiffuseA"
Name 63 "samLinearA"
Name 76 "input"
Name 78 "input_Pos"
Name 81 "PS_INPUT"
MemberName 81(PS_INPUT) 0 "Tex"
Name 83 "input"
Name 89 "@entryPointOutput"
Name 90 "param"
Name 93 "txDiffuseB"
Name 94 "samLinearB"
MemberDecorate 23(cbChangesEveryFrame) 0 RowMajor
MemberDecorate 23(cbChangesEveryFrame) 0 Offset 0
MemberDecorate 23(cbChangesEveryFrame) 0 MatrixStride 16
MemberDecorate 23(cbChangesEveryFrame) 1 Offset 64
Decorate 23(cbChangesEveryFrame) Block
Decorate 25 DescriptorSet 2
Decorate 25 Binding 2
MemberDecorate 34(cbNeverChanges) 0 RowMajor
MemberDecorate 34(cbNeverChanges) 0 Offset 0
MemberDecorate 34(cbNeverChanges) 0 MatrixStride 16
Decorate 34(cbNeverChanges) Block
Decorate 36 DescriptorSet 2
Decorate 36 Binding 0
MemberDecorate 43(cbChangeOnResize) 0 RowMajor
MemberDecorate 43(cbChangeOnResize) 0 Offset 0
MemberDecorate 43(cbChangeOnResize) 0 MatrixStride 16
Decorate 43(cbChangeOnResize) Block
Decorate 45 DescriptorSet 2
Decorate 45 Binding 1
Decorate 59(txDiffuseA) DescriptorSet 0
Decorate 59(txDiffuseA) Binding 0
Decorate 63(samLinearA) DescriptorSet 0
Decorate 63(samLinearA) Binding 1
Decorate 78(input_Pos) BuiltIn FragCoord
Decorate 83(input) Location 0
Decorate 89(@entryPointOutput) Location 0
Decorate 93(txDiffuseB) DescriptorSet 1
Decorate 93(txDiffuseB) Binding 0
Decorate 94(samLinearB) DescriptorSet 1
Decorate 94(samLinearB) Binding 1
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypeVector 6(float) 2
9(PS_INPUT): TypeStruct 7(fvec4) 8(fvec2)
10: TypePointer Function 9(PS_INPUT)
11: TypeFunction 7(fvec4) 10(ptr)
16: 6(float) Constant 0
17: 7(fvec4) ConstantComposite 16 16 16 16
18: 8(fvec2) ConstantComposite 16 16
19: 9(PS_INPUT) ConstantComposite 17 18
20: TypeInt 32 1
21: 20(int) Constant 0
22: TypeMatrix 7(fvec4) 4
23(cbChangesEveryFrame): TypeStruct 22 7(fvec4)
24: TypePointer Uniform 23(cbChangesEveryFrame)
25: 24(ptr) Variable Uniform
26: TypePointer Uniform 22
29: TypePointer Function 7(fvec4)
34(cbNeverChanges): TypeStruct 22
35: TypePointer Uniform 34(cbNeverChanges)
36: 35(ptr) Variable Uniform
43(cbChangeOnResize): TypeStruct 22
44: TypePointer Uniform 43(cbChangeOnResize)
45: 44(ptr) Variable Uniform
52: 20(int) Constant 1
53: TypePointer Function 8(fvec2)
57: TypeImage 6(float) 2D sampled format:Unknown
58: TypePointer UniformConstant 57
59(txDiffuseA): 58(ptr) Variable UniformConstant
61: TypeSampler
62: TypePointer UniformConstant 61
63(samLinearA): 62(ptr) Variable UniformConstant
65: TypeSampledImage 57
70: TypePointer Uniform 7(fvec4)
77: TypePointer Input 7(fvec4)
78(input_Pos): 77(ptr) Variable Input
81(PS_INPUT): TypeStruct 8(fvec2)
82: TypePointer Input 81(PS_INPUT)
83(input): 82(ptr) Variable Input
84: TypePointer Input 8(fvec2)
88: TypePointer Output 7(fvec4)
89(@entryPointOutput): 88(ptr) Variable Output
93(txDiffuseB): 58(ptr) Variable UniformConstant
94(samLinearB): 62(ptr) Variable UniformConstant
4(main): 2 Function None 3
5: Label
76(input): 10(ptr) Variable Function
90(param): 10(ptr) Variable Function
79: 7(fvec4) Load 78(input_Pos)
80: 29(ptr) AccessChain 76(input) 21
Store 80 79
85: 84(ptr) AccessChain 83(input) 21
86: 8(fvec2) Load 85
87: 53(ptr) AccessChain 76(input) 52
Store 87 86
91: 9(PS_INPUT) Load 76(input)
Store 90(param) 91
92: 7(fvec4) FunctionCall 13(@main(struct-PS_INPUT-vf4-vf21;) 90(param)
Store 89(@entryPointOutput) 92
Return
FunctionEnd
13(@main(struct-PS_INPUT-vf4-vf21;): 7(fvec4) Function None 11
12(input): 10(ptr) FunctionParameter
14: Label
15(output): 10(ptr) Variable Function
Store 15(output) 19
27: 26(ptr) AccessChain 25 21
28: 22 Load 27
30: 29(ptr) AccessChain 12(input) 21
31: 7(fvec4) Load 30
32: 7(fvec4) MatrixTimesVector 28 31
33: 29(ptr) AccessChain 15(output) 21
Store 33 32
37: 26(ptr) AccessChain 36 21
38: 22 Load 37
39: 29(ptr) AccessChain 15(output) 21
40: 7(fvec4) Load 39
41: 7(fvec4) MatrixTimesVector 38 40
42: 29(ptr) AccessChain 15(output) 21
Store 42 41
46: 26(ptr) AccessChain 45 21
47: 22 Load 46
48: 29(ptr) AccessChain 15(output) 21
49: 7(fvec4) Load 48
50: 7(fvec4) MatrixTimesVector 47 49
51: 29(ptr) AccessChain 15(output) 21
Store 51 50
54: 53(ptr) AccessChain 12(input) 52
55: 8(fvec2) Load 54
56: 53(ptr) AccessChain 15(output) 52
Store 56 55
60: 57 Load 59(txDiffuseA)
64: 61 Load 63(samLinearA)
66: 65 SampledImage 60 64
67: 53(ptr) AccessChain 15(output) 52
68: 8(fvec2) Load 67
69: 7(fvec4) ImageSampleImplicitLod 66 68
71: 70(ptr) AccessChain 25 52
72: 7(fvec4) Load 71
73: 7(fvec4) FMul 69 72
ReturnValue 73
FunctionEnd

View File

@ -13,7 +13,7 @@ Warning, version 400 is not yet complete; most version-specific features are pre
Source GLSL 400
Name 4 "main"
Name 9 "arraySize"
Name 14 "foo(vf4[s1518];"
Name 14 "foo(vf4[s1521];"
Name 13 "p"
Name 17 "builtin_spec_constant("
Name 20 "color"
@ -104,10 +104,10 @@ Warning, version 400 is not yet complete; most version-specific features are pre
Store 20(color) 46
48: 10 Load 22(ucol)
Store 47(param) 48
49: 2 FunctionCall 14(foo(vf4[s1518];) 47(param)
49: 2 FunctionCall 14(foo(vf4[s1521];) 47(param)
Return
FunctionEnd
14(foo(vf4[s1518];): 2 Function None 12
14(foo(vf4[s1521];): 2 Function None 12
13(p): 11(ptr) FunctionParameter
15: Label
54: 24(ptr) AccessChain 53(dupUcol) 23

View File

@ -0,0 +1,66 @@
spv.textureBuffer.vert
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 42
Capability Shader
Capability SampledBuffer
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main"
Source GLSL 450
Name 4 "main"
Name 9 "tBuf"
Name 13 "s"
Name 23 "sBuf"
Name 32 "utBuf"
Name 38 "itBuf"
Decorate 9(tBuf) DescriptorSet 0
Decorate 13(s) DescriptorSet 0
Decorate 23(sBuf) DescriptorSet 0
Decorate 32(utBuf) DescriptorSet 0
Decorate 38(itBuf) DescriptorSet 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeImage 6(float) Buffer sampled format:Unknown
8: TypePointer UniformConstant 7
9(tBuf): 8(ptr) Variable UniformConstant
11: TypeSampler
12: TypePointer UniformConstant 11
13(s): 12(ptr) Variable UniformConstant
15: TypeSampledImage 7
17: TypeInt 32 1
18: 17(int) Constant 13
20: TypeVector 6(float) 4
22: TypePointer UniformConstant 15
23(sBuf): 22(ptr) Variable UniformConstant
29: TypeInt 32 0
30: TypeImage 29(int) Buffer sampled format:Unknown
31: TypePointer UniformConstant 30
32(utBuf): 31(ptr) Variable UniformConstant
34: TypeVector 29(int) 4
36: TypeImage 17(int) Buffer sampled format:Unknown
37: TypePointer UniformConstant 36
38(itBuf): 37(ptr) Variable UniformConstant
40: TypeVector 17(int) 4
4(main): 2 Function None 3
5: Label
10: 7 Load 9(tBuf)
14: 11 Load 13(s)
16: 15 SampledImage 10 14
19: 7 Image 16
21: 20(fvec4) ImageFetch 19 18
24: 15 Load 23(sBuf)
25: 7 Image 24
26: 20(fvec4) ImageFetch 25 18
27: 7 Load 9(tBuf)
28: 20(fvec4) ImageFetch 27 18
33: 30 Load 32(utBuf)
35: 34(ivec4) ImageFetch 33 18
39: 36 Load 38(itBuf)
41: 40(ivec4) ImageFetch 39 18
Return
FunctionEnd

View File

@ -12,4 +12,12 @@ float4 main() : SV_TARGET
return 0.0.xxxx;
if (!1)
return 0.0.xxxx;
if (0 || 1)
return 0.0.xxxx;
if (1 && 0)
return 0.0.xxxx;
if (1 || false)
return 0.0.xxxx;
if (true && 1)
return 0.0.xxxx;
}

View File

@ -0,0 +1,45 @@
Texture2D txDiffuseA : register( t0 );
Texture2D txDiffuseB : register( t1 );
SamplerState samLinearA : register( s0 );
SamplerState samLinearB : register( s1 );
cbuffer cbNeverChanges : register( b0 )
{
matrix View;
};
cbuffer cbChangeOnResize : register( b1 )
{
matrix Projection;
};
cbuffer cbChangesEveryFrame : register( b2 )
{
matrix World;
float4 vMeshColor;
};
struct VS_INPUT
{
float4 Pos : POSITION;
float2 Tex : TEXCOORD0;
};
struct PS_INPUT
{
float4 Pos : SV_POSITION;
float2 Tex : TEXCOORD0;
};
float4 main( PS_INPUT input) : SV_Target
{
PS_INPUT output = (PS_INPUT)0;
output.Pos = mul( input.Pos, World );
output.Pos = mul( output.Pos, View );
output.Pos = mul( output.Pos, Projection );
output.Tex = input.Tex;
return txDiffuseA.Sample( samLinearA, output.Tex ) * vMeshColor;
}

View File

@ -85,6 +85,13 @@ echo Running hlsl offsets
$EXE -i --hlsl-offsets -D -e main -H hlsl.hlslOffset.vert > $TARGETDIR/hlsl.hlslOffset.vert.out
diff -b $BASEDIR/hlsl.hlslOffset.vert.out $TARGETDIR/hlsl.hlslOffset.vert.out || HASERROR=1
#
# Tesing --resource-set-binding
#
echo Configuring HLSL descriptor set and binding number manually
$EXE -V -D -e main -H hlsl.multiDescriptorSet.frag --rsb frag t0 0 0 t1 1 0 s0 0 1 s1 1 1 b0 2 0 b1 2 1 b2 2 2 > $TARGETDIR/hlsl.multiDescriptorSet.frag.out
diff -b $BASEDIR/hlsl.multiDescriptorSet.frag.out $TARGETDIR/hlsl.multiDescriptorSet.frag.out
#
# Final checking
#

View File

@ -0,0 +1,17 @@
#version 450
uniform textureBuffer tBuf;
uniform sampler s;
uniform samplerBuffer sBuf;
uniform utextureBuffer utBuf;
uniform itextureBuffer itBuf;
void main()
{
texelFetch(samplerBuffer(tBuf, s), 13);
texelFetch(sBuf, 13);
texelFetch(tBuf, 13);
texelFetch(utBuf, 13);
texelFetch(itBuf, 13);
}

View File

@ -3844,6 +3844,16 @@ void TBuiltIns::add2ndGenerationSamplingImaging(int version, EProfile profile, c
else {
addSamplingFunctions(sampler, typeName, version, profile);
addGatherFunctions(sampler, typeName, version, profile);
if (spvVersion.vulkan > 0 && sampler.dim == EsdBuffer && sampler.isCombined()) {
// Vulkan wants a textureBuffer to allow texelFetch() --
// a sampled image with no sampler.
// So, add sampling functions for both the
// samplerBuffer and textureBuffer types.
sampler.setTexture(sampler.type, sampler.dim, sampler.arrayed, sampler.shadow,
sampler.ms);
TString textureTypeName = sampler.getString();
addSamplingFunctions(sampler, textureTypeName, version, profile);
}
}
}
}
@ -3867,7 +3877,7 @@ void TBuiltIns::add2ndGenerationSamplingImaging(int version, EProfile profile, c
//
// Add all the query functions for the given type.
//
void TBuiltIns::addQueryFunctions(TSampler sampler, TString& typeName, int version, EProfile profile)
void TBuiltIns::addQueryFunctions(TSampler sampler, const TString& typeName, int version, EProfile profile)
{
if (sampler.image && ((profile == EEsProfile && version < 310) || (profile != EEsProfile && version < 430)))
return;
@ -3944,7 +3954,7 @@ void TBuiltIns::addQueryFunctions(TSampler sampler, TString& typeName, int versi
//
// Add all the image access functions for the given type.
//
void TBuiltIns::addImageFunctions(TSampler sampler, TString& typeName, int version, EProfile profile)
void TBuiltIns::addImageFunctions(TSampler sampler, const TString& typeName, int version, EProfile profile)
{
int dims = dimMap[sampler.dim];
// most things with an array add a dimension, except for cubemaps
@ -4037,7 +4047,7 @@ void TBuiltIns::addImageFunctions(TSampler sampler, TString& typeName, int versi
//
// Add all the subpass access functions for the given type.
//
void TBuiltIns::addSubpassSampling(TSampler sampler, TString& typeName, int /*version*/, EProfile /*profile*/)
void TBuiltIns::addSubpassSampling(TSampler sampler, const TString& typeName, int /*version*/, EProfile /*profile*/)
{
stageBuiltins[EShLangFragment].append(prefixes[sampler.type]);
stageBuiltins[EShLangFragment].append("vec4 subpassLoad");
@ -4054,7 +4064,7 @@ void TBuiltIns::addSubpassSampling(TSampler sampler, TString& typeName, int /*ve
//
// Add all the texture lookup functions for the given type.
//
void TBuiltIns::addSamplingFunctions(TSampler sampler, TString& typeName, int version, EProfile profile)
void TBuiltIns::addSamplingFunctions(TSampler sampler, const TString& typeName, int version, EProfile profile)
{
//
// texturing
@ -4284,7 +4294,7 @@ void TBuiltIns::addSamplingFunctions(TSampler sampler, TString& typeName, int ve
//
// Add all the texture gather functions for the given type.
//
void TBuiltIns::addGatherFunctions(TSampler sampler, TString& typeName, int version, EProfile profile)
void TBuiltIns::addGatherFunctions(TSampler sampler, const TString& typeName, int version, EProfile profile)
{
switch (sampler.dim) {
case Esd2D:

View File

@ -94,11 +94,11 @@ public:
protected:
void add2ndGenerationSamplingImaging(int version, EProfile profile, const SpvVersion& spvVersion);
void addSubpassSampling(TSampler, TString& typeName, int version, EProfile profile);
void addQueryFunctions(TSampler, TString& typeName, int version, EProfile profile);
void addImageFunctions(TSampler, TString& typeName, int version, EProfile profile);
void addSamplingFunctions(TSampler, TString& typeName, int version, EProfile profile);
void addGatherFunctions(TSampler, TString& typeName, int version, EProfile profile);
void addSubpassSampling(TSampler, const TString& typeName, int version, EProfile profile);
void addQueryFunctions(TSampler, const TString& typeName, int version, EProfile profile);
void addImageFunctions(TSampler, const TString& typeName, int version, EProfile profile);
void addSamplingFunctions(TSampler, const TString& typeName, int version, EProfile profile);
void addGatherFunctions(TSampler, const TString& typeName, int version, EProfile profile);
// Helpers for making textual representations of the permutations
// of texturing/imaging functions.

View File

@ -148,8 +148,8 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn
// If they are both (non-specialization) constants, they must be folded.
// (Unless it's the sequence (comma) operator, but that's handled in addComma().)
//
TIntermConstantUnion *leftTempConstant = left->getAsConstantUnion();
TIntermConstantUnion *rightTempConstant = right->getAsConstantUnion();
TIntermConstantUnion *leftTempConstant = node->getLeft()->getAsConstantUnion();
TIntermConstantUnion *rightTempConstant = node->getRight()->getAsConstantUnion();
if (leftTempConstant && rightTempConstant) {
TIntermTyped* folded = leftTempConstant->fold(node->getOp(), rightTempConstant);
if (folded)
@ -158,7 +158,7 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn
// If can propagate spec-constantness and if the operation is an allowed
// specialization-constant operation, make a spec-constant.
if (specConstantPropagates(*left, *right) && isSpecializationOperation(*node))
if (specConstantPropagates(*node->getLeft(), *node->getRight()) && isSpecializationOperation(*node))
node->getWritableType().getQualifier().makeSpecConstant();
return node;

View File

@ -33,6 +33,8 @@
// POSSIBILITY OF SUCH DAMAGE.
//
#pragma once
#include "../Include/Common.h"
#include "reflection.h"
#include "localintermediate.h"

View File

@ -32,6 +32,8 @@
// POSSIBILITY OF SUCH DAMAGE.
//
#pragma once
namespace glslang {
void RemoveAllTreeNodes(TIntermNode*);

View File

@ -38,6 +38,8 @@
// sits between the preprocessor scanner and parser.
//
#pragma once
#include "ParseHelper.h"
namespace glslang {

View File

@ -1575,6 +1575,7 @@ void TShader::setAutoMapBindings(bool map) { intermediate->setAutoM
void TShader::setHlslIoMapping(bool hlslIoMap) { intermediate->setHlslIoMapping(hlslIoMap); }
void TShader::setFlattenUniformArrays(bool flatten) { intermediate->setFlattenUniformArrays(flatten); }
void TShader::setNoStorageFormat(bool useUnknownFormat) { intermediate->setNoStorageFormat(useUnknownFormat); }
void TShader::setResourceSetBinding(const std::vector<std::string>& base) { intermediate->setResourceSetBinding(base); }
//
// Turn the shader strings into a parse tree in the TIntermediate.

View File

@ -21,6 +21,8 @@
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
#pragma once
#define GL_FLOAT 0x1406
#define GL_FLOAT_VEC2 0x8B50
#define GL_FLOAT_VEC3 0x8B51

View File

@ -349,6 +349,7 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver
int baseUboBinding;
int baseSsboBinding;
int baseUavBinding;
std::vector<std::string> baseResourceSetBinding;
bool doAutoMapping;
typedef std::vector<int> TSlotSet;
typedef std::unordered_map<int, TSlotSet> TSlotSetMap;
@ -656,6 +657,7 @@ bool TIoMapper::addStage(EShLanguage stage, TIntermediate &intermediate, TInfoSi
intermediate.getShiftUboBinding() == 0 &&
intermediate.getShiftSsboBinding() == 0 &&
intermediate.getShiftUavBinding() == 0 &&
intermediate.getResourceSetBinding().empty() &&
intermediate.getAutoMapBindings() == false &&
resolver == nullptr)
return true;
@ -686,6 +688,7 @@ bool TIoMapper::addStage(EShLanguage stage, TIntermediate &intermediate, TInfoSi
resolverBase->baseUboBinding = intermediate.getShiftUboBinding();
resolverBase->baseSsboBinding = intermediate.getShiftSsboBinding();
resolverBase->baseUavBinding = intermediate.getShiftUavBinding();
resolverBase->baseResourceSetBinding = intermediate.getResourceSetBinding();
resolverBase->doAutoMapping = intermediate.getAutoMapBindings();
resolver = resolverBase;

View File

@ -216,6 +216,8 @@ public:
unsigned int getShiftSsboBinding() const { return shiftSsboBinding; }
void setShiftUavBinding(unsigned int shift) { shiftUavBinding = shift; }
unsigned int getShiftUavBinding() const { return shiftUavBinding; }
void setResourceSetBinding(const std::vector<std::string>& shift) { resourceSetBinding = shift; }
const std::vector<std::string>& getResourceSetBinding() const { return resourceSetBinding; }
void setAutoMapBindings(bool map) { autoMapBindings = map; }
bool getAutoMapBindings() const { return autoMapBindings; }
void setFlattenUniformArrays(bool flatten) { flattenUniformArrays = flatten; }
@ -512,6 +514,7 @@ protected:
unsigned int shiftUboBinding;
unsigned int shiftSsboBinding;
unsigned int shiftUavBinding;
std::vector<std::string> resourceSetBinding;
bool autoMapBindings;
bool flattenUniformArrays;
bool useUnknownFormat;

View File

@ -76,7 +76,9 @@ TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\****************************************************************************/
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <sstream>
#include <cstdlib>

View File

@ -76,7 +76,9 @@ TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\****************************************************************************/
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <cassert>
#include <cstdlib>

View File

@ -76,7 +76,9 @@ TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\****************************************************************************/
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <cstdlib>
#include <cstring>

View File

@ -80,8 +80,10 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// For recording and playing back the stream of tokens in a macro definition.
//
#if (defined(_MSC_VER) && _MSC_VER < 1900 /*vs2015*/)
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#if (defined(_MSC_VER) && _MSC_VER < 1900 /*vs2015*/)
#define snprintf sprintf_s
#endif

View File

@ -37,6 +37,8 @@
// propagate 'noContraction' qualifier.
//
#pragma once
#include "../Include/intermediate.h"
namespace glslang {

View File

@ -40,6 +40,7 @@
#include "../MachineIndependent/Versions.h"
#include <cstring>
#include <vector>
#ifdef _WIN32
#define C_DECL __cdecl
@ -306,6 +307,7 @@ public:
void setShiftUavBinding(unsigned int base);
void setShiftCbufferBinding(unsigned int base); // synonym for setShiftUboBinding
void setShiftSsboBinding(unsigned int base);
void setResourceSetBinding(const std::vector<std::string>& base);
void setAutoMapBindings(bool map);
void setHlslIoMapping(bool hlslIoMap);
void setFlattenUniformArrays(bool flatten);

View File

@ -286,7 +286,7 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.typeGraphCopy.vert", "main"},
{"hlsl.typedef.frag", "PixelShaderFunction"},
{"hlsl.whileLoop.frag", "PixelShaderFunction"},
{"hlsl.void.frag", "PixelShaderFunction"},
{"hlsl.void.frag", "PixelShaderFunction"}
}),
FileNameAsCustomTestSuffix
);

View File

@ -283,6 +283,7 @@ INSTANTIATE_TEST_CASE_P(
"spv.test.vert",
"spv.texture.frag",
"spv.texture.vert",
"spv.textureBuffer.vert",
"spv.image.frag",
"spv.types.frag",
"spv.uint.frag",

View File

@ -4821,6 +4821,7 @@ void HlslParseContext::handleRegister(const TSourceLoc& loc, TQualifier& qualifi
}
// TODO: learn what all these really mean and how they interact with regNumber and subComponent
std::vector<std::string> resourceInfo = intermediate.getResourceSetBinding();
switch (std::tolower(desc[0])) {
case 'b':
case 't':
@ -4828,6 +4829,13 @@ void HlslParseContext::handleRegister(const TSourceLoc& loc, TQualifier& qualifi
case 's':
case 'u':
qualifier.layoutBinding = regNumber + subComponent;
for (auto it = resourceInfo.cbegin(); it != resourceInfo.cend(); it = it + 3) {
if (strcmp(desc.c_str(), it[0].c_str()) == 0) {
qualifier.layoutSet = atoi(it[1].c_str());
qualifier.layoutBinding = atoi(it[2].c_str()) + subComponent;
break;
}
}
break;
default:
warn(loc, "ignoring unrecognized register type", "register", "%c", desc[0]);

View File

@ -4479,6 +4479,8 @@ static void Scrollbar(ImGuiWindow* window, bool horizontal)
: ImRect(window_rect.Max.x - style.ScrollbarSize, window->Pos.y + border_size, window_rect.Max.x - border_size, window_rect.Max.y - other_scrollbar_size_w - border_size);
if (!horizontal)
bb.Min.y += window->TitleBarHeight() + ((window->Flags & ImGuiWindowFlags_MenuBar) ? window->MenuBarHeight() : 0.0f);
if (bb.GetWidth() <= 0.0f || bb.GetHeight() <= 0.0f)
return;
float window_rounding = (window->Flags & ImGuiWindowFlags_ChildWindow) ? style.ChildWindowRounding : style.WindowRounding;
int window_rounding_corners;