summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Branimir Karadžić <branimirkaradzic@gmail.com>2017-02-05 13:56:35 +0100
committer Miodrag Milanovic <mmicko@gmail.com>2017-02-05 13:56:35 +0100
commit1607745432f50099711d7aee355111111e66ff51 (patch)
treec4eaec8008f6e0283ca652cdffb55a34eca9b9bb
parent193e8c8a89a4be5c63909cdbbcca4d9d6f8fee02 (diff)
Update BGFX and BX (nw)
-rw-r--r--3rdparty/bgfx/3rdparty/forsyth-too/forsythtriangleorderoptimizer.cpp2
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/CMakeLists.txt10
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/OGLCompilersDLL/InitializeDll.cpp34
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/OGLCompilersDLL/InitializeDll.h35
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/README.md2
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/SPIRV/CMakeLists.txt8
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/SPIRV/GLSL.ext.KHR.h2
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/SPIRV/GLSL.ext.NV.h33
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/SPIRV/GlslangToSpv.cpp254
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/SPIRV/GlslangToSpv.h34
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/SPIRV/InReadableOrder.cpp34
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/SPIRV/SPVRemapper.cpp54
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/SPIRV/SPVRemapper.h45
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/SPIRV/SpvBuilder.cpp70
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/SPIRV/SpvBuilder.h62
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/SPIRV/disassemble.cpp56
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/SPIRV/disassemble.h34
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/SPIRV/doc.cpp60
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/SPIRV/doc.h34
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/SPIRV/spirv.hpp4
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/SPIRV/spvIR.h44
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/StandAlone/CMakeLists.txt4
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/StandAlone/StandAlone.cpp68
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/StandAlone/Worklist.h44
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/StandAlone/spirv-remap.cpp39
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/120.frag8
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/120.frag.out44
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/310.tesc.out20
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/310.tese.out16
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/420.vert.out12
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/cppBad2.vert.out19
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/cppComplexExpr.vert.out40
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.basic.comp.out52
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.basic.geom.out31
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.entry-in.frag.out245
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.gather.basic.dx10.vert.out20
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.getdimensions.dx10.vert.out20
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.init.frag.out20
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.init2.frag.out450
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.intrinsics.d3dcolortoubyte4.frag.out111
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.intrinsics.negative.frag.out44
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.layout.frag.out5
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.load.basic.dx10.vert.out20
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.matrixSwizzle.vert.out818
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.numthreads.comp.out10
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.params.default.frag.out639
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.params.default.negative.frag.out379
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.partialInit.frag.out269
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.rw.swizzle.frag.out286
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.samplegrad.basic.dx10.vert.out20
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.samplelevel.basic.dx10.vert.out20
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.frag.out171
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split-1.vert.out217
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split.array.geom.out299
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split.assign.frag.out196
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split.call.vert.out325
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split.nested.geom.out283
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split.trivial.geom.out192
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split.trivial.vert.out116
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.structarray.flatten.geom.out316
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.structin.vert.out143
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.type.half.frag.out161
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.type.identifier.frag.out382
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/link1.vk.frag.out60
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/preprocessor.include.disabled.vert.err10
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/preprocessor.include.enabled.vert.err24
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/specExamples.frag.out4
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.float16.frag.out23
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.int64.frag.out53
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.shaderBallotAMD.comp.out1217
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.shaderGroupVote.comp.out43
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.specConst.vert.out7
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.specConstant.vert.out81
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.specConstantComposite.vert.out28
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.specConstantOperations.vert.out83
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.stereoViewRendering.tesc.out86
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.stereoViewRendering.vert.out69
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.viewportArray2.tesc.out59
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.viewportArray2.vert.out48
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/tokenLength.vert.out12
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/vulkan.ast.vert.out65
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/baseResults/vulkan.frag.out3
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/cppBad2.vert3
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/hlsl.basic.comp4
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/hlsl.flatten.return.frag2
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/hlsl.init.frag5
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/hlsl.init2.frag19
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/hlsl.intrinsics.d3dcolortoubyte4.frag7
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/hlsl.matrixSwizzle.vert33
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/hlsl.params.default.frag51
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/hlsl.params.default.negative.frag50
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/hlsl.partialInit.frag9
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/hlsl.pp.tokenpasting.frag18
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/hlsl.rw.swizzle.frag28
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split-1.vert25
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split.array.geom21
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split.assign.frag12
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split.call.vert32
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split.nested.geom31
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split.trivial.geom21
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split.trivial.vert22
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/hlsl.structarray.flatten.geom22
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/hlsl.type.half.frag11
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/hlsl.type.identifier.frag28
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/link1.vk.frag10
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/link2.vk.frag8
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/preprocessor.include.disabled.vert3
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/preprocessor.include.enabled.vert19
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/spv.shaderBallotAMD.comp165
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/spv.stereoViewRendering.tesc18
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/spv.stereoViewRendering.vert12
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/spv.viewportArray2.tesc16
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/spv.viewportArray2.vert10
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/Test/vulkan.frag2
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/CMakeLists.txt9
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/GenericCodeGen/CodeGen.cpp34
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/GenericCodeGen/Link.cpp34
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/Include/BaseTypes.h50
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/Include/Common.h44
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/Include/ConstantUnion.h78
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/Include/InfoSink.h44
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/Include/InitializeGlobals.h34
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/Include/PoolAlloc.h67
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/Include/ResourceLimits.h38
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/Include/ShHandle.h51
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/Include/Types.h125
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/Include/arrays.h36
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/Include/intermediate.h70
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/Include/revision.h4
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/Include/revision.template2
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Constant.cpp49
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/InfoSink.cpp46
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Initialize.cpp947
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Initialize.h41
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/IntermTraverse.cpp38
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Intermediate.cpp121
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/LiveTraverser.h34
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/ParseContextBase.cpp182
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp375
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.h42
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/PoolAlloc.cpp58
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/RemoveTree.cpp36
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/RemoveTree.h34
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Scan.cpp58
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Scan.h38
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/ScanContext.h34
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/ShaderLang.cpp143
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/SymbolTable.cpp37
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/SymbolTable.h74
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Versions.cpp116
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Versions.h51
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/glslang.y36
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/intermOut.cpp52
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/iomapper.cpp41
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/iomapper.h34
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/limits.cpp40
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/linkValidate.cpp104
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/localintermediate.h126
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/parseConst.cpp64
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/parseVersions.h34
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/Pp.cpp207
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpAtom.cpp38
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpContext.cpp40
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpContext.h65
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpMemory.cpp38
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpScanner.cpp212
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpSymbols.cpp38
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpTokens.cpp38
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpTokens.h38
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/propagateNoContraction.cpp13
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/reflection.cpp43
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/reflection.h46
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/OSDependent/Unix/ossource.cpp171
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/OSDependent/Windows/main.cpp34
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/OSDependent/Windows/ossource.cpp35
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/OSDependent/osinclude.h34
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/glslang/Public/ShaderLang.h119
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/gtests/AST.FromFile.cpp1
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/gtests/CMakeLists.txt15
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/gtests/Hlsl.FromFile.cpp14
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/gtests/Link.FromFile.Vk.cpp97
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/gtests/Spv.FromFile.cpp32
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/gtests/TestFixture.h2
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/hlsl/hlslAttributes.cpp38
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/hlsl/hlslAttributes.h34
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/hlsl/hlslGrammar.cpp244
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/hlsl/hlslGrammar.h39
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/hlsl/hlslOpMap.cpp38
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/hlsl/hlslOpMap.h34
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/hlsl/hlslParseHelper.cpp1470
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/hlsl/hlslParseHelper.h108
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/hlsl/hlslParseables.cpp81
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/hlsl/hlslParseables.h36
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/hlsl/hlslScanContext.cpp51
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/hlsl/hlslScanContext.h34
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/hlsl/hlslTokenStream.cpp34
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/hlsl/hlslTokenStream.h34
-rw-r--r--3rdparty/bgfx/3rdparty/glslang/hlsl/hlslTokens.h41
-rw-r--r--3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.cpp41
-rw-r--r--3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.h2
-rw-r--r--3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_demo.cpp6
-rw-r--r--3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_draw.cpp3
-rw-r--r--3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_internal.h5
-rw-r--r--3rdparty/bgfx/3rdparty/ocornut-imgui/widgets/gizmo.h4
-rw-r--r--3rdparty/bgfx/3rdparty/ocornut-imgui/widgets/gizmo.inl275
-rw-r--r--3rdparty/bgfx/3rdparty/ocornut-imgui/widgets/range_slider.inl2
-rw-r--r--3rdparty/bgfx/3rdparty/remotery/lib/Remotery.c1529
-rw-r--r--3rdparty/bgfx/3rdparty/remotery/lib/Remotery.h63
-rw-r--r--3rdparty/bgfx/3rdparty/remotery/lib/RemoteryMetal.mm49
-rw-r--r--3rdparty/bgfx/3rdparty/remotery/readme.md23
-rw-r--r--3rdparty/bgfx/3rdparty/remotery/vis/Code/Console.js8
-rw-r--r--3rdparty/bgfx/3rdparty/remotery/vis/Code/DataViewReader.js47
-rw-r--r--3rdparty/bgfx/3rdparty/remotery/vis/Code/Remotery.js117
-rw-r--r--3rdparty/bgfx/3rdparty/remotery/vis/Code/SampleWindow.js34
-rw-r--r--3rdparty/bgfx/3rdparty/remotery/vis/Code/TimelineRow.js5
-rw-r--r--3rdparty/bgfx/3rdparty/remotery/vis/Code/WebSocketConnection.js17
-rw-r--r--3rdparty/bgfx/3rdparty/remotery/vis/index.html1
-rw-r--r--3rdparty/bgfx/3rdparty/tinyexr/tinyexr.h10
-rw-r--r--3rdparty/bgfx/README.md2
-rw-r--r--3rdparty/bgfx/examples/01-cubes/makefile12
-rw-r--r--3rdparty/bgfx/examples/02-metaballs/makefile4
-rw-r--r--3rdparty/bgfx/examples/03-raymarch/makefile12
-rw-r--r--3rdparty/bgfx/examples/04-mesh/makefile12
-rw-r--r--3rdparty/bgfx/examples/05-instancing/makefile12
-rw-r--r--3rdparty/bgfx/examples/06-bump/makefile12
-rw-r--r--3rdparty/bgfx/examples/07-callback/callback.cpp14
-rw-r--r--3rdparty/bgfx/examples/07-callback/makefile12
-rw-r--r--3rdparty/bgfx/examples/08-update/makefile12
-rw-r--r--3rdparty/bgfx/examples/09-hdr/makefile12
-rw-r--r--3rdparty/bgfx/examples/12-lod/makefile12
-rw-r--r--3rdparty/bgfx/examples/13-stencil/makefile12
-rw-r--r--3rdparty/bgfx/examples/14-shadowvolumes/makefile12
-rw-r--r--3rdparty/bgfx/examples/15-shadowmaps-simple/makefile12
-rw-r--r--3rdparty/bgfx/examples/16-shadowmaps/makefile12
-rw-r--r--3rdparty/bgfx/examples/17-drawstress/makefile4
-rw-r--r--3rdparty/bgfx/examples/18-ibl/makefile12
-rw-r--r--3rdparty/bgfx/examples/19-oit/makefile12
-rw-r--r--3rdparty/bgfx/examples/21-deferred/fs_deferred_light.sc8
-rw-r--r--3rdparty/bgfx/examples/21-deferred/makefile11
-rw-r--r--3rdparty/bgfx/examples/23-vectordisplay/makefile12
-rw-r--r--3rdparty/bgfx/examples/24-nbody/makefile12
-rw-r--r--3rdparty/bgfx/examples/27-terrain/makefile12
-rw-r--r--3rdparty/bgfx/examples/28-wireframe/makefile12
-rw-r--r--3rdparty/bgfx/examples/29-debugdraw/debugdraw.cpp2
-rw-r--r--3rdparty/bgfx/examples/30-picking/makefile12
-rw-r--r--3rdparty/bgfx/examples/31-rsm/fs_rsm_combine.sc9
-rw-r--r--3rdparty/bgfx/examples/31-rsm/fs_rsm_lbuffer.sc8
-rw-r--r--3rdparty/bgfx/examples/31-rsm/makefile12
-rw-r--r--3rdparty/bgfx/examples/31-rsm/vs_rsm_lbuffer.sc8
-rw-r--r--3rdparty/bgfx/examples/32-particles/particles.cpp426
-rw-r--r--3rdparty/bgfx/examples/32-particles/screenshot.pngbin0 -> 142060 bytes
-rw-r--r--3rdparty/bgfx/examples/common/bgfx_utils.cpp2
-rw-r--r--3rdparty/bgfx/examples/common/bounds.cpp6
-rw-r--r--3rdparty/bgfx/examples/common/bounds.h3
-rw-r--r--3rdparty/bgfx/examples/common/debugdraw/makefile4
-rw-r--r--3rdparty/bgfx/examples/common/entry/cmd.cpp2
-rw-r--r--3rdparty/bgfx/examples/common/entry/dbg.cpp87
-rw-r--r--3rdparty/bgfx/examples/common/entry/dbg.h9
-rw-r--r--3rdparty/bgfx/examples/common/entry/entry.cpp2
-rw-r--r--3rdparty/bgfx/examples/common/entry/entry_p.h2
-rw-r--r--3rdparty/bgfx/examples/common/entry/entry_sdl.cpp8
-rw-r--r--3rdparty/bgfx/examples/common/entry/entry_windows.cpp5
-rw-r--r--3rdparty/bgfx/examples/common/entry/entry_x11.cpp2
-rw-r--r--3rdparty/bgfx/examples/common/entry/input.cpp2
-rw-r--r--3rdparty/bgfx/examples/common/font/makefile4
-rw-r--r--3rdparty/bgfx/examples/common/imgui/makefile4
-rw-r--r--3rdparty/bgfx/examples/common/nanovg/makefile4
-rw-r--r--3rdparty/bgfx/examples/common/ps/fs_particle.bin.h150
-rw-r--r--3rdparty/bgfx/examples/common/ps/fs_particle.sc19
-rw-r--r--3rdparty/bgfx/examples/common/ps/makefile9
-rw-r--r--3rdparty/bgfx/examples/common/ps/particle_system.cpp703
-rw-r--r--3rdparty/bgfx/examples/common/ps/particle_system.h91
-rw-r--r--3rdparty/bgfx/examples/common/ps/varying.def.sc6
-rw-r--r--3rdparty/bgfx/examples/common/ps/vs_particle.bin.h151
-rw-r--r--3rdparty/bgfx/examples/common/ps/vs_particle.sc16
-rw-r--r--3rdparty/bgfx/examples/makefile4
-rw-r--r--3rdparty/bgfx/examples/runtime/textures/particle.ktxbin0 -> 262212 bytes
-rw-r--r--3rdparty/bgfx/include/bgfx/bgfx.h36
-rw-r--r--3rdparty/bgfx/include/bgfx/c99/bgfx.h4
-rw-r--r--3rdparty/bgfx/include/bgfx/c99/platform.h4
-rw-r--r--3rdparty/bgfx/include/bgfx/defines.h2
-rw-r--r--3rdparty/bgfx/makefile4
-rw-r--r--3rdparty/bgfx/scripts/bgfx.lua8
-rw-r--r--3rdparty/bgfx/scripts/genie.lua6
-rw-r--r--3rdparty/bgfx/scripts/geometryc.lua4
-rw-r--r--3rdparty/bgfx/scripts/shader-embeded.mk10
-rw-r--r--3rdparty/bgfx/scripts/shader.mk15
-rw-r--r--3rdparty/bgfx/scripts/shaderc.lua32
-rw-r--r--3rdparty/bgfx/scripts/texturec.lua9
-rw-r--r--3rdparty/bgfx/scripts/texturev.lua1
-rw-r--r--3rdparty/bgfx/scripts/tools.mk4
-rw-r--r--3rdparty/bgfx/src/bgfx.cpp41
-rw-r--r--3rdparty/bgfx/src/bgfx_p.h31
-rw-r--r--3rdparty/bgfx/src/bgfx_shader.sh4
-rw-r--r--3rdparty/bgfx/src/config.h6
-rw-r--r--3rdparty/bgfx/src/debug_renderdoc.cpp2
-rw-r--r--3rdparty/bgfx/src/glcontext_glx.cpp2
-rw-r--r--3rdparty/bgfx/src/image.cpp1320
-rw-r--r--3rdparty/bgfx/src/image.h234
-rw-r--r--3rdparty/bgfx/src/makefile6
-rw-r--r--3rdparty/bgfx/src/renderer.h4
-rw-r--r--3rdparty/bgfx/src/renderer_d3d11.cpp37
-rw-r--r--3rdparty/bgfx/src/renderer_d3d11.h2
-rw-r--r--3rdparty/bgfx/src/renderer_d3d12.cpp28
-rw-r--r--3rdparty/bgfx/src/renderer_d3d12.h2
-rw-r--r--3rdparty/bgfx/src/renderer_d3d9.cpp15
-rw-r--r--3rdparty/bgfx/src/renderer_d3d9.h2
-rw-r--r--3rdparty/bgfx/src/renderer_gl.cpp37
-rw-r--r--3rdparty/bgfx/src/renderer_gl.h2
-rw-r--r--3rdparty/bgfx/src/renderer_mtl.h8
-rw-r--r--3rdparty/bgfx/src/renderer_mtl.mm32
-rw-r--r--3rdparty/bgfx/src/renderer_vk.cpp8
-rw-r--r--3rdparty/bgfx/src/shader.cpp8
-rw-r--r--3rdparty/bgfx/src/vertexdecl.cpp26
-rw-r--r--3rdparty/bgfx/tools/geometryc/geometryc.cpp1
-rw-r--r--3rdparty/bgfx/tools/shaderc/shaderc.cpp26
-rw-r--r--3rdparty/bgfx/tools/shaderc/shaderc_spirv.cpp1
-rw-r--r--3rdparty/bgfx/tools/texturec/texturec.cpp10
-rw-r--r--3rdparty/bgfx/tools/texturev/makefile4
-rw-r--r--3rdparty/bgfx/tools/texturev/texturev.cpp2
-rw-r--r--3rdparty/bx/include/bx/allocator.h158
-rw-r--r--3rdparty/bx/include/bx/allocator.inl104
-rw-r--r--3rdparty/bx/include/bx/bx.h42
-rw-r--r--3rdparty/bx/include/bx/commandline.h233
-rw-r--r--3rdparty/bx/include/bx/crtimpl.h416
-rw-r--r--3rdparty/bx/include/bx/debug.h71
-rw-r--r--3rdparty/bx/include/bx/easing.h289
-rw-r--r--3rdparty/bx/include/bx/easing.inl256
-rw-r--r--3rdparty/bx/include/bx/endian.h73
-rw-r--r--3rdparty/bx/include/bx/endian.inl78
-rw-r--r--3rdparty/bx/include/bx/error.h87
-rw-r--r--3rdparty/bx/include/bx/error.inl73
-rw-r--r--3rdparty/bx/include/bx/foreach.h71
-rw-r--r--3rdparty/bx/include/bx/fpumath.h1580
-rw-r--r--3rdparty/bx/include/bx/fpumath.inl1416
-rw-r--r--3rdparty/bx/include/bx/handlealloc.h719
-rw-r--r--3rdparty/bx/include/bx/handlealloc.inl712
-rw-r--r--3rdparty/bx/include/bx/hash.h162
-rw-r--r--3rdparty/bx/include/bx/hash.inl154
-rw-r--r--3rdparty/bx/include/bx/mutex.h120
-rw-r--r--3rdparty/bx/include/bx/mutex.inl34
-rw-r--r--3rdparty/bx/include/bx/os.h362
-rw-r--r--3rdparty/bx/include/bx/pixelformat.h243
-rw-r--r--3rdparty/bx/include/bx/pixelformat.inl945
-rw-r--r--3rdparty/bx/include/bx/platform.h67
-rw-r--r--3rdparty/bx/include/bx/process.h80
-rw-r--r--3rdparty/bx/include/bx/radixsort.h306
-rw-r--r--3rdparty/bx/include/bx/radixsort.inl288
-rw-r--r--3rdparty/bx/include/bx/readerwriter.h565
-rw-r--r--3rdparty/bx/include/bx/readerwriter.inl452
-rw-r--r--3rdparty/bx/include/bx/rng.h178
-rw-r--r--3rdparty/bx/include/bx/rng.inl171
-rw-r--r--3rdparty/bx/include/bx/sem.h233
-rw-r--r--3rdparty/bx/include/bx/simd256_avx.inl6
-rw-r--r--3rdparty/bx/include/bx/string.h756
-rw-r--r--3rdparty/bx/include/bx/string.inl200
-rw-r--r--3rdparty/bx/include/bx/thread.h270
-rw-r--r--3rdparty/bx/include/bx/thread.inl65
-rw-r--r--3rdparty/bx/include/bx/timer.h51
-rw-r--r--3rdparty/bx/include/bx/timer.inl61
-rw-r--r--3rdparty/bx/include/bx/tokenizecmd.h146
-rw-r--r--3rdparty/bx/include/bx/uint32_t.h971
-rw-r--r--3rdparty/bx/include/bx/uint32_t.inl781
-rw-r--r--3rdparty/bx/makefile4
-rw-r--r--3rdparty/bx/scripts/bin2c.lua4
-rw-r--r--3rdparty/bx/scripts/bx.lua25
-rw-r--r--3rdparty/bx/scripts/genie.lua8
-rw-r--r--3rdparty/bx/scripts/toolchain.lua16
-rw-r--r--3rdparty/bx/src/commandline.cpp322
-rw-r--r--3rdparty/bx/src/crt.cpp362
-rw-r--r--3rdparty/bx/src/crtimpl.cpp360
-rw-r--r--3rdparty/bx/src/debug.cpp143
-rw-r--r--3rdparty/bx/src/dtoa.cpp528
-rw-r--r--3rdparty/bx/src/fpumath.cpp100
-rw-r--r--3rdparty/bx/src/mutex.cpp92
-rw-r--r--3rdparty/bx/src/os.cpp454
-rw-r--r--3rdparty/bx/src/sem.cpp221
-rw-r--r--3rdparty/bx/src/string.cpp515
-rw-r--r--3rdparty/bx/src/thread.cpp208
-rw-r--r--3rdparty/bx/tests/dbg.cpp87
-rw-r--r--3rdparty/bx/tests/dbg.h9
-rw-r--r--3rdparty/bx/tests/fpumath_test.cpp22
-rw-r--r--3rdparty/bx/tests/handle_bench.cpp12
-rw-r--r--3rdparty/bx/tests/misc_test.cpp8
-rw-r--r--3rdparty/bx/tests/os_test.cpp20
-rw-r--r--3rdparty/bx/tests/string_test.cpp136
-rw-r--r--3rdparty/bx/tests/test.h4
-rw-r--r--3rdparty/bx/tests/tokenizecmd_test.cpp4
-rw-r--r--3rdparty/bx/tests/uint32_test.cpp65
-rw-r--r--3rdparty/bx/tests/vector_complex_test.cpp6
-rw-r--r--3rdparty/bx/tests/vsnprintf_test.cpp68
-rwxr-xr-x3rdparty/bx/tools/bin/darwin/geniebin524544 -> 524544 bytes
-rwxr-xr-x3rdparty/bx/tools/bin/linux/geniebin503472 -> 503472 bytes
-rw-r--r--3rdparty/bx/tools/bin/windows/genie.exebin507904 -> 508416 bytes
394 files changed, 28762 insertions, 13078 deletions
diff --git a/3rdparty/bgfx/3rdparty/forsyth-too/forsythtriangleorderoptimizer.cpp b/3rdparty/bgfx/3rdparty/forsyth-too/forsythtriangleorderoptimizer.cpp
index 3d23d2ba0ab..261016ffc5e 100644
--- a/3rdparty/bgfx/3rdparty/forsyth-too/forsythtriangleorderoptimizer.cpp
+++ b/3rdparty/bgfx/3rdparty/forsyth-too/forsythtriangleorderoptimizer.cpp
@@ -135,7 +135,7 @@ namespace Forsyth
float FindVertexScore(uint numActiveFaces, uint cachePosition, uint vertexCacheSize)
{
- assert(s_vertexScoresComputed);
+ assert(s_vertexScoresComputed); (void)s_vertexScoresComputed;
if ( numActiveFaces == 0 )
{
diff --git a/3rdparty/bgfx/3rdparty/glslang/CMakeLists.txt b/3rdparty/bgfx/3rdparty/glslang/CMakeLists.txt
index e7b22e5ef84..d4537201696 100644
--- a/3rdparty/bgfx/3rdparty/glslang/CMakeLists.txt
+++ b/3rdparty/bgfx/3rdparty/glslang/CMakeLists.txt
@@ -6,6 +6,8 @@ option(ENABLE_GLSLANG_BINARIES "Builds glslangValidator and spirv-remap" ON)
option(ENABLE_NV_EXTENSIONS "Enables support of Nvidia-specific extensions" ON)
+option(ENABLE_HLSL "Enables HLSL input support" ON)
+
enable_testing()
set(CMAKE_INSTALL_PREFIX "install" CACHE STRING "prefix")
@@ -20,6 +22,10 @@ if(ENABLE_NV_EXTENSIONS)
add_definitions(-DNV_EXTENSIONS)
endif(ENABLE_NV_EXTENSIONS)
+if(ENABLE_HLSL)
+ add_definitions(-DENABLE_HLSL)
+endif(ENABLE_HLSL)
+
if(WIN32)
set(CMAKE_DEBUG_POSTFIX "d")
include(ChooseMSVCCRT.cmake)
@@ -63,5 +69,7 @@ if(ENABLE_GLSLANG_BINARIES)
add_subdirectory(StandAlone)
endif()
add_subdirectory(SPIRV)
-add_subdirectory(hlsl)
+if(ENABLE_HLSL)
+ add_subdirectory(hlsl)
+endif(ENABLE_HLSL)
add_subdirectory(gtests)
diff --git a/3rdparty/bgfx/3rdparty/glslang/OGLCompilersDLL/InitializeDll.cpp b/3rdparty/bgfx/3rdparty/glslang/OGLCompilersDLL/InitializeDll.cpp
index e4798815206..2eb912c422f 100644
--- a/3rdparty/bgfx/3rdparty/glslang/OGLCompilersDLL/InitializeDll.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/OGLCompilersDLL/InitializeDll.cpp
@@ -1,10 +1,10 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -18,18 +18,18 @@
// 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.
+// 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.
//
#define SH_EXPORTING
diff --git a/3rdparty/bgfx/3rdparty/glslang/OGLCompilersDLL/InitializeDll.h b/3rdparty/bgfx/3rdparty/glslang/OGLCompilersDLL/InitializeDll.h
index 2d24557435d..60b2b1593d6 100644
--- a/3rdparty/bgfx/3rdparty/glslang/OGLCompilersDLL/InitializeDll.h
+++ b/3rdparty/bgfx/3rdparty/glslang/OGLCompilersDLL/InitializeDll.h
@@ -1,10 +1,10 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -18,23 +18,22 @@
// 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.
+// 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.
//
#ifndef __INITIALIZEDLL_H
#define __INITIALIZEDLL_H
-
#include "../glslang/OSDependent/osinclude.h"
namespace glslang {
diff --git a/3rdparty/bgfx/3rdparty/glslang/README.md b/3rdparty/bgfx/3rdparty/glslang/README.md
index 9cfdce1839c..193e38da874 100644
--- a/3rdparty/bgfx/3rdparty/glslang/README.md
+++ b/3rdparty/bgfx/3rdparty/glslang/README.md
@@ -17,7 +17,7 @@ There are several components:
1. A GLSL/ESSL front-end for reference validation and translation of GLSL/ESSL into an AST.
-2. An HLSL front-end for translation of a broad generic HLL into the AST.
+2. An HLSL front-end for translation of a broad generic HLL into the AST. See [issue 362](https://github.com/KhronosGroup/glslang/issues/362) and [issue 701](https://github.com/KhronosGroup/glslang/issues/701) for current status.
3. A SPIR-V back end for translating the AST to SPIR-V.
diff --git a/3rdparty/bgfx/3rdparty/glslang/SPIRV/CMakeLists.txt b/3rdparty/bgfx/3rdparty/glslang/SPIRV/CMakeLists.txt
index c538e841537..aaf117802fe 100644
--- a/3rdparty/bgfx/3rdparty/glslang/SPIRV/CMakeLists.txt
+++ b/3rdparty/bgfx/3rdparty/glslang/SPIRV/CMakeLists.txt
@@ -34,12 +34,14 @@ if(ENABLE_AMD_EXTENSIONS)
endif(ENABLE_AMD_EXTENSIONS)
if(ENABLE_NV_EXTENSIONS)
- set(HEADERS
- GLSL.ext.NV.h)
+ list(APPEND
+ HEADERS
+ GLSL.ext.NV.h)
endif(ENABLE_NV_EXTENSIONS)
add_library(SPIRV STATIC ${SOURCES} ${HEADERS})
set_property(TARGET SPIRV PROPERTY FOLDER glslang)
+target_link_libraries(SPIRV glslang)
add_library(SPVRemapper STATIC ${SPVREMAP_SOURCES} ${SPVREMAP_HEADERS})
set_property(TARGET SPVRemapper PROPERTY FOLDER glslang)
@@ -51,3 +53,5 @@ endif(WIN32)
install(TARGETS SPIRV SPVRemapper
ARCHIVE DESTINATION lib)
+
+install(FILES ${HEADERS} ${SPVREMAP_HEADERS} DESTINATION include/SPIRV/)
diff --git a/3rdparty/bgfx/3rdparty/glslang/SPIRV/GLSL.ext.KHR.h b/3rdparty/bgfx/3rdparty/glslang/SPIRV/GLSL.ext.KHR.h
index 344dd398c3b..4614a3c6754 100644
--- a/3rdparty/bgfx/3rdparty/glslang/SPIRV/GLSL.ext.KHR.h
+++ b/3rdparty/bgfx/3rdparty/glslang/SPIRV/GLSL.ext.KHR.h
@@ -32,5 +32,5 @@ static const char* const E_SPV_KHR_shader_ballot = "SPV_KHR_shade
// SPV_KHR_shader_draw_parameters
static const char* const E_SPV_KHR_shader_draw_parameters = "SPV_KHR_shader_draw_parameters";
-
+static const char* const E_SPV_KHR_subgroup_vote = "SPV_KHR_subgroup_vote";
#endif // #ifndef GLSLextKHR_H
diff --git a/3rdparty/bgfx/3rdparty/glslang/SPIRV/GLSL.ext.NV.h b/3rdparty/bgfx/3rdparty/glslang/SPIRV/GLSL.ext.NV.h
index adfcb0f345c..89f0a5c0338 100644
--- a/3rdparty/bgfx/3rdparty/glslang/SPIRV/GLSL.ext.NV.h
+++ b/3rdparty/bgfx/3rdparty/glslang/SPIRV/GLSL.ext.NV.h
@@ -30,20 +30,45 @@
enum BuiltIn;
enum Decoration;
enum Op;
+enum Capability;
static const int GLSLextNVVersion = 100;
-static const int GLSLextNVRevision = 2;
+static const int GLSLextNVRevision = 4;
//SPV_NV_sample_mask_override_coverage
const char* const E_SPV_NV_sample_mask_override_coverage = "SPV_NV_sample_mask_override_coverage";
-static const Decoration OverrideCoverageNV = static_cast<Decoration>(5248);
+static const Decoration DecorationOverrideCoverageNV = static_cast<Decoration>(5248);
//SPV_NV_geometry_shader_passthrough
const char* const E_SPV_NV_geometry_shader_passthrough = "SPV_NV_geometry_shader_passthrough";
-static const Decoration PassthroughNV = static_cast<Decoration>(5250);
+static const Decoration DecorationPassthroughNV = static_cast<Decoration>(5250);
+
+static const Capability CapabilityGeometryShaderPassthroughNV = static_cast<Capability>(5251);
+
+
+//SPV_NV_viewport_array2
+const char* const E_SPV_NV_viewport_array2 = "SPV_NV_viewport_array2";
+const char* const E_ARB_shader_viewport_layer_array = "SPV_ARB_shader_viewport_layer_array";
+
+static const Decoration DecorationViewportRelativeNV = static_cast<Decoration>(5252);
+
+static const BuiltIn BuiltInViewportMaskNV = static_cast<BuiltIn>(5253);
+
+static const Capability CapabilityShaderViewportIndexLayerNV = static_cast<Capability>(5254);
+static const Capability CapabilityShaderViewportMaskNV = static_cast<Capability>(5255);
+
+
+//SPV_NV_stereo_view_rendering
+const char* const E_SPV_NV_stereo_view_rendering = "SPV_NV_stereo_view_rendering";
+
+static const Decoration DecorationSecondaryViewportRelativeNV = static_cast<Decoration>(5256);
+
+static const BuiltIn BuiltInSecondaryPositionNV = static_cast<BuiltIn>(5257);
+static const BuiltIn BuiltInSecondaryViewportMaskNV = static_cast<BuiltIn>(5258);
+
+static const Capability CapabilityShaderStereoViewNV = static_cast<Capability>(5259);
-static const Capability GeometryShaderPassthroughNV = static_cast<Capability>(5251);
#endif // #ifndef GLSLextNV_H \ No newline at end of file
diff --git a/3rdparty/bgfx/3rdparty/glslang/SPIRV/GlslangToSpv.cpp b/3rdparty/bgfx/3rdparty/glslang/SPIRV/GlslangToSpv.cpp
index 3c287a7eff1..0b48dfcdd53 100644
--- a/3rdparty/bgfx/3rdparty/glslang/SPIRV/GlslangToSpv.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/SPIRV/GlslangToSpv.cpp
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2014-2016 LunarG, Inc.
-//Copyright (C) 2015-2016 Google, Inc.
+// Copyright (C) 2014-2016 LunarG, Inc.
+// Copyright (C) 2015-2016 Google, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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.
//
// Visit the nodes in the glslang intermediate tree representation to
@@ -161,7 +161,7 @@ protected:
spv::Id makeSmearedConstant(spv::Id constant, int vectorSize);
spv::Id createAtomicOperation(glslang::TOperator op, spv::Decoration precision, spv::Id typeId, std::vector<spv::Id>& operands, glslang::TBasicType typeProxy);
spv::Id createInvocationsOperation(glslang::TOperator op, spv::Id typeId, std::vector<spv::Id>& operands, glslang::TBasicType typeProxy);
- spv::Id CreateInvocationsVectorOperation(spv::Op op, spv::Id typeId, std::vector<spv::Id>& operands);
+ spv::Id CreateInvocationsVectorOperation(spv::Op op, spv::GroupOperation groupOperation, spv::Id typeId, std::vector<spv::Id>& operands);
spv::Id createMiscOperation(glslang::TOperator op, spv::Decoration precision, spv::Id typeId, std::vector<spv::Id>& operands, glslang::TBasicType typeProxy);
spv::Id createNoArgOperation(glslang::TOperator op, spv::Decoration precision, spv::Id typeId);
spv::Id getSymbolId(const glslang::TIntermSymbol* node);
@@ -221,7 +221,7 @@ spv::SourceLanguage TranslateSourceLanguage(glslang::EShSource source, EProfile
return spv::SourceLanguageUnknown;
}
case glslang::EShSourceHlsl:
- //Use SourceLanguageUnknown instead of SourceLanguageHLSL for now, until Vulkan knows what HLSL is
+ // Use SourceLanguageUnknown instead of SourceLanguageHLSL for now, until Vulkan knows what HLSL is
return spv::SourceLanguageUnknown;
default:
return spv::SourceLanguageUnknown;
@@ -439,7 +439,6 @@ spv::Decoration TranslateNoContractionDecoration(const glslang::TQualifier& qual
return spv::DecorationMax;
}
-
// Translate a glslang built-in variable to a SPIR-V built in decoration. Also generate
// associated capabilities when required. For some built-in variables, a capability
// is generated only when using the variable in an executable instruction, but not when
@@ -483,6 +482,15 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
case glslang::EbvViewportIndex:
builder.addCapability(spv::CapabilityMultiViewport);
+#ifdef NV_EXTENSIONS
+ if (glslangIntermediate->getStage() == EShLangVertex ||
+ glslangIntermediate->getStage() == EShLangTessControl ||
+ glslangIntermediate->getStage() == EShLangTessEvaluation)
+ {
+ builder.addExtension(spv::E_SPV_NV_viewport_array2);
+ builder.addCapability(spv::CapabilityShaderViewportIndexLayerNV);
+ }
+#endif
return spv::BuiltInViewportIndex;
case glslang::EbvSampleId:
@@ -499,6 +507,18 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
case glslang::EbvLayer:
builder.addCapability(spv::CapabilityGeometry);
+#ifdef NV_EXTENSIONS
+ if (!memberDeclaration)
+ {
+ if (glslangIntermediate->getStage() == EShLangVertex ||
+ glslangIntermediate->getStage() == EShLangTessControl ||
+ glslangIntermediate->getStage() == EShLangTessEvaluation)
+ {
+ builder.addExtension(spv::E_SPV_NV_viewport_array2);
+ builder.addCapability(spv::CapabilityShaderViewportIndexLayerNV);
+ }
+ }
+#endif
return spv::BuiltInLayer;
case glslang::EbvPosition: return spv::BuiltInPosition;
@@ -608,6 +628,21 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
builder.addExtension(spv::E_SPV_AMD_shader_explicit_vertex_parameter);
return spv::BuiltInBaryCoordPullModelAMD;
#endif
+
+#ifdef NV_EXTENSIONS
+ case glslang::EbvViewportMaskNV:
+ builder.addExtension(spv::E_SPV_NV_viewport_array2);
+ builder.addCapability(spv::CapabilityShaderViewportMaskNV);
+ return spv::BuiltInViewportMaskNV;
+ case glslang::EbvSecondaryPositionNV:
+ builder.addExtension(spv::E_SPV_NV_stereo_view_rendering);
+ builder.addCapability(spv::CapabilityShaderStereoViewNV);
+ return spv::BuiltInSecondaryPositionNV;
+ case glslang::EbvSecondaryViewportMaskNV:
+ builder.addExtension(spv::E_SPV_NV_stereo_view_rendering);
+ builder.addCapability(spv::CapabilityShaderStereoViewNV);
+ return spv::BuiltInSecondaryViewportMaskNV;
+#endif
default: return spv::BuiltInMax;
}
}
@@ -1116,6 +1151,9 @@ bool TGlslangToSpvTraverser::visitBinary(glslang::TVisit /* visit */, glslang::T
builder.accessChainPushSwizzle(swizzle, convertGlslangToSpvType(node->getLeft()->getType()));
}
return false;
+ case glslang::EOpMatrixSwizzle:
+ logger->missingFunctionality("matrix swizzle");
+ return true;
case glslang::EOpLogicalOr:
case glslang::EOpLogicalAnd:
{
@@ -1410,7 +1448,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
{
if (node->isUserDefined())
result = handleUserFunctionCall(node);
- //assert(result); // this can happen for bad shaders because the call graph completeness checking is not yet done
+ // assert(result); // this can happen for bad shaders because the call graph completeness checking is not yet done
if (result) {
builder.clearAccessChain();
builder.setAccessChainRValue(result);
@@ -1633,7 +1671,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
// Does it need a swizzle inversion? If so, evaluation is inverted;
// operate first on the swizzle base, then apply the swizzle.
- if (glslangOperands[0]->getAsOperator() &&
+ if (glslangOperands[0]->getAsOperator() &&
glslangOperands[0]->getAsOperator()->getOp() == glslang::EOpVectorSwizzle)
invertedType = convertGlslangToSpvType(glslangOperands[0]->getAsBinaryNode()->getLeft()->getType());
}
@@ -1960,7 +1998,7 @@ spv::Id TGlslangToSpvTraverser::getSampledType(const glslang::TSampler& sampler)
// is applied.
spv::Id TGlslangToSpvTraverser::getInvertedSwizzleType(const glslang::TIntermTyped& node)
{
- if (node.getAsOperator() &&
+ if (node.getAsOperator() &&
node.getAsOperator()->getOp() == glslang::EOpVectorSwizzle)
return convertGlslangToSpvType(node.getAsBinaryNode()->getLeft()->getType());
else
@@ -2013,7 +2051,6 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
#ifdef AMD_EXTENSIONS
case glslang::EbtFloat16:
builder.addExtension(spv::E_SPV_AMD_gpu_shader_half_float);
- builder.addCapability(spv::CapabilityFloat16);
spvType = builder.makeFloatType(16);
break;
#endif
@@ -2139,7 +2176,6 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
return spvType;
}
-
// Do full recursive conversion of a glslang structure (or block) type to a SPIR-V Id.
// explicitLayout can be kept the same throughout the hierarchical recursive walk.
// Mutually recursive with convertGlslangToSpvType().
@@ -2275,6 +2311,22 @@ void TGlslangToSpvTraverser::decorateStructType(const glslang::TType& type,
spv::BuiltIn builtIn = TranslateBuiltInDecoration(glslangMember.getQualifier().builtIn, true);
if (builtIn != spv::BuiltInMax)
addMemberDecoration(spvType, member, spv::DecorationBuiltIn, (int)builtIn);
+
+#ifdef NV_EXTENSIONS
+ if (builtIn == spv::BuiltInLayer) {
+ // SPV_NV_viewport_array2 extension
+ if (glslangMember.getQualifier().layoutViewportRelative){
+ addMemberDecoration(spvType, member, (spv::Decoration)spv::DecorationViewportRelativeNV);
+ builder.addCapability(spv::CapabilityShaderViewportMaskNV);
+ builder.addExtension(spv::E_SPV_NV_viewport_array2);
+ }
+ if (glslangMember.getQualifier().layoutSecondaryViewportRelativeOffset != -2048){
+ addMemberDecoration(spvType, member, (spv::Decoration)spv::DecorationSecondaryViewportRelativeNV, glslangMember.getQualifier().layoutSecondaryViewportRelativeOffset);
+ builder.addCapability(spv::CapabilityShaderStereoViewNV);
+ builder.addExtension(spv::E_SPV_NV_stereo_view_rendering);
+ }
+ }
+#endif
}
}
@@ -2546,6 +2598,12 @@ void TGlslangToSpvTraverser::declareUseOfStructMember(const glslang::TTypeList&
case glslang::EbvClipDistance:
case glslang::EbvCullDistance:
case glslang::EbvPointSize:
+#ifdef NV_EXTENSIONS
+ case glslang::EbvLayer:
+ case glslang::EbvViewportMaskNV:
+ case glslang::EbvSecondaryPositionNV:
+ case glslang::EbvSecondaryViewportMaskNV:
+#endif
// Generate the associated capability. Delegate to TranslateBuiltInDecoration.
// Alternately, we could just call this for any glslang built-in, since the
// capability already guards against duplicates.
@@ -3012,7 +3070,7 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
}
// copy the projective coordinate if we have to
if (projTargetComp != projSourceComp) {
- spv::Id projComp = builder.createCompositeExtract(params.coords,
+ spv::Id projComp = builder.createCompositeExtract(params.coords,
builder.getScalarTypeId(builder.getTypeId(params.coords)),
projSourceComp);
params.coords = builder.createCompositeInsert(projComp, params.coords,
@@ -3742,6 +3800,18 @@ spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, spv:
case glslang::EOpMinInvocationsNonUniform:
case glslang::EOpMaxInvocationsNonUniform:
case glslang::EOpAddInvocationsNonUniform:
+ case glslang::EOpMinInvocationsInclusiveScan:
+ case glslang::EOpMaxInvocationsInclusiveScan:
+ case glslang::EOpAddInvocationsInclusiveScan:
+ case glslang::EOpMinInvocationsInclusiveScanNonUniform:
+ case glslang::EOpMaxInvocationsInclusiveScanNonUniform:
+ case glslang::EOpAddInvocationsInclusiveScanNonUniform:
+ case glslang::EOpMinInvocationsExclusiveScan:
+ case glslang::EOpMaxInvocationsExclusiveScan:
+ case glslang::EOpAddInvocationsExclusiveScan:
+ case glslang::EOpMinInvocationsExclusiveScanNonUniform:
+ case glslang::EOpMaxInvocationsExclusiveScanNonUniform:
+ case glslang::EOpAddInvocationsExclusiveScanNonUniform:
#endif
{
std::vector<spv::Id> operands;
@@ -4129,26 +4199,66 @@ spv::Id TGlslangToSpvTraverser::createInvocationsOperation(glslang::TOperator op
#endif
spv::Op opCode = spv::OpNop;
-
std::vector<spv::Id> spvGroupOperands;
+ spv::GroupOperation groupOperation = spv::GroupOperationMax;
+
if (op == glslang::EOpBallot || op == glslang::EOpReadFirstInvocation ||
op == glslang::EOpReadInvocation) {
builder.addExtension(spv::E_SPV_KHR_shader_ballot);
builder.addCapability(spv::CapabilitySubgroupBallotKHR);
+ } else if (op == glslang::EOpAnyInvocation ||
+ op == glslang::EOpAllInvocations ||
+ op == glslang::EOpAllInvocationsEqual) {
+ builder.addExtension(spv::E_SPV_KHR_subgroup_vote);
+ builder.addCapability(spv::CapabilitySubgroupVoteKHR);
} else {
builder.addCapability(spv::CapabilityGroups);
#ifdef AMD_EXTENSIONS
if (op == glslang::EOpMinInvocationsNonUniform ||
op == glslang::EOpMaxInvocationsNonUniform ||
- op == glslang::EOpAddInvocationsNonUniform)
+ op == glslang::EOpAddInvocationsNonUniform ||
+ op == glslang::EOpMinInvocationsInclusiveScanNonUniform ||
+ op == glslang::EOpMaxInvocationsInclusiveScanNonUniform ||
+ op == glslang::EOpAddInvocationsInclusiveScanNonUniform ||
+ op == glslang::EOpMinInvocationsExclusiveScanNonUniform ||
+ op == glslang::EOpMaxInvocationsExclusiveScanNonUniform ||
+ op == glslang::EOpAddInvocationsExclusiveScanNonUniform)
builder.addExtension(spv::E_SPV_AMD_shader_ballot);
#endif
spvGroupOperands.push_back(builder.makeUintConstant(spv::ScopeSubgroup));
#ifdef AMD_EXTENSIONS
- if (op == glslang::EOpMinInvocations || op == glslang::EOpMaxInvocations || op == glslang::EOpAddInvocations ||
- op == glslang::EOpMinInvocationsNonUniform || op == glslang::EOpMaxInvocationsNonUniform || op == glslang::EOpAddInvocationsNonUniform)
- spvGroupOperands.push_back(spv::GroupOperationReduce);
+ switch (op) {
+ case glslang::EOpMinInvocations:
+ case glslang::EOpMaxInvocations:
+ case glslang::EOpAddInvocations:
+ case glslang::EOpMinInvocationsNonUniform:
+ case glslang::EOpMaxInvocationsNonUniform:
+ case glslang::EOpAddInvocationsNonUniform:
+ groupOperation = spv::GroupOperationReduce;
+ spvGroupOperands.push_back(groupOperation);
+ break;
+ case glslang::EOpMinInvocationsInclusiveScan:
+ case glslang::EOpMaxInvocationsInclusiveScan:
+ case glslang::EOpAddInvocationsInclusiveScan:
+ case glslang::EOpMinInvocationsInclusiveScanNonUniform:
+ case glslang::EOpMaxInvocationsInclusiveScanNonUniform:
+ case glslang::EOpAddInvocationsInclusiveScanNonUniform:
+ groupOperation = spv::GroupOperationInclusiveScan;
+ spvGroupOperands.push_back(groupOperation);
+ break;
+ case glslang::EOpMinInvocationsExclusiveScan:
+ case glslang::EOpMaxInvocationsExclusiveScan:
+ case glslang::EOpAddInvocationsExclusiveScan:
+ case glslang::EOpMinInvocationsExclusiveScanNonUniform:
+ case glslang::EOpMaxInvocationsExclusiveScanNonUniform:
+ case glslang::EOpAddInvocationsExclusiveScanNonUniform:
+ groupOperation = spv::GroupOperationExclusiveScan;
+ spvGroupOperands.push_back(groupOperation);
+ break;
+ default:
+ break;
+ }
#endif
}
@@ -4157,24 +4267,18 @@ spv::Id TGlslangToSpvTraverser::createInvocationsOperation(glslang::TOperator op
switch (op) {
case glslang::EOpAnyInvocation:
- opCode = spv::OpGroupAny;
+ opCode = spv::OpSubgroupAnyKHR;
break;
case glslang::EOpAllInvocations:
- opCode = spv::OpGroupAll;
+ opCode = spv::OpSubgroupAllKHR;
break;
case glslang::EOpAllInvocationsEqual:
- {
- spv::Id groupAll = builder.createOp(spv::OpGroupAll, typeId, spvGroupOperands);
- spv::Id groupAny = builder.createOp(spv::OpGroupAny, typeId, spvGroupOperands);
-
- return builder.createBinOp(spv::OpLogicalOr, typeId, groupAll,
- builder.createUnaryOp(spv::OpLogicalNot, typeId, groupAny));
- }
-
+ opCode = spv::OpSubgroupAllEqualKHR;
+ break;
case glslang::EOpReadInvocation:
opCode = spv::OpSubgroupReadInvocationKHR;
if (builder.isVectorType(typeId))
- return CreateInvocationsVectorOperation(opCode, typeId, operands);
+ return CreateInvocationsVectorOperation(opCode, groupOperation, typeId, operands);
break;
case glslang::EOpReadFirstInvocation:
opCode = spv::OpSubgroupFirstInvocationKHR;
@@ -4204,7 +4308,15 @@ spv::Id TGlslangToSpvTraverser::createInvocationsOperation(glslang::TOperator op
case glslang::EOpMinInvocations:
case glslang::EOpMaxInvocations:
case glslang::EOpAddInvocations:
- if (op == glslang::EOpMinInvocations) {
+ case glslang::EOpMinInvocationsInclusiveScan:
+ case glslang::EOpMaxInvocationsInclusiveScan:
+ case glslang::EOpAddInvocationsInclusiveScan:
+ case glslang::EOpMinInvocationsExclusiveScan:
+ case glslang::EOpMaxInvocationsExclusiveScan:
+ case glslang::EOpAddInvocationsExclusiveScan:
+ if (op == glslang::EOpMinInvocations ||
+ op == glslang::EOpMinInvocationsInclusiveScan ||
+ op == glslang::EOpMinInvocationsExclusiveScan) {
if (isFloat)
opCode = spv::OpGroupFMin;
else {
@@ -4213,7 +4325,9 @@ spv::Id TGlslangToSpvTraverser::createInvocationsOperation(glslang::TOperator op
else
opCode = spv::OpGroupSMin;
}
- } else if (op == glslang::EOpMaxInvocations) {
+ } else if (op == glslang::EOpMaxInvocations ||
+ op == glslang::EOpMaxInvocationsInclusiveScan ||
+ op == glslang::EOpMaxInvocationsExclusiveScan) {
if (isFloat)
opCode = spv::OpGroupFMax;
else {
@@ -4230,13 +4344,21 @@ spv::Id TGlslangToSpvTraverser::createInvocationsOperation(glslang::TOperator op
}
if (builder.isVectorType(typeId))
- return CreateInvocationsVectorOperation(opCode, typeId, operands);
+ return CreateInvocationsVectorOperation(opCode, groupOperation, typeId, operands);
break;
case glslang::EOpMinInvocationsNonUniform:
case glslang::EOpMaxInvocationsNonUniform:
case glslang::EOpAddInvocationsNonUniform:
- if (op == glslang::EOpMinInvocationsNonUniform) {
+ case glslang::EOpMinInvocationsInclusiveScanNonUniform:
+ case glslang::EOpMaxInvocationsInclusiveScanNonUniform:
+ case glslang::EOpAddInvocationsInclusiveScanNonUniform:
+ case glslang::EOpMinInvocationsExclusiveScanNonUniform:
+ case glslang::EOpMaxInvocationsExclusiveScanNonUniform:
+ case glslang::EOpAddInvocationsExclusiveScanNonUniform:
+ if (op == glslang::EOpMinInvocationsNonUniform ||
+ op == glslang::EOpMinInvocationsInclusiveScanNonUniform ||
+ op == glslang::EOpMinInvocationsExclusiveScanNonUniform) {
if (isFloat)
opCode = spv::OpGroupFMinNonUniformAMD;
else {
@@ -4246,7 +4368,9 @@ spv::Id TGlslangToSpvTraverser::createInvocationsOperation(glslang::TOperator op
opCode = spv::OpGroupSMinNonUniformAMD;
}
}
- else if (op == glslang::EOpMaxInvocationsNonUniform) {
+ else if (op == glslang::EOpMaxInvocationsNonUniform ||
+ op == glslang::EOpMaxInvocationsInclusiveScanNonUniform ||
+ op == glslang::EOpMaxInvocationsExclusiveScanNonUniform) {
if (isFloat)
opCode = spv::OpGroupFMaxNonUniformAMD;
else {
@@ -4264,7 +4388,7 @@ spv::Id TGlslangToSpvTraverser::createInvocationsOperation(glslang::TOperator op
}
if (builder.isVectorType(typeId))
- return CreateInvocationsVectorOperation(opCode, typeId, operands);
+ return CreateInvocationsVectorOperation(opCode, groupOperation, typeId, operands);
break;
#endif
@@ -4278,7 +4402,7 @@ spv::Id TGlslangToSpvTraverser::createInvocationsOperation(glslang::TOperator op
}
// Create group invocation operations on a vector
-spv::Id TGlslangToSpvTraverser::CreateInvocationsVectorOperation(spv::Op op, spv::Id typeId, std::vector<spv::Id>& operands)
+spv::Id TGlslangToSpvTraverser::CreateInvocationsVectorOperation(spv::Op op, spv::GroupOperation groupOperation, spv::Id typeId, std::vector<spv::Id>& operands)
{
#ifdef AMD_EXTENSIONS
assert(op == spv::OpGroupFMin || op == spv::OpGroupUMin || op == spv::OpGroupSMin ||
@@ -4322,7 +4446,7 @@ spv::Id TGlslangToSpvTraverser::CreateInvocationsVectorOperation(spv::Op op, spv
spvGroupOperands.push_back(operands[1]);
} else {
spvGroupOperands.push_back(builder.makeUintConstant(spv::ScopeSubgroup));
- spvGroupOperands.push_back(spv::GroupOperationReduce);
+ spvGroupOperands.push_back(groupOperation);
spvGroupOperands.push_back(scalar);
}
@@ -4731,12 +4855,12 @@ spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol
if (builtIn != spv::BuiltInMax)
addDecoration(id, spv::DecorationBuiltIn, (int)builtIn);
-#ifdef NV_EXTENSIONS
+#ifdef NV_EXTENSIONS
if (builtIn == spv::BuiltInSampleMask) {
spv::Decoration decoration;
// GL_NV_sample_mask_override_coverage extension
if (glslangIntermediate->getLayoutOverrideCoverage())
- decoration = (spv::Decoration)spv::OverrideCoverageNV;
+ decoration = (spv::Decoration)spv::DecorationOverrideCoverageNV;
else
decoration = (spv::Decoration)spv::DecorationMax;
addDecoration(id, decoration);
@@ -4744,9 +4868,25 @@ spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol
builder.addExtension(spv::E_SPV_NV_sample_mask_override_coverage);
}
}
+ else if (builtIn == spv::BuiltInLayer) {
+ // SPV_NV_viewport_array2 extension
+ if (symbol->getQualifier().layoutViewportRelative)
+ {
+ addDecoration(id, (spv::Decoration)spv::DecorationViewportRelativeNV);
+ builder.addCapability(spv::CapabilityShaderViewportMaskNV);
+ builder.addExtension(spv::E_SPV_NV_viewport_array2);
+ }
+ if(symbol->getQualifier().layoutSecondaryViewportRelativeOffset != -2048)
+ {
+ addDecoration(id, (spv::Decoration)spv::DecorationSecondaryViewportRelativeNV, symbol->getQualifier().layoutSecondaryViewportRelativeOffset);
+ builder.addCapability(spv::CapabilityShaderStereoViewNV);
+ builder.addExtension(spv::E_SPV_NV_stereo_view_rendering);
+ }
+ }
+
if (symbol->getQualifier().layoutPassthrough) {
- addDecoration(id, spv::PassthroughNV);
- builder.addCapability(spv::GeometryShaderPassthroughNV);
+ addDecoration(id, spv::DecorationPassthroughNV);
+ builder.addCapability(spv::CapabilityGeometryShaderPassthroughNV);
builder.addExtension(spv::E_SPV_NV_geometry_shader_passthrough);
}
#endif
@@ -4831,7 +4971,9 @@ spv::Id TGlslangToSpvTraverser::createSpvConstant(const glslang::TIntermTyped& n
return accessChainLoad(sub_tree->getType());
} else if (auto* const_union_array = &sn->getConstArray()){
int nextConst = 0;
- return createSpvConstantFromConstUnionArray(sn->getType(), *const_union_array, nextConst, true);
+ spv::Id id = createSpvConstantFromConstUnionArray(sn->getType(), *const_union_array, nextConst, true);
+ builder.addName(id, sn->getName().c_str());
+ return id;
}
}
diff --git a/3rdparty/bgfx/3rdparty/glslang/SPIRV/GlslangToSpv.h b/3rdparty/bgfx/3rdparty/glslang/SPIRV/GlslangToSpv.h
index 428cfb6a7d9..ceb23b5a5a9 100644
--- a/3rdparty/bgfx/3rdparty/glslang/SPIRV/GlslangToSpv.h
+++ b/3rdparty/bgfx/3rdparty/glslang/SPIRV/GlslangToSpv.h
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2014 LunarG, Inc.
+// Copyright (C) 2014 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
#if _MSC_VER >= 1900
#pragma warning(disable : 4464) // relative include path contains '..'
diff --git a/3rdparty/bgfx/3rdparty/glslang/SPIRV/InReadableOrder.cpp b/3rdparty/bgfx/3rdparty/glslang/SPIRV/InReadableOrder.cpp
index 86aae6d057f..4bb3d772c5d 100644
--- a/3rdparty/bgfx/3rdparty/glslang/SPIRV/InReadableOrder.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/SPIRV/InReadableOrder.cpp
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2016 Google, Inc.
+// Copyright (C) 2016 Google, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
// The SPIR-V spec requires code blocks to appear in an order satisfying the
// dominator-tree direction (ie, dominator before the dominated). This is,
diff --git a/3rdparty/bgfx/3rdparty/glslang/SPIRV/SPVRemapper.cpp b/3rdparty/bgfx/3rdparty/glslang/SPIRV/SPVRemapper.cpp
index f30963b13c5..9b1270501be 100644
--- a/3rdparty/bgfx/3rdparty/glslang/SPIRV/SPVRemapper.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/SPIRV/SPVRemapper.cpp
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2015 LunarG, Inc.
+// Copyright (C) 2015 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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 "SPVRemapper.h"
@@ -103,10 +103,10 @@ namespace spv {
switch (opCode) {
case spv::OpTypeVector: // fall through
- case spv::OpTypeMatrix: // ...
- case spv::OpTypeSampler: // ...
- case spv::OpTypeArray: // ...
- case spv::OpTypeRuntimeArray: // ...
+ case spv::OpTypeMatrix: // ...
+ case spv::OpTypeSampler: // ...
+ case spv::OpTypeArray: // ...
+ case spv::OpTypeRuntimeArray: // ...
case spv::OpTypePipe: return range_t(2, 3);
case spv::OpTypeStruct: // fall through
case spv::OpTypeFunction: return range_t(2, maxCount);
@@ -286,7 +286,6 @@ namespace spv {
return literal;
}
-
void spirvbin_t::applyMap()
{
msg(3, 2, std::string("Applying map: "));
@@ -300,7 +299,6 @@ namespace spv {
);
}
-
// Find free IDs for anything we haven't mapped
void spirvbin_t::mapRemainder()
{
@@ -355,7 +353,7 @@ namespace spv {
if (idPosR.find(asId(start+1)) == idPosR.end())
stripInst(start);
break;
- default:
+ default:
break; // leave it alone
}
@@ -399,7 +397,7 @@ namespace spv {
if (spv::InstructionDesc[opCode].hasResult()) {
const spv::Id resultId = asId(word++);
idPosR[resultId] = start;
-
+
if (typeId != spv::NoResult) {
const unsigned idTypeSize = typeSizeInWords(typeId);
@@ -462,7 +460,6 @@ namespace spv {
error("bad schema, must be 0");
}
-
int spirvbin_t::processInstruction(unsigned word, instfn_t instFn, idfn_t idFn)
{
const auto instructionStart = word;
@@ -902,7 +899,7 @@ namespace spv {
},
// If local var id used anywhere else, don't eliminate
- [&](spv::Id& id) {
+ [&](spv::Id& id) {
if (fnLocalVars.count(id) > 0) {
fnLocalVars.erase(id);
idMap.erase(id);
@@ -1079,7 +1076,6 @@ namespace spv {
}
}
-
#ifdef NOTDEF
bool spirvbin_t::matchType(const spirvbin_t::globaltypes_t& globalTypes, spv::Id lt, spv::Id gt) const
{
@@ -1139,7 +1135,6 @@ namespace spv {
}
}
-
// Look for an equivalent type in the globalTypes map
spv::Id spirvbin_t::findType(const spirvbin_t::globaltypes_t& globalTypes, spv::Id lt) const
{
@@ -1261,7 +1256,6 @@ namespace spv {
}
}
-
// Strip a single binary by removing ranges given in stripRange
void spirvbin_t::strip()
{
diff --git a/3rdparty/bgfx/3rdparty/glslang/SPIRV/SPVRemapper.h b/3rdparty/bgfx/3rdparty/glslang/SPIRV/SPVRemapper.h
index 77c965821a1..f9f369a37c3 100644
--- a/3rdparty/bgfx/3rdparty/glslang/SPIRV/SPVRemapper.h
+++ b/3rdparty/bgfx/3rdparty/glslang/SPIRV/SPVRemapper.h
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2015 LunarG, Inc.
+// Copyright (C) 2015 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
#ifndef SPIRVREMAPPER_H
@@ -112,7 +112,8 @@ class spirvbin_t : public spirvbin_base_t
{
public:
spirvbin_t(int verbose = 0) : entryPoint(spv::NoResult), largestNewId(0), verbose(verbose) { }
-
+ virtual ~spirvbin_t() { }
+
// remap on an existing binary in memory
void remap(std::vector<std::uint32_t>& spv, std::uint32_t opts = DO_EVERYTHING);
@@ -175,7 +176,7 @@ private:
range_t constRange(spv::Op opCode) const;
unsigned typeSizeInWords(spv::Id id) const;
unsigned idTypeSizeInWords(spv::Id id) const;
-
+
spv::Id& asId(unsigned word) { return spv[word]; }
const spv::Id& asId(unsigned word) const { return spv[word]; }
spv::Op asOpCode(unsigned word) const { return opOpCode(spv[word]); }
@@ -242,7 +243,7 @@ private:
void stripDebug(); // strip all debug info
void stripDeadRefs(); // strips debug info for now-dead references after DCE
void strip(); // remove debug symbols
-
+
std::vector<spirword_t> spv; // SPIR words
namemap_t nameMap; // ID names from OpName
@@ -268,11 +269,11 @@ private:
// Which functions are called, anywhere in the module, with a call count
std::unordered_map<spv::Id, int> fnCalls;
-
+
posmap_t typeConstPos; // word positions that define types & consts (ordered)
posmap_rev_t idPosR; // reverse map from IDs to positions
typesize_map_t idTypeSizeMap; // maps each ID to its type size, if known.
-
+
std::vector<spv::Id> idMapL; // ID {M}ap from {L}ocal to {G}lobal IDs
spv::Id entryPoint; // module entry point
diff --git a/3rdparty/bgfx/3rdparty/glslang/SPIRV/SpvBuilder.cpp b/3rdparty/bgfx/3rdparty/glslang/SPIRV/SpvBuilder.cpp
index b0b74b24386..c0ca970ffbb 100644
--- a/3rdparty/bgfx/3rdparty/glslang/SPIRV/SpvBuilder.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/SPIRV/SpvBuilder.cpp
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2014-2015 LunarG, Inc.
-//Copyright (C) 2015-2016 Google, Inc.
+// Copyright (C) 2014-2015 LunarG, Inc.
+// Copyright (C) 2015-2016 Google, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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.
//
// Helper for making SPIR-V IR. Generally, this is documented in the header
@@ -79,7 +79,7 @@ Id Builder::import(const char* name)
{
Instruction* import = new Instruction(getUniqueId(), NoType, OpExtInstImport);
import->addStringOperand(name);
-
+
imports.push_back(std::unique_ptr<Instruction>(import));
return import->getResultId();
}
@@ -246,7 +246,7 @@ Id Builder::makeStructResultType(Id type0, Id type1)
type = groupedTypes[OpTypeStruct][t];
if (type->getNumOperands() != 2)
continue;
- if (type->getIdOperand(0) != type0 ||
+ if (type->getIdOperand(0) != type0 ||
type->getIdOperand(1) != type1)
continue;
return type->getResultId();
@@ -628,7 +628,7 @@ Id Builder::findScalarConstant(Op typeClass, Op opcode, Id typeId, unsigned v1,
bool Builder::isConstantOpCode(Op opcode) const
{
switch (opcode) {
- case OpUndef:
+ case OpUndef:
case OpConstantTrue:
case OpConstantFalse:
case OpConstant:
@@ -819,7 +819,7 @@ Id Builder::makeFloat16Constant(float f16, bool specConstant)
}
#endif
-Id Builder::findCompositeConstant(Op typeClass, std::vector<Id>& comps) const
+Id Builder::findCompositeConstant(Op typeClass, const std::vector<Id>& comps) const
{
Instruction* constant = 0;
bool found = false;
@@ -848,7 +848,7 @@ Id Builder::findCompositeConstant(Op typeClass, std::vector<Id>& comps) const
}
// Comments in header
-Id Builder::makeCompositeConstant(Id typeId, std::vector<Id>& members, bool specConstant)
+Id Builder::makeCompositeConstant(Id typeId, const std::vector<Id>& members, bool specConstant)
{
Op opcode = specConstant ? OpSpecConstantComposite : OpConstantComposite;
assert(typeId);
@@ -1098,7 +1098,7 @@ Id Builder::createLoad(Id lValue)
}
// Comments in header
-Id Builder::createAccessChain(StorageClass storageClass, Id base, std::vector<Id>& offsets)
+Id Builder::createAccessChain(StorageClass storageClass, Id base, const std::vector<Id>& offsets)
{
// Figure out the final resulting type.
spv::Id typeId = getTypeId(base);
@@ -1148,7 +1148,7 @@ Id Builder::createCompositeExtract(Id composite, Id typeId, unsigned index)
return extract->getResultId();
}
-Id Builder::createCompositeExtract(Id composite, Id typeId, std::vector<unsigned>& indexes)
+Id Builder::createCompositeExtract(Id composite, Id typeId, const std::vector<unsigned>& indexes)
{
// Generate code for spec constants if in spec constant operation
// generation mode.
@@ -1175,7 +1175,7 @@ Id Builder::createCompositeInsert(Id object, Id composite, Id typeId, unsigned i
return insert->getResultId();
}
-Id Builder::createCompositeInsert(Id object, Id composite, Id typeId, std::vector<unsigned>& indexes)
+Id Builder::createCompositeInsert(Id object, Id composite, Id typeId, const std::vector<unsigned>& indexes)
{
Instruction* insert = new Instruction(getUniqueId(), typeId, OpCompositeInsert);
insert->addIdOperand(object);
@@ -1326,7 +1326,7 @@ Id Builder::createSpecConstantOp(Op opCode, Id typeId, const std::vector<Id>& op
return op->getResultId();
}
-Id Builder::createFunctionCall(spv::Function* function, std::vector<spv::Id>& args)
+Id Builder::createFunctionCall(spv::Function* function, const std::vector<spv::Id>& args)
{
Instruction* op = new Instruction(getUniqueId(), function->getReturnType(), OpFunctionCall);
op->addIdOperand(function->getId());
@@ -1338,7 +1338,7 @@ Id Builder::createFunctionCall(spv::Function* function, std::vector<spv::Id>& ar
}
// Comments in header
-Id Builder::createRvalueSwizzle(Decoration precision, Id typeId, Id source, std::vector<unsigned>& channels)
+Id Builder::createRvalueSwizzle(Decoration precision, Id typeId, Id source, const std::vector<unsigned>& channels)
{
if (channels.size() == 1)
return setPrecision(createCompositeExtract(source, typeId, channels.front()), precision);
@@ -1360,7 +1360,7 @@ Id Builder::createRvalueSwizzle(Decoration precision, Id typeId, Id source, std:
}
// Comments in header
-Id Builder::createLvalueSwizzle(Id typeId, Id target, Id source, std::vector<unsigned>& channels)
+Id Builder::createLvalueSwizzle(Id typeId, Id target, Id source, const std::vector<unsigned>& channels)
{
if (channels.size() == 1 && getNumComponents(source) == 1)
return createCompositeInsert(source, target, typeId, channels.front());
@@ -1446,7 +1446,7 @@ Id Builder::smearScalar(Decoration precision, Id scalar, Id vectorType)
}
// Comments in header
-Id Builder::createBuiltinCall(Id resultType, Id builtins, int entryPoint, std::vector<Id>& args)
+Id Builder::createBuiltinCall(Id resultType, Id builtins, int entryPoint, const std::vector<Id>& args)
{
Instruction* inst = new Instruction(getUniqueId(), resultType, OpExtInst);
inst->addIdOperand(builtins);
@@ -1794,7 +1794,7 @@ Id Builder::createCompositeCompare(Decoration precision, Id value1, Id value2, b
}
// OpCompositeConstruct
-Id Builder::createCompositeConstruct(Id typeId, std::vector<Id>& constituents)
+Id Builder::createCompositeConstruct(Id typeId, const std::vector<Id>& constituents)
{
assert(isAggregateType(typeId) || (getNumTypeConstituents(typeId) > 1 && getNumTypeConstituents(typeId) == (int)constituents.size()));
@@ -1936,7 +1936,6 @@ Id Builder::createMatrixConstructor(Decoration precision, const std::vector<Id>&
}
}
-
// Step 2: Construct a matrix from that array.
// First make the column vectors, then make the matrix.
@@ -2012,7 +2011,8 @@ void Builder::If::makeEndIf()
}
// Comments in header
-void Builder::makeSwitch(Id selector, int numSegments, std::vector<int>& caseValues, std::vector<int>& valueIndexToSegment, int defaultSegment,
+void Builder::makeSwitch(Id selector, int numSegments, const std::vector<int>& caseValues,
+ const std::vector<int>& valueIndexToSegment, int defaultSegment,
std::vector<Block*>& segmentBlocks)
{
Function& function = buildPoint->getParent();
@@ -2355,7 +2355,7 @@ void Builder::dump(std::vector<unsigned int>& out) const
for (auto it = extensions.cbegin(); it != extensions.cend(); ++it) {
Instruction extInst(0, 0, OpExtension);
- extInst.addStringOperand(*it);
+ extInst.addStringOperand(it->c_str());
extInst.dump(out);
}
@@ -2492,7 +2492,7 @@ void Builder::createAndSetNoPredecessorBlock(const char* /*name*/)
buildPoint->getParent().addBlock(block);
setBuildPoint(block);
- //if (name)
+ // if (name)
// addName(block->getId(), name);
}
diff --git a/3rdparty/bgfx/3rdparty/glslang/SPIRV/SpvBuilder.h b/3rdparty/bgfx/3rdparty/glslang/SPIRV/SpvBuilder.h
index e8524b2b1b7..fe83ac1d079 100644
--- a/3rdparty/bgfx/3rdparty/glslang/SPIRV/SpvBuilder.h
+++ b/3rdparty/bgfx/3rdparty/glslang/SPIRV/SpvBuilder.h
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2014-2015 LunarG, Inc.
-//Copyright (C) 2015-2016 Google, Inc.
+// Copyright (C) 2014-2015 LunarG, Inc.
+// Copyright (C) 2015-2016 Google, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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.
//
// "Builder" is an interface to fully build SPIR-V IR. Allocate one of
@@ -196,7 +196,7 @@ public:
#endif
// Turn the array of constants into a proper spv constant of the requested type.
- Id makeCompositeConstant(Id type, std::vector<Id>& comps, bool specConst = false);
+ Id makeCompositeConstant(Id type, const std::vector<Id>& comps, bool specConst = false);
// Methods for adding information outside the CFG.
Instruction* addEntryPoint(ExecutionModel, Function*, const char* name);
@@ -244,16 +244,16 @@ public:
Id createLoad(Id lValue);
// Create an OpAccessChain instruction
- Id createAccessChain(StorageClass, Id base, std::vector<Id>& offsets);
+ Id createAccessChain(StorageClass, Id base, const std::vector<Id>& offsets);
// Create an OpArrayLength instruction
Id createArrayLength(Id base, unsigned int member);
// Create an OpCompositeExtract instruction
Id createCompositeExtract(Id composite, Id typeId, unsigned index);
- Id createCompositeExtract(Id composite, Id typeId, std::vector<unsigned>& indexes);
+ Id createCompositeExtract(Id composite, Id typeId, const std::vector<unsigned>& indexes);
Id createCompositeInsert(Id object, Id composite, Id typeId, unsigned index);
- Id createCompositeInsert(Id object, Id composite, Id typeId, std::vector<unsigned>& indexes);
+ Id createCompositeInsert(Id object, Id composite, Id typeId, const std::vector<unsigned>& indexes);
Id createVectorExtractDynamic(Id vector, Id typeId, Id componentIndex);
Id createVectorInsertDynamic(Id vector, Id typeId, Id component, Id componentIndex);
@@ -267,18 +267,18 @@ public:
Id createBinOp(Op, Id typeId, Id operand1, Id operand2);
Id createTriOp(Op, Id typeId, Id operand1, Id operand2, Id operand3);
Id createOp(Op, Id typeId, const std::vector<Id>& operands);
- Id createFunctionCall(spv::Function*, std::vector<spv::Id>&);
+ Id createFunctionCall(spv::Function*, const std::vector<spv::Id>&);
Id createSpecConstantOp(Op, Id typeId, const std::vector<spv::Id>& operands, const std::vector<unsigned>& literals);
// Take an rvalue (source) and a set of channels to extract from it to
// make a new rvalue, which is returned.
- Id createRvalueSwizzle(Decoration precision, Id typeId, Id source, std::vector<unsigned>& channels);
+ Id createRvalueSwizzle(Decoration precision, Id typeId, Id source, const std::vector<unsigned>& channels);
// Take a copy of an lvalue (target) and a source of components, and set the
// source components into the lvalue where the 'channels' say to put them.
// An updated version of the target is returned.
// (No true lvalue or stores are used.)
- Id createLvalueSwizzle(Id typeId, Id target, Id source, std::vector<unsigned>& channels);
+ Id createLvalueSwizzle(Id typeId, Id target, Id source, const std::vector<unsigned>& channels);
// If both the id and precision are valid, the id
// gets tagged with the requested precision.
@@ -311,7 +311,7 @@ public:
Id smearScalar(Decoration precision, Id scalarVal, Id vectorType);
// Create a call to a built-in function.
- Id createBuiltinCall(Id resultType, Id builtins, int entryPoint, std::vector<Id>& args);
+ Id createBuiltinCall(Id resultType, Id builtins, int entryPoint, const std::vector<Id>& args);
// List of parameters used to create a texture operation
struct TextureParameters {
@@ -346,7 +346,7 @@ public:
Id createCompositeCompare(Decoration precision, Id, Id, bool /* true if for equal, false if for not-equal */);
// OpCompositeConstruct
- Id createCompositeConstruct(Id typeId, std::vector<Id>& constituents);
+ Id createCompositeConstruct(Id typeId, const std::vector<Id>& constituents);
// vector or scalar constructor
Id createConstructor(Decoration precision, const std::vector<Id>& sources, Id resultTypeId);
@@ -388,8 +388,8 @@ public:
// Returns the right set of basic blocks to start each code segment with, so that the caller's
// recursion stack can hold the memory for it.
//
- void makeSwitch(Id condition, int numSegments, std::vector<int>& caseValues, std::vector<int>& valueToSegment, int defaultSegment,
- std::vector<Block*>& segmentBB); // return argument
+ void makeSwitch(Id condition, int numSegments, const std::vector<int>& caseValues,
+ const std::vector<int>& valueToSegment, int defaultSegment, std::vector<Block*>& segmentBB); // return argument
// Add a branch to the innermost switch's merge block.
void addSwitchBreak();
@@ -545,7 +545,7 @@ public:
Id makeInt64Constant(Id typeId, unsigned long long value, bool specConstant);
Id findScalarConstant(Op typeClass, Op opcode, Id typeId, unsigned value) const;
Id findScalarConstant(Op typeClass, Op opcode, Id typeId, unsigned v1, unsigned v2) const;
- Id findCompositeConstant(Op typeClass, std::vector<Id>& comps) const;
+ Id findCompositeConstant(Op typeClass, const std::vector<Id>& comps) const;
Id collapseAccessChain();
void transferAccessChainSwizzle(bool dynamic);
void simplifyAccessChainSwizzle();
@@ -555,7 +555,7 @@ public:
SourceLanguage source;
int sourceVersion;
- std::set<const char*> extensions;
+ std::set<std::string> extensions;
std::vector<const char*> sourceExtensions;
AddressingModel addressModel;
MemoryModel memoryModel;
diff --git a/3rdparty/bgfx/3rdparty/glslang/SPIRV/disassemble.cpp b/3rdparty/bgfx/3rdparty/glslang/SPIRV/disassemble.cpp
index cbc9a9b6cea..74ae40767f8 100644
--- a/3rdparty/bgfx/3rdparty/glslang/SPIRV/disassemble.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/SPIRV/disassemble.cpp
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2014-2015 LunarG, Inc.
+// Copyright (C) 2014-2015 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
// Disassembler for SPIR-V.
@@ -482,7 +482,8 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode,
#endif
#ifdef NV_EXTENSIONS
}else if (strcmp(spv::E_SPV_NV_sample_mask_override_coverage, name) == 0 ||
- strcmp(spv::E_SPV_NV_geometry_shader_passthrough, name) == 0) {
+ strcmp(spv::E_SPV_NV_geometry_shader_passthrough, name) == 0 ||
+ strcmp(spv::E_SPV_NV_viewport_array2, name) == 0) {
extInstSet = GLSLextNVInst;
#endif
}
@@ -656,12 +657,21 @@ static const char* GLSLextAMDGetDebugNames(const char* name, unsigned entrypoint
static const char* GLSLextNVGetDebugNames(const char* name, unsigned entrypoint)
{
if (strcmp(name, spv::E_SPV_NV_sample_mask_override_coverage) == 0 ||
- strcmp(name, spv::E_SPV_NV_geometry_shader_passthrough) == 0) {
+ strcmp(name, spv::E_SPV_NV_geometry_shader_passthrough) == 0 ||
+ strcmp(name, spv::E_ARB_shader_viewport_layer_array) == 0 ||
+ strcmp(name, spv::E_SPV_NV_viewport_array2) == 0){
switch (entrypoint) {
- case OverrideCoverageNV: return "OverrideCoverageNV";
- case PassthroughNV: return "PassthroughNV";
- case GeometryShaderPassthroughNV: return "GeometryShaderPassthroughNV";
- default: return "Bad";
+ case DecorationOverrideCoverageNV: return "OverrideCoverageNV";
+ case DecorationPassthroughNV: return "PassthroughNV";
+ case CapabilityGeometryShaderPassthroughNV: return "GeometryShaderPassthroughNV";
+ case DecorationViewportRelativeNV: return "ViewportRelativeNV";
+ case BuiltInViewportMaskNV: return "ViewportMaskNV";
+ case CapabilityShaderViewportMaskNV: return "ShaderViewportMaskNV";
+ case DecorationSecondaryViewportRelativeNV: return "SecondaryViewportRelativeNV";
+ case BuiltInSecondaryPositionNV: return "SecondaryPositionNV";
+ case BuiltInSecondaryViewportMaskNV: return "SecondaryViewportMaskNV";
+ case CapabilityShaderStereoViewNV: return "ShaderStereoViewNV";
+ default: return "Bad";
}
}
return "Bad";
diff --git a/3rdparty/bgfx/3rdparty/glslang/SPIRV/disassemble.h b/3rdparty/bgfx/3rdparty/glslang/SPIRV/disassemble.h
index f5d0bc23bed..47cef65a573 100644
--- a/3rdparty/bgfx/3rdparty/glslang/SPIRV/disassemble.h
+++ b/3rdparty/bgfx/3rdparty/glslang/SPIRV/disassemble.h
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2014-2015 LunarG, Inc.
+// Copyright (C) 2014-2015 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
// Disassembler for SPIR-V.
diff --git a/3rdparty/bgfx/3rdparty/glslang/SPIRV/doc.cpp b/3rdparty/bgfx/3rdparty/glslang/SPIRV/doc.cpp
index b20944fc8c3..87180997867 100644
--- a/3rdparty/bgfx/3rdparty/glslang/SPIRV/doc.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/SPIRV/doc.cpp
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2014-2015 LunarG, Inc.
+// Copyright (C) 2014-2015 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
// 1) Programmatically fill in instruction/operand information.
@@ -262,6 +262,8 @@ const char* DecorationString(int decoration)
#ifdef NV_EXTENSIONS
case 5248: return "OverrideCoverageNV";
case 5250: return "PassthroughNV";
+ case 5252: return "ViewportRelativeNV";
+ case 5256: return "SecondaryViewportRelativeNV";
#endif
}
}
@@ -338,6 +340,11 @@ const char* BuiltInString(int builtIn)
case 4997: return "BaryCoordSmoothSampleAMD";
case 4998: return "BaryCoordPullModelAMD";
#endif
+#ifdef NV_EXTENSIONS
+ case 5253: return "ViewportMaskNV";
+ case 5257: return "SecondaryPositionNV";
+ case 5258: return "SecondaryViewportMaskNV";
+#endif
}
}
@@ -819,9 +826,13 @@ const char* CapabilityString(int info)
case 4423: return "SubgroupBallotKHR";
case 4427: return "DrawParameters";
+ case 4431: return "SubgroupVoteKHR";
#ifdef NV_EXTENSIONS
case 5251: return "GeometryShaderPassthroughNV";
+ case 5254: return "ShaderViewportIndexLayerNV";
+ case 5255: return "ShaderViewportMaskNV";
+ case 5259: return "ShaderStereoViewNV";
#endif
}
@@ -1158,6 +1169,9 @@ const char* OpcodeString(int op)
case 4421: return "OpSubgroupBallotKHR";
case 4422: return "OpSubgroupFirstInvocationKHR";
+ case 4428: return "OpSubgroupAnyKHR";
+ case 4429: return "OpSubgroupAllKHR";
+ case 4430: return "OpSubgroupAllEqualKHR";
case 4432: return "OpSubgroupReadInvocationKHR";
#ifdef AMD_EXTENSIONS
@@ -2771,6 +2785,18 @@ void Parameterize()
InstructionDesc[OpSubgroupFirstInvocationKHR].operands.push(OperandId, "'Value'");
+ InstructionDesc[OpSubgroupAnyKHR].capabilities.push_back(CapabilitySubgroupVoteKHR);
+ InstructionDesc[OpSubgroupAnyKHR].operands.push(OperandScope, "'Execution'");
+ InstructionDesc[OpSubgroupAnyKHR].operands.push(OperandId, "'Predicate'");
+
+ InstructionDesc[OpSubgroupAllKHR].capabilities.push_back(CapabilitySubgroupVoteKHR);
+ InstructionDesc[OpSubgroupAllKHR].operands.push(OperandScope, "'Execution'");
+ InstructionDesc[OpSubgroupAllKHR].operands.push(OperandId, "'Predicate'");
+
+ InstructionDesc[OpSubgroupAllEqualKHR].capabilities.push_back(CapabilitySubgroupVoteKHR);
+ InstructionDesc[OpSubgroupAllEqualKHR].operands.push(OperandScope, "'Execution'");
+ InstructionDesc[OpSubgroupAllEqualKHR].operands.push(OperandId, "'Predicate'");
+
InstructionDesc[OpSubgroupReadInvocationKHR].capabilities.push_back(CapabilityGroups);
InstructionDesc[OpSubgroupReadInvocationKHR].operands.push(OperandId, "'Value'");
InstructionDesc[OpSubgroupReadInvocationKHR].operands.push(OperandId, "'Index'");
diff --git a/3rdparty/bgfx/3rdparty/glslang/SPIRV/doc.h b/3rdparty/bgfx/3rdparty/glslang/SPIRV/doc.h
index 743896ff4a7..7dcc51dd354 100644
--- a/3rdparty/bgfx/3rdparty/glslang/SPIRV/doc.h
+++ b/3rdparty/bgfx/3rdparty/glslang/SPIRV/doc.h
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2014-2015 LunarG, Inc.
+// Copyright (C) 2014-2015 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
// Parameterize the SPIR-V enumerants.
diff --git a/3rdparty/bgfx/3rdparty/glslang/SPIRV/spirv.hpp b/3rdparty/bgfx/3rdparty/glslang/SPIRV/spirv.hpp
index 088b1af10bb..c7b3d5faadb 100644
--- a/3rdparty/bgfx/3rdparty/glslang/SPIRV/spirv.hpp
+++ b/3rdparty/bgfx/3rdparty/glslang/SPIRV/spirv.hpp
@@ -605,6 +605,7 @@ enum Capability {
CapabilityMultiViewport = 57,
CapabilitySubgroupBallotKHR = 4423,
CapabilityDrawParameters = 4427,
+ CapabilitySubgroupVoteKHR = 4431,
CapabilityMax = 0x7fffffff,
};
@@ -906,6 +907,9 @@ enum Op {
OpSubgroupBallotKHR = 4421,
OpSubgroupFirstInvocationKHR = 4422,
OpSubgroupReadInvocationKHR = 4432,
+ OpSubgroupAllKHR = 4428,
+ OpSubgroupAnyKHR = 4429,
+ OpSubgroupAllEqualKHR = 4430,
OpMax = 0x7fffffff,
};
diff --git a/3rdparty/bgfx/3rdparty/glslang/SPIRV/spvIR.h b/3rdparty/bgfx/3rdparty/glslang/SPIRV/spvIR.h
index c584c9dcb4a..8cfef9e148a 100644
--- a/3rdparty/bgfx/3rdparty/glslang/SPIRV/spvIR.h
+++ b/3rdparty/bgfx/3rdparty/glslang/SPIRV/spvIR.h
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2014 LunarG, Inc.
+// Copyright (C) 2014 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,26 +19,26 @@
// 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.
+// 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.
// SPIRV-IR
//
// Simple in-memory representation (IR) of SPIRV. Just for holding
// Each function's CFG of blocks. Has this hierarchy:
-// - Module, which is a list of
-// - Function, which is a list of
-// - Block, which is a list of
+// - Module, which is a list of
+// - Function, which is a list of
+// - Block, which is a list of
// - Instruction
//
@@ -65,7 +65,7 @@ const Id NoResult = 0;
const Id NoType = 0;
const Decoration NoPrecision = DecorationMax;
-const MemorySemanticsMask MemorySemanticsAllMemory =
+const MemorySemanticsMask MemorySemanticsAllMemory =
(MemorySemanticsMask)(MemorySemanticsSequentiallyConsistentMask |
MemorySemanticsUniformMemoryMask |
MemorySemanticsSubgroupMemoryMask |
@@ -229,7 +229,7 @@ protected:
std::vector<std::unique_ptr<Instruction> > localVariables;
Function& parent;
- // track whether this block is known to be uncreachable (not necessarily
+ // track whether this block is known to be uncreachable (not necessarily
// true for all unreachable blocks, but should be set at least
// for the extraneous ones introduced by the builder).
bool unreachable;
diff --git a/3rdparty/bgfx/3rdparty/glslang/StandAlone/CMakeLists.txt b/3rdparty/bgfx/3rdparty/glslang/StandAlone/CMakeLists.txt
index 231ba277a7b..2a9a3c47e35 100644
--- a/3rdparty/bgfx/3rdparty/glslang/StandAlone/CMakeLists.txt
+++ b/3rdparty/bgfx/3rdparty/glslang/StandAlone/CMakeLists.txt
@@ -20,13 +20,11 @@ glslang_set_link_args(spirv-remap)
set(LIBRARIES
glslang
- OGLCompiler
- OSDependent
- HLSL
SPIRV
SPVRemapper
glslang-default-resource-limits)
+
if(WIN32)
set(LIBRARIES ${LIBRARIES} psapi)
elseif(UNIX)
diff --git a/3rdparty/bgfx/3rdparty/glslang/StandAlone/StandAlone.cpp b/3rdparty/bgfx/3rdparty/glslang/StandAlone/StandAlone.cpp
index d40673c1552..d133b594874 100644
--- a/3rdparty/bgfx/3rdparty/glslang/StandAlone/StandAlone.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/StandAlone/StandAlone.cpp
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2013-2016 LunarG, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2013-2016 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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.
//
// this only applies to the standalone wrapper, not the front end in general
@@ -229,7 +229,7 @@ void ProcessBindingBase(int& argc, char**& argv, std::array<unsigned int, EShLan
if (!isdigit(argv[1][0])) {
if (argc < 3) // this form needs one more argument
usage();
-
+
// Parse form: --argname stage base
const EShLanguage lang = FindLanguage(argv[1], false);
base[lang] = atoi(argv[2]);
@@ -265,7 +265,7 @@ void ProcessArguments(int argc, char* argv[])
Work[w] = 0;
argc--;
- argv++;
+ argv++;
for (; argc >= 1; argc--, argv++) {
if (argv[0][0] == '-') {
switch (argv[0][1]) {
@@ -292,7 +292,7 @@ void ProcessArguments(int argc, char* argv[])
lowerword == "sub") {
ProcessBindingBase(argc, argv, baseUboBinding);
} else if (lowerword == "auto-map-bindings" || // synonyms
- lowerword == "auto-map-binding" ||
+ lowerword == "auto-map-binding" ||
lowerword == "amb") {
Options |= EOptionAutoMapBindings;
} else if (lowerword == "flatten-uniform-arrays" || // synonyms
@@ -575,14 +575,14 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
if (Options & EOptionAutoMapBindings)
shader->setAutoMapBindings(true);
-
+
shaders.push_back(shader);
const int defaultVersion = Options & EOptionDefaultDesktop? 110: 100;
if (Options & EOptionOutputPreprocessed) {
std::string str;
- glslang::TShader::ForbidInclude includer;
+ glslang::TShader::ForbidIncluder includer;
if (shader->preprocess(&Resources, defaultVersion, ENoProfile, false, false,
messages, &str, includer)) {
PutsIfNonEmpty(str.c_str());
@@ -619,7 +619,7 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
if (!program.mapIO())
LinkFailed = true;
}
-
+
// Report
if (! (Options & EOptionSuppressInfolog) &&
! (Options & EOptionMemoryLeakMode)) {
@@ -863,7 +863,7 @@ EShLanguage FindLanguage(const std::string& name, bool parseSuffix)
}
//
-// Read a file's data into a string, and compile it using the old interface ShCompile,
+// Read a file's data into a string, and compile it using the old interface ShCompile,
// for non-linkable results.
//
void CompileFile(const char* fileName, ShHandle compiler)
@@ -887,16 +887,16 @@ void CompileFile(const char* fileName, ShHandle compiler)
EShMessages messages = EShMsgDefault;
SetMessageOptions(messages);
-
+
for (int i = 0; i < ((Options & EOptionMemoryLeakMode) ? 100 : 1); ++i) {
for (int j = 0; j < ((Options & EOptionMemoryLeakMode) ? 100 : 1); ++j) {
- //ret = ShCompile(compiler, shaderStrings, NumShaderStrings, lengths, EShOptNone, &Resources, Options, (Options & EOptionDefaultDesktop) ? 110 : 100, false, messages);
+ // ret = ShCompile(compiler, shaderStrings, NumShaderStrings, lengths, EShOptNone, &Resources, Options, (Options & EOptionDefaultDesktop) ? 110 : 100, false, messages);
ret = ShCompile(compiler, shaderStrings, NumShaderStrings, nullptr, EShOptNone, &Resources, Options, (Options & EOptionDefaultDesktop) ? 110 : 100, false, messages);
- //const char* multi[12] = { "# ve", "rsion", " 300 e", "s", "\n#err",
- // "or should be l", "ine 1", "string 5\n", "float glo", "bal",
+ // const char* multi[12] = { "# ve", "rsion", " 300 e", "s", "\n#err",
+ // "or should be l", "ine 1", "string 5\n", "float glo", "bal",
// ";\n#error should be line 2\n void main() {", "global = 2.3;}" };
- //const char* multi[7] = { "/", "/", "\\", "\n", "\n", "#", "version 300 es" };
- //ret = ShCompile(compiler, multi, 7, nullptr, EShOptNone, &Resources, Options, (Options & EOptionDefaultDesktop) ? 110 : 100, false, messages);
+ // const char* multi[7] = { "/", "/", "\\", "\n", "\n", "#", "version 300 es" };
+ // ret = ShCompile(compiler, multi, 7, nullptr, EShOptNone, &Resources, Options, (Options & EOptionDefaultDesktop) ? 110 : 100, false, messages);
}
if (Options & EOptionMemoryLeakMode)
@@ -1024,7 +1024,7 @@ int fopen_s(
//
// Malloc a string of sufficient size and read a string into it.
//
-char** ReadFileData(const char* fileName)
+char** ReadFileData(const char* fileName)
{
FILE *in = nullptr;
int errorCode = fopen_s(&in, fileName, "r");
@@ -1035,7 +1035,7 @@ char** ReadFileData(const char* fileName)
if (errorCode || in == nullptr)
Error("unable to open input file");
-
+
while (fgetc(in) != EOF)
count++;
@@ -1080,7 +1080,7 @@ char** ReadFileData(const char* fileName)
break;
}
len = count;
- }
+ }
++i;
}
diff --git a/3rdparty/bgfx/3rdparty/glslang/StandAlone/Worklist.h b/3rdparty/bgfx/3rdparty/glslang/StandAlone/Worklist.h
index 57dc0db7b29..2a14294e838 100644
--- a/3rdparty/bgfx/3rdparty/glslang/StandAlone/Worklist.h
+++ b/3rdparty/bgfx/3rdparty/glslang/StandAlone/Worklist.h
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2013 LunarG, Inc.
+// Copyright (C) 2013 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
#ifndef WORKLIST_H_INCLUDED
#define WORKLIST_H_INCLUDED
@@ -59,21 +59,21 @@ namespace glslang {
void add(TWorkItem* item)
{
GetGlobalLock();
-
+
worklist.push_back(item);
-
+
ReleaseGlobalLock();
}
-
+
bool remove(TWorkItem*& item)
{
GetGlobalLock();
-
+
if (worklist.empty())
return false;
item = worklist.front();
worklist.pop_front();
-
+
ReleaseGlobalLock();
return true;
diff --git a/3rdparty/bgfx/3rdparty/glslang/StandAlone/spirv-remap.cpp b/3rdparty/bgfx/3rdparty/glslang/StandAlone/spirv-remap.cpp
index f35b58eda99..998f7428aa5 100644
--- a/3rdparty/bgfx/3rdparty/glslang/StandAlone/spirv-remap.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/StandAlone/spirv-remap.cpp
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2015 LunarG, Inc.
+// Copyright (C) 2015 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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 <iostream>
@@ -143,8 +143,8 @@ namespace {
<< " [--map (all|types|names|funcs)]"
<< " [--dce (all|types|funcs)]"
<< " [--opt (all|loadstore)]"
- << " [--strip-all | --strip all | -s]"
- << " [--do-everything]"
+ << " [--strip-all | --strip all | -s]"
+ << " [--do-everything]"
<< " --input | -i file1 [file2...] --output|-o DESTDIR"
<< std::endl;
@@ -311,7 +311,6 @@ namespace {
} // namespace
-
int main(int argc, char** argv)
{
std::vector<std::string> inputFile;
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/120.frag b/3rdparty/bgfx/3rdparty/glslang/Test/120.frag
index 9035aed7b41..028d308101d 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/120.frag
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/120.frag
@@ -236,3 +236,11 @@ void foo12111()
v = shadow2DRectProjGradARB(s2DRS, v, v2, v2);
}
+
+void voidTernary()
+{
+ bool b;
+ b ? foo121111() : foo12111();
+ b ? foo121111() : 4; // ERROR
+ b ? 3 : foo12111(); // ERROR
+} \ No newline at end of file
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/120.frag.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/120.frag.out
index 79898aafc3b..5028b751404 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/120.frag.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/120.frag.out
@@ -15,11 +15,9 @@ ERROR: 0:63: 'bitwise-or assign' : not supported for this version or the enabled
ERROR: 0:63: 'assign' : cannot convert from 'temp bool' to 'temp float'
ERROR: 0:79: ':' : wrong operand types: no operation ':' exists that takes a left-hand operand of type 'temp 4-component vector of float' and a right operand of type 'temp 4X4 matrix of float' (or there is no acceptable conversion)
ERROR: 0:79: 'assign' : cannot convert from 'temp 4X4 matrix of float' to 'fragColor 4-component vector of float FragColor'
-ERROR: 0:82: 'xr' : illegal - vector component fields not from the same set
-ERROR: 0:83: 'xyxyx' : illegal vector field selection
-ERROR: 0:83: 'scalar swizzle' : not supported for this version or the enabled extensions
-ERROR: 0:83: 'xy' : vector field selection out of range
-ERROR: 0:84: 'z' : vector field selection out of range
+ERROR: 0:82: 'xr' : vector swizzle selectors not from the same set
+ERROR: 0:83: 'xyxyx' : vector swizzle too long
+ERROR: 0:84: 'z' : vector swizzle selection out of range
ERROR: 0:85: 'assign' : l-value required
ERROR: 0:91: 'int' : overloaded functions must have the same return type
ERROR: 0:91: 'main' : function already has a body
@@ -52,6 +50,8 @@ ERROR: 0:191: 'shadow2DProjGradARB' : required extension not requested: GL_ARB_s
ERROR: 0:209: 'shadow2DRectProjGradARB' : no matching overloaded function found
ERROR: 0:209: 'assign' : cannot convert from 'const float' to 'temp 4-component vector of float'
ERROR: 0:212: 'sampler2DRect' : Reserved word.
+ERROR: 0:244: ':' : wrong operand types: no operation ':' exists that takes a left-hand operand of type 'global void' and a right operand of type 'const int' (or there is no acceptable conversion)
+ERROR: 0:245: ':' : wrong operand types: no operation ':' exists that takes a left-hand operand of type 'const int' and a right operand of type 'global void' (or there is no acceptable conversion)
ERROR: 53 compilation errors. No code generated.
@@ -251,10 +251,23 @@ ERROR: node is still EOpNull!
0:82 'gl_FragColor' (fragColor 4-component vector of float FragColor)
0:82 Constant:
0:82 0 (const int)
-0:83 direct index (temp float)
-0:83 'gl_FragColor' (fragColor 4-component vector of float FragColor)
-0:83 Constant:
-0:83 0 (const int)
+0:83 vector swizzle (temp 2-component vector of float)
+0:83 vector swizzle (temp 4-component vector of float)
+0:83 'gl_FragColor' (fragColor 4-component vector of float FragColor)
+0:83 Sequence
+0:83 Constant:
+0:83 0 (const int)
+0:83 Constant:
+0:83 1 (const int)
+0:83 Constant:
+0:83 0 (const int)
+0:83 Constant:
+0:83 1 (const int)
+0:83 Sequence
+0:83 Constant:
+0:83 0 (const int)
+0:83 Constant:
+0:83 1 (const int)
0:84 direct index (temp float)
0:84 'centTexCoord' (centroid smooth in 2-component vector of float)
0:84 Constant:
@@ -590,6 +603,19 @@ ERROR: node is still EOpNull!
0:237 'v' (temp 4-component vector of float)
0:237 'v2' (temp 2-component vector of float)
0:237 'v2' (temp 2-component vector of float)
+0:240 Function Definition: voidTernary( (global void)
+0:240 Function Parameters:
+0:? Sequence
+0:243 Test condition and select (temp void)
+0:243 Condition
+0:243 'b' (temp bool)
+0:243 true case
+0:243 Function Call: foo121111( (global void)
+0:243 false case
+0:243 Function Call: foo12111( (global void)
+0:244 Constant:
+0:244 4 (const int)
+0:245 Function Call: foo12111( (global void)
0:? Linker Objects
0:? 'lowp' (global float)
0:? 'mediump' (global float)
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/310.tesc.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/310.tesc.out
index ab27198f61e..d004fa166c2 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/310.tesc.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/310.tesc.out
@@ -71,8 +71,8 @@ ERROR: node is still EOpNull!
0:25 move second child to first child (temp highp 4-component vector of float)
0:25 'p' (temp highp 4-component vector of float)
0:25 gl_Position: direct index for structure (in highp 4-component vector of float Position)
-0:25 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
-0:25 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
+0:25 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV})
+0:25 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV})
0:25 Constant:
0:25 1 (const int)
0:25 Constant:
@@ -81,8 +81,8 @@ ERROR: node is still EOpNull!
0:26 move second child to first child (temp highp float)
0:26 'ps' (temp highp float)
0:26 gl_PointSize: direct index for structure (in highp float PointSize)
-0:26 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
-0:26 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
+0:26 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV})
+0:26 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV})
0:26 Constant:
0:26 1 (const int)
0:26 Constant:
@@ -210,8 +210,8 @@ ERROR: node is still EOpNull!
0:114 move second child to first child (temp highp float)
0:114 'ps' (temp highp float)
0:114 gl_PointSize: direct index for structure (in highp float PointSize)
-0:114 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
-0:114 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
+0:114 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV})
+0:114 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV})
0:114 Constant:
0:114 1 (const int)
0:114 Constant:
@@ -402,8 +402,8 @@ ERROR: node is still EOpNull!
0:25 move second child to first child (temp highp 4-component vector of float)
0:25 'p' (temp highp 4-component vector of float)
0:25 gl_Position: direct index for structure (in highp 4-component vector of float Position)
-0:25 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
-0:25 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
+0:25 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV})
+0:25 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV})
0:25 Constant:
0:25 1 (const int)
0:25 Constant:
@@ -412,8 +412,8 @@ ERROR: node is still EOpNull!
0:26 move second child to first child (temp highp float)
0:26 'ps' (temp highp float)
0:26 gl_PointSize: direct index for structure (in highp float PointSize)
-0:26 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
-0:26 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
+0:26 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV})
+0:26 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV})
0:26 Constant:
0:26 1 (const int)
0:26 Constant:
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/310.tese.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/310.tese.out
index 62894ec7978..c6ce6650bd3 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/310.tese.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/310.tese.out
@@ -78,8 +78,8 @@ ERROR: node is still EOpNull!
0:36 move second child to first child (temp highp 4-component vector of float)
0:36 'p' (temp highp 4-component vector of float)
0:36 gl_Position: direct index for structure (in highp 4-component vector of float Position)
-0:36 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
-0:36 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
+0:36 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV})
+0:36 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV})
0:36 Constant:
0:36 1 (const int)
0:36 Constant:
@@ -88,8 +88,8 @@ ERROR: node is still EOpNull!
0:37 move second child to first child (temp highp float)
0:37 'ps' (temp highp float)
0:37 gl_PointSize: direct index for structure (in highp float PointSize)
-0:37 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
-0:37 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
+0:37 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV})
+0:37 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV})
0:37 Constant:
0:37 1 (const int)
0:37 Constant:
@@ -211,8 +211,8 @@ ERROR: node is still EOpNull!
0:36 move second child to first child (temp highp 4-component vector of float)
0:36 'p' (temp highp 4-component vector of float)
0:36 gl_Position: direct index for structure (in highp 4-component vector of float Position)
-0:36 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
-0:36 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
+0:36 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV})
+0:36 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV})
0:36 Constant:
0:36 1 (const int)
0:36 Constant:
@@ -221,8 +221,8 @@ ERROR: node is still EOpNull!
0:37 move second child to first child (temp highp float)
0:37 'ps' (temp highp float)
0:37 gl_PointSize: direct index for structure (in highp float PointSize)
-0:37 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
-0:37 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
+0:37 direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV})
+0:37 'gl_in' (in 32-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize, in highp 4-component vector of float gl_SecondaryPositionNV})
0:37 Constant:
0:37 1 (const int)
0:37 Constant:
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/420.vert.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/420.vert.out
index a70b44e7897..b8e1306d787 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/420.vert.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/420.vert.out
@@ -18,9 +18,9 @@ ERROR: 0:40: 'j' : undeclared identifier
ERROR: 0:40: '=' : cannot convert from 'temp float' to 'temp int'
ERROR: 0:44: 'jj' : undeclared identifier
ERROR: 0:44: '=' : cannot convert from 'temp float' to 'temp int'
-ERROR: 0:54: 'y' : vector field selection out of range
-ERROR: 0:62: 'xxxxx' : illegal vector field selection
-ERROR: 0:63: 'xxy' : vector field selection out of range
+ERROR: 0:54: 'y' : vector swizzle selection out of range
+ERROR: 0:62: 'xxxxx' : vector swizzle too long
+ERROR: 0:63: 'xxy' : vector swizzle selection out of range
ERROR: 0:66: 'binding' : cannot declare a default, include a type or full declaration
ERROR: 0:69: 'location/component/index' : cannot declare a default, use a full declaration
ERROR: 0:70: 'input block' : not supported in this stage: vertex
@@ -124,8 +124,10 @@ ERROR: node is still EOpNull!
0:61 'smeared' (temp 3-component vector of float)
0:61 Construct vec3 (temp 3-component vector of float)
0:61 'f' (temp float)
-0:62 'f' (temp float)
-0:63 'f' (temp float)
+0:62 Construct vec4 (temp 4-component vector of float)
+0:62 'f' (temp float)
+0:63 Construct vec2 (temp 2-component vector of float)
+0:63 'f' (temp float)
0:88 Function Definition: bar23444( (global void)
0:88 Function Parameters:
0:? Sequence
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/cppBad2.vert.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/cppBad2.vert.out
new file mode 100644
index 00000000000..0398e5e484c
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/cppBad2.vert.out
@@ -0,0 +1,19 @@
+cppBad2.vert
+ERROR: 0:3: 'macro expansion' : End of input in macro b
+ERROR: 0:3: '' : compilation terminated
+ERROR: 2 compilation errors. No code generated.
+
+
+Shader version: 100
+ERROR: node is still EOpNull!
+0:? Linker Objects
+
+
+Linked vertex stage:
+
+ERROR: Linking vertex stage: Missing entry point: Each stage requires one entry point
+
+Shader version: 100
+ERROR: node is still EOpNull!
+0:? Linker Objects
+
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/cppComplexExpr.vert.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/cppComplexExpr.vert.out
index 352dcac1815..90d62c126d8 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/cppComplexExpr.vert.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/cppComplexExpr.vert.out
@@ -1,6 +1,8 @@
cppComplexExpr.vert
-ERROR: 0:46: 'xyxwx' : illegal vector field selection
-ERROR: 0:46: 'xyxwx' : illegal vector field selection
+ERROR: 0:46: 'xyxwx' : vector swizzle too long
+ERROR: 0:46: 'xyxwx' : vector swizzle too long
+ERROR: 0:46: 'return' : cannot convert return value to function return type
+WARNING: 0:46: 'return' : type conversion on return values was not explicitly allowed until version 420
ERROR: 0:66: '#define' : Macro redefined; different substitutions: BIG
ERROR: 0:81: 'preprocessor evaluation' : bad expression
ERROR: 0:81: '#if' : unexpected tokens following directive
@@ -47,7 +49,7 @@ ERROR: 0:0: 'preprocessor evaluation' : division by 0
ERROR: 0:3: 'preprocessor evaluation' : bad expression
ERROR: 0:3: 'preprocessor evaluation' : division by 0
ERROR: 0:10001: '' : missing #endif
-ERROR: 48 compilation errors. No code generated.
+ERROR: 49 compilation errors. No code generated.
Shader version: 300
@@ -80,19 +82,33 @@ ERROR: node is still EOpNull!
0:44 Function Parameters:
0:46 Sequence
0:46 Branch: Return with expression
-0:46 add (temp highp float)
-0:46 add (temp highp float)
-0:46 direct index (temp highp float)
+0:46 add (temp highp 4-component vector of float)
+0:46 add (temp highp 4-component vector of float)
+0:46 vector swizzle (temp highp 4-component vector of float)
0:46 'gl_Position' (gl_Position highp 4-component vector of float Position)
-0:46 Constant:
-0:46 0 (const int)
+0:46 Sequence
+0:46 Constant:
+0:46 0 (const int)
+0:46 Constant:
+0:46 1 (const int)
+0:46 Constant:
+0:46 0 (const int)
+0:46 Constant:
+0:46 3 (const int)
0:46 Constant:
0:46 3.000000
-0:46 add (temp highp float)
-0:46 direct index (temp highp float)
+0:46 add (temp highp 4-component vector of float)
+0:46 vector swizzle (temp highp 4-component vector of float)
0:46 'gl_Position' (gl_Position highp 4-component vector of float Position)
-0:46 Constant:
-0:46 0 (const int)
+0:46 Sequence
+0:46 Constant:
+0:46 0 (const int)
+0:46 Constant:
+0:46 1 (const int)
+0:46 Constant:
+0:46 0 (const int)
+0:46 Constant:
+0:46 3 (const int)
0:46 Constant:
0:46 3.000000
0:47 Branch: Return with expression
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.basic.comp.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.basic.comp.out
index 9101e22f8e6..b6557efa50c 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.basic.comp.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.basic.comp.out
@@ -2,13 +2,17 @@ hlsl.basic.comp
Shader version: 450
local_size = (1, 1, 1)
0:? Sequence
-0:4 Function Definition: main(i1; (temp void)
+0:4 Function Definition: main(i1;i1; (temp void)
0:4 Function Parameters:
-0:4 'dti' (in int LocalInvocationID)
+0:4 'dti' (in int GlobalInvocationID)
+0:4 'gti' (in int LocalInvocationID)
0:? Sequence
-0:5 'dti' (in int LocalInvocationID)
+0:5 subtract (temp int)
+0:5 'dti' (in int GlobalInvocationID)
+0:5 'gti' (in int LocalInvocationID)
0:? Linker Objects
-0:? 'dti' (in int LocalInvocationID)
+0:? 'dti' (in int GlobalInvocationID)
+0:? 'gti' (in int LocalInvocationID)
0:? 'a' (shared 100-element array of 4-component vector of float)
@@ -18,41 +22,51 @@ Linked compute stage:
Shader version: 450
local_size = (1, 1, 1)
0:? Sequence
-0:4 Function Definition: main(i1; (temp void)
+0:4 Function Definition: main(i1;i1; (temp void)
0:4 Function Parameters:
-0:4 'dti' (in int LocalInvocationID)
+0:4 'dti' (in int GlobalInvocationID)
+0:4 'gti' (in int LocalInvocationID)
0:? Sequence
-0:5 'dti' (in int LocalInvocationID)
+0:5 subtract (temp int)
+0:5 'dti' (in int GlobalInvocationID)
+0:5 'gti' (in int LocalInvocationID)
0:? Linker Objects
-0:? 'dti' (in int LocalInvocationID)
+0:? 'dti' (in int GlobalInvocationID)
+0:? 'gti' (in int LocalInvocationID)
0:? 'a' (shared 100-element array of 4-component vector of float)
// Module Version 10000
// Generated by (magic number): 80001
-// Id's are bound by 16
+// Id's are bound by 20
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
- EntryPoint GLCompute 4 "main" 8
+ EntryPoint GLCompute 4 "main" 8 10
ExecutionMode 4 LocalSize 1 1 1
Name 4 "main"
Name 8 "dti"
- Name 15 "a"
- Decorate 8(dti) BuiltIn LocalInvocationId
+ Name 10 "gti"
+ Name 19 "a"
+ Decorate 8(dti) BuiltIn GlobalInvocationId
+ Decorate 10(gti) BuiltIn LocalInvocationId
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 1
7: TypePointer Input 6(int)
8(dti): 7(ptr) Variable Input
- 9: TypeFloat 32
- 10: TypeVector 9(float) 4
- 11: TypeInt 32 0
- 12: 11(int) Constant 100
- 13: TypeArray 10(fvec4) 12
- 14: TypePointer Workgroup 13
- 15(a): 14(ptr) Variable Workgroup
+ 10(gti): 7(ptr) Variable Input
+ 13: TypeFloat 32
+ 14: TypeVector 13(float) 4
+ 15: TypeInt 32 0
+ 16: 15(int) Constant 100
+ 17: TypeArray 14(fvec4) 16
+ 18: TypePointer Workgroup 17
+ 19(a): 18(ptr) Variable Workgroup
4(main): 2 Function None 3
5: Label
+ 9: 6(int) Load 8(dti)
+ 11: 6(int) Load 10(gti)
+ 12: 6(int) ISub 9 11
Return
FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.basic.geom.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.basic.geom.out
index 2c20b439c14..67477fba58d 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.basic.geom.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.basic.geom.out
@@ -9,7 +9,7 @@ output primitive = line_strip
0:16 Function Parameters:
0:16 'VertexID' (layout(location=0 ) in 3-element array of uint)
0:16 'test' (layout(location=3 ) in 3-element array of uint)
-0:16 'OutputStream' (out structure{temp float myfloat, temp int something})
+0:16 'OutputStream' (layout(location=0 ) out structure{temp float myfloat, temp int something})
0:? Sequence
0:19 move second child to first child (temp float)
0:19 myfloat: direct index for structure (temp float)
@@ -43,20 +43,19 @@ output primitive = line_strip
0:20 0 (const int)
0:22 Sequence
0:22 move second child to first child (temp structure{temp float myfloat, temp int something})
-0:22 'OutputStream' (out structure{temp float myfloat, temp int something})
+0:22 'OutputStream' (layout(location=0 ) out structure{temp float myfloat, temp int something})
0:22 'Vert' (temp structure{temp float myfloat, temp int something})
0:22 EmitVertex (temp void)
0:23 Sequence
0:23 move second child to first child (temp structure{temp float myfloat, temp int something})
-0:23 'OutputStream' (out structure{temp float myfloat, temp int something})
+0:23 'OutputStream' (layout(location=0 ) out structure{temp float myfloat, temp int something})
0:23 'Vert' (temp structure{temp float myfloat, temp int something})
0:23 EmitVertex (temp void)
0:24 EndPrimitive (temp void)
0:? Linker Objects
0:? 'VertexID' (layout(location=0 ) in 3-element array of uint)
0:? 'test' (layout(location=3 ) in 3-element array of uint)
-0:? 'myfloat' (layout(location=0 ) out float)
-0:? 'something' (layout(location=1 ) out int)
+0:? 'OutputStream' (layout(location=0 ) out structure{temp float myfloat, temp int something})
Linked geometry stage:
@@ -72,7 +71,7 @@ output primitive = line_strip
0:16 Function Parameters:
0:16 'VertexID' (layout(location=0 ) in 3-element array of uint)
0:16 'test' (layout(location=3 ) in 3-element array of uint)
-0:16 'OutputStream' (out structure{temp float myfloat, temp int something})
+0:16 'OutputStream' (layout(location=0 ) out structure{temp float myfloat, temp int something})
0:? Sequence
0:19 move second child to first child (temp float)
0:19 myfloat: direct index for structure (temp float)
@@ -106,29 +105,28 @@ output primitive = line_strip
0:20 0 (const int)
0:22 Sequence
0:22 move second child to first child (temp structure{temp float myfloat, temp int something})
-0:22 'OutputStream' (out structure{temp float myfloat, temp int something})
+0:22 'OutputStream' (layout(location=0 ) out structure{temp float myfloat, temp int something})
0:22 'Vert' (temp structure{temp float myfloat, temp int something})
0:22 EmitVertex (temp void)
0:23 Sequence
0:23 move second child to first child (temp structure{temp float myfloat, temp int something})
-0:23 'OutputStream' (out structure{temp float myfloat, temp int something})
+0:23 'OutputStream' (layout(location=0 ) out structure{temp float myfloat, temp int something})
0:23 'Vert' (temp structure{temp float myfloat, temp int something})
0:23 EmitVertex (temp void)
0:24 EndPrimitive (temp void)
0:? Linker Objects
0:? 'VertexID' (layout(location=0 ) in 3-element array of uint)
0:? 'test' (layout(location=3 ) in 3-element array of uint)
-0:? 'myfloat' (layout(location=0 ) out float)
-0:? 'something' (layout(location=1 ) out int)
+0:? 'OutputStream' (layout(location=0 ) out structure{temp float myfloat, temp int something})
// Module Version 10000
// Generated by (magic number): 80001
-// Id's are bound by 45
+// Id's are bound by 41
Capability Geometry
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
- EntryPoint Geometry 4 "main" 16 31 38 42 44
+ EntryPoint Geometry 4 "main" 16 31 38
ExecutionMode 4 Triangles
ExecutionMode 4 Invocations 1
ExecutionMode 4 OutputLineStrip
@@ -141,12 +139,9 @@ output primitive = line_strip
Name 16 "test"
Name 31 "VertexID"
Name 38 "OutputStream"
- Name 42 "myfloat"
- Name 44 "something"
Decorate 16(test) Location 3
Decorate 31(VertexID) Location 0
- Decorate 42(myfloat) Location 0
- Decorate 44(something) Location 1
+ Decorate 38(OutputStream) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@@ -167,10 +162,6 @@ output primitive = line_strip
35: TypePointer Function 7(int)
37: TypePointer Output 8(PSInput)
38(OutputStream): 37(ptr) Variable Output
- 41: TypePointer Output 6(float)
- 42(myfloat): 41(ptr) Variable Output
- 43: TypePointer Output 7(int)
- 44(something): 43(ptr) Variable Output
4(main): 2 Function None 3
5: Label
10(Vert): 9(ptr) Variable Function
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.entry-in.frag.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.entry-in.frag.out
index 04e3935d1fa..9dfbe419414 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.entry-in.frag.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.entry-in.frag.out
@@ -4,27 +4,27 @@ gl_FragCoord origin is upper left
0:? Sequence
0:8 Function Definition: fun(struct-InParam-vf2-vf4-vi21; (temp float)
0:8 Function Parameters:
-0:8 'p' (in structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
+0:8 'p' (temp structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
0:? Sequence
0:9 Branch: Return with expression
0:9 add (temp float)
0:9 direct index (temp float)
0:9 v: direct index for structure (temp 2-component vector of float)
-0:9 'p' (in structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
+0:9 'p' (temp structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
0:9 Constant:
0:9 0 (const int)
0:9 Constant:
0:9 1 (const int)
0:9 direct index (temp float)
-0:9 fragCoord: direct index for structure (temp 4-component vector of float FragCoord)
-0:9 'p' (in structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
+0:9 fragCoord: direct index for structure (temp 4-component vector of float)
+0:9 'p' (temp structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
0:9 Constant:
0:9 1 (const int)
0:9 Constant:
0:9 0 (const int)
0:13 Function Definition: PixelShaderFunction(struct-InParam-vf2-vf4-vi21; (temp 4-component vector of float)
0:13 Function Parameters:
-0:13 'i' (in structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
+0:13 'i' (in structure{temp 2-component vector of float v, temp 4-component vector of float FragCoord fragCoord, temp 2-component vector of int i2})
0:? Sequence
0:15 Sequence
0:15 move second child to first child (temp 2-component vector of float)
@@ -32,19 +32,25 @@ gl_FragCoord origin is upper left
0:15 'local' (temp structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
0:15 Constant:
0:15 0 (const int)
-0:? 'v' (layout(location=0 ) in 2-component vector of float)
+0:15 v: direct index for structure (temp 2-component vector of float)
+0:15 'i' (layout(location=0 ) in structure{temp 2-component vector of float v, temp 2-component vector of int i2})
+0:15 Constant:
+0:15 0 (const int)
0:15 move second child to first child (temp 4-component vector of float)
0:15 fragCoord: direct index for structure (temp 4-component vector of float)
0:15 'local' (temp structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
0:15 Constant:
0:15 1 (const int)
-0:? 'fragCoord' (in 4-component vector of float FragCoord)
+0:? 'i_fragCoord' (in 4-component vector of float FragCoord)
0:15 move second child to first child (temp 2-component vector of int)
0:15 i2: direct index for structure (temp 2-component vector of int)
0:15 'local' (temp structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
0:15 Constant:
0:15 2 (const int)
-0:? 'i2' (layout(location=1 ) in 2-component vector of int)
+0:15 i2: direct index for structure (temp 2-component vector of int)
+0:15 'i' (layout(location=0 ) in structure{temp 2-component vector of float v, temp 2-component vector of int i2})
+0:15 Constant:
+0:15 1 (const int)
0:16 Sequence
0:16 move second child to first child (temp float)
0:16 'ret1' (temp float)
@@ -54,27 +60,33 @@ gl_FragCoord origin is upper left
0:17 move second child to first child (temp float)
0:17 'ret2' (temp float)
0:17 Function Call: fun(struct-InParam-vf2-vf4-vi21; (temp float)
-0:17 Comma (temp structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
+0:17 Comma (temp structure{temp 2-component vector of float v, temp 4-component vector of float FragCoord fragCoord, temp 2-component vector of int i2})
0:17 Sequence
0:17 move second child to first child (temp 2-component vector of float)
0:17 v: direct index for structure (temp 2-component vector of float)
-0:17 'aggShadow' (temp structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
+0:17 'aggShadow' (temp structure{temp 2-component vector of float v, temp 4-component vector of float FragCoord fragCoord, temp 2-component vector of int i2})
+0:17 Constant:
+0:17 0 (const int)
+0:17 v: direct index for structure (temp 2-component vector of float)
+0:17 'i' (layout(location=0 ) in structure{temp 2-component vector of float v, temp 2-component vector of int i2})
0:17 Constant:
0:17 0 (const int)
-0:? 'v' (layout(location=0 ) in 2-component vector of float)
0:17 move second child to first child (temp 4-component vector of float)
-0:17 fragCoord: direct index for structure (temp 4-component vector of float)
-0:17 'aggShadow' (temp structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
+0:17 fragCoord: direct index for structure (temp 4-component vector of float FragCoord)
+0:17 'aggShadow' (temp structure{temp 2-component vector of float v, temp 4-component vector of float FragCoord fragCoord, temp 2-component vector of int i2})
0:17 Constant:
0:17 1 (const int)
-0:? 'fragCoord' (in 4-component vector of float FragCoord)
+0:? 'i_fragCoord' (in 4-component vector of float FragCoord)
0:17 move second child to first child (temp 2-component vector of int)
0:17 i2: direct index for structure (temp 2-component vector of int)
-0:17 'aggShadow' (temp structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
+0:17 'aggShadow' (temp structure{temp 2-component vector of float v, temp 4-component vector of float FragCoord fragCoord, temp 2-component vector of int i2})
0:17 Constant:
0:17 2 (const int)
-0:? 'i2' (layout(location=1 ) in 2-component vector of int)
-0:17 'aggShadow' (temp structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
+0:17 i2: direct index for structure (temp 2-component vector of int)
+0:17 'i' (layout(location=0 ) in structure{temp 2-component vector of float v, temp 2-component vector of int i2})
+0:17 Constant:
+0:17 1 (const int)
+0:17 'aggShadow' (temp structure{temp 2-component vector of float v, temp 4-component vector of float FragCoord fragCoord, temp 2-component vector of int i2})
0:19 Sequence
0:19 move second child to first child (temp 4-component vector of float)
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
@@ -89,9 +101,8 @@ gl_FragCoord origin is upper left
0:19 Branch: Return
0:? Linker Objects
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
-0:? 'v' (layout(location=0 ) in 2-component vector of float)
-0:? 'fragCoord' (in 4-component vector of float FragCoord)
-0:? 'i2' (layout(location=1 ) in 2-component vector of int)
+0:? 'i' (layout(location=0 ) in structure{temp 2-component vector of float v, temp 2-component vector of int i2})
+0:? 'i_fragCoord' (in 4-component vector of float FragCoord)
Linked fragment stage:
@@ -102,27 +113,27 @@ gl_FragCoord origin is upper left
0:? Sequence
0:8 Function Definition: fun(struct-InParam-vf2-vf4-vi21; (temp float)
0:8 Function Parameters:
-0:8 'p' (in structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
+0:8 'p' (temp structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
0:? Sequence
0:9 Branch: Return with expression
0:9 add (temp float)
0:9 direct index (temp float)
0:9 v: direct index for structure (temp 2-component vector of float)
-0:9 'p' (in structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
+0:9 'p' (temp structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
0:9 Constant:
0:9 0 (const int)
0:9 Constant:
0:9 1 (const int)
0:9 direct index (temp float)
-0:9 fragCoord: direct index for structure (temp 4-component vector of float FragCoord)
-0:9 'p' (in structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
+0:9 fragCoord: direct index for structure (temp 4-component vector of float)
+0:9 'p' (temp structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
0:9 Constant:
0:9 1 (const int)
0:9 Constant:
0:9 0 (const int)
0:13 Function Definition: PixelShaderFunction(struct-InParam-vf2-vf4-vi21; (temp 4-component vector of float)
0:13 Function Parameters:
-0:13 'i' (in structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
+0:13 'i' (in structure{temp 2-component vector of float v, temp 4-component vector of float FragCoord fragCoord, temp 2-component vector of int i2})
0:? Sequence
0:15 Sequence
0:15 move second child to first child (temp 2-component vector of float)
@@ -130,19 +141,25 @@ gl_FragCoord origin is upper left
0:15 'local' (temp structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
0:15 Constant:
0:15 0 (const int)
-0:? 'v' (layout(location=0 ) in 2-component vector of float)
+0:15 v: direct index for structure (temp 2-component vector of float)
+0:15 'i' (layout(location=0 ) in structure{temp 2-component vector of float v, temp 2-component vector of int i2})
+0:15 Constant:
+0:15 0 (const int)
0:15 move second child to first child (temp 4-component vector of float)
0:15 fragCoord: direct index for structure (temp 4-component vector of float)
0:15 'local' (temp structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
0:15 Constant:
0:15 1 (const int)
-0:? 'fragCoord' (in 4-component vector of float FragCoord)
+0:? 'i_fragCoord' (in 4-component vector of float FragCoord)
0:15 move second child to first child (temp 2-component vector of int)
0:15 i2: direct index for structure (temp 2-component vector of int)
0:15 'local' (temp structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
0:15 Constant:
0:15 2 (const int)
-0:? 'i2' (layout(location=1 ) in 2-component vector of int)
+0:15 i2: direct index for structure (temp 2-component vector of int)
+0:15 'i' (layout(location=0 ) in structure{temp 2-component vector of float v, temp 2-component vector of int i2})
+0:15 Constant:
+0:15 1 (const int)
0:16 Sequence
0:16 move second child to first child (temp float)
0:16 'ret1' (temp float)
@@ -152,27 +169,33 @@ gl_FragCoord origin is upper left
0:17 move second child to first child (temp float)
0:17 'ret2' (temp float)
0:17 Function Call: fun(struct-InParam-vf2-vf4-vi21; (temp float)
-0:17 Comma (temp structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
+0:17 Comma (temp structure{temp 2-component vector of float v, temp 4-component vector of float FragCoord fragCoord, temp 2-component vector of int i2})
0:17 Sequence
0:17 move second child to first child (temp 2-component vector of float)
0:17 v: direct index for structure (temp 2-component vector of float)
-0:17 'aggShadow' (temp structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
+0:17 'aggShadow' (temp structure{temp 2-component vector of float v, temp 4-component vector of float FragCoord fragCoord, temp 2-component vector of int i2})
+0:17 Constant:
+0:17 0 (const int)
+0:17 v: direct index for structure (temp 2-component vector of float)
+0:17 'i' (layout(location=0 ) in structure{temp 2-component vector of float v, temp 2-component vector of int i2})
0:17 Constant:
0:17 0 (const int)
-0:? 'v' (layout(location=0 ) in 2-component vector of float)
0:17 move second child to first child (temp 4-component vector of float)
-0:17 fragCoord: direct index for structure (temp 4-component vector of float)
-0:17 'aggShadow' (temp structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
+0:17 fragCoord: direct index for structure (temp 4-component vector of float FragCoord)
+0:17 'aggShadow' (temp structure{temp 2-component vector of float v, temp 4-component vector of float FragCoord fragCoord, temp 2-component vector of int i2})
0:17 Constant:
0:17 1 (const int)
-0:? 'fragCoord' (in 4-component vector of float FragCoord)
+0:? 'i_fragCoord' (in 4-component vector of float FragCoord)
0:17 move second child to first child (temp 2-component vector of int)
0:17 i2: direct index for structure (temp 2-component vector of int)
-0:17 'aggShadow' (temp structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
+0:17 'aggShadow' (temp structure{temp 2-component vector of float v, temp 4-component vector of float FragCoord fragCoord, temp 2-component vector of int i2})
0:17 Constant:
0:17 2 (const int)
-0:? 'i2' (layout(location=1 ) in 2-component vector of int)
-0:17 'aggShadow' (temp structure{temp 2-component vector of float v, temp 4-component vector of float fragCoord, temp 2-component vector of int i2})
+0:17 i2: direct index for structure (temp 2-component vector of int)
+0:17 'i' (layout(location=0 ) in structure{temp 2-component vector of float v, temp 2-component vector of int i2})
+0:17 Constant:
+0:17 1 (const int)
+0:17 'aggShadow' (temp structure{temp 2-component vector of float v, temp 4-component vector of float FragCoord fragCoord, temp 2-component vector of int i2})
0:19 Sequence
0:19 move second child to first child (temp 4-component vector of float)
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
@@ -187,18 +210,17 @@ gl_FragCoord origin is upper left
0:19 Branch: Return
0:? Linker Objects
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
-0:? 'v' (layout(location=0 ) in 2-component vector of float)
-0:? 'fragCoord' (in 4-component vector of float FragCoord)
-0:? 'i2' (layout(location=1 ) in 2-component vector of int)
+0:? 'i' (layout(location=0 ) in structure{temp 2-component vector of float v, temp 2-component vector of int i2})
+0:? 'i_fragCoord' (in 4-component vector of float FragCoord)
// Module Version 10000
// Generated by (magic number): 80001
-// Id's are bound by 71
+// Id's are bound by 78
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
- EntryPoint Fragment 4 "PixelShaderFunction" 32 37 43 63
+ EntryPoint Fragment 4 "PixelShaderFunction" 33 40 70
ExecutionMode 4 OriginUpperLeft
Name 4 "PixelShaderFunction"
Name 11 "InParam"
@@ -208,19 +230,25 @@ gl_FragCoord origin is upper left
Name 15 "fun(struct-InParam-vf2-vf4-vi21;"
Name 14 "p"
Name 30 "local"
- Name 32 "v"
- Name 37 "fragCoord"
- Name 43 "i2"
- Name 47 "ret1"
- Name 48 "param"
- Name 51 "ret2"
- Name 52 "aggShadow"
- Name 59 "param"
- Name 63 "@entryPointOutput"
- Decorate 32(v) Location 0
- Decorate 37(fragCoord) BuiltIn FragCoord
- Decorate 43(i2) Location 1
- Decorate 63(@entryPointOutput) Location 0
+ Name 31 "InParam"
+ MemberName 31(InParam) 0 "v"
+ MemberName 31(InParam) 1 "i2"
+ Name 33 "i"
+ Name 40 "i_fragCoord"
+ Name 50 "ret1"
+ Name 51 "param"
+ Name 54 "ret2"
+ Name 55 "InParam"
+ MemberName 55(InParam) 0 "v"
+ MemberName 55(InParam) 1 "fragCoord"
+ MemberName 55(InParam) 2 "i2"
+ Name 57 "aggShadow"
+ Name 66 "param"
+ Name 70 "@entryPointOutput"
+ Decorate 33(i) Location 0
+ Decorate 40(i_fragCoord) BuiltIn FragCoord
+ MemberDecorate 55(InParam) 1 BuiltIn FragCoord
+ Decorate 70(@entryPointOutput) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@@ -237,59 +265,66 @@ gl_FragCoord origin is upper left
20: TypePointer Function 6(float)
23: 9(int) Constant 1
24: 18(int) Constant 0
- 31: TypePointer Input 7(fvec2)
- 32(v): 31(ptr) Variable Input
- 34: TypePointer Function 7(fvec2)
- 36: TypePointer Input 8(fvec4)
- 37(fragCoord): 36(ptr) Variable Input
- 39: TypePointer Function 8(fvec4)
- 41: 9(int) Constant 2
- 42: TypePointer Input 10(ivec2)
- 43(i2): 42(ptr) Variable Input
- 45: TypePointer Function 10(ivec2)
- 62: TypePointer Output 8(fvec4)
-63(@entryPointOutput): 62(ptr) Variable Output
+ 31(InParam): TypeStruct 7(fvec2) 10(ivec2)
+ 32: TypePointer Input 31(InParam)
+ 33(i): 32(ptr) Variable Input
+ 34: TypePointer Input 7(fvec2)
+ 37: TypePointer Function 7(fvec2)
+ 39: TypePointer Input 8(fvec4)
+ 40(i_fragCoord): 39(ptr) Variable Input
+ 42: TypePointer Function 8(fvec4)
+ 44: 9(int) Constant 2
+ 45: TypePointer Input 10(ivec2)
+ 48: TypePointer Function 10(ivec2)
+ 55(InParam): TypeStruct 7(fvec2) 8(fvec4) 10(ivec2)
+ 56: TypePointer Function 55(InParam)
+ 69: TypePointer Output 8(fvec4)
+70(@entryPointOutput): 69(ptr) Variable Output
4(PixelShaderFunction): 2 Function None 3
5: Label
30(local): 12(ptr) Variable Function
- 47(ret1): 20(ptr) Variable Function
- 48(param): 12(ptr) Variable Function
- 51(ret2): 20(ptr) Variable Function
- 52(aggShadow): 12(ptr) Variable Function
- 59(param): 12(ptr) Variable Function
- 33: 7(fvec2) Load 32(v)
- 35: 34(ptr) AccessChain 30(local) 17
- Store 35 33
- 38: 8(fvec4) Load 37(fragCoord)
- 40: 39(ptr) AccessChain 30(local) 23
- Store 40 38
- 44: 10(ivec2) Load 43(i2)
- 46: 45(ptr) AccessChain 30(local) 41
- Store 46 44
- 49: 11(InParam) Load 30(local)
- Store 48(param) 49
- 50: 6(float) FunctionCall 15(fun(struct-InParam-vf2-vf4-vi21;) 48(param)
- Store 47(ret1) 50
- 53: 7(fvec2) Load 32(v)
- 54: 34(ptr) AccessChain 52(aggShadow) 17
- Store 54 53
- 55: 8(fvec4) Load 37(fragCoord)
- 56: 39(ptr) AccessChain 52(aggShadow) 23
- Store 56 55
- 57: 10(ivec2) Load 43(i2)
- 58: 45(ptr) AccessChain 52(aggShadow) 41
- Store 58 57
- 60: 11(InParam) Load 52(aggShadow)
- Store 59(param) 60
- 61: 6(float) FunctionCall 15(fun(struct-InParam-vf2-vf4-vi21;) 59(param)
- Store 51(ret2) 61
- 64: 39(ptr) AccessChain 30(local) 23
- 65: 8(fvec4) Load 64
- 66: 6(float) Load 47(ret1)
- 67: 8(fvec4) VectorTimesScalar 65 66
- 68: 6(float) Load 51(ret2)
- 69: 8(fvec4) VectorTimesScalar 67 68
- Store 63(@entryPointOutput) 69
+ 50(ret1): 20(ptr) Variable Function
+ 51(param): 12(ptr) Variable Function
+ 54(ret2): 20(ptr) Variable Function
+ 57(aggShadow): 56(ptr) Variable Function
+ 66(param): 56(ptr) Variable Function
+ 35: 34(ptr) AccessChain 33(i) 17
+ 36: 7(fvec2) Load 35
+ 38: 37(ptr) AccessChain 30(local) 17
+ Store 38 36
+ 41: 8(fvec4) Load 40(i_fragCoord)
+ 43: 42(ptr) AccessChain 30(local) 23
+ Store 43 41
+ 46: 45(ptr) AccessChain 33(i) 23
+ 47: 10(ivec2) Load 46
+ 49: 48(ptr) AccessChain 30(local) 44
+ Store 49 47
+ 52: 11(InParam) Load 30(local)
+ Store 51(param) 52
+ 53: 6(float) FunctionCall 15(fun(struct-InParam-vf2-vf4-vi21;) 51(param)
+ Store 50(ret1) 53
+ 58: 34(ptr) AccessChain 33(i) 17
+ 59: 7(fvec2) Load 58
+ 60: 37(ptr) AccessChain 57(aggShadow) 17
+ Store 60 59
+ 61: 8(fvec4) Load 40(i_fragCoord)
+ 62: 42(ptr) AccessChain 57(aggShadow) 23
+ Store 62 61
+ 63: 45(ptr) AccessChain 33(i) 23
+ 64: 10(ivec2) Load 63
+ 65: 48(ptr) AccessChain 57(aggShadow) 44
+ Store 65 64
+ 67: 55(InParam) Load 57(aggShadow)
+ Store 66(param) 67
+ 68: 6(float) FunctionCall 15(fun(struct-InParam-vf2-vf4-vi21;) 66(param)
+ Store 54(ret2) 68
+ 71: 42(ptr) AccessChain 30(local) 23
+ 72: 8(fvec4) Load 71
+ 73: 6(float) Load 50(ret1)
+ 74: 8(fvec4) VectorTimesScalar 72 73
+ 75: 6(float) Load 54(ret2)
+ 76: 8(fvec4) VectorTimesScalar 74 75
+ Store 70(@entryPointOutput) 76
Return
FunctionEnd
15(fun(struct-InParam-vf2-vf4-vi21;): 6(float) Function None 13
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.gather.basic.dx10.vert.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.gather.basic.dx10.vert.out
index a8936753d30..bea5142b3f2 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.gather.basic.dx10.vert.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.gather.basic.dx10.vert.out
@@ -1,7 +1,7 @@
hlsl.gather.basic.dx10.vert
Shader version: 450
0:? Sequence
-0:28 Function Definition: main( (temp structure{temp 4-component vector of float Pos})
+0:28 Function Definition: main( (temp structure{temp 4-component vector of float Position Pos})
0:28 Function Parameters:
0:? Sequence
0:33 Sequence
@@ -87,7 +87,6 @@ Shader version: 450
0:45 0 (const int)
0:45 Branch: Return
0:? Linker Objects
-0:? 'Pos' (out 4-component vector of float Position)
0:? 'g_sSamp' (layout(binding=0 ) uniform sampler)
0:? 'g_sSamp2d' (uniform sampler)
0:? 'g_tTex1df4a' (layout(binding=1 ) uniform texture1D)
@@ -103,6 +102,7 @@ Shader version: 450
0:? 'g_tTexcdf4' (uniform textureCube)
0:? 'g_tTexcdi4' (uniform itextureCube)
0:? 'g_tTexcdu4' (uniform utextureCube)
+0:? 'PerVertex_out' (out block{out 4-component vector of float Position Pos})
Linked vertex stage:
@@ -110,7 +110,7 @@ Linked vertex stage:
Shader version: 450
0:? Sequence
-0:28 Function Definition: main( (temp structure{temp 4-component vector of float Pos})
+0:28 Function Definition: main( (temp structure{temp 4-component vector of float Position Pos})
0:28 Function Parameters:
0:? Sequence
0:33 Sequence
@@ -196,7 +196,6 @@ Shader version: 450
0:45 0 (const int)
0:45 Branch: Return
0:? Linker Objects
-0:? 'Pos' (out 4-component vector of float Position)
0:? 'g_sSamp' (layout(binding=0 ) uniform sampler)
0:? 'g_sSamp2d' (uniform sampler)
0:? 'g_tTex1df4a' (layout(binding=1 ) uniform texture1D)
@@ -212,16 +211,17 @@ Shader version: 450
0:? 'g_tTexcdf4' (uniform textureCube)
0:? 'g_tTexcdi4' (uniform itextureCube)
0:? 'g_tTexcdu4' (uniform utextureCube)
+0:? 'PerVertex_out' (out block{out 4-component vector of float Position Pos})
// Module Version 10000
// Generated by (magic number): 80001
-// Id's are bound by 121
+// Id's are bound by 124
Capability Shader
Capability Sampled1D
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
- EntryPoint Vertex 4 "main" 97
+ EntryPoint Vertex 4 "main" 97 123
Name 4 "main"
Name 9 "txval20"
Name 12 "g_tTex2df4"
@@ -248,6 +248,9 @@ Shader version: 450
Name 114 "g_tTex3df4"
Name 117 "g_tTex3di4"
Name 120 "g_tTex3du4"
+ Name 121 "PerVertex_out"
+ MemberName 121(PerVertex_out) 0 "Pos"
+ Name 123 "PerVertex_out"
Decorate 12(g_tTex2df4) DescriptorSet 0
Decorate 16(g_sSamp) DescriptorSet 0
Decorate 16(g_sSamp) Binding 0
@@ -267,6 +270,8 @@ Shader version: 450
Decorate 114(g_tTex3df4) DescriptorSet 0
Decorate 117(g_tTex3di4) DescriptorSet 0
Decorate 120(g_tTex3du4) DescriptorSet 0
+ MemberDecorate 121(PerVertex_out) 0 BuiltIn Position
+ Decorate 121(PerVertex_out) Block
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@@ -349,6 +354,9 @@ Shader version: 450
118: TypeImage 41(int) 3D sampled format:Unknown
119: TypePointer UniformConstant 118
120(g_tTex3du4): 119(ptr) Variable UniformConstant
+121(PerVertex_out): TypeStruct 7(fvec4)
+ 122: TypePointer Output 121(PerVertex_out)
+123(PerVertex_out): 122(ptr) Variable Output
4(main): 2 Function None 3
5: Label
9(txval20): 8(ptr) Variable Function
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.getdimensions.dx10.vert.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.getdimensions.dx10.vert.out
index c1c90f4b257..85a25af4df8 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.getdimensions.dx10.vert.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.getdimensions.dx10.vert.out
@@ -1,7 +1,7 @@
hlsl.getdimensions.dx10.vert
Shader version: 450
0:? Sequence
-0:11 Function Definition: main( (temp structure{temp 4-component vector of float Pos})
+0:11 Function Definition: main( (temp structure{temp 4-component vector of float Position Pos})
0:11 Function Parameters:
0:? Sequence
0:21 Sequence
@@ -46,9 +46,9 @@ Shader version: 450
0:26 0 (const int)
0:26 Branch: Return
0:? Linker Objects
-0:? 'Pos' (out 4-component vector of float Position)
0:? 'g_sSamp' (layout(binding=0 ) uniform sampler)
0:? 'g_tTex1df4' (layout(binding=0 ) uniform texture1D)
+0:? 'PerVertex_out' (out block{out 4-component vector of float Position Pos})
Linked vertex stage:
@@ -56,7 +56,7 @@ Linked vertex stage:
Shader version: 450
0:? Sequence
-0:11 Function Definition: main( (temp structure{temp 4-component vector of float Pos})
+0:11 Function Definition: main( (temp structure{temp 4-component vector of float Position Pos})
0:11 Function Parameters:
0:? Sequence
0:21 Sequence
@@ -101,20 +101,20 @@ Shader version: 450
0:26 0 (const int)
0:26 Branch: Return
0:? Linker Objects
-0:? 'Pos' (out 4-component vector of float Position)
0:? 'g_sSamp' (layout(binding=0 ) uniform sampler)
0:? 'g_tTex1df4' (layout(binding=0 ) uniform texture1D)
+0:? 'PerVertex_out' (out block{out 4-component vector of float Position Pos})
// Module Version 10000
// Generated by (magic number): 80001
-// Id's are bound by 43
+// Id's are bound by 46
Capability Shader
Capability Sampled1D
Capability ImageQuery
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
- EntryPoint Vertex 4 "main" 36
+ EntryPoint Vertex 4 "main" 36 45
Name 4 "main"
Name 8 "sizeQueryTemp"
Name 12 "g_tTex1df4"
@@ -126,11 +126,16 @@ Shader version: 450
Name 29 "vsout"
Name 36 "Pos"
Name 42 "g_sSamp"
+ Name 43 "PerVertex_out"
+ MemberName 43(PerVertex_out) 0 "Pos"
+ Name 45 "PerVertex_out"
Decorate 12(g_tTex1df4) DescriptorSet 0
Decorate 12(g_tTex1df4) Binding 0
Decorate 36(Pos) BuiltIn Position
Decorate 42(g_sSamp) DescriptorSet 0
Decorate 42(g_sSamp) Binding 0
+ MemberDecorate 43(PerVertex_out) 0 BuiltIn Position
+ Decorate 43(PerVertex_out) Block
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
@@ -153,6 +158,9 @@ Shader version: 450
40: TypeSampler
41: TypePointer UniformConstant 40
42(g_sSamp): 41(ptr) Variable UniformConstant
+43(PerVertex_out): TypeStruct 26(fvec4)
+ 44: TypePointer Output 43(PerVertex_out)
+45(PerVertex_out): 44(ptr) Variable Output
4(main): 2 Function None 3
5: Label
8(sizeQueryTemp): 7(ptr) Variable Function
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.init.frag.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.init.frag.out
index 42f94caefa9..c7e5e23fcd9 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.init.frag.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.init.frag.out
@@ -1,4 +1,7 @@
hlsl.init.frag
+WARNING: 0:40: 'typedef' : struct-member initializers ignored
+WARNING: 0:40: 'typedef' : struct-member initializers ignored
+
Shader version: 450
gl_FragCoord origin is upper left
0:? Sequence
@@ -152,6 +155,7 @@ gl_FragCoord origin is upper left
0:? 'single2' (global structure{temp 2-component vector of uint v})
0:? 'single3' (global structure{temp structure{temp int f} s1})
0:? 'single4' (global structure{temp structure{temp 2-component vector of uint v} s1})
+0:? 'anon@0' (layout(row_major std140 ) uniform block{layout(row_major std140 ) uniform float a, layout(row_major std140 ) uniform float b, layout(row_major std140 ) uniform float c})
Linked fragment stage:
@@ -310,10 +314,11 @@ gl_FragCoord origin is upper left
0:? 'single2' (global structure{temp 2-component vector of uint v})
0:? 'single3' (global structure{temp structure{temp int f} s1})
0:? 'single4' (global structure{temp structure{temp 2-component vector of uint v} s1})
+0:? 'anon@0' (layout(row_major std140 ) uniform block{layout(row_major std140 ) uniform float a, layout(row_major std140 ) uniform float b, layout(row_major std140 ) uniform float c})
// Module Version 10000
// Generated by (magic number): 80001
-// Id's are bound by 97
+// Id's are bound by 100
Capability Shader
1: ExtInstImport "GLSL.std.450"
@@ -361,8 +366,18 @@ gl_FragCoord origin is upper left
Name 90 "input"
Name 95 "c4"
Name 96 "b5"
+ Name 97 "Constants"
+ MemberName 97(Constants) 0 "a"
+ MemberName 97(Constants) 1 "b"
+ MemberName 97(Constants) 2 "c"
+ Name 99 ""
Decorate 88(@entryPointOutput) Location 0
Decorate 90(input) Location 0
+ MemberDecorate 97(Constants) 0 Offset 0
+ MemberDecorate 97(Constants) 1 Offset 4
+ MemberDecorate 97(Constants) 2 Offset 8
+ Decorate 97(Constants) Block
+ Decorate 99 DescriptorSet 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@@ -437,6 +452,9 @@ gl_FragCoord origin is upper left
90(input): 89(ptr) Variable Input
95(c4): 22(ptr) Variable Private
96(b5): 22(ptr) Variable Private
+ 97(Constants): TypeStruct 6(float) 6(float) 6(float)
+ 98: TypePointer Uniform 97(Constants)
+ 99: 98(ptr) Variable Uniform
4(ShaderFunction): 2 Function None 3
5: Label
62(a2): 61(ptr) Variable Function
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.init2.frag.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.init2.frag.out
index 9b53e30499c..d8d2d371f9a 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.init2.frag.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.init2.frag.out
@@ -29,29 +29,147 @@ gl_FragCoord origin is upper left
0:20 8.000000
0:20 9.000000
0:20 10.000000
-0:26 Function Definition: main( (temp structure{temp 4-component vector of float color})
-0:26 Function Parameters:
+0:22 Constant:
+0:22 10.000000
+0:25 Sequence
+0:25 move second child to first child (temp float)
+0:25 'n' (temp float)
+0:25 Constant:
+0:25 0.000000
+0:26 Sequence
+0:26 move second child to first child (temp 8-element array of 3-component vector of float)
+0:26 'a' (const (read only) 8-element array of 3-component vector of float)
+0:26 Construct vec3 (temp 8-element array of 3-component vector of float)
+0:27 vector-scale (temp 3-component vector of float)
+0:? Constant:
+0:? 0.577350
+0:? 0.577350
+0:? 0.577350
+0:27 add second child into first child (temp float)
+0:27 'n' (temp float)
+0:27 Constant:
+0:27 1.000000
+0:28 vector-scale (temp 3-component vector of float)
+0:? Constant:
+0:? -0.577350
+0:? -0.577350
+0:? -0.577350
+0:28 add second child into first child (temp float)
+0:28 'n' (temp float)
+0:28 Constant:
+0:28 1.000000
+0:29 vector-scale (temp 3-component vector of float)
+0:? Constant:
+0:? -0.577350
+0:? -0.577350
+0:? 0.577350
+0:29 add second child into first child (temp float)
+0:29 'n' (temp float)
+0:29 Constant:
+0:29 1.000000
+0:30 vector-scale (temp 3-component vector of float)
+0:? Constant:
+0:? -0.577350
+0:? 0.577350
+0:? -0.577350
+0:30 add second child into first child (temp float)
+0:30 'n' (temp float)
+0:30 Constant:
+0:30 1.000000
+0:31 vector-scale (temp 3-component vector of float)
+0:? Constant:
+0:? -0.577350
+0:? 0.577350
+0:? 0.577350
+0:31 add second child into first child (temp float)
+0:31 'n' (temp float)
+0:31 Constant:
+0:31 1.000000
+0:32 vector-scale (temp 3-component vector of float)
+0:? Constant:
+0:? 0.577350
+0:? -0.577350
+0:? -0.577350
+0:32 add second child into first child (temp float)
+0:32 'n' (temp float)
+0:32 Constant:
+0:32 1.000000
+0:33 vector-scale (temp 3-component vector of float)
+0:? Constant:
+0:? 0.577350
+0:? -0.577350
+0:? 0.577350
+0:33 add second child into first child (temp float)
+0:33 'n' (temp float)
+0:33 Constant:
+0:33 1.000000
+0:34 vector-scale (temp 3-component vector of float)
+0:? Constant:
+0:? 0.577350
+0:? 0.577350
+0:? -0.577350
+0:34 add second child into first child (temp float)
+0:34 'n' (temp float)
+0:34 Constant:
+0:34 1.000000
+0:36 Sequence
+0:36 move second child to first child (temp structure{temp 3-component vector of float a})
+0:36 'oneNonConst' (const (read only) structure{temp 3-component vector of float a})
+0:36 Construct structure (temp structure{temp 3-component vector of float a})
+0:36 vector-scale (temp 3-component vector of float)
+0:? Constant:
+0:? -0.577350
+0:? 0.577350
+0:? 0.577350
+0:36 add second child into first child (temp float)
+0:36 'n' (temp float)
+0:36 Constant:
+0:36 1.000000
+0:38 Sequence
+0:38 move second child to first child (temp structure{temp 3-component vector of float a, temp 3-component vector of float b})
+0:38 'twoNonConst' (const (read only) structure{temp 3-component vector of float a, temp 3-component vector of float b})
+0:38 Construct structure (temp structure{temp 3-component vector of float a, temp 3-component vector of float b})
+0:38 vector-scale (temp 3-component vector of float)
+0:? Constant:
+0:? -0.577350
+0:? 0.577350
+0:? 0.577350
+0:38 add second child into first child (temp float)
+0:38 'n' (temp float)
+0:38 Constant:
+0:38 1.000000
+0:39 vector-scale (temp 3-component vector of float)
+0:? Constant:
+0:? -0.577350
+0:? 0.577350
+0:? 0.577350
+0:39 add second child into first child (temp float)
+0:39 'n' (temp float)
+0:39 Constant:
+0:39 1.000000
+0:45 Function Definition: main( (temp structure{temp 4-component vector of float color})
+0:45 Function Parameters:
0:? Sequence
-0:27 Function Call: Test1( (temp void)
-0:30 move second child to first child (temp 4-component vector of float)
-0:30 color: direct index for structure (temp 4-component vector of float)
-0:30 'ps_output' (temp structure{temp 4-component vector of float color})
-0:30 Constant:
-0:30 0 (const int)
-0:30 Constant:
-0:30 1.000000
-0:30 1.000000
-0:30 1.000000
-0:30 1.000000
-0:31 Sequence
-0:31 Sequence
-0:31 move second child to first child (temp 4-component vector of float)
+0:46 Function Call: Test1( (temp void)
+0:49 move second child to first child (temp 4-component vector of float)
+0:49 color: direct index for structure (temp 4-component vector of float)
+0:49 'ps_output' (temp structure{temp 4-component vector of float color})
+0:49 Constant:
+0:49 0 (const int)
+0:49 Constant:
+0:49 1.000000
+0:49 1.000000
+0:49 1.000000
+0:49 1.000000
+0:50 Sequence
+0:50 Sequence
+0:50 move second child to first child (temp 4-component vector of float)
0:? 'color' (layout(location=0 ) out 4-component vector of float)
-0:31 color: direct index for structure (temp 4-component vector of float)
-0:31 'ps_output' (temp structure{temp 4-component vector of float color})
-0:31 Constant:
-0:31 0 (const int)
-0:31 Branch: Return
+0:50 color: direct index for structure (temp 4-component vector of float)
+0:50 'ps_output' (temp structure{temp 4-component vector of float color})
+0:50 Constant:
+0:50 0 (const int)
+0:50 Branch: Return
0:? Linker Objects
0:? 'color' (layout(location=0 ) out 4-component vector of float)
@@ -89,40 +207,158 @@ gl_FragCoord origin is upper left
0:20 8.000000
0:20 9.000000
0:20 10.000000
-0:26 Function Definition: main( (temp structure{temp 4-component vector of float color})
-0:26 Function Parameters:
+0:22 Constant:
+0:22 10.000000
+0:25 Sequence
+0:25 move second child to first child (temp float)
+0:25 'n' (temp float)
+0:25 Constant:
+0:25 0.000000
+0:26 Sequence
+0:26 move second child to first child (temp 8-element array of 3-component vector of float)
+0:26 'a' (const (read only) 8-element array of 3-component vector of float)
+0:26 Construct vec3 (temp 8-element array of 3-component vector of float)
+0:27 vector-scale (temp 3-component vector of float)
+0:? Constant:
+0:? 0.577350
+0:? 0.577350
+0:? 0.577350
+0:27 add second child into first child (temp float)
+0:27 'n' (temp float)
+0:27 Constant:
+0:27 1.000000
+0:28 vector-scale (temp 3-component vector of float)
+0:? Constant:
+0:? -0.577350
+0:? -0.577350
+0:? -0.577350
+0:28 add second child into first child (temp float)
+0:28 'n' (temp float)
+0:28 Constant:
+0:28 1.000000
+0:29 vector-scale (temp 3-component vector of float)
+0:? Constant:
+0:? -0.577350
+0:? -0.577350
+0:? 0.577350
+0:29 add second child into first child (temp float)
+0:29 'n' (temp float)
+0:29 Constant:
+0:29 1.000000
+0:30 vector-scale (temp 3-component vector of float)
+0:? Constant:
+0:? -0.577350
+0:? 0.577350
+0:? -0.577350
+0:30 add second child into first child (temp float)
+0:30 'n' (temp float)
+0:30 Constant:
+0:30 1.000000
+0:31 vector-scale (temp 3-component vector of float)
+0:? Constant:
+0:? -0.577350
+0:? 0.577350
+0:? 0.577350
+0:31 add second child into first child (temp float)
+0:31 'n' (temp float)
+0:31 Constant:
+0:31 1.000000
+0:32 vector-scale (temp 3-component vector of float)
+0:? Constant:
+0:? 0.577350
+0:? -0.577350
+0:? -0.577350
+0:32 add second child into first child (temp float)
+0:32 'n' (temp float)
+0:32 Constant:
+0:32 1.000000
+0:33 vector-scale (temp 3-component vector of float)
+0:? Constant:
+0:? 0.577350
+0:? -0.577350
+0:? 0.577350
+0:33 add second child into first child (temp float)
+0:33 'n' (temp float)
+0:33 Constant:
+0:33 1.000000
+0:34 vector-scale (temp 3-component vector of float)
+0:? Constant:
+0:? 0.577350
+0:? 0.577350
+0:? -0.577350
+0:34 add second child into first child (temp float)
+0:34 'n' (temp float)
+0:34 Constant:
+0:34 1.000000
+0:36 Sequence
+0:36 move second child to first child (temp structure{temp 3-component vector of float a})
+0:36 'oneNonConst' (const (read only) structure{temp 3-component vector of float a})
+0:36 Construct structure (temp structure{temp 3-component vector of float a})
+0:36 vector-scale (temp 3-component vector of float)
+0:? Constant:
+0:? -0.577350
+0:? 0.577350
+0:? 0.577350
+0:36 add second child into first child (temp float)
+0:36 'n' (temp float)
+0:36 Constant:
+0:36 1.000000
+0:38 Sequence
+0:38 move second child to first child (temp structure{temp 3-component vector of float a, temp 3-component vector of float b})
+0:38 'twoNonConst' (const (read only) structure{temp 3-component vector of float a, temp 3-component vector of float b})
+0:38 Construct structure (temp structure{temp 3-component vector of float a, temp 3-component vector of float b})
+0:38 vector-scale (temp 3-component vector of float)
+0:? Constant:
+0:? -0.577350
+0:? 0.577350
+0:? 0.577350
+0:38 add second child into first child (temp float)
+0:38 'n' (temp float)
+0:38 Constant:
+0:38 1.000000
+0:39 vector-scale (temp 3-component vector of float)
+0:? Constant:
+0:? -0.577350
+0:? 0.577350
+0:? 0.577350
+0:39 add second child into first child (temp float)
+0:39 'n' (temp float)
+0:39 Constant:
+0:39 1.000000
+0:45 Function Definition: main( (temp structure{temp 4-component vector of float color})
+0:45 Function Parameters:
0:? Sequence
-0:27 Function Call: Test1( (temp void)
-0:30 move second child to first child (temp 4-component vector of float)
-0:30 color: direct index for structure (temp 4-component vector of float)
-0:30 'ps_output' (temp structure{temp 4-component vector of float color})
-0:30 Constant:
-0:30 0 (const int)
-0:30 Constant:
-0:30 1.000000
-0:30 1.000000
-0:30 1.000000
-0:30 1.000000
-0:31 Sequence
-0:31 Sequence
-0:31 move second child to first child (temp 4-component vector of float)
+0:46 Function Call: Test1( (temp void)
+0:49 move second child to first child (temp 4-component vector of float)
+0:49 color: direct index for structure (temp 4-component vector of float)
+0:49 'ps_output' (temp structure{temp 4-component vector of float color})
+0:49 Constant:
+0:49 0 (const int)
+0:49 Constant:
+0:49 1.000000
+0:49 1.000000
+0:49 1.000000
+0:49 1.000000
+0:50 Sequence
+0:50 Sequence
+0:50 move second child to first child (temp 4-component vector of float)
0:? 'color' (layout(location=0 ) out 4-component vector of float)
-0:31 color: direct index for structure (temp 4-component vector of float)
-0:31 'ps_output' (temp structure{temp 4-component vector of float color})
-0:31 Constant:
-0:31 0 (const int)
-0:31 Branch: Return
+0:50 color: direct index for structure (temp 4-component vector of float)
+0:50 'ps_output' (temp structure{temp 4-component vector of float color})
+0:50 Constant:
+0:50 0 (const int)
+0:50 Branch: Return
0:? Linker Objects
0:? 'color' (layout(location=0 ) out 4-component vector of float)
// Module Version 10000
// Generated by (magic number): 80001
-// Id's are bound by 47
+// Id's are bound by 107
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
- EntryPoint Fragment 4 "main" 43
+ EntryPoint Fragment 4 "main" 103
ExecutionMode 4 OriginUpperLeft
Name 4 "main"
Name 6 "Test1("
@@ -136,11 +372,20 @@ gl_FragCoord origin is upper left
MemberName 25(mystruct2) 1 "b"
MemberName 25(mystruct2) 2 "c"
Name 27 "test5"
- Name 34 "PS_OUTPUT"
- MemberName 34(PS_OUTPUT) 0 "color"
- Name 36 "ps_output"
- Name 43 "color"
- Decorate 43(color) Location 0
+ Name 32 "n"
+ Name 39 "a"
+ Name 75 "one"
+ MemberName 75(one) 0 "a"
+ Name 77 "oneNonConst"
+ Name 82 "two"
+ MemberName 82(two) 0 "a"
+ MemberName 82(two) 1 "b"
+ Name 84 "twoNonConst"
+ Name 94 "PS_OUTPUT"
+ MemberName 94(PS_OUTPUT) 0 "color"
+ Name 96 "ps_output"
+ Name 103 "color"
+ Decorate 103(color) Location 0
2: TypeVoid
3: TypeFunction 2
8: TypeFloat 32
@@ -163,24 +408,44 @@ gl_FragCoord origin is upper left
29: 8(float) Constant 1091567616
30: 8(float) Constant 1092616192
31:25(mystruct2) ConstantComposite 28 29 30
- 33: TypeVector 8(float) 4
- 34(PS_OUTPUT): TypeStruct 33(fvec4)
- 35: TypePointer Function 34(PS_OUTPUT)
- 37: TypeInt 32 1
- 38: 37(int) Constant 0
- 39: 33(fvec4) ConstantComposite 13 13 13 13
- 40: TypePointer Function 33(fvec4)
- 42: TypePointer Output 33(fvec4)
- 43(color): 42(ptr) Variable Output
+ 33: 8(float) Constant 0
+ 34: TypeVector 8(float) 3
+ 35: TypeInt 32 0
+ 36: 35(int) Constant 8
+ 37: TypeArray 34(fvec3) 36
+ 38: TypePointer Function 37
+ 40: 8(float) Constant 1058262330
+ 41: 34(fvec3) ConstantComposite 40 40 40
+ 45: 8(float) Constant 3205745978
+ 46: 34(fvec3) ConstantComposite 45 45 45
+ 50: 34(fvec3) ConstantComposite 45 45 40
+ 54: 34(fvec3) ConstantComposite 45 40 45
+ 58: 34(fvec3) ConstantComposite 45 40 40
+ 62: 34(fvec3) ConstantComposite 40 45 45
+ 66: 34(fvec3) ConstantComposite 40 45 40
+ 70: 34(fvec3) ConstantComposite 40 40 45
+ 75(one): TypeStruct 34(fvec3)
+ 76: TypePointer Function 75(one)
+ 82(two): TypeStruct 34(fvec3) 34(fvec3)
+ 83: TypePointer Function 82(two)
+ 93: TypeVector 8(float) 4
+ 94(PS_OUTPUT): TypeStruct 93(fvec4)
+ 95: TypePointer Function 94(PS_OUTPUT)
+ 97: TypeInt 32 1
+ 98: 97(int) Constant 0
+ 99: 93(fvec4) ConstantComposite 13 13 13 13
+ 100: TypePointer Function 93(fvec4)
+ 102: TypePointer Output 93(fvec4)
+ 103(color): 102(ptr) Variable Output
4(main): 2 Function None 3
5: Label
- 36(ps_output): 35(ptr) Variable Function
- 32: 2 FunctionCall 6(Test1()
- 41: 40(ptr) AccessChain 36(ps_output) 38
- Store 41 39
- 44: 40(ptr) AccessChain 36(ps_output) 38
- 45: 33(fvec4) Load 44
- Store 43(color) 45
+ 96(ps_output): 95(ptr) Variable Function
+ 92: 2 FunctionCall 6(Test1()
+ 101: 100(ptr) AccessChain 96(ps_output) 98
+ Store 101 99
+ 104: 100(ptr) AccessChain 96(ps_output) 98
+ 105: 93(fvec4) Load 104
+ Store 103(color) 105
Return
FunctionEnd
6(Test1(): 2 Function None 3
@@ -189,9 +454,64 @@ gl_FragCoord origin is upper left
17(test2): 11(ptr) Variable Function
23(test4): 22(ptr) Variable Function
27(test5): 26(ptr) Variable Function
+ 32(n): 22(ptr) Variable Function
+ 39(a): 38(ptr) Variable Function
+ 77(oneNonConst): 76(ptr) Variable Function
+ 84(twoNonConst): 83(ptr) Variable Function
Store 12(test1) 16
Store 17(test2) 21
Store 23(test4) 24
Store 27(test5) 31
+ Store 32(n) 33
+ 42: 8(float) Load 32(n)
+ 43: 8(float) FAdd 42 13
+ Store 32(n) 43
+ 44: 34(fvec3) VectorTimesScalar 41 43
+ 47: 8(float) Load 32(n)
+ 48: 8(float) FAdd 47 13
+ Store 32(n) 48
+ 49: 34(fvec3) VectorTimesScalar 46 48
+ 51: 8(float) Load 32(n)
+ 52: 8(float) FAdd 51 13
+ Store 32(n) 52
+ 53: 34(fvec3) VectorTimesScalar 50 52
+ 55: 8(float) Load 32(n)
+ 56: 8(float) FAdd 55 13
+ Store 32(n) 56
+ 57: 34(fvec3) VectorTimesScalar 54 56
+ 59: 8(float) Load 32(n)
+ 60: 8(float) FAdd 59 13
+ Store 32(n) 60
+ 61: 34(fvec3) VectorTimesScalar 58 60
+ 63: 8(float) Load 32(n)
+ 64: 8(float) FAdd 63 13
+ Store 32(n) 64
+ 65: 34(fvec3) VectorTimesScalar 62 64
+ 67: 8(float) Load 32(n)
+ 68: 8(float) FAdd 67 13
+ Store 32(n) 68
+ 69: 34(fvec3) VectorTimesScalar 66 68
+ 71: 8(float) Load 32(n)
+ 72: 8(float) FAdd 71 13
+ Store 32(n) 72
+ 73: 34(fvec3) VectorTimesScalar 70 72
+ 74: 37 CompositeConstruct 44 49 53 57 61 65 69 73
+ Store 39(a) 74
+ 78: 8(float) Load 32(n)
+ 79: 8(float) FAdd 78 13
+ Store 32(n) 79
+ 80: 34(fvec3) VectorTimesScalar 58 79
+ 81: 75(one) CompositeConstruct 80
+ Store 77(oneNonConst) 81
+ 85: 8(float) Load 32(n)
+ 86: 8(float) FAdd 85 13
+ Store 32(n) 86
+ 87: 34(fvec3) VectorTimesScalar 58 86
+ 88: 8(float) Load 32(n)
+ 89: 8(float) FAdd 88 13
+ Store 32(n) 89
+ 90: 34(fvec3) VectorTimesScalar 58 89
+ 91: 82(two) CompositeConstruct 87 90
+ Store 84(twoNonConst) 91
Return
FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.intrinsics.d3dcolortoubyte4.frag.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.intrinsics.d3dcolortoubyte4.frag.out
new file mode 100644
index 00000000000..0bd429b522e
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.intrinsics.d3dcolortoubyte4.frag.out
@@ -0,0 +1,111 @@
+hlsl.intrinsics.d3dcolortoubyte4.frag
+Shader version: 450
+gl_FragCoord origin is upper left
+0:? Sequence
+0:5 Function Definition: main( (temp 4-component vector of int)
+0:5 Function Parameters:
+0:? Sequence
+0:6 Sequence
+0:6 move second child to first child (temp 4-component vector of int)
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of int)
+0:6 Convert float to int (temp 4-component vector of int)
+0:6 vector-scale (temp 4-component vector of float)
+0:6 Constant:
+0:6 255.001953
+0:6 vector swizzle (temp 4-component vector of float)
+0:6 col4: direct index for structure (layout(offset=0 ) uniform 4-component vector of float)
+0:6 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of float col4})
+0:6 Constant:
+0:6 0 (const uint)
+0:6 Sequence
+0:6 Constant:
+0:6 2 (const int)
+0:6 Constant:
+0:6 1 (const int)
+0:6 Constant:
+0:6 0 (const int)
+0:6 Constant:
+0:6 3 (const int)
+0:6 Branch: Return
+0:? Linker Objects
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of int)
+0:? 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of float col4})
+
+
+Linked fragment stage:
+
+
+Shader version: 450
+gl_FragCoord origin is upper left
+0:? Sequence
+0:5 Function Definition: main( (temp 4-component vector of int)
+0:5 Function Parameters:
+0:? Sequence
+0:6 Sequence
+0:6 move second child to first child (temp 4-component vector of int)
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of int)
+0:6 Convert float to int (temp 4-component vector of int)
+0:6 vector-scale (temp 4-component vector of float)
+0:6 Constant:
+0:6 255.001953
+0:6 vector swizzle (temp 4-component vector of float)
+0:6 col4: direct index for structure (layout(offset=0 ) uniform 4-component vector of float)
+0:6 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of float col4})
+0:6 Constant:
+0:6 0 (const uint)
+0:6 Sequence
+0:6 Constant:
+0:6 2 (const int)
+0:6 Constant:
+0:6 1 (const int)
+0:6 Constant:
+0:6 0 (const int)
+0:6 Constant:
+0:6 3 (const int)
+0:6 Branch: Return
+0:? Linker Objects
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of int)
+0:? 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of float col4})
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 24
+
+ Capability Shader
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Fragment 4 "main" 9
+ ExecutionMode 4 OriginUpperLeft
+ Name 4 "main"
+ Name 9 "@entryPointOutput"
+ Name 13 "$Global"
+ MemberName 13($Global) 0 "col4"
+ Name 15 ""
+ Decorate 9(@entryPointOutput) Location 0
+ MemberDecorate 13($Global) 0 Offset 0
+ Decorate 13($Global) Block
+ Decorate 15 DescriptorSet 0
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeInt 32 1
+ 7: TypeVector 6(int) 4
+ 8: TypePointer Output 7(ivec4)
+9(@entryPointOutput): 8(ptr) Variable Output
+ 10: TypeFloat 32
+ 11: 10(float) Constant 1132396672
+ 12: TypeVector 10(float) 4
+ 13($Global): TypeStruct 12(fvec4)
+ 14: TypePointer Uniform 13($Global)
+ 15: 14(ptr) Variable Uniform
+ 16: 6(int) Constant 0
+ 17: TypePointer Uniform 12(fvec4)
+ 4(main): 2 Function None 3
+ 5: Label
+ 18: 17(ptr) AccessChain 15 16
+ 19: 12(fvec4) Load 18
+ 20: 12(fvec4) VectorShuffle 19 19 2 1 0 3
+ 21: 12(fvec4) VectorTimesScalar 20 11
+ 22: 7(ivec4) ConvertFToS 21
+ Store 9(@entryPointOutput) 22
+ Return
+ FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.intrinsics.negative.frag.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.intrinsics.negative.frag.out
index e275054325c..0468863fd1d 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.intrinsics.negative.frag.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.intrinsics.negative.frag.out
@@ -1,6 +1,10 @@
hlsl.intrinsics.negative.frag
ERROR: 0:10: 'determinant' : no matching overloaded function found
ERROR: 0:12: 'f32tof16' : unimplemented intrinsic: handle natively
+ERROR: 0:23: 'length' : ambiguous best function under implicit type conversion
+ERROR: 0:25: 'normalize' : ambiguous best function under implicit type conversion
+ERROR: 0:26: 'reflect' : ambiguous best function under implicit type conversion
+ERROR: 0:27: 'refract' : ambiguous best function under implicit type conversion
ERROR: 0:28: 'refract' : no matching overloaded function found
ERROR: 0:30: 'transpose' : no matching overloaded function found
ERROR: 0:39: 'GetRenderTargetSamplePosition' : no matching overloaded function found
@@ -59,7 +63,7 @@ ERROR: 0:133: 'normalize' : no matching overloaded function found
ERROR: 0:133: 'reflect' : no matching overloaded function found
ERROR: 0:133: 'refract' : no matching overloaded function found
ERROR: 0:133: 'reversebits' : no matching overloaded function found
-ERROR: 60 compilation errors. No code generated.
+ERROR: 64 compilation errors. No code generated.
Shader version: 450
@@ -89,9 +93,22 @@ ERROR: node is still EOpNull!
0:8 'inF0' (in float)
0:8 Construct vec3 (in 3-component vector of float)
0:8 'inF1' (in float)
-0:9 Function Call: D3DCOLORtoUBYTE4(vf4; (temp 4-component vector of int)
-0:9 Construct vec4 (in 4-component vector of float)
-0:9 'inF0' (in float)
+0:9 Convert float to int (temp 4-component vector of int)
+0:9 vector-scale (temp 4-component vector of float)
+0:9 Constant:
+0:9 255.001953
+0:9 vector swizzle (temp 4-component vector of float)
+0:9 Construct vec4 (in 4-component vector of float)
+0:9 'inF0' (in float)
+0:9 Sequence
+0:9 Constant:
+0:9 2 (const int)
+0:9 Constant:
+0:9 1 (const int)
+0:9 Constant:
+0:9 0 (const int)
+0:9 Constant:
+0:9 3 (const int)
0:10 Constant:
0:10 0.000000
0:12 ERROR: Bad unary op
@@ -445,9 +462,22 @@ ERROR: node is still EOpNull!
0:8 'inF0' (in float)
0:8 Construct vec3 (in 3-component vector of float)
0:8 'inF1' (in float)
-0:9 Function Call: D3DCOLORtoUBYTE4(vf4; (temp 4-component vector of int)
-0:9 Construct vec4 (in 4-component vector of float)
-0:9 'inF0' (in float)
+0:9 Convert float to int (temp 4-component vector of int)
+0:9 vector-scale (temp 4-component vector of float)
+0:9 Constant:
+0:9 255.001953
+0:9 vector swizzle (temp 4-component vector of float)
+0:9 Construct vec4 (in 4-component vector of float)
+0:9 'inF0' (in float)
+0:9 Sequence
+0:9 Constant:
+0:9 2 (const int)
+0:9 Constant:
+0:9 1 (const int)
+0:9 Constant:
+0:9 0 (const int)
+0:9 Constant:
+0:9 3 (const int)
0:10 Constant:
0:10 0.000000
0:12 ERROR: Bad unary op
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.layout.frag.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.layout.frag.out
index 0c12435a14d..65a9f271db5 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.layout.frag.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.layout.frag.out
@@ -87,6 +87,7 @@ gl_FragCoord origin is upper left
Name 30 "tbufName2"
MemberName 30(tbufName2) 0 "v1PostLayout"
Name 32 ""
+ Name 38 "specConst"
MemberDecorate 14(tbufName) 0 Offset 16
Decorate 14(tbufName) BufferBlock
Decorate 16 DescriptorSet 3
@@ -97,7 +98,7 @@ gl_FragCoord origin is upper left
Decorate 30(tbufName2) BufferBlock
Decorate 32 DescriptorSet 4
Decorate 32 Binding 7
- Decorate 38 SpecId 17
+ Decorate 38(specConst) SpecId 17
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@@ -117,7 +118,7 @@ gl_FragCoord origin is upper left
30(tbufName2): TypeStruct 7(fvec4)
31: TypePointer Uniform 30(tbufName2)
32: 31(ptr) Variable Uniform
- 38: 17(int) SpecConstant 10
+ 38(specConst): 17(int) SpecConstant 10
4(main): 2 Function None 3
5: Label
Return
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.load.basic.dx10.vert.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.load.basic.dx10.vert.out
index a86f0aea977..a3e45e4f4f9 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.load.basic.dx10.vert.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.load.basic.dx10.vert.out
@@ -1,7 +1,7 @@
hlsl.load.basic.dx10.vert
Shader version: 450
0:? Sequence
-0:47 Function Definition: main( (temp structure{temp 4-component vector of float Pos})
+0:47 Function Definition: main( (temp structure{temp 4-component vector of float Position Pos})
0:47 Function Parameters:
0:? Sequence
0:51 textureFetch (temp 4-component vector of float)
@@ -195,7 +195,6 @@ Shader version: 450
0:69 0 (const int)
0:69 Branch: Return
0:? Linker Objects
-0:? 'Pos' (out 4-component vector of float Position)
0:? 'g_sSamp' (layout(binding=0 ) uniform sampler)
0:? 'g_tTex1df4' (layout(binding=0 ) uniform texture1D)
0:? 'g_tTex1di4' (uniform itexture1D)
@@ -219,6 +218,7 @@ Shader version: 450
0:? 'g_tTexcdi4a' (uniform itextureCubeArray)
0:? 'g_tTexcdu4a' (uniform utextureCubeArray)
0:? 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform int c1, layout(offset=8 ) uniform 2-component vector of int c2, layout(offset=16 ) uniform 3-component vector of int c3, layout(offset=32 ) uniform 4-component vector of int c4, layout(offset=48 ) uniform int o1, layout(offset=56 ) uniform 2-component vector of int o2, layout(offset=64 ) uniform 3-component vector of int o3, layout(offset=80 ) uniform 4-component vector of int o4})
+0:? 'PerVertex_out' (out block{out 4-component vector of float Position Pos})
Linked vertex stage:
@@ -226,7 +226,7 @@ Linked vertex stage:
Shader version: 450
0:? Sequence
-0:47 Function Definition: main( (temp structure{temp 4-component vector of float Pos})
+0:47 Function Definition: main( (temp structure{temp 4-component vector of float Position Pos})
0:47 Function Parameters:
0:? Sequence
0:51 textureFetch (temp 4-component vector of float)
@@ -420,7 +420,6 @@ Shader version: 450
0:69 0 (const int)
0:69 Branch: Return
0:? Linker Objects
-0:? 'Pos' (out 4-component vector of float Position)
0:? 'g_sSamp' (layout(binding=0 ) uniform sampler)
0:? 'g_tTex1df4' (layout(binding=0 ) uniform texture1D)
0:? 'g_tTex1di4' (uniform itexture1D)
@@ -444,17 +443,18 @@ Shader version: 450
0:? 'g_tTexcdi4a' (uniform itextureCubeArray)
0:? 'g_tTexcdu4a' (uniform utextureCubeArray)
0:? 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform int c1, layout(offset=8 ) uniform 2-component vector of int c2, layout(offset=16 ) uniform 3-component vector of int c3, layout(offset=32 ) uniform 4-component vector of int c4, layout(offset=48 ) uniform int o1, layout(offset=56 ) uniform 2-component vector of int o2, layout(offset=64 ) uniform 3-component vector of int o3, layout(offset=80 ) uniform 4-component vector of int o4})
+0:? 'PerVertex_out' (out block{out 4-component vector of float Position Pos})
// Module Version 10000
// Generated by (magic number): 80001
-// Id's are bound by 166
+// Id's are bound by 169
Capability Shader
Capability Sampled1D
Capability SampledCubeArray
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
- EntryPoint Vertex 4 "main" 123
+ EntryPoint Vertex 4 "main" 123 168
Name 4 "main"
Name 9 "g_tTex1df4"
Name 15 "$Global"
@@ -492,6 +492,9 @@ Shader version: 450
Name 159 "g_tTexcdf4a"
Name 162 "g_tTexcdi4a"
Name 165 "g_tTexcdu4a"
+ Name 166 "PerVertex_out"
+ MemberName 166(PerVertex_out) 0 "Pos"
+ Name 168 "PerVertex_out"
Decorate 9(g_tTex1df4) DescriptorSet 0
Decorate 9(g_tTex1df4) Binding 0
MemberDecorate 15($Global) 0 Offset 0
@@ -527,6 +530,8 @@ Shader version: 450
Decorate 159(g_tTexcdf4a) DescriptorSet 0
Decorate 162(g_tTexcdi4a) DescriptorSet 0
Decorate 165(g_tTexcdu4a) DescriptorSet 0
+ MemberDecorate 166(PerVertex_out) 0 BuiltIn Position
+ Decorate 166(PerVertex_out) Block
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@@ -624,6 +629,9 @@ Shader version: 450
163: TypeImage 19(int) Cube array sampled format:Unknown
164: TypePointer UniformConstant 163
165(g_tTexcdu4a): 164(ptr) Variable UniformConstant
+166(PerVertex_out): TypeStruct 27(fvec4)
+ 167: TypePointer Output 166(PerVertex_out)
+168(PerVertex_out): 167(ptr) Variable Output
4(main): 2 Function None 3
5: Label
116(vsout): 115(ptr) Variable Function
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.matrixSwizzle.vert.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.matrixSwizzle.vert.out
new file mode 100644
index 00000000000..cf79f724589
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.matrixSwizzle.vert.out
@@ -0,0 +1,818 @@
+hlsl.matrixSwizzle.vert
+Shader version: 450
+0:? Sequence
+0:2 Function Definition: ShaderFunction(f1; (temp void)
+0:2 Function Parameters:
+0:2 'inf' (layout(location=0 ) in float)
+0:? Sequence
+0:7 move second child to first child (temp float)
+0:7 direct index (temp float)
+0:7 direct index (temp 4-component vector of float)
+0:7 'm' (temp 3X4 matrix of float)
+0:7 Constant:
+0:7 2 (const int)
+0:7 Constant:
+0:7 3 (const int)
+0:7 Constant:
+0:7 1.000000
+0:8 move second child to first child (temp float)
+0:8 direct index (temp float)
+0:8 direct index (temp 4-component vector of float)
+0:8 'm' (temp 3X4 matrix of float)
+0:8 Constant:
+0:8 2 (const int)
+0:8 Constant:
+0:8 3 (const int)
+0:8 Constant:
+0:8 2.000000
+0:9 move second child to first child (temp float)
+0:9 direct index (temp float)
+0:9 direct index (temp 4-component vector of float)
+0:9 'm' (temp 3X4 matrix of float)
+0:9 Constant:
+0:9 2 (const int)
+0:9 Constant:
+0:9 3 (const int)
+0:9 Constant:
+0:9 2.000000
+0:11 move second child to first child (temp 4-component vector of float)
+0:11 direct index (temp 4-component vector of float)
+0:11 'm' (temp 3X4 matrix of float)
+0:11 Constant:
+0:11 0 (const int)
+0:11 Constant:
+0:11 3.000000
+0:11 3.000000
+0:11 3.000000
+0:11 3.000000
+0:12 move second child to first child (temp 4-component vector of float)
+0:12 direct index (temp 4-component vector of float)
+0:12 'm' (temp 3X4 matrix of float)
+0:12 Constant:
+0:12 1 (const int)
+0:12 Constant:
+0:12 3.000000
+0:12 3.000000
+0:12 3.000000
+0:12 3.000000
+0:13 move second child to first child (temp 4-component vector of float)
+0:13 direct index (temp 4-component vector of float)
+0:13 'm' (temp 3X4 matrix of float)
+0:13 Constant:
+0:13 1 (const int)
+0:13 Constant:
+0:13 3.000000
+0:13 3.000000
+0:13 3.000000
+0:13 3.000000
+0:? Sequence
+0:18 move second child to first child (temp float)
+0:18 direct index (temp float)
+0:18 direct index (temp 4-component vector of float)
+0:18 'm' (temp 3X4 matrix of float)
+0:18 Constant:
+0:18 0 (const int)
+0:18 Constant:
+0:18 0 (const int)
+0:18 direct index (temp float)
+0:18 'f3' (temp 3-component vector of float)
+0:18 Constant:
+0:18 0 (const int)
+0:18 move second child to first child (temp float)
+0:18 direct index (temp float)
+0:18 direct index (temp 4-component vector of float)
+0:18 'm' (temp 3X4 matrix of float)
+0:18 Constant:
+0:18 1 (const int)
+0:18 Constant:
+0:18 1 (const int)
+0:18 direct index (temp float)
+0:18 'f3' (temp 3-component vector of float)
+0:18 Constant:
+0:18 1 (const int)
+0:18 move second child to first child (temp float)
+0:18 direct index (temp float)
+0:18 direct index (temp 4-component vector of float)
+0:18 'm' (temp 3X4 matrix of float)
+0:18 Constant:
+0:18 1 (const int)
+0:18 Constant:
+0:18 2 (const int)
+0:18 direct index (temp float)
+0:18 'f3' (temp 3-component vector of float)
+0:18 Constant:
+0:18 2 (const int)
+0:19 Sequence
+0:19 move second child to first child (temp 3-component vector of float)
+0:19 'intermVec' (temp 3-component vector of float)
+0:19 Constant:
+0:19 5.000000
+0:19 5.000000
+0:19 5.000000
+0:19 move second child to first child (temp float)
+0:19 direct index (temp float)
+0:19 direct index (temp 4-component vector of float)
+0:19 'm' (temp 3X4 matrix of float)
+0:19 Constant:
+0:19 1 (const int)
+0:19 Constant:
+0:19 0 (const int)
+0:19 direct index (temp float)
+0:19 'intermVec' (temp 3-component vector of float)
+0:19 Constant:
+0:19 0 (const int)
+0:19 move second child to first child (temp float)
+0:19 direct index (temp float)
+0:19 direct index (temp 4-component vector of float)
+0:19 'm' (temp 3X4 matrix of float)
+0:19 Constant:
+0:19 0 (const int)
+0:19 Constant:
+0:19 1 (const int)
+0:19 direct index (temp float)
+0:19 'intermVec' (temp 3-component vector of float)
+0:19 Constant:
+0:19 1 (const int)
+0:19 move second child to first child (temp float)
+0:19 direct index (temp float)
+0:19 direct index (temp 4-component vector of float)
+0:19 'm' (temp 3X4 matrix of float)
+0:19 Constant:
+0:19 2 (const int)
+0:19 Constant:
+0:19 0 (const int)
+0:19 direct index (temp float)
+0:19 'intermVec' (temp 3-component vector of float)
+0:19 Constant:
+0:19 2 (const int)
+0:20 Sequence
+0:20 move second child to first child (temp 3-component vector of float)
+0:20 'intermVec' (temp 3-component vector of float)
+0:20 vector-scale (temp 3-component vector of float)
+0:20 Constant:
+0:20 2.000000
+0:20 'f3' (temp 3-component vector of float)
+0:20 move second child to first child (temp float)
+0:20 direct index (temp float)
+0:20 direct index (temp 4-component vector of float)
+0:20 'm' (temp 3X4 matrix of float)
+0:20 Constant:
+0:20 0 (const int)
+0:20 Constant:
+0:20 0 (const int)
+0:20 direct index (temp float)
+0:20 'intermVec' (temp 3-component vector of float)
+0:20 Constant:
+0:20 0 (const int)
+0:20 move second child to first child (temp float)
+0:20 direct index (temp float)
+0:20 direct index (temp 4-component vector of float)
+0:20 'm' (temp 3X4 matrix of float)
+0:20 Constant:
+0:20 0 (const int)
+0:20 Constant:
+0:20 1 (const int)
+0:20 direct index (temp float)
+0:20 'intermVec' (temp 3-component vector of float)
+0:20 Constant:
+0:20 1 (const int)
+0:20 move second child to first child (temp float)
+0:20 direct index (temp float)
+0:20 direct index (temp 4-component vector of float)
+0:20 'm' (temp 3X4 matrix of float)
+0:20 Constant:
+0:20 1 (const int)
+0:20 Constant:
+0:20 0 (const int)
+0:20 direct index (temp float)
+0:20 'intermVec' (temp 3-component vector of float)
+0:20 Constant:
+0:20 2 (const int)
+0:23 move second child to first child (temp 3-component vector of float)
+0:23 'f3' (temp 3-component vector of float)
+0:23 matrix swizzle (temp 3-component vector of float)
+0:23 'm' (temp 3X4 matrix of float)
+0:23 Sequence
+0:23 Constant:
+0:23 1 (const int)
+0:23 Constant:
+0:23 0 (const int)
+0:23 Constant:
+0:23 0 (const int)
+0:23 Constant:
+0:23 1 (const int)
+0:23 Constant:
+0:23 2 (const int)
+0:23 Constant:
+0:23 0 (const int)
+0:27 Function Definition: createMat3x3(vf3;vf3;vf3; (temp 3X3 matrix of float)
+0:27 Function Parameters:
+0:27 'a' (in 3-component vector of float)
+0:27 'b' (in 3-component vector of float)
+0:27 'c' (in 3-component vector of float)
+0:? Sequence
+0:? Sequence
+0:29 move second child to first child (temp float)
+0:29 direct index (temp float)
+0:29 direct index (temp 3-component vector of float)
+0:29 'm' (temp 3X3 matrix of float)
+0:29 Constant:
+0:29 0 (const int)
+0:29 Constant:
+0:29 0 (const int)
+0:29 direct index (temp float)
+0:29 'a' (in 3-component vector of float)
+0:29 Constant:
+0:29 0 (const int)
+0:29 move second child to first child (temp float)
+0:29 direct index (temp float)
+0:29 direct index (temp 3-component vector of float)
+0:29 'm' (temp 3X3 matrix of float)
+0:29 Constant:
+0:29 1 (const int)
+0:29 Constant:
+0:29 0 (const int)
+0:29 direct index (temp float)
+0:29 'a' (in 3-component vector of float)
+0:29 Constant:
+0:29 1 (const int)
+0:29 move second child to first child (temp float)
+0:29 direct index (temp float)
+0:29 direct index (temp 3-component vector of float)
+0:29 'm' (temp 3X3 matrix of float)
+0:29 Constant:
+0:29 2 (const int)
+0:29 Constant:
+0:29 0 (const int)
+0:29 direct index (temp float)
+0:29 'a' (in 3-component vector of float)
+0:29 Constant:
+0:29 2 (const int)
+0:? Sequence
+0:30 move second child to first child (temp float)
+0:30 direct index (temp float)
+0:30 direct index (temp 3-component vector of float)
+0:30 'm' (temp 3X3 matrix of float)
+0:30 Constant:
+0:30 0 (const int)
+0:30 Constant:
+0:30 1 (const int)
+0:30 direct index (temp float)
+0:30 'b' (in 3-component vector of float)
+0:30 Constant:
+0:30 0 (const int)
+0:30 move second child to first child (temp float)
+0:30 direct index (temp float)
+0:30 direct index (temp 3-component vector of float)
+0:30 'm' (temp 3X3 matrix of float)
+0:30 Constant:
+0:30 1 (const int)
+0:30 Constant:
+0:30 1 (const int)
+0:30 direct index (temp float)
+0:30 'b' (in 3-component vector of float)
+0:30 Constant:
+0:30 1 (const int)
+0:30 move second child to first child (temp float)
+0:30 direct index (temp float)
+0:30 direct index (temp 3-component vector of float)
+0:30 'm' (temp 3X3 matrix of float)
+0:30 Constant:
+0:30 2 (const int)
+0:30 Constant:
+0:30 1 (const int)
+0:30 direct index (temp float)
+0:30 'b' (in 3-component vector of float)
+0:30 Constant:
+0:30 2 (const int)
+0:? Sequence
+0:31 move second child to first child (temp float)
+0:31 direct index (temp float)
+0:31 direct index (temp 3-component vector of float)
+0:31 'm' (temp 3X3 matrix of float)
+0:31 Constant:
+0:31 0 (const int)
+0:31 Constant:
+0:31 2 (const int)
+0:31 direct index (temp float)
+0:31 'c' (in 3-component vector of float)
+0:31 Constant:
+0:31 0 (const int)
+0:31 move second child to first child (temp float)
+0:31 direct index (temp float)
+0:31 direct index (temp 3-component vector of float)
+0:31 'm' (temp 3X3 matrix of float)
+0:31 Constant:
+0:31 1 (const int)
+0:31 Constant:
+0:31 2 (const int)
+0:31 direct index (temp float)
+0:31 'c' (in 3-component vector of float)
+0:31 Constant:
+0:31 1 (const int)
+0:31 move second child to first child (temp float)
+0:31 direct index (temp float)
+0:31 direct index (temp 3-component vector of float)
+0:31 'm' (temp 3X3 matrix of float)
+0:31 Constant:
+0:31 2 (const int)
+0:31 Constant:
+0:31 2 (const int)
+0:31 direct index (temp float)
+0:31 'c' (in 3-component vector of float)
+0:31 Constant:
+0:31 2 (const int)
+0:32 Branch: Return with expression
+0:32 'm' (temp 3X3 matrix of float)
+0:? Linker Objects
+0:? 'inf' (layout(location=0 ) in float)
+
+
+Linked vertex stage:
+
+
+Shader version: 450
+0:? Sequence
+0:2 Function Definition: ShaderFunction(f1; (temp void)
+0:2 Function Parameters:
+0:2 'inf' (layout(location=0 ) in float)
+0:? Sequence
+0:7 move second child to first child (temp float)
+0:7 direct index (temp float)
+0:7 direct index (temp 4-component vector of float)
+0:7 'm' (temp 3X4 matrix of float)
+0:7 Constant:
+0:7 2 (const int)
+0:7 Constant:
+0:7 3 (const int)
+0:7 Constant:
+0:7 1.000000
+0:8 move second child to first child (temp float)
+0:8 direct index (temp float)
+0:8 direct index (temp 4-component vector of float)
+0:8 'm' (temp 3X4 matrix of float)
+0:8 Constant:
+0:8 2 (const int)
+0:8 Constant:
+0:8 3 (const int)
+0:8 Constant:
+0:8 2.000000
+0:9 move second child to first child (temp float)
+0:9 direct index (temp float)
+0:9 direct index (temp 4-component vector of float)
+0:9 'm' (temp 3X4 matrix of float)
+0:9 Constant:
+0:9 2 (const int)
+0:9 Constant:
+0:9 3 (const int)
+0:9 Constant:
+0:9 2.000000
+0:11 move second child to first child (temp 4-component vector of float)
+0:11 direct index (temp 4-component vector of float)
+0:11 'm' (temp 3X4 matrix of float)
+0:11 Constant:
+0:11 0 (const int)
+0:11 Constant:
+0:11 3.000000
+0:11 3.000000
+0:11 3.000000
+0:11 3.000000
+0:12 move second child to first child (temp 4-component vector of float)
+0:12 direct index (temp 4-component vector of float)
+0:12 'm' (temp 3X4 matrix of float)
+0:12 Constant:
+0:12 1 (const int)
+0:12 Constant:
+0:12 3.000000
+0:12 3.000000
+0:12 3.000000
+0:12 3.000000
+0:13 move second child to first child (temp 4-component vector of float)
+0:13 direct index (temp 4-component vector of float)
+0:13 'm' (temp 3X4 matrix of float)
+0:13 Constant:
+0:13 1 (const int)
+0:13 Constant:
+0:13 3.000000
+0:13 3.000000
+0:13 3.000000
+0:13 3.000000
+0:? Sequence
+0:18 move second child to first child (temp float)
+0:18 direct index (temp float)
+0:18 direct index (temp 4-component vector of float)
+0:18 'm' (temp 3X4 matrix of float)
+0:18 Constant:
+0:18 0 (const int)
+0:18 Constant:
+0:18 0 (const int)
+0:18 direct index (temp float)
+0:18 'f3' (temp 3-component vector of float)
+0:18 Constant:
+0:18 0 (const int)
+0:18 move second child to first child (temp float)
+0:18 direct index (temp float)
+0:18 direct index (temp 4-component vector of float)
+0:18 'm' (temp 3X4 matrix of float)
+0:18 Constant:
+0:18 1 (const int)
+0:18 Constant:
+0:18 1 (const int)
+0:18 direct index (temp float)
+0:18 'f3' (temp 3-component vector of float)
+0:18 Constant:
+0:18 1 (const int)
+0:18 move second child to first child (temp float)
+0:18 direct index (temp float)
+0:18 direct index (temp 4-component vector of float)
+0:18 'm' (temp 3X4 matrix of float)
+0:18 Constant:
+0:18 1 (const int)
+0:18 Constant:
+0:18 2 (const int)
+0:18 direct index (temp float)
+0:18 'f3' (temp 3-component vector of float)
+0:18 Constant:
+0:18 2 (const int)
+0:19 Sequence
+0:19 move second child to first child (temp 3-component vector of float)
+0:19 'intermVec' (temp 3-component vector of float)
+0:19 Constant:
+0:19 5.000000
+0:19 5.000000
+0:19 5.000000
+0:19 move second child to first child (temp float)
+0:19 direct index (temp float)
+0:19 direct index (temp 4-component vector of float)
+0:19 'm' (temp 3X4 matrix of float)
+0:19 Constant:
+0:19 1 (const int)
+0:19 Constant:
+0:19 0 (const int)
+0:19 direct index (temp float)
+0:19 'intermVec' (temp 3-component vector of float)
+0:19 Constant:
+0:19 0 (const int)
+0:19 move second child to first child (temp float)
+0:19 direct index (temp float)
+0:19 direct index (temp 4-component vector of float)
+0:19 'm' (temp 3X4 matrix of float)
+0:19 Constant:
+0:19 0 (const int)
+0:19 Constant:
+0:19 1 (const int)
+0:19 direct index (temp float)
+0:19 'intermVec' (temp 3-component vector of float)
+0:19 Constant:
+0:19 1 (const int)
+0:19 move second child to first child (temp float)
+0:19 direct index (temp float)
+0:19 direct index (temp 4-component vector of float)
+0:19 'm' (temp 3X4 matrix of float)
+0:19 Constant:
+0:19 2 (const int)
+0:19 Constant:
+0:19 0 (const int)
+0:19 direct index (temp float)
+0:19 'intermVec' (temp 3-component vector of float)
+0:19 Constant:
+0:19 2 (const int)
+0:20 Sequence
+0:20 move second child to first child (temp 3-component vector of float)
+0:20 'intermVec' (temp 3-component vector of float)
+0:20 vector-scale (temp 3-component vector of float)
+0:20 Constant:
+0:20 2.000000
+0:20 'f3' (temp 3-component vector of float)
+0:20 move second child to first child (temp float)
+0:20 direct index (temp float)
+0:20 direct index (temp 4-component vector of float)
+0:20 'm' (temp 3X4 matrix of float)
+0:20 Constant:
+0:20 0 (const int)
+0:20 Constant:
+0:20 0 (const int)
+0:20 direct index (temp float)
+0:20 'intermVec' (temp 3-component vector of float)
+0:20 Constant:
+0:20 0 (const int)
+0:20 move second child to first child (temp float)
+0:20 direct index (temp float)
+0:20 direct index (temp 4-component vector of float)
+0:20 'm' (temp 3X4 matrix of float)
+0:20 Constant:
+0:20 0 (const int)
+0:20 Constant:
+0:20 1 (const int)
+0:20 direct index (temp float)
+0:20 'intermVec' (temp 3-component vector of float)
+0:20 Constant:
+0:20 1 (const int)
+0:20 move second child to first child (temp float)
+0:20 direct index (temp float)
+0:20 direct index (temp 4-component vector of float)
+0:20 'm' (temp 3X4 matrix of float)
+0:20 Constant:
+0:20 1 (const int)
+0:20 Constant:
+0:20 0 (const int)
+0:20 direct index (temp float)
+0:20 'intermVec' (temp 3-component vector of float)
+0:20 Constant:
+0:20 2 (const int)
+0:23 move second child to first child (temp 3-component vector of float)
+0:23 'f3' (temp 3-component vector of float)
+0:23 matrix swizzle (temp 3-component vector of float)
+0:23 'm' (temp 3X4 matrix of float)
+0:23 Sequence
+0:23 Constant:
+0:23 1 (const int)
+0:23 Constant:
+0:23 0 (const int)
+0:23 Constant:
+0:23 0 (const int)
+0:23 Constant:
+0:23 1 (const int)
+0:23 Constant:
+0:23 2 (const int)
+0:23 Constant:
+0:23 0 (const int)
+0:27 Function Definition: createMat3x3(vf3;vf3;vf3; (temp 3X3 matrix of float)
+0:27 Function Parameters:
+0:27 'a' (in 3-component vector of float)
+0:27 'b' (in 3-component vector of float)
+0:27 'c' (in 3-component vector of float)
+0:? Sequence
+0:? Sequence
+0:29 move second child to first child (temp float)
+0:29 direct index (temp float)
+0:29 direct index (temp 3-component vector of float)
+0:29 'm' (temp 3X3 matrix of float)
+0:29 Constant:
+0:29 0 (const int)
+0:29 Constant:
+0:29 0 (const int)
+0:29 direct index (temp float)
+0:29 'a' (in 3-component vector of float)
+0:29 Constant:
+0:29 0 (const int)
+0:29 move second child to first child (temp float)
+0:29 direct index (temp float)
+0:29 direct index (temp 3-component vector of float)
+0:29 'm' (temp 3X3 matrix of float)
+0:29 Constant:
+0:29 1 (const int)
+0:29 Constant:
+0:29 0 (const int)
+0:29 direct index (temp float)
+0:29 'a' (in 3-component vector of float)
+0:29 Constant:
+0:29 1 (const int)
+0:29 move second child to first child (temp float)
+0:29 direct index (temp float)
+0:29 direct index (temp 3-component vector of float)
+0:29 'm' (temp 3X3 matrix of float)
+0:29 Constant:
+0:29 2 (const int)
+0:29 Constant:
+0:29 0 (const int)
+0:29 direct index (temp float)
+0:29 'a' (in 3-component vector of float)
+0:29 Constant:
+0:29 2 (const int)
+0:? Sequence
+0:30 move second child to first child (temp float)
+0:30 direct index (temp float)
+0:30 direct index (temp 3-component vector of float)
+0:30 'm' (temp 3X3 matrix of float)
+0:30 Constant:
+0:30 0 (const int)
+0:30 Constant:
+0:30 1 (const int)
+0:30 direct index (temp float)
+0:30 'b' (in 3-component vector of float)
+0:30 Constant:
+0:30 0 (const int)
+0:30 move second child to first child (temp float)
+0:30 direct index (temp float)
+0:30 direct index (temp 3-component vector of float)
+0:30 'm' (temp 3X3 matrix of float)
+0:30 Constant:
+0:30 1 (const int)
+0:30 Constant:
+0:30 1 (const int)
+0:30 direct index (temp float)
+0:30 'b' (in 3-component vector of float)
+0:30 Constant:
+0:30 1 (const int)
+0:30 move second child to first child (temp float)
+0:30 direct index (temp float)
+0:30 direct index (temp 3-component vector of float)
+0:30 'm' (temp 3X3 matrix of float)
+0:30 Constant:
+0:30 2 (const int)
+0:30 Constant:
+0:30 1 (const int)
+0:30 direct index (temp float)
+0:30 'b' (in 3-component vector of float)
+0:30 Constant:
+0:30 2 (const int)
+0:? Sequence
+0:31 move second child to first child (temp float)
+0:31 direct index (temp float)
+0:31 direct index (temp 3-component vector of float)
+0:31 'm' (temp 3X3 matrix of float)
+0:31 Constant:
+0:31 0 (const int)
+0:31 Constant:
+0:31 2 (const int)
+0:31 direct index (temp float)
+0:31 'c' (in 3-component vector of float)
+0:31 Constant:
+0:31 0 (const int)
+0:31 move second child to first child (temp float)
+0:31 direct index (temp float)
+0:31 direct index (temp 3-component vector of float)
+0:31 'm' (temp 3X3 matrix of float)
+0:31 Constant:
+0:31 1 (const int)
+0:31 Constant:
+0:31 2 (const int)
+0:31 direct index (temp float)
+0:31 'c' (in 3-component vector of float)
+0:31 Constant:
+0:31 1 (const int)
+0:31 move second child to first child (temp float)
+0:31 direct index (temp float)
+0:31 direct index (temp 3-component vector of float)
+0:31 'm' (temp 3X3 matrix of float)
+0:31 Constant:
+0:31 2 (const int)
+0:31 Constant:
+0:31 2 (const int)
+0:31 direct index (temp float)
+0:31 'c' (in 3-component vector of float)
+0:31 Constant:
+0:31 2 (const int)
+0:32 Branch: Return with expression
+0:32 'm' (temp 3X3 matrix of float)
+0:? Linker Objects
+0:? 'inf' (layout(location=0 ) in float)
+
+Missing functionality: matrix swizzle
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 109
+
+ Capability Shader
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Vertex 4 "ShaderFunction" 108
+ Name 4 "ShaderFunction"
+ Name 14 "createMat3x3(vf3;vf3;vf3;"
+ Name 11 "a"
+ Name 12 "b"
+ Name 13 "c"
+ Name 19 "m"
+ Name 38 "f3"
+ Name 51 "intermVec"
+ Name 63 "intermVec"
+ Name 76 "m"
+ Name 108 "inf"
+ Decorate 108(inf) Location 0
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeFloat 32
+ 7: TypeVector 6(float) 3
+ 8: TypePointer Function 7(fvec3)
+ 9: TypeMatrix 7(fvec3) 3
+ 10: TypeFunction 9 8(ptr) 8(ptr) 8(ptr)
+ 16: TypeVector 6(float) 4
+ 17: TypeMatrix 16(fvec4) 3
+ 18: TypePointer Function 17
+ 20: TypeInt 32 1
+ 21: 20(int) Constant 2
+ 22: 6(float) Constant 1065353216
+ 23: TypeInt 32 0
+ 24: 23(int) Constant 3
+ 25: TypePointer Function 6(float)
+ 27: 6(float) Constant 1073741824
+ 30: 20(int) Constant 0
+ 31: 6(float) Constant 1077936128
+ 32: 16(fvec4) ConstantComposite 31 31 31 31
+ 33: TypePointer Function 16(fvec4)
+ 35: 20(int) Constant 1
+ 39: 23(int) Constant 0
+ 43: 23(int) Constant 1
+ 47: 23(int) Constant 2
+ 52: 6(float) Constant 1084227584
+ 53: 7(fvec3) ConstantComposite 52 52 52
+ 75: TypePointer Function 9
+ 107: TypePointer Input 6(float)
+ 108(inf): 107(ptr) Variable Input
+4(ShaderFunction): 2 Function None 3
+ 5: Label
+ 19(m): 18(ptr) Variable Function
+ 38(f3): 8(ptr) Variable Function
+ 51(intermVec): 8(ptr) Variable Function
+ 63(intermVec): 8(ptr) Variable Function
+ 26: 25(ptr) AccessChain 19(m) 21 24
+ Store 26 22
+ 28: 25(ptr) AccessChain 19(m) 21 24
+ Store 28 27
+ 29: 25(ptr) AccessChain 19(m) 21 24
+ Store 29 27
+ 34: 33(ptr) AccessChain 19(m) 30
+ Store 34 32
+ 36: 33(ptr) AccessChain 19(m) 35
+ Store 36 32
+ 37: 33(ptr) AccessChain 19(m) 35
+ Store 37 32
+ 40: 25(ptr) AccessChain 38(f3) 39
+ 41: 6(float) Load 40
+ 42: 25(ptr) AccessChain 19(m) 30 39
+ Store 42 41
+ 44: 25(ptr) AccessChain 38(f3) 43
+ 45: 6(float) Load 44
+ 46: 25(ptr) AccessChain 19(m) 35 43
+ Store 46 45
+ 48: 25(ptr) AccessChain 38(f3) 47
+ 49: 6(float) Load 48
+ 50: 25(ptr) AccessChain 19(m) 35 47
+ Store 50 49
+ Store 51(intermVec) 53
+ 54: 25(ptr) AccessChain 51(intermVec) 39
+ 55: 6(float) Load 54
+ 56: 25(ptr) AccessChain 19(m) 35 39
+ Store 56 55
+ 57: 25(ptr) AccessChain 51(intermVec) 43
+ 58: 6(float) Load 57
+ 59: 25(ptr) AccessChain 19(m) 30 43
+ Store 59 58
+ 60: 25(ptr) AccessChain 51(intermVec) 47
+ 61: 6(float) Load 60
+ 62: 25(ptr) AccessChain 19(m) 21 39
+ Store 62 61
+ 64: 7(fvec3) Load 38(f3)
+ 65: 7(fvec3) VectorTimesScalar 64 27
+ Store 63(intermVec) 65
+ 66: 25(ptr) AccessChain 63(intermVec) 39
+ 67: 6(float) Load 66
+ 68: 25(ptr) AccessChain 19(m) 30 39
+ Store 68 67
+ 69: 25(ptr) AccessChain 63(intermVec) 43
+ 70: 6(float) Load 69
+ 71: 25(ptr) AccessChain 19(m) 30 43
+ Store 71 70
+ 72: 25(ptr) AccessChain 63(intermVec) 47
+ 73: 6(float) Load 72
+ 74: 25(ptr) AccessChain 19(m) 35 39
+ Store 74 73
+ Store 38(f3) 30
+ Return
+ FunctionEnd
+14(createMat3x3(vf3;vf3;vf3;): 9 Function None 10
+ 11(a): 8(ptr) FunctionParameter
+ 12(b): 8(ptr) FunctionParameter
+ 13(c): 8(ptr) FunctionParameter
+ 15: Label
+ 76(m): 75(ptr) Variable Function
+ 77: 25(ptr) AccessChain 11(a) 39
+ 78: 6(float) Load 77
+ 79: 25(ptr) AccessChain 76(m) 30 39
+ Store 79 78
+ 80: 25(ptr) AccessChain 11(a) 43
+ 81: 6(float) Load 80
+ 82: 25(ptr) AccessChain 76(m) 35 39
+ Store 82 81
+ 83: 25(ptr) AccessChain 11(a) 47
+ 84: 6(float) Load 83
+ 85: 25(ptr) AccessChain 76(m) 21 39
+ Store 85 84
+ 86: 25(ptr) AccessChain 12(b) 39
+ 87: 6(float) Load 86
+ 88: 25(ptr) AccessChain 76(m) 30 43
+ Store 88 87
+ 89: 25(ptr) AccessChain 12(b) 43
+ 90: 6(float) Load 89
+ 91: 25(ptr) AccessChain 76(m) 35 43
+ Store 91 90
+ 92: 25(ptr) AccessChain 12(b) 47
+ 93: 6(float) Load 92
+ 94: 25(ptr) AccessChain 76(m) 21 43
+ Store 94 93
+ 95: 25(ptr) AccessChain 13(c) 39
+ 96: 6(float) Load 95
+ 97: 25(ptr) AccessChain 76(m) 30 47
+ Store 97 96
+ 98: 25(ptr) AccessChain 13(c) 43
+ 99: 6(float) Load 98
+ 100: 25(ptr) AccessChain 76(m) 35 47
+ Store 100 99
+ 101: 25(ptr) AccessChain 13(c) 47
+ 102: 6(float) Load 101
+ 103: 25(ptr) AccessChain 76(m) 21 47
+ Store 103 102
+ 104: 9 Load 76(m)
+ ReturnValue 104
+ FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.numthreads.comp.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.numthreads.comp.out
index 76e95c8f86b..8ac76a962c8 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.numthreads.comp.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.numthreads.comp.out
@@ -7,9 +7,9 @@ local_size = (4, 4, 2)
0:4 'tid' (in 3-component vector of uint)
0:9 Function Definition: main_aux1(vu3; (temp void)
0:9 Function Parameters:
-0:9 'tid' (in 3-component vector of uint LocalInvocationID)
+0:9 'tid' (in 3-component vector of uint GlobalInvocationID)
0:? Linker Objects
-0:? 'tid' (in 3-component vector of uint LocalInvocationID)
+0:? 'tid' (in 3-component vector of uint GlobalInvocationID)
Linked compute stage:
@@ -23,9 +23,9 @@ local_size = (4, 4, 2)
0:4 'tid' (in 3-component vector of uint)
0:9 Function Definition: main_aux1(vu3; (temp void)
0:9 Function Parameters:
-0:9 'tid' (in 3-component vector of uint LocalInvocationID)
+0:9 'tid' (in 3-component vector of uint GlobalInvocationID)
0:? Linker Objects
-0:? 'tid' (in 3-component vector of uint LocalInvocationID)
+0:? 'tid' (in 3-component vector of uint GlobalInvocationID)
// Module Version 10000
// Generated by (magic number): 80001
@@ -40,7 +40,7 @@ local_size = (4, 4, 2)
Name 11 "main(vu3;"
Name 10 "tid"
Name 14 "tid"
- Decorate 14(tid) BuiltIn LocalInvocationId
+ Decorate 14(tid) BuiltIn GlobalInvocationId
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.params.default.frag.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.params.default.frag.out
new file mode 100644
index 00000000000..3c62c5db5cb
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.params.default.frag.out
@@ -0,0 +1,639 @@
+hlsl.params.default.frag
+Shader version: 450
+gl_FragCoord origin is upper left
+0:? Sequence
+0:9 Function Definition: fn1(vi4;b1;b1; (temp 4-component vector of int)
+0:9 Function Parameters:
+0:9 'p0' (in 4-component vector of int)
+0:9 'b1' (in bool)
+0:9 'b2' (in bool)
+0:? Sequence
+0:10 Branch: Return with expression
+0:10 'p0' (in 4-component vector of int)
+0:17 Function Definition: fn1(vi4;vi4;i1[2];i1; (temp 4-component vector of int)
+0:17 Function Parameters:
+0:17 'p0' (in 4-component vector of int)
+0:17 'p1' (in 4-component vector of int)
+0:17 'p2' (in 2-element array of int)
+0:17 'p3' (in int)
+0:? Sequence
+0:18 Branch: Return with expression
+0:18 add (temp 4-component vector of int)
+0:18 add (temp 4-component vector of int)
+0:18 add (temp 4-component vector of int)
+0:18 'p0' (in 4-component vector of int)
+0:18 'p1' (in 4-component vector of int)
+0:18 direct index (temp int)
+0:18 'p2' (in 2-element array of int)
+0:18 Constant:
+0:18 0 (const int)
+0:18 'p3' (in int)
+0:23 Function Definition: fn2(vi4;i1; (temp 4-component vector of int)
+0:23 Function Parameters:
+0:23 'p0' (in 4-component vector of int)
+0:23 'x' (in int)
+0:? Sequence
+0:24 Branch: Return with expression
+0:? Constant:
+0:? 10 (const int)
+0:? 11 (const int)
+0:? 12 (const int)
+0:? 13 (const int)
+0:28 Function Definition: fn2(vi4;f1; (temp 4-component vector of int)
+0:28 Function Parameters:
+0:28 'p0' (in 4-component vector of int)
+0:28 'x' (in float)
+0:? Sequence
+0:29 Branch: Return with expression
+0:29 add (temp 4-component vector of int)
+0:29 'p0' (in 4-component vector of int)
+0:? Constant:
+0:? 20 (const int)
+0:? 21 (const int)
+0:? 22 (const int)
+0:? 23 (const int)
+0:32 Function Definition: fn3(i1; (temp void)
+0:32 Function Parameters:
+0:32 'p0' (in int)
+0:36 Function Definition: main( (temp 4-component vector of int)
+0:36 Function Parameters:
+0:? Sequence
+0:37 Sequence
+0:37 move second child to first child (temp 2-element array of int)
+0:37 'myarray' (temp 2-element array of int)
+0:37 Constant:
+0:37 30 (const int)
+0:37 31 (const int)
+0:39 Function Call: fn3(i1; (temp void)
+0:32 Constant:
+0:32 3 (const int)
+0:40 Function Call: fn3(i1; (temp void)
+0:40 Constant:
+0:40 5 (const int)
+0:50 Sequence
+0:50 move second child to first child (temp 4-component vector of int)
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of int)
+0:49 add (temp 4-component vector of int)
+0:47 add (temp 4-component vector of int)
+0:46 add (temp 4-component vector of int)
+0:45 add (temp 4-component vector of int)
+0:44 add (temp 4-component vector of int)
+0:43 add (temp 4-component vector of int)
+0:42 add (temp 4-component vector of int)
+0:42 Function Call: fn1(vi4;vi4;i1[2];i1; (temp 4-component vector of int)
+0:42 Constant:
+0:42 100 (const int)
+0:42 100 (const int)
+0:42 100 (const int)
+0:42 100 (const int)
+0:? Constant:
+0:? -1 (const int)
+0:? -2 (const int)
+0:? -3 (const int)
+0:? -4 (const int)
+0:15 Constant:
+0:15 1 (const int)
+0:15 2 (const int)
+0:16 Constant:
+0:16 42 (const int)
+0:43 Function Call: fn1(vi4;vi4;i1[2];i1; (temp 4-component vector of int)
+0:43 Constant:
+0:43 101 (const int)
+0:43 101 (const int)
+0:43 101 (const int)
+0:43 101 (const int)
+0:43 ui4: direct index for structure (layout(offset=0 ) uniform 4-component vector of int)
+0:43 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of int ui4})
+0:43 Constant:
+0:43 0 (const uint)
+0:15 Constant:
+0:15 1 (const int)
+0:15 2 (const int)
+0:16 Constant:
+0:16 42 (const int)
+0:44 Function Call: fn1(vi4;vi4;i1[2];i1; (temp 4-component vector of int)
+0:44 Constant:
+0:44 102 (const int)
+0:44 102 (const int)
+0:44 102 (const int)
+0:44 102 (const int)
+0:44 ui4: direct index for structure (layout(offset=0 ) uniform 4-component vector of int)
+0:44 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of int ui4})
+0:44 Constant:
+0:44 0 (const uint)
+0:44 'myarray' (temp 2-element array of int)
+0:16 Constant:
+0:16 42 (const int)
+0:45 Function Call: fn1(vi4;vi4;i1[2];i1; (temp 4-component vector of int)
+0:45 Constant:
+0:45 103 (const int)
+0:45 103 (const int)
+0:45 103 (const int)
+0:45 103 (const int)
+0:45 ui4: direct index for structure (layout(offset=0 ) uniform 4-component vector of int)
+0:45 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of int ui4})
+0:45 Constant:
+0:45 0 (const uint)
+0:45 'myarray' (temp 2-element array of int)
+0:45 Constant:
+0:45 99 (const int)
+0:46 Function Call: fn1(vi4;b1;b1; (temp 4-component vector of int)
+0:46 Constant:
+0:46 104 (const int)
+0:46 104 (const int)
+0:46 104 (const int)
+0:46 104 (const int)
+0:46 Constant:
+0:46 false (const bool)
+0:9 Constant:
+0:9 false (const bool)
+0:47 Function Call: fn1(vi4;b1;b1; (temp 4-component vector of int)
+0:47 Constant:
+0:47 105 (const int)
+0:47 105 (const int)
+0:47 105 (const int)
+0:47 105 (const int)
+0:47 Constant:
+0:47 false (const bool)
+0:47 Constant:
+0:47 true (const bool)
+0:49 Function Call: fn2(vi4;f1; (temp 4-component vector of int)
+0:49 Constant:
+0:49 110 (const int)
+0:49 110 (const int)
+0:49 110 (const int)
+0:49 110 (const int)
+0:49 Constant:
+0:49 11.110000
+0:50 Function Call: fn2(vi4;i1; (temp 4-component vector of int)
+0:50 Constant:
+0:50 111 (const int)
+0:50 111 (const int)
+0:50 111 (const int)
+0:50 111 (const int)
+0:50 Constant:
+0:50 12 (const int)
+0:50 Branch: Return
+0:? Linker Objects
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of int)
+0:? 'cia' (const int)
+0:? -4 (const int)
+0:? 'cib' (const int)
+0:? -42 (const int)
+0:? 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of int ui4})
+
+
+Linked fragment stage:
+
+
+Shader version: 450
+gl_FragCoord origin is upper left
+0:? Sequence
+0:9 Function Definition: fn1(vi4;b1;b1; (temp 4-component vector of int)
+0:9 Function Parameters:
+0:9 'p0' (in 4-component vector of int)
+0:9 'b1' (in bool)
+0:9 'b2' (in bool)
+0:? Sequence
+0:10 Branch: Return with expression
+0:10 'p0' (in 4-component vector of int)
+0:17 Function Definition: fn1(vi4;vi4;i1[2];i1; (temp 4-component vector of int)
+0:17 Function Parameters:
+0:17 'p0' (in 4-component vector of int)
+0:17 'p1' (in 4-component vector of int)
+0:17 'p2' (in 2-element array of int)
+0:17 'p3' (in int)
+0:? Sequence
+0:18 Branch: Return with expression
+0:18 add (temp 4-component vector of int)
+0:18 add (temp 4-component vector of int)
+0:18 add (temp 4-component vector of int)
+0:18 'p0' (in 4-component vector of int)
+0:18 'p1' (in 4-component vector of int)
+0:18 direct index (temp int)
+0:18 'p2' (in 2-element array of int)
+0:18 Constant:
+0:18 0 (const int)
+0:18 'p3' (in int)
+0:23 Function Definition: fn2(vi4;i1; (temp 4-component vector of int)
+0:23 Function Parameters:
+0:23 'p0' (in 4-component vector of int)
+0:23 'x' (in int)
+0:? Sequence
+0:24 Branch: Return with expression
+0:? Constant:
+0:? 10 (const int)
+0:? 11 (const int)
+0:? 12 (const int)
+0:? 13 (const int)
+0:28 Function Definition: fn2(vi4;f1; (temp 4-component vector of int)
+0:28 Function Parameters:
+0:28 'p0' (in 4-component vector of int)
+0:28 'x' (in float)
+0:? Sequence
+0:29 Branch: Return with expression
+0:29 add (temp 4-component vector of int)
+0:29 'p0' (in 4-component vector of int)
+0:? Constant:
+0:? 20 (const int)
+0:? 21 (const int)
+0:? 22 (const int)
+0:? 23 (const int)
+0:32 Function Definition: fn3(i1; (temp void)
+0:32 Function Parameters:
+0:32 'p0' (in int)
+0:36 Function Definition: main( (temp 4-component vector of int)
+0:36 Function Parameters:
+0:? Sequence
+0:37 Sequence
+0:37 move second child to first child (temp 2-element array of int)
+0:37 'myarray' (temp 2-element array of int)
+0:37 Constant:
+0:37 30 (const int)
+0:37 31 (const int)
+0:39 Function Call: fn3(i1; (temp void)
+0:32 Constant:
+0:32 3 (const int)
+0:40 Function Call: fn3(i1; (temp void)
+0:40 Constant:
+0:40 5 (const int)
+0:50 Sequence
+0:50 move second child to first child (temp 4-component vector of int)
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of int)
+0:49 add (temp 4-component vector of int)
+0:47 add (temp 4-component vector of int)
+0:46 add (temp 4-component vector of int)
+0:45 add (temp 4-component vector of int)
+0:44 add (temp 4-component vector of int)
+0:43 add (temp 4-component vector of int)
+0:42 add (temp 4-component vector of int)
+0:42 Function Call: fn1(vi4;vi4;i1[2];i1; (temp 4-component vector of int)
+0:42 Constant:
+0:42 100 (const int)
+0:42 100 (const int)
+0:42 100 (const int)
+0:42 100 (const int)
+0:? Constant:
+0:? -1 (const int)
+0:? -2 (const int)
+0:? -3 (const int)
+0:? -4 (const int)
+0:15 Constant:
+0:15 1 (const int)
+0:15 2 (const int)
+0:16 Constant:
+0:16 42 (const int)
+0:43 Function Call: fn1(vi4;vi4;i1[2];i1; (temp 4-component vector of int)
+0:43 Constant:
+0:43 101 (const int)
+0:43 101 (const int)
+0:43 101 (const int)
+0:43 101 (const int)
+0:43 ui4: direct index for structure (layout(offset=0 ) uniform 4-component vector of int)
+0:43 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of int ui4})
+0:43 Constant:
+0:43 0 (const uint)
+0:15 Constant:
+0:15 1 (const int)
+0:15 2 (const int)
+0:16 Constant:
+0:16 42 (const int)
+0:44 Function Call: fn1(vi4;vi4;i1[2];i1; (temp 4-component vector of int)
+0:44 Constant:
+0:44 102 (const int)
+0:44 102 (const int)
+0:44 102 (const int)
+0:44 102 (const int)
+0:44 ui4: direct index for structure (layout(offset=0 ) uniform 4-component vector of int)
+0:44 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of int ui4})
+0:44 Constant:
+0:44 0 (const uint)
+0:44 'myarray' (temp 2-element array of int)
+0:16 Constant:
+0:16 42 (const int)
+0:45 Function Call: fn1(vi4;vi4;i1[2];i1; (temp 4-component vector of int)
+0:45 Constant:
+0:45 103 (const int)
+0:45 103 (const int)
+0:45 103 (const int)
+0:45 103 (const int)
+0:45 ui4: direct index for structure (layout(offset=0 ) uniform 4-component vector of int)
+0:45 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of int ui4})
+0:45 Constant:
+0:45 0 (const uint)
+0:45 'myarray' (temp 2-element array of int)
+0:45 Constant:
+0:45 99 (const int)
+0:46 Function Call: fn1(vi4;b1;b1; (temp 4-component vector of int)
+0:46 Constant:
+0:46 104 (const int)
+0:46 104 (const int)
+0:46 104 (const int)
+0:46 104 (const int)
+0:46 Constant:
+0:46 false (const bool)
+0:9 Constant:
+0:9 false (const bool)
+0:47 Function Call: fn1(vi4;b1;b1; (temp 4-component vector of int)
+0:47 Constant:
+0:47 105 (const int)
+0:47 105 (const int)
+0:47 105 (const int)
+0:47 105 (const int)
+0:47 Constant:
+0:47 false (const bool)
+0:47 Constant:
+0:47 true (const bool)
+0:49 Function Call: fn2(vi4;f1; (temp 4-component vector of int)
+0:49 Constant:
+0:49 110 (const int)
+0:49 110 (const int)
+0:49 110 (const int)
+0:49 110 (const int)
+0:49 Constant:
+0:49 11.110000
+0:50 Function Call: fn2(vi4;i1; (temp 4-component vector of int)
+0:50 Constant:
+0:50 111 (const int)
+0:50 111 (const int)
+0:50 111 (const int)
+0:50 111 (const int)
+0:50 Constant:
+0:50 12 (const int)
+0:50 Branch: Return
+0:? Linker Objects
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of int)
+0:? 'cia' (const int)
+0:? -4 (const int)
+0:? 'cib' (const int)
+0:? -42 (const int)
+0:? 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of int ui4})
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 173
+
+ Capability Shader
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Fragment 4 "main" 88
+ ExecutionMode 4 OriginUpperLeft
+ Name 4 "main"
+ Name 15 "fn1(vi4;b1;b1;"
+ Name 12 "p0"
+ Name 13 "b1"
+ Name 14 "b2"
+ Name 27 "fn1(vi4;vi4;i1[2];i1;"
+ Name 23 "p0"
+ Name 24 "p1"
+ Name 25 "p2"
+ Name 26 "p3"
+ Name 32 "fn2(vi4;i1;"
+ Name 30 "p0"
+ Name 31 "x"
+ Name 39 "fn2(vi4;f1;"
+ Name 37 "p0"
+ Name 38 "x"
+ Name 43 "fn3(i1;"
+ Name 42 "p0"
+ Name 77 "myarray"
+ Name 82 "param"
+ Name 85 "param"
+ Name 88 "@entryPointOutput"
+ Name 100 "param"
+ Name 101 "param"
+ Name 102 "param"
+ Name 103 "param"
+ Name 107 "$Global"
+ MemberName 107($Global) 0 "ui4"
+ Name 109 ""
+ Name 110 "param"
+ Name 111 "param"
+ Name 115 "param"
+ Name 116 "param"
+ Name 121 "param"
+ Name 122 "param"
+ Name 125 "param"
+ Name 127 "param"
+ Name 133 "param"
+ Name 134 "param"
+ Name 137 "param"
+ Name 139 "param"
+ Name 145 "param"
+ Name 146 "param"
+ Name 147 "param"
+ Name 153 "param"
+ Name 154 "param"
+ Name 155 "param"
+ Name 161 "param"
+ Name 162 "param"
+ Name 167 "param"
+ Name 168 "param"
+ Decorate 88(@entryPointOutput) Location 0
+ MemberDecorate 107($Global) 0 Offset 0
+ Decorate 107($Global) Block
+ Decorate 109 DescriptorSet 0
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeInt 32 1
+ 7: TypeVector 6(int) 4
+ 8: TypePointer Function 7(ivec4)
+ 9: TypeBool
+ 10: TypePointer Function 9(bool)
+ 11: TypeFunction 7(ivec4) 8(ptr) 10(ptr) 10(ptr)
+ 17: TypeInt 32 0
+ 18: 17(int) Constant 2
+ 19: TypeArray 6(int) 18
+ 20: TypePointer Function 19
+ 21: TypePointer Function 6(int)
+ 22: TypeFunction 7(ivec4) 8(ptr) 8(ptr) 20(ptr) 21(ptr)
+ 29: TypeFunction 7(ivec4) 8(ptr) 21(ptr)
+ 34: TypeFloat 32
+ 35: TypePointer Function 34(float)
+ 36: TypeFunction 7(ivec4) 8(ptr) 35(ptr)
+ 41: TypeFunction 2 21(ptr)
+ 51: 6(int) Constant 0
+ 61: 6(int) Constant 10
+ 62: 6(int) Constant 11
+ 63: 6(int) Constant 12
+ 64: 6(int) Constant 13
+ 65: 7(ivec4) ConstantComposite 61 62 63 64
+ 69: 6(int) Constant 20
+ 70: 6(int) Constant 21
+ 71: 6(int) Constant 22
+ 72: 6(int) Constant 23
+ 73: 7(ivec4) ConstantComposite 69 70 71 72
+ 78: 6(int) Constant 30
+ 79: 6(int) Constant 31
+ 80: 19 ConstantComposite 78 79
+ 81: 6(int) Constant 3
+ 84: 6(int) Constant 5
+ 87: TypePointer Output 7(ivec4)
+88(@entryPointOutput): 87(ptr) Variable Output
+ 89: 6(int) Constant 100
+ 90: 7(ivec4) ConstantComposite 89 89 89 89
+ 91: 6(int) Constant 4294967295
+ 92: 6(int) Constant 4294967294
+ 93: 6(int) Constant 4294967293
+ 94: 6(int) Constant 4294967292
+ 95: 7(ivec4) ConstantComposite 91 92 93 94
+ 96: 6(int) Constant 1
+ 97: 6(int) Constant 2
+ 98: 19 ConstantComposite 96 97
+ 99: 6(int) Constant 42
+ 105: 6(int) Constant 101
+ 106: 7(ivec4) ConstantComposite 105 105 105 105
+ 107($Global): TypeStruct 7(ivec4)
+ 108: TypePointer Uniform 107($Global)
+ 109: 108(ptr) Variable Uniform
+ 112: TypePointer Uniform 7(ivec4)
+ 119: 6(int) Constant 102
+ 120: 7(ivec4) ConstantComposite 119 119 119 119
+ 130: 6(int) Constant 103
+ 131: 7(ivec4) ConstantComposite 130 130 130 130
+ 132: 6(int) Constant 99
+ 142: 6(int) Constant 104
+ 143: 7(ivec4) ConstantComposite 142 142 142 142
+ 144: 9(bool) ConstantFalse
+ 150: 6(int) Constant 105
+ 151: 7(ivec4) ConstantComposite 150 150 150 150
+ 152: 9(bool) ConstantTrue
+ 158: 6(int) Constant 110
+ 159: 7(ivec4) ConstantComposite 158 158 158 158
+ 160: 34(float) Constant 1093780111
+ 165: 6(int) Constant 111
+ 166: 7(ivec4) ConstantComposite 165 165 165 165
+ 172: 6(int) Constant 4294967254
+ 4(main): 2 Function None 3
+ 5: Label
+ 77(myarray): 20(ptr) Variable Function
+ 82(param): 21(ptr) Variable Function
+ 85(param): 21(ptr) Variable Function
+ 100(param): 8(ptr) Variable Function
+ 101(param): 8(ptr) Variable Function
+ 102(param): 20(ptr) Variable Function
+ 103(param): 21(ptr) Variable Function
+ 110(param): 8(ptr) Variable Function
+ 111(param): 8(ptr) Variable Function
+ 115(param): 20(ptr) Variable Function
+ 116(param): 21(ptr) Variable Function
+ 121(param): 8(ptr) Variable Function
+ 122(param): 8(ptr) Variable Function
+ 125(param): 20(ptr) Variable Function
+ 127(param): 21(ptr) Variable Function
+ 133(param): 8(ptr) Variable Function
+ 134(param): 8(ptr) Variable Function
+ 137(param): 20(ptr) Variable Function
+ 139(param): 21(ptr) Variable Function
+ 145(param): 8(ptr) Variable Function
+ 146(param): 10(ptr) Variable Function
+ 147(param): 10(ptr) Variable Function
+ 153(param): 8(ptr) Variable Function
+ 154(param): 10(ptr) Variable Function
+ 155(param): 10(ptr) Variable Function
+ 161(param): 8(ptr) Variable Function
+ 162(param): 35(ptr) Variable Function
+ 167(param): 8(ptr) Variable Function
+ 168(param): 21(ptr) Variable Function
+ Store 77(myarray) 80
+ Store 82(param) 81
+ 83: 2 FunctionCall 43(fn3(i1;) 82(param)
+ Store 85(param) 84
+ 86: 2 FunctionCall 43(fn3(i1;) 85(param)
+ Store 100(param) 90
+ Store 101(param) 95
+ Store 102(param) 98
+ Store 103(param) 99
+ 104: 7(ivec4) FunctionCall 27(fn1(vi4;vi4;i1[2];i1;) 100(param) 101(param) 102(param) 103(param)
+ Store 110(param) 106
+ 113: 112(ptr) AccessChain 109 51
+ 114: 7(ivec4) Load 113
+ Store 111(param) 114
+ Store 115(param) 98
+ Store 116(param) 99
+ 117: 7(ivec4) FunctionCall 27(fn1(vi4;vi4;i1[2];i1;) 110(param) 111(param) 115(param) 116(param)
+ 118: 7(ivec4) IAdd 104 117
+ Store 121(param) 120
+ 123: 112(ptr) AccessChain 109 51
+ 124: 7(ivec4) Load 123
+ Store 122(param) 124
+ 126: 19 Load 77(myarray)
+ Store 125(param) 126
+ Store 127(param) 99
+ 128: 7(ivec4) FunctionCall 27(fn1(vi4;vi4;i1[2];i1;) 121(param) 122(param) 125(param) 127(param)
+ 129: 7(ivec4) IAdd 118 128
+ Store 133(param) 131
+ 135: 112(ptr) AccessChain 109 51
+ 136: 7(ivec4) Load 135
+ Store 134(param) 136
+ 138: 19 Load 77(myarray)
+ Store 137(param) 138
+ Store 139(param) 132
+ 140: 7(ivec4) FunctionCall 27(fn1(vi4;vi4;i1[2];i1;) 133(param) 134(param) 137(param) 139(param)
+ 141: 7(ivec4) IAdd 129 140
+ Store 145(param) 143
+ Store 146(param) 144
+ Store 147(param) 144
+ 148: 7(ivec4) FunctionCall 15(fn1(vi4;b1;b1;) 145(param) 146(param) 147(param)
+ 149: 7(ivec4) IAdd 141 148
+ Store 153(param) 151
+ Store 154(param) 144
+ Store 155(param) 152
+ 156: 7(ivec4) FunctionCall 15(fn1(vi4;b1;b1;) 153(param) 154(param) 155(param)
+ 157: 7(ivec4) IAdd 149 156
+ Store 161(param) 159
+ Store 162(param) 160
+ 163: 7(ivec4) FunctionCall 39(fn2(vi4;f1;) 161(param) 162(param)
+ 164: 7(ivec4) IAdd 157 163
+ Store 167(param) 166
+ Store 168(param) 63
+ 169: 7(ivec4) FunctionCall 32(fn2(vi4;i1;) 167(param) 168(param)
+ 170: 7(ivec4) IAdd 164 169
+ Store 88(@entryPointOutput) 170
+ Return
+ FunctionEnd
+15(fn1(vi4;b1;b1;): 7(ivec4) Function None 11
+ 12(p0): 8(ptr) FunctionParameter
+ 13(b1): 10(ptr) FunctionParameter
+ 14(b2): 10(ptr) FunctionParameter
+ 16: Label
+ 45: 7(ivec4) Load 12(p0)
+ ReturnValue 45
+ FunctionEnd
+27(fn1(vi4;vi4;i1[2];i1;): 7(ivec4) Function None 22
+ 23(p0): 8(ptr) FunctionParameter
+ 24(p1): 8(ptr) FunctionParameter
+ 25(p2): 20(ptr) FunctionParameter
+ 26(p3): 21(ptr) FunctionParameter
+ 28: Label
+ 48: 7(ivec4) Load 23(p0)
+ 49: 7(ivec4) Load 24(p1)
+ 50: 7(ivec4) IAdd 48 49
+ 52: 21(ptr) AccessChain 25(p2) 51
+ 53: 6(int) Load 52
+ 54: 7(ivec4) CompositeConstruct 53 53 53 53
+ 55: 7(ivec4) IAdd 50 54
+ 56: 6(int) Load 26(p3)
+ 57: 7(ivec4) CompositeConstruct 56 56 56 56
+ 58: 7(ivec4) IAdd 55 57
+ ReturnValue 58
+ FunctionEnd
+ 32(fn2(vi4;i1;): 7(ivec4) Function None 29
+ 30(p0): 8(ptr) FunctionParameter
+ 31(x): 21(ptr) FunctionParameter
+ 33: Label
+ ReturnValue 65
+ FunctionEnd
+ 39(fn2(vi4;f1;): 7(ivec4) Function None 36
+ 37(p0): 8(ptr) FunctionParameter
+ 38(x): 35(ptr) FunctionParameter
+ 40: Label
+ 68: 7(ivec4) Load 37(p0)
+ 74: 7(ivec4) IAdd 68 73
+ ReturnValue 74
+ FunctionEnd
+ 43(fn3(i1;): 2 Function None 41
+ 42(p0): 21(ptr) FunctionParameter
+ 44: Label
+ Return
+ FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.params.default.negative.frag.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.params.default.negative.frag.out
new file mode 100644
index 00000000000..fa723f3e107
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.params.default.negative.frag.out
@@ -0,0 +1,379 @@
+hlsl.params.default.negative.frag
+ERROR: 0:27: '' : invalid default parameter value
+ERROR: 0:32: 'p1' : invalid parameter after default value parameters
+ERROR: 0:40: 'fn1' : ambiguous best function under implicit type conversion
+ERROR: 0:47: 'fn2' : ambiguous best function under implicit type conversion
+ERROR: 4 compilation errors. No code generated.
+
+
+Shader version: 450
+gl_FragCoord origin is upper left
+ERROR: node is still EOpNull!
+0:7 Function Definition: fn1(vi4; (temp 4-component vector of int)
+0:7 Function Parameters:
+0:7 'p0' (in 4-component vector of int)
+0:? Sequence
+0:7 Branch: Return with expression
+0:? Constant:
+0:? 1 (const int)
+0:? 2 (const int)
+0:? 3 (const int)
+0:? 4 (const int)
+0:9 Function Definition: fn1(vi4;b1;b1; (temp 4-component vector of int)
+0:9 Function Parameters:
+0:9 'p0' (in 4-component vector of int)
+0:9 'b1' (in bool)
+0:9 'b2' (in bool)
+0:? Sequence
+0:10 Branch: Return with expression
+0:10 'p0' (in 4-component vector of int)
+0:17 Function Definition: fn1(vi4;vi4;i1[2];i1; (temp 4-component vector of int)
+0:17 Function Parameters:
+0:17 'p0' (in 4-component vector of int)
+0:17 'p1' (in 4-component vector of int)
+0:17 'p2' (in 2-element array of int)
+0:17 'p3' (in int)
+0:? Sequence
+0:18 Branch: Return with expression
+0:18 add (temp 4-component vector of int)
+0:18 add (temp 4-component vector of int)
+0:18 add (temp 4-component vector of int)
+0:18 'p0' (in 4-component vector of int)
+0:18 'p1' (in 4-component vector of int)
+0:18 direct index (temp int)
+0:18 'p2' (in 2-element array of int)
+0:18 Constant:
+0:18 0 (const int)
+0:18 'p3' (in int)
+0:23 Function Definition: fn2(vi4;i1; (temp 4-component vector of int)
+0:23 Function Parameters:
+0:23 'p0' (in 4-component vector of int)
+0:23 'x' (in int)
+0:? Sequence
+0:24 Branch: Return with expression
+0:? Constant:
+0:? 10 (const int)
+0:? 11 (const int)
+0:? 12 (const int)
+0:? 13 (const int)
+0:28 Function Definition: fn2(vi4; (temp 4-component vector of int)
+0:28 Function Parameters:
+0:28 'p0' (in 4-component vector of int)
+0:? Sequence
+0:29 Branch: Return with expression
+0:29 add (temp 4-component vector of int)
+0:29 'p0' (in 4-component vector of int)
+0:? Constant:
+0:? 20 (const int)
+0:? 21 (const int)
+0:? 22 (const int)
+0:? 23 (const int)
+0:33 Function Definition: fn3(i1; (temp void)
+0:33 Function Parameters:
+0:33 'p0' (in int)
+0:37 Function Definition: main( (temp 4-component vector of int)
+0:37 Function Parameters:
+0:? Sequence
+0:38 Sequence
+0:38 move second child to first child (temp 2-element array of int)
+0:38 'myarray' (temp 2-element array of int)
+0:38 Constant:
+0:38 30 (const int)
+0:38 31 (const int)
+0:49 Sequence
+0:49 move second child to first child (temp 4-component vector of int)
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of int)
+0:48 add (temp 4-component vector of int)
+0:47 add (temp 4-component vector of int)
+0:45 add (temp 4-component vector of int)
+0:44 add (temp 4-component vector of int)
+0:43 add (temp 4-component vector of int)
+0:42 add (temp 4-component vector of int)
+0:41 add (temp 4-component vector of int)
+0:40 add (temp 4-component vector of int)
+0:40 Function Call: fn1(vi4; (temp 4-component vector of int)
+0:40 Constant:
+0:40 100 (const int)
+0:40 100 (const int)
+0:40 100 (const int)
+0:40 100 (const int)
+0:41 Function Call: fn1(vi4;vi4;i1[2];i1; (temp 4-component vector of int)
+0:41 Constant:
+0:41 101 (const int)
+0:41 101 (const int)
+0:41 101 (const int)
+0:41 101 (const int)
+0:41 ui4: direct index for structure (layout(offset=0 ) uniform 4-component vector of int)
+0:41 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of int ui4, layout(offset=16 ) uniform float ufvar})
+0:41 Constant:
+0:41 0 (const uint)
+0:15 Constant:
+0:15 1 (const int)
+0:15 2 (const int)
+0:16 Constant:
+0:16 42 (const int)
+0:42 Function Call: fn1(vi4;vi4;i1[2];i1; (temp 4-component vector of int)
+0:42 Constant:
+0:42 102 (const int)
+0:42 102 (const int)
+0:42 102 (const int)
+0:42 102 (const int)
+0:42 ui4: direct index for structure (layout(offset=0 ) uniform 4-component vector of int)
+0:42 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of int ui4, layout(offset=16 ) uniform float ufvar})
+0:42 Constant:
+0:42 0 (const uint)
+0:42 'myarray' (temp 2-element array of int)
+0:16 Constant:
+0:16 42 (const int)
+0:43 Function Call: fn1(vi4;vi4;i1[2];i1; (temp 4-component vector of int)
+0:43 Constant:
+0:43 103 (const int)
+0:43 103 (const int)
+0:43 103 (const int)
+0:43 103 (const int)
+0:43 ui4: direct index for structure (layout(offset=0 ) uniform 4-component vector of int)
+0:43 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of int ui4, layout(offset=16 ) uniform float ufvar})
+0:43 Constant:
+0:43 0 (const uint)
+0:43 'myarray' (temp 2-element array of int)
+0:43 Constant:
+0:43 99 (const int)
+0:44 Function Call: fn1(vi4;b1;b1; (temp 4-component vector of int)
+0:44 Constant:
+0:44 104 (const int)
+0:44 104 (const int)
+0:44 104 (const int)
+0:44 104 (const int)
+0:44 Constant:
+0:44 false (const bool)
+0:9 Constant:
+0:9 false (const bool)
+0:45 Function Call: fn1(vi4;b1;b1; (temp 4-component vector of int)
+0:45 Constant:
+0:45 105 (const int)
+0:45 105 (const int)
+0:45 105 (const int)
+0:45 105 (const int)
+0:45 Constant:
+0:45 false (const bool)
+0:45 Constant:
+0:45 true (const bool)
+0:47 Function Call: fn2(vi4; (temp 4-component vector of int)
+0:47 Constant:
+0:47 112 (const int)
+0:47 112 (const int)
+0:47 112 (const int)
+0:47 112 (const int)
+0:48 Function Call: fn2(vi4;i1; (temp 4-component vector of int)
+0:48 Constant:
+0:48 110 (const int)
+0:48 110 (const int)
+0:48 110 (const int)
+0:48 110 (const int)
+0:48 Constant:
+0:48 11 (const int)
+0:49 Function Call: fn2(vi4;i1; (temp 4-component vector of int)
+0:49 Constant:
+0:49 111 (const int)
+0:49 111 (const int)
+0:49 111 (const int)
+0:49 111 (const int)
+0:49 Constant:
+0:49 12 (const int)
+0:49 Branch: Return
+0:? Linker Objects
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of int)
+0:? 'cia' (const int)
+0:? -4 (const int)
+0:? 'cib' (const int)
+0:? -42 (const int)
+0:? 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of int ui4, layout(offset=16 ) uniform float ufvar})
+
+
+Linked fragment stage:
+
+
+Shader version: 450
+gl_FragCoord origin is upper left
+ERROR: node is still EOpNull!
+0:7 Function Definition: fn1(vi4; (temp 4-component vector of int)
+0:7 Function Parameters:
+0:7 'p0' (in 4-component vector of int)
+0:? Sequence
+0:7 Branch: Return with expression
+0:? Constant:
+0:? 1 (const int)
+0:? 2 (const int)
+0:? 3 (const int)
+0:? 4 (const int)
+0:9 Function Definition: fn1(vi4;b1;b1; (temp 4-component vector of int)
+0:9 Function Parameters:
+0:9 'p0' (in 4-component vector of int)
+0:9 'b1' (in bool)
+0:9 'b2' (in bool)
+0:? Sequence
+0:10 Branch: Return with expression
+0:10 'p0' (in 4-component vector of int)
+0:17 Function Definition: fn1(vi4;vi4;i1[2];i1; (temp 4-component vector of int)
+0:17 Function Parameters:
+0:17 'p0' (in 4-component vector of int)
+0:17 'p1' (in 4-component vector of int)
+0:17 'p2' (in 2-element array of int)
+0:17 'p3' (in int)
+0:? Sequence
+0:18 Branch: Return with expression
+0:18 add (temp 4-component vector of int)
+0:18 add (temp 4-component vector of int)
+0:18 add (temp 4-component vector of int)
+0:18 'p0' (in 4-component vector of int)
+0:18 'p1' (in 4-component vector of int)
+0:18 direct index (temp int)
+0:18 'p2' (in 2-element array of int)
+0:18 Constant:
+0:18 0 (const int)
+0:18 'p3' (in int)
+0:23 Function Definition: fn2(vi4;i1; (temp 4-component vector of int)
+0:23 Function Parameters:
+0:23 'p0' (in 4-component vector of int)
+0:23 'x' (in int)
+0:? Sequence
+0:24 Branch: Return with expression
+0:? Constant:
+0:? 10 (const int)
+0:? 11 (const int)
+0:? 12 (const int)
+0:? 13 (const int)
+0:28 Function Definition: fn2(vi4; (temp 4-component vector of int)
+0:28 Function Parameters:
+0:28 'p0' (in 4-component vector of int)
+0:? Sequence
+0:29 Branch: Return with expression
+0:29 add (temp 4-component vector of int)
+0:29 'p0' (in 4-component vector of int)
+0:? Constant:
+0:? 20 (const int)
+0:? 21 (const int)
+0:? 22 (const int)
+0:? 23 (const int)
+0:33 Function Definition: fn3(i1; (temp void)
+0:33 Function Parameters:
+0:33 'p0' (in int)
+0:37 Function Definition: main( (temp 4-component vector of int)
+0:37 Function Parameters:
+0:? Sequence
+0:38 Sequence
+0:38 move second child to first child (temp 2-element array of int)
+0:38 'myarray' (temp 2-element array of int)
+0:38 Constant:
+0:38 30 (const int)
+0:38 31 (const int)
+0:49 Sequence
+0:49 move second child to first child (temp 4-component vector of int)
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of int)
+0:48 add (temp 4-component vector of int)
+0:47 add (temp 4-component vector of int)
+0:45 add (temp 4-component vector of int)
+0:44 add (temp 4-component vector of int)
+0:43 add (temp 4-component vector of int)
+0:42 add (temp 4-component vector of int)
+0:41 add (temp 4-component vector of int)
+0:40 add (temp 4-component vector of int)
+0:40 Function Call: fn1(vi4; (temp 4-component vector of int)
+0:40 Constant:
+0:40 100 (const int)
+0:40 100 (const int)
+0:40 100 (const int)
+0:40 100 (const int)
+0:41 Function Call: fn1(vi4;vi4;i1[2];i1; (temp 4-component vector of int)
+0:41 Constant:
+0:41 101 (const int)
+0:41 101 (const int)
+0:41 101 (const int)
+0:41 101 (const int)
+0:41 ui4: direct index for structure (layout(offset=0 ) uniform 4-component vector of int)
+0:41 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of int ui4, layout(offset=16 ) uniform float ufvar})
+0:41 Constant:
+0:41 0 (const uint)
+0:15 Constant:
+0:15 1 (const int)
+0:15 2 (const int)
+0:16 Constant:
+0:16 42 (const int)
+0:42 Function Call: fn1(vi4;vi4;i1[2];i1; (temp 4-component vector of int)
+0:42 Constant:
+0:42 102 (const int)
+0:42 102 (const int)
+0:42 102 (const int)
+0:42 102 (const int)
+0:42 ui4: direct index for structure (layout(offset=0 ) uniform 4-component vector of int)
+0:42 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of int ui4, layout(offset=16 ) uniform float ufvar})
+0:42 Constant:
+0:42 0 (const uint)
+0:42 'myarray' (temp 2-element array of int)
+0:16 Constant:
+0:16 42 (const int)
+0:43 Function Call: fn1(vi4;vi4;i1[2];i1; (temp 4-component vector of int)
+0:43 Constant:
+0:43 103 (const int)
+0:43 103 (const int)
+0:43 103 (const int)
+0:43 103 (const int)
+0:43 ui4: direct index for structure (layout(offset=0 ) uniform 4-component vector of int)
+0:43 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of int ui4, layout(offset=16 ) uniform float ufvar})
+0:43 Constant:
+0:43 0 (const uint)
+0:43 'myarray' (temp 2-element array of int)
+0:43 Constant:
+0:43 99 (const int)
+0:44 Function Call: fn1(vi4;b1;b1; (temp 4-component vector of int)
+0:44 Constant:
+0:44 104 (const int)
+0:44 104 (const int)
+0:44 104 (const int)
+0:44 104 (const int)
+0:44 Constant:
+0:44 false (const bool)
+0:9 Constant:
+0:9 false (const bool)
+0:45 Function Call: fn1(vi4;b1;b1; (temp 4-component vector of int)
+0:45 Constant:
+0:45 105 (const int)
+0:45 105 (const int)
+0:45 105 (const int)
+0:45 105 (const int)
+0:45 Constant:
+0:45 false (const bool)
+0:45 Constant:
+0:45 true (const bool)
+0:47 Function Call: fn2(vi4; (temp 4-component vector of int)
+0:47 Constant:
+0:47 112 (const int)
+0:47 112 (const int)
+0:47 112 (const int)
+0:47 112 (const int)
+0:48 Function Call: fn2(vi4;i1; (temp 4-component vector of int)
+0:48 Constant:
+0:48 110 (const int)
+0:48 110 (const int)
+0:48 110 (const int)
+0:48 110 (const int)
+0:48 Constant:
+0:48 11 (const int)
+0:49 Function Call: fn2(vi4;i1; (temp 4-component vector of int)
+0:49 Constant:
+0:49 111 (const int)
+0:49 111 (const int)
+0:49 111 (const int)
+0:49 111 (const int)
+0:49 Constant:
+0:49 12 (const int)
+0:49 Branch: Return
+0:? Linker Objects
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of int)
+0:? 'cia' (const int)
+0:? -4 (const int)
+0:? 'cib' (const int)
+0:? -42 (const int)
+0:? 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of int ui4, layout(offset=16 ) uniform float ufvar})
+
+SPIR-V is not generated for failed compile or link
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.partialInit.frag.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.partialInit.frag.out
index 5bf838a4a56..e0bda0e1bf8 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.partialInit.frag.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.partialInit.frag.out
@@ -1,4 +1,7 @@
hlsl.partialInit.frag
+WARNING: 0:35: 'cgf2a' : variable with qualifier 'const' not initialized; zero initializing
+WARNING: 0:36: 'ci' : variable with qualifier 'const' not initialized; zero initializing
+
Shader version: 450
gl_FragCoord origin is upper left
0:? Sequence
@@ -109,32 +112,64 @@ gl_FragCoord origin is upper left
0:26 0.000000
0:26 false (const bool)
0:28 Sequence
-0:28 Sequence
-0:28 move second child to first child (temp int)
+0:28 move second child to first child (temp 4-element array of 2-component vector of float)
+0:28 'gf2a' (temp 4-element array of 2-component vector of float)
+0:28 Constant:
+0:28 0.000000
+0:28 0.000000
+0:28 0.000000
+0:28 0.000000
+0:28 0.000000
+0:28 0.000000
+0:28 0.000000
+0:28 0.000000
+0:29 Sequence
+0:29 move second child to first child (temp int)
+0:29 'cgi' (temp int)
+0:29 Constant:
+0:29 0 (const int)
+0:30 move second child to first child (temp float)
+0:30 b: direct index for structure (temp float)
+0:30 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
+0:30 Constant:
+0:30 1 (const int)
+0:30 component-wise multiply (temp float)
+0:30 direct index (temp float)
+0:30 direct index (temp 2-component vector of float)
+0:30 'gf2a' (temp 4-element array of 2-component vector of float)
+0:30 Constant:
+0:30 2 (const int)
+0:30 Constant:
+0:30 1 (const int)
+0:30 Convert int to float (temp float)
+0:30 'cgi' (temp int)
+0:32 Sequence
+0:32 Sequence
+0:32 move second child to first child (temp int)
0:? 'a' (layout(location=0 ) out int)
-0:28 a: direct index for structure (temp int)
-0:28 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
-0:28 Constant:
-0:28 0 (const int)
-0:28 move second child to first child (temp float)
+0:32 a: direct index for structure (temp int)
+0:32 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
+0:32 Constant:
+0:32 0 (const int)
+0:32 move second child to first child (temp float)
0:? 'b' (layout(location=1 ) out float)
-0:28 b: direct index for structure (temp float)
-0:28 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
-0:28 Constant:
-0:28 1 (const int)
-0:28 move second child to first child (temp bool)
+0:32 b: direct index for structure (temp float)
+0:32 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
+0:32 Constant:
+0:32 1 (const int)
+0:32 move second child to first child (temp bool)
0:? 'c' (layout(location=2 ) out bool)
-0:28 c: direct index for structure (temp bool)
-0:28 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
-0:28 Constant:
-0:28 2 (const int)
-0:28 move second child to first child (temp 4-component vector of float)
+0:32 c: direct index for structure (temp bool)
+0:32 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
+0:32 Constant:
+0:32 2 (const int)
+0:32 move second child to first child (temp 4-component vector of float)
0:? 'v' (layout(location=3 ) out 4-component vector of float)
-0:28 v: direct index for structure (temp 4-component vector of float)
-0:28 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
-0:28 Constant:
-0:28 3 (const int)
-0:28 Branch: Return
+0:32 v: direct index for structure (temp 4-component vector of float)
+0:32 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
+0:32 Constant:
+0:32 3 (const int)
+0:32 Branch: Return
0:? Linker Objects
0:? 'a' (layout(location=0 ) out int)
0:? 'b' (layout(location=1 ) out float)
@@ -143,6 +178,15 @@ gl_FragCoord origin is upper left
0:? 'input' (layout(location=0 ) in 4-component vector of float)
0:? 'gv' (global 4-component vector of float)
0:? 'gfa' (global 3-element array of float)
+0:? 'cgf2a' (const 3-element array of 2-component vector of float)
+0:? 0.000000
+0:? 0.000000
+0:? 0.000000
+0:? 0.000000
+0:? 0.000000
+0:? 0.000000
+0:? 'ci' (const int)
+0:? 0 (const int)
Linked fragment stage:
@@ -258,32 +302,64 @@ gl_FragCoord origin is upper left
0:26 0.000000
0:26 false (const bool)
0:28 Sequence
-0:28 Sequence
-0:28 move second child to first child (temp int)
+0:28 move second child to first child (temp 4-element array of 2-component vector of float)
+0:28 'gf2a' (temp 4-element array of 2-component vector of float)
+0:28 Constant:
+0:28 0.000000
+0:28 0.000000
+0:28 0.000000
+0:28 0.000000
+0:28 0.000000
+0:28 0.000000
+0:28 0.000000
+0:28 0.000000
+0:29 Sequence
+0:29 move second child to first child (temp int)
+0:29 'cgi' (temp int)
+0:29 Constant:
+0:29 0 (const int)
+0:30 move second child to first child (temp float)
+0:30 b: direct index for structure (temp float)
+0:30 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
+0:30 Constant:
+0:30 1 (const int)
+0:30 component-wise multiply (temp float)
+0:30 direct index (temp float)
+0:30 direct index (temp 2-component vector of float)
+0:30 'gf2a' (temp 4-element array of 2-component vector of float)
+0:30 Constant:
+0:30 2 (const int)
+0:30 Constant:
+0:30 1 (const int)
+0:30 Convert int to float (temp float)
+0:30 'cgi' (temp int)
+0:32 Sequence
+0:32 Sequence
+0:32 move second child to first child (temp int)
0:? 'a' (layout(location=0 ) out int)
-0:28 a: direct index for structure (temp int)
-0:28 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
-0:28 Constant:
-0:28 0 (const int)
-0:28 move second child to first child (temp float)
+0:32 a: direct index for structure (temp int)
+0:32 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
+0:32 Constant:
+0:32 0 (const int)
+0:32 move second child to first child (temp float)
0:? 'b' (layout(location=1 ) out float)
-0:28 b: direct index for structure (temp float)
-0:28 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
-0:28 Constant:
-0:28 1 (const int)
-0:28 move second child to first child (temp bool)
+0:32 b: direct index for structure (temp float)
+0:32 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
+0:32 Constant:
+0:32 1 (const int)
+0:32 move second child to first child (temp bool)
0:? 'c' (layout(location=2 ) out bool)
-0:28 c: direct index for structure (temp bool)
-0:28 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
-0:28 Constant:
-0:28 2 (const int)
-0:28 move second child to first child (temp 4-component vector of float)
+0:32 c: direct index for structure (temp bool)
+0:32 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
+0:32 Constant:
+0:32 2 (const int)
+0:32 move second child to first child (temp 4-component vector of float)
0:? 'v' (layout(location=3 ) out 4-component vector of float)
-0:28 v: direct index for structure (temp 4-component vector of float)
-0:28 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
-0:28 Constant:
-0:28 3 (const int)
-0:28 Branch: Return
+0:32 v: direct index for structure (temp 4-component vector of float)
+0:32 'o4' (temp structure{temp int a, temp float b, temp bool c, temp 4-component vector of float v})
+0:32 Constant:
+0:32 3 (const int)
+0:32 Branch: Return
0:? Linker Objects
0:? 'a' (layout(location=0 ) out int)
0:? 'b' (layout(location=1 ) out float)
@@ -292,15 +368,24 @@ gl_FragCoord origin is upper left
0:? 'input' (layout(location=0 ) in 4-component vector of float)
0:? 'gv' (global 4-component vector of float)
0:? 'gfa' (global 3-element array of float)
+0:? 'cgf2a' (const 3-element array of 2-component vector of float)
+0:? 0.000000
+0:? 0.000000
+0:? 0.000000
+0:? 0.000000
+0:? 0.000000
+0:? 0.000000
+0:? 'ci' (const int)
+0:? 0 (const int)
// Module Version 10000
// Generated by (magic number): 80001
-// Id's are bound by 75
+// Id's are bound by 92
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
- EntryPoint Fragment 4 "PixelShaderFunction" 54 59 65 69 74
+ EntryPoint Fragment 4 "PixelShaderFunction" 72 76 80 84 89
ExecutionMode 4 OriginUpperLeft
Name 4 "PixelShaderFunction"
Name 9 "gv"
@@ -319,16 +404,18 @@ gl_FragCoord origin is upper left
MemberName 47(Nest) 1 "os"
MemberName 47(Nest) 2 "b"
Name 49 "nest"
- Name 54 "a"
- Name 59 "b"
- Name 65 "c"
- Name 69 "v"
- Name 74 "input"
- Decorate 54(a) Location 0
- Decorate 59(b) Location 1
- Decorate 65(c) Location 2
- Decorate 69(v) Location 3
- Decorate 74(input) Location 0
+ Name 57 "gf2a"
+ Name 61 "cgi"
+ Name 72 "a"
+ Name 76 "b"
+ Name 80 "c"
+ Name 84 "v"
+ Name 89 "input"
+ Decorate 72(a) Location 0
+ Decorate 76(b) Location 1
+ Decorate 80(c) Location 2
+ Decorate 84(v) Location 3
+ Decorate 89(input) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@@ -365,19 +452,28 @@ gl_FragCoord origin is upper left
50: 45(fvec3) ConstantComposite 10 10 10
51: 46 ConstantComposite 50 50 50 50
52: 47(Nest) ConstantComposite 51 39 25
- 53: TypePointer Output 19(int)
- 54(a): 53(ptr) Variable Output
- 55: TypePointer Function 19(int)
- 58: TypePointer Output 6(float)
- 59(b): 58(ptr) Variable Output
- 60: 19(int) Constant 1
- 61: TypePointer Function 6(float)
- 64: TypePointer Output 20(bool)
- 65(c): 64(ptr) Variable Output
- 68: TypePointer Output 7(fvec4)
- 69(v): 68(ptr) Variable Output
- 73: TypePointer Input 7(fvec4)
- 74(input): 73(ptr) Variable Input
+ 53: TypeVector 6(float) 2
+ 54: 13(int) Constant 4
+ 55: TypeArray 53(fvec2) 54
+ 56: TypePointer Function 55
+ 58: 53(fvec2) ConstantComposite 10 10
+ 59: 55 ConstantComposite 58 58 58 58
+ 60: TypePointer Function 19(int)
+ 62: 19(int) Constant 1
+ 63: 13(int) Constant 1
+ 64: TypePointer Function 6(float)
+ 71: TypePointer Output 19(int)
+ 72(a): 71(ptr) Variable Output
+ 75: TypePointer Output 6(float)
+ 76(b): 75(ptr) Variable Output
+ 79: TypePointer Output 20(bool)
+ 80(c): 79(ptr) Variable Output
+ 83: TypePointer Output 7(fvec4)
+ 84(v): 83(ptr) Variable Output
+ 88: TypePointer Input 7(fvec4)
+ 89(input): 88(ptr) Variable Input
+ 90: TypeArray 53(fvec2) 14
+ 91: 90 ConstantComposite 58 58 58
4(PixelShaderFunction): 2 Function None 3
5: Label
23(o2): 22(ptr) Variable Function
@@ -385,6 +481,8 @@ gl_FragCoord origin is upper left
37(o1): 22(ptr) Variable Function
40(o3): 22(ptr) Variable Function
49(nest): 48(ptr) Variable Function
+ 57(gf2a): 56(ptr) Variable Function
+ 61(cgi): 60(ptr) Variable Function
Store 9(gv) 12
Store 17(gfa) 18
Store 23(o2) 27
@@ -402,17 +500,26 @@ gl_FragCoord origin is upper left
44: 41(ptr) AccessChain 28(o4) 30
Store 44 43
Store 49(nest) 52
- 56: 55(ptr) AccessChain 28(o4) 38
- 57: 19(int) Load 56
- Store 54(a) 57
- 62: 61(ptr) AccessChain 28(o4) 60
- 63: 6(float) Load 62
- Store 59(b) 63
- 66: 41(ptr) AccessChain 28(o4) 30
- 67: 20(bool) Load 66
- Store 65(c) 67
- 70: 35(ptr) AccessChain 28(o4) 24
- 71: 7(fvec4) Load 70
- Store 69(v) 71
+ Store 57(gf2a) 59
+ Store 61(cgi) 38
+ 65: 64(ptr) AccessChain 57(gf2a) 30 63
+ 66: 6(float) Load 65
+ 67: 19(int) Load 61(cgi)
+ 68: 6(float) ConvertSToF 67
+ 69: 6(float) FMul 66 68
+ 70: 64(ptr) AccessChain 28(o4) 62
+ Store 70 69
+ 73: 60(ptr) AccessChain 28(o4) 38
+ 74: 19(int) Load 73
+ Store 72(a) 74
+ 77: 64(ptr) AccessChain 28(o4) 62
+ 78: 6(float) Load 77
+ Store 76(b) 78
+ 81: 41(ptr) AccessChain 28(o4) 30
+ 82: 20(bool) Load 81
+ Store 80(c) 82
+ 85: 35(ptr) AccessChain 28(o4) 24
+ 86: 7(fvec4) Load 85
+ Store 84(v) 86
Return
FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.rw.swizzle.frag.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.rw.swizzle.frag.out
new file mode 100644
index 00000000000..807fa681eac
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.rw.swizzle.frag.out
@@ -0,0 +1,286 @@
+hlsl.rw.swizzle.frag
+Shader version: 450
+gl_FragCoord origin is upper left
+0:? Sequence
+0:4 Function Definition: SomeValue( (temp 3-component vector of float)
+0:4 Function Parameters:
+0:? Sequence
+0:4 Branch: Return with expression
+0:? Constant:
+0:? 1.000000
+0:? 2.000000
+0:? 3.000000
+0:7 Function Definition: main( (temp 4-component vector of float)
+0:7 Function Parameters:
+0:? Sequence
+0:8 Sequence
+0:8 move second child to first child (temp 2-component vector of int)
+0:8 'tc2' (temp 2-component vector of int)
+0:8 Constant:
+0:8 0 (const int)
+0:8 0 (const int)
+0:9 Sequence
+0:9 move second child to first child (temp int)
+0:9 'tc' (temp int)
+0:9 Constant:
+0:9 0 (const int)
+0:12 Sequence
+0:12 move second child to first child (temp 3-component vector of float)
+0:12 vector swizzle (temp 3-component vector of float)
+0:12 'storeTemp' (temp 3-component vector of float)
+0:12 Sequence
+0:12 Constant:
+0:12 2 (const int)
+0:12 Constant:
+0:12 1 (const int)
+0:12 Constant:
+0:12 0 (const int)
+0:? Constant:
+0:? 1.000000
+0:? 2.000000
+0:? 3.000000
+0:12 imageStore (temp void)
+0:12 'rwtx' (layout(rgba32f ) uniform image2D)
+0:12 'tc2' (temp 2-component vector of int)
+0:12 'storeTemp' (temp 3-component vector of float)
+0:12 'storeTemp' (temp 3-component vector of float)
+0:13 Sequence
+0:13 move second child to first child (temp 3-component vector of float)
+0:13 vector swizzle (temp 3-component vector of float)
+0:13 'storeTemp' (temp 3-component vector of float)
+0:13 Sequence
+0:13 Constant:
+0:13 2 (const int)
+0:13 Constant:
+0:13 1 (const int)
+0:13 Constant:
+0:13 0 (const int)
+0:13 Function Call: SomeValue( (temp 3-component vector of float)
+0:13 imageStore (temp void)
+0:13 'rwtx' (layout(rgba32f ) uniform image2D)
+0:13 'tc2' (temp 2-component vector of int)
+0:13 'storeTemp' (temp 3-component vector of float)
+0:13 'storeTemp' (temp 3-component vector of float)
+0:14 Sequence
+0:14 move second child to first child (temp 3-component vector of float)
+0:14 vector swizzle (temp 3-component vector of float)
+0:14 'storeTemp' (temp 3-component vector of float)
+0:14 Sequence
+0:14 Constant:
+0:14 2 (const int)
+0:14 Constant:
+0:14 1 (const int)
+0:14 Constant:
+0:14 0 (const int)
+0:14 Constant:
+0:14 2.000000
+0:14 2.000000
+0:14 2.000000
+0:14 imageStore (temp void)
+0:14 'rwtx' (layout(rgba32f ) uniform image2D)
+0:14 'tc2' (temp 2-component vector of int)
+0:14 'storeTemp' (temp 3-component vector of float)
+0:14 'storeTemp' (temp 3-component vector of float)
+0:27 Sequence
+0:27 move second child to first child (temp 4-component vector of float)
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
+0:27 Constant:
+0:27 0.000000
+0:27 0.000000
+0:27 0.000000
+0:27 0.000000
+0:27 Branch: Return
+0:? Linker Objects
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
+0:? 'rwtx' (layout(rgba32f ) uniform image2D)
+0:? 'buf' (layout(rgba32f ) uniform imageBuffer)
+
+
+Linked fragment stage:
+
+
+Shader version: 450
+gl_FragCoord origin is upper left
+0:? Sequence
+0:4 Function Definition: SomeValue( (temp 3-component vector of float)
+0:4 Function Parameters:
+0:? Sequence
+0:4 Branch: Return with expression
+0:? Constant:
+0:? 1.000000
+0:? 2.000000
+0:? 3.000000
+0:7 Function Definition: main( (temp 4-component vector of float)
+0:7 Function Parameters:
+0:? Sequence
+0:8 Sequence
+0:8 move second child to first child (temp 2-component vector of int)
+0:8 'tc2' (temp 2-component vector of int)
+0:8 Constant:
+0:8 0 (const int)
+0:8 0 (const int)
+0:9 Sequence
+0:9 move second child to first child (temp int)
+0:9 'tc' (temp int)
+0:9 Constant:
+0:9 0 (const int)
+0:12 Sequence
+0:12 move second child to first child (temp 3-component vector of float)
+0:12 vector swizzle (temp 3-component vector of float)
+0:12 'storeTemp' (temp 3-component vector of float)
+0:12 Sequence
+0:12 Constant:
+0:12 2 (const int)
+0:12 Constant:
+0:12 1 (const int)
+0:12 Constant:
+0:12 0 (const int)
+0:? Constant:
+0:? 1.000000
+0:? 2.000000
+0:? 3.000000
+0:12 imageStore (temp void)
+0:12 'rwtx' (layout(rgba32f ) uniform image2D)
+0:12 'tc2' (temp 2-component vector of int)
+0:12 'storeTemp' (temp 3-component vector of float)
+0:12 'storeTemp' (temp 3-component vector of float)
+0:13 Sequence
+0:13 move second child to first child (temp 3-component vector of float)
+0:13 vector swizzle (temp 3-component vector of float)
+0:13 'storeTemp' (temp 3-component vector of float)
+0:13 Sequence
+0:13 Constant:
+0:13 2 (const int)
+0:13 Constant:
+0:13 1 (const int)
+0:13 Constant:
+0:13 0 (const int)
+0:13 Function Call: SomeValue( (temp 3-component vector of float)
+0:13 imageStore (temp void)
+0:13 'rwtx' (layout(rgba32f ) uniform image2D)
+0:13 'tc2' (temp 2-component vector of int)
+0:13 'storeTemp' (temp 3-component vector of float)
+0:13 'storeTemp' (temp 3-component vector of float)
+0:14 Sequence
+0:14 move second child to first child (temp 3-component vector of float)
+0:14 vector swizzle (temp 3-component vector of float)
+0:14 'storeTemp' (temp 3-component vector of float)
+0:14 Sequence
+0:14 Constant:
+0:14 2 (const int)
+0:14 Constant:
+0:14 1 (const int)
+0:14 Constant:
+0:14 0 (const int)
+0:14 Constant:
+0:14 2.000000
+0:14 2.000000
+0:14 2.000000
+0:14 imageStore (temp void)
+0:14 'rwtx' (layout(rgba32f ) uniform image2D)
+0:14 'tc2' (temp 2-component vector of int)
+0:14 'storeTemp' (temp 3-component vector of float)
+0:14 'storeTemp' (temp 3-component vector of float)
+0:27 Sequence
+0:27 move second child to first child (temp 4-component vector of float)
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
+0:27 Constant:
+0:27 0.000000
+0:27 0.000000
+0:27 0.000000
+0:27 0.000000
+0:27 Branch: Return
+0:? Linker Objects
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
+0:? 'rwtx' (layout(rgba32f ) uniform image2D)
+0:? 'buf' (layout(rgba32f ) uniform imageBuffer)
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 58
+
+ Capability Shader
+ Capability SampledBuffer
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Fragment 4 "main" 51
+ ExecutionMode 4 OriginUpperLeft
+ Name 4 "main"
+ Name 9 "SomeValue("
+ Name 20 "tc2"
+ Name 24 "tc"
+ Name 26 "storeTemp"
+ Name 31 "rwtx"
+ Name 35 "storeTemp"
+ Name 42 "storeTemp"
+ Name 51 "@entryPointOutput"
+ Name 57 "buf"
+ Decorate 31(rwtx) DescriptorSet 0
+ Decorate 51(@entryPointOutput) Location 0
+ Decorate 57(buf) DescriptorSet 0
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeFloat 32
+ 7: TypeVector 6(float) 3
+ 8: TypeFunction 7(fvec3)
+ 11: 6(float) Constant 1065353216
+ 12: 6(float) Constant 1073741824
+ 13: 6(float) Constant 1077936128
+ 14: 7(fvec3) ConstantComposite 11 12 13
+ 17: TypeInt 32 1
+ 18: TypeVector 17(int) 2
+ 19: TypePointer Function 18(ivec2)
+ 21: 17(int) Constant 0
+ 22: 18(ivec2) ConstantComposite 21 21
+ 23: TypePointer Function 17(int)
+ 25: TypePointer Function 7(fvec3)
+ 29: TypeImage 6(float) 2D nonsampled format:Rgba32f
+ 30: TypePointer UniformConstant 29
+ 31(rwtx): 30(ptr) Variable UniformConstant
+ 43: 7(fvec3) ConstantComposite 12 12 12
+ 49: TypeVector 6(float) 4
+ 50: TypePointer Output 49(fvec4)
+51(@entryPointOutput): 50(ptr) Variable Output
+ 52: 6(float) Constant 0
+ 53: 49(fvec4) ConstantComposite 52 52 52 52
+ 55: TypeImage 6(float) Buffer nonsampled format:Rgba32f
+ 56: TypePointer UniformConstant 55
+ 57(buf): 56(ptr) Variable UniformConstant
+ 4(main): 2 Function None 3
+ 5: Label
+ 20(tc2): 19(ptr) Variable Function
+ 24(tc): 23(ptr) Variable Function
+ 26(storeTemp): 25(ptr) Variable Function
+ 35(storeTemp): 25(ptr) Variable Function
+ 42(storeTemp): 25(ptr) Variable Function
+ Store 20(tc2) 22
+ Store 24(tc) 21
+ 27: 7(fvec3) Load 26(storeTemp)
+ 28: 7(fvec3) VectorShuffle 27 14 5 4 3
+ Store 26(storeTemp) 28
+ 32: 29 Load 31(rwtx)
+ 33: 18(ivec2) Load 20(tc2)
+ 34: 7(fvec3) Load 26(storeTemp)
+ ImageWrite 32 33 34
+ 36: 7(fvec3) FunctionCall 9(SomeValue()
+ 37: 7(fvec3) Load 35(storeTemp)
+ 38: 7(fvec3) VectorShuffle 37 36 5 4 3
+ Store 35(storeTemp) 38
+ 39: 29 Load 31(rwtx)
+ 40: 18(ivec2) Load 20(tc2)
+ 41: 7(fvec3) Load 35(storeTemp)
+ ImageWrite 39 40 41
+ 44: 7(fvec3) Load 42(storeTemp)
+ 45: 7(fvec3) VectorShuffle 44 43 5 4 3
+ Store 42(storeTemp) 45
+ 46: 29 Load 31(rwtx)
+ 47: 18(ivec2) Load 20(tc2)
+ 48: 7(fvec3) Load 42(storeTemp)
+ ImageWrite 46 47 48
+ Store 51(@entryPointOutput) 53
+ Return
+ FunctionEnd
+ 9(SomeValue(): 7(fvec3) Function None 8
+ 10: Label
+ ReturnValue 14
+ FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.samplegrad.basic.dx10.vert.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.samplegrad.basic.dx10.vert.out
index f6d37c3be2e..1f438cee479 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.samplegrad.basic.dx10.vert.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.samplegrad.basic.dx10.vert.out
@@ -1,7 +1,7 @@
hlsl.samplegrad.basic.dx10.vert
Shader version: 450
0:? Sequence
-0:27 Function Definition: main( (temp structure{temp 4-component vector of float Pos})
+0:27 Function Definition: main( (temp structure{temp 4-component vector of float Position Pos})
0:27 Function Parameters:
0:? Sequence
0:30 Sequence
@@ -225,7 +225,6 @@ Shader version: 450
0:48 0 (const int)
0:48 Branch: Return
0:? Linker Objects
-0:? 'Pos' (out 4-component vector of float Position)
0:? 'g_sSamp' (layout(binding=0 ) uniform sampler)
0:? 'g_tTex1df4a' (layout(binding=1 ) uniform texture1D)
0:? 'g_tTex1df4' (layout(binding=0 ) uniform texture1D)
@@ -240,6 +239,7 @@ Shader version: 450
0:? 'g_tTexcdf4' (uniform textureCube)
0:? 'g_tTexcdi4' (uniform itextureCube)
0:? 'g_tTexcdu4' (uniform utextureCube)
+0:? 'PerVertex_out' (out block{out 4-component vector of float Position Pos})
Linked vertex stage:
@@ -247,7 +247,7 @@ Linked vertex stage:
Shader version: 450
0:? Sequence
-0:27 Function Definition: main( (temp structure{temp 4-component vector of float Pos})
+0:27 Function Definition: main( (temp structure{temp 4-component vector of float Position Pos})
0:27 Function Parameters:
0:? Sequence
0:30 Sequence
@@ -471,7 +471,6 @@ Shader version: 450
0:48 0 (const int)
0:48 Branch: Return
0:? Linker Objects
-0:? 'Pos' (out 4-component vector of float Position)
0:? 'g_sSamp' (layout(binding=0 ) uniform sampler)
0:? 'g_tTex1df4a' (layout(binding=1 ) uniform texture1D)
0:? 'g_tTex1df4' (layout(binding=0 ) uniform texture1D)
@@ -486,16 +485,17 @@ Shader version: 450
0:? 'g_tTexcdf4' (uniform textureCube)
0:? 'g_tTexcdi4' (uniform itextureCube)
0:? 'g_tTexcdu4' (uniform utextureCube)
+0:? 'PerVertex_out' (out block{out 4-component vector of float Position Pos})
// Module Version 10000
// Generated by (magic number): 80001
-// Id's are bound by 161
+// Id's are bound by 164
Capability Shader
Capability Sampled1D
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
- EntryPoint Vertex 4 "main" 156
+ EntryPoint Vertex 4 "main" 156 163
Name 4 "main"
Name 9 "txval10"
Name 12 "g_tTex1df4"
@@ -527,6 +527,9 @@ Shader version: 450
Name 150 "vsout"
Name 156 "Pos"
Name 160 "g_tTex1df4a"
+ Name 161 "PerVertex_out"
+ MemberName 161(PerVertex_out) 0 "Pos"
+ Name 163 "PerVertex_out"
Decorate 12(g_tTex1df4) DescriptorSet 0
Decorate 12(g_tTex1df4) Binding 0
Decorate 16(g_sSamp) DescriptorSet 0
@@ -545,6 +548,8 @@ Shader version: 450
Decorate 156(Pos) BuiltIn Position
Decorate 160(g_tTex1df4a) DescriptorSet 0
Decorate 160(g_tTex1df4a) Binding 1
+ MemberDecorate 161(PerVertex_out) 0 BuiltIn Position
+ Decorate 161(PerVertex_out) Block
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@@ -637,6 +642,9 @@ Shader version: 450
155: TypePointer Output 7(fvec4)
156(Pos): 155(ptr) Variable Output
160(g_tTex1df4a): 11(ptr) Variable UniformConstant
+161(PerVertex_out): TypeStruct 7(fvec4)
+ 162: TypePointer Output 161(PerVertex_out)
+163(PerVertex_out): 162(ptr) Variable Output
4(main): 2 Function None 3
5: Label
9(txval10): 8(ptr) Variable Function
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.samplelevel.basic.dx10.vert.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.samplelevel.basic.dx10.vert.out
index 04d0870e275..a811ed256fb 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.samplelevel.basic.dx10.vert.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.samplelevel.basic.dx10.vert.out
@@ -1,7 +1,7 @@
hlsl.samplelevel.basic.dx10.vert
Shader version: 450
0:? Sequence
-0:27 Function Definition: main( (temp structure{temp 4-component vector of float Pos})
+0:27 Function Definition: main( (temp structure{temp 4-component vector of float Position Pos})
0:27 Function Parameters:
0:? Sequence
0:30 Sequence
@@ -171,7 +171,6 @@ Shader version: 450
0:48 0 (const int)
0:48 Branch: Return
0:? Linker Objects
-0:? 'Pos' (out 4-component vector of float Position)
0:? 'g_sSamp' (layout(binding=0 ) uniform sampler)
0:? 'g_tTex1df4a' (layout(binding=1 ) uniform texture1D)
0:? 'g_tTex1df4' (layout(binding=0 ) uniform texture1D)
@@ -186,6 +185,7 @@ Shader version: 450
0:? 'g_tTexcdf4' (uniform textureCube)
0:? 'g_tTexcdi4' (uniform itextureCube)
0:? 'g_tTexcdu4' (uniform utextureCube)
+0:? 'PerVertex_out' (out block{out 4-component vector of float Position Pos})
Linked vertex stage:
@@ -193,7 +193,7 @@ Linked vertex stage:
Shader version: 450
0:? Sequence
-0:27 Function Definition: main( (temp structure{temp 4-component vector of float Pos})
+0:27 Function Definition: main( (temp structure{temp 4-component vector of float Position Pos})
0:27 Function Parameters:
0:? Sequence
0:30 Sequence
@@ -363,7 +363,6 @@ Shader version: 450
0:48 0 (const int)
0:48 Branch: Return
0:? Linker Objects
-0:? 'Pos' (out 4-component vector of float Position)
0:? 'g_sSamp' (layout(binding=0 ) uniform sampler)
0:? 'g_tTex1df4a' (layout(binding=1 ) uniform texture1D)
0:? 'g_tTex1df4' (layout(binding=0 ) uniform texture1D)
@@ -378,16 +377,17 @@ Shader version: 450
0:? 'g_tTexcdf4' (uniform textureCube)
0:? 'g_tTexcdi4' (uniform itextureCube)
0:? 'g_tTexcdu4' (uniform utextureCube)
+0:? 'PerVertex_out' (out block{out 4-component vector of float Position Pos})
// Module Version 10000
// Generated by (magic number): 80001
-// Id's are bound by 157
+// Id's are bound by 160
Capability Shader
Capability Sampled1D
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
- EntryPoint Vertex 4 "main" 152
+ EntryPoint Vertex 4 "main" 152 159
Name 4 "main"
Name 9 "txval10"
Name 12 "g_tTex1df4"
@@ -419,6 +419,9 @@ Shader version: 450
Name 146 "vsout"
Name 152 "Pos"
Name 156 "g_tTex1df4a"
+ Name 157 "PerVertex_out"
+ MemberName 157(PerVertex_out) 0 "Pos"
+ Name 159 "PerVertex_out"
Decorate 12(g_tTex1df4) DescriptorSet 0
Decorate 12(g_tTex1df4) Binding 0
Decorate 16(g_sSamp) DescriptorSet 0
@@ -437,6 +440,8 @@ Shader version: 450
Decorate 152(Pos) BuiltIn Position
Decorate 156(g_tTex1df4a) DescriptorSet 0
Decorate 156(g_tTex1df4a) Binding 1
+ MemberDecorate 157(PerVertex_out) 0 BuiltIn Position
+ Decorate 157(PerVertex_out) Block
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@@ -525,6 +530,9 @@ Shader version: 450
151: TypePointer Output 7(fvec4)
152(Pos): 151(ptr) Variable Output
156(g_tTex1df4a): 11(ptr) Variable UniformConstant
+157(PerVertex_out): TypeStruct 7(fvec4)
+ 158: TypePointer Output 157(PerVertex_out)
+159(PerVertex_out): 158(ptr) Variable Output
4(main): 2 Function None 3
5: Label
9(txval10): 8(ptr) Variable Function
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.frag.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.frag.out
index c14018ea232..3c94ffaed18 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.frag.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.frag.out
@@ -9,7 +9,7 @@ gl_FragCoord origin is upper left
0:34 Function Definition: PixelShaderFunction(vf4;struct-IN_S-vf4-b1-vf1-vf2-b1-b1-b1-vf41; (temp 4-component vector of float)
0:34 Function Parameters:
0:34 'input' (layout(location=0 ) in 4-component vector of float)
-0:34 's' (in structure{temp 4-component vector of float a, temp bool b, temp 1-component vector of float c, temp 2-component vector of float d, temp bool ff1, temp bool ff2, temp bool ff3, temp 4-component vector of float ff4})
+0:34 's' (in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool Face ff1, layout(offset=4 ) temp bool ff2, layout(binding=0 offset=4 ) temp bool ff3, layout(binding=0 offset=4 ) temp 4-component vector of float ff4})
0:? Sequence
0:39 Compare Equal (temp bool)
0:39 's3' (temp structure{temp 3-component vector of bool b3})
@@ -19,7 +19,10 @@ gl_FragCoord origin is upper left
0:40 's2' (global structure{temp 4-component vector of float i})
0:40 Constant:
0:40 0 (const int)
-0:? 'ff4' (layout(location=7 binding=0 offset=4 ) in 4-component vector of float)
+0:40 ff4: direct index for structure (layout(binding=0 offset=4 ) temp 4-component vector of float)
+0:40 's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, layout(offset=4 ) temp bool ff2, layout(binding=0 offset=4 ) temp bool ff3, layout(binding=0 offset=4 ) temp 4-component vector of float ff4})
+0:40 Constant:
+0:40 6 (const int)
0:42 Sequence
0:42 move second child to first child (temp 4-component vector of float)
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
@@ -28,16 +31,10 @@ gl_FragCoord origin is upper left
0:? Linker Objects
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
0:? 'input' (layout(location=0 ) in 4-component vector of float)
-0:? 'a' (layout(location=1 ) smooth in 4-component vector of float)
-0:? 'b' (layout(location=2 ) flat in bool)
-0:? 'c' (layout(location=3 ) centroid noperspective in 1-component vector of float)
-0:? 'd' (layout(location=4 ) centroid sample in 2-component vector of float)
-0:? 'ff1' (in bool Face)
-0:? 'ff2' (layout(location=5 offset=4 ) in bool)
-0:? 'ff3' (layout(location=6 binding=0 offset=4 ) in bool)
-0:? 'ff4' (layout(location=7 binding=0 offset=4 ) in 4-component vector of float)
+0:? 's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, layout(offset=4 ) temp bool ff2, layout(binding=0 offset=4 ) temp bool ff3, layout(binding=0 offset=4 ) temp 4-component vector of float ff4})
0:? 's2' (global structure{temp 4-component vector of float i})
0:? 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform structure{temp bool b, temp bool c, temp 4-component vector of float a, temp 4-component vector of float d} s1, layout(binding=5 offset=1620 ) uniform float ff5, layout(binding=8 offset=1636 ) uniform float ff6})
+0:? 's_ff1' (in bool Face)
Linked fragment stage:
@@ -49,7 +46,7 @@ gl_FragCoord origin is upper left
0:34 Function Definition: PixelShaderFunction(vf4;struct-IN_S-vf4-b1-vf1-vf2-b1-b1-b1-vf41; (temp 4-component vector of float)
0:34 Function Parameters:
0:34 'input' (layout(location=0 ) in 4-component vector of float)
-0:34 's' (in structure{temp 4-component vector of float a, temp bool b, temp 1-component vector of float c, temp 2-component vector of float d, temp bool ff1, temp bool ff2, temp bool ff3, temp 4-component vector of float ff4})
+0:34 's' (in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool Face ff1, layout(offset=4 ) temp bool ff2, layout(binding=0 offset=4 ) temp bool ff3, layout(binding=0 offset=4 ) temp 4-component vector of float ff4})
0:? Sequence
0:39 Compare Equal (temp bool)
0:39 's3' (temp structure{temp 3-component vector of bool b3})
@@ -59,7 +56,10 @@ gl_FragCoord origin is upper left
0:40 's2' (global structure{temp 4-component vector of float i})
0:40 Constant:
0:40 0 (const int)
-0:? 'ff4' (layout(location=7 binding=0 offset=4 ) in 4-component vector of float)
+0:40 ff4: direct index for structure (layout(binding=0 offset=4 ) temp 4-component vector of float)
+0:40 's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, layout(offset=4 ) temp bool ff2, layout(binding=0 offset=4 ) temp bool ff3, layout(binding=0 offset=4 ) temp 4-component vector of float ff4})
+0:40 Constant:
+0:40 6 (const int)
0:42 Sequence
0:42 move second child to first child (temp 4-component vector of float)
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
@@ -68,25 +68,19 @@ gl_FragCoord origin is upper left
0:? Linker Objects
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
0:? 'input' (layout(location=0 ) in 4-component vector of float)
-0:? 'a' (layout(location=1 ) smooth in 4-component vector of float)
-0:? 'b' (layout(location=2 ) flat in bool)
-0:? 'c' (layout(location=3 ) centroid noperspective in 1-component vector of float)
-0:? 'd' (layout(location=4 ) centroid sample in 2-component vector of float)
-0:? 'ff1' (in bool Face)
-0:? 'ff2' (layout(location=5 offset=4 ) in bool)
-0:? 'ff3' (layout(location=6 binding=0 offset=4 ) in bool)
-0:? 'ff4' (layout(location=7 binding=0 offset=4 ) in 4-component vector of float)
+0:? 's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, layout(offset=4 ) temp bool ff2, layout(binding=0 offset=4 ) temp bool ff3, layout(binding=0 offset=4 ) temp 4-component vector of float ff4})
0:? 's2' (global structure{temp 4-component vector of float i})
0:? 'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform structure{temp bool b, temp bool c, temp 4-component vector of float a, temp 4-component vector of float d} s1, layout(binding=5 offset=1620 ) uniform float ff5, layout(binding=8 offset=1636 ) uniform float ff6})
+0:? 's_ff1' (in bool Face)
// Module Version 10000
// Generated by (magic number): 80001
-// Id's are bound by 50
+// Id's are bound by 46
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
- EntryPoint Fragment 4 "PixelShaderFunction" 25 30 31 34 36 38 41 42 43 44
+ EntryPoint Fragment 4 "PixelShaderFunction" 27 35 36 45
ExecutionMode 4 OriginUpperLeft
Name 4 "PixelShaderFunction"
Name 8 "FS"
@@ -95,54 +89,41 @@ gl_FragCoord origin is upper left
Name 19 ""
MemberName 19 0 "i"
Name 21 "s2"
- Name 25 "ff4"
- Name 30 "@entryPointOutput"
- Name 31 "input"
- Name 34 "a"
- Name 36 "b"
- Name 38 "c"
- Name 41 "d"
- Name 42 "ff1"
- Name 43 "ff2"
- Name 44 "ff3"
- Name 46 "myS"
- MemberName 46(myS) 0 "b"
- MemberName 46(myS) 1 "c"
- MemberName 46(myS) 2 "a"
- MemberName 46(myS) 3 "d"
- Name 47 "$Global"
- MemberName 47($Global) 0 "s1"
- MemberName 47($Global) 1 "ff5"
- MemberName 47($Global) 2 "ff6"
- Name 49 ""
- Decorate 25(ff4) Offset 4
- Decorate 25(ff4) Location 7
- Decorate 25(ff4) Binding 0
- Decorate 30(@entryPointOutput) Location 0
- Decorate 31(input) Location 0
- Decorate 34(a) Location 1
- Decorate 36(b) Flat
- Decorate 36(b) Location 2
- Decorate 38(c) NoPerspective
- Decorate 38(c) Centroid
- Decorate 38(c) Location 3
- Decorate 41(d) Centroid
- Decorate 41(d) Location 4
- Decorate 42(ff1) BuiltIn FrontFacing
- Decorate 43(ff2) Offset 4
- Decorate 43(ff2) Location 5
- Decorate 44(ff3) Offset 4
- Decorate 44(ff3) Location 6
- Decorate 44(ff3) Binding 0
- MemberDecorate 46(myS) 0 Offset 0
- MemberDecorate 46(myS) 1 Offset 4
- MemberDecorate 46(myS) 2 Offset 16
- MemberDecorate 46(myS) 3 Offset 32
- MemberDecorate 47($Global) 0 Offset 0
- MemberDecorate 47($Global) 1 Offset 1620
- MemberDecorate 47($Global) 2 Offset 1636
- Decorate 47($Global) Block
- Decorate 49 DescriptorSet 0
+ Name 25 "IN_S"
+ MemberName 25(IN_S) 0 "a"
+ MemberName 25(IN_S) 1 "b"
+ MemberName 25(IN_S) 2 "c"
+ MemberName 25(IN_S) 3 "d"
+ MemberName 25(IN_S) 4 "ff2"
+ MemberName 25(IN_S) 5 "ff3"
+ MemberName 25(IN_S) 6 "ff4"
+ Name 27 "s"
+ Name 35 "@entryPointOutput"
+ Name 36 "input"
+ Name 40 "myS"
+ MemberName 40(myS) 0 "b"
+ MemberName 40(myS) 1 "c"
+ MemberName 40(myS) 2 "a"
+ MemberName 40(myS) 3 "d"
+ Name 41 "$Global"
+ MemberName 41($Global) 0 "s1"
+ MemberName 41($Global) 1 "ff5"
+ MemberName 41($Global) 2 "ff6"
+ Name 43 ""
+ Name 45 "s_ff1"
+ Decorate 27(s) Location 1
+ Decorate 35(@entryPointOutput) Location 0
+ Decorate 36(input) Location 0
+ MemberDecorate 40(myS) 0 Offset 0
+ MemberDecorate 40(myS) 1 Offset 4
+ MemberDecorate 40(myS) 2 Offset 16
+ MemberDecorate 40(myS) 3 Offset 32
+ MemberDecorate 41($Global) 0 Offset 0
+ MemberDecorate 41($Global) 1 Offset 1620
+ MemberDecorate 41($Global) 2 Offset 1636
+ Decorate 41($Global) Block
+ Decorate 43 DescriptorSet 0
+ Decorate 45(s_ff1) BuiltIn FrontFacing
2: TypeVoid
3: TypeFunction 2
6: TypeBool
@@ -156,28 +137,23 @@ gl_FragCoord origin is upper left
21(s2): 20(ptr) Variable Private
22: TypeInt 32 1
23: 22(int) Constant 0
- 24: TypePointer Input 18(fvec4)
- 25(ff4): 24(ptr) Variable Input
- 27: TypePointer Private 18(fvec4)
- 29: TypePointer Output 18(fvec4)
-30(@entryPointOutput): 29(ptr) Variable Output
- 31(input): 24(ptr) Variable Input
- 34(a): 24(ptr) Variable Input
- 35: TypePointer Input 6(bool)
- 36(b): 35(ptr) Variable Input
- 37: TypePointer Input 17(float)
- 38(c): 37(ptr) Variable Input
- 39: TypeVector 17(float) 2
- 40: TypePointer Input 39(fvec2)
- 41(d): 40(ptr) Variable Input
- 42(ff1): 35(ptr) Variable Input
- 43(ff2): 35(ptr) Variable Input
- 44(ff3): 35(ptr) Variable Input
- 45: TypeInt 32 0
- 46(myS): TypeStruct 45(int) 45(int) 18(fvec4) 18(fvec4)
- 47($Global): TypeStruct 46(myS) 17(float) 17(float)
- 48: TypePointer Uniform 47($Global)
- 49: 48(ptr) Variable Uniform
+ 24: TypeVector 17(float) 2
+ 25(IN_S): TypeStruct 18(fvec4) 6(bool) 17(float) 24(fvec2) 6(bool) 6(bool) 18(fvec4)
+ 26: TypePointer Input 25(IN_S)
+ 27(s): 26(ptr) Variable Input
+ 28: 22(int) Constant 6
+ 29: TypePointer Input 18(fvec4)
+ 32: TypePointer Private 18(fvec4)
+ 34: TypePointer Output 18(fvec4)
+35(@entryPointOutput): 34(ptr) Variable Output
+ 36(input): 29(ptr) Variable Input
+ 39: TypeInt 32 0
+ 40(myS): TypeStruct 39(int) 39(int) 18(fvec4) 18(fvec4)
+ 41($Global): TypeStruct 40(myS) 17(float) 17(float)
+ 42: TypePointer Uniform 41($Global)
+ 43: 42(ptr) Variable Uniform
+ 44: TypePointer Input 6(bool)
+ 45(s_ff1): 44(ptr) Variable Input
4(PixelShaderFunction): 2 Function None 3
5: Label
10(s3): 9(ptr) Variable Function
@@ -187,10 +163,11 @@ gl_FragCoord origin is upper left
14: 7(bvec3) CompositeExtract 12 0
15: 7(bvec3) LogicalEqual 13 14
16: 6(bool) All 15
- 26: 18(fvec4) Load 25(ff4)
- 28: 27(ptr) AccessChain 21(s2) 23
- Store 28 26
- 32: 18(fvec4) Load 31(input)
- Store 30(@entryPointOutput) 32
+ 30: 29(ptr) AccessChain 27(s) 28
+ 31: 18(fvec4) Load 30
+ 33: 32(ptr) AccessChain 21(s2) 23
+ Store 33 31
+ 37: 18(fvec4) Load 36(input)
+ Store 35(@entryPointOutput) 37
Return
FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split-1.vert.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split-1.vert.out
new file mode 100644
index 00000000000..a1c0c0c8191
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split-1.vert.out
@@ -0,0 +1,217 @@
+hlsl.struct.split-1.vert
+Shader version: 450
+0:? Sequence
+0:17 Function Definition: main(struct-VS_INPUT-i1-vf4-i11;vf4; (temp structure{temp int x0_out, temp 4-component vector of float Position Pos_out, temp int x1_out})
+0:17 Function Parameters:
+0:17 'vsin' (in structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
+0:17 'Pos_loose' (in 4-component vector of float Position)
+0:? Sequence
+0:20 move second child to first child (temp int)
+0:20 x0_out: direct index for structure (temp int)
+0:20 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:20 Constant:
+0:20 0 (const int)
+0:? 'x0_in' (layout(location=0 ) in int)
+0:21 move second child to first child (temp 4-component vector of float)
+0:21 Pos_out: direct index for structure (temp 4-component vector of float)
+0:21 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:21 Constant:
+0:21 1 (const int)
+0:21 add (temp 4-component vector of float)
+0:? 'Pos_in' (in 4-component vector of float Position)
+0:21 'Pos_loose' (in 4-component vector of float Position)
+0:22 move second child to first child (temp int)
+0:22 x1_out: direct index for structure (temp int)
+0:22 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:22 Constant:
+0:22 2 (const int)
+0:? 'x1_in' (layout(location=1 ) in int)
+0:24 Sequence
+0:24 Sequence
+0:24 move second child to first child (temp int)
+0:24 x0_out: direct index for structure (temp int)
+0:24 '@entryPointOutput' (layout(location=0 ) out structure{temp int x0_out, temp int x1_out})
+0:24 Constant:
+0:24 0 (const int)
+0:24 x0_out: direct index for structure (temp int)
+0:24 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:24 Constant:
+0:24 0 (const int)
+0:24 move second child to first child (temp 4-component vector of float)
+0:? 'Pos_out' (out 4-component vector of float Position)
+0:24 Pos_out: direct index for structure (temp 4-component vector of float)
+0:24 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:24 Constant:
+0:24 1 (const int)
+0:24 move second child to first child (temp int)
+0:24 x1_out: direct index for structure (temp int)
+0:24 '@entryPointOutput' (layout(location=0 ) out structure{temp int x0_out, temp int x1_out})
+0:24 Constant:
+0:24 1 (const int)
+0:24 x1_out: direct index for structure (temp int)
+0:24 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:24 Constant:
+0:24 2 (const int)
+0:24 Branch: Return
+0:? Linker Objects
+0:? '@entryPointOutput' (layout(location=0 ) out structure{temp int x0_out, temp int x1_out})
+0:? 'x0_in' (layout(location=0 ) in int)
+0:? 'Pos_in' (in 4-component vector of float Position)
+0:? 'x1_in' (layout(location=1 ) in int)
+0:? 'Pos_loose' (in 4-component vector of float Position)
+0:? 'PerVertex_out' (out block{out 4-component vector of float Position Pos_out})
+
+
+Linked vertex stage:
+
+
+Shader version: 450
+0:? Sequence
+0:17 Function Definition: main(struct-VS_INPUT-i1-vf4-i11;vf4; (temp structure{temp int x0_out, temp 4-component vector of float Position Pos_out, temp int x1_out})
+0:17 Function Parameters:
+0:17 'vsin' (in structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
+0:17 'Pos_loose' (in 4-component vector of float Position)
+0:? Sequence
+0:20 move second child to first child (temp int)
+0:20 x0_out: direct index for structure (temp int)
+0:20 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:20 Constant:
+0:20 0 (const int)
+0:? 'x0_in' (layout(location=0 ) in int)
+0:21 move second child to first child (temp 4-component vector of float)
+0:21 Pos_out: direct index for structure (temp 4-component vector of float)
+0:21 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:21 Constant:
+0:21 1 (const int)
+0:21 add (temp 4-component vector of float)
+0:? 'Pos_in' (in 4-component vector of float Position)
+0:21 'Pos_loose' (in 4-component vector of float Position)
+0:22 move second child to first child (temp int)
+0:22 x1_out: direct index for structure (temp int)
+0:22 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:22 Constant:
+0:22 2 (const int)
+0:? 'x1_in' (layout(location=1 ) in int)
+0:24 Sequence
+0:24 Sequence
+0:24 move second child to first child (temp int)
+0:24 x0_out: direct index for structure (temp int)
+0:24 '@entryPointOutput' (layout(location=0 ) out structure{temp int x0_out, temp int x1_out})
+0:24 Constant:
+0:24 0 (const int)
+0:24 x0_out: direct index for structure (temp int)
+0:24 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:24 Constant:
+0:24 0 (const int)
+0:24 move second child to first child (temp 4-component vector of float)
+0:? 'Pos_out' (out 4-component vector of float Position)
+0:24 Pos_out: direct index for structure (temp 4-component vector of float)
+0:24 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:24 Constant:
+0:24 1 (const int)
+0:24 move second child to first child (temp int)
+0:24 x1_out: direct index for structure (temp int)
+0:24 '@entryPointOutput' (layout(location=0 ) out structure{temp int x0_out, temp int x1_out})
+0:24 Constant:
+0:24 1 (const int)
+0:24 x1_out: direct index for structure (temp int)
+0:24 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:24 Constant:
+0:24 2 (const int)
+0:24 Branch: Return
+0:? Linker Objects
+0:? '@entryPointOutput' (layout(location=0 ) out structure{temp int x0_out, temp int x1_out})
+0:? 'x0_in' (layout(location=0 ) in int)
+0:? 'Pos_in' (in 4-component vector of float Position)
+0:? 'x1_in' (layout(location=1 ) in int)
+0:? 'Pos_loose' (in 4-component vector of float Position)
+0:? 'PerVertex_out' (out block{out 4-component vector of float Position Pos_out})
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 49
+
+ Capability Shader
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Vertex 4 "main" 14 20 22 28 33 39 48
+ Name 4 "main"
+ Name 9 "VS_OUTPUT"
+ MemberName 9(VS_OUTPUT) 0 "x0_out"
+ MemberName 9(VS_OUTPUT) 1 "Pos_out"
+ MemberName 9(VS_OUTPUT) 2 "x1_out"
+ Name 11 "vsout"
+ Name 14 "x0_in"
+ Name 20 "Pos_in"
+ Name 22 "Pos_loose"
+ Name 28 "x1_in"
+ Name 31 "VS_OUTPUT"
+ MemberName 31(VS_OUTPUT) 0 "x0_out"
+ MemberName 31(VS_OUTPUT) 1 "x1_out"
+ Name 33 "@entryPointOutput"
+ Name 39 "Pos_out"
+ Name 46 "PerVertex_out"
+ MemberName 46(PerVertex_out) 0 "Pos_out"
+ Name 48 "PerVertex_out"
+ Decorate 14(x0_in) Location 0
+ Decorate 20(Pos_in) BuiltIn Position
+ Decorate 22(Pos_loose) BuiltIn Position
+ Decorate 28(x1_in) Location 1
+ Decorate 33(@entryPointOutput) Location 0
+ Decorate 39(Pos_out) BuiltIn Position
+ MemberDecorate 46(PerVertex_out) 0 BuiltIn Position
+ Decorate 46(PerVertex_out) Block
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeInt 32 1
+ 7: TypeFloat 32
+ 8: TypeVector 7(float) 4
+ 9(VS_OUTPUT): TypeStruct 6(int) 8(fvec4) 6(int)
+ 10: TypePointer Function 9(VS_OUTPUT)
+ 12: 6(int) Constant 0
+ 13: TypePointer Input 6(int)
+ 14(x0_in): 13(ptr) Variable Input
+ 16: TypePointer Function 6(int)
+ 18: 6(int) Constant 1
+ 19: TypePointer Input 8(fvec4)
+ 20(Pos_in): 19(ptr) Variable Input
+ 22(Pos_loose): 19(ptr) Variable Input
+ 25: TypePointer Function 8(fvec4)
+ 27: 6(int) Constant 2
+ 28(x1_in): 13(ptr) Variable Input
+ 31(VS_OUTPUT): TypeStruct 6(int) 6(int)
+ 32: TypePointer Output 31(VS_OUTPUT)
+33(@entryPointOutput): 32(ptr) Variable Output
+ 36: TypePointer Output 6(int)
+ 38: TypePointer Output 8(fvec4)
+ 39(Pos_out): 38(ptr) Variable Output
+46(PerVertex_out): TypeStruct 8(fvec4)
+ 47: TypePointer Output 46(PerVertex_out)
+48(PerVertex_out): 47(ptr) Variable Output
+ 4(main): 2 Function None 3
+ 5: Label
+ 11(vsout): 10(ptr) Variable Function
+ 15: 6(int) Load 14(x0_in)
+ 17: 16(ptr) AccessChain 11(vsout) 12
+ Store 17 15
+ 21: 8(fvec4) Load 20(Pos_in)
+ 23: 8(fvec4) Load 22(Pos_loose)
+ 24: 8(fvec4) FAdd 21 23
+ 26: 25(ptr) AccessChain 11(vsout) 18
+ Store 26 24
+ 29: 6(int) Load 28(x1_in)
+ 30: 16(ptr) AccessChain 11(vsout) 27
+ Store 30 29
+ 34: 16(ptr) AccessChain 11(vsout) 12
+ 35: 6(int) Load 34
+ 37: 36(ptr) AccessChain 33(@entryPointOutput) 12
+ Store 37 35
+ 40: 25(ptr) AccessChain 11(vsout) 18
+ 41: 8(fvec4) Load 40
+ Store 39(Pos_out) 41
+ 42: 16(ptr) AccessChain 11(vsout) 27
+ 43: 6(int) Load 42
+ 44: 36(ptr) AccessChain 33(@entryPointOutput) 18
+ Store 44 43
+ Return
+ FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split.array.geom.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split.array.geom.out
new file mode 100644
index 00000000000..bc5b00d1cbb
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split.array.geom.out
@@ -0,0 +1,299 @@
+hlsl.struct.split.array.geom
+Shader version: 450
+invocations = -1
+max_vertices = 4
+input primitive = points
+output primitive = triangle_strip
+0:? Sequence
+0:13 Function Definition: main(u1[1];struct-PSInput-vf4-vf2-vf3-u11; (temp void)
+0:13 Function Parameters:
+0:13 'v' (layout(location=0 ) in 1-element array of uint)
+0:13 'OutputStream' (out structure{temp 4-component vector of float Position Pos, temp 2-component vector of float TexCoord, temp 3-component vector of float TerrainPos, temp uint VertexID})
+0:? Sequence
+0:16 Sequence
+0:16 move second child to first child (temp structure{temp 4-component vector of float Pos, temp 2-component vector of float TexCoord, temp 3-component vector of float TerrainPos, temp uint VertexID})
+0:16 'Out' (temp structure{temp 4-component vector of float Pos, temp 2-component vector of float TexCoord, temp 3-component vector of float TerrainPos, temp uint VertexID})
+0:16 Constant:
+0:16 0.000000
+0:16 0.000000
+0:16 0.000000
+0:16 0.000000
+0:16 0.000000
+0:16 0.000000
+0:16 0.000000
+0:16 0.000000
+0:16 0.000000
+0:16 0 (const uint)
+0:18 Sequence
+0:18 move second child to first child (temp int)
+0:18 'x' (temp int)
+0:18 Constant:
+0:18 0 (const int)
+0:18 Loop with condition tested first
+0:18 Loop Condition
+0:18 Compare Less Than (temp bool)
+0:18 'x' (temp int)
+0:18 Constant:
+0:18 2 (const int)
+0:18 Loop Body
+0:19 Sequence
+0:19 move second child to first child (temp int)
+0:19 'y' (temp int)
+0:19 Constant:
+0:19 0 (const int)
+0:19 Loop with condition tested first
+0:19 Loop Condition
+0:19 Compare Less Than (temp bool)
+0:19 'y' (temp int)
+0:19 Constant:
+0:19 2 (const int)
+0:19 Loop Body
+0:20 move second child to first child (temp structure{temp 4-component vector of float Pos, temp 2-component vector of float TexCoord, temp 3-component vector of float TerrainPos, temp uint VertexID})
+0:20 indirect index (temp structure{temp 4-component vector of float Pos, temp 2-component vector of float TexCoord, temp 3-component vector of float TerrainPos, temp uint VertexID})
+0:20 indirect index (temp 3-element array of structure{temp 4-component vector of float Pos, temp 2-component vector of float TexCoord, temp 3-component vector of float TerrainPos, temp uint VertexID})
+0:20 'Verts' (temp 2-element array of 3-element array of structure{temp 4-component vector of float Pos, temp 2-component vector of float TexCoord, temp 3-component vector of float TerrainPos, temp uint VertexID})
+0:20 'x' (temp int)
+0:20 'y' (temp int)
+0:20 'Out' (temp structure{temp 4-component vector of float Pos, temp 2-component vector of float TexCoord, temp 3-component vector of float TerrainPos, temp uint VertexID})
+0:19 Loop Terminal Expression
+0:19 Pre-Increment (temp int)
+0:19 'y' (temp int)
+0:18 Loop Terminal Expression
+0:18 Pre-Increment (temp int)
+0:18 'x' (temp int)
+0:? Linker Objects
+0:? 'v' (layout(location=0 ) in 1-element array of uint)
+0:? 'OutputStream' (layout(location=0 ) out structure{temp 2-component vector of float TexCoord, temp 3-component vector of float TerrainPos, temp uint VertexID})
+0:? 'PerVertex_out' (out block{out 4-component vector of float Position OutputStream_Pos})
+
+
+Linked geometry stage:
+
+
+Shader version: 450
+invocations = 1
+max_vertices = 4
+input primitive = points
+output primitive = triangle_strip
+0:? Sequence
+0:13 Function Definition: main(u1[1];struct-PSInput-vf4-vf2-vf3-u11; (temp void)
+0:13 Function Parameters:
+0:13 'v' (layout(location=0 ) in 1-element array of uint)
+0:13 'OutputStream' (out structure{temp 4-component vector of float Position Pos, temp 2-component vector of float TexCoord, temp 3-component vector of float TerrainPos, temp uint VertexID})
+0:? Sequence
+0:16 Sequence
+0:16 move second child to first child (temp structure{temp 4-component vector of float Pos, temp 2-component vector of float TexCoord, temp 3-component vector of float TerrainPos, temp uint VertexID})
+0:16 'Out' (temp structure{temp 4-component vector of float Pos, temp 2-component vector of float TexCoord, temp 3-component vector of float TerrainPos, temp uint VertexID})
+0:16 Constant:
+0:16 0.000000
+0:16 0.000000
+0:16 0.000000
+0:16 0.000000
+0:16 0.000000
+0:16 0.000000
+0:16 0.000000
+0:16 0.000000
+0:16 0.000000
+0:16 0 (const uint)
+0:18 Sequence
+0:18 move second child to first child (temp int)
+0:18 'x' (temp int)
+0:18 Constant:
+0:18 0 (const int)
+0:18 Loop with condition tested first
+0:18 Loop Condition
+0:18 Compare Less Than (temp bool)
+0:18 'x' (temp int)
+0:18 Constant:
+0:18 2 (const int)
+0:18 Loop Body
+0:19 Sequence
+0:19 move second child to first child (temp int)
+0:19 'y' (temp int)
+0:19 Constant:
+0:19 0 (const int)
+0:19 Loop with condition tested first
+0:19 Loop Condition
+0:19 Compare Less Than (temp bool)
+0:19 'y' (temp int)
+0:19 Constant:
+0:19 2 (const int)
+0:19 Loop Body
+0:20 move second child to first child (temp structure{temp 4-component vector of float Pos, temp 2-component vector of float TexCoord, temp 3-component vector of float TerrainPos, temp uint VertexID})
+0:20 indirect index (temp structure{temp 4-component vector of float Pos, temp 2-component vector of float TexCoord, temp 3-component vector of float TerrainPos, temp uint VertexID})
+0:20 indirect index (temp 3-element array of structure{temp 4-component vector of float Pos, temp 2-component vector of float TexCoord, temp 3-component vector of float TerrainPos, temp uint VertexID})
+0:20 'Verts' (temp 2-element array of 3-element array of structure{temp 4-component vector of float Pos, temp 2-component vector of float TexCoord, temp 3-component vector of float TerrainPos, temp uint VertexID})
+0:20 'x' (temp int)
+0:20 'y' (temp int)
+0:20 'Out' (temp structure{temp 4-component vector of float Pos, temp 2-component vector of float TexCoord, temp 3-component vector of float TerrainPos, temp uint VertexID})
+0:19 Loop Terminal Expression
+0:19 Pre-Increment (temp int)
+0:19 'y' (temp int)
+0:18 Loop Terminal Expression
+0:18 Pre-Increment (temp int)
+0:18 'x' (temp int)
+0:? Linker Objects
+0:? 'v' (layout(location=0 ) in 1-element array of uint)
+0:? 'OutputStream' (layout(location=0 ) out structure{temp 2-component vector of float TexCoord, temp 3-component vector of float TerrainPos, temp uint VertexID})
+0:? 'PerVertex_out' (out block{out 4-component vector of float Position OutputStream_Pos})
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 90
+
+ Capability Geometry
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Geometry 4 "main" 83 86 89
+ ExecutionMode 4 InputPoints
+ ExecutionMode 4 Invocations 1
+ ExecutionMode 4 OutputTriangleStrip
+ ExecutionMode 4 OutputVertices 4
+ Name 4 "main"
+ Name 11 "PSInput"
+ MemberName 11(PSInput) 0 "Pos"
+ MemberName 11(PSInput) 1 "TexCoord"
+ MemberName 11(PSInput) 2 "TerrainPos"
+ MemberName 11(PSInput) 3 "VertexID"
+ Name 13 "Out"
+ Name 14 "PSInput"
+ MemberName 14(PSInput) 0 "Pos"
+ MemberName 14(PSInput) 1 "TexCoord"
+ MemberName 14(PSInput) 2 "TerrainPos"
+ MemberName 14(PSInput) 3 "VertexID"
+ Name 39 "x"
+ Name 48 "y"
+ Name 56 "PSInput"
+ MemberName 56(PSInput) 0 "Pos"
+ MemberName 56(PSInput) 1 "TexCoord"
+ MemberName 56(PSInput) 2 "TerrainPos"
+ MemberName 56(PSInput) 3 "VertexID"
+ Name 62 "Verts"
+ Name 83 "v"
+ Name 84 "PSInput"
+ MemberName 84(PSInput) 0 "TexCoord"
+ MemberName 84(PSInput) 1 "TerrainPos"
+ MemberName 84(PSInput) 2 "VertexID"
+ Name 86 "OutputStream"
+ Name 87 "PerVertex_out"
+ MemberName 87(PerVertex_out) 0 "OutputStream_Pos"
+ Name 89 "PerVertex_out"
+ MemberDecorate 14(PSInput) 0 BuiltIn Position
+ Decorate 83(v) Location 0
+ Decorate 86(OutputStream) Location 0
+ MemberDecorate 87(PerVertex_out) 0 BuiltIn Position
+ Decorate 87(PerVertex_out) Block
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeFloat 32
+ 7: TypeVector 6(float) 4
+ 8: TypeVector 6(float) 2
+ 9: TypeVector 6(float) 3
+ 10: TypeInt 32 0
+ 11(PSInput): TypeStruct 7(fvec4) 8(fvec2) 9(fvec3) 10(int)
+ 12: TypePointer Function 11(PSInput)
+ 14(PSInput): TypeStruct 7(fvec4) 8(fvec2) 9(fvec3) 10(int)
+ 15: 6(float) Constant 0
+ 16: 7(fvec4) ConstantComposite 15 15 15 15
+ 17: 8(fvec2) ConstantComposite 15 15
+ 18: 9(fvec3) ConstantComposite 15 15 15
+ 19: 10(int) Constant 0
+ 20: 14(PSInput) ConstantComposite 16 17 18 19
+ 22: TypeInt 32 1
+ 23: 22(int) Constant 0
+ 24: TypePointer Function 7(fvec4)
+ 27: 22(int) Constant 1
+ 28: TypePointer Function 8(fvec2)
+ 31: 22(int) Constant 2
+ 32: TypePointer Function 9(fvec3)
+ 35: 22(int) Constant 3
+ 36: TypePointer Function 10(int)
+ 38: TypePointer Function 22(int)
+ 46: TypeBool
+ 56(PSInput): TypeStruct 7(fvec4) 8(fvec2) 9(fvec3) 10(int)
+ 57: 10(int) Constant 3
+ 58: TypeArray 56(PSInput) 57
+ 59: 10(int) Constant 2
+ 60: TypeArray 58 59
+ 61: TypePointer Function 60
+ 66: TypePointer Function 56(PSInput)
+ 80: 10(int) Constant 1
+ 81: TypeArray 10(int) 80
+ 82: TypePointer Input 81
+ 83(v): 82(ptr) Variable Input
+ 84(PSInput): TypeStruct 8(fvec2) 9(fvec3) 10(int)
+ 85: TypePointer Output 84(PSInput)
+86(OutputStream): 85(ptr) Variable Output
+87(PerVertex_out): TypeStruct 7(fvec4)
+ 88: TypePointer Output 87(PerVertex_out)
+89(PerVertex_out): 88(ptr) Variable Output
+ 4(main): 2 Function None 3
+ 5: Label
+ 13(Out): 12(ptr) Variable Function
+ 39(x): 38(ptr) Variable Function
+ 48(y): 38(ptr) Variable Function
+ 62(Verts): 61(ptr) Variable Function
+ 21: 7(fvec4) CompositeExtract 20 0
+ 25: 24(ptr) AccessChain 13(Out) 23
+ Store 25 21
+ 26: 8(fvec2) CompositeExtract 20 1
+ 29: 28(ptr) AccessChain 13(Out) 27
+ Store 29 26
+ 30: 9(fvec3) CompositeExtract 20 2
+ 33: 32(ptr) AccessChain 13(Out) 31
+ Store 33 30
+ 34: 10(int) CompositeExtract 20 3
+ 37: 36(ptr) AccessChain 13(Out) 35
+ Store 37 34
+ Store 39(x) 23
+ Branch 40
+ 40: Label
+ LoopMerge 42 43 None
+ Branch 44
+ 44: Label
+ 45: 22(int) Load 39(x)
+ 47: 46(bool) SLessThan 45 31
+ BranchConditional 47 41 42
+ 41: Label
+ Store 48(y) 23
+ Branch 49
+ 49: Label
+ LoopMerge 51 52 None
+ Branch 53
+ 53: Label
+ 54: 22(int) Load 48(y)
+ 55: 46(bool) SLessThan 54 31
+ BranchConditional 55 50 51
+ 50: Label
+ 63: 22(int) Load 39(x)
+ 64: 22(int) Load 48(y)
+ 65: 11(PSInput) Load 13(Out)
+ 67: 66(ptr) AccessChain 62(Verts) 63 64
+ 68: 7(fvec4) CompositeExtract 65 0
+ 69: 24(ptr) AccessChain 67 23
+ Store 69 68
+ 70: 8(fvec2) CompositeExtract 65 1
+ 71: 28(ptr) AccessChain 67 27
+ Store 71 70
+ 72: 9(fvec3) CompositeExtract 65 2
+ 73: 32(ptr) AccessChain 67 31
+ Store 73 72
+ 74: 10(int) CompositeExtract 65 3
+ 75: 36(ptr) AccessChain 67 35
+ Store 75 74
+ Branch 52
+ 52: Label
+ 76: 22(int) Load 48(y)
+ 77: 22(int) IAdd 76 27
+ Store 48(y) 77
+ Branch 49
+ 51: Label
+ Branch 43
+ 43: Label
+ 78: 22(int) Load 39(x)
+ 79: 22(int) IAdd 78 27
+ Store 39(x) 79
+ Branch 40
+ 42: Label
+ Return
+ FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split.assign.frag.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split.assign.frag.out
new file mode 100644
index 00000000000..e214c51200f
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split.assign.frag.out
@@ -0,0 +1,196 @@
+hlsl.struct.split.assign.frag
+Shader version: 450
+gl_FragCoord origin is upper left
+0:? Sequence
+0:7 Function Definition: main(i1;struct-S-f1-vf41[3]; (temp 4-component vector of float)
+0:7 Function Parameters:
+0:7 'i' (layout(location=0 ) in int)
+0:7 'input' (in 3-element array of structure{temp float f, temp 4-component vector of float FragCoord pos})
+0:? Sequence
+0:9 Sequence
+0:9 move second child to first child (temp float)
+0:9 f: direct index for structure (temp float)
+0:9 direct index (layout(location=1 ) in structure{temp float f})
+0:9 'input' (layout(location=1 ) in 3-element array of structure{temp float f})
+0:9 Constant:
+0:9 0 (const int)
+0:9 Constant:
+0:9 0 (const int)
+0:9 f: direct index for structure (temp float)
+0:9 direct index (temp structure{temp float f, temp 4-component vector of float pos})
+0:9 'a' (temp 3-element array of structure{temp float f, temp 4-component vector of float pos})
+0:9 Constant:
+0:9 0 (const int)
+0:9 Constant:
+0:9 0 (const int)
+0:9 move second child to first child (temp float)
+0:9 f: direct index for structure (temp float)
+0:9 direct index (layout(location=1 ) in structure{temp float f})
+0:9 'input' (layout(location=1 ) in 3-element array of structure{temp float f})
+0:9 Constant:
+0:9 1 (const int)
+0:9 Constant:
+0:9 0 (const int)
+0:9 f: direct index for structure (temp float)
+0:9 direct index (temp structure{temp float f, temp 4-component vector of float pos})
+0:9 'a' (temp 3-element array of structure{temp float f, temp 4-component vector of float pos})
+0:9 Constant:
+0:9 1 (const int)
+0:9 Constant:
+0:9 0 (const int)
+0:9 move second child to first child (temp float)
+0:9 f: direct index for structure (temp float)
+0:9 direct index (layout(location=1 ) in structure{temp float f})
+0:9 'input' (layout(location=1 ) in 3-element array of structure{temp float f})
+0:9 Constant:
+0:9 2 (const int)
+0:9 Constant:
+0:9 0 (const int)
+0:9 f: direct index for structure (temp float)
+0:9 direct index (temp structure{temp float f, temp 4-component vector of float pos})
+0:9 'a' (temp 3-element array of structure{temp float f, temp 4-component vector of float pos})
+0:9 Constant:
+0:9 2 (const int)
+0:9 Constant:
+0:9 0 (const int)
+0:11 Sequence
+0:11 Branch: Return
+0:? Linker Objects
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
+0:? 'i' (layout(location=0 ) in int)
+0:? 'input' (layout(location=1 ) in 3-element array of structure{temp float f})
+0:? 'input_pos' (in 3-element array of 4-component vector of float FragCoord)
+
+
+Linked fragment stage:
+
+
+Shader version: 450
+gl_FragCoord origin is upper left
+0:? Sequence
+0:7 Function Definition: main(i1;struct-S-f1-vf41[3]; (temp 4-component vector of float)
+0:7 Function Parameters:
+0:7 'i' (layout(location=0 ) in int)
+0:7 'input' (in 3-element array of structure{temp float f, temp 4-component vector of float FragCoord pos})
+0:? Sequence
+0:9 Sequence
+0:9 move second child to first child (temp float)
+0:9 f: direct index for structure (temp float)
+0:9 direct index (layout(location=1 ) in structure{temp float f})
+0:9 'input' (layout(location=1 ) in 3-element array of structure{temp float f})
+0:9 Constant:
+0:9 0 (const int)
+0:9 Constant:
+0:9 0 (const int)
+0:9 f: direct index for structure (temp float)
+0:9 direct index (temp structure{temp float f, temp 4-component vector of float pos})
+0:9 'a' (temp 3-element array of structure{temp float f, temp 4-component vector of float pos})
+0:9 Constant:
+0:9 0 (const int)
+0:9 Constant:
+0:9 0 (const int)
+0:9 move second child to first child (temp float)
+0:9 f: direct index for structure (temp float)
+0:9 direct index (layout(location=1 ) in structure{temp float f})
+0:9 'input' (layout(location=1 ) in 3-element array of structure{temp float f})
+0:9 Constant:
+0:9 1 (const int)
+0:9 Constant:
+0:9 0 (const int)
+0:9 f: direct index for structure (temp float)
+0:9 direct index (temp structure{temp float f, temp 4-component vector of float pos})
+0:9 'a' (temp 3-element array of structure{temp float f, temp 4-component vector of float pos})
+0:9 Constant:
+0:9 1 (const int)
+0:9 Constant:
+0:9 0 (const int)
+0:9 move second child to first child (temp float)
+0:9 f: direct index for structure (temp float)
+0:9 direct index (layout(location=1 ) in structure{temp float f})
+0:9 'input' (layout(location=1 ) in 3-element array of structure{temp float f})
+0:9 Constant:
+0:9 2 (const int)
+0:9 Constant:
+0:9 0 (const int)
+0:9 f: direct index for structure (temp float)
+0:9 direct index (temp structure{temp float f, temp 4-component vector of float pos})
+0:9 'a' (temp 3-element array of structure{temp float f, temp 4-component vector of float pos})
+0:9 Constant:
+0:9 2 (const int)
+0:9 Constant:
+0:9 0 (const int)
+0:11 Sequence
+0:11 Branch: Return
+0:? Linker Objects
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
+0:? 'i' (layout(location=0 ) in int)
+0:? 'input' (layout(location=1 ) in 3-element array of structure{temp float f})
+0:? 'input_pos' (in 3-element array of 4-component vector of float FragCoord)
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 41
+
+ Capability Shader
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Fragment 4 "main" 12 35 37 40
+ ExecutionMode 4 OriginUpperLeft
+ Name 4 "main"
+ Name 7 "S"
+ MemberName 7(S) 0 "f"
+ Name 12 "input"
+ Name 16 "S"
+ MemberName 16(S) 0 "f"
+ MemberName 16(S) 1 "pos"
+ Name 19 "a"
+ Name 35 "@entryPointOutput"
+ Name 37 "i"
+ Name 40 "input_pos"
+ Decorate 12(input) Location 1
+ Decorate 35(@entryPointOutput) Location 0
+ Decorate 37(i) Location 0
+ Decorate 40(input_pos) BuiltIn FragCoord
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeFloat 32
+ 7(S): TypeStruct 6(float)
+ 8: TypeInt 32 0
+ 9: 8(int) Constant 3
+ 10: TypeArray 7(S) 9
+ 11: TypePointer Input 10
+ 12(input): 11(ptr) Variable Input
+ 13: TypeInt 32 1
+ 14: 13(int) Constant 0
+ 15: TypeVector 6(float) 4
+ 16(S): TypeStruct 6(float) 15(fvec4)
+ 17: TypeArray 16(S) 9
+ 18: TypePointer Function 17
+ 20: TypePointer Function 6(float)
+ 23: TypePointer Input 6(float)
+ 25: 13(int) Constant 1
+ 29: 13(int) Constant 2
+ 34: TypePointer Output 15(fvec4)
+35(@entryPointOutput): 34(ptr) Variable Output
+ 36: TypePointer Input 13(int)
+ 37(i): 36(ptr) Variable Input
+ 38: TypeArray 15(fvec4) 9
+ 39: TypePointer Input 38
+ 40(input_pos): 39(ptr) Variable Input
+ 4(main): 2 Function None 3
+ 5: Label
+ 19(a): 18(ptr) Variable Function
+ 21: 20(ptr) AccessChain 19(a) 14 14
+ 22: 6(float) Load 21
+ 24: 23(ptr) AccessChain 12(input) 14 14
+ Store 24 22
+ 26: 20(ptr) AccessChain 19(a) 25 14
+ 27: 6(float) Load 26
+ 28: 23(ptr) AccessChain 12(input) 25 14
+ Store 28 27
+ 30: 20(ptr) AccessChain 19(a) 29 14
+ 31: 6(float) Load 30
+ 32: 23(ptr) AccessChain 12(input) 29 14
+ Store 32 31
+ Return
+ FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split.call.vert.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split.call.vert.out
new file mode 100644
index 00000000000..40245f44105
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split.call.vert.out
@@ -0,0 +1,325 @@
+hlsl.struct.split.call.vert
+Shader version: 450
+0:? Sequence
+0:17 Function Definition: Fn1(struct-VS_INPUT-i1-vf4-i11;struct-VS_OUTPUT-i1-vf4-i11; (temp void)
+0:17 Function Parameters:
+0:17 'fn1_in' (temp structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
+0:17 'fn1_out' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:? Sequence
+0:18 add (temp 4-component vector of float)
+0:18 Pos_in: direct index for structure (temp 4-component vector of float)
+0:18 'fn1_in' (temp structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
+0:18 Constant:
+0:18 1 (const int)
+0:18 Pos_out: direct index for structure (temp 4-component vector of float)
+0:18 'fn1_out' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:18 Constant:
+0:18 1 (const int)
+0:22 Function Definition: main(struct-VS_INPUT-i1-vf4-i11; (temp structure{temp int x0_out, temp 4-component vector of float Position Pos_out, temp int x1_out})
+0:22 Function Parameters:
+0:22 'vsin' (in structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
+0:? Sequence
+0:25 move second child to first child (temp int)
+0:25 x0_out: direct index for structure (temp int)
+0:25 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:25 Constant:
+0:25 0 (const int)
+0:? 'x0_in' (layout(location=0 ) in int)
+0:26 move second child to first child (temp 4-component vector of float)
+0:26 Pos_out: direct index for structure (temp 4-component vector of float)
+0:26 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:26 Constant:
+0:26 1 (const int)
+0:? 'Pos_in' (in 4-component vector of float Position)
+0:27 move second child to first child (temp int)
+0:27 x1_out: direct index for structure (temp int)
+0:27 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:27 Constant:
+0:27 2 (const int)
+0:? 'x1_in' (layout(location=1 ) in int)
+0:29 Function Call: Fn1(struct-VS_INPUT-i1-vf4-i11;struct-VS_OUTPUT-i1-vf4-i11; (temp void)
+0:29 Comma (temp structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
+0:29 Sequence
+0:29 move second child to first child (temp int)
+0:29 x0_in: direct index for structure (temp int)
+0:29 'aggShadow' (temp structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
+0:29 Constant:
+0:29 0 (const int)
+0:? 'x0_in' (layout(location=0 ) in int)
+0:29 move second child to first child (temp 4-component vector of float)
+0:29 Pos_in: direct index for structure (temp 4-component vector of float)
+0:29 'aggShadow' (temp structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
+0:29 Constant:
+0:29 1 (const int)
+0:? 'Pos_in' (in 4-component vector of float Position)
+0:29 move second child to first child (temp int)
+0:29 x1_in: direct index for structure (temp int)
+0:29 'aggShadow' (temp structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
+0:29 Constant:
+0:29 2 (const int)
+0:? 'x1_in' (layout(location=1 ) in int)
+0:29 'aggShadow' (temp structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
+0:29 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:31 Sequence
+0:31 Sequence
+0:31 move second child to first child (temp int)
+0:31 x0_out: direct index for structure (temp int)
+0:31 '@entryPointOutput' (layout(location=0 ) out structure{temp int x0_out, temp int x1_out})
+0:31 Constant:
+0:31 0 (const int)
+0:31 x0_out: direct index for structure (temp int)
+0:31 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:31 Constant:
+0:31 0 (const int)
+0:31 move second child to first child (temp 4-component vector of float)
+0:? 'Pos_out' (out 4-component vector of float Position)
+0:31 Pos_out: direct index for structure (temp 4-component vector of float)
+0:31 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:31 Constant:
+0:31 1 (const int)
+0:31 move second child to first child (temp int)
+0:31 x1_out: direct index for structure (temp int)
+0:31 '@entryPointOutput' (layout(location=0 ) out structure{temp int x0_out, temp int x1_out})
+0:31 Constant:
+0:31 1 (const int)
+0:31 x1_out: direct index for structure (temp int)
+0:31 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:31 Constant:
+0:31 2 (const int)
+0:31 Branch: Return
+0:? Linker Objects
+0:? '@entryPointOutput' (layout(location=0 ) out structure{temp int x0_out, temp int x1_out})
+0:? 'x0_in' (layout(location=0 ) in int)
+0:? 'Pos_in' (in 4-component vector of float Position)
+0:? 'x1_in' (layout(location=1 ) in int)
+0:? 'PerVertex_out' (out block{out 4-component vector of float Position Pos_out})
+
+
+Linked vertex stage:
+
+
+Shader version: 450
+0:? Sequence
+0:17 Function Definition: Fn1(struct-VS_INPUT-i1-vf4-i11;struct-VS_OUTPUT-i1-vf4-i11; (temp void)
+0:17 Function Parameters:
+0:17 'fn1_in' (temp structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
+0:17 'fn1_out' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:? Sequence
+0:18 add (temp 4-component vector of float)
+0:18 Pos_in: direct index for structure (temp 4-component vector of float)
+0:18 'fn1_in' (temp structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
+0:18 Constant:
+0:18 1 (const int)
+0:18 Pos_out: direct index for structure (temp 4-component vector of float)
+0:18 'fn1_out' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:18 Constant:
+0:18 1 (const int)
+0:22 Function Definition: main(struct-VS_INPUT-i1-vf4-i11; (temp structure{temp int x0_out, temp 4-component vector of float Position Pos_out, temp int x1_out})
+0:22 Function Parameters:
+0:22 'vsin' (in structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
+0:? Sequence
+0:25 move second child to first child (temp int)
+0:25 x0_out: direct index for structure (temp int)
+0:25 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:25 Constant:
+0:25 0 (const int)
+0:? 'x0_in' (layout(location=0 ) in int)
+0:26 move second child to first child (temp 4-component vector of float)
+0:26 Pos_out: direct index for structure (temp 4-component vector of float)
+0:26 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:26 Constant:
+0:26 1 (const int)
+0:? 'Pos_in' (in 4-component vector of float Position)
+0:27 move second child to first child (temp int)
+0:27 x1_out: direct index for structure (temp int)
+0:27 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:27 Constant:
+0:27 2 (const int)
+0:? 'x1_in' (layout(location=1 ) in int)
+0:29 Function Call: Fn1(struct-VS_INPUT-i1-vf4-i11;struct-VS_OUTPUT-i1-vf4-i11; (temp void)
+0:29 Comma (temp structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
+0:29 Sequence
+0:29 move second child to first child (temp int)
+0:29 x0_in: direct index for structure (temp int)
+0:29 'aggShadow' (temp structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
+0:29 Constant:
+0:29 0 (const int)
+0:? 'x0_in' (layout(location=0 ) in int)
+0:29 move second child to first child (temp 4-component vector of float)
+0:29 Pos_in: direct index for structure (temp 4-component vector of float)
+0:29 'aggShadow' (temp structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
+0:29 Constant:
+0:29 1 (const int)
+0:? 'Pos_in' (in 4-component vector of float Position)
+0:29 move second child to first child (temp int)
+0:29 x1_in: direct index for structure (temp int)
+0:29 'aggShadow' (temp structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
+0:29 Constant:
+0:29 2 (const int)
+0:? 'x1_in' (layout(location=1 ) in int)
+0:29 'aggShadow' (temp structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
+0:29 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:31 Sequence
+0:31 Sequence
+0:31 move second child to first child (temp int)
+0:31 x0_out: direct index for structure (temp int)
+0:31 '@entryPointOutput' (layout(location=0 ) out structure{temp int x0_out, temp int x1_out})
+0:31 Constant:
+0:31 0 (const int)
+0:31 x0_out: direct index for structure (temp int)
+0:31 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:31 Constant:
+0:31 0 (const int)
+0:31 move second child to first child (temp 4-component vector of float)
+0:? 'Pos_out' (out 4-component vector of float Position)
+0:31 Pos_out: direct index for structure (temp 4-component vector of float)
+0:31 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:31 Constant:
+0:31 1 (const int)
+0:31 move second child to first child (temp int)
+0:31 x1_out: direct index for structure (temp int)
+0:31 '@entryPointOutput' (layout(location=0 ) out structure{temp int x0_out, temp int x1_out})
+0:31 Constant:
+0:31 1 (const int)
+0:31 x1_out: direct index for structure (temp int)
+0:31 'vsout' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
+0:31 Constant:
+0:31 2 (const int)
+0:31 Branch: Return
+0:? Linker Objects
+0:? '@entryPointOutput' (layout(location=0 ) out structure{temp int x0_out, temp int x1_out})
+0:? 'x0_in' (layout(location=0 ) in int)
+0:? 'Pos_in' (in 4-component vector of float Position)
+0:? 'x1_in' (layout(location=1 ) in int)
+0:? 'PerVertex_out' (out block{out 4-component vector of float Position Pos_out})
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 72
+
+ Capability Shader
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Vertex 4 "main" 28 33 37 56 62 71
+ Name 4 "main"
+ Name 9 "VS_INPUT"
+ MemberName 9(VS_INPUT) 0 "x0_in"
+ MemberName 9(VS_INPUT) 1 "Pos_in"
+ MemberName 9(VS_INPUT) 2 "x1_in"
+ Name 11 "VS_OUTPUT"
+ MemberName 11(VS_OUTPUT) 0 "x0_out"
+ MemberName 11(VS_OUTPUT) 1 "Pos_out"
+ MemberName 11(VS_OUTPUT) 2 "x1_out"
+ Name 16 "Fn1(struct-VS_INPUT-i1-vf4-i11;struct-VS_OUTPUT-i1-vf4-i11;"
+ Name 14 "fn1_in"
+ Name 15 "fn1_out"
+ Name 25 "vsout"
+ Name 28 "x0_in"
+ Name 33 "Pos_in"
+ Name 37 "x1_in"
+ Name 40 "VS_INPUT"
+ MemberName 40(VS_INPUT) 0 "x0_in"
+ MemberName 40(VS_INPUT) 1 "Pos_in"
+ MemberName 40(VS_INPUT) 2 "x1_in"
+ Name 42 "aggShadow"
+ Name 49 "param"
+ Name 51 "param"
+ Name 54 "VS_OUTPUT"
+ MemberName 54(VS_OUTPUT) 0 "x0_out"
+ MemberName 54(VS_OUTPUT) 1 "x1_out"
+ Name 56 "@entryPointOutput"
+ Name 62 "Pos_out"
+ Name 69 "PerVertex_out"
+ MemberName 69(PerVertex_out) 0 "Pos_out"
+ Name 71 "PerVertex_out"
+ Decorate 28(x0_in) Location 0
+ Decorate 33(Pos_in) BuiltIn Position
+ Decorate 37(x1_in) Location 1
+ Decorate 56(@entryPointOutput) Location 0
+ Decorate 62(Pos_out) BuiltIn Position
+ MemberDecorate 69(PerVertex_out) 0 BuiltIn Position
+ Decorate 69(PerVertex_out) Block
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeInt 32 1
+ 7: TypeFloat 32
+ 8: TypeVector 7(float) 4
+ 9(VS_INPUT): TypeStruct 6(int) 8(fvec4) 6(int)
+ 10: TypePointer Function 9(VS_INPUT)
+ 11(VS_OUTPUT): TypeStruct 6(int) 8(fvec4) 6(int)
+ 12: TypePointer Function 11(VS_OUTPUT)
+ 13: TypeFunction 2 10(ptr) 12(ptr)
+ 18: 6(int) Constant 1
+ 19: TypePointer Function 8(fvec4)
+ 26: 6(int) Constant 0
+ 27: TypePointer Input 6(int)
+ 28(x0_in): 27(ptr) Variable Input
+ 30: TypePointer Function 6(int)
+ 32: TypePointer Input 8(fvec4)
+ 33(Pos_in): 32(ptr) Variable Input
+ 36: 6(int) Constant 2
+ 37(x1_in): 27(ptr) Variable Input
+ 40(VS_INPUT): TypeStruct 6(int) 8(fvec4) 6(int)
+ 41: TypePointer Function 40(VS_INPUT)
+ 54(VS_OUTPUT): TypeStruct 6(int) 6(int)
+ 55: TypePointer Output 54(VS_OUTPUT)
+56(@entryPointOutput): 55(ptr) Variable Output
+ 59: TypePointer Output 6(int)
+ 61: TypePointer Output 8(fvec4)
+ 62(Pos_out): 61(ptr) Variable Output
+69(PerVertex_out): TypeStruct 8(fvec4)
+ 70: TypePointer Output 69(PerVertex_out)
+71(PerVertex_out): 70(ptr) Variable Output
+ 4(main): 2 Function None 3
+ 5: Label
+ 25(vsout): 12(ptr) Variable Function
+ 42(aggShadow): 41(ptr) Variable Function
+ 49(param): 41(ptr) Variable Function
+ 51(param): 12(ptr) Variable Function
+ 29: 6(int) Load 28(x0_in)
+ 31: 30(ptr) AccessChain 25(vsout) 26
+ Store 31 29
+ 34: 8(fvec4) Load 33(Pos_in)
+ 35: 19(ptr) AccessChain 25(vsout) 18
+ Store 35 34
+ 38: 6(int) Load 37(x1_in)
+ 39: 30(ptr) AccessChain 25(vsout) 36
+ Store 39 38
+ 43: 6(int) Load 28(x0_in)
+ 44: 30(ptr) AccessChain 42(aggShadow) 26
+ Store 44 43
+ 45: 8(fvec4) Load 33(Pos_in)
+ 46: 19(ptr) AccessChain 42(aggShadow) 18
+ Store 46 45
+ 47: 6(int) Load 37(x1_in)
+ 48: 30(ptr) AccessChain 42(aggShadow) 36
+ Store 48 47
+ 50:40(VS_INPUT) Load 42(aggShadow)
+ Store 49(param) 50
+ 52:11(VS_OUTPUT) Load 25(vsout)
+ Store 51(param) 52
+ 53: 2 FunctionCall 16(Fn1(struct-VS_INPUT-i1-vf4-i11;struct-VS_OUTPUT-i1-vf4-i11;) 49(param) 51(param)
+ 57: 30(ptr) AccessChain 25(vsout) 26
+ 58: 6(int) Load 57
+ 60: 59(ptr) AccessChain 56(@entryPointOutput) 26
+ Store 60 58
+ 63: 19(ptr) AccessChain 25(vsout) 18
+ 64: 8(fvec4) Load 63
+ Store 62(Pos_out) 64
+ 65: 30(ptr) AccessChain 25(vsout) 36
+ 66: 6(int) Load 65
+ 67: 59(ptr) AccessChain 56(@entryPointOutput) 18
+ Store 67 66
+ Return
+ FunctionEnd
+16(Fn1(struct-VS_INPUT-i1-vf4-i11;struct-VS_OUTPUT-i1-vf4-i11;): 2 Function None 13
+ 14(fn1_in): 10(ptr) FunctionParameter
+ 15(fn1_out): 12(ptr) FunctionParameter
+ 17: Label
+ 20: 19(ptr) AccessChain 14(fn1_in) 18
+ 21: 8(fvec4) Load 20
+ 22: 19(ptr) AccessChain 15(fn1_out) 18
+ 23: 8(fvec4) Load 22
+ 24: 8(fvec4) FAdd 21 23
+ Return
+ FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split.nested.geom.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split.nested.geom.out
new file mode 100644
index 00000000000..a1db67d979c
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split.nested.geom.out
@@ -0,0 +1,283 @@
+hlsl.struct.split.nested.geom
+Shader version: 450
+invocations = -1
+max_vertices = 3
+input primitive = triangles
+output primitive = triangle_strip
+0:? Sequence
+0:24 Function Definition: main(struct-PS_IN-vf4-vf21[3];struct-GS_OUT-struct-PS_IN-vf4-vf21-struct-STRUCT_WITH_NO_BUILTIN_INTERSTAGE_IO-f1[2]-i111; (temp void)
+0:24 Function Parameters:
+0:24 'tin' (in 3-element array of structure{temp 4-component vector of float Position pos, temp 2-component vector of float tc})
+0:24 'ts' (out structure{temp structure{temp 4-component vector of float Position pos, temp 2-component vector of float tc} psIn, temp structure{temp 2-element array of float m0_array, temp int m1} contains_no_builtin_io})
+0:? Sequence
+0:27 move second child to first child (temp 4-component vector of float)
+0:27 pos: direct index for structure (temp 4-component vector of float)
+0:27 psIn: direct index for structure (temp structure{temp 4-component vector of float pos, temp 2-component vector of float tc})
+0:27 'o' (temp structure{temp structure{temp 4-component vector of float pos, temp 2-component vector of float tc} psIn, temp structure{temp 2-element array of float m0_array, temp int m1} contains_no_builtin_io})
+0:27 Constant:
+0:27 0 (const int)
+0:27 Constant:
+0:27 0 (const int)
+0:? Constant:
+0:? 1.000000
+0:? 2.000000
+0:? 3.000000
+0:? 4.000000
+0:28 move second child to first child (temp 2-component vector of float)
+0:28 tc: direct index for structure (temp 2-component vector of float)
+0:28 psIn: direct index for structure (temp structure{temp 4-component vector of float pos, temp 2-component vector of float tc})
+0:28 'o' (temp structure{temp structure{temp 4-component vector of float pos, temp 2-component vector of float tc} psIn, temp structure{temp 2-element array of float m0_array, temp int m1} contains_no_builtin_io})
+0:28 Constant:
+0:28 0 (const int)
+0:28 Constant:
+0:28 1 (const int)
+0:? Constant:
+0:? 5.000000
+0:? 6.000000
+0:30 Sequence
+0:30 Sequence
+0:30 move second child to first child (temp 4-component vector of float)
+0:? 'ts_psIn_pos' (out 4-component vector of float Position)
+0:30 pos: direct index for structure (temp 4-component vector of float)
+0:30 psIn: direct index for structure (temp structure{temp 4-component vector of float pos, temp 2-component vector of float tc})
+0:30 'o' (temp structure{temp structure{temp 4-component vector of float pos, temp 2-component vector of float tc} psIn, temp structure{temp 2-element array of float m0_array, temp int m1} contains_no_builtin_io})
+0:30 Constant:
+0:30 0 (const int)
+0:30 Constant:
+0:30 0 (const int)
+0:30 move second child to first child (temp 2-component vector of float)
+0:30 tc: direct index for structure (temp 2-component vector of float)
+0:30 psIn: direct index for structure (temp structure{temp 2-component vector of float tc})
+0:30 'ts' (layout(location=0 ) out structure{temp structure{temp 2-component vector of float tc} psIn, temp structure{temp 2-element array of float m0_array, temp int m1} contains_no_builtin_io})
+0:30 Constant:
+0:30 0 (const int)
+0:30 Constant:
+0:30 0 (const int)
+0:30 tc: direct index for structure (temp 2-component vector of float)
+0:30 psIn: direct index for structure (temp structure{temp 4-component vector of float pos, temp 2-component vector of float tc})
+0:30 'o' (temp structure{temp structure{temp 4-component vector of float pos, temp 2-component vector of float tc} psIn, temp structure{temp 2-element array of float m0_array, temp int m1} contains_no_builtin_io})
+0:30 Constant:
+0:30 0 (const int)
+0:30 Constant:
+0:30 1 (const int)
+0:30 move second child to first child (temp structure{temp 2-element array of float m0_array, temp int m1})
+0:30 contains_no_builtin_io: direct index for structure (temp structure{temp 2-element array of float m0_array, temp int m1})
+0:30 'ts' (layout(location=0 ) out structure{temp structure{temp 2-component vector of float tc} psIn, temp structure{temp 2-element array of float m0_array, temp int m1} contains_no_builtin_io})
+0:30 Constant:
+0:30 1 (const int)
+0:30 contains_no_builtin_io: direct index for structure (temp structure{temp 2-element array of float m0_array, temp int m1})
+0:30 'o' (temp structure{temp structure{temp 4-component vector of float pos, temp 2-component vector of float tc} psIn, temp structure{temp 2-element array of float m0_array, temp int m1} contains_no_builtin_io})
+0:30 Constant:
+0:30 1 (const int)
+0:30 EmitVertex (temp void)
+0:? Linker Objects
+0:? 'tin' (layout(location=0 ) in 3-element array of structure{temp 2-component vector of float tc})
+0:? 'ts' (layout(location=0 ) out structure{temp structure{temp 2-component vector of float tc} psIn, temp structure{temp 2-element array of float m0_array, temp int m1} contains_no_builtin_io})
+0:? 'PerVertex_in' (in 3-element array of block{in 4-component vector of float Position tin_pos})
+0:? 'PerVertex_out' (out block{out 4-component vector of float Position ts_psIn_pos})
+
+
+Linked geometry stage:
+
+
+Shader version: 450
+invocations = 1
+max_vertices = 3
+input primitive = triangles
+output primitive = triangle_strip
+0:? Sequence
+0:24 Function Definition: main(struct-PS_IN-vf4-vf21[3];struct-GS_OUT-struct-PS_IN-vf4-vf21-struct-STRUCT_WITH_NO_BUILTIN_INTERSTAGE_IO-f1[2]-i111; (temp void)
+0:24 Function Parameters:
+0:24 'tin' (in 3-element array of structure{temp 4-component vector of float Position pos, temp 2-component vector of float tc})
+0:24 'ts' (out structure{temp structure{temp 4-component vector of float Position pos, temp 2-component vector of float tc} psIn, temp structure{temp 2-element array of float m0_array, temp int m1} contains_no_builtin_io})
+0:? Sequence
+0:27 move second child to first child (temp 4-component vector of float)
+0:27 pos: direct index for structure (temp 4-component vector of float)
+0:27 psIn: direct index for structure (temp structure{temp 4-component vector of float pos, temp 2-component vector of float tc})
+0:27 'o' (temp structure{temp structure{temp 4-component vector of float pos, temp 2-component vector of float tc} psIn, temp structure{temp 2-element array of float m0_array, temp int m1} contains_no_builtin_io})
+0:27 Constant:
+0:27 0 (const int)
+0:27 Constant:
+0:27 0 (const int)
+0:? Constant:
+0:? 1.000000
+0:? 2.000000
+0:? 3.000000
+0:? 4.000000
+0:28 move second child to first child (temp 2-component vector of float)
+0:28 tc: direct index for structure (temp 2-component vector of float)
+0:28 psIn: direct index for structure (temp structure{temp 4-component vector of float pos, temp 2-component vector of float tc})
+0:28 'o' (temp structure{temp structure{temp 4-component vector of float pos, temp 2-component vector of float tc} psIn, temp structure{temp 2-element array of float m0_array, temp int m1} contains_no_builtin_io})
+0:28 Constant:
+0:28 0 (const int)
+0:28 Constant:
+0:28 1 (const int)
+0:? Constant:
+0:? 5.000000
+0:? 6.000000
+0:30 Sequence
+0:30 Sequence
+0:30 move second child to first child (temp 4-component vector of float)
+0:? 'ts_psIn_pos' (out 4-component vector of float Position)
+0:30 pos: direct index for structure (temp 4-component vector of float)
+0:30 psIn: direct index for structure (temp structure{temp 4-component vector of float pos, temp 2-component vector of float tc})
+0:30 'o' (temp structure{temp structure{temp 4-component vector of float pos, temp 2-component vector of float tc} psIn, temp structure{temp 2-element array of float m0_array, temp int m1} contains_no_builtin_io})
+0:30 Constant:
+0:30 0 (const int)
+0:30 Constant:
+0:30 0 (const int)
+0:30 move second child to first child (temp 2-component vector of float)
+0:30 tc: direct index for structure (temp 2-component vector of float)
+0:30 psIn: direct index for structure (temp structure{temp 2-component vector of float tc})
+0:30 'ts' (layout(location=0 ) out structure{temp structure{temp 2-component vector of float tc} psIn, temp structure{temp 2-element array of float m0_array, temp int m1} contains_no_builtin_io})
+0:30 Constant:
+0:30 0 (const int)
+0:30 Constant:
+0:30 0 (const int)
+0:30 tc: direct index for structure (temp 2-component vector of float)
+0:30 psIn: direct index for structure (temp structure{temp 4-component vector of float pos, temp 2-component vector of float tc})
+0:30 'o' (temp structure{temp structure{temp 4-component vector of float pos, temp 2-component vector of float tc} psIn, temp structure{temp 2-element array of float m0_array, temp int m1} contains_no_builtin_io})
+0:30 Constant:
+0:30 0 (const int)
+0:30 Constant:
+0:30 1 (const int)
+0:30 move second child to first child (temp structure{temp 2-element array of float m0_array, temp int m1})
+0:30 contains_no_builtin_io: direct index for structure (temp structure{temp 2-element array of float m0_array, temp int m1})
+0:30 'ts' (layout(location=0 ) out structure{temp structure{temp 2-component vector of float tc} psIn, temp structure{temp 2-element array of float m0_array, temp int m1} contains_no_builtin_io})
+0:30 Constant:
+0:30 1 (const int)
+0:30 contains_no_builtin_io: direct index for structure (temp structure{temp 2-element array of float m0_array, temp int m1})
+0:30 'o' (temp structure{temp structure{temp 4-component vector of float pos, temp 2-component vector of float tc} psIn, temp structure{temp 2-element array of float m0_array, temp int m1} contains_no_builtin_io})
+0:30 Constant:
+0:30 1 (const int)
+0:30 EmitVertex (temp void)
+0:? Linker Objects
+0:? 'tin' (layout(location=0 ) in 3-element array of structure{temp 2-component vector of float tc})
+0:? 'ts' (layout(location=0 ) out structure{temp structure{temp 2-component vector of float tc} psIn, temp structure{temp 2-element array of float m0_array, temp int m1} contains_no_builtin_io})
+0:? 'PerVertex_in' (in 3-element array of block{in 4-component vector of float Position tin_pos})
+0:? 'PerVertex_out' (out block{out 4-component vector of float Position ts_psIn_pos})
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 68
+
+ Capability Geometry
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Geometry 4 "main" 33 40 60 64 67
+ ExecutionMode 4 Triangles
+ ExecutionMode 4 Invocations 1
+ ExecutionMode 4 OutputTriangleStrip
+ ExecutionMode 4 OutputVertices 3
+ Name 4 "main"
+ Name 9 "PS_IN"
+ MemberName 9(PS_IN) 0 "pos"
+ MemberName 9(PS_IN) 1 "tc"
+ Name 14 "STRUCT_WITH_NO_BUILTIN_INTERSTAGE_IO"
+ MemberName 14(STRUCT_WITH_NO_BUILTIN_INTERSTAGE_IO) 0 "m0_array"
+ MemberName 14(STRUCT_WITH_NO_BUILTIN_INTERSTAGE_IO) 1 "m1"
+ Name 15 "GS_OUT"
+ MemberName 15(GS_OUT) 0 "psIn"
+ MemberName 15(GS_OUT) 1 "contains_no_builtin_io"
+ Name 17 "o"
+ Name 33 "ts_psIn_pos"
+ Name 36 "PS_IN"
+ MemberName 36(PS_IN) 0 "tc"
+ Name 37 "STRUCT_WITH_NO_BUILTIN_INTERSTAGE_IO"
+ MemberName 37(STRUCT_WITH_NO_BUILTIN_INTERSTAGE_IO) 0 "m0_array"
+ MemberName 37(STRUCT_WITH_NO_BUILTIN_INTERSTAGE_IO) 1 "m1"
+ Name 38 "GS_OUT"
+ MemberName 38(GS_OUT) 0 "psIn"
+ MemberName 38(GS_OUT) 1 "contains_no_builtin_io"
+ Name 40 "ts"
+ Name 56 "PS_IN"
+ MemberName 56(PS_IN) 0 "tc"
+ Name 60 "tin"
+ Name 61 "PerVertex_in"
+ MemberName 61(PerVertex_in) 0 "tin_pos"
+ Name 64 "PerVertex_in"
+ Name 65 "PerVertex_out"
+ MemberName 65(PerVertex_out) 0 "ts_psIn_pos"
+ Name 67 "PerVertex_out"
+ Decorate 33(ts_psIn_pos) BuiltIn Position
+ Decorate 40(ts) Location 0
+ Decorate 60(tin) Location 0
+ MemberDecorate 61(PerVertex_in) 0 BuiltIn Position
+ Decorate 61(PerVertex_in) Block
+ MemberDecorate 65(PerVertex_out) 0 BuiltIn Position
+ Decorate 65(PerVertex_out) Block
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeFloat 32
+ 7: TypeVector 6(float) 4
+ 8: TypeVector 6(float) 2
+ 9(PS_IN): TypeStruct 7(fvec4) 8(fvec2)
+ 10: TypeInt 32 0
+ 11: 10(int) Constant 2
+ 12: TypeArray 6(float) 11
+ 13: TypeInt 32 1
+14(STRUCT_WITH_NO_BUILTIN_INTERSTAGE_IO): TypeStruct 12 13(int)
+ 15(GS_OUT): TypeStruct 9(PS_IN) 14(STRUCT_WITH_NO_BUILTIN_INTERSTAGE_IO)
+ 16: TypePointer Function 15(GS_OUT)
+ 18: 13(int) Constant 0
+ 19: 6(float) Constant 1065353216
+ 20: 6(float) Constant 1073741824
+ 21: 6(float) Constant 1077936128
+ 22: 6(float) Constant 1082130432
+ 23: 7(fvec4) ConstantComposite 19 20 21 22
+ 24: TypePointer Function 7(fvec4)
+ 26: 13(int) Constant 1
+ 27: 6(float) Constant 1084227584
+ 28: 6(float) Constant 1086324736
+ 29: 8(fvec2) ConstantComposite 27 28
+ 30: TypePointer Function 8(fvec2)
+ 32: TypePointer Output 7(fvec4)
+ 33(ts_psIn_pos): 32(ptr) Variable Output
+ 36(PS_IN): TypeStruct 8(fvec2)
+37(STRUCT_WITH_NO_BUILTIN_INTERSTAGE_IO): TypeStruct 12 13(int)
+ 38(GS_OUT): TypeStruct 36(PS_IN) 37(STRUCT_WITH_NO_BUILTIN_INTERSTAGE_IO)
+ 39: TypePointer Output 38(GS_OUT)
+ 40(ts): 39(ptr) Variable Output
+ 43: TypePointer Output 8(fvec2)
+ 45: TypePointer Function 14(STRUCT_WITH_NO_BUILTIN_INTERSTAGE_IO)
+ 48: TypePointer Output 37(STRUCT_WITH_NO_BUILTIN_INTERSTAGE_IO)
+ 51: TypePointer Output 12
+ 54: TypePointer Output 13(int)
+ 56(PS_IN): TypeStruct 8(fvec2)
+ 57: 10(int) Constant 3
+ 58: TypeArray 56(PS_IN) 57
+ 59: TypePointer Input 58
+ 60(tin): 59(ptr) Variable Input
+61(PerVertex_in): TypeStruct 7(fvec4)
+ 62: TypeArray 61(PerVertex_in) 57
+ 63: TypePointer Input 62
+64(PerVertex_in): 63(ptr) Variable Input
+65(PerVertex_out): TypeStruct 7(fvec4)
+ 66: TypePointer Output 65(PerVertex_out)
+67(PerVertex_out): 66(ptr) Variable Output
+ 4(main): 2 Function None 3
+ 5: Label
+ 17(o): 16(ptr) Variable Function
+ 25: 24(ptr) AccessChain 17(o) 18 18
+ Store 25 23
+ 31: 30(ptr) AccessChain 17(o) 18 26
+ Store 31 29
+ 34: 24(ptr) AccessChain 17(o) 18 18
+ 35: 7(fvec4) Load 34
+ Store 33(ts_psIn_pos) 35
+ 41: 30(ptr) AccessChain 17(o) 18 26
+ 42: 8(fvec2) Load 41
+ 44: 43(ptr) AccessChain 40(ts) 18 18
+ Store 44 42
+ 46: 45(ptr) AccessChain 17(o) 26
+ 47:14(STRUCT_WITH_NO_BUILTIN_INTERSTAGE_IO) Load 46
+ 49: 48(ptr) AccessChain 40(ts) 26
+ 50: 12 CompositeExtract 47 0
+ 52: 51(ptr) AccessChain 49 18
+ Store 52 50
+ 53: 13(int) CompositeExtract 47 1
+ 55: 54(ptr) AccessChain 49 26
+ Store 55 53
+ EmitVertex
+ Return
+ FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split.trivial.geom.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split.trivial.geom.out
new file mode 100644
index 00000000000..2ab8fdf7159
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split.trivial.geom.out
@@ -0,0 +1,192 @@
+hlsl.struct.split.trivial.geom
+Shader version: 450
+invocations = -1
+max_vertices = 3
+input primitive = triangles
+output primitive = triangle_strip
+0:? Sequence
+0:14 Function Definition: main(struct-PS_IN-vf41[3];struct-GS_OUT-vf41; (temp void)
+0:14 Function Parameters:
+0:14 'i' (in 3-element array of structure{temp 4-component vector of float Position pos})
+0:14 'ts' (out structure{temp 4-component vector of float Position pos})
+0:? Sequence
+0:17 Sequence
+0:17 move second child to first child (temp int)
+0:17 'x' (temp int)
+0:17 Constant:
+0:17 0 (const int)
+0:17 Loop with condition tested first
+0:17 Loop Condition
+0:17 Compare Less Than (temp bool)
+0:17 'x' (temp int)
+0:17 Constant:
+0:17 3 (const int)
+0:17 Loop Body
+0:? Sequence
+0:18 move second child to first child (temp 4-component vector of float)
+0:18 pos: direct index for structure (temp 4-component vector of float)
+0:18 'o' (temp structure{temp 4-component vector of float pos})
+0:18 Constant:
+0:18 0 (const int)
+0:18 indirect index (temp 4-component vector of float Position)
+0:18 'i_pos' (in 3-element array of 4-component vector of float Position)
+0:18 'x' (temp int)
+0:19 Sequence
+0:19 Sequence
+0:19 move second child to first child (temp 4-component vector of float)
+0:? 'ts_pos' (out 4-component vector of float Position)
+0:19 pos: direct index for structure (temp 4-component vector of float)
+0:19 'o' (temp structure{temp 4-component vector of float pos})
+0:19 Constant:
+0:19 0 (const int)
+0:19 EmitVertex (temp void)
+0:17 Loop Terminal Expression
+0:17 Pre-Increment (temp int)
+0:17 'x' (temp int)
+0:? Linker Objects
+0:? 'PerVertex_in' (in 3-element array of block{in 4-component vector of float Position i_pos})
+0:? 'PerVertex_out' (out block{out 4-component vector of float Position ts_pos})
+
+
+Linked geometry stage:
+
+
+Shader version: 450
+invocations = 1
+max_vertices = 3
+input primitive = triangles
+output primitive = triangle_strip
+0:? Sequence
+0:14 Function Definition: main(struct-PS_IN-vf41[3];struct-GS_OUT-vf41; (temp void)
+0:14 Function Parameters:
+0:14 'i' (in 3-element array of structure{temp 4-component vector of float Position pos})
+0:14 'ts' (out structure{temp 4-component vector of float Position pos})
+0:? Sequence
+0:17 Sequence
+0:17 move second child to first child (temp int)
+0:17 'x' (temp int)
+0:17 Constant:
+0:17 0 (const int)
+0:17 Loop with condition tested first
+0:17 Loop Condition
+0:17 Compare Less Than (temp bool)
+0:17 'x' (temp int)
+0:17 Constant:
+0:17 3 (const int)
+0:17 Loop Body
+0:? Sequence
+0:18 move second child to first child (temp 4-component vector of float)
+0:18 pos: direct index for structure (temp 4-component vector of float)
+0:18 'o' (temp structure{temp 4-component vector of float pos})
+0:18 Constant:
+0:18 0 (const int)
+0:18 indirect index (temp 4-component vector of float Position)
+0:18 'i_pos' (in 3-element array of 4-component vector of float Position)
+0:18 'x' (temp int)
+0:19 Sequence
+0:19 Sequence
+0:19 move second child to first child (temp 4-component vector of float)
+0:? 'ts_pos' (out 4-component vector of float Position)
+0:19 pos: direct index for structure (temp 4-component vector of float)
+0:19 'o' (temp structure{temp 4-component vector of float pos})
+0:19 Constant:
+0:19 0 (const int)
+0:19 EmitVertex (temp void)
+0:17 Loop Terminal Expression
+0:17 Pre-Increment (temp int)
+0:17 'x' (temp int)
+0:? Linker Objects
+0:? 'PerVertex_in' (in 3-element array of block{in 4-component vector of float Position i_pos})
+0:? 'PerVertex_out' (out block{out 4-component vector of float Position ts_pos})
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 49
+
+ Capability Geometry
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Geometry 4 "main" 28 36 45 48
+ ExecutionMode 4 Triangles
+ ExecutionMode 4 Invocations 1
+ ExecutionMode 4 OutputTriangleStrip
+ ExecutionMode 4 OutputVertices 3
+ Name 4 "main"
+ Name 8 "x"
+ Name 21 "GS_OUT"
+ MemberName 21(GS_OUT) 0 "pos"
+ Name 23 "o"
+ Name 28 "i_pos"
+ Name 36 "ts_pos"
+ Name 42 "PerVertex_in"
+ MemberName 42(PerVertex_in) 0 "i_pos"
+ Name 45 "PerVertex_in"
+ Name 46 "PerVertex_out"
+ MemberName 46(PerVertex_out) 0 "ts_pos"
+ Name 48 "PerVertex_out"
+ Decorate 28(i_pos) BuiltIn Position
+ Decorate 36(ts_pos) BuiltIn Position
+ MemberDecorate 42(PerVertex_in) 0 BuiltIn Position
+ Decorate 42(PerVertex_in) Block
+ MemberDecorate 46(PerVertex_out) 0 BuiltIn Position
+ Decorate 46(PerVertex_out) Block
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeInt 32 1
+ 7: TypePointer Function 6(int)
+ 9: 6(int) Constant 0
+ 16: 6(int) Constant 3
+ 17: TypeBool
+ 19: TypeFloat 32
+ 20: TypeVector 19(float) 4
+ 21(GS_OUT): TypeStruct 20(fvec4)
+ 22: TypePointer Function 21(GS_OUT)
+ 24: TypeInt 32 0
+ 25: 24(int) Constant 3
+ 26: TypeArray 20(fvec4) 25
+ 27: TypePointer Input 26
+ 28(i_pos): 27(ptr) Variable Input
+ 30: TypePointer Input 20(fvec4)
+ 33: TypePointer Function 20(fvec4)
+ 35: TypePointer Output 20(fvec4)
+ 36(ts_pos): 35(ptr) Variable Output
+ 40: 6(int) Constant 1
+42(PerVertex_in): TypeStruct 20(fvec4)
+ 43: TypeArray 42(PerVertex_in) 25
+ 44: TypePointer Input 43
+45(PerVertex_in): 44(ptr) Variable Input
+46(PerVertex_out): TypeStruct 20(fvec4)
+ 47: TypePointer Output 46(PerVertex_out)
+48(PerVertex_out): 47(ptr) Variable Output
+ 4(main): 2 Function None 3
+ 5: Label
+ 8(x): 7(ptr) Variable Function
+ 23(o): 22(ptr) Variable Function
+ Store 8(x) 9
+ Branch 10
+ 10: Label
+ LoopMerge 12 13 None
+ Branch 14
+ 14: Label
+ 15: 6(int) Load 8(x)
+ 18: 17(bool) SLessThan 15 16
+ BranchConditional 18 11 12
+ 11: Label
+ 29: 6(int) Load 8(x)
+ 31: 30(ptr) AccessChain 28(i_pos) 29
+ 32: 20(fvec4) Load 31
+ 34: 33(ptr) AccessChain 23(o) 9
+ Store 34 32
+ 37: 33(ptr) AccessChain 23(o) 9
+ 38: 20(fvec4) Load 37
+ Store 36(ts_pos) 38
+ EmitVertex
+ Branch 13
+ 13: Label
+ 39: 6(int) Load 8(x)
+ 41: 6(int) IAdd 39 40
+ Store 8(x) 41
+ Branch 10
+ 12: Label
+ Return
+ FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split.trivial.vert.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split.trivial.vert.out
new file mode 100644
index 00000000000..29fb9f50230
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.struct.split.trivial.vert.out
@@ -0,0 +1,116 @@
+hlsl.struct.split.trivial.vert
+Shader version: 450
+0:? Sequence
+0:16 Function Definition: main(struct-VS_INPUT-vf41;vf4; (temp structure{temp 4-component vector of float Position Pos})
+0:16 Function Parameters:
+0:16 'vsin' (in structure{temp 4-component vector of float Pos_in})
+0:16 'Pos_loose' (in 4-component vector of float Position)
+0:? Sequence
+0:19 move second child to first child (temp 4-component vector of float)
+0:19 Pos: direct index for structure (temp 4-component vector of float)
+0:19 'vsout' (temp structure{temp 4-component vector of float Pos})
+0:19 Constant:
+0:19 0 (const int)
+0:19 add (temp 4-component vector of float)
+0:? 'Pos_in' (in 4-component vector of float Position)
+0:19 'Pos_loose' (in 4-component vector of float Position)
+0:21 Sequence
+0:21 Sequence
+0:21 move second child to first child (temp 4-component vector of float)
+0:? 'Pos' (out 4-component vector of float Position)
+0:21 Pos: direct index for structure (temp 4-component vector of float)
+0:21 'vsout' (temp structure{temp 4-component vector of float Pos})
+0:21 Constant:
+0:21 0 (const int)
+0:21 Branch: Return
+0:? Linker Objects
+0:? 'Pos_in' (in 4-component vector of float Position)
+0:? 'Pos_loose' (in 4-component vector of float Position)
+0:? 'PerVertex_out' (out block{out 4-component vector of float Position Pos})
+
+
+Linked vertex stage:
+
+
+Shader version: 450
+0:? Sequence
+0:16 Function Definition: main(struct-VS_INPUT-vf41;vf4; (temp structure{temp 4-component vector of float Position Pos})
+0:16 Function Parameters:
+0:16 'vsin' (in structure{temp 4-component vector of float Pos_in})
+0:16 'Pos_loose' (in 4-component vector of float Position)
+0:? Sequence
+0:19 move second child to first child (temp 4-component vector of float)
+0:19 Pos: direct index for structure (temp 4-component vector of float)
+0:19 'vsout' (temp structure{temp 4-component vector of float Pos})
+0:19 Constant:
+0:19 0 (const int)
+0:19 add (temp 4-component vector of float)
+0:? 'Pos_in' (in 4-component vector of float Position)
+0:19 'Pos_loose' (in 4-component vector of float Position)
+0:21 Sequence
+0:21 Sequence
+0:21 move second child to first child (temp 4-component vector of float)
+0:? 'Pos' (out 4-component vector of float Position)
+0:21 Pos: direct index for structure (temp 4-component vector of float)
+0:21 'vsout' (temp structure{temp 4-component vector of float Pos})
+0:21 Constant:
+0:21 0 (const int)
+0:21 Branch: Return
+0:? Linker Objects
+0:? 'Pos_in' (in 4-component vector of float Position)
+0:? 'Pos_loose' (in 4-component vector of float Position)
+0:? 'PerVertex_out' (out block{out 4-component vector of float Position Pos})
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 29
+
+ Capability Shader
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Vertex 4 "main" 14 16 22 28
+ Name 4 "main"
+ Name 8 "VS_OUTPUT"
+ MemberName 8(VS_OUTPUT) 0 "Pos"
+ Name 10 "vsout"
+ Name 14 "Pos_in"
+ Name 16 "Pos_loose"
+ Name 22 "Pos"
+ Name 26 "PerVertex_out"
+ MemberName 26(PerVertex_out) 0 "Pos"
+ Name 28 "PerVertex_out"
+ Decorate 14(Pos_in) BuiltIn Position
+ Decorate 16(Pos_loose) BuiltIn Position
+ Decorate 22(Pos) BuiltIn Position
+ MemberDecorate 26(PerVertex_out) 0 BuiltIn Position
+ Decorate 26(PerVertex_out) Block
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeFloat 32
+ 7: TypeVector 6(float) 4
+ 8(VS_OUTPUT): TypeStruct 7(fvec4)
+ 9: TypePointer Function 8(VS_OUTPUT)
+ 11: TypeInt 32 1
+ 12: 11(int) Constant 0
+ 13: TypePointer Input 7(fvec4)
+ 14(Pos_in): 13(ptr) Variable Input
+ 16(Pos_loose): 13(ptr) Variable Input
+ 19: TypePointer Function 7(fvec4)
+ 21: TypePointer Output 7(fvec4)
+ 22(Pos): 21(ptr) Variable Output
+26(PerVertex_out): TypeStruct 7(fvec4)
+ 27: TypePointer Output 26(PerVertex_out)
+28(PerVertex_out): 27(ptr) Variable Output
+ 4(main): 2 Function None 3
+ 5: Label
+ 10(vsout): 9(ptr) Variable Function
+ 15: 7(fvec4) Load 14(Pos_in)
+ 17: 7(fvec4) Load 16(Pos_loose)
+ 18: 7(fvec4) FAdd 15 17
+ 20: 19(ptr) AccessChain 10(vsout) 12
+ Store 20 18
+ 23: 19(ptr) AccessChain 10(vsout) 12
+ 24: 7(fvec4) Load 23
+ Store 22(Pos) 24
+ Return
+ FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.structarray.flatten.geom.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.structarray.flatten.geom.out
index 0994af84f6a..626ab8dde7e 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.structarray.flatten.geom.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.structarray.flatten.geom.out
@@ -1,52 +1,82 @@
hlsl.structarray.flatten.geom
-ERROR: 0:10: 'vin' : recursive type not yet supported in GS input
-ERROR: 1 compilation errors. No code generated.
-
-
Shader version: 450
invocations = -1
max_vertices = 4
input primitive = lines
output primitive = triangle_strip
-ERROR: node is still EOpNull!
-0:10 Function Definition: main(struct-VertexData-vf4-vf4-vf21[2];struct-VertexData-vf4-vf4-vf21; (temp void)
-0:10 Function Parameters:
-0:10 'vin' (in 2-element array of structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
-0:10 'outStream' (out structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:? Sequence
+0:16 Function Definition: main(struct-VertexData-vf4-vf4-vf21[2];struct-PS_IN-vf4-vf4-vf21; (temp void)
+0:16 Function Parameters:
+0:16 'vin' (layout(location=0 ) in 2-element array of structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:16 'outStream' (out structure{temp 4-component vector of float Position position, temp 4-component vector of float color, temp 2-component vector of float uv})
0:? Sequence
-0:13 move second child to first child (temp 4-component vector of float)
-0:13 color: direct index for structure (temp 4-component vector of float)
-0:13 'vout' (temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
-0:13 Constant:
-0:13 1 (const int)
-0:? 'vin[0].color' (layout(location=1 ) in 4-component vector of float)
-0:14 move second child to first child (temp 2-component vector of float)
-0:14 uv: direct index for structure (temp 2-component vector of float)
-0:14 'vout' (temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
-0:14 Constant:
-0:14 2 (const int)
-0:? 'vin[0].uv' (layout(location=2 ) in 2-component vector of float)
-0:15 move second child to first child (temp 4-component vector of float)
-0:15 position: direct index for structure (temp 4-component vector of float)
-0:15 'vout' (temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
-0:15 Constant:
-0:15 0 (const int)
-0:? 'vin[0].position' (layout(location=0 ) in 4-component vector of float)
-0:16 Sequence
-0:16 move second child to first child (temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
-0:16 'outStream' (out structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
-0:16 'vout' (temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
-0:16 EmitVertex (temp void)
+0:19 move second child to first child (temp 4-component vector of float)
+0:19 color: direct index for structure (temp 4-component vector of float)
+0:19 'vout' (temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:19 Constant:
+0:19 1 (const int)
+0:19 color: direct index for structure (temp 4-component vector of float)
+0:19 direct index (layout(location=0 ) temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:19 'vin' (layout(location=0 ) in 2-element array of structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:19 Constant:
+0:19 1 (const int)
+0:19 Constant:
+0:19 1 (const int)
+0:20 move second child to first child (temp 2-component vector of float)
+0:20 uv: direct index for structure (temp 2-component vector of float)
+0:20 'vout' (temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:20 Constant:
+0:20 2 (const int)
+0:20 uv: direct index for structure (temp 2-component vector of float)
+0:20 direct index (layout(location=0 ) temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:20 'vin' (layout(location=0 ) in 2-element array of structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:20 Constant:
+0:20 1 (const int)
+0:20 Constant:
+0:20 2 (const int)
+0:21 move second child to first child (temp 4-component vector of float)
+0:21 position: direct index for structure (temp 4-component vector of float)
+0:21 'vout' (temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:21 Constant:
+0:21 0 (const int)
+0:21 position: direct index for structure (temp 4-component vector of float)
+0:21 direct index (layout(location=0 ) temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:21 'vin' (layout(location=0 ) in 2-element array of structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:21 Constant:
+0:21 1 (const int)
+0:21 Constant:
+0:21 0 (const int)
+0:22 Sequence
+0:22 Sequence
+0:22 move second child to first child (temp 4-component vector of float)
+0:? 'outStream_position' (out 4-component vector of float Position)
+0:22 position: direct index for structure (temp 4-component vector of float)
+0:22 'vout' (temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:22 Constant:
+0:22 0 (const int)
+0:22 move second child to first child (temp 4-component vector of float)
+0:22 color: direct index for structure (temp 4-component vector of float)
+0:22 'outStream' (layout(location=0 ) out structure{temp 4-component vector of float color, temp 2-component vector of float uv})
+0:22 Constant:
+0:22 0 (const int)
+0:22 color: direct index for structure (temp 4-component vector of float)
+0:22 'vout' (temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:22 Constant:
+0:22 1 (const int)
+0:22 move second child to first child (temp 2-component vector of float)
+0:22 uv: direct index for structure (temp 2-component vector of float)
+0:22 'outStream' (layout(location=0 ) out structure{temp 4-component vector of float color, temp 2-component vector of float uv})
+0:22 Constant:
+0:22 1 (const int)
+0:22 uv: direct index for structure (temp 2-component vector of float)
+0:22 'vout' (temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:22 Constant:
+0:22 2 (const int)
+0:22 EmitVertex (temp void)
0:? Linker Objects
-0:? 'vin[0].position' (layout(location=0 ) in 4-component vector of float)
-0:? 'vin[0].color' (layout(location=1 ) in 4-component vector of float)
-0:? 'vin[0].uv' (layout(location=2 ) in 2-component vector of float)
-0:? 'vin[1].position' (layout(location=3 ) in 4-component vector of float)
-0:? 'vin[1].color' (layout(location=4 ) in 4-component vector of float)
-0:? 'vin[1].uv' (layout(location=5 ) in 2-component vector of float)
-0:? 'position' (layout(location=0 ) out 4-component vector of float)
-0:? 'color' (layout(location=1 ) out 4-component vector of float)
-0:? 'uv' (layout(location=2 ) out 2-component vector of float)
+0:? 'vin' (layout(location=0 ) in 2-element array of structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:? 'outStream' (layout(location=0 ) out structure{temp 4-component vector of float color, temp 2-component vector of float uv})
+0:? 'PerVertex_out' (out block{out 4-component vector of float Position outStream_position})
Linked geometry stage:
@@ -57,44 +87,172 @@ invocations = 1
max_vertices = 4
input primitive = lines
output primitive = triangle_strip
-ERROR: node is still EOpNull!
-0:10 Function Definition: main(struct-VertexData-vf4-vf4-vf21[2];struct-VertexData-vf4-vf4-vf21; (temp void)
-0:10 Function Parameters:
-0:10 'vin' (in 2-element array of structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
-0:10 'outStream' (out structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:? Sequence
+0:16 Function Definition: main(struct-VertexData-vf4-vf4-vf21[2];struct-PS_IN-vf4-vf4-vf21; (temp void)
+0:16 Function Parameters:
+0:16 'vin' (layout(location=0 ) in 2-element array of structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:16 'outStream' (out structure{temp 4-component vector of float Position position, temp 4-component vector of float color, temp 2-component vector of float uv})
0:? Sequence
-0:13 move second child to first child (temp 4-component vector of float)
-0:13 color: direct index for structure (temp 4-component vector of float)
-0:13 'vout' (temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
-0:13 Constant:
-0:13 1 (const int)
-0:? 'vin[0].color' (layout(location=1 ) in 4-component vector of float)
-0:14 move second child to first child (temp 2-component vector of float)
-0:14 uv: direct index for structure (temp 2-component vector of float)
-0:14 'vout' (temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
-0:14 Constant:
-0:14 2 (const int)
-0:? 'vin[0].uv' (layout(location=2 ) in 2-component vector of float)
-0:15 move second child to first child (temp 4-component vector of float)
-0:15 position: direct index for structure (temp 4-component vector of float)
-0:15 'vout' (temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
-0:15 Constant:
-0:15 0 (const int)
-0:? 'vin[0].position' (layout(location=0 ) in 4-component vector of float)
-0:16 Sequence
-0:16 move second child to first child (temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
-0:16 'outStream' (out structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
-0:16 'vout' (temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
-0:16 EmitVertex (temp void)
+0:19 move second child to first child (temp 4-component vector of float)
+0:19 color: direct index for structure (temp 4-component vector of float)
+0:19 'vout' (temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:19 Constant:
+0:19 1 (const int)
+0:19 color: direct index for structure (temp 4-component vector of float)
+0:19 direct index (layout(location=0 ) temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:19 'vin' (layout(location=0 ) in 2-element array of structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:19 Constant:
+0:19 1 (const int)
+0:19 Constant:
+0:19 1 (const int)
+0:20 move second child to first child (temp 2-component vector of float)
+0:20 uv: direct index for structure (temp 2-component vector of float)
+0:20 'vout' (temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:20 Constant:
+0:20 2 (const int)
+0:20 uv: direct index for structure (temp 2-component vector of float)
+0:20 direct index (layout(location=0 ) temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:20 'vin' (layout(location=0 ) in 2-element array of structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:20 Constant:
+0:20 1 (const int)
+0:20 Constant:
+0:20 2 (const int)
+0:21 move second child to first child (temp 4-component vector of float)
+0:21 position: direct index for structure (temp 4-component vector of float)
+0:21 'vout' (temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:21 Constant:
+0:21 0 (const int)
+0:21 position: direct index for structure (temp 4-component vector of float)
+0:21 direct index (layout(location=0 ) temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:21 'vin' (layout(location=0 ) in 2-element array of structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:21 Constant:
+0:21 1 (const int)
+0:21 Constant:
+0:21 0 (const int)
+0:22 Sequence
+0:22 Sequence
+0:22 move second child to first child (temp 4-component vector of float)
+0:? 'outStream_position' (out 4-component vector of float Position)
+0:22 position: direct index for structure (temp 4-component vector of float)
+0:22 'vout' (temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:22 Constant:
+0:22 0 (const int)
+0:22 move second child to first child (temp 4-component vector of float)
+0:22 color: direct index for structure (temp 4-component vector of float)
+0:22 'outStream' (layout(location=0 ) out structure{temp 4-component vector of float color, temp 2-component vector of float uv})
+0:22 Constant:
+0:22 0 (const int)
+0:22 color: direct index for structure (temp 4-component vector of float)
+0:22 'vout' (temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:22 Constant:
+0:22 1 (const int)
+0:22 move second child to first child (temp 2-component vector of float)
+0:22 uv: direct index for structure (temp 2-component vector of float)
+0:22 'outStream' (layout(location=0 ) out structure{temp 4-component vector of float color, temp 2-component vector of float uv})
+0:22 Constant:
+0:22 1 (const int)
+0:22 uv: direct index for structure (temp 2-component vector of float)
+0:22 'vout' (temp structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:22 Constant:
+0:22 2 (const int)
+0:22 EmitVertex (temp void)
0:? Linker Objects
-0:? 'vin[0].position' (layout(location=0 ) in 4-component vector of float)
-0:? 'vin[0].color' (layout(location=1 ) in 4-component vector of float)
-0:? 'vin[0].uv' (layout(location=2 ) in 2-component vector of float)
-0:? 'vin[1].position' (layout(location=3 ) in 4-component vector of float)
-0:? 'vin[1].color' (layout(location=4 ) in 4-component vector of float)
-0:? 'vin[1].uv' (layout(location=5 ) in 2-component vector of float)
-0:? 'position' (layout(location=0 ) out 4-component vector of float)
-0:? 'color' (layout(location=1 ) out 4-component vector of float)
-0:? 'uv' (layout(location=2 ) out 2-component vector of float)
+0:? 'vin' (layout(location=0 ) in 2-element array of structure{temp 4-component vector of float position, temp 4-component vector of float color, temp 2-component vector of float uv})
+0:? 'outStream' (layout(location=0 ) out structure{temp 4-component vector of float color, temp 2-component vector of float uv})
+0:? 'PerVertex_out' (out block{out 4-component vector of float Position outStream_position})
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 52
-SPIR-V is not generated for failed compile or link
+ Capability Geometry
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Geometry 4 "main" 19 36 41 51
+ ExecutionMode 4 InputLines
+ ExecutionMode 4 Invocations 1
+ ExecutionMode 4 OutputTriangleStrip
+ ExecutionMode 4 OutputVertices 4
+ Name 4 "main"
+ Name 9 "PS_IN"
+ MemberName 9(PS_IN) 0 "position"
+ MemberName 9(PS_IN) 1 "color"
+ MemberName 9(PS_IN) 2 "uv"
+ Name 11 "vout"
+ Name 14 "VertexData"
+ MemberName 14(VertexData) 0 "position"
+ MemberName 14(VertexData) 1 "color"
+ MemberName 14(VertexData) 2 "uv"
+ Name 19 "vin"
+ Name 36 "outStream_position"
+ Name 39 "PS_IN"
+ MemberName 39(PS_IN) 0 "color"
+ MemberName 39(PS_IN) 1 "uv"
+ Name 41 "outStream"
+ Name 49 "PerVertex_out"
+ MemberName 49(PerVertex_out) 0 "outStream_position"
+ Name 51 "PerVertex_out"
+ Decorate 19(vin) Location 0
+ Decorate 36(outStream_position) BuiltIn Position
+ Decorate 41(outStream) Location 0
+ MemberDecorate 49(PerVertex_out) 0 BuiltIn Position
+ Decorate 49(PerVertex_out) Block
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeFloat 32
+ 7: TypeVector 6(float) 4
+ 8: TypeVector 6(float) 2
+ 9(PS_IN): TypeStruct 7(fvec4) 7(fvec4) 8(fvec2)
+ 10: TypePointer Function 9(PS_IN)
+ 12: TypeInt 32 1
+ 13: 12(int) Constant 1
+ 14(VertexData): TypeStruct 7(fvec4) 7(fvec4) 8(fvec2)
+ 15: TypeInt 32 0
+ 16: 15(int) Constant 2
+ 17: TypeArray 14(VertexData) 16
+ 18: TypePointer Input 17
+ 19(vin): 18(ptr) Variable Input
+ 20: TypePointer Input 7(fvec4)
+ 23: TypePointer Function 7(fvec4)
+ 25: 12(int) Constant 2
+ 26: TypePointer Input 8(fvec2)
+ 29: TypePointer Function 8(fvec2)
+ 31: 12(int) Constant 0
+ 35: TypePointer Output 7(fvec4)
+36(outStream_position): 35(ptr) Variable Output
+ 39(PS_IN): TypeStruct 7(fvec4) 8(fvec2)
+ 40: TypePointer Output 39(PS_IN)
+ 41(outStream): 40(ptr) Variable Output
+ 47: TypePointer Output 8(fvec2)
+49(PerVertex_out): TypeStruct 7(fvec4)
+ 50: TypePointer Output 49(PerVertex_out)
+51(PerVertex_out): 50(ptr) Variable Output
+ 4(main): 2 Function None 3
+ 5: Label
+ 11(vout): 10(ptr) Variable Function
+ 21: 20(ptr) AccessChain 19(vin) 13 13
+ 22: 7(fvec4) Load 21
+ 24: 23(ptr) AccessChain 11(vout) 13
+ Store 24 22
+ 27: 26(ptr) AccessChain 19(vin) 13 25
+ 28: 8(fvec2) Load 27
+ 30: 29(ptr) AccessChain 11(vout) 25
+ Store 30 28
+ 32: 20(ptr) AccessChain 19(vin) 13 31
+ 33: 7(fvec4) Load 32
+ 34: 23(ptr) AccessChain 11(vout) 31
+ Store 34 33
+ 37: 23(ptr) AccessChain 11(vout) 31
+ 38: 7(fvec4) Load 37
+ Store 36(outStream_position) 38
+ 42: 23(ptr) AccessChain 11(vout) 13
+ 43: 7(fvec4) Load 42
+ 44: 35(ptr) AccessChain 41(outStream) 31
+ Store 44 43
+ 45: 29(ptr) AccessChain 11(vout) 25
+ 46: 8(fvec2) Load 45
+ 48: 47(ptr) AccessChain 41(outStream) 13
+ Store 48 46
+ EmitVertex
+ Return
+ FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.structin.vert.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.structin.vert.out
index a5feea8aa9a..5e83ed4fac9 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.structin.vert.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.structin.vert.out
@@ -28,50 +28,42 @@ Shader version: 450
0:11 'e' (layout(location=5 ) in 4-component vector of float)
0:13 Sequence
0:13 Sequence
-0:13 move second child to first child (temp 4-component vector of float)
-0:? 'm[0]' (layout(location=0 ) out 4-component vector of float)
-0:13 direct index (temp 4-component vector of float)
-0:13 m: direct index for structure (temp 2-element array of 4-component vector of float)
-0:13 'local' (temp structure{temp 2-element array of 4-component vector of float m, temp 2-component vector of uint coord, temp 4-component vector of float b})
-0:13 Constant:
-0:13 0 (const int)
+0:13 move second child to first child (temp 2-element array of 4-component vector of float)
+0:13 m: direct index for structure (temp 2-element array of 4-component vector of float)
+0:13 '@entryPointOutput' (out structure Position{temp 2-element array of 4-component vector of float m, temp 2-component vector of uint coord, smooth temp 4-component vector of float b})
0:13 Constant:
0:13 0 (const int)
-0:13 move second child to first child (temp 4-component vector of float)
-0:? 'm[1]' (layout(location=1 ) out 4-component vector of float)
-0:13 direct index (temp 4-component vector of float)
-0:13 m: direct index for structure (temp 2-element array of 4-component vector of float)
-0:13 'local' (temp structure{temp 2-element array of 4-component vector of float m, temp 2-component vector of uint coord, temp 4-component vector of float b})
-0:13 Constant:
-0:13 0 (const int)
+0:13 m: direct index for structure (temp 2-element array of 4-component vector of float)
+0:13 'local' (temp structure{temp 2-element array of 4-component vector of float m, temp 2-component vector of uint coord, temp 4-component vector of float b})
0:13 Constant:
-0:13 1 (const int)
+0:13 0 (const int)
0:13 move second child to first child (temp 2-component vector of uint)
-0:? 'coord' (layout(location=2 ) out 2-component vector of uint)
+0:13 coord: direct index for structure (temp 2-component vector of uint)
+0:13 '@entryPointOutput' (out structure Position{temp 2-element array of 4-component vector of float m, temp 2-component vector of uint coord, smooth temp 4-component vector of float b})
+0:13 Constant:
+0:13 1 (const int)
0:13 coord: direct index for structure (temp 2-component vector of uint)
0:13 'local' (temp structure{temp 2-element array of 4-component vector of float m, temp 2-component vector of uint coord, temp 4-component vector of float b})
0:13 Constant:
0:13 1 (const int)
0:13 move second child to first child (temp 4-component vector of float)
-0:? 'b' (layout(location=3 ) smooth out 4-component vector of float)
+0:13 b: direct index for structure (smooth temp 4-component vector of float)
+0:13 '@entryPointOutput' (out structure Position{temp 2-element array of 4-component vector of float m, temp 2-component vector of uint coord, smooth temp 4-component vector of float b})
+0:13 Constant:
+0:13 2 (const int)
0:13 b: direct index for structure (temp 4-component vector of float)
0:13 'local' (temp structure{temp 2-element array of 4-component vector of float m, temp 2-component vector of uint coord, temp 4-component vector of float b})
0:13 Constant:
0:13 2 (const int)
0:13 Branch: Return
0:? Linker Objects
-0:? 'm[0]' (layout(location=0 ) out 4-component vector of float)
-0:? 'm[1]' (layout(location=1 ) out 4-component vector of float)
-0:? 'coord' (layout(location=2 ) out 2-component vector of uint)
-0:? 'b' (layout(location=3 ) smooth out 4-component vector of float)
+0:? '@entryPointOutput' (out structure Position{temp 2-element array of 4-component vector of float m, temp 2-component vector of uint coord, smooth temp 4-component vector of float b})
0:? 'd' (layout(location=0 ) in 4-component vector of float)
0:? 'm[0]' (layout(location=1 ) in 4-component vector of float)
0:? 'm[1]' (layout(location=2 ) in 4-component vector of float)
0:? 'coord' (layout(location=3 ) in 2-component vector of uint)
-0:? 'b' (layout(location=4 ) in 4-component vector of float)
+0:? 'b' (layout(location=4 ) smooth in 4-component vector of float)
0:? 'e' (layout(location=5 ) in 4-component vector of float)
-0:? 'm[0]' (layout(location=0 ) out 4-component vector of float)
-0:? 'm[1]' (layout(location=1 ) out 4-component vector of float)
0:? 'm[0]' (layout(location=1 ) in 4-component vector of float)
0:? 'm[1]' (layout(location=2 ) in 4-component vector of float)
@@ -108,61 +100,53 @@ Shader version: 450
0:11 'e' (layout(location=5 ) in 4-component vector of float)
0:13 Sequence
0:13 Sequence
-0:13 move second child to first child (temp 4-component vector of float)
-0:? 'm[0]' (layout(location=0 ) out 4-component vector of float)
-0:13 direct index (temp 4-component vector of float)
-0:13 m: direct index for structure (temp 2-element array of 4-component vector of float)
-0:13 'local' (temp structure{temp 2-element array of 4-component vector of float m, temp 2-component vector of uint coord, temp 4-component vector of float b})
-0:13 Constant:
-0:13 0 (const int)
+0:13 move second child to first child (temp 2-element array of 4-component vector of float)
+0:13 m: direct index for structure (temp 2-element array of 4-component vector of float)
+0:13 '@entryPointOutput' (out structure Position{temp 2-element array of 4-component vector of float m, temp 2-component vector of uint coord, smooth temp 4-component vector of float b})
0:13 Constant:
0:13 0 (const int)
-0:13 move second child to first child (temp 4-component vector of float)
-0:? 'm[1]' (layout(location=1 ) out 4-component vector of float)
-0:13 direct index (temp 4-component vector of float)
-0:13 m: direct index for structure (temp 2-element array of 4-component vector of float)
-0:13 'local' (temp structure{temp 2-element array of 4-component vector of float m, temp 2-component vector of uint coord, temp 4-component vector of float b})
-0:13 Constant:
-0:13 0 (const int)
+0:13 m: direct index for structure (temp 2-element array of 4-component vector of float)
+0:13 'local' (temp structure{temp 2-element array of 4-component vector of float m, temp 2-component vector of uint coord, temp 4-component vector of float b})
0:13 Constant:
-0:13 1 (const int)
+0:13 0 (const int)
0:13 move second child to first child (temp 2-component vector of uint)
-0:? 'coord' (layout(location=2 ) out 2-component vector of uint)
+0:13 coord: direct index for structure (temp 2-component vector of uint)
+0:13 '@entryPointOutput' (out structure Position{temp 2-element array of 4-component vector of float m, temp 2-component vector of uint coord, smooth temp 4-component vector of float b})
+0:13 Constant:
+0:13 1 (const int)
0:13 coord: direct index for structure (temp 2-component vector of uint)
0:13 'local' (temp structure{temp 2-element array of 4-component vector of float m, temp 2-component vector of uint coord, temp 4-component vector of float b})
0:13 Constant:
0:13 1 (const int)
0:13 move second child to first child (temp 4-component vector of float)
-0:? 'b' (layout(location=3 ) smooth out 4-component vector of float)
+0:13 b: direct index for structure (smooth temp 4-component vector of float)
+0:13 '@entryPointOutput' (out structure Position{temp 2-element array of 4-component vector of float m, temp 2-component vector of uint coord, smooth temp 4-component vector of float b})
+0:13 Constant:
+0:13 2 (const int)
0:13 b: direct index for structure (temp 4-component vector of float)
0:13 'local' (temp structure{temp 2-element array of 4-component vector of float m, temp 2-component vector of uint coord, temp 4-component vector of float b})
0:13 Constant:
0:13 2 (const int)
0:13 Branch: Return
0:? Linker Objects
-0:? 'm[0]' (layout(location=0 ) out 4-component vector of float)
-0:? 'm[1]' (layout(location=1 ) out 4-component vector of float)
-0:? 'coord' (layout(location=2 ) out 2-component vector of uint)
-0:? 'b' (layout(location=3 ) smooth out 4-component vector of float)
+0:? '@entryPointOutput' (out structure Position{temp 2-element array of 4-component vector of float m, temp 2-component vector of uint coord, smooth temp 4-component vector of float b})
0:? 'd' (layout(location=0 ) in 4-component vector of float)
0:? 'm[0]' (layout(location=1 ) in 4-component vector of float)
0:? 'm[1]' (layout(location=2 ) in 4-component vector of float)
0:? 'coord' (layout(location=3 ) in 2-component vector of uint)
-0:? 'b' (layout(location=4 ) in 4-component vector of float)
+0:? 'b' (layout(location=4 ) smooth in 4-component vector of float)
0:? 'e' (layout(location=5 ) in 4-component vector of float)
-0:? 'm[0]' (layout(location=0 ) out 4-component vector of float)
-0:? 'm[1]' (layout(location=1 ) out 4-component vector of float)
0:? 'm[0]' (layout(location=1 ) in 4-component vector of float)
0:? 'm[1]' (layout(location=2 ) in 4-component vector of float)
// Module Version 10000
// Generated by (magic number): 80001
-// Id's are bound by 59
+// Id's are bound by 61
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
- EntryPoint Vertex 4 "main" 18 20 24 32 35 41 45 50 54 58
+ EntryPoint Vertex 4 "main" 18 20 24 32 35 42 60
Name 4 "main"
Name 12 "VI"
MemberName 12(VI) 0 "m"
@@ -174,21 +158,19 @@ Shader version: 450
Name 24 "coord"
Name 32 "d"
Name 35 "e"
- Name 41 "m[0]"
- Name 45 "m[1]"
- Name 50 "coord"
- Name 54 "b"
- Name 58 "b"
+ Name 40 "VI"
+ MemberName 40(VI) 0 "m"
+ MemberName 40(VI) 1 "coord"
+ MemberName 40(VI) 2 "b"
+ Name 42 "@entryPointOutput"
+ Name 60 "b"
Decorate 18(m[1]) Location 2
Decorate 20(m[0]) Location 1
Decorate 24(coord) Location 3
Decorate 32(d) Location 0
Decorate 35(e) Location 5
- Decorate 41(m[0]) Location 0
- Decorate 45(m[1]) Location 1
- Decorate 50(coord) Location 2
- Decorate 54(b) Location 3
- Decorate 58(b) Location 4
+ Decorate 42(@entryPointOutput) BuiltIn Position
+ Decorate 60(b) Location 4
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@@ -211,16 +193,17 @@ Shader version: 450
32(d): 17(ptr) Variable Input
35(e): 17(ptr) Variable Input
38: TypePointer Function 7(fvec4)
- 40: TypePointer Output 7(fvec4)
- 41(m[0]): 40(ptr) Variable Output
- 42: 15(int) Constant 0
- 45(m[1]): 40(ptr) Variable Output
- 46: 15(int) Constant 1
- 49: TypePointer Output 11(ivec2)
- 50(coord): 49(ptr) Variable Output
- 51: TypePointer Function 11(ivec2)
- 54(b): 40(ptr) Variable Output
- 58(b): 17(ptr) Variable Input
+ 40(VI): TypeStruct 10 11(ivec2) 7(fvec4)
+ 41: TypePointer Output 40(VI)
+42(@entryPointOutput): 41(ptr) Variable Output
+ 43: 15(int) Constant 0
+ 44: TypePointer Function 10
+ 47: TypePointer Output 10
+ 49: 15(int) Constant 1
+ 50: TypePointer Function 11(ivec2)
+ 53: TypePointer Output 11(ivec2)
+ 57: TypePointer Output 7(fvec4)
+ 60(b): 17(ptr) Variable Input
4(main): 2 Function None 3
5: Label
14(local): 13(ptr) Variable Function
@@ -238,17 +221,17 @@ Shader version: 450
37: 7(fvec4) FAdd 34 36
39: 38(ptr) AccessChain 14(local) 16
Store 39 37
- 43: 38(ptr) AccessChain 14(local) 42 42
- 44: 7(fvec4) Load 43
- Store 41(m[0]) 44
- 47: 38(ptr) AccessChain 14(local) 42 46
- 48: 7(fvec4) Load 47
- Store 45(m[1]) 48
- 52: 51(ptr) AccessChain 14(local) 46
- 53: 11(ivec2) Load 52
- Store 50(coord) 53
+ 45: 44(ptr) AccessChain 14(local) 43
+ 46: 10 Load 45
+ 48: 47(ptr) AccessChain 42(@entryPointOutput) 43
+ Store 48 46
+ 51: 50(ptr) AccessChain 14(local) 49
+ 52: 11(ivec2) Load 51
+ 54: 53(ptr) AccessChain 42(@entryPointOutput) 49
+ Store 54 52
55: 38(ptr) AccessChain 14(local) 16
56: 7(fvec4) Load 55
- Store 54(b) 56
+ 58: 57(ptr) AccessChain 42(@entryPointOutput) 16
+ Store 58 56
Return
FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.type.half.frag.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.type.half.frag.out
new file mode 100644
index 00000000000..284835109e9
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.type.half.frag.out
@@ -0,0 +1,161 @@
+hlsl.type.half.frag
+Shader version: 450
+gl_FragCoord origin is upper left
+0:? Sequence
+0:3 Function Definition: main( (temp 4-component vector of float)
+0:3 Function Parameters:
+0:? Sequence
+0:4 Sequence
+0:4 move second child to first child (temp mediump float)
+0:4 'h0' (temp mediump float)
+0:4 Constant:
+0:4 0.000000
+0:5 Sequence
+0:5 move second child to first child (temp mediump 1-component vector of float)
+0:5 'h1' (temp mediump 1-component vector of float)
+0:5 Constant:
+0:5 1.000000
+0:6 Sequence
+0:6 move second child to first child (temp mediump 2-component vector of float)
+0:6 'h2' (temp mediump 2-component vector of float)
+0:6 Constant:
+0:6 2.000000
+0:6 2.000000
+0:7 Sequence
+0:7 move second child to first child (temp mediump 3-component vector of float)
+0:7 'h3' (temp mediump 3-component vector of float)
+0:7 Constant:
+0:7 3.000000
+0:7 3.000000
+0:7 3.000000
+0:8 Sequence
+0:8 move second child to first child (temp mediump 4-component vector of float)
+0:8 'h4' (temp mediump 4-component vector of float)
+0:8 Constant:
+0:8 4.000000
+0:8 4.000000
+0:8 4.000000
+0:8 4.000000
+0:10 Sequence
+0:10 move second child to first child (temp 4-component vector of float)
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
+0:10 Constant:
+0:10 0.000000
+0:10 0.000000
+0:10 0.000000
+0:10 0.000000
+0:10 Branch: Return
+0:? Linker Objects
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
+
+
+Linked fragment stage:
+
+
+Shader version: 450
+gl_FragCoord origin is upper left
+0:? Sequence
+0:3 Function Definition: main( (temp 4-component vector of float)
+0:3 Function Parameters:
+0:? Sequence
+0:4 Sequence
+0:4 move second child to first child (temp mediump float)
+0:4 'h0' (temp mediump float)
+0:4 Constant:
+0:4 0.000000
+0:5 Sequence
+0:5 move second child to first child (temp mediump 1-component vector of float)
+0:5 'h1' (temp mediump 1-component vector of float)
+0:5 Constant:
+0:5 1.000000
+0:6 Sequence
+0:6 move second child to first child (temp mediump 2-component vector of float)
+0:6 'h2' (temp mediump 2-component vector of float)
+0:6 Constant:
+0:6 2.000000
+0:6 2.000000
+0:7 Sequence
+0:7 move second child to first child (temp mediump 3-component vector of float)
+0:7 'h3' (temp mediump 3-component vector of float)
+0:7 Constant:
+0:7 3.000000
+0:7 3.000000
+0:7 3.000000
+0:8 Sequence
+0:8 move second child to first child (temp mediump 4-component vector of float)
+0:8 'h4' (temp mediump 4-component vector of float)
+0:8 Constant:
+0:8 4.000000
+0:8 4.000000
+0:8 4.000000
+0:8 4.000000
+0:10 Sequence
+0:10 move second child to first child (temp 4-component vector of float)
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
+0:10 Constant:
+0:10 0.000000
+0:10 0.000000
+0:10 0.000000
+0:10 0.000000
+0:10 Branch: Return
+0:? Linker Objects
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 31
+
+ Capability Shader
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Fragment 4 "main" 28
+ ExecutionMode 4 OriginUpperLeft
+ Name 4 "main"
+ Name 8 "h0"
+ Name 10 "h1"
+ Name 14 "h2"
+ Name 19 "h3"
+ Name 24 "h4"
+ Name 28 "@entryPointOutput"
+ Decorate 8(h0) RelaxedPrecision
+ Decorate 10(h1) RelaxedPrecision
+ Decorate 14(h2) RelaxedPrecision
+ Decorate 19(h3) RelaxedPrecision
+ Decorate 24(h4) RelaxedPrecision
+ Decorate 28(@entryPointOutput) Location 0
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeFloat 32
+ 7: TypePointer Function 6(float)
+ 9: 6(float) Constant 0
+ 11: 6(float) Constant 1065353216
+ 12: TypeVector 6(float) 2
+ 13: TypePointer Function 12(fvec2)
+ 15: 6(float) Constant 1073741824
+ 16: 12(fvec2) ConstantComposite 15 15
+ 17: TypeVector 6(float) 3
+ 18: TypePointer Function 17(fvec3)
+ 20: 6(float) Constant 1077936128
+ 21: 17(fvec3) ConstantComposite 20 20 20
+ 22: TypeVector 6(float) 4
+ 23: TypePointer Function 22(fvec4)
+ 25: 6(float) Constant 1082130432
+ 26: 22(fvec4) ConstantComposite 25 25 25 25
+ 27: TypePointer Output 22(fvec4)
+28(@entryPointOutput): 27(ptr) Variable Output
+ 29: 22(fvec4) ConstantComposite 9 9 9 9
+ 4(main): 2 Function None 3
+ 5: Label
+ 8(h0): 7(ptr) Variable Function
+ 10(h1): 7(ptr) Variable Function
+ 14(h2): 13(ptr) Variable Function
+ 19(h3): 18(ptr) Variable Function
+ 24(h4): 23(ptr) Variable Function
+ Store 8(h0) 9
+ Store 10(h1) 11
+ Store 14(h2) 16
+ Store 19(h3) 21
+ Store 24(h4) 26
+ Store 28(@entryPointOutput) 29
+ Return
+ FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.type.identifier.frag.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.type.identifier.frag.out
new file mode 100644
index 00000000000..73d8969c36a
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/hlsl.type.identifier.frag.out
@@ -0,0 +1,382 @@
+hlsl.type.identifier.frag
+Shader version: 450
+gl_FragCoord origin is upper left
+0:? Sequence
+0:6 Function Definition: fn(f1; (temp float)
+0:6 Function Parameters:
+0:6 'float' (in float)
+0:? Sequence
+0:6 Branch: Return with expression
+0:6 'float' (in float)
+0:9 Function Definition: main( (temp 4-component vector of float)
+0:9 Function Parameters:
+0:? Sequence
+0:10 Sequence
+0:10 move second child to first child (temp float)
+0:10 'float' (temp float)
+0:10 Constant:
+0:10 7.000000
+0:11 Sequence
+0:11 move second child to first child (temp 2-element array of bool)
+0:11 'bool' (temp 2-element array of bool)
+0:11 Construct bool (temp 2-element array of bool)
+0:11 Convert float to bool (temp bool)
+0:11 'float' (temp float)
+0:11 Convert float to bool (temp bool)
+0:11 'float' (temp float)
+0:12 Sequence
+0:12 move second child to first child (temp int)
+0:12 'int' (temp int)
+0:12 Convert bool to int (temp int)
+0:12 direct index (temp bool)
+0:12 'bool' (temp 2-element array of bool)
+0:12 Constant:
+0:12 1 (const int)
+0:13 Sequence
+0:13 move second child to first child (temp uint)
+0:13 'uint' (temp uint)
+0:13 Convert float to uint (temp uint)
+0:13 add (temp float)
+0:13 'float' (temp float)
+0:13 Convert int to float (temp float)
+0:13 'int' (temp int)
+0:14 Sequence
+0:14 move second child to first child (temp mediump float)
+0:14 'min16float' (temp mediump float)
+0:14 Convert uint to float (temp mediump float)
+0:14 'uint' (temp mediump uint)
+0:15 Sequence
+0:15 move second child to first child (temp mediump float)
+0:15 'min10float' (temp mediump float)
+0:15 'min16float' (temp mediump float)
+0:16 Sequence
+0:16 move second child to first child (temp mediump float)
+0:16 'half' (temp mediump float)
+0:16 Constant:
+0:16 0.500000
+0:? Sequence
+0:20 move second child to first child (temp float)
+0:20 float: direct index for structure (temp float)
+0:20 'float' (temp structure{temp float float})
+0:20 Constant:
+0:20 0 (const int)
+0:20 Constant:
+0:20 42.000000
+0:23 move second child to first child (temp bool)
+0:23 direct index (temp bool)
+0:23 'bool' (temp 2-element array of bool)
+0:23 Constant:
+0:23 0 (const int)
+0:23 direct index (temp bool)
+0:23 'bool' (temp 2-element array of bool)
+0:23 Constant:
+0:23 1 (const int)
+0:25 move second child to first child (temp mediump float)
+0:25 'float' (temp mediump float)
+0:25 add (temp mediump float)
+0:25 add (temp mediump float)
+0:25 add (temp mediump float)
+0:25 add (temp mediump float)
+0:25 add (temp mediump float)
+0:25 add (temp mediump float)
+0:25 'float' (temp mediump float)
+0:25 Convert int to float (temp mediump float)
+0:25 'int' (temp mediump int)
+0:25 Convert uint to float (temp mediump float)
+0:25 'uint' (temp mediump uint)
+0:25 'min16float' (temp mediump float)
+0:25 'min10float' (temp mediump float)
+0:25 Test condition and select (temp mediump float)
+0:25 Condition
+0:25 direct index (temp bool)
+0:25 'bool' (temp 2-element array of bool)
+0:25 Constant:
+0:25 0 (const int)
+0:25 true case
+0:25 Convert int to float (temp mediump float)
+0:25 'int' (temp mediump int)
+0:25 false case
+0:25 'float' (temp mediump float)
+0:25 Function Call: fn(f1; (temp mediump float)
+0:25 'float' (temp mediump float)
+0:27 Sequence
+0:27 move second child to first child (temp 4-component vector of float)
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
+0:27 Construct vec4 (temp 4-component vector of float)
+0:27 'float' (temp float)
+0:27 Branch: Return
+0:? Linker Objects
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
+
+
+Linked fragment stage:
+
+
+Shader version: 450
+gl_FragCoord origin is upper left
+0:? Sequence
+0:6 Function Definition: fn(f1; (temp float)
+0:6 Function Parameters:
+0:6 'float' (in float)
+0:? Sequence
+0:6 Branch: Return with expression
+0:6 'float' (in float)
+0:9 Function Definition: main( (temp 4-component vector of float)
+0:9 Function Parameters:
+0:? Sequence
+0:10 Sequence
+0:10 move second child to first child (temp float)
+0:10 'float' (temp float)
+0:10 Constant:
+0:10 7.000000
+0:11 Sequence
+0:11 move second child to first child (temp 2-element array of bool)
+0:11 'bool' (temp 2-element array of bool)
+0:11 Construct bool (temp 2-element array of bool)
+0:11 Convert float to bool (temp bool)
+0:11 'float' (temp float)
+0:11 Convert float to bool (temp bool)
+0:11 'float' (temp float)
+0:12 Sequence
+0:12 move second child to first child (temp int)
+0:12 'int' (temp int)
+0:12 Convert bool to int (temp int)
+0:12 direct index (temp bool)
+0:12 'bool' (temp 2-element array of bool)
+0:12 Constant:
+0:12 1 (const int)
+0:13 Sequence
+0:13 move second child to first child (temp uint)
+0:13 'uint' (temp uint)
+0:13 Convert float to uint (temp uint)
+0:13 add (temp float)
+0:13 'float' (temp float)
+0:13 Convert int to float (temp float)
+0:13 'int' (temp int)
+0:14 Sequence
+0:14 move second child to first child (temp mediump float)
+0:14 'min16float' (temp mediump float)
+0:14 Convert uint to float (temp mediump float)
+0:14 'uint' (temp mediump uint)
+0:15 Sequence
+0:15 move second child to first child (temp mediump float)
+0:15 'min10float' (temp mediump float)
+0:15 'min16float' (temp mediump float)
+0:16 Sequence
+0:16 move second child to first child (temp mediump float)
+0:16 'half' (temp mediump float)
+0:16 Constant:
+0:16 0.500000
+0:? Sequence
+0:20 move second child to first child (temp float)
+0:20 float: direct index for structure (temp float)
+0:20 'float' (temp structure{temp float float})
+0:20 Constant:
+0:20 0 (const int)
+0:20 Constant:
+0:20 42.000000
+0:23 move second child to first child (temp bool)
+0:23 direct index (temp bool)
+0:23 'bool' (temp 2-element array of bool)
+0:23 Constant:
+0:23 0 (const int)
+0:23 direct index (temp bool)
+0:23 'bool' (temp 2-element array of bool)
+0:23 Constant:
+0:23 1 (const int)
+0:25 move second child to first child (temp mediump float)
+0:25 'float' (temp mediump float)
+0:25 add (temp mediump float)
+0:25 add (temp mediump float)
+0:25 add (temp mediump float)
+0:25 add (temp mediump float)
+0:25 add (temp mediump float)
+0:25 add (temp mediump float)
+0:25 'float' (temp mediump float)
+0:25 Convert int to float (temp mediump float)
+0:25 'int' (temp mediump int)
+0:25 Convert uint to float (temp mediump float)
+0:25 'uint' (temp mediump uint)
+0:25 'min16float' (temp mediump float)
+0:25 'min10float' (temp mediump float)
+0:25 Test condition and select (temp mediump float)
+0:25 Condition
+0:25 direct index (temp bool)
+0:25 'bool' (temp 2-element array of bool)
+0:25 Constant:
+0:25 0 (const int)
+0:25 true case
+0:25 Convert int to float (temp mediump float)
+0:25 'int' (temp mediump int)
+0:25 false case
+0:25 'float' (temp mediump float)
+0:25 Function Call: fn(f1; (temp mediump float)
+0:25 'float' (temp mediump float)
+0:27 Sequence
+0:27 move second child to first child (temp 4-component vector of float)
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
+0:27 Construct vec4 (temp 4-component vector of float)
+0:27 'float' (temp float)
+0:27 Branch: Return
+0:? Linker Objects
+0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
+
+// Module Version 10000
+// Generated by (magic number): 80001
+// Id's are bound by 92
+
+ Capability Shader
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Fragment 4 "main" 88
+ ExecutionMode 4 OriginUpperLeft
+ Name 4 "main"
+ Name 10 "fn(f1;"
+ Name 9 "float"
+ Name 15 "float"
+ Name 22 "bool"
+ Name 31 "int"
+ Name 39 "uint"
+ Name 45 "min16float"
+ Name 48 "min10float"
+ Name 50 "half"
+ Name 52 "foo_t"
+ MemberName 52(foo_t) 0 "float"
+ Name 54 "float"
+ Name 82 "param"
+ Name 88 "@entryPointOutput"
+ Decorate 45(min16float) RelaxedPrecision
+ Decorate 46 RelaxedPrecision
+ Decorate 47 RelaxedPrecision
+ Decorate 48(min10float) RelaxedPrecision
+ Decorate 49 RelaxedPrecision
+ Decorate 50(half) RelaxedPrecision
+ Decorate 60 RelaxedPrecision
+ Decorate 61 RelaxedPrecision
+ Decorate 62 RelaxedPrecision
+ Decorate 63 RelaxedPrecision
+ Decorate 64 RelaxedPrecision
+ Decorate 65 RelaxedPrecision
+ Decorate 66 RelaxedPrecision
+ Decorate 67 RelaxedPrecision
+ Decorate 68 RelaxedPrecision
+ Decorate 69 RelaxedPrecision
+ Decorate 70 RelaxedPrecision
+ Decorate 76 RelaxedPrecision
+ Decorate 77 RelaxedPrecision
+ Decorate 79 RelaxedPrecision
+ Decorate 80 RelaxedPrecision
+ Decorate 81 RelaxedPrecision
+ Decorate 83 RelaxedPrecision
+ Decorate 84 RelaxedPrecision
+ Decorate 85 RelaxedPrecision
+ Decorate 88(@entryPointOutput) Location 0
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeFloat 32
+ 7: TypePointer Function 6(float)
+ 8: TypeFunction 6(float) 7(ptr)
+ 16: 6(float) Constant 1088421888
+ 17: TypeBool
+ 18: TypeInt 32 0
+ 19: 18(int) Constant 2
+ 20: TypeArray 17(bool) 19
+ 21: TypePointer Function 20
+ 24: 6(float) Constant 0
+ 29: TypeInt 32 1
+ 30: TypePointer Function 29(int)
+ 32: 29(int) Constant 1
+ 33: TypePointer Function 17(bool)
+ 36: 29(int) Constant 0
+ 38: TypePointer Function 18(int)
+ 51: 6(float) Constant 1056964608
+ 52(foo_t): TypeStruct 6(float)
+ 53: TypePointer Function 52(foo_t)
+ 55: 6(float) Constant 1109917696
+ 86: TypeVector 6(float) 4
+ 87: TypePointer Output 86(fvec4)
+88(@entryPointOutput): 87(ptr) Variable Output
+ 4(main): 2 Function None 3
+ 5: Label
+ 15(float): 7(ptr) Variable Function
+ 22(bool): 21(ptr) Variable Function
+ 31(int): 30(ptr) Variable Function
+ 39(uint): 38(ptr) Variable Function
+ 45(min16float): 7(ptr) Variable Function
+ 48(min10float): 7(ptr) Variable Function
+ 50(half): 7(ptr) Variable Function
+ 54(float): 53(ptr) Variable Function
+ 71: 7(ptr) Variable Function
+ 82(param): 7(ptr) Variable Function
+ Store 15(float) 16
+ 23: 6(float) Load 15(float)
+ 25: 17(bool) FOrdNotEqual 23 24
+ 26: 6(float) Load 15(float)
+ 27: 17(bool) FOrdNotEqual 26 24
+ 28: 20 CompositeConstruct 25 27
+ Store 22(bool) 28
+ 34: 33(ptr) AccessChain 22(bool) 32
+ 35: 17(bool) Load 34
+ 37: 29(int) Select 35 32 36
+ Store 31(int) 37
+ 40: 6(float) Load 15(float)
+ 41: 29(int) Load 31(int)
+ 42: 6(float) ConvertSToF 41
+ 43: 6(float) FAdd 40 42
+ 44: 18(int) ConvertFToU 43
+ Store 39(uint) 44
+ 46: 18(int) Load 39(uint)
+ 47: 6(float) ConvertUToF 46
+ Store 45(min16float) 47
+ 49: 6(float) Load 45(min16float)
+ Store 48(min10float) 49
+ Store 50(half) 51
+ 56: 7(ptr) AccessChain 54(float) 36
+ Store 56 55
+ 57: 33(ptr) AccessChain 22(bool) 32
+ 58: 17(bool) Load 57
+ 59: 33(ptr) AccessChain 22(bool) 36
+ Store 59 58
+ 60: 6(float) Load 15(float)
+ 61: 29(int) Load 31(int)
+ 62: 6(float) ConvertSToF 61
+ 63: 6(float) FAdd 60 62
+ 64: 18(int) Load 39(uint)
+ 65: 6(float) ConvertUToF 64
+ 66: 6(float) FAdd 63 65
+ 67: 6(float) Load 45(min16float)
+ 68: 6(float) FAdd 66 67
+ 69: 6(float) Load 48(min10float)
+ 70: 6(float) FAdd 68 69
+ 72: 33(ptr) AccessChain 22(bool) 36
+ 73: 17(bool) Load 72
+ SelectionMerge 75 None
+ BranchConditional 73 74 78
+ 74: Label
+ 76: 29(int) Load 31(int)
+ 77: 6(float) ConvertSToF 76
+ Store 71 77
+ Branch 75
+ 78: Label
+ 79: 6(float) Load 15(float)
+ Store 71 79
+ Branch 75
+ 75: Label
+ 80: 6(float) Load 71
+ 81: 6(float) FAdd 70 80
+ 83: 6(float) Load 15(float)
+ Store 82(param) 83
+ 84: 6(float) FunctionCall 10(fn(f1;) 82(param)
+ 85: 6(float) FAdd 81 84
+ Store 15(float) 85
+ 89: 6(float) Load 15(float)
+ 90: 86(fvec4) CompositeConstruct 89 89 89 89
+ Store 88(@entryPointOutput) 90
+ Return
+ FunctionEnd
+ 10(fn(f1;): 6(float) Function None 8
+ 9(float): 7(ptr) FunctionParameter
+ 11: Label
+ 12: 6(float) Load 9(float)
+ ReturnValue 12
+ FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/link1.vk.frag.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/link1.vk.frag.out
new file mode 100644
index 00000000000..2688e634ef2
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/link1.vk.frag.out
@@ -0,0 +1,60 @@
+link1.vk.frag
+Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
+
+Shader version: 450
+gl_FragCoord origin is upper left
+0:? Sequence
+0:7 Function Definition: main( (global void)
+0:7 Function Parameters:
+0:9 Sequence
+0:9 move second child to first child (temp highp 4-component vector of float)
+0:9 'color' (out highp 4-component vector of float)
+0:9 Function Call: getColor( (global highp 4-component vector of float)
+0:? Linker Objects
+0:? 'color' (out highp 4-component vector of float)
+
+link2.vk.frag
+Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
+
+Shader version: 450
+gl_FragCoord origin is upper left
+0:? Sequence
+0:5 Function Definition: getColor( (global highp 4-component vector of float)
+0:5 Function Parameters:
+0:7 Sequence
+0:7 Branch: Return with expression
+0:7 texture (global highp 4-component vector of float)
+0:7 's2D' (uniform highp sampler2D)
+0:7 Constant:
+0:7 0.500000
+0:7 0.500000
+0:? Linker Objects
+0:? 's2D' (uniform highp sampler2D)
+
+
+Linked fragment stage:
+
+
+Shader version: 450
+gl_FragCoord origin is upper left
+0:? Sequence
+0:7 Function Definition: main( (global void)
+0:7 Function Parameters:
+0:9 Sequence
+0:9 move second child to first child (temp highp 4-component vector of float)
+0:9 'color' (out highp 4-component vector of float)
+0:9 Function Call: getColor( (global highp 4-component vector of float)
+0:5 Function Definition: getColor( (global highp 4-component vector of float)
+0:5 Function Parameters:
+0:7 Sequence
+0:7 Branch: Return with expression
+0:7 texture (global highp 4-component vector of float)
+0:7 's2D' (uniform highp sampler2D)
+0:7 Constant:
+0:7 0.500000
+0:7 0.500000
+0:? Linker Objects
+0:? 'color' (out highp 4-component vector of float)
+0:? 's2D' (uniform highp sampler2D)
+
+SPIR-V is not generated for failed compile or link
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/preprocessor.include.disabled.vert.err b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/preprocessor.include.disabled.vert.err
index 7d1f0a00588..14192046a89 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/preprocessor.include.disabled.vert.err
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/preprocessor.include.disabled.vert.err
@@ -1,13 +1,13 @@
ERROR: 0:8000: '#include' : required extension not requested: GL_GOOGLE_include_directive
-ERROR: 0:8000: '#include' : must be followed by a file designation
+ERROR: 0:8000: '#include' : must be followed by a header name
ERROR: 0:8001: '#include' : required extension not requested: GL_GOOGLE_include_directive
-ERROR: 0:8001: '#include' : must be followed by a file designation
+ERROR: 0:8001: '#include' : must be followed by a header name
ERROR: 0:8002: '#include' : required extension not requested: GL_GOOGLE_include_directive
-ERROR: 0:8002: '#include' : unexpected include directive
+ERROR: 0:8002: '#include' : Could not process include directive for header name: foo
ERROR: 0:8003: '#include' : required extension not requested: GL_GOOGLE_include_directive
-ERROR: 0:8003: '#include' : extra content after file designation
+ERROR: 0:8003: '#include' : extra content after header name: foo
ERROR: 0:8004: '#include' : required extension not requested: GL_GOOGLE_include_directive
-ERROR: 0:8004: '#include' : unexpected include directive
+ERROR: 0:8004: '#include' : expected newline after header name: no-eol
ERROR: 10 compilation errors. No code generated.
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/preprocessor.include.enabled.vert.err b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/preprocessor.include.enabled.vert.err
index be8c5cf3a10..252e661f09e 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/preprocessor.include.enabled.vert.err
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/preprocessor.include.enabled.vert.err
@@ -1,8 +1,20 @@
-ERROR: 0:8000: '#include' : must be followed by a file designation
-ERROR: 0:8001: '#include' : must be followed by a file designation
-ERROR: 0:8002: '#include' : unexpected include directive
-ERROR: 0:8003: '#include' : extra content after file designation
-ERROR: 0:8004: '#include' : unexpected include directive
-ERROR: 5 compilation errors. No code generated.
+ERROR: 0:8000: '#include' : must be followed by a header name
+ERROR: 0:8001: '#include' : must be followed by a header name
+ERROR: 0:8002: '#include' : Could not process include directive for header name: foo.oeu
+ERROR: 0:8003: '#include' : Could not process include directive for header name: foo.oeu/ao eu/ao.h
+ERROR: 0:8004: '#include' : Could not process include directive for header name: foo<oeu
+ERROR: 0:8005: '#include' : Could not process include directive for header name: foo.oe>
+ERROR: 0:8006: '#include' : Could not process include directive for header name: foo.oe
+ERROR: 0:8007: '#include' : Could not process include directive for header name: foo"bar"
+ERROR: 0:8008: '#include' : Could not process include directive for header name: foo\bar
+ERROR: 0:8009: '#include' : Could not process include directive for header name: foo.oe>
+ERROR: 0:8010: '#include' : Could not process include directive for header name: foo
+ERROR: 0:8011: '#include' : extra content after header name: foo2.h
+ERROR: 0:8012: '#include' : extra content after header name: foo.h
+ERROR: 0:8014: '#include' : Could not process include directive for header name: ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789
+ERROR: 0:8016: '' : header name too long
+ERROR: 0:8016: '#include' : Could not process include directive for header name: ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789
+ERROR: 0:8017: '#include' : expected newline after header name: no-eol
+ERROR: 17 compilation errors. No code generated.
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/specExamples.frag.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/specExamples.frag.out
index a66144a7c55..f660e66f7cf 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/specExamples.frag.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/specExamples.frag.out
@@ -22,14 +22,14 @@ ERROR: 0:172: '[]' : scalar integer expression required
ERROR: 0:175: 'x' : undeclared identifier
ERROR: 0:175: '[]' : scalar integer expression required
ERROR: 0:175: 'b' : left of '[' is not of type array, matrix, or vector
-ERROR: 0:175: 'a' : vector field selection out of range
+ERROR: 0:175: 'a' : vector swizzle selection out of range
ERROR: 0:175: 'length' : does not operate on this type: const float
ERROR: 0:175: '' : function call, method, or subroutine call expected
ERROR: 0:175: '' : no matching overloaded function found
ERROR: 0:178: '[]' : scalar integer expression required
ERROR: 0:178: 's' : undeclared identifier
ERROR: 0:178: 's' : left of '[' is not of type array, matrix, or vector
-ERROR: 0:178: 'a' : vector field selection out of range
+ERROR: 0:178: 'a' : vector swizzle selection out of range
ERROR: 0:178: 'length' : does not operate on this type: const float
ERROR: 0:178: '' : function call, method, or subroutine call expected
ERROR: 0:178: '' : no matching overloaded function found
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.float16.frag.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.float16.frag.out
index 5499b7e8e85..78156e40b1d 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.float16.frag.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.float16.frag.out
@@ -105,6 +105,9 @@ Warning, version 450 is not yet complete; most version-specific features are pre
MemberName 523(B2) 6 "u"
MemberName 523(B2) 7 "v"
Name 525 ""
+ Name 526 "sf16"
+ Name 527 "sf"
+ Name 528 "sd"
Decorate 512 ArrayStride 16
Decorate 513 ArrayStride 32
MemberDecorate 514(S) 0 Offset 0
@@ -145,9 +148,9 @@ Warning, version 450 is not yet complete; most version-specific features are pre
MemberDecorate 523(B2) 7 Offset 72
Decorate 523(B2) BufferBlock
Decorate 525 DescriptorSet 0
- Decorate 526 SpecId 100
- Decorate 527 SpecId 101
- Decorate 528 SpecId 102
+ Decorate 526(sf16) SpecId 100
+ Decorate 527(sf) SpecId 101
+ Decorate 528(sd) SpecId 102
2: TypeVoid
3: TypeFunction 2
28: TypeFloat 16
@@ -223,14 +226,14 @@ Warning, version 450 is not yet complete; most version-specific features are pre
523(B2): TypeStruct 28(float) 29(fvec2) 151(fvec3) 519 406 520 521(S) 522
524: TypePointer Uniform 523(B2)
525: 524(ptr) Variable Uniform
- 526: 28(float) SpecConstant 12288
- 527: 164(float) SpecConstant 1048576000
- 528: 172(float) SpecConstant 0 1071644672
- 529: 164(float) SpecConstantOp 115 526
- 530: 164(float) SpecConstantOp 115 526
+ 526(sf16): 28(float) SpecConstant 12288
+ 527(sf): 164(float) SpecConstant 1048576000
+ 528(sd): 172(float) SpecConstant 0 1071644672
+ 529: 164(float) SpecConstantOp 115 526(sf16)
+ 530: 164(float) SpecConstantOp 115 526(sf16)
531: 172(float) SpecConstantOp 115 530
- 532: 28(float) SpecConstantOp 115 527
- 533: 28(float) SpecConstantOp 115 528
+ 532: 28(float) SpecConstantOp 115 527(sf)
+ 533: 28(float) SpecConstantOp 115 528(sd)
4(main): 2 Function None 3
5: Label
Return
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.int64.frag.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.int64.frag.out
index cb5433ec6a6..df35fea780e 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.int64.frag.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.int64.frag.out
@@ -51,6 +51,11 @@ Warning, version 450 is not yet complete; most version-specific features are pre
MemberName 454(Block) 0 "i64v"
MemberName 454(Block) 1 "u64"
Name 456 "block"
+ Name 457 "si64"
+ Name 458 "su64"
+ Name 459 "si"
+ Name 460 "su"
+ Name 461 "sb"
MemberDecorate 28(Uniforms) 0 Offset 0
Decorate 28(Uniforms) Block
Decorate 30 DescriptorSet 0
@@ -60,11 +65,11 @@ Warning, version 450 is not yet complete; most version-specific features are pre
Decorate 454(Block) Block
Decorate 456(block) DescriptorSet 0
Decorate 456(block) Binding 1
- Decorate 457 SpecId 100
- Decorate 458 SpecId 101
- Decorate 459 SpecId 102
- Decorate 460 SpecId 103
- Decorate 461 SpecId 104
+ Decorate 457(si64) SpecId 100
+ Decorate 458(su64) SpecId 101
+ Decorate 459(si) SpecId 102
+ Decorate 460(su) SpecId 103
+ Decorate 461(sb) SpecId 104
2: TypeVoid
3: TypeFunction 2
14: TypeInt 64 0
@@ -148,28 +153,28 @@ Warning, version 450 is not yet complete; most version-specific features are pre
454(Block): TypeStruct 136(ivec3) 14(int)
455: TypePointer Uniform 454(Block)
456(block): 455(ptr) Variable Uniform
- 457: 18(int) SpecConstant 4294967286 4294967295
- 458: 14(int) SpecConstant 20 0
- 459: 31(int) SpecConstant 4294967291
- 460: 21(int) SpecConstant 4
- 461: 55(bool) SpecConstantTrue
- 462: 55(bool) SpecConstantOp 171 457 69
- 463: 55(bool) SpecConstantOp 171 458 69
- 464: 18(int) SpecConstantOp 169 461 61 60
- 465: 14(int) SpecConstantOp 169 461 70 69
- 466: 31(int) SpecConstantOp 114 457
- 467: 18(int) SpecConstantOp 114 459
- 468: 21(int) SpecConstantOp 113 458
- 469: 14(int) SpecConstantOp 113 460
- 470: 18(int) SpecConstantOp 128 458 69
- 471: 14(int) SpecConstantOp 128 457 69
- 472: 21(int) SpecConstantOp 113 458
+ 457(si64): 18(int) SpecConstant 4294967286 4294967295
+ 458(su64): 14(int) SpecConstant 20 0
+ 459(si): 31(int) SpecConstant 4294967291
+ 460(su): 21(int) SpecConstant 4
+ 461(sb): 55(bool) SpecConstantTrue
+ 462: 55(bool) SpecConstantOp 171 457(si64) 69
+ 463: 55(bool) SpecConstantOp 171 458(su64) 69
+ 464: 18(int) SpecConstantOp 169 461(sb) 61 60
+ 465: 14(int) SpecConstantOp 169 461(sb) 70 69
+ 466: 31(int) SpecConstantOp 114 457(si64)
+ 467: 18(int) SpecConstantOp 114 459(si)
+ 468: 21(int) SpecConstantOp 113 458(su64)
+ 469: 14(int) SpecConstantOp 113 460(su)
+ 470: 18(int) SpecConstantOp 128 458(su64) 69
+ 471: 14(int) SpecConstantOp 128 457(si64) 69
+ 472: 21(int) SpecConstantOp 113 458(su64)
473: 31(int) SpecConstantOp 128 472 219
- 474: 18(int) SpecConstantOp 114 459
+ 474: 18(int) SpecConstantOp 114 459(si)
475: 14(int) SpecConstantOp 128 474 69
- 476: 31(int) SpecConstantOp 114 457
+ 476: 31(int) SpecConstantOp 114 457(si64)
477: 21(int) SpecConstantOp 128 476 219
- 478: 14(int) SpecConstantOp 113 460
+ 478: 14(int) SpecConstantOp 113 460(su)
479: 18(int) SpecConstantOp 128 478 69
4(main): 2 Function None 3
5: Label
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.shaderBallotAMD.comp.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.shaderBallotAMD.comp.out
new file mode 100644
index 00000000000..bb7f8c1627f
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.shaderBallotAMD.comp.out
@@ -0,0 +1,1217 @@
+spv.shaderBallotAMD.comp
+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 1048
+
+ Capability Shader
+ Capability Float16
+ Capability Float64
+ Capability Int64
+ Capability Groups
+ Extension "SPV_AMD_gpu_shader_half_float"
+ Extension "SPV_AMD_shader_ballot"
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint GLCompute 4 "main"
+ ExecutionMode 4 LocalSize 8 8 1
+ Source GLSL 450
+ SourceExtension "GL_AMD_gpu_shader_half_float"
+ SourceExtension "GL_AMD_shader_ballot"
+ SourceExtension "GL_ARB_gpu_shader_int64"
+ Name 4 "main"
+ Name 18 "Buffers"
+ MemberName 18(Buffers) 0 "i"
+ MemberName 18(Buffers) 1 "uv"
+ MemberName 18(Buffers) 2 "fv"
+ MemberName 18(Buffers) 3 "dv"
+ MemberName 18(Buffers) 4 "i64"
+ MemberName 18(Buffers) 5 "u64v"
+ MemberName 18(Buffers) 6 "f16v"
+ Name 20 ""
+ MemberDecorate 18(Buffers) 0 Offset 0
+ MemberDecorate 18(Buffers) 1 Offset 8
+ MemberDecorate 18(Buffers) 2 Offset 16
+ MemberDecorate 18(Buffers) 3 Offset 32
+ MemberDecorate 18(Buffers) 4 Offset 64
+ MemberDecorate 18(Buffers) 5 Offset 80
+ MemberDecorate 18(Buffers) 6 Offset 96
+ Decorate 18(Buffers) BufferBlock
+ Decorate 20 DescriptorSet 0
+ Decorate 20 Binding 0
+ Decorate 1047 BuiltIn WorkgroupSize
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeInt 32 1
+ 7: TypeInt 32 0
+ 8: TypeVector 7(int) 2
+ 9: TypeFloat 32
+ 10: TypeVector 9(float) 3
+ 11: TypeFloat 64
+ 12: TypeVector 11(float) 4
+ 13: TypeInt 64 1
+ 14: TypeInt 64 0
+ 15: TypeVector 14(int) 2
+ 16: TypeFloat 16
+ 17: TypeVector 16(float) 3
+ 18(Buffers): TypeStruct 6(int) 8(ivec2) 10(fvec3) 12(fvec4) 13(int) 15(ivec2) 17(fvec3)
+ 19: TypePointer Uniform 18(Buffers)
+ 20: 19(ptr) Variable Uniform
+ 21: 6(int) Constant 0
+ 22: TypePointer Uniform 6(int)
+ 25: 7(int) Constant 3
+ 28: 6(int) Constant 1
+ 29: TypePointer Uniform 8(ivec2)
+ 38: 6(int) Constant 2
+ 39: TypePointer Uniform 10(fvec3)
+ 50: 6(int) Constant 3
+ 51: TypePointer Uniform 12(fvec4)
+ 64: 6(int) Constant 4
+ 65: TypePointer Uniform 13(int)
+ 70: 6(int) Constant 5
+ 71: TypePointer Uniform 15(ivec2)
+ 80: 6(int) Constant 6
+ 81: TypePointer Uniform 17(fvec3)
+ 1044: TypeVector 7(int) 3
+ 1045: 7(int) Constant 8
+ 1046: 7(int) Constant 1
+ 1047: 1044(ivec3) ConstantComposite 1045 1045 1046
+ 4(main): 2 Function None 3
+ 5: Label
+ 23: 22(ptr) AccessChain 20 21
+ 24: 6(int) Load 23
+ 26: 6(int) GroupSMin 25 Reduce 24
+ 27: 22(ptr) AccessChain 20 21
+ Store 27 26
+ 30: 29(ptr) AccessChain 20 28
+ 31: 8(ivec2) Load 30
+ 32: 7(int) CompositeExtract 31 0
+ 33: 7(int) GroupUMin 25 Reduce 32
+ 34: 7(int) CompositeExtract 31 1
+ 35: 7(int) GroupUMin 25 Reduce 34
+ 36: 8(ivec2) CompositeConstruct 33 35
+ 37: 29(ptr) AccessChain 20 28
+ Store 37 36
+ 40: 39(ptr) AccessChain 20 38
+ 41: 10(fvec3) Load 40
+ 42: 9(float) CompositeExtract 41 0
+ 43: 9(float) GroupFMin 25 Reduce 42
+ 44: 9(float) CompositeExtract 41 1
+ 45: 9(float) GroupFMin 25 Reduce 44
+ 46: 9(float) CompositeExtract 41 2
+ 47: 9(float) GroupFMin 25 Reduce 46
+ 48: 10(fvec3) CompositeConstruct 43 45 47
+ 49: 39(ptr) AccessChain 20 38
+ Store 49 48
+ 52: 51(ptr) AccessChain 20 50
+ 53: 12(fvec4) Load 52
+ 54: 11(float) CompositeExtract 53 0
+ 55: 11(float) GroupFMin 25 Reduce 54
+ 56: 11(float) CompositeExtract 53 1
+ 57: 11(float) GroupFMin 25 Reduce 56
+ 58: 11(float) CompositeExtract 53 2
+ 59: 11(float) GroupFMin 25 Reduce 58
+ 60: 11(float) CompositeExtract 53 3
+ 61: 11(float) GroupFMin 25 Reduce 60
+ 62: 12(fvec4) CompositeConstruct 55 57 59 61
+ 63: 51(ptr) AccessChain 20 50
+ Store 63 62
+ 66: 65(ptr) AccessChain 20 64
+ 67: 13(int) Load 66
+ 68: 13(int) GroupSMin 25 Reduce 67
+ 69: 65(ptr) AccessChain 20 64
+ Store 69 68
+ 72: 71(ptr) AccessChain 20 70
+ 73: 15(ivec2) Load 72
+ 74: 14(int) CompositeExtract 73 0
+ 75: 14(int) GroupUMin 25 Reduce 74
+ 76: 14(int) CompositeExtract 73 1
+ 77: 14(int) GroupUMin 25 Reduce 76
+ 78: 15(ivec2) CompositeConstruct 75 77
+ 79: 71(ptr) AccessChain 20 70
+ Store 79 78
+ 82: 81(ptr) AccessChain 20 80
+ 83: 17(fvec3) Load 82
+ 84: 16(float) CompositeExtract 83 0
+ 85: 16(float) GroupFMin 25 Reduce 84
+ 86: 16(float) CompositeExtract 83 1
+ 87: 16(float) GroupFMin 25 Reduce 86
+ 88: 16(float) CompositeExtract 83 2
+ 89: 16(float) GroupFMin 25 Reduce 88
+ 90: 17(fvec3) CompositeConstruct 85 87 89
+ 91: 81(ptr) AccessChain 20 80
+ Store 91 90
+ 92: 22(ptr) AccessChain 20 21
+ 93: 6(int) Load 92
+ 94: 6(int) GroupSMax 25 Reduce 93
+ 95: 22(ptr) AccessChain 20 21
+ Store 95 94
+ 96: 29(ptr) AccessChain 20 28
+ 97: 8(ivec2) Load 96
+ 98: 7(int) CompositeExtract 97 0
+ 99: 7(int) GroupUMax 25 Reduce 98
+ 100: 7(int) CompositeExtract 97 1
+ 101: 7(int) GroupUMax 25 Reduce 100
+ 102: 8(ivec2) CompositeConstruct 99 101
+ 103: 29(ptr) AccessChain 20 28
+ Store 103 102
+ 104: 39(ptr) AccessChain 20 38
+ 105: 10(fvec3) Load 104
+ 106: 9(float) CompositeExtract 105 0
+ 107: 9(float) GroupFMax 25 Reduce 106
+ 108: 9(float) CompositeExtract 105 1
+ 109: 9(float) GroupFMax 25 Reduce 108
+ 110: 9(float) CompositeExtract 105 2
+ 111: 9(float) GroupFMax 25 Reduce 110
+ 112: 10(fvec3) CompositeConstruct 107 109 111
+ 113: 39(ptr) AccessChain 20 38
+ Store 113 112
+ 114: 51(ptr) AccessChain 20 50
+ 115: 12(fvec4) Load 114
+ 116: 11(float) CompositeExtract 115 0
+ 117: 11(float) GroupFMax 25 Reduce 116
+ 118: 11(float) CompositeExtract 115 1
+ 119: 11(float) GroupFMax 25 Reduce 118
+ 120: 11(float) CompositeExtract 115 2
+ 121: 11(float) GroupFMax 25 Reduce 120
+ 122: 11(float) CompositeExtract 115 3
+ 123: 11(float) GroupFMax 25 Reduce 122
+ 124: 12(fvec4) CompositeConstruct 117 119 121 123
+ 125: 51(ptr) AccessChain 20 50
+ Store 125 124
+ 126: 65(ptr) AccessChain 20 64
+ 127: 13(int) Load 126
+ 128: 13(int) GroupSMax 25 Reduce 127
+ 129: 65(ptr) AccessChain 20 64
+ Store 129 128
+ 130: 71(ptr) AccessChain 20 70
+ 131: 15(ivec2) Load 130
+ 132: 14(int) CompositeExtract 131 0
+ 133: 14(int) GroupUMax 25 Reduce 132
+ 134: 14(int) CompositeExtract 131 1
+ 135: 14(int) GroupUMax 25 Reduce 134
+ 136: 15(ivec2) CompositeConstruct 133 135
+ 137: 71(ptr) AccessChain 20 70
+ Store 137 136
+ 138: 81(ptr) AccessChain 20 80
+ 139: 17(fvec3) Load 138
+ 140: 16(float) CompositeExtract 139 0
+ 141: 16(float) GroupFMax 25 Reduce 140
+ 142: 16(float) CompositeExtract 139 1
+ 143: 16(float) GroupFMax 25 Reduce 142
+ 144: 16(float) CompositeExtract 139 2
+ 145: 16(float) GroupFMax 25 Reduce 144
+ 146: 17(fvec3) CompositeConstruct 141 143 145
+ 147: 81(ptr) AccessChain 20 80
+ Store 147 146
+ 148: 22(ptr) AccessChain 20 21
+ 149: 6(int) Load 148
+ 150: 6(int) GroupIAdd 25 Reduce 149
+ 151: 22(ptr) AccessChain 20 21
+ Store 151 150
+ 152: 29(ptr) AccessChain 20 28
+ 153: 8(ivec2) Load 152
+ 154: 7(int) CompositeExtract 153 0
+ 155: 7(int) GroupIAdd 25 Reduce 154
+ 156: 7(int) CompositeExtract 153 1
+ 157: 7(int) GroupIAdd 25 Reduce 156
+ 158: 8(ivec2) CompositeConstruct 155 157
+ 159: 29(ptr) AccessChain 20 28
+ Store 159 158
+ 160: 39(ptr) AccessChain 20 38
+ 161: 10(fvec3) Load 160
+ 162: 9(float) CompositeExtract 161 0
+ 163: 9(float) GroupFAdd 25 Reduce 162
+ 164: 9(float) CompositeExtract 161 1
+ 165: 9(float) GroupFAdd 25 Reduce 164
+ 166: 9(float) CompositeExtract 161 2
+ 167: 9(float) GroupFAdd 25 Reduce 166
+ 168: 10(fvec3) CompositeConstruct 163 165 167
+ 169: 39(ptr) AccessChain 20 38
+ Store 169 168
+ 170: 51(ptr) AccessChain 20 50
+ 171: 12(fvec4) Load 170
+ 172: 11(float) CompositeExtract 171 0
+ 173: 11(float) GroupFAdd 25 Reduce 172
+ 174: 11(float) CompositeExtract 171 1
+ 175: 11(float) GroupFAdd 25 Reduce 174
+ 176: 11(float) CompositeExtract 171 2
+ 177: 11(float) GroupFAdd 25 Reduce 176
+ 178: 11(float) CompositeExtract 171 3
+ 179: 11(float) GroupFAdd 25 Reduce 178
+ 180: 12(fvec4) CompositeConstruct 173 175 177 179
+ 181: 51(ptr) AccessChain 20 50
+ Store 181 180
+ 182: 65(ptr) AccessChain 20 64
+ 183: 13(int) Load 182
+ 184: 13(int) GroupIAdd 25 Reduce 183
+ 185: 65(ptr) AccessChain 20 64
+ Store 185 184
+ 186: 71(ptr) AccessChain 20 70
+ 187: 15(ivec2) Load 186
+ 188: 14(int) CompositeExtract 187 0
+ 189: 14(int) GroupIAdd 25 Reduce 188
+ 190: 14(int) CompositeExtract 187 1
+ 191: 14(int) GroupIAdd 25 Reduce 190
+ 192: 15(ivec2) CompositeConstruct 189 191
+ 193: 71(ptr) AccessChain 20 70
+ Store 193 192
+ 194: 81(ptr) AccessChain 20 80
+ 195: 17(fvec3) Load 194
+ 196: 16(float) CompositeExtract 195 0
+ 197: 16(float) GroupFAdd 25 Reduce 196
+ 198: 16(float) CompositeExtract 195 1
+ 199: 16(float) GroupFAdd 25 Reduce 198
+ 200: 16(float) CompositeExtract 195 2
+ 201: 16(float) GroupFAdd 25 Reduce 200
+ 202: 17(fvec3) CompositeConstruct 197 199 201
+ 203: 81(ptr) AccessChain 20 80
+ Store 203 202
+ 204: 22(ptr) AccessChain 20 21
+ 205: 6(int) Load 204
+ 206: 6(int) GroupSMinNonUniformAMD 25 Reduce 205
+ 207: 22(ptr) AccessChain 20 21
+ Store 207 206
+ 208: 29(ptr) AccessChain 20 28
+ 209: 8(ivec2) Load 208
+ 210: 7(int) CompositeExtract 209 0
+ 211: 7(int) GroupUMinNonUniformAMD 25 Reduce 210
+ 212: 7(int) CompositeExtract 209 1
+ 213: 7(int) GroupUMinNonUniformAMD 25 Reduce 212
+ 214: 8(ivec2) CompositeConstruct 211 213
+ 215: 29(ptr) AccessChain 20 28
+ Store 215 214
+ 216: 39(ptr) AccessChain 20 38
+ 217: 10(fvec3) Load 216
+ 218: 9(float) CompositeExtract 217 0
+ 219: 9(float) GroupFMinNonUniformAMD 25 Reduce 218
+ 220: 9(float) CompositeExtract 217 1
+ 221: 9(float) GroupFMinNonUniformAMD 25 Reduce 220
+ 222: 9(float) CompositeExtract 217 2
+ 223: 9(float) GroupFMinNonUniformAMD 25 Reduce 222
+ 224: 10(fvec3) CompositeConstruct 219 221 223
+ 225: 39(ptr) AccessChain 20 38
+ Store 225 224
+ 226: 51(ptr) AccessChain 20 50
+ 227: 12(fvec4) Load 226
+ 228: 11(float) CompositeExtract 227 0
+ 229: 11(float) GroupFMinNonUniformAMD 25 Reduce 228
+ 230: 11(float) CompositeExtract 227 1
+ 231: 11(float) GroupFMinNonUniformAMD 25 Reduce 230
+ 232: 11(float) CompositeExtract 227 2
+ 233: 11(float) GroupFMinNonUniformAMD 25 Reduce 232
+ 234: 11(float) CompositeExtract 227 3
+ 235: 11(float) GroupFMinNonUniformAMD 25 Reduce 234
+ 236: 12(fvec4) CompositeConstruct 229 231 233 235
+ 237: 51(ptr) AccessChain 20 50
+ Store 237 236
+ 238: 65(ptr) AccessChain 20 64
+ 239: 13(int) Load 238
+ 240: 13(int) GroupSMinNonUniformAMD 25 Reduce 239
+ 241: 65(ptr) AccessChain 20 64
+ Store 241 240
+ 242: 71(ptr) AccessChain 20 70
+ 243: 15(ivec2) Load 242
+ 244: 14(int) CompositeExtract 243 0
+ 245: 14(int) GroupUMinNonUniformAMD 25 Reduce 244
+ 246: 14(int) CompositeExtract 243 1
+ 247: 14(int) GroupUMinNonUniformAMD 25 Reduce 246
+ 248: 15(ivec2) CompositeConstruct 245 247
+ 249: 71(ptr) AccessChain 20 70
+ Store 249 248
+ 250: 81(ptr) AccessChain 20 80
+ 251: 17(fvec3) Load 250
+ 252: 16(float) CompositeExtract 251 0
+ 253: 16(float) GroupFMinNonUniformAMD 25 Reduce 252
+ 254: 16(float) CompositeExtract 251 1
+ 255: 16(float) GroupFMinNonUniformAMD 25 Reduce 254
+ 256: 16(float) CompositeExtract 251 2
+ 257: 16(float) GroupFMinNonUniformAMD 25 Reduce 256
+ 258: 17(fvec3) CompositeConstruct 253 255 257
+ 259: 81(ptr) AccessChain 20 80
+ Store 259 258
+ 260: 22(ptr) AccessChain 20 21
+ 261: 6(int) Load 260
+ 262: 6(int) GroupSMaxNonUniformAMD 25 Reduce 261
+ 263: 22(ptr) AccessChain 20 21
+ Store 263 262
+ 264: 29(ptr) AccessChain 20 28
+ 265: 8(ivec2) Load 264
+ 266: 7(int) CompositeExtract 265 0
+ 267: 7(int) GroupUMaxNonUniformAMD 25 Reduce 266
+ 268: 7(int) CompositeExtract 265 1
+ 269: 7(int) GroupUMaxNonUniformAMD 25 Reduce 268
+ 270: 8(ivec2) CompositeConstruct 267 269
+ 271: 29(ptr) AccessChain 20 28
+ Store 271 270
+ 272: 39(ptr) AccessChain 20 38
+ 273: 10(fvec3) Load 272
+ 274: 9(float) CompositeExtract 273 0
+ 275: 9(float) GroupFMaxNonUniformAMD 25 Reduce 274
+ 276: 9(float) CompositeExtract 273 1
+ 277: 9(float) GroupFMaxNonUniformAMD 25 Reduce 276
+ 278: 9(float) CompositeExtract 273 2
+ 279: 9(float) GroupFMaxNonUniformAMD 25 Reduce 278
+ 280: 10(fvec3) CompositeConstruct 275 277 279
+ 281: 39(ptr) AccessChain 20 38
+ Store 281 280
+ 282: 51(ptr) AccessChain 20 50
+ 283: 12(fvec4) Load 282
+ 284: 11(float) CompositeExtract 283 0
+ 285: 11(float) GroupFMaxNonUniformAMD 25 Reduce 284
+ 286: 11(float) CompositeExtract 283 1
+ 287: 11(float) GroupFMaxNonUniformAMD 25 Reduce 286
+ 288: 11(float) CompositeExtract 283 2
+ 289: 11(float) GroupFMaxNonUniformAMD 25 Reduce 288
+ 290: 11(float) CompositeExtract 283 3
+ 291: 11(float) GroupFMaxNonUniformAMD 25 Reduce 290
+ 292: 12(fvec4) CompositeConstruct 285 287 289 291
+ 293: 51(ptr) AccessChain 20 50
+ Store 293 292
+ 294: 65(ptr) AccessChain 20 64
+ 295: 13(int) Load 294
+ 296: 13(int) GroupSMaxNonUniformAMD 25 Reduce 295
+ 297: 65(ptr) AccessChain 20 64
+ Store 297 296
+ 298: 71(ptr) AccessChain 20 70
+ 299: 15(ivec2) Load 298
+ 300: 14(int) CompositeExtract 299 0
+ 301: 14(int) GroupUMaxNonUniformAMD 25 Reduce 300
+ 302: 14(int) CompositeExtract 299 1
+ 303: 14(int) GroupUMaxNonUniformAMD 25 Reduce 302
+ 304: 15(ivec2) CompositeConstruct 301 303
+ 305: 71(ptr) AccessChain 20 70
+ Store 305 304
+ 306: 81(ptr) AccessChain 20 80
+ 307: 17(fvec3) Load 306
+ 308: 16(float) CompositeExtract 307 0
+ 309: 16(float) GroupFMaxNonUniformAMD 25 Reduce 308
+ 310: 16(float) CompositeExtract 307 1
+ 311: 16(float) GroupFMaxNonUniformAMD 25 Reduce 310
+ 312: 16(float) CompositeExtract 307 2
+ 313: 16(float) GroupFMaxNonUniformAMD 25 Reduce 312
+ 314: 17(fvec3) CompositeConstruct 309 311 313
+ 315: 81(ptr) AccessChain 20 80
+ Store 315 314
+ 316: 22(ptr) AccessChain 20 21
+ 317: 6(int) Load 316
+ 318: 6(int) GroupIAddNonUniformAMD 25 Reduce 317
+ 319: 22(ptr) AccessChain 20 21
+ Store 319 318
+ 320: 29(ptr) AccessChain 20 28
+ 321: 8(ivec2) Load 320
+ 322: 7(int) CompositeExtract 321 0
+ 323: 7(int) GroupIAddNonUniformAMD 25 Reduce 322
+ 324: 7(int) CompositeExtract 321 1
+ 325: 7(int) GroupIAddNonUniformAMD 25 Reduce 324
+ 326: 8(ivec2) CompositeConstruct 323 325
+ 327: 29(ptr) AccessChain 20 28
+ Store 327 326
+ 328: 39(ptr) AccessChain 20 38
+ 329: 10(fvec3) Load 328
+ 330: 9(float) CompositeExtract 329 0
+ 331: 9(float) GroupFAddNonUniformAMD 25 Reduce 330
+ 332: 9(float) CompositeExtract 329 1
+ 333: 9(float) GroupFAddNonUniformAMD 25 Reduce 332
+ 334: 9(float) CompositeExtract 329 2
+ 335: 9(float) GroupFAddNonUniformAMD 25 Reduce 334
+ 336: 10(fvec3) CompositeConstruct 331 333 335
+ 337: 39(ptr) AccessChain 20 38
+ Store 337 336
+ 338: 51(ptr) AccessChain 20 50
+ 339: 12(fvec4) Load 338
+ 340: 11(float) CompositeExtract 339 0
+ 341: 11(float) GroupFAddNonUniformAMD 25 Reduce 340
+ 342: 11(float) CompositeExtract 339 1
+ 343: 11(float) GroupFAddNonUniformAMD 25 Reduce 342
+ 344: 11(float) CompositeExtract 339 2
+ 345: 11(float) GroupFAddNonUniformAMD 25 Reduce 344
+ 346: 11(float) CompositeExtract 339 3
+ 347: 11(float) GroupFAddNonUniformAMD 25 Reduce 346
+ 348: 12(fvec4) CompositeConstruct 341 343 345 347
+ 349: 51(ptr) AccessChain 20 50
+ Store 349 348
+ 350: 65(ptr) AccessChain 20 64
+ 351: 13(int) Load 350
+ 352: 13(int) GroupIAddNonUniformAMD 25 Reduce 351
+ 353: 65(ptr) AccessChain 20 64
+ Store 353 352
+ 354: 71(ptr) AccessChain 20 70
+ 355: 15(ivec2) Load 354
+ 356: 14(int) CompositeExtract 355 0
+ 357: 14(int) GroupIAddNonUniformAMD 25 Reduce 356
+ 358: 14(int) CompositeExtract 355 1
+ 359: 14(int) GroupIAddNonUniformAMD 25 Reduce 358
+ 360: 15(ivec2) CompositeConstruct 357 359
+ 361: 71(ptr) AccessChain 20 70
+ Store 361 360
+ 362: 81(ptr) AccessChain 20 80
+ 363: 17(fvec3) Load 362
+ 364: 16(float) CompositeExtract 363 0
+ 365: 16(float) GroupFAddNonUniformAMD 25 Reduce 364
+ 366: 16(float) CompositeExtract 363 1
+ 367: 16(float) GroupFAddNonUniformAMD 25 Reduce 366
+ 368: 16(float) CompositeExtract 363 2
+ 369: 16(float) GroupFAddNonUniformAMD 25 Reduce 368
+ 370: 17(fvec3) CompositeConstruct 365 367 369
+ 371: 81(ptr) AccessChain 20 80
+ Store 371 370
+ 372: 22(ptr) AccessChain 20 21
+ 373: 6(int) Load 372
+ 374: 6(int) GroupSMin 25 InclusiveScan 373
+ 375: 22(ptr) AccessChain 20 21
+ Store 375 374
+ 376: 29(ptr) AccessChain 20 28
+ 377: 8(ivec2) Load 376
+ 378: 7(int) CompositeExtract 377 0
+ 379: 7(int) GroupUMin 25 InclusiveScan 378
+ 380: 7(int) CompositeExtract 377 1
+ 381: 7(int) GroupUMin 25 InclusiveScan 380
+ 382: 8(ivec2) CompositeConstruct 379 381
+ 383: 29(ptr) AccessChain 20 28
+ Store 383 382
+ 384: 39(ptr) AccessChain 20 38
+ 385: 10(fvec3) Load 384
+ 386: 9(float) CompositeExtract 385 0
+ 387: 9(float) GroupFMin 25 InclusiveScan 386
+ 388: 9(float) CompositeExtract 385 1
+ 389: 9(float) GroupFMin 25 InclusiveScan 388
+ 390: 9(float) CompositeExtract 385 2
+ 391: 9(float) GroupFMin 25 InclusiveScan 390
+ 392: 10(fvec3) CompositeConstruct 387 389 391
+ 393: 39(ptr) AccessChain 20 38
+ Store 393 392
+ 394: 51(ptr) AccessChain 20 50
+ 395: 12(fvec4) Load 394
+ 396: 11(float) CompositeExtract 395 0
+ 397: 11(float) GroupFMin 25 InclusiveScan 396
+ 398: 11(float) CompositeExtract 395 1
+ 399: 11(float) GroupFMin 25 InclusiveScan 398
+ 400: 11(float) CompositeExtract 395 2
+ 401: 11(float) GroupFMin 25 InclusiveScan 400
+ 402: 11(float) CompositeExtract 395 3
+ 403: 11(float) GroupFMin 25 InclusiveScan 402
+ 404: 12(fvec4) CompositeConstruct 397 399 401 403
+ 405: 51(ptr) AccessChain 20 50
+ Store 405 404
+ 406: 65(ptr) AccessChain 20 64
+ 407: 13(int) Load 406
+ 408: 13(int) GroupSMin 25 InclusiveScan 407
+ 409: 65(ptr) AccessChain 20 64
+ Store 409 408
+ 410: 71(ptr) AccessChain 20 70
+ 411: 15(ivec2) Load 410
+ 412: 14(int) CompositeExtract 411 0
+ 413: 14(int) GroupUMin 25 InclusiveScan 412
+ 414: 14(int) CompositeExtract 411 1
+ 415: 14(int) GroupUMin 25 InclusiveScan 414
+ 416: 15(ivec2) CompositeConstruct 413 415
+ 417: 71(ptr) AccessChain 20 70
+ Store 417 416
+ 418: 81(ptr) AccessChain 20 80
+ 419: 17(fvec3) Load 418
+ 420: 16(float) CompositeExtract 419 0
+ 421: 16(float) GroupFMin 25 InclusiveScan 420
+ 422: 16(float) CompositeExtract 419 1
+ 423: 16(float) GroupFMin 25 InclusiveScan 422
+ 424: 16(float) CompositeExtract 419 2
+ 425: 16(float) GroupFMin 25 InclusiveScan 424
+ 426: 17(fvec3) CompositeConstruct 421 423 425
+ 427: 81(ptr) AccessChain 20 80
+ Store 427 426
+ 428: 22(ptr) AccessChain 20 21
+ 429: 6(int) Load 428
+ 430: 6(int) GroupSMax 25 InclusiveScan 429
+ 431: 22(ptr) AccessChain 20 21
+ Store 431 430
+ 432: 29(ptr) AccessChain 20 28
+ 433: 8(ivec2) Load 432
+ 434: 7(int) CompositeExtract 433 0
+ 435: 7(int) GroupUMax 25 InclusiveScan 434
+ 436: 7(int) CompositeExtract 433 1
+ 437: 7(int) GroupUMax 25 InclusiveScan 436
+ 438: 8(ivec2) CompositeConstruct 435 437
+ 439: 29(ptr) AccessChain 20 28
+ Store 439 438
+ 440: 39(ptr) AccessChain 20 38
+ 441: 10(fvec3) Load 440
+ 442: 9(float) CompositeExtract 441 0
+ 443: 9(float) GroupFMax 25 InclusiveScan 442
+ 444: 9(float) CompositeExtract 441 1
+ 445: 9(float) GroupFMax 25 InclusiveScan 444
+ 446: 9(float) CompositeExtract 441 2
+ 447: 9(float) GroupFMax 25 InclusiveScan 446
+ 448: 10(fvec3) CompositeConstruct 443 445 447
+ 449: 39(ptr) AccessChain 20 38
+ Store 449 448
+ 450: 51(ptr) AccessChain 20 50
+ 451: 12(fvec4) Load 450
+ 452: 11(float) CompositeExtract 451 0
+ 453: 11(float) GroupFMax 25 InclusiveScan 452
+ 454: 11(float) CompositeExtract 451 1
+ 455: 11(float) GroupFMax 25 InclusiveScan 454
+ 456: 11(float) CompositeExtract 451 2
+ 457: 11(float) GroupFMax 25 InclusiveScan 456
+ 458: 11(float) CompositeExtract 451 3
+ 459: 11(float) GroupFMax 25 InclusiveScan 458
+ 460: 12(fvec4) CompositeConstruct 453 455 457 459
+ 461: 51(ptr) AccessChain 20 50
+ Store 461 460
+ 462: 65(ptr) AccessChain 20 64
+ 463: 13(int) Load 462
+ 464: 13(int) GroupSMax 25 InclusiveScan 463
+ 465: 65(ptr) AccessChain 20 64
+ Store 465 464
+ 466: 71(ptr) AccessChain 20 70
+ 467: 15(ivec2) Load 466
+ 468: 14(int) CompositeExtract 467 0
+ 469: 14(int) GroupUMax 25 InclusiveScan 468
+ 470: 14(int) CompositeExtract 467 1
+ 471: 14(int) GroupUMax 25 InclusiveScan 470
+ 472: 15(ivec2) CompositeConstruct 469 471
+ 473: 71(ptr) AccessChain 20 70
+ Store 473 472
+ 474: 81(ptr) AccessChain 20 80
+ 475: 17(fvec3) Load 474
+ 476: 16(float) CompositeExtract 475 0
+ 477: 16(float) GroupFMax 25 InclusiveScan 476
+ 478: 16(float) CompositeExtract 475 1
+ 479: 16(float) GroupFMax 25 InclusiveScan 478
+ 480: 16(float) CompositeExtract 475 2
+ 481: 16(float) GroupFMax 25 InclusiveScan 480
+ 482: 17(fvec3) CompositeConstruct 477 479 481
+ 483: 81(ptr) AccessChain 20 80
+ Store 483 482
+ 484: 22(ptr) AccessChain 20 21
+ 485: 6(int) Load 484
+ 486: 6(int) GroupIAdd 25 InclusiveScan 485
+ 487: 22(ptr) AccessChain 20 21
+ Store 487 486
+ 488: 29(ptr) AccessChain 20 28
+ 489: 8(ivec2) Load 488
+ 490: 7(int) CompositeExtract 489 0
+ 491: 7(int) GroupIAdd 25 InclusiveScan 490
+ 492: 7(int) CompositeExtract 489 1
+ 493: 7(int) GroupIAdd 25 InclusiveScan 492
+ 494: 8(ivec2) CompositeConstruct 491 493
+ 495: 29(ptr) AccessChain 20 28
+ Store 495 494
+ 496: 39(ptr) AccessChain 20 38
+ 497: 10(fvec3) Load 496
+ 498: 9(float) CompositeExtract 497 0
+ 499: 9(float) GroupFAdd 25 InclusiveScan 498
+ 500: 9(float) CompositeExtract 497 1
+ 501: 9(float) GroupFAdd 25 InclusiveScan 500
+ 502: 9(float) CompositeExtract 497 2
+ 503: 9(float) GroupFAdd 25 InclusiveScan 502
+ 504: 10(fvec3) CompositeConstruct 499 501 503
+ 505: 39(ptr) AccessChain 20 38
+ Store 505 504
+ 506: 51(ptr) AccessChain 20 50
+ 507: 12(fvec4) Load 506
+ 508: 11(float) CompositeExtract 507 0
+ 509: 11(float) GroupFAdd 25 InclusiveScan 508
+ 510: 11(float) CompositeExtract 507 1
+ 511: 11(float) GroupFAdd 25 InclusiveScan 510
+ 512: 11(float) CompositeExtract 507 2
+ 513: 11(float) GroupFAdd 25 InclusiveScan 512
+ 514: 11(float) CompositeExtract 507 3
+ 515: 11(float) GroupFAdd 25 InclusiveScan 514
+ 516: 12(fvec4) CompositeConstruct 509 511 513 515
+ 517: 51(ptr) AccessChain 20 50
+ Store 517 516
+ 518: 65(ptr) AccessChain 20 64
+ 519: 13(int) Load 518
+ 520: 13(int) GroupIAdd 25 InclusiveScan 519
+ 521: 65(ptr) AccessChain 20 64
+ Store 521 520
+ 522: 71(ptr) AccessChain 20 70
+ 523: 15(ivec2) Load 522
+ 524: 14(int) CompositeExtract 523 0
+ 525: 14(int) GroupIAdd 25 InclusiveScan 524
+ 526: 14(int) CompositeExtract 523 1
+ 527: 14(int) GroupIAdd 25 InclusiveScan 526
+ 528: 15(ivec2) CompositeConstruct 525 527
+ 529: 71(ptr) AccessChain 20 70
+ Store 529 528
+ 530: 81(ptr) AccessChain 20 80
+ 531: 17(fvec3) Load 530
+ 532: 16(float) CompositeExtract 531 0
+ 533: 16(float) GroupFAdd 25 InclusiveScan 532
+ 534: 16(float) CompositeExtract 531 1
+ 535: 16(float) GroupFAdd 25 InclusiveScan 534
+ 536: 16(float) CompositeExtract 531 2
+ 537: 16(float) GroupFAdd 25 InclusiveScan 536
+ 538: 17(fvec3) CompositeConstruct 533 535 537
+ 539: 81(ptr) AccessChain 20 80
+ Store 539 538
+ 540: 22(ptr) AccessChain 20 21
+ 541: 6(int) Load 540
+ 542: 6(int) GroupSMin 25 ExclusiveScan 541
+ 543: 22(ptr) AccessChain 20 21
+ Store 543 542
+ 544: 29(ptr) AccessChain 20 28
+ 545: 8(ivec2) Load 544
+ 546: 7(int) CompositeExtract 545 0
+ 547: 7(int) GroupUMin 25 ExclusiveScan 546
+ 548: 7(int) CompositeExtract 545 1
+ 549: 7(int) GroupUMin 25 ExclusiveScan 548
+ 550: 8(ivec2) CompositeConstruct 547 549
+ 551: 29(ptr) AccessChain 20 28
+ Store 551 550
+ 552: 39(ptr) AccessChain 20 38
+ 553: 10(fvec3) Load 552
+ 554: 9(float) CompositeExtract 553 0
+ 555: 9(float) GroupFMin 25 ExclusiveScan 554
+ 556: 9(float) CompositeExtract 553 1
+ 557: 9(float) GroupFMin 25 ExclusiveScan 556
+ 558: 9(float) CompositeExtract 553 2
+ 559: 9(float) GroupFMin 25 ExclusiveScan 558
+ 560: 10(fvec3) CompositeConstruct 555 557 559
+ 561: 39(ptr) AccessChain 20 38
+ Store 561 560
+ 562: 51(ptr) AccessChain 20 50
+ 563: 12(fvec4) Load 562
+ 564: 11(float) CompositeExtract 563 0
+ 565: 11(float) GroupFMin 25 ExclusiveScan 564
+ 566: 11(float) CompositeExtract 563 1
+ 567: 11(float) GroupFMin 25 ExclusiveScan 566
+ 568: 11(float) CompositeExtract 563 2
+ 569: 11(float) GroupFMin 25 ExclusiveScan 568
+ 570: 11(float) CompositeExtract 563 3
+ 571: 11(float) GroupFMin 25 ExclusiveScan 570
+ 572: 12(fvec4) CompositeConstruct 565 567 569 571
+ 573: 51(ptr) AccessChain 20 50
+ Store 573 572
+ 574: 65(ptr) AccessChain 20 64
+ 575: 13(int) Load 574
+ 576: 13(int) GroupSMin 25 ExclusiveScan 575
+ 577: 65(ptr) AccessChain 20 64
+ Store 577 576
+ 578: 71(ptr) AccessChain 20 70
+ 579: 15(ivec2) Load 578
+ 580: 14(int) CompositeExtract 579 0
+ 581: 14(int) GroupUMin 25 ExclusiveScan 580
+ 582: 14(int) CompositeExtract 579 1
+ 583: 14(int) GroupUMin 25 ExclusiveScan 582
+ 584: 15(ivec2) CompositeConstruct 581 583
+ 585: 71(ptr) AccessChain 20 70
+ Store 585 584
+ 586: 81(ptr) AccessChain 20 80
+ 587: 17(fvec3) Load 586
+ 588: 16(float) CompositeExtract 587 0
+ 589: 16(float) GroupFMin 25 ExclusiveScan 588
+ 590: 16(float) CompositeExtract 587 1
+ 591: 16(float) GroupFMin 25 ExclusiveScan 590
+ 592: 16(float) CompositeExtract 587 2
+ 593: 16(float) GroupFMin 25 ExclusiveScan 592
+ 594: 17(fvec3) CompositeConstruct 589 591 593
+ 595: 81(ptr) AccessChain 20 80
+ Store 595 594
+ 596: 22(ptr) AccessChain 20 21
+ 597: 6(int) Load 596
+ 598: 6(int) GroupSMax 25 ExclusiveScan 597
+ 599: 22(ptr) AccessChain 20 21
+ Store 599 598
+ 600: 29(ptr) AccessChain 20 28
+ 601: 8(ivec2) Load 600
+ 602: 7(int) CompositeExtract 601 0
+ 603: 7(int) GroupUMax 25 ExclusiveScan 602
+ 604: 7(int) CompositeExtract 601 1
+ 605: 7(int) GroupUMax 25 ExclusiveScan 604
+ 606: 8(ivec2) CompositeConstruct 603 605
+ 607: 29(ptr) AccessChain 20 28
+ Store 607 606
+ 608: 39(ptr) AccessChain 20 38
+ 609: 10(fvec3) Load 608
+ 610: 9(float) CompositeExtract 609 0
+ 611: 9(float) GroupFMax 25 ExclusiveScan 610
+ 612: 9(float) CompositeExtract 609 1
+ 613: 9(float) GroupFMax 25 ExclusiveScan 612
+ 614: 9(float) CompositeExtract 609 2
+ 615: 9(float) GroupFMax 25 ExclusiveScan 614
+ 616: 10(fvec3) CompositeConstruct 611 613 615
+ 617: 39(ptr) AccessChain 20 38
+ Store 617 616
+ 618: 51(ptr) AccessChain 20 50
+ 619: 12(fvec4) Load 618
+ 620: 11(float) CompositeExtract 619 0
+ 621: 11(float) GroupFMax 25 ExclusiveScan 620
+ 622: 11(float) CompositeExtract 619 1
+ 623: 11(float) GroupFMax 25 ExclusiveScan 622
+ 624: 11(float) CompositeExtract 619 2
+ 625: 11(float) GroupFMax 25 ExclusiveScan 624
+ 626: 11(float) CompositeExtract 619 3
+ 627: 11(float) GroupFMax 25 ExclusiveScan 626
+ 628: 12(fvec4) CompositeConstruct 621 623 625 627
+ 629: 51(ptr) AccessChain 20 50
+ Store 629 628
+ 630: 65(ptr) AccessChain 20 64
+ 631: 13(int) Load 630
+ 632: 13(int) GroupSMax 25 ExclusiveScan 631
+ 633: 65(ptr) AccessChain 20 64
+ Store 633 632
+ 634: 71(ptr) AccessChain 20 70
+ 635: 15(ivec2) Load 634
+ 636: 14(int) CompositeExtract 635 0
+ 637: 14(int) GroupUMax 25 ExclusiveScan 636
+ 638: 14(int) CompositeExtract 635 1
+ 639: 14(int) GroupUMax 25 ExclusiveScan 638
+ 640: 15(ivec2) CompositeConstruct 637 639
+ 641: 71(ptr) AccessChain 20 70
+ Store 641 640
+ 642: 81(ptr) AccessChain 20 80
+ 643: 17(fvec3) Load 642
+ 644: 16(float) CompositeExtract 643 0
+ 645: 16(float) GroupFMax 25 ExclusiveScan 644
+ 646: 16(float) CompositeExtract 643 1
+ 647: 16(float) GroupFMax 25 ExclusiveScan 646
+ 648: 16(float) CompositeExtract 643 2
+ 649: 16(float) GroupFMax 25 ExclusiveScan 648
+ 650: 17(fvec3) CompositeConstruct 645 647 649
+ 651: 81(ptr) AccessChain 20 80
+ Store 651 650
+ 652: 22(ptr) AccessChain 20 21
+ 653: 6(int) Load 652
+ 654: 6(int) GroupIAdd 25 ExclusiveScan 653
+ 655: 22(ptr) AccessChain 20 21
+ Store 655 654
+ 656: 29(ptr) AccessChain 20 28
+ 657: 8(ivec2) Load 656
+ 658: 7(int) CompositeExtract 657 0
+ 659: 7(int) GroupIAdd 25 ExclusiveScan 658
+ 660: 7(int) CompositeExtract 657 1
+ 661: 7(int) GroupIAdd 25 ExclusiveScan 660
+ 662: 8(ivec2) CompositeConstruct 659 661
+ 663: 29(ptr) AccessChain 20 28
+ Store 663 662
+ 664: 39(ptr) AccessChain 20 38
+ 665: 10(fvec3) Load 664
+ 666: 9(float) CompositeExtract 665 0
+ 667: 9(float) GroupFAdd 25 ExclusiveScan 666
+ 668: 9(float) CompositeExtract 665 1
+ 669: 9(float) GroupFAdd 25 ExclusiveScan 668
+ 670: 9(float) CompositeExtract 665 2
+ 671: 9(float) GroupFAdd 25 ExclusiveScan 670
+ 672: 10(fvec3) CompositeConstruct 667 669 671
+ 673: 39(ptr) AccessChain 20 38
+ Store 673 672
+ 674: 51(ptr) AccessChain 20 50
+ 675: 12(fvec4) Load 674
+ 676: 11(float) CompositeExtract 675 0
+ 677: 11(float) GroupFAdd 25 ExclusiveScan 676
+ 678: 11(float) CompositeExtract 675 1
+ 679: 11(float) GroupFAdd 25 ExclusiveScan 678
+ 680: 11(float) CompositeExtract 675 2
+ 681: 11(float) GroupFAdd 25 ExclusiveScan 680
+ 682: 11(float) CompositeExtract 675 3
+ 683: 11(float) GroupFAdd 25 ExclusiveScan 682
+ 684: 12(fvec4) CompositeConstruct 677 679 681 683
+ 685: 51(ptr) AccessChain 20 50
+ Store 685 684
+ 686: 65(ptr) AccessChain 20 64
+ 687: 13(int) Load 686
+ 688: 13(int) GroupIAdd 25 ExclusiveScan 687
+ 689: 65(ptr) AccessChain 20 64
+ Store 689 688
+ 690: 71(ptr) AccessChain 20 70
+ 691: 15(ivec2) Load 690
+ 692: 14(int) CompositeExtract 691 0
+ 693: 14(int) GroupIAdd 25 ExclusiveScan 692
+ 694: 14(int) CompositeExtract 691 1
+ 695: 14(int) GroupIAdd 25 ExclusiveScan 694
+ 696: 15(ivec2) CompositeConstruct 693 695
+ 697: 71(ptr) AccessChain 20 70
+ Store 697 696
+ 698: 81(ptr) AccessChain 20 80
+ 699: 17(fvec3) Load 698
+ 700: 16(float) CompositeExtract 699 0
+ 701: 16(float) GroupFAdd 25 ExclusiveScan 700
+ 702: 16(float) CompositeExtract 699 1
+ 703: 16(float) GroupFAdd 25 ExclusiveScan 702
+ 704: 16(float) CompositeExtract 699 2
+ 705: 16(float) GroupFAdd 25 ExclusiveScan 704
+ 706: 17(fvec3) CompositeConstruct 701 703 705
+ 707: 81(ptr) AccessChain 20 80
+ Store 707 706
+ 708: 22(ptr) AccessChain 20 21
+ 709: 6(int) Load 708
+ 710: 6(int) GroupSMinNonUniformAMD 25 InclusiveScan 709
+ 711: 22(ptr) AccessChain 20 21
+ Store 711 710
+ 712: 29(ptr) AccessChain 20 28
+ 713: 8(ivec2) Load 712
+ 714: 7(int) CompositeExtract 713 0
+ 715: 7(int) GroupUMinNonUniformAMD 25 InclusiveScan 714
+ 716: 7(int) CompositeExtract 713 1
+ 717: 7(int) GroupUMinNonUniformAMD 25 InclusiveScan 716
+ 718: 8(ivec2) CompositeConstruct 715 717
+ 719: 29(ptr) AccessChain 20 28
+ Store 719 718
+ 720: 39(ptr) AccessChain 20 38
+ 721: 10(fvec3) Load 720
+ 722: 9(float) CompositeExtract 721 0
+ 723: 9(float) GroupFMinNonUniformAMD 25 InclusiveScan 722
+ 724: 9(float) CompositeExtract 721 1
+ 725: 9(float) GroupFMinNonUniformAMD 25 InclusiveScan 724
+ 726: 9(float) CompositeExtract 721 2
+ 727: 9(float) GroupFMinNonUniformAMD 25 InclusiveScan 726
+ 728: 10(fvec3) CompositeConstruct 723 725 727
+ 729: 39(ptr) AccessChain 20 38
+ Store 729 728
+ 730: 51(ptr) AccessChain 20 50
+ 731: 12(fvec4) Load 730
+ 732: 11(float) CompositeExtract 731 0
+ 733: 11(float) GroupFMinNonUniformAMD 25 InclusiveScan 732
+ 734: 11(float) CompositeExtract 731 1
+ 735: 11(float) GroupFMinNonUniformAMD 25 InclusiveScan 734
+ 736: 11(float) CompositeExtract 731 2
+ 737: 11(float) GroupFMinNonUniformAMD 25 InclusiveScan 736
+ 738: 11(float) CompositeExtract 731 3
+ 739: 11(float) GroupFMinNonUniformAMD 25 InclusiveScan 738
+ 740: 12(fvec4) CompositeConstruct 733 735 737 739
+ 741: 51(ptr) AccessChain 20 50
+ Store 741 740
+ 742: 65(ptr) AccessChain 20 64
+ 743: 13(int) Load 742
+ 744: 13(int) GroupSMinNonUniformAMD 25 InclusiveScan 743
+ 745: 65(ptr) AccessChain 20 64
+ Store 745 744
+ 746: 71(ptr) AccessChain 20 70
+ 747: 15(ivec2) Load 746
+ 748: 14(int) CompositeExtract 747 0
+ 749: 14(int) GroupUMinNonUniformAMD 25 InclusiveScan 748
+ 750: 14(int) CompositeExtract 747 1
+ 751: 14(int) GroupUMinNonUniformAMD 25 InclusiveScan 750
+ 752: 15(ivec2) CompositeConstruct 749 751
+ 753: 71(ptr) AccessChain 20 70
+ Store 753 752
+ 754: 81(ptr) AccessChain 20 80
+ 755: 17(fvec3) Load 754
+ 756: 16(float) CompositeExtract 755 0
+ 757: 16(float) GroupFMinNonUniformAMD 25 InclusiveScan 756
+ 758: 16(float) CompositeExtract 755 1
+ 759: 16(float) GroupFMinNonUniformAMD 25 InclusiveScan 758
+ 760: 16(float) CompositeExtract 755 2
+ 761: 16(float) GroupFMinNonUniformAMD 25 InclusiveScan 760
+ 762: 17(fvec3) CompositeConstruct 757 759 761
+ 763: 81(ptr) AccessChain 20 80
+ Store 763 762
+ 764: 22(ptr) AccessChain 20 21
+ 765: 6(int) Load 764
+ 766: 6(int) GroupSMaxNonUniformAMD 25 InclusiveScan 765
+ 767: 22(ptr) AccessChain 20 21
+ Store 767 766
+ 768: 29(ptr) AccessChain 20 28
+ 769: 8(ivec2) Load 768
+ 770: 7(int) CompositeExtract 769 0
+ 771: 7(int) GroupUMaxNonUniformAMD 25 InclusiveScan 770
+ 772: 7(int) CompositeExtract 769 1
+ 773: 7(int) GroupUMaxNonUniformAMD 25 InclusiveScan 772
+ 774: 8(ivec2) CompositeConstruct 771 773
+ 775: 29(ptr) AccessChain 20 28
+ Store 775 774
+ 776: 39(ptr) AccessChain 20 38
+ 777: 10(fvec3) Load 776
+ 778: 9(float) CompositeExtract 777 0
+ 779: 9(float) GroupFMaxNonUniformAMD 25 InclusiveScan 778
+ 780: 9(float) CompositeExtract 777 1
+ 781: 9(float) GroupFMaxNonUniformAMD 25 InclusiveScan 780
+ 782: 9(float) CompositeExtract 777 2
+ 783: 9(float) GroupFMaxNonUniformAMD 25 InclusiveScan 782
+ 784: 10(fvec3) CompositeConstruct 779 781 783
+ 785: 39(ptr) AccessChain 20 38
+ Store 785 784
+ 786: 51(ptr) AccessChain 20 50
+ 787: 12(fvec4) Load 786
+ 788: 11(float) CompositeExtract 787 0
+ 789: 11(float) GroupFMaxNonUniformAMD 25 InclusiveScan 788
+ 790: 11(float) CompositeExtract 787 1
+ 791: 11(float) GroupFMaxNonUniformAMD 25 InclusiveScan 790
+ 792: 11(float) CompositeExtract 787 2
+ 793: 11(float) GroupFMaxNonUniformAMD 25 InclusiveScan 792
+ 794: 11(float) CompositeExtract 787 3
+ 795: 11(float) GroupFMaxNonUniformAMD 25 InclusiveScan 794
+ 796: 12(fvec4) CompositeConstruct 789 791 793 795
+ 797: 51(ptr) AccessChain 20 50
+ Store 797 796
+ 798: 65(ptr) AccessChain 20 64
+ 799: 13(int) Load 798
+ 800: 13(int) GroupSMaxNonUniformAMD 25 InclusiveScan 799
+ 801: 65(ptr) AccessChain 20 64
+ Store 801 800
+ 802: 71(ptr) AccessChain 20 70
+ 803: 15(ivec2) Load 802
+ 804: 14(int) CompositeExtract 803 0
+ 805: 14(int) GroupUMaxNonUniformAMD 25 InclusiveScan 804
+ 806: 14(int) CompositeExtract 803 1
+ 807: 14(int) GroupUMaxNonUniformAMD 25 InclusiveScan 806
+ 808: 15(ivec2) CompositeConstruct 805 807
+ 809: 71(ptr) AccessChain 20 70
+ Store 809 808
+ 810: 81(ptr) AccessChain 20 80
+ 811: 17(fvec3) Load 810
+ 812: 16(float) CompositeExtract 811 0
+ 813: 16(float) GroupFMaxNonUniformAMD 25 InclusiveScan 812
+ 814: 16(float) CompositeExtract 811 1
+ 815: 16(float) GroupFMaxNonUniformAMD 25 InclusiveScan 814
+ 816: 16(float) CompositeExtract 811 2
+ 817: 16(float) GroupFMaxNonUniformAMD 25 InclusiveScan 816
+ 818: 17(fvec3) CompositeConstruct 813 815 817
+ 819: 81(ptr) AccessChain 20 80
+ Store 819 818
+ 820: 22(ptr) AccessChain 20 21
+ 821: 6(int) Load 820
+ 822: 6(int) GroupIAddNonUniformAMD 25 InclusiveScan 821
+ 823: 22(ptr) AccessChain 20 21
+ Store 823 822
+ 824: 29(ptr) AccessChain 20 28
+ 825: 8(ivec2) Load 824
+ 826: 7(int) CompositeExtract 825 0
+ 827: 7(int) GroupIAddNonUniformAMD 25 InclusiveScan 826
+ 828: 7(int) CompositeExtract 825 1
+ 829: 7(int) GroupIAddNonUniformAMD 25 InclusiveScan 828
+ 830: 8(ivec2) CompositeConstruct 827 829
+ 831: 29(ptr) AccessChain 20 28
+ Store 831 830
+ 832: 39(ptr) AccessChain 20 38
+ 833: 10(fvec3) Load 832
+ 834: 9(float) CompositeExtract 833 0
+ 835: 9(float) GroupFAddNonUniformAMD 25 InclusiveScan 834
+ 836: 9(float) CompositeExtract 833 1
+ 837: 9(float) GroupFAddNonUniformAMD 25 InclusiveScan 836
+ 838: 9(float) CompositeExtract 833 2
+ 839: 9(float) GroupFAddNonUniformAMD 25 InclusiveScan 838
+ 840: 10(fvec3) CompositeConstruct 835 837 839
+ 841: 39(ptr) AccessChain 20 38
+ Store 841 840
+ 842: 51(ptr) AccessChain 20 50
+ 843: 12(fvec4) Load 842
+ 844: 11(float) CompositeExtract 843 0
+ 845: 11(float) GroupFAddNonUniformAMD 25 InclusiveScan 844
+ 846: 11(float) CompositeExtract 843 1
+ 847: 11(float) GroupFAddNonUniformAMD 25 InclusiveScan 846
+ 848: 11(float) CompositeExtract 843 2
+ 849: 11(float) GroupFAddNonUniformAMD 25 InclusiveScan 848
+ 850: 11(float) CompositeExtract 843 3
+ 851: 11(float) GroupFAddNonUniformAMD 25 InclusiveScan 850
+ 852: 12(fvec4) CompositeConstruct 845 847 849 851
+ 853: 51(ptr) AccessChain 20 50
+ Store 853 852
+ 854: 65(ptr) AccessChain 20 64
+ 855: 13(int) Load 854
+ 856: 13(int) GroupIAddNonUniformAMD 25 InclusiveScan 855
+ 857: 65(ptr) AccessChain 20 64
+ Store 857 856
+ 858: 71(ptr) AccessChain 20 70
+ 859: 15(ivec2) Load 858
+ 860: 14(int) CompositeExtract 859 0
+ 861: 14(int) GroupIAddNonUniformAMD 25 InclusiveScan 860
+ 862: 14(int) CompositeExtract 859 1
+ 863: 14(int) GroupIAddNonUniformAMD 25 InclusiveScan 862
+ 864: 15(ivec2) CompositeConstruct 861 863
+ 865: 71(ptr) AccessChain 20 70
+ Store 865 864
+ 866: 81(ptr) AccessChain 20 80
+ 867: 17(fvec3) Load 866
+ 868: 16(float) CompositeExtract 867 0
+ 869: 16(float) GroupFAddNonUniformAMD 25 InclusiveScan 868
+ 870: 16(float) CompositeExtract 867 1
+ 871: 16(float) GroupFAddNonUniformAMD 25 InclusiveScan 870
+ 872: 16(float) CompositeExtract 867 2
+ 873: 16(float) GroupFAddNonUniformAMD 25 InclusiveScan 872
+ 874: 17(fvec3) CompositeConstruct 869 871 873
+ 875: 81(ptr) AccessChain 20 80
+ Store 875 874
+ 876: 22(ptr) AccessChain 20 21
+ 877: 6(int) Load 876
+ 878: 6(int) GroupSMinNonUniformAMD 25 ExclusiveScan 877
+ 879: 22(ptr) AccessChain 20 21
+ Store 879 878
+ 880: 29(ptr) AccessChain 20 28
+ 881: 8(ivec2) Load 880
+ 882: 7(int) CompositeExtract 881 0
+ 883: 7(int) GroupUMinNonUniformAMD 25 ExclusiveScan 882
+ 884: 7(int) CompositeExtract 881 1
+ 885: 7(int) GroupUMinNonUniformAMD 25 ExclusiveScan 884
+ 886: 8(ivec2) CompositeConstruct 883 885
+ 887: 29(ptr) AccessChain 20 28
+ Store 887 886
+ 888: 39(ptr) AccessChain 20 38
+ 889: 10(fvec3) Load 888
+ 890: 9(float) CompositeExtract 889 0
+ 891: 9(float) GroupFMinNonUniformAMD 25 ExclusiveScan 890
+ 892: 9(float) CompositeExtract 889 1
+ 893: 9(float) GroupFMinNonUniformAMD 25 ExclusiveScan 892
+ 894: 9(float) CompositeExtract 889 2
+ 895: 9(float) GroupFMinNonUniformAMD 25 ExclusiveScan 894
+ 896: 10(fvec3) CompositeConstruct 891 893 895
+ 897: 39(ptr) AccessChain 20 38
+ Store 897 896
+ 898: 51(ptr) AccessChain 20 50
+ 899: 12(fvec4) Load 898
+ 900: 11(float) CompositeExtract 899 0
+ 901: 11(float) GroupFMinNonUniformAMD 25 ExclusiveScan 900
+ 902: 11(float) CompositeExtract 899 1
+ 903: 11(float) GroupFMinNonUniformAMD 25 ExclusiveScan 902
+ 904: 11(float) CompositeExtract 899 2
+ 905: 11(float) GroupFMinNonUniformAMD 25 ExclusiveScan 904
+ 906: 11(float) CompositeExtract 899 3
+ 907: 11(float) GroupFMinNonUniformAMD 25 ExclusiveScan 906
+ 908: 12(fvec4) CompositeConstruct 901 903 905 907
+ 909: 51(ptr) AccessChain 20 50
+ Store 909 908
+ 910: 65(ptr) AccessChain 20 64
+ 911: 13(int) Load 910
+ 912: 13(int) GroupSMinNonUniformAMD 25 ExclusiveScan 911
+ 913: 65(ptr) AccessChain 20 64
+ Store 913 912
+ 914: 71(ptr) AccessChain 20 70
+ 915: 15(ivec2) Load 914
+ 916: 14(int) CompositeExtract 915 0
+ 917: 14(int) GroupUMinNonUniformAMD 25 ExclusiveScan 916
+ 918: 14(int) CompositeExtract 915 1
+ 919: 14(int) GroupUMinNonUniformAMD 25 ExclusiveScan 918
+ 920: 15(ivec2) CompositeConstruct 917 919
+ 921: 71(ptr) AccessChain 20 70
+ Store 921 920
+ 922: 81(ptr) AccessChain 20 80
+ 923: 17(fvec3) Load 922
+ 924: 16(float) CompositeExtract 923 0
+ 925: 16(float) GroupFMinNonUniformAMD 25 ExclusiveScan 924
+ 926: 16(float) CompositeExtract 923 1
+ 927: 16(float) GroupFMinNonUniformAMD 25 ExclusiveScan 926
+ 928: 16(float) CompositeExtract 923 2
+ 929: 16(float) GroupFMinNonUniformAMD 25 ExclusiveScan 928
+ 930: 17(fvec3) CompositeConstruct 925 927 929
+ 931: 81(ptr) AccessChain 20 80
+ Store 931 930
+ 932: 22(ptr) AccessChain 20 21
+ 933: 6(int) Load 932
+ 934: 6(int) GroupSMaxNonUniformAMD 25 ExclusiveScan 933
+ 935: 22(ptr) AccessChain 20 21
+ Store 935 934
+ 936: 29(ptr) AccessChain 20 28
+ 937: 8(ivec2) Load 936
+ 938: 7(int) CompositeExtract 937 0
+ 939: 7(int) GroupUMaxNonUniformAMD 25 ExclusiveScan 938
+ 940: 7(int) CompositeExtract 937 1
+ 941: 7(int) GroupUMaxNonUniformAMD 25 ExclusiveScan 940
+ 942: 8(ivec2) CompositeConstruct 939 941
+ 943: 29(ptr) AccessChain 20 28
+ Store 943 942
+ 944: 39(ptr) AccessChain 20 38
+ 945: 10(fvec3) Load 944
+ 946: 9(float) CompositeExtract 945 0
+ 947: 9(float) GroupFMaxNonUniformAMD 25 ExclusiveScan 946
+ 948: 9(float) CompositeExtract 945 1
+ 949: 9(float) GroupFMaxNonUniformAMD 25 ExclusiveScan 948
+ 950: 9(float) CompositeExtract 945 2
+ 951: 9(float) GroupFMaxNonUniformAMD 25 ExclusiveScan 950
+ 952: 10(fvec3) CompositeConstruct 947 949 951
+ 953: 39(ptr) AccessChain 20 38
+ Store 953 952
+ 954: 51(ptr) AccessChain 20 50
+ 955: 12(fvec4) Load 954
+ 956: 11(float) CompositeExtract 955 0
+ 957: 11(float) GroupFMaxNonUniformAMD 25 ExclusiveScan 956
+ 958: 11(float) CompositeExtract 955 1
+ 959: 11(float) GroupFMaxNonUniformAMD 25 ExclusiveScan 958
+ 960: 11(float) CompositeExtract 955 2
+ 961: 11(float) GroupFMaxNonUniformAMD 25 ExclusiveScan 960
+ 962: 11(float) CompositeExtract 955 3
+ 963: 11(float) GroupFMaxNonUniformAMD 25 ExclusiveScan 962
+ 964: 12(fvec4) CompositeConstruct 957 959 961 963
+ 965: 51(ptr) AccessChain 20 50
+ Store 965 964
+ 966: 65(ptr) AccessChain 20 64
+ 967: 13(int) Load 966
+ 968: 13(int) GroupSMaxNonUniformAMD 25 ExclusiveScan 967
+ 969: 65(ptr) AccessChain 20 64
+ Store 969 968
+ 970: 71(ptr) AccessChain 20 70
+ 971: 15(ivec2) Load 970
+ 972: 14(int) CompositeExtract 971 0
+ 973: 14(int) GroupUMaxNonUniformAMD 25 ExclusiveScan 972
+ 974: 14(int) CompositeExtract 971 1
+ 975: 14(int) GroupUMaxNonUniformAMD 25 ExclusiveScan 974
+ 976: 15(ivec2) CompositeConstruct 973 975
+ 977: 71(ptr) AccessChain 20 70
+ Store 977 976
+ 978: 81(ptr) AccessChain 20 80
+ 979: 17(fvec3) Load 978
+ 980: 16(float) CompositeExtract 979 0
+ 981: 16(float) GroupFMaxNonUniformAMD 25 ExclusiveScan 980
+ 982: 16(float) CompositeExtract 979 1
+ 983: 16(float) GroupFMaxNonUniformAMD 25 ExclusiveScan 982
+ 984: 16(float) CompositeExtract 979 2
+ 985: 16(float) GroupFMaxNonUniformAMD 25 ExclusiveScan 984
+ 986: 17(fvec3) CompositeConstruct 981 983 985
+ 987: 81(ptr) AccessChain 20 80
+ Store 987 986
+ 988: 22(ptr) AccessChain 20 21
+ 989: 6(int) Load 988
+ 990: 6(int) GroupIAddNonUniformAMD 25 ExclusiveScan 989
+ 991: 22(ptr) AccessChain 20 21
+ Store 991 990
+ 992: 29(ptr) AccessChain 20 28
+ 993: 8(ivec2) Load 992
+ 994: 7(int) CompositeExtract 993 0
+ 995: 7(int) GroupIAddNonUniformAMD 25 ExclusiveScan 994
+ 996: 7(int) CompositeExtract 993 1
+ 997: 7(int) GroupIAddNonUniformAMD 25 ExclusiveScan 996
+ 998: 8(ivec2) CompositeConstruct 995 997
+ 999: 29(ptr) AccessChain 20 28
+ Store 999 998
+ 1000: 39(ptr) AccessChain 20 38
+ 1001: 10(fvec3) Load 1000
+ 1002: 9(float) CompositeExtract 1001 0
+ 1003: 9(float) GroupFAddNonUniformAMD 25 ExclusiveScan 1002
+ 1004: 9(float) CompositeExtract 1001 1
+ 1005: 9(float) GroupFAddNonUniformAMD 25 ExclusiveScan 1004
+ 1006: 9(float) CompositeExtract 1001 2
+ 1007: 9(float) GroupFAddNonUniformAMD 25 ExclusiveScan 1006
+ 1008: 10(fvec3) CompositeConstruct 1003 1005 1007
+ 1009: 39(ptr) AccessChain 20 38
+ Store 1009 1008
+ 1010: 51(ptr) AccessChain 20 50
+ 1011: 12(fvec4) Load 1010
+ 1012: 11(float) CompositeExtract 1011 0
+ 1013: 11(float) GroupFAddNonUniformAMD 25 ExclusiveScan 1012
+ 1014: 11(float) CompositeExtract 1011 1
+ 1015: 11(float) GroupFAddNonUniformAMD 25 ExclusiveScan 1014
+ 1016: 11(float) CompositeExtract 1011 2
+ 1017: 11(float) GroupFAddNonUniformAMD 25 ExclusiveScan 1016
+ 1018: 11(float) CompositeExtract 1011 3
+ 1019: 11(float) GroupFAddNonUniformAMD 25 ExclusiveScan 1018
+ 1020: 12(fvec4) CompositeConstruct 1013 1015 1017 1019
+ 1021: 51(ptr) AccessChain 20 50
+ Store 1021 1020
+ 1022: 65(ptr) AccessChain 20 64
+ 1023: 13(int) Load 1022
+ 1024: 13(int) GroupIAddNonUniformAMD 25 ExclusiveScan 1023
+ 1025: 65(ptr) AccessChain 20 64
+ Store 1025 1024
+ 1026: 71(ptr) AccessChain 20 70
+ 1027: 15(ivec2) Load 1026
+ 1028: 14(int) CompositeExtract 1027 0
+ 1029: 14(int) GroupIAddNonUniformAMD 25 ExclusiveScan 1028
+ 1030: 14(int) CompositeExtract 1027 1
+ 1031: 14(int) GroupIAddNonUniformAMD 25 ExclusiveScan 1030
+ 1032: 15(ivec2) CompositeConstruct 1029 1031
+ 1033: 71(ptr) AccessChain 20 70
+ Store 1033 1032
+ 1034: 81(ptr) AccessChain 20 80
+ 1035: 17(fvec3) Load 1034
+ 1036: 16(float) CompositeExtract 1035 0
+ 1037: 16(float) GroupFAddNonUniformAMD 25 ExclusiveScan 1036
+ 1038: 16(float) CompositeExtract 1035 1
+ 1039: 16(float) GroupFAddNonUniformAMD 25 ExclusiveScan 1038
+ 1040: 16(float) CompositeExtract 1035 2
+ 1041: 16(float) GroupFAddNonUniformAMD 25 ExclusiveScan 1040
+ 1042: 17(fvec3) CompositeConstruct 1037 1039 1041
+ 1043: 81(ptr) AccessChain 20 80
+ Store 1043 1042
+ Return
+ FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.shaderGroupVote.comp.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.shaderGroupVote.comp.out
index f8bfae804a9..464787f6dd4 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.shaderGroupVote.comp.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.shaderGroupVote.comp.out
@@ -3,10 +3,11 @@ Warning, version 450 is not yet complete; most version-specific features are pre
// Module Version 10000
// Generated by (magic number): 80001
-// Id's are bound by 37
+// Id's are bound by 33
Capability Shader
- Capability Groups
+ Capability SubgroupVoteKHR
+ Extension "SPV_KHR_subgroup_vote"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint GLCompute 4 "main"
@@ -22,7 +23,7 @@ Warning, version 450 is not yet complete; most version-specific features are pre
Decorate 10(Buffers) BufferBlock
Decorate 12 DescriptorSet 0
Decorate 12 Binding 0
- Decorate 36 BuiltIn WorkgroupSize
+ Decorate 32 BuiltIn WorkgroupSize
2: TypeVoid
3: TypeFunction 2
6: TypeBool
@@ -35,11 +36,10 @@ Warning, version 450 is not yet complete; most version-specific features are pre
14: 13(int) Constant 0
15: TypePointer Uniform 9(int)
18: 9(int) Constant 0
- 21: 9(int) Constant 3
- 31: 9(int) Constant 1
- 34: TypeVector 9(int) 3
- 35: 9(int) Constant 4
- 36: 34(ivec3) ConstantComposite 35 35 31
+ 27: 9(int) Constant 1
+ 30: TypeVector 9(int) 3
+ 31: 9(int) Constant 4
+ 32: 30(ivec3) ConstantComposite 31 31 27
4(main): 2 Function None 3
5: Label
8(b1): 7(ptr) Variable Function
@@ -48,20 +48,17 @@ Warning, version 450 is not yet complete; most version-specific features are pre
19: 6(bool) INotEqual 17 18
Store 8(b1) 19
20: 6(bool) Load 8(b1)
- 22: 6(bool) GroupAny 21 20
- Store 8(b1) 22
- 23: 6(bool) Load 8(b1)
- 24: 6(bool) GroupAll 21 23
- Store 8(b1) 24
- 25: 6(bool) Load 8(b1)
- 26: 6(bool) GroupAll 21 25
- 27: 6(bool) GroupAny 21 25
- 28: 6(bool) LogicalNot 27
- 29: 6(bool) LogicalOr 26 28
- Store 8(b1) 29
- 30: 6(bool) Load 8(b1)
- 32: 9(int) Select 30 31 18
- 33: 15(ptr) AccessChain 12 14
- Store 33 32
+ 21: 6(bool) SubgroupAllKHR 20
+ Store 8(b1) 21
+ 22: 6(bool) Load 8(b1)
+ 23: 6(bool) SubgroupAnyKHR 22
+ Store 8(b1) 23
+ 24: 6(bool) Load 8(b1)
+ 25: 6(bool) SubgroupAllEqualKHR 24
+ Store 8(b1) 25
+ 26: 6(bool) Load 8(b1)
+ 28: 9(int) Select 26 27 18
+ 29: 15(ptr) AccessChain 12 14
+ Store 29 28
Return
FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.specConst.vert.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.specConst.vert.out
index 5a7de46feed..5e2020fe015 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.specConst.vert.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.specConst.vert.out
@@ -17,6 +17,7 @@ Warning, version 450 is not yet complete; most version-specific features are pre
MemberName 11(gl_PerVertex) 2 "gl_ClipDistance"
MemberName 11(gl_PerVertex) 3 "gl_CullDistance"
Name 13 ""
+ Name 18 "a"
Name 25 "gl_VertexID"
Name 26 "gl_InstanceID"
MemberDecorate 11(gl_PerVertex) 0 BuiltIn Position
@@ -24,7 +25,7 @@ Warning, version 450 is not yet complete; most version-specific features are pre
MemberDecorate 11(gl_PerVertex) 2 BuiltIn ClipDistance
MemberDecorate 11(gl_PerVertex) 3 BuiltIn CullDistance
Decorate 11(gl_PerVertex) Block
- Decorate 18 SpecId 11
+ Decorate 18(a) SpecId 11
Decorate 25(gl_VertexID) BuiltIn VertexId
Decorate 26(gl_InstanceID) BuiltIn InstanceId
2: TypeVoid
@@ -41,14 +42,14 @@ Warning, version 450 is not yet complete; most version-specific features are pre
15: 14(int) Constant 0
16: 6(float) Constant 1065353216
17: 7(fvec4) ConstantComposite 16 16 16 16
- 18: 14(int) SpecConstant 8
+ 18(a): 14(int) SpecConstant 8
22: TypePointer Output 7(fvec4)
24: TypePointer Input 14(int)
25(gl_VertexID): 24(ptr) Variable Input
26(gl_InstanceID): 24(ptr) Variable Input
4(main): 2 Function None 3
5: Label
- 19: 6(float) ConvertSToF 18
+ 19: 6(float) ConvertSToF 18(a)
20: 7(fvec4) CompositeConstruct 19 19 19 19
21: 7(fvec4) FDiv 17 20
23: 22(ptr) AccessChain 13 15
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.specConstant.vert.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.specConstant.vert.out
index dc10e238799..a6750e57935 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.specConstant.vert.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.specConstant.vert.out
@@ -12,33 +12,44 @@ Warning, version 400 is not yet complete; most version-specific features are pre
EntryPoint Vertex 4 "main" 20 22 28 53
Source GLSL 400
Name 4 "main"
+ Name 9 "arraySize"
Name 14 "foo(vf4[s1516];"
Name 13 "p"
Name 17 "builtin_spec_constant("
Name 20 "color"
Name 22 "ucol"
Name 28 "size"
+ Name 30 "spBool"
+ Name 34 "scale"
+ Name 39 "spDouble"
+ Name 40 "spFloat"
Name 47 "param"
+ Name 50 "dupArraySize"
Name 53 "dupUcol"
+ Name 60 "spDupBool"
+ Name 63 "dupScale"
+ Name 67 "spDupDouble"
+ Name 68 "spDupFloat"
Name 76 "result"
- Decorate 9 SpecId 16
- Decorate 30 SpecId 17
- Decorate 34 SpecId 22
- Decorate 39 SpecId 19
- Decorate 40 SpecId 18
- Decorate 50 SpecId 116
- Decorate 60 SpecId 117
- Decorate 63 SpecId 122
- Decorate 67 SpecId 119
- Decorate 68 SpecId 118
- Decorate 77 SpecId 24
+ Name 77 "gl_MaxImageUnits"
+ Decorate 9(arraySize) SpecId 16
+ Decorate 30(spBool) SpecId 17
+ Decorate 34(scale) SpecId 22
+ Decorate 39(spDouble) SpecId 19
+ Decorate 40(spFloat) SpecId 18
+ Decorate 50(dupArraySize) SpecId 116
+ Decorate 60(spDupBool) SpecId 117
+ Decorate 63(dupScale) SpecId 122
+ Decorate 67(spDupDouble) SpecId 119
+ Decorate 68(spDupFloat) SpecId 118
+ Decorate 77(gl_MaxImageUnits) SpecId 24
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypeInt 32 1
- 9: 8(int) SpecConstant 5
- 10: TypeArray 7(fvec4) 9
+ 9(arraySize): 8(int) SpecConstant 5
+ 10: TypeArray 7(fvec4) 9(arraySize)
11: TypePointer Function 10
12: TypeFunction 2 11(ptr)
16: TypeFunction 8(int)
@@ -51,41 +62,41 @@ Warning, version 400 is not yet complete; most version-specific features are pre
27: TypePointer Output 8(int)
28(size): 27(ptr) Variable Output
29: TypeBool
- 30: 29(bool) SpecConstantTrue
+ 30(spBool): 29(bool) SpecConstantTrue
33: TypeInt 32 0
- 34: 33(int) SpecConstant 2
+ 34(scale): 33(int) SpecConstant 2
38: TypeFloat 64
- 39: 38(float) SpecConstant 1413754136 1074340347
- 40: 6(float) SpecConstant 1078523331
- 41: 38(float) SpecConstantOp 115 40
- 50: 8(int) SpecConstant 12
- 51: TypeArray 7(fvec4) 50
+ 39(spDouble): 38(float) SpecConstant 1413754136 1074340347
+ 40(spFloat): 6(float) SpecConstant 1078523331
+ 41: 38(float) SpecConstantOp 115 40(spFloat)
+50(dupArraySize): 8(int) SpecConstant 12
+ 51: TypeArray 7(fvec4) 50(dupArraySize)
52: TypePointer Input 51
53(dupUcol): 52(ptr) Variable Input
- 60: 29(bool) SpecConstantTrue
- 63: 33(int) SpecConstant 2
- 67: 38(float) SpecConstant 1413754136 1074340347
- 68: 6(float) SpecConstant 1078523331
- 69: 38(float) SpecConstantOp 115 68
+ 60(spDupBool): 29(bool) SpecConstantTrue
+ 63(dupScale): 33(int) SpecConstant 2
+ 67(spDupDouble): 38(float) SpecConstant 1413754136 1074340347
+ 68(spDupFloat): 6(float) SpecConstant 1078523331
+ 69: 38(float) SpecConstantOp 115 68(spDupFloat)
75: TypePointer Function 8(int)
- 77: 8(int) SpecConstant 8
+77(gl_MaxImageUnits): 8(int) SpecConstant 8
4(main): 2 Function None 3
5: Label
47(param): 11(ptr) Variable Function
25: 24(ptr) AccessChain 22(ucol) 23
26: 7(fvec4) Load 25
Store 20(color) 26
- Store 28(size) 9
+ Store 28(size) 9(arraySize)
SelectionMerge 32 None
- BranchConditional 30 31 32
+ BranchConditional 30(spBool) 31 32
31: Label
- 35: 6(float) ConvertUToF 34
+ 35: 6(float) ConvertUToF 34(scale)
36: 7(fvec4) Load 20(color)
37: 7(fvec4) VectorTimesScalar 36 35
Store 20(color) 37
Branch 32
32: Label
- 42: 38(float) FDiv 39 41
+ 42: 38(float) FDiv 39(spDouble) 41
43: 6(float) FConvert 42
44: 7(fvec4) Load 20(color)
45: 7(fvec4) CompositeConstruct 43 43 43 43
@@ -105,18 +116,18 @@ Warning, version 400 is not yet complete; most version-specific features are pre
57: 7(fvec4) FAdd 56 55
Store 20(color) 57
58: 8(int) Load 28(size)
- 59: 8(int) IAdd 58 50
+ 59: 8(int) IAdd 58 50(dupArraySize)
Store 28(size) 59
SelectionMerge 62 None
- BranchConditional 60 61 62
+ BranchConditional 60(spDupBool) 61 62
61: Label
- 64: 6(float) ConvertUToF 63
+ 64: 6(float) ConvertUToF 63(dupScale)
65: 7(fvec4) Load 20(color)
66: 7(fvec4) VectorTimesScalar 65 64
Store 20(color) 66
Branch 62
62: Label
- 70: 38(float) FDiv 67 69
+ 70: 38(float) FDiv 67(spDupDouble) 69
71: 6(float) FConvert 70
72: 7(fvec4) Load 20(color)
73: 7(fvec4) CompositeConstruct 71 71 71 71
@@ -127,7 +138,7 @@ Warning, version 400 is not yet complete; most version-specific features are pre
17(builtin_spec_constant(): 8(int) Function None 16
18: Label
76(result): 75(ptr) Variable Function
- Store 76(result) 77
+ Store 76(result) 77(gl_MaxImageUnits)
78: 8(int) Load 76(result)
ReturnValue 78
FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.specConstantComposite.vert.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.specConstantComposite.vert.out
index f8c556edcad..9079554bae9 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.specConstantComposite.vert.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.specConstantComposite.vert.out
@@ -18,29 +18,33 @@ Warning, version 450 is not yet complete; most version-specific features are pre
Name 12 "refer_composite_bracket_dereference("
Name 16 "refer_spec_const_array_length("
Name 18 "declare_spec_const_in_func("
+ Name 21 "spec_bool"
Name 27 "color"
+ Name 28 "spec_int"
Name 33 "len"
+ Name 37 "spec_float"
+ Name 39 "spec_double"
Name 42 "global_vec4_array_with_spec_length"
- Decorate 21 SpecId 203
- Decorate 28 SpecId 200
- Decorate 37 SpecId 201
- Decorate 39 SpecId 202
+ Decorate 21(spec_bool) SpecId 203
+ Decorate 28(spec_int) SpecId 200
+ Decorate 37(spec_float) SpecId 201
+ Decorate 39(spec_double) SpecId 202
2: TypeVoid
3: TypeFunction 2
14: TypeInt 32 1
15: TypeFunction 14(int)
20: TypeBool
- 21: 20(bool) SpecConstantTrue
+ 21(spec_bool): 20(bool) SpecConstantTrue
24: TypeFloat 32
25: TypeVector 24(float) 4
26: TypePointer Output 25(fvec4)
27(color): 26(ptr) Variable Output
- 28: 14(int) SpecConstant 3
+ 28(spec_int): 14(int) SpecConstant 3
32: TypePointer Function 14(int)
- 37: 24(float) SpecConstant 1078523331
+ 37(spec_float): 24(float) SpecConstant 1078523331
38: TypeFloat 64
- 39: 38(float) SpecConstant 1413754136 1074340347
- 40: TypeArray 25(fvec4) 28
+ 39(spec_double): 38(float) SpecConstant 1413754136 1074340347
+ 40: TypeArray 25(fvec4) 28(spec_int)
41: TypePointer Input 40
42(global_vec4_array_with_spec_length): 41(ptr) Variable Input
4(main): 2 Function None 3
@@ -50,9 +54,9 @@ Warning, version 450 is not yet complete; most version-specific features are pre
6(refer_primary_spec_const(): 2 Function None 3
7: Label
SelectionMerge 23 None
- BranchConditional 21 22 23
+ BranchConditional 21(spec_bool) 22 23
22: Label
- 29: 24(float) ConvertSToF 28
+ 29: 24(float) ConvertSToF 28(spec_int)
30: 25(fvec4) Load 27(color)
31: 25(fvec4) VectorTimesScalar 30 29
Store 27(color) 31
@@ -75,7 +79,7 @@ Warning, version 450 is not yet complete; most version-specific features are pre
16(refer_spec_const_array_length(): 14(int) Function None 15
17: Label
33(len): 32(ptr) Variable Function
- Store 33(len) 28
+ Store 33(len) 28(spec_int)
34: 14(int) Load 33(len)
ReturnValue 34
FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.specConstantOperations.vert.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.specConstantOperations.vert.out
index e2395c82b82..d6da726e602 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.specConstantOperations.vert.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.specConstantOperations.vert.out
@@ -14,85 +14,90 @@ Warning, version 450 is not yet complete; most version-specific features are pre
Name 4 "main"
Name 8 "non_const_array_size_from_spec_const("
Name 11 "i"
+ Name 19 "sp_int"
Name 27 "array"
- Decorate 19 SpecId 201
- Decorate 40 SpecId 200
- Decorate 42 SpecId 202
- Decorate 43 SpecId 203
- Decorate 45 SpecId 204
+ Name 40 "sp_float"
+ Name 42 "sp_uint"
+ Name 43 "sp_sint"
+ Name 45 "sp_double"
+ Decorate 19(sp_int) SpecId 201
+ Decorate 40(sp_float) SpecId 200
+ Decorate 42(sp_uint) SpecId 202
+ Decorate 43(sp_sint) SpecId 203
+ Decorate 45(sp_double) SpecId 204
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 1
7: TypeFunction 6(int)
10: TypePointer Function 6(int)
12: 6(int) Constant 0
- 19: 6(int) SpecConstant 10
+ 19(sp_int): 6(int) SpecConstant 10
20: 6(int) Constant 2
- 21: 6(int) SpecConstantOp 128 19 20
+ 21: 6(int) SpecConstantOp 128 19(sp_int) 20
22: TypeBool
- 24: 6(int) SpecConstantOp 128 19 20
+ 24: 6(int) SpecConstantOp 128 19(sp_int) 20
25: TypeArray 6(int) 24
26: TypePointer Function 25
29: 6(int) Constant 1023
32: 6(int) Constant 1
- 34: 6(int) SpecConstantOp 128 19 32
+ 34: 6(int) SpecConstantOp 128 19(sp_int) 32
39: TypeFloat 32
- 40: 39(float) SpecConstant 1078530010
+ 40(sp_float): 39(float) SpecConstant 1078530010
41: TypeInt 32 0
- 42: 41(int) SpecConstant 100
- 43: 6(int) SpecConstant 4294967286
+ 42(sp_uint): 41(int) SpecConstant 100
+ 43(sp_sint): 6(int) SpecConstant 4294967286
44: TypeFloat 64
- 45: 44(float) SpecConstant 2333366019 1074118410
- 46: 39(float) SpecConstantOp 115 45
- 47: 44(float) SpecConstantOp 115 40
+ 45(sp_double): 44(float) SpecConstant 2333366019 1074118410
+ 46: 39(float) SpecConstantOp 115 45(sp_double)
+ 47: 44(float) SpecConstantOp 115 40(sp_float)
48: 41(int) Constant 0
- 49: 22(bool) SpecConstantOp 171 19 48
- 50: 22(bool) SpecConstantOp 171 42 48
+ 49: 22(bool) SpecConstantOp 171 19(sp_int) 48
+ 50: 22(bool) SpecConstantOp 171 42(sp_uint) 48
51: 6(int) SpecConstantOp 169 49 32 12
52: 41(int) Constant 1
53: 41(int) SpecConstantOp 169 49 52 48
- 54: 41(int) SpecConstantOp 128 43 48
- 55: 6(int) SpecConstantOp 128 42 48
- 56: 6(int) SpecConstantOp 126 19
- 57: 6(int) SpecConstantOp 200 19
- 58: 6(int) SpecConstantOp 128 19 20
- 59: 6(int) SpecConstantOp 128 19 20
+ 54: 41(int) SpecConstantOp 128 43(sp_sint) 48
+ 55: 6(int) SpecConstantOp 128 42(sp_uint) 48
+ 56: 6(int) SpecConstantOp 126 19(sp_int)
+ 57: 6(int) SpecConstantOp 200 19(sp_int)
+ 58: 6(int) SpecConstantOp 128 19(sp_int) 20
+ 59: 6(int) SpecConstantOp 128 19(sp_int) 20
60: 6(int) Constant 3
61: 6(int) SpecConstantOp 130 59 60
62: 6(int) Constant 4
63: 6(int) SpecConstantOp 130 58 62
- 64: 6(int) SpecConstantOp 132 43 20
+ 64: 6(int) SpecConstantOp 132 43(sp_sint) 20
65: 41(int) Constant 2
- 66: 41(int) SpecConstantOp 132 42 65
+ 66: 41(int) SpecConstantOp 132 42(sp_uint) 65
67: 6(int) Constant 5
68: 6(int) SpecConstantOp 135 64 67
69: 41(int) Constant 5
70: 41(int) SpecConstantOp 134 66 69
- 71: 6(int) SpecConstantOp 139 43 62
+ 71: 6(int) SpecConstantOp 139 43(sp_sint) 62
72: 41(int) Constant 4
- 73: 41(int) SpecConstantOp 137 42 72
- 74: 6(int) SpecConstantOp 132 43 60
+ 73: 41(int) SpecConstantOp 137 42(sp_uint) 72
+ 74: 6(int) SpecConstantOp 132 43(sp_sint) 60
75: 6(int) SpecConstantOp 135 74 67
76: 6(int) Constant 10
- 77: 6(int) SpecConstantOp 195 43 76
+ 77: 6(int) SpecConstantOp 195 43(sp_sint) 76
78: 6(int) Constant 20
- 79: 41(int) SpecConstantOp 194 42 78
- 80: 6(int) SpecConstantOp 196 43 32
- 81: 41(int) SpecConstantOp 196 42 20
+ 79: 41(int) SpecConstantOp 194 42(sp_uint) 78
+ 80: 6(int) SpecConstantOp 196 43(sp_sint) 32
+ 81: 41(int) SpecConstantOp 196 42(sp_uint) 20
82: 6(int) Constant 256
- 83: 6(int) SpecConstantOp 197 43 82
+ 83: 6(int) SpecConstantOp 197 43(sp_sint) 82
84: 41(int) Constant 512
- 85: 41(int) SpecConstantOp 198 42 84
- 86: 22(bool) SpecConstantOp 177 19 43
- 87: 22(bool) SpecConstantOp 170 42 42
- 88: 22(bool) SpecConstantOp 173 19 43
+ 85: 41(int) SpecConstantOp 198 42(sp_uint) 84
+ 86: 22(bool) SpecConstantOp 177 19(sp_int) 43(sp_sint)
+ 87: 22(bool) SpecConstantOp 170 42(sp_uint) 42(sp_uint)
+ 88: 22(bool) SpecConstantOp 173 19(sp_int) 43(sp_sint)
89: 6(int) Constant 30
90: TypeVector 6(int) 4
- 91: 90(ivec4) SpecConstantComposite 78 89 19 19
+ 91: 90(ivec4) SpecConstantComposite 78 89 19(sp_int) 19(sp_int)
92: 41(int) Constant 4294967295
93: 41(int) Constant 4294967294
94: TypeVector 41(int) 4
- 95: 94(ivec4) SpecConstantComposite 42 42 92 93
+ 95: 94(ivec4) SpecConstantComposite 42(sp_uint) 42(sp_uint) 92 93
96: TypeVector 22(bool) 4
97: 94(ivec4) ConstantComposite 48 48 48 48
98: 96(bvec4) SpecConstantOp 171 91 97
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.stereoViewRendering.tesc.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.stereoViewRendering.tesc.out
new file mode 100644
index 00000000000..c8f9642c1af
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.stereoViewRendering.tesc.out
@@ -0,0 +1,86 @@
+spv.stereoViewRendering.tesc
+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 38
+
+ Capability Geometry
+ Capability Tessellation
+ Capability ShaderViewportMaskNV
+ Capability ShaderStereoViewNV
+ Extension "SPV_NV_stereo_view_rendering"
+ Extension "SPV_NV_viewport_array2"
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint TessellationControl 4 "main" 16 18 32
+ ExecutionMode 4 OutputVertices 4
+ Source GLSL 450
+ SourceExtension "GL_NV_stereo_view_rendering"
+ SourceExtension "GL_NV_viewport_array2"
+ Name 4 "main"
+ Name 12 "gl_PerVertex"
+ MemberName 12(gl_PerVertex) 0 "gl_Layer"
+ MemberName 12(gl_PerVertex) 1 "gl_SecondaryPositionNV"
+ MemberName 12(gl_PerVertex) 2 "gl_SecondaryViewportMaskNV"
+ Name 16 "gl_out"
+ Name 18 "gl_InvocationID"
+ Name 28 "gl_PerVertex"
+ MemberName 28(gl_PerVertex) 0 "gl_Position"
+ MemberName 28(gl_PerVertex) 1 "gl_PointSize"
+ MemberName 28(gl_PerVertex) 2 "gl_ClipDistance"
+ MemberName 28(gl_PerVertex) 3 "gl_CullDistance"
+ MemberName 28(gl_PerVertex) 4 "gl_SecondaryPositionNV"
+ Name 32 "gl_in"
+ MemberDecorate 12(gl_PerVertex) 0 BuiltIn Layer
+ MemberDecorate 12(gl_PerVertex) 0 ViewportRelativeNV
+ MemberDecorate 12(gl_PerVertex) 0 SecondaryViewportRelativeNV 1
+ MemberDecorate 12(gl_PerVertex) 1 BuiltIn SecondaryPositionNV
+ MemberDecorate 12(gl_PerVertex) 2 BuiltIn SecondaryViewportMaskNV
+ Decorate 12(gl_PerVertex) Block
+ Decorate 18(gl_InvocationID) BuiltIn InvocationId
+ MemberDecorate 28(gl_PerVertex) 0 BuiltIn Position
+ MemberDecorate 28(gl_PerVertex) 1 BuiltIn PointSize
+ MemberDecorate 28(gl_PerVertex) 2 BuiltIn ClipDistance
+ MemberDecorate 28(gl_PerVertex) 3 BuiltIn CullDistance
+ Decorate 28(gl_PerVertex) Block
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeInt 32 1
+ 7: TypeFloat 32
+ 8: TypeVector 7(float) 4
+ 9: TypeInt 32 0
+ 10: 9(int) Constant 2
+ 11: TypeArray 6(int) 10
+12(gl_PerVertex): TypeStruct 6(int) 8(fvec4) 11
+ 13: 9(int) Constant 4
+ 14: TypeArray 12(gl_PerVertex) 13
+ 15: TypePointer Output 14
+ 16(gl_out): 15(ptr) Variable Output
+ 17: TypePointer Input 6(int)
+18(gl_InvocationID): 17(ptr) Variable Input
+ 20: 6(int) Constant 2
+ 21: 6(int) Constant 0
+ 22: 6(int) Constant 1
+ 23: TypePointer Output 6(int)
+ 26: 9(int) Constant 1
+ 27: TypeArray 7(float) 26
+28(gl_PerVertex): TypeStruct 8(fvec4) 7(float) 27 27 8(fvec4)
+ 29: 9(int) Constant 32
+ 30: TypeArray 28(gl_PerVertex) 29
+ 31: TypePointer Input 30
+ 32(gl_in): 31(ptr) Variable Input
+ 33: TypePointer Input 8(fvec4)
+ 36: TypePointer Output 8(fvec4)
+ 4(main): 2 Function None 3
+ 5: Label
+ 19: 6(int) Load 18(gl_InvocationID)
+ 24: 23(ptr) AccessChain 16(gl_out) 19 20 21
+ Store 24 22
+ 25: 6(int) Load 18(gl_InvocationID)
+ 34: 33(ptr) AccessChain 32(gl_in) 22 21
+ 35: 8(fvec4) Load 34
+ 37: 36(ptr) AccessChain 16(gl_out) 25 22
+ Store 37 35
+ Return
+ FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.stereoViewRendering.vert.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.stereoViewRendering.vert.out
new file mode 100644
index 00000000000..d6c695601e3
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.stereoViewRendering.vert.out
@@ -0,0 +1,69 @@
+spv.stereoViewRendering.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 27
+
+ Capability Shader
+ Capability Geometry
+ Capability ShaderViewportIndexLayerNV
+ Capability ShaderViewportMaskNV
+ Capability ShaderStereoViewNV
+ Extension "SPV_NV_stereo_view_rendering"
+ Extension "SPV_NV_viewport_array2"
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Vertex 4 "main" 11 19 23 26
+ Source GLSL 450
+ SourceExtension "GL_NV_stereo_view_rendering"
+ SourceExtension "GL_NV_viewport_array2"
+ Name 4 "main"
+ Name 11 "gl_SecondaryViewportMaskNV"
+ Name 19 "gl_SecondaryPositionNV"
+ Name 21 "gl_PerVertex"
+ MemberName 21(gl_PerVertex) 0 "gl_Position"
+ MemberName 21(gl_PerVertex) 1 "gl_PointSize"
+ MemberName 21(gl_PerVertex) 2 "gl_ClipDistance"
+ MemberName 21(gl_PerVertex) 3 "gl_CullDistance"
+ Name 23 ""
+ Name 26 "gl_Layer"
+ Decorate 11(gl_SecondaryViewportMaskNV) BuiltIn SecondaryViewportMaskNV
+ Decorate 19(gl_SecondaryPositionNV) BuiltIn SecondaryPositionNV
+ MemberDecorate 21(gl_PerVertex) 0 BuiltIn Position
+ MemberDecorate 21(gl_PerVertex) 1 BuiltIn PointSize
+ MemberDecorate 21(gl_PerVertex) 2 BuiltIn ClipDistance
+ MemberDecorate 21(gl_PerVertex) 3 BuiltIn CullDistance
+ Decorate 21(gl_PerVertex) Block
+ Decorate 26(gl_Layer) BuiltIn Layer
+ Decorate 26(gl_Layer) ViewportRelativeNV
+ Decorate 26(gl_Layer) SecondaryViewportRelativeNV 2
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeInt 32 1
+ 7: TypeInt 32 0
+ 8: 7(int) Constant 1
+ 9: TypeArray 6(int) 8
+ 10: TypePointer Output 9
+11(gl_SecondaryViewportMaskNV): 10(ptr) Variable Output
+ 12: 6(int) Constant 0
+ 13: 6(int) Constant 1
+ 14: TypePointer Output 6(int)
+ 16: TypeFloat 32
+ 17: TypeVector 16(float) 4
+ 18: TypePointer Output 17(fvec4)
+19(gl_SecondaryPositionNV): 18(ptr) Variable Output
+ 20: TypeArray 16(float) 8
+21(gl_PerVertex): TypeStruct 17(fvec4) 16(float) 20 20
+ 22: TypePointer Output 21(gl_PerVertex)
+ 23: 22(ptr) Variable Output
+ 26(gl_Layer): 14(ptr) Variable Output
+ 4(main): 2 Function None 3
+ 5: Label
+ 15: 14(ptr) AccessChain 11(gl_SecondaryViewportMaskNV) 12
+ Store 15 13
+ 24: 18(ptr) AccessChain 23 12
+ 25: 17(fvec4) Load 24
+ Store 19(gl_SecondaryPositionNV) 25
+ Return
+ FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.viewportArray2.tesc.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.viewportArray2.tesc.out
new file mode 100644
index 00000000000..6d73fc399d8
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.viewportArray2.tesc.out
@@ -0,0 +1,59 @@
+spv.viewportArray2.tesc
+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 25
+
+ Capability Geometry
+ Capability Tessellation
+ Capability MultiViewport
+ Capability ShaderViewportIndexLayerNV
+ Capability ShaderViewportMaskNV
+ Extension "SPV_NV_viewport_array2"
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint TessellationControl 4 "main" 14 16
+ ExecutionMode 4 OutputVertices 4
+ Source GLSL 450
+ SourceExtension "GL_NV_viewport_array2"
+ Name 4 "main"
+ Name 10 "gl_PerVertex"
+ MemberName 10(gl_PerVertex) 0 "gl_ViewportIndex"
+ MemberName 10(gl_PerVertex) 1 "gl_Layer"
+ MemberName 10(gl_PerVertex) 2 "gl_ViewportMask"
+ Name 14 "gl_out"
+ Name 16 "gl_InvocationID"
+ MemberDecorate 10(gl_PerVertex) 0 BuiltIn ViewportIndex
+ MemberDecorate 10(gl_PerVertex) 1 BuiltIn Layer
+ MemberDecorate 10(gl_PerVertex) 1 ViewportRelativeNV
+ MemberDecorate 10(gl_PerVertex) 2 BuiltIn ViewportMaskNV
+ Decorate 10(gl_PerVertex) Block
+ Decorate 16(gl_InvocationID) BuiltIn InvocationId
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeInt 32 1
+ 7: TypeInt 32 0
+ 8: 7(int) Constant 2
+ 9: TypeArray 6(int) 8
+10(gl_PerVertex): TypeStruct 6(int) 6(int) 9
+ 11: 7(int) Constant 4
+ 12: TypeArray 10(gl_PerVertex) 11
+ 13: TypePointer Output 12
+ 14(gl_out): 13(ptr) Variable Output
+ 15: TypePointer Input 6(int)
+16(gl_InvocationID): 15(ptr) Variable Input
+ 18: 6(int) Constant 2
+ 19: 6(int) Constant 0
+ 20: 6(int) Constant 1
+ 21: TypePointer Output 6(int)
+ 4(main): 2 Function None 3
+ 5: Label
+ 17: 6(int) Load 16(gl_InvocationID)
+ 22: 21(ptr) AccessChain 14(gl_out) 17 18 19
+ Store 22 20
+ 23: 6(int) Load 16(gl_InvocationID)
+ 24: 21(ptr) AccessChain 14(gl_out) 23 19
+ Store 24 18
+ Return
+ FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.viewportArray2.vert.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.viewportArray2.vert.out
new file mode 100644
index 00000000000..766685f6978
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/spv.viewportArray2.vert.out
@@ -0,0 +1,48 @@
+spv.viewportArray2.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 19
+
+ Capability Shader
+ Capability Geometry
+ Capability MultiViewport
+ Capability ShaderViewportIndexLayerNV
+ Capability ShaderViewportMaskNV
+ Extension "SPV_NV_viewport_array2"
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Vertex 4 "main" 11 16 18
+ Source GLSL 450
+ SourceExtension "GL_ARB_shader_viewport_layer_array"
+ SourceExtension "GL_NV_viewport_array2"
+ Name 4 "main"
+ Name 11 "gl_ViewportMask"
+ Name 16 "gl_ViewportIndex"
+ Name 18 "gl_Layer"
+ Decorate 11(gl_ViewportMask) BuiltIn ViewportMaskNV
+ Decorate 16(gl_ViewportIndex) BuiltIn ViewportIndex
+ Decorate 18(gl_Layer) BuiltIn Layer
+ Decorate 18(gl_Layer) ViewportRelativeNV
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeInt 32 1
+ 7: TypeInt 32 0
+ 8: 7(int) Constant 1
+ 9: TypeArray 6(int) 8
+ 10: TypePointer Output 9
+11(gl_ViewportMask): 10(ptr) Variable Output
+ 12: 6(int) Constant 0
+ 13: 6(int) Constant 1
+ 14: TypePointer Output 6(int)
+16(gl_ViewportIndex): 14(ptr) Variable Output
+ 17: 6(int) Constant 2
+ 18(gl_Layer): 14(ptr) Variable Output
+ 4(main): 2 Function None 3
+ 5: Label
+ 15: 14(ptr) AccessChain 11(gl_ViewportMask) 12
+ Store 15 13
+ Store 16(gl_ViewportIndex) 17
+ Return
+ FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/tokenLength.vert.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/tokenLength.vert.out
index 11bdd4b5919..f12874b6796 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/tokenLength.vert.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/tokenLength.vert.out
@@ -11,8 +11,6 @@ ERROR: 0:34: '' : octal literal too big
ERROR: 0:35: '' : numeric literal too long
ERROR: 0:35: '' : numeric literal too big
ERROR: 0:36: '' : float literal too long
-ERROR: 0:36: '' : float literal too long
-ERROR: 0:36: '' : float literal too long
WARNING: 0:39: '#extension' : extension not supported: a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhooooooooooooooooooooooooooooooohhhhhhhhhhhhhhhhh01234
ERROR: 0:40: '' : name too long
WARNING: 0:40: '#extension' : extension not supported: a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhooooooooooooooooooooooooooooooohhhhhhhhhhhhhhhhh01234
@@ -29,7 +27,7 @@ ERROR: 0:62: 'preprocessor evaluation' : undefined macro in expression not allow
ERROR: 0:67: '' : numeric literal too long
ERROR: 0:70: '' : name too long
ERROR: 0:70: 'preprocessor evaluation' : undefined macro in expression not allowed in es profile A000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-ERROR: 28 compilation errors. No code generated.
+ERROR: 26 compilation errors. No code generated.
Shader version: 300
@@ -73,7 +71,7 @@ ERROR: node is still EOpNull!
0:23 move second child to first child (temp highp float)
0:23 'E3' (global highp float)
0:23 Constant:
-0:23 12.000000
+0:23 1.012346
0:25 Function Definition: main( (global void)
0:25 Function Parameters:
0:27 Sequence
@@ -104,7 +102,7 @@ ERROR: node is still EOpNull!
0:36 move second child to first child (temp highp float)
0:36 'superF' (global highp float)
0:36 Constant:
-0:36 inf
+0:36 1.012346
0:? Linker Objects
0:? 'BCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789' (in highp float)
0:? 'ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789' (in highp float)
@@ -169,7 +167,7 @@ ERROR: node is still EOpNull!
0:23 move second child to first child (temp highp float)
0:23 'E3' (global highp float)
0:23 Constant:
-0:23 12.000000
+0:23 1.012346
0:25 Function Definition: main( (global void)
0:25 Function Parameters:
0:27 Sequence
@@ -200,7 +198,7 @@ ERROR: node is still EOpNull!
0:36 move second child to first child (temp highp float)
0:36 'superF' (global highp float)
0:36 Constant:
-0:36 inf
+0:36 1.012346
0:? Linker Objects
0:? 'BCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789' (in highp float)
0:? 'ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789' (in highp float)
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/vulkan.ast.vert.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/vulkan.ast.vert.out
index f245585a41b..c07656d1cee 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/vulkan.ast.vert.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/vulkan.ast.vert.out
@@ -269,56 +269,59 @@ Shader version: 450
EntryPoint Vertex 4 "main"
Source GLSL 450
Name 4 "main"
- Decorate 7 SpecId 200
- Decorate 11 SpecId 201
- Decorate 13 SpecId 202
+ Name 7 "scf1"
+ Name 11 "scbt"
+ Name 13 "sci2"
+ Decorate 7(scf1) SpecId 200
+ Decorate 11(scbt) SpecId 201
+ Decorate 13(sci2) SpecId 202
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
- 7: 6(float) SpecConstant 1065353216
+ 7(scf1): 6(float) SpecConstant 1065353216
8: TypeBool
9: 6(float) Constant 0
- 11: 8(bool) SpecConstantTrue
+ 11(scbt): 8(bool) SpecConstantTrue
12: TypeInt 32 1
- 13: 12(int) SpecConstant 2
+ 13(sci2): 12(int) SpecConstant 2
14: TypeInt 32 0
15: 14(int) Constant 0
- 16: 8(bool) SpecConstantOp 171 13 15
+ 16: 8(bool) SpecConstantOp 171 13(sci2) 15
17: 6(float) Constant 1065353216
21: 12(int) Constant 0
22: 12(int) Constant 1
- 23: 12(int) SpecConstantOp 169 11 22 21
- 25: 8(bool) SpecConstantOp 166 11 11
- 26: 12(int) SpecConstantOp 132 13 13
- 30: 8(bool) SpecConstantOp 168 11
- 31: 12(int) SpecConstantOp 126 13
- 33: 8(bool) SpecConstantOp 173 13 13
- 35: 8(bool) SpecConstantOp 165 11 11
- 36: 8(bool) SpecConstantOp 171 13 13
+ 23: 12(int) SpecConstantOp 169 11(scbt) 22 21
+ 25: 8(bool) SpecConstantOp 166 11(scbt) 11(scbt)
+ 26: 12(int) SpecConstantOp 132 13(sci2) 13(sci2)
+ 30: 8(bool) SpecConstantOp 168 11(scbt)
+ 31: 12(int) SpecConstantOp 126 13(sci2)
+ 33: 8(bool) SpecConstantOp 173 13(sci2) 13(sci2)
+ 35: 8(bool) SpecConstantOp 165 11(scbt) 11(scbt)
+ 36: 8(bool) SpecConstantOp 171 13(sci2) 13(sci2)
37: TypeVector 12(int) 2
- 38: 37(ivec2) SpecConstantComposite 13 13
- 39: 37(ivec2) SpecConstantComposite 13 13
- 40: 37(ivec2) SpecConstantComposite 13 13
+ 38: 37(ivec2) SpecConstantComposite 13(sci2) 13(sci2)
+ 39: 37(ivec2) SpecConstantComposite 13(sci2) 13(sci2)
+ 40: 37(ivec2) SpecConstantComposite 13(sci2) 13(sci2)
41: 14(int) Constant 2
42: TypeArray 37(ivec2) 41
44: TypeVector 6(float) 2
48: TypeArray 44(fvec2) 41
4(main): 2 Function None 3
5: Label
- 10: 8(bool) FOrdNotEqual 7 9
- 18: 6(float) Select 11 17 9
- 19: 6(float) ConvertSToF 13
- 20: 12(int) ConvertFToS 7
- 24: 6(float) FMul 7 7
- 27: 6(float) ConvertSToF 13
- 28: 6(float) FAdd 7 27
- 29: 6(float) FNegate 7
- 32: 8(bool) FOrdGreaterThan 7 7
- 34: 8(bool) FOrdNotEqual 7 7
+ 10: 8(bool) FOrdNotEqual 7(scf1) 9
+ 18: 6(float) Select 11(scbt) 17 9
+ 19: 6(float) ConvertSToF 13(sci2)
+ 20: 12(int) ConvertFToS 7(scf1)
+ 24: 6(float) FMul 7(scf1) 7(scf1)
+ 27: 6(float) ConvertSToF 13(sci2)
+ 28: 6(float) FAdd 7(scf1) 27
+ 29: 6(float) FNegate 7(scf1)
+ 32: 8(bool) FOrdGreaterThan 7(scf1) 7(scf1)
+ 34: 8(bool) FOrdNotEqual 7(scf1) 7(scf1)
43: 42 CompositeConstruct 39 40
- 45: 44(fvec2) CompositeConstruct 7 7
- 46: 44(fvec2) CompositeConstruct 7 7
- 47: 44(fvec2) CompositeConstruct 7 7
+ 45: 44(fvec2) CompositeConstruct 7(scf1) 7(scf1)
+ 46: 44(fvec2) CompositeConstruct 7(scf1) 7(scf1)
+ 47: 44(fvec2) CompositeConstruct 7(scf1) 7(scf1)
49: 48 CompositeConstruct 46 47
Return
FunctionEnd
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/vulkan.frag.out b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/vulkan.frag.out
index 1df2c3eb530..0e3057ebaf2 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/vulkan.frag.out
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/baseResults/vulkan.frag.out
@@ -40,7 +40,8 @@ ERROR: 0:92: 'call argument' : sampler constructor must appear at point of use
ERROR: 0:93: ',' : sampler constructor must appear at point of use
ERROR: 0:94: ':' : wrong operand types: no operation ':' exists that takes a left-hand operand of type 'temp sampler2D' and a right operand of type 'temp sampler2D' (or there is no acceptable conversion)
ERROR: 0:94: 'call argument' : sampler constructor must appear at point of use
-ERROR: 38 compilation errors. No code generated.
+ERROR: 0:96: 'gl_NumSamples' : undeclared identifier
+ERROR: 39 compilation errors. No code generated.
ERROR: Linking fragment stage: Only one push_constant block is allowed per stage
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/cppBad2.vert b/3rdparty/bgfx/3rdparty/glslang/Test/cppBad2.vert
new file mode 100644
index 00000000000..5e61b49ef35
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/cppBad2.vert
@@ -0,0 +1,3 @@
+#define a b(
+#define b(x)
+b(a) \ No newline at end of file
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.basic.comp b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.basic.comp
index 8a65a59616f..1d95239ed8f 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.basic.comp
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.basic.comp
@@ -1,6 +1,6 @@
groupshared float4 a[100];
-void main(int dti : SV_DispatchThreadID)
+void main(int dti : SV_DispatchThreadID, int gti : SV_GroupThreadID)
{
- dti;
+ dti - gti;
}
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.flatten.return.frag b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.flatten.return.frag
index c633e679882..4aa3f501924 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.flatten.return.frag
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.flatten.return.frag
@@ -9,7 +9,7 @@ struct PS_OUTPUT
PS_OUTPUT Func1()
{
- return PS_OUTPUT(float4(1), 2, 3, 4);
+ return PS_OUTPUT(float4(1,1,1,1), 2, 3, 4);
}
PS_OUTPUT main()
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.init.frag b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.init.frag
index a3f6f0e79d5..8caf3c7d94e 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.init.frag
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.init.frag
@@ -34,3 +34,8 @@ float4 ShaderFunction(float4 input) : COLOR0
return input * a1;
}
+
+cbuffer Constants
+{
+ float a = 1.0f, b, c = 2.0f;
+};
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.init2.frag b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.init2.frag
index 789f1a06553..2b9b7e688c2 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.init2.frag
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.init2.frag
@@ -18,6 +18,25 @@ void Test1()
struct mystruct2 { float a; float b; float c; };
mystruct2 test5 = { {8,}, {9,}, {10}, };
+ const mystruct2 constTest5 = { {8,}, {9,}, {10}, };
+ constTest5.c;
+
+ const float step = 1.f;
+ float n = 0;
+ const float3 a[8] = {
+ normalize(float3(1, 1, 1)) * (n += step),
+ normalize(float3(-1, -1, -1)) * (n += step),
+ normalize(float3(-1, -1, 1)) * (n += step),
+ normalize(float3(-1, 1, -1)) * (n += step),
+ normalize(float3(-1, 1, 1)) * (n += step),
+ normalize(float3(1, -1, -1)) * (n += step),
+ normalize(float3(1, -1, 1)) * (n += step),
+ normalize(float3(1, 1, -1)) * (n += step) };
+
+ const struct one { float3 a; } oneNonConst = { normalize(float3(-1, 1, 1)) * (n += step) };
+ const struct two { float3 a;
+ float3 b; } twoNonConst = { normalize(float3(-1, 1, 1)) * (n += step),
+ normalize(float3(-1, 1, 1)) * (n += step) };
}
struct PS_OUTPUT { float4 color : SV_Target0; };
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.intrinsics.d3dcolortoubyte4.frag b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.intrinsics.d3dcolortoubyte4.frag
new file mode 100644
index 00000000000..295374fb784
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.intrinsics.d3dcolortoubyte4.frag
@@ -0,0 +1,7 @@
+
+uniform float4 col4;
+
+int4 main() : SV_Target0
+{
+ return D3DCOLORtoUBYTE4(col4);
+}
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.matrixSwizzle.vert b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.matrixSwizzle.vert
new file mode 100644
index 00000000000..c06996b31f6
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.matrixSwizzle.vert
@@ -0,0 +1,33 @@
+void ShaderFunction(float inf) : COLOR0
+{
+ float3x4 m;
+
+ // tests that convert to non-matrix swizzles
+
+ m._34 = 1.0; // AST should have a normal component select
+ m._m23 = 2.0; // same code
+ m[2][3] = 2.0; // same code
+
+ m._11_12_13_14 = float4(3.0); // AST should have normal column selection (first row)
+ m._m10_m11_m12_m13 = float4(3.0); // AST should have normal column selection (second row)
+ m[1] = float4(3.0); // same code
+
+ // tests that stay as matrix swizzles
+
+ float3 f3;
+ m._11_22_23 = f3;
+ m._21_12_31 = float3(5.0);
+ m._11_12_21 = 2 * f3;
+
+ // r-value
+ f3 = m._21_12_31;
+}
+
+float3x3 createMat3x3(float3 a, float3 b, float3 c)
+{
+ float3x3 m;
+ m._11_21_31 = a;
+ m._12_22_32 = b;
+ m._13_23_33 = c;
+ return m;
+}
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.params.default.frag b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.params.default.frag
new file mode 100644
index 00000000000..42ad84f845d
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.params.default.frag
@@ -0,0 +1,51 @@
+uniform int4 ui4;
+
+static const int cia = -4;
+static const int cib = -42;
+
+// ERROR: Ambiguous with fn1 below.
+// int4 fn1(int4 p0) { return int4(1,2,3,4); }
+
+int4 fn1(int4 p0, bool b1, bool b2 = false) {
+ return p0;
+}
+
+int4 fn1(int4 p0,
+ int4 p1 : FOO = int4(-1,-2,-3, cia),
+ int p2[2] : BAR = { int(1), 2 },
+ int p3 = abs(cib) )
+{
+ return p0 + p1 + p2[0] + p3;
+}
+
+// These should not be ambiguous if given either an int or a float explicit second parameter.
+int4 fn2(int4 p0, int x = 3)
+{
+ return int4(10,11,12,13);
+}
+
+int4 fn2(int4 p0, float x = sin(3.3)) // OK to have a const expression as a default value
+{
+ return p0 + int4(20,21,22,23);
+}
+
+void fn3(int p0 = 3) { }
+
+
+int4 main() : SV_Target0
+{
+ int myarray[2] = {30,31};
+
+ fn3();
+ fn3(5);
+
+ return fn1(100) +
+ fn1(101, ui4) +
+ fn1(102, ui4, myarray) +
+ fn1(103, ui4, myarray, 99) +
+ fn1(104, false) +
+ fn1(105, false, true) +
+
+ fn2(110, 11.11) + // calls int4, float form
+ fn2(111, 12); // calls int4, int form
+}
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.params.default.negative.frag b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.params.default.negative.frag
new file mode 100644
index 00000000000..c9ff330b5c7
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.params.default.negative.frag
@@ -0,0 +1,50 @@
+uniform int4 ui4;
+uniform float ufvar;
+
+static const int cia = -4;
+static const int cib = -42;
+
+int4 fn1(int4 p0) { return int4(1,2,3,4); }
+
+int4 fn1(int4 p0, bool b1, bool b2 = false) {
+ return p0;
+}
+
+int4 fn1(int4 p0,
+ int4 p1 : FOO = int4(-1,-2,-3, cia),
+ int p2[2] : BAR = { int(1), 2 },
+ int p3 = abs(cib) )
+{
+ return p0 + p1 + p2[0] + p3;
+}
+
+// These should not be ambiguous if given either an int or a float explicit second parameter.
+int4 fn2(int4 p0, int x = 3)
+{
+ return int4(10,11,12,13);
+}
+
+int4 fn2(int4 p0, float x = ufvar) // ERROR: non-const expression
+{
+ return p0 + int4(20,21,22,23);
+}
+
+void fn3(int p0 = 5, int p1) // ERROR no-default param after default param
+{
+}
+
+int4 main() : SV_Target0
+{
+ int myarray[2] = {30,31};
+
+ return fn1(100) + // ERROR: ambiguous
+ fn1(101, ui4) +
+ fn1(102, ui4, myarray) +
+ fn1(103, ui4, myarray, 99) +
+ fn1(104, false) +
+ fn1(105, false, true) +
+
+ fn2(112) + // ERROR: ambiguous
+ fn2(110, 11.11) + // calls int4, float form
+ fn2(111, 12); // calls int4, int form
+}
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.partialInit.frag b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.partialInit.frag
index 59e8a529cad..01aee8e60b5 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.partialInit.frag
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.partialInit.frag
@@ -25,5 +25,12 @@ outs PixelShaderFunction(float4 input) : COLOR0
o4.c = o1.c;
Nest nest = (Nest)0;
+ float2 gf2a[4] = { };
+ int cgi = { };
+ o4.b = gf2a[2].y * cgi;
+
return o4;
-} \ No newline at end of file
+}
+
+static const float2 cgf2a[3];
+static const int ci;
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.pp.tokenpasting.frag b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.pp.tokenpasting.frag
new file mode 100644
index 00000000000..5415670fe02
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.pp.tokenpasting.frag
@@ -0,0 +1,18 @@
+
+#define foobarblee zzzz
+
+#define ar qqqq
+
+#define MACRO1(x,y) foo##x##y
+// #define MACRO2 abc##def
+
+// #define SPACE_IN_MACRO int var1
+
+float4 main() : SV_Target0
+{
+ // float MACRO2 = 10;
+ float MACRO1(b##ar,blee) = 3;
+
+ return float4(foobarblee,0,0,0);
+}
+
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.rw.swizzle.frag b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.rw.swizzle.frag
new file mode 100644
index 00000000000..356ed73dd3e
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.rw.swizzle.frag
@@ -0,0 +1,28 @@
+RWTexture2D<float3> rwtx;
+RWBuffer<float3> buf;
+
+float3 SomeValue() { return float3(1,2,3); }
+
+float4 main() : SV_Target0
+{
+ int2 tc2 = { 0, 0 };
+ int tc = 0;
+
+ // Test swizzles and partial updates of L-values when writing to buffers and writable textures.
+ rwtx[tc2].zyx = float3(1,2,3); // full swizzle, simple RHS
+ rwtx[tc2].zyx = SomeValue(); // full swizzle, complex RHS
+ rwtx[tc2].zyx = 2; // full swizzle, modify op
+
+ // Partial updates not yet supported.
+ // Partial values, which will use swizzles.
+ // buf[tc].yz = 42; // partial swizzle, simple RHS
+ // buf[tc].yz = SomeValue().x; // partial swizzle, complex RHS
+ // buf[tc].yz += 43; // partial swizzle, modify op
+
+ // // Partial values, which will use index.
+ // buf[tc].y = 44; // single index, simple RHS
+ // buf[tc].y = SomeValue().x; // single index, complex RHS
+ // buf[tc].y += 45; // single index, modify op
+
+ return 0.0;
+}
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split-1.vert b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split-1.vert
new file mode 100644
index 00000000000..ce5f51f9214
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split-1.vert
@@ -0,0 +1,25 @@
+
+struct VS_INPUT
+{
+ int x0_in : foo0;
+ float4 Pos_in : SV_Position;
+ int x1_in : foo1;
+};
+
+struct VS_OUTPUT
+{
+ int x0_out : foo0;
+ float4 Pos_out : SV_Position;
+ int x1_out : foo1;
+};
+
+VS_OUTPUT main(VS_INPUT vsin, float4 Pos_loose : SV_Position)
+{
+ VS_OUTPUT vsout;
+
+ vsout.x0_out = vsin.x0_in;
+ vsout.Pos_out = vsin.Pos_in + Pos_loose;
+ vsout.x1_out = vsin.x1_in;
+
+ return vsout;
+}
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split.array.geom b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split.array.geom
new file mode 100644
index 00000000000..9008df1685b
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split.array.geom
@@ -0,0 +1,21 @@
+struct PSInput
+{
+ float4 Pos : SV_POSITION;
+ float2 TexCoord : TEXCOORD;
+ float3 TerrainPos : TERRAINPOS;
+ uint VertexID : VertexID;
+};
+
+typedef PSInput foo_t[2][3];
+
+[maxvertexcount(4)]
+void main(point uint v[1] : VertexID, inout TriangleStream<PSInput> OutputStream)
+{
+ foo_t Verts;
+
+ PSInput Out = (PSInput) 0;
+
+ for (int x=0; x<2; ++x)
+ for (int y=0; y<2; ++y)
+ Verts[x][y] = Out;
+}
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split.assign.frag b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split.assign.frag
new file mode 100644
index 00000000000..e7fe028870c
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split.assign.frag
@@ -0,0 +1,12 @@
+struct S {
+ float f;
+ float4 pos : SV_Position;
+};
+
+float4 main(int i, S input[3]) : COLOR0
+{
+ S a[3];
+ input = a;
+
+ return float3(1.0);
+}
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split.call.vert b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split.call.vert
new file mode 100644
index 00000000000..543adebb36e
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split.call.vert
@@ -0,0 +1,32 @@
+// Test passing split structs to functions.
+
+struct VS_INPUT
+{
+ int x0_in : foo0;
+ float4 Pos_in : SV_Position;
+ int x1_in : foo1;
+};
+
+struct VS_OUTPUT
+{
+ int x0_out : foo0;
+ float4 Pos_out : SV_Position;
+ int x1_out : foo1;
+};
+
+void Fn1(VS_INPUT fn1_in, VS_OUTPUT fn1_out) {
+ fn1_in.Pos_in + fn1_out.Pos_out;
+}
+
+VS_OUTPUT main(VS_INPUT vsin)
+{
+ VS_OUTPUT vsout;
+
+ vsout.x0_out = vsin.x0_in;
+ vsout.Pos_out = vsin.Pos_in;
+ vsout.x1_out = vsin.x1_in;
+
+ Fn1(vsin, vsout);
+
+ return vsout;
+}
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split.nested.geom b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split.nested.geom
new file mode 100644
index 00000000000..03bf38f3e28
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split.nested.geom
@@ -0,0 +1,31 @@
+
+struct STRUCT_WITH_NO_BUILTIN_INTERSTAGE_IO
+{
+ float m0_array[2];
+ int m1;
+};
+
+struct PS_IN
+{
+ float4 pos : SV_Position;
+ float2 tc : TEXCOORD0;
+ // float c : SV_ClipDistance0;
+};
+
+struct GS_OUT
+{
+ PS_IN psIn;
+ STRUCT_WITH_NO_BUILTIN_INTERSTAGE_IO contains_no_builtin_io;
+};
+
+
+[maxvertexcount(3)]
+void main(triangle PS_IN tin[3], inout TriangleStream <GS_OUT> ts )
+{
+ GS_OUT o;
+
+ o.psIn.pos = float4(1,2,3,4);
+ o.psIn.tc = float2(5,6);
+
+ ts.Append(o);
+}
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split.trivial.geom b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split.trivial.geom
new file mode 100644
index 00000000000..343da38e1ce
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split.trivial.geom
@@ -0,0 +1,21 @@
+
+struct PS_IN
+{
+ float4 pos : SV_Position;
+};
+
+struct GS_OUT
+{
+ float4 pos : SV_Position;
+};
+
+[maxvertexcount(3)]
+void main(triangle PS_IN i[3], inout TriangleStream <GS_OUT> ts)
+{
+ GS_OUT o;
+
+ for (int x=0; x<3; ++x) {
+ o.pos = i[x].pos;
+ ts.Append(o);
+ }
+}
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split.trivial.vert b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split.trivial.vert
new file mode 100644
index 00000000000..351e4182aeb
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.struct.split.trivial.vert
@@ -0,0 +1,22 @@
+
+// Test trivial case for structure splitting: the IN and OUT structs have ONLY an interstage IO.
+// This should fall back to flattening, and not produce any empty structures.
+
+struct VS_INPUT
+{
+ float4 Pos_in : SV_Position;
+};
+
+struct VS_OUTPUT
+{
+ float4 Pos : SV_Position;
+};
+
+VS_OUTPUT main(VS_INPUT vsin, float4 Pos_loose : SV_Position)
+{
+ VS_OUTPUT vsout;
+
+ vsout.Pos = vsin.Pos_in + Pos_loose;
+
+ return vsout;
+}
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.structarray.flatten.geom b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.structarray.flatten.geom
index 1b05dc11d28..990532d32e0 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.structarray.flatten.geom
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.structarray.flatten.geom
@@ -1,17 +1,23 @@
struct VertexData {
- float4 position : POSITION;
- float4 color : COLOR0;
- float2 uv : TEXCOORD0;
+ float4 position : POSITION;
+ float4 color : COLOR0;
+ float2 uv : TEXCOORD0;
+};
+
+struct PS_IN {
+ float4 position : SV_POSITION;
+ float4 color : COLOR0;
+ float2 uv : TEXCOORD0;
};
[maxvertexcount(4)]
-void main(line VertexData vin[2], inout TriangleStream<VertexData> outStream)
+void main(line VertexData vin[2], inout TriangleStream<PS_IN> outStream)
{
- VertexData vout;
+ PS_IN vout;
- vout.color = vin[0].color;
- vout.uv = vin[0].uv;
- vout.position = vin[0].position;
+ vout.color = vin[1].color;
+ vout.uv = vin[1].uv;
+ vout.position = vin[1].position;
outStream.Append(vout);
}
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.type.half.frag b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.type.half.frag
new file mode 100644
index 00000000000..f082039d296
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.type.half.frag
@@ -0,0 +1,11 @@
+
+float4 main() : SV_Target0
+{
+ half h0 = 0;
+ half1 h1 = 1;
+ half2 h2 = 2;
+ half3 h3 = 3;
+ half4 h4 = 4;
+
+ return 0.0;
+}
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.type.identifier.frag b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.type.identifier.frag
new file mode 100644
index 00000000000..25ba45739f6
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/hlsl.type.identifier.frag
@@ -0,0 +1,28 @@
+
+struct foo_t {
+ float float;
+};
+
+float fn(float float) { return float; }
+
+float4 main() : SV_Target0
+{
+ float float = 7;
+ bool bool[2] = { float, float };
+ int int = bool[1];
+ uint uint = float + int;
+ min16float min16float = uint;
+ min10float min10float = min16float;
+ half half = 0.5;
+
+ {
+ foo_t float;
+ float.float = 42;
+ }
+
+ bool[0] = bool[1];
+
+ float = float + int + uint + min16float + min10float + (bool[0] ? int : float) + fn(float);
+
+ return float;
+}
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/link1.vk.frag b/3rdparty/bgfx/3rdparty/glslang/Test/link1.vk.frag
new file mode 100644
index 00000000000..443a32052c1
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/link1.vk.frag
@@ -0,0 +1,10 @@
+#version 450
+
+vec4 getColor();
+
+out vec4 color;
+
+void main()
+{
+ color = getColor();
+}
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/link2.vk.frag b/3rdparty/bgfx/3rdparty/glslang/Test/link2.vk.frag
new file mode 100644
index 00000000000..b1630cb58e9
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/link2.vk.frag
@@ -0,0 +1,8 @@
+#version 450
+
+uniform sampler2D s2D;
+
+vec4 getColor()
+{
+ return texture(s2D, vec2(0.5));
+}
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/preprocessor.include.disabled.vert b/3rdparty/bgfx/3rdparty/glslang/Test/preprocessor.include.disabled.vert
index 130d928e52d..865baa189d8 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/preprocessor.include.disabled.vert
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/preprocessor.include.disabled.vert
@@ -3,5 +3,4 @@
#include 123
#include "foo"
#include "foo" garbage
-#include "no-eol"
-
+#include "no-eol" \ No newline at end of file
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/preprocessor.include.enabled.vert b/3rdparty/bgfx/3rdparty/glslang/Test/preprocessor.include.enabled.vert
index ecdf466e1b2..985eae2ce51 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/preprocessor.include.enabled.vert
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/preprocessor.include.enabled.vert
@@ -2,6 +2,19 @@
#line 8000
#include
#include 123
-#include "foo"
-#include "foo" garbage
-#include "no-eol"
+#include "foo.oeu"
+#include "foo.oeu/ao eu/ao.h"
+#include "foo<oeu"
+#include "foo.oe>"
+#include <foo.oe>
+#include <foo"bar">
+#include <foo\bar>
+#include "foo.oe>"
+#include <foo>
+#include "foo2.h" garbage
+#include <foo.h> garbage
+// max length
+#include <ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789>
+// too long
+#include <ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF01234567890>
+#include "no-eol" \ No newline at end of file
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/spv.shaderBallotAMD.comp b/3rdparty/bgfx/3rdparty/glslang/Test/spv.shaderBallotAMD.comp
new file mode 100644
index 00000000000..d6d370aea72
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/spv.shaderBallotAMD.comp
@@ -0,0 +1,165 @@
+#version 450
+
+#extension GL_ARB_gpu_shader_int64: enable
+#extension GL_AMD_gpu_shader_half_float: enable
+#extension GL_AMD_shader_ballot: enable
+
+layout (local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
+
+layout(binding = 0) buffer Buffers
+{
+ int i;
+ uvec2 uv;
+ vec3 fv;
+ dvec4 dv;
+ int64_t i64;
+ u64vec2 u64v;
+ f16vec3 f16v;
+};
+
+void main()
+{
+ i = minInvocationsAMD(i);
+ uv = minInvocationsAMD(uv);
+ fv = minInvocationsAMD(fv);
+ dv = minInvocationsAMD(dv);
+ i64 = minInvocationsAMD(i64);
+ u64v = minInvocationsAMD(u64v);
+ f16v = minInvocationsAMD(f16v);
+
+ i = maxInvocationsAMD(i);
+ uv = maxInvocationsAMD(uv);
+ fv = maxInvocationsAMD(fv);
+ dv = maxInvocationsAMD(dv);
+ i64 = maxInvocationsAMD(i64);
+ u64v = maxInvocationsAMD(u64v);
+ f16v = maxInvocationsAMD(f16v);
+
+ i = addInvocationsAMD(i);
+ uv = addInvocationsAMD(uv);
+ fv = addInvocationsAMD(fv);
+ dv = addInvocationsAMD(dv);
+ i64 = addInvocationsAMD(i64);
+ u64v = addInvocationsAMD(u64v);
+ f16v = addInvocationsAMD(f16v);
+
+ i = minInvocationsNonUniformAMD(i);
+ uv = minInvocationsNonUniformAMD(uv);
+ fv = minInvocationsNonUniformAMD(fv);
+ dv = minInvocationsNonUniformAMD(dv);
+ i64 = minInvocationsNonUniformAMD(i64);
+ u64v = minInvocationsNonUniformAMD(u64v);
+ f16v = minInvocationsNonUniformAMD(f16v);
+
+ i = maxInvocationsNonUniformAMD(i);
+ uv = maxInvocationsNonUniformAMD(uv);
+ fv = maxInvocationsNonUniformAMD(fv);
+ dv = maxInvocationsNonUniformAMD(dv);
+ i64 = maxInvocationsNonUniformAMD(i64);
+ u64v = maxInvocationsNonUniformAMD(u64v);
+ f16v = maxInvocationsNonUniformAMD(f16v);
+
+ i = addInvocationsNonUniformAMD(i);
+ uv = addInvocationsNonUniformAMD(uv);
+ fv = addInvocationsNonUniformAMD(fv);
+ dv = addInvocationsNonUniformAMD(dv);
+ i64 = addInvocationsNonUniformAMD(i64);
+ u64v = addInvocationsNonUniformAMD(u64v);
+ f16v = addInvocationsNonUniformAMD(f16v);
+
+ i = minInvocationsInclusiveScanAMD(i);
+ uv = minInvocationsInclusiveScanAMD(uv);
+ fv = minInvocationsInclusiveScanAMD(fv);
+ dv = minInvocationsInclusiveScanAMD(dv);
+ i64 = minInvocationsInclusiveScanAMD(i64);
+ u64v = minInvocationsInclusiveScanAMD(u64v);
+ f16v = minInvocationsInclusiveScanAMD(f16v);
+
+ i = maxInvocationsInclusiveScanAMD(i);
+ uv = maxInvocationsInclusiveScanAMD(uv);
+ fv = maxInvocationsInclusiveScanAMD(fv);
+ dv = maxInvocationsInclusiveScanAMD(dv);
+ i64 = maxInvocationsInclusiveScanAMD(i64);
+ u64v = maxInvocationsInclusiveScanAMD(u64v);
+ f16v = maxInvocationsInclusiveScanAMD(f16v);
+
+ i = addInvocationsInclusiveScanAMD(i);
+ uv = addInvocationsInclusiveScanAMD(uv);
+ fv = addInvocationsInclusiveScanAMD(fv);
+ dv = addInvocationsInclusiveScanAMD(dv);
+ i64 = addInvocationsInclusiveScanAMD(i64);
+ u64v = addInvocationsInclusiveScanAMD(u64v);
+ f16v = addInvocationsInclusiveScanAMD(f16v);
+
+ i = minInvocationsExclusiveScanAMD(i);
+ uv = minInvocationsExclusiveScanAMD(uv);
+ fv = minInvocationsExclusiveScanAMD(fv);
+ dv = minInvocationsExclusiveScanAMD(dv);
+ i64 = minInvocationsExclusiveScanAMD(i64);
+ u64v = minInvocationsExclusiveScanAMD(u64v);
+ f16v = minInvocationsExclusiveScanAMD(f16v);
+
+ i = maxInvocationsExclusiveScanAMD(i);
+ uv = maxInvocationsExclusiveScanAMD(uv);
+ fv = maxInvocationsExclusiveScanAMD(fv);
+ dv = maxInvocationsExclusiveScanAMD(dv);
+ i64 = maxInvocationsExclusiveScanAMD(i64);
+ u64v = maxInvocationsExclusiveScanAMD(u64v);
+ f16v = maxInvocationsExclusiveScanAMD(f16v);
+
+ i = addInvocationsExclusiveScanAMD(i);
+ uv = addInvocationsExclusiveScanAMD(uv);
+ fv = addInvocationsExclusiveScanAMD(fv);
+ dv = addInvocationsExclusiveScanAMD(dv);
+ i64 = addInvocationsExclusiveScanAMD(i64);
+ u64v = addInvocationsExclusiveScanAMD(u64v);
+ f16v = addInvocationsExclusiveScanAMD(f16v);
+
+ i = minInvocationsInclusiveScanNonUniformAMD(i);
+ uv = minInvocationsInclusiveScanNonUniformAMD(uv);
+ fv = minInvocationsInclusiveScanNonUniformAMD(fv);
+ dv = minInvocationsInclusiveScanNonUniformAMD(dv);
+ i64 = minInvocationsInclusiveScanNonUniformAMD(i64);
+ u64v = minInvocationsInclusiveScanNonUniformAMD(u64v);
+ f16v = minInvocationsInclusiveScanNonUniformAMD(f16v);
+
+ i = maxInvocationsInclusiveScanNonUniformAMD(i);
+ uv = maxInvocationsInclusiveScanNonUniformAMD(uv);
+ fv = maxInvocationsInclusiveScanNonUniformAMD(fv);
+ dv = maxInvocationsInclusiveScanNonUniformAMD(dv);
+ i64 = maxInvocationsInclusiveScanNonUniformAMD(i64);
+ u64v = maxInvocationsInclusiveScanNonUniformAMD(u64v);
+ f16v = maxInvocationsInclusiveScanNonUniformAMD(f16v);
+
+ i = addInvocationsInclusiveScanNonUniformAMD(i);
+ uv = addInvocationsInclusiveScanNonUniformAMD(uv);
+ fv = addInvocationsInclusiveScanNonUniformAMD(fv);
+ dv = addInvocationsInclusiveScanNonUniformAMD(dv);
+ i64 = addInvocationsInclusiveScanNonUniformAMD(i64);
+ u64v = addInvocationsInclusiveScanNonUniformAMD(u64v);
+ f16v = addInvocationsInclusiveScanNonUniformAMD(f16v);
+
+ i = minInvocationsExclusiveScanNonUniformAMD(i);
+ uv = minInvocationsExclusiveScanNonUniformAMD(uv);
+ fv = minInvocationsExclusiveScanNonUniformAMD(fv);
+ dv = minInvocationsExclusiveScanNonUniformAMD(dv);
+ i64 = minInvocationsExclusiveScanNonUniformAMD(i64);
+ u64v = minInvocationsExclusiveScanNonUniformAMD(u64v);
+ f16v = minInvocationsExclusiveScanNonUniformAMD(f16v);
+
+ i = maxInvocationsExclusiveScanNonUniformAMD(i);
+ uv = maxInvocationsExclusiveScanNonUniformAMD(uv);
+ fv = maxInvocationsExclusiveScanNonUniformAMD(fv);
+ dv = maxInvocationsExclusiveScanNonUniformAMD(dv);
+ i64 = maxInvocationsExclusiveScanNonUniformAMD(i64);
+ u64v = maxInvocationsExclusiveScanNonUniformAMD(u64v);
+ f16v = maxInvocationsExclusiveScanNonUniformAMD(f16v);
+
+ i = addInvocationsExclusiveScanNonUniformAMD(i);
+ uv = addInvocationsExclusiveScanNonUniformAMD(uv);
+ fv = addInvocationsExclusiveScanNonUniformAMD(fv);
+ dv = addInvocationsExclusiveScanNonUniformAMD(dv);
+ i64 = addInvocationsExclusiveScanNonUniformAMD(i64);
+ u64v = addInvocationsExclusiveScanNonUniformAMD(u64v);
+ f16v = addInvocationsExclusiveScanNonUniformAMD(f16v);
+}
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/spv.stereoViewRendering.tesc b/3rdparty/bgfx/3rdparty/glslang/Test/spv.stereoViewRendering.tesc
new file mode 100644
index 00000000000..62fc956be5d
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/spv.stereoViewRendering.tesc
@@ -0,0 +1,18 @@
+#version 450
+
+#extension GL_NV_viewport_array2 :require
+#extension GL_NV_stereo_view_rendering : require
+
+layout(vertices = 4) out;
+
+out gl_PerVertex {
+ int gl_SecondaryViewportMaskNV[2];
+ vec4 gl_SecondaryPositionNV;
+ layout (viewport_relative, secondary_view_offset = 1) out highp int gl_Layer;
+} gl_out[4];
+
+void main()
+{
+ gl_out[gl_InvocationID].gl_SecondaryViewportMaskNV[0] = 1;
+ gl_out[gl_InvocationID].gl_SecondaryPositionNV = gl_in[1].gl_Position;
+}
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/spv.stereoViewRendering.vert b/3rdparty/bgfx/3rdparty/glslang/Test/spv.stereoViewRendering.vert
new file mode 100644
index 00000000000..fc7d52e2486
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/spv.stereoViewRendering.vert
@@ -0,0 +1,12 @@
+#version 450
+
+#extension GL_NV_viewport_array2 :require
+#extension GL_NV_stereo_view_rendering : require
+
+layout (viewport_relative, secondary_view_offset = 2) out highp int gl_Layer;
+void main()
+{
+ gl_SecondaryViewportMaskNV[0] = 1;
+ gl_SecondaryPositionNV = gl_Position;
+}
+
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/spv.viewportArray2.tesc b/3rdparty/bgfx/3rdparty/glslang/Test/spv.viewportArray2.tesc
new file mode 100644
index 00000000000..f629b438ca1
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/spv.viewportArray2.tesc
@@ -0,0 +1,16 @@
+#version 450
+#extension GL_NV_viewport_array2 :require
+
+layout(vertices = 4) out;
+
+out gl_PerVertex {
+ int gl_ViewportMask[2];
+ int gl_ViewportIndex;
+ layout (viewport_relative) out highp int gl_Layer;
+} gl_out[4];
+
+void main()
+{
+ gl_out[gl_InvocationID].gl_ViewportMask[0] = 1;
+ gl_out[gl_InvocationID].gl_ViewportIndex = 2;
+}
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/spv.viewportArray2.vert b/3rdparty/bgfx/3rdparty/glslang/Test/spv.viewportArray2.vert
new file mode 100644
index 00000000000..a373d5e891b
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/spv.viewportArray2.vert
@@ -0,0 +1,10 @@
+#version 450
+#extension GL_ARB_shader_viewport_layer_array : require
+#extension GL_NV_viewport_array2 : require
+
+layout (viewport_relative) out highp int gl_Layer;
+void main()
+{
+ gl_ViewportMask[0] = 1;
+ gl_ViewportIndex = 2;
+} \ No newline at end of file
diff --git a/3rdparty/bgfx/3rdparty/glslang/Test/vulkan.frag b/3rdparty/bgfx/3rdparty/glslang/Test/vulkan.frag
index fd9106cda30..16baf8624d7 100644
--- a/3rdparty/bgfx/3rdparty/glslang/Test/vulkan.frag
+++ b/3rdparty/bgfx/3rdparty/glslang/Test/vulkan.frag
@@ -92,4 +92,6 @@ void callUserTexture()
userTexture((sampler2D(t2d,s)), vTexCoord); // ERROR, not point of use
userTexture((sampler2D(t2d,s), sampler2D(t2d,s)), vTexCoord); // ERROR, not point of use
userTexture(cond ? sampler2D(t2d,s) : sampler2D(t2d,s), vTexCoord); // ERROR, no ?:, not point of use
+
+ gl_NumSamples; // ERROR, not for Vulkan
}
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/CMakeLists.txt b/3rdparty/bgfx/3rdparty/glslang/glslang/CMakeLists.txt
index 95d4bdd8fcd..dac8cb89210 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/CMakeLists.txt
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/CMakeLists.txt
@@ -82,6 +82,10 @@ set(HEADERS
add_library(glslang STATIC ${BISON_GLSLParser_OUTPUT_SOURCE} ${SOURCES} ${HEADERS})
set_property(TARGET glslang PROPERTY FOLDER glslang)
+target_link_libraries(glslang OGLCompiler OSDependent)
+if(ENABLE_HLSL)
+ target_link_libraries(glslang HLSL)
+endif()
if(WIN32)
source_group("Public" REGULAR_EXPRESSION "Public/*")
@@ -93,3 +97,8 @@ endif(WIN32)
install(TARGETS glslang
ARCHIVE DESTINATION lib)
+
+foreach(file ${HEADERS})
+ get_filename_component(dir ${file} DIRECTORY)
+ install(FILES ${file} DESTINATION include/glslang/${dir})
+endforeach()
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/GenericCodeGen/CodeGen.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/GenericCodeGen/CodeGen.cpp
index dc78342ac96..b3c7226dfa4 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/GenericCodeGen/CodeGen.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/GenericCodeGen/CodeGen.cpp
@@ -1,10 +1,10 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -18,18 +18,18 @@
// 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.
+// 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 "../Include/Common.h"
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/GenericCodeGen/Link.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/GenericCodeGen/Link.cpp
index 8da88bda799..c38db0f69fb 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/GenericCodeGen/Link.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/GenericCodeGen/Link.cpp
@@ -1,10 +1,10 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -18,18 +18,18 @@
// 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.
+// 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.
//
//
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/BaseTypes.h b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/BaseTypes.h
index f7074406721..449e3aeacf8 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/BaseTypes.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/BaseTypes.h
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2012-2013 LunarG, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2012-2013 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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.
//
#ifndef _BASICTYPES_INCLUDED_
@@ -84,7 +84,7 @@ enum TStorageQualifier {
EvqUniform, // read only, shared with app
EvqBuffer, // read/write, shared with app
EvqShared, // compute shader's read/write 'shared' qualifier
-
+
// parameters
EvqIn, // also, for 'in' in the grammar before we know if it's a pipeline input or an 'in' parameter
EvqOut, // also, for 'out' in the grammar before we know if it's a pipeline output or an 'out' parameter
@@ -203,6 +203,11 @@ enum TBuiltInVariable {
EbvBaryCoordPullModel,
#endif
+#ifdef NV_EXTENSIONS
+ EbvViewportMaskNV,
+ EbvSecondaryPositionNV,
+ EbvSecondaryViewportMaskNV,
+#endif
// HLSL built-ins that live only temporarily, until they get remapped
// to one of the above.
EbvFragDepthGreater,
@@ -212,7 +217,7 @@ enum TBuiltInVariable {
};
// These will show up in error messages
-__inline const char* GetStorageQualifierString(TStorageQualifier q)
+__inline const char* GetStorageQualifierString(TStorageQualifier q)
{
switch (q) {
case EvqTemporary: return "temp"; break;
@@ -316,6 +321,11 @@ __inline const char* GetBuiltInVariableString(TBuiltInVariable v)
case EbvBaryCoordSmoothSample: return "BaryCoordSmoothSample";
case EbvBaryCoordPullModel: return "BaryCoordPullModel";
#endif
+#ifdef NV_EXTENSIONS
+ case EbvViewportMaskNV: return "ViewportMaskNV";
+ case EbvSecondaryPositionNV: return "SecondaryPositionNV";
+ case EbvSecondaryViewportMaskNV: return "SecondaryViewportMaskNV";
+#endif
default: return "unknown built-in variable";
}
}
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/Common.h b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/Common.h
index 1433770cf4c..17c2bd984fc 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/Common.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/Common.h
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2012-2013 LunarG, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2012-2013 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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.
//
#ifndef _COMMON_INCLUDED_
@@ -66,7 +66,7 @@ std::string to_string(const T& val) {
#if defined(_MSC_VER) && _MSC_VER < 1700
inline long long int strtoll (const char* str, char** endptr, int base)
{
- return _strtoi64(str, endptr, base);
+ return _strtoi64(str, endptr, base);
}
inline unsigned long long int strtoull (const char* str, char** endptr, int base)
{
@@ -178,7 +178,7 @@ public:
template <class T> class TList : public std::list<T, pool_allocator<T> > {
};
-template <class K, class D, class CMP = std::less<K> >
+template <class K, class D, class CMP = std::less<K> >
class TMap : public std::map<K, D, CMP, pool_allocator<std::pair<K const, D> > > {
};
@@ -212,14 +212,14 @@ inline const TString String(const int i, const int base = 10)
inline const TString String(const int i, const int /*base*/ = 10)
{
char text[16]; // 32 bit ints are at most 10 digits in base 10
-
+
// we assume base 10 for all cases
snprintf(text, sizeof(text), "%d", i);
return text;
}
#endif
-
+
struct TSourceLoc {
void init() { name = nullptr; string = 0; line = 0; column = 0; }
// Returns the name if it exists. Otherwise, returns the string number.
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/ConstantUnion.h b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/ConstantUnion.h
index ec6aff1171b..b95bc25a0a1 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/ConstantUnion.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/ConstantUnion.h
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2013 LunarG, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2013 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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.
//
#ifndef _CONSTANT_UNION_INCLUDED_
@@ -46,14 +46,14 @@ public:
TConstUnion() : iConst(0), type(EbtInt) { }
void setIConst(int i)
- {
- iConst = i;
+ {
+ iConst = i;
type = EbtInt;
}
void setUConst(unsigned int u)
{
- uConst = u;
+ uConst = u;
type = EbtUint;
}
@@ -71,13 +71,13 @@ public:
void setDConst(double d)
{
- dConst = d;
+ dConst = d;
type = EbtDouble;
}
void setBConst(bool b)
{
- bConst = b;
+ bConst = b;
type = EbtBool;
}
@@ -215,7 +215,7 @@ public:
}
bool operator>(const TConstUnion& constant) const
- {
+ {
assert(type == constant.type);
switch (type) {
case EbtInt:
@@ -250,7 +250,7 @@ public:
}
bool operator<(const TConstUnion& constant) const
- {
+ {
assert(type == constant.type);
switch (type) {
case EbtInt:
@@ -285,7 +285,7 @@ public:
}
TConstUnion operator+(const TConstUnion& constant) const
- {
+ {
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
@@ -301,7 +301,7 @@ public:
}
TConstUnion operator-(const TConstUnion& constant) const
- {
+ {
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
@@ -317,7 +317,7 @@ public:
}
TConstUnion operator*(const TConstUnion& constant) const
- {
+ {
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
@@ -325,7 +325,7 @@ public:
case EbtInt64: returnValue.setI64Const(i64Const * constant.i64Const); break;
case EbtUint: returnValue.setUConst(uConst * constant.uConst); break;
case EbtUint64: returnValue.setU64Const(u64Const * constant.u64Const); break;
- case EbtDouble: returnValue.setDConst(dConst * constant.dConst); break;
+ case EbtDouble: returnValue.setDConst(dConst * constant.dConst); break;
default: assert(false && "Default missing");
}
@@ -333,7 +333,7 @@ public:
}
TConstUnion operator%(const TConstUnion& constant) const
- {
+ {
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
@@ -348,7 +348,7 @@ public:
}
TConstUnion operator>>(const TConstUnion& constant) const
- {
+ {
TConstUnion returnValue;
switch (type) {
case EbtInt:
@@ -394,7 +394,7 @@ public:
}
TConstUnion operator<<(const TConstUnion& constant) const
- {
+ {
TConstUnion returnValue;
switch (type) {
case EbtInt:
@@ -440,7 +440,7 @@ public:
}
TConstUnion operator&(const TConstUnion& constant) const
- {
+ {
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
@@ -455,7 +455,7 @@ public:
}
TConstUnion operator|(const TConstUnion& constant) const
- {
+ {
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
@@ -470,7 +470,7 @@ public:
}
TConstUnion operator^(const TConstUnion& constant) const
- {
+ {
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
@@ -485,7 +485,7 @@ public:
}
TConstUnion operator~() const
- {
+ {
TConstUnion returnValue;
switch (type) {
case EbtInt: returnValue.setIConst(~iConst); break;
@@ -499,7 +499,7 @@ public:
}
TConstUnion operator&&(const TConstUnion& constant) const
- {
+ {
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
@@ -511,7 +511,7 @@ public:
}
TConstUnion operator||(const TConstUnion& constant) const
- {
+ {
TConstUnion returnValue;
assert(type == constant.type);
switch (type) {
@@ -544,7 +544,7 @@ private:
// One convenience is being able to use [] to go inside the array, instead
// of C++ assuming it as an array of pointers to vectors.
//
-// General usage is that the size is known up front, and it is
+// General usage is that the size is known up front, and it is
// created once with the proper size.
//
class TConstUnionArray {
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/InfoSink.h b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/InfoSink.h
index 0cbd99bdaae..dceb603cffe 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/InfoSink.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/InfoSink.h
@@ -1,10 +1,10 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -18,18 +18,18 @@
// 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.
+// 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.
//
#ifndef _INFOSINK_INCLUDED_
@@ -74,9 +74,9 @@ public:
TInfoSinkBase& operator<<(const char* s) { append(s); return *this; }
TInfoSinkBase& operator<<(int n) { append(String(n)); return *this; }
TInfoSinkBase& operator<<(unsigned int n) { append(String(n)); return *this; }
- TInfoSinkBase& operator<<(float n) { const int size = 40; char buf[size];
+ TInfoSinkBase& operator<<(float n) { const int size = 40; char buf[size];
snprintf(buf, size, (fabs(n) > 1e-8 && fabs(n) < 1e8) || n == 0.0f ? "%f" : "%g", n);
- append(buf);
+ append(buf);
return *this; }
TInfoSinkBase& operator+(const TPersistString& t) { append(t); return *this; }
TInfoSinkBase& operator+(const TString& t) { append(t); return *this; }
@@ -113,20 +113,20 @@ public:
append(s);
append("\n");
}
-
+
void setOutputStream(int output = 4)
{
outputStream = output;
}
protected:
- void append(const char* s);
+ void append(const char* s);
void append(int count, char c);
void append(const TPersistString& t);
void append(const TString& t);
- void checkMem(size_t growth) { if (sink.capacity() < sink.size() + growth + 2)
+ void checkMem(size_t growth) { if (sink.capacity() < sink.size() + growth + 2)
sink.reserve(sink.capacity() + sink.capacity() / 2); }
void appendToStream(const char* s);
TPersistString sink;
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/InitializeGlobals.h b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/InitializeGlobals.h
index 6c9f54a03d4..4cf2dca7c40 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/InitializeGlobals.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/InitializeGlobals.h
@@ -1,10 +1,10 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -18,18 +18,18 @@
// 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.
+// 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.
//
#ifndef __INITIALIZE_GLOBALS_INCLUDED_
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/PoolAlloc.h b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/PoolAlloc.h
index 635be79ef95..69bacb156f8 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/PoolAlloc.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/PoolAlloc.h
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2012-2013 LunarG, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2012-2013 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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.
//
#ifndef _POOLALLOC_INCLUDED_
@@ -43,8 +43,8 @@
//
// This header defines an allocator that can be used to efficiently
-// allocate a large number of small requests for heap memory, with the
-// intention that they are not individually deallocated, but rather
+// allocate a large number of small requests for heap memory, with the
+// intention that they are not individually deallocated, but rather
// collectively deallocated at one time.
//
// This simultaneously
@@ -70,7 +70,7 @@ namespace glslang {
// If we are using guard blocks, we must track each individual
// allocation. If we aren't using guard blocks, these
// never get instantiated, so won't have any impact.
-//
+//
class TAllocation {
public:
@@ -87,7 +87,7 @@ public:
memset(postGuard(), guardBlockEndVal, guardBlockSize);
# endif
}
-
+
void check() const {
checkGuardBlock(preGuard(), guardBlockBeginVal, "before");
checkGuardBlock(postGuard(), guardBlockEndVal, "after");
@@ -100,7 +100,7 @@ public:
inline static size_t allocationSize(size_t size) {
return size + 2 * guardBlockSize + headerSize();
}
-
+
// Offset from surrounding buffer to get to user data buffer.
inline static unsigned char* offsetAllocation(unsigned char* m) {
return m + guardBlockSize + headerSize();
@@ -123,16 +123,16 @@ private:
const static unsigned char userDataFill;
const static size_t guardBlockSize;
-# ifdef GUARD_BLOCKS
+# ifdef GUARD_BLOCKS
inline static size_t headerSize() { return sizeof(TAllocation); }
# else
inline static size_t headerSize() { return 0; }
# endif
};
-
+
//
// There are several stacks. One is to track the pushing and popping
-// of the user, and not yet implemented. The others are simply a
+// of the user, and not yet implemented. The others are simply a
// repositories of free pages or used pages.
//
// Page stacks are linked together with a simple header at the beginning
@@ -141,7 +141,7 @@ private:
// re-use.
//
// The "page size" used is not, nor must it match, the underlying OS
-// page size. But, having it be about that size or equal to a set of
+// page size. But, having it be about that size or equal to a set of
// pages is likely most optimal.
//
class TPoolAllocator {
@@ -185,7 +185,7 @@ public:
protected:
friend struct tHeader;
-
+
struct tHeader {
tHeader(tHeader* nextPage, size_t pageCount) :
#ifdef GUARD_BLOCKS
@@ -227,7 +227,7 @@ protected:
}
size_t pageSize; // granularity of allocation from the OS
- size_t alignment; // all returned allocations will be aligned at
+ size_t alignment; // all returned allocations will be aligned at
// this granularity, which will be a power of 2
size_t alignmentMask;
size_t headerSkip; // amount of memory to skip to make room for the
@@ -245,7 +245,6 @@ private:
TPoolAllocator(const TPoolAllocator&); // don't allow default copy constructor
};
-
//
// There could potentially be many pools with pops happening at
// different times. But a simple use is to have a global pop
@@ -256,7 +255,7 @@ extern TPoolAllocator& GetThreadPoolAllocator();
struct TThreadMemoryPools
{
- TPoolAllocator* threadPoolAllocator;
+ TPoolAllocator* threadPoolAllocator;
};
void SetThreadPoolAllocator(TPoolAllocator& poolAllocator);
@@ -278,7 +277,7 @@ public:
typedef T& reference;
typedef const T& const_reference;
typedef T value_type;
- template<class Other>
+ template<class Other>
struct rebind {
typedef pool_allocator<Other> other;
};
@@ -292,9 +291,9 @@ public:
template<class Other>
pool_allocator(const pool_allocator<Other>& p) : allocator(p.getAllocator()) { }
- pointer allocate(size_type n) {
+ pointer allocate(size_type n) {
return reinterpret_cast<pointer>(getAllocator().allocate(n * sizeof(T))); }
- pointer allocate(size_type n, const void*) {
+ pointer allocate(size_type n, const void*) {
return reinterpret_cast<pointer>(getAllocator().allocate(n * sizeof(T))); }
void deallocate(void*, size_type) { }
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/ResourceLimits.h b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/ResourceLimits.h
index e8c743d6b7c..0d07b8c841f 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/ResourceLimits.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/ResourceLimits.h
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2013 LunarG, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2013 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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.
//
#ifndef _RESOURCE_LIMITS_INCLUDED_
@@ -81,7 +81,7 @@ struct TBuiltInResource {
int maxComputeImageUniforms;
int maxComputeAtomicCounters;
int maxComputeAtomicCounterBuffers;
- int maxVaryingComponents;
+ int maxVaryingComponents;
int maxVertexOutputComponents;
int maxGeometryInputComponents;
int maxGeometryOutputComponents;
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/ShHandle.h b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/ShHandle.h
index bfc97db8b24..64ba6d636c0 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/ShHandle.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/ShHandle.h
@@ -1,10 +1,10 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -18,18 +18,18 @@
// 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.
+// 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.
//
#ifndef _SHHANDLE_INCLUDED_
@@ -42,8 +42,7 @@
// This should not be included by driver code.
//
-
-#define SH_EXPORTING
+#define SH_EXPORTING
#include "../Public/ShaderLang.h"
#include "../MachineIndependent/Versions.h"
#include "InfoSink.h"
@@ -73,7 +72,7 @@ public:
TUniformMap() { }
virtual ~TUniformMap() { }
virtual TUniformMap* getAsUniformMap() { return this; }
- virtual int getLocation(const char* name) = 0;
+ virtual int getLocation(const char* name) = 0;
virtual TInfoSink& getInfoSink() { return infoSink; }
TInfoSink infoSink;
};
@@ -95,7 +94,7 @@ public:
virtual TCompiler* getAsCompiler() { return this; }
virtual bool linkable() { return haveValidObjectCode; }
-
+
TInfoSink& infoSink;
protected:
TCompiler& operator=(TCompiler&);
@@ -117,9 +116,9 @@ typedef glslang::TVector<TShHandleBase*> THandleList;
class TLinker : public TShHandleBase {
public:
- TLinker(EShExecutable e, TInfoSink& iSink) :
+ TLinker(EShExecutable e, TInfoSink& iSink) :
infoSink(iSink),
- executable(e),
+ executable(e),
haveReturnableObjectCode(false),
appAttributeBindings(0),
fixedAttributeBindings(0),
@@ -147,7 +146,7 @@ protected:
const ShBindingTable* fixedAttributeBindings;
const int* excludedAttributes;
int excludedCount;
- ShBindingTable* uniformBindings; // created by the linker
+ ShBindingTable* uniformBindings; // created by the linker
};
//
@@ -155,7 +154,7 @@ protected:
// and the machine dependent code.
//
// The machine dependent code should derive from the classes
-// above. Then Construct*() and Delete*() will create and
+// above. Then Construct*() and Delete*() will create and
// destroy the machine dependent objects, which contain the
// above machine independent information.
//
@@ -165,7 +164,7 @@ TShHandleBase* ConstructLinker(EShExecutable, int);
TShHandleBase* ConstructBindings();
void DeleteLinker(TShHandleBase*);
void DeleteBindingList(TShHandleBase* bindingList);
-
+
TUniformMap* ConstructUniformMap();
void DeleteCompiler(TCompiler*);
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/Types.h b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/Types.h
index ae40465b94d..6fce15ec3fa 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/Types.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/Types.h
@@ -1,13 +1,13 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2012-2016 LunarG, Inc.
-//Copyright (C) 2015-2016 Google, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2012-2016 LunarG, Inc.
+// Copyright (C) 2015-2016 Google, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -21,18 +21,18 @@
// 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.
+// 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.
//
#ifndef _TYPES_INCLUDED
@@ -421,7 +421,7 @@ public:
clearLayout();
}
- // Drop just the storage qualification, which perhaps should
+ // Drop just the storage qualification, which perhaps should
// never be done, as it is fundamentally inconsistent, but need to
// explore what downstream consumers need.
// E.g., in a deference, it is an inconsistency between:
@@ -601,6 +601,9 @@ public:
layoutPushConstant = false;
#ifdef NV_EXTENSIONS
layoutPassthrough = false;
+ layoutViewportRelative = false;
+ // -2048 as the default vaule indicating layoutSecondaryViewportRelative is not set
+ layoutSecondaryViewportRelativeOffset = -2048;
#endif
}
bool hasLayout() const
@@ -657,6 +660,8 @@ public:
#ifdef NV_EXTENSIONS
bool layoutPassthrough;
+ bool layoutViewportRelative;
+ int layoutSecondaryViewportRelativeOffset;
#endif
bool hasUniformLayout() const
@@ -927,9 +932,9 @@ struct TShaderQualifiers {
TLayoutDepth layoutDepth;
bool blendEquation; // true if any blend equation was specified
-#ifdef NV_EXTENSIONS
+#ifdef NV_EXTENSIONS
bool layoutOverrideCoverage; // true if layout override_coverage set
-#endif
+#endif
void init()
{
@@ -950,7 +955,7 @@ struct TShaderQualifiers {
earlyFragmentTests = false;
layoutDepth = EldNone;
blendEquation = false;
-#ifdef NV_EXTENSIONS
+#ifdef NV_EXTENSIONS
layoutOverrideCoverage = false;
#endif
}
@@ -989,10 +994,10 @@ struct TShaderQualifiers {
layoutDepth = src.layoutDepth;
if (src.blendEquation)
blendEquation = src.blendEquation;
-#ifdef NV_EXTENSIONS
+#ifdef NV_EXTENSIONS
if (src.layoutOverrideCoverage)
layoutOverrideCoverage = src.layoutOverrideCoverage;
-#endif
+#endif
}
};
@@ -1085,7 +1090,7 @@ public:
qualifier.storage = q;
}
// for explicit precision qualifier
- TType(TBasicType t, TStorageQualifier q, TPrecisionQualifier p, int vs = 1, int mc = 0, int mr = 0,
+ TType(TBasicType t, TStorageQualifier q, TPrecisionQualifier p, int vs = 1, int mc = 0, int mr = 0,
bool isVector = false) :
basicType(t), vectorSize(vs), matrixCols(mc), matrixRows(mr), vector1(isVector && vs == 1),
arraySizes(nullptr), structure(nullptr), fieldName(nullptr), typeName(nullptr)
@@ -1223,6 +1228,16 @@ public:
typeName = NewPoolTString(copyOf.typeName->c_str());
}
+ // Recursively make temporary
+ void makeTemporary()
+ {
+ getQualifier().makeTemporary();
+
+ if (isStruct())
+ for (unsigned int i = 0; i < structure->size(); ++i)
+ (*structure)[i].type->makeTemporary();
+ }
+
TType* clone() const
{
TType *newType = new TType();
@@ -1309,6 +1324,44 @@ public:
virtual bool isImage() const { return basicType == EbtSampler && getSampler().isImage(); }
virtual bool isSubpass() const { return basicType == EbtSampler && getSampler().isSubpass(); }
+ virtual bool isBuiltInInterstageIO(EShLanguage language) const
+ {
+ return isPerVertexAndBuiltIn(language) || isLooseAndBuiltIn(language);
+ }
+
+ // Return true if this is an interstage IO builtin
+ virtual bool isPerVertexAndBuiltIn(EShLanguage language) const
+ {
+ if (language == EShLangFragment)
+ return false;
+
+ // Any non-fragment stage
+ switch (getQualifier().builtIn) {
+ case EbvPosition:
+ case EbvPointSize:
+ case EbvClipDistance:
+ case EbvCullDistance:
+#ifdef NV_EXTENSIONS
+ case EbvLayer:
+ case EbvViewportMaskNV:
+ case EbvSecondaryPositionNV:
+ case EbvSecondaryViewportMaskNV:
+#endif
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ // Return true if this is a loose builtin
+ virtual bool isLooseAndBuiltIn(EShLanguage language) const
+ {
+ if (getQualifier().builtIn == EbvNone)
+ return false;
+
+ return !isPerVertexAndBuiltIn(language);
+ }
+
// Recursively checks if the type contains the given basic type
virtual bool containsBasicType(TBasicType checkType) const
{
@@ -1376,6 +1429,21 @@ public:
return false;
}
+ // Recursively checks if the type contains an interstage IO builtin
+ virtual bool containsBuiltInInterstageIO(EShLanguage language) const
+ {
+ if (isBuiltInInterstageIO(language))
+ return true;
+
+ if (! structure)
+ return false;
+ for (unsigned int i = 0; i < structure->size(); ++i) {
+ if ((*structure)[i].type->containsBuiltInInterstageIO(language))
+ return true;
+ }
+ return false;
+ }
+
virtual bool containsNonOpaque() const
{
// list all non-opaque types
@@ -1547,9 +1615,12 @@ public:
#ifdef NV_EXTENSIONS
if (qualifier.layoutPassthrough)
p += snprintf(p, end - p, "passthrough ");
+ if (qualifier.layoutViewportRelative)
+ p += snprintf(p, end - p, "layoutViewportRelative ");
+ if (qualifier.layoutSecondaryViewportRelativeOffset != -2048)
+ p += snprintf(p, end - p, "layoutSecondaryViewportRelativeOffset=%d ", qualifier.layoutSecondaryViewportRelativeOffset);
#endif
-
p += snprintf(p, end - p, ") ");
}
}
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/arrays.h b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/arrays.h
index a50088d2dbe..b6b5e479d74 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/arrays.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/arrays.h
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2012-2013 LunarG, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2012-2013 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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.
//
//
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/intermediate.h b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/intermediate.h
index 8f7ffcc0daa..dc87ba905b6 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/intermediate.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/intermediate.h
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2012-2016 LunarG, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2012-2016 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,25 +20,25 @@
// 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.
+// 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.
//
//
// Definition of the in-memory high-level intermediate representation
// of shaders. This is a tree that parser creates.
//
-// Nodes in the tree are defined as a hierarchy of classes derived from
+// Nodes in the tree are defined as a hierarchy of classes derived from
// TIntermNode. Each is a node in a tree. There is no preset branching factor;
// each node can have it's own type of list of children.
//
@@ -66,14 +66,14 @@ enum TOperator {
EOpNull, // if in a node, should only mean a node is still being built
EOpSequence, // denotes a list of statements, or parameters, etc.
EOpLinkerObjects, // for aggregate node of objects the linker may need, if not reference by the rest of the AST
- EOpFunctionCall,
+ EOpFunctionCall,
EOpFunction, // For function definition
EOpParameters, // an aggregate listing the parameters to a function
//
// Unary operators
//
-
+
EOpNegative,
EOpLogicalNot,
EOpVectorLogicalNot,
@@ -335,6 +335,18 @@ enum TOperator {
EOpMinInvocationsNonUniform,
EOpMaxInvocationsNonUniform,
EOpAddInvocationsNonUniform,
+ EOpMinInvocationsInclusiveScan,
+ EOpMaxInvocationsInclusiveScan,
+ EOpAddInvocationsInclusiveScan,
+ EOpMinInvocationsInclusiveScanNonUniform,
+ EOpMaxInvocationsInclusiveScanNonUniform,
+ EOpAddInvocationsInclusiveScanNonUniform,
+ EOpMinInvocationsExclusiveScan,
+ EOpMaxInvocationsExclusiveScan,
+ EOpAddInvocationsExclusiveScan,
+ EOpMinInvocationsExclusiveScanNonUniform,
+ EOpMaxInvocationsExclusiveScanNonUniform,
+ EOpAddInvocationsExclusiveScanNonUniform,
EOpSwizzleInvocations,
EOpSwizzleInvocationsMasked,
EOpWriteInvocation,
@@ -445,7 +457,7 @@ enum TOperator {
//
// moves
//
-
+
EOpAssign,
EOpAddAssign,
EOpSubAssign,
@@ -597,6 +609,7 @@ enum TOperator {
EOpLit, // HLSL lighting coefficient vector
EOpTextureBias, // HLSL texture bias: will be lowered to EOpTexture
EOpAsDouble, // slightly different from EOpUint64BitsToDouble
+ EOpD3DCOLORtoUBYTE4, // convert and swizzle 4-component color to UBYTE4 range
EOpMethodSample, // Texture object methods. These are translated to existing
EOpMethodSampleBias, // AST methods, and exist to represent HLSL semantics until that
@@ -625,6 +638,9 @@ enum TOperator {
// geometry methods
EOpMethodAppend, // Geometry shader methods
EOpMethodRestartStrip, // ...
+
+ // matrix
+ EOpMatrixSwizzle, // select multiple matrix components (non-column)
};
class TIntermTraverser;
@@ -708,7 +724,7 @@ public:
virtual void setType(const TType& t) { type.shallowCopy(t); }
virtual const TType& getType() const { return type; }
virtual TType& getWritableType() { return type; }
-
+
virtual TBasicType getBasicType() const { return type.getBasicType(); }
virtual TQualifier& getQualifier() { return type.getQualifier(); }
virtual const TQualifier& getQualifier() const { return type.getQualifier(); }
@@ -733,7 +749,7 @@ protected:
//
class TIntermLoop : public TIntermNode {
public:
- TIntermLoop(TIntermNode* aBody, TIntermTyped* aTest, TIntermTyped* aTerminal, bool testFirst) :
+ TIntermLoop(TIntermNode* aBody, TIntermTyped* aTest, TIntermTyped* aTerminal, bool testFirst) :
body(aBody),
test(aTest),
terminal(aTerminal),
@@ -1147,7 +1163,7 @@ enum TVisit
};
//
-// For traversing the tree. User should derive from this,
+// For traversing the tree. User should derive from this,
// put their traversal specific data in it, and then pass
// it to a Traverse method.
//
@@ -1159,10 +1175,10 @@ enum TVisit
// the subtree). Similarly for inVisit for in-order visiting of nodes with
// multiple children.
//
-// If you only want post-visits, explicitly turn off preVisit (and inVisit)
+// If you only want post-visits, explicitly turn off preVisit (and inVisit)
// and turn on postVisit.
//
-// In general, for the visit*() methods, return true from interior nodes
+// In general, for the visit*() methods, return true from interior nodes
// to have the traversal continue on to children.
//
// If you process children yourself, or don't want them processed, return false.
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/revision.h b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/revision.h
index 530612572f5..796f81a9bc1 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/revision.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/revision.h
@@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits.
// For the date, it uses the current date (when then script is run).
-#define GLSLANG_REVISION "Overload400-PrecQual.1721"
-#define GLSLANG_DATE "21-Dec-2016"
+#define GLSLANG_REVISION "Overload400-PrecQual.1805"
+#define GLSLANG_DATE "02-Feb-2017"
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/revision.template b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/revision.template
index 1dc3392b39f..6c13630b27e 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/Include/revision.template
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/Include/revision.template
@@ -1,4 +1,4 @@
-// The file revision.h should be updated to the latest version, somehow, on
+// The file revision.h should be updated to the latest version, somehow, on
// check-in, if glslang has changed.
//
// revision.template is the source for revision.h when using SubWCRev as the
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Constant.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Constant.cpp
index 61b6f67e794..fff8fd26da0 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Constant.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Constant.cpp
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2012-2013 LunarG, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2012-2013 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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 "localintermediate.h"
@@ -629,6 +629,9 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType)
//
TIntermTyped* TIntermediate::fold(TIntermAggregate* aggrNode)
{
+ if (aggrNode == nullptr)
+ return aggrNode;
+
if (! areAllChildConst(aggrNode))
return aggrNode;
@@ -971,20 +974,20 @@ TIntermTyped* TIntermediate::foldDereference(TIntermTyped* node, int index, cons
// Make a constant vector node or constant scalar node, representing a given
// constant vector and constant swizzle into it.
//
-TIntermTyped* TIntermediate::foldSwizzle(TIntermTyped* node, TVectorFields& fields, const TSourceLoc& loc)
+TIntermTyped* TIntermediate::foldSwizzle(TIntermTyped* node, TSwizzleSelectors<TVectorSelector>& selectors, const TSourceLoc& loc)
{
const TConstUnionArray& unionArray = node->getAsConstantUnion()->getConstArray();
- TConstUnionArray constArray(fields.num);
+ TConstUnionArray constArray(selectors.size());
- for (int i = 0; i < fields.num; i++)
- constArray[i] = unionArray[fields.offsets[i]];
+ for (int i = 0; i < selectors.size(); i++)
+ constArray[i] = unionArray[selectors[i]];
TIntermTyped* result = addConstantUnion(constArray, node->getType(), loc);
if (result == 0)
result = node;
else
- result->setType(TType(node->getBasicType(), EvqConst, fields.num));
+ result->setType(TType(node->getBasicType(), EvqConst, selectors.size()));
return result;
}
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/InfoSink.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/InfoSink.cpp
index 79acba87884..d00c4225666 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/InfoSink.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/InfoSink.cpp
@@ -1,10 +1,10 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -18,18 +18,18 @@
// 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.
+// 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 "../Include/InfoSink.h"
@@ -59,10 +59,10 @@ void TInfoSinkBase::append(const char* s)
}
void TInfoSinkBase::append(int count, char c)
-{
+{
if (outputStream & EString) {
checkMem(count);
- sink.append(count, c);
+ sink.append(count, c);
}
//#ifdef _WIN32
@@ -79,10 +79,10 @@ void TInfoSinkBase::append(int count, char c)
}
void TInfoSinkBase::append(const TPersistString& t)
-{
+{
if (outputStream & EString) {
checkMem(t.size());
- sink.append(t);
+ sink.append(t);
}
//#ifdef _WIN32
@@ -95,10 +95,10 @@ void TInfoSinkBase::append(const TPersistString& t)
}
void TInfoSinkBase::append(const TString& t)
-{
+{
if (outputStream & EString) {
checkMem(t.size());
- sink.append(t.c_str());
+ sink.append(t.c_str());
}
//#ifdef _WIN32
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Initialize.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Initialize.cpp
index c8739535e7b..287d6d69a8a 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Initialize.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Initialize.cpp
@@ -1,13 +1,13 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2012-2016 LunarG, Inc.
-//Copyright (C) 2015-2016 Google, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2012-2016 LunarG, Inc.
+// Copyright (C) 2015-2016 Google, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -21,22 +21,22 @@
// 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.
+// 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.
//
//
-// Create strings that declare built-in definitions, add built-ins programmatically
+// Create strings that declare built-in definitions, add built-ins programmatically
// that cannot be expressed in the strings, and establish mappings between
// built-in functions and operators.
//
@@ -103,7 +103,6 @@ TBuiltIns::~TBuiltIns()
{
}
-
//
// Add all context-independent built-in functions and variables that are present
// for the given version and profile. Share common ones across stages, otherwise
@@ -128,47 +127,47 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"vec2 radians(vec2 degrees);"
"vec3 radians(vec3 degrees);"
"vec4 radians(vec4 degrees);"
-
+
"float degrees(float radians);"
"vec2 degrees(vec2 radians);"
"vec3 degrees(vec3 radians);"
"vec4 degrees(vec4 radians);"
-
+
"float sin(float angle);"
"vec2 sin(vec2 angle);"
"vec3 sin(vec3 angle);"
"vec4 sin(vec4 angle);"
-
+
"float cos(float angle);"
"vec2 cos(vec2 angle);"
"vec3 cos(vec3 angle);"
"vec4 cos(vec4 angle);"
-
+
"float tan(float angle);"
"vec2 tan(vec2 angle);"
"vec3 tan(vec3 angle);"
"vec4 tan(vec4 angle);"
-
+
"float asin(float x);"
"vec2 asin(vec2 x);"
"vec3 asin(vec3 x);"
"vec4 asin(vec4 x);"
-
+
"float acos(float x);"
"vec2 acos(vec2 x);"
"vec3 acos(vec3 x);"
"vec4 acos(vec4 x);"
-
+
"float atan(float y, float x);"
"vec2 atan(vec2 y, vec2 x);"
"vec3 atan(vec3 y, vec3 x);"
"vec4 atan(vec4 y, vec4 x);"
-
+
"float atan(float y_over_x);"
"vec2 atan(vec2 y_over_x);"
"vec3 atan(vec3 y_over_x);"
"vec4 atan(vec4 y_over_x);"
-
+
"\n");
if (version >= 130) {
@@ -177,32 +176,32 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"vec2 sinh(vec2 angle);"
"vec3 sinh(vec3 angle);"
"vec4 sinh(vec4 angle);"
-
+
"float cosh(float angle);"
"vec2 cosh(vec2 angle);"
"vec3 cosh(vec3 angle);"
"vec4 cosh(vec4 angle);"
-
+
"float tanh(float angle);"
"vec2 tanh(vec2 angle);"
"vec3 tanh(vec3 angle);"
"vec4 tanh(vec4 angle);"
-
+
"float asinh(float x);"
"vec2 asinh(vec2 x);"
"vec3 asinh(vec3 x);"
"vec4 asinh(vec4 x);"
-
+
"float acosh(float x);"
"vec2 acosh(vec2 x);"
"vec3 acosh(vec3 x);"
"vec4 acosh(vec4 x);"
-
+
"float atanh(float y_over_x);"
"vec2 atanh(vec2 y_over_x);"
"vec3 atanh(vec3 y_over_x);"
"vec4 atanh(vec4 y_over_x);"
-
+
"\n");
}
@@ -214,37 +213,37 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"vec2 pow(vec2 x, vec2 y);"
"vec3 pow(vec3 x, vec3 y);"
"vec4 pow(vec4 x, vec4 y);"
-
+
"float exp(float x);"
"vec2 exp(vec2 x);"
"vec3 exp(vec3 x);"
"vec4 exp(vec4 x);"
-
+
"float log(float x);"
"vec2 log(vec2 x);"
"vec3 log(vec3 x);"
"vec4 log(vec4 x);"
-
+
"float exp2(float x);"
"vec2 exp2(vec2 x);"
"vec3 exp2(vec3 x);"
"vec4 exp2(vec4 x);"
-
+
"float log2(float x);"
"vec2 log2(vec2 x);"
"vec3 log2(vec3 x);"
"vec4 log2(vec4 x);"
-
+
"float sqrt(float x);"
"vec2 sqrt(vec2 x);"
"vec3 sqrt(vec3 x);"
"vec4 sqrt(vec4 x);"
-
+
"float inversesqrt(float x);"
"vec2 inversesqrt(vec2 x);"
"vec3 inversesqrt(vec3 x);"
"vec4 inversesqrt(vec4 x);"
-
+
"\n");
//
@@ -255,27 +254,27 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"vec2 abs(vec2 x);"
"vec3 abs(vec3 x);"
"vec4 abs(vec4 x);"
-
+
"float sign(float x);"
"vec2 sign(vec2 x);"
"vec3 sign(vec3 x);"
"vec4 sign(vec4 x);"
-
+
"float floor(float x);"
"vec2 floor(vec2 x);"
"vec3 floor(vec3 x);"
"vec4 floor(vec4 x);"
-
+
"float ceil(float x);"
"vec2 ceil(vec2 x);"
"vec3 ceil(vec3 x);"
"vec4 ceil(vec4 x);"
-
+
"float fract(float x);"
"vec2 fract(vec2 x);"
"vec3 fract(vec3 x);"
"vec4 fract(vec4 x);"
-
+
"float mod(float x, float y);"
"vec2 mod(vec2 x, float y);"
"vec3 mod(vec3 x, float y);"
@@ -283,7 +282,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"vec2 mod(vec2 x, vec2 y);"
"vec3 mod(vec3 x, vec3 y);"
"vec4 mod(vec4 x, vec4 y);"
-
+
"float min(float x, float y);"
"vec2 min(vec2 x, float y);"
"vec3 min(vec3 x, float y);"
@@ -291,7 +290,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"vec2 min(vec2 x, vec2 y);"
"vec3 min(vec3 x, vec3 y);"
"vec4 min(vec4 x, vec4 y);"
-
+
"float max(float x, float y);"
"vec2 max(vec2 x, float y);"
"vec3 max(vec3 x, float y);"
@@ -299,7 +298,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"vec2 max(vec2 x, vec2 y);"
"vec3 max(vec3 x, vec3 y);"
"vec4 max(vec4 x, vec4 y);"
-
+
"float clamp(float x, float minVal, float maxVal);"
"vec2 clamp(vec2 x, float minVal, float maxVal);"
"vec3 clamp(vec3 x, float minVal, float maxVal);"
@@ -307,7 +306,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal);"
"vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal);"
"vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal);"
-
+
"float mix(float x, float y, float a);"
"vec2 mix(vec2 x, vec2 y, float a);"
"vec3 mix(vec3 x, vec3 y, float a);"
@@ -323,7 +322,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"vec2 step(float edge, vec2 x);"
"vec3 step(float edge, vec3 x);"
"vec4 step(float edge, vec4 x);"
-
+
"float smoothstep(float edge0, float edge1, float x);"
"vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x);"
"vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x);"
@@ -331,7 +330,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"vec2 smoothstep(float edge0, float edge1, vec2 x);"
"vec3 smoothstep(float edge0, float edge1, vec3 x);"
"vec4 smoothstep(float edge0, float edge1, vec4 x);"
-
+
"\n");
if (version >= 130) {
@@ -350,22 +349,22 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"vec2 trunc(vec2 x);"
"vec3 trunc(vec3 x);"
"vec4 trunc(vec4 x);"
-
+
"float round(float x);"
"vec2 round(vec2 x);"
"vec3 round(vec3 x);"
"vec4 round(vec4 x);"
-
+
"float roundEven(float x);"
"vec2 roundEven(vec2 x);"
"vec3 roundEven(vec3 x);"
"vec4 roundEven(vec4 x);"
-
+
"float modf(float, out float);"
"vec2 modf(vec2, out vec2 );"
"vec3 modf(vec3, out vec3 );"
"vec4 modf(vec4, out vec4 );"
-
+
" int min(int x, int y);"
"ivec2 min(ivec2 x, int y);"
"ivec3 min(ivec3 x, int y);"
@@ -373,7 +372,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"ivec2 min(ivec2 x, ivec2 y);"
"ivec3 min(ivec3 x, ivec3 y);"
"ivec4 min(ivec4 x, ivec4 y);"
-
+
" uint min(uint x, uint y);"
"uvec2 min(uvec2 x, uint y);"
"uvec3 min(uvec3 x, uint y);"
@@ -381,7 +380,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"uvec2 min(uvec2 x, uvec2 y);"
"uvec3 min(uvec3 x, uvec3 y);"
"uvec4 min(uvec4 x, uvec4 y);"
-
+
" int max(int x, int y);"
"ivec2 max(ivec2 x, int y);"
"ivec3 max(ivec3 x, int y);"
@@ -589,12 +588,12 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"dvec2 faceforward(dvec2, dvec2, dvec2);"
"dvec3 faceforward(dvec3, dvec3, dvec3);"
"dvec4 faceforward(dvec4, dvec4, dvec4);"
-
+
"double reflect(double, double);"
"dvec2 reflect(dvec2 , dvec2 );"
"dvec3 reflect(dvec3 , dvec3 );"
"dvec4 reflect(dvec4 , dvec4 );"
-
+
"double refract(double, double, double);"
"dvec2 refract(dvec2 , dvec2 , double);"
"dvec3 refract(dvec3 , dvec3 , double);"
@@ -1079,38 +1078,38 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"float length(vec2 x);"
"float length(vec3 x);"
"float length(vec4 x);"
-
+
"float distance(float p0, float p1);"
"float distance(vec2 p0, vec2 p1);"
"float distance(vec3 p0, vec3 p1);"
"float distance(vec4 p0, vec4 p1);"
-
+
"float dot(float x, float y);"
"float dot(vec2 x, vec2 y);"
"float dot(vec3 x, vec3 y);"
"float dot(vec4 x, vec4 y);"
-
+
"vec3 cross(vec3 x, vec3 y);"
"float normalize(float x);"
"vec2 normalize(vec2 x);"
"vec3 normalize(vec3 x);"
"vec4 normalize(vec4 x);"
-
+
"float faceforward(float N, float I, float Nref);"
"vec2 faceforward(vec2 N, vec2 I, vec2 Nref);"
"vec3 faceforward(vec3 N, vec3 I, vec3 Nref);"
"vec4 faceforward(vec4 N, vec4 I, vec4 Nref);"
-
+
"float reflect(float I, float N);"
"vec2 reflect(vec2 I, vec2 N);"
"vec3 reflect(vec3 I, vec3 N);"
"vec4 reflect(vec4 I, vec4 N);"
-
+
"float refract(float I, float N, float eta);"
"vec2 refract(vec2 I, vec2 N, float eta);"
"vec3 refract(vec3 I, vec3 N, float eta);"
"vec4 refract(vec4 I, vec4 N, float eta);"
-
+
"\n");
//
@@ -1120,7 +1119,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"mat2 matrixCompMult(mat2 x, mat2 y);"
"mat3 matrixCompMult(mat3 x, mat3 y);"
"mat4 matrixCompMult(mat4 x, mat4 y);"
-
+
"\n");
// 120 is correct for both ES and desktop
@@ -1135,7 +1134,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"mat4x2 outerProduct(vec2 c, vec4 r);"
"mat3x4 outerProduct(vec4 c, vec3 r);"
"mat4x3 outerProduct(vec3 c, vec4 r);"
-
+
"mat2 transpose(mat2 m);"
"mat3 transpose(mat3 m);"
"mat4 transpose(mat4 m);"
@@ -1151,8 +1150,8 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"mat3x2 matrixCompMult(mat3x2, mat3x2);"
"mat3x4 matrixCompMult(mat3x4, mat3x4);"
"mat4x2 matrixCompMult(mat4x2, mat4x2);"
- "mat4x3 matrixCompMult(mat4x3, mat4x3);"
-
+ "mat4x3 matrixCompMult(mat4x3, mat4x3);"
+
"\n");
// 150 is correct for both ES and desktop
@@ -1161,11 +1160,11 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"float determinant(mat2 m);"
"float determinant(mat3 m);"
"float determinant(mat4 m);"
-
+
"mat2 inverse(mat2 m);"
"mat3 inverse(mat3 m);"
"mat4 inverse(mat4 m);"
-
+
"\n");
}
}
@@ -1177,71 +1176,71 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"bvec2 lessThan(vec2 x, vec2 y);"
"bvec3 lessThan(vec3 x, vec3 y);"
"bvec4 lessThan(vec4 x, vec4 y);"
-
+
"bvec2 lessThan(ivec2 x, ivec2 y);"
"bvec3 lessThan(ivec3 x, ivec3 y);"
"bvec4 lessThan(ivec4 x, ivec4 y);"
-
+
"bvec2 lessThanEqual(vec2 x, vec2 y);"
"bvec3 lessThanEqual(vec3 x, vec3 y);"
"bvec4 lessThanEqual(vec4 x, vec4 y);"
-
+
"bvec2 lessThanEqual(ivec2 x, ivec2 y);"
"bvec3 lessThanEqual(ivec3 x, ivec3 y);"
"bvec4 lessThanEqual(ivec4 x, ivec4 y);"
-
+
"bvec2 greaterThan(vec2 x, vec2 y);"
"bvec3 greaterThan(vec3 x, vec3 y);"
"bvec4 greaterThan(vec4 x, vec4 y);"
-
+
"bvec2 greaterThan(ivec2 x, ivec2 y);"
"bvec3 greaterThan(ivec3 x, ivec3 y);"
"bvec4 greaterThan(ivec4 x, ivec4 y);"
-
+
"bvec2 greaterThanEqual(vec2 x, vec2 y);"
"bvec3 greaterThanEqual(vec3 x, vec3 y);"
"bvec4 greaterThanEqual(vec4 x, vec4 y);"
-
+
"bvec2 greaterThanEqual(ivec2 x, ivec2 y);"
"bvec3 greaterThanEqual(ivec3 x, ivec3 y);"
"bvec4 greaterThanEqual(ivec4 x, ivec4 y);"
-
+
"bvec2 equal(vec2 x, vec2 y);"
"bvec3 equal(vec3 x, vec3 y);"
"bvec4 equal(vec4 x, vec4 y);"
-
+
"bvec2 equal(ivec2 x, ivec2 y);"
"bvec3 equal(ivec3 x, ivec3 y);"
"bvec4 equal(ivec4 x, ivec4 y);"
-
+
"bvec2 equal(bvec2 x, bvec2 y);"
"bvec3 equal(bvec3 x, bvec3 y);"
"bvec4 equal(bvec4 x, bvec4 y);"
-
+
"bvec2 notEqual(vec2 x, vec2 y);"
"bvec3 notEqual(vec3 x, vec3 y);"
"bvec4 notEqual(vec4 x, vec4 y);"
-
+
"bvec2 notEqual(ivec2 x, ivec2 y);"
"bvec3 notEqual(ivec3 x, ivec3 y);"
"bvec4 notEqual(ivec4 x, ivec4 y);"
-
+
"bvec2 notEqual(bvec2 x, bvec2 y);"
"bvec3 notEqual(bvec3 x, bvec3 y);"
"bvec4 notEqual(bvec4 x, bvec4 y);"
-
+
"bool any(bvec2 x);"
"bool any(bvec3 x);"
"bool any(bvec4 x);"
-
+
"bool all(bvec2 x);"
"bool all(bvec3 x);"
"bool all(bvec4 x);"
-
+
"bvec2 not(bvec2 x);"
"bvec3 not(bvec3 x);"
"bvec4 not(bvec4 x);"
-
+
"\n");
if (version >= 130) {
@@ -1249,27 +1248,27 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"bvec2 lessThan(uvec2 x, uvec2 y);"
"bvec3 lessThan(uvec3 x, uvec3 y);"
"bvec4 lessThan(uvec4 x, uvec4 y);"
-
+
"bvec2 lessThanEqual(uvec2 x, uvec2 y);"
"bvec3 lessThanEqual(uvec3 x, uvec3 y);"
"bvec4 lessThanEqual(uvec4 x, uvec4 y);"
-
+
"bvec2 greaterThan(uvec2 x, uvec2 y);"
"bvec3 greaterThan(uvec3 x, uvec3 y);"
"bvec4 greaterThan(uvec4 x, uvec4 y);"
-
+
"bvec2 greaterThanEqual(uvec2 x, uvec2 y);"
"bvec3 greaterThanEqual(uvec3 x, uvec3 y);"
"bvec4 greaterThanEqual(uvec4 x, uvec4 y);"
-
+
"bvec2 equal(uvec2 x, uvec2 y);"
"bvec3 equal(uvec3 x, uvec3 y);"
"bvec4 equal(uvec4 x, uvec4 y);"
"bvec2 notEqual(uvec2 x, uvec2 y);"
"bvec3 notEqual(uvec3 x, uvec3 y);"
- "bvec4 notEqual(uvec4 x, uvec4 y);"
-
+ "bvec4 notEqual(uvec4 x, uvec4 y);"
+
"\n");
}
@@ -1292,7 +1291,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"vec4 texture3DProj(sampler3D, vec4);" // OES_texture_3D, but caught by keyword check
"vec4 textureCube(samplerCube, vec3);"
-
+
"\n");
}
}
@@ -1306,7 +1305,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"vec4 texture1DProj(sampler1D, vec2);"
"vec4 texture1DProj(sampler1D, vec4);"
-
+
"vec4 shadow1D(sampler1DShadow, vec3);"
"vec4 shadow2D(sampler2DShadow, vec3);"
"vec4 shadow1DProj(sampler1DShadow, vec4);"
@@ -1346,22 +1345,22 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"float noise1(vec2 x);"
"float noise1(vec3 x);"
"float noise1(vec4 x);"
-
+
"vec2 noise2(float x);"
"vec2 noise2(vec2 x);"
"vec2 noise2(vec3 x);"
"vec2 noise2(vec4 x);"
-
+
"vec3 noise3(float x);"
"vec3 noise3(vec2 x);"
"vec3 noise3(vec3 x);"
"vec3 noise3(vec4 x);"
-
+
"vec4 noise4(float x);"
"vec4 noise4(vec2 x);"
"vec4 noise4(vec3 x);"
"vec4 noise4(vec4 x);"
-
+
"\n");
}
@@ -1517,7 +1516,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"lowp ivec2 findMSB(highp uvec2);"
"lowp ivec3 findMSB(highp uvec3);"
"lowp ivec4 findMSB(highp uvec4);"
-
+
"\n");
}
@@ -1588,6 +1587,96 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"uvec3 minInvocationsAMD(uvec3);"
"uvec4 minInvocationsAMD(uvec4);"
+ "double minInvocationsAMD(double);"
+ "dvec2 minInvocationsAMD(dvec2);"
+ "dvec3 minInvocationsAMD(dvec3);"
+ "dvec4 minInvocationsAMD(dvec4);"
+
+ "int64_t minInvocationsAMD(int64_t);"
+ "i64vec2 minInvocationsAMD(i64vec2);"
+ "i64vec3 minInvocationsAMD(i64vec3);"
+ "i64vec4 minInvocationsAMD(i64vec4);"
+
+ "uint64_t minInvocationsAMD(uint64_t);"
+ "u64vec2 minInvocationsAMD(u64vec2);"
+ "u64vec3 minInvocationsAMD(u64vec3);"
+ "u64vec4 minInvocationsAMD(u64vec4);"
+
+ "float16_t minInvocationsAMD(float16_t);"
+ "f16vec2 minInvocationsAMD(f16vec2);"
+ "f16vec3 minInvocationsAMD(f16vec3);"
+ "f16vec4 minInvocationsAMD(f16vec4);"
+
+ "float minInvocationsInclusiveScanAMD(float);"
+ "vec2 minInvocationsInclusiveScanAMD(vec2);"
+ "vec3 minInvocationsInclusiveScanAMD(vec3);"
+ "vec4 minInvocationsInclusiveScanAMD(vec4);"
+
+ "int minInvocationsInclusiveScanAMD(int);"
+ "ivec2 minInvocationsInclusiveScanAMD(ivec2);"
+ "ivec3 minInvocationsInclusiveScanAMD(ivec3);"
+ "ivec4 minInvocationsInclusiveScanAMD(ivec4);"
+
+ "uint minInvocationsInclusiveScanAMD(uint);"
+ "uvec2 minInvocationsInclusiveScanAMD(uvec2);"
+ "uvec3 minInvocationsInclusiveScanAMD(uvec3);"
+ "uvec4 minInvocationsInclusiveScanAMD(uvec4);"
+
+ "double minInvocationsInclusiveScanAMD(double);"
+ "dvec2 minInvocationsInclusiveScanAMD(dvec2);"
+ "dvec3 minInvocationsInclusiveScanAMD(dvec3);"
+ "dvec4 minInvocationsInclusiveScanAMD(dvec4);"
+
+ "int64_t minInvocationsInclusiveScanAMD(int64_t);"
+ "i64vec2 minInvocationsInclusiveScanAMD(i64vec2);"
+ "i64vec3 minInvocationsInclusiveScanAMD(i64vec3);"
+ "i64vec4 minInvocationsInclusiveScanAMD(i64vec4);"
+
+ "uint64_t minInvocationsInclusiveScanAMD(uint64_t);"
+ "u64vec2 minInvocationsInclusiveScanAMD(u64vec2);"
+ "u64vec3 minInvocationsInclusiveScanAMD(u64vec3);"
+ "u64vec4 minInvocationsInclusiveScanAMD(u64vec4);"
+
+ "float16_t minInvocationsInclusiveScanAMD(float16_t);"
+ "f16vec2 minInvocationsInclusiveScanAMD(f16vec2);"
+ "f16vec3 minInvocationsInclusiveScanAMD(f16vec3);"
+ "f16vec4 minInvocationsInclusiveScanAMD(f16vec4);"
+
+ "float minInvocationsExclusiveScanAMD(float);"
+ "vec2 minInvocationsExclusiveScanAMD(vec2);"
+ "vec3 minInvocationsExclusiveScanAMD(vec3);"
+ "vec4 minInvocationsExclusiveScanAMD(vec4);"
+
+ "int minInvocationsExclusiveScanAMD(int);"
+ "ivec2 minInvocationsExclusiveScanAMD(ivec2);"
+ "ivec3 minInvocationsExclusiveScanAMD(ivec3);"
+ "ivec4 minInvocationsExclusiveScanAMD(ivec4);"
+
+ "uint minInvocationsExclusiveScanAMD(uint);"
+ "uvec2 minInvocationsExclusiveScanAMD(uvec2);"
+ "uvec3 minInvocationsExclusiveScanAMD(uvec3);"
+ "uvec4 minInvocationsExclusiveScanAMD(uvec4);"
+
+ "double minInvocationsExclusiveScanAMD(double);"
+ "dvec2 minInvocationsExclusiveScanAMD(dvec2);"
+ "dvec3 minInvocationsExclusiveScanAMD(dvec3);"
+ "dvec4 minInvocationsExclusiveScanAMD(dvec4);"
+
+ "int64_t minInvocationsExclusiveScanAMD(int64_t);"
+ "i64vec2 minInvocationsExclusiveScanAMD(i64vec2);"
+ "i64vec3 minInvocationsExclusiveScanAMD(i64vec3);"
+ "i64vec4 minInvocationsExclusiveScanAMD(i64vec4);"
+
+ "uint64_t minInvocationsExclusiveScanAMD(uint64_t);"
+ "u64vec2 minInvocationsExclusiveScanAMD(u64vec2);"
+ "u64vec3 minInvocationsExclusiveScanAMD(u64vec3);"
+ "u64vec4 minInvocationsExclusiveScanAMD(u64vec4);"
+
+ "float16_t minInvocationsExclusiveScanAMD(float16_t);"
+ "f16vec2 minInvocationsExclusiveScanAMD(f16vec2);"
+ "f16vec3 minInvocationsExclusiveScanAMD(f16vec3);"
+ "f16vec4 minInvocationsExclusiveScanAMD(f16vec4);"
+
"float maxInvocationsAMD(float);"
"vec2 maxInvocationsAMD(vec2);"
"vec3 maxInvocationsAMD(vec3);"
@@ -1603,6 +1692,96 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"uvec3 maxInvocationsAMD(uvec3);"
"uvec4 maxInvocationsAMD(uvec4);"
+ "double maxInvocationsAMD(double);"
+ "dvec2 maxInvocationsAMD(dvec2);"
+ "dvec3 maxInvocationsAMD(dvec3);"
+ "dvec4 maxInvocationsAMD(dvec4);"
+
+ "int64_t maxInvocationsAMD(int64_t);"
+ "i64vec2 maxInvocationsAMD(i64vec2);"
+ "i64vec3 maxInvocationsAMD(i64vec3);"
+ "i64vec4 maxInvocationsAMD(i64vec4);"
+
+ "uint64_t maxInvocationsAMD(uint64_t);"
+ "u64vec2 maxInvocationsAMD(u64vec2);"
+ "u64vec3 maxInvocationsAMD(u64vec3);"
+ "u64vec4 maxInvocationsAMD(u64vec4);"
+
+ "float16_t maxInvocationsAMD(float16_t);"
+ "f16vec2 maxInvocationsAMD(f16vec2);"
+ "f16vec3 maxInvocationsAMD(f16vec3);"
+ "f16vec4 maxInvocationsAMD(f16vec4);"
+
+ "float maxInvocationsInclusiveScanAMD(float);"
+ "vec2 maxInvocationsInclusiveScanAMD(vec2);"
+ "vec3 maxInvocationsInclusiveScanAMD(vec3);"
+ "vec4 maxInvocationsInclusiveScanAMD(vec4);"
+
+ "int maxInvocationsInclusiveScanAMD(int);"
+ "ivec2 maxInvocationsInclusiveScanAMD(ivec2);"
+ "ivec3 maxInvocationsInclusiveScanAMD(ivec3);"
+ "ivec4 maxInvocationsInclusiveScanAMD(ivec4);"
+
+ "uint maxInvocationsInclusiveScanAMD(uint);"
+ "uvec2 maxInvocationsInclusiveScanAMD(uvec2);"
+ "uvec3 maxInvocationsInclusiveScanAMD(uvec3);"
+ "uvec4 maxInvocationsInclusiveScanAMD(uvec4);"
+
+ "double maxInvocationsInclusiveScanAMD(double);"
+ "dvec2 maxInvocationsInclusiveScanAMD(dvec2);"
+ "dvec3 maxInvocationsInclusiveScanAMD(dvec3);"
+ "dvec4 maxInvocationsInclusiveScanAMD(dvec4);"
+
+ "int64_t maxInvocationsInclusiveScanAMD(int64_t);"
+ "i64vec2 maxInvocationsInclusiveScanAMD(i64vec2);"
+ "i64vec3 maxInvocationsInclusiveScanAMD(i64vec3);"
+ "i64vec4 maxInvocationsInclusiveScanAMD(i64vec4);"
+
+ "uint64_t maxInvocationsInclusiveScanAMD(uint64_t);"
+ "u64vec2 maxInvocationsInclusiveScanAMD(u64vec2);"
+ "u64vec3 maxInvocationsInclusiveScanAMD(u64vec3);"
+ "u64vec4 maxInvocationsInclusiveScanAMD(u64vec4);"
+
+ "float16_t maxInvocationsInclusiveScanAMD(float16_t);"
+ "f16vec2 maxInvocationsInclusiveScanAMD(f16vec2);"
+ "f16vec3 maxInvocationsInclusiveScanAMD(f16vec3);"
+ "f16vec4 maxInvocationsInclusiveScanAMD(f16vec4);"
+
+ "float maxInvocationsExclusiveScanAMD(float);"
+ "vec2 maxInvocationsExclusiveScanAMD(vec2);"
+ "vec3 maxInvocationsExclusiveScanAMD(vec3);"
+ "vec4 maxInvocationsExclusiveScanAMD(vec4);"
+
+ "int maxInvocationsExclusiveScanAMD(int);"
+ "ivec2 maxInvocationsExclusiveScanAMD(ivec2);"
+ "ivec3 maxInvocationsExclusiveScanAMD(ivec3);"
+ "ivec4 maxInvocationsExclusiveScanAMD(ivec4);"
+
+ "uint maxInvocationsExclusiveScanAMD(uint);"
+ "uvec2 maxInvocationsExclusiveScanAMD(uvec2);"
+ "uvec3 maxInvocationsExclusiveScanAMD(uvec3);"
+ "uvec4 maxInvocationsExclusiveScanAMD(uvec4);"
+
+ "double maxInvocationsExclusiveScanAMD(double);"
+ "dvec2 maxInvocationsExclusiveScanAMD(dvec2);"
+ "dvec3 maxInvocationsExclusiveScanAMD(dvec3);"
+ "dvec4 maxInvocationsExclusiveScanAMD(dvec4);"
+
+ "int64_t maxInvocationsExclusiveScanAMD(int64_t);"
+ "i64vec2 maxInvocationsExclusiveScanAMD(i64vec2);"
+ "i64vec3 maxInvocationsExclusiveScanAMD(i64vec3);"
+ "i64vec4 maxInvocationsExclusiveScanAMD(i64vec4);"
+
+ "uint64_t maxInvocationsExclusiveScanAMD(uint64_t);"
+ "u64vec2 maxInvocationsExclusiveScanAMD(u64vec2);"
+ "u64vec3 maxInvocationsExclusiveScanAMD(u64vec3);"
+ "u64vec4 maxInvocationsExclusiveScanAMD(u64vec4);"
+
+ "float16_t maxInvocationsExclusiveScanAMD(float16_t);"
+ "f16vec2 maxInvocationsExclusiveScanAMD(f16vec2);"
+ "f16vec3 maxInvocationsExclusiveScanAMD(f16vec3);"
+ "f16vec4 maxInvocationsExclusiveScanAMD(f16vec4);"
+
"float addInvocationsAMD(float);"
"vec2 addInvocationsAMD(vec2);"
"vec3 addInvocationsAMD(vec3);"
@@ -1618,6 +1797,96 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"uvec3 addInvocationsAMD(uvec3);"
"uvec4 addInvocationsAMD(uvec4);"
+ "double addInvocationsAMD(double);"
+ "dvec2 addInvocationsAMD(dvec2);"
+ "dvec3 addInvocationsAMD(dvec3);"
+ "dvec4 addInvocationsAMD(dvec4);"
+
+ "int64_t addInvocationsAMD(int64_t);"
+ "i64vec2 addInvocationsAMD(i64vec2);"
+ "i64vec3 addInvocationsAMD(i64vec3);"
+ "i64vec4 addInvocationsAMD(i64vec4);"
+
+ "uint64_t addInvocationsAMD(uint64_t);"
+ "u64vec2 addInvocationsAMD(u64vec2);"
+ "u64vec3 addInvocationsAMD(u64vec3);"
+ "u64vec4 addInvocationsAMD(u64vec4);"
+
+ "float16_t addInvocationsAMD(float16_t);"
+ "f16vec2 addInvocationsAMD(f16vec2);"
+ "f16vec3 addInvocationsAMD(f16vec3);"
+ "f16vec4 addInvocationsAMD(f16vec4);"
+
+ "float addInvocationsInclusiveScanAMD(float);"
+ "vec2 addInvocationsInclusiveScanAMD(vec2);"
+ "vec3 addInvocationsInclusiveScanAMD(vec3);"
+ "vec4 addInvocationsInclusiveScanAMD(vec4);"
+
+ "int addInvocationsInclusiveScanAMD(int);"
+ "ivec2 addInvocationsInclusiveScanAMD(ivec2);"
+ "ivec3 addInvocationsInclusiveScanAMD(ivec3);"
+ "ivec4 addInvocationsInclusiveScanAMD(ivec4);"
+
+ "uint addInvocationsInclusiveScanAMD(uint);"
+ "uvec2 addInvocationsInclusiveScanAMD(uvec2);"
+ "uvec3 addInvocationsInclusiveScanAMD(uvec3);"
+ "uvec4 addInvocationsInclusiveScanAMD(uvec4);"
+
+ "double addInvocationsInclusiveScanAMD(double);"
+ "dvec2 addInvocationsInclusiveScanAMD(dvec2);"
+ "dvec3 addInvocationsInclusiveScanAMD(dvec3);"
+ "dvec4 addInvocationsInclusiveScanAMD(dvec4);"
+
+ "int64_t addInvocationsInclusiveScanAMD(int64_t);"
+ "i64vec2 addInvocationsInclusiveScanAMD(i64vec2);"
+ "i64vec3 addInvocationsInclusiveScanAMD(i64vec3);"
+ "i64vec4 addInvocationsInclusiveScanAMD(i64vec4);"
+
+ "uint64_t addInvocationsInclusiveScanAMD(uint64_t);"
+ "u64vec2 addInvocationsInclusiveScanAMD(u64vec2);"
+ "u64vec3 addInvocationsInclusiveScanAMD(u64vec3);"
+ "u64vec4 addInvocationsInclusiveScanAMD(u64vec4);"
+
+ "float16_t addInvocationsInclusiveScanAMD(float16_t);"
+ "f16vec2 addInvocationsInclusiveScanAMD(f16vec2);"
+ "f16vec3 addInvocationsInclusiveScanAMD(f16vec3);"
+ "f16vec4 addInvocationsInclusiveScanAMD(f16vec4);"
+
+ "float addInvocationsExclusiveScanAMD(float);"
+ "vec2 addInvocationsExclusiveScanAMD(vec2);"
+ "vec3 addInvocationsExclusiveScanAMD(vec3);"
+ "vec4 addInvocationsExclusiveScanAMD(vec4);"
+
+ "int addInvocationsExclusiveScanAMD(int);"
+ "ivec2 addInvocationsExclusiveScanAMD(ivec2);"
+ "ivec3 addInvocationsExclusiveScanAMD(ivec3);"
+ "ivec4 addInvocationsExclusiveScanAMD(ivec4);"
+
+ "uint addInvocationsExclusiveScanAMD(uint);"
+ "uvec2 addInvocationsExclusiveScanAMD(uvec2);"
+ "uvec3 addInvocationsExclusiveScanAMD(uvec3);"
+ "uvec4 addInvocationsExclusiveScanAMD(uvec4);"
+
+ "double addInvocationsExclusiveScanAMD(double);"
+ "dvec2 addInvocationsExclusiveScanAMD(dvec2);"
+ "dvec3 addInvocationsExclusiveScanAMD(dvec3);"
+ "dvec4 addInvocationsExclusiveScanAMD(dvec4);"
+
+ "int64_t addInvocationsExclusiveScanAMD(int64_t);"
+ "i64vec2 addInvocationsExclusiveScanAMD(i64vec2);"
+ "i64vec3 addInvocationsExclusiveScanAMD(i64vec3);"
+ "i64vec4 addInvocationsExclusiveScanAMD(i64vec4);"
+
+ "uint64_t addInvocationsExclusiveScanAMD(uint64_t);"
+ "u64vec2 addInvocationsExclusiveScanAMD(u64vec2);"
+ "u64vec3 addInvocationsExclusiveScanAMD(u64vec3);"
+ "u64vec4 addInvocationsExclusiveScanAMD(u64vec4);"
+
+ "float16_t addInvocationsExclusiveScanAMD(float16_t);"
+ "f16vec2 addInvocationsExclusiveScanAMD(f16vec2);"
+ "f16vec3 addInvocationsExclusiveScanAMD(f16vec3);"
+ "f16vec4 addInvocationsExclusiveScanAMD(f16vec4);"
+
"float minInvocationsNonUniformAMD(float);"
"vec2 minInvocationsNonUniformAMD(vec2);"
"vec3 minInvocationsNonUniformAMD(vec3);"
@@ -1633,6 +1902,96 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"uvec3 minInvocationsNonUniformAMD(uvec3);"
"uvec4 minInvocationsNonUniformAMD(uvec4);"
+ "double minInvocationsNonUniformAMD(double);"
+ "dvec2 minInvocationsNonUniformAMD(dvec2);"
+ "dvec3 minInvocationsNonUniformAMD(dvec3);"
+ "dvec4 minInvocationsNonUniformAMD(dvec4);"
+
+ "int64_t minInvocationsNonUniformAMD(int64_t);"
+ "i64vec2 minInvocationsNonUniformAMD(i64vec2);"
+ "i64vec3 minInvocationsNonUniformAMD(i64vec3);"
+ "i64vec4 minInvocationsNonUniformAMD(i64vec4);"
+
+ "uint64_t minInvocationsNonUniformAMD(uint64_t);"
+ "u64vec2 minInvocationsNonUniformAMD(u64vec2);"
+ "u64vec3 minInvocationsNonUniformAMD(u64vec3);"
+ "u64vec4 minInvocationsNonUniformAMD(u64vec4);"
+
+ "float16_t minInvocationsNonUniformAMD(float16_t);"
+ "f16vec2 minInvocationsNonUniformAMD(f16vec2);"
+ "f16vec3 minInvocationsNonUniformAMD(f16vec3);"
+ "f16vec4 minInvocationsNonUniformAMD(f16vec4);"
+
+ "float minInvocationsInclusiveScanNonUniformAMD(float);"
+ "vec2 minInvocationsInclusiveScanNonUniformAMD(vec2);"
+ "vec3 minInvocationsInclusiveScanNonUniformAMD(vec3);"
+ "vec4 minInvocationsInclusiveScanNonUniformAMD(vec4);"
+
+ "int minInvocationsInclusiveScanNonUniformAMD(int);"
+ "ivec2 minInvocationsInclusiveScanNonUniformAMD(ivec2);"
+ "ivec3 minInvocationsInclusiveScanNonUniformAMD(ivec3);"
+ "ivec4 minInvocationsInclusiveScanNonUniformAMD(ivec4);"
+
+ "uint minInvocationsInclusiveScanNonUniformAMD(uint);"
+ "uvec2 minInvocationsInclusiveScanNonUniformAMD(uvec2);"
+ "uvec3 minInvocationsInclusiveScanNonUniformAMD(uvec3);"
+ "uvec4 minInvocationsInclusiveScanNonUniformAMD(uvec4);"
+
+ "double minInvocationsInclusiveScanNonUniformAMD(double);"
+ "dvec2 minInvocationsInclusiveScanNonUniformAMD(dvec2);"
+ "dvec3 minInvocationsInclusiveScanNonUniformAMD(dvec3);"
+ "dvec4 minInvocationsInclusiveScanNonUniformAMD(dvec4);"
+
+ "int64_t minInvocationsInclusiveScanNonUniformAMD(int64_t);"
+ "i64vec2 minInvocationsInclusiveScanNonUniformAMD(i64vec2);"
+ "i64vec3 minInvocationsInclusiveScanNonUniformAMD(i64vec3);"
+ "i64vec4 minInvocationsInclusiveScanNonUniformAMD(i64vec4);"
+
+ "uint64_t minInvocationsInclusiveScanNonUniformAMD(uint64_t);"
+ "u64vec2 minInvocationsInclusiveScanNonUniformAMD(u64vec2);"
+ "u64vec3 minInvocationsInclusiveScanNonUniformAMD(u64vec3);"
+ "u64vec4 minInvocationsInclusiveScanNonUniformAMD(u64vec4);"
+
+ "float16_t minInvocationsInclusiveScanNonUniformAMD(float16_t);"
+ "f16vec2 minInvocationsInclusiveScanNonUniformAMD(f16vec2);"
+ "f16vec3 minInvocationsInclusiveScanNonUniformAMD(f16vec3);"
+ "f16vec4 minInvocationsInclusiveScanNonUniformAMD(f16vec4);"
+
+ "float minInvocationsExclusiveScanNonUniformAMD(float);"
+ "vec2 minInvocationsExclusiveScanNonUniformAMD(vec2);"
+ "vec3 minInvocationsExclusiveScanNonUniformAMD(vec3);"
+ "vec4 minInvocationsExclusiveScanNonUniformAMD(vec4);"
+
+ "int minInvocationsExclusiveScanNonUniformAMD(int);"
+ "ivec2 minInvocationsExclusiveScanNonUniformAMD(ivec2);"
+ "ivec3 minInvocationsExclusiveScanNonUniformAMD(ivec3);"
+ "ivec4 minInvocationsExclusiveScanNonUniformAMD(ivec4);"
+
+ "uint minInvocationsExclusiveScanNonUniformAMD(uint);"
+ "uvec2 minInvocationsExclusiveScanNonUniformAMD(uvec2);"
+ "uvec3 minInvocationsExclusiveScanNonUniformAMD(uvec3);"
+ "uvec4 minInvocationsExclusiveScanNonUniformAMD(uvec4);"
+
+ "double minInvocationsExclusiveScanNonUniformAMD(double);"
+ "dvec2 minInvocationsExclusiveScanNonUniformAMD(dvec2);"
+ "dvec3 minInvocationsExclusiveScanNonUniformAMD(dvec3);"
+ "dvec4 minInvocationsExclusiveScanNonUniformAMD(dvec4);"
+
+ "int64_t minInvocationsExclusiveScanNonUniformAMD(int64_t);"
+ "i64vec2 minInvocationsExclusiveScanNonUniformAMD(i64vec2);"
+ "i64vec3 minInvocationsExclusiveScanNonUniformAMD(i64vec3);"
+ "i64vec4 minInvocationsExclusiveScanNonUniformAMD(i64vec4);"
+
+ "uint64_t minInvocationsExclusiveScanNonUniformAMD(uint64_t);"
+ "u64vec2 minInvocationsExclusiveScanNonUniformAMD(u64vec2);"
+ "u64vec3 minInvocationsExclusiveScanNonUniformAMD(u64vec3);"
+ "u64vec4 minInvocationsExclusiveScanNonUniformAMD(u64vec4);"
+
+ "float16_t minInvocationsExclusiveScanNonUniformAMD(float16_t);"
+ "f16vec2 minInvocationsExclusiveScanNonUniformAMD(f16vec2);"
+ "f16vec3 minInvocationsExclusiveScanNonUniformAMD(f16vec3);"
+ "f16vec4 minInvocationsExclusiveScanNonUniformAMD(f16vec4);"
+
"float maxInvocationsNonUniformAMD(float);"
"vec2 maxInvocationsNonUniformAMD(vec2);"
"vec3 maxInvocationsNonUniformAMD(vec3);"
@@ -1648,6 +2007,96 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"uvec3 maxInvocationsNonUniformAMD(uvec3);"
"uvec4 maxInvocationsNonUniformAMD(uvec4);"
+ "double maxInvocationsNonUniformAMD(double);"
+ "dvec2 maxInvocationsNonUniformAMD(dvec2);"
+ "dvec3 maxInvocationsNonUniformAMD(dvec3);"
+ "dvec4 maxInvocationsNonUniformAMD(dvec4);"
+
+ "int64_t maxInvocationsNonUniformAMD(int64_t);"
+ "i64vec2 maxInvocationsNonUniformAMD(i64vec2);"
+ "i64vec3 maxInvocationsNonUniformAMD(i64vec3);"
+ "i64vec4 maxInvocationsNonUniformAMD(i64vec4);"
+
+ "uint64_t maxInvocationsNonUniformAMD(uint64_t);"
+ "u64vec2 maxInvocationsNonUniformAMD(u64vec2);"
+ "u64vec3 maxInvocationsNonUniformAMD(u64vec3);"
+ "u64vec4 maxInvocationsNonUniformAMD(u64vec4);"
+
+ "float16_t maxInvocationsNonUniformAMD(float16_t);"
+ "f16vec2 maxInvocationsNonUniformAMD(f16vec2);"
+ "f16vec3 maxInvocationsNonUniformAMD(f16vec3);"
+ "f16vec4 maxInvocationsNonUniformAMD(f16vec4);"
+
+ "float maxInvocationsInclusiveScanNonUniformAMD(float);"
+ "vec2 maxInvocationsInclusiveScanNonUniformAMD(vec2);"
+ "vec3 maxInvocationsInclusiveScanNonUniformAMD(vec3);"
+ "vec4 maxInvocationsInclusiveScanNonUniformAMD(vec4);"
+
+ "int maxInvocationsInclusiveScanNonUniformAMD(int);"
+ "ivec2 maxInvocationsInclusiveScanNonUniformAMD(ivec2);"
+ "ivec3 maxInvocationsInclusiveScanNonUniformAMD(ivec3);"
+ "ivec4 maxInvocationsInclusiveScanNonUniformAMD(ivec4);"
+
+ "uint maxInvocationsInclusiveScanNonUniformAMD(uint);"
+ "uvec2 maxInvocationsInclusiveScanNonUniformAMD(uvec2);"
+ "uvec3 maxInvocationsInclusiveScanNonUniformAMD(uvec3);"
+ "uvec4 maxInvocationsInclusiveScanNonUniformAMD(uvec4);"
+
+ "double maxInvocationsInclusiveScanNonUniformAMD(double);"
+ "dvec2 maxInvocationsInclusiveScanNonUniformAMD(dvec2);"
+ "dvec3 maxInvocationsInclusiveScanNonUniformAMD(dvec3);"
+ "dvec4 maxInvocationsInclusiveScanNonUniformAMD(dvec4);"
+
+ "int64_t maxInvocationsInclusiveScanNonUniformAMD(int64_t);"
+ "i64vec2 maxInvocationsInclusiveScanNonUniformAMD(i64vec2);"
+ "i64vec3 maxInvocationsInclusiveScanNonUniformAMD(i64vec3);"
+ "i64vec4 maxInvocationsInclusiveScanNonUniformAMD(i64vec4);"
+
+ "uint64_t maxInvocationsInclusiveScanNonUniformAMD(uint64_t);"
+ "u64vec2 maxInvocationsInclusiveScanNonUniformAMD(u64vec2);"
+ "u64vec3 maxInvocationsInclusiveScanNonUniformAMD(u64vec3);"
+ "u64vec4 maxInvocationsInclusiveScanNonUniformAMD(u64vec4);"
+
+ "float16_t maxInvocationsInclusiveScanNonUniformAMD(float16_t);"
+ "f16vec2 maxInvocationsInclusiveScanNonUniformAMD(f16vec2);"
+ "f16vec3 maxInvocationsInclusiveScanNonUniformAMD(f16vec3);"
+ "f16vec4 maxInvocationsInclusiveScanNonUniformAMD(f16vec4);"
+
+ "float maxInvocationsExclusiveScanNonUniformAMD(float);"
+ "vec2 maxInvocationsExclusiveScanNonUniformAMD(vec2);"
+ "vec3 maxInvocationsExclusiveScanNonUniformAMD(vec3);"
+ "vec4 maxInvocationsExclusiveScanNonUniformAMD(vec4);"
+
+ "int maxInvocationsExclusiveScanNonUniformAMD(int);"
+ "ivec2 maxInvocationsExclusiveScanNonUniformAMD(ivec2);"
+ "ivec3 maxInvocationsExclusiveScanNonUniformAMD(ivec3);"
+ "ivec4 maxInvocationsExclusiveScanNonUniformAMD(ivec4);"
+
+ "uint maxInvocationsExclusiveScanNonUniformAMD(uint);"
+ "uvec2 maxInvocationsExclusiveScanNonUniformAMD(uvec2);"
+ "uvec3 maxInvocationsExclusiveScanNonUniformAMD(uvec3);"
+ "uvec4 maxInvocationsExclusiveScanNonUniformAMD(uvec4);"
+
+ "double maxInvocationsExclusiveScanNonUniformAMD(double);"
+ "dvec2 maxInvocationsExclusiveScanNonUniformAMD(dvec2);"
+ "dvec3 maxInvocationsExclusiveScanNonUniformAMD(dvec3);"
+ "dvec4 maxInvocationsExclusiveScanNonUniformAMD(dvec4);"
+
+ "int64_t maxInvocationsExclusiveScanNonUniformAMD(int64_t);"
+ "i64vec2 maxInvocationsExclusiveScanNonUniformAMD(i64vec2);"
+ "i64vec3 maxInvocationsExclusiveScanNonUniformAMD(i64vec3);"
+ "i64vec4 maxInvocationsExclusiveScanNonUniformAMD(i64vec4);"
+
+ "uint64_t maxInvocationsExclusiveScanNonUniformAMD(uint64_t);"
+ "u64vec2 maxInvocationsExclusiveScanNonUniformAMD(u64vec2);"
+ "u64vec3 maxInvocationsExclusiveScanNonUniformAMD(u64vec3);"
+ "u64vec4 maxInvocationsExclusiveScanNonUniformAMD(u64vec4);"
+
+ "float16_t maxInvocationsExclusiveScanNonUniformAMD(float16_t);"
+ "f16vec2 maxInvocationsExclusiveScanNonUniformAMD(f16vec2);"
+ "f16vec3 maxInvocationsExclusiveScanNonUniformAMD(f16vec3);"
+ "f16vec4 maxInvocationsExclusiveScanNonUniformAMD(f16vec4);"
+
"float addInvocationsNonUniformAMD(float);"
"vec2 addInvocationsNonUniformAMD(vec2);"
"vec3 addInvocationsNonUniformAMD(vec3);"
@@ -1663,6 +2112,96 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"uvec3 addInvocationsNonUniformAMD(uvec3);"
"uvec4 addInvocationsNonUniformAMD(uvec4);"
+ "double addInvocationsNonUniformAMD(double);"
+ "dvec2 addInvocationsNonUniformAMD(dvec2);"
+ "dvec3 addInvocationsNonUniformAMD(dvec3);"
+ "dvec4 addInvocationsNonUniformAMD(dvec4);"
+
+ "int64_t addInvocationsNonUniformAMD(int64_t);"
+ "i64vec2 addInvocationsNonUniformAMD(i64vec2);"
+ "i64vec3 addInvocationsNonUniformAMD(i64vec3);"
+ "i64vec4 addInvocationsNonUniformAMD(i64vec4);"
+
+ "uint64_t addInvocationsNonUniformAMD(uint64_t);"
+ "u64vec2 addInvocationsNonUniformAMD(u64vec2);"
+ "u64vec3 addInvocationsNonUniformAMD(u64vec3);"
+ "u64vec4 addInvocationsNonUniformAMD(u64vec4);"
+
+ "float16_t addInvocationsNonUniformAMD(float16_t);"
+ "f16vec2 addInvocationsNonUniformAMD(f16vec2);"
+ "f16vec3 addInvocationsNonUniformAMD(f16vec3);"
+ "f16vec4 addInvocationsNonUniformAMD(f16vec4);"
+
+ "float addInvocationsInclusiveScanNonUniformAMD(float);"
+ "vec2 addInvocationsInclusiveScanNonUniformAMD(vec2);"
+ "vec3 addInvocationsInclusiveScanNonUniformAMD(vec3);"
+ "vec4 addInvocationsInclusiveScanNonUniformAMD(vec4);"
+
+ "int addInvocationsInclusiveScanNonUniformAMD(int);"
+ "ivec2 addInvocationsInclusiveScanNonUniformAMD(ivec2);"
+ "ivec3 addInvocationsInclusiveScanNonUniformAMD(ivec3);"
+ "ivec4 addInvocationsInclusiveScanNonUniformAMD(ivec4);"
+
+ "uint addInvocationsInclusiveScanNonUniformAMD(uint);"
+ "uvec2 addInvocationsInclusiveScanNonUniformAMD(uvec2);"
+ "uvec3 addInvocationsInclusiveScanNonUniformAMD(uvec3);"
+ "uvec4 addInvocationsInclusiveScanNonUniformAMD(uvec4);"
+
+ "double addInvocationsInclusiveScanNonUniformAMD(double);"
+ "dvec2 addInvocationsInclusiveScanNonUniformAMD(dvec2);"
+ "dvec3 addInvocationsInclusiveScanNonUniformAMD(dvec3);"
+ "dvec4 addInvocationsInclusiveScanNonUniformAMD(dvec4);"
+
+ "int64_t addInvocationsInclusiveScanNonUniformAMD(int64_t);"
+ "i64vec2 addInvocationsInclusiveScanNonUniformAMD(i64vec2);"
+ "i64vec3 addInvocationsInclusiveScanNonUniformAMD(i64vec3);"
+ "i64vec4 addInvocationsInclusiveScanNonUniformAMD(i64vec4);"
+
+ "uint64_t addInvocationsInclusiveScanNonUniformAMD(uint64_t);"
+ "u64vec2 addInvocationsInclusiveScanNonUniformAMD(u64vec2);"
+ "u64vec3 addInvocationsInclusiveScanNonUniformAMD(u64vec3);"
+ "u64vec4 addInvocationsInclusiveScanNonUniformAMD(u64vec4);"
+
+ "float16_t addInvocationsInclusiveScanNonUniformAMD(float16_t);"
+ "f16vec2 addInvocationsInclusiveScanNonUniformAMD(f16vec2);"
+ "f16vec3 addInvocationsInclusiveScanNonUniformAMD(f16vec3);"
+ "f16vec4 addInvocationsInclusiveScanNonUniformAMD(f16vec4);"
+
+ "float addInvocationsExclusiveScanNonUniformAMD(float);"
+ "vec2 addInvocationsExclusiveScanNonUniformAMD(vec2);"
+ "vec3 addInvocationsExclusiveScanNonUniformAMD(vec3);"
+ "vec4 addInvocationsExclusiveScanNonUniformAMD(vec4);"
+
+ "int addInvocationsExclusiveScanNonUniformAMD(int);"
+ "ivec2 addInvocationsExclusiveScanNonUniformAMD(ivec2);"
+ "ivec3 addInvocationsExclusiveScanNonUniformAMD(ivec3);"
+ "ivec4 addInvocationsExclusiveScanNonUniformAMD(ivec4);"
+
+ "uint addInvocationsExclusiveScanNonUniformAMD(uint);"
+ "uvec2 addInvocationsExclusiveScanNonUniformAMD(uvec2);"
+ "uvec3 addInvocationsExclusiveScanNonUniformAMD(uvec3);"
+ "uvec4 addInvocationsExclusiveScanNonUniformAMD(uvec4);"
+
+ "double addInvocationsExclusiveScanNonUniformAMD(double);"
+ "dvec2 addInvocationsExclusiveScanNonUniformAMD(dvec2);"
+ "dvec3 addInvocationsExclusiveScanNonUniformAMD(dvec3);"
+ "dvec4 addInvocationsExclusiveScanNonUniformAMD(dvec4);"
+
+ "int64_t addInvocationsExclusiveScanNonUniformAMD(int64_t);"
+ "i64vec2 addInvocationsExclusiveScanNonUniformAMD(i64vec2);"
+ "i64vec3 addInvocationsExclusiveScanNonUniformAMD(i64vec3);"
+ "i64vec4 addInvocationsExclusiveScanNonUniformAMD(i64vec4);"
+
+ "uint64_t addInvocationsExclusiveScanNonUniformAMD(uint64_t);"
+ "u64vec2 addInvocationsExclusiveScanNonUniformAMD(u64vec2);"
+ "u64vec3 addInvocationsExclusiveScanNonUniformAMD(u64vec3);"
+ "u64vec4 addInvocationsExclusiveScanNonUniformAMD(u64vec4);"
+
+ "float16_t addInvocationsExclusiveScanNonUniformAMD(float16_t);"
+ "f16vec2 addInvocationsExclusiveScanNonUniformAMD(f16vec2);"
+ "f16vec3 addInvocationsExclusiveScanNonUniformAMD(f16vec3);"
+ "f16vec4 addInvocationsExclusiveScanNonUniformAMD(f16vec4);"
+
"float swizzleInvocationsAMD(float, uvec4);"
"vec2 swizzleInvocationsAMD(vec2, uvec4);"
"vec3 swizzleInvocationsAMD(vec3, uvec4);"
@@ -2243,7 +2782,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"vec2 dFdx(vec2 p);"
"vec3 dFdx(vec3 p);"
"vec4 dFdx(vec4 p);"
-
+
"float dFdy(float p);"
"vec2 dFdy(vec2 p);"
"vec3 dFdy(vec3 p);"
@@ -2286,12 +2825,12 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"vec2 dFdyCoarse(vec2 p);"
"vec3 dFdyCoarse(vec3 p);"
"vec4 dFdyCoarse(vec4 p);"
-
+
"float fwidthCoarse(float p);"
"vec2 fwidthCoarse(vec2 p);"
"vec3 fwidthCoarse(vec3 p);"
"vec4 fwidthCoarse(vec4 p);"
-
+
"\n");
}
@@ -2462,11 +3001,11 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"uniform mat4 gl_ModelViewMatrixInverse;"
"uniform mat4 gl_ProjectionMatrixInverse;"
"uniform mat4 gl_ModelViewProjectionMatrixInverse;"
-
+
"uniform mat4 gl_ModelViewMatrixTranspose;"
"uniform mat4 gl_ProjectionMatrixTranspose;"
"uniform mat4 gl_ModelViewProjectionMatrixTranspose;"
-
+
"uniform mat4 gl_ModelViewMatrixInverseTranspose;"
"uniform mat4 gl_ProjectionMatrixInverseTranspose;"
"uniform mat4 gl_ModelViewProjectionMatrixInverseTranspose;"
@@ -2524,7 +3063,6 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"float quadraticAttenuation;"// K2
"};"
-
"struct gl_LightModelParameters {"
"vec4 ambient;" // Acs
"};"
@@ -2559,7 +3097,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"};"
"uniform gl_FogParameters gl_Fog;"
-
+
"\n");
}
@@ -2589,7 +3127,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
// Define the interface to the vertex shader.
//
//============================================================================
-
+
if (profile != EEsProfile) {
if (version < 130) {
stageBuiltins[EShLangVertex].append(
@@ -2621,7 +3159,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"in vec4 gl_MultiTexCoord5;"
"in vec4 gl_MultiTexCoord6;"
"in vec4 gl_MultiTexCoord7;"
- "in float gl_FogCoord;"
+ "in float gl_FogCoord;"
"\n");
}
@@ -2663,7 +3201,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"vec4 gl_Position;" // needs qualifier fixed later
"float gl_PointSize;" // needs qualifier fixed later
"float gl_ClipDistance[];"
- );
+ );
if (IncludeLegacy(version, profile, spvVersion))
stageBuiltins[EShLangVertex].append(
"vec4 gl_ClipVertex;" // needs qualifier fixed later
@@ -2702,6 +3240,18 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"in int gl_DrawIDARB;"
);
}
+
+#ifdef NV_EXTENSIONS
+ if (version >= 450)
+ stageBuiltins[EShLangVertex].append(
+ "out int gl_ViewportIndex;"
+ "out int gl_Layer;"
+ "out int gl_ViewportMask[];"
+ "out int gl_SecondaryViewportMaskNV[];"
+ "out vec4 gl_SecondaryPositionNV;"
+ );
+#endif
+
} else {
// ES profile
if (version == 100) {
@@ -2761,6 +3311,9 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
if (version >= 450)
stageBuiltins[EShLangGeometry].append(
"float gl_CullDistance[];"
+#ifdef NV_EXTENSIONS
+ "vec4 gl_SecondaryPositionNV;"
+#endif
);
stageBuiltins[EShLangGeometry].append(
"} gl_in[];"
@@ -2805,6 +3358,16 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
stageBuiltins[EShLangGeometry].append(
"out int gl_ViewportIndex;"
);
+
+#ifdef NV_EXTENSIONS
+ if (version >= 450)
+ stageBuiltins[EShLangGeometry].append(
+ "out int gl_ViewportMask[];"
+ "out int gl_SecondaryViewportMaskNV[];"
+ "out vec4 gl_SecondaryPositionNV;"
+ );
+#endif
+
stageBuiltins[EShLangGeometry].append("\n");
} else if (profile == EEsProfile && version >= 310) {
stageBuiltins[EShLangGeometry].append(
@@ -2827,7 +3390,6 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
);
}
-
//============================================================================
//
// Define the interface to the tessellation control shader.
@@ -2861,6 +3423,13 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
if (version >= 450)
stageBuiltins[EShLangTessControl].append(
"float gl_CullDistance[];"
+#ifdef NV_EXTENSIONS
+ "int gl_ViewportIndex;"
+ "int gl_Layer;"
+ "int gl_ViewportMask[];"
+ "vec4 gl_SecondaryPositionNV;"
+ "int gl_SecondaryViewportMaskNV[];"
+#endif
);
stageBuiltins[EShLangTessControl].append(
"} gl_out[];"
@@ -2907,7 +3476,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"patch in float gl_TessLevelOuter[4];"
"patch in float gl_TessLevelInner[2];"
-
+
"out gl_PerVertex {"
"vec4 gl_Position;"
"float gl_PointSize;"
@@ -2930,6 +3499,18 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
stageBuiltins[EShLangTessEvaluation].append(
"};"
"\n");
+
+#ifdef NV_EXTENSIONS
+ if (version >= 450)
+ stageBuiltins[EShLangTessEvaluation].append(
+ "out int gl_ViewportIndex;"
+ "out int gl_Layer;"
+ "out int gl_ViewportMask[];"
+ "out vec4 gl_SecondaryPositionNV;"
+ "out int gl_SecondaryViewportMaskNV[];"
+ );
+#endif
+
} else if (profile == EEsProfile && version >= 310) {
// Note: "in gl_PerVertex {...} gl_in[gl_MaxPatchVertices];" is declared in initialize() below,
// as it depends on the resource sizing of gl_MaxPatchVertices.
@@ -2941,7 +3522,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"patch in highp float gl_TessLevelOuter[4];"
"patch in highp float gl_TessLevelInner[2];"
-
+
"out gl_PerVertex {"
"highp vec4 gl_Position;"
"highp float gl_PointSize;"
@@ -3010,14 +3591,18 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"flat in int gl_PrimitiveID;"
);
- if (version >= 400)
+ if (version >= 400) {
stageBuiltins[EShLangFragment].append(
"flat in int gl_SampleID;"
" in vec2 gl_SamplePosition;"
"flat in int gl_SampleMaskIn[];"
" out int gl_SampleMask[];"
- "uniform int gl_NumSamples;"
);
+ if (spvVersion.spv == 0)
+ stageBuiltins[EShLangFragment].append(
+ "uniform int gl_NumSamples;"
+ );
+ }
if (version >= 430)
stageBuiltins[EShLangFragment].append(
@@ -3074,8 +3659,11 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
" in mediump vec2 gl_SamplePosition;"
"flat in highp int gl_SampleMaskIn[];"
" out highp int gl_SampleMask[];"
- "uniform lowp int gl_NumSamples;"
);
+ if (spvVersion.spv == 0)
+ stageBuiltins[EShLangFragment].append( // GL_OES_sample_variables
+ "uniform lowp int gl_NumSamples;"
+ );
}
stageBuiltins[EShLangFragment].append(
"highp float gl_FragDepthEXT;" // GL_EXT_frag_depth
@@ -3101,12 +3689,12 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"\n");
}
- //printf("%s\n", commonBuiltins.c_str());
- //printf("%s\n", stageBuiltins[EShLangFragment].c_str());
+ // printf("%s\n", commonBuiltins.c_str());
+ // printf("%s\n", stageBuiltins[EShLangFragment].c_str());
}
//
-// Helper function for initialize(), to add the second set of names for texturing,
+// Helper function for initialize(), to add the second set of names for texturing,
// when adding context-independent built-in functions.
//
void TBuiltIns::add2ndGenerationSamplingImaging(int version, EProfile profile, const SpvVersion& spvVersion)
@@ -3214,7 +3802,7 @@ void TBuiltIns::add2ndGenerationSamplingImaging(int version, EProfile profile, c
}
//
-// Helper function for add2ndGenerationSamplingImaging(),
+// Helper function for add2ndGenerationSamplingImaging(),
// when adding context-independent built-in functions.
//
// Add all the query functions for the given type.
@@ -3291,7 +3879,7 @@ void TBuiltIns::addQueryFunctions(TSampler sampler, TString& typeName, int versi
}
//
-// Helper function for add2ndGenerationSamplingImaging(),
+// Helper function for add2ndGenerationSamplingImaging(),
// when adding context-independent built-in functions.
//
// Add all the image access functions for the given type.
@@ -3350,7 +3938,7 @@ void TBuiltIns::addImageFunctions(TSampler sampler, TString& typeName, int versi
" imageAtomicOr(volatile coherent ",
" imageAtomicXor(volatile coherent ",
" imageAtomicExchange(volatile coherent "
- };
+ };
for (size_t i = 0; i < numBuiltins; ++i) {
commonBuiltins.append(dataType);
@@ -3401,7 +3989,7 @@ void TBuiltIns::addSubpassSampling(TSampler sampler, TString& typeName, int /*ve
}
//
-// Helper function for add2ndGenerationSamplingImaging(),
+// Helper function for add2ndGenerationSamplingImaging(),
// when adding context-independent built-in functions.
//
// Add all the texture lookup functions for the given type.
@@ -3615,7 +4203,7 @@ void TBuiltIns::addSamplingFunctions(TSampler sampler, TString& typeName, int ve
// Add to the per-language set of built-ins
- if (bias)
+ if (bias || lodClamp)
stageBuiltins[EShLangFragment].append(s);
else
commonBuiltins.append(s);
@@ -3630,9 +4218,8 @@ void TBuiltIns::addSamplingFunctions(TSampler sampler, TString& typeName, int ve
}
}
-
//
-// Helper function for add2ndGenerationSamplingImaging(),
+// Helper function for add2ndGenerationSamplingImaging(),
// when adding context-independent built-in functions.
//
// Add all the texture gather functions for the given type.
@@ -3833,7 +4420,7 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
s.append(builtInConstant);
snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlTotalOutputComponents = %d;", resources.maxTessControlTotalOutputComponents);
s.append(builtInConstant);
-
+
snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationInputComponents = %d;", resources.maxTessEvaluationInputComponents);
s.append(builtInConstant);
snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationOutputComponents = %d;", resources.maxTessEvaluationOutputComponents);
@@ -3842,7 +4429,7 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
s.append(builtInConstant);
snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationUniformComponents = %d;", resources.maxTessEvaluationUniformComponents);
s.append(builtInConstant);
-
+
snprintf(builtInConstant, maxSize, "const int gl_MaxTessPatchComponents = %d;", resources.maxTessPatchComponents);
s.append(builtInConstant);
@@ -3857,6 +4444,9 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
"in gl_PerVertex {"
"highp vec4 gl_Position;"
"highp float gl_PointSize;"
+#ifdef NV_EXTENSIONS
+ "highp vec4 gl_SecondaryPositionNV;"
+#endif
"} gl_in[gl_MaxPatchVertices];"
"\n");
}
@@ -4005,7 +4595,7 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
s.append(builtInConstant);
snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlTotalOutputComponents = %d;", resources.maxTessControlTotalOutputComponents);
s.append(builtInConstant);
-
+
snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationInputComponents = %d;", resources.maxTessEvaluationInputComponents);
s.append(builtInConstant);
snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationOutputComponents = %d;", resources.maxTessEvaluationOutputComponents);
@@ -4014,7 +4604,7 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
s.append(builtInConstant);
snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationUniformComponents = %d;", resources.maxTessEvaluationUniformComponents);
s.append(builtInConstant);
-
+
snprintf(builtInConstant, maxSize, "const int gl_MaxTessPatchComponents = %d;", resources.maxTessPatchComponents);
s.append(builtInConstant);
snprintf(builtInConstant, maxSize, "const int gl_MaxTessGenLevel = %d;", resources.maxTessGenLevel);
@@ -4043,6 +4633,9 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
if (profile != EEsProfile && version >= 450)
s.append(
"float gl_CullDistance[];"
+#ifdef NV_EXTENSIONS
+ "vec4 gl_SecondaryPositionNV;"
+#endif
);
s.append(
"} gl_in[gl_MaxPatchVertices];"
@@ -4079,7 +4672,7 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
}
// images (some in compute below)
- if ((profile == EEsProfile && version >= 310) ||
+ if ((profile == EEsProfile && version >= 310) ||
(profile != EEsProfile && version >= 130)) {
snprintf(builtInConstant, maxSize, "const int gl_MaxImageUnits = %d;", resources.maxImageUnits);
s.append(builtInConstant);
@@ -4094,7 +4687,7 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
}
// atomic counters (some in compute below)
- if ((profile == EEsProfile && version >= 310) ||
+ if ((profile == EEsProfile && version >= 310) ||
(profile != EEsProfile && version >= 420)) {
snprintf(builtInConstant, maxSize, "const int gl_MaxVertexAtomicCounters = %d;", resources. maxVertexAtomicCounters);
s.append(builtInConstant);
@@ -4130,12 +4723,11 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
s.append("\n");
}
-
// compute
if ((profile == EEsProfile && version >= 310) || (profile != EEsProfile && version >= 420)) {
snprintf(builtInConstant, maxSize, "const ivec3 gl_MaxComputeWorkGroupCount = ivec3(%d,%d,%d);", resources.maxComputeWorkGroupCountX,
resources.maxComputeWorkGroupCountY,
- resources.maxComputeWorkGroupCountZ);
+ resources.maxComputeWorkGroupCountZ);
s.append(builtInConstant);
snprintf(builtInConstant, maxSize, "const ivec3 gl_MaxComputeWorkGroupSize = ivec3(%d,%d,%d);", resources.maxComputeWorkGroupSizeX,
resources.maxComputeWorkGroupSizeY,
@@ -4265,7 +4857,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
// N.B.: a symbol should only be tagged once, and this function is called multiple times, once
// per stage that's used for this profile. So
// - generally, stick common ones in the fragment stage to ensure they are tagged exactly once
- // - for ES, which has different precisions for different stages, the coarsest-grained tagging
+ // - for ES, which has different precisions for different stages, the coarsest-grained tagging
// for a built-in used in many stages needs to be once for the fragment stage and once for
// the vertex stage
@@ -4322,6 +4914,19 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
symbolTable.setFunctionExtensions("swizzleInvocationsWithPatternAMD", 1, &E_GL_AMD_shader_ballot);
symbolTable.setFunctionExtensions("writeInvocationAMD", 1, &E_GL_AMD_shader_ballot);
symbolTable.setFunctionExtensions("mbcntAMD", 1, &E_GL_AMD_shader_ballot);
+
+ symbolTable.setFunctionExtensions("minInvocationsInclusiveScanAMD", 1, &E_GL_AMD_shader_ballot);
+ symbolTable.setFunctionExtensions("maxInvocationsInclusiveScanAMD", 1, &E_GL_AMD_shader_ballot);
+ symbolTable.setFunctionExtensions("addInvocationsInclusiveScanAMD", 1, &E_GL_AMD_shader_ballot);
+ symbolTable.setFunctionExtensions("minInvocationsInclusiveScanNonUniformAMD", 1, &E_GL_AMD_shader_ballot);
+ symbolTable.setFunctionExtensions("maxInvocationsInclusiveScanNonUniformAMD", 1, &E_GL_AMD_shader_ballot);
+ symbolTable.setFunctionExtensions("addInvocationsInclusiveScanNonUniformAMD", 1, &E_GL_AMD_shader_ballot);
+ symbolTable.setFunctionExtensions("minInvocationsExclusiveScanAMD", 1, &E_GL_AMD_shader_ballot);
+ symbolTable.setFunctionExtensions("maxInvocationsExclusiveScanAMD", 1, &E_GL_AMD_shader_ballot);
+ symbolTable.setFunctionExtensions("addInvocationsExclusiveScanAMD", 1, &E_GL_AMD_shader_ballot);
+ symbolTable.setFunctionExtensions("minInvocationsExclusiveScanNonUniformAMD", 1, &E_GL_AMD_shader_ballot);
+ symbolTable.setFunctionExtensions("maxInvocationsExclusiveScanNonUniformAMD", 1, &E_GL_AMD_shader_ballot);
+ symbolTable.setFunctionExtensions("addInvocationsExclusiveScanNonUniformAMD", 1, &E_GL_AMD_shader_ballot);
}
if (profile != EEsProfile) {
@@ -4419,6 +5024,30 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
BuiltInVariable("gl_InvocationID", EbvInvocationId, symbolTable);
BuiltInVariable("gl_Layer", EbvLayer, symbolTable);
BuiltInVariable("gl_ViewportIndex", EbvViewportIndex, symbolTable);
+
+#ifdef NV_EXTENSIONS
+ if (language != EShLangGeometry) {
+ symbolTable.setVariableExtensions("gl_Layer", Num_viewportEXTs, viewportEXTs);
+ symbolTable.setVariableExtensions("gl_ViewportIndex", Num_viewportEXTs, viewportEXTs);
+ }
+ symbolTable.setVariableExtensions("gl_ViewportMask", 1, &E_GL_NV_viewport_array2);
+ symbolTable.setVariableExtensions("gl_SecondaryPositionNV", 1, &E_GL_NV_stereo_view_rendering);
+ symbolTable.setVariableExtensions("gl_SecondaryViewportMaskNV", 1, &E_GL_NV_stereo_view_rendering);
+
+ BuiltInVariable("gl_ViewportMask", EbvViewportMaskNV, symbolTable);
+ BuiltInVariable("gl_SecondaryPositionNV", EbvSecondaryPositionNV, symbolTable);
+ BuiltInVariable("gl_SecondaryViewportMaskNV", EbvSecondaryViewportMaskNV, symbolTable);
+
+ if (language != EShLangVertex)
+ BuiltInVariable("gl_in", "gl_SecondaryPositionNV", EbvSecondaryPositionNV, symbolTable);
+
+ BuiltInVariable("gl_out", "gl_Layer", EbvLayer, symbolTable);
+ BuiltInVariable("gl_out", "gl_ViewportIndex", EbvViewportIndex, symbolTable);
+ BuiltInVariable("gl_out", "gl_ViewportMask", EbvViewportMaskNV, symbolTable);
+ BuiltInVariable("gl_out", "gl_SecondaryPositionNV", EbvSecondaryPositionNV, symbolTable);
+ BuiltInVariable("gl_out", "gl_SecondaryViewportMaskNV", EbvSecondaryViewportMaskNV, symbolTable);
+#endif
+
BuiltInVariable("gl_PatchVerticesIn", EbvPatchVertices, symbolTable);
BuiltInVariable("gl_TessLevelOuter", EbvTessLevelOuter, symbolTable);
BuiltInVariable("gl_TessLevelInner", EbvTessLevelInner, symbolTable);
@@ -4458,7 +5087,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
// However, the current automatic extension scheme does not work per block member,
// so for now check when parsing.
//
- //if (profile == EEsProfile) {
+ // if (profile == EEsProfile) {
// if (language == EShLangGeometry)
// symbolTable.setVariableExtensions("gl_PointSize", Num_AEP_geometry_point_size, AEP_geometry_point_size);
// else if (language == EShLangTessEvaluation || language == EShLangTessControl)
@@ -4494,7 +5123,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
symbolTable.setVariableExtensions("gl_NumSamples", 1, &E_GL_OES_sample_variables);
}
}
-
+
BuiltInVariable("gl_Layer", EbvLayer, symbolTable);
BuiltInVariable("gl_ViewportIndex", EbvViewportIndex, symbolTable);
@@ -4984,16 +5613,28 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
symbolTable.relateToOperator("allInvocationsEqualARB", EOpAllInvocationsEqual);
#ifdef AMD_EXTENSIONS
- symbolTable.relateToOperator("minInvocationsAMD", EOpMinInvocations);
- symbolTable.relateToOperator("maxInvocationsAMD", EOpMaxInvocations);
- symbolTable.relateToOperator("addInvocationsAMD", EOpAddInvocations);
- symbolTable.relateToOperator("minInvocationsNonUniformAMD", EOpMinInvocationsNonUniform);
- symbolTable.relateToOperator("maxInvocationsNonUniformAMD", EOpMaxInvocationsNonUniform);
- symbolTable.relateToOperator("addInvocationsNonUniformAMD", EOpAddInvocationsNonUniform);
- symbolTable.relateToOperator("swizzleInvocationsAMD", EOpSwizzleInvocations);
- symbolTable.relateToOperator("swizzleInvocationsMaskedAMD", EOpSwizzleInvocationsMasked);
- symbolTable.relateToOperator("writeInvocationAMD", EOpWriteInvocation);
- symbolTable.relateToOperator("mbcntAMD", EOpMbcnt);
+ symbolTable.relateToOperator("minInvocationsAMD", EOpMinInvocations);
+ symbolTable.relateToOperator("maxInvocationsAMD", EOpMaxInvocations);
+ symbolTable.relateToOperator("addInvocationsAMD", EOpAddInvocations);
+ symbolTable.relateToOperator("minInvocationsNonUniformAMD", EOpMinInvocationsNonUniform);
+ symbolTable.relateToOperator("maxInvocationsNonUniformAMD", EOpMaxInvocationsNonUniform);
+ symbolTable.relateToOperator("addInvocationsNonUniformAMD", EOpAddInvocationsNonUniform);
+ symbolTable.relateToOperator("minInvocationsInclusiveScanAMD", EOpMinInvocationsInclusiveScan);
+ symbolTable.relateToOperator("maxInvocationsInclusiveScanAMD", EOpMaxInvocationsInclusiveScan);
+ symbolTable.relateToOperator("addInvocationsInclusiveScanAMD", EOpAddInvocationsInclusiveScan);
+ symbolTable.relateToOperator("minInvocationsInclusiveScanNonUniformAMD", EOpMinInvocationsInclusiveScanNonUniform);
+ symbolTable.relateToOperator("maxInvocationsInclusiveScanNonUniformAMD", EOpMaxInvocationsInclusiveScanNonUniform);
+ symbolTable.relateToOperator("addInvocationsInclusiveScanNonUniformAMD", EOpAddInvocationsInclusiveScanNonUniform);
+ symbolTable.relateToOperator("minInvocationsExclusiveScanAMD", EOpMinInvocationsExclusiveScan);
+ symbolTable.relateToOperator("maxInvocationsExclusiveScanAMD", EOpMaxInvocationsExclusiveScan);
+ symbolTable.relateToOperator("addInvocationsExclusiveScanAMD", EOpAddInvocationsExclusiveScan);
+ symbolTable.relateToOperator("minInvocationsExclusiveScanNonUniformAMD", EOpMinInvocationsExclusiveScanNonUniform);
+ symbolTable.relateToOperator("maxInvocationsExclusiveScanNonUniformAMD", EOpMaxInvocationsExclusiveScanNonUniform);
+ symbolTable.relateToOperator("addInvocationsExclusiveScanNonUniformAMD", EOpAddInvocationsExclusiveScanNonUniform);
+ symbolTable.relateToOperator("swizzleInvocationsAMD", EOpSwizzleInvocations);
+ symbolTable.relateToOperator("swizzleInvocationsMaskedAMD", EOpSwizzleInvocationsMasked);
+ symbolTable.relateToOperator("writeInvocationAMD", EOpWriteInvocation);
+ symbolTable.relateToOperator("mbcntAMD", EOpMbcnt);
symbolTable.relateToOperator("min3", EOpMin3);
symbolTable.relateToOperator("max3", EOpMax3);
@@ -5055,7 +5696,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
//
// Add context-dependent (resource-specific) built-ins not handled by the above. These
-// would be ones that need to be programmatically added because they cannot
+// would be ones that need to be programmatically added because they cannot
// be added by simple text strings. For these, also
// 1) Map built-in functions to operators, for those that will turn into an operation node
// instead of remaining a function call.
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Initialize.h b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Initialize.h
index 23f57acc17e..45b439562f2 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Initialize.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Initialize.h
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2013-2016 LunarG, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2013-2016 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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.
//
#ifndef _INITIALIZE_INCLUDED_
@@ -67,7 +67,7 @@ public:
virtual const TString& getStageString(EShLanguage language) const { return stageBuiltins[language]; }
virtual void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable) = 0;
-
+
virtual void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources) = 0;
protected:
@@ -89,7 +89,7 @@ public:
void initialize(const TBuiltInResource& resources, int version, EProfile, const SpvVersion& spvVersion, EShLanguage);
void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable);
-
+
void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources);
protected:
@@ -107,7 +107,6 @@ protected:
int dimMap[EsdNumDims];
};
-
} // end namespace glslang
#endif // _INITIALIZE_INCLUDED_
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/IntermTraverse.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/IntermTraverse.cpp
index b910f473883..f46010b7121 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/IntermTraverse.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/IntermTraverse.cpp
@@ -1,13 +1,13 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2013 LunarG, Inc.
-//Copyright (c) 2002-2010 The ANGLE Project Authors.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2013 LunarG, Inc.
+// Copyright (c) 2002-2010 The ANGLE Project Authors.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -21,18 +21,18 @@
// 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.
+// 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 "../Include/intermediate.h"
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Intermediate.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Intermediate.cpp
index 999fd5d8a92..af3e8119d8c 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Intermediate.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Intermediate.cpp
@@ -1,13 +1,13 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2012-2015 LunarG, Inc.
-//Copyright (C) 2015-2016 Google, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2012-2015 LunarG, Inc.
+// Copyright (C) 2015-2016 Google, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -21,18 +21,18 @@
// 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.
+// 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.
//
//
@@ -155,7 +155,7 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn
return folded;
}
- // If either is a specialization constant, while the other is
+ // If either is a specialization constant, while the other is
// a constant (or specialization constant), the result is still
// a specialization constant, if the operation is an allowed
// specialization-constant operation.
@@ -192,7 +192,7 @@ TIntermBinary* TIntermediate::addBinaryNode(TOperator op, TIntermTyped* left, TI
node->setType(type);
return node;
}
-
+
//
// Low level: add unary node (no promotions or other argument modifications)
//
@@ -286,7 +286,7 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermTyped* child, TSo
if (source == EShSourceHlsl) {
break; // HLSL can promote logical not
}
-
+
if (child->getType().getBasicType() != EbtBool || child->getType().isMatrix() || child->getType().isArray() || child->getType().isVector()) {
return nullptr;
}
@@ -474,7 +474,7 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
// samplers can get assigned via a sampler constructor
// (well, not yet, but code in the rest of this function is ready for it)
- if (node->getBasicType() == EbtSampler && op == EOpAssign &&
+ if (node->getBasicType() == EbtSampler && op == EOpAssign &&
node->getAsOperator() != nullptr && node->getAsOperator()->getOp() == EOpConstructTextureSampler)
break;
@@ -867,16 +867,16 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
if (fromConvertable && toConvertable) {
switch (op) {
case EOpAndAssign: // assignments can perform arbitrary conversions
- case EOpInclusiveOrAssign: // ...
- case EOpExclusiveOrAssign: // ...
- case EOpAssign: // ...
- case EOpAddAssign: // ...
- case EOpSubAssign: // ...
- case EOpMulAssign: // ...
- case EOpVectorTimesScalarAssign: // ...
- case EOpMatrixTimesScalarAssign: // ...
- case EOpDivAssign: // ...
- case EOpModAssign: // ...
+ case EOpInclusiveOrAssign: // ...
+ case EOpExclusiveOrAssign: // ...
+ case EOpAssign: // ...
+ case EOpAddAssign: // ...
+ case EOpSubAssign: // ...
+ case EOpMulAssign: // ...
+ case EOpVectorTimesScalarAssign: // ...
+ case EOpMatrixTimesScalarAssign: // ...
+ case EOpDivAssign: // ...
+ case EOpModAssign: // ...
case EOpReturn: // function returns can also perform arbitrary conversions
case EOpFunctionCall: // conversion of a calling parameter
case EOpLogicalNot:
@@ -1232,7 +1232,7 @@ TIntermAggregate* TIntermediate::makeAggregate(const TSourceLoc& loc)
//
// Returns the selection node created.
//
-TIntermNode* TIntermediate::addSelection(TIntermTyped* cond, TIntermNodePair nodePair, const TSourceLoc& loc)
+TIntermTyped* TIntermediate::addSelection(TIntermTyped* cond, TIntermNodePair nodePair, const TSourceLoc& loc)
{
//
// Don't prune the false path for compile-time constants; it's needed
@@ -1245,13 +1245,12 @@ TIntermNode* TIntermediate::addSelection(TIntermTyped* cond, TIntermNodePair nod
return node;
}
-
TIntermTyped* TIntermediate::addComma(TIntermTyped* left, TIntermTyped* right, const TSourceLoc& loc)
{
// However, the lowest precedence operators of the sequence operator ( , ) and the assignment operators
// ... are not included in the operators that can create a constant expression.
//
- //if (left->getType().getQualifier().storage == EvqConst &&
+ // if (left->getType().getQualifier().storage == EvqConst &&
// right->getType().getQualifier().storage == EvqConst) {
// return right;
@@ -1282,6 +1281,12 @@ TIntermTyped* TIntermediate::addMethod(TIntermTyped* object, const TType& type,
//
TIntermTyped* TIntermediate::addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, const TSourceLoc& loc)
{
+ // If it's void, go to the if-then-else selection()
+ if (trueBlock->getBasicType() == EbtVoid && falseBlock->getBasicType() == EbtVoid) {
+ TIntermNodePair pair = { trueBlock, falseBlock };
+ return addSelection(cond, pair, loc);
+ }
+
//
// Get compatible types.
//
@@ -1393,18 +1398,35 @@ TIntermConstantUnion* TIntermediate::addConstantUnion(double d, TBasicType baseT
return addConstantUnion(unionArray, TType(baseType, EvqConst), loc, literal);
}
-TIntermTyped* TIntermediate::addSwizzle(TVectorFields& fields, const TSourceLoc& loc)
+// Put vector swizzle selectors onto the given sequence
+void TIntermediate::pushSelector(TIntermSequence& sequence, const TVectorSelector& selector, const TSourceLoc& loc)
+{
+ TIntermConstantUnion* constIntNode = addConstantUnion(selector, loc);
+ sequence.push_back(constIntNode);
+}
+
+// Put matrix swizzle selectors onto the given sequence
+void TIntermediate::pushSelector(TIntermSequence& sequence, const TMatrixSelector& selector, const TSourceLoc& loc)
+{
+ TIntermConstantUnion* constIntNode = addConstantUnion(selector.coord1, loc);
+ sequence.push_back(constIntNode);
+ constIntNode = addConstantUnion(selector.coord2, loc);
+ sequence.push_back(constIntNode);
+}
+
+// Make an aggregate node that has a sequence of all selectors.
+template TIntermTyped* TIntermediate::addSwizzle<TVectorSelector>(TSwizzleSelectors<TVectorSelector>& selector, const TSourceLoc& loc);
+template TIntermTyped* TIntermediate::addSwizzle<TMatrixSelector>(TSwizzleSelectors<TMatrixSelector>& selector, const TSourceLoc& loc);
+template<typename selectorType>
+TIntermTyped* TIntermediate::addSwizzle(TSwizzleSelectors<selectorType>& selector, const TSourceLoc& loc)
{
TIntermAggregate* node = new TIntermAggregate(EOpSequence);
node->setLoc(loc);
- TIntermConstantUnion* constIntNode;
TIntermSequence &sequenceVector = node->getSequence();
- for (int i = 0; i < fields.num; i++) {
- constIntNode = addConstantUnion(fields.offsets[i], loc);
- sequenceVector.push_back(constIntNode);
- }
+ for (int i = 0; i < selector.size(); i++)
+ pushSelector(sequenceVector, selector[i], loc);
return node;
}
@@ -1426,10 +1448,10 @@ const TIntermTyped* TIntermediate::findLValueBase(const TIntermTyped* node, bool
if (binary == nullptr)
return node;
TOperator op = binary->getOp();
- if (op != EOpIndexDirect && op != EOpIndexIndirect && op != EOpIndexDirectStruct && op != EOpVectorSwizzle)
+ if (op != EOpIndexDirect && op != EOpIndexIndirect && op != EOpIndexDirectStruct && op != EOpVectorSwizzle && op != EOpMatrixSwizzle)
return nullptr;
if (! swizzleOkay) {
- if (op == EOpVectorSwizzle)
+ if (op == EOpVectorSwizzle || op == EOpMatrixSwizzle)
return nullptr;
if ((op == EOpIndexDirect || op == EOpIndexIndirect) &&
(binary->getLeft()->getType().isVector() || binary->getLeft()->getType().isScalar()) &&
@@ -1520,7 +1542,7 @@ void TIntermediate::addSymbolLinkageNodes(TIntermAggregate*& linkage, EShLanguag
// - ftransform() can make gl_Vertex and gl_ModelViewProjectionMatrix active.
//
- //if (ftransformUsed) {
+ // if (ftransformUsed) {
// TODO: 1.1 lowering functionality: track ftransform() usage
// addSymbolLinkageNode(root, symbolTable, "gl_Vertex");
// addSymbolLinkageNode(root, symbolTable, "gl_ModelViewProjectionMatrix");
@@ -2256,8 +2278,8 @@ bool TIntermediate::promoteAggregate(TIntermAggregate& node)
case EOpDot:
case EOpDst:
case EOpFaceForward:
- // case EOpFindMSB: TODO: ??
- // case EOpFindLSB: TODO: ??
+ // case EOpFindMSB: TODO:
+ // case EOpFindLSB: TODO:
case EOpFma:
case EOpMod:
case EOpFrexp:
@@ -2267,11 +2289,11 @@ bool TIntermediate::promoteAggregate(TIntermAggregate& node)
case EOpMax:
case EOpMin:
case EOpModf:
- // case EOpGenMul: TODO: ??
+ // case EOpGenMul: TODO:
case EOpPow:
case EOpReflect:
case EOpRefract:
- // case EOpSinCos: TODO: ??
+ // case EOpSinCos: TODO:
case EOpSmoothStep:
case EOpStep:
break;
@@ -2304,7 +2326,6 @@ bool TIntermediate::promoteAggregate(TIntermAggregate& node)
return false;
}
-
void TIntermBinary::updatePrecision()
{
#ifdef AMD_EXTENSIONS
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/LiveTraverser.h b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/LiveTraverser.h
index 286efe6ceff..029c24a822b 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/LiveTraverser.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/LiveTraverser.h
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2016 LunarG, Inc.
+// Copyright (C) 2016 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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 "../Include/Common.h"
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/ParseContextBase.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/ParseContextBase.cpp
index d86e19d2406..24c8e6095d8 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/ParseContextBase.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/ParseContextBase.cpp
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2016 Google, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2016 Google, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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.
//
// Implement the TParseContextBase class.
@@ -129,6 +129,7 @@ bool TParseContextBase::lValueErrorCheck(const TSourceLoc& loc, const char* op,
case EOpIndexIndirect: // fall through
case EOpIndexDirectStruct: // fall through
case EOpVectorSwizzle:
+ case EOpMatrixSwizzle:
return lValueErrorCheck(loc, op, binaryNode->getLeft());
default:
break;
@@ -208,6 +209,7 @@ void TParseContextBase::rValueErrorCheck(const TSourceLoc& loc, const char* op,
case EOpIndexIndirect:
case EOpIndexDirectStruct:
case EOpVectorSwizzle:
+ case EOpMatrixSwizzle:
rValueErrorCheck(loc, op, binaryNode->getLeft());
default:
break;
@@ -240,7 +242,7 @@ void TParseContextBase::trackLinkageDeferred(TSymbol& symbol)
linkageSymbols.push_back(&symbol);
}
-// Make a shared symbol have a non-shared version that can be edited by the current
+// Make a shared symbol have a non-shared version that can be edited by the current
// compile, such that editing its type will not change the shared version and will
// effect all nodes already sharing it (non-shallow type),
// or adopting its full type after being edited (shallow type).
@@ -308,20 +310,20 @@ const TFunction* TParseContextBase::selectFunction(
std::function<bool(const TType& from, const TType& to1, const TType& to2)> better,
/* output */ bool& tie)
{
-//
+//
// Operation
-//
+//
// 1. Prune the input list of candidates down to a list of viable candidates,
// where each viable candidate has
-//
+//
// * at least as many parameters as there are calling arguments, with any
// remaining parameters being optional or having default values
// * each parameter is true under convertible(A, B), where A is the calling
// type for in and B is the formal type, and in addition, for out B is the
// calling type and A is the formal type
-//
+//
// 2. If there are no viable candidates, return with no match.
-//
+//
// 3. If there is only one viable candidate, it is the best match.
//
// 4. If there are multiple viable candidates, select the first viable candidate
@@ -329,7 +331,7 @@ const TFunction* TParseContextBase::selectFunction(
// that candidate is better (bullets below), make it the incumbent. Repeat, with
// a linear walk through the viable candidate list. The final incumbent will be
// returned as the best match. A viable candidate is better than the incumbent if
-//
+//
// * it has a function argument with a better(...) conversion than the incumbent,
// for all directions needed by in and out
// * the incumbent has no argument with a better(...) conversion then the
@@ -348,13 +350,18 @@ const TFunction* TParseContextBase::selectFunction(
for (auto it = candidateList.begin(); it != candidateList.end(); ++it) {
const TFunction& candidate = *(*it);
- // to even be a potential match, number of arguments has to match
- if (call.getParamCount() != candidate.getParamCount())
+ // to even be a potential match, number of arguments must be >= the number of
+ // fixed (non-default) parameters, and <= the total (including parameter with defaults).
+ if (call.getParamCount() < candidate.getFixedParamCount() ||
+ call.getParamCount() > candidate.getParamCount())
continue;
// see if arguments are convertible
bool viable = true;
- for (int param = 0; param < candidate.getParamCount(); ++param) {
+
+ // The call can have fewer parameters than the candidate, if some have defaults.
+ const int paramCount = std::min(call.getParamCount(), candidate.getParamCount());
+ for (int param = 0; param < paramCount; ++param) {
if (candidate[param].type->getQualifier().isParamInput()) {
if (! convertible(*call[param].type, *candidate[param].type, candidate.getBuiltInOp(), param)) {
viable = false;
@@ -382,7 +389,7 @@ const TFunction* TParseContextBase::selectFunction(
return viableCandidates.front();
// 4. find best...
- auto betterParam = [&call, &better](const TFunction& can1, const TFunction& can2) -> bool {
+ const auto betterParam = [&call, &better](const TFunction& can1, const TFunction& can2) -> bool {
// is call -> can2 better than call -> can1 for any parameter
bool hasBetterParam = false;
for (int param = 0; param < call.getParamCount(); ++param) {
@@ -394,6 +401,16 @@ const TFunction* TParseContextBase::selectFunction(
return hasBetterParam;
};
+ const auto equivalentParams = [&call, &better](const TFunction& can1, const TFunction& can2) -> bool {
+ // is call -> can2 equivalent to call -> can1 for all the call parameters?
+ for (int param = 0; param < call.getParamCount(); ++param) {
+ if (better(*call[param].type, *can1[param].type, *can2[param].type) ||
+ better(*call[param].type, *can2[param].type, *can1[param].type))
+ return false;
+ }
+ return true;
+ };
+
const TFunction* incumbent = viableCandidates.front();
for (auto it = viableCandidates.begin() + 1; it != viableCandidates.end(); ++it) {
const TFunction& candidate = *(*it);
@@ -406,7 +423,10 @@ const TFunction* TParseContextBase::selectFunction(
if (incumbent == *it)
continue;
const TFunction& candidate = *(*it);
- if (betterParam(*incumbent, candidate))
+
+ // In the case of default parameters, it may have an identical initial set, which is
+ // also ambiguous
+ if (betterParam(*incumbent, candidate) || equivalentParams(*incumbent, candidate))
tie = true;
}
@@ -414,6 +434,108 @@ const TFunction* TParseContextBase::selectFunction(
}
//
+// Look at a '.' field selector string and change it into numerical selectors
+// for a vector or scalar.
+//
+// Always return some form of swizzle, so the result is always usable.
+//
+void TParseContextBase::parseSwizzleSelector(const TSourceLoc& loc, const TString& compString, int vecSize,
+ TSwizzleSelectors<TVectorSelector>& selector)
+{
+ // Too long?
+ if (compString.size() > MaxSwizzleSelectors)
+ error(loc, "vector swizzle too long", compString.c_str(), "");
+
+ // Use this to test that all swizzle characters are from the same swizzle-namespace-set
+ enum {
+ exyzw,
+ ergba,
+ estpq,
+ } fieldSet[MaxSwizzleSelectors];
+
+ // Decode the swizzle string.
+ int size = std::min(MaxSwizzleSelectors, (int)compString.size());
+ for (int i = 0; i < size; ++i) {
+ switch (compString[i]) {
+ case 'x':
+ selector.push_back(0);
+ fieldSet[i] = exyzw;
+ break;
+ case 'r':
+ selector.push_back(0);
+ fieldSet[i] = ergba;
+ break;
+ case 's':
+ selector.push_back(0);
+ fieldSet[i] = estpq;
+ break;
+
+ case 'y':
+ selector.push_back(1);
+ fieldSet[i] = exyzw;
+ break;
+ case 'g':
+ selector.push_back(1);
+ fieldSet[i] = ergba;
+ break;
+ case 't':
+ selector.push_back(1);
+ fieldSet[i] = estpq;
+ break;
+
+ case 'z':
+ selector.push_back(2);
+ fieldSet[i] = exyzw;
+ break;
+ case 'b':
+ selector.push_back(2);
+ fieldSet[i] = ergba;
+ break;
+ case 'p':
+ selector.push_back(2);
+ fieldSet[i] = estpq;
+ break;
+
+ case 'w':
+ selector.push_back(3);
+ fieldSet[i] = exyzw;
+ break;
+ case 'a':
+ selector.push_back(3);
+ fieldSet[i] = ergba;
+ break;
+ case 'q':
+ selector.push_back(3);
+ fieldSet[i] = estpq;
+ break;
+
+ default:
+ error(loc, "unknown swizzle selection", compString.c_str(), "");
+ break;
+ }
+ }
+
+ // Additional error checking.
+ for (int i = 0; i < selector.size(); ++i) {
+ if (selector[i] >= vecSize) {
+ error(loc, "vector swizzle selection out of range", compString.c_str(), "");
+ selector.resize(i);
+ break;
+ }
+
+ if (i > 0 && fieldSet[i] != fieldSet[i-1]) {
+ error(loc, "vector swizzle selectors not from the same set", compString.c_str(), "");
+ selector.resize(i);
+ break;
+ }
+ }
+
+ // Ensure it is valid.
+ if (selector.size() == 0)
+ selector.push_back(0);
+}
+
+//
// Make the passed-in variable information become a member of the
// global uniform block. If this doesn't exist yet, make it.
//
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp
index 67bb883cc43..f2ae8efa497 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp
@@ -1,13 +1,13 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2012-2015 LunarG, Inc.
-//Copyright (C) 2015-2016 Google, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2012-2015 LunarG, Inc.
+// Copyright (C) 2015-2016 Google, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -21,18 +21,18 @@
// 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.
+// 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 "ParseHelper.h"
@@ -50,7 +50,7 @@ namespace glslang {
TParseContext::TParseContext(TSymbolTable& symbolTable, TIntermediate& interm, bool parsingBuiltins,
int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language,
TInfoSink& infoSink, bool forwardCompatible, EShMessages messages) :
- TParseContextBase(symbolTable, interm, parsingBuiltins, version, profile, spvVersion, language, infoSink, forwardCompatible, messages),
+ TParseContextBase(symbolTable, interm, parsingBuiltins, version, profile, spvVersion, language, infoSink, forwardCompatible, messages),
contextPragma(true, false), loopNestingLevel(0), structNestingLevel(0), controlFlowNestingLevel(0), statementNestingLevel(0),
inMain(false), postMainReturn(false), currentFunctionType(nullptr), blockName(nullptr),
limits(resources.limits),
@@ -76,7 +76,7 @@ TParseContext::TParseContext(TSymbolTable& symbolTable, TIntermediate& interm, b
globalInputDefaults.clear();
globalOutputDefaults.clear();
- // "Shaders in the transform
+ // "Shaders in the transform
// feedback capturing mode have an initial global default of
// layout(xfb_buffer = 0) out;"
if (language == EShLangVertex ||
@@ -258,106 +258,6 @@ void TParseContext::handlePragma(const TSourceLoc& loc, const TVector<TString>&
}
}
-///////////////////////////////////////////////////////////////////////
-//
-// Sub- vector and matrix fields
-//
-////////////////////////////////////////////////////////////////////////
-
-//
-// Look at a '.' field selector string and change it into offsets
-// for a vector or scalar
-//
-// Returns true if there is no error.
-//
-bool TParseContext::parseVectorFields(const TSourceLoc& loc, const TString& compString, int vecSize, TVectorFields& fields)
-{
- fields.num = (int)compString.size();
- if (fields.num > 4) {
- error(loc, "illegal vector field selection", compString.c_str(), "");
- return false;
- }
-
- enum {
- exyzw,
- ergba,
- estpq,
- } fieldSet[4];
-
- for (int i = 0; i < fields.num; ++i) {
- switch (compString[i]) {
- case 'x':
- fields.offsets[i] = 0;
- fieldSet[i] = exyzw;
- break;
- case 'r':
- fields.offsets[i] = 0;
- fieldSet[i] = ergba;
- break;
- case 's':
- fields.offsets[i] = 0;
- fieldSet[i] = estpq;
- break;
- case 'y':
- fields.offsets[i] = 1;
- fieldSet[i] = exyzw;
- break;
- case 'g':
- fields.offsets[i] = 1;
- fieldSet[i] = ergba;
- break;
- case 't':
- fields.offsets[i] = 1;
- fieldSet[i] = estpq;
- break;
- case 'z':
- fields.offsets[i] = 2;
- fieldSet[i] = exyzw;
- break;
- case 'b':
- fields.offsets[i] = 2;
- fieldSet[i] = ergba;
- break;
- case 'p':
- fields.offsets[i] = 2;
- fieldSet[i] = estpq;
- break;
-
- case 'w':
- fields.offsets[i] = 3;
- fieldSet[i] = exyzw;
- break;
- case 'a':
- fields.offsets[i] = 3;
- fieldSet[i] = ergba;
- break;
- case 'q':
- fields.offsets[i] = 3;
- fieldSet[i] = estpq;
- break;
- default:
- error(loc, "illegal vector field selection", compString.c_str(), "");
- return false;
- }
- }
-
- for (int i = 0; i < fields.num; ++i) {
- if (fields.offsets[i] >= vecSize) {
- error(loc, "vector field selection out of range", compString.c_str(), "");
- return false;
- }
-
- if (i > 0) {
- if (fieldSet[i] != fieldSet[i-1]) {
- error(loc, "illegal - vector component fields not from the same set", compString.c_str(), "");
- return false;
- }
- }
- }
-
- return true;
-}
-
//
// Handle seeing a variable identifier in the grammar.
//
@@ -370,12 +270,12 @@ TIntermTyped* TParseContext::handleVariable(const TSourceLoc& loc, TSymbol* symb
requireExtensions(loc, symbol->getNumExtensions(), symbol->getExtensions(), symbol->getName().c_str());
if (symbol && symbol->isReadOnly()) {
- // All shared things containing an implicitly sized array must be copied up
+ // All shared things containing an implicitly sized array must be copied up
// on first use, so that all future references will share its array structure,
// so that editing the implicit size will effect all nodes consuming it,
// and so that editing the implicit size won't change the shared one.
//
- // If this is a variable or a block, check it and all it contains, but if this
+ // If this is a variable or a block, check it and all it contains, but if this
// is a member of an anonymous block, check the whole block, as the whole block
// will need to be copied up if it contains an implicitly-sized array.
if (symbol->getType().containsImplicitlySizedArray() ||
@@ -537,7 +437,7 @@ void TParseContext::checkIndex(const TSourceLoc& loc, const TType& type, int& in
error(loc, "", "[", "matrix index out of range '%d'", index);
index = type.getMatrixCols() - 1;
}
- }
+ }
}
// for ES 2.0 (version 100) limitations for almost all index operations except vertex-shader uniforms
@@ -558,7 +458,7 @@ void TParseContext::handleIndexLimits(const TSourceLoc& /*loc*/, TIntermTyped* b
}
}
-// Make a shared symbol have a non-shared version that can be edited by the current
+// Make a shared symbol have a non-shared version that can be edited by the current
// compile, such that editing its type will not change the shared version and will
// effect all nodes sharing it.
void TParseContext::makeEditable(TSymbol*& symbol)
@@ -600,7 +500,7 @@ void TParseContext::fixIoArraySize(const TSourceLoc& loc, TType& type)
// Issue any errors if the non-array object is missing arrayness WRT
// shader I/O that has array requirements.
-// All arrayness checking is handled in array paths, this is for
+// All arrayness checking is handled in array paths, this is for
void TParseContext::ioArrayCheck(const TSourceLoc& loc, const TType& type, const TString& identifier)
{
if (! type.isArray() && ! symbolTable.atBuiltInLevel()) {
@@ -633,7 +533,7 @@ void TParseContext::handleIoResizeArrayAccess(const TSourceLoc& /*loc*/, TInterm
// If there has been an input primitive declaration (geometry shader) or an output
// number of vertices declaration(tessellation shader), make sure all input array types
-// match it in size. Types come either from nodes in the AST or symbols in the
+// match it in size. Types come either from nodes in the AST or symbols in the
// symbol table.
//
// Types without an array size will be given one.
@@ -729,7 +629,7 @@ TIntermTyped* TParseContext::handleUnaryMath(const TSourceLoc& loc, const char*
return result;
else
unaryOpError(loc, str, childNode->getCompleteString());
-
+
return childNode;
}
@@ -742,7 +642,7 @@ TIntermTyped* TParseContext::handleDotDereference(const TSourceLoc& loc, TInterm
//
// .length() can't be resolved until we later see the function-calling syntax.
- // Save away the name in the AST for now. Processing is completed in
+ // Save away the name in the AST for now. Processing is completed in
// handleLengthMethod().
//
if (field == "length") {
@@ -781,17 +681,14 @@ TIntermTyped* TParseContext::handleDotDereference(const TSourceLoc& loc, TInterm
profileRequires(loc, ~EEsProfile, 420, E_GL_ARB_shading_language_420pack, dotFeature);
}
- TVectorFields fields;
- if (! parseVectorFields(loc, field, base->getVectorSize(), fields)) {
- fields.num = 1;
- fields.offsets[0] = 0;
- }
+ TSwizzleSelectors<TVectorSelector> selectors;
+ parseSwizzleSelector(loc, field, base->getVectorSize(), selectors);
if (base->isScalar()) {
- if (fields.num == 1)
+ if (selectors.size() == 1)
return result;
else {
- TType type(base->getBasicType(), EvqTemporary, fields.num);
+ TType type(base->getBasicType(), EvqTemporary, selectors.size());
// Swizzle operations propagate specialization-constantness
if (base->getQualifier().isSpecConstant())
type.getQualifier().makeSpecConstant();
@@ -800,17 +697,16 @@ TIntermTyped* TParseContext::handleDotDereference(const TSourceLoc& loc, TInterm
}
if (base->getType().getQualifier().isFrontEndConstant())
- result = intermediate.foldSwizzle(base, fields, loc);
+ result = intermediate.foldSwizzle(base, selectors, loc);
else {
- if (fields.num == 1) {
- TIntermTyped* index = intermediate.addConstantUnion(fields.offsets[0], loc);
+ if (selectors.size() == 1) {
+ TIntermTyped* index = intermediate.addConstantUnion(selectors[0], loc);
result = intermediate.addIndex(EOpIndexDirect, base, index, loc);
result->setType(TType(base->getBasicType(), EvqTemporary, base->getType().getQualifier().precision));
} else {
- TString vectorString = field;
- TIntermTyped* index = intermediate.addSwizzle(fields, loc);
+ TIntermTyped* index = intermediate.addSwizzle(selectors, loc);
result = intermediate.addIndex(EOpVectorSwizzle, base, index, loc);
- result->setType(TType(base->getBasicType(), EvqTemporary, base->getType().getQualifier().precision, (int)vectorString.size()));
+ result->setType(TType(base->getBasicType(), EvqTemporary, base->getType().getQualifier().precision, selectors.size()));
}
// Swizzle operations propagate specialization-constantness
if (base->getType().getQualifier().isSpecConstant())
@@ -906,7 +802,7 @@ TFunction* TParseContext::handleFunctionDeclarator(const TSourceLoc& loc, TFunct
if (symbolTable.atBuiltInLevel())
function.setDefined();
else {
- if (prevDec && ! builtIn)
+ if (prevDec && ! builtIn)
symbol->getAsFunction()->setPrototyped(); // need a writable one, but like having prevDec as a const
function.setPrototyped();
}
@@ -926,7 +822,7 @@ TFunction* TParseContext::handleFunctionDeclarator(const TSourceLoc& loc, TFunct
}
//
-// Handle seeing the function prototype in front of a function definition in the grammar.
+// Handle seeing the function prototype in front of a function definition in the grammar.
// The body is handled after this function returns.
//
TIntermAggregate* TParseContext::handleFunctionDefinition(const TSourceLoc& loc, TFunction& function)
@@ -1087,10 +983,10 @@ TIntermTyped* TParseContext::handleFunctionCall(const TSourceLoc& loc, TFunction
if (argQualifier.writeonly && ! formalQualifier.writeonly)
error(arguments->getLoc(), message, "writeonly", "");
}
- // TODO 4.5 functionality: A shader will fail to compile
+ // TODO 4.5 functionality: A shader will fail to compile
// if the value passed to the memargument of an atomic memory function does not correspond to a buffer or
- // shared variable. It is acceptable to pass an element of an array or a single component of a vector to the
- // memargument of an atomic memory function, as long as the underlying array or vector is a buffer or
+ // shared variable. It is acceptable to pass an element of an array or a single component of a vector to the
+ // memargument of an atomic memory function, as long as the underlying array or vector is a buffer or
// shared variable.
}
@@ -1213,7 +1109,7 @@ void TParseContext::computeBuiltinPrecisions(TIntermTyped& node, const TFunction
operationPrecision = std::max(function[0].type->getQualifier().precision,
unaryNode->getOperand()->getType().getQualifier().precision);
if (function.getType().getBasicType() != EbtBool)
- resultPrecision = function.getType().getQualifier().precision == EpqNone ?
+ resultPrecision = function.getType().getQualifier().precision == EpqNone ?
operationPrecision :
function.getType().getQualifier().precision;
} else if (TIntermAggregate* agg = node.getAsAggregate()) {
@@ -1243,7 +1139,7 @@ void TParseContext::computeBuiltinPrecisions(TIntermTyped& node, const TFunction
if (agg->isSampling() || agg->getOp() == EOpImageLoad || agg->getOp() == EOpImageStore)
resultPrecision = sequence[0]->getAsTyped()->getQualifier().precision;
else if (function.getType().getBasicType() != EbtBool)
- resultPrecision = function.getType().getQualifier().precision == EpqNone ?
+ resultPrecision = function.getType().getQualifier().precision == EpqNone ?
operationPrecision :
function.getType().getQualifier().precision;
}
@@ -1301,7 +1197,7 @@ void TParseContext::checkLocation(const TSourceLoc& loc, TOperator op)
}
// Finish processing object.length(). This started earlier in handleDotDereference(), where
-// the ".length" part was recognized and semantically checked, and finished here where the
+// the ".length" part was recognized and semantically checked, and finished here where the
// function syntax "()" is recognized.
//
// Return resulting tree node.
@@ -1319,8 +1215,8 @@ TIntermTyped* TParseContext::handleLengthMethod(const TSourceLoc& loc, TFunction
return intermediate.addBuiltInFunctionCall(loc, EOpArrayLength, true, intermNode, TType(EbtInt));
} else if (type.isImplicitlySizedArray()) {
if (intermNode->getAsSymbolNode() && isIoResizeArray(type)) {
- // We could be between a layout declaration that gives a built-in io array implicit size and
- // a user redeclaration of that array, meaning we have to substitute its implicit size here
+ // We could be between a layout declaration that gives a built-in io array implicit size and
+ // a user redeclaration of that array, meaning we have to substitute its implicit size here
// without actually redeclaring the array. (It is an error to use a member before the
// redeclaration, but not an error to use the array name itself.)
const TString& name = intermNode->getAsSymbolNode()->getName();
@@ -1604,7 +1500,7 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
if (imageType.getQualifier().layoutFormat != ElfR32i && imageType.getQualifier().layoutFormat != ElfR32ui)
error(loc, "only supported on image with format r32i or r32ui", fnCandidate.getName().c_str(), "");
} else {
- if (fnCandidate.getName().compare(0, 19, "imageAtomicExchange") != 0)
+ if (fnCandidate.getName().compare(0, 19, "imageAtomicExchange") != 0)
error(loc, "only supported on integer images", fnCandidate.getName().c_str(), "");
else if (imageType.getQualifier().layoutFormat != ElfR32f && profile == EEsProfile)
error(loc, "only supported on image with format r32f", fnCandidate.getName().c_str(), "");
@@ -1654,7 +1550,7 @@ extern bool PureOperatorBuiltins;
//
void TParseContext::nonOpBuiltInCheck(const TSourceLoc& loc, const TFunction& fnCandidate, TIntermAggregate& callNode)
{
- // Further maintenance of this function is deprecated, because the "correct"
+ // Further maintenance of this function is deprecated, because the "correct"
// future-oriented design is to not have to do string compares on function names.
// If PureOperatorBuiltins == true, then all built-ins should be mapped
@@ -1759,7 +1655,7 @@ void TParseContext::nonOpBuiltInCheck(const TSourceLoc& loc, const TFunction& fn
if (imageType.getQualifier().layoutFormat != ElfR32i && imageType.getQualifier().layoutFormat != ElfR32ui)
error(loc, "only supported on image with format r32i or r32ui", fnCandidate.getName().c_str(), "");
} else {
- if (fnCandidate.getName().compare(0, 19, "imageAtomicExchange") != 0)
+ if (fnCandidate.getName().compare(0, 19, "imageAtomicExchange") != 0)
error(loc, "only supported on integer images", fnCandidate.getName().c_str(), "");
else if (imageType.getQualifier().layoutFormat != ElfR32f && profile == EEsProfile)
error(loc, "only supported on image with format r32f", fnCandidate.getName().c_str(), "");
@@ -2412,8 +2308,8 @@ bool TParseContext::constructorTextureSamplerError(const TSourceLoc& loc, const
// of the texture type must match that of the constructed sampler type
// (that is, the suffixes of the type of the first argument and the
// type of the constructor will be spelled the same way)
- if (function[0].type->getBasicType() != EbtSampler ||
- ! function[0].type->getSampler().isTexture() ||
+ if (function[0].type->getBasicType() != EbtSampler ||
+ ! function[0].type->getSampler().isTexture() ||
function[0].type->isArray()) {
error(loc, "sampler-constructor first argument must be a scalar textureXXX type", token, "");
return true;
@@ -2502,7 +2398,6 @@ void TParseContext::atomicUintCheck(const TSourceLoc& loc, const TType& type, co
void TParseContext::transparentCheck(const TSourceLoc& loc, const TType& type, const TString& /*identifier*/)
{
- // double standard due to gl_NumSamples
if (parsingBuiltins)
return;
@@ -2721,7 +2616,7 @@ void TParseContext::mergeQualifiers(const TSourceLoc& loc, TQualifier& dst, cons
#endif
// Ordering
- if (! force && ((profile != EEsProfile && version < 420) ||
+ if (! force && ((profile != EEsProfile && version < 420) ||
(profile == EEsProfile && version < 310))
&& ! extensionTurnedOn(E_GL_ARB_shading_language_420pack)) {
// non-function parameters
@@ -3255,7 +3150,7 @@ bool TParseContext::lineDirectiveShouldSetNextLine() const
void TParseContext::nonInitConstCheck(const TSourceLoc& loc, TString& identifier, TType& type)
{
//
- // Make the qualifier make sense, given that there is an initializer.
+ // Make the qualifier make sense, given that there is not an initializer.
//
if (type.getQualifier().storage == EvqConst ||
type.getQualifier().storage == EvqConstReadOnly) {
@@ -3310,6 +3205,7 @@ TSymbol* TParseContext::redeclareBuiltinVariable(const TSourceLoc& loc, const TS
(identifier == "gl_Color" && language == EShLangFragment) ||
#ifdef NV_EXTENSIONS
identifier == "gl_SampleMask" ||
+ identifier == "gl_Layer" ||
#endif
identifier == "gl_TexCoord") {
@@ -3331,7 +3227,7 @@ TSymbol* TParseContext::redeclareBuiltinVariable(const TSourceLoc& loc, const TS
// Now, modify the type of the copy, as per the type of the current redeclaration.
TQualifier& symbolQualifier = symbol->getWritableType().getQualifier();
- if (ssoPre150) {
+ if (ssoPre150) {
if (intermediate.inIoAccessed(identifier))
error(loc, "cannot redeclare after use", identifier.c_str(), "");
if (qualifier.hasLayout())
@@ -3369,7 +3265,7 @@ TSymbol* TParseContext::redeclareBuiltinVariable(const TSourceLoc& loc, const TS
error(loc, "can only change layout qualification of", "redeclaration", symbol->getName().c_str());
if (qualifier.storage != EvqVaryingIn)
error(loc, "cannot change input storage qualification of", "redeclaration", symbol->getName().c_str());
- if (! builtIn && (publicType.pixelCenterInteger != intermediate.getPixelCenterInteger() ||
+ if (! builtIn && (publicType.pixelCenterInteger != intermediate.getPixelCenterInteger() ||
publicType.originUpperLeft != intermediate.getOriginUpperLeft()))
error(loc, "cannot redeclare with different qualification:", "redeclaration", symbol->getName().c_str());
if (publicType.pixelCenterInteger)
@@ -3389,13 +3285,19 @@ TSymbol* TParseContext::redeclareBuiltinVariable(const TSourceLoc& loc, const TS
error(loc, "all redeclarations must use the same depth layout on", "redeclaration", symbol->getName().c_str());
}
}
-#ifdef NV_EXTENSIONS
+#ifdef NV_EXTENSIONS
else if (identifier == "gl_SampleMask") {
if (!publicType.layoutOverrideCoverage) {
error(loc, "redeclaration only allowed for override_coverage layout", "redeclaration", symbol->getName().c_str());
}
intermediate.setLayoutOverrideCoverage();
}
+ else if (identifier == "gl_Layer") {
+ if (!qualifier.layoutViewportRelative && qualifier.layoutSecondaryViewportRelativeOffset == -2048)
+ error(loc, "redeclaration only allowed for viewport_relative or secondary_view_offset layout", "redeclaration", symbol->getName().c_str());
+ symbolQualifier.layoutViewportRelative = qualifier.layoutViewportRelative;
+ symbolQualifier.layoutSecondaryViewportRelativeOffset = qualifier.layoutSecondaryViewportRelativeOffset;
+ }
#endif
// TODO: semantics quality: separate smooth from nothing declared, then use IsInterpolation for several tests above
@@ -3522,12 +3424,20 @@ void TParseContext::redeclareBuiltinBlock(const TSourceLoc& loc, TTypeList& newT
oldType.getQualifier().flat = newType.getQualifier().flat;
oldType.getQualifier().nopersp = newType.getQualifier().nopersp;
+#ifdef NV_EXTENSIONS
+ if (member->type->getFieldName() == "gl_Layer") {
+ if (!newType.getQualifier().layoutViewportRelative && newType.getQualifier().layoutSecondaryViewportRelativeOffset == -2048)
+ error(loc, "redeclaration only allowed for viewport_relative or secondary_view_offset layout", "redeclaration", member->type->getFieldName().c_str());
+ oldType.getQualifier().layoutViewportRelative = newType.getQualifier().layoutViewportRelative;
+ oldType.getQualifier().layoutSecondaryViewportRelativeOffset = newType.getQualifier().layoutSecondaryViewportRelativeOffset;
+ }
+#endif
if (oldType.isImplicitlySizedArray() && newType.isExplicitlySizedArray())
oldType.changeOuterArraySize(newType.getOuterArraySize());
// go to next member
++member;
- } else {
+ } else {
// For missing members of anonymous blocks that have been redeclared,
// hide the original (shared) declaration.
// Instance-named blocks can just have the member removed.
@@ -3660,7 +3570,7 @@ void TParseContext::structTypeCheck(const TSourceLoc& /*loc*/, TPublicType& publ
// fix and check for member storage qualifiers and types that don't belong within a structure
for (unsigned int member = 0; member < typeList.size(); ++member) {
- TQualifier& memberQualifier = typeList[member].type->getQualifier();
+ TQualifier& memberQualifier = typeList[member].type->getQualifier();
const TSourceLoc& memberLoc = typeList[member].loc;
if (memberQualifier.isAuxiliary() ||
memberQualifier.isInterpolation() ||
@@ -3834,7 +3744,7 @@ void TParseContext::finish()
// Check for stages that are enabled by extension.
// Can't do this at the beginning, it is chicken and egg to add a stage by
// extension.
- // Stage-specific features were correctly tested for already, this is just
+ // Stage-specific features were correctly tested for already, this is just
// about the stage itself.
switch (language) {
case EShLangGeometry:
@@ -4042,14 +3952,26 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
error(loc, "unknown blend equation", "blend_support", "");
return;
}
-#ifdef NV_EXTENSIONS
+#ifdef NV_EXTENSIONS
if (id == "override_coverage") {
requireExtensions(loc, 1, &E_GL_NV_sample_mask_override_coverage, "sample mask override coverage");
publicType.shaderQualifiers.layoutOverrideCoverage = true;
return;
}
-#endif
}
+ if (language == EShLangVertex ||
+ language == EShLangTessControl ||
+ language == EShLangTessEvaluation ||
+ language == EShLangGeometry ) {
+ if (id == "viewport_relative") {
+ requireExtensions(loc, 1, &E_GL_NV_viewport_array2, "view port array2");
+ publicType.qualifier.layoutViewportRelative = true;
+ return;
+ }
+ }
+#else
+ }
+#endif
error(loc, "unrecognized layout identifier, or qualifier requires assignment (e.g., binding = 4)", id.c_str(), "");
}
@@ -4080,7 +4002,7 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
}
std::transform(id.begin(), id.end(), id.begin(), ::tolower);
-
+
if (id == "offset") {
// "offset" can be for either
// - uniform offsets
@@ -4136,9 +4058,9 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
publicType.qualifier.layoutComponent = value;
return;
} else if (id.compare(0, 4, "xfb_") == 0) {
- // "Any shader making any static use (after preprocessing) of any of these
- // *xfb_* qualifiers will cause the shader to be in a transform feedback
- // capturing mode and hence responsible for describing the transform feedback
+ // "Any shader making any static use (after preprocessing) of any of these
+ // *xfb_* qualifiers will cause the shader to be in a transform feedback
+ // capturing mode and hence responsible for describing the transform feedback
// setup."
intermediate.setXfbMode();
const char* feature = "transform feedback qualifier";
@@ -4149,7 +4071,7 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
// "It is a compile-time error to specify an *xfb_buffer* that is greater than
// the implementation-dependent constant gl_MaxTransformFeedbackBuffers."
if (value >= resources.maxTransformFeedbackBuffers)
- error(loc, "buffer is too large:", id.c_str(), "gl_MaxTransformFeedbackBuffers is %d", resources.maxTransformFeedbackBuffers);
+ error(loc, "buffer is too large:", id.c_str(), "gl_MaxTransformFeedbackBuffers is %d", resources.maxTransformFeedbackBuffers);
if (value >= (int)TQualifier::layoutXfbBufferEnd)
error(loc, "buffer is too large:", id.c_str(), "internal max is %d", TQualifier::layoutXfbBufferEnd-1);
else
@@ -4162,7 +4084,7 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
publicType.qualifier.layoutXfbOffset = value;
return;
} else if (id == "xfb_stride") {
- // "The resulting stride (implicit or explicit), when divided by 4, must be less than or equal to the
+ // "The resulting stride (implicit or explicit), when divided by 4, must be less than or equal to the
// implementation-dependent constant gl_MaxTransformFeedbackInterleavedComponents."
if (value > 4 * resources.maxTransformFeedbackInterleavedComponents)
error(loc, "1/4 stride is too large:", id.c_str(), "gl_MaxTransformFeedbackInterleavedComponents is %d", resources.maxTransformFeedbackInterleavedComponents);
@@ -4195,6 +4117,19 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
return;
}
+#if NV_EXTENSIONS
+ if (language == EShLangVertex ||
+ language == EShLangTessControl ||
+ language == EShLangTessEvaluation ||
+ language == EShLangGeometry) {
+ if (id == "secondary_view_offset") {
+ requireExtensions(loc, 1, &E_GL_NV_stereo_view_rendering, "stereo view rendering");
+ publicType.qualifier.layoutSecondaryViewportRelativeOffset = value;
+ return;
+ }
+ }
+#endif
+
switch (language) {
case EShLangVertex:
break;
@@ -4296,17 +4231,17 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
// Merge any layout qualifier information from src into dst, leaving everything else in dst alone
//
// "More than one layout qualifier may appear in a single declaration.
-// Additionally, the same layout-qualifier-name can occur multiple times
-// within a layout qualifier or across multiple layout qualifiers in the
-// same declaration. When the same layout-qualifier-name occurs
-// multiple times, in a single declaration, the last occurrence overrides
-// the former occurrence(s). Further, if such a layout-qualifier-name
-// will effect subsequent declarations or other observable behavior, it
-// is only the last occurrence that will have any effect, behaving as if
-// the earlier occurrence(s) within the declaration are not present.
-// This is also true for overriding layout-qualifier-names, where one
-// overrides the other (e.g., row_major vs. column_major); only the last
-// occurrence has any effect."
+// Additionally, the same layout-qualifier-name can occur multiple times
+// within a layout qualifier or across multiple layout qualifiers in the
+// same declaration. When the same layout-qualifier-name occurs
+// multiple times, in a single declaration, the last occurrence overrides
+// the former occurrence(s). Further, if such a layout-qualifier-name
+// will effect subsequent declarations or other observable behavior, it
+// is only the last occurrence that will have any effect, behaving as if
+// the earlier occurrence(s) within the declaration are not present.
+// This is also true for overriding layout-qualifier-names, where one
+// overrides the other (e.g., row_major vs. column_major); only the last
+// occurrence has any effect."
//
void TParseContext::mergeObjectLayoutQualifiers(TQualifier& dst, const TQualifier& src, bool inheritOnly)
{
@@ -4358,6 +4293,10 @@ void TParseContext::mergeObjectLayoutQualifiers(TQualifier& dst, const TQualifie
#ifdef NV_EXTENSIONS
if (src.layoutPassthrough)
dst.layoutPassthrough = true;
+ if (src.layoutViewportRelative)
+ dst.layoutViewportRelative = true;
+ if (src.layoutSecondaryViewportRelativeOffset != -2048)
+ dst.layoutSecondaryViewportRelativeOffset = src.layoutSecondaryViewportRelativeOffset;
#endif
}
}
@@ -4385,7 +4324,7 @@ void TParseContext::layoutObjectCheck(const TSourceLoc& loc, const TSymbol& symb
}
}
- // Check packing and matrix
+ // Check packing and matrix
if (qualifier.hasUniformLayout()) {
switch (qualifier.storage) {
case EvqUniform:
@@ -4473,8 +4412,8 @@ void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type)
if (repeated >= 0)
error(loc, "overlapping offsets at", "xfb_offset", "offset %d in buffer %d", repeated, qualifier.layoutXfbBuffer);
- // "The offset must be a multiple of the size of the first component of the first
- // qualified variable or block member, or a compile-time error results. Further, if applied to an aggregate
+ // "The offset must be a multiple of the size of the first component of the first
+ // qualified variable or block member, or a compile-time error results. Further, if applied to an aggregate
// containing a double, the offset must also be a multiple of 8..."
if (type.containsBasicType(EbtDouble) && ! IsMultipleOfPow2(qualifier.layoutXfbOffset, 8))
error(loc, "type contains double; xfb_offset must be a multiple of 8", "xfb_offset", "");
@@ -4548,7 +4487,7 @@ void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type)
error(loc, "does not apply to unsigned integer images", TQualifier::getLayoutFormatString(qualifier.layoutFormat), "");
if (profile == EEsProfile) {
- // "Except for image variables qualified with the format qualifiers r32f, r32i, and r32ui, image variables must
+ // "Except for image variables qualified with the format qualifiers r32f, r32i, and r32ui, image variables must
// specify either memory qualifier readonly or the memory qualifier writeonly."
if (! (qualifier.layoutFormat == ElfR32f || qualifier.layoutFormat == ElfR32i || qualifier.layoutFormat == ElfR32ui)) {
if (! qualifier.readonly && ! qualifier.writeonly)
@@ -4610,8 +4549,8 @@ void TParseContext::layoutQualifierCheck(const TSourceLoc& loc, const TQualifier
if (qualifier.hasAnyLocation()) {
- // "As with input layout qualifiers, all shaders except compute shaders
- // allow *location* layout qualifiers on output variable declarations,
+ // "As with input layout qualifiers, all shaders except compute shaders
+ // allow *location* layout qualifiers on output variable declarations,
// output block declarations, and output block member declarations."
switch (qualifier.storage) {
@@ -4922,7 +4861,7 @@ const TFunction* TParseContext::findFunction400(const TSourceLoc& loc, const TFu
// create list of candidates to send
TVector<const TFunction*> candidateList;
symbolTable.findFunctionNameList(call.getMangledName(), candidateList, builtIn);
-
+
// can 'from' convert to 'to'?
const auto convertible = [this](const TType& from, const TType& to, TOperator, int) -> bool {
if (from == to)
@@ -4954,7 +4893,7 @@ const TFunction* TParseContext::findFunction400(const TSourceLoc& loc, const TFu
// for ambiguity reporting
bool tie = false;
-
+
// send to the generic selector
const TFunction* bestMatch = selectFunction(candidateList, call, convertible, better, tie);
@@ -4966,7 +4905,7 @@ const TFunction* TParseContext::findFunction400(const TSourceLoc& loc, const TFu
return bestMatch;
}
-// When a declaration includes a type, but not a variable name, it can be
+// When a declaration includes a type, but not a variable name, it can be
// to establish defaults.
void TParseContext::declareTypeDefaults(const TSourceLoc& loc, const TPublicType& publicType)
{
@@ -5007,7 +4946,7 @@ TIntermNode* TParseContext::declareVariable(const TSourceLoc& loc, TString& iden
if (voidErrorCheck(loc, identifier, type.getBasicType()))
return nullptr;
- if (initializer)
+ if (initializer)
rValueErrorCheck(loc, "initializer", initializer);
else
nonInitConstCheck(loc, identifier, type);
@@ -5030,7 +4969,7 @@ TIntermNode* TParseContext::declareVariable(const TSourceLoc& loc, TString& iden
// Declare the variable
if (arraySizes || type.isArray()) {
- // Arrayness is potentially coming both from the type and from the
+ // Arrayness is potentially coming both from the type and from the
// variable: "int[] a[];" or just one or the other.
// Merge it all to the type, so all arrayness is part of the type.
arrayDimCheck(loc, &type, arraySizes);
@@ -5094,7 +5033,7 @@ void TParseContext::inheritGlobalDefaults(TQualifier& dst) const
//
TVariable* TParseContext::makeInternalVariable(const char* name, const TType& type) const
{
- TString* nameString = new TString(name);
+ TString* nameString = NewPoolTString(name);
TVariable* variable = new TVariable(nameString, type);
symbolTable.makeInternalVariable(*variable);
@@ -5668,9 +5607,9 @@ void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, con
error(memberLoc, "member cannot contradict block", "stream", "");
}
- // "This includes a block's inheritance of the
- // current global default buffer, a block member's inheritance of the block's
- // buffer, and the requirement that any *xfb_buffer* declared on a block
+ // "This includes a block's inheritance of the
+ // current global default buffer, a block member's inheritance of the block's
+ // buffer, and the requirement that any *xfb_buffer* declared on a block
// member must match the buffer inherited from the block."
if (memberQualifier.hasXfbBuffer()) {
if (defaultQualification.layoutXfbBuffer != memberQualifier.layoutXfbBuffer)
@@ -5855,15 +5794,15 @@ void TParseContext::blockQualifierCheck(const TSourceLoc& loc, const TQualifier&
}
//
-// "For a block, this process applies to the entire block, or until the first member
-// is reached that has a location layout qualifier. When a block member is declared with a location
+// "For a block, this process applies to the entire block, or until the first member
+// is reached that has a location layout qualifier. When a block member is declared with a location
// qualifier, its location comes from that qualifier: The member's location qualifier overrides the block-level
-// declaration. Subsequent members are again assigned consecutive locations, based on the newest location,
-// until the next member declared with a location qualifier. The values used for locations do not have to be
+// declaration. Subsequent members are again assigned consecutive locations, based on the newest location,
+// until the next member declared with a location qualifier. The values used for locations do not have to be
// declared in increasing order."
void TParseContext::fixBlockLocations(const TSourceLoc& loc, TQualifier& qualifier, TTypeList& typeList, bool memberWithLocation, bool memberWithoutLocation)
{
- // "If a block has no block-level location layout qualifier, it is required that either all or none of its members
+ // "If a block has no block-level location layout qualifier, it is required that either all or none of its members
// have a location layout qualifier, or a compile-time error results."
if (! qualifier.hasLocation() && memberWithLocation && memberWithoutLocation)
error(loc, "either the block needs a location, or all members need a location, or no members have a location", "location", "");
@@ -5899,9 +5838,9 @@ void TParseContext::fixBlockLocations(const TSourceLoc& loc, TQualifier& qualifi
void TParseContext::fixBlockXfbOffsets(TQualifier& qualifier, TTypeList& typeList)
{
- // "If a block is qualified with xfb_offset, all its
- // members are assigned transform feedback buffer offsets. If a block is not qualified with xfb_offset, any
- // members of that block not qualified with an xfb_offset will not be assigned transform feedback buffer
+ // "If a block is qualified with xfb_offset, all its
+ // members are assigned transform feedback buffer offsets. If a block is not qualified with xfb_offset, any
+ // members of that block not qualified with an xfb_offset will not be assigned transform feedback buffer
// offsets."
if (! qualifier.hasXfbBuffer() || ! qualifier.hasXfbOffset())
@@ -5928,10 +5867,10 @@ void TParseContext::fixBlockXfbOffsets(TQualifier& qualifier, TTypeList& typeLis
qualifier.layoutXfbOffset = TQualifier::layoutXfbOffsetEnd;
}
-// Calculate and save the offset of each block member, using the recursively
+// Calculate and save the offset of each block member, using the recursively
// defined block offset rules and the user-provided offset and align.
//
-// Also, compute and save the total size of the block. For the block's size, arrayness
+// Also, compute and save the total size of the block. For the block's size, arrayness
// is not taken into account, as each element is backed by a separate buffer.
//
void TParseContext::fixBlockUniformOffsets(TQualifier& qualifier, TTypeList& typeList)
@@ -5955,20 +5894,20 @@ void TParseContext::fixBlockUniformOffsets(TQualifier& qualifier, TTypeList& typ
int memberAlignment = intermediate.getBaseAlignment(*typeList[member].type, memberSize, dummyStride, qualifier.layoutPacking == ElpStd140,
subMatrixLayout != ElmNone ? subMatrixLayout == ElmRowMajor : qualifier.layoutMatrix == ElmRowMajor);
if (memberQualifier.hasOffset()) {
- // "The specified offset must be a multiple
+ // "The specified offset must be a multiple
// of the base alignment of the type of the block member it qualifies, or a compile-time error results."
if (! IsMultipleOfPow2(memberQualifier.layoutOffset, memberAlignment))
error(memberLoc, "must be a multiple of the member's alignment", "offset", "");
- // GLSL: "It is a compile-time error to specify an offset that is smaller than the offset of the previous
+ // GLSL: "It is a compile-time error to specify an offset that is smaller than the offset of the previous
// member in the block or that lies within the previous member of the block"
if (spvVersion.spv == 0) {
if (memberQualifier.layoutOffset < offset)
error(memberLoc, "cannot lie in previous members", "offset", "");
- // "The offset qualifier forces the qualified member to start at or after the specified
- // integral-constant expression, which will be its byte offset from the beginning of the buffer.
- // "The actual offset of a member is computed as
+ // "The offset qualifier forces the qualified member to start at or after the specified
+ // integral-constant expression, which will be its byte offset from the beginning of the buffer.
+ // "The actual offset of a member is computed as
// follows: If offset was declared, start with that offset, otherwise start with the next available offset."
offset = std::max(offset, memberQualifier.layoutOffset);
} else {
@@ -5979,13 +5918,13 @@ void TParseContext::fixBlockUniformOffsets(TQualifier& qualifier, TTypeList& typ
}
}
- // "The actual alignment of a member will be the greater of the specified align alignment and the standard
+ // "The actual alignment of a member will be the greater of the specified align alignment and the standard
// (e.g., std140) base alignment for the member's type."
if (memberQualifier.hasAlign())
memberAlignment = std::max(memberAlignment, memberQualifier.layoutAlign);
// "If the resulting offset is not a multiple of the actual alignment,
- // increase it to the first offset that is a multiple of
+ // increase it to the first offset that is a multiple of
// the actual alignment."
RoundToPow2(offset, memberAlignment);
typeList[member].type->getQualifier().layoutOffset = offset;
@@ -6075,7 +6014,7 @@ void TParseContext::updateStandaloneQualifierDefaults(const TSourceLoc& loc, con
error(loc, "can only apply to 'out'", id, "");
if (! intermediate.setVertices(publicType.shaderQualifiers.vertices))
error(loc, "cannot change previously set layout value", id, "");
-
+
if (language == EShLangTessControl)
checkIoArraysConsistency(loc);
}
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.h b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.h
index f850f089714..2e09a5ae96a 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/ParseHelper.h
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2012-2013 LunarG, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2012-2013 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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.
//
//
@@ -170,6 +170,9 @@ protected:
std::function<bool(const TType&, const TType&, const TType&)>,
/* output */ bool& tie);
+ virtual void parseSwizzleSelector(const TSourceLoc&, const TString&, int size,
+ TSwizzleSelectors<TVectorSelector>&);
+
// Manage the global uniform block (default uniforms in GLSL, $Global in HLSL)
TVariable* globalUniformBlock; // the actual block, inserted into the symbol table
int firstNewMember; // the index of the first member not yet inserted into the symbol table
@@ -284,7 +287,6 @@ public:
void handlePrecisionQualifier(const TSourceLoc&, TQualifier&, TPrecisionQualifier);
void checkPrecisionQualifier(const TSourceLoc&, TPrecisionQualifier);
- bool parseVectorFields(const TSourceLoc&, const TString&, int vecSize, TVectorFields&);
void assignError(const TSourceLoc&, const char* op, TString left, TString right);
void unaryOpError(const TSourceLoc&, const char* op, TString operand);
void binaryOpError(const TSourceLoc&, const char* op, TString left, TString right);
@@ -448,7 +450,7 @@ protected:
// * note, that appropriately gives an error if redeclaring a block that
// was already used and hence already copied-up
//
- // - on seeing a layout declaration that sizes the array, fix everything in the
+ // - on seeing a layout declaration that sizes the array, fix everything in the
// resize-list, giving errors for mismatch
//
// - on seeing an array size declaration, give errors on mismatch between it and previous
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/PoolAlloc.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/PoolAlloc.cpp
index 9dfcd30558d..4007c386153 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/PoolAlloc.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/PoolAlloc.cpp
@@ -1,10 +1,10 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -18,18 +18,18 @@
// 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.
+// 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 "../Include/Common.h"
@@ -44,14 +44,14 @@ OS_TLSIndex PoolIndex;
void InitializeMemoryPools()
{
- TThreadMemoryPools* pools = static_cast<TThreadMemoryPools*>(OS_GetTLSValue(PoolIndex));
+ TThreadMemoryPools* pools = static_cast<TThreadMemoryPools*>(OS_GetTLSValue(PoolIndex));
if (pools)
return;
TPoolAllocator *threadPoolAllocator = new TPoolAllocator();
TThreadMemoryPools* threadData = new TThreadMemoryPools();
-
+
threadData->threadPoolAllocator = threadPoolAllocator;
OS_SetTLSValue(PoolIndex, threadData);
@@ -60,12 +60,12 @@ void InitializeMemoryPools()
void FreeGlobalPools()
{
// Release the allocated memory for this thread.
- TThreadMemoryPools* globalPools = static_cast<TThreadMemoryPools*>(OS_GetTLSValue(PoolIndex));
+ TThreadMemoryPools* globalPools = static_cast<TThreadMemoryPools*>(OS_GetTLSValue(PoolIndex));
if (! globalPools)
return;
GetThreadPoolAllocator().popAll();
- delete &GetThreadPoolAllocator();
+ delete &GetThreadPoolAllocator();
delete globalPools;
}
@@ -102,11 +102,11 @@ void SetThreadPoolAllocator(TPoolAllocator& poolAllocator)
// Implement the functionality of the TPoolAllocator class, which
// is documented in PoolAlloc.h.
//
-TPoolAllocator::TPoolAllocator(int growthIncrement, int allocationAlignment) :
+TPoolAllocator::TPoolAllocator(int growthIncrement, int allocationAlignment) :
pageSize(growthIncrement),
alignment(allocationAlignment),
- freeList(0),
- inUseList(0),
+ freeList(nullptr),
+ inUseList(nullptr),
numCalls(0)
{
//
@@ -206,13 +206,12 @@ void TAllocation::checkGuardBlock(unsigned char*, unsigned char, const char*) co
#endif
}
-
void TPoolAllocator::push()
{
tAllocState state = { currentPageOffset, inUseList };
stack.push_back(state);
-
+
//
// Indicate there is no current page to allocate from.
//
@@ -237,7 +236,7 @@ void TPoolAllocator::pop()
while (inUseList != page) {
// invoke destructor to free allocation list
inUseList->~tHeader();
-
+
tHeader* nextInUse = inUseList->nextPage;
if (inUseList->pageCount > 1)
delete [] reinterpret_cast<char*>(inUseList);
@@ -269,7 +268,7 @@ void* TPoolAllocator::allocate(size_t numBytes)
// size including guard blocks. In release build,
// guardBlockSize=0 and this all gets optimized away.
size_t allocationSize = TAllocation::allocationSize(numBytes);
-
+
//
// Just keep some interesting statistics.
//
@@ -327,14 +326,13 @@ void* TPoolAllocator::allocate(size_t numBytes)
// Use placement-new to initialize header
new(memory) tHeader(inUseList, 1);
inUseList = memory;
-
+
unsigned char* ret = reinterpret_cast<unsigned char*>(inUseList) + headerSkip;
currentPageOffset = (headerSkip + allocationSize + alignmentMask) & ~alignmentMask;
return initializeAllocation(inUseList, ret, numBytes);
}
-
//
// Check all allocations in a list for damage by calling check on each.
//
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/RemoveTree.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/RemoveTree.cpp
index a4fa551cadf..1d33bfd2035 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/RemoveTree.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/RemoveTree.cpp
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2013 LunarG, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2013 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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 "../Include/intermediate.h"
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/RemoveTree.h b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/RemoveTree.h
index 483b25dcb51..507307e44b3 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/RemoveTree.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/RemoveTree.h
@@ -1,10 +1,10 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -18,18 +18,18 @@
// 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.
+// 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.
//
namespace glslang {
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Scan.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Scan.cpp
index 3ea316d8f71..0e64364e2e7 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Scan.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Scan.cpp
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2013 LunarG, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2013 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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.
//
//
@@ -142,13 +142,13 @@ void TInputScanner::consumeWhitespaceComment(bool& foundNonSpaceTab)
{
do {
consumeWhiteSpace(foundNonSpaceTab);
-
+
// if not starting a comment now, then done
int c = peek();
if (c != '/' || c == EndOfInput)
return;
- // skip potential comment
+ // skip potential comment
foundNonSpaceTab = true;
if (! consumeComment())
return;
@@ -199,10 +199,10 @@ bool TInputScanner::scanVersion(int& version, EProfile& profile, bool& notFirstT
}
lookingInMiddle = true;
- // Nominal start, skipping the desktop allowed comments and white space, but tracking if
+ // Nominal start, skipping the desktop allowed comments and white space, but tracking if
// something else was found for ES:
consumeWhitespaceComment(foundNonSpaceTab);
- if (foundNonSpaceTab)
+ if (foundNonSpaceTab)
versionNotFirst = true;
// "#"
@@ -721,7 +721,7 @@ int TScanContext::tokenize(TPpContext* pp, TParserToken& token)
default:
char buf[2];
- buf[0] = token;
+ buf[0] = (char)token;
buf[1] = 0;
parseContext.error(loc, "unexpected token", buf, "");
break;
@@ -802,7 +802,7 @@ int TScanContext::tokenizeIdentifier()
return keyword;
case BUFFER:
- if ((parseContext.profile == EEsProfile && parseContext.version < 310) ||
+ if ((parseContext.profile == EEsProfile && parseContext.version < 310) ||
(parseContext.profile != EEsProfile && parseContext.version < 430))
return identifierOrType();
return keyword;
@@ -962,7 +962,7 @@ int TScanContext::tokenizeIdentifier()
case U64VEC3:
case U64VEC4:
afterType = true;
- if (parseContext.symbolTable.atBuiltInLevel() ||
+ if (parseContext.symbolTable.atBuiltInLevel() ||
(parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_int64) &&
parseContext.profile != EEsProfile && parseContext.version >= 450))
return keyword;
@@ -1194,7 +1194,7 @@ int TScanContext::tokenizeIdentifier()
return keyword;
case PRECISE:
- if ((parseContext.profile == EEsProfile && parseContext.extensionsTurnedOn(Num_AEP_gpu_shader5, AEP_gpu_shader5)) ||
+ if ((parseContext.profile == EEsProfile && parseContext.extensionsTurnedOn(Num_AEP_gpu_shader5, AEP_gpu_shader5)) ||
(parseContext.profile != EEsProfile && parseContext.version >= 400))
return keyword;
if (parseContext.profile == EEsProfile && parseContext.version == 310) {
@@ -1356,7 +1356,7 @@ int TScanContext::dMat()
int TScanContext::firstGenerationImage(bool inEs310)
{
- if (parseContext.symbolTable.atBuiltInLevel() ||
+ if (parseContext.symbolTable.atBuiltInLevel() ||
(parseContext.profile != EEsProfile && (parseContext.version >= 420 || parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))) ||
(inEs310 && parseContext.profile == EEsProfile && parseContext.version >= 310))
return keyword;
@@ -1381,8 +1381,8 @@ int TScanContext::secondGenerationImage()
return keyword;
}
- if (parseContext.symbolTable.atBuiltInLevel() ||
- (parseContext.profile != EEsProfile &&
+ if (parseContext.symbolTable.atBuiltInLevel() ||
+ (parseContext.profile != EEsProfile &&
(parseContext.version >= 420 || parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))))
return keyword;
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Scan.h b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Scan.h
index 67c86d2efe7..9b8f2d4517c 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Scan.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Scan.h
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2013 LunarG, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2013 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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.
//
#ifndef _GLSLANG_SCAN_INCLUDED_
#define _GLSLANG_SCAN_INCLUDED_
@@ -254,7 +254,7 @@ protected:
size_t currentChar;
// This is for reporting what string/line an error occurred on, and can be overridden by #line.
- // It remembers the last state of each source string as it is left for the next one, so unget()
+ // It remembers the last state of each source string as it is left for the next one, so unget()
// can restore that state.
TSourceLoc* loc; // an array
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/ScanContext.h b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/ScanContext.h
index f237bee9f29..1d86348eb38 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/ScanContext.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/ScanContext.h
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2013 LunarG, Inc.
+// Copyright (C) 2013 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
//
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/ShaderLang.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/ShaderLang.cpp
index 9038a7f0e9e..b0e55132a2d 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/ShaderLang.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/ShaderLang.cpp
@@ -1,13 +1,13 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2013-2016 LunarG, Inc.
-//Copyright (C) 2015-2016 Google, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2013-2016 LunarG, Inc.
+// Copyright (C) 2015-2016 Google, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -21,18 +21,18 @@
// 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.
+// 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.
//
//
@@ -47,11 +47,14 @@
#include <memory>
#include "SymbolTable.h"
#include "ParseHelper.h"
-#include "../../hlsl/hlslParseHelper.h"
-#include "../../hlsl/hlslParseables.h"
#include "Scan.h"
#include "ScanContext.h"
+
+#ifdef ENABLE_HLSL
+#include "../../hlsl/hlslParseHelper.h"
+#include "../../hlsl/hlslParseables.h"
#include "../../hlsl/hlslScanContext.h"
+#endif
#include "../Include/ShHandle.h"
#include "../../OGLCompilersDLL/InitializeDll.h"
@@ -73,7 +76,9 @@ TBuiltInParseables* CreateBuiltInParseables(TInfoSink& infoSink, EShSource sourc
{
switch (source) {
case EShSourceGlsl: return new TBuiltIns(); // GLSL builtIns
+#ifdef ENABLE_HLSL
case EShSourceHlsl: return new TBuiltInParseablesHlsl(); // HLSL intrinsics
+#endif
default:
infoSink.info.message(EPrefixInternalError, "Unable to determine source language");
@@ -88,15 +93,21 @@ TParseContextBase* CreateParseContext(TSymbolTable& symbolTable, TIntermediate&
SpvVersion spvVersion, bool forwardCompatible, EShMessages messages,
bool parsingBuiltIns, const std::string sourceEntryPointName = "")
{
+#ifndef ENABLE_HLSL
+ (void)sourceEntryPointName; // Unused argument.
+#endif
+
switch (source) {
case EShSourceGlsl:
intermediate.setEntryPointName("main");
return new TParseContext(symbolTable, intermediate, parsingBuiltIns, version, profile, spvVersion,
language, infoSink, forwardCompatible, messages);
+#ifdef ENABLE_HLSL
case EShSourceHlsl:
return new HlslParseContext(symbolTable, intermediate, parsingBuiltIns, version, profile, spvVersion,
language, infoSink, sourceEntryPointName.c_str(), forwardCompatible, messages);
+#endif
default:
infoSink.info.message(EPrefixInternalError, "Unable to determine source language");
return nullptr;
@@ -194,11 +205,11 @@ enum EPrecisionClass {
EPcCount
};
-// A process-global symbol table per version per profile for built-ins common
-// to multiple stages (languages), and a process-global symbol table per version
+// A process-global symbol table per version per profile for built-ins common
+// to multiple stages (languages), and a process-global symbol table per version
// per profile per stage for built-ins unique to each stage. They will be sparsely
// populated, so they will only be generated as needed.
-//
+//
// Each has a different set of built-ins, and we want to preserve that from
// compile to compile.
//
@@ -214,19 +225,19 @@ bool InitializeSymbolTable(const TString& builtIns, int version, EProfile profil
EShSource source, TInfoSink& infoSink, TSymbolTable& symbolTable)
{
TIntermediate intermediate(language, version, profile);
-
+
intermediate.setSource(source);
- std::unique_ptr<TParseContextBase> parseContext(CreateParseContext(symbolTable, intermediate, version, profile, source,
+ std::unique_ptr<TParseContextBase> parseContext(CreateParseContext(symbolTable, intermediate, version, profile, source,
language, infoSink, spvVersion, true, EShMsgDefault,
true));
- TShader::ForbidInclude includer;
+ TShader::ForbidIncluder includer;
TPpContext ppContext(*parseContext, "", includer);
TScanContext scanContext(*parseContext);
parseContext->setScanContext(&scanContext);
parseContext->setPpContext(&ppContext);
-
+
//
// Push the symbol table to give it an initial scope. This
// push should not have a corresponding pop, so that built-ins
@@ -242,7 +253,7 @@ bool InitializeSymbolTable(const TString& builtIns, int version, EProfile profil
if (builtInLengths[0] == 0)
return true;
-
+
TInputScanner input(1, builtInShaders, builtInLengths);
if (! parseContext->parseShaderStrings(ppContext, input) != 0) {
infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins");
@@ -285,6 +296,9 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TS
{
std::unique_ptr<TBuiltInParseables> builtInParseables(CreateBuiltInParseables(infoSink, source));
+ if (builtInParseables == nullptr)
+ return false;
+
builtInParseables->initialize(version, profile, spvVersion);
// do the common tables
@@ -330,7 +344,10 @@ bool AddContextSpecificSymbols(const TBuiltInResource* resources, TInfoSink& inf
EProfile profile, const SpvVersion& spvVersion, EShLanguage language, EShSource source)
{
std::unique_ptr<TBuiltInParseables> builtInParseables(CreateBuiltInParseables(infoSink, source));
-
+
+ if (builtInParseables == nullptr)
+ return false;
+
builtInParseables->initialize(*resources, version, profile, spvVersion, language);
InitializeSymbolTable(builtInParseables->getCommonString(), version, profile, spvVersion, language, source, infoSink, symbolTable);
builtInParseables->identifyBuiltIns(version, profile, spvVersion, language, symbolTable, *resources);
@@ -339,7 +356,7 @@ bool AddContextSpecificSymbols(const TBuiltInResource* resources, TInfoSink& inf
}
//
-// To do this on the fly, we want to leave the current state of our thread's
+// To do this on the fly, we want to leave the current state of our thread's
// pool allocator intact, so:
// - Switch to a new pool for parsing the built-ins
// - Do the parsing, which builds the symbol table, using the new pool
@@ -402,7 +419,7 @@ void SetupBuiltinSymbolTable(int version, EProfile profile, const SpvVersion& sp
[versionIndex][spvVersionIndex][profileIndex][sourceIndex][CommonIndex(profile, (EShLanguage)stage)]);
SharedSymbolTables[versionIndex][spvVersionIndex][profileIndex][sourceIndex][stage]->copyTable(*stageTables[stage]);
SharedSymbolTables[versionIndex][spvVersionIndex][profileIndex][sourceIndex][stage]->readOnly();
- }
+ }
}
// Clean up the local tables before deleting the pool they used.
@@ -471,7 +488,7 @@ bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNo
profile = ECoreProfile;
else
profile = ENoProfile;
- }
+ }
// else: typical desktop case... e.g., "#version 410 core"
}
}
@@ -628,7 +645,7 @@ bool ProcessDeferred(
if (numStrings == 0)
return true;
-
+
// Move to length-based strings, rather than null-terminated strings.
// Also, add strings to include the preamble and to ensure the shader is not null,
// which lets the grammar accept what was a null (post preprocessing) shader.
@@ -710,24 +727,25 @@ bool ProcessDeferred(
if (spvVersion.vulkan >= 100)
intermediate.setOriginUpperLeft();
SetupBuiltinSymbolTable(version, profile, spvVersion, source);
-
+
TSymbolTable* cachedTable = SharedSymbolTables[MapVersionToIndex(version)]
[MapSpvVersionToIndex(spvVersion)]
[MapProfileToIndex(profile)]
[MapSourceToIndex(source)]
[compiler->getLanguage()];
-
+
// Dynamically allocate the symbol table so we can control when it is deallocated WRT the pool.
TSymbolTable* symbolTableMemory = new TSymbolTable;
TSymbolTable& symbolTable = *symbolTableMemory;
if (cachedTable)
symbolTable.adoptLevels(*cachedTable);
-
+
// Add built-in symbols that are potentially context dependent;
// they get popped again further down.
- AddContextSpecificSymbols(resources, compiler->infoSink, symbolTable, version, profile, spvVersion,
- compiler->getLanguage(), source);
-
+ if (! AddContextSpecificSymbols(resources, compiler->infoSink, symbolTable, version, profile, spvVersion,
+ compiler->getLanguage(), source))
+ return false;
+
//
// Now we can process the full shader under proper symbols and rules.
//
@@ -754,7 +772,7 @@ bool ProcessDeferred(
}
parseContext->initializeExtensionBehavior();
-
+
// Fill in the strings as outlined above.
std::string preamble;
parseContext->getPreamble(preamble);
@@ -978,7 +996,7 @@ struct DoFullParse{
bool operator()(TParseContextBase& parseContext, TPpContext& ppContext,
TInputScanner& fullInput, bool versionWillBeError,
TSymbolTable&, TIntermediate& intermediate,
- EShOptimizationLevel optLevel, EShMessages messages)
+ EShOptimizationLevel optLevel, EShMessages messages)
{
bool success = true;
// Parse the full shader.
@@ -1032,7 +1050,6 @@ bool PreprocessDeferred(
false, includer);
}
-
//
// do a partial compile on the given strings for a single compilation unit
// for a potential deferred link into a single stage (and deferred full compile of that
@@ -1041,7 +1058,7 @@ bool PreprocessDeferred(
// all preprocessing, parsing, semantic checks, etc. for a single compilation unit
// are done here.
//
-// return: the tree and other information is filled into the intermediate argument,
+// return: the tree and other information is filled into the intermediate argument,
// and true is returned by the function for success.
//
bool CompileDeferred(
@@ -1072,7 +1089,6 @@ bool CompileDeferred(
} // end anonymous namespace for local functions
-
//
// ShInitialize() should be called exactly once per process, not per thread.
//
@@ -1087,7 +1103,9 @@ int ShInitialize()
PerProcessGPA = new TPoolAllocator();
glslang::TScanContext::fillInKeywordMap();
+#ifdef ENABLE_HLSL
glslang::HlslScanContext::fillInKeywordMap();
+#endif
return 1;
}
@@ -1103,7 +1121,7 @@ ShHandle ShConstructCompiler(const EShLanguage language, int debugOptions)
return 0;
TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(language, debugOptions));
-
+
return reinterpret_cast<void*>(base);
}
@@ -1180,7 +1198,9 @@ int __fastcall ShFinalize()
}
glslang::TScanContext::deleteKeywordMap();
+#ifdef ENABLE_HLSL
glslang::HlslScanContext::deleteKeywordMap();
+#endif
return 1;
}
@@ -1219,7 +1239,7 @@ int ShCompile(
compiler->infoSink.debug.erase();
TIntermediate intermediate(compiler->getLanguage());
- TShader::ForbidInclude includer;
+ TShader::ForbidIncluder includer;
bool success = CompileDeferred(compiler, shaderStrings, numStrings, inputLengths, nullptr,
"", optLevel, resources, defaultVersion, ENoProfile, false,
forwardCompatible, messages, intermediate, includer);
@@ -1264,8 +1284,7 @@ int ShLinkExt(
}
if (base->getAsCompiler())
cObjects.push_back(base->getAsCompiler());
-
-
+
if (cObjects[i] == 0)
return 0;
}
@@ -1281,7 +1300,7 @@ int ShLinkExt(
for (int i = 0; i < numHandles; ++i) {
if (cObjects[i]->getAsCompiler()) {
if (! cObjects[i]->getAsCompiler()->linkable()) {
- linker->infoSink.info.message(EPrefixError, "Not all shaders have valid object code.");
+ linker->infoSink.info.message(EPrefixError, "Not all shaders have valid object code.");
return 0;
}
}
@@ -1340,7 +1359,7 @@ const void* ShGetExecutable(const ShHandle handle)
return 0;
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
-
+
TLinker* linker = static_cast<TLinker*>(base->getAsLinker());
if (linker == 0)
return 0;
@@ -1357,7 +1376,7 @@ const void* ShGetExecutable(const ShHandle handle)
// success or failure.
//
int ShSetVirtualAttributeBindings(const ShHandle handle, const ShBindingTable* table)
-{
+{
if (!InitThread())
return 0;
@@ -1369,7 +1388,7 @@ int ShSetVirtualAttributeBindings(const ShHandle handle, const ShBindingTable* t
if (linker == 0)
return 0;
-
+
linker->setAppAttributeBindings(table);
return 1;
@@ -1446,7 +1465,7 @@ int ShGetUniformLocation(const ShHandle handle, const char* name)
//
// Below is a new alternate C++ interface that might potentially replace the above
// opaque handle-based interface.
-//
+//
// See more detailed comment in ShaderLang.h
//
@@ -1552,7 +1571,7 @@ bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion
{
if (! InitThread())
return false;
-
+
pool = new TPoolAllocator();
SetThreadPoolAllocator(*pool);
if (! preamble)
@@ -1613,6 +1632,7 @@ TProgram::TProgram() : pool(0), reflection(0), ioMapper(nullptr), linked(false)
TProgram::~TProgram()
{
+ delete ioMapper;
delete infoSink;
delete reflection;
@@ -1636,7 +1656,7 @@ bool TProgram::link(EShMessages messages)
linked = true;
bool error = false;
-
+
pool = new TPoolAllocator();
SetThreadPoolAllocator(*pool);
@@ -1688,6 +1708,15 @@ bool TProgram::linkStage(EShLanguage stage, EShMessages messages)
intermediate[stage] = new TIntermediate(stage,
firstIntermediate->getVersion(),
firstIntermediate->getProfile());
+
+
+ // The new TIntermediate must use the same origin as the original TIntermediates.
+ // Otherwise linking will fail due to different coordinate systems.
+ if (firstIntermediate->getOriginUpperLeft()) {
+ intermediate[stage]->setOriginUpperLeft();
+ }
+ intermediate[stage]->setSpv(firstIntermediate->getSpv());
+
newedIntermediate[stage] = true;
}
@@ -1723,7 +1752,7 @@ const char* TProgram::getInfoDebugLog()
//
bool TProgram::buildReflection()
-{
+{
if (! linked || reflection)
return false;
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/SymbolTable.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/SymbolTable.cpp
index fb09fdf9913..080a5e0f482 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/SymbolTable.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/SymbolTable.cpp
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2012-2013 LunarG, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2012-2013 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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.
//
//
@@ -295,6 +295,7 @@ TFunction::TFunction(const TFunction& copyOf) : TSymbol(copyOf)
op = copyOf.op;
defined = copyOf.defined;
prototyped = copyOf.prototyped;
+ defaultParamCount = copyOf.defaultParamCount;
}
TFunction* TFunction::clone() const
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/SymbolTable.h b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/SymbolTable.h
index aeec34fc029..9028dd76245 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/SymbolTable.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/SymbolTable.h
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2013 LunarG, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2013 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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.
//
#ifndef _SYMBOL_TABLE_INCLUDED_
@@ -120,7 +120,7 @@ protected:
const TString *name;
unsigned int uniqueId; // For cross-scope comparing during code generation
- // For tracking what extensions must be present
+ // For tracking what extensions must be present
// (don't use if correct version/profile is present).
int numExtensions;
const char** extensions; // an array of pointers to existing constant char strings
@@ -145,7 +145,7 @@ protected:
class TVariable : public TSymbol {
public:
TVariable(const TString *name, const TType& t, bool uT = false )
- : TSymbol(name),
+ : TSymbol(name),
userType(uT),
constSubtree(nullptr),
anonId(-1) { type.shallowCopy(t); }
@@ -191,13 +191,15 @@ protected:
struct TParameter {
TString *name;
TType* type;
- void copyParam(const TParameter& param)
+ TIntermTyped* defaultValue;
+ void copyParam(const TParameter& param)
{
if (param.name)
name = NewPoolTString(param.name->c_str());
else
name = 0;
type = param.type->clone();
+ defaultValue = param.defaultValue;
}
};
@@ -209,12 +211,12 @@ public:
explicit TFunction(TOperator o) :
TSymbol(0),
op(o),
- defined(false), prototyped(false) { }
+ defined(false), prototyped(false), defaultParamCount(0) { }
TFunction(const TString *name, const TType& retType, TOperator tOp = EOpNull) :
TSymbol(name),
mangledName(*name + '('),
op(tOp),
- defined(false), prototyped(false) { returnType.shallowCopy(retType); }
+ defined(false), prototyped(false), defaultParamCount(0) { returnType.shallowCopy(retType); }
virtual TFunction* clone() const;
virtual ~TFunction();
@@ -226,6 +228,9 @@ public:
assert(writable);
parameters.push_back(p);
p.type->appendMangledName(mangledName);
+
+ if (p.defaultValue != nullptr)
+ defaultParamCount++;
}
virtual const TString& getMangledName() const { return mangledName; }
@@ -238,7 +243,13 @@ public:
virtual void setPrototyped() { assert(writable); prototyped = true; }
virtual bool isPrototyped() const { return prototyped; }
+ // Return total number of parameters
virtual int getParamCount() const { return static_cast<int>(parameters.size()); }
+ // Return number of parameters with default values.
+ virtual int getDefaultParamCount() const { return defaultParamCount; }
+ // Return number of fixed parameters (without default values)
+ virtual int getFixedParamCount() const { return getParamCount() - getDefaultParamCount(); }
+
virtual TParameter& operator[](int i) { assert(writable); return parameters[i]; }
virtual const TParameter& operator[](int i) const { return parameters[i]; }
@@ -255,6 +266,7 @@ protected:
TOperator op;
bool defined;
bool prototyped;
+ int defaultParamCount;
};
//
@@ -272,7 +284,7 @@ public:
virtual const TAnonMember* getAsAnonMember() const { return this; }
virtual const TVariable& getAnonContainer() const { return anonContainer; }
virtual unsigned int getMemberNumber() const { return memberNumber; }
-
+
virtual const TType& getType() const
{
const TTypeList& types = *anonContainer.getType().getStruct();
@@ -285,7 +297,7 @@ public:
const TTypeList& types = *anonContainer.getType().getStruct();
return *types[memberNumber].type;
}
-
+
virtual int getAnonId() const { return anonId; }
virtual void dump(TInfoSink &infoSink) const;
@@ -365,7 +377,7 @@ public:
TSymbol* find(const TString& name) const
{
tLevel::const_iterator it = level.find(name);
- if (it == level.end())
+ if (it == level.end())
return 0;
else
return (*it).second;
@@ -488,7 +500,7 @@ public:
while (table.size() > adoptedLevels)
pop(0);
}
-
+
void adoptLevels(TSymbolTable& symTable)
{
for (unsigned int level = 0; level < symTable.table.size(); ++level) {
@@ -520,7 +532,7 @@ public:
void setNoBuiltInRedeclarations() { noBuiltInRedeclarations = true; }
void setSeparateNameSpaces() { separateNameSpaces = true; }
-
+
void push()
{
table.push_back(new TSymbolTableLevel);
@@ -546,7 +558,7 @@ public:
// make sure there isn't a function of this variable name
if (! separateNameSpaces && ! symbol.getAsFunction() && table[currentLevel()]->hasFunctionName(symbol.getName()))
return false;
-
+
// check for not overloading or redefining a built-in function
if (noBuiltInRedeclarations) {
if (atGlobalLevel() && currentLevel() > 0) {
@@ -570,7 +582,7 @@ public:
//
// To allocate an internal temporary, which will need to be uniquely
- // identified by the consumer of the AST, but never need to
+ // identified by the consumer of the AST, but never need to
// found by doing a symbol table search by name, hence allowed an
// arbitrary name in the symbol with no worry of collision.
//
@@ -672,7 +684,7 @@ public:
for (unsigned int level = 0; level < table.size(); ++level)
table[level]->relateToOperator(name, op);
}
-
+
void setFunctionExtensions(const char* name, int num, const char* const extensions[])
{
for (unsigned int level = 0; level < table.size(); ++level)
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Versions.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Versions.cpp
index afedb4f713b..9025e7612f4 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Versions.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Versions.cpp
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2012-2013 LunarG, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2012-2013 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,24 +20,24 @@
// 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.
+// 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.
//
//
// Help manage multiple profiles, versions, extensions etc.
//
-// These don't return error codes, as the presumption is parsing will
+// These don't return error codes, as the presumption is parsing will
// always continue as if the tested feature were enabled, and thus there
// is no error recovery needed.
//
@@ -47,25 +47,25 @@
//
// To add a new hypothetical "Feature F" to the front end, where an extension
// "XXX_extension_X" can be used to enable the feature, do the following.
-//
+//
// OVERVIEW: Specific features are what are error-checked for, not
-// extensions: A specific Feature F might be enabled by an extension, or a
+// extensions: A specific Feature F might be enabled by an extension, or a
// particular version in a particular profile, or a stage, or combinations, etc.
-//
-// The basic mechanism is to use the following to "declare" all the things that
+//
+// The basic mechanism is to use the following to "declare" all the things that
// enable/disable Feature F, in a code path that implements Feature F:
-//
+//
// requireProfile()
// profileRequires()
// requireStage()
// checkDeprecated()
// requireNotRemoved()
// requireExtensions()
-//
-// Typically, only the first two calls are needed. They go into a code path that
-// implements Feature F, and will log the proper error/warning messages. Parsing
+//
+// Typically, only the first two calls are needed. They go into a code path that
+// implements Feature F, and will log the proper error/warning messages. Parsing
// will then always continue as if the tested feature was enabled.
-//
+//
// There is typically no if-testing or conditional parsing, just insertion of the calls above.
// However, if symbols specific to the extension are added (step 5), they will
// only be added under tests that the minimum version and profile are present.
@@ -73,10 +73,10 @@
// 1) Add a symbol name for the extension string at the bottom of Versions.h:
//
// const char* const XXX_extension_X = "XXX_extension_X";
-//
+//
// 2) Add extension initialization to TParseVersions::initializeExtensionBehavior(),
// the first function below:
-//
+//
// extensionBehavior[XXX_extension_X] = EBhDisable;
//
// 3) Add any preprocessor directives etc. in the next function, TParseVersions::getPreamble():
@@ -84,50 +84,50 @@
// "#define XXX_extension_X 1\n"
//
// The new-line is important, as that ends preprocess tokens.
-//
+//
// 4) Insert a profile check in the feature's path (unless all profiles support the feature,
// for some version level). That is, call requireProfile() to constrain the profiles, e.g.:
-//
+//
// // ... in a path specific to Feature F...
// requireProfile(loc,
// ECoreProfile | ECompatibilityProfile,
// "Feature F");
-//
+//
// 5) For each profile that supports the feature, insert version/extension checks:
-//
+//
// The mostly likely scenario is that Feature F can only be used with a
// particular profile if XXX_extension_X is present or the version is
// high enough that the core specification already incorporated it.
-//
+//
// // following the requireProfile() call...
-// profileRequires(loc,
+// profileRequires(loc,
// ECoreProfile | ECompatibilityProfile,
// 420, // 0 if no version incorporated the feature into the core spec.
// XXX_extension_X, // can be a list of extensions that all add the feature
// "Feature F Description");
-//
+//
// This allows the feature if either A) one of the extensions is enabled or
// B) the version is high enough. If no version yet incorporates the feature
// into core, pass in 0.
-//
+//
// This can be called multiple times, if different profiles support the
-// feature starting at different version numbers or with different
+// feature starting at different version numbers or with different
// extensions.
-//
+//
// This must be called for each profile allowed by the initial call to requireProfile().
-//
+//
// Profiles are all masks, which can be "or"-ed together.
-//
+//
// ENoProfile
// ECoreProfile
// ECompatibilityProfile
// EEsProfile
-//
+//
// The ENoProfile profile is only for desktop, before profiles showed up in version 150;
// All other #version with no profile default to either es or core, and so have profiles.
-//
+//
// You can select all but a particular profile using ~. The following basically means "desktop":
-//
+//
// ~EEsProfile
//
// 6) If built-in symbols are added by the extension, add them in Initialize.cpp: Their use
@@ -155,7 +155,7 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_EXT_frag_depth] = EBhDisable;
extensionBehavior[E_GL_OES_EGL_image_external] = EBhDisable;
extensionBehavior[E_GL_EXT_shader_texture_lod] = EBhDisable;
-
+
extensionBehavior[E_GL_ARB_texture_rectangle] = EBhDisable;
extensionBehavior[E_GL_3DL_array_objects] = EBhDisable;
extensionBehavior[E_GL_ARB_shading_language_420pack] = EBhDisable;
@@ -195,9 +195,12 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_AMD_gpu_shader_half_float] = EBhDisable;
#endif
-#ifdef NV_EXTENSIONS
+#ifdef NV_EXTENSIONS
extensionBehavior[E_GL_NV_sample_mask_override_coverage] = EBhDisable;
extensionBehavior[E_SPV_NV_geometry_shader_passthrough] = EBhDisable;
+ extensionBehavior[E_GL_ARB_shader_viewport_layer_array] = EBhDisable;
+ extensionBehavior[E_GL_NV_viewport_array2] = EBhDisable;
+ extensionBehavior[E_GL_NV_stereo_view_rendering] = EBhDisable;
#endif
// AEP
@@ -234,7 +237,7 @@ void TParseVersions::initializeExtensionBehavior()
void TParseVersions::getPreamble(std::string& preamble)
{
if (profile == EEsProfile) {
- preamble =
+ preamble =
"#define GL_ES 1\n"
"#define GL_FRAGMENT_PRECISION_HIGH 1\n"
"#define GL_OES_texture_3D 1\n"
@@ -273,7 +276,7 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_EXT_shader_non_constant_global_initializers 1\n"
;
} else {
- preamble =
+ preamble =
"#define GL_FRAGMENT_PRECISION_HIGH 1\n"
"#define GL_ARB_texture_rectangle 1\n"
"#define GL_ARB_shading_language_420pack 1\n"
@@ -308,15 +311,16 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_AMD_gpu_shader_half_float 1\n"
#endif
-#ifdef NV_EXTENSIONS
+#ifdef NV_EXTENSIONS
"#define GL_NV_sample_mask_override_coverage 1\n"
"#define GL_NV_geometry_shader_passthrough 1\n"
+ "#define GL_NV_viewport_array2 1\n"
#endif
;
}
// #line and #include
- preamble +=
+ preamble +=
"#define GL_GOOGLE_cpp_style_line_directive 1\n"
"#define GL_GOOGLE_include_directive 1\n"
;
@@ -343,7 +347,7 @@ void TParseVersions::getPreamble(std::string& preamble)
//
// When to use requireProfile():
//
-// Use if only some profiles support a feature. However, if within a profile the feature
+// Use if only some profiles support a feature. However, if within a profile the feature
// is version or extension specific, follow this call with calls to profileRequires().
//
// Operation: If the current profile is not one of the profileMask,
@@ -358,7 +362,7 @@ void TParseVersions::requireProfile(const TSourceLoc& loc, int profileMask, cons
//
// Map from stage enum to externally readable text name.
//
-const char* StageName(EShLanguage stage)
+const char* StageName(EShLanguage stage)
{
switch(stage) {
case EShLangVertex: return "vertex";
@@ -383,7 +387,7 @@ const char* StageName(EShLanguage stage)
// Operation: Will issue warnings/errors based on the current profile, version, and extension
// behaviors. It only checks extensions when the current profile is one of the profileMask.
//
-// A minVersion of 0 means no version of the profileMask support this in core,
+// A minVersion of 0 means no version of the profileMask support this in core,
// the extension must be present.
//
@@ -421,7 +425,7 @@ void TParseVersions::profileRequires(const TSourceLoc& loc, int profileMask, int
//
// When to use requireStage()
//
-// If only some stages support a feature.
+// If only some stages support a feature.
//
// Operation: If the current stage is not present, give an error message.
//
@@ -663,7 +667,7 @@ void TParseVersions::updateExtensionBehavior(const char* extension, TExtensionBe
// Call for any operation needing full GLSL integer data-type support.
void TParseVersions::fullIntegerCheck(const TSourceLoc& loc, const char* op)
{
- profileRequires(loc, ENoProfile, 130, nullptr, op);
+ profileRequires(loc, ENoProfile, 130, nullptr, op);
profileRequires(loc, EEsProfile, 300, nullptr, op);
}
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Versions.h b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Versions.h
index fe9764ffee2..cf8f5e23dd3 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Versions.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/Versions.h
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2012-2013 LunarG, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2012-2013 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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.
//
#ifndef _VERSIONS_INCLUDED_
#define _VERSIONS_INCLUDED_
@@ -127,7 +127,7 @@ const char* const E_GL_ARB_gpu_shader_int64 = "GL_ARB_gpu_shader_int
const char* const E_GL_ARB_shader_ballot = "GL_ARB_shader_ballot";
const char* const E_GL_ARB_sparse_texture2 = "GL_ARB_sparse_texture2";
const char* const E_GL_ARB_sparse_texture_clamp = "GL_ARB_sparse_texture_clamp";
-//const char* const E_GL_ARB_cull_distance = "GL_ARB_cull_distance"; // present for 4.5, but need extension control over block members
+// const char* const E_GL_ARB_cull_distance = "GL_ARB_cull_distance"; // present for 4.5, but need extension control over block members
const char* const E_GL_EXT_shader_non_constant_global_initializers = "GL_EXT_shader_non_constant_global_initializers";
@@ -143,8 +143,17 @@ const char* const E_GL_AMD_gcn_shader = "GL_AMD_gcn_sh
const char* const E_GL_AMD_gpu_shader_half_float = "GL_AMD_gpu_shader_half_float";
#endif
#ifdef NV_EXTENSIONS
-const char* const E_GL_NV_sample_mask_override_coverage = "GL_NV_sample_mask_override_coverage";
-const char* const E_SPV_NV_geometry_shader_passthrough = "GL_NV_geometry_shader_passthrough";
+
+const char* const E_GL_NV_sample_mask_override_coverage = "GL_NV_sample_mask_override_coverage";
+const char* const E_SPV_NV_geometry_shader_passthrough = "GL_NV_geometry_shader_passthrough";
+const char* const E_GL_ARB_shader_viewport_layer_array = "GL_ARB_shader_viewport_layer_array";
+const char* const E_GL_NV_viewport_array2 = "GL_NV_viewport_array2";
+const char* const E_GL_NV_stereo_view_rendering = "GL_NV_stereo_view_rendering";
+
+// Arrays of extensions for the above viewportEXTs duplications
+
+const char* const viewportEXTs[] = { E_GL_ARB_shader_viewport_layer_array, E_GL_NV_viewport_array2 };
+const int Num_viewportEXTs = sizeof(viewportEXTs) / sizeof(viewportEXTs[0]);
#endif
// AEP
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/glslang.y b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/glslang.y
index 060ffdd6fa9..f2512b82801 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/glslang.y
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/glslang.y
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2012-2013 LunarG, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2012-2013 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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.
//
/**
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/intermOut.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/intermOut.cpp
index f8c963b72e7..b8a6969d1b6 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/intermOut.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/intermOut.cpp
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2012-2016 LunarG, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2012-2016 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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 "localintermediate.h"
@@ -146,6 +146,7 @@ bool TOutputTraverser::visitBinary(TVisit /* visit */, TIntermBinary* node)
out.debug << (*node->getLeft()->getType().getStruct())[node->getRight()->getAsConstantUnion()->getConstArray()[0].getIConst()].type->getFieldName();
out.debug << ": direct index for structure"; break;
case EOpVectorSwizzle: out.debug << "vector swizzle"; break;
+ case EOpMatrixSwizzle: out.debug << "matrix swizzle"; break;
case EOpAdd: out.debug << "add"; break;
case EOpSub: out.debug << "subtract"; break;
@@ -376,6 +377,21 @@ bool TOutputTraverser::visitUnary(TVisit /* visit */, TIntermUnary* node)
case EOpMinInvocationsNonUniform: out.debug << "minInvocationsNonUniform"; break;
case EOpMaxInvocationsNonUniform: out.debug << "maxInvocationsNonUniform"; break;
case EOpAddInvocationsNonUniform: out.debug << "addInvocationsNonUniform"; break;
+
+ case EOpMinInvocationsInclusiveScan: out.debug << "minInvocationsInclusiveScan"; break;
+ case EOpMaxInvocationsInclusiveScan: out.debug << "maxInvocationsInclusiveScan"; break;
+ case EOpAddInvocationsInclusiveScan: out.debug << "addInvocationsInclusiveScan"; break;
+ case EOpMinInvocationsInclusiveScanNonUniform: out.debug << "minInvocationsInclusiveScanNonUniform"; break;
+ case EOpMaxInvocationsInclusiveScanNonUniform: out.debug << "maxInvocationsInclusiveScanNonUniform"; break;
+ case EOpAddInvocationsInclusiveScanNonUniform: out.debug << "addInvocationsInclusiveScanNonUniform"; break;
+
+ case EOpMinInvocationsExclusiveScan: out.debug << "minInvocationsExclusiveScan"; break;
+ case EOpMaxInvocationsExclusiveScan: out.debug << "maxInvocationsExclusiveScan"; break;
+ case EOpAddInvocationsExclusiveScan: out.debug << "addInvocationsExclusiveScan"; break;
+ case EOpMinInvocationsExclusiveScanNonUniform: out.debug << "minInvocationsExclusiveScanNonUniform"; break;
+ case EOpMaxInvocationsExclusiveScanNonUniform: out.debug << "maxInvocationsExclusiveScanNonUniform"; break;
+ case EOpAddInvocationsExclusiveScanNonUniform: out.debug << "addInvocationsExclusiveScanNonUniform"; break;
+
case EOpMbcnt: out.debug << "mbcnt"; break;
case EOpCubeFaceIndex: out.debug << "cubeFaceIndex"; break;
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/iomapper.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/iomapper.cpp
index 269d6549545..04868f16aa5 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/iomapper.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/iomapper.cpp
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2016 LunarG, Inc.
+// Copyright (C) 2016 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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 "../Include/Common.h"
@@ -168,8 +168,8 @@ public:
struct TResolverAdaptor
{
TResolverAdaptor(EShLanguage s, TIoMapResolver& r, TInfoSink& i, bool& e)
- : resolver(r)
- , stage(s)
+ : stage(s)
+ , resolver(r)
, infoSink(i)
, error(e)
{
@@ -209,6 +209,9 @@ struct TResolverAdaptor
TIoMapResolver& resolver;
TInfoSink& infoSink;
bool& error;
+
+private:
+ TResolverAdaptor& operator=(TResolverAdaptor&);
};
/*
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/iomapper.h b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/iomapper.h
index ff47543d2c5..5e0d4391cc5 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/iomapper.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/iomapper.h
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2016 LunarG, Inc.
+// Copyright (C) 2016 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
#ifndef _IOMAPPER_INCLUDED
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/limits.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/limits.cpp
index 49da930110d..64d191b4720 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/limits.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/limits.cpp
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2013 LunarG, Inc.
+// Copyright (C) 2013 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
//
@@ -83,7 +83,7 @@ protected:
// check binary operations for those modifying the loop index
bool TInductiveTraverser::visitBinary(TVisit /* visit */, TIntermBinary* node)
{
- if (node->modifiesState() && node->getLeft()->getAsSymbolNode() &&
+ if (node->modifiesState() && node->getLeft()->getAsSymbolNode() &&
node->getLeft()->getAsSymbolNode()->getId() == loopId) {
bad = true;
badLoc = node->getLoc();
@@ -95,7 +95,7 @@ bool TInductiveTraverser::visitBinary(TVisit /* visit */, TIntermBinary* node)
// check unary operations for those modifying the loop index
bool TInductiveTraverser::visitUnary(TVisit /* visit */, TIntermUnary* node)
{
- if (node->modifiesState() && node->getOperand()->getAsSymbolNode() &&
+ if (node->modifiesState() && node->getOperand()->getAsSymbolNode() &&
node->getOperand()->getAsSymbolNode()->getId() == loopId) {
bad = true;
badLoc = node->getLoc();
@@ -145,7 +145,7 @@ void TParseContext::inductiveLoopBodyCheck(TIntermNode* body, int loopId, TSymbo
//
// The "constant-index-expression" tranverser.
//
-// Just look at things that can form an index.
+// Just look at things that can form an index.
//
class TIndexTraverser : public TIntermTraverser {
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/linkValidate.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/linkValidate.cpp
index b8ce6d7e8b1..761cb4164b3 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/linkValidate.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/linkValidate.cpp
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2013 LunarG, Inc.
+// Copyright (C) 2013 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
//
@@ -48,7 +48,7 @@
#include "../Include/InfoSink.h"
namespace glslang {
-
+
//
// Link-time error emitter.
//
@@ -67,8 +67,8 @@ void TIntermediate::warn(TInfoSink& infoSink, const char* message)
infoSink.info << "Linking " << StageName(language) << " stage: " << message << "\n";
}
-// TODO: 4.4 offset/align: "Two blocks linked together in the same program with the same block
-// name must have the exact same set of members qualified with offset and their integral-constant
+// TODO: 4.4 offset/align: "Two blocks linked together in the same program with the same block
+// name must have the exact same set of members qualified with offset and their integral-constant
// expression values must be the same, or a link-time error results."
//
@@ -112,12 +112,12 @@ void TIntermediate::merge(TInfoSink& infoSink, TIntermediate& unit)
inputPrimitive = unit.inputPrimitive;
else if (inputPrimitive != unit.inputPrimitive)
error(infoSink, "Contradictory input layout primitives");
-
+
if (outputPrimitive == ElgNone)
outputPrimitive = unit.outputPrimitive;
else if (outputPrimitive != unit.outputPrimitive)
error(infoSink, "Contradictory output layout primitives");
-
+
if (vertices == TQualifier::layoutNotSet)
vertices = unit.vertices;
else if (vertices != unit.vertices) {
@@ -178,7 +178,7 @@ void TIntermediate::merge(TInfoSink& infoSink, TIntermediate& unit)
}
// Getting this far means we have two existing trees to merge...
-
+
version = std::max(version, unit.version);
requestedExtensions.insert(unit.requestedExtensions.begin(), unit.requestedExtensions.end());
@@ -341,9 +341,9 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy
writeTypeComparison = true;
}
- // Layouts...
- // TODO: 4.4 enhanced layouts: Generalize to include offset/align: current spec
- // requires separate user-supplied offset from actual computed offset, but
+ // Layouts...
+ // TODO: 4.4 enhanced layouts: Generalize to include offset/align: current spec
+ // requires separate user-supplied offset from actual computed offset, but
// current implementation only has one offset.
if (symbol.getQualifier().layoutMatrix != unitSymbol.getQualifier().layoutMatrix ||
symbol.getQualifier().layoutPacking != unitSymbol.getQualifier().layoutPacking ||
@@ -417,7 +417,7 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
if (xfbBuffers[b].containsDouble)
RoundToPow2(xfbBuffers[b].implicitStride, 8);
- // "It is a compile-time or link-time error to have
+ // "It is a compile-time or link-time error to have
// any xfb_offset that overflows xfb_stride, whether stated on declarations before or after the xfb_stride, or
// in different compilation units. While xfb_stride can be declared multiple times for the same buffer, it is a
// compile-time or link-time error to have different values specified for the stride for the same buffer."
@@ -429,8 +429,8 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
if (xfbBuffers[b].stride == TQualifier::layoutXfbStrideEnd)
xfbBuffers[b].stride = xfbBuffers[b].implicitStride;
- // "If the buffer is capturing any
- // outputs with double-precision components, the stride must be a multiple of 8, otherwise it must be a
+ // "If the buffer is capturing any
+ // outputs with double-precision components, the stride must be a multiple of 8, otherwise it must be a
// multiple of 4, or a compile-time or link-time error results."
if (xfbBuffers[b].containsDouble && ! IsMultipleOfPow2(xfbBuffers[b].stride, 8)) {
error(infoSink, "xfb_stride must be multiple of 8 for buffer holding a double:");
@@ -442,7 +442,7 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
infoSink.info << " xfb_buffer " << (unsigned int)b << ", xfb_stride " << xfbBuffers[b].stride << "\n";
}
- // "The resulting stride (implicit or explicit), when divided by 4, must be less than or equal to the
+ // "The resulting stride (implicit or explicit), when divided by 4, must be less than or equal to the
// implementation-dependent constant gl_MaxTransformFeedbackInterleavedComponents."
if (xfbBuffers[b].stride > (unsigned int)(4 * resources.maxTransformFeedbackInterleavedComponents)) {
error(infoSink, "xfb_stride is too large:");
@@ -540,7 +540,7 @@ void TIntermediate::checkCallGraphCycles(TInfoSink& infoSink)
break;
// Otherwise, we found a new subgraph, process it:
- // See what all can be reached by this new root, and if any of
+ // See what all can be reached by this new root, and if any of
// that is recursive. This is done by depth-first traversals, seeing
// if a new call is found that was already in the currentPath (a back edge),
// thereby detecting recursion.
@@ -709,7 +709,7 @@ TIntermSequence& TIntermediate::findLinkerObjects() const
}
// See if a variable was both a user-declared output and used.
-// Note: the spec discusses writing to one, but this looks at read or write, which
+// Note: the spec discusses writing to one, but this looks at read or write, which
// is more useful, and perhaps the spec should be changed to reflect that.
bool TIntermediate::userOutputUsed() const
{
@@ -720,7 +720,7 @@ bool TIntermediate::userOutputUsed() const
const TIntermSymbol& symbolNode = *linkerObjects[i]->getAsSymbolNode();
if (symbolNode.getQualifier().storage == EvqVaryingOut &&
symbolNode.getName().compare(0, 3, "gl_") != 0 &&
- inIoAccessed(symbolNode.getName())) {
+ inIoAccessed(symbolNode.getName())) {
found = true;
break;
}
@@ -899,7 +899,7 @@ bool TIntermediate::addUsedConstantId(int id)
// Return the size of type, as measured by "locations".
int TIntermediate::computeTypeLocationSize(const TType& type) const
{
- // "If the declared input is an array of size n and each element takes m locations, it will be assigned m * n
+ // "If the declared input is an array of size n and each element takes m locations, it will be assigned m * n
// consecutive locations..."
if (type.isArray()) {
// TODO: perf: this can be flattened by using getCumulativeArraySize(), and a deref that discards all arrayness
@@ -911,8 +911,8 @@ int TIntermediate::computeTypeLocationSize(const TType& type) const
return type.getOuterArraySize() * computeTypeLocationSize(elementType);
}
- // "The locations consumed by block and structure members are determined by applying the rules above
- // recursively..."
+ // "The locations consumed by block and structure members are determined by applying the rules above
+ // recursively..."
if (type.isStruct()) {
int size = 0;
for (int member = 0; member < (int)type.getStruct()->size(); ++member) {
@@ -924,9 +924,9 @@ int TIntermediate::computeTypeLocationSize(const TType& type) const
// ES: "If a shader input is any scalar or vector type, it will consume a single location."
- // Desktop: "If a vertex shader input is any scalar or vector type, it will consume a single location. If a non-vertex
- // shader input is a scalar or vector type other than dvec3 or dvec4, it will consume a single location, while
- // types dvec3 or dvec4 will consume two consecutive locations. Inputs of type double and dvec2 will
+ // Desktop: "If a vertex shader input is any scalar or vector type, it will consume a single location. If a non-vertex
+ // shader input is a scalar or vector type other than dvec3 or dvec4, it will consume a single location, while
+ // types dvec3 or dvec4 will consume two consecutive locations. Inputs of type double and dvec2 will
// consume only a single location, in all stages."
if (type.isScalar())
return 1;
@@ -940,7 +940,7 @@ int TIntermediate::computeTypeLocationSize(const TType& type) const
}
// "If the declared input is an n x m single- or double-precision matrix, ...
- // The number of locations assigned for each matrix will be the same as
+ // The number of locations assigned for each matrix will be the same as
// for an n-element array of m-component vectors..."
if (type.isMatrix()) {
TType columnType(type, 0);
@@ -986,14 +986,14 @@ int TIntermediate::addXfbBufferOffset(const TType& type)
// N.B. Caller must set containsDouble to false before calling.
unsigned int TIntermediate::computeTypeXfbSize(const TType& type, bool& containsDouble) const
{
- // "...if applied to an aggregate containing a double, the offset must also be a multiple of 8,
+ // "...if applied to an aggregate containing a double, the offset must also be a multiple of 8,
// and the space taken in the buffer will be a multiple of 8.
- // ...within the qualified entity, subsequent components are each
+ // ...within the qualified entity, subsequent components are each
// assigned, in order, to the next available offset aligned to a multiple of
// that component's size. Aggregate types are flattened down to the component
// level to get this sequence of components."
- if (type.isArray()) {
+ if (type.isArray()) {
// TODO: perf: this can be flattened by using getCumulativeArraySize(), and a deref that discards all arrayness
assert(type.isExplicitlySizedArray());
TType elementType(type, 0);
@@ -1005,8 +1005,8 @@ unsigned int TIntermediate::computeTypeXfbSize(const TType& type, bool& contains
bool structContainsDouble = false;
for (int member = 0; member < (int)type.getStruct()->size(); ++member) {
TType memberType(type, member);
- // "... if applied to
- // an aggregate containing a double, the offset must also be a multiple of 8,
+ // "... if applied to
+ // an aggregate containing a double, the offset must also be a multiple of 8,
// and the space taken in the buffer will be a multiple of 8."
bool memberContainsDouble = false;
int memberSize = computeTypeXfbSize(memberType, memberContainsDouble);
@@ -1064,7 +1064,7 @@ int TIntermediate::getBaseAlignmentScalar(const TType& type, int& size)
// Implement base-alignment and size rules from section 7.6.2.2 Standard Uniform Block Layout
// Operates recursively.
//
-// If std140 is true, it does the rounding up to vec4 size required by std140,
+// If std140 is true, it does the rounding up to vec4 size required by std140,
// otherwise it does not, yielding std430 rules.
//
// The size is returned in the 'size' parameter
@@ -1093,7 +1093,7 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, int& stride, b
//
// 1. If the member is a scalar consuming N basic machine units, the base alignment is N.
//
- // 2. If the member is a two- or four-component vector with components consuming N basic
+ // 2. If the member is a two- or four-component vector with components consuming N basic
// machine units, the base alignment is 2N or 4N, respectively.
//
// 3. If the member is a three-component vector with components consuming N
@@ -1106,7 +1106,7 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, int& stride, b
// the array is rounded up to the next multiple of the base alignment.
//
// 5. If the member is a column-major matrix with C columns and R rows, the
- // matrix is stored identically to an array of C column vectors with R
+ // matrix is stored identically to an array of C column vectors with R
// components each, according to rule (4).
//
// 6. If the member is an array of S column-major matrices with C columns and
@@ -1123,7 +1123,7 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, int& stride, b
//
// 9. If the member is a structure, the base alignment of the structure is N , where
// N is the largest base alignment value of any of its members, and rounded
- // up to the base alignment of a vec4. The individual members of this substructure
+ // up to the base alignment of a vec4. The individual members of this substructure
// are then assigned offsets by applying this set of rules recursively,
// where the base offset of the first member of the sub-structure is equal to the
// aligned offset of the structure. The structure may have padding at the end;
@@ -1165,7 +1165,7 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, int& stride, b
int memberAlignment = getBaseAlignment(*memberList[m].type, memberSize, dummyStride, std140,
(subMatrixLayout != ElmNone) ? (subMatrixLayout == ElmRowMajor) : rowMajor);
maxAlignment = std::max(maxAlignment, memberAlignment);
- RoundToPow2(size, memberAlignment);
+ RoundToPow2(size, memberAlignment);
size += memberSize;
}
@@ -1188,7 +1188,7 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, int& stride, b
case 2:
size *= 2;
return 2 * scalarAlign;
- default:
+ default:
size *= type.getVectorSize();
return 4 * scalarAlign;
}
@@ -1198,7 +1198,7 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, int& stride, b
if (type.isMatrix()) {
// rule 5: deref to row, not to column, meaning the size of vector is num columns instead of num rows
TType derefType(type, 0, rowMajor);
-
+
alignment = getBaseAlignment(derefType, size, dummyStride, std140, rowMajor);
if (std140)
alignment = std::max(baseAlignmentVec4Std140, alignment);
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/localintermediate.h b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/localintermediate.h
index 34875c2be38..29efb54c9bc 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/localintermediate.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/localintermediate.h
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2016 LunarG, Inc.
-//All rights reserved.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// 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:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
#ifndef _LOCAL_INTERMEDIATE_INCLUDED_
@@ -47,19 +47,40 @@ class TInfoSink;
namespace glslang {
-struct TVectorFields {
- TVectorFields() { }
+struct TMatrixSelector {
+ int coord1; // stay agnostic about column/row; this is parse order
+ int coord2;
+};
+
+typedef int TVectorSelector;
+
+const int MaxSwizzleSelectors = 4;
+
+template<typename selectorType>
+class TSwizzleSelectors {
+public:
+ TSwizzleSelectors() : size_(0) { }
- TVectorFields(int c0, int c1, int c2, int c3) : num(4)
+ void push_back(selectorType comp)
{
- offsets[0] = c0;
- offsets[1] = c1;
- offsets[2] = c2;
- offsets[3] = c3;
+ if (size_ < MaxSwizzleSelectors)
+ components[size_++] = comp;
}
-
- int offsets[4];
- int num;
+ void resize(int s)
+ {
+ assert(s <= size_);
+ size_ = s;
+ }
+ int size() const { return size_; }
+ selectorType operator[](int i) const
+ {
+ assert(i < MaxSwizzleSelectors);
+ return components[i];
+ }
+
+private:
+ int size_;
+ selectorType components[MaxSwizzleSelectors];
};
//
@@ -83,7 +104,7 @@ struct TCall {
// A generic 1-D range.
struct TRange {
TRange(int start, int last) : start(start), last(last) { }
- bool overlap(const TRange& rhs) const
+ bool overlap(const TRange& rhs) const
{
return last >= rhs.start && start <= rhs.last;
}
@@ -139,22 +160,22 @@ class TVariable;
class TIntermediate {
public:
explicit TIntermediate(EShLanguage l, int v = 0, EProfile p = ENoProfile) :
- source(EShSourceNone), language(l), profile(p), version(v), treeRoot(0),
+ language(l), source(EShSourceNone), profile(p), version(v), treeRoot(0),
numEntryPoints(0), numErrors(0), numPushConstants(0), recursive(false),
invocations(TQualifier::layoutNotSet), vertices(TQualifier::layoutNotSet), inputPrimitive(ElgNone), outputPrimitive(ElgNone),
pixelCenterInteger(false), originUpperLeft(false),
vertexSpacing(EvsNone), vertexOrder(EvoNone), pointMode(false), earlyFragmentTests(false), depthLayout(EldNone), depthReplacing(false), blendEquations(0),
- multiStream(false), xfbMode(false),
+ xfbMode(false), multiStream(false),
+#ifdef NV_EXTENSIONS
+ layoutOverrideCoverage(false),
+ geoPassthroughEXT(false),
+#endif
shiftSamplerBinding(0),
shiftTextureBinding(0),
shiftImageBinding(0),
shiftUboBinding(0),
autoMapBindings(false),
flattenUniformArrays(false),
-#ifdef NV_EXTENSIONS
- layoutOverrideCoverage(false),
- geoPassthroughEXT(false),
-#endif
useUnknownFormat(false)
{
localSize[0] = 1;
@@ -192,7 +213,7 @@ public:
bool getFlattenUniformArrays() const { return flattenUniformArrays; }
void setNoStorageFormat(bool b) { useUnknownFormat = b; }
bool getNoStorageFormat() const { return useUnknownFormat; }
-
+
void setVersion(int v) { version = v; }
int getVersion() const { return version; }
void setProfile(EProfile p) { profile = p; }
@@ -231,7 +252,7 @@ public:
TIntermAggregate* makeAggregate(const TSourceLoc&);
TIntermTyped* setAggregateOperator(TIntermNode*, TOperator, const TType& type, TSourceLoc);
bool areAllChildConst(TIntermAggregate* aggrNode);
- TIntermNode* addSelection(TIntermTyped* cond, TIntermNodePair code, const TSourceLoc&);
+ TIntermTyped* addSelection(TIntermTyped* cond, TIntermNodePair code, const TSourceLoc&);
TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, const TSourceLoc&);
TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, const TSourceLoc&);
TIntermTyped* addMethod(TIntermTyped*, const TType&, const TString*, const TSourceLoc&);
@@ -248,7 +269,7 @@ public:
TIntermAggregate* addForLoop(TIntermNode*, TIntermNode*, TIntermTyped*, TIntermTyped*, bool testFirst, const TSourceLoc&);
TIntermBranch* addBranch(TOperator, const TSourceLoc&);
TIntermBranch* addBranch(TOperator, TIntermTyped*, const TSourceLoc&);
- TIntermTyped* addSwizzle(TVectorFields&, const TSourceLoc&);
+ template<typename selectorType> TIntermTyped* addSwizzle(TSwizzleSelectors<selectorType>&, const TSourceLoc&);
// Low level functions to add nodes (no conversions or other higher level transformations)
// If a type is provided, the node's type will be set to it.
@@ -264,7 +285,7 @@ public:
TIntermTyped* fold(TIntermAggregate* aggrNode);
TIntermTyped* foldConstructor(TIntermAggregate* aggrNode);
TIntermTyped* foldDereference(TIntermTyped* node, int index, const TSourceLoc&);
- TIntermTyped* foldSwizzle(TIntermTyped* node, TVectorFields& fields, const TSourceLoc&);
+ TIntermTyped* foldSwizzle(TIntermTyped* node, TSwizzleSelectors<TVectorSelector>& fields, const TSourceLoc&);
// Tree ops
static const TIntermTyped* findLValueBase(const TIntermTyped*, bool swizzleOkay);
@@ -273,7 +294,7 @@ public:
void addSymbolLinkageNodes(TIntermAggregate*& linkage, EShLanguage, TSymbolTable&);
void addSymbolLinkageNode(TIntermAggregate*& linkage, const TSymbol&);
- bool setInvocations(int i)
+ bool setInvocations(int i)
{
if (invocations != TQualifier::layoutNotSet)
return invocations == i;
@@ -315,7 +336,7 @@ public:
TVertexOrder getVertexOrder() const { return vertexOrder; }
void setPointMode() { pointMode = true; }
bool getPointMode() const { return pointMode; }
-
+
bool setLocalSize(int dim, int size)
{
if (localSize[dim] > 1)
@@ -391,7 +412,7 @@ public:
static int getBaseAlignment(const TType&, int& size, int& stride, bool std140, bool rowMajor);
bool promote(TIntermOperator*);
-#ifdef NV_EXTENSIONS
+#ifdef NV_EXTENSIONS
void setLayoutOverrideCoverage() { layoutOverrideCoverage = true; }
bool getLayoutOverrideCoverage() const { return layoutOverrideCoverage; }
void setGeoPassthroughEXT() { geoPassthroughEXT = true; }
@@ -417,18 +438,13 @@ protected:
bool promoteBinary(TIntermBinary&);
void addSymbolLinkageNode(TIntermAggregate*& linkage, TSymbolTable&, const TString&);
bool promoteAggregate(TIntermAggregate&);
-
+ void pushSelector(TIntermSequence&, const TVectorSelector&, const TSourceLoc&);
+ void pushSelector(TIntermSequence&, const TMatrixSelector&, const TSourceLoc&);
+
const EShLanguage language; // stage, known at construction time
EShSource source; // source language, known a bit later
std::string entryPointName;
std::string entryPointMangledName;
- unsigned int shiftSamplerBinding;
- unsigned int shiftTextureBinding;
- unsigned int shiftImageBinding;
- unsigned int shiftUboBinding;
- bool autoMapBindings;
- bool flattenUniformArrays;
- bool useUnknownFormat;
EProfile profile;
int version;
@@ -458,11 +474,19 @@ protected:
bool xfbMode;
bool multiStream;
-#ifdef NV_EXTENSIONS
+#ifdef NV_EXTENSIONS
bool layoutOverrideCoverage;
bool geoPassthroughEXT;
#endif
+ unsigned int shiftSamplerBinding;
+ unsigned int shiftTextureBinding;
+ unsigned int shiftImageBinding;
+ unsigned int shiftUboBinding;
+ bool autoMapBindings;
+ bool flattenUniformArrays;
+ bool useUnknownFormat;
+
typedef std::list<TCall> TGraph;
TGraph callGraph;
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/parseConst.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/parseConst.cpp
index 90621d39f47..22b55516aaa 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/parseConst.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/parseConst.cpp
@@ -1,10 +1,10 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -18,22 +18,22 @@
// 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.
+// 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.
//
//
-// Travarse a tree of constants to create a single folded constant.
+// Traverse a tree of constants to create a single folded constant.
// It should only be used when the whole tree is known to be constant.
//
@@ -45,7 +45,7 @@ class TConstTraverser : public TIntermTraverser {
public:
TConstTraverser(const TConstUnionArray& cUnion, bool singleConstParam, TOperator constructType, const TType& t)
: unionArray(cUnion), type(t),
- constructorType(constructType), singleConstantParam(singleConstParam), error(false), isMatrix(false),
+ constructorType(constructType), singleConstantParam(singleConstParam), error(false), isMatrix(false),
matrixCols(0), matrixRows(0) { index = 0; tOp = EOpNull; }
virtual void visitConstantUnion(TIntermConstantUnion* node);
@@ -73,7 +73,7 @@ bool TConstTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node)
if (! node->isConstructor() && node->getOp() != EOpComma) {
error = true;
- return false;
+ return false;
}
if (node->getSequence().size() == 0) {
@@ -84,7 +84,7 @@ bool TConstTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node)
bool flag = node->getSequence().size() == 1 && node->getSequence()[0]->getAsTyped()->getAsConstantUnion();
if (flag) {
- singleConstantParam = true;
+ singleConstantParam = true;
constructorType = node->getOp();
size = node->getType().computeNumComponents();
@@ -93,19 +93,19 @@ bool TConstTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node)
matrixCols = node->getType().getMatrixCols();
matrixRows = node->getType().getMatrixRows();
}
- }
+ }
- for (TIntermSequence::iterator p = node->getSequence().begin();
+ for (TIntermSequence::iterator p = node->getSequence().begin();
p != node->getSequence().end(); p++) {
if (node->getOp() == EOpComma)
- index = 0;
+ index = 0;
(*p)->traverse(this);
- }
- if (flag)
+ }
+ if (flag)
{
- singleConstantParam = false;
+ singleConstantParam = false;
constructorType = EOpNull;
size = 0;
isMatrix = false;
@@ -126,7 +126,7 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node)
if (! singleConstantParam) {
int rightUnionSize = node->getType().computeNumComponents();
-
+
const TConstUnionArray& rightUnionArray = node->getConstArray();
for (int i = 0; i < rightUnionSize; i++) {
if (index >= instanceSize)
@@ -148,7 +148,7 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node)
leftUnionArray[i] = rightUnionArray[count];
(index)++;
-
+
if (nodeComps > 1)
count++;
}
@@ -180,13 +180,13 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node)
return;
if (i == startIndex || (i - startIndex) % (matrixRows + 1) == 0 )
leftUnionArray[i] = rightUnionArray[count];
- else
+ else
leftUnionArray[i].setDConst(0.0);
index++;
if (nodeComps > 1)
- count++;
+ count++;
}
}
}
@@ -199,7 +199,7 @@ bool TIntermediate::parseConstTree(TIntermNode* root, TConstUnionArray unionArra
return false;
TConstTraverser it(unionArray, singleConstantParam, constructorType, t);
-
+
root->traverse(&it);
if (it.error)
return true;
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/parseVersions.h b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/parseVersions.h
index acb57507a46..0c85f8a19a7 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/parseVersions.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/parseVersions.h
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2016 Google, Inc.
+// Copyright (C) 2016 Google, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
// This is implemented in Versions.cpp
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/Pp.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/Pp.cpp
index 595b7295d5a..abce3b5648d 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/Pp.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/Pp.cpp
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2013 LunarG, Inc.
-//All rights reserved.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2013 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:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
/****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation.
@@ -57,7 +57,7 @@ Except as expressly stated in this notice, no other rights or licenses
express or implied, are granted by NVIDIA herein, including but not
limited to any patent rights that may be infringed by your derivative
works or by other works in which the NVIDIA Software may be
-incorporated. No hardware is licensed hereunder.
+incorporated. No hardware is licensed hereunder.
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
@@ -113,7 +113,7 @@ int TPpContext::CPPdefine(TPpToken* ppToken)
mac.emptyArgs = 1;
do {
token = scanToken(ppToken);
- if (mac.args.size() == 0 && token == ')')
+ if (mac.args.size() == 0 && token == ')')
break;
if (token != PpAtomIdentifier) {
parseContext.ppError(ppToken->loc, "bad argument", "#define", "");
@@ -177,7 +177,7 @@ int TPpContext::CPPdefine(TPpToken* ppToken)
newToken = ReadToken(mac.body, &newPpToken);
if (oldToken != newToken || oldPpToken != newPpToken) {
parseContext.ppError(defineLoc, "Macro redefined; different substitutions:", "#define", atomStrings.getString(defAtom));
- break;
+ break;
}
} while (newToken > 0);
}
@@ -238,8 +238,8 @@ int TPpContext::CPPelse(int matchelse, TPpToken* ppToken)
int nextAtom = atomStrings.getAtom(ppToken->name);
if (nextAtom == PpAtomIf || nextAtom == PpAtomIfdef || nextAtom == PpAtomIfndef) {
- depth++;
- ifdepth++;
+ depth++;
+ ifdepth++;
elsetracker++;
} else if (nextAtom == PpAtomEndif) {
token = extraTokenCheck(nextAtom, ppToken, scanToken(ppToken));
@@ -247,7 +247,7 @@ int TPpContext::CPPelse(int matchelse, TPpToken* ppToken)
--elsetracker;
if (depth == 0) {
// found the #endif we are looking for
- if (ifdepth)
+ if (ifdepth)
--ifdepth;
break;
}
@@ -461,7 +461,7 @@ int TPpContext::eval(int token, int precedence, bool shortCircuit, int& res, boo
// Perform evaluation of binary operation, if there is one, otherwise we are done.
while (! err) {
- if (token == ')' || token == '\n')
+ if (token == ')' || token == '\n')
break;
int op;
for (op = NUM_ELEMENTS(binop) - 1; op >= 0; op--) {
@@ -523,7 +523,7 @@ int TPpContext::evalToToken(int token, bool shortCircuit, int& res, bool& err, T
}
// Handle #if
-int TPpContext::CPPif(TPpToken* ppToken)
+int TPpContext::CPPif(TPpToken* ppToken)
{
int token = scanToken(ppToken);
elsetracker++;
@@ -554,7 +554,7 @@ int TPpContext::CPPifdef(int defined, TPpToken* ppToken)
if (token != PpAtomIdentifier) {
if (defined)
parseContext.ppError(ppToken->loc, "must be followed by macro name", "#ifdef", "");
- else
+ else
parseContext.ppError(ppToken->loc, "must be followed by macro name", "#ifndef", "");
} else {
MacroSymbol* macro = lookupMacroDef(atomStrings.getAtom(ppToken->name));
@@ -571,51 +571,82 @@ int TPpContext::CPPifdef(int defined, TPpToken* ppToken)
return token;
}
-// Handle #include
+// Handle #include ...
+// TODO: Handle macro expansions for the header name
int TPpContext::CPPinclude(TPpToken* ppToken)
{
const TSourceLoc directiveLoc = ppToken->loc;
+ bool startWithLocalSearch = true; // to additionally include the extra "" paths
int token = scanToken(ppToken);
+
+ // handle <header-name>-style #include
+ if (token == '<') {
+ startWithLocalSearch = false;
+ token = scanHeaderName(ppToken, '>');
+ }
+ // otherwise ppToken already has the header name and it was "header-name" style
+
if (token != PpAtomConstString) {
- // TODO: handle angle brackets.
- parseContext.ppError(directiveLoc, "must be followed by a file designation", "#include", "");
- } else {
- // Make a copy of the name because it will be overwritten by the next token scan.
- const std::string filename = ppToken->name;
- token = scanToken(ppToken);
- if (token != '\n' && token != EndOfInput) {
- parseContext.ppError(ppToken->loc, "extra content after file designation", "#include", "");
+ parseContext.ppError(directiveLoc, "must be followed by a header name", "#include", "");
+ return token;
+ }
+
+ // Make a copy of the name because it will be overwritten by the next token scan.
+ const std::string filename = ppToken->name;
+
+ // See if the directive was well formed
+ token = scanToken(ppToken);
+ if (token != '\n') {
+ if (token == EndOfInput)
+ parseContext.ppError(ppToken->loc, "expected newline after header name:", "#include", "%s", filename.c_str());
+ else
+ parseContext.ppError(ppToken->loc, "extra content after header name:", "#include", "%s", filename.c_str());
+ return token;
+ }
+
+ // Process well-formed directive
+
+ // Find the inclusion, first look in "Local" ("") paths, if requested,
+ // otherwise, only search the "System" (<>) paths.
+ TShader::Includer::IncludeResult* res = nullptr;
+ if (startWithLocalSearch)
+ res = includer.includeLocal(filename.c_str(), currentSourceFile.c_str(), includeStack.size() + 1);
+ if (! res || res->headerName.empty()) {
+ includer.releaseInclude(res);
+ res = includer.includeSystem(filename.c_str(), currentSourceFile.c_str(), includeStack.size() + 1);
+ }
+
+ // Process the results
+ if (res && !res->headerName.empty()) {
+ if (res->headerData && res->headerLength) {
+ // path for processing one or more tokens from an included header, hand off 'res'
+ const bool forNextLine = parseContext.lineDirectiveShouldSetNextLine();
+ std::ostringstream prologue;
+ std::ostringstream epilogue;
+ prologue << "#line " << forNextLine << " " << "\"" << res->headerName << "\"\n";
+ epilogue << (res->headerData[res->headerLength - 1] == '\n'? "" : "\n") <<
+ "#line " << directiveLoc.line + forNextLine << " " << directiveLoc.getStringNameOrNum() << "\n";
+ pushInput(new TokenizableIncludeFile(directiveLoc, prologue.str(), res, epilogue.str(), this));
+ // There's no "current" location anymore.
+ parseContext.setCurrentColumn(0);
} else {
- TShader::Includer::IncludeResult* res = includer.include(filename.c_str(), TShader::Includer::EIncludeRelative, currentSourceFile.c_str(), includeStack.size() + 1);
- if (res && !res->file_name.empty()) {
- if (res->file_data && res->file_length) {
- const bool forNextLine = parseContext.lineDirectiveShouldSetNextLine();
- std::ostringstream prologue;
- std::ostringstream epilogue;
- prologue << "#line " << forNextLine << " " << "\"" << res->file_name << "\"\n";
- epilogue << (res->file_data[res->file_length - 1] == '\n'? "" : "\n") << "#line " << directiveLoc.line + forNextLine << " " << directiveLoc.getStringNameOrNum() << "\n";
- pushInput(new TokenizableIncludeFile(directiveLoc, prologue.str(), res, epilogue.str(), this));
- }
- // At EOF, there's no "current" location anymore.
- if (token != EndOfInput) parseContext.setCurrentColumn(0);
- // Don't accidentally return EndOfInput, which will end all preprocessing.
- return '\n';
- } else {
- std::string message =
- res ? std::string(res->file_data, res->file_length)
- : std::string("Could not process include directive");
- parseContext.ppError(directiveLoc, message.c_str(), "#include", "");
- if (res) {
- includer.releaseInclude(res);
- }
- }
+ // things are okay, but there is nothing to process
+ includer.releaseInclude(res);
}
+ } else {
+ // error path, clean up
+ std::string message =
+ res ? std::string(res->headerData, res->headerLength)
+ : std::string("Could not process include directive");
+ parseContext.ppError(directiveLoc, message.c_str(), "#include", "for header name: %s", filename.c_str());
+ includer.releaseInclude(res);
}
+
return token;
}
// Handle #line
-int TPpContext::CPPline(TPpToken* ppToken)
+int TPpContext::CPPline(TPpToken* ppToken)
{
// "#line must have, after macro substitution, one of the following forms:
// "#line line
@@ -673,7 +704,7 @@ int TPpContext::CPPline(TPpToken* ppToken)
}
// Handle #error
-int TPpContext::CPPerror(TPpToken* ppToken)
+int TPpContext::CPPerror(TPpToken* ppToken)
{
int token = scanToken(ppToken);
std::string message;
@@ -696,7 +727,7 @@ int TPpContext::CPPerror(TPpToken* ppToken)
token = scanToken(ppToken);
}
parseContext.notifyErrorDirective(loc.line, message.c_str());
- //store this msg into the shader's information log..set the Compile Error flag!!!!
+ // store this msg into the shader's information log..set the Compile Error flag!!!!
parseContext.ppError(loc, message.c_str(), "#error", "");
return '\n';
@@ -850,7 +881,7 @@ int TPpContext::readCPPline(TPpToken* ppToken)
if (elseSeen[elsetracker])
parseContext.ppError(ppToken->loc, "#elif after #else", "#elif", "");
// this token is really a dont care, but we still need to eat the tokens
- token = scanToken(ppToken);
+ token = scanToken(ppToken);
while (token != '\n' && token != EndOfInput)
token = scanToken(ppToken);
token = CPPelse(0, ppToken);
@@ -911,6 +942,38 @@ int TPpContext::readCPPline(TPpToken* ppToken)
return token;
}
+// Context-dependent parsing of a #include <header-name>.
+// Assumes no macro expansions etc. are being done; the name is just on the current input.
+// Always creates a name and returns PpAtomicConstString, unless we run out of input.
+int TPpContext::scanHeaderName(TPpToken* ppToken, char delimit)
+{
+ bool tooLong = false;
+
+ if (inputStack.empty())
+ return EndOfInput;
+
+ int len = 0;
+ ppToken->name[0] = '\0';
+ do {
+ int ch = inputStack.back()->getch();
+
+ // done yet?
+ if (ch == delimit) {
+ ppToken->name[len] = '\0';
+ if (tooLong)
+ parseContext.ppError(ppToken->loc, "header name too long", "", "");
+ return PpAtomConstString;
+ } else if (ch == EndOfInput)
+ return EndOfInput;
+
+ // found a character to expand the name with
+ if (len < MaxTokenLength)
+ ppToken->name[len++] = (char)ch;
+ else
+ tooLong = true;
+ } while (true);
+}
+
// Macro-expand a macro argument 'arg' to create 'expandedArg'.
// Does not replace 'arg'.
// Returns nullptr if no expanded argument is created.
@@ -934,17 +997,25 @@ TPpContext::TokenStream* TPpContext::PrescanMacroArg(TokenStream& arg, TPpToken*
TokenStream* expandedArg = new TokenStream;
pushInput(new tMarkerInput(this));
pushTokenStreamInput(arg);
- while ((token = scanToken(ppToken)) != tMarkerInput::marker) {
+ while ((token = scanToken(ppToken)) != tMarkerInput::marker && token != EndOfInput) {
if (token == PpAtomIdentifier && MacroExpand(ppToken, false, newLineOkay) != 0)
continue;
RecordToken(*expandedArg, token, ppToken);
}
- popInput();
+
+ if (token == EndOfInput) {
+ // MacroExpand ate the marker, so had bad input, recover
+ delete expandedArg;
+ expandedArg = nullptr;
+ } else {
+ // remove the marker
+ popInput();
+ }
return expandedArg;
}
-//
+//
// Return the next token for a macro expansion, handling macro arguments,
// whose semantics are dependent on being adjacent to ##.
//
@@ -1053,7 +1124,7 @@ int TPpContext::tZeroInput::scan(TPpToken* ppToken)
// Check a token to see if it is a macro that should be expanded.
// If it is, and defined, push a tInput that will produce the appropriate expansion
// and return 1.
-// If it is, but undefined, and expandUndef is requested, push a tInput that will
+// If it is, but undefined, and expandUndef is requested, push a tInput that will
// expand to 0 and return -1.
// Otherwise, return 0 to indicate no expansion, which is not necessarily an error.
//
@@ -1133,7 +1204,7 @@ int TPpContext::MacroExpand(TPpToken* ppToken, bool expandUndef, bool newLineOka
depth = 0;
while (1) {
token = scanToken(ppToken);
- if (token == EndOfInput) {
+ if (token == EndOfInput || token == tMarkerInput::marker) {
parseContext.ppError(loc, "End of input in macro", "macro expansion", atomStrings.getString(macroAtom));
delete in;
return 0;
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpAtom.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpAtom.cpp
index 6948aada47e..c4904033af5 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpAtom.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpAtom.cpp
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2013 LunarG, Inc.
-//All rights reserved.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2013 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:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
/****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation.
@@ -57,7 +57,7 @@ Except as expressly stated in this notice, no other rights or licenses
express or implied, are granted by NVIDIA herein, including but not
limited to any patent rights that may be infringed by your derivative
works or by other works in which the NVIDIA Software may be
-incorporated. No hardware is licensed hereunder.
+incorporated. No hardware is licensed hereunder.
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpContext.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpContext.cpp
index e31127faae4..6a2e05fefa4 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpContext.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpContext.cpp
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2013 LunarG, Inc.
-//All rights reserved.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2013 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:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
/****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation.
@@ -57,7 +57,7 @@ Except as expressly stated in this notice, no other rights or licenses
express or implied, are granted by NVIDIA herein, including but not
limited to any patent rights that may be infringed by your derivative
works or by other works in which the NVIDIA Software may be
-incorporated. No hardware is licensed hereunder.
+incorporated. No hardware is licensed hereunder.
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
@@ -82,7 +82,7 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace glslang {
-TPpContext::TPpContext(TParseContextBase& pc, const std::string& rootFileName, TShader::Includer& inclr) :
+TPpContext::TPpContext(TParseContextBase& pc, const std::string& rootFileName, TShader::Includer& inclr) :
preamble(0), strings(0), previous_token('\n'), parseContext(pc), includer(inclr), inComment(false),
rootFileName(rootFileName),
currentSourceFile(rootFileName)
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpContext.h b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpContext.h
index 64f99efee45..15e54b79f0b 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpContext.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpContext.h
@@ -1,10 +1,10 @@
//
-//Copyright (C) 2013 LunarG, Inc.
-//All rights reserved.
+// Copyright (C) 2013 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:
+// 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.
@@ -18,18 +18,18 @@
// 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.
+// 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.
//
/****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation.
@@ -56,7 +56,7 @@ Except as expressly stated in this notice, no other rights or licenses
express or implied, are granted by NVIDIA herein, including but not
limited to any patent rights that may be infringed by your derivative
works or by other works in which the NVIDIA Software may be
-incorporated. No hardware is licensed hereunder.
+incorporated. No hardware is licensed hereunder.
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
@@ -94,7 +94,7 @@ class TPpToken {
public:
TPpToken() : space(false), ival(0), dval(0.0), i64val(0)
{
- loc.init();
+ loc.init();
name[0] = 0;
}
@@ -287,7 +287,7 @@ protected:
static const int maxIfNesting = 64;
- int ifdepth; // current #if-#else-#endif nesting in the cpp.c file (pre-processor)
+ int ifdepth; // current #if-#else-#endif nesting in the cpp.c file (pre-processor)
bool elseSeen[maxIfNesting]; // Keep a track of whether an else has been seen at a particular depth
int elsetracker; // #if-#else and #endif constructs...Counter.
@@ -359,15 +359,16 @@ protected:
int extraTokenCheck(int atom, TPpToken* ppToken, int token);
int eval(int token, int precedence, bool shortCircuit, int& res, bool& err, TPpToken * ppToken);
int evalToToken(int token, bool shortCircuit, int& res, bool& err, TPpToken * ppToken);
- int CPPif (TPpToken * ppToken);
+ int CPPif (TPpToken * ppToken);
int CPPifdef(int defined, TPpToken * ppToken);
int CPPinclude(TPpToken * ppToken);
- int CPPline(TPpToken * ppToken);
- int CPPerror(TPpToken * ppToken);
+ int CPPline(TPpToken * ppToken);
+ int CPPerror(TPpToken * ppToken);
int CPPpragma(TPpToken * ppToken);
int CPPversion(TPpToken * ppToken);
int CPPextension(TPpToken * ppToken);
int readCPPline(TPpToken * ppToken);
+ int scanHeaderName(TPpToken* ppToken, char delimit);
TokenStream* PrescanMacroArg(TokenStream&, TPpToken*, bool newLineOkay);
int MacroExpand(TPpToken* ppToken, bool expandUndef, bool newLineOkay);
@@ -382,7 +383,7 @@ protected:
int ReadToken(TokenStream&, TPpToken*);
void pushTokenStreamInput(TokenStream&, bool pasting = false);
void UngetToken(int token, TPpToken*);
-
+
class tTokenInput : public tInput {
public:
tTokenInput(TPpContext* pp, TokenStream* t, bool prepasting) : tInput(pp), tokens(t), lastTokenPastes(prepasting) { }
@@ -440,7 +441,7 @@ protected:
return '\\';
} while (ch == '\\');
}
-
+
// handle any non-escaped newline
if (ch == '\r' || ch == '\n') {
if (ch == '\r' && input->peek() == '\n')
@@ -485,7 +486,7 @@ protected:
TInputScanner* input;
};
- // Holds a reference to included file data, as well as a
+ // Holds a reference to included file data, as well as a
// prologue and an epilogue string. This can be scanned using the tInput
// interface and acts as a single source string.
class TokenizableIncludeFile : public tInput {
@@ -499,18 +500,18 @@ protected:
TPpContext* pp)
: tInput(pp),
prologue_(prologue),
- includedFile_(includedFile),
epilogue_(epilogue),
+ includedFile_(includedFile),
scanner(3, strings, lengths, names, 0, 0, true),
prevScanner(nullptr),
stringInput(pp, scanner)
{
strings[0] = prologue_.data();
- strings[1] = includedFile_->file_data;
+ strings[1] = includedFile_->headerData;
strings[2] = epilogue_.data();
lengths[0] = prologue_.size();
- lengths[1] = includedFile_->file_length;
+ lengths[1] = includedFile_->headerLength;
lengths[2] = epilogue_.size();
scanner.setLine(startLoc.line);
@@ -551,7 +552,7 @@ protected:
// Points to the IncludeResult that this TokenizableIncludeFile represents.
TShader::Includer::IncludeResult* includedFile_;
- // Will point to prologue_, includedFile_->file_data and epilogue_
+ // Will point to prologue_, includedFile_->headerData and epilogue_
// This is passed to scanner constructor.
// These do not own the storage and it must remain valid until this
// object has been destroyed.
@@ -575,7 +576,7 @@ protected:
void push_include(TShader::Includer::IncludeResult* result)
{
- currentSourceFile = result->file_name;
+ currentSourceFile = result->headerName;
includeStack.push(result);
}
@@ -587,7 +588,7 @@ protected:
if (includeStack.empty()) {
currentSourceFile = rootFileName;
} else {
- currentSourceFile = includeStack.top()->file_name;
+ currentSourceFile = includeStack.top()->headerName;
}
}
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpMemory.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpMemory.cpp
index 4d0f32a492e..e30db7f6d26 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpMemory.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpMemory.cpp
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2013 LunarG, Inc.
-//All rights reserved.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2013 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:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
/****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation.
@@ -57,7 +57,7 @@ Except as expressly stated in this notice, no other rights or licenses
express or implied, are granted by NVIDIA herein, including but not
limited to any patent rights that may be infringed by your derivative
works or by other works in which the NVIDIA Software may be
-incorporated. No hardware is licensed hereunder.
+incorporated. No hardware is licensed hereunder.
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpScanner.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpScanner.cpp
index 4bb7c932b00..83e6c89cc42 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpScanner.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpScanner.cpp
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2013 LunarG, Inc.
-//All rights reserved.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2013 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:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
/****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation.
@@ -57,7 +57,7 @@ Except as expressly stated in this notice, no other rights or licenses
express or implied, are granted by NVIDIA herein, including but not
limited to any patent rights that may be infringed by your derivative
works or by other works in which the NVIDIA Software may be
-incorporated. No hardware is licensed hereunder.
+incorporated. No hardware is licensed hereunder.
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
@@ -100,36 +100,26 @@ namespace glslang {
int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
{
bool HasDecimalOrExponent = false;
- int declen;
- int str_len;
int isDouble = 0;
#ifdef AMD_EXTENSIONS
int isFloat16 = 0;
bool enableFloat16 = parseContext.version >= 450 && parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_half_float);
#endif
- declen = 0;
+ const auto saveName = [&](int ch) {
+ if (len <= MaxTokenLength)
+ ppToken->name[len++] = static_cast<char>(ch);
+ };
+
+ // Decimal:
- str_len=len;
- char* str = ppToken->name;
if (ch == '.') {
HasDecimalOrExponent = true;
- str[len++] = (char)ch;
+ saveName(ch);
ch = getChar();
while (ch >= '0' && ch <= '9') {
- if (len < MaxTokenLength) {
- declen++;
- if (len > 0 || ch != '0') {
- str[len] = (char)ch;
- len++;
- str_len++;
- }
- ch = getChar();
- } else {
- parseContext.ppError(ppToken->loc, "float literal too long", "", "");
- len = 1;
- str_len = 1;
- }
+ saveName(ch);
+ ch = getChar();
}
}
@@ -137,101 +127,74 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
if (ch == 'e' || ch == 'E') {
HasDecimalOrExponent = true;
- if (len >= MaxTokenLength) {
- parseContext.ppError(ppToken->loc, "float literal too long", "", "");
- len = 1;
- str_len = 1;
- } else {
- str[len++] = (char)ch;
+ saveName(ch);
+ ch = getChar();
+ if (ch == '+' || ch == '-') {
+ saveName(ch);
ch = getChar();
- if (ch == '+') {
- str[len++] = (char)ch;
- ch = getChar();
- } else if (ch == '-') {
- str[len++] = (char)ch;
+ }
+ if (ch >= '0' && ch <= '9') {
+ while (ch >= '0' && ch <= '9') {
+ saveName(ch);
ch = getChar();
}
- if (ch >= '0' && ch <= '9') {
- while (ch >= '0' && ch <= '9') {
- if (len < MaxTokenLength) {
- str[len++] = (char)ch;
- ch = getChar();
- } else {
- parseContext.ppError(ppToken->loc, "float literal too long", "", "");
- len = 1;
- str_len = 1;
- }
- }
- } else {
- parseContext.ppError(ppToken->loc, "bad character in float exponent", "", "");
- }
+ } else {
+ parseContext.ppError(ppToken->loc, "bad character in float exponent", "", "");
}
}
- if (len == 0) {
- ppToken->dval = 0.0;
- strcpy(str, "0.0");
- } else {
- if (ch == 'l' || ch == 'L') {
- parseContext.doubleCheck(ppToken->loc, "double floating-point suffix");
- if (! HasDecimalOrExponent)
- parseContext.ppError(ppToken->loc, "float literal needs a decimal point or exponent", "", "");
- int ch2 = getChar();
- if (ch2 != 'f' && ch2 != 'F') {
- ungetChar();
- ungetChar();
- } else {
- if (len < MaxTokenLength) {
- str[len++] = (char)ch;
- str[len++] = (char)ch2;
- isDouble = 1;
- } else {
- parseContext.ppError(ppToken->loc, "float literal too long", "", "");
- len = 1,str_len=1;
- }
- }
+ // Suffix:
+
+ if (ch == 'l' || ch == 'L') {
+ parseContext.doubleCheck(ppToken->loc, "double floating-point suffix");
+ if (! HasDecimalOrExponent)
+ parseContext.ppError(ppToken->loc, "float literal needs a decimal point or exponent", "", "");
+ int ch2 = getChar();
+ if (ch2 != 'f' && ch2 != 'F') {
+ ungetChar();
+ ungetChar();
+ } else {
+ saveName(ch);
+ saveName(ch2);
+ isDouble = 1;
+ }
#ifdef AMD_EXTENSIONS
- } else if (enableFloat16 && (ch == 'h' || ch == 'H')) {
- parseContext.float16Check(ppToken->loc, "half floating-point suffix");
- if (!HasDecimalOrExponent)
- parseContext.ppError(ppToken->loc, "float literal needs a decimal point or exponent", "", "");
- int ch2 = getChar();
- if (ch2 != 'f' && ch2 != 'F') {
- ungetChar();
- ungetChar();
- }
- else {
- if (len < MaxTokenLength) {
- str[len++] = (char)ch;
- str[len++] = (char)ch2;
- isFloat16 = 1;
- }
- else {
- parseContext.ppError(ppToken->loc, "float literal too long", "", "");
- len = 1, str_len = 1;
- }
- }
-#endif
- } else if (ch == 'f' || ch == 'F') {
- parseContext.profileRequires(ppToken->loc, EEsProfile, 300, nullptr, "floating-point suffix");
- if (! parseContext.relaxedErrors())
- parseContext.profileRequires(ppToken->loc, ~EEsProfile, 120, nullptr, "floating-point suffix");
- if (! HasDecimalOrExponent)
- parseContext.ppError(ppToken->loc, "float literal needs a decimal point or exponent", "", "");
- if (len < MaxTokenLength)
- str[len++] = (char)ch;
- else {
- parseContext.ppError(ppToken->loc, "float literal too long", "", "");
- len = 1,str_len=1;
- }
- } else
+ } else if (enableFloat16 && (ch == 'h' || ch == 'H')) {
+ parseContext.float16Check(ppToken->loc, "half floating-point suffix");
+ if (!HasDecimalOrExponent)
+ parseContext.ppError(ppToken->loc, "float literal needs a decimal point or exponent", "", "");
+ int ch2 = getChar();
+ if (ch2 != 'f' && ch2 != 'F') {
ungetChar();
-
- str[len]='\0';
-
- ppToken->dval = strtod(str, nullptr);
+ ungetChar();
+ } else {
+ saveName(ch);
+ saveName(ch2);
+ isFloat16 = 1;
+ }
+#endif
+ } else if (ch == 'f' || ch == 'F') {
+ parseContext.profileRequires(ppToken->loc, EEsProfile, 300, nullptr, "floating-point suffix");
+ if (! parseContext.relaxedErrors())
+ parseContext.profileRequires(ppToken->loc, ~EEsProfile, 120, nullptr, "floating-point suffix");
+ if (! HasDecimalOrExponent)
+ parseContext.ppError(ppToken->loc, "float literal needs a decimal point or exponent", "", "");
+ saveName(ch);
+ } else
+ ungetChar();
+
+ // Patch up the name, length, etc.
+
+ if (len > MaxTokenLength) {
+ len = MaxTokenLength;
+ parseContext.ppError(ppToken->loc, "float literal too long", "", "");
}
+ ppToken->name[len] = '\0';
+
+ // Get the numerical value
+ ppToken->dval = strtod(ppToken->name, nullptr);
+ // Return the right token type
if (isDouble)
return PpAtomConstDouble;
#ifdef AMD_EXTENSIONS
@@ -688,6 +651,9 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
}
break;
case '"':
+ // TODO: If this gets enhanced to handle escape sequences, or
+ // anything that is different than what #include needs, then
+ // #include needs to use scanHeaderName() for this.
ch = getch();
while (ch != '"' && ch != '\n' && ch != EndOfInput) {
if (len < MaxTokenLength) {
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpSymbols.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpSymbols.cpp
index 585bf2c8d50..700d82e2fe8 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpSymbols.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpSymbols.cpp
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2013 LunarG, Inc.
-//All rights reserved.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2013 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:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
/****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation.
@@ -57,7 +57,7 @@ Except as expressly stated in this notice, no other rights or licenses
express or implied, are granted by NVIDIA herein, including but not
limited to any patent rights that may be infringed by your derivative
works or by other works in which the NVIDIA Software may be
-incorporated. No hardware is licensed hereunder.
+incorporated. No hardware is licensed hereunder.
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpTokens.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpTokens.cpp
index 471f26c028c..f0441b7f8d2 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpTokens.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpTokens.cpp
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2013 LunarG, Inc.
-//All rights reserved.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2013 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:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
/****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation.
@@ -57,7 +57,7 @@ Except as expressly stated in this notice, no other rights or licenses
express or implied, are granted by NVIDIA herein, including but not
limited to any patent rights that may be infringed by your derivative
works or by other works in which the NVIDIA Software may be
-incorporated. No hardware is licensed hereunder.
+incorporated. No hardware is licensed hereunder.
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpTokens.h b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpTokens.h
index 20aeb1010dd..3b1367f3b42 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpTokens.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/preprocessor/PpTokens.h
@@ -1,10 +1,10 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -18,18 +18,18 @@
// 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.
+// 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.
//
/****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation.
@@ -56,7 +56,7 @@ Except as expressly stated in this notice, no other rights or licenses
express or implied, are granted by NVIDIA herein, including but not
limited to any patent rights that may be infringed by your derivative
works or by other works in which the NVIDIA Software may be
-incorporated. No hardware is licensed hereunder.
+incorporated. No hardware is licensed hereunder.
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
@@ -128,7 +128,7 @@ enum EFixedAtoms {
#endif
PpAtomConstString,
- // Identifiers
+ // Identifiers
PpAtomIdentifier,
// preprocessor "keywords"
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/propagateNoContraction.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/propagateNoContraction.cpp
index caa6e200d5e..ae95688ae8b 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/propagateNoContraction.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/propagateNoContraction.cpp
@@ -90,6 +90,7 @@ bool isDereferenceOperation(glslang::TOperator op)
case glslang::EOpIndexDirectStruct:
case glslang::EOpIndexIndirect:
case glslang::EOpVectorSwizzle:
+ case glslang::EOpMatrixSwizzle:
return true;
default:
return false;
@@ -272,9 +273,9 @@ TSymbolDefinitionCollectingTraverser::TSymbolDefinitionCollectingTraverser(
ObjectAccesschainSet* precise_objects,
std::unordered_set<glslang::TIntermBranch*>* precise_return_nodes)
: TIntermTraverser(true, false, false), symbol_definition_mapping_(*symbol_definition_mapping),
- precise_objects_(*precise_objects), current_object_(),
- accesschain_mapping_(*accesschain_mapping), current_function_definition_node_(nullptr),
- precise_return_nodes_(*precise_return_nodes) {}
+ precise_objects_(*precise_objects), precise_return_nodes_(*precise_return_nodes),
+ current_object_(), accesschain_mapping_(*accesschain_mapping),
+ current_function_definition_node_(nullptr) {}
// Visits a symbol node, set the current_object_ to the
// current node symbol ID, and record a mapping from this node to the current
@@ -616,9 +617,9 @@ class TNoContractionPropagator : public glslang::TIntermTraverser {
public:
TNoContractionPropagator(ObjectAccesschainSet* precise_objects,
const AccessChainMapping& accesschain_mapping)
- : TIntermTraverser(true, false, false), remained_accesschain_(),
- precise_objects_(*precise_objects), accesschain_mapping_(accesschain_mapping),
- added_precise_object_ids_() {}
+ : TIntermTraverser(true, false, false),
+ precise_objects_(*precise_objects), added_precise_object_ids_(),
+ remained_accesschain_(), accesschain_mapping_(accesschain_mapping) {}
// Propagates 'precise' in the right nodes of a given assignment node with
// access chain record from the assignee node to a 'precise' object it
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/reflection.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/reflection.cpp
index 31bd1725571..688827da982 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/reflection.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/reflection.cpp
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2013-2016 LunarG, Inc.
+// Copyright (C) 2013-2016 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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 "../Include/Common.h"
@@ -63,7 +63,6 @@
// there wasn't exactly one entry point.
//
-
namespace glslang {
//
@@ -355,7 +354,6 @@ public:
return blockIndex;
}
-
// Are we at a level in a dereference chain at which individual active uniform queries are made?
bool isReflectionGranularity(const TType& type)
{
@@ -694,7 +692,6 @@ void TReflectionTraverser::visitSymbol(TIntermSymbol* base)
addAttribute(*base);
}
-
//
// Implement TReflection methods.
//
@@ -739,10 +736,10 @@ void TReflection::dump()
indexToAttribute[i].dump();
printf("\n");
- //printf("Live names\n");
- //for (TNameToIndex::const_iterator it = nameToIndex.begin(); it != nameToIndex.end(); ++it)
+ // printf("Live names\n");
+ // for (TNameToIndex::const_iterator it = nameToIndex.begin(); it != nameToIndex.end(); ++it)
// printf("%s: %d\n", it->first.c_str(), it->second);
- //printf("\n");
+ // printf("\n");
}
} // end namespace glslang
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/reflection.h b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/reflection.h
index 13f5177c0f4..bae131cfdb3 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/reflection.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/reflection.h
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2013-2016 LunarG, Inc.
+// Copyright (C) 2013-2016 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
#ifndef _REFLECTION_INCLUDED
@@ -55,9 +55,9 @@ class TReflectionTraverser;
// Data needed for just a single object at the granularity exchanged by the reflection API
class TObjectReflection {
public:
- TObjectReflection(const TString& pName, const TType& pType, int pOffset, int pGLDefineType, int pSize, int pIndex) :
- name(pName), type(pType.clone()),
- offset(pOffset), glDefineType(pGLDefineType), size(pSize), index(pIndex) { }
+ TObjectReflection(const TString& pName, const TType& pType, int pOffset, int pGLDefineType, int pSize, int pIndex) :
+ name(pName), offset(pOffset),
+ glDefineType(pGLDefineType), size(pSize), index(pIndex), type(pType.clone()) { }
void dump() const {
printf("%s: offset %d, type %x, size %d, index %d, binding %d\n",
@@ -81,7 +81,7 @@ protected:
return type->getQualifier().layoutBinding;
}
- TObjectReflection() : type(nullptr), offset(-1), glDefineType(-1), size(-1), index(-1) { }
+ TObjectReflection() : offset(-1), glDefineType(-1), size(-1), index(-1), type(nullptr) { }
const TType* type;
};
@@ -107,7 +107,7 @@ public:
// for mapping a block index to the block's description
int getNumUniformBlocks() const { return (int)indexToUniformBlock.size(); }
- const TObjectReflection& getUniformBlock(int i) const
+ const TObjectReflection& getUniformBlock(int i) const
{
if (i >= 0 && i < (int)indexToUniformBlock.size())
return indexToUniformBlock[i];
@@ -126,7 +126,7 @@ public:
}
// for mapping any name to its index (block names, uniform names and attribute names)
- int getIndex(const char* name) const
+ int getIndex(const char* name) const
{
TNameToIndex::const_iterator it = nameToIndex.find(name);
if (it == nameToIndex.end())
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/OSDependent/Unix/ossource.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/OSDependent/Unix/ossource.cpp
index 7e84d4eb233..4f8098b752a 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/OSDependent/Unix/ossource.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/OSDependent/Unix/ossource.cpp
@@ -1,10 +1,10 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -18,18 +18,18 @@
// 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.
+// 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.
//
//
@@ -51,122 +51,119 @@ namespace glslang {
//
//
-// Wrapper for Linux call to DetachThread. This is required as pthread_cleanup_push() expects
+// Wrapper for Linux call to DetachThread. This is required as pthread_cleanup_push() expects
// the cleanup routine to return void.
-//
+//
static void DetachThreadLinux(void *)
{
- DetachThread();
+ DetachThread();
}
-
//
// Registers cleanup handler, sets cancel type and state, and executes the thread specific
-// cleanup handler. This function will be called in the Standalone.cpp for regression
-// testing. When OpenGL applications are run with the driver code, Linux OS does the
+// cleanup handler. This function will be called in the Standalone.cpp for regression
+// testing. When OpenGL applications are run with the driver code, Linux OS does the
// thread cleanup.
-//
+//
void OS_CleanupThreadData(void)
{
#ifdef __ANDROID__
- DetachThreadLinux(NULL);
+ DetachThreadLinux(NULL);
#else
- int old_cancel_state, old_cancel_type;
- void *cleanupArg = NULL;
-
- //
- // Set thread cancel state and push cleanup handler.
- //
- pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old_cancel_state);
- pthread_cleanup_push(DetachThreadLinux, (void *) cleanupArg);
-
- //
- // Put the thread in deferred cancellation mode.
- //
- pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &old_cancel_type);
-
- //
- // Pop cleanup handler and execute it prior to unregistering the cleanup handler.
- //
- pthread_cleanup_pop(1);
-
- //
- // Restore the thread's previous cancellation mode.
- //
- pthread_setcanceltype(old_cancel_state, NULL);
+ int old_cancel_state, old_cancel_type;
+ void *cleanupArg = NULL;
+
+ //
+ // Set thread cancel state and push cleanup handler.
+ //
+ pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old_cancel_state);
+ pthread_cleanup_push(DetachThreadLinux, (void *) cleanupArg);
+
+ //
+ // Put the thread in deferred cancellation mode.
+ //
+ pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &old_cancel_type);
+
+ //
+ // Pop cleanup handler and execute it prior to unregistering the cleanup handler.
+ //
+ pthread_cleanup_pop(1);
+
+ //
+ // Restore the thread's previous cancellation mode.
+ //
+ pthread_setcanceltype(old_cancel_state, NULL);
#endif
}
-
//
// Thread Local Storage Operations
//
inline OS_TLSIndex PthreadKeyToTLSIndex(pthread_key_t key)
{
- return (OS_TLSIndex)((uintptr_t)key + 1);
+ return (OS_TLSIndex)((uintptr_t)key + 1);
}
inline pthread_key_t TLSIndexToPthreadKey(OS_TLSIndex nIndex)
{
- return (pthread_key_t)((uintptr_t)nIndex - 1);
+ return (pthread_key_t)((uintptr_t)nIndex - 1);
}
OS_TLSIndex OS_AllocTLSIndex()
{
- pthread_key_t pPoolIndex;
+ pthread_key_t pPoolIndex;
- //
- // Create global pool key.
- //
- if ((pthread_key_create(&pPoolIndex, NULL)) != 0) {
- assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");
- return OS_INVALID_TLS_INDEX;
- }
- else
- return PthreadKeyToTLSIndex(pPoolIndex);
+ //
+ // Create global pool key.
+ //
+ if ((pthread_key_create(&pPoolIndex, NULL)) != 0) {
+ assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");
+ return OS_INVALID_TLS_INDEX;
+ }
+ else
+ return PthreadKeyToTLSIndex(pPoolIndex);
}
-
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
{
- if (nIndex == OS_INVALID_TLS_INDEX) {
- assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
- return false;
- }
+ if (nIndex == OS_INVALID_TLS_INDEX) {
+ assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
+ return false;
+ }
- if (pthread_setspecific(TLSIndexToPthreadKey(nIndex), lpvValue) == 0)
- return true;
- else
- return false;
+ if (pthread_setspecific(TLSIndexToPthreadKey(nIndex), lpvValue) == 0)
+ return true;
+ else
+ return false;
}
void* OS_GetTLSValue(OS_TLSIndex nIndex)
{
- //
- // This function should return 0 if nIndex is invalid.
- //
- assert(nIndex != OS_INVALID_TLS_INDEX);
- return pthread_getspecific(TLSIndexToPthreadKey(nIndex));
+ //
+ // This function should return 0 if nIndex is invalid.
+ //
+ assert(nIndex != OS_INVALID_TLS_INDEX);
+ return pthread_getspecific(TLSIndexToPthreadKey(nIndex));
}
bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
{
- if (nIndex == OS_INVALID_TLS_INDEX) {
- assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
- return false;
- }
+ if (nIndex == OS_INVALID_TLS_INDEX) {
+ assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
+ return false;
+ }
- //
- // Delete the global pool key.
- //
- if (pthread_key_delete(TLSIndexToPthreadKey(nIndex)) == 0)
- return true;
- else
- return false;
+ //
+ // Delete the global pool key.
+ //
+ if (pthread_key_delete(TLSIndexToPthreadKey(nIndex)) == 0)
+ return true;
+ else
+ return false;
}
namespace {
-pthread_mutex_t gMutex;
+ pthread_mutex_t gMutex;
}
void InitGlobalLock()
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/OSDependent/Windows/main.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/OSDependent/Windows/main.cpp
index 6d6b0fddcb8..0bcde7b6603 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/OSDependent/Windows/main.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/OSDependent/Windows/main.cpp
@@ -1,10 +1,10 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -18,18 +18,18 @@
// 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.
+// 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 "InitializeDll.h"
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/OSDependent/Windows/ossource.cpp b/3rdparty/bgfx/3rdparty/glslang/glslang/OSDependent/Windows/ossource.cpp
index f71fac9cb61..73ae0ca7162 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/OSDependent/Windows/ossource.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/OSDependent/Windows/ossource.cpp
@@ -1,10 +1,10 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -18,18 +18,18 @@
// 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.
+// 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 "../osinclude.h"
@@ -77,7 +77,6 @@ OS_TLSIndex OS_AllocTLSIndex()
return ToGenericTLSIndex(dwIndex);
}
-
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
{
if (nIndex == OS_INVALID_TLS_INDEX) {
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/OSDependent/osinclude.h b/3rdparty/bgfx/3rdparty/glslang/glslang/OSDependent/osinclude.h
index 33f880380f2..e8325268e9b 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/OSDependent/osinclude.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/OSDependent/osinclude.h
@@ -1,10 +1,10 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -18,18 +18,18 @@
// 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.
+// 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.
//
#ifndef __OSINCLUDE_H
diff --git a/3rdparty/bgfx/3rdparty/glslang/glslang/Public/ShaderLang.h b/3rdparty/bgfx/3rdparty/glslang/glslang/Public/ShaderLang.h
index afdc7d1eb26..d2f4e1b5c4e 100644
--- a/3rdparty/bgfx/3rdparty/glslang/glslang/Public/ShaderLang.h
+++ b/3rdparty/bgfx/3rdparty/glslang/glslang/Public/ShaderLang.h
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//Copyright (C) 2013-2016 LunarG, Inc.
+// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+// Copyright (C) 2013-2016 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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.
//
#ifndef _COMPILER_INTERFACE_INCLUDED_
#define _COMPILER_INTERFACE_INCLUDED_
@@ -165,9 +165,9 @@ typedef struct {
//
// ShHandle held by but opaque to the driver. It is allocated,
-// managed, and de-allocated by the compiler/linker. It's contents
+// managed, and de-allocated by the compiler/linker. It's contents
// are defined by and used by the compiler and linker. For example,
-// symbol table information and object code passed from the compiler
+// symbol table information and object code passed from the compiler
// to the linker can be stored where ShHandle points.
//
// If handle creation fails, 0 will be returned.
@@ -187,7 +187,7 @@ SH_IMPORT_EXPORT void ShDestruct(ShHandle);
// The return value of ShCompile is boolean, non-zero indicating
// success.
//
-// The info-log should be written by ShCompile into
+// The info-log should be written by ShCompile into
// ShHandle, so it can answer future queries.
//
SH_IMPORT_EXPORT int ShCompile(
@@ -251,8 +251,8 @@ SH_IMPORT_EXPORT int ShGetUniformLocation(const ShHandle uniformMap, const char*
// -----------------------------------
//
// Below is a new alternate C++ interface that might potentially replace the above
-// opaque handle-based interface.
-//
+// opaque handle-based interface.
+//
// The below is further designed to handle multiple compilation units per stage, where
// the intermediate results, including the parse tree, are preserved until link time,
// rather than the above interface which is designed to have each compilation unit
@@ -331,72 +331,76 @@ public:
// release the IncludeResult object.
class Includer {
public:
- typedef enum {
- EIncludeRelative, // For #include "something"
- EIncludeStandard // Reserved. For #include <something>
- } IncludeType;
-
// An IncludeResult contains the resolved name and content of a source
// inclusion.
struct IncludeResult {
- IncludeResult(const std::string& file_name, const char* const file_data, const size_t file_length, void* user_data) :
- file_name(file_name), file_data(file_data), file_length(file_length), user_data(user_data) { }
+ IncludeResult(const std::string& headerName, const char* const headerData, const size_t headerLength, void* userData) :
+ headerName(headerName), headerData(headerData), headerLength(headerLength), userData(userData) { }
// For a successful inclusion, the fully resolved name of the requested
// include. For example, in a file system-based includer, full resolution
// should convert a relative path name into an absolute path name.
// For a failed inclusion, this is an empty string.
- const std::string file_name;
+ const std::string headerName;
// The content and byte length of the requested inclusion. The
// Includer producing this IncludeResult retains ownership of the
// storage.
- // For a failed inclusion, the file_data
+ // For a failed inclusion, the header
// field points to a string containing error details.
- const char* const file_data;
- const size_t file_length;
+ const char* const headerData;
+ const size_t headerLength;
// Include resolver's context.
- void* user_data;
+ void* userData;
protected:
IncludeResult& operator=(const IncludeResult&);
IncludeResult();
};
- // Resolves an inclusion request by name, type, current source name,
+ // For both include methods below:
+ //
+ // Resolves an inclusion request by name, current source name,
// and include depth.
// On success, returns an IncludeResult containing the resolved name
- // and content of the include. On failure, returns an IncludeResult
- // with an empty string for the file_name and error details in the
- // file_data field. The Includer retains ownership of the contents
+ // and content of the include.
+ // On failure, returns a nullptr, or an IncludeResult
+ // with an empty string for the headerName and error details in the
+ // header field.
+ // The Includer retains ownership of the contents
// of the returned IncludeResult value, and those contents must
// remain valid until the releaseInclude method is called on that
// IncludeResult object.
- virtual IncludeResult* include(const char* requested_source,
- IncludeType type,
- const char* requesting_source,
- size_t inclusion_depth) = 0;
+ //
+ // Note "local" vs. "system" is not an "either/or": "local" is an
+ // extra thing to do over "system". Both might get called, as per
+ // the C++ specification.
+
+ // For the "system" or <>-style includes; search the "system" paths.
+ virtual IncludeResult* includeSystem(const char* /*headerName*/,
+ const char* /*includerName*/,
+ size_t /*inclusionDepth*/) { return nullptr; }
+
+ // For the "local"-only aspect of a "" include. Should not search in the
+ // "system" paths, because on returning a failure, the parser will
+ // call includeSystem() to look in the "system" locations.
+ virtual IncludeResult* includeLocal(const char* /*headerName*/,
+ const char* /*includerName*/,
+ size_t /*inclusionDepth*/) { return nullptr; }
+
// Signals that the parser will no longer use the contents of the
// specified IncludeResult.
- virtual void releaseInclude(IncludeResult* result) = 0;
+ virtual void releaseInclude(IncludeResult*) = 0;
virtual ~Includer() {}
};
- // Returns an error message for any #include directive.
- class ForbidInclude : public Includer {
+ // Fail all Includer searches
+ class ForbidIncluder : public Includer {
public:
- IncludeResult* include(const char*, IncludeType, const char*, size_t) override
- {
- const char* unexpected_include = "unexpected include directive";
- return new IncludeResult(std::string(""), unexpected_include, strlen(unexpected_include), nullptr);
- }
- virtual void releaseInclude(IncludeResult* result) override
- {
- delete result;
- }
+ virtual void releaseInclude(IncludeResult*) override { }
};
bool parse(const TBuiltInResource* res, int defaultVersion, EProfile defaultProfile, bool forceDefaultVersionAndProfile,
bool forwardCompatible, EShMessages messages)
{
- TShader::ForbidInclude includer;
+ TShader::ForbidIncluder includer;
return parse(res, defaultVersion, defaultProfile, forceDefaultVersionAndProfile, forwardCompatible, messages, includer);
}
@@ -513,7 +517,7 @@ public:
const char *getAttributeName(int index) const; // can be used for glGetActiveAttrib()
int getAttributeType(int index) const; // can be used for glGetActiveAttrib()
const TType* getUniformTType(int index) const; // returns a TType*
- const TType* getUniformBlockTType(int index) const; // returns a TType*
+ const TType* getUniformBlockTType(int index) const; // returns a TType*
const TType* getAttributeTType(int index) const; // returns a TType*
void dumpReflection();
@@ -536,6 +540,7 @@ protected:
bool linked;
private:
+ TProgram(TProgram&);
TProgram& operator=(TProgram&);
};
diff --git a/3rdparty/bgfx/3rdparty/glslang/gtests/AST.FromFile.cpp b/3rdparty/bgfx/3rdparty/glslang/gtests/AST.FromFile.cpp
index 70705337f52..d8a5ef94c92 100644
--- a/3rdparty/bgfx/3rdparty/glslang/gtests/AST.FromFile.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/gtests/AST.FromFile.cpp
@@ -79,6 +79,7 @@ INSTANTIATE_TEST_CASE_P(
"cppIndent.vert",
"cppNest.vert",
"cppBad.vert",
+ "cppBad2.vert",
"cppComplexExpr.vert",
"badChars.frag",
"pointCoord.frag",
diff --git a/3rdparty/bgfx/3rdparty/glslang/gtests/CMakeLists.txt b/3rdparty/bgfx/3rdparty/glslang/gtests/CMakeLists.txt
index 268caff7f93..c383ca0741e 100644
--- a/3rdparty/bgfx/3rdparty/glslang/gtests/CMakeLists.txt
+++ b/3rdparty/bgfx/3rdparty/glslang/gtests/CMakeLists.txt
@@ -17,6 +17,7 @@ if (TARGET gmock)
${CMAKE_CURRENT_SOURCE_DIR}/HexFloat.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Hlsl.FromFile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Link.FromFile.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/Link.FromFile.Vk.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Pp.FromFile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Spv.FromFile.cpp
# -- Remapper tests
@@ -40,9 +41,15 @@ if (TARGET gmock)
${PROJECT_SOURCE_DIR}
${gmock_SOURCE_DIR}/include
${gtest_SOURCE_DIR}/include)
- target_link_libraries(glslangtests PRIVATE
- SPVRemapper glslang OSDependent OGLCompiler HLSL glslang
- SPIRV glslang-default-resource-limits gmock)
+
+ set(LIBRARIES
+ SPVRemapper glslang OSDependent OGLCompiler glslang
+ SPIRV glslang-default-resource-limits)
+ if(ENABLE_HLSL)
+ set(LIBRARIES ${LIBRARIES} HLSL)
+ endif(ENABLE_HLSL)
+ target_link_libraries(glslangtests PRIVATE ${LIBRARIES} gmock)
+
add_test(NAME glslang-gtests
- COMMAND glslangtests --test-root "${GLSLANG_TEST_DIRECTORY}")
+ COMMAND glslangtests --test-root "${GLSLANG_TEST_DIRECTORY}")
endif()
diff --git a/3rdparty/bgfx/3rdparty/glslang/gtests/Hlsl.FromFile.cpp b/3rdparty/bgfx/3rdparty/glslang/gtests/Hlsl.FromFile.cpp
index f0332aac611..b703398cfed 100644
--- a/3rdparty/bgfx/3rdparty/glslang/gtests/Hlsl.FromFile.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/gtests/Hlsl.FromFile.cpp
@@ -127,6 +127,7 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.intrinsics.barriers.comp", "ComputeShaderFunction"},
{"hlsl.intrinsics.comp", "ComputeShaderFunction"},
{"hlsl.intrinsics.evalfns.frag", "main"},
+ {"hlsl.intrinsics.d3dcolortoubyte4.frag", "main"},
{"hlsl.intrinsics.double.frag", "PixelShaderFunction"},
{"hlsl.intrinsics.f1632.frag", "PixelShaderFunction"},
{"hlsl.intrinsics.frag", "main"},
@@ -153,6 +154,7 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.logical.binary.frag", "main"},
{"hlsl.logical.binary.vec.frag", "main"},
{"hlsl.matNx1.frag", "main"},
+ {"hlsl.matrixSwizzle.vert", "ShaderFunction"},
{"hlsl.mintypes.frag", "main"},
{"hlsl.multiEntry.vert", "RealEntrypoint"},
{"hlsl.multiReturn.frag", "main"},
@@ -160,6 +162,8 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.numericsuffixes.frag", "main"},
{"hlsl.numthreads.comp", "main_aux1"},
{"hlsl.overload.frag", "PixelShaderFunction"},
+ {"hlsl.params.default.frag", "main"},
+ {"hlsl.params.default.negative.frag", "main"},
{"hlsl.partialInit.frag", "PixelShaderFunction"},
{"hlsl.pp.line.frag", "main"},
{"hlsl.precise.frag", "main"},
@@ -171,6 +175,7 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.rw.bracket.frag", "main"},
{"hlsl.rw.register.frag", "main"},
{"hlsl.rw.scalar.bracket.frag", "main"},
+ {"hlsl.rw.swizzle.frag", "main"},
{"hlsl.rw.vec2.bracket.frag", "main"},
{"hlsl.sample.array.dx10.frag", "main"},
{"hlsl.sample.basic.dx10.frag", "main"},
@@ -204,6 +209,13 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.shapeConvRet.frag", "main"},
{"hlsl.stringtoken.frag", "main"},
{"hlsl.string.frag", "main"},
+ {"hlsl.struct.split-1.vert", "main"},
+ {"hlsl.struct.split.array.geom", "main"},
+ {"hlsl.struct.split.assign.frag", "main"},
+ {"hlsl.struct.split.call.vert", "main"},
+ {"hlsl.struct.split.nested.geom", "main"},
+ {"hlsl.struct.split.trivial.geom", "main"},
+ {"hlsl.struct.split.trivial.vert", "main"},
{"hlsl.structarray.flatten.frag", "main"},
{"hlsl.structarray.flatten.geom", "main"},
{"hlsl.structin.vert", "main"},
@@ -221,6 +233,8 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.swizzle.frag", "PixelShaderFunction"},
{"hlsl.templatetypes.frag", "PixelShaderFunction"},
{"hlsl.tx.bracket.frag", "main"},
+ {"hlsl.type.half.frag", "main"},
+ {"hlsl.type.identifier.frag", "main"},
{"hlsl.typedef.frag", "PixelShaderFunction"},
{"hlsl.whileLoop.frag", "PixelShaderFunction"},
{"hlsl.void.frag", "PixelShaderFunction"},
diff --git a/3rdparty/bgfx/3rdparty/glslang/gtests/Link.FromFile.Vk.cpp b/3rdparty/bgfx/3rdparty/glslang/gtests/Link.FromFile.Vk.cpp
new file mode 100644
index 00000000000..6ce1fe9f79a
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/glslang/gtests/Link.FromFile.Vk.cpp
@@ -0,0 +1,97 @@
+//
+// Copyright (C) 2016-2017 Google, 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 <memory>
+
+#include <gtest/gtest.h>
+
+#include "TestFixture.h"
+
+namespace glslangtest {
+namespace {
+
+using LinkTestVulkan = GlslangTest<
+ ::testing::TestWithParam<std::vector<std::string>>>;
+
+TEST_P(LinkTestVulkan, FromFile)
+{
+ const auto& fileNames = GetParam();
+ const size_t fileCount = fileNames.size();
+ const EShMessages controls = DeriveOptions(Source::GLSL, Semantics::Vulkan, Target::AST);
+ GlslangResult result;
+
+ // Compile each input shader file.
+ std::vector<std::unique_ptr<glslang::TShader>> shaders;
+ for (size_t i = 0; i < fileCount; ++i) {
+ std::string contents;
+ tryLoadFile(GlobalTestSettings.testRoot + "/" + fileNames[i],
+ "input", &contents);
+ shaders.emplace_back(
+ new glslang::TShader(GetShaderStage(GetSuffix(fileNames[i]))));
+ auto* shader = shaders.back().get();
+ compile(shader, contents, "", controls);
+ result.shaderResults.push_back(
+ {fileNames[i], shader->getInfoLog(), shader->getInfoDebugLog()});
+ }
+
+ // Link all of them.
+ glslang::TProgram program;
+ for (const auto& shader : shaders) program.addShader(shader.get());
+ program.link(controls);
+ result.linkingOutput = program.getInfoLog();
+ result.linkingError = program.getInfoDebugLog();
+
+ std::ostringstream stream;
+ outputResultToStream(&stream, result, controls);
+
+ // Check with expected results.
+ const std::string expectedOutputFname =
+ GlobalTestSettings.testRoot + "/baseResults/" + fileNames.front() + ".out";
+ std::string expectedOutput;
+ tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
+
+ checkEqAndUpdateIfRequested(expectedOutput, stream.str(), expectedOutputFname);
+}
+
+// clang-format off
+INSTANTIATE_TEST_CASE_P(
+ Glsl, LinkTestVulkan,
+ ::testing::ValuesIn(std::vector<std::vector<std::string>>({
+ {"link1.vk.frag", "link2.vk.frag"},
+ })),
+);
+// clang-format on
+
+} // anonymous namespace
+} // namespace glslangtest
diff --git a/3rdparty/bgfx/3rdparty/glslang/gtests/Spv.FromFile.cpp b/3rdparty/bgfx/3rdparty/glslang/gtests/Spv.FromFile.cpp
index c946ef7ee19..fc0ba06a66d 100644
--- a/3rdparty/bgfx/3rdparty/glslang/gtests/Spv.FromFile.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/gtests/Spv.FromFile.cpp
@@ -71,6 +71,9 @@ using GlslIoMap = GlslangTest<::testing::TestWithParam<IoMapData>>;
#ifdef AMD_EXTENSIONS
using CompileVulkanToSpirvTestAMD = GlslangTest<::testing::TestWithParam<std::string>>;
#endif
+#ifdef NV_EXTENSIONS
+using CompileVulkanToSpirvTestNV = GlslangTest<::testing::TestWithParam<std::string>>;
+#endif
// Compiling GLSL to SPIR-V under Vulkan semantics. Expected to successfully
// generate SPIR-V.
@@ -155,6 +158,17 @@ TEST_P(CompileVulkanToSpirvTestAMD, FromFile)
}
#endif
+#ifdef NV_EXTENSIONS
+// Compiling GLSL to SPIR-V under Vulkan semantics (AMD extensions enabled).
+// Expected to successfully generate SPIR-V.
+TEST_P(CompileVulkanToSpirvTestNV, FromFile)
+{
+ loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
+ Source::GLSL, Semantics::Vulkan,
+ Target::Spv);
+}
+#endif
+
// clang-format off
INSTANTIATE_TEST_CASE_P(
Glsl, CompileVulkanToSpirvTest,
@@ -216,7 +230,6 @@ INSTANTIATE_TEST_CASE_P(
"spv.forwardFun.frag",
"spv.functionCall.frag",
"spv.functionSemantics.frag",
- "spv.GeometryShaderPassthrough.geom",
"spv.interpOps.frag",
"spv.int64.frag",
"spv.layoutNested.vert",
@@ -241,7 +254,6 @@ INSTANTIATE_TEST_CASE_P(
"spv.precision.frag",
"spv.prepost.frag",
"spv.qualifiers.vert",
- "spv.sampleMaskOverrideCoverage.frag",
"spv.shaderBallot.comp",
"spv.shaderDrawParams.vert",
"spv.shaderGroupVote.comp",
@@ -358,10 +370,26 @@ INSTANTIATE_TEST_CASE_P(
Glsl, CompileVulkanToSpirvTestAMD,
::testing::ValuesIn(std::vector<std::string>({
"spv.float16.frag",
+ "spv.shaderBallotAMD.comp"
})),
FileNameAsCustomTestSuffix
);
#endif
+
+#ifdef NV_EXTENSIONS
+INSTANTIATE_TEST_CASE_P(
+ Glsl, CompileVulkanToSpirvTestNV,
+ ::testing::ValuesIn(std::vector<std::string>({
+ "spv.sampleMaskOverrideCoverage.frag",
+ "spv.GeometryShaderPassthrough.geom",
+ "spv.viewportArray2.vert",
+ "spv.viewportArray2.tesc",
+ "spv.stereoViewRendering.vert",
+ "spv.stereoViewRendering.tesc",
+})),
+FileNameAsCustomTestSuffix
+);
+#endif
// clang-format on
} // anonymous namespace
diff --git a/3rdparty/bgfx/3rdparty/glslang/gtests/TestFixture.h b/3rdparty/bgfx/3rdparty/glslang/gtests/TestFixture.h
index e795e8dc90d..6f4afc6613c 100644
--- a/3rdparty/bgfx/3rdparty/glslang/gtests/TestFixture.h
+++ b/3rdparty/bgfx/3rdparty/glslang/gtests/TestFixture.h
@@ -521,7 +521,7 @@ public:
glslang::TShader shader(EShLangVertex);
shader.setStringsWithLengths(&shaderStrings, &shaderLengths, 1);
std::string ppShader;
- glslang::TShader::ForbidInclude includer;
+ glslang::TShader::ForbidIncluder includer;
const bool success = shader.preprocess(
&glslang::DefaultTBuiltInResource, defaultVersion, defaultProfile,
forceVersionProfile, isForwardCompatible, (EShMessages)(EShMsgOnlyPreprocessor | EShMsgCascadingErrors),
diff --git a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslAttributes.cpp b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslAttributes.cpp
index 966ff352101..df370468890 100644
--- a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslAttributes.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslAttributes.cpp
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2016 LunarG, Inc.
+// Copyright (C) 2016 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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 "hlslAttributes.h"
@@ -95,7 +95,7 @@ namespace glslang {
if (attr != EatNone)
attributes[attr] = value;
-
+
return attr;
}
@@ -106,5 +106,5 @@ namespace glslang {
return (entry == attributes.end()) ? nullptr : entry->second;
}
-
+
} // end namespace glslang
diff --git a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslAttributes.h b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslAttributes.h
index 312a4564262..820909b19be 100644
--- a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslAttributes.h
+++ b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslAttributes.h
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2016 LunarG, Inc.
+// Copyright (C) 2016 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
#ifndef HLSLATTRIBUTES_H_
diff --git a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslGrammar.cpp b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslGrammar.cpp
index b874aa8c9cb..1ae130dcc43 100644
--- a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslGrammar.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslGrammar.cpp
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2016 Google, Inc.
-//Copyright (C) 2016 LunarG, Inc.
+// Copyright (C) 2016 Google, Inc.
+// Copyright (C) 2016 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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.
//
//
@@ -85,21 +85,36 @@ bool HlslGrammar::acceptIdentifier(HlslToken& idToken)
return true;
}
- // Even though "sample" is a keyword (for interpolation modifiers), it IS still accepted as
- // an identifier. This appears to be a solitary exception: other interp modifier keywords such
- // as "linear" or "centroid" NOT valid identifiers. This code special cases "sample",
- // so e.g, "int sample;" is accepted.
- if (peekTokenClass(EHTokSample)) {
- token.string = NewPoolTString("sample");
- token.tokenClass = EHTokIdentifier;
- token.symbol = nullptr;
+ // Even though "sample", "bool", "float", etc keywords (for types, interpolation modifiers),
+ // they ARE still accepted as identifiers. This is not a dense space: e.g, "void" is not a
+ // valid identifier, nor is "linear". This code special cases the known instances of this, so
+ // e.g, "int sample;" or "float float;" is accepted. Other cases can be added here if needed.
- idToken = token;
- advanceToken();
- return true;
+ TString* idString = nullptr;
+ switch (peek()) {
+ case EHTokSample: idString = NewPoolTString("sample"); break;
+ case EHTokHalf: idString = NewPoolTString("half"); break;
+ case EHTokBool: idString = NewPoolTString("bool"); break;
+ case EHTokFloat: idString = NewPoolTString("float"); break;
+ case EHTokDouble: idString = NewPoolTString("double"); break;
+ case EHTokInt: idString = NewPoolTString("int"); break;
+ case EHTokUint: idString = NewPoolTString("uint"); break;
+ case EHTokMin16float: idString = NewPoolTString("min16float"); break;
+ case EHTokMin10float: idString = NewPoolTString("min10float"); break;
+ case EHTokMin16int: idString = NewPoolTString("min16int"); break;
+ case EHTokMin12int: idString = NewPoolTString("min12int"); break;
+ default:
+ return false;
}
- return false;
+ token.string = idString;
+ token.tokenClass = EHTokIdentifier;
+ token.symbol = nullptr;
+ idToken = token;
+
+ advanceToken();
+
+ return true;
}
// compilationUnit
@@ -131,7 +146,7 @@ bool HlslGrammar::acceptCompilationUnit()
}
// sampler_state
-// : LEFT_BRACE [sampler_state_assignment ... ] RIGHT_BRACE
+// : LEFT_BRACE [sampler_state_assignment ... ] RIGHT_BRACE
//
// sampler_state_assignment
// : sampler_state_identifier EQUAL value SEMICOLON
@@ -156,7 +171,7 @@ bool HlslGrammar::acceptSamplerState()
return true;
parseContext.warn(token.loc, "unimplemented", "immediate sampler state", "");
-
+
do {
// read state name
HlslToken state;
@@ -235,7 +250,7 @@ bool HlslGrammar::acceptSamplerDeclarationDX9(TType& /*type*/)
{
if (! acceptTokenClass(EHTokSampler))
return false;
-
+
// TODO: remove this when DX9 style declarations are implemented.
unimplemented("Direct3D 9 sampler declaration");
@@ -254,7 +269,6 @@ bool HlslGrammar::acceptSamplerDeclarationDX9(TType& /*type*/)
return false;
}
-
// declaration
// : sampler_declaration_dx9 post_decls SEMICOLON
// | fully_specified_type declarator_list SEMICOLON
@@ -297,7 +311,7 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& node)
// be possible to simultaneously compile D3D10+ style shaders and DX9 shaders. If we want to compile DX9
// HLSL shaders, this will have to be a master level switch
// As such, the sampler keyword in D3D10+ turns into an automatic sampler type, and is commonly used
- // For that reason, this line is commented out
+ // For that reason, this line is commented out
// if (acceptSamplerDeclarationDX9(declaredType))
// return true;
@@ -337,7 +351,7 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& node)
if (declaredType.getQualifier().storage == EvqTemporary && parseContext.symbolTable.atGlobalLevel())
declaredType.getQualifier().storage = EvqUniform;
- // We can handle multiple variables per type declaration, so
+ // We can handle multiple variables per type declaration, so
// the number of types can expand when arrayness is different.
TType variableType;
variableType.shallowCopy(declaredType);
@@ -418,10 +432,18 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& node)
// SEMICOLON
if (! acceptTokenClass(EHTokSemicolon)) {
- expected(";");
+ // This may have been a false detection of what appeared to be a declaration, but
+ // was actually an assignment such as "float = 4", where "float" is an identifier.
+ // We put the token back to let further parsing happen for cases where that may
+ // happen. This errors on the side of caution, and mostly triggers the error.
+
+ if (peek() == EHTokAssign || peek() == EHTokLeftBracket || peek() == EHTokDot || peek() == EHTokComma)
+ recedeToken();
+ else
+ expected(";");
return false;
}
-
+
return true;
}
@@ -478,7 +500,7 @@ bool HlslGrammar::acceptFullySpecifiedType(TType& type)
// type_specifier
if (! acceptType(type)) {
// If this is not a type, we may have inadvertently gone down a wrong path
- // py parsing "sample", which can be treated like either an identifier or a
+ // by parsing "sample", which can be treated like either an identifier or a
// qualifier. Back it out, if we did.
if (qualifier.sample)
recedeToken();
@@ -597,13 +619,13 @@ bool HlslGrammar::acceptQualifier(TQualifier& qualifier)
qualifier.storage = EvqIn;
if (!parseContext.handleInputGeometry(token.loc, ElgLinesAdjacency))
return false;
- break;
+ break;
case EHTokTriangleAdj:
qualifier.storage = EvqIn;
if (!parseContext.handleInputGeometry(token.loc, ElgTrianglesAdjacency))
return false;
- break;
-
+ break;
+
default:
return true;
}
@@ -790,7 +812,7 @@ bool HlslGrammar::acceptMatrixTemplateType(TType& type)
expected(",");
return false;
}
-
+
// integer cols
if (! peekTokenClass(EHTokIntConstant)) {
expected("literal integer");
@@ -847,7 +869,7 @@ bool HlslGrammar::acceptStreamOutTemplateType(TType& type, TLayoutGeometry& geom
if (! acceptTokenClass(EHTokLeftAngle))
return false;
-
+
if (! acceptType(type)) {
expected("stream output type");
return false;
@@ -862,7 +884,7 @@ bool HlslGrammar::acceptStreamOutTemplateType(TType& type, TLayoutGeometry& geom
return true;
}
-
+
// annotations
// : LEFT_ANGLE declaration SEMI_COLON ... declaration SEMICOLON RIGHT_ANGLE
//
@@ -970,7 +992,7 @@ bool HlslGrammar::acceptTextureType(TType& type)
case EHTokTexture1darray: dim = Esd1D; array = true; break;
case EHTokTexture2d: dim = Esd2D; break;
case EHTokTexture2darray: dim = Esd2D; array = true; break;
- case EHTokTexture3d: dim = Esd3D; break;
+ case EHTokTexture3d: dim = Esd3D; break;
case EHTokTextureCube: dim = EsdCube; break;
case EHTokTextureCubearray: dim = EsdCube; array = true; break;
case EHTokTexture2DMS: dim = Esd2D; ms = true; break;
@@ -988,7 +1010,7 @@ bool HlslGrammar::acceptTextureType(TType& type)
advanceToken(); // consume the texture object keyword
TType txType(EbtFloat, EvqUniform, 4); // default type is float4
-
+
TIntermTyped* msCount = nullptr;
// texture type: required for multisample types and RWBuffer/RWTextures!
@@ -1069,14 +1091,13 @@ bool HlslGrammar::acceptTextureType(TType& type)
// Remember the declared vector size.
sampler.vectorSize = txType.getVectorSize();
-
+
type.shallowCopy(TType(sampler, EvqUniform, arraySizes));
type.getQualifier().layoutFormat = format;
return true;
}
-
// If token is for a type, update 'type' with the type information,
// and return true and advance.
// Otherwise, return false, and don't advance
@@ -1086,6 +1107,7 @@ bool HlslGrammar::acceptType(TType& type)
// changes, e.g, to use native halfs.
static const TBasicType min16float_bt = EbtFloat;
static const TBasicType min10float_bt = EbtFloat;
+ static const TBasicType half_bt = EbtFloat;
static const TBasicType min16int_bt = EbtInt;
static const TBasicType min12int_bt = EbtInt;
static const TBasicType min16uint_bt = EbtUint;
@@ -1109,7 +1131,7 @@ bool HlslGrammar::acceptType(TType& type)
if (! parseContext.handleOutputGeometry(token.loc, geometry))
return false;
-
+
return true;
}
@@ -1237,7 +1259,6 @@ bool HlslGrammar::acceptType(TType& type)
new(&type) TType(EbtUint, EvqTemporary, 4);
break;
-
case EHTokBool:
new(&type) TType(EbtBool);
break;
@@ -1255,6 +1276,23 @@ bool HlslGrammar::acceptType(TType& type)
new(&type) TType(EbtBool, EvqTemporary, 4);
break;
+ case EHTokHalf:
+ new(&type) TType(half_bt, EvqTemporary, EpqMedium);
+ break;
+ case EHTokHalf1:
+ new(&type) TType(half_bt, EvqTemporary, EpqMedium);
+ type.makeVector();
+ break;
+ case EHTokHalf2:
+ new(&type) TType(half_bt, EvqTemporary, EpqMedium, 2);
+ break;
+ case EHTokHalf3:
+ new(&type) TType(half_bt, EvqTemporary, EpqMedium, 3);
+ break;
+ case EHTokHalf4:
+ new(&type) TType(half_bt, EvqTemporary, EpqMedium, 4);
+ break;
+
case EHTokMin16float:
new(&type) TType(min16float_bt, EvqTemporary, EpqMedium);
break;
@@ -1271,7 +1309,7 @@ bool HlslGrammar::acceptType(TType& type)
case EHTokMin16float4:
new(&type) TType(min16float_bt, EvqTemporary, EpqMedium, 4);
break;
-
+
case EHTokMin10float:
new(&type) TType(min10float_bt, EvqTemporary, EpqMedium);
break;
@@ -1288,7 +1326,7 @@ bool HlslGrammar::acceptType(TType& type)
case EHTokMin10float4:
new(&type) TType(min10float_bt, EvqTemporary, EpqMedium, 4);
break;
-
+
case EHTokMin16int:
new(&type) TType(min16int_bt, EvqTemporary, EpqMedium);
break;
@@ -1305,7 +1343,7 @@ bool HlslGrammar::acceptType(TType& type)
case EHTokMin16int4:
new(&type) TType(min16int_bt, EvqTemporary, EpqMedium, 4);
break;
-
+
case EHTokMin12int:
new(&type) TType(min12int_bt, EvqTemporary, EpqMedium);
break;
@@ -1322,7 +1360,7 @@ bool HlslGrammar::acceptType(TType& type)
case EHTokMin12int4:
new(&type) TType(min12int_bt, EvqTemporary, EpqMedium, 4);
break;
-
+
case EHTokMin16uint:
new(&type) TType(min16uint_bt, EvqTemporary, EpqMedium);
break;
@@ -1683,6 +1721,7 @@ bool HlslGrammar::acceptStruct(TType& type)
bool HlslGrammar::acceptStructDeclarationList(TTypeList*& typeList)
{
typeList = new TTypeList();
+ HlslToken idToken;
do {
// success on seeing the RIGHT_BRACE coming up
@@ -1700,8 +1739,7 @@ bool HlslGrammar::acceptStructDeclarationList(TTypeList*& typeList)
// struct_declarator COMMA struct_declarator ...
do {
- // peek IDENTIFIER
- if (! peekTokenClass(EHTokIdentifier)) {
+ if (! acceptIdentifier(idToken)) {
expected("member name");
return false;
}
@@ -1709,12 +1747,9 @@ bool HlslGrammar::acceptStructDeclarationList(TTypeList*& typeList)
// add it to the list of members
TTypeLoc member = { new TType(EbtVoid), token.loc };
member.type->shallowCopy(memberType);
- member.type->setFieldName(*token.string);
+ member.type->setFieldName(*idToken.string);
typeList->push_back(member);
- // accept IDENTIFIER
- advanceToken();
-
// array_specifier
TArraySizes* arraySizes = nullptr;
acceptArraySpecifier(arraySizes);
@@ -1723,6 +1758,16 @@ bool HlslGrammar::acceptStructDeclarationList(TTypeList*& typeList)
acceptPostDecls(member.type->getQualifier());
+ // EQUAL assignment_expression
+ if (acceptTokenClass(EHTokAssign)) {
+ parseContext.warn(idToken.loc, "struct-member initializers ignored", "typedef", "");
+ TIntermTyped* expressionNode = nullptr;
+ if (! acceptAssignmentExpression(expressionNode)) {
+ expected("initializer");
+ return false;
+ }
+ }
+
// success on seeing the SEMICOLON coming up
if (peekTokenClass(EHTokSemicolon))
break;
@@ -1776,9 +1821,54 @@ bool HlslGrammar::acceptFunctionParameters(TFunction& function)
return true;
}
+// default_parameter_declaration
+// : EQUAL conditional_expression
+// : EQUAL initializer
+bool HlslGrammar::acceptDefaultParameterDeclaration(const TType& type, TIntermTyped*& node)
+{
+ node = nullptr;
+
+ // Valid not to have a default_parameter_declaration
+ if (!acceptTokenClass(EHTokAssign))
+ return true;
+
+ if (!acceptConditionalExpression(node)) {
+ if (!acceptInitializer(node))
+ return false;
+
+ // For initializer lists, we have to const-fold into a constructor for the type, so build
+ // that.
+ TFunction* constructor = parseContext.handleConstructorCall(token.loc, type);
+ if (constructor == nullptr) // cannot construct
+ return false;
+
+ TIntermTyped* arguments = nullptr;
+ for (int i = 0; i < int(node->getAsAggregate()->getSequence().size()); i++)
+ parseContext.handleFunctionArgument(constructor, arguments, node->getAsAggregate()->getSequence()[i]->getAsTyped());
+
+ node = parseContext.handleFunctionCall(token.loc, constructor, node);
+ }
+
+ // If this is simply a constant, we can use it directly.
+ if (node->getAsConstantUnion())
+ return true;
+
+ // Otherwise, it has to be const-foldable.
+ TIntermTyped* origNode = node;
+
+ node = intermediate.fold(node->getAsAggregate());
+
+ if (node != nullptr && origNode != node)
+ return true;
+
+ parseContext.error(token.loc, "invalid default parameter value", "", "");
+
+ return false;
+}
+
// parameter_declaration
-// : fully_specified_type post_decls
-// | fully_specified_type identifier array_specifier post_decls
+// : fully_specified_type post_decls [ = default_parameter_declaration ]
+// | fully_specified_type identifier array_specifier post_decls [ = default_parameter_declaration ]
//
bool HlslGrammar::acceptParameterDeclaration(TFunction& function)
{
@@ -1806,9 +1896,19 @@ bool HlslGrammar::acceptParameterDeclaration(TFunction& function)
// post_decls
acceptPostDecls(type->getQualifier());
+ TIntermTyped* defaultValue;
+ if (!acceptDefaultParameterDeclaration(*type, defaultValue))
+ return false;
+
parseContext.paramFix(*type);
- TParameter param = { idToken.string, type };
+ // If any prior parameters have default values, all the parameters after that must as well.
+ if (defaultValue == nullptr && function.getDefaultParamCount() > 0) {
+ parseContext.error(idToken.loc, "invalid parameter after default value parameters", idToken.string->c_str(), "");
+ return false;
+ }
+
+ TParameter param = { idToken.string, type, defaultValue };
function.addParameter(param);
return true;
@@ -2149,7 +2249,7 @@ bool HlslGrammar::acceptUnaryExpression(TIntermTyped*& node)
// peek for "op unary_expression"
TOperator unaryOp = HlslOpMap::preUnary(peek());
-
+
// postfix_expression (if no unary operator)
if (unaryOp == EOpNull)
return acceptPostfixExpression(node);
@@ -2205,7 +2305,7 @@ bool HlslGrammar::acceptPostfixExpression(TIntermTyped*& node)
return false;
}
} else if (acceptLiteral(node)) {
- // literal (nothing else to do yet), go on to the
+ // literal (nothing else to do yet), go on to the
} else if (acceptConstructor(node)) {
// constructor (nothing else to do yet)
} else if (acceptIdentifier(idToken)) {
@@ -2229,6 +2329,8 @@ bool HlslGrammar::acceptPostfixExpression(TIntermTyped*& node)
tFinalize(HlslParseContext& p) : parseContext(p) { }
~tFinalize() { parseContext.finalizeFlattening(); }
HlslParseContext& parseContext;
+ private:
+ tFinalize& operator=(tFinalize&) { return *this; }
} finalize(parseContext);
// Initialize the flattening accumulation data, so we can track data across multiple bracket or
@@ -2322,7 +2424,9 @@ bool HlslGrammar::acceptConstructor(TIntermTyped*& node)
// arguments
TIntermTyped* arguments = nullptr;
if (! acceptArguments(constructorFunction, arguments)) {
- expected("constructor arguments");
+ // It's possible this is a type keyword used as an identifier. Put the token back
+ // for later use.
+ recedeToken();
return false;
}
@@ -2607,7 +2711,7 @@ void HlslGrammar::acceptAttributes(TAttributeMap& attributes)
TIntermTyped* node;
bool expectingExpression = false;
-
+
while (acceptAssignmentExpression(node)) {
expectingExpression = false;
expressions->getSequence().push_back(node);
@@ -2894,7 +2998,7 @@ bool HlslGrammar::acceptJumpStatement(TIntermNode*& statement)
// SEMICOLON
if (! acceptTokenClass(EHTokSemicolon))
expected(";");
-
+
return true;
}
@@ -2990,7 +3094,7 @@ void HlslGrammar::acceptArraySpecifier(TArraySizes*& arraySizes)
void HlslGrammar::acceptPostDecls(TQualifier& qualifier)
{
do {
- // COLON
+ // COLON
if (acceptTokenClass(EHTokColon)) {
HlslToken idToken;
if (peekTokenClass(EHTokLayout))
diff --git a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslGrammar.h b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslGrammar.h
index 8804b217ec7..29e4b1763f8 100644
--- a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslGrammar.h
+++ b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslGrammar.h
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2016 Google, Inc.
-//Copyright (C) 2016 LunarG, Inc.
+// Copyright (C) 2016 Google, Inc.
+// Copyright (C) 2016 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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.
//
#ifndef HLSLGRAMMAR_H_
@@ -44,7 +44,7 @@
namespace glslang {
class TAttributeMap; // forward declare
-
+
// Should just be the grammar aspect of HLSL.
// Described in more detail in hlslGrammar.cpp.
@@ -111,6 +111,7 @@ namespace glslang {
bool acceptDefaultLabel(TIntermNode*&);
void acceptArraySpecifier(TArraySizes*&);
void acceptPostDecls(TQualifier&);
+ bool acceptDefaultParameterDeclaration(const TType&, TIntermTyped*&);
HlslParseContext& parseContext; // state of parsing and helper functions for building the intermediate
TIntermediate& intermediate; // the final product, the intermediate representation, includes the AST
diff --git a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslOpMap.cpp b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslOpMap.cpp
index 524e66a2a2e..ba56eeb604c 100644
--- a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslOpMap.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslOpMap.cpp
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2016 Google, Inc.
+// Copyright (C) 2016 Google, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
// Map from physical token form (e.g. '-') to logical operator
@@ -99,7 +99,7 @@ TOperator HlslOpMap::preUnary(EHlslTokenClass op)
case EHTokDash: return EOpNegative;
case EHTokBang: return EOpLogicalNot;
case EHTokTilde: return EOpBitwiseNot;
-
+
case EHTokIncOp: return EOpPreIncrement;
case EHTokDecOp: return EOpPreDecrement;
@@ -114,7 +114,7 @@ TOperator HlslOpMap::postUnary(EHlslTokenClass op)
switch (op) {
case EHTokDot: return EOpIndexDirectStruct;
case EHTokLeftBracket: return EOpIndexIndirect;
-
+
case EHTokIncOp: return EOpPostIncrement;
case EHTokDecOp: return EOpPostDecrement;
diff --git a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslOpMap.h b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslOpMap.h
index 924637878c8..4e783f3f0c4 100644
--- a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslOpMap.h
+++ b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslOpMap.h
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2016 Google, Inc.
+// Copyright (C) 2016 Google, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
#ifndef HLSLOPMAP_H_
diff --git a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslParseHelper.cpp b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslParseHelper.cpp
index 62dac4bfa57..fca8452ab04 100644
--- a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslParseHelper.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslParseHelper.cpp
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2016 Google, Inc.
-//Copyright (C) 2016 LunarG, Inc.
+// Copyright (C) 2016 Google, Inc.
+// Copyright (C) 2016 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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 "hlslParseHelper.h"
@@ -47,6 +47,7 @@
#include <algorithm>
#include <functional>
#include <cctype>
+#include <array>
namespace glslang {
@@ -57,9 +58,12 @@ HlslParseContext::HlslParseContext(TSymbolTable& symbolTable, TIntermediate& int
TParseContextBase(symbolTable, interm, parsingBuiltins, version, profile, spvVersion, language, infoSink, forwardCompatible, messages),
contextPragma(true, false),
loopNestingLevel(0), annotationNestingLevel(0), structNestingLevel(0), controlFlowNestingLevel(0),
+ inEntryPoint(false),
postEntryPointReturn(false),
limits(resources.limits),
entryPointOutput(nullptr),
+ builtInIoIndex(nullptr),
+ builtInIoBase(nullptr),
nextInLocation(0), nextOutLocation(0),
sourceEntryPointName(sourceEntryPointName)
{
@@ -74,7 +78,7 @@ HlslParseContext::HlslParseContext(TSymbolTable& symbolTable, TIntermediate& int
globalInputDefaults.clear();
globalOutputDefaults.clear();
- // "Shaders in the transform
+ // "Shaders in the transform
// feedback capturing mode have an initial global default of
// layout(xfb_buffer = 0) out;"
if (language == EShLangVertex ||
@@ -144,6 +148,12 @@ bool HlslParseContext::shouldConvertLValue(const TIntermNode* node) const
return false;
const TIntermAggregate* lhsAsAggregate = node->getAsAggregate();
+ const TIntermBinary* lhsAsBinary = node->getAsBinaryNode();
+
+ // If it's a swizzled/indexed aggregate, look at the left node instead.
+ if (lhsAsBinary != nullptr &&
+ (lhsAsBinary->getOp() == EOpVectorSwizzle || lhsAsBinary->getOp() == EOpIndexDirect))
+ lhsAsAggregate = lhsAsBinary->getLeft()->getAsAggregate();
if (lhsAsAggregate != nullptr && lhsAsAggregate->getOp() == EOpImageLoad)
return true;
@@ -189,7 +199,7 @@ bool HlslParseContext::lValueErrorCheck(const TSourceLoc& loc, const char* op, T
TIntermAggregate* lhsAsAggregate = node->getAsAggregate();
TIntermTyped* object = lhsAsAggregate->getSequence()[0]->getAsTyped();
-
+
if (!object->getType().getSampler().isImage()) {
error(loc, "operator[] on a non-RW texture must be an r-value", "", "");
return true;
@@ -207,7 +217,7 @@ bool HlslParseContext::lValueErrorCheck(const TSourceLoc& loc, const char* op, T
// series of other image operations.
//
// Most things are passed through unmodified, except for error checking.
-//
+//
TIntermTyped* HlslParseContext::handleLvalue(const TSourceLoc& loc, const char* op, TIntermTyped* node)
{
if (node == nullptr)
@@ -282,14 +292,59 @@ TIntermTyped* HlslParseContext::handleLvalue(const TSourceLoc& loc, const char*
loc);
};
+ // Return true if swizzle or index writes all components of the given variable.
+ const auto writesAllComponents = [&](TIntermSymbol* var, TIntermBinary* swizzle) -> bool {
+ if (swizzle == nullptr) // not a swizzle or index
+ return true;
+
+ // Track which components are being set.
+ std::array<bool, 4> compIsSet;
+ compIsSet.fill(false);
+
+ const TIntermConstantUnion* asConst = swizzle->getRight()->getAsConstantUnion();
+ const TIntermAggregate* asAggregate = swizzle->getRight()->getAsAggregate();
+
+ // This could be either a direct index, or a swizzle.
+ if (asConst) {
+ compIsSet[asConst->getConstArray()[0].getIConst()] = true;
+ } else if (asAggregate) {
+ const TIntermSequence& seq = asAggregate->getSequence();
+ for (int comp=0; comp<int(seq.size()); ++comp)
+ compIsSet[seq[comp]->getAsConstantUnion()->getConstArray()[0].getIConst()] = true;
+ } else {
+ assert(0);
+ }
+
+ // Return true if all components are being set by the index or swizzle
+ return std::all_of(compIsSet.begin(), compIsSet.begin() + var->getType().getVectorSize(),
+ [](bool isSet) { return isSet; } );
+ };
+
// helper to create a temporary variable
const auto addTmpVar = [&](const char* name, const TType& derefType) -> TIntermSymbol* {
TVariable* tmpVar = makeInternalVariable(name, derefType);
tmpVar->getWritableType().getQualifier().makeTemporary();
return intermediate.addSymbol(*tmpVar, loc);
};
-
+
+ // Create swizzle matching input swizzle
+ const auto addSwizzle = [&](TIntermSymbol* var, TIntermBinary* swizzle) -> TIntermTyped* {
+ if (swizzle)
+ return intermediate.addBinaryNode(swizzle->getOp(), var, swizzle->getRight(), loc, swizzle->getType());
+ else
+ return var;
+ };
+
+ TIntermBinary* lhsAsBinary = lhs->getAsBinaryNode();
TIntermAggregate* lhsAsAggregate = lhs->getAsAggregate();
+ bool lhsIsSwizzle = false;
+
+ // If it's a swizzled L-value, remember the swizzle, and use the LHS.
+ if (lhsAsBinary != nullptr && (lhsAsBinary->getOp() == EOpVectorSwizzle || lhsAsBinary->getOp() == EOpIndexDirect)) {
+ lhsAsAggregate = lhsAsBinary->getLeft()->getAsAggregate();
+ lhsIsSwizzle = true;
+ }
+
TIntermTyped* object = lhsAsAggregate->getSequence()[0]->getAsTyped();
TIntermTyped* coord = lhsAsAggregate->getSequence()[1]->getAsTyped();
@@ -339,13 +394,23 @@ TIntermTyped* HlslParseContext::handleLvalue(const TSourceLoc& loc, const char*
// rhsTmp op= rhs
// OpImageStore(object, coordTmp, rhsTmp)
// rhsTmp
+ //
+ // If the lvalue is swizzled, we apply that when writing the temp variable, like so:
+ // ...
+ // rhsTmp.some_swizzle = ...
+ // For partial writes, an error is generated.
TIntermSymbol* rhsTmp = rhs->getAsSymbolNode();
TIntermTyped* coordTmp = coord;
-
- if (rhsTmp == nullptr || isModifyOp) {
+
+ if (rhsTmp == nullptr || isModifyOp || lhsIsSwizzle) {
rhsTmp = addTmpVar("storeTemp", objDerefType);
+ // Partial updates not yet supported
+ if (!writesAllComponents(rhsTmp, lhsAsBinary)) {
+ error(loc, "unimplemented: partial image updates", "", "");
+ }
+
// Assign storeTemp = rhs
if (isModifyOp) {
// We have to make a temp var for the coordinate, to avoid evaluating it twice.
@@ -355,9 +420,9 @@ TIntermTyped* HlslParseContext::handleLvalue(const TSourceLoc& loc, const char*
}
// rhsTmp op= rhs.
- makeBinary(assignOp, intermediate.addSymbol(*rhsTmp), rhs);
+ makeBinary(assignOp, addSwizzle(intermediate.addSymbol(*rhsTmp), lhsAsBinary), rhs);
}
-
+
makeStore(object, coordTmp, rhsTmp); // add a store
return finishSequence(rhsTmp, objDerefType); // return rhsTmp from sequence
}
@@ -381,10 +446,10 @@ TIntermTyped* HlslParseContext::handleLvalue(const TSourceLoc& loc, const char*
// rhsTmp op
// OpImageStore(object, coordTmp, rhsTmp)
// rhsTmp
-
+
TIntermSymbol* rhsTmp = addTmpVar("storeTemp", objDerefType);
TIntermTyped* coordTmp = addTmpVar("coordTemp", coord->getType());
-
+
makeBinary(EOpAssign, coordTmp, coord); // coordtmp = load[param1]
makeLoad(rhsTmp, object, coordTmp, objDerefType); // rhsTmp = OpImageLoad(object, coordTmp)
makeUnary(assignOp, rhsTmp); // op rhsTmp
@@ -414,7 +479,7 @@ TIntermTyped* HlslParseContext::handleLvalue(const TSourceLoc& loc, const char*
makeStore(object, coordTmp, rhsTmp2); // OpImageStore(object, coordTmp, rhsTmp2)
return finishSequence(rhsTmp1, objDerefType); // return rhsTmp from sequence
}
-
+
default:
break;
}
@@ -423,7 +488,7 @@ TIntermTyped* HlslParseContext::handleLvalue(const TSourceLoc& loc, const char*
if (lhs)
if (lValueErrorCheck(loc, op, lhs))
return nullptr;
-
+
return node;
}
@@ -437,97 +502,87 @@ void HlslParseContext::handlePragma(const TSourceLoc& loc, const TVector<TString
}
//
-// Look at a '.' field selector string and change it into offsets
-// for a vector or scalar
+// Look at a '.' matrix selector string and change it into components
+// for a matrix. There are two types:
+//
+// _21 second row, first column (one based)
+// _m21 third row, second column (zero based)
//
// Returns true if there is no error.
//
-bool HlslParseContext::parseVectorFields(const TSourceLoc& loc, const TString& compString, int vecSize, TVectorFields& fields)
+bool HlslParseContext::parseMatrixSwizzleSelector(const TSourceLoc& loc, const TString& fields, int cols, int rows,
+ TSwizzleSelectors<TMatrixSelector>& components)
{
- fields.num = (int)compString.size();
- if (fields.num > 4) {
- error(loc, "illegal vector field selection", compString.c_str(), "");
- return false;
- }
-
- enum {
- exyzw,
- ergba,
- estpq,
- } fieldSet[4];
-
- for (int i = 0; i < fields.num; ++i) {
- switch (compString[i]) {
- case 'x':
- fields.offsets[i] = 0;
- fieldSet[i] = exyzw;
- break;
- case 'r':
- fields.offsets[i] = 0;
- fieldSet[i] = ergba;
- break;
- case 's':
- fields.offsets[i] = 0;
- fieldSet[i] = estpq;
- break;
- case 'y':
- fields.offsets[i] = 1;
- fieldSet[i] = exyzw;
- break;
- case 'g':
- fields.offsets[i] = 1;
- fieldSet[i] = ergba;
- break;
- case 't':
- fields.offsets[i] = 1;
- fieldSet[i] = estpq;
- break;
- case 'z':
- fields.offsets[i] = 2;
- fieldSet[i] = exyzw;
- break;
- case 'b':
- fields.offsets[i] = 2;
- fieldSet[i] = ergba;
- break;
- case 'p':
- fields.offsets[i] = 2;
- fieldSet[i] = estpq;
- break;
-
- case 'w':
- fields.offsets[i] = 3;
- fieldSet[i] = exyzw;
- break;
- case 'a':
- fields.offsets[i] = 3;
- fieldSet[i] = ergba;
- break;
- case 'q':
- fields.offsets[i] = 3;
- fieldSet[i] = estpq;
- break;
- default:
- error(loc, "illegal vector field selection", compString.c_str(), "");
+ int startPos[MaxSwizzleSelectors];
+ int numComps = 0;
+ TString compString = fields;
+
+ // Find where each component starts,
+ // recording the first character position after the '_'.
+ for (size_t c = 0; c < compString.size(); ++c) {
+ if (compString[c] == '_') {
+ if (numComps >= MaxSwizzleSelectors) {
+ error(loc, "matrix component swizzle has too many components", compString.c_str(), "");
return false;
}
- }
-
- for (int i = 0; i < fields.num; ++i) {
- if (fields.offsets[i] >= vecSize) {
- error(loc, "vector field selection out of range", compString.c_str(), "");
+ if (c > compString.size() - 3 ||
+ ((compString[c+1] == 'm' || compString[c+1] == 'M') && c > compString.size() - 4)) {
+ error(loc, "matrix component swizzle missing", compString.c_str(), "");
return false;
}
+ startPos[numComps++] = c + 1;
+ }
+ }
- if (i > 0) {
- if (fieldSet[i] != fieldSet[i - 1]) {
- error(loc, "illegal - vector component fields not from the same set", compString.c_str(), "");
- return false;
- }
- }
+ // Process each component
+ for (int i = 0; i < numComps; ++i) {
+ int pos = startPos[i];
+ int bias = -1;
+ if (compString[pos] == 'm' || compString[pos] == 'M') {
+ bias = 0;
+ ++pos;
+ }
+ TMatrixSelector comp;
+ comp.coord1 = compString[pos+0] - '0' + bias;
+ comp.coord2 = compString[pos+1] - '0' + bias;
+ if (comp.coord1 < 0 || comp.coord1 >= cols) {
+ error(loc, "matrix row component out of range", compString.c_str(), "");
+ return false;
}
+ if (comp.coord2 < 0 || comp.coord2 >= rows) {
+ error(loc, "matrix column component out of range", compString.c_str(), "");
+ return false;
+ }
+ components.push_back(comp);
+ }
- return true;
+ return true;
+}
+
+// If the 'comps' express a column of a matrix,
+// return the column. Column means the first coords all match.
+//
+// Otherwise, return -1.
+//
+int HlslParseContext::getMatrixComponentsColumn(int rows, const TSwizzleSelectors<TMatrixSelector>& selector)
+{
+ int col = -1;
+
+ // right number of comps?
+ if (selector.size() != rows)
+ return -1;
+
+ // all comps in the same column?
+ // rows in order?
+ col = selector[0].coord1;
+ for (int i = 0; i < rows; ++i) {
+ if (col != selector[i].coord1)
+ return -1;
+ if (i != selector[i].coord2)
+ return -1;
+ }
+
+ return col;
}
//
@@ -656,11 +711,13 @@ TIntermTyped* HlslParseContext::handleBracketDereference(const TSourceLoc& loc,
if (base->getAsSymbolNode() && (wasFlattened(base) || shouldFlatten(base->getType()))) {
if (index->getQualifier().storage != EvqConst)
- error(loc, "Invalid variable index to flattened uniform array", base->getAsSymbolNode()->getName().c_str(), "");
+ error(loc, "Invalid variable index to flattened array", base->getAsSymbolNode()->getName().c_str(), "");
- result = flattenAccess(loc, base, indexValue);
+ result = flattenAccess(base, indexValue);
flattened = (result != base);
} else {
+ splitAccessArray(loc, base, index);
+
if (index->getQualifier().storage == EvqConst) {
if (base->getType().isImplicitlySizedArray())
updateImplicitArraySize(loc, base, indexValue);
@@ -729,7 +786,7 @@ TIntermTyped* HlslParseContext::handleDotDereference(const TSourceLoc& loc, TInt
//
// methods can't be resolved until we later see the function-calling syntax.
- // Save away the name in the AST for now. Processing is completed in
+ // Save away the name in the AST for now. Processing is completed in
// handleLengthMethod(), etc.
//
if (field == "length") {
@@ -765,11 +822,9 @@ TIntermTyped* HlslParseContext::handleDotDereference(const TSourceLoc& loc, TInt
}
} else if (field == "Append" ||
field == "RestartStrip") {
- // These methods only valid on stage in variables
- // TODO: ... which are stream out types, if there's any way to test that here.
- if (base->getType().getQualifier().storage == EvqVaryingOut) {
- return intermediate.addMethod(base, TType(EbtVoid), &field, loc);
- }
+ // We cannot check the type here: it may be sanitized if we're not compiling a geometry shader, but
+ // the code is around in the shader source.
+ return intermediate.addMethod(base, TType(EbtVoid), &field, loc);
}
// It's not .length() if we get to here.
@@ -785,44 +840,76 @@ TIntermTyped* HlslParseContext::handleDotDereference(const TSourceLoc& loc, TInt
TIntermTyped* result = base;
if (base->isVector() || base->isScalar()) {
- TVectorFields fields;
- if (! parseVectorFields(loc, field, base->getVectorSize(), fields)) {
- fields.num = 1;
- fields.offsets[0] = 0;
- }
+ TSwizzleSelectors<TVectorSelector> selectors;
+ parseSwizzleSelector(loc, field, base->getVectorSize(), selectors);
if (base->isScalar()) {
- if (fields.num == 1)
+ if (selectors.size() == 1)
return result;
else {
- TType type(base->getBasicType(), EvqTemporary, fields.num);
+ TType type(base->getBasicType(), EvqTemporary, selectors.size());
return addConstructor(loc, base, type);
}
}
if (base->getVectorSize() == 1) {
TType scalarType(base->getBasicType(), EvqTemporary, 1);
- if (fields.num == 1)
+ if (selectors.size() == 1)
return addConstructor(loc, base, scalarType);
else {
- TType vectorType(base->getBasicType(), EvqTemporary, fields.num);
+ TType vectorType(base->getBasicType(), EvqTemporary, selectors.size());
return addConstructor(loc, addConstructor(loc, base, scalarType), vectorType);
}
}
if (base->getType().getQualifier().isFrontEndConstant())
- result = intermediate.foldSwizzle(base, fields, loc);
+ result = intermediate.foldSwizzle(base, selectors, loc);
else {
- if (fields.num == 1) {
- TIntermTyped* index = intermediate.addConstantUnion(fields.offsets[0], loc);
+ if (selectors.size() == 1) {
+ TIntermTyped* index = intermediate.addConstantUnion(selectors[0], loc);
result = intermediate.addIndex(EOpIndexDirect, base, index, loc);
result->setType(TType(base->getBasicType(), EvqTemporary));
} else {
- TString vectorString = field;
- TIntermTyped* index = intermediate.addSwizzle(fields, loc);
+ TIntermTyped* index = intermediate.addSwizzle(selectors, loc);
result = intermediate.addIndex(EOpVectorSwizzle, base, index, loc);
- result->setType(TType(base->getBasicType(), EvqTemporary, base->getType().getQualifier().precision, (int)vectorString.size()));
+ result->setType(TType(base->getBasicType(), EvqTemporary, base->getType().getQualifier().precision, selectors.size()));
}
}
+ } else if (base->isMatrix()) {
+ TSwizzleSelectors<TMatrixSelector> selectors;
+ if (! parseMatrixSwizzleSelector(loc, field, base->getMatrixCols(), base->getMatrixRows(), selectors))
+ return result;
+
+ if (selectors.size() == 1) {
+ // Representable by m[c][r]
+ if (base->getType().getQualifier().isFrontEndConstant()) {
+ result = intermediate.foldDereference(base, selectors[0].coord1, loc);
+ result = intermediate.foldDereference(result, selectors[0].coord2, loc);
+ } else {
+ result = intermediate.addIndex(EOpIndexDirect, base, intermediate.addConstantUnion(selectors[0].coord1, loc), loc);
+ TType dereferencedCol(base->getType(), 0);
+ result->setType(dereferencedCol);
+ result = intermediate.addIndex(EOpIndexDirect, result, intermediate.addConstantUnion(selectors[0].coord2, loc), loc);
+ TType dereferenced(dereferencedCol, 0);
+ result->setType(dereferenced);
+ }
+ } else {
+ int column = getMatrixComponentsColumn(base->getMatrixRows(), selectors);
+ if (column >= 0) {
+ // Representable by m[c]
+ if (base->getType().getQualifier().isFrontEndConstant())
+ result = intermediate.foldDereference(base, column, loc);
+ else {
+ result = intermediate.addIndex(EOpIndexDirect, base, intermediate.addConstantUnion(column, loc), loc);
+ TType dereferenced(base->getType(), 0);
+ result->setType(dereferenced);
+ }
+ } else {
+ // general case, not a column, not a single component
+ TIntermTyped* index = intermediate.addSwizzle(selectors, loc);
+ result = intermediate.addIndex(EOpMatrixSwizzle, base, index, loc);
+ result->setType(TType(base->getBasicType(), EvqTemporary, base->getType().getQualifier().precision, selectors.size()));
+ }
+ }
} else if (base->getBasicType() == EbtStruct || base->getBasicType() == EbtBlock) {
const TTypeList* fields = base->getType().getStruct();
bool fieldFound = false;
@@ -834,15 +921,21 @@ TIntermTyped* HlslParseContext::handleDotDereference(const TSourceLoc& loc, TInt
}
}
if (fieldFound) {
- if (base->getAsSymbolNode() && (wasFlattened(base) || shouldFlatten(base->getType())))
- result = flattenAccess(loc, base, member);
- else {
- if (base->getType().getQualifier().storage == EvqConst)
- result = intermediate.foldDereference(base, member, loc);
- else {
- TIntermTyped* index = intermediate.addConstantUnion(member, loc);
- result = intermediate.addIndex(EOpIndexDirectStruct, base, index, loc);
- result->setType(*(*fields)[member].type);
+ if (base->getAsSymbolNode() && (wasFlattened(base) || shouldFlatten(base->getType()))) {
+ result = flattenAccess(base, member);
+ } else {
+ // Update the base and member to access if this was a split structure.
+ result = splitAccessStruct(loc, base, member);
+ fields = base->getType().getStruct();
+
+ if (result == nullptr) {
+ if (base->getType().getQualifier().storage == EvqConst)
+ result = intermediate.foldDereference(base, member, loc);
+ else {
+ TIntermTyped* index = intermediate.addConstantUnion(member, loc);
+ result = intermediate.addIndex(EOpIndexDirectStruct, base, index, loc);
+ result->setType(*(*fields)[member].type);
+ }
}
}
} else
@@ -853,10 +946,106 @@ TIntermTyped* HlslParseContext::handleDotDereference(const TSourceLoc& loc, TInt
return result;
}
+// Determine whether we should split this type
+bool HlslParseContext::shouldSplit(const TType& type)
+{
+ if (! inEntryPoint)
+ return false;
+
+ const TStorageQualifier qualifier = type.getQualifier().storage;
+
+ // If it contains interstage IO, but not ONLY interstage IO, split the struct.
+ return type.isStruct() && type.containsBuiltInInterstageIO(language) &&
+ (qualifier == EvqVaryingIn || qualifier == EvqVaryingOut);
+}
+
+// Split the type of the given node into two structs:
+// 1. interstage IO
+// 2. everything else
+// IO members are put into the ioStruct. The type is modified to remove them.
+void HlslParseContext::split(TIntermTyped* node)
+{
+ if (node == nullptr)
+ return;
+
+ TIntermSymbol* symNode = node->getAsSymbolNode();
+
+ if (symNode == nullptr)
+ return;
+
+ // Create a new variable:
+ TType& splitType = split(*symNode->getType().clone(), symNode->getName());
+
+ splitIoVars[symNode->getId()] = makeInternalVariable(symNode->getName(), splitType);
+}
+
+// Split the type of the given variable into two structs:
+void HlslParseContext::split(const TVariable& variable)
+{
+ const TType& type = variable.getType();
+
+ TString name = (&variable == entryPointOutput) ? "" : variable.getName();
+
+ // Create a new variable:
+ TType& splitType = split(*type.clone(), name);
+
+ splitIoVars[variable.getUniqueId()] = makeInternalVariable(variable.getName(), splitType);
+}
+
+// Recursive implementation of split(const TVariable& variable).
+// Returns reference to the modified type.
+TType& HlslParseContext::split(TType& type, TString name, const TType* outerStructType)
+{
+ const TArraySizes* arraySizes = nullptr;
+
+ // At the outer-most scope, remember the struct type so we can examine its storage class
+ // at deeper levels.
+ if (outerStructType == nullptr)
+ outerStructType = &type;
+
+ if (type.isArray())
+ arraySizes = &type.getArraySizes();
+
+ // We can ignore arrayness: it's uninvolved.
+ if (type.isStruct()) {
+ TTypeList* userStructure = type.getWritableStruct();
+
+ // Get iterator to (now at end) set of builtin iterstage IO members
+ const auto firstIo = std::stable_partition(userStructure->begin(), userStructure->end(),
+ [this](const TTypeLoc& t) {return !t.type->isBuiltInInterstageIO(language);});
+
+ // Move those to the builtin IO. However, we also propagate arrayness (just one level is handled
+ // now) to this variable.
+ for (auto ioType = firstIo; ioType != userStructure->end(); ++ioType) {
+ const TType& memberType = *ioType->type;
+ TVariable* ioVar = makeInternalVariable(name + (name.empty() ? "" : "_") + memberType.getFieldName(), memberType);
+
+ if (arraySizes)
+ ioVar->getWritableType().newArraySizes(*arraySizes);
+
+ interstageBuiltInIo[tInterstageIoData(memberType, *outerStructType)] = ioVar;
+
+ // Merge qualifier from the user structure
+ mergeQualifiers(ioVar->getWritableType().getQualifier(), outerStructType->getQualifier());
+ }
+
+ // Erase the IO vars from the user structure.
+ userStructure->erase(firstIo, userStructure->end());
+
+ // Recurse further into the members.
+ for (unsigned int i = 0; i < userStructure->size(); ++i)
+ split(*(*userStructure)[i].type,
+ name + (name.empty() ? "" : "_") + (*userStructure)[i].type->getFieldName(),
+ outerStructType);
+ }
+
+ return type;
+}
+
// Determine whether we should flatten an arbitrary type.
bool HlslParseContext::shouldFlatten(const TType& type) const
{
- return shouldFlattenIO(type) || shouldFlattenUniform(type);
+ return shouldFlattenIO(type) || shouldFlattenUniform(type);
}
// Is this an IO variable that can't be passed down the stack?
@@ -868,9 +1057,11 @@ bool HlslParseContext::shouldFlattenIO(const TType& type) const
const TStorageQualifier qualifier = type.getQualifier().storage;
- return type.isStruct() &&
- (qualifier == EvqVaryingIn ||
- qualifier == EvqVaryingOut);
+ if (!type.isStruct())
+ return false;
+
+ return ((language == EShLangVertex && qualifier == EvqVaryingIn) ||
+ (language == EShLangFragment && qualifier == EvqVaryingOut));
}
// Is this a uniform array which should be flattened?
@@ -888,14 +1079,13 @@ void HlslParseContext::flatten(const TSourceLoc& loc, const TVariable& variable)
{
const TType& type = variable.getType();
- // emplace gives back a pair whose .first is an iterator to the item...
- auto entry = flattenMap.emplace(variable.getUniqueId(),
- TFlattenData(type.getQualifier().layoutBinding));
-
- // ... and the item is a map pair, so first->second is the TFlattenData itself.
+ auto entry = flattenMap.insert(std::make_pair(variable.getUniqueId(),
+ TFlattenData(type.getQualifier().layoutBinding)));
+
+ // the item is a map pair, so first->second is the TFlattenData itself.
flatten(loc, variable, type, entry.first->second, "");
}
-
+
// Recursively flatten the given variable at the provided type, building the flattenData as we go.
//
// This is mutually recursive with flattenStruct and flattenArray.
@@ -904,7 +1094,7 @@ void HlslParseContext::flatten(const TSourceLoc& loc, const TVariable& variable)
// location in this linear sequence.
//
// If the tree was N-ary, that can be directly calculated. However, we are dealing with
-// arbitrary numbers - peraps a struct of 7 members containing an array of 3. Thus, we must
+// arbitrary numbers - perhaps a struct of 7 members containing an array of 3. Thus, we must
// build a data structure to allow the sequence of bracket and dot operators on arrays and
// structs to arrive at the proper member.
//
@@ -926,13 +1116,6 @@ void HlslParseContext::flatten(const TSourceLoc& loc, const TVariable& variable)
int HlslParseContext::flatten(const TSourceLoc& loc, const TVariable& variable, const TType& type,
TFlattenData& flattenData, TString name)
{
- // TODO: when struct splitting is in place we can remove this restriction.
- if (language == EShLangGeometry) {
- const TType derefType(type, 0);
- if (!isFinalFlattening(derefType) && type.getQualifier().storage == EvqVaryingIn)
- error(loc, "recursive type not yet supported in GS input", variable.getName().c_str(), "");
- }
-
// If something is an arrayed struct, the array flattener will recursively call flatten()
// to then flatten the struct, so this is an "if else": we don't do both.
if (type.isArray())
@@ -947,13 +1130,13 @@ int HlslParseContext::flatten(const TSourceLoc& loc, const TVariable& variable,
// Add a single flattened member to the flattened data being tracked for the composite
// Returns true for the final flattening level.
-int HlslParseContext::addFlattenedMember(const TSourceLoc& loc,
- const TVariable& variable, const TType& type, TFlattenData& flattenData,
+int HlslParseContext::addFlattenedMember(const TSourceLoc& loc,
+ const TVariable& variable, const TType& type, TFlattenData& flattenData,
const TString& memberName, bool track)
{
if (isFinalFlattening(type)) {
// This is as far as we flatten. Insert the variable.
- TVariable* memberVariable = makeInternalVariable(memberName.c_str(), type);
+ TVariable* memberVariable = makeInternalVariable(memberName, type);
mergeQualifiers(memberVariable->getWritableType().getQualifier(), variable.getType().getQualifier());
if (flattenData.nextBinding != TQualifier::layoutBindingEnd)
@@ -979,7 +1162,7 @@ int HlslParseContext::addFlattenedMember(const TSourceLoc& loc,
// effecting a transfer of this information to the flattened variable form.
//
// Assumes shouldFlatten() or equivalent was called first.
-int HlslParseContext::flattenStruct(const TSourceLoc& loc, const TVariable& variable, const TType& type,
+int HlslParseContext::flattenStruct(const TSourceLoc& loc, const TVariable& variable, const TType& type,
TFlattenData& flattenData, TString name)
{
assert(type.isStruct());
@@ -1009,7 +1192,7 @@ int HlslParseContext::flattenStruct(const TSourceLoc& loc, const TVariable& vari
// equivalent set of individual variables.
//
// Assumes shouldFlatten() or equivalent was called first.
-int HlslParseContext::flattenArray(const TSourceLoc& loc, const TVariable& variable, const TType& type,
+int HlslParseContext::flattenArray(const TSourceLoc& loc, const TVariable& variable, const TType& type,
TFlattenData& flattenData, TString name)
{
assert(type.isArray());
@@ -1028,7 +1211,7 @@ int HlslParseContext::flattenArray(const TSourceLoc& loc, const TVariable& varia
int pos = start;
flattenData.offsets.resize(int(pos + size), -1);
- for (int element=0; element < size; ++element) {
+ for (int element=0; element < size; ++element) {
char elementNumBuf[20]; // sufficient for MAXINT
snprintf(elementNumBuf, sizeof(elementNumBuf)-1, "[%d]", element);
const int mpos = addFlattenedMember(loc, variable, dereferencedType, flattenData,
@@ -1043,16 +1226,21 @@ int HlslParseContext::flattenArray(const TSourceLoc& loc, const TVariable& varia
// Return true if we have flattened this node.
bool HlslParseContext::wasFlattened(const TIntermTyped* node) const
{
- return node != nullptr &&
- node->getAsSymbolNode() != nullptr &&
+ return node != nullptr && node->getAsSymbolNode() != nullptr &&
wasFlattened(node->getAsSymbolNode()->getId());
}
+// Return true if we have split this structure
+bool HlslParseContext::wasSplit(const TIntermTyped* node) const
+{
+ return node != nullptr && node->getAsSymbolNode() != nullptr &&
+ wasSplit(node->getAsSymbolNode()->getId());
+}
// Turn an access into an aggregate that was flattened to instead be
// an access to the individual variable the member was flattened to.
// Assumes shouldFlatten() or equivalent was called first.
-TIntermTyped* HlslParseContext::flattenAccess(const TSourceLoc&, TIntermTyped* base, int member)
+TIntermTyped* HlslParseContext::flattenAccess(TIntermTyped* base, int member)
{
const TType dereferencedType(base->getType(), member); // dereferenced type
@@ -1078,6 +1266,114 @@ TIntermTyped* HlslParseContext::flattenAccess(const TSourceLoc&, TIntermTyped* b
}
}
+// Find and return the split IO TVariable for id, or nullptr if none.
+TVariable* HlslParseContext::getSplitIoVar(int id) const
+{
+ const auto splitIoVar = splitIoVars.find(id);
+
+ if (splitIoVar == splitIoVars.end())
+ return nullptr;
+
+ return splitIoVar->second;
+}
+
+// Find and return the split IO TVariable for variable, or nullptr if none.
+TVariable* HlslParseContext::getSplitIoVar(const TVariable* var) const
+{
+ if (var == nullptr)
+ return nullptr;
+
+ return getSplitIoVar(var->getUniqueId());
+}
+
+// Find and return the split IO TVariable for symbol in this node, or nullptr if none.
+TVariable* HlslParseContext::getSplitIoVar(const TIntermTyped* node) const
+{
+ if (node == nullptr)
+ return nullptr;
+
+ const TIntermSymbol* symbolNode = node->getAsSymbolNode();
+
+ if (symbolNode == nullptr)
+ return nullptr;
+
+ return getSplitIoVar(symbolNode->getId());
+}
+
+// Remember the index used to dereference into this structure, in case it has to be moved to a
+// split-off builtin IO member.
+void HlslParseContext::splitAccessArray(const TSourceLoc& loc, TIntermTyped* base, TIntermTyped* index)
+{
+ const TVariable* splitIoVar = getSplitIoVar(base);
+
+ // Not a split structure
+ if (splitIoVar == nullptr)
+ return;
+
+ if (builtInIoBase) {
+ error(loc, "only one array dimension supported for builtIn IO variable", "", "");
+ return;
+ }
+
+ builtInIoBase = base;
+ builtInIoIndex = index;
+}
+
+// Turn an access into an struct that was split to instead be an
+// access to either the modified structure, or a direct reference to
+// one of the split member variables.
+TIntermTyped* HlslParseContext::splitAccessStruct(const TSourceLoc& loc, TIntermTyped*& base, int& member)
+{
+ // nothing to do
+ if (base == nullptr)
+ return nullptr;
+
+ // We have a pending bracket reference to an outer struct that we may want to move to an inner member.
+ if (builtInIoBase)
+ base = builtInIoBase;
+
+ const TVariable* splitIoVar = getSplitIoVar(base);
+
+ if (splitIoVar == nullptr)
+ return nullptr;
+
+ const TTypeList& members = *base->getType().getStruct();
+
+ const TType& memberType = *members[member].type;
+
+ if (memberType.isBuiltInInterstageIO(language)) {
+ // It's one of the interstage IO variables we split off.
+ TIntermTyped* builtIn = intermediate.addSymbol(*interstageBuiltInIo[tInterstageIoData(memberType, base->getType())], loc);
+
+ // If there's an array reference to an outer split struct, we re-apply it here.
+ if (builtInIoIndex != nullptr) {
+ if (builtInIoIndex->getQualifier().storage == EvqConst)
+ builtIn = intermediate.addIndex(EOpIndexDirect, builtIn, builtInIoIndex, loc);
+ else
+ builtIn = intermediate.addIndex(EOpIndexIndirect, builtIn, builtInIoIndex, loc);
+
+ builtIn->setType(memberType);
+
+ builtInIoIndex = nullptr;
+ builtInIoBase = nullptr;
+ }
+
+ return builtIn;
+ } else {
+ // It's not an IO variable. Find the equivalent index into the new variable.
+ base = intermediate.addSymbol(*splitIoVar, loc);
+
+ int newMember = 0;
+ for (int m=0; m<member; ++m)
+ if (!members[m].type->isBuiltInInterstageIO(language))
+ ++newMember;
+
+ member = newMember;
+
+ return nullptr;
+ }
+}
+
// Variables that correspond to the user-interface in and out of a stage
// (not the built-in interface) are assigned locations and
// registered as a linkage node (part of the stage's external interface).
@@ -1105,8 +1401,17 @@ void HlslParseContext::assignLocations(TVariable& variable)
auto& memberList = flattenMap[variable.getUniqueId()].members;
for (auto member = memberList.begin(); member != memberList.end(); ++member)
assignLocation(**member);
- } else
+ } else if (wasSplit(variable.getUniqueId())) {
+ TVariable* splitIoVar = getSplitIoVar(&variable);
+ const TTypeList* structure = splitIoVar->getType().getStruct();
+ // Struct splitting can produce empty structures if the only members of the
+ // struct were builtin interstage IO types. Only assign locations if it
+ // isn't a struct, or is a non-empty struct.
+ if (structure == nullptr || !structure->empty())
+ assignLocation(*splitIoVar);
+ } else {
assignLocation(variable);
+ }
}
//
@@ -1150,11 +1455,97 @@ TFunction& HlslParseContext::handleFunctionDeclarator(const TSourceLoc& loc, TFu
return function;
}
+// Add interstage IO variables to the linkage in canonical order.
+void HlslParseContext::addInterstageIoToLinkage()
+{
+ TSourceLoc loc;
+ loc.init();
+
+ std::vector<tInterstageIoData> io;
+ io.reserve(interstageBuiltInIo.size());
+
+ for (auto ioVar = interstageBuiltInIo.begin(); ioVar != interstageBuiltInIo.end(); ++ioVar)
+ io.push_back(ioVar->first);
+
+ // Our canonical order is the TBuiltInVariable numeric order.
+ std::sort(io.begin(), io.end());
+
+ // We have to (potentially) track two IO blocks, one in, one out. E.g, a GS may have a
+ // PerVertex block in both directions, possibly with different members.
+ static const TStorageQualifier ioType[2] = { EvqVaryingIn, EvqVaryingOut };
+ static const char* blockName[2] = { "PerVertex_in", "PerVertex_out" };
+
+ TTypeList* ioBlockTypes[2] = { nullptr, nullptr };
+ TArraySizes* ioBlockArray[2] = { nullptr, nullptr };
+
+ for (int idx = 0; idx < int(io.size()); ++idx) {
+ TVariable* var = interstageBuiltInIo[io[idx]];
+
+ // Add the loose interstage IO to the linkage
+ if (var->getType().isLooseAndBuiltIn(language))
+ trackLinkageDeferred(*var);
+
+ // Add the PerVertex interstage IO to the IO block
+ if (var->getType().isPerVertexAndBuiltIn(language)) {
+ int blockId = 0;
+ switch (var->getType().getQualifier().storage) {
+ case EvqVaryingIn: blockId = 0; break;
+ case EvqVaryingOut: blockId = 1; break;
+ default: assert(0 && "Invalid storage qualifier");
+ }
+
+ // Lazy creation of type list only if we end up needing it.
+ if (ioBlockTypes[blockId] == nullptr)
+ ioBlockTypes[blockId] = new TTypeList();
+
+ TTypeLoc member = { new TType(EbtVoid), loc };
+ member.type->shallowCopy(var->getType());
+ member.type->setFieldName(var->getName());
+
+ // We may have collected these from different parts of different structures. If their
+ // array dimensions are not the same, we don't know what to do, so issue an error.
+ if (member.type->isArray()) {
+ if (ioBlockArray[blockId] == nullptr) {
+ ioBlockArray[blockId] = &member.type->getArraySizes();
+ } else {
+ if (*ioBlockArray[blockId] != member.type->getArraySizes())
+ error(loc, "PerVertex block array dimension mismatch", "", "");
+ }
+ member.type->clearArraySizes();
+ }
+
+ ioBlockTypes[blockId]->push_back(member);
+ }
+ }
+
+ // If there were PerVertex items, add the block to the linkage. Handle in and out separately.
+ for (int blockId = 0; blockId <= 1; ++blockId) {
+ if (ioBlockTypes[blockId] != nullptr) {
+ const TString* instanceName = NewPoolTString(blockName[blockId]);
+ TQualifier blockQualifier;
+
+ blockQualifier.clear();
+ blockQualifier.storage = ioType[blockId];
+
+ TType blockType(ioBlockTypes[blockId], *instanceName, blockQualifier);
+
+ if (ioBlockArray[blockId] != nullptr)
+ blockType.newArraySizes(*ioBlockArray[blockId]);
+
+ TVariable* ioBlock = new TVariable(instanceName, blockType);
+ if (!symbolTable.insert(*ioBlock))
+ error(loc, "block instance name redefinition", ioBlock->getName().c_str(), "");
+ else
+ trackLinkageDeferred(*ioBlock);
+ }
+ }
+}
+
//
-// Handle seeing the function prototype in front of a function definition in the grammar.
+// Handle seeing the function prototype in front of a function definition in the grammar.
// The body is handled after this function returns.
//
-TIntermAggregate* HlslParseContext::handleFunctionDefinition(const TSourceLoc& loc, TFunction& function,
+TIntermAggregate* HlslParseContext::handleFunctionDefinition(const TSourceLoc& loc, TFunction& function,
const TAttributeMap& attributes)
{
currentCaller = function.getMangledName();
@@ -1180,18 +1571,9 @@ TIntermAggregate* HlslParseContext::handleFunctionDefinition(const TSourceLoc& l
currentFunctionType = new TType(EbtVoid);
functionReturnsValue = false;
- inEntryPoint = function.getName().compare(intermediate.getEntryPointName().c_str()) == 0;
- if (inEntryPoint) {
- intermediate.setEntryPointMangledName(function.getMangledName().c_str());
- intermediate.incrementEntryPointCount();
- remapEntryPointIO(function);
- if (entryPointOutput) {
- if (shouldFlatten(entryPointOutput->getType()))
- flatten(loc, *entryPointOutput);
- assignLocations(*entryPointOutput);
- }
- } else
- remapNonEntryPointIO(function);
+ // Entry points need different I/O and other handling, transform it so the
+ // rest of this function doesn't care.
+ transformEntryPoint(loc, function, attributes);
// Insert the $Global constant buffer.
// TODO: this design fails if new members are declared between function definitions.
@@ -1215,7 +1597,15 @@ TIntermAggregate* HlslParseContext::handleFunctionDefinition(const TSourceLoc& l
for (int i = 0; i < function.getParamCount(); i++) {
TParameter& param = function[i];
if (param.name != nullptr) {
- TVariable *variable = new TVariable(param.name, *param.type);
+ TType* sanitizedType;
+
+ // If we're not in the entry point, parameters are sanitized types.
+ if (inEntryPoint)
+ sanitizedType = param.type;
+ else
+ sanitizedType = sanitizeType(param.type);
+
+ TVariable *variable = new TVariable(param.name, *sanitizedType);
// Insert the parameters with name in the symbol table.
if (! symbolTable.insert(*variable))
@@ -1225,6 +1615,8 @@ TIntermAggregate* HlslParseContext::handleFunctionDefinition(const TSourceLoc& l
if (inEntryPoint) {
if (shouldFlatten(*param.type))
flatten(loc, *variable);
+ if (shouldSplit(*param.type))
+ split(*variable);
assignLocations(*variable);
}
@@ -1239,28 +1631,53 @@ TIntermAggregate* HlslParseContext::handleFunctionDefinition(const TSourceLoc& l
} else
paramNodes = intermediate.growAggregate(paramNodes, intermediate.addSymbol(*param.type, loc), loc);
}
+
intermediate.setAggregateOperator(paramNodes, EOpParameters, TType(EbtVoid), loc);
loopNestingLevel = 0;
controlFlowNestingLevel = 0;
postEntryPointReturn = false;
- // Handle function attributes
- if (inEntryPoint) {
- const TIntermAggregate* numThreads = attributes[EatNumThreads];
- if (numThreads != nullptr) {
- const TIntermSequence& sequence = numThreads->getSequence();
-
- for (int lid = 0; lid < int(sequence.size()); ++lid)
- intermediate.setLocalSize(lid, sequence[lid]->getAsConstantUnion()->getConstArray()[0].getIConst());
- }
+ return paramNodes;
+}
- const TIntermAggregate* maxVertexCount = attributes[EatMaxVertexCount];
- if (maxVertexCount != nullptr) {
- intermediate.setVertices(maxVertexCount->getSequence()[0]->getAsConstantUnion()->getConstArray()[0].getIConst());
- }
+//
+// Do all special handling for the entry point.
+//
+void HlslParseContext::transformEntryPoint(const TSourceLoc& loc, TFunction& function, const TAttributeMap& attributes)
+{
+ inEntryPoint = function.getName().compare(intermediate.getEntryPointName().c_str()) == 0;
+
+ if (!inEntryPoint) {
+ remapNonEntryPointIO(function);
+ return;
}
- return paramNodes;
+ // entry point logic...
+
+ intermediate.setEntryPointMangledName(function.getMangledName().c_str());
+ intermediate.incrementEntryPointCount();
+
+ // Handle parameters and return value
+ remapEntryPointIO(function);
+ if (entryPointOutput) {
+ if (shouldFlatten(entryPointOutput->getType()))
+ flatten(loc, *entryPointOutput);
+ if (shouldSplit(entryPointOutput->getType()))
+ split(*entryPointOutput);
+ assignLocations(*entryPointOutput);
+ }
+
+ // Handle function attributes
+ const TIntermAggregate* numThreads = attributes[EatNumThreads];
+ if (numThreads != nullptr) {
+ const TIntermSequence& sequence = numThreads->getSequence();
+
+ for (int lid = 0; lid < int(sequence.size()); ++lid)
+ intermediate.setLocalSize(lid, sequence[lid]->getAsConstantUnion()->getConstArray()[0].getIConst());
+ }
+ const TIntermAggregate* maxVertexCount = attributes[EatMaxVertexCount];
+ if (maxVertexCount != nullptr)
+ intermediate.setVertices(maxVertexCount->getSequence()[0]->getAsConstantUnion()->getConstArray()[0].getIConst());
}
void HlslParseContext::handleFunctionBody(const TSourceLoc& loc, TFunction& function, TIntermNode* functionBody, TIntermNode*& node)
@@ -1373,10 +1790,12 @@ TIntermNode* HlslParseContext::handleReturnValue(const TSourceLoc& loc, TIntermT
return intermediate.addBranch(EOpReturn, value, loc);
}
-void HlslParseContext::handleFunctionArgument(TFunction* function, TIntermTyped*& arguments, TIntermTyped* newArg)
+void HlslParseContext::handleFunctionArgument(TFunction* function,
+ TIntermTyped*& arguments, TIntermTyped* newArg)
{
- TParameter param = { 0, new TType };
+ TParameter param = { 0, new TType, nullptr };
param.type->shallowCopy(newArg->getType());
+
function->addParameter(param);
if (arguments)
arguments = intermediate.growAggregate(arguments, newArg);
@@ -1385,21 +1804,28 @@ void HlslParseContext::handleFunctionArgument(TFunction* function, TIntermTyped*
}
// Some simple source assignments need to be flattened to a sequence
-// of AST assignments. Catch these and flatten, otherwise, pass through
+// of AST assignments. Catch these and flatten, otherwise, pass through
// to intermediate.addAssign().
-TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op, TIntermTyped* left, TIntermTyped* right) const
+//
+// Also, assignment to matrix swizzles requires multiple component assignments,
+// intercept those as well.
+TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op, TIntermTyped* left, TIntermTyped* right)
{
if (left == nullptr || right == nullptr)
return nullptr;
- const auto mustFlatten = [&](const TIntermTyped& node) {
- return wasFlattened(&node) && node.getAsSymbolNode() &&
- flattenMap.find(node.getAsSymbolNode()->getId()) != flattenMap.end();
- };
+ if (left->getAsOperator() && left->getAsOperator()->getOp() == EOpMatrixSwizzle)
+ return handleAssignToMatrixSwizzle(loc, op, left, right);
- const bool flattenLeft = mustFlatten(*left);
- const bool flattenRight = mustFlatten(*right);
- if (! flattenLeft && ! flattenRight)
+ const bool isSplitLeft = wasSplit(left);
+ const bool isSplitRight = wasSplit(right);
+
+ const bool isFlattenLeft = wasFlattened(left);
+ const bool isFlattenRight = wasFlattened(right);
+
+ // OK to do a single assign if both are split, or both are unsplit. But if one is and the other
+ // isn't, we fall back to a member-wise copy.
+ if (! isFlattenLeft && ! isFlattenRight && !isSplitLeft && !isSplitRight)
return intermediate.addAssign(op, left, right, loc);
TIntermAggregate* assignList = nullptr;
@@ -1413,10 +1839,6 @@ TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op
// If the RHS is a simple symbol node, we'll copy it for each member.
TIntermSymbol* cloneSymNode = nullptr;
- // Array structs are not yet handled in flattening. (Compilation error upstream, so
- // this should never fire).
- assert(!(left->getType().isStruct() && left->getType().isArray()));
-
int memberCount = 0;
// Track how many items there are to copy.
@@ -1425,17 +1847,17 @@ TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op
if (left->getType().isArray())
memberCount = left->getType().getCumulativeArraySize();
- if (flattenLeft)
+ if (isFlattenLeft)
leftVariables = &flattenMap.find(left->getAsSymbolNode()->getId())->second.members;
- if (flattenRight) {
+ if (isFlattenRight) {
rightVariables = &flattenMap.find(right->getAsSymbolNode()->getId())->second.members;
} else {
// The RHS is not flattened. There are several cases:
// 1. 1 item to copy: Use the RHS directly.
// 2. >1 item, simple symbol RHS: we'll create a new TIntermSymbol node for each, but no assign to temp.
// 3. >1 item, complex RHS: assign it to a new temp variable, and create a TIntermSymbol for each member.
-
+
if (memberCount <= 1) {
// case 1: we'll use the symbol directly below. Nothing to do.
} else {
@@ -1456,57 +1878,100 @@ TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op
int memberIdx = 0;
- const auto getMember = [&](bool flatten, TIntermTyped* node,
- const TVector<TVariable*>& memberVariables, int member,
- TOperator op, const TType& memberType) -> TIntermTyped * {
+ // We track the outer-most aggregate, so that we can use its storage class later.
+ const TIntermTyped* outerLeft = left;
+ const TIntermTyped* outerRight = right;
+
+ const auto getMember = [&](bool isLeft, TIntermTyped* node, int member, TIntermTyped* splitNode, int splitMember) -> TIntermTyped * {
TIntermTyped* subTree;
- if (flatten && isFinalFlattening(memberType)) {
- subTree = intermediate.addSymbol(*memberVariables[memberIdx++]);
+
+ const bool flattened = isLeft ? isFlattenLeft : isFlattenRight;
+ const bool split = isLeft ? isSplitLeft : isSplitRight;
+ const TIntermTyped* outer = isLeft ? outerLeft : outerRight;
+ const TVector<TVariable*>& flatVariables = isLeft ? *leftVariables : *rightVariables;
+ const TOperator op = node->getType().isArray() ? EOpIndexDirect : EOpIndexDirectStruct;
+ const TType derefType(node->getType(), member);
+
+ if (split && derefType.isBuiltInInterstageIO(language)) {
+ // copy from interstage IO builtin if needed
+ subTree = intermediate.addSymbol(*interstageBuiltInIo[tInterstageIoData(derefType, outer->getType())]);
+ } else if (flattened && isFinalFlattening(derefType)) {
+ subTree = intermediate.addSymbol(*flatVariables[memberIdx++]);
} else {
- subTree = intermediate.addIndex(op, node, intermediate.addConstantUnion(member, loc), loc);
- subTree->setType(memberType);
+ const TType splitDerefType(splitNode->getType(), splitMember);
+
+ subTree = intermediate.addIndex(op, splitNode, intermediate.addConstantUnion(splitMember, loc), loc);
+ subTree->setType(splitDerefType);
}
return subTree;
};
+ // Use the proper RHS node: a new symbol from a TVariable, copy
+ // of an TIntermSymbol node, or sometimes the right node directly.
+ right = rhsTempVar ? intermediate.addSymbol(*rhsTempVar, loc) :
+ cloneSymNode ? intermediate.addSymbol(*cloneSymNode) :
+ right;
+
// Cannot use auto here, because this is recursive, and auto can't work out the type without seeing the
// whole thing. So, we'll resort to an explicit type via std::function.
- const std::function<void(TIntermTyped* left, TIntermTyped* right)>
- traverse = [&](TIntermTyped* left, TIntermTyped* right) -> void {
+ const std::function<void(TIntermTyped* left, TIntermTyped* right, TIntermTyped* splitLeft, TIntermTyped* splitRight)>
+ traverse = [&](TIntermTyped* left, TIntermTyped* right, TIntermTyped* splitLeft, TIntermTyped* splitRight) -> void {
// If we get here, we are assigning to or from a whole array or struct that must be
// flattened, so have to do member-by-member assignment:
if (left->getType().isArray()) {
- // array case
const TType dereferencedType(left->getType(), 0);
+ // array case
for (int element=0; element < left->getType().getOuterArraySize(); ++element) {
// Add a new AST symbol node if we have a temp variable holding a complex RHS.
- TIntermTyped* subRight = getMember(flattenRight, right, *rightVariables, element,
- EOpIndexDirect, dereferencedType);
- TIntermTyped* subLeft = getMember(flattenLeft, left, *leftVariables, element,
- EOpIndexDirect, dereferencedType);
+ TIntermTyped* subLeft = getMember(true, left, element, left, element);
+ TIntermTyped* subRight = getMember(false, right, element, right, element);
+
+ TIntermTyped* subSplitLeft = isSplitLeft ? getMember(true, left, element, splitLeft, element) : subLeft;
+ TIntermTyped* subSplitRight = isSplitRight ? getMember(false, right, element, splitRight, element) : subRight;
if (isFinalFlattening(dereferencedType))
assignList = intermediate.growAggregate(assignList, intermediate.addAssign(op, subLeft, subRight, loc), loc);
else
- traverse(subLeft, subRight);
+ traverse(subLeft, subRight, subSplitLeft, subSplitRight);
}
} else if (left->getType().isStruct()) {
// struct case
- const auto& members = *left->getType().getStruct();
-
- for (int member = 0; member < (int)members.size(); ++member) {
- TIntermTyped* subRight = getMember(flattenRight, right, *rightVariables, member,
- EOpIndexDirectStruct, *members[member].type);
- TIntermTyped* subLeft = getMember(flattenLeft, left, *leftVariables, member,
- EOpIndexDirectStruct, *members[member].type);
+ const auto& membersL = *left->getType().getStruct();
+ const auto& membersR = *right->getType().getStruct();
+
+ // These track the members in the split structures corresponding to the same in the unsplit structures,
+ // which we traverse in parallel.
+ int memberL = 0;
+ int memberR = 0;
+
+ for (int member = 0; member < int(membersL.size()); ++member) {
+ const TType& typeL = *membersL[member].type;
+ const TType& typeR = *membersR[member].type;
+
+ TIntermTyped* subLeft = getMember(true, left, member, left, member);
+ TIntermTyped* subRight = getMember(false, right, member, right, member);
+
+ // If there is no splitting, use the same values to avoid inefficiency.
+ TIntermTyped* subSplitLeft = isSplitLeft ? getMember(true, left, member, splitLeft, memberL) : subLeft;
+ TIntermTyped* subSplitRight = isSplitRight ? getMember(false, right, member, splitRight, memberR) : subRight;
+
+ // If this is the final flattening (no nested types below to flatten) we'll copy the member, else
+ // recurse into the type hierarchy. However, if splitting the struct, that means we can copy a whole
+ // subtree here IFF it does not itself contain any interstage built-in IO variables, so we only have to
+ // recurse into it if there's something for splitting to do. That can save a lot of AST verbosity for
+ // a bunch of memberwise copies.
+ if (isFinalFlattening(typeL) || (!isFlattenLeft && !isFlattenRight &&
+ !typeL.containsBuiltInInterstageIO(language) && !typeR.containsBuiltInInterstageIO(language))) {
+ assignList = intermediate.growAggregate(assignList, intermediate.addAssign(op, subSplitLeft, subSplitRight, loc), loc);
+ } else {
+ traverse(subLeft, subRight, subSplitLeft, subSplitRight);
+ }
- if (isFinalFlattening(*members[member].type))
- assignList = intermediate.growAggregate(assignList, intermediate.addAssign(op, subLeft, subRight, loc), loc);
- else
- traverse(subLeft, subRight);
+ memberL += (typeL.isBuiltInInterstageIO(language) ? 0 : 1);
+ memberR += (typeR.isBuiltInInterstageIO(language) ? 0 : 1);
}
} else {
assert(0); // we should never be called on a non-flattenable thing, because
@@ -1515,14 +1980,19 @@ TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op
};
- // Use the proper RHS node: a new symbol from a TVariable, copy
- // of an TIntermSymbol node, or sometimes the right node directly.
- right = rhsTempVar ? intermediate.addSymbol(*rhsTempVar, loc) :
- cloneSymNode ? intermediate.addSymbol(*cloneSymNode) :
- right;
+ TIntermTyped* splitLeft = left;
+ TIntermTyped* splitRight = right;
+
+ // If either left or right was a split structure, we must read or write it, but still have to
+ // parallel-recurse through the unsplit structure to identify the builtin IO vars.
+ if (isSplitLeft)
+ splitLeft = intermediate.addSymbol(*getSplitIoVar(left), loc);
+
+ if (isSplitRight)
+ splitRight = intermediate.addSymbol(*getSplitIoVar(right), loc);
// This makes the whole assignment, recursing through subtypes as needed.
- traverse(left, right);
+ traverse(left, right, splitLeft, splitRight);
assert(assignList != nullptr);
assignList->setOperator(EOpSequence);
@@ -1530,6 +2000,65 @@ TIntermTyped* HlslParseContext::handleAssign(const TSourceLoc& loc, TOperator op
return assignList;
}
+// An assignment to matrix swizzle must be decomposed into individual assignments.
+// These must be selected component-wise from the RHS and stored component-wise
+// into the LHS.
+TIntermTyped* HlslParseContext::handleAssignToMatrixSwizzle(const TSourceLoc& loc, TOperator op, TIntermTyped* left, TIntermTyped* right)
+{
+ assert(left->getAsOperator() && left->getAsOperator()->getOp() == EOpMatrixSwizzle);
+
+ if (op != EOpAssign)
+ error(loc, "only simple assignment to non-simple matrix swizzle is supported", "assign", "");
+
+ // isolate the matrix and swizzle nodes
+ TIntermTyped* matrix = left->getAsBinaryNode()->getLeft()->getAsTyped();
+ const TIntermSequence& swizzle = left->getAsBinaryNode()->getRight()->getAsAggregate()->getSequence();
+
+ // if the RHS isn't already a simple vector, let's store into one
+ TIntermSymbol* vector = right->getAsSymbolNode();
+ TIntermTyped* vectorAssign = nullptr;
+ if (vector == nullptr) {
+ // create a new intermediate vector variable to assign to
+ TType vectorType(matrix->getBasicType(), EvqTemporary, matrix->getQualifier().precision, swizzle.size()/2);
+ vector = intermediate.addSymbol(*makeInternalVariable("intermVec", vectorType), loc);
+
+ // assign the right to the new vector
+ vectorAssign = handleAssign(loc, op, vector, right);
+ }
+
+ // Assign the vector components to the matrix components.
+ // Store this as a sequence, so a single aggregate node represents this
+ // entire operation.
+ TIntermAggregate* result = intermediate.makeAggregate(vectorAssign);
+ TType columnType(matrix->getType(), 0);
+ TType componentType(columnType, 0);
+ TType indexType(EbtInt);
+ for (int i = 0; i < (int)swizzle.size(); i += 2) {
+ // the right component, single index into the RHS vector
+ TIntermTyped* rightComp = intermediate.addIndex(EOpIndexDirect, vector,
+ intermediate.addConstantUnion(i/2, loc), loc);
+
+ // the left component, double index into the LHS matrix
+ TIntermTyped* leftComp = intermediate.addIndex(EOpIndexDirect, matrix,
+ intermediate.addConstantUnion(swizzle[i]->getAsConstantUnion()->getConstArray(),
+ indexType, loc),
+ loc);
+ leftComp->setType(columnType);
+ leftComp = intermediate.addIndex(EOpIndexDirect, leftComp,
+ intermediate.addConstantUnion(swizzle[i+1]->getAsConstantUnion()->getConstArray(),
+ indexType, loc),
+ loc);
+ leftComp->setType(componentType);
+
+ // Add the assignment to the aggregate
+ result = intermediate.growAggregate(result, intermediate.addAssign(op, leftComp, rightComp, loc));
+ }
+
+ result->setOp(EOpSequence);
+
+ return result;
+}
+
//
// HLSL atomic operations have slightly different arguments than
// GLSL/AST/SPIRV. The semantics are converted below in decomposeIntrinsic.
@@ -1546,7 +2075,7 @@ TOperator HlslParseContext::mapAtomicOp(const TSourceLoc& loc, TOperator op, boo
case EOpInterlockedOr: return isImage ? EOpImageAtomicOr : EOpAtomicOr;
case EOpInterlockedXor: return isImage ? EOpImageAtomicXor : EOpAtomicXor;
case EOpInterlockedExchange: return isImage ? EOpImageAtomicExchange : EOpAtomicExchange;
- case EOpInterlockedCompareStore: // TODO: ...
+ case EOpInterlockedCompareStore: // TODO: ...
default:
error(loc, "unknown atomic operation", "unknown op", "");
return EOpNull;
@@ -1645,7 +2174,7 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
tex->getSequence().push_back(arg0); // sampler
tex->getSequence().push_back(constructCoord); // coordinate
tex->getSequence().push_back(bias); // bias
-
+
node = clampReturn(tex, sampler);
break;
@@ -1690,7 +2219,7 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
break;
}
-
+
case EOpMethodSampleGrad: // ...
{
TIntermTyped* argTex = argAggregate->getSequence()[0]->getAsTyped();
@@ -1797,7 +2326,7 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
} else {
indexedOut = sizeQueryReturn;
}
-
+
TIntermTyped* outParam = argAggregate->getSequence()[outParamBase + compNum]->getAsTyped();
TIntermTyped* compAssign = intermediate.addAssign(EOpAssign, outParam, indexedOut, loc);
@@ -1825,7 +2354,7 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
samplesQuery->getSequence().push_back(argTex);
samplesQuery->setType(TType(EbtUint, EvqTemporary, 1));
samplesQuery->setLoc(loc);
-
+
TIntermTyped* compAssign = intermediate.addAssign(EOpAssign, outParam, samplesQuery, loc);
compoundStatement = intermediate.growAggregate(compoundStatement, compAssign);
}
@@ -1851,7 +2380,7 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
// optional offset value
if (argAggregate->getSequence().size() > 4)
argOffset = argAggregate->getSequence()[4]->getAsTyped();
-
+
const int coordDimWithCmpVal = argCoord->getType().getVectorSize() + 1; // +1 for cmp
// AST wants comparison value as one of the texture coordinates
@@ -1920,14 +2449,16 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
coordSwizzle = argCoord;
} else {
// Extract coordinate
- TVectorFields coordFields(0,1,2,3);
- coordFields.num = argCoord->getType().getVectorSize() - (isMS ? 0 : 1);
+ int swizzleSize = argCoord->getType().getVectorSize() - (isMS ? 0 : 1);
+ TSwizzleSelectors<TVectorSelector> coordFields;
+ for (int i = 0; i < swizzleSize; ++i)
+ coordFields.push_back(i);
TIntermTyped* coordIdx = intermediate.addSwizzle(coordFields, loc);
coordSwizzle = intermediate.addIndex(EOpVectorSwizzle, argCoord, coordIdx, loc);
- coordSwizzle->setType(TType(coordBaseType, EvqTemporary, coordFields.num));
+ coordSwizzle->setType(TType(coordBaseType, EvqTemporary, coordFields.size()));
// Extract LOD
- TIntermTyped* lodIdx = intermediate.addConstantUnion(coordFields.num, loc, true);
+ TIntermTyped* lodIdx = intermediate.addConstantUnion(coordFields.size(), loc, true);
lodComponent = intermediate.addIndex(EOpIndexDirect, argCoord, lodIdx, loc);
lodComponent->setType(TType(coordBaseType, EvqTemporary, 1));
}
@@ -1978,12 +2509,12 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
TIntermTyped* argLod = argAggregate->getSequence()[3]->getAsTyped();
TIntermTyped* argOffset = nullptr;
const TSampler& sampler = argTex->getType().getSampler();
-
+
const int numArgs = (int)argAggregate->getSequence().size();
if (numArgs == 5) // offset, if present
argOffset = argAggregate->getSequence()[4]->getAsTyped();
-
+
const TOperator textureOp = (argOffset == nullptr ? EOpTextureLod : EOpTextureLodOffset);
TIntermAggregate* txsample = new TIntermAggregate(textureOp);
@@ -2030,7 +2561,7 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
break;
}
-
+
case EOpMethodGatherRed: // fall through...
case EOpMethodGatherGreen: // ...
case EOpMethodGatherBlue: // ...
@@ -2214,9 +2745,9 @@ void HlslParseContext::decomposeGeometryMethods(const TSourceLoc& loc, TIntermTy
emit->setType(TType(EbtVoid));
sequence = intermediate.growAggregate(sequence,
- intermediate.addAssign(EOpAssign,
- argAggregate->getSequence()[0]->getAsTyped(),
- argAggregate->getSequence()[1]->getAsTyped(), loc),
+ handleAssign(loc, EOpAssign,
+ argAggregate->getSequence()[0]->getAsTyped(),
+ argAggregate->getSequence()[1]->getAsTyped()),
loc);
sequence = intermediate.growAggregate(sequence, emit);
@@ -2274,7 +2805,7 @@ void HlslParseContext::decomposeIntrinsic(const TSourceLoc& loc, TIntermTyped*&
if (!decomposeHlslIntrinsics || !node || !node->getAsOperator())
return;
-
+
const TIntermAggregate* argAggregate = arguments ? arguments->getAsAggregate() : nullptr;
TIntermUnary* fnUnary = node->getAsUnaryNode();
const TOperator op = node->getAsOperator()->getOp();
@@ -2371,7 +2902,7 @@ void HlslParseContext::decomposeIntrinsic(const TSourceLoc& loc, TIntermTyped*&
arg0->getType().isVector()));
// calculate # of components for comparison const
- const int constComponentCount =
+ const int constComponentCount =
std::max(arg0->getType().getVectorSize(), 1) *
std::max(arg0->getType().getMatrixCols(), 1) *
std::max(arg0->getType().getMatrixRows(), 1);
@@ -2387,12 +2918,12 @@ void HlslParseContext::decomposeIntrinsic(const TSourceLoc& loc, TIntermTyped*&
TIntermTyped* zero = intermediate.addConstantUnion(0, type0, loc, true);
compareNode = handleBinaryMath(loc, "clip", EOpLessThan, arg0, zero);
}
-
+
TIntermBranch* killNode = intermediate.addBranch(EOpKill, loc);
node = new TIntermSelection(compareNode, killNode, nullptr);
node->setLoc(loc);
-
+
break;
}
@@ -2461,7 +2992,7 @@ void HlslParseContext::decomposeIntrinsic(const TSourceLoc& loc, TIntermTyped*&
atomic->setType(arg0->getType());
atomic->getWritableType().getQualifier().makeTemporary();
atomic->setLoc(loc);
-
+
if (isImage) {
// orig_value = imageAtomicOp(image, loc, data)
imageAtomicParams(atomic, arg0);
@@ -2512,7 +3043,7 @@ void HlslParseContext::decomposeIntrinsic(const TSourceLoc& loc, TIntermTyped*&
atomic->getSequence().push_back(arg1);
atomic->getSequence().push_back(arg2);
node = intermediate.addAssign(EOpAssign, arg3, atomic, loc);
-
+
break;
}
@@ -2538,7 +3069,7 @@ void HlslParseContext::decomposeIntrinsic(const TSourceLoc& loc, TIntermTyped*&
intermediate.addConversion(EOpConstructFloat,
TType(EbtFloat, EvqTemporary, 2), iU),
recip16);
-
+
TIntermAggregate* interp = new TIntermAggregate(EOpInterpolateAtOffset);
interp->getSequence().push_back(arg0);
interp->getSequence().push_back(floatOffset);
@@ -2582,7 +3113,7 @@ void HlslParseContext::decomposeIntrinsic(const TSourceLoc& loc, TIntermTyped*&
TIntermTyped* n_dot_h_m = handleBinaryMath(loc, "mul", EOpMul, n_dot_h, m); // n_dot_h * m
dst->getSequence().push_back(intermediate.addSelection(compare, zero, n_dot_h_m, loc));
-
+
// One:
dst->getSequence().push_back(intermediate.addConstantUnion(1.0, EbtFloat, loc, true));
@@ -2617,10 +3148,10 @@ void HlslParseContext::decomposeIntrinsic(const TSourceLoc& loc, TIntermTyped*&
convert->setLoc(loc);
convert->setType(TType(EbtDouble, EvqTemporary));
node = convert;
-
+
break;
}
-
+
case EOpF16tof32:
case EOpF32tof16:
{
@@ -2629,6 +3160,31 @@ void HlslParseContext::decomposeIntrinsic(const TSourceLoc& loc, TIntermTyped*&
break;
}
+ case EOpD3DCOLORtoUBYTE4:
+ {
+ // ivec4 ( x.zyxw * 255.001953 );
+ TIntermTyped* arg0 = node->getAsUnaryNode()->getOperand();
+ TSwizzleSelectors<TVectorSelector> selectors;
+ selectors.push_back(2);
+ selectors.push_back(1);
+ selectors.push_back(0);
+ selectors.push_back(3);
+ TIntermTyped* swizzleIdx = intermediate.addSwizzle(selectors, loc);
+ TIntermTyped* swizzled = intermediate.addIndex(EOpVectorSwizzle, arg0, swizzleIdx, loc);
+ swizzled->setType(arg0->getType());
+ swizzled->getWritableType().getQualifier().makeTemporary();
+
+ TIntermTyped* conversion = intermediate.addConstantUnion(255.001953f, EbtFloat, loc, true);
+ TIntermTyped* rangeConverted = handleBinaryMath(loc, "mul", EOpMul, conversion, swizzled);
+ rangeConverted->setType(arg0->getType());
+ rangeConverted->getWritableType().getQualifier().makeTemporary();
+
+ node = intermediate.addConversion(EOpConstructInt, TType(EbtInt, EvqTemporary, 4), rangeConverted);
+ node->setLoc(loc);
+ node->setType(TType(EbtInt, EvqTemporary, 4));
+ break;
+ }
+
default:
break; // most pass through unchanged
}
@@ -2643,7 +3199,7 @@ void HlslParseContext::decomposeIntrinsic(const TSourceLoc& loc, TIntermTyped*&
// - user function
// - subroutine call (not implemented yet)
//
-TIntermTyped* HlslParseContext::handleFunctionCall(const TSourceLoc& loc, TFunction* function, TIntermNode* arguments)
+TIntermTyped* HlslParseContext::handleFunctionCall(const TSourceLoc& loc, TFunction* function, TIntermTyped* arguments)
{
TIntermTyped* result = nullptr;
@@ -2715,7 +3271,7 @@ TIntermTyped* HlslParseContext::handleFunctionCall(const TSourceLoc& loc, TFunct
// for decompositions, since we want to operate on the function node, not the aggregate holding
// output conversions.
- const TIntermTyped* fnNode = result;
+ const TIntermTyped* fnNode = result;
decomposeIntrinsic(loc, result, arguments); // HLSL->AST intrinsic decompositions
decomposeSampleMethods(loc, result, arguments); // HLSL->AST sample method decompositions
@@ -2746,7 +3302,7 @@ TIntermTyped* HlslParseContext::handleFunctionCall(const TSourceLoc& loc, TFunct
}
// Finish processing object.length(). This started earlier in handleDotDereference(), where
-// the ".length" part was recognized and semantically checked, and finished here where the
+// the ".length" part was recognized and semantically checked, and finished here where the
// function syntax "()" is recognized.
//
// Return resulting tree node.
@@ -2783,10 +3339,10 @@ TIntermTyped* HlslParseContext::handleLengthMethod(const TSourceLoc& loc, TFunct
//
// Add any needed implicit conversions for function-call arguments to input parameters.
//
-void HlslParseContext::addInputArgumentConversions(const TFunction& function, TIntermNode*& arguments)
+void HlslParseContext::addInputArgumentConversions(const TFunction& function, TIntermTyped*& arguments)
{
TIntermAggregate* aggregate = arguments->getAsAggregate();
- const auto setArg = [&](int argNum, TIntermNode* arg) {
+ const auto setArg = [&](int argNum, TIntermTyped* arg) {
if (function.getParamCount() == 1)
arguments = arg;
else {
@@ -2819,14 +3375,14 @@ void HlslParseContext::addInputArgumentConversions(const TFunction& function, TI
else
error(arg->getLoc(), "cannot convert input argument, argument", "", "%d", i);
} else {
- if (wasFlattened(arg)) {
+ if (wasFlattened(arg) || wasSplit(arg)) {
// Will make a two-level subtree.
// The deepest will copy member-by-member to build the structure to pass.
// The level above that will be a two-operand EOpComma sequence that follows the copy by the
// object itself.
TVariable* internalAggregate = makeInternalVariable("aggShadow", *function[i].type);
internalAggregate->getWritableType().getQualifier().makeTemporary();
- TIntermSymbol* internalSymbolNode = new TIntermSymbol(internalAggregate->getUniqueId(),
+ TIntermSymbol* internalSymbolNode = new TIntermSymbol(internalAggregate->getUniqueId(),
internalAggregate->getName(),
internalAggregate->getType());
internalSymbolNode->setLoc(arg->getLoc());
@@ -3118,8 +3674,7 @@ void HlslParseContext::handleSemantic(TSourceLoc loc, TQualifier& qualifier, con
// Also, in DX10 if a SV value is present as the input of a stage, but isn't appropriate for that
// stage, it would just be ignored as it is likely there as part of an output struct from one stage
// to the next
-
-
+
bool bParseDX9 = false;
if (bParseDX9) {
if (semanticUpperCase == "PSIZE")
@@ -3134,7 +3689,7 @@ void HlslParseContext::handleSemantic(TSourceLoc loc, TQualifier& qualifier, con
qualifier.builtIn = EbvFragCoord;
}
- //SV Position has a different meaning in vertex vs fragment
+ // SV Position has a different meaning in vertex vs fragment
if (semanticUpperCase == "SV_POSITION" && language != EShLangFragment)
qualifier.builtIn = EbvPosition;
else if (semanticUpperCase == "SV_POSITION" && language == EShLangFragment)
@@ -3150,34 +3705,34 @@ void HlslParseContext::handleSemantic(TSourceLoc loc, TQualifier& qualifier, con
else if (semanticUpperCase == "SV_TESSFACTOR")
qualifier.builtIn = EbvTessLevelOuter;
- //Targets are defined 0-7
+ // Targets are defined 0-7
else if (semanticUpperCase == "SV_TARGET") {
qualifier.builtIn = EbvNone;
- //qualifier.layoutLocation = 0;
+ // qualifier.layoutLocation = 0;
} else if (semanticUpperCase == "SV_TARGET0") {
qualifier.builtIn = EbvNone;
- //qualifier.layoutLocation = 0;
+ // qualifier.layoutLocation = 0;
} else if (semanticUpperCase == "SV_TARGET1") {
qualifier.builtIn = EbvNone;
- //qualifier.layoutLocation = 1;
+ // qualifier.layoutLocation = 1;
} else if (semanticUpperCase == "SV_TARGET2") {
qualifier.builtIn = EbvNone;
- //qualifier.layoutLocation = 2;
+ // qualifier.layoutLocation = 2;
} else if (semanticUpperCase == "SV_TARGET3") {
qualifier.builtIn = EbvNone;
- //qualifier.layoutLocation = 3;
+ // qualifier.layoutLocation = 3;
} else if (semanticUpperCase == "SV_TARGET4") {
qualifier.builtIn = EbvNone;
- //qualifier.layoutLocation = 4;
+ // qualifier.layoutLocation = 4;
} else if (semanticUpperCase == "SV_TARGET5") {
qualifier.builtIn = EbvNone;
- //qualifier.layoutLocation = 5;
+ // qualifier.layoutLocation = 5;
} else if (semanticUpperCase == "SV_TARGET6") {
qualifier.builtIn = EbvNone;
- //qualifier.layoutLocation = 6;
+ // qualifier.layoutLocation = 6;
} else if (semanticUpperCase == "SV_TARGET7") {
qualifier.builtIn = EbvNone;
- //qualifier.layoutLocation = 7;
+ // qualifier.layoutLocation = 7;
} else if (semanticUpperCase == "SV_SAMPLEINDEX")
qualifier.builtIn = EbvSampleId;
else if (semanticUpperCase == "SV_RENDERTARGETARRAYINDEX")
@@ -3195,7 +3750,7 @@ void HlslParseContext::handleSemantic(TSourceLoc loc, TQualifier& qualifier, con
else if (semanticUpperCase == "SV_GSINSTANCEID")
qualifier.builtIn = EbvInvocationId;
else if (semanticUpperCase == "SV_DISPATCHTHREADID")
- qualifier.builtIn = EbvLocalInvocationId;
+ qualifier.builtIn = EbvGlobalInvocationId;
else if (semanticUpperCase == "SV_GROUPTHREADID")
qualifier.builtIn = EbvLocalInvocationId;
else if (semanticUpperCase == "SV_GROUPID")
@@ -3207,7 +3762,7 @@ void HlslParseContext::handleSemantic(TSourceLoc loc, TQualifier& qualifier, con
else if( semanticUpperCase == "SV_COVERAGE")
qualifier.builtIn = EbvSampleMask;
- //TODO, these need to get refined to be more specific
+ // TODO, these need to get refined to be more specific
else if( semanticUpperCase == "SV_DEPTHGREATEREQUAL")
qualifier.builtIn = EbvFragDepthGreater;
else if( semanticUpperCase == "SV_DEPTHLESSEQUAL")
@@ -3409,7 +3964,6 @@ void HlslParseContext::globalCheck(const TSourceLoc& loc, const char* token)
error(loc, "not allowed in nested scope", token, "");
}
-
bool HlslParseContext::builtInName(const TString& /*identifier*/)
{
return false;
@@ -3893,6 +4447,23 @@ void HlslParseContext::updateImplicitArraySize(const TSourceLoc& loc, TIntermNod
}
//
+// Enforce non-initializer type/qualifier rules.
+//
+void HlslParseContext::fixConstInit(const TSourceLoc& loc, TString& identifier, TType& type, TIntermTyped*& initializer)
+{
+ //
+ // Make the qualifier make sense, given that there is an initializer.
+ //
+ if (initializer == nullptr) {
+ if (type.getQualifier().storage == EvqConst ||
+ type.getQualifier().storage == EvqConstReadOnly) {
+ initializer = intermediate.makeAggregate(loc);
+ warn(loc, "variable with qualifier 'const' not initialized; zero initializing", identifier.c_str(), "");
+ }
+ }
+}
+
+//
// See if the identifier is a built-in symbol that can be redeclared, and if so,
// copy the symbol table's read-only built-in variable to the current
// global level, where it can be modified based on the passed in type.
@@ -4078,38 +4649,38 @@ void HlslParseContext::setLayoutQualifier(const TSourceLoc& loc, TQualifier& qua
}
if (language == EShLangGeometry || language == EShLangTessEvaluation) {
if (id == TQualifier::getGeometryString(ElgTriangles)) {
- //publicType.shaderQualifiers.geometry = ElgTriangles;
+ // publicType.shaderQualifiers.geometry = ElgTriangles;
warn(loc, "ignored", id.c_str(), "");
return;
}
if (language == EShLangGeometry) {
if (id == TQualifier::getGeometryString(ElgPoints)) {
- //publicType.shaderQualifiers.geometry = ElgPoints;
+ // publicType.shaderQualifiers.geometry = ElgPoints;
warn(loc, "ignored", id.c_str(), "");
return;
}
if (id == TQualifier::getGeometryString(ElgLineStrip)) {
- //publicType.shaderQualifiers.geometry = ElgLineStrip;
+ // publicType.shaderQualifiers.geometry = ElgLineStrip;
warn(loc, "ignored", id.c_str(), "");
return;
}
if (id == TQualifier::getGeometryString(ElgLines)) {
- //publicType.shaderQualifiers.geometry = ElgLines;
+ // publicType.shaderQualifiers.geometry = ElgLines;
warn(loc, "ignored", id.c_str(), "");
return;
}
if (id == TQualifier::getGeometryString(ElgLinesAdjacency)) {
- //publicType.shaderQualifiers.geometry = ElgLinesAdjacency;
+ // publicType.shaderQualifiers.geometry = ElgLinesAdjacency;
warn(loc, "ignored", id.c_str(), "");
return;
}
if (id == TQualifier::getGeometryString(ElgTrianglesAdjacency)) {
- //publicType.shaderQualifiers.geometry = ElgTrianglesAdjacency;
+ // publicType.shaderQualifiers.geometry = ElgTrianglesAdjacency;
warn(loc, "ignored", id.c_str(), "");
return;
}
if (id == TQualifier::getGeometryString(ElgTriangleStrip)) {
- //publicType.shaderQualifiers.geometry = ElgTriangleStrip;
+ // publicType.shaderQualifiers.geometry = ElgTriangleStrip;
warn(loc, "ignored", id.c_str(), "");
return;
}
@@ -4118,53 +4689,53 @@ void HlslParseContext::setLayoutQualifier(const TSourceLoc& loc, TQualifier& qua
// input primitive
if (id == TQualifier::getGeometryString(ElgTriangles)) {
- //publicType.shaderQualifiers.geometry = ElgTriangles;
+ // publicType.shaderQualifiers.geometry = ElgTriangles;
warn(loc, "ignored", id.c_str(), "");
return;
}
if (id == TQualifier::getGeometryString(ElgQuads)) {
- //publicType.shaderQualifiers.geometry = ElgQuads;
+ // publicType.shaderQualifiers.geometry = ElgQuads;
warn(loc, "ignored", id.c_str(), "");
return;
}
if (id == TQualifier::getGeometryString(ElgIsolines)) {
- //publicType.shaderQualifiers.geometry = ElgIsolines;
+ // publicType.shaderQualifiers.geometry = ElgIsolines;
warn(loc, "ignored", id.c_str(), "");
return;
}
// vertex spacing
if (id == TQualifier::getVertexSpacingString(EvsEqual)) {
- //publicType.shaderQualifiers.spacing = EvsEqual;
+ // publicType.shaderQualifiers.spacing = EvsEqual;
warn(loc, "ignored", id.c_str(), "");
return;
}
if (id == TQualifier::getVertexSpacingString(EvsFractionalEven)) {
- //publicType.shaderQualifiers.spacing = EvsFractionalEven;
+ // publicType.shaderQualifiers.spacing = EvsFractionalEven;
warn(loc, "ignored", id.c_str(), "");
return;
}
if (id == TQualifier::getVertexSpacingString(EvsFractionalOdd)) {
- //publicType.shaderQualifiers.spacing = EvsFractionalOdd;
+ // publicType.shaderQualifiers.spacing = EvsFractionalOdd;
warn(loc, "ignored", id.c_str(), "");
return;
}
// triangle order
if (id == TQualifier::getVertexOrderString(EvoCw)) {
- //publicType.shaderQualifiers.order = EvoCw;
+ // publicType.shaderQualifiers.order = EvoCw;
warn(loc, "ignored", id.c_str(), "");
return;
}
if (id == TQualifier::getVertexOrderString(EvoCcw)) {
- //publicType.shaderQualifiers.order = EvoCcw;
+ // publicType.shaderQualifiers.order = EvoCcw;
warn(loc, "ignored", id.c_str(), "");
return;
}
// point mode
if (id == "point_mode") {
- //publicType.shaderQualifiers.pointMode = true;
+ // publicType.shaderQualifiers.pointMode = true;
warn(loc, "ignored", id.c_str(), "");
return;
}
@@ -4172,23 +4743,23 @@ void HlslParseContext::setLayoutQualifier(const TSourceLoc& loc, TQualifier& qua
}
if (language == EShLangFragment) {
if (id == "origin_upper_left") {
- //publicType.shaderQualifiers.originUpperLeft = true;
+ // publicType.shaderQualifiers.originUpperLeft = true;
warn(loc, "ignored", id.c_str(), "");
return;
}
if (id == "pixel_center_integer") {
- //publicType.shaderQualifiers.pixelCenterInteger = true;
+ // publicType.shaderQualifiers.pixelCenterInteger = true;
warn(loc, "ignored", id.c_str(), "");
return;
}
if (id == "early_fragment_tests") {
- //publicType.shaderQualifiers.earlyFragmentTests = true;
+ // publicType.shaderQualifiers.earlyFragmentTests = true;
warn(loc, "ignored", id.c_str(), "");
return;
}
for (TLayoutDepth depth = (TLayoutDepth)(EldNone + 1); depth < EldCount; depth = (TLayoutDepth)(depth + 1)) {
if (id == TQualifier::getLayoutDepthString(depth)) {
- //publicType.shaderQualifiers.layoutDepth = depth;
+ // publicType.shaderQualifiers.layoutDepth = depth;
warn(loc, "ignored", id.c_str(), "");
return;
}
@@ -4199,7 +4770,7 @@ void HlslParseContext::setLayoutQualifier(const TSourceLoc& loc, TQualifier& qua
if (id == TQualifier::getBlendEquationString(be)) {
requireExtensions(loc, 1, &E_GL_KHR_blend_equation_advanced, "blend equation");
intermediate.addBlendEquation(be);
- //publicType.shaderQualifiers.blendEquation = true;
+ // publicType.shaderQualifiers.blendEquation = true;
warn(loc, "ignored", id.c_str(), "");
found = true;
break;
@@ -4218,7 +4789,7 @@ void HlslParseContext::setLayoutQualifier(const TSourceLoc& loc, TQualifier& qua
void HlslParseContext::setLayoutQualifier(const TSourceLoc& loc, TQualifier& qualifier, TString& id, const TIntermTyped* node)
{
const char* feature = "layout-id value";
- //const char* nonLiteralFeature = "non-literal layout-id value";
+ // const char* nonLiteralFeature = "non-literal layout-id value";
integerCheck(node, feature);
const TIntermConstantUnion* constUnion = node->getAsConstantUnion();
@@ -4264,9 +4835,9 @@ void HlslParseContext::setLayoutQualifier(const TSourceLoc& loc, TQualifier& qua
qualifier.layoutComponent = value;
return;
} else if (id.compare(0, 4, "xfb_") == 0) {
- // "Any shader making any static use (after preprocessing) of any of these
- // *xfb_* qualifiers will cause the shader to be in a transform feedback
- // capturing mode and hence responsible for describing the transform feedback
+ // "Any shader making any static use (after preprocessing) of any of these
+ // *xfb_* qualifiers will cause the shader to be in a transform feedback
+ // capturing mode and hence responsible for describing the transform feedback
// setup."
intermediate.setXfbMode();
if (id == "xfb_buffer") {
@@ -4286,7 +4857,7 @@ void HlslParseContext::setLayoutQualifier(const TSourceLoc& loc, TQualifier& qua
qualifier.layoutXfbOffset = value;
return;
} else if (id == "xfb_stride") {
- // "The resulting stride (implicit or explicit), when divided by 4, must be less than or equal to the
+ // "The resulting stride (implicit or explicit), when divided by 4, must be less than or equal to the
// implementation-dependent constant gl_MaxTransformFeedbackInterleavedComponents."
if (value > 4 * resources.maxTransformFeedbackInterleavedComponents)
error(loc, "1/4 stride is too large:", id.c_str(), "gl_MaxTransformFeedbackInterleavedComponents is %d", resources.maxTransformFeedbackInterleavedComponents);
@@ -4328,7 +4899,7 @@ void HlslParseContext::setLayoutQualifier(const TSourceLoc& loc, TQualifier& qua
if (value == 0)
error(loc, "must be greater than 0", "vertices", "");
else
- //publicType.shaderQualifiers.vertices = value;
+ // publicType.shaderQualifiers.vertices = value;
warn(loc, "ignored", id.c_str(), "");
return;
}
@@ -4342,12 +4913,12 @@ void HlslParseContext::setLayoutQualifier(const TSourceLoc& loc, TQualifier& qua
if (value == 0)
error(loc, "must be at least 1", "invocations", "");
else
- //publicType.shaderQualifiers.invocations = value;
+ // publicType.shaderQualifiers.invocations = value;
warn(loc, "ignored", id.c_str(), "");
return;
}
if (id == "max_vertices") {
- //publicType.shaderQualifiers.vertices = value;
+ // publicType.shaderQualifiers.vertices = value;
warn(loc, "ignored", id.c_str(), "");
if (value > resources.maxGeometryOutputVertices)
error(loc, "too large, must be less than gl_MaxGeometryOutputVertices", "max_vertices", "");
@@ -4369,33 +4940,33 @@ void HlslParseContext::setLayoutQualifier(const TSourceLoc& loc, TQualifier& qua
case EShLangCompute:
if (id.compare(0, 11, "local_size_") == 0) {
if (id == "local_size_x") {
- //publicType.shaderQualifiers.localSize[0] = value;
+ // publicType.shaderQualifiers.localSize[0] = value;
warn(loc, "ignored", id.c_str(), "");
return;
}
if (id == "local_size_y") {
- //publicType.shaderQualifiers.localSize[1] = value;
+ // publicType.shaderQualifiers.localSize[1] = value;
warn(loc, "ignored", id.c_str(), "");
return;
}
if (id == "local_size_z") {
- //publicType.shaderQualifiers.localSize[2] = value;
+ // publicType.shaderQualifiers.localSize[2] = value;
warn(loc, "ignored", id.c_str(), "");
return;
}
if (spvVersion.spv != 0) {
if (id == "local_size_x_id") {
- //publicType.shaderQualifiers.localSizeSpecId[0] = value;
+ // publicType.shaderQualifiers.localSizeSpecId[0] = value;
warn(loc, "ignored", id.c_str(), "");
return;
}
if (id == "local_size_y_id") {
- //publicType.shaderQualifiers.localSizeSpecId[1] = value;
+ // publicType.shaderQualifiers.localSizeSpecId[1] = value;
warn(loc, "ignored", id.c_str(), "");
return;
}
if (id == "local_size_z_id") {
- //publicType.shaderQualifiers.localSizeSpecId[2] = value;
+ // publicType.shaderQualifiers.localSizeSpecId[2] = value;
warn(loc, "ignored", id.c_str(), "");
return;
}
@@ -4413,17 +4984,17 @@ void HlslParseContext::setLayoutQualifier(const TSourceLoc& loc, TQualifier& qua
// Merge any layout qualifier information from src into dst, leaving everything else in dst alone
//
// "More than one layout qualifier may appear in a single declaration.
-// Additionally, the same layout-qualifier-name can occur multiple times
-// within a layout qualifier or across multiple layout qualifiers in the
-// same declaration. When the same layout-qualifier-name occurs
-// multiple times, in a single declaration, the last occurrence overrides
-// the former occurrence(s). Further, if such a layout-qualifier-name
-// will effect subsequent declarations or other observable behavior, it
-// is only the last occurrence that will have any effect, behaving as if
-// the earlier occurrence(s) within the declaration are not present.
-// This is also true for overriding layout-qualifier-names, where one
-// overrides the other (e.g., row_major vs. column_major); only the last
-// occurrence has any effect."
+// Additionally, the same layout-qualifier-name can occur multiple times
+// within a layout qualifier or across multiple layout qualifiers in the
+// same declaration. When the same layout-qualifier-name occurs
+// multiple times, in a single declaration, the last occurrence overrides
+// the former occurrence(s). Further, if such a layout-qualifier-name
+// will effect subsequent declarations or other observable behavior, it
+// is only the last occurrence that will have any effect, behaving as if
+// the earlier occurrence(s) within the declaration are not present.
+// This is also true for overriding layout-qualifier-names, where one
+// overrides the other (e.g., row_major vs. column_major); only the last
+// occurrence has any effect."
//
void HlslParseContext::mergeObjectLayoutQualifiers(TQualifier& dst, const TQualifier& src, bool inheritOnly)
{
@@ -4478,13 +5049,13 @@ void HlslParseContext::mergeObjectLayoutQualifiers(TQualifier& dst, const TQuali
// Look up a function name in the symbol table, and make sure it is a function.
//
// First, look for an exact match. If there is none, use the generic selector
-// TParseContextBase::selectFunction() to find one, parameterized by the
+// TParseContextBase::selectFunction() to find one, parameterized by the
// convertible() and better() predicates defined below.
//
// Return the function symbol if found, otherwise nullptr.
//
-const TFunction* HlslParseContext::findFunction(const TSourceLoc& loc, const TFunction& call, bool& builtIn,
- TIntermNode* args)
+const TFunction* HlslParseContext::findFunction(const TSourceLoc& loc, TFunction& call, bool& builtIn,
+ TIntermTyped*& args)
{
// const TFunction* function = nullptr;
@@ -4503,7 +5074,7 @@ const TFunction* HlslParseContext::findFunction(const TSourceLoc& loc, const TFu
// create list of candidates to send
TVector<const TFunction*> candidateList;
symbolTable.findFunctionNameList(call.getMangledName(), candidateList, builtIn);
-
+
// These builtin ops can accept any type, so we bypass the argument selection
if (candidateList.size() == 1 && builtIn &&
(candidateList[0]->getBuiltInOp() == EOpMethodAppend ||
@@ -4520,7 +5091,7 @@ const TFunction* HlslParseContext::findFunction(const TSourceLoc& loc, const TFu
return true;
// no aggregate conversions
- if (from.isArray() || to.isArray() ||
+ if (from.isArray() || to.isArray() ||
from.isStruct() || to.isStruct())
return false;
@@ -4537,12 +5108,45 @@ const TFunction* HlslParseContext::findFunction(const TSourceLoc& loc, const TFu
// We do not promote the texture or image type for these ocodes. Normally that would not
// be an issue because it's a buffer, but we haven't decomposed the opcode yet, and at this
// stage it's merely e.g, a basic integer type.
- //
+ //
// Instead, we want to promote other arguments, but stay within the same family. In other
// words, InterlockedAdd(RWBuffer<int>, ...) will always use the int flavor, never the uint flavor,
// but it is allowed to promote its other arguments.
if (arg == 0)
return false;
+ break;
+ case EOpMethodSample:
+ case EOpMethodSampleBias:
+ case EOpMethodSampleCmp:
+ case EOpMethodSampleCmpLevelZero:
+ case EOpMethodSampleGrad:
+ case EOpMethodSampleLevel:
+ case EOpMethodLoad:
+ case EOpMethodGetDimensions:
+ case EOpMethodGetSamplePosition:
+ case EOpMethodGather:
+ case EOpMethodCalculateLevelOfDetail:
+ case EOpMethodCalculateLevelOfDetailUnclamped:
+ case EOpMethodGatherRed:
+ case EOpMethodGatherGreen:
+ case EOpMethodGatherBlue:
+ case EOpMethodGatherAlpha:
+ case EOpMethodGatherCmp:
+ case EOpMethodGatherCmpRed:
+ case EOpMethodGatherCmpGreen:
+ case EOpMethodGatherCmpBlue:
+ case EOpMethodGatherCmpAlpha:
+ case EOpMethodAppend:
+ case EOpMethodRestartStrip:
+ // those are method calls, the object type can not be changed
+ // they are equal if the dim and type match (is dim sufficient?)
+ if (arg == 0)
+ return from.getSampler().type == to.getSampler().type &&
+ from.getSampler().arrayed == to.getSampler().arrayed &&
+ from.getSampler().shadow == to.getSampler().shadow &&
+ from.getSampler().ms == to.getSampler().ms &&
+ from.getSampler().dim == to.getSampler().dim;
+ break;
default:
break;
}
@@ -4583,6 +5187,22 @@ const TFunction* HlslParseContext::findFunction(const TSourceLoc& loc, const TFu
return false;
}
+ // Handle sampler betterness: An exact sampler match beats a non-exact match.
+ // (If we just looked at basic type, all EbtSamplers would look the same).
+ // If any type is not a sampler, just use the linearize function below.
+ if (from.getBasicType() == EbtSampler && to1.getBasicType() == EbtSampler && to2.getBasicType() == EbtSampler) {
+ // We can ignore the vector size in the comparison.
+ TSampler to1Sampler = to1.getSampler();
+ TSampler to2Sampler = to2.getSampler();
+
+ to1Sampler.vectorSize = to2Sampler.vectorSize = from.getSampler().vectorSize;
+
+ if (from.getSampler() == to2Sampler)
+ return from.getSampler() != to1Sampler;
+ if (from.getSampler() == to1Sampler)
+ return false;
+ }
+
// Might or might not be changing shape, which means basic type might
// or might not match, so within that, the question is how big a
// basic-type conversion is being done.
@@ -4612,7 +5232,7 @@ const TFunction* HlslParseContext::findFunction(const TSourceLoc& loc, const TFu
// for ambiguity reporting
bool tie = false;
-
+
// send to the generic selector
const TFunction* bestMatch = selectFunction(candidateList, call, convertible, better, tie);
@@ -4672,18 +5292,18 @@ const TFunction* HlslParseContext::findFunction(const TSourceLoc& loc, const TFu
// Handle aggregates: put all args into the new function call
for (int arg=0; arg<int(args->getAsAggregate()->getSequence().size()); ++arg) {
// TODO: But for constness, we could avoid the new & shallowCopy, and use the pointer directly.
- TParameter param = { 0, new TType };
+ TParameter param = { 0, new TType, nullptr };
param.type->shallowCopy(args->getAsAggregate()->getSequence()[arg]->getAsTyped()->getType());
convertedCall.addParameter(param);
}
} else if (args->getAsUnaryNode()) {
// Handle unaries: put all args into the new function call
- TParameter param = { 0, new TType };
+ TParameter param = { 0, new TType, nullptr };
param.type->shallowCopy(args->getAsUnaryNode()->getOperand()->getAsTyped()->getType());
convertedCall.addParameter(param);
} else if (args->getAsTyped()) {
// Handle bare e.g, floats, not in an aggregate.
- TParameter param = { 0, new TType };
+ TParameter param = { 0, new TType, nullptr };
param.type->shallowCopy(args->getAsTyped()->getType());
convertedCall.addParameter(param);
} else {
@@ -4701,12 +5321,19 @@ const TFunction* HlslParseContext::findFunction(const TSourceLoc& loc, const TFu
if (tie)
error(loc, "ambiguous best function under implicit type conversion", call.getName().c_str(), "");
+ // Append default parameter values if needed
+ if (!tie && bestMatch != nullptr) {
+ for (int defParam = call.getParamCount(); defParam < bestMatch->getParamCount(); ++defParam) {
+ handleFunctionArgument(&call, args, (*bestMatch)[defParam].defaultValue);
+ }
+ }
+
return bestMatch;
}
//
// Do everything necessary to handle a typedef declaration, for a single symbol.
-//
+//
// 'parseType' is the type part of the declaration (to the left)
// 'arraySizes' is the arrayness tagged on the identifier (to the right)
//
@@ -4720,6 +5347,43 @@ void HlslParseContext::declareTypedef(const TSourceLoc& loc, TString& identifier
error(loc, "name already defined", "typedef", identifier.c_str());
}
+// Type sanitization: return existing sanitized (temporary) type if there is one, else make new one.
+TType* HlslParseContext::sanitizeType(TType* type)
+{
+ // We only do this for structs.
+ if (!type->isStruct())
+ return type;
+
+ // Type sanitization: if this is declaring a variable of a type that contains
+ // interstage IO, we want to make it a temporary.
+ const auto sanitizedTypeIter = sanitizedTypeMap.find(type->getStruct());
+
+ if (sanitizedTypeIter != sanitizedTypeMap.end()) {
+ // We've sanitized this before. Use that one.
+ TType* sanitizedType = new TType();
+ sanitizedType->shallowCopy(*sanitizedTypeIter->second);
+
+ // Arrayness is not part of the sanitized type. Use the input type's arrayness.
+ if (type->isArray())
+ sanitizedType->newArraySizes(type->getArraySizes());
+ else
+ sanitizedType->clearArraySizes();
+ return sanitizedType;
+ } else {
+ if (type->containsBuiltInInterstageIO(language)) {
+ // This means the type contains interstage IO, but we've never encountered it before.
+ // Copy it, sanitize it, and remember it in the sanitizedTypeMap
+ TType* sanitizedType = type->clone();
+ sanitizedType->makeTemporary();
+ sanitizedTypeMap[type->getStruct()] = sanitizedType;
+ return sanitizedType;
+ } else {
+ // This means the type has no interstage IO, so we can use it as is.
+ return type;
+ }
+ }
+}
+
//
// Do everything necessary to handle a variable (non-block) declaration.
// Either redeclaring a variable, or making a new one, updating the symbol
@@ -4736,21 +5400,29 @@ TIntermNode* HlslParseContext::declareVariable(const TSourceLoc& loc, TString& i
if (voidErrorCheck(loc, identifier, type.getBasicType()))
return nullptr;
+ // make const and initialization consistent
+ fixConstInit(loc, identifier, type, initializer);
+
// Check for redeclaration of built-ins and/or attempting to declare a reserved name
TSymbol* symbol = nullptr;
inheritGlobalDefaults(type.getQualifier());
const bool flattenVar = shouldFlatten(type);
+ const bool splitVar = shouldSplit(type);
+
+ // Type sanitization: if this is declaring a variable of a type that contains
+ // interstage IO, we want to make it a temporary.
+ TType* sanitizedType = sanitizeType(&type);
// Declare the variable
if (type.isArray()) {
// array case
- declareArray(loc, identifier, type, symbol, !flattenVar);
+ declareArray(loc, identifier, *sanitizedType, symbol, !flattenVar);
} else {
// non-array case
if (! symbol)
- symbol = declareNonArray(loc, identifier, type, !flattenVar);
+ symbol = declareNonArray(loc, identifier, *sanitizedType, !flattenVar);
else if (type != symbol->getType())
error(loc, "cannot change the type of", "redeclaration", symbol->getName().c_str());
}
@@ -4758,6 +5430,9 @@ TIntermNode* HlslParseContext::declareVariable(const TSourceLoc& loc, TString& i
if (flattenVar)
flatten(loc, *symbol->getAsVariable());
+ if (splitVar)
+ split(*symbol->getAsVariable());
+
if (! symbol)
return nullptr;
@@ -4797,7 +5472,7 @@ void HlslParseContext::inheritGlobalDefaults(TQualifier& dst) const
//
TVariable* HlslParseContext::makeInternalVariable(const char* name, const TType& type) const
{
- TString* nameString = new TString(name);
+ TString* nameString = NewPoolTString(name);
TVariable* variable = new TVariable(nameString, type);
symbolTable.makeInternalVariable(*variable);
@@ -4845,8 +5520,16 @@ TIntermNode* HlslParseContext::executeInitializer(const TSourceLoc& loc, TInterm
// constructor-style subtree, allowing the rest of the code to operate
// identically for both kinds of initializers.
//
+ //
+ // Type can't be deduced from the initializer list, so a skeletal type to
+ // follow has to be passed in. Constness and specialization-constness
+ // should be deduced bottom up, not dictated by the skeletal type.
+ //
+ TType skeletalType;
+ skeletalType.shallowCopy(variable->getType());
+ skeletalType.getQualifier().makeTemporary();
if (initializer->getAsAggregate() && initializer->getAsAggregate()->getOp() == EOpNull)
- initializer = convertInitializerList(loc, variable->getType(), initializer);
+ initializer = convertInitializerList(loc, skeletalType, initializer);
if (! initializer) {
// error recovery; don't leave const without constant values
if (qualifier == EvqConst)
@@ -4960,12 +5643,16 @@ TIntermTyped* HlslParseContext::convertInitializerList(const TSourceLoc& loc, co
// edit array sizes to fill in unsized dimensions
if (type.isImplicitlySizedArray())
arrayType.changeOuterArraySize((int)initList->getSequence().size());
- TIntermTyped* firstInit = initList->getSequence()[0]->getAsTyped();
- if (arrayType.isArrayOfArrays() && firstInit->getType().isArray() &&
- arrayType.getArraySizes().getNumDims() == firstInit->getType().getArraySizes()->getNumDims() + 1) {
- for (int d = 1; d < arrayType.getArraySizes().getNumDims(); ++d) {
- if (arrayType.getArraySizes().getDimSize(d) == UnsizedArraySize)
- arrayType.getArraySizes().setDimSize(d, firstInit->getType().getArraySizes()->getDimSize(d - 1));
+
+ // set unsized array dimensions that can be derived from the initializer's first element
+ if (arrayType.isArrayOfArrays() && initList->getSequence().size() > 0) {
+ TIntermTyped* firstInit = initList->getSequence()[0]->getAsTyped();
+ if (firstInit->getType().isArray() &&
+ arrayType.getArraySizes().getNumDims() == firstInit->getType().getArraySizes()->getNumDims() + 1) {
+ for (int d = 1; d < arrayType.getArraySizes().getNumDims(); ++d) {
+ if (arrayType.getArraySizes().getDimSize(d) == UnsizedArraySize)
+ arrayType.getArraySizes().setDimSize(d, firstInit->getType().getArraySizes()->getDimSize(d - 1));
+ }
}
}
@@ -5024,6 +5711,9 @@ TIntermTyped* HlslParseContext::convertInitializerList(const TSourceLoc& loc, co
return nullptr;
}
} else if (type.isScalar()) {
+ // lengthen list to be long enough
+ lengthenList(loc, initList->getSequence(), 1);
+
if ((int)initList->getSequence().size() != 1) {
error(loc, "scalar expected one element:", "initializer list", type.getCompleteString().c_str());
return nullptr;
@@ -5275,7 +5965,7 @@ void HlslParseContext::declareBlock(const TSourceLoc& loc, TType& type, const TS
// This might be a redeclaration of a built-in block. If so, redeclareBuiltinBlock() will
// do all the rest.
- //if (! symbolTable.atBuiltInLevel() && builtInName(*blockName)) {
+ // if (! symbolTable.atBuiltInLevel() && builtInName(*blockName)) {
// redeclareBuiltinBlock(loc, typeList, *blockName, instanceName, arraySizes);
// return;
//}
@@ -5310,9 +6000,9 @@ void HlslParseContext::declareBlock(const TSourceLoc& loc, TType& type, const TS
error(memberLoc, "member cannot contradict block", "stream", "");
}
- // "This includes a block's inheritance of the
- // current global default buffer, a block member's inheritance of the block's
- // buffer, and the requirement that any *xfb_buffer* declared on a block
+ // "This includes a block's inheritance of the
+ // current global default buffer, a block member's inheritance of the block's
+ // buffer, and the requirement that any *xfb_buffer* declared on a block
// member must match the buffer inherited from the block."
if (memberQualifier.hasXfbBuffer()) {
if (defaultQualification.layoutXfbBuffer != memberQualifier.layoutXfbBuffer)
@@ -5389,15 +6079,15 @@ void HlslParseContext::finalizeGlobalUniformBlockLayout(TVariable& block)
}
//
-// "For a block, this process applies to the entire block, or until the first member
-// is reached that has a location layout qualifier. When a block member is declared with a location
+// "For a block, this process applies to the entire block, or until the first member
+// is reached that has a location layout qualifier. When a block member is declared with a location
// qualifier, its location comes from that qualifier: The member's location qualifier overrides the block-level
-// declaration. Subsequent members are again assigned consecutive locations, based on the newest location,
-// until the next member declared with a location qualifier. The values used for locations do not have to be
+// declaration. Subsequent members are again assigned consecutive locations, based on the newest location,
+// until the next member declared with a location qualifier. The values used for locations do not have to be
// declared in increasing order."
void HlslParseContext::fixBlockLocations(const TSourceLoc& loc, TQualifier& qualifier, TTypeList& typeList, bool memberWithLocation, bool memberWithoutLocation)
{
- // "If a block has no block-level location layout qualifier, it is required that either all or none of its members
+ // "If a block has no block-level location layout qualifier, it is required that either all or none of its members
// have a location layout qualifier, or a compile-time error results."
if (! qualifier.hasLocation() && memberWithLocation && memberWithoutLocation)
error(loc, "either the block needs a location, or all members need a location, or no members have a location", "location", "");
@@ -5433,9 +6123,9 @@ void HlslParseContext::fixBlockLocations(const TSourceLoc& loc, TQualifier& qual
void HlslParseContext::fixBlockXfbOffsets(TQualifier& qualifier, TTypeList& typeList)
{
- // "If a block is qualified with xfb_offset, all its
- // members are assigned transform feedback buffer offsets. If a block is not qualified with xfb_offset, any
- // members of that block not qualified with an xfb_offset will not be assigned transform feedback buffer
+ // "If a block is qualified with xfb_offset, all its
+ // members are assigned transform feedback buffer offsets. If a block is not qualified with xfb_offset, any
+ // members of that block not qualified with an xfb_offset will not be assigned transform feedback buffer
// offsets."
if (! qualifier.hasXfbBuffer() || ! qualifier.hasXfbOffset())
@@ -5462,10 +6152,10 @@ void HlslParseContext::fixBlockXfbOffsets(TQualifier& qualifier, TTypeList& type
qualifier.layoutXfbOffset = TQualifier::layoutXfbOffsetEnd;
}
-// Calculate and save the offset of each block member, using the recursively
+// Calculate and save the offset of each block member, using the recursively
// defined block offset rules and the user-provided offset and align.
//
-// Also, compute and save the total size of the block. For the block's size, arrayness
+// Also, compute and save the total size of the block. For the block's size, arrayness
// is not taken into account, as each element is backed by a separate buffer.
//
void HlslParseContext::fixBlockUniformOffsets(const TQualifier& qualifier, TTypeList& typeList)
@@ -5491,25 +6181,25 @@ void HlslParseContext::fixBlockUniformOffsets(const TQualifier& qualifier, TType
subMatrixLayout != ElmNone ? subMatrixLayout == ElmRowMajor
: qualifier.layoutMatrix == ElmRowMajor);
if (memberQualifier.hasOffset()) {
- // "The specified offset must be a multiple
+ // "The specified offset must be a multiple
// of the base alignment of the type of the block member it qualifies, or a compile-time error results."
if (! IsMultipleOfPow2(memberQualifier.layoutOffset, memberAlignment))
error(memberLoc, "must be a multiple of the member's alignment", "offset", "");
- // "The offset qualifier forces the qualified member to start at or after the specified
- // integral-constant expression, which will be its byte offset from the beginning of the buffer.
- // "The actual offset of a member is computed as
+ // "The offset qualifier forces the qualified member to start at or after the specified
+ // integral-constant expression, which will be its byte offset from the beginning of the buffer.
+ // "The actual offset of a member is computed as
// follows: If offset was declared, start with that offset, otherwise start with the next available offset."
offset = std::max(offset, memberQualifier.layoutOffset);
}
- // "The actual alignment of a member will be the greater of the specified align alignment and the standard
+ // "The actual alignment of a member will be the greater of the specified align alignment and the standard
// (e.g., std140) base alignment for the member's type."
if (memberQualifier.hasAlign())
memberAlignment = std::max(memberAlignment, memberQualifier.layoutAlign);
// "If the resulting offset is not a multiple of the actual alignment,
- // increase it to the first offset that is a multiple of
+ // increase it to the first offset that is a multiple of
// the actual alignment."
RoundToPow2(offset, memberAlignment);
typeList[member].type->getQualifier().layoutOffset = offset;
@@ -5789,7 +6479,15 @@ void HlslParseContext::renameShaderFunction(TString*& name) const
// Replace the entry point name given in the shader with the real entry point name,
// if there is a substitution.
if (name != nullptr && *name == sourceEntryPointName)
- name = new TString(intermediate.getEntryPointName().c_str());
+ name = NewPoolTString(intermediate.getEntryPointName().c_str());
+}
+
+// post-processing
+void HlslParseContext::finish()
+{
+ addInterstageIoToLinkage();
+
+ TParseContextBase::finish();
}
} // end namespace glslang
diff --git a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslParseHelper.h b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslParseHelper.h
index d017a2a7cd3..1bfca8f8718 100644
--- a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslParseHelper.h
+++ b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslParseHelper.h
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2016 Google, Inc.
-//Copyright (C) 2016 LunarG, Inc.
+// Copyright (C) 2016 Google, Inc.
+// Copyright (C) 2016 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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.
//
#ifndef HLSL_PARSE_INCLUDED_
#define HLSL_PARSE_INCLUDED_
@@ -73,18 +73,20 @@ public:
void assignLocations(TVariable& variable);
TFunction& handleFunctionDeclarator(const TSourceLoc&, TFunction& function, bool prototype);
TIntermAggregate* handleFunctionDefinition(const TSourceLoc&, TFunction&, const TAttributeMap&);
+ void transformEntryPoint(const TSourceLoc&, TFunction&, const TAttributeMap&);
void handleFunctionBody(const TSourceLoc&, TFunction&, TIntermNode* functionBody, TIntermNode*& node);
void remapEntryPointIO(TFunction& function);
void remapNonEntryPointIO(TFunction& function);
TIntermNode* handleReturnValue(const TSourceLoc&, TIntermTyped*);
void handleFunctionArgument(TFunction*, TIntermTyped*& arguments, TIntermTyped* newArg);
- TIntermTyped* handleAssign(const TSourceLoc&, TOperator, TIntermTyped* left, TIntermTyped* right) const;
- TIntermTyped* handleFunctionCall(const TSourceLoc&, TFunction*, TIntermNode*);
+ TIntermTyped* handleAssign(const TSourceLoc&, TOperator, TIntermTyped* left, TIntermTyped* right);
+ TIntermTyped* handleAssignToMatrixSwizzle(const TSourceLoc&, TOperator, TIntermTyped* left, TIntermTyped* right);
+ TIntermTyped* handleFunctionCall(const TSourceLoc&, TFunction*, TIntermTyped*);
void decomposeIntrinsic(const TSourceLoc&, TIntermTyped*& node, TIntermNode* arguments);
void decomposeSampleMethods(const TSourceLoc&, TIntermTyped*& node, TIntermNode* arguments);
void decomposeGeometryMethods(const TSourceLoc&, TIntermTyped*& node, TIntermNode* arguments);
TIntermTyped* handleLengthMethod(const TSourceLoc&, TFunction*, TIntermNode*);
- void addInputArgumentConversions(const TFunction&, TIntermNode*&);
+ void addInputArgumentConversions(const TFunction&, TIntermTyped*&);
TIntermTyped* addOutputArgumentConversions(const TFunction&, TIntermOperator&);
void builtInOpCheck(const TSourceLoc&, const TFunction&, TIntermOperator&);
TFunction* handleConstructorCall(const TSourceLoc&, const TType&);
@@ -96,7 +98,8 @@ public:
TIntermAggregate* handleSamplerTextureCombine(const TSourceLoc& loc, TIntermTyped* argTex, TIntermTyped* argSampler);
- bool parseVectorFields(const TSourceLoc&, const TString&, int vecSize, TVectorFields&);
+ bool parseMatrixSwizzleSelector(const TSourceLoc&, const TString&, int cols, int rows, TSwizzleSelectors<TMatrixSelector>&);
+ int getMatrixComponentsColumn(int rows, const TSwizzleSelectors<TMatrixSelector>&);
void assignError(const TSourceLoc&, const char* op, TString left, TString right);
void unaryOpError(const TSourceLoc&, const char* op, TString operand);
void binaryOpError(const TSourceLoc&, const char* op, TString left, TString right);
@@ -126,7 +129,7 @@ public:
void mergeObjectLayoutQualifiers(TQualifier& dest, const TQualifier& src, bool inheritOnly);
void checkNoShaderLayouts(const TSourceLoc&, const TShaderQualifiers&);
- const TFunction* findFunction(const TSourceLoc& loc, const TFunction& call, bool& builtIn, TIntermNode* args);
+ const TFunction* findFunction(const TSourceLoc& loc, TFunction& call, bool& builtIn, TIntermTyped*& args);
void declareTypedef(const TSourceLoc&, TString& identifier, const TType&, TArraySizes* typeArray = 0);
TIntermNode* declareVariable(const TSourceLoc&, TString& identifier, TType&, TIntermTyped* initializer = 0);
void lengthenList(const TSourceLoc&, TIntermSequence& list, int size);
@@ -183,8 +186,12 @@ protected:
int nextBinding; // next binding to use.
};
+ void fixConstInit(const TSourceLoc&, TString& identifier, TType& type, TIntermTyped*& initializer);
void inheritGlobalDefaults(TQualifier& dst) const;
TVariable* makeInternalVariable(const char* name, const TType&) const;
+ TVariable* makeInternalVariable(const TString& name, const TType& type) const {
+ return makeInternalVariable(name.c_str(), type);
+ }
TVariable* declareNonArray(const TSourceLoc&, TString& identifier, TType&, bool track);
void declareArray(const TSourceLoc&, TString& identifier, const TType&, TSymbol*&, bool track);
TIntermNode* executeInitializer(const TSourceLoc&, TIntermTyped* initializer, TVariable* variable);
@@ -197,7 +204,7 @@ protected:
// Array and struct flattening
bool shouldFlatten(const TType& type) const;
- TIntermTyped* flattenAccess(const TSourceLoc&, TIntermTyped* base, int member);
+ TIntermTyped* flattenAccess(TIntermTyped* base, int member);
bool shouldFlattenIO(const TType&) const;
bool shouldFlattenUniform(const TType&) const;
bool wasFlattened(const TIntermTyped* node) const;
@@ -205,11 +212,30 @@ protected:
int addFlattenedMember(const TSourceLoc& loc, const TVariable&, const TType&, TFlattenData&, const TString& name, bool track);
bool isFinalFlattening(const TType& type) const { return !(type.isStruct() || type.isArray()); }
+ // Structure splitting (splits interstage builtin types into its own struct)
+ bool shouldSplit(const TType&);
+ TIntermTyped* splitAccessStruct(const TSourceLoc& loc, TIntermTyped*& base, int& member);
+ void splitAccessArray(const TSourceLoc& loc, TIntermTyped* base, TIntermTyped* index);
+ TType& split(TType& type, TString name, const TType* outerStructType = nullptr);
+ void split(TIntermTyped*);
+ void split(const TVariable&);
+ bool wasSplit(const TIntermTyped* node) const;
+ bool wasSplit(int id) const { return splitIoVars.find(id) != splitIoVars.end(); }
+ TVariable* getSplitIoVar(const TIntermTyped* node) const;
+ TVariable* getSplitIoVar(const TVariable* var) const;
+ TVariable* getSplitIoVar(int id) const;
+ void addInterstageIoToLinkage();
+
void flatten(const TSourceLoc& loc, const TVariable& variable);
int flatten(const TSourceLoc& loc, const TVariable& variable, const TType&, TFlattenData&, TString name);
int flattenStruct(const TSourceLoc& loc, const TVariable& variable, const TType&, TFlattenData&, TString name);
int flattenArray(const TSourceLoc& loc, const TVariable& variable, const TType&, TFlattenData&, TString name);
+ // Type sanitization: return existing sanitized (temporary) type if there is one, else make new one.
+ TType* sanitizeType(TType*);
+
+ void finish() override; // post-processing
+
// Current state of parsing
struct TPragma contextPragma;
int loopNestingLevel; // 0 if outside all loops
@@ -263,7 +289,7 @@ protected:
// * note, that appropriately gives an error if redeclaring a block that
// was already used and hence already copied-up
//
- // - on seeing a layout declaration that sizes the array, fix everything in the
+ // - on seeing a layout declaration that sizes the array, fix everything in the
// resize-list, giving errors for mismatch
//
// - on seeing an array size declaration, give errors on mismatch between it and previous
@@ -275,6 +301,38 @@ protected:
TVector<int> flattenLevel; // nested postfix operator level for flattening
TVector<int> flattenOffset; // cumulative offset for flattening
+ // Sanitized type map. During declarations we use the sanitized form of the type
+ // if it exists.
+ TMap<const TTypeList*, TType*> sanitizedTypeMap;
+
+ // Structure splitting data:
+ TMap<int, TVariable*> splitIoVars; // variables with the builtin interstage IO removed, indexed by unique ID.
+
+ // The builtin interstage IO map considers e.g, EvqPosition on input and output separately, so that we
+ // can build the linkage correctly if position appears on both sides. Otherwise, multiple positions
+ // are considered identical.
+ struct tInterstageIoData {
+ tInterstageIoData(const TType& memberType, const TType& storageType) :
+ builtIn(memberType.getQualifier().builtIn),
+ storage(storageType.getQualifier().storage) { }
+
+ TBuiltInVariable builtIn;
+ TStorageQualifier storage;
+
+ // ordering for maps
+ bool operator<(const tInterstageIoData d) const {
+ return (builtIn != d.builtIn) ? (builtIn < d.builtIn) : (storage < d.storage);
+ }
+ };
+
+ TMap<tInterstageIoData, TVariable*> interstageBuiltInIo; // individual builtin interstage IO vars, inxed by builtin type.
+
+ // We have to move array references to structs containing builtin interstage IO to the split variables.
+ // This is only handled for one level. This stores the index, because we'll need it in the future, since
+ // unlike normal array references, here the index happens before we discover what it applies to.
+ TIntermTyped* builtInIoIndex;
+ TIntermTyped* builtInIoBase;
+
unsigned int nextInLocation;
unsigned int nextOutLocation;
diff --git a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslParseables.cpp b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslParseables.cpp
index 8ecaec9dd56..442f3b17542 100644
--- a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslParseables.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslParseables.cpp
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2016 LunarG, Inc.
+// Copyright (C) 2016 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,22 +19,22 @@
// 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.
+// 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.
//
//
-// Create strings that declare built-in definitions, add built-ins programmatically
+// Create strings that declare built-in definitions, add built-ins programmatically
// that cannot be expressed in the strings, and establish mappings between
// built-in functions and operators.
//
@@ -102,14 +102,14 @@ bool IsIllegalSample(const glslang::TString& name, const char* argOrder, int dim
return true;
}
- const bool isGather =
- (name == "Gather" ||
+ const bool isGather =
+ (name == "Gather" ||
name == "GatherRed" ||
- name == "GatherGreen" ||
+ name == "GatherGreen" ||
name == "GatherBlue" ||
name == "GatherAlpha");
- const bool isGatherCmp =
+ const bool isGatherCmp =
(name == "GatherCmpRed" ||
name == "GatherCmpGreen" ||
name == "GatherCmpBlue" ||
@@ -174,7 +174,7 @@ const char* IoParam(glslang::TString& s, const char* nthArgOrder)
} else if (*nthArgOrder == '<') { // input params
++nthArgOrder;
s.append("in ");
- }
+ }
return nthArgOrder;
}
@@ -195,9 +195,8 @@ inline bool IsEndOfArg(const char* arg)
return arg == nullptr || *arg == '\0' || *arg == ',';
}
-
// If this is a fixed vector size, such as V3, return the size. Else return 0.
-int FixedVecSize(const char* arg)
+int FixedVecSize(const char* arg)
{
while (!IsEndOfArg(arg)) {
if (isdigit(*arg))
@@ -208,7 +207,6 @@ int FixedVecSize(const char* arg)
return 0; // none found.
}
-
// Create and return a type name. This is done in GLSL, not HLSL conventions, until such
// time as builtins are parsed using the HLSL parser.
//
@@ -229,7 +227,7 @@ glslang::TString& AppendTypeName(glslang::TString& s, const char* argOrder, cons
char type = *argType;
if (isTranspose) { // Take transpose of matrix dimensions
- std::swap(dim0, dim1);
+ std::swap(dim0, dim1);
} else if (isTexture) {
if (type == 'F') // map base type to texture of that type.
type = 'T'; // e.g, int -> itexture, uint -> utexture, etc.
@@ -255,10 +253,10 @@ glslang::TString& AppendTypeName(glslang::TString& s, const char* argOrder, cons
case 'S': s += "sampler"; break;
case 's': s += "SamplerComparisonState"; break;
case 'T': s += ((isBuffer && isImage) ? "RWBuffer" :
- isBuffer ? "Buffer" :
+ isBuffer ? "Buffer" :
isImage ? "RWTexture" : "Texture"); break;
case 'i': s += ((isBuffer && isImage) ? "RWBuffer" :
- isBuffer ? "Buffer" :
+ isBuffer ? "Buffer" :
isImage ? "RWTexture" : "Texture"); break;
case 'u': s += ((isBuffer && isImage) ? "RWBuffer" :
isBuffer ? "Buffer" :
@@ -322,7 +320,7 @@ glslang::TString& AppendTypeName(glslang::TString& s, const char* argOrder, cons
case 'V':
s += ('0' + char(dim0));
break;
- case 'M':
+ case 'M':
s += ('0' + char(dim0));
s += 'x';
s += ('0' + char(dim1));
@@ -389,7 +387,6 @@ inline bool IsValid(const char* cname, char retOrder, char retType, char argOrde
return true;
}
-
// return position of end of argument specifier
inline const char* FindEndOfArg(const char* arg)
{
@@ -424,7 +421,7 @@ inline void FindVectorMatrixBounds(const char* argOrder, int fixedVecSize, int&
if (fixedVecSize > 0) // handle fixed sized vectors
dim0Min = dim0Max = fixedVecSize;
}
-
+
} // end anonymous namespace
namespace glslang {
@@ -433,7 +430,6 @@ TBuiltInParseablesHlsl::TBuiltInParseablesHlsl()
{
}
-
//
// Handle creation of mat*mat specially, since it doesn't fall conveniently out of
// the generic prototype creation code below.
@@ -476,7 +472,6 @@ void TBuiltInParseablesHlsl::createMatTimesMat()
s.append(");\n"); // close paren
-
// Create V*M
AppendTypeName(s, "V", "F", xCols, 1); // add return type
s.append(" "); // space between type and name
@@ -508,7 +503,7 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c
// needed for furture validation. For now, they are commented out, and set below
// to EShLangAll, to allow any intrinsic to be used in any shader, which is legal
// if it is not called.
- //
+ //
// static const EShLanguageMask EShLangPSCS = EShLanguageMask(EShLangFragmentMask | EShLangComputeMask);
// static const EShLanguageMask EShLangVSPSGS = EShLanguageMask(EShLangVertexMask | EShLangFragmentMask | EShLangGeometryMask);
// static const EShLanguageMask EShLangCS = EShLangComputeMask;
@@ -586,7 +581,7 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c
{ "DeviceMemoryBarrier", nullptr, nullptr, "-", "-", EShLangPSCS },
{ "DeviceMemoryBarrierWithGroupSync", nullptr, nullptr, "-", "-", EShLangCS },
{ "distance", "S", "F", "V,", "F,", EShLangAll },
- { "dot", "S", nullptr, "V,", "FI,", EShLangAll },
+ { "dot", "S", nullptr, "SV,", "FI,", EShLangAll },
{ "dst", nullptr, nullptr, "V4,", "F,", EShLangAll },
// { "errorf", "-", "-", "", "", EShLangAll }, TODO: varargs
{ "EvaluateAttributeAtCentroid", nullptr, nullptr, "SVM", "F", EShLangPS },
@@ -745,7 +740,7 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c
{ "GetSamplePosition", "V2", "F", "$&2,S", "FUI,I", EShLangVSPSGS },
- //
+ //
// UINT Width
// UINT MipLevel, UINT Width, UINT NumberOfLevels
{ "GetDimensions", /* 1D */ "-", "-", "%!~1,>S", "FUI,U", EShLangAll },
@@ -947,7 +942,7 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c
AppendTypeName(s, nthArgOrder, nthArgType, argDim0, dim1); // Add arguments
}
-
+
s.append(");\n"); // close paren and trailing semicolon
} // dim 1 loop
} // dim 0 loop
@@ -956,10 +951,10 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c
// skip over special characters
if (isTexture && isalpha(argOrder[1]))
++argOrder;
- if (isdigit(argOrder[1]))
+ if (isdigit(argOrder[1]))
++argOrder;
} // arg order loop
-
+
if (intrinsic.stage == EShLangAll) // common builtins are only added once.
break;
}
@@ -988,7 +983,6 @@ void TBuiltInParseablesHlsl::initialize(const TBuiltInResource& /*resources*/, i
{
}
-
//
// Finish adding/processing context-independent built-in symbols.
// 1) Programmatically add symbols that could not be added by simple text strings above.
@@ -1022,7 +1016,7 @@ void TBuiltInParseablesHlsl::identifyBuiltIns(int /*version*/, EProfile /*profil
symbolTable.relateToOperator("cosh", EOpCosh);
symbolTable.relateToOperator("countbits", EOpBitCount);
symbolTable.relateToOperator("cross", EOpCross);
- // symbolTable.relateToOperator("D3DCOLORtoUBYTE4", EOpD3DCOLORtoUBYTE4);
+ symbolTable.relateToOperator("D3DCOLORtoUBYTE4", EOpD3DCOLORtoUBYTE4);
symbolTable.relateToOperator("ddx", EOpDPdx);
symbolTable.relateToOperator("ddx_coarse", EOpDPdxCoarse);
symbolTable.relateToOperator("ddx_fine", EOpDPdxFine);
@@ -1167,7 +1161,7 @@ void TBuiltInParseablesHlsl::identifyBuiltIns(int /*version*/, EProfile /*profil
//
// Add context-dependent (resource-specific) built-ins not handled by the above. These
-// would be ones that need to be programmatically added because they cannot
+// would be ones that need to be programmatically added because they cannot
// be added by simple text strings. For these, also
// 1) Map built-in functions to operators, for those that will turn into an operation node
// instead of remaining a function call.
@@ -1179,5 +1173,4 @@ void TBuiltInParseablesHlsl::identifyBuiltIns(int /*version*/, EProfile /*profil
{
}
-
} // end namespace glslang
diff --git a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslParseables.h b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslParseables.h
index c8375900308..28f424b3172 100644
--- a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslParseables.h
+++ b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslParseables.h
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2016 LunarG, Inc.
+// Copyright (C) 2016 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
#ifndef _HLSLPARSEABLES_INCLUDED_
@@ -52,7 +52,7 @@ public:
void initialize(const TBuiltInResource& resources, int version, EProfile, const SpvVersion& spvVersion, EShLanguage);
void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable);
-
+
void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources);
private:
diff --git a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslScanContext.cpp b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslScanContext.cpp
index 3ae19fc7e01..69c1e37f869 100644
--- a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslScanContext.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslScanContext.cpp
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2016 Google, Inc.
-//Copyright (C) 2016 LunarG, Inc.
+// Copyright (C) 2016 Google, Inc.
+// Copyright (C) 2016 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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.
//
//
@@ -52,7 +52,7 @@
// preprocessor includes
#include "../glslang/MachineIndependent/preprocessor/PpContext.h"
#include "../glslang/MachineIndependent/preprocessor/PpTokens.h"
-
+
namespace {
struct str_eq
@@ -142,7 +142,7 @@ void HlslScanContext::fillInKeywordMap()
(*KeywordMap)["half"] = EHTokHalf;
(*KeywordMap)["float"] = EHTokFloat;
(*KeywordMap)["double"] = EHTokDouble;
- (*KeywordMap)["min16float"] = EHTokMin16float;
+ (*KeywordMap)["min16float"] = EHTokMin16float;
(*KeywordMap)["min10float"] = EHTokMin10float;
(*KeywordMap)["min16int"] = EHTokMin16int;
(*KeywordMap)["min12int"] = EHTokMin12int;
@@ -169,6 +169,10 @@ void HlslScanContext::fillInKeywordMap()
(*KeywordMap)["uint3"] = EHTokUint3;
(*KeywordMap)["uint4"] = EHTokUint4;
+ (*KeywordMap)["half1"] = EHTokHalf1;
+ (*KeywordMap)["half2"] = EHTokHalf2;
+ (*KeywordMap)["half3"] = EHTokHalf3;
+ (*KeywordMap)["half4"] = EHTokHalf4;
(*KeywordMap)["min16float1"] = EHTokMin16float1;
(*KeywordMap)["min16float2"] = EHTokMin16float2;
(*KeywordMap)["min16float3"] = EHTokMin16float3;
@@ -312,7 +316,6 @@ void HlslScanContext::fillInKeywordMap()
(*KeywordMap)["RWTexture3D"] = EHTokRWTexture3d;
(*KeywordMap)["RWBuffer"] = EHTokRWBuffer;
-
(*KeywordMap)["struct"] = EHTokStruct;
(*KeywordMap)["cbuffer"] = EHTokCBuffer;
(*KeywordMap)["tbuffer"] = EHTokTBuffer;
@@ -336,7 +339,7 @@ void HlslScanContext::fillInKeywordMap()
// TODO: get correct set here
ReservedSet = new std::unordered_set<const char*, str_hash, str_eq>;
-
+
ReservedSet->insert("auto");
ReservedSet->insert("catch");
ReservedSet->insert("char");
@@ -579,6 +582,10 @@ EHlslTokenClass HlslScanContext::tokenizeIdentifier()
case EHTokUint2:
case EHTokUint3:
case EHTokUint4:
+ case EHTokHalf1:
+ case EHTokHalf2:
+ case EHTokHalf3:
+ case EHTokHalf4:
case EHTokMin16float1:
case EHTokMin16float2:
case EHTokMin16float3:
diff --git a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslScanContext.h b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslScanContext.h
index 144a85343f5..b931d9be9bd 100644
--- a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslScanContext.h
+++ b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslScanContext.h
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2016 Google, Inc.
+// Copyright (C) 2016 Google, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
//
diff --git a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslTokenStream.cpp b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslTokenStream.cpp
index c915e0b593b..b458ba47cff 100644
--- a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslTokenStream.cpp
+++ b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslTokenStream.cpp
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2016 Google, Inc.
+// Copyright (C) 2016 Google, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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 "hlslTokenStream.h"
diff --git a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslTokenStream.h b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslTokenStream.h
index ec4288943e6..95589988885 100644
--- a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslTokenStream.h
+++ b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslTokenStream.h
@@ -1,11 +1,11 @@
//
-//Copyright (C) 2016 Google, Inc.
+// Copyright (C) 2016 Google, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -19,18 +19,18 @@
// 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.
+// 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.
//
#ifndef HLSLTOKENSTREAM_H_
diff --git a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslTokens.h b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslTokens.h
index 6902070cbe3..ae267705e25 100644
--- a/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslTokens.h
+++ b/3rdparty/bgfx/3rdparty/glslang/hlsl/hlslTokens.h
@@ -1,12 +1,12 @@
//
-//Copyright (C) 2016 Google, Inc.
-//Copyright (C) 2016 LunarG, Inc.
+// Copyright (C) 2016 Google, Inc.
+// Copyright (C) 2016 LunarG, Inc.
//
-//All rights reserved.
+// All rights reserved.
//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
+// 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.
@@ -20,18 +20,18 @@
// 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.
+// 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.
//
#ifndef EHLSLTOKENS_H_
@@ -120,6 +120,10 @@ enum EHlslTokenClass {
EHTokUint2,
EHTokUint3,
EHTokUint4,
+ EHTokHalf1,
+ EHTokHalf2,
+ EHTokHalf3,
+ EHTokHalf4,
EHTokMin16float1,
EHTokMin16float2,
EHTokMin16float3,
@@ -247,7 +251,6 @@ enum EHlslTokenClass {
EHTokRWTexture2darray,
EHTokRWTexture3d,
EHTokRWBuffer,
-
// variable, user type, ...
EHTokIdentifier,
diff --git a/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.cpp b/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.cpp
index 4c0c02b950d..db8ce64e9cb 100644
--- a/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.cpp
+++ b/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.cpp
@@ -1316,7 +1316,7 @@ FILE* ImFileOpen(const char* filename, const char* mode)
// Load file content into memory
// Memory allocated with ImGui::MemAlloc(), must be freed by user using ImGui::MemFree()
-void* ImLoadFileToMemory(const char* filename, const char* file_open_mode, int* out_file_size, int padding_bytes)
+void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, int* out_file_size, int padding_bytes)
{
IM_ASSERT(filename && file_open_mode);
if (out_file_size)
@@ -1863,7 +1863,7 @@ ImGuiWindow* ImGui::GetParentWindow()
return g.CurrentWindowStack[(unsigned int)g.CurrentWindowStack.Size - 2];
}
-void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window = NULL)
+void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
{
ImGuiContext& g = *GImGui;
g.ActiveId = id;
@@ -1874,6 +1874,11 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window = NULL)
g.ActiveIdWindow = window;
}
+void ImGui::ClearActiveID()
+{
+ SetActiveID(0, NULL);
+}
+
void ImGui::SetHoveredID(ImGuiID id)
{
ImGuiContext& g = *GImGui;
@@ -2209,7 +2214,7 @@ void ImGui::NewFrame()
g.HoveredId = 0;
g.HoveredIdAllowOverlap = false;
if (!g.ActiveIdIsAlive && g.ActiveIdPreviousFrame == g.ActiveId && g.ActiveId != 0)
- SetActiveID(0);
+ ClearActiveID();
g.ActiveIdPreviousFrame = g.ActiveId;
g.ActiveIdIsAlive = false;
g.ActiveIdIsJustActivated = false;
@@ -2232,7 +2237,7 @@ void ImGui::NewFrame()
}
else
{
- SetActiveID(0);
+ ClearActiveID();
g.MovedWindow = NULL;
g.MovedWindowMoveId = 0;
}
@@ -2462,7 +2467,7 @@ static void LoadIniSettingsFromDisk(const char* ini_filename)
return;
int file_size;
- char* file_data = (char*)ImLoadFileToMemory(ini_filename, "rb", &file_size, 1);
+ char* file_data = (char*)ImFileLoadToMemory(ini_filename, "rb", &file_size, 1);
if (!file_data)
return;
@@ -4219,7 +4224,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
ApplySizeFullWithConstraint(window, size_auto_fit);
if (!(flags & ImGuiWindowFlags_NoSavedSettings))
MarkIniSettingsDirty();
- SetActiveID(0);
+ ClearActiveID();
}
else if (held)
{
@@ -4568,7 +4573,7 @@ void ImGui::FocusWindow(ImGuiWindow* window)
// Steal focus on active widgets
if (window->Flags & ImGuiWindowFlags_Popup) // FIXME: This statement should be unnecessary. Need further testing before removing it..
if (g.ActiveId != 0 && g.ActiveIdWindow && g.ActiveIdWindow->RootWindow != window)
- SetActiveID(0);
+ ClearActiveID();
// Bring to front
if ((window->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus) || g.Windows.back() == window)
@@ -5542,7 +5547,7 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
{
if (out_hovered) *out_hovered = false;
if (out_held) *out_held = false;
- if (g.ActiveId == id) SetActiveID(0);
+ if (g.ActiveId == id) ClearActiveID();
return false;
}
@@ -5570,14 +5575,14 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
if (((flags & ImGuiButtonFlags_PressedOnClick) && g.IO.MouseClicked[0]) || ((flags & ImGuiButtonFlags_PressedOnDoubleClick) && g.IO.MouseDoubleClicked[0]))
{
pressed = true;
- SetActiveID(0);
+ ClearActiveID();
FocusWindow(window);
}
if ((flags & ImGuiButtonFlags_PressedOnRelease) && g.IO.MouseReleased[0])
{
if (!((flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[0] >= g.IO.KeyRepeatDelay)) // Repeat mode trumps <on release>
pressed = true;
- SetActiveID(0);
+ ClearActiveID();
}
// 'Repeat' mode acts when held regardless of _PressedOn flags (see table above).
@@ -5599,7 +5604,7 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
if (hovered && (flags & ImGuiButtonFlags_PressedOnClickRelease))
if (!((flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[0] >= g.IO.KeyRepeatDelay)) // Repeat mode trumps <on release>
pressed = true;
- SetActiveID(0);
+ ClearActiveID();
}
}
@@ -6564,7 +6569,7 @@ bool ImGui::SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v
}
else
{
- SetActiveID(0);
+ ClearActiveID();
}
}
@@ -6880,7 +6885,7 @@ bool ImGui::DragBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v_s
}
else
{
- SetActiveID(0);
+ ClearActiveID();
}
}
@@ -7783,7 +7788,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
{
// Release focus when we click outside
if (g.ActiveId == id)
- SetActiveID(0);
+ ClearActiveID();
}
bool value_changed = false;
@@ -7885,7 +7890,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
bool ctrl_enter_for_new_line = (flags & ImGuiInputTextFlags_CtrlEnterForNewLine) != 0;
if (!is_multiline || (ctrl_enter_for_new_line && !io.KeyCtrl) || (!ctrl_enter_for_new_line && io.KeyCtrl))
{
- SetActiveID(0);
+ ClearActiveID();
enter_pressed = true;
}
else if (is_editable)
@@ -7901,7 +7906,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
if (InputTextFilterCharacter(&c, flags, callback, user_data))
edit_state.OnKeyPressed((int)c);
}
- else if (IsKeyPressedMap(ImGuiKey_Escape)) { SetActiveID(0); cancel_edit = true; }
+ else if (IsKeyPressedMap(ImGuiKey_Escape)) { ClearActiveID(); cancel_edit = true; }
else if (is_shortcut_key_only && IsKeyPressedMap(ImGuiKey_Z) && is_editable) { edit_state.OnKeyPressed(STB_TEXTEDIT_K_UNDO); edit_state.ClearSelection(); }
else if (is_shortcut_key_only && IsKeyPressedMap(ImGuiKey_Y) && is_editable) { edit_state.OnKeyPressed(STB_TEXTEDIT_K_REDO); edit_state.ClearSelection(); }
else if (is_shortcut_key_only && IsKeyPressedMap(ImGuiKey_A)) { edit_state.SelectAll(); edit_state.CursorFollow = true; }
@@ -8496,7 +8501,7 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
SetHoveredID(id);
if (g.IO.MouseClicked[0])
{
- SetActiveID(0);
+ ClearActiveID();
if (IsPopupOpen(id))
{
ClosePopup(id);
@@ -8545,7 +8550,7 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
item_text = "*Unknown item*";
if (Selectable(item_text, item_selected))
{
- SetActiveID(0);
+ ClearActiveID();
value_changed = true;
*current_item = i;
}
diff --git a/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.h b/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.h
index a25d18f3aa6..f698f0be874 100644
--- a/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.h
+++ b/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.h
@@ -372,7 +372,7 @@ namespace ImGui
// Popups
IMGUI_API void OpenPopup(const char* str_id); // mark popup as open. popups are closed when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level).
IMGUI_API bool BeginPopup(const char* str_id); // return true if the popup is open, and you can start outputting to it. only call EndPopup() if BeginPopup() returned true!
- IMGUI_API bool BeginPopupModal(const char* name, bool* p_open = NULL, ImGuiWindowFlags extra_flags = 0); // modal dialog (can't close them by clicking outside)
+ IMGUI_API bool BeginPopupModal(const char* name, bool* p_open = NULL, ImGuiWindowFlags extra_flags = 0); // modal dialog (block interactions behind the modal window, can't close the modal window by clicking outside)
IMGUI_API bool BeginPopupContextItem(const char* str_id, int mouse_button = 1); // helper to open and begin popup when clicked on last item. read comments in .cpp!
IMGUI_API bool BeginPopupContextWindow(bool also_over_items = true, const char* str_id = NULL, int mouse_button = 1); // helper to open and begin popup when clicked on current window.
IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, int mouse_button = 1); // helper to open and begin popup when clicked in void (no window).
diff --git a/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_demo.cpp b/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_demo.cpp
index 894492367e1..c08de0ccf3e 100644
--- a/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_demo.cpp
+++ b/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_demo.cpp
@@ -362,7 +362,7 @@ void ImGui::ShowTestWindow(bool* p_open)
ImVec2 pos = ImGui::GetCursorScreenPos();
ImGui::GetWindowDrawList()->AddRectFilled(ImVec2(pos.x + wrap_width, pos.y), ImVec2(pos.x + wrap_width + 10, pos.y + ImGui::GetTextLineHeight()), IM_COL32(255,0,255,255));
ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + wrap_width);
- ImGui::Text("lazy dog. This paragraph is made to fit within %.0f pixels. The quick brown fox jumps over the lazy dog.", wrap_width);
+ ImGui::Text("The lazy dog is a good dog. This paragraph is made to fit within %.0f pixels. Testing a 1 character word. The quick brown fox jumps over the lazy dog.", wrap_width);
ImGui::GetWindowDrawList()->AddRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), IM_COL32(255,255,0,255));
ImGui::PopTextWrapPos();
@@ -370,7 +370,7 @@ void ImGui::ShowTestWindow(bool* p_open)
pos = ImGui::GetCursorScreenPos();
ImGui::GetWindowDrawList()->AddRectFilled(ImVec2(pos.x + wrap_width, pos.y), ImVec2(pos.x + wrap_width + 10, pos.y + ImGui::GetTextLineHeight()), IM_COL32(255,0,255,255));
ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + wrap_width);
- ImGui::Text("aaaaaaaa bbbbbbbb, cccccccc,dddddddd. eeeeeeee ffffffff. gggggggg!hhhhhhhh");
+ ImGui::Text("aaaaaaaa bbbbbbbb, c cccccccc,dddddddd. d eeeeeeee ffffffff. gggggggg!hhhhhhhh");
ImGui::GetWindowDrawList()->AddRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), IM_COL32(255,255,0,255));
ImGui::PopTextWrapPos();
@@ -2317,7 +2317,7 @@ struct ExampleAppConsole
for (int i = 0; i < candidates.Size && all_candidates_matches; i++)
if (i == 0)
c = toupper(candidates[i][match_len]);
- else if (c != toupper(candidates[i][match_len]))
+ else if (c == 0 || c != toupper(candidates[i][match_len]))
all_candidates_matches = false;
if (!all_candidates_matches)
break;
diff --git a/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_draw.cpp b/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_draw.cpp
index 0aa8c750af6..8b3b2ec1489 100644
--- a/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_draw.cpp
+++ b/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_draw.cpp
@@ -1197,7 +1197,7 @@ ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template)
ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
{
int data_size = 0;
- void* data = ImLoadFileToMemory(filename, "rb", &data_size, 0);
+ void* data = ImFileLoadToMemory(filename, "rb", &data_size, 0);
if (!data)
{
IM_ASSERT(0); // Could not load file.
@@ -1853,6 +1853,7 @@ const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, const c
{
line_width += blank_width;
blank_width = 0.0f;
+ word_end = s;
}
blank_width += char_width;
inside_word = false;
diff --git a/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_internal.h b/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_internal.h
index ff188b0f78e..effc5ce7fb2 100644
--- a/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_internal.h
+++ b/3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_internal.h
@@ -88,8 +88,8 @@ IMGUI_API int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, cons
// Helpers: Misc
IMGUI_API ImU32 ImHash(const void* data, int data_size, ImU32 seed = 0); // Pass data_size==0 for zero-terminated strings
-IMGUI_API void* ImLoadFileToMemory(const char* filename, const char* file_open_mode, int* out_file_size = NULL, int padding_bytes = 0);
-IMGUI_API FILE* ImOpenFile(const char* filename, const char* file_open_mode);
+IMGUI_API void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, int* out_file_size = NULL, int padding_bytes = 0);
+IMGUI_API FILE* ImFileOpen(const char* filename, const char* file_open_mode);
IMGUI_API bool ImIsPointInTriangle(const ImVec2& p, const ImVec2& a, const ImVec2& b, const ImVec2& c);
static inline bool ImCharIsSpace(int c) { return c == ' ' || c == '\t' || c == 0x3000; }
static inline int ImUpperPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; }
@@ -710,6 +710,7 @@ namespace ImGui
IMGUI_API void EndFrame(); // Ends the ImGui frame. Automatically called by Render()! you most likely don't need to ever call that yourself directly. If you don't need to render you can call EndFrame() but you'll have wasted CPU already. If you don't need to render, don't create any windows instead!
IMGUI_API void SetActiveID(ImGuiID id, ImGuiWindow* window);
+ IMGUI_API void ClearActiveID();
IMGUI_API void SetHoveredID(ImGuiID id);
IMGUI_API void KeepAliveID(ImGuiID id);
diff --git a/3rdparty/bgfx/3rdparty/ocornut-imgui/widgets/gizmo.h b/3rdparty/bgfx/3rdparty/ocornut-imgui/widgets/gizmo.h
index 7b398fefe51..caac98694bc 100644
--- a/3rdparty/bgfx/3rdparty/ocornut-imgui/widgets/gizmo.h
+++ b/3rdparty/bgfx/3rdparty/ocornut-imgui/widgets/gizmo.h
@@ -143,7 +143,7 @@ namespace ImGuizmo
{
TRANSLATE,
ROTATE,
- SCALE
+ SCALE,
};
enum MODE
@@ -152,5 +152,5 @@ namespace ImGuizmo
WORLD
};
- void Manipulate(const float *view, const float *projection, OPERATION operation, MODE mode, float *matrix, float *deltaMatrix = 0, float *snap = 0);
+ void Manipulate(const float *view, const float *projection, OPERATION operation, MODE mode, float *matrix, float *deltaMatrix = 0, float *snap = 0, float *localBounds = NULL, float *boundsSnap = NULL);
};
diff --git a/3rdparty/bgfx/3rdparty/ocornut-imgui/widgets/gizmo.inl b/3rdparty/bgfx/3rdparty/ocornut-imgui/widgets/gizmo.inl
index e578691f9c9..4843e86006a 100644
--- a/3rdparty/bgfx/3rdparty/ocornut-imgui/widgets/gizmo.inl
+++ b/3rdparty/bgfx/3rdparty/ocornut-imgui/widgets/gizmo.inl
@@ -89,7 +89,7 @@ namespace ImGuizmo
float LengthSq() const { return (x*x + y*y + z*z); };
vec_t Normalize() { (*this) *= (1.f / Length()); return (*this); }
vec_t Normalize(const vec_t& v) { this->Set(v.x, v.y, v.z, v.w); this->Normalize(); return (*this); }
-
+ vec_t Abs() const;
void Cross(const vec_t& v)
{
vec_t res;
@@ -136,7 +136,7 @@ namespace ImGuizmo
vec_t vec_t::operator - (const vec_t& v) const { return makeVect(x - v.x, y - v.y, z - v.z, w - v.w); }
vec_t vec_t::operator + (const vec_t& v) const { return makeVect(x + v.x, y + v.y, z + v.z, w + v.w); }
vec_t vec_t::operator * (const vec_t& v) const { return makeVect(x * v.x, y * v.y, z * v.z, w * v.w); }
-
+ vec_t vec_t::Abs() const { return makeVect(fabsf(x), fabsf(y), fabsf(z)); }
ImVec2 operator+ (const ImVec2& a, const ImVec2& b) { return ImVec2(a.x + b.x, a.y + b.y); }
vec_t Normalized(const vec_t& v) { vec_t res; res = v; res.Normalize(); return res; }
@@ -178,6 +178,7 @@ namespace ImGuizmo
{
vec_t right, up, dir, position;
} v;
+ vec_t component[4];
};
matrix_t(const matrix_t& other) { memcpy(&m16[0], &other.m16[0], sizeof(float) * 16); }
@@ -239,7 +240,6 @@ namespace ImGuizmo
}
float Inverse(const matrix_t &srcMatrix, bool affine = false);
- float Inverse(bool affine = false);
void SetToIdentity()
{
v.right.Set(1.f, 0.f, 0.f, 0.f);
@@ -481,11 +481,12 @@ namespace ImGuizmo
SCALE_Y,
SCALE_Z,
SCALE_XYZ,
+ BOUNDS
};
struct Context
{
- Context() : mbUsing(false), mbEnable(true)
+ Context() : mbUsing(false), mbEnable(true), mbUsingBounds(false)
{
}
@@ -540,6 +541,17 @@ namespace ImGuizmo
bool mBelowPlaneLimit[3];
float mAxisFactor[3];
+ // bounds stretching
+ vec_t mBoundsPivot;
+ vec_t mBoundsAnchor;
+ vec_t mBoundsPlan;
+ vec_t mBoundsLocalPivot;
+ int mBoundsBestAxis;
+ int mBoundsAxis[2];
+ bool mbUsingBounds;
+ matrix_t mBoundsMatrix;
+
+
//
int mCurrentOperation;
};
@@ -625,7 +637,7 @@ namespace ImGuizmo
bool IsUsing()
{
- return gContext.mbUsing;
+ return gContext.mbUsing||gContext.mbUsingBounds;
}
bool IsOver()
@@ -636,8 +648,11 @@ namespace ImGuizmo
void Enable(bool enable)
{
gContext.mbEnable = enable;
- if (!enable)
- gContext.mbUsing = false;
+ if (!enable)
+ {
+ gContext.mbUsing = false;
+ gContext.mbUsingBounds = false;
+ }
}
static float GetUniform(const vec_t& position, const matrix_t& mat)
@@ -770,22 +785,22 @@ namespace ImGuizmo
}
}
- static void ComputeSnap(float*value, float *snap)
+ static void ComputeSnap(float*value, float snap)
{
- if (*snap <= FLT_EPSILON)
+ if (snap <= FLT_EPSILON)
return;
- float modulo = fmodf(*value, *snap);
- float moduloRatio = fabsf(modulo) / *snap;
+ float modulo = fmodf(*value, snap);
+ float moduloRatio = fabsf(modulo) / snap;
if (moduloRatio < snapTension)
*value -= modulo;
else if (moduloRatio >(1.f - snapTension))
- *value = *value - modulo + *snap * ((*value<0.f) ? -1.f : 1.f);
+ *value = *value - modulo + snap * ((*value<0.f) ? -1.f : 1.f);
}
static void ComputeSnap(vec_t& value, float *snap)
{
for (int i = 0; i < 3; i++)
{
- ComputeSnap(&value[i], &snap[i]);
+ ComputeSnap(&value[i], snap[i]);
}
}
@@ -996,6 +1011,178 @@ namespace ImGuizmo
}
}
+ static void HandleAndDrawLocalBounds(float *bounds, matrix_t *matrix, float *snapValues)
+ {
+ ImGuiIO& io = ImGui::GetIO();
+ ImDrawList* drawList = gContext.mDrawList;
+
+ // compute best projection axis
+ vec_t bestAxisWorldDirection;
+ int bestAxis = gContext.mBoundsBestAxis;
+ if (!gContext.mbUsingBounds)
+ {
+
+ float bestDot = 0.f;
+ for (unsigned int i = 0; i < 3; i++)
+ {
+ vec_t dirPlaneNormalWorld;
+ dirPlaneNormalWorld.TransformVector(directionUnary[i], gContext.mModelSource);
+ dirPlaneNormalWorld.Normalize();
+
+ float dt = Dot(Normalized(gContext.mCameraEye - gContext.mModelSource.v.position), dirPlaneNormalWorld);
+ if (fabsf(dt) >= bestDot)
+ {
+ bestDot = fabsf(dt);
+ bestAxis = i;
+ bestAxisWorldDirection = dirPlaneNormalWorld;
+ }
+ }
+ }
+
+ // corners
+ vec_t aabb[4];
+
+ int secondAxis = (bestAxis + 1) % 3;
+ int thirdAxis = (bestAxis + 2) % 3;
+
+ for (int i = 0; i < 4; i++)
+ {
+ aabb[i][3] = aabb[i][bestAxis] = 0.f;
+ aabb[i][secondAxis] = bounds[secondAxis + 3 * (i >> 1)];
+ aabb[i][thirdAxis] = bounds[thirdAxis + 3 * ((i >> 1) ^ (i & 1))];
+ }
+
+ // draw bounds
+ unsigned int anchorAlpha = gContext.mbEnable ? 0xFF000000 : 0x80000000;
+
+ matrix_t boundsMVP = gContext.mModelSource * gContext.mViewProjection;
+ for (int i = 0; i < 4;i++)
+ {
+ ImVec2 worldBound1 = worldToPos(aabb[i], boundsMVP);
+ ImVec2 worldBound2 = worldToPos(aabb[(i+1)%4], boundsMVP);
+ float boundDistance = sqrtf(ImLengthSqr(worldBound1 - worldBound2));
+ int stepCount = (int)(boundDistance / 10.f);
+ float stepLength = 1.f / (float)stepCount;
+ for (int j = 0; j < stepCount; j++)
+ {
+ float t1 = (float)j * stepLength;
+ float t2 = (float)j * stepLength + stepLength * 0.5f;
+ ImVec2 worldBoundSS1 = ImLerp(worldBound1, worldBound2, ImVec2(t1, t1));
+ ImVec2 worldBoundSS2 = ImLerp(worldBound1, worldBound2, ImVec2(t2, t2));
+ drawList->AddLine(worldBoundSS1, worldBoundSS2, 0xAAAAAA + anchorAlpha, 3.f);
+ }
+ vec_t midPoint = (aabb[i] + aabb[(i + 1) % 4] ) * 0.5f;
+ ImVec2 midBound = worldToPos(midPoint, boundsMVP);
+ static const float AnchorBigRadius = 8.f;
+ static const float AnchorSmallRadius = 6.f;
+ bool overBigAnchor = ImLengthSqr(worldBound1 - io.MousePos) <= (AnchorBigRadius*AnchorBigRadius);
+ bool overSmallAnchor = ImLengthSqr(midBound - io.MousePos) <= (AnchorBigRadius*AnchorBigRadius);
+
+
+ unsigned int bigAnchorColor = overBigAnchor ? selectionColor : (0xAAAAAA + anchorAlpha);
+ unsigned int smallAnchorColor = overSmallAnchor ? selectionColor : (0xAAAAAA + anchorAlpha);
+
+ drawList->AddCircleFilled(worldBound1, AnchorBigRadius, bigAnchorColor);
+ drawList->AddCircleFilled(midBound, AnchorSmallRadius, smallAnchorColor);
+ int oppositeIndex = (i + 2) % 4;
+ // big anchor on corners
+ if (!gContext.mbUsingBounds && gContext.mbEnable && overBigAnchor && io.MouseDown[0])
+ {
+ gContext.mBoundsPivot.TransformPoint(aabb[(i + 2) % 4], gContext.mModelSource);
+ gContext.mBoundsAnchor.TransformPoint(aabb[i], gContext.mModelSource);
+ gContext.mBoundsPlan = BuildPlan(gContext.mBoundsAnchor, bestAxisWorldDirection);
+ gContext.mBoundsBestAxis = bestAxis;
+ gContext.mBoundsAxis[0] = secondAxis;
+ gContext.mBoundsAxis[1] = thirdAxis;
+
+ gContext.mBoundsLocalPivot.Set(0.f);
+ gContext.mBoundsLocalPivot[secondAxis] = aabb[oppositeIndex][secondAxis];
+ gContext.mBoundsLocalPivot[thirdAxis] = aabb[oppositeIndex][thirdAxis];
+
+ gContext.mbUsingBounds = true;
+ gContext.mBoundsMatrix = gContext.mModelSource;
+ }
+ // small anchor on middle of segment
+ if (!gContext.mbUsingBounds && gContext.mbEnable && overSmallAnchor && io.MouseDown[0])
+ {
+ vec_t midPointOpposite = (aabb[(i + 2) % 4] + aabb[(i + 3) % 4]) * 0.5f;
+ gContext.mBoundsPivot.TransformPoint(midPointOpposite, gContext.mModelSource);
+ gContext.mBoundsAnchor.TransformPoint(midPoint, gContext.mModelSource);
+ gContext.mBoundsPlan = BuildPlan(gContext.mBoundsAnchor, bestAxisWorldDirection);
+ gContext.mBoundsBestAxis = bestAxis;
+ int indices[] = { secondAxis , thirdAxis };
+ gContext.mBoundsAxis[0] = indices[i%2];
+ gContext.mBoundsAxis[1] = -1;
+
+ gContext.mBoundsLocalPivot.Set(0.f);
+ gContext.mBoundsLocalPivot[gContext.mBoundsAxis[0]] = aabb[oppositeIndex][indices[i % 2]];// bounds[gContext.mBoundsAxis[0]] * (((i + 1) & 2) ? 1.f : -1.f);
+
+ gContext.mbUsingBounds = true;
+ gContext.mBoundsMatrix = gContext.mModelSource;
+ }
+ }
+
+ if (gContext.mbUsingBounds)
+ {
+ matrix_t scale;
+ scale.SetToIdentity();
+
+ // compute projected mouse position on plan
+ const float len = IntersectRayPlane(gContext.mRayOrigin, gContext.mRayVector, gContext.mBoundsPlan);
+ vec_t newPos = gContext.mRayOrigin + gContext.mRayVector * len;
+
+ // compute a reference and delta vectors base on mouse move
+ vec_t deltaVector = (newPos - gContext.mBoundsPivot).Abs();
+ vec_t referenceVector = (gContext.mBoundsAnchor - gContext.mBoundsPivot).Abs();
+
+ // for 1 or 2 axes, compute a ratio that's used for scale and snap it based on resulting length
+ for (int i = 0; i < 2; i++)
+ {
+ int axisIndex = gContext.mBoundsAxis[i];
+ if (axisIndex == -1)
+ continue;
+
+ float ratioAxis = 1.f;
+ vec_t axisDir = gContext.mBoundsMatrix.component[axisIndex].Abs();
+
+ float dtAxis = axisDir.Dot(referenceVector);
+ float boundSize = bounds[axisIndex + 3] - bounds[axisIndex];
+ if (dtAxis > FLT_EPSILON)
+ ratioAxis = axisDir.Dot(deltaVector) / dtAxis;
+
+ if (snapValues)
+ {
+ float length = boundSize * ratioAxis;
+ ComputeSnap(&length, snapValues[axisIndex]);
+ if (boundSize > FLT_EPSILON)
+ ratioAxis = length / boundSize;
+ }
+ scale.component[axisIndex] *= ratioAxis;
+ }
+
+ // transform matrix
+ matrix_t preScale, postScale;
+ preScale.Translation(-gContext.mBoundsLocalPivot);
+ postScale.Translation(gContext.mBoundsLocalPivot);
+ matrix_t res = preScale * scale * postScale * gContext.mBoundsMatrix;
+ *matrix = res;
+
+ // info text
+ char tmps[512];
+ ImVec2 destinationPosOnScreen = worldToPos(gContext.mModel.v.position, gContext.mViewProjection);
+ ImFormatString(tmps, sizeof(tmps), "X: %.2f Y: %.2f Z:%.2f"
+ , (bounds[3] - bounds[0]) * gContext.mBoundsMatrix.component[0].Length() * scale.component[0].Length()
+ , (bounds[4] - bounds[1]) * gContext.mBoundsMatrix.component[1].Length() * scale.component[1].Length()
+ , (bounds[5] - bounds[2]) * gContext.mBoundsMatrix.component[2].Length() * scale.component[2].Length()
+ );
+ drawList->AddText(ImVec2(destinationPosOnScreen.x + 15, destinationPosOnScreen.y + 15), 0xFF000000, tmps);
+ drawList->AddText(ImVec2(destinationPosOnScreen.x + 14, destinationPosOnScreen.y + 14), 0xFFFFFFFF, tmps);
+ }
+
+ if (!io.MouseDown[0])
+ gContext.mbUsingBounds = false;
+ }
+
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
@@ -1311,7 +1498,7 @@ namespace ImGuizmo
if (snap)
{
float snapInRadian = snap[0] * DEG2RAD;
- ComputeSnap(&gContext.mRotationAngle, &snapInRadian);
+ ComputeSnap(&gContext.mRotationAngle, snapInRadian);
}
vec_t rotationAxisLocalSpace;
@@ -1393,7 +1580,7 @@ namespace ImGuizmo
mat.v.position.Set(translation[0], translation[1], translation[2], 1.f);
}
- void Manipulate(const float *view, const float *projection, OPERATION operation, MODE mode, float *matrix, float *deltaMatrix, float *snap)
+ void Manipulate(const float *view, const float *projection, OPERATION operation, MODE mode, float *matrix, float *deltaMatrix, float *snap, float *localBounds, float *boundsSnap)
{
ComputeContext(view, projection, matrix, mode);
@@ -1411,32 +1598,41 @@ namespace ImGuizmo
int type = NONE;
if (gContext.mbEnable)
{
- switch (operation)
- {
- case ROTATE:
- HandleRotation(matrix, deltaMatrix, type, snap);
- break;
- case TRANSLATE:
- HandleTranslation(matrix, deltaMatrix, type, snap);
- break;
- case SCALE:
- HandleScale(matrix, deltaMatrix, type, snap);
- break;
- }
+ if (!gContext.mbUsingBounds)
+ {
+ switch (operation)
+ {
+ case ROTATE:
+ HandleRotation(matrix, deltaMatrix, type, snap);
+ break;
+ case TRANSLATE:
+ HandleTranslation(matrix, deltaMatrix, type, snap);
+ break;
+ case SCALE:
+ HandleScale(matrix, deltaMatrix, type, snap);
+ break;
+ }
+ }
}
- switch (operation)
- {
- case ROTATE:
- DrawRotationGizmo(type);
- break;
- case TRANSLATE:
- DrawTranslationGizmo(type);
- break;
- case SCALE:
- DrawScaleGizmo(type);
- break;
- }
+ if (localBounds && !gContext.mbUsing)
+ HandleAndDrawLocalBounds(localBounds, (matrix_t*)matrix, boundsSnap);
+
+ if (!gContext.mbUsingBounds)
+ {
+ switch (operation)
+ {
+ case ROTATE:
+ DrawRotationGizmo(type);
+ break;
+ case TRANSLATE:
+ DrawTranslationGizmo(type);
+ break;
+ case SCALE:
+ DrawScaleGizmo(type);
+ break;
+ }
+ }
}
void DrawCube(const float *view, const float *projection, float *matrix)
@@ -1492,4 +1688,3 @@ namespace ImGuizmo
}
}
};
-
diff --git a/3rdparty/bgfx/3rdparty/ocornut-imgui/widgets/range_slider.inl b/3rdparty/bgfx/3rdparty/ocornut-imgui/widgets/range_slider.inl
index 0dffad7759e..e4851a05a4f 100644
--- a/3rdparty/bgfx/3rdparty/ocornut-imgui/widgets/range_slider.inl
+++ b/3rdparty/bgfx/3rdparty/ocornut-imgui/widgets/range_slider.inl
@@ -100,7 +100,7 @@ bool RangeSliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v1, float* v
}
else
{
- SetActiveID(0);
+ ClearActiveID();
}
}
diff --git a/3rdparty/bgfx/3rdparty/remotery/lib/Remotery.c b/3rdparty/bgfx/3rdparty/remotery/lib/Remotery.c
index 4dc2bf4753a..74b351f4073 100644
--- a/3rdparty/bgfx/3rdparty/remotery/lib/Remotery.c
+++ b/3rdparty/bgfx/3rdparty/remotery/lib/Remotery.c
@@ -1,5 +1,5 @@
//
-// Copyright 2014-2016 Celtoys Ltd
+// Copyright 2014-2017 Celtoys Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -27,6 +27,8 @@
@SAFEC: Safe C Library excerpts
@OBJALLOC: Reusable Object Allocator
@DYNBUF: Dynamic Buffer
+ @HASHTABLE: Integer pair hash map for inserts/finds. No removes for added simplicity.
+ @STRINGTABLE: Map from string hash to string offset in local buffer
@SOCKETS: Sockets TCP/IP Wrapper
@SHA1: SHA-1 Cryptographic Hash Function
@BASE64: Base-64 encoder
@@ -34,7 +36,6 @@
@WEBSOCKETS: WebSockets
@MESSAGEQ: Multiple producer, single consumer message queue
@NETWORK: Network Server
- @JSON: Basic, text-based JSON serialisation
@SAMPLE: Base Sample Description (CPU by default)
@SAMPLETREE: A tree of samples with their allocator
@TSAMPLER: Per-Thread Sampler
@@ -42,6 +43,7 @@
@CUDA: CUDA event sampling
@D3D11: Direct3D 11 event sampling
@OPENGL: OpenGL event sampling
+ @METAL: Metal event sampling
*/
#define RMT_IMPL
@@ -140,6 +142,7 @@ static rmtBool g_SettingsInitialized = RMT_FALSE;
#endif
+
rmtU8 minU8(rmtU8 a, rmtU8 b)
{
return a < b ? a : b;
@@ -283,7 +286,7 @@ static void usTimer_Init(usTimer* timer)
struct timespec tv;
clock_gettime(CLOCK_REALTIME, &tv);
- timer->counter_start = (rmtU64)(tv.tv_sec * 1000000) + (rmtU64)(tv.tv_nsec * 0.001);
+ timer->counter_start = (rmtU64)(tv.tv_sec * (rmtU64)1000000) + (rmtU64)(tv.tv_nsec * 0.001);
#endif
}
@@ -309,7 +312,7 @@ static rmtU64 usTimer_Get(usTimer* timer)
struct timespec tv;
clock_gettime(CLOCK_REALTIME, &tv);
- return ((rmtU64)(tv.tv_sec * 1000000) + (rmtU64)(tv.tv_nsec * 0.001)) - timer->counter_start;
+ return ((rmtU64)(tv.tv_sec * (rmtU64)1000000) + (rmtU64)(tv.tv_nsec * 0.001)) - timer->counter_start;
#endif
}
@@ -480,6 +483,8 @@ static void WriteFence()
{
#if defined(RMT_PLATFORM_WINDOWS) && !defined(__MINGW32__)
_WriteBarrier();
+#elif defined (__clang__)
+ __asm__ volatile("" : : : "memory");
#else
asm volatile ("" : : : "memory");
#endif
@@ -866,11 +871,11 @@ static void VirtualMirrorBuffer_Destructor(VirtualMirrorBuffer* buffer)
*/
-struct Thread;
-typedef rmtError(*ThreadProc)(struct Thread* thread);
+typedef struct Thread_t rmtThread;
+typedef rmtError(*ThreadProc)(rmtThread* thread);
-typedef struct Thread
+struct Thread_t
{
// OS-specific data
#if defined(RMT_PLATFORM_WINDOWS)
@@ -891,14 +896,14 @@ typedef struct Thread
// External threads can set this to request an exit
volatile rmtBool request_exit;
-} Thread;
+};
#if defined(RMT_PLATFORM_WINDOWS)
static DWORD WINAPI ThreadProcWindows(LPVOID lpParameter)
{
- Thread* thread = (Thread*)lpParameter;
+ rmtThread* thread = (rmtThread*)lpParameter;
assert(thread != NULL);
thread->error = thread->callback(thread);
return thread->error == RMT_ERROR_NONE ? 1 : 0;
@@ -907,7 +912,7 @@ typedef struct Thread
#else
static void* StartFunc( void* pArgs )
{
- Thread* thread = (Thread*)pArgs;
+ rmtThread* thread = (rmtThread*)pArgs;
assert(thread != NULL);
thread->error = thread->callback(thread);
return NULL; // returned error not use, check thread->error.
@@ -915,7 +920,7 @@ typedef struct Thread
#endif
-static int Thread_Valid(Thread* thread)
+static int rmtThread_Valid(rmtThread* thread)
{
assert(thread != NULL);
@@ -927,7 +932,7 @@ static int Thread_Valid(Thread* thread)
}
-static rmtError Thread_Constructor(Thread* thread, ThreadProc callback, void* param)
+static rmtError rmtThread_Constructor(rmtThread* thread, ThreadProc callback, void* param)
{
assert(thread != NULL);
@@ -968,7 +973,7 @@ static rmtError Thread_Constructor(Thread* thread, ThreadProc callback, void* pa
}
-static void Thread_RequestExit(Thread* thread)
+static void rmtThread_RequestExit(rmtThread* thread)
{
// Not really worried about memory barriers or delayed visibility to the target thread
assert(thread != NULL);
@@ -976,9 +981,9 @@ static void Thread_RequestExit(Thread* thread)
}
-static void Thread_Join(Thread* thread)
+static void rmtThread_Join(rmtThread* thread)
{
- assert(Thread_Valid(thread));
+ assert(rmtThread_Valid(thread));
#if defined(RMT_PLATFORM_WINDOWS)
WaitForSingleObject(thread->handle, INFINITE);
@@ -988,15 +993,15 @@ static void Thread_Join(Thread* thread)
}
-static void Thread_Destructor(Thread* thread)
+static void rmtThread_Destructor(rmtThread* thread)
{
assert(thread != NULL);
- if (Thread_Valid(thread))
+ if (rmtThread_Valid(thread))
{
// Shutdown the thread
- Thread_RequestExit(thread);
- Thread_Join(thread);
+ rmtThread_RequestExit(thread);
+ rmtThread_Join(thread);
// OS-specific release of thread resources
@@ -1334,7 +1339,6 @@ strcpy_s(char *dest, rsize_t dmax, const char *src)
return RCNEGATE(EOK);
}
- /* hold base of dest in case src was not copied */
if (dest < src) {
overlap_bumper = src;
@@ -1380,7 +1384,7 @@ strcpy_s(char *dest, rsize_t dmax, const char *src)
return RCNEGATE(ESNOSPC);
}
-
+#if !(defined(RMT_PLATFORM_LINUX) && RMT_USE_POSIX_THREADNAMES)
/* very simple integer to hex */
static const char* hex_encoding_table = "0123456789ABCDEF";
@@ -1417,6 +1421,7 @@ static void itoahex_s( char *dest, rsize_t dmax, rmtS32 value )
}
}
+#endif
/*
------------------------------------------------------------------------------------------------------------------------
@@ -1676,10 +1681,260 @@ static rmtError Buffer_Write(Buffer* buffer, void* data, rmtU32 length)
}
-static rmtError Buffer_WriteString(Buffer* buffer, rmtPStr string)
+static rmtError Buffer_WriteStringZ(Buffer* buffer, rmtPStr string)
{
assert(string != NULL);
- return Buffer_Write(buffer, (void*)string, (rmtU32)strnlen_s(string, 2048));
+ return Buffer_Write(buffer, (void*)string, (rmtU32)strnlen_s(string, 2048) + 1);
+}
+
+
+static void U32ToByteArray(rmtU8* dest, rmtU32 value)
+{
+ // Commit as little-endian
+ dest[0] = value & 255;
+ dest[1] = (value >> 8) & 255;
+ dest[2] = (value >> 16) & 255;
+ dest[3] = value >> 24;
+}
+
+
+static rmtError Buffer_WriteU32(Buffer* buffer, rmtU32 value)
+{
+ rmtU8 temp[4];
+ U32ToByteArray(temp, value);
+ return Buffer_Write(buffer, temp, sizeof(temp));
+}
+
+
+static rmtBool IsLittleEndian()
+{
+ // Not storing this in a global variable allows the compiler to more easily optimise
+ // this away altogether.
+ union
+ {
+ unsigned int i;
+ unsigned char c[sizeof(unsigned int)];
+ } u;
+ u.i = 1;
+ return u.c[0] == 1 ? RMT_TRUE : RMT_FALSE;
+}
+
+
+static rmtError Buffer_WriteU64(Buffer* buffer, rmtU64 value)
+{
+ // Write as a double as Javascript DataView doesn't have a 64-bit integer read
+ union
+ {
+ double d;
+ unsigned char c[sizeof(double)];
+ } u;
+ char temp[8];
+ u.d = (double)value;
+ if (IsLittleEndian())
+ {
+ temp[0] = u.c[0];
+ temp[1] = u.c[1];
+ temp[2] = u.c[2];
+ temp[3] = u.c[3];
+ temp[4] = u.c[4];
+ temp[5] = u.c[5];
+ temp[6] = u.c[6];
+ temp[7] = u.c[7];
+ }
+ else
+ {
+ temp[0] = u.c[7];
+ temp[1] = u.c[6];
+ temp[2] = u.c[5];
+ temp[3] = u.c[4];
+ temp[4] = u.c[3];
+ temp[5] = u.c[2];
+ temp[6] = u.c[1];
+ temp[7] = u.c[0];
+ }
+ return Buffer_Write(buffer, u.c, sizeof(u.c));
+}
+
+
+static rmtError Buffer_WriteStringWithLength(Buffer* buffer, rmtPStr string)
+{
+ rmtU32 length = (rmtU32)strnlen_s(string, 2048);
+ rmtError error;
+
+ error = Buffer_WriteU32(buffer, length);
+ if (error != RMT_ERROR_NONE)
+ return error;
+
+ return Buffer_Write(buffer, (void*)string, length);
+}
+
+
+
+/*
+------------------------------------------------------------------------------------------------------------------------
+------------------------------------------------------------------------------------------------------------------------
+ @HASHTABLE: Integer pair hash map for inserts/finds. No removes for added simplicity.
+------------------------------------------------------------------------------------------------------------------------
+------------------------------------------------------------------------------------------------------------------------
+*/
+
+
+
+#define RMT_NOT_FOUND 0xFFFFFFFF
+
+
+typedef struct
+{
+ // Non-zero, pre-hashed key
+ rmtU32 key;
+
+ // Value that's not equal to RMT_NOT_FOUND
+ rmtU32 value;
+} HashSlot;
+
+
+typedef struct
+{
+ // Stats
+ rmtU32 max_nb_slots;
+ rmtU32 nb_slots;
+
+ // Data
+ HashSlot* slots;
+} rmtHashTable;
+
+
+static rmtError rmtHashTable_Constructor(rmtHashTable* table, rmtU32 max_nb_slots)
+{
+ // Default initialise
+ assert(table != NULL);
+ table->max_nb_slots = max_nb_slots;
+ table->nb_slots = 0;
+
+ // Allocate and clear the hash slots
+ table->slots = (HashSlot*)rmtMalloc(table->max_nb_slots * sizeof(HashSlot));
+ if (table->slots == NULL)
+ return RMT_ERROR_MALLOC_FAIL;
+ memset(table->slots, 0, table->max_nb_slots * sizeof(HashSlot));
+
+ return RMT_ERROR_NONE;
+}
+
+
+static void rmtHashTable_Destructor(rmtHashTable* table)
+{
+ assert(table != NULL);
+
+ if (table->slots != NULL)
+ {
+ rmtFree(table->slots);
+ table->slots = NULL;
+ }
+}
+
+
+static rmtError rmtHashTable_Resize(rmtHashTable* table);
+
+
+static rmtError rmtHashTable_Insert(rmtHashTable* table, rmtU32 key, rmtU32 value)
+{
+ HashSlot* slot = NULL;
+ rmtError error = RMT_ERROR_NONE;
+
+ // Calculate initial slot location for this key
+ rmtU32 index_mask = table->max_nb_slots - 1;
+ rmtU32 index = key & index_mask;
+
+ assert(key != 0);
+ assert(value != RMT_NOT_FOUND);
+
+ // Linear probe for free slot, reusing any existing key matches
+ // There will always be at least one free slot due to load factor management
+ while (table->slots[index].key)
+ {
+ if (table->slots[index].key == key)
+ {
+ // Counter occupied slot increments below
+ table->nb_slots--;
+ break;
+ }
+
+ index = (index + 1) & index_mask;
+ }
+
+ // Just verify that I've got no errors in the code above
+ assert(index < table->max_nb_slots);
+
+ // Add to the table
+ slot = table->slots + index;
+ slot->key = key;
+ slot->value = value;
+ table->nb_slots++;
+
+ // Resize when load factor is greater than 2/3
+ if (table->nb_slots > (table->max_nb_slots * 2) / 3)
+ error = rmtHashTable_Resize(table);
+
+ return error;
+}
+
+
+static rmtError rmtHashTable_Resize(rmtHashTable* table)
+{
+ rmtU32 old_max_nb_slots = table->max_nb_slots;
+ HashSlot* new_slots = NULL;
+ HashSlot* old_slots = table->slots;
+
+ // Increase the table size
+ rmtU32 new_max_nb_slots = table->max_nb_slots;
+ if (new_max_nb_slots < 8192 * 4)
+ new_max_nb_slots *= 4;
+ else
+ new_max_nb_slots *= 2;
+
+ // Allocate and clear a new table
+ new_slots = (HashSlot*)rmtMalloc(new_max_nb_slots * sizeof(HashSlot));
+ if (new_slots == NULL)
+ return RMT_ERROR_MALLOC_FAIL;
+ memset(new_slots, 0, new_max_nb_slots * sizeof(HashSlot));
+
+ // Update fields of the table after successful allocation only
+ table->slots = new_slots;
+ table->max_nb_slots = new_max_nb_slots;
+ table->nb_slots = 0;
+
+ // Reinsert all objects into the new table
+ for (rmtU32 i = 0; i < old_max_nb_slots; i++)
+ {
+ HashSlot* slot = old_slots + i;
+ if (slot->key != 0)
+ rmtHashTable_Insert(table, slot->key, slot->key);
+ }
+
+ free(old_slots);
+
+ return RMT_ERROR_NONE;
+}
+
+
+static rmtU32 rmtHashTable_Find(rmtHashTable* table, rmtU32 key)
+{
+ // Calculate initial slot location for this key
+ rmtU32 index_mask = table->max_nb_slots - 1;
+ rmtU32 index = key & index_mask;
+
+ // Linear probe for matching hash
+ while (table->slots[index].key)
+ {
+ HashSlot* slot = table->slots + index;
+
+ if (slot->key == key)
+ return slot->value;
+
+ index = (index + 1) & index_mask;
+ }
+
+ return RMT_NOT_FOUND;
}
@@ -1687,11 +1942,88 @@ static rmtError Buffer_WriteString(Buffer* buffer, rmtPStr string)
/*
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
+ @STRINGTABLE: Map from string hash to string offset in local buffer
+------------------------------------------------------------------------------------------------------------------------
+------------------------------------------------------------------------------------------------------------------------
+*/
+
+
+
+typedef struct
+{
+ // Growable dynamic array of strings added so far
+ Buffer* text;
+
+ // Map from text hash to text location in the buffer
+ rmtHashTable* text_map;
+} StringTable;
+
+
+static rmtError StringTable_Constructor(StringTable* table)
+{
+ rmtError error;
+
+ // Default initialise
+ assert(table != NULL);
+ table->text = NULL;
+ table->text_map = NULL;
+
+ // Allocate reasonably storage for initial sample names
+
+ New_1(Buffer, table->text, 8 * 1024);
+ if (error != RMT_ERROR_NONE)
+ return error;
+
+ New_1(rmtHashTable, table->text_map, 1 * 1024);
+ if (error != RMT_ERROR_NONE)
+ return error;
+
+ return RMT_ERROR_NONE;
+}
+
+
+static void StringTable_Destructor(StringTable* table)
+{
+ assert(table != NULL);
+
+ Delete(rmtHashTable, table->text_map);
+ Delete(Buffer, table->text);
+}
+
+
+static rmtPStr StringTable_Find(StringTable* table, rmtU32 name_hash)
+{
+ rmtU32 text_offset = rmtHashTable_Find(table->text_map, name_hash);
+ if (text_offset != RMT_NOT_FOUND)
+ return (rmtPStr)(table->text->data + text_offset);
+ return NULL;
+}
+
+
+static void StringTable_Insert(StringTable* table, rmtU32 name_hash, rmtPStr name)
+{
+ // Only add to the buffer if the string isn't already there
+ rmtU32 text_offset = rmtHashTable_Find(table->text_map, name_hash);
+ if (text_offset == RMT_NOT_FOUND)
+ {
+ // TODO: Allocation errors aren't being passed on to the caller
+ text_offset = table->text->bytes_used;
+ Buffer_WriteStringZ(table->text, name);
+ rmtHashTable_Insert(table->text_map, name_hash, text_offset);
+ }
+}
+
+
+/*
+------------------------------------------------------------------------------------------------------------------------
+------------------------------------------------------------------------------------------------------------------------
@SOCKETS: Sockets TCP/IP Wrapper
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
*/
+
+
#ifndef RMT_PLATFORM_WINDOWS
typedef int SOCKET;
#define INVALID_SOCKET -1
@@ -1699,6 +2031,8 @@ static rmtError Buffer_WriteString(Buffer* buffer, rmtPStr string)
#define SD_SEND SHUT_WR
#define closesocket close
#endif
+
+
typedef struct
{
SOCKET socket;
@@ -2272,7 +2606,7 @@ static void calc(const void* src, const int bytelength, unsigned char* hash)
{
w[lastBlockBytes >> 2] |= (unsigned int) sarray[lastBlockBytes + currentBlock] << ((3 - (lastBlockBytes & 3)) << 3);
}
- w[lastBlockBytes >> 2] |= 0x80 << ((3 - (lastBlockBytes & 3)) << 3);
+ w[lastBlockBytes >> 2] |= 0x80U << ((3 - (lastBlockBytes & 3)) << 3);
if (endCurrentBlock >= 56)
{
innerHash(result, w);
@@ -2958,7 +3292,7 @@ typedef struct Message
// Multiple producer, single consumer message queue that uses its own data buffer
// to store the message data.
-typedef struct MessageQueue
+typedef struct rmtMessageQueue
{
rmtU32 size;
@@ -2972,10 +3306,10 @@ typedef struct MessageQueue
rmtU32 read_pos;
rmtU32 write_pos;
-} MessageQueue;
+} rmtMessageQueue;
-static rmtError MessageQueue_Constructor(MessageQueue* queue, rmtU32 size)
+static rmtError rmtMessageQueue_Constructor(rmtMessageQueue* queue, rmtU32 size)
{
rmtError error;
@@ -3002,14 +3336,14 @@ static rmtError MessageQueue_Constructor(MessageQueue* queue, rmtU32 size)
}
-static void MessageQueue_Destructor(MessageQueue* queue)
+static void rmtMessageQueue_Destructor(rmtMessageQueue* queue)
{
assert(queue != NULL);
Delete(VirtualMirrorBuffer, queue->data);
}
-static rmtU32 MessageQueue_SizeForPayload(rmtU32 payload_size)
+static rmtU32 rmtMessageQueue_SizeForPayload(rmtU32 payload_size)
{
// Add message header and align for ARM platforms
rmtU32 size = sizeof(Message) + payload_size;
@@ -3018,11 +3352,11 @@ static rmtU32 MessageQueue_SizeForPayload(rmtU32 payload_size)
}
-static Message* MessageQueue_AllocMessage(MessageQueue* queue, rmtU32 payload_size, struct ThreadSampler* thread_sampler)
+static Message* rmtMessageQueue_AllocMessage(rmtMessageQueue* queue, rmtU32 payload_size, struct ThreadSampler* thread_sampler)
{
Message* msg;
- rmtU32 write_size = MessageQueue_SizeForPayload(payload_size);
+ rmtU32 write_size = rmtMessageQueue_SizeForPayload(payload_size);
assert(queue != NULL);
@@ -3052,7 +3386,7 @@ static Message* MessageQueue_AllocMessage(MessageQueue* queue, rmtU32 payload_si
}
-static void MessageQueue_CommitMessage(Message* message, MessageID id)
+static void rmtMessageQueue_CommitMessage(Message* message, MessageID id)
{
assert(message != NULL);
@@ -3065,7 +3399,7 @@ static void MessageQueue_CommitMessage(Message* message, MessageID id)
}
-Message* MessageQueue_PeekNextMessage(MessageQueue* queue)
+Message* rmtMessageQueue_PeekNextMessage(rmtMessageQueue* queue)
{
Message* ptr;
rmtU32 r;
@@ -3088,7 +3422,7 @@ Message* MessageQueue_PeekNextMessage(MessageQueue* queue)
}
-static void MessageQueue_ConsumeNextMessage(MessageQueue* queue, Message* message)
+static void rmtMessageQueue_ConsumeNextMessage(rmtMessageQueue* queue, Message* message)
{
rmtU32 message_size;
@@ -3104,7 +3438,7 @@ static void MessageQueue_ConsumeNextMessage(MessageQueue* queue, Message* messag
// the read position so that a winning thread's allocation will inherit the "not ready" state.
//
// This costs some write bandwidth and has the potential to flush cache to other cores.
- message_size = MessageQueue_SizeForPayload(message->payload_size);
+ message_size = rmtMessageQueue_SizeForPayload(message->payload_size);
memset(message, MsgID_NotReady, message_size);
// Ensure clear completes before advancing the read position
@@ -3113,6 +3447,13 @@ static void MessageQueue_ConsumeNextMessage(MessageQueue* queue, Message* messag
}
+static rmtBool rmtMessageQueue_IsEmpty(rmtMessageQueue* queue)
+{
+ assert(queue != NULL);
+ return queue->write_pos - queue->read_pos == 0;
+}
+
+
/*
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
@@ -3122,6 +3463,8 @@ static void MessageQueue_ConsumeNextMessage(MessageQueue* queue, Message* messag
*/
+typedef rmtError (*Server_ReceiveHandler)(void*, char*, rmtU32);
+
typedef struct
{
@@ -3133,6 +3476,10 @@ typedef struct
rmtU16 port;
rmtBool limit_connections_to_localhost;
+
+ // Handler for receiving messages from the client
+ Server_ReceiveHandler receive_handler;
+ void* receive_handler_context;
} Server;
@@ -3142,7 +3489,7 @@ static rmtError Server_CreateListenSocket(Server* server, rmtU16 port, rmtBool l
New_1(WebSocket, server->listen_socket, NULL);
if (error == RMT_ERROR_NONE)
- error = WebSocket_RunServer(server->listen_socket, port, limit_connections_to_localhost, WEBSOCKET_TEXT);
+ error = WebSocket_RunServer(server->listen_socket, port, limit_connections_to_localhost, WEBSOCKET_BINARY);
return error;
}
@@ -3156,6 +3503,8 @@ static rmtError Server_Constructor(Server* server, rmtU16 port, rmtBool limit_co
server->last_ping_time = 0;
server->port = port;
server->limit_connections_to_localhost = limit_connections_to_localhost;
+ server->receive_handler = NULL;
+ server->receive_handler_context = NULL;
// Create the listening WebSocket
return Server_CreateListenSocket(server, port, limit_connections_to_localhost);
@@ -3230,19 +3579,11 @@ static rmtError Server_ReceiveMessage(Server* server, char message_first_byte, r
if (message_length < 4)
return RMT_ERROR_NONE;
- // Silly check for console input message ('CONI')
- // (don't want to add safe strcmp to lib yet)
- if (message_data[0] == 'C' && message_data[1] == 'O' && message_data[2] == 'N' && message_data[3] == 'I')
- {
- // Pass on to any registered handler
- if (g_Settings.input_handler != NULL)
- g_Settings.input_handler(message_data + 4, g_Settings.input_handler_context);
-
- rmt_LogText("Console message received...");
- rmt_LogText(message_data + 4);
- }
+ // Dispatch to handler
+ if (server->receive_handler)
+ error = server->receive_handler(server->receive_handler_context, message_data, message_length);
- return RMT_ERROR_NONE;
+ return error;
}
@@ -3275,29 +3616,43 @@ static void Server_Update(Server* server)
else
{
- // Check for any incoming messages
- char message_first_byte;
- rmtU32 message_length;
- rmtError error = WebSocket_Receive(server->client_socket, &message_first_byte, &message_length, 1, 0);
- if (error == RMT_ERROR_NONE)
- {
- // Parse remaining message
- error = Server_ReceiveMessage(server, message_first_byte, message_length);
- if (error != RMT_ERROR_NONE)
- Server_DisconnectClient(server);
- }
- else if (error == RMT_ERROR_SOCKET_RECV_NO_DATA)
- {
- // no data available
- }
- else if (error == RMT_ERROR_SOCKET_RECV_TIMEOUT)
- {
- // data not available yet, can afford to ignore as we're only reading the first byte
- }
- else
+ // Loop checking for incoming messages
+ for (;;)
{
+ // Inspect first byte to see if a message is there
+ char message_first_byte;
+ rmtU32 message_length;
+ rmtError error = WebSocket_Receive(server->client_socket, &message_first_byte, &message_length, 1, 0);
+ if (error == RMT_ERROR_NONE)
+ {
+ // Parse remaining message
+ error = Server_ReceiveMessage(server, message_first_byte, message_length);
+ if (error != RMT_ERROR_NONE)
+ {
+ Server_DisconnectClient(server);
+ break;
+ }
+
+ // Check for more...
+ continue;
+ }
+
+ // Passable errors...
+ if (error == RMT_ERROR_SOCKET_RECV_NO_DATA)
+ {
+ // No data available
+ break;
+ }
+
+ if (error == RMT_ERROR_SOCKET_RECV_TIMEOUT)
+ {
+ // Data not available yet, can afford to ignore as we're only reading the first byte
+ break;
+ }
+
// Anything else is an error that may have closed the connection
Server_DisconnectClient(server);
+ break;
}
}
@@ -3305,8 +3660,8 @@ static void Server_Update(Server* server)
cur_time = msTimer_Get();
if (cur_time - server->last_ping_time > 1000)
{
- rmtPStr ping_message = "{ \"id\": \"PING\" }";
- Server_Send(server, ping_message, (rmtU32)strlen(ping_message), 20);
+ rmtPStr ping_message = "PING";
+ Server_Send(server, ping_message, (rmtU32)strlen(ping_message), 4);
server->last_ping_time = cur_time;
}
}
@@ -3316,111 +3671,6 @@ static void Server_Update(Server* server)
/*
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
- @JSON: Basic, text-based JSON serialisation
-------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------
-*/
-
-
-
-//
-// Simple macro for hopefully making the serialisation a little clearer by hiding the error handling
-//
-#define JSON_ERROR_CHECK(stmt) { error = stmt; if (error != RMT_ERROR_NONE) return error; }
-
-
-
-static rmtError json_OpenObject(Buffer* buffer)
-{
- return Buffer_Write(buffer, (void*)"{", 1);
-}
-
-
-static rmtError json_CloseObject(Buffer* buffer)
-{
- return Buffer_Write(buffer, (void*)"}", 1);
-}
-
-
-static rmtError json_Comma(Buffer* buffer)
-{
- return Buffer_Write(buffer, (void*)",", 1);
-}
-
-
-static rmtError json_Colon(Buffer* buffer)
-{
- return Buffer_Write(buffer, (void*)":", 1);
-}
-
-
-static rmtError json_String(Buffer* buffer, rmtPStr string)
-{
- rmtError error;
- JSON_ERROR_CHECK(Buffer_Write(buffer, (void*)"\"", 1));
- JSON_ERROR_CHECK(Buffer_WriteString(buffer, string));
- return Buffer_Write(buffer, (void*)"\"", 1);
-}
-
-
-static rmtError json_FieldStr(Buffer* buffer, rmtPStr name, rmtPStr value)
-{
- rmtError error;
- JSON_ERROR_CHECK(json_String(buffer, name));
- JSON_ERROR_CHECK(json_Colon(buffer));
- return json_String(buffer, value);
-}
-
-
-static rmtError json_FieldU64(Buffer* buffer, rmtPStr name, rmtU64 value)
-{
- static char temp_buf[32];
-
- char* end;
- char* tptr;
-
- json_String(buffer, name);
- json_Colon(buffer);
-
- if (value == 0)
- return Buffer_Write(buffer, (void*)"0", 1);
-
- // Null terminate and start at the end
- end = temp_buf + sizeof(temp_buf) - 1;
- *end = 0;
- tptr = end;
-
- // Loop through the value with radix 10
- do
- {
- rmtU64 next_value = value / 10;
- *--tptr = (char)('0' + (value - next_value * 10));
- value = next_value;
- } while (value);
-
- return Buffer_Write(buffer, tptr, (rmtU32)(end - tptr));
-}
-
-
-static rmtError json_OpenArray(Buffer* buffer, rmtPStr name)
-{
- rmtError error;
- JSON_ERROR_CHECK(json_String(buffer, name));
- JSON_ERROR_CHECK(json_Colon(buffer));
- return Buffer_Write(buffer, (void*)"[", 1);
-}
-
-
-static rmtError json_CloseArray(Buffer* buffer)
-{
- return Buffer_Write(buffer, (void*)"]", 1);
-}
-
-
-
-/*
-------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------
@SAMPLE: Base Sample Description for CPU by default
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
@@ -3437,6 +3687,7 @@ enum SampleType
SampleType_CUDA,
SampleType_D3D11,
SampleType_OpenGL,
+ SampleType_Metal,
SampleType_Count,
};
@@ -3451,8 +3702,7 @@ typedef struct Sample
// Used to anonymously copy sample data without knowning its type
rmtU32 size_bytes;
- // Sample name and unique hash
- char name[SAMPLE_NAME_LEN];
+ // Hash generated from sample name
rmtU32 name_hash;
// Unique, persistent ID among all samples
@@ -3487,7 +3737,6 @@ static rmtError Sample_Constructor(Sample* sample)
sample->type = SampleType_CPU;
sample->size_bytes = sizeof(Sample);
- sample->name[0] = 0;
sample->name_hash = 0;
sample->unique_id = 0;
sample->unique_id_html_colour[0] = '#';
@@ -3512,12 +3761,8 @@ static void Sample_Destructor(Sample* sample)
}
-static void Sample_Prepare(Sample* sample, rmtPStr name, rmtU32 name_hash, Sample* parent)
+static void Sample_Prepare(Sample* sample, rmtU32 name_hash, Sample* parent)
{
- // Copy sample name away for two reasons:
- // 1. It allows dynamic sprintf-style strings to be transient
- // 2. The Remotery thread can still inspect the sample even when the source module has been unloaded
- strcpy_s(sample->name, sizeof(sample->name), name);
sample->name_hash = name_hash;
sample->unique_id = 0;
sample->parent = parent;
@@ -3531,53 +3776,39 @@ static void Sample_Prepare(Sample* sample, rmtPStr name, rmtU32 name_hash, Sampl
}
-static rmtError json_SampleArray(Buffer* buffer, Sample* first_sample, rmtPStr name);
+#define BIN_ERROR_CHECK(stmt) { error = stmt; if (error != RMT_ERROR_NONE) return error; }
+
+
+static rmtError bin_SampleArray(Buffer* buffer, Sample* first_sample);
-static rmtError json_Sample(Buffer* buffer, Sample* sample)
+static rmtError bin_Sample(Buffer* buffer, Sample* sample)
{
rmtError error;
assert(sample != NULL);
- JSON_ERROR_CHECK(json_OpenObject(buffer));
-
- JSON_ERROR_CHECK(json_FieldStr(buffer, "name", sample->name));
- JSON_ERROR_CHECK(json_Comma(buffer));
- JSON_ERROR_CHECK(json_FieldU64(buffer, "id", sample->unique_id));
- JSON_ERROR_CHECK(json_Comma(buffer));
- JSON_ERROR_CHECK(json_FieldStr(buffer, "colour", (rmtPStr)sample->unique_id_html_colour));
- JSON_ERROR_CHECK(json_Comma(buffer));
- JSON_ERROR_CHECK(json_FieldU64(buffer, "us_start", sample->us_start));
- JSON_ERROR_CHECK(json_Comma(buffer));
- JSON_ERROR_CHECK(json_FieldU64(buffer, "us_length", maxS64(sample->us_length, 0)));
-
- if (sample->first_child != NULL)
- {
- JSON_ERROR_CHECK(json_Comma(buffer));
- JSON_ERROR_CHECK(json_SampleArray(buffer, sample->first_child, "children"));
- }
+ BIN_ERROR_CHECK(Buffer_WriteU32(buffer, sample->name_hash));
+ BIN_ERROR_CHECK(Buffer_WriteU32(buffer, sample->unique_id));
+ BIN_ERROR_CHECK(Buffer_Write(buffer, sample->unique_id_html_colour, 7));
+ BIN_ERROR_CHECK(Buffer_WriteU64(buffer, sample->us_start));
+ BIN_ERROR_CHECK(Buffer_WriteU64(buffer, maxS64(sample->us_length, 0)));
+ BIN_ERROR_CHECK(bin_SampleArray(buffer, sample));
- return json_CloseObject(buffer);
+ return RMT_ERROR_NONE;
}
-static rmtError json_SampleArray(Buffer* buffer, Sample* first_sample, rmtPStr name)
+static rmtError bin_SampleArray(Buffer* buffer, Sample* parent_sample)
{
rmtError error;
-
Sample* sample;
- JSON_ERROR_CHECK(json_OpenArray(buffer, name));
-
- for (sample = first_sample; sample != NULL; sample = sample->next_sibling)
- {
- JSON_ERROR_CHECK(json_Sample(buffer, sample));
- if (sample->next_sibling != NULL)
- JSON_ERROR_CHECK(json_Comma(buffer));
- }
+ BIN_ERROR_CHECK(Buffer_WriteU32(buffer, parent_sample->nb_children));
+ for (sample = parent_sample->first_child; sample != NULL; sample = sample->next_sibling)
+ BIN_ERROR_CHECK(bin_Sample(buffer, sample));
- return json_CloseArray(buffer);
+ return RMT_ERROR_NONE;
}
@@ -3625,7 +3856,7 @@ static rmtError SampleTree_Constructor(SampleTree* tree, rmtU32 sample_size, Obj
error = ObjectAllocator_Alloc(tree->allocator, (void**)&tree->root);
if (error != RMT_ERROR_NONE)
return error;
- Sample_Prepare(tree->root, "<Root Sample>", 0, NULL);
+ Sample_Prepare(tree->root, 0, NULL);
tree->current_parent = tree->root;
return RMT_ERROR_NONE;
@@ -3658,7 +3889,7 @@ static rmtU32 HashCombine(rmtU32 hash_a, rmtU32 hash_b)
}
-static rmtError SampleTree_Push(SampleTree* tree, rmtPStr name, rmtU32 name_hash, rmtU32 flags, Sample** sample)
+static rmtError SampleTree_Push(SampleTree* tree, rmtU32 name_hash, rmtU32 flags, Sample** sample)
{
Sample* parent;
rmtError error;
@@ -3693,7 +3924,7 @@ static rmtError SampleTree_Push(SampleTree* tree, rmtPStr name, rmtU32 name_hash
error = ObjectAllocator_Alloc(tree->allocator, (void**)sample);
if (error != RMT_ERROR_NONE)
return error;
- Sample_Prepare(*sample, name, name_hash, parent);
+ Sample_Prepare(*sample, name_hash, parent);
// Generate a unique ID for this sample in the tree
unique_id = parent->unique_id;
@@ -3783,12 +4014,12 @@ typedef struct Msg_SampleTree
} Msg_SampleTree;
-static void AddSampleTreeMessage(MessageQueue* queue, Sample* sample, ObjectAllocator* allocator, rmtPStr thread_name, struct ThreadSampler* thread_sampler)
+static void AddSampleTreeMessage(rmtMessageQueue* queue, Sample* sample, ObjectAllocator* allocator, rmtPStr thread_name, struct ThreadSampler* thread_sampler)
{
Msg_SampleTree* payload;
// Attempt to allocate a message for sending the tree to the viewer
- Message* message = MessageQueue_AllocMessage(queue, sizeof(Msg_SampleTree), thread_sampler);
+ Message* message = rmtMessageQueue_AllocMessage(queue, sizeof(Msg_SampleTree), thread_sampler);
if (message == NULL)
{
// Discard the tree on failure
@@ -3801,7 +4032,7 @@ static void AddSampleTreeMessage(MessageQueue* queue, Sample* sample, ObjectAllo
payload->root_sample = sample;
payload->allocator = allocator;
payload->thread_name = thread_name;
- MessageQueue_CommitMessage(message, MsgID_SampleTree);
+ rmtMessageQueue_CommitMessage(message, MsgID_SampleTree);
}
@@ -3825,6 +4056,9 @@ typedef struct ThreadSampler
// Store a unique sample tree for each type
SampleTree* sample_trees[SampleType_Count];
+ // Table of all sample names encountered on this thread
+ StringTable* names;
+
// Next in the global list of active thread samplers
struct ThreadSampler* volatile next;
@@ -3840,6 +4074,7 @@ static rmtError ThreadSampler_Constructor(ThreadSampler* thread_sampler)
// Set defaults
for (i = 0; i < SampleType_Count; i++)
thread_sampler->sample_trees[i] = NULL;
+ thread_sampler->names = NULL;
thread_sampler->next = NULL;
// Set the initial name to Thread0 etc. or use the existing Linux name.
@@ -3860,6 +4095,11 @@ static rmtError ThreadSampler_Constructor(ThreadSampler* thread_sampler)
if (error != RMT_ERROR_NONE)
return error;
+ // Create sample name string table
+ New_0(StringTable, thread_sampler->names);
+ if (error != RMT_ERROR_NONE)
+ return error;
+
return RMT_ERROR_NONE;
}
@@ -3869,18 +4109,21 @@ static void ThreadSampler_Destructor(ThreadSampler* ts)
int i;
assert(ts != NULL);
+
+ Delete(StringTable, ts->names);
+
for (i = 0; i < SampleType_Count; i++)
Delete(SampleTree, ts->sample_trees[i]);
}
-static rmtError ThreadSampler_Push(SampleTree* tree, rmtPStr name, rmtU32 name_hash, rmtU32 flags, Sample** sample)
+static rmtError ThreadSampler_Push(SampleTree* tree, rmtU32 name_hash, rmtU32 flags, Sample** sample)
{
- return SampleTree_Push(tree, name, name_hash, flags, sample);
+ return SampleTree_Push(tree, name_hash, flags, sample);
}
-static rmtBool ThreadSampler_Pop(ThreadSampler* ts, MessageQueue* queue, Sample* sample)
+static rmtBool ThreadSampler_Pop(ThreadSampler* ts, rmtMessageQueue* queue, Sample* sample)
{
SampleTree* tree = ts->sample_trees[sample->type];
SampleTree_Pop(tree, sample);
@@ -3902,6 +4145,34 @@ static rmtBool ThreadSampler_Pop(ThreadSampler* ts, MessageQueue* queue, Sample*
}
+static rmtU32 ThreadSampler_GetNameHash(ThreadSampler* ts, rmtPStr name, rmtU32* hash_cache)
+{
+ rmtU32 name_hash = 0;
+
+ // Hash cache provided?
+ if (hash_cache != NULL)
+ {
+ // Calculate the hash first time round only
+ if (*hash_cache == 0)
+ {
+ assert(name != NULL);
+ *hash_cache = MurmurHash3_x86_32(name, (int)strnlen_s(name, 256), 0);
+
+ // Also add to the string table on its first encounter
+ StringTable_Insert(ts->names, *hash_cache, name);
+ }
+
+ return *hash_cache;
+ }
+
+ // Have to recalculate and speculatively insert the name every time when no cache storage exists
+ name_hash = MurmurHash3_x86_32(name, (int)strnlen_s(name, 256), 0);
+ StringTable_Insert(ts->names, name_hash, name);
+ return name_hash;
+}
+
+
+
/*
------------------------------------------------------------------------------------------------------------------------
@@ -3921,12 +4192,19 @@ static void D3D11_Destructor(D3D11* d3d11);
#if RMT_USE_OPENGL
-typedef struct OpenGL OpenGL;
+typedef struct OpenGL_t OpenGL;
static rmtError OpenGL_Create(OpenGL** opengl);
static void OpenGL_Destructor(OpenGL* opengl);
#endif
+#if RMT_USE_METAL
+typedef struct Metal_t Metal;
+static rmtError Metal_Create(Metal** metal);
+static void Metal_Destructor(Metal* metal);
+#endif
+
+
struct Remotery
{
Server* server;
@@ -3940,13 +4218,13 @@ struct Remotery
ThreadSampler* volatile first_thread_sampler;
// Queue between clients and main remotery thread
- MessageQueue* mq_to_rmt_thread;
+ rmtMessageQueue* mq_to_rmt_thread;
- // A dynamically-sized buffer used for encoding the sample tree as JSON and sending to the client
- Buffer* json_buf;
+ // A dynamically-sized buffer used for binary-encoding the sample tree and sending to the client
+ Buffer* bin_buf;
// The main server thread
- Thread* thread;
+ rmtThread* thread;
#if RMT_USE_CUDA
rmtCUDABind cuda;
@@ -3959,6 +4237,10 @@ struct Remotery
#if RMT_USE_OPENGL
OpenGL* opengl;
#endif
+
+#if RMT_USE_METAL
+ Metal* metal;
+#endif
};
@@ -4037,7 +4319,7 @@ static rmtError Remotery_SendLogTextMessage(Remotery* rmt, Message* message)
}
-static rmtError json_SampleTree(Buffer* buffer, Msg_SampleTree* msg)
+static rmtError bin_SampleTree(Buffer* buffer, Msg_SampleTree* msg)
{
Sample* root_sample;
char thread_name[64];
@@ -4063,29 +4345,33 @@ static rmtError json_SampleTree(Buffer* buffer, Msg_SampleTree* msg)
strncat_s(thread_name, sizeof(thread_name), " (D3D11)", 8);
if (root_sample->type == SampleType_OpenGL)
strncat_s(thread_name, sizeof(thread_name), " (OpenGL)", 9);
+ if (root_sample->type == SampleType_Metal)
+ strncat_s(thread_name, sizeof(thread_name), " (Metal)", 8);
// Get digest hash of samples so that viewer can efficiently rebuild its tables
+ rmt_BeginCPUSample(GetSampleDigest, RMTSF_Aggregate);
GetSampleDigest(root_sample, &digest_hash, &nb_samples);
+ rmt_EndCPUSample();
- // Build the sample data
- JSON_ERROR_CHECK(json_OpenObject(buffer));
+ // Write global message header
+ BIN_ERROR_CHECK(Buffer_Write(buffer, (void*)"SMPL ", 8));
- JSON_ERROR_CHECK(json_FieldStr(buffer, "id", "SAMPLES"));
- JSON_ERROR_CHECK(json_Comma(buffer));
- JSON_ERROR_CHECK(json_FieldStr(buffer, "thread_name", thread_name));
- JSON_ERROR_CHECK(json_Comma(buffer));
- JSON_ERROR_CHECK(json_FieldU64(buffer, "nb_samples", nb_samples));
- JSON_ERROR_CHECK(json_Comma(buffer));
- JSON_ERROR_CHECK(json_FieldU64(buffer, "sample_digest", digest_hash));
- JSON_ERROR_CHECK(json_Comma(buffer));
- JSON_ERROR_CHECK(json_SampleArray(buffer, root_sample, "samples"));
+ // Write sample message header
+ BIN_ERROR_CHECK(Buffer_WriteStringWithLength(buffer, thread_name));
+ BIN_ERROR_CHECK(Buffer_WriteU32(buffer, nb_samples));
+ BIN_ERROR_CHECK(Buffer_WriteU32(buffer, digest_hash));
- JSON_ERROR_CHECK(json_CloseObject(buffer));
+ // Write entire sample tree
+ BIN_ERROR_CHECK(bin_Sample(buffer, root_sample));
+
+ // Patch message size
+ U32ToByteArray(buffer->data + 4, buffer->bytes_used);
return RMT_ERROR_NONE;
}
+
#if RMT_USE_CUDA
static rmtBool AreCUDASamplesReady(Sample* sample);
static rmtBool GetCUDASampleTimes(Sample* root_sample, Sample* sample);
@@ -4129,9 +4415,15 @@ static rmtError Remotery_SendSampleTreeMessage(Remotery* rmt, Message* message)
// Serialise the sample tree and send to the viewer with a reasonably long timeout as the size
// of the sample data may be large
- error = json_SampleTree(rmt->json_buf, sample_tree);
+ rmt_BeginCPUSample(bin_SampleTree, RMTSF_Aggregate);
+ error = bin_SampleTree(rmt->bin_buf, sample_tree);
+ rmt_EndCPUSample();
if (error == RMT_ERROR_NONE)
- error = Server_Send(rmt->server, rmt->json_buf->data, rmt->json_buf->bytes_used, 5000);
+ {
+ rmt_BeginCPUSample(Server_Send, RMTSF_Aggregate);
+ error = Server_Send(rmt->server, rmt->bin_buf->data, rmt->bin_buf->bytes_used, 50000);
+ rmt_EndCPUSample();
+ }
// Release the sample tree back to its allocator
FreeSampleTree(sample, sample_tree->allocator);
@@ -4155,7 +4447,7 @@ static rmtError Remotery_ConsumeMessageQueue(Remotery* rmt)
while( nb_messages_sent++ < maxNbMessagesPerUpdate )
{
rmtError error = RMT_ERROR_NONE;
- Message* message = MessageQueue_PeekNextMessage(rmt->mq_to_rmt_thread);
+ Message* message = rmtMessageQueue_PeekNextMessage(rmt->mq_to_rmt_thread);
if (message == NULL)
break;
@@ -4171,12 +4463,14 @@ static rmtError Remotery_ConsumeMessageQueue(Remotery* rmt)
error = Remotery_SendLogTextMessage(rmt, message);
break;
case MsgID_SampleTree:
+ rmt_BeginCPUSample(SendSampleTreeMessage, RMTSF_Aggregate);
error = Remotery_SendSampleTreeMessage(rmt, message);
+ rmt_EndCPUSample();
break;
}
// Consume the message before reacting to any errors
- MessageQueue_ConsumeNextMessage(rmt->mq_to_rmt_thread, message);
+ rmtMessageQueue_ConsumeNextMessage(rmt->mq_to_rmt_thread, message);
if (error != RMT_ERROR_NONE)
return error;
}
@@ -4192,7 +4486,7 @@ static void Remotery_FlushMessageQueue(Remotery* rmt)
// Loop reading all remaining messages
for (;;)
{
- Message* message = MessageQueue_PeekNextMessage(rmt->mq_to_rmt_thread);
+ Message* message = rmtMessageQueue_PeekNextMessage(rmt->mq_to_rmt_thread);
if (message == NULL)
break;
@@ -4212,12 +4506,12 @@ static void Remotery_FlushMessageQueue(Remotery* rmt)
}
}
- MessageQueue_ConsumeNextMessage(rmt->mq_to_rmt_thread, message);
+ rmtMessageQueue_ConsumeNextMessage(rmt->mq_to_rmt_thread, message);
}
}
-static rmtError Remotery_ThreadMain(Thread* thread)
+static rmtError Remotery_ThreadMain(rmtThread* thread)
{
Remotery* rmt = (Remotery*)thread->param;
assert(rmt != NULL);
@@ -4259,6 +4553,69 @@ static rmtError Remotery_ThreadMain(Thread* thread)
}
+static rmtError Remotery_ReceiveMessage(void* context, char* message_data, rmtU32 message_length)
+{
+ Remotery* rmt = (Remotery*)context;
+
+ // Manual dispatch on 4-byte message headers (message ID is little-endian encoded)
+ #define FOURCC(a, b, c, d) (rmtU32)( ((d) << 24) | ((c) << 16) | ((b) << 8) | (a) )
+ rmtU32 message_id = *(rmtU32*)message_data;
+
+ switch (message_id)
+ {
+ case FOURCC('C', 'O', 'N', 'I'):
+ {
+ // Pass on to any registered handler
+ if (g_Settings.input_handler != NULL)
+ g_Settings.input_handler(message_data + 4, g_Settings.input_handler_context);
+
+ rmt_LogText("Console message received...");
+ rmt_LogText(message_data + 4);
+ break;
+ }
+
+ case FOURCC('G', 'S', 'M', 'P'):
+ {
+ // Convert name hash to integer
+ rmtU32 name_hash = 0;
+ const char* cur = message_data + 4;
+ const char* end = cur + message_length - 4;
+ while (cur < end)
+ name_hash = name_hash * 10 + *cur++ - '0';
+
+ // Search all threads for a matching string hash
+ ThreadSampler* ts;
+ for (ts = rmt->first_thread_sampler; ts != NULL; ts = ts->next)
+ {
+ rmtPStr name = StringTable_Find(ts->names, name_hash);
+ if (name != NULL)
+ {
+ // Construct a response message containing the matching name
+ rmtU8 response[256];
+ rmtU32 name_length = (rmtU32)strnlen_s(name, 256 - 12);
+ response[0] = 'S';
+ response[1] = 'S';
+ response[2] = 'M';
+ response[3] = 'P';
+ U32ToByteArray(response + 4, name_hash);
+ U32ToByteArray(response + 8, name_length);
+ memcpy(response + 12, name, name_length);
+
+ // Send back immediately as we're on the server thread
+ return Server_Send(rmt->server, response, 12 + name_length, 10);
+ }
+ }
+
+ break;
+ }
+ }
+
+ #undef FOURCC
+
+ return RMT_ERROR_NONE;
+}
+
+
static rmtError Remotery_Constructor(Remotery* rmt)
{
rmtError error;
@@ -4270,7 +4627,7 @@ static rmtError Remotery_Constructor(Remotery* rmt)
rmt->thread_sampler_tls_handle = TLS_INVALID_HANDLE;
rmt->first_thread_sampler = NULL;
rmt->mq_to_rmt_thread = NULL;
- rmt->json_buf = NULL;
+ rmt->bin_buf = NULL;
rmt->thread = NULL;
#if RMT_USE_CUDA
@@ -4290,6 +4647,10 @@ static rmtError Remotery_Constructor(Remotery* rmt)
rmt->opengl = NULL;
#endif
+ #if RMT_USE_METAL
+ rmt->metal = NULL;
+ #endif
+
// Kick-off the timer
usTimer_Init(&rmt->timer);
@@ -4303,13 +4664,17 @@ static rmtError Remotery_Constructor(Remotery* rmt)
if (error != RMT_ERROR_NONE)
return error;
+ // Setup incoming message handler
+ rmt->server->receive_handler = Remotery_ReceiveMessage;
+ rmt->server->receive_handler_context = rmt;
+
// Create the main message thread with only one page
- New_1(MessageQueue, rmt->mq_to_rmt_thread, g_Settings.messageQueueSizeInBytes);
+ New_1(rmtMessageQueue, rmt->mq_to_rmt_thread, g_Settings.messageQueueSizeInBytes);
if (error != RMT_ERROR_NONE)
return error;
- // Create the JSON serialisation buffer
- New_1(Buffer, rmt->json_buf, 4096);
+ // Create the binary serialisation buffer
+ New_1(Buffer, rmt->bin_buf, 4096);
if (error != RMT_ERROR_NONE)
return error;
@@ -4325,6 +4690,13 @@ static rmtError Remotery_Constructor(Remotery* rmt)
return error;
#endif
+ #if RMT_USE_METAL
+ error = Metal_Create(&rmt->metal);
+ if (error != RMT_ERROR_NONE)
+ return error;
+ #endif
+
+
// Set as the global instance before creating any threads that uses it for sampling itself
assert(g_Remotery == NULL);
g_Remotery = rmt;
@@ -4334,7 +4706,7 @@ static rmtError Remotery_Constructor(Remotery* rmt)
WriteFence();
// Create the main update thread once everything has been defined for the global remotery object
- New_2(Thread, rmt->thread, Remotery_ThreadMain, rmt);
+ New_2(rmtThread, rmt->thread, Remotery_ThreadMain, rmt);
return error;
}
@@ -4344,7 +4716,7 @@ static void Remotery_Destructor(Remotery* rmt)
assert(rmt != NULL);
// Join the remotery thread before clearing the global object as the thread is profiling itself
- Delete(Thread, rmt->thread);
+ Delete(rmtThread, rmt->thread);
if (g_RemoteryCreated)
{
@@ -4360,8 +4732,12 @@ static void Remotery_Destructor(Remotery* rmt)
Delete(OpenGL, rmt->opengl);
#endif
- Delete(Buffer, rmt->json_buf);
- Delete(MessageQueue, rmt->mq_to_rmt_thread);
+ #if RMT_USE_METAL
+ Delete(Metal, rmt->metal);
+ #endif
+
+ Delete(Buffer, rmt->bin_buf);
+ Delete(rmtMessageQueue, rmt->mq_to_rmt_thread);
Remotery_DestroyThreadSamplers(rmt);
@@ -4412,6 +4788,31 @@ static rmtError Remotery_GetThreadSampler(Remotery* rmt, ThreadSampler** thread_
}
+static void Remotery_BlockingDeleteSampleTree(Remotery* rmt, enum SampleType sample_type)
+{
+ ThreadSampler* ts;
+
+ // Get the attached thread sampler
+ assert(rmt != NULL);
+ if (Remotery_GetThreadSampler(rmt, &ts) == RMT_ERROR_NONE)
+ {
+ SampleTree* sample_tree = ts->sample_trees[sample_type];
+ if (sample_tree != NULL)
+ {
+ // Wait around until the Remotery server thread has sent all sample trees
+ // of this type to the client
+ while (sample_tree->allocator->nb_inuse > 1)
+ msSleep(1);
+
+ // Now free to delete
+ Delete(SampleTree, sample_tree);
+ ts->sample_trees[sample_type] = NULL;
+ }
+ }
+}
+
+
+
static void Remotery_DestroyThreadSamplers(Remotery* rmt)
{
// If the handle failed to create in the first place then it shouldn't be possible to create thread samplers
@@ -4474,8 +4875,8 @@ RMT_API rmtSettings* _rmt_Settings(void)
g_Settings.port = 0x4597;
g_Settings.limit_connections_to_localhost = RMT_FALSE;
g_Settings.msSleepBetweenServerUpdates = 10;
- g_Settings.messageQueueSizeInBytes = 64 * 1024;
- g_Settings.maxNbMessagesPerUpdate = 100;
+ g_Settings.messageQueueSizeInBytes = 128 * 1024;
+ g_Settings.maxNbMessagesPerUpdate = 10;
g_Settings.malloc = CRTMalloc;
g_Settings.free = CRTFree;
g_Settings.realloc = CRTRealloc;
@@ -4575,7 +4976,6 @@ static void SetDebuggerThreadName(const char* name)
RMT_API void _rmt_SetCurrentThreadName(rmtPStr thread_name)
{
ThreadSampler* ts;
- rsize_t slen;
if (g_Remotery == NULL)
return;
@@ -4584,47 +4984,39 @@ RMT_API void _rmt_SetCurrentThreadName(rmtPStr thread_name)
if (Remotery_GetThreadSampler(g_Remotery, &ts) != RMT_ERROR_NONE)
return;
- // Use strcat to strcpy the thread name over
- slen = strnlen_s(thread_name, sizeof(ts->name));
- ts->name[0] = 0;
- strncat_s(ts->name, sizeof(ts->name), thread_name, slen);
-
- // Apply to the debugger
+ // Copy name and apply to the debugger
+ strcpy_s(ts->name, sizeof(ts->name), thread_name);
SetDebuggerThreadName(thread_name);
}
-static rmtBool QueueLine(MessageQueue* queue, char* text, rmtU32 size, struct ThreadSampler* thread_sampler)
+static rmtBool QueueLine(rmtMessageQueue* queue, unsigned char* text, rmtU32 size, struct ThreadSampler* thread_sampler)
{
Message* message;
assert(queue != NULL);
- // String/JSON block/null terminate
- text[size++] = '\"';
- text[size++] = '}';
- text[size] = 0;
+ // Prefix with text size
+ rmtU32 text_size = size - 8;
+ U32ToByteArray(text + 4, text_size);
// Allocate some space for the line
- message = MessageQueue_AllocMessage(queue, size, thread_sampler);
+ message = rmtMessageQueue_AllocMessage(queue, size, thread_sampler);
if (message == NULL)
return RMT_FALSE;
// Copy the text and commit the message
memcpy(message->payload, text, size);
- MessageQueue_CommitMessage(message, MsgID_LogText);
+ rmtMessageQueue_CommitMessage(message, MsgID_LogText);
return RMT_TRUE;
}
-static const char log_message[] = "{ \"id\": \"LOG\", \"text\": \"";
-
-
RMT_API void _rmt_LogText(rmtPStr text)
{
int start_offset, prev_offset, i;
- char line_buffer[1024] = { 0 };
+ unsigned char line_buffer[1024] = { 0 };
ThreadSampler* ts;
if (g_Remotery == NULL)
@@ -4632,9 +5024,12 @@ RMT_API void _rmt_LogText(rmtPStr text)
Remotery_GetThreadSampler(g_Remotery, &ts);
- // Start the line buffer off with the JSON message markup
- strncat_s(line_buffer, sizeof(line_buffer), log_message, sizeof(log_message));
- start_offset = (int)strnlen_s(line_buffer, sizeof(line_buffer) - 1);
+ // Start the line with the message header
+ line_buffer[0] = 'L';
+ line_buffer[1] = 'O';
+ line_buffer[2] = 'G';
+ line_buffer[3] = 'M';
+ start_offset = 8;
// There might be newlines in the buffer, so split them into multiple network calls
prev_offset = start_offset;
@@ -4686,26 +5081,6 @@ RMT_API void _rmt_LogText(rmtPStr text)
}
-static rmtU32 GetNameHash(rmtPStr name, rmtU32* hash_cache)
-{
- // Hash cache provided?
- if (hash_cache != NULL)
- {
- // Calculate the hash first time round only
- if (*hash_cache == 0)
- {
- assert(name != NULL);
- *hash_cache = MurmurHash3_x86_32(name, (int)strnlen_s(name, 256), 0);
- }
-
- return *hash_cache;
- }
-
- // Have to recalculate every time when no cache storage exists
- return MurmurHash3_x86_32(name, (int)strnlen_s(name, 256), 0);
-}
-
-
RMT_API void _rmt_BeginCPUSample(rmtPStr name, rmtU32 flags, rmtU32* hash_cache)
{
// 'hash_cache' stores a pointer to a sample name's hash value. Internally this is used to identify unique callstacks and it
@@ -4724,8 +5099,8 @@ RMT_API void _rmt_BeginCPUSample(rmtPStr name, rmtU32 flags, rmtU32* hash_cache)
if (Remotery_GetThreadSampler(g_Remotery, &ts) == RMT_ERROR_NONE)
{
Sample* sample;
- rmtU32 name_hash = GetNameHash(name, hash_cache);
- if (ThreadSampler_Push(ts->sample_trees[SampleType_CPU], name, name_hash, flags, &sample) == RMT_ERROR_NONE)
+ rmtU32 name_hash = ThreadSampler_GetNameHash(ts, name, hash_cache);
+ if (ThreadSampler_Push(ts->sample_trees[SampleType_CPU], name_hash, flags, &sample) == RMT_ERROR_NONE)
{
// If this is an aggregate sample, store the time in 'end' as we want to preserve 'start'
if (sample->us_length != 0)
@@ -4999,7 +5374,7 @@ RMT_API void _rmt_BeginCUDASample(rmtPStr name, rmtU32* hash_cache, void* stream
{
rmtError error;
Sample* sample;
- rmtU32 name_hash = GetNameHash(name, hash_cache);
+ rmtU32 name_hash = ThreadSampler_GetNameHash(ts, name, hash_cache);
// Create the CUDA tree on-demand as the tree needs an up-front-created root.
// This is not possible to create on initialisation as a CUDA binding is not yet available.
@@ -5021,7 +5396,7 @@ RMT_API void _rmt_BeginCUDASample(rmtPStr name, rmtU32* hash_cache, void* stream
}
// Push the same and record its event
- if (ThreadSampler_Push(*cuda_tree, name, name_hash, 0, &sample) == RMT_ERROR_NONE)
+ if (ThreadSampler_Push(*cuda_tree, name_hash, 0, &sample) == RMT_ERROR_NONE)
{
CUDASample* cuda_sample = (CUDASample*)sample;
CUDAEventRecord(cuda_sample->event_start, stream);
@@ -5083,14 +5458,10 @@ typedef struct D3D11
HRESULT last_error;
- // An allocator separate to the samples themselves so that D3D resource lifetime can be controlled
- // outside of the Remotery thread.
- ObjectAllocator* timestamp_allocator;
-
// Queue to the D3D 11 main update thread
// Given that BeginSample/EndSample need to be called from the same thread that does the update, there
// is really no need for this to be a thread-safe queue. I'm using it for its convenience.
- MessageQueue* mq_to_d3d11_main;
+ rmtMessageQueue* mq_to_d3d11_main;
// Mark the first time so that remaining timestamps are offset from this
rmtU64 first_timestamp;
@@ -5112,11 +5483,10 @@ static rmtError D3D11_Create(D3D11** d3d11)
(*d3d11)->device = NULL;
(*d3d11)->context = NULL;
(*d3d11)->last_error = S_OK;
- (*d3d11)->timestamp_allocator = NULL;
(*d3d11)->mq_to_d3d11_main = NULL;
(*d3d11)->first_timestamp = 0;
- New_1(MessageQueue, (*d3d11)->mq_to_d3d11_main, g_Settings.messageQueueSizeInBytes);
+ New_1(rmtMessageQueue, (*d3d11)->mq_to_d3d11_main, g_Settings.messageQueueSizeInBytes);
if (error != RMT_ERROR_NONE)
{
Delete(D3D11, *d3d11);
@@ -5130,9 +5500,7 @@ static rmtError D3D11_Create(D3D11** d3d11)
static void D3D11_Destructor(D3D11* d3d11)
{
assert(d3d11 != NULL);
-
- Delete(ObjectAllocator, d3d11->timestamp_allocator);
- Delete(MessageQueue, d3d11->mq_to_d3d11_main);
+ Delete(rmtMessageQueue, d3d11->mq_to_d3d11_main);
}
@@ -5285,13 +5653,15 @@ typedef struct D3D11Sample
static rmtError D3D11Sample_Constructor(D3D11Sample* sample)
{
+ rmtError error;
+
assert(sample != NULL);
// Chain to sample constructor
Sample_Constructor((Sample*)sample);
sample->Sample.type = SampleType_D3D11;
sample->Sample.size_bytes = sizeof(D3D11Sample);
- sample->timestamp = NULL;
+ New_0(D3D11Timestamp, sample->timestamp);
return RMT_ERROR_NONE;
}
@@ -5299,6 +5669,7 @@ static rmtError D3D11Sample_Constructor(D3D11Sample* sample)
static void D3D11Sample_Destructor(D3D11Sample* sample)
{
+ Delete(D3D11Timestamp, sample->timestamp);
Sample_Destructor((Sample*)sample);
}
@@ -5317,21 +5688,7 @@ RMT_API void _rmt_BindD3D11(void* device, void* context)
}
-static void FreeD3D11TimeStamps(Sample* sample)
-{
- Sample* child;
-
- D3D11Sample* d3d_sample = (D3D11Sample*)sample;
-
- assert(g_Remotery != NULL);
- assert(g_Remotery->d3d11 != NULL);
- assert(d3d_sample->timestamp != NULL);
- ObjectAllocator_Free(g_Remotery->d3d11->timestamp_allocator, (void*)d3d_sample->timestamp);
- d3d_sample->timestamp = NULL;
-
- for (child = sample->first_child; child != NULL; child = child->next_sibling)
- FreeD3D11TimeStamps(child);
-}
+static void UpdateD3D11Frame(void);
RMT_API void _rmt_UnbindD3D11(void)
@@ -5341,33 +5698,17 @@ RMT_API void _rmt_UnbindD3D11(void)
D3D11* d3d11 = g_Remotery->d3d11;
assert(d3d11 != NULL);
+ // Stall waiting for the D3D queue to empty into the Remotery queue
+ while (!rmtMessageQueue_IsEmpty(d3d11->mq_to_d3d11_main))
+ UpdateD3D11Frame();
+
// Inform sampler to not add any more samples
d3d11->device = NULL;
d3d11->context = NULL;
- // Flush the main queue of allocated D3D timestamps
- for (;;)
- {
- Msg_SampleTree* sample_tree;
- Sample* sample;
-
- Message* message = MessageQueue_PeekNextMessage(d3d11->mq_to_d3d11_main);
- if (message == NULL)
- break;
-
- // There's only one valid message type in this queue
- assert(message->id == MsgID_SampleTree);
- sample_tree = (Msg_SampleTree*)message->payload;
- sample = sample_tree->root_sample;
- assert(sample->type == SampleType_D3D11);
- FreeD3D11TimeStamps(sample);
- FreeSampleTree(sample, sample_tree->allocator);
-
- MessageQueue_ConsumeNextMessage(d3d11->mq_to_d3d11_main, message);
- }
-
- // Free all allocated D3D resources
- Delete(ObjectAllocator, d3d11->timestamp_allocator);
+ // Forcefully delete sample tree on this thread to release time stamps from
+ // the same thread that created them
+ Remotery_BlockingDeleteSampleTree(g_Remotery, SampleType_D3D11);
}
}
@@ -5388,34 +5729,25 @@ RMT_API void _rmt_BeginD3D11Sample(rmtPStr name, rmtU32* hash_cache)
if (Remotery_GetThreadSampler(g_Remotery, &ts) == RMT_ERROR_NONE)
{
- rmtError error;
Sample* sample;
- rmtU32 name_hash = GetNameHash(name, hash_cache);
+ rmtU32 name_hash = ThreadSampler_GetNameHash(ts, name, hash_cache);
// Create the D3D11 tree on-demand as the tree needs an up-front-created root.
// This is not possible to create on initialisation as a D3D11 binding is not yet available.
SampleTree** d3d_tree = &ts->sample_trees[SampleType_D3D11];
if (*d3d_tree == NULL)
{
+ rmtError error;
New_3(SampleTree, *d3d_tree, sizeof(D3D11Sample), (ObjConstructor)D3D11Sample_Constructor, (ObjDestructor)D3D11Sample_Destructor);
if (error != RMT_ERROR_NONE)
return;
}
- // Also create the timestamp allocator on-demand to keep the D3D11 code localised to the same file section
- if (d3d11->timestamp_allocator == NULL)
- New_3(ObjectAllocator, d3d11->timestamp_allocator, sizeof(D3D11Timestamp), (ObjConstructor)D3D11Timestamp_Constructor, (ObjDestructor)D3D11Timestamp_Destructor);
-
- // Push the sample
- if (ThreadSampler_Push(*d3d_tree, name, name_hash, 0, &sample) == RMT_ERROR_NONE)
+ // Push the sample and activate the timestamp
+ if (ThreadSampler_Push(*d3d_tree, name_hash, 0, &sample) == RMT_ERROR_NONE)
{
D3D11Sample* d3d_sample = (D3D11Sample*)sample;
-
- // Allocate a timestamp for the sample and activate it
- assert(d3d_sample->timestamp == NULL);
- error = ObjectAllocator_Alloc(d3d11->timestamp_allocator, (void**)&d3d_sample->timestamp);
- if (error == RMT_ERROR_NONE)
- D3D11Timestamp_Begin(d3d_sample->timestamp, d3d11->context);
+ D3D11Timestamp_Begin(d3d_sample->timestamp, d3d11->context);
}
}
}
@@ -5480,7 +5812,7 @@ static void UpdateD3D11Frame(void)
Msg_SampleTree* sample_tree;
Sample* sample;
- Message* message = MessageQueue_PeekNextMessage(d3d11->mq_to_d3d11_main);
+ Message* message = rmtMessageQueue_PeekNextMessage(d3d11->mq_to_d3d11_main);
if (message == NULL)
break;
@@ -5496,9 +5828,8 @@ static void UpdateD3D11Frame(void)
break;
// Pass samples onto the remotery thread for sending to the viewer
- FreeD3D11TimeStamps(sample);
AddSampleTreeMessage(g_Remotery->mq_to_rmt_thread, sample, sample_tree->allocator, sample_tree->thread_name, message->thread_sampler);
- MessageQueue_ConsumeNextMessage(d3d11->mq_to_d3d11_main, message);
+ rmtMessageQueue_ConsumeNextMessage(d3d11->mq_to_d3d11_main, message);
}
rmt_EndCPUSample();
@@ -5600,20 +5931,20 @@ typedef void (GLAPIENTRY * PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target);
#define GL_TIME_ELAPSED 0x88BF
#define GL_TIMESTAMP 0x8E28
-#define RMT_GL_GET_FUN(x) assert(g_Remotery->opengl->x != NULL), g_Remotery->opengl->x
+#define RMT_GL_GET_FUN(x) assert(g_Remotery->opengl->x != NULL); g_Remotery->opengl->x
-#define glGenQueries RMT_GL_GET_FUN(__glGenQueries)
-#define glDeleteQueries RMT_GL_GET_FUN(__glDeleteQueries)
-#define glBeginQuery RMT_GL_GET_FUN(__glBeginQuery)
-#define glEndQuery RMT_GL_GET_FUN(__glEndQuery)
-#define glGetQueryObjectiv RMT_GL_GET_FUN(__glGetQueryObjectiv)
-#define glGetQueryObjectuiv RMT_GL_GET_FUN(__glGetQueryObjectuiv)
-#define glGetQueryObjecti64v RMT_GL_GET_FUN(__glGetQueryObjecti64v)
-#define glGetQueryObjectui64v RMT_GL_GET_FUN(__glGetQueryObjectui64v)
-#define glQueryCounter RMT_GL_GET_FUN(__glQueryCounter)
+#define rmtglGenQueries RMT_GL_GET_FUN(__glGenQueries)
+#define rmtglDeleteQueries RMT_GL_GET_FUN(__glDeleteQueries)
+#define rmtglBeginQuery RMT_GL_GET_FUN(__glBeginQuery)
+#define rmtglEndQuery RMT_GL_GET_FUN(__glEndQuery)
+#define rmtglGetQueryObjectiv RMT_GL_GET_FUN(__glGetQueryObjectiv)
+#define rmtglGetQueryObjectuiv RMT_GL_GET_FUN(__glGetQueryObjectuiv)
+#define rmtglGetQueryObjecti64v RMT_GL_GET_FUN(__glGetQueryObjecti64v)
+#define rmtglGetQueryObjectui64v RMT_GL_GET_FUN(__glGetQueryObjectui64v)
+#define rmtglQueryCounter RMT_GL_GET_FUN(__glQueryCounter)
-typedef struct OpenGL
+struct OpenGL_t
{
// Handle to the OS OpenGL DLL
void* dll_handle;
@@ -5629,18 +5960,14 @@ typedef struct OpenGL
PFNGLGETQUERYOBJECTUI64VPROC __glGetQueryObjectui64v;
PFNGLQUERYCOUNTERPROC __glQueryCounter;
- // An allocator separate to the samples themselves so that OpenGL resource lifetime can be controlled
- // outside of the Remotery thread.
- ObjectAllocator* timestamp_allocator;
-
// Queue to the OpenGL main update thread
// Given that BeginSample/EndSample need to be called from the same thread that does the update, there
// is really no need for this to be a thread-safe queue. I'm using it for its convenience.
- MessageQueue* mq_to_opengl_main;
+ rmtMessageQueue* mq_to_opengl_main;
// Mark the first time so that remaining timestamps are offset from this
rmtU64 first_timestamp;
-} OpenGL;
+};
static GLenum rmtglGetError(void)
@@ -5667,23 +5994,21 @@ static GLenum rmtglGetError(void)
static void* rmtglGetProcAddress(OpenGL* opengl, const char* symbol)
{
- assert(opengl != NULL);
-
#if defined(RMT_PLATFORM_WINDOWS)
{
// Get OpenGL extension-loading function for each call
typedef void* (*wglGetProcAddressFn)(LPCSTR);
{
+ assert(opengl != NULL);
wglGetProcAddressFn wglGetProcAddress = (wglGetProcAddressFn)rmtGetProcAddress(opengl->dll_handle, "wglGetProcAddress");
if (wglGetProcAddress != NULL)
return wglGetProcAddress(symbol);
}
}
- #elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX)
+ #elif defined(RMT_PLATFORM_MACOS) && !defined(GLEW_APPLE_GLX)
- extern void* nsglGetProcAddress(const GLubyte* _name);
- return nsglGetProcAddress((const GLubyte*)symbol);
+ return rmtGetProcAddress(opengl->dll_handle, symbol);
#elif defined(RMT_PLATFORM_LINUX)
@@ -5718,11 +6043,10 @@ static rmtError OpenGL_Create(OpenGL** opengl)
(*opengl)->__glGetQueryObjectui64v = NULL;
(*opengl)->__glQueryCounter = NULL;
- (*opengl)->timestamp_allocator = NULL;
(*opengl)->mq_to_opengl_main = NULL;
(*opengl)->first_timestamp = 0;
- New_1(MessageQueue, (*opengl)->mq_to_opengl_main, g_Settings.messageQueueSizeInBytes);
+ New_1(rmtMessageQueue, (*opengl)->mq_to_opengl_main, g_Settings.messageQueueSizeInBytes);
return error;
}
@@ -5730,8 +6054,7 @@ static rmtError OpenGL_Create(OpenGL** opengl)
static void OpenGL_Destructor(OpenGL* opengl)
{
assert(opengl != NULL);
- Delete(ObjectAllocator, opengl->timestamp_allocator);
- Delete(MessageQueue, opengl->mq_to_opengl_main);
+ Delete(rmtMessageQueue, opengl->mq_to_opengl_main);
}
@@ -5758,7 +6081,7 @@ static rmtError OpenGLTimestamp_Constructor(OpenGLTimestamp* stamp)
// Create start/end timestamp queries
assert(g_Remotery != NULL);
- glGenQueries(2, stamp->queries);
+ rmtglGenQueries(2, stamp->queries);
error = rmtglGetError();
if (error != GL_NO_ERROR)
return RMT_ERROR_OPENGL_ERROR;
@@ -5775,7 +6098,7 @@ static void OpenGLTimestamp_Destructor(OpenGLTimestamp* stamp)
if (stamp->queries[0] != 0)
{
int error;
- glDeleteQueries(2, stamp->queries);
+ rmtglDeleteQueries(2, stamp->queries);
error = rmtglGetError();
assert(error == GL_NO_ERROR);
}
@@ -5784,29 +6107,21 @@ static void OpenGLTimestamp_Destructor(OpenGLTimestamp* stamp)
static void OpenGLTimestamp_Begin(OpenGLTimestamp* stamp)
{
- int error;
-
assert(stamp != NULL);
- // Start of disjoint and first query
+ // First query
assert(g_Remotery != NULL);
- glQueryCounter(stamp->queries[0], GL_TIMESTAMP);
- error = rmtglGetError();
- assert(error == GL_NO_ERROR);
+ rmtglQueryCounter(stamp->queries[0], GL_TIMESTAMP);
}
static void OpenGLTimestamp_End(OpenGLTimestamp* stamp)
{
- int error;
-
assert(stamp != NULL);
- // End of disjoint and second query
+ // Second query
assert(g_Remotery != NULL);
- glQueryCounter(stamp->queries[1], GL_TIMESTAMP);
- error = rmtglGetError();
- assert(error == GL_NO_ERROR);
+ rmtglQueryCounter(stamp->queries[1], GL_TIMESTAMP);
}
@@ -5823,21 +6138,21 @@ static rmtBool OpenGLTimestamp_GetData(OpenGLTimestamp* stamp, rmtU64* out_start
// Check to see if all queries are ready
// If any fail to arrive, wait until later
- glGetQueryObjectiv(stamp->queries[0], GL_QUERY_RESULT_AVAILABLE, &startAvailable);
+ rmtglGetQueryObjectiv(stamp->queries[0], GL_QUERY_RESULT_AVAILABLE, &startAvailable);
error = rmtglGetError();
assert(error == GL_NO_ERROR);
if (!startAvailable)
return RMT_FALSE;
- glGetQueryObjectiv(stamp->queries[1], GL_QUERY_RESULT_AVAILABLE, &endAvailable);
+ rmtglGetQueryObjectiv(stamp->queries[1], GL_QUERY_RESULT_AVAILABLE, &endAvailable);
error = rmtglGetError();
assert(error == GL_NO_ERROR);
if (!endAvailable)
return RMT_FALSE;
- glGetQueryObjectui64v(stamp->queries[0], GL_QUERY_RESULT, &start);
+ rmtglGetQueryObjectui64v(stamp->queries[0], GL_QUERY_RESULT, &start);
error = rmtglGetError();
assert(error == GL_NO_ERROR);
- glGetQueryObjectui64v(stamp->queries[1], GL_QUERY_RESULT, &end);
+ rmtglGetQueryObjectui64v(stamp->queries[1], GL_QUERY_RESULT, &end);
error = rmtglGetError();
assert(error == GL_NO_ERROR);
@@ -5866,13 +6181,15 @@ typedef struct OpenGLSample
static rmtError OpenGLSample_Constructor(OpenGLSample* sample)
{
+ rmtError error;
+
assert(sample != NULL);
// Chain to sample constructor
Sample_Constructor((Sample*)sample);
sample->m_sample.type = SampleType_OpenGL;
sample->m_sample.size_bytes = sizeof(OpenGLSample);
- sample->timestamp = NULL;
+ New_0(OpenGLTimestamp, sample->timestamp);
return RMT_ERROR_NONE;
}
@@ -5880,6 +6197,7 @@ static rmtError OpenGLSample_Constructor(OpenGLSample* sample)
static void OpenGLSample_Destructor(OpenGLSample* sample)
{
+ Delete(OpenGLTimestamp, sample->timestamp);
Sample_Destructor((Sample*)sample);
}
@@ -5893,6 +6211,8 @@ RMT_API void _rmt_BindOpenGL()
#if defined (RMT_PLATFORM_WINDOWS)
opengl->dll_handle = rmtLoadLibrary("opengl32.dll");
+ #elif defined (RMT_PLATFORM_MACOS)
+ opengl->dll_handle = rmtLoadLibrary("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL");
#endif
opengl->__glGetError = (PFNGLGETERRORPROC)rmtGetProcAddress(opengl->dll_handle, "glGetError");
@@ -5909,19 +6229,7 @@ RMT_API void _rmt_BindOpenGL()
}
-static void FreeOpenGLTimeStamps(Sample* sample)
-{
- Sample* child;
-
- OpenGLSample* ogl_sample = (OpenGLSample*)sample;
-
- assert(ogl_sample->timestamp != NULL);
- ObjectAllocator_Free(g_Remotery->opengl->timestamp_allocator, (void*)ogl_sample->timestamp);
- ogl_sample->timestamp = NULL;
-
- for (child = sample->first_child; child != NULL; child = child->next_sibling)
- FreeOpenGLTimeStamps(child);
-}
+static void UpdateOpenGLFrame(void);
RMT_API void _rmt_UnbindOpenGL(void)
@@ -5931,29 +6239,13 @@ RMT_API void _rmt_UnbindOpenGL(void)
OpenGL* opengl = g_Remotery->opengl;
assert(opengl != NULL);
- // Flush the main queue of allocated OpenGL timestamps
- while (1)
- {
- Msg_SampleTree* sample_tree;
- Sample* sample;
-
- Message* message = MessageQueue_PeekNextMessage(opengl->mq_to_opengl_main);
- if (message == NULL)
- break;
-
- // There's only one valid message type in this queue
- assert(message->id == MsgID_SampleTree);
- sample_tree = (Msg_SampleTree*)message->payload;
- sample = sample_tree->root_sample;
- assert(sample->type == SampleType_OpenGL);
- FreeOpenGLTimeStamps(sample);
- FreeSampleTree(sample, sample_tree->allocator);
+ // Stall waiting for the OpenGL queue to empty into the Remotery queue
+ while (!rmtMessageQueue_IsEmpty(opengl->mq_to_opengl_main))
+ UpdateOpenGLFrame();
- MessageQueue_ConsumeNextMessage(opengl->mq_to_opengl_main, message);
- }
-
- // Free all allocated OpenGL resources
- Delete(ObjectAllocator, opengl->timestamp_allocator);
+ // Forcefully delete sample tree on this thread to release time stamps from
+ // the same thread that created them
+ Remotery_BlockingDeleteSampleTree(g_Remotery, SampleType_OpenGL);
// Release reference to the OpenGL DLL
if (opengl->dll_handle != NULL)
@@ -5974,37 +6266,25 @@ RMT_API void _rmt_BeginOpenGLSample(rmtPStr name, rmtU32* hash_cache)
if (Remotery_GetThreadSampler(g_Remotery, &ts) == RMT_ERROR_NONE)
{
- rmtError error;
Sample* sample;
- rmtU32 name_hash = GetNameHash(name, hash_cache);
-
- OpenGL* opengl = g_Remotery->opengl;
+ rmtU32 name_hash = ThreadSampler_GetNameHash(ts, name, hash_cache);
// Create the OpenGL tree on-demand as the tree needs an up-front-created root.
// This is not possible to create on initialisation as a OpenGL binding is not yet available.
SampleTree** ogl_tree = &ts->sample_trees[SampleType_OpenGL];
if (*ogl_tree == NULL)
{
- New_3(SampleTree, *ogl_tree, sizeof(OpenGLSample), (ObjConstructor)OpenGLSample_Constructor, (ObjDestructor)OpenGLSample_Destructor);
+ rmtError error;
+ New_3(SampleTree, *ogl_tree, sizeof(OpenGLSample), (ObjConstructor)OpenGLSample_Constructor, (ObjDestructor)OpenGLSample_Destructor);
if (error != RMT_ERROR_NONE)
return;
}
- // Also create the timestamp allocator on-demand to keep the OpenGL code localised to the same file section
- assert(opengl != NULL);
- if (opengl->timestamp_allocator == NULL)
- New_3(ObjectAllocator, opengl->timestamp_allocator, sizeof(OpenGLTimestamp), (ObjConstructor)OpenGLTimestamp_Constructor, (ObjDestructor)OpenGLTimestamp_Destructor);
-
- // Push the sample
- if (ThreadSampler_Push(*ogl_tree, name, name_hash, 0, &sample) == RMT_ERROR_NONE)
+ // Push the sample and activate the timestamp
+ if (ThreadSampler_Push(*ogl_tree, name_hash, 0, &sample) == RMT_ERROR_NONE)
{
OpenGLSample* ogl_sample = (OpenGLSample*)sample;
-
- // Allocate a timestamp for the sample and activate it
- assert(ogl_sample->timestamp == NULL);
- error = ObjectAllocator_Alloc(opengl->timestamp_allocator, (void**)&ogl_sample->timestamp);
- if (error == RMT_ERROR_NONE)
- OpenGLTimestamp_Begin(ogl_sample->timestamp);
+ OpenGLTimestamp_Begin(ogl_sample->timestamp);
}
}
}
@@ -6054,7 +6334,7 @@ static void UpdateOpenGLFrame(void)
Msg_SampleTree* sample_tree;
Sample* sample;
- Message* message = MessageQueue_PeekNextMessage(opengl->mq_to_opengl_main);
+ Message* message = rmtMessageQueue_PeekNextMessage(opengl->mq_to_opengl_main);
if (message == NULL)
break;
@@ -6070,9 +6350,8 @@ static void UpdateOpenGLFrame(void)
break;
// Pass samples onto the remotery thread for sending to the viewer
- FreeOpenGLTimeStamps(sample);
AddSampleTreeMessage(g_Remotery->mq_to_rmt_thread, sample, sample_tree->allocator, sample_tree->thread_name, message->thread_sampler);
- MessageQueue_ConsumeNextMessage(opengl->mq_to_opengl_main, message);
+ rmtMessageQueue_ConsumeNextMessage(opengl->mq_to_opengl_main, message);
}
rmt_EndCPUSample();
@@ -6105,4 +6384,314 @@ RMT_API void _rmt_EndOpenGLSample(void)
#endif // RMT_USE_OPENGL
+
+/*
+ ------------------------------------------------------------------------------------------------------------------------
+ ------------------------------------------------------------------------------------------------------------------------
+ @Metal: Metal event sampling
+ ------------------------------------------------------------------------------------------------------------------------
+ ------------------------------------------------------------------------------------------------------------------------
+ */
+
+
+
+#if RMT_USE_METAL
+
+
+
+struct Metal_t
+{
+ // Queue to the Metal main update thread
+ // Given that BeginSample/EndSample need to be called from the same thread that does the update, there
+ // is really no need for this to be a thread-safe queue. I'm using it for its convenience.
+ rmtMessageQueue* mq_to_metal_main;
+};
+
+
+static rmtError Metal_Create(Metal** metal)
+{
+ rmtError error;
+
+ assert(metal != NULL);
+
+ *metal = (Metal*)rmtMalloc(sizeof(Metal));
+ if (*metal == NULL)
+ return RMT_ERROR_MALLOC_FAIL;
+
+ (*metal)->mq_to_metal_main = NULL;
+
+ New_1(rmtMessageQueue, (*metal)->mq_to_metal_main, g_Settings.messageQueueSizeInBytes);
+ return error;
+}
+
+
+static void Metal_Destructor(Metal* metal)
+{
+ assert(metal != NULL);
+ Delete(rmtMessageQueue, metal->mq_to_metal_main);
+}
+
+
+typedef struct MetalTimestamp
+{
+ // Inherit so that timestamps can be quickly allocated
+ ObjectLink Link;
+
+ // Output from GPU callbacks
+ rmtU64 start;
+ rmtU64 end;
+ rmtBool ready;
+} MetalTimestamp;
+
+
+static rmtError MetalTimestamp_Constructor(MetalTimestamp* stamp)
+{
+ assert(stamp != NULL);
+
+ ObjectLink_Constructor((ObjectLink*)stamp);
+
+ // Set defaults
+ stamp->start = 0;
+ stamp->end = 0;
+ stamp->ready = RMT_FALSE;
+
+ return RMT_ERROR_NONE;
+}
+
+
+static void MetalTimestamp_Destructor(MetalTimestamp* stamp)
+{
+ assert(stamp != NULL);
+}
+
+
+rmtU64 rmtMetal_usGetTime()
+{
+ // Share the CPU timer for auto-sync
+ assert(g_Remotery != NULL);
+ return usTimer_Get(&g_Remotery->timer);
+}
+
+
+void rmtMetal_MeasureCommandBuffer(unsigned long long* out_start, unsigned long long* out_end, unsigned int* out_ready);
+
+
+static void MetalTimestamp_Begin(MetalTimestamp* stamp)
+{
+ assert(stamp != NULL);
+ stamp->ready = RMT_FALSE;
+
+ // Metal can currently only issue callbacks at the command buffer level
+ // So for now measure execution of the entire command buffer
+ rmtMetal_MeasureCommandBuffer(&stamp->start, &stamp->end, &stamp->ready);
+}
+
+
+static void MetalTimestamp_End(MetalTimestamp* stamp)
+{
+ assert(stamp != NULL);
+
+ // As Metal can currently only measure entire command buffers, this function is a no-op
+ // as the completed handler was already issued in Begin
+}
+
+
+static rmtBool MetalTimestamp_GetData(MetalTimestamp* stamp, rmtU64* out_start, rmtU64* out_end)
+{
+ assert(g_Remotery != NULL);
+ assert(stamp != NULL);
+
+ // GPU writes ready flag when complete handler is called
+ if (stamp->ready == RMT_FALSE)
+ return RMT_FALSE;
+
+ *out_start = stamp->start;
+ *out_end = stamp->end;
+
+ return RMT_TRUE;
+}
+
+
+typedef struct MetalSample
+{
+ // IS-A inheritance relationship
+ Sample m_sample;
+
+ MetalTimestamp* timestamp;
+
+} MetalSample;
+
+
+static rmtError MetalSample_Constructor(MetalSample* sample)
+{
+ rmtError error;
+
+ assert(sample != NULL);
+
+ // Chain to sample constructor
+ Sample_Constructor((Sample*)sample);
+ sample->m_sample.type = SampleType_Metal;
+ sample->m_sample.size_bytes = sizeof(MetalSample);
+ New_0(MetalTimestamp, sample->timestamp);
+
+ return RMT_ERROR_NONE;
+}
+
+
+static void MetalSample_Destructor(MetalSample* sample)
+{
+ Delete(MetalTimestamp, sample->timestamp);
+ Sample_Destructor((Sample*)sample);
+}
+
+
+static void UpdateOpenGLFrame(void);
+
+
+/*RMT_API void _rmt_UnbindMetal(void)
+{
+ if (g_Remotery != NULL)
+ {
+ Metal* metal = g_Remotery->metal;
+ assert(metal != NULL);
+
+ // Stall waiting for the Metal queue to empty into the Remotery queue
+ while (!rmtMessageQueue_IsEmpty(metal->mq_to_metal_main))
+ UpdateMetalFrame();
+
+ // Forcefully delete sample tree on this thread to release time stamps from
+ // the same thread that created them
+ Remotery_BlockingDeleteSampleTree(g_Remotery, SampleType_Metal);
+ }
+}*/
+
+
+RMT_API void _rmt_BeginMetalSample(rmtPStr name, rmtU32* hash_cache)
+{
+ ThreadSampler* ts;
+
+ if (g_Remotery == NULL)
+ return;
+
+ if (Remotery_GetThreadSampler(g_Remotery, &ts) == RMT_ERROR_NONE)
+ {
+ Sample* sample;
+ rmtU32 name_hash = ThreadSampler_GetNameHash(ts, name, hash_cache);
+
+ // Create the Metal tree on-demand as the tree needs an up-front-created root.
+ // This is not possible to create on initialisation as a Metal binding is not yet available.
+ SampleTree** metal_tree = &ts->sample_trees[SampleType_Metal];
+ if (*metal_tree == NULL)
+ {
+ rmtError error;
+ New_3(SampleTree, *metal_tree, sizeof(MetalSample), (ObjConstructor)MetalSample_Constructor, (ObjDestructor)MetalSample_Destructor);
+ if (error != RMT_ERROR_NONE)
+ return;
+ }
+
+ // Push the sample and activate the timestamp
+ if (ThreadSampler_Push(*metal_tree, name_hash, 0, &sample) == RMT_ERROR_NONE)
+ {
+ MetalSample* metal_sample = (MetalSample*)sample;
+ MetalTimestamp_Begin(metal_sample->timestamp);
+ }
+ }
+}
+
+
+static rmtBool GetMetalSampleTimes(Sample* sample)
+{
+ Sample* child;
+
+ MetalSample* metal_sample = (MetalSample*)sample;
+
+ assert(sample != NULL);
+ if (metal_sample->timestamp != NULL)
+ {
+ if (!MetalTimestamp_GetData(metal_sample->timestamp, &sample->us_start, &sample->us_end))
+ return RMT_FALSE;
+
+ sample->us_length = sample->us_end - sample->us_start;
+ }
+
+ // Get child sample times
+ for (child = sample->first_child; child != NULL; child = child->next_sibling)
+ {
+ if (!GetMetalSampleTimes(child))
+ return RMT_FALSE;
+ }
+
+ return RMT_TRUE;
+}
+
+
+static void UpdateMetalFrame(void)
+{
+ Metal* metal;
+
+ if (g_Remotery == NULL)
+ return;
+
+ metal = g_Remotery->metal;
+ assert(metal != NULL);
+
+ rmt_BeginCPUSample(rmt_UpdateMetalFrame, 0);
+
+ // Process all messages in the Metal queue
+ while (1)
+ {
+ Msg_SampleTree* sample_tree;
+ Sample* sample;
+
+ Message* message = rmtMessageQueue_PeekNextMessage(metal->mq_to_metal_main);
+ if (message == NULL)
+ break;
+
+ // There's only one valid message type in this queue
+ assert(message->id == MsgID_SampleTree);
+ sample_tree = (Msg_SampleTree*)message->payload;
+ sample = sample_tree->root_sample;
+ assert(sample->type == SampleType_Metal);
+
+ // Retrieve timing of all Metal samples
+ // If they aren't ready leave the message unconsumed, holding up later frames and maintaining order
+ if (!GetMetalSampleTimes(sample))
+ break;
+
+ // Pass samples onto the remotery thread for sending to the viewer
+ AddSampleTreeMessage(g_Remotery->mq_to_rmt_thread, sample, sample_tree->allocator, sample_tree->thread_name, message->thread_sampler);
+ rmtMessageQueue_ConsumeNextMessage(metal->mq_to_metal_main, message);
+ }
+
+ rmt_EndCPUSample();
+}
+
+
+RMT_API void _rmt_EndMetalSample(void)
+{
+ ThreadSampler* ts;
+
+ if (g_Remotery == NULL)
+ return;
+
+ if (Remotery_GetThreadSampler(g_Remotery, &ts) == RMT_ERROR_NONE)
+ {
+ // Close the timestamp
+ MetalSample* metal_sample = (MetalSample*)ts->sample_trees[SampleType_Metal]->current_parent;
+ if (metal_sample->timestamp != NULL)
+ MetalTimestamp_End(metal_sample->timestamp);
+
+ // Send to the update loop for ready-polling
+ if (ThreadSampler_Pop(ts, g_Remotery->metal->mq_to_metal_main, (Sample*)metal_sample))
+ // Perform ready-polling on popping of the root sample
+ UpdateMetalFrame();
+ }
+}
+
+
+
+#endif // RMT_USE_METAL
+
+
#endif // RMT_ENABLED
+
diff --git a/3rdparty/bgfx/3rdparty/remotery/lib/Remotery.h b/3rdparty/bgfx/3rdparty/remotery/lib/Remotery.h
index 141aeb9315f..9b25a0c40e1 100644
--- a/3rdparty/bgfx/3rdparty/remotery/lib/Remotery.h
+++ b/3rdparty/bgfx/3rdparty/remotery/lib/Remotery.h
@@ -67,6 +67,11 @@ documented just below this comment.
#define RMT_USE_OPENGL 0
#endif
+// Allow Metal profiling
+#ifndef RMT_USE_METAL
+#define RMT_USE_METAL 0
+#endif
+
// Initially use POSIX thread names to name threads instead of Thread0, 1, ...
#ifndef RMT_USE_POSIX_THREADNAMES
#define RMT_USE_POSIX_THREADNAMES 0
@@ -129,9 +134,14 @@ documented just below this comment.
#define IFDEF_RMT_USE_D3D11(t, f) f
#endif
#if RMT_ENABLED && RMT_USE_OPENGL
-#define IFDEF_RMT_USE_OPENGL(t, f) t
+ #define IFDEF_RMT_USE_OPENGL(t, f) t
+#else
+ #define IFDEF_RMT_USE_OPENGL(t, f) f
+#endif
+#if RMT_ENABLED && RMT_USE_METAL
+ #define IFDEF_RMT_USE_METAL(t, f) t
#else
-#define IFDEF_RMT_USE_OPENGL(t, f) f
+ #define IFDEF_RMT_USE_METAL(t, f) f
#endif
@@ -237,7 +247,7 @@ typedef enum rmtError
RMT_ERROR_D3D11_FAILED_TO_CREATE_QUERY, // Failed to create query for sample
// OpenGL error messages
- RMT_ERROR_OPENGL_ERROR, // Generic OpenGL error, no real need to expose more detail since app will probably have an OpenGL error callback registered
+ RMT_ERROR_OPENGL_ERROR, // Generic OpenGL error, no need to expose detail since app will need an OpenGL error callback registered
RMT_ERROR_CUDA_UNKNOWN,
} rmtError;
@@ -424,6 +434,26 @@ typedef struct rmtCUDABind
RMT_OPTIONAL(RMT_USE_OPENGL, _rmt_EndOpenGLSample())
+#define rmt_BindMetal(command_buffer) \
+ RMT_OPTIONAL(RMT_USE_METAL, _rmt_BindMetal(command_buffer));
+
+#define rmt_UnbindMetal() \
+ RMT_OPTIONAL(RMT_USE_METAL, _rmt_UnbindMetal());
+
+#define rmt_BeginMetalSample(name) \
+ RMT_OPTIONAL(RMT_USE_METAL, { \
+ static rmtU32 rmt_sample_hash_##name = 0; \
+ _rmt_BeginMetalSample(#name, &rmt_sample_hash_##name); \
+ })
+
+#define rmt_BeginMetalSampleDynamic(namestr) \
+ RMT_OPTIONAL(RMT_USE_METAL, _rmt_BeginMetalSample(namestr, NULL))
+
+#define rmt_EndMetalSample() \
+ RMT_OPTIONAL(RMT_USE_METAL, _rmt_EndMetalSample())
+
+
+
/*
------------------------------------------------------------------------------------------------------------------------
@@ -485,6 +515,17 @@ struct rmt_EndOpenGLSampleOnScopeExit
};
#endif
+#if RMT_USE_METAL
+extern "C" RMT_API void _rmt_EndMetalSample(void);
+struct rmt_EndMetalSampleOnScopeExit
+{
+ ~rmt_EndMetalSampleOnScopeExit()
+ {
+ _rmt_EndMetalSample();
+ }
+};
+#endif
+
#endif
@@ -502,6 +543,9 @@ struct rmt_EndOpenGLSampleOnScopeExit
#define rmt_ScopedOpenGLSample(name) \
RMT_OPTIONAL(RMT_USE_OPENGL, rmt_BeginOpenGLSample(name)); \
RMT_OPTIONAL(RMT_USE_OPENGL, rmt_EndOpenGLSampleOnScopeExit rmt_ScopedOpenGLSample##name);
+#define rmt_ScopedMetalSample(name) \
+ RMT_OPTIONAL(RMT_USE_METAL, rmt_BeginMetalSample(name)); \
+ RMT_OPTIONAL(RMT_USE_METAL, rmt_EndMetalSampleOnScopeExit rmt_ScopedMetalSample##name);
#endif
@@ -553,10 +597,23 @@ RMT_API void _rmt_BeginOpenGLSample(rmtPStr name, rmtU32* hash_cache);
RMT_API void _rmt_EndOpenGLSample(void);
#endif
+#if RMT_USE_METAL
+RMT_API void _rmt_BeginMetalSample(rmtPStr name, rmtU32* hash_cache);
+RMT_API void _rmt_EndMetalSample(void);
+#endif
+
#ifdef __cplusplus
+
}
#endif
+#if RMT_USE_METAL
+#ifdef __OBJC__
+RMT_API void _rmt_BindMetal(id command_buffer);
+RMT_API void _rmt_UnbindMetal();
+#endif
+#endif
+
#endif // RMT_ENABLED
diff --git a/3rdparty/bgfx/3rdparty/remotery/lib/RemoteryMetal.mm b/3rdparty/bgfx/3rdparty/remotery/lib/RemoteryMetal.mm
new file mode 100644
index 00000000000..b2538eda87a
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/remotery/lib/RemoteryMetal.mm
@@ -0,0 +1,49 @@
+
+#include <Foundation/NSThread.h>
+#include <Foundation/NSDictionary.h>
+#include <Foundation/NSString.h>
+
+#import <Metal/Metal.h>
+
+
+// Store command buffer in thread-local so that each thread can point to its own
+void SetCommandBuffer(id command_buffer)
+{
+ NSMutableDictionary* thread_data = [[NSThread currentThread] threadDictionary];
+ thread_data[@"rmtMTLCommandBuffer"] = command_buffer;
+}
+id GetCommandBuffer()
+{
+ NSMutableDictionary* thread_data = [[NSThread currentThread] threadDictionary];
+ return thread_data[@"rmtMTLCommandBuffer"];
+}
+
+
+void _rmt_BindMetal(id command_buffer)
+{
+ SetCommandBuffer(command_buffer);
+}
+
+
+void _rmt_UnbindMetal()
+{
+ SetCommandBuffer(0);
+}
+
+
+// Needs to be in the same lib for this to work
+unsigned long long rmtMetal_usGetTime();
+
+
+static void SetTimestamp(void* data)
+{
+ *((unsigned long long*)data) = rmtMetal_usGetTime();
+}
+
+
+void rmtMetal_MeasureCommandBuffer(unsigned long long* out_start, unsigned long long* out_end, unsigned int* out_ready)
+{
+ id command_buffer = GetCommandBuffer();
+ [command_buffer addScheduledHandler:^(id <MTLCommandBuffer>){ SetTimestamp(out_start); }];
+ [command_buffer addCompletedHandler:^(id <MTLCommandBuffer>){ SetTimestamp(out_end); *out_ready = 1; }];
+}
diff --git a/3rdparty/bgfx/3rdparty/remotery/readme.md b/3rdparty/bgfx/3rdparty/remotery/readme.md
index 143f58247b7..3dc26f04e6c 100644
--- a/3rdparty/bgfx/3rdparty/remotery/readme.md
+++ b/3rdparty/bgfx/3rdparty/remotery/readme.md
@@ -23,7 +23,7 @@ Compiling
directories to add Remotery/lib path. The required library ws2_32.lib should be picked
up through the use of the #pragma comment(lib, "ws2_32.lib") directive in Remotery.c.
-* Mac OS X (XCode) - simply add lib/Remotery.c and lib/Remotery.h to your program.
+* Mac OS X (XCode) - simply add lib/Remotery.c, lib/Remotery.h and lib/Remotery.mm to your program.
* Linux (GCC) - add the source in lib folder. Compilation of the code requires -pthreads for
library linkage. For example to compile the same run: cc lib/Remotery.c sample/sample.c
@@ -37,7 +37,8 @@ You can define some extra macros to modify what features are compiled into Remot
RMT_USE_TINYCRT 0 Used by the Celtoys TinyCRT library (not released yet)
RMT_USE_CUDA 0 Assuming CUDA headers/libs are setup, allow CUDA profiling
RMT_USE_D3D11 0 Assuming Direct3D 11 headers/libs are setup, allow D3D11 GPU profiling
- RMT_USE_OPENGL 0 Allow OpenGL GPU profiling (standalone except you must link to OpenGL which you already do if you use it)
+ RMT_USE_OPENGL 0 Allow OpenGL GPU profiling (dynamically links OpenGL libraries on available platforms)
+ RMT_USE_METAL 0 Allow Metal profiling of command buffers
Basic Use
@@ -176,6 +177,24 @@ your OpenGL device and context, ensure you notify Remotery before shutting down
rmt_UnbindOpenGL();
+Sampling Metal GPU activity
+---------------------------
+
+Remotery can sample Metal command buffers issued to the GPU from multiple threads. As the Metal API does not
+support finer grained profiling, samples will return only the timing of the bound command buffer, irrespective
+of how many you issue. As such, make sure you bind and sample the command buffer for each call site:
+
+ rmt_BindMetal(mtl_command_buffer);
+ rmt_ScopedMetalSample(command_buffer_name);
+
+The C API supports begin/end also:
+
+ rmt_BindMetal(mtl_command_buffer);
+ rmt_BeginMetalSample(command_buffer_name);
+ ...
+ rmt_EndMetalSample();
+
+
Applying Configuration Settings
-------------------------------
diff --git a/3rdparty/bgfx/3rdparty/remotery/vis/Code/Console.js b/3rdparty/bgfx/3rdparty/remotery/vis/Code/Console.js
index a18f3dce49e..cd25dc7f708 100644
--- a/3rdparty/bgfx/3rdparty/remotery/vis/Code/Console.js
+++ b/3rdparty/bgfx/3rdparty/remotery/vis/Code/Console.js
@@ -36,7 +36,7 @@ Console = (function()
// Setup log requests from the server
this.Server = server;
server.SetConsole(this);
- server.AddMessageHandler("LOG", Bind(OnLog, this));
+ server.AddMessageHandler("LOGM", Bind(OnLog, this));
}
@@ -65,9 +65,11 @@ Console = (function()
}
- function OnLog(self, socket, message)
+ function OnLog(self, socket, data_view)
{
- self.AppTextBuffer = LogText(self.AppTextBuffer, message.text);
+ var data_view_reader = new DataViewReader(data_view, 4);
+ var text = data_view_reader.GetString();
+ self.AppTextBuffer = LogText(self.AppTextBuffer, text);
}
diff --git a/3rdparty/bgfx/3rdparty/remotery/vis/Code/DataViewReader.js b/3rdparty/bgfx/3rdparty/remotery/vis/Code/DataViewReader.js
new file mode 100644
index 00000000000..ba3fc8e0da0
--- /dev/null
+++ b/3rdparty/bgfx/3rdparty/remotery/vis/Code/DataViewReader.js
@@ -0,0 +1,47 @@
+
+//
+// Simple wrapper around DataView that auto-advances the read offset and provides
+// a few common data type conversions specific to this app
+//
+DataViewReader = (function ()
+{
+ function DataViewReader(data_view, offset)
+ {
+ this.DataView = data_view;
+ this.Offset = offset;
+ }
+
+ DataViewReader.prototype.GetUInt32 = function ()
+ {
+ var v = this.DataView.getUint32(this.Offset, true);
+ this.Offset += 4;
+ return v;
+ }
+
+ DataViewReader.prototype.GetUInt64 = function ()
+ {
+ var v = this.DataView.getFloat64(this.Offset, true);
+ this.Offset += 8;
+ return v;
+ }
+
+ DataViewReader.prototype.GetStringOfLength = function (string_length)
+ {
+ var string = "";
+ for (var i = 0; i < string_length; i++)
+ {
+ string += String.fromCharCode(this.DataView.getInt8(this.Offset));
+ this.Offset++;
+ }
+
+ return string;
+ }
+
+ DataViewReader.prototype.GetString = function ()
+ {
+ var string_length = this.GetUInt32();
+ return this.GetStringOfLength(string_length);
+ }
+
+ return DataViewReader;
+})();
diff --git a/3rdparty/bgfx/3rdparty/remotery/vis/Code/Remotery.js b/3rdparty/bgfx/3rdparty/remotery/vis/Code/Remotery.js
index 5030f8802bb..ca1d4f7984c 100644
--- a/3rdparty/bgfx/3rdparty/remotery/vis/Code/Remotery.js
+++ b/3rdparty/bgfx/3rdparty/remotery/vis/Code/Remotery.js
@@ -20,12 +20,37 @@ Settings = (function()
Remotery = (function()
{
+ // crack the url and get the parameter we want
+ var getUrlParameter = function getUrlParameter( search_param)
+ {
+ var page_url = decodeURIComponent( window.location.search.substring(1) ),
+ url_vars = page_url.split('&'),
+ param_name,
+ i;
+
+ for (i = 0; i < url_vars.length; i++)
+ {
+ param_name = url_vars[i].split('=');
+
+ if (param_name[0] === search_param)
+ {
+ return param_name[1] === undefined ? true : param_name[1];
+ }
+ }
+ };
+
function Remotery()
{
this.WindowManager = new WM.WindowManager();
this.Settings = new Settings();
- this.ConnectionAddress = LocalStore.Get("App", "Global", "ConnectionAddress", "ws://127.0.0.1:17815/rmt");
+ // "addr" param is ip:port and will override the local store version if passed in the URL
+ var addr = getUrlParameter( "addr" );
+ if ( addr != null )
+ this.ConnectionAddress = "ws://" + addr + "/rmt";
+ else
+ this.ConnectionAddress = LocalStore.Get("App", "Global", "ConnectionAddress", "ws://127.0.0.1:17815/rmt");
+
this.Server = new WebSocketConnection();
this.Server.AddConnectHandler(Bind(OnConnect, this));
@@ -43,8 +68,10 @@ Remotery = (function()
this.SampleWindows = { };
this.FrameHistory = { };
this.SelectedFrames = { };
+ this.NameMap = { };
- this.Server.AddMessageHandler("SAMPLES", Bind(OnSamples, this));
+ this.Server.AddMessageHandler("SMPL", Bind(OnSamples, this));
+ this.Server.AddMessageHandler("SSMP", Bind(OnSampleName, this));
// Kick-off the auto-connect loop
AutoConnect(this);
@@ -80,10 +107,6 @@ Remotery = (function()
{
// Connection address has been validated
LocalStore.Set("App", "Global", "ConnectionAddress", self.ConnectionAddress);
-
- self.TimelineWindow.ResetTimeRange();
- self.FrameHistory = { };
- self.SelectedFrames = { };
}
@@ -115,7 +138,8 @@ Remotery = (function()
// requestAnimationFrame can run up to 60hz which is way too much for drawing the timeline
// Assume it's running at 60hz and skip frames to achieve 10hz instead
- // Doing this instead of using setTimeout because it's better for browser rendering (or; will be once WebGL is in use)
+ // Doing this instead of using setTimeout because it's better for browser rendering (or; will be once WebGL is in use)
+ // TODO: Expose as config variable because high refresh rate is great when using a separate viewiing machine
if ((self.DisplayFrame % 10) == 0)
self.TimelineWindow.DrawAllRows();
@@ -123,15 +147,74 @@ Remotery = (function()
}
- function OnSamples(self, socket, message)
+ function DecodeSample(self, data_view_reader)
{
- var name = message.thread_name;
+ var sample = {};
+
+ // Get name hash and lookup name it map
+ sample.name_hash = data_view_reader.GetUInt32();
+ sample.name = self.NameMap[sample.name_hash];
+
+ // If the name doesn't exist in the map yet, request it from the server
+ if (sample.name == undefined)
+ {
+ // Meanwhile, store the hash as the name
+ sample.name = sample.name_hash;
+ self.Server.Send("GSMP" + sample.name);
+ }
+
+ // Get the rest of the sample data
+ sample.id = data_view_reader.GetUInt32();
+ sample.colour = data_view_reader.GetStringOfLength(7);
+ sample.us_start = data_view_reader.GetUInt64();
+ sample.us_length = data_view_reader.GetUInt64();
+
+ // Recurse into children
+ sample.children = [];
+ DecodeSampleArray(self, data_view_reader, sample.children);
+
+ return sample;
+ }
+
+
+ function DecodeSampleArray(self, data_view_reader, samples)
+ {
+ var nb_samples = data_view_reader.GetUInt32();
+ for (var i = 0; i < nb_samples; i++)
+ {
+ var sample = DecodeSample(self, data_view_reader);
+ samples.push(sample)
+ }
+ }
+
+ function DecodeSamples(self, data_view_reader)
+ {
+ // Message-specific header
+ var message = { };
+ message.thread_name = data_view_reader.GetString();
+ message.nb_samples = data_view_reader.GetUInt32();
+ message.sample_digest = data_view_reader.GetUInt32();
+
+ // Read samples
+ message.samples = [];
+ message.samples.push(DecodeSample(self, data_view_reader));
+
+ return message;
+ }
+
+
+ function OnSamples(self, socket, data_view)
+ {
// Discard any new samples while paused
if (self.Settings.IsPaused)
- return;
+ return;
+
+ // Binary decode incoming sample data
+ var message = DecodeSamples(self, new DataViewReader(data_view, 8));
+ var name = message.thread_name;
- // Add to frame history for this thread
+ // Add to frame history for this thread
var thread_frame = new ThreadFrame(message);
if (!(name in self.FrameHistory))
self.FrameHistory[name] = [ ];
@@ -142,7 +225,7 @@ Remotery = (function()
var max_nb_frames = 10000;
var extra_frames = frame_history.length - max_nb_frames;
if (extra_frames > 0)
- frame_history.splice(0, extra_frames);
+ frame_history.splice(0, extra_frames);
// Create sample windows on-demand
if (!(name in self.SampleWindows))
@@ -159,6 +242,16 @@ Remotery = (function()
}
+ function OnSampleName(self, socket, data_view)
+ {
+ // Add any names sent by the server to the local map
+ var data_view_reader = new DataViewReader(data_view, 4);
+ var name_hash = data_view_reader.GetUInt32();
+ var name = data_view_reader.GetString();
+ self.NameMap[name_hash] = name;
+ }
+
+
function OnTimelineCheck(self, name, evt)
{
// Show/hide the equivalent sample window and move all the others to occupy any left-over space
diff --git a/3rdparty/bgfx/3rdparty/remotery/vis/Code/SampleWindow.js b/3rdparty/bgfx/3rdparty/remotery/vis/Code/SampleWindow.js
index 7d7fa6cf551..74f769eff8a 100644
--- a/3rdparty/bgfx/3rdparty/remotery/vis/Code/SampleWindow.js
+++ b/3rdparty/bgfx/3rdparty/remotery/vis/Code/SampleWindow.js
@@ -72,7 +72,7 @@ SampleWindow = (function()
if (this.SampleDigest != sample_digest)
{
this.RootRow.Rows.ClearIndex("_ID");
- var index = UpdateSamples(this.RootRow, samples, 0, "");
+ var index = UpdateAllSampleFields(this.RootRow, samples, 0, "");
this.SampleDigest = sample_digest;
// Clear out any left-over rows
@@ -85,8 +85,8 @@ SampleWindow = (function()
else if (this.Visible)
{
- // Otherwise just update the existing sample times
- UpdateSampleTimes(this.RootRow, samples);
+ // Otherwise just update the existing sample fields
+ UpdateChangedSampleFields(this.RootRow, samples, "");
}
}
@@ -99,7 +99,7 @@ SampleWindow = (function()
{
var cell_data =
{
- _ID: i,
+ _ID: i,
Name: "",
Control: new WM.Label()
};
@@ -114,7 +114,7 @@ SampleWindow = (function()
}
- function UpdateSamples(parent_row, samples, index, indent)
+ function UpdateAllSampleFields(parent_row, samples, index, indent)
{
for (var i in samples)
{
@@ -131,21 +131,24 @@ SampleWindow = (function()
row.CellData._ID = sample.id;
parent_row.Rows.AddRowToIndex("_ID", sample.id, row);
- // Set sample name and colour
+ // Record sample name for later comparison
+ row.CellData.Name = sample.name;
+
+ // Set sample name and colour
var name_node = row.CellNodes["Name"];
name_node.innerHTML = indent + sample.name;
DOM.Node.SetColour(name_node, sample.colour);
row.CellData.Control.SetText(sample.us_length);
- index = UpdateSamples(parent_row, sample.children, index, indent + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
+ index = UpdateAllSampleFields(parent_row, sample.children, index, indent + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
}
return index;
}
- function UpdateSampleTimes(parent_row, samples)
+ function UpdateChangedSampleFields(parent_row, samples, indent)
{
for (var i in samples)
{
@@ -153,9 +156,20 @@ SampleWindow = (function()
var row = parent_row.Rows.GetBy("_ID", sample.id);
if (row)
- row.CellData.Control.SetText(sample.us_length);
+ {
+ row.CellData.Control.SetText(sample.us_length);
+
+ // Sample name will change when it switches from hash ID to network-retrieved
+ // name. Quickly check that before re-applying the HTML for the name.
+ if (row.CellData.Name != sample.name)
+ {
+ var name_node = row.CellNodes["Name"];
+ row.CellData.Name = sample.name;
+ name_node.innerHTML = indent + sample.name;
+ }
+ }
- UpdateSampleTimes(parent_row, sample.children);
+ UpdateChangedSampleFields(parent_row, sample.children, indent + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
}
}
diff --git a/3rdparty/bgfx/3rdparty/remotery/vis/Code/TimelineRow.js b/3rdparty/bgfx/3rdparty/remotery/vis/Code/TimelineRow.js
index 40af0430329..9645f25a6b5 100644
--- a/3rdparty/bgfx/3rdparty/remotery/vis/Code/TimelineRow.js
+++ b/3rdparty/bgfx/3rdparty/remotery/vis/Code/TimelineRow.js
@@ -356,8 +356,9 @@ TimelineRow = (function()
ctx.strokeRect(offset_x + 0.5, offset_y + 0.5, size_x - 1, size_y - 1);
}
- // Draw sample names clipped to the bounds of the sample
- if (draw_text)
+ // Draw sample names clipped to the bounds of the sample
+ // Also reject tiny samples with no space to render text
+ if (draw_text && size_x > 8)
{
ctx.save();
ctx.beginPath();
diff --git a/3rdparty/bgfx/3rdparty/remotery/vis/Code/WebSocketConnection.js b/3rdparty/bgfx/3rdparty/remotery/vis/Code/WebSocketConnection.js
index 2fbc31b7453..95b1208be03 100644
--- a/3rdparty/bgfx/3rdparty/remotery/vis/Code/WebSocketConnection.js
+++ b/3rdparty/bgfx/3rdparty/remotery/vis/Code/WebSocketConnection.js
@@ -52,6 +52,7 @@ WebSocketConnection = (function()
Log(this, "Connecting to " + address);
this.Socket = new WebSocket(address);
+ this.Socket.binaryType = "arraybuffer";
this.Socket.onopen = Bind(OnOpen, this);
this.Socket.onmessage = Bind(OnMessage, this);
this.Socket.onclose = Bind(OnClose, this);
@@ -80,13 +81,13 @@ WebSocketConnection = (function()
}
- function CallMessageHandlers(self, message_name, message)
+ function CallMessageHandlers(self, message_name, data_view)
{
if (message_name in self.MessageHandlers)
{
var handlers = self.MessageHandlers[message_name];
for (var i in handlers)
- handlers[i](self, message);
+ handlers[i](self, data_view);
}
}
@@ -120,9 +121,15 @@ WebSocketConnection = (function()
function OnMessage(self, event)
{
- var message = JSON.parse(event.data);
- if ("id" in message)
- CallMessageHandlers(self, message.id, message);
+ var data_view = new DataView(event.data);
+
+ var id = String.fromCharCode(
+ data_view.getInt8(0),
+ data_view.getInt8(1),
+ data_view.getInt8(2),
+ data_view.getInt8(3));
+
+ CallMessageHandlers(self, id, data_view);
}
diff --git a/3rdparty/bgfx/3rdparty/remotery/vis/index.html b/3rdparty/bgfx/3rdparty/remotery/vis/index.html
index b761290559a..3e572568256 100644
--- a/3rdparty/bgfx/3rdparty/remotery/vis/index.html
+++ b/3rdparty/bgfx/3rdparty/remotery/vis/index.html
@@ -29,6 +29,7 @@
<script type="text/javascript" src="extern/BrowserLib/WindowManager/Code/Button.js"></script>
<!-- Main Application -->
+ <script type="text/javascript" src="Code/DataViewReader.js"></script>
<script type="text/javascript" src="Code/Console.js"></script>
<script type="text/javascript" src="Code/WebSocketConnection.js"></script>
<script type="text/javascript" src="Code/TitleWindow.js"></script>
diff --git a/3rdparty/bgfx/3rdparty/tinyexr/tinyexr.h b/3rdparty/bgfx/3rdparty/tinyexr/tinyexr.h
index 38ac53c66eb..947941de4c9 100644
--- a/3rdparty/bgfx/3rdparty/tinyexr/tinyexr.h
+++ b/3rdparty/bgfx/3rdparty/tinyexr/tinyexr.h
@@ -440,11 +440,15 @@ extern int LoadEXRFromMemory(float *out_rgba, const unsigned char *memory,
#include "zfp.h"
#endif
+#if __cplusplus > 199711L
+// C++11
+#include <cstdint>
+#endif // __cplusplus > 199711L
+
namespace tinyexr {
#if __cplusplus > 199711L
// C++11
-#include <cstdint>
typedef uint64_t tinyexr_uint64;
typedef int64_t tinyexr_int64;
#else
@@ -7076,7 +7080,7 @@ static const char *ReadString(std::string *s, const char *ptr) {
static bool ReadAttribute(std::string *name, std::string *type,
std::vector<unsigned char> *data, size_t *marker_size,
const char *marker, size_t size) {
- size_t name_len = bx::strnlen(marker, size);
+ size_t name_len = strnlen(marker, size);
if (name_len == size) {
// String does not have a terminating character.
return false;
@@ -7086,7 +7090,7 @@ static bool ReadAttribute(std::string *name, std::string *type,
marker += name_len + 1;
size -= name_len + 1;
- size_t type_len = bx::strnlen(marker, size);
+ size_t type_len = strnlen(marker, size);
if (type_len == size) {
return false;
}
diff --git a/3rdparty/bgfx/README.md b/3rdparty/bgfx/README.md
index 35364020c97..2c4a3be59ba 100644
--- a/3rdparty/bgfx/README.md
+++ b/3rdparty/bgfx/README.md
@@ -190,6 +190,8 @@ width="640" height="480" border="0" /></a>
https://github.com/degenerated1123/REGoth - Open source reimplementation of the
zEngine, used by the game "Gothic" and "Gothic II".
+Browser demo: http://gothic-dx11.de/gothic-js/REGoth.html
+
<a href="http://www.youtube.com/watch?feature=player_embedded&v=8bLAGttYYpY
" target="_blank"><img src="http://img.youtube.com/vi/8bLAGttYYpY/0.jpg"
alt="REGoth Engine"
diff --git a/3rdparty/bgfx/examples/01-cubes/makefile b/3rdparty/bgfx/examples/01-cubes/makefile
index e6278cb66dc..94d3aae708a 100644
--- a/3rdparty/bgfx/examples/01-cubes/makefile
+++ b/3rdparty/bgfx/examples/01-cubes/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
BGFX_DIR=../..
@@ -8,11 +8,3 @@ RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
BUILD_DIR=../../.build
include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
- @make -s --no-print-directory TARGET=0 clean all
- @make -s --no-print-directory TARGET=1 clean all
- @make -s --no-print-directory TARGET=2 clean all
- @make -s --no-print-directory TARGET=3 clean all
- @make -s --no-print-directory TARGET=4 clean all
- @make -s --no-print-directory TARGET=5 clean all
diff --git a/3rdparty/bgfx/examples/02-metaballs/makefile b/3rdparty/bgfx/examples/02-metaballs/makefile
index 818fe30cbd7..a9e31815229 100644
--- a/3rdparty/bgfx/examples/02-metaballs/makefile
+++ b/3rdparty/bgfx/examples/02-metaballs/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
include ../../scripts/shader-embeded.mk
diff --git a/3rdparty/bgfx/examples/03-raymarch/makefile b/3rdparty/bgfx/examples/03-raymarch/makefile
index e6278cb66dc..94d3aae708a 100644
--- a/3rdparty/bgfx/examples/03-raymarch/makefile
+++ b/3rdparty/bgfx/examples/03-raymarch/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
BGFX_DIR=../..
@@ -8,11 +8,3 @@ RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
BUILD_DIR=../../.build
include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
- @make -s --no-print-directory TARGET=0 clean all
- @make -s --no-print-directory TARGET=1 clean all
- @make -s --no-print-directory TARGET=2 clean all
- @make -s --no-print-directory TARGET=3 clean all
- @make -s --no-print-directory TARGET=4 clean all
- @make -s --no-print-directory TARGET=5 clean all
diff --git a/3rdparty/bgfx/examples/04-mesh/makefile b/3rdparty/bgfx/examples/04-mesh/makefile
index e6278cb66dc..94d3aae708a 100644
--- a/3rdparty/bgfx/examples/04-mesh/makefile
+++ b/3rdparty/bgfx/examples/04-mesh/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
BGFX_DIR=../..
@@ -8,11 +8,3 @@ RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
BUILD_DIR=../../.build
include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
- @make -s --no-print-directory TARGET=0 clean all
- @make -s --no-print-directory TARGET=1 clean all
- @make -s --no-print-directory TARGET=2 clean all
- @make -s --no-print-directory TARGET=3 clean all
- @make -s --no-print-directory TARGET=4 clean all
- @make -s --no-print-directory TARGET=5 clean all
diff --git a/3rdparty/bgfx/examples/05-instancing/makefile b/3rdparty/bgfx/examples/05-instancing/makefile
index e6278cb66dc..94d3aae708a 100644
--- a/3rdparty/bgfx/examples/05-instancing/makefile
+++ b/3rdparty/bgfx/examples/05-instancing/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
BGFX_DIR=../..
@@ -8,11 +8,3 @@ RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
BUILD_DIR=../../.build
include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
- @make -s --no-print-directory TARGET=0 clean all
- @make -s --no-print-directory TARGET=1 clean all
- @make -s --no-print-directory TARGET=2 clean all
- @make -s --no-print-directory TARGET=3 clean all
- @make -s --no-print-directory TARGET=4 clean all
- @make -s --no-print-directory TARGET=5 clean all
diff --git a/3rdparty/bgfx/examples/06-bump/makefile b/3rdparty/bgfx/examples/06-bump/makefile
index e6278cb66dc..94d3aae708a 100644
--- a/3rdparty/bgfx/examples/06-bump/makefile
+++ b/3rdparty/bgfx/examples/06-bump/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
BGFX_DIR=../..
@@ -8,11 +8,3 @@ RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
BUILD_DIR=../../.build
include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
- @make -s --no-print-directory TARGET=0 clean all
- @make -s --no-print-directory TARGET=1 clean all
- @make -s --no-print-directory TARGET=2 clean all
- @make -s --no-print-directory TARGET=3 clean all
- @make -s --no-print-directory TARGET=4 clean all
- @make -s --no-print-directory TARGET=5 clean all
diff --git a/3rdparty/bgfx/examples/07-callback/callback.cpp b/3rdparty/bgfx/examples/07-callback/callback.cpp
index b2eb8ad0a47..9b2305e81c0 100644
--- a/3rdparty/bgfx/examples/07-callback/callback.cpp
+++ b/3rdparty/bgfx/examples/07-callback/callback.cpp
@@ -126,7 +126,7 @@ struct BgfxCallback : public bgfx::CallbackI
virtual void fatal(bgfx::Fatal::Enum _code, const char* _str) BX_OVERRIDE
{
// Something unexpected happened, inform user and bail out.
- dbgPrintf("Fatal error: 0x%08x: %s", _code, _str);
+ bx::debugPrintf("Fatal error: 0x%08x: %s", _code, _str);
// Must terminate, continuing will cause crash anyway.
abort();
@@ -134,8 +134,8 @@ struct BgfxCallback : public bgfx::CallbackI
virtual void traceVargs(const char* _filePath, uint16_t _line, const char* _format, va_list _argList) BX_OVERRIDE
{
- dbgPrintf("%s (%d): ", _filePath, _line);
- dbgPrintfVargs(_format, _argList);
+ bx::debugPrintf("%s (%d): ", _filePath, _line);
+ bx::debugPrintfVargs(_format, _argList);
}
virtual uint32_t cacheReadSize(uint64_t _id) BX_OVERRIDE
@@ -257,7 +257,7 @@ public:
{
if (BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT >= _align)
{
- dbgPrintf("%s(%d): FREE %p\n", _file, _line, _ptr);
+ bx::debugPrintf("%s(%d): FREE %p\n", _file, _line, _ptr);
::free(_ptr);
--m_numBlocks;
}
@@ -274,7 +274,7 @@ public:
if (BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT >= _align)
{
void* ptr = ::malloc(_size);
- dbgPrintf("%s(%d): ALLOC %p of %d byte(s)\n", _file, _line, ptr, _size);
+ bx::debugPrintf("%s(%d): ALLOC %p of %d byte(s)\n", _file, _line, ptr, _size);
++m_numBlocks;
m_maxBlocks = bx::uint32_max(m_maxBlocks, m_numBlocks);
return ptr;
@@ -286,7 +286,7 @@ public:
if (BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT >= _align)
{
void* ptr = ::realloc(_ptr, _size);
- dbgPrintf("%s(%d): REALLOC %p (old %p) of %d byte(s)\n", _file, _line, ptr, _ptr, _size);
+ bx::debugPrintf("%s(%d): REALLOC %p (old %p) of %d byte(s)\n", _file, _line, ptr, _ptr, _size);
if (NULL == _ptr)
{
@@ -302,7 +302,7 @@ public:
void dumpStats() const
{
- dbgPrintf("Allocator stats: num blocks %d (peak: %d)\n", m_numBlocks, m_maxBlocks);
+ bx::debugPrintf("Allocator stats: num blocks %d (peak: %d)\n", m_numBlocks, m_maxBlocks);
}
private:
diff --git a/3rdparty/bgfx/examples/07-callback/makefile b/3rdparty/bgfx/examples/07-callback/makefile
index e6278cb66dc..94d3aae708a 100644
--- a/3rdparty/bgfx/examples/07-callback/makefile
+++ b/3rdparty/bgfx/examples/07-callback/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
BGFX_DIR=../..
@@ -8,11 +8,3 @@ RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
BUILD_DIR=../../.build
include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
- @make -s --no-print-directory TARGET=0 clean all
- @make -s --no-print-directory TARGET=1 clean all
- @make -s --no-print-directory TARGET=2 clean all
- @make -s --no-print-directory TARGET=3 clean all
- @make -s --no-print-directory TARGET=4 clean all
- @make -s --no-print-directory TARGET=5 clean all
diff --git a/3rdparty/bgfx/examples/08-update/makefile b/3rdparty/bgfx/examples/08-update/makefile
index e6278cb66dc..94d3aae708a 100644
--- a/3rdparty/bgfx/examples/08-update/makefile
+++ b/3rdparty/bgfx/examples/08-update/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
BGFX_DIR=../..
@@ -8,11 +8,3 @@ RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
BUILD_DIR=../../.build
include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
- @make -s --no-print-directory TARGET=0 clean all
- @make -s --no-print-directory TARGET=1 clean all
- @make -s --no-print-directory TARGET=2 clean all
- @make -s --no-print-directory TARGET=3 clean all
- @make -s --no-print-directory TARGET=4 clean all
- @make -s --no-print-directory TARGET=5 clean all
diff --git a/3rdparty/bgfx/examples/09-hdr/makefile b/3rdparty/bgfx/examples/09-hdr/makefile
index e6278cb66dc..94d3aae708a 100644
--- a/3rdparty/bgfx/examples/09-hdr/makefile
+++ b/3rdparty/bgfx/examples/09-hdr/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
BGFX_DIR=../..
@@ -8,11 +8,3 @@ RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
BUILD_DIR=../../.build
include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
- @make -s --no-print-directory TARGET=0 clean all
- @make -s --no-print-directory TARGET=1 clean all
- @make -s --no-print-directory TARGET=2 clean all
- @make -s --no-print-directory TARGET=3 clean all
- @make -s --no-print-directory TARGET=4 clean all
- @make -s --no-print-directory TARGET=5 clean all
diff --git a/3rdparty/bgfx/examples/12-lod/makefile b/3rdparty/bgfx/examples/12-lod/makefile
index e6278cb66dc..94d3aae708a 100644
--- a/3rdparty/bgfx/examples/12-lod/makefile
+++ b/3rdparty/bgfx/examples/12-lod/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
BGFX_DIR=../..
@@ -8,11 +8,3 @@ RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
BUILD_DIR=../../.build
include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
- @make -s --no-print-directory TARGET=0 clean all
- @make -s --no-print-directory TARGET=1 clean all
- @make -s --no-print-directory TARGET=2 clean all
- @make -s --no-print-directory TARGET=3 clean all
- @make -s --no-print-directory TARGET=4 clean all
- @make -s --no-print-directory TARGET=5 clean all
diff --git a/3rdparty/bgfx/examples/13-stencil/makefile b/3rdparty/bgfx/examples/13-stencil/makefile
index e6278cb66dc..94d3aae708a 100644
--- a/3rdparty/bgfx/examples/13-stencil/makefile
+++ b/3rdparty/bgfx/examples/13-stencil/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
BGFX_DIR=../..
@@ -8,11 +8,3 @@ RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
BUILD_DIR=../../.build
include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
- @make -s --no-print-directory TARGET=0 clean all
- @make -s --no-print-directory TARGET=1 clean all
- @make -s --no-print-directory TARGET=2 clean all
- @make -s --no-print-directory TARGET=3 clean all
- @make -s --no-print-directory TARGET=4 clean all
- @make -s --no-print-directory TARGET=5 clean all
diff --git a/3rdparty/bgfx/examples/14-shadowvolumes/makefile b/3rdparty/bgfx/examples/14-shadowvolumes/makefile
index e6278cb66dc..94d3aae708a 100644
--- a/3rdparty/bgfx/examples/14-shadowvolumes/makefile
+++ b/3rdparty/bgfx/examples/14-shadowvolumes/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
BGFX_DIR=../..
@@ -8,11 +8,3 @@ RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
BUILD_DIR=../../.build
include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
- @make -s --no-print-directory TARGET=0 clean all
- @make -s --no-print-directory TARGET=1 clean all
- @make -s --no-print-directory TARGET=2 clean all
- @make -s --no-print-directory TARGET=3 clean all
- @make -s --no-print-directory TARGET=4 clean all
- @make -s --no-print-directory TARGET=5 clean all
diff --git a/3rdparty/bgfx/examples/15-shadowmaps-simple/makefile b/3rdparty/bgfx/examples/15-shadowmaps-simple/makefile
index e6278cb66dc..94d3aae708a 100644
--- a/3rdparty/bgfx/examples/15-shadowmaps-simple/makefile
+++ b/3rdparty/bgfx/examples/15-shadowmaps-simple/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
BGFX_DIR=../..
@@ -8,11 +8,3 @@ RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
BUILD_DIR=../../.build
include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
- @make -s --no-print-directory TARGET=0 clean all
- @make -s --no-print-directory TARGET=1 clean all
- @make -s --no-print-directory TARGET=2 clean all
- @make -s --no-print-directory TARGET=3 clean all
- @make -s --no-print-directory TARGET=4 clean all
- @make -s --no-print-directory TARGET=5 clean all
diff --git a/3rdparty/bgfx/examples/16-shadowmaps/makefile b/3rdparty/bgfx/examples/16-shadowmaps/makefile
index e6278cb66dc..94d3aae708a 100644
--- a/3rdparty/bgfx/examples/16-shadowmaps/makefile
+++ b/3rdparty/bgfx/examples/16-shadowmaps/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
BGFX_DIR=../..
@@ -8,11 +8,3 @@ RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
BUILD_DIR=../../.build
include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
- @make -s --no-print-directory TARGET=0 clean all
- @make -s --no-print-directory TARGET=1 clean all
- @make -s --no-print-directory TARGET=2 clean all
- @make -s --no-print-directory TARGET=3 clean all
- @make -s --no-print-directory TARGET=4 clean all
- @make -s --no-print-directory TARGET=5 clean all
diff --git a/3rdparty/bgfx/examples/17-drawstress/makefile b/3rdparty/bgfx/examples/17-drawstress/makefile
index 818fe30cbd7..a9e31815229 100644
--- a/3rdparty/bgfx/examples/17-drawstress/makefile
+++ b/3rdparty/bgfx/examples/17-drawstress/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
include ../../scripts/shader-embeded.mk
diff --git a/3rdparty/bgfx/examples/18-ibl/makefile b/3rdparty/bgfx/examples/18-ibl/makefile
index e6278cb66dc..94d3aae708a 100644
--- a/3rdparty/bgfx/examples/18-ibl/makefile
+++ b/3rdparty/bgfx/examples/18-ibl/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
BGFX_DIR=../..
@@ -8,11 +8,3 @@ RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
BUILD_DIR=../../.build
include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
- @make -s --no-print-directory TARGET=0 clean all
- @make -s --no-print-directory TARGET=1 clean all
- @make -s --no-print-directory TARGET=2 clean all
- @make -s --no-print-directory TARGET=3 clean all
- @make -s --no-print-directory TARGET=4 clean all
- @make -s --no-print-directory TARGET=5 clean all
diff --git a/3rdparty/bgfx/examples/19-oit/makefile b/3rdparty/bgfx/examples/19-oit/makefile
index e6278cb66dc..94d3aae708a 100644
--- a/3rdparty/bgfx/examples/19-oit/makefile
+++ b/3rdparty/bgfx/examples/19-oit/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
BGFX_DIR=../..
@@ -8,11 +8,3 @@ RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
BUILD_DIR=../../.build
include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
- @make -s --no-print-directory TARGET=0 clean all
- @make -s --no-print-directory TARGET=1 clean all
- @make -s --no-print-directory TARGET=2 clean all
- @make -s --no-print-directory TARGET=3 clean all
- @make -s --no-print-directory TARGET=4 clean all
- @make -s --no-print-directory TARGET=5 clean all
diff --git a/3rdparty/bgfx/examples/21-deferred/fs_deferred_light.sc b/3rdparty/bgfx/examples/21-deferred/fs_deferred_light.sc
index 0f9873b2c7d..8d11c47933f 100644
--- a/3rdparty/bgfx/examples/21-deferred/fs_deferred_light.sc
+++ b/3rdparty/bgfx/examples/21-deferred/fs_deferred_light.sc
@@ -56,11 +56,11 @@ vec3 calcLight(int _idx, vec3 _wpos, vec3 _normal, vec3 _view)
float toClipSpaceDepth(float _depthTextureZ)
{
-#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
+#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_METAL
return _depthTextureZ;
#else
return _depthTextureZ * 2.0 - 1.0;
-#endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
+#endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_METAL
}
vec3 clipToWorld(mat4 _invViewProj, vec3 _clipPos)
@@ -76,9 +76,9 @@ void main()
float depth = toClipSpaceDepth(deviceDepth);
vec3 clip = vec3(v_texcoord0 * 2.0 - 1.0, depth);
-#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
+#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_METAL
clip.y = -clip.y;
-#endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
+#endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_METAL
vec3 wpos = clipToWorld(u_mtx, clip);
vec3 view = mul(u_view, vec4(wpos, 0.0) ).xyz;
diff --git a/3rdparty/bgfx/examples/21-deferred/makefile b/3rdparty/bgfx/examples/21-deferred/makefile
index 4f81fb5bfb9..94d3aae708a 100644
--- a/3rdparty/bgfx/examples/21-deferred/makefile
+++ b/3rdparty/bgfx/examples/21-deferred/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
BGFX_DIR=../..
@@ -8,10 +8,3 @@ RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
BUILD_DIR=../../.build
include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
- @make -s --no-print-directory TARGET=0 clean all
- @make -s --no-print-directory TARGET=1 clean all
- @make -s --no-print-directory TARGET=2 clean all
- @make -s --no-print-directory TARGET=3 clean all
- @make -s --no-print-directory TARGET=4 clean all
diff --git a/3rdparty/bgfx/examples/23-vectordisplay/makefile b/3rdparty/bgfx/examples/23-vectordisplay/makefile
index e6278cb66dc..94d3aae708a 100644
--- a/3rdparty/bgfx/examples/23-vectordisplay/makefile
+++ b/3rdparty/bgfx/examples/23-vectordisplay/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
BGFX_DIR=../..
@@ -8,11 +8,3 @@ RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
BUILD_DIR=../../.build
include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
- @make -s --no-print-directory TARGET=0 clean all
- @make -s --no-print-directory TARGET=1 clean all
- @make -s --no-print-directory TARGET=2 clean all
- @make -s --no-print-directory TARGET=3 clean all
- @make -s --no-print-directory TARGET=4 clean all
- @make -s --no-print-directory TARGET=5 clean all
diff --git a/3rdparty/bgfx/examples/24-nbody/makefile b/3rdparty/bgfx/examples/24-nbody/makefile
index e6278cb66dc..94d3aae708a 100644
--- a/3rdparty/bgfx/examples/24-nbody/makefile
+++ b/3rdparty/bgfx/examples/24-nbody/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
BGFX_DIR=../..
@@ -8,11 +8,3 @@ RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
BUILD_DIR=../../.build
include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
- @make -s --no-print-directory TARGET=0 clean all
- @make -s --no-print-directory TARGET=1 clean all
- @make -s --no-print-directory TARGET=2 clean all
- @make -s --no-print-directory TARGET=3 clean all
- @make -s --no-print-directory TARGET=4 clean all
- @make -s --no-print-directory TARGET=5 clean all
diff --git a/3rdparty/bgfx/examples/27-terrain/makefile b/3rdparty/bgfx/examples/27-terrain/makefile
index e6278cb66dc..94d3aae708a 100644
--- a/3rdparty/bgfx/examples/27-terrain/makefile
+++ b/3rdparty/bgfx/examples/27-terrain/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
BGFX_DIR=../..
@@ -8,11 +8,3 @@ RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
BUILD_DIR=../../.build
include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
- @make -s --no-print-directory TARGET=0 clean all
- @make -s --no-print-directory TARGET=1 clean all
- @make -s --no-print-directory TARGET=2 clean all
- @make -s --no-print-directory TARGET=3 clean all
- @make -s --no-print-directory TARGET=4 clean all
- @make -s --no-print-directory TARGET=5 clean all
diff --git a/3rdparty/bgfx/examples/28-wireframe/makefile b/3rdparty/bgfx/examples/28-wireframe/makefile
index e6278cb66dc..94d3aae708a 100644
--- a/3rdparty/bgfx/examples/28-wireframe/makefile
+++ b/3rdparty/bgfx/examples/28-wireframe/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
BGFX_DIR=../..
@@ -8,11 +8,3 @@ RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
BUILD_DIR=../../.build
include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
- @make -s --no-print-directory TARGET=0 clean all
- @make -s --no-print-directory TARGET=1 clean all
- @make -s --no-print-directory TARGET=2 clean all
- @make -s --no-print-directory TARGET=3 clean all
- @make -s --no-print-directory TARGET=4 clean all
- @make -s --no-print-directory TARGET=5 clean all
diff --git a/3rdparty/bgfx/examples/29-debugdraw/debugdraw.cpp b/3rdparty/bgfx/examples/29-debugdraw/debugdraw.cpp
index ec30ab7f1a8..1c82e0d52e1 100644
--- a/3rdparty/bgfx/examples/29-debugdraw/debugdraw.cpp
+++ b/3rdparty/bgfx/examples/29-debugdraw/debugdraw.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2015 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2017 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
diff --git a/3rdparty/bgfx/examples/30-picking/makefile b/3rdparty/bgfx/examples/30-picking/makefile
index e6278cb66dc..94d3aae708a 100644
--- a/3rdparty/bgfx/examples/30-picking/makefile
+++ b/3rdparty/bgfx/examples/30-picking/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
BGFX_DIR=../..
@@ -8,11 +8,3 @@ RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
BUILD_DIR=../../.build
include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
- @make -s --no-print-directory TARGET=0 clean all
- @make -s --no-print-directory TARGET=1 clean all
- @make -s --no-print-directory TARGET=2 clean all
- @make -s --no-print-directory TARGET=3 clean all
- @make -s --no-print-directory TARGET=4 clean all
- @make -s --no-print-directory TARGET=5 clean all
diff --git a/3rdparty/bgfx/examples/31-rsm/fs_rsm_combine.sc b/3rdparty/bgfx/examples/31-rsm/fs_rsm_combine.sc
index ae684960e71..352dbb02ee7 100644
--- a/3rdparty/bgfx/examples/31-rsm/fs_rsm_combine.sc
+++ b/3rdparty/bgfx/examples/31-rsm/fs_rsm_combine.sc
@@ -68,11 +68,11 @@ float PCF(sampler2DShadow _sampler, vec4 _shadowCoord, float _bias, vec2 _texelS
float toClipSpaceDepth(float _depthTextureZ)
{
-#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
+#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_METAL
return _depthTextureZ;
#else
return _depthTextureZ * 2.0 - 1.0;
-#endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
+#endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_METAL
}
vec3 clipToWorld(mat4 _invViewProj, vec3 _clipPos)
@@ -81,7 +81,6 @@ vec3 clipToWorld(mat4 _invViewProj, vec3 _clipPos)
return wpos.xyz / wpos.w;
}
-
void main()
{
vec3 n = texture2D(s_normal, v_texcoord0).xyz;
@@ -98,9 +97,9 @@ void main()
float deviceDepth = texture2D(s_depth, texCoord).x;
float depth = toClipSpaceDepth(deviceDepth);
vec3 clip = vec3(texCoord * 2.0 - 1.0, depth);
-#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
+#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_METAL
clip.y = -clip.y;
-#endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
+#endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_METAL
vec3 wpos = clipToWorld(u_invMvp, clip);
const float shadowMapOffset = 0.003;
diff --git a/3rdparty/bgfx/examples/31-rsm/fs_rsm_lbuffer.sc b/3rdparty/bgfx/examples/31-rsm/fs_rsm_lbuffer.sc
index 259c850a3e5..bbcc51d1fdc 100644
--- a/3rdparty/bgfx/examples/31-rsm/fs_rsm_lbuffer.sc
+++ b/3rdparty/bgfx/examples/31-rsm/fs_rsm_lbuffer.sc
@@ -14,11 +14,11 @@ uniform mat4 u_invMvp;
float toClipSpaceDepth(float _depthTextureZ)
{
-#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
+#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_METAL
return _depthTextureZ;
#else
return _depthTextureZ * 2.0 - 1.0;
-#endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
+#endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_METAL
}
vec3 clipToWorld(mat4 _invViewProj, vec3 _clipPos)
@@ -40,9 +40,9 @@ void main()
float depth = toClipSpaceDepth(deviceDepth);
vec3 clip = vec3(texCoord * 2.0 - 1.0, depth);
-#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
+#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_METAL
clip.y = -clip.y;
-#endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
+#endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_METAL
vec3 wpos = clipToWorld(u_invMvp, clip);
// Get normal from its map, and decompress
diff --git a/3rdparty/bgfx/examples/31-rsm/makefile b/3rdparty/bgfx/examples/31-rsm/makefile
index e6278cb66dc..94d3aae708a 100644
--- a/3rdparty/bgfx/examples/31-rsm/makefile
+++ b/3rdparty/bgfx/examples/31-rsm/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
BGFX_DIR=../..
@@ -8,11 +8,3 @@ RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
BUILD_DIR=../../.build
include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
- @make -s --no-print-directory TARGET=0 clean all
- @make -s --no-print-directory TARGET=1 clean all
- @make -s --no-print-directory TARGET=2 clean all
- @make -s --no-print-directory TARGET=3 clean all
- @make -s --no-print-directory TARGET=4 clean all
- @make -s --no-print-directory TARGET=5 clean all
diff --git a/3rdparty/bgfx/examples/31-rsm/vs_rsm_lbuffer.sc b/3rdparty/bgfx/examples/31-rsm/vs_rsm_lbuffer.sc
index 357b38ec387..eed5b732cec 100644
--- a/3rdparty/bgfx/examples/31-rsm/vs_rsm_lbuffer.sc
+++ b/3rdparty/bgfx/examples/31-rsm/vs_rsm_lbuffer.sc
@@ -18,11 +18,11 @@ SAMPLER2D(s_rsm, 3); // Reflective shadow map, used to scale/color light
float toClipSpaceDepth(float _depthTextureZ)
{
-#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
+#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_METAL
return _depthTextureZ;
#else
return _depthTextureZ * 2.0 - 1.0;
-#endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
+#endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_METAL
}
vec3 clipToWorld(mat4 _invViewProj, vec3 _clipPos)
@@ -41,9 +41,9 @@ void main()
float deviceDepth = texture2DLod(s_shadowMap, texCoord, 0).x;
float depth = toClipSpaceDepth(deviceDepth);
vec3 clip = vec3(texCoord * 2.0 - 1.0, depth);
-#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
+#if BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_METAL
clip.y = -clip.y;
-#endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_METAL
+#endif // BGFX_SHADER_LANGUAGE_HLSL || BGFX_SHADER_LANGUAGE_PSSL || BGFX_SHADER_LANGUAGE_METAL
vec3 wPos = clipToWorld(u_invMvpShadow, clip);
wPos.y -= 0.001; // Would be much better to perturb in normal direction, but I didn't do that.
diff --git a/3rdparty/bgfx/examples/32-particles/particles.cpp b/3rdparty/bgfx/examples/32-particles/particles.cpp
new file mode 100644
index 00000000000..3173a15388d
--- /dev/null
+++ b/3rdparty/bgfx/examples/32-particles/particles.cpp
@@ -0,0 +1,426 @@
+/*
+ * Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
+ */
+
+#include "common.h"
+#include "bgfx_utils.h"
+#include <entry/cmd.h>
+#include <entry/input.h>
+
+#include <camera.h>
+#include <debugdraw/debugdraw.h>
+#include <imgui/imgui.h>
+
+#include <bx/rng.h>
+#include <bx/easing.h>
+
+#include <ps/particle_system.h>
+
+static const char* s_shapeNames[] =
+{
+ "Sphere",
+ "Hemisphere",
+ "Circle",
+ "Disc",
+ "Rect",
+};
+
+static const char* s_directionName[] =
+{
+ "Up",
+ "Outward",
+};
+
+static const char* s_easeFuncName[] =
+{
+ "Linear",
+ "InQuad",
+ "OutQuad",
+ "InOutQuad",
+ "OutInQuad",
+ "InCubic",
+ "OutCubic",
+ "InOutCubic",
+ "OutInCubic",
+ "InQuart",
+ "OutQuart",
+ "InOutQuart",
+ "OutInQuart",
+ "InQuint",
+ "OutQuint",
+ "InOutQuint",
+ "OutInQuint",
+ "InSine",
+ "OutSine",
+ "InOutSine",
+ "OutInSine",
+ "InExpo",
+ "OutExpo",
+ "InOutExpo",
+ "OutInExpo",
+ "InCirc",
+ "OutCirc",
+ "InOutCirc",
+ "OutInCirc",
+ "InElastic",
+ "OutElastic",
+ "InOutElastic",
+ "OutInElastic",
+ "InBack",
+ "OutBack",
+ "InOutBack",
+ "OutInBack",
+ "InBounce",
+ "OutBounce",
+ "InOutBounce",
+ "OutInBounce",
+};
+BX_STATIC_ASSERT(BX_COUNTOF(s_easeFuncName) == bx::Easing::Count);
+
+struct Emitter
+{
+ EmitterUniforms m_uniforms;
+ EmitterHandle m_handle;
+
+ EmitterShape::Enum m_shape;
+ EmitterDirection::Enum m_direction;
+
+ void create()
+ {
+ m_shape = EmitterShape::Sphere;
+ m_direction = EmitterDirection::Outward;
+
+ m_handle = psCreateEmitter(m_shape, m_direction, 1024);
+ m_uniforms.reset();
+ }
+
+ void destroy()
+ {
+ psDestroyEmitter(m_handle);
+ }
+
+ void update()
+ {
+ psUpdateEmitter(m_handle, &m_uniforms);
+ }
+
+ void imgui(const float* _view, const float* _proj)
+ {
+// if (ImGui::CollapsingHeader("General") )
+ {
+ if (ImGui::Combo("Shape", (int*)&m_shape, s_shapeNames, BX_COUNTOF(s_shapeNames) )
+ || ImGui::Combo("Direction", (int*)&m_direction, s_directionName, BX_COUNTOF(s_directionName) ) )
+ {
+ psDestroyEmitter(m_handle);
+ m_handle = psCreateEmitter(m_shape, m_direction, 1024);
+ }
+
+ ImGui::SliderInt("particles / s", (int*)&m_uniforms.m_particlesPerSecond, 0, 1024);
+
+ ImGui::SliderFloat("Gravity scale"
+ , &m_uniforms.m_gravityScale
+ , -2.0f
+ , 2.0f
+ );
+
+ ImGui::RangeSliderFloat("Life span"
+ , &m_uniforms.m_lifeSpan[0]
+ , &m_uniforms.m_lifeSpan[1]
+ , 0.1f
+ , 5.0f
+ );
+
+ if (ImGui::Button("Reset") )
+ {
+ psUpdateEmitter(m_handle);
+ }
+ }
+
+ if (ImGui::CollapsingHeader("Position and scale") )
+ {
+ ImGui::Combo("Position Ease", (int*)&m_uniforms.m_easePos, s_easeFuncName, BX_COUNTOF(s_easeFuncName) );
+
+ ImGui::RangeSliderFloat("Start offset"
+ , &m_uniforms.m_offsetStart[0]
+ , &m_uniforms.m_offsetStart[1]
+ , 0.0f
+ , 10.0f
+ );
+ ImGui::RangeSliderFloat("End offset"
+ , &m_uniforms.m_offsetEnd[0]
+ , &m_uniforms.m_offsetEnd[1]
+ , 0.0f
+ , 10.0f
+ );
+
+ ImGui::Text("Scale:");
+
+ ImGui::Combo("Scale Ease", (int*)&m_uniforms.m_easeScale, s_easeFuncName, BX_COUNTOF(s_easeFuncName) );
+
+ ImGui::RangeSliderFloat("Scale Start"
+ , &m_uniforms.m_scaleStart[0]
+ , &m_uniforms.m_scaleStart[1]
+ , 0.0f
+ , 3.0f
+ );
+ ImGui::RangeSliderFloat("Scale End"
+ , &m_uniforms.m_scaleEnd[0]
+ , &m_uniforms.m_scaleEnd[1]
+ , 0.0f
+ , 3.0f
+ );
+ }
+
+ if (ImGui::CollapsingHeader("Blending and color") )
+ {
+ ImGui::Combo("Blend Ease", (int*)&m_uniforms.m_easeBlend, s_easeFuncName, BX_COUNTOF(s_easeFuncName) );
+ ImGui::RangeSliderFloat("Blend Start"
+ , &m_uniforms.m_blendStart[0]
+ , &m_uniforms.m_blendStart[1]
+ , 0.0f
+ , 1.0f
+ );
+ ImGui::RangeSliderFloat("Blend End"
+ , &m_uniforms.m_blendEnd[0]
+ , &m_uniforms.m_blendEnd[1]
+ , 0.0f
+ , 1.0f
+ );
+
+ ImGui::Text("Color:");
+
+ ImGui::Combo("RGBA Ease", (int*)&m_uniforms.m_easeRgba, s_easeFuncName, BX_COUNTOF(s_easeFuncName) );
+ ImGui::ColorEdit4("RGBA0", &m_uniforms.m_rgba[0], true);
+ ImGui::ColorEdit4("RGBA1", &m_uniforms.m_rgba[1], true);
+ ImGui::ColorEdit4("RGBA2", &m_uniforms.m_rgba[2], true);
+ ImGui::ColorEdit4("RGBA3", &m_uniforms.m_rgba[3], true);
+ ImGui::ColorEdit4("RGBA4", &m_uniforms.m_rgba[4], true);
+ }
+
+ ImGui::End();
+
+ float mtx[16];
+ bx::mtxSRT(mtx
+ , 1.0f, 1.0f, 1.0f
+ , m_uniforms.m_angle[0], m_uniforms.m_angle[1], m_uniforms.m_angle[2]
+ , m_uniforms.m_position[0], m_uniforms.m_position[1], m_uniforms.m_position[2]
+ );
+
+ ImGuizmo::Manipulate(
+ _view
+ , _proj
+ , ImGuizmo::OPERATION::TRANSLATE
+ , ImGuizmo::MODE::LOCAL
+ , mtx
+ );
+
+ float scale[3];
+ ImGuizmo::DecomposeMatrixToComponents(mtx, m_uniforms.m_position, m_uniforms.m_angle, scale);
+ }
+};
+
+class Particles : public entry::AppI
+{
+ void init(int _argc, char** _argv) BX_OVERRIDE
+ {
+ Args args(_argc, _argv);
+
+ m_width = 1280;
+ m_height = 720;
+ m_debug = BGFX_DEBUG_TEXT;
+ m_reset = BGFX_RESET_VSYNC;
+
+ bgfx::init(args.m_type, args.m_pciId);
+ bgfx::reset(m_width, m_height, m_reset);
+
+ // Enable m_debug text.
+ bgfx::setDebug(m_debug);
+
+ // Set view 0 clear state.
+ bgfx::setViewClear(0
+ , BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
+ , 0x202020ff
+ , 1.0f
+ , 0
+ );
+
+ ddInit();
+
+ psInit();
+
+ for (uint32_t ii = 0; ii < BX_COUNTOF(m_emitter); ++ii)
+ {
+ m_emitter[ii].create();
+ }
+
+ imguiCreate();
+
+ cameraCreate();
+
+ const float initialPos[3] = { 0.0f, 2.0f, -12.0f };
+ cameraSetPosition(initialPos);
+ cameraSetVerticalAngle(0.0f);
+
+ m_timeOffset = bx::getHPCounter();
+ }
+
+ virtual int shutdown() BX_OVERRIDE
+ {
+ for (uint32_t ii = 0; ii < BX_COUNTOF(m_emitter); ++ii)
+ {
+ m_emitter[ii].destroy();
+ }
+
+ psShutdown();
+
+ ddShutdown();
+
+ imguiDestroy();
+
+ cameraDestroy();
+
+ // Shutdown bgfx.
+ bgfx::shutdown();
+
+ return 0;
+ }
+
+ bool update() BX_OVERRIDE
+ {
+ if (!entry::processEvents(m_width, m_height, m_debug, m_reset, &m_mouseState) )
+ {
+ // Set view 0 default viewport.
+ bgfx::setViewRect(0, 0, 0, m_width, m_height);
+
+ bgfx::touch(0);
+
+ int64_t now = bx::getHPCounter() - m_timeOffset;
+ static int64_t last = now;
+ const int64_t frameTime = now - last;
+ last = now;
+ const double freq = double(bx::getHPFrequency() );
+ const double toMs = 1000.0/freq;
+ const float deltaTime = float(frameTime/freq);
+
+ // Use debug font to print information about this example.
+ bgfx::dbgTextClear();
+ bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/32-particles");
+ bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Particles.");
+ bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
+
+ // Update camera.George RR Martin
+ cameraUpdate(deltaTime, m_mouseState);
+
+ float view[16];
+ cameraGetViewMtx(view);
+
+ float proj[16];
+
+ // Set view and projection matrix for view 0.
+ const bgfx::HMD* hmd = bgfx::getHMD();
+ if (NULL != hmd && 0 != (hmd->flags & BGFX_HMD_RENDERING) )
+ {
+ float eye[3];
+ cameraGetPosition(eye);
+ bx::mtxQuatTranslationHMD(view, hmd->eye[0].rotation, eye);
+ bgfx::setViewTransform(0, view, hmd->eye[0].projection, BGFX_VIEW_STEREO, hmd->eye[1].projection);
+ bgfx::setViewRect(0, 0, 0, hmd->width, hmd->height);
+ }
+ else
+ {
+ bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f);
+
+ bgfx::setViewTransform(0, view, proj);
+ bgfx::setViewRect(0, 0, 0, m_width, m_height);
+ }
+
+ imguiBeginFrame(
+ m_mouseState.m_mx
+ , m_mouseState.m_my
+ , (m_mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0)
+ | (m_mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0)
+ | (m_mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0)
+ , m_mouseState.m_mz
+ , m_width
+ , m_height
+ );
+
+ ImGui::Begin("Properties"
+ , NULL
+ , ImVec2(400.0f, 600.0f)
+ , ImGuiWindowFlags_AlwaysAutoResize
+ );
+
+ static float timeScale = 1.0f;
+ ImGui::SliderFloat("Time scale"
+ , &timeScale
+ , 0.0f
+ , 1.0f
+ );
+
+ static bool showBounds;
+ ImGui::Checkbox("Show bounds", &showBounds);
+
+ ImGui::Text("Emitter:");
+ static int currentEmitter = 0;
+ for (uint32_t ii = 0; ii < BX_COUNTOF(m_emitter); ++ii)
+ {
+ ImGui::SameLine();
+
+ char name[16];
+ bx::snprintf(name, BX_COUNTOF(name), "%d", ii);
+
+ ImGui::RadioButton(name, &currentEmitter, ii);
+ }
+
+ m_emitter[currentEmitter].imgui(view, proj);
+
+ imguiEndFrame();
+
+ ddBegin(0);
+
+ float center[3] = { 0.0f, 0.0f, 0.0f };
+ ddDrawGrid(Axis::Y, center);
+
+ float eye[3];
+ cameraGetPosition(eye);
+
+ m_emitter[currentEmitter].update();
+
+ psUpdate(deltaTime * timeScale);
+ psRender(0, view, eye);
+
+ if (showBounds)
+ {
+ Aabb aabb;
+ psGetAabb(m_emitter[currentEmitter].m_handle, aabb);
+ ddSetColor(0xff0000ff);
+ ddDraw(aabb);
+ }
+
+ ddEnd();
+
+ // Advance to next frame. Rendering thread will be kicked to
+ // process submitted rendering primitives.
+ bgfx::frame();
+
+ return true;
+ }
+
+ return false;
+ }
+
+ entry::MouseState m_mouseState;
+
+ int64_t m_timeOffset;
+
+ uint32_t m_width;
+ uint32_t m_height;
+ uint32_t m_debug;
+ uint32_t m_reset;
+
+ Emitter m_emitter[4];
+};
+
+ENTRY_IMPLEMENT_MAIN(Particles);
diff --git a/3rdparty/bgfx/examples/32-particles/screenshot.png b/3rdparty/bgfx/examples/32-particles/screenshot.png
new file mode 100644
index 00000000000..2e88fe88fd1
--- /dev/null
+++ b/3rdparty/bgfx/examples/32-particles/screenshot.png
Binary files differ
diff --git a/3rdparty/bgfx/examples/common/bgfx_utils.cpp b/3rdparty/bgfx/examples/common/bgfx_utils.cpp
index 2b4bb5c2ded..f728582cc53 100644
--- a/3rdparty/bgfx/examples/common/bgfx_utils.cpp
+++ b/3rdparty/bgfx/examples/common/bgfx_utils.cpp
@@ -23,7 +23,9 @@ namespace stl = tinystl;
BX_PRAGMA_DIAGNOSTIC_PUSH()
BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wtype-limits")
+BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wunused-parameter")
BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wunused-value")
+BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4100) // error C4100: '' : unreferenced formal parameter
#define MINIZ_NO_STDIO
#define TINYEXR_IMPLEMENTATION
#include <tinyexr/tinyexr.h>
diff --git a/3rdparty/bgfx/examples/common/bounds.cpp b/3rdparty/bgfx/examples/common/bounds.cpp
index 96a775024d2..6afd5755d0c 100644
--- a/3rdparty/bgfx/examples/common/bounds.cpp
+++ b/3rdparty/bgfx/examples/common/bounds.cpp
@@ -182,6 +182,12 @@ void aabbExpand(Aabb& _aabb, float _factor)
_aabb.m_max[2] += _factor;
}
+void aabbExpand(Aabb& _aabb, const float* _pos)
+{
+ bx::vec3Min(_aabb.m_min, _aabb.m_min, _pos);
+ bx::vec3Max(_aabb.m_max, _aabb.m_max, _pos);
+}
+
uint32_t aabbOverlapTest(const Aabb& _aabb0, const Aabb& _aabb1)
{
const uint32_t ltMinX = _aabb0.m_max[0] < _aabb1.m_min[0];
diff --git a/3rdparty/bgfx/examples/common/bounds.h b/3rdparty/bgfx/examples/common/bounds.h
index fcfd1872c48..604892c3fef 100644
--- a/3rdparty/bgfx/examples/common/bounds.h
+++ b/3rdparty/bgfx/examples/common/bounds.h
@@ -84,6 +84,9 @@ void toAabb(Aabb& _aabb, const float* _mtx, const void* _vertices, uint32_t _num
/// Expand AABB.
void aabbExpand(Aabb& _aabb, float _factor);
+/// Expand AABB with xyz.
+void aabbExpand(Aabb& _aabb, const float* _pos);
+
/// Calculate surface area of axis aligned bounding box.
float calcAreaAabb(const Aabb& _aabb);
diff --git a/3rdparty/bgfx/examples/common/debugdraw/makefile b/3rdparty/bgfx/examples/common/debugdraw/makefile
index ab2bae2d539..27e6c6bf04d 100644
--- a/3rdparty/bgfx/examples/common/debugdraw/makefile
+++ b/3rdparty/bgfx/examples/common/debugdraw/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
include ../../../../bgfx/scripts/shader-embeded.mk
diff --git a/3rdparty/bgfx/examples/common/entry/cmd.cpp b/3rdparty/bgfx/examples/common/entry/cmd.cpp
index 47bbb73b30a..7c6c3c99307 100644
--- a/3rdparty/bgfx/examples/common/entry/cmd.cpp
+++ b/3rdparty/bgfx/examples/common/entry/cmd.cpp
@@ -10,7 +10,7 @@
#include <bx/allocator.h>
#include <bx/hash.h>
-#include <bx/tokenizecmd.h>
+#include <bx/commandline.h>
#include "dbg.h"
#include "cmd.h"
diff --git a/3rdparty/bgfx/examples/common/entry/dbg.cpp b/3rdparty/bgfx/examples/common/entry/dbg.cpp
deleted file mode 100644
index c99610b2c95..00000000000
--- a/3rdparty/bgfx/examples/common/entry/dbg.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2011-2017 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include <stdio.h>
-#include <stdint.h>
-#include <inttypes.h>
-#include <ctype.h> // isprint
-
-#include "dbg.h"
-#include <bx/string.h>
-#include <bx/debug.h>
-
-void dbgPrintfVargs(const char* _format, va_list _argList)
-{
- char temp[8192];
- char* out = temp;
- int32_t len = bx::vsnprintf(out, sizeof(temp), _format, _argList);
- if ( (int32_t)sizeof(temp) < len)
- {
- out = (char*)alloca(len+1);
- len = bx::vsnprintf(out, len, _format, _argList);
- }
- out[len] = '\0';
- bx::debugOutput(out);
-}
-
-void dbgPrintf(const char* _format, ...)
-{
- va_list argList;
- va_start(argList, _format);
- dbgPrintfVargs(_format, argList);
- va_end(argList);
-}
-
-#define DBG_ADDRESS "%" PRIxPTR
-
-void dbgPrintfData(const void* _data, uint32_t _size, const char* _format, ...)
-{
-#define HEX_DUMP_WIDTH 16
-#define HEX_DUMP_SPACE_WIDTH 48
-#define HEX_DUMP_FORMAT "%-" DBG_STRINGIZE(HEX_DUMP_SPACE_WIDTH) "." DBG_STRINGIZE(HEX_DUMP_SPACE_WIDTH) "s"
-
- va_list argList;
- va_start(argList, _format);
- dbgPrintfVargs(_format, argList);
- va_end(argList);
-
- dbgPrintf("\ndata: " DBG_ADDRESS ", size: %d\n", _data, _size);
-
- if (NULL != _data)
- {
- const uint8_t* data = reinterpret_cast<const uint8_t*>(_data);
- char hex[HEX_DUMP_WIDTH*3+1];
- char ascii[HEX_DUMP_WIDTH+1];
- uint32_t hexPos = 0;
- uint32_t asciiPos = 0;
- for (uint32_t ii = 0; ii < _size; ++ii)
- {
- bx::snprintf(&hex[hexPos], sizeof(hex)-hexPos, "%02x ", data[asciiPos]);
- hexPos += 3;
-
- ascii[asciiPos] = isprint(data[asciiPos]) ? data[asciiPos] : '.';
- asciiPos++;
-
- if (HEX_DUMP_WIDTH == asciiPos)
- {
- ascii[asciiPos] = '\0';
- dbgPrintf("\t" DBG_ADDRESS "\t" HEX_DUMP_FORMAT "\t%s\n", data, hex, ascii);
- data += asciiPos;
- hexPos = 0;
- asciiPos = 0;
- }
- }
-
- if (0 != asciiPos)
- {
- ascii[asciiPos] = '\0';
- dbgPrintf("\t" DBG_ADDRESS "\t" HEX_DUMP_FORMAT "\t%s\n", data, hex, ascii);
- }
- }
-
-#undef HEX_DUMP_WIDTH
-#undef HEX_DUMP_SPACE_WIDTH
-#undef HEX_DUMP_FORMAT
-}
diff --git a/3rdparty/bgfx/examples/common/entry/dbg.h b/3rdparty/bgfx/examples/common/entry/dbg.h
index 92265063ee3..06a228ed753 100644
--- a/3rdparty/bgfx/examples/common/entry/dbg.h
+++ b/3rdparty/bgfx/examples/common/entry/dbg.h
@@ -6,16 +6,11 @@
#ifndef DBG_H_HEADER_GUARD
#define DBG_H_HEADER_GUARD
-#include <stdarg.h> // va_list
-#include <stdint.h>
+#include <bx/debug.h>
#define DBG_STRINGIZE(_x) DBG_STRINGIZE_(_x)
#define DBG_STRINGIZE_(_x) #_x
#define DBG_FILE_LINE_LITERAL "" __FILE__ "(" DBG_STRINGIZE(__LINE__) "): "
-#define DBG(_format, ...) dbgPrintf(DBG_FILE_LINE_LITERAL "" _format "\n", ##__VA_ARGS__)
-
-extern void dbgPrintfVargs(const char* _format, va_list _argList);
-extern void dbgPrintf(const char* _format, ...);
-extern void dbgPrintfData(const void* _data, uint32_t _size, const char* _format, ...);
+#define DBG(_format, ...) bx::debugPrintf(DBG_FILE_LINE_LITERAL "" _format "\n", ##__VA_ARGS__)
#endif // DBG_H_HEADER_GUARD
diff --git a/3rdparty/bgfx/examples/common/entry/entry.cpp b/3rdparty/bgfx/examples/common/entry/entry.cpp
index 703be976529..edc237a49cd 100644
--- a/3rdparty/bgfx/examples/common/entry/entry.cpp
+++ b/3rdparty/bgfx/examples/common/entry/entry.cpp
@@ -353,6 +353,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
{ entry::Key::KeyF, entry::Modifier::RightCtrl, 1, NULL, "graphics fullscreen" },
{ entry::Key::Return, entry::Modifier::RightAlt, 1, NULL, "graphics fullscreen" },
{ entry::Key::F1, entry::Modifier::None, 1, NULL, "graphics stats" },
+ { entry::Key::F1, entry::Modifier::LeftCtrl, 1, NULL, "graphics ifh" },
{ entry::Key::GamepadStart, entry::Modifier::None, 1, NULL, "graphics stats" },
{ entry::Key::F1, entry::Modifier::LeftShift, 1, NULL, "graphics stats 0\ngraphics text 0" },
{ entry::Key::F3, entry::Modifier::None, 1, NULL, "graphics wireframe" },
@@ -364,6 +365,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
{ entry::Key::F9, entry::Modifier::None, 1, NULL, "graphics flush" },
{ entry::Key::F10, entry::Modifier::None, 1, NULL, "graphics hidpi" },
{ entry::Key::Print, entry::Modifier::None, 1, NULL, "graphics screenshot" },
+ { entry::Key::KeyP, entry::Modifier::LeftCtrl, 1, NULL, "graphics screenshot" },
INPUT_BINDING_END
};
diff --git a/3rdparty/bgfx/examples/common/entry/entry_p.h b/3rdparty/bgfx/examples/common/entry/entry_p.h
index 3cd9d95c782..74a279f8e2c 100644
--- a/3rdparty/bgfx/examples/common/entry/entry_p.h
+++ b/3rdparty/bgfx/examples/common/entry/entry_p.h
@@ -14,7 +14,7 @@
#include <string.h> // memcpy
#ifndef ENTRY_CONFIG_USE_NOOP
-# define ENTRY_CONFIG_USE_NOOP (BX_PLATFORM_QNX || BX_PLATFORM_PS4)
+# define ENTRY_CONFIG_USE_NOOP (BX_PLATFORM_QNX)
#endif // ENTRY_CONFIG_USE_NOOP
#ifndef ENTRY_CONFIG_USE_SDL
diff --git a/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp b/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp
index 47aca39ff46..757c9f3a357 100644
--- a/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp
+++ b/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp
@@ -487,13 +487,13 @@ namespace entry
setWindowSize(defaultWindow, m_width, m_height, true);
bx::FileReaderI* reader = getFileReader();
- if (bx::open(&reader, "gamecontrollerdb.txt") )
+ if (bx::open(reader, "gamecontrollerdb.txt") )
{
bx::AllocatorI* allocator = getAllocator();
- uint32_t size = (uint32_t)bx::getSize(&reader);
+ uint32_t size = (uint32_t)bx::getSize(reader);
void* data = BX_ALLOC(allocator, size);
- bx::read(&reader, data, size);
- bx::close(&reader);
+ bx::read(reader, data, size);
+ bx::close(reader);
SDL_GameControllerAddMapping( (char*)data);
diff --git a/3rdparty/bgfx/examples/common/entry/entry_windows.cpp b/3rdparty/bgfx/examples/common/entry/entry_windows.cpp
index 5be017bce3b..ca38c9208c3 100644
--- a/3rdparty/bgfx/examples/common/entry/entry_windows.cpp
+++ b/3rdparty/bgfx/examples/common/entry/entry_windows.cpp
@@ -143,13 +143,14 @@ namespace entry
}
WindowHandle defaultWindow = { 0 };
- GamepadHandle handle = { 0 };
- for (uint32_t ii = 0; ii < BX_COUNTOF(m_state); ++ii)
+ for (uint16_t ii = 0; ii < BX_COUNTOF(m_state); ++ii)
{
XINPUT_STATE state;
DWORD result = XInputGetState(ii, &state);
+ GamepadHandle handle = { ii };
+
bool connected = ERROR_SUCCESS == result;
if (connected != m_connected[ii])
{
diff --git a/3rdparty/bgfx/examples/common/entry/entry_x11.cpp b/3rdparty/bgfx/examples/common/entry/entry_x11.cpp
index faa7f07548d..7016b8b640f 100644
--- a/3rdparty/bgfx/examples/common/entry/entry_x11.cpp
+++ b/3rdparty/bgfx/examples/common/entry/entry_x11.cpp
@@ -14,6 +14,8 @@
#include <X11/Xutil.h>
#include <bgfx/platform.h>
+#include <unistd.h> // syscall
+
#undef None
#include <bx/thread.h>
#include <bx/os.h>
diff --git a/3rdparty/bgfx/examples/common/entry/input.cpp b/3rdparty/bgfx/examples/common/entry/input.cpp
index a7155b5d07a..697ef1e5e69 100644
--- a/3rdparty/bgfx/examples/common/entry/input.cpp
+++ b/3rdparty/bgfx/examples/common/entry/input.cpp
@@ -85,7 +85,7 @@ struct InputKeyboard
static uint32_t encodeKeyState(uint8_t _modifiers, bool _down)
{
uint32_t state = 0;
- state |= uint32_t(_modifiers)<<16;
+ state |= uint32_t(_down ? _modifiers : 0)<<16;
state |= uint32_t(_down)<<8;
return state;
}
diff --git a/3rdparty/bgfx/examples/common/font/makefile b/3rdparty/bgfx/examples/common/font/makefile
index 38f4d0d7d86..928467df33c 100644
--- a/3rdparty/bgfx/examples/common/font/makefile
+++ b/3rdparty/bgfx/examples/common/font/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
include ../../../scripts/shader-embeded.mk
diff --git a/3rdparty/bgfx/examples/common/imgui/makefile b/3rdparty/bgfx/examples/common/imgui/makefile
index b7d3b8329bb..b9648f147fd 100644
--- a/3rdparty/bgfx/examples/common/imgui/makefile
+++ b/3rdparty/bgfx/examples/common/imgui/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
include ../../../scripts/shader-embeded.mk
diff --git a/3rdparty/bgfx/examples/common/nanovg/makefile b/3rdparty/bgfx/examples/common/nanovg/makefile
index 38f4d0d7d86..928467df33c 100644
--- a/3rdparty/bgfx/examples/common/nanovg/makefile
+++ b/3rdparty/bgfx/examples/common/nanovg/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
include ../../../scripts/shader-embeded.mk
diff --git a/3rdparty/bgfx/examples/common/ps/fs_particle.bin.h b/3rdparty/bgfx/examples/common/ps/fs_particle.bin.h
new file mode 100644
index 00000000000..3c96bf68ac5
--- /dev/null
+++ b/3rdparty/bgfx/examples/common/ps/fs_particle.bin.h
@@ -0,0 +1,150 @@
+static const uint8_t fs_particle_glsl[403] =
+{
+ 0x46, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x01, 0x00, 0x0a, 0x73, 0x5f, 0x74, 0x65, 0x78, // FSH........s_tex
+ 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x73, 0x01, 0x00, 0x00, 0x76, // Color......s...v
+ 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, // arying highp vec
+ 0x34, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, // 4 v_color0;.vary
+ 0x69, 0x6e, 0x67, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x76, // ing highp vec4 v
+ 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, // _texcoord0;.unif
+ 0x6f, 0x72, 0x6d, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x32, 0x44, 0x20, 0x73, 0x5f, // orm sampler2D s_
+ 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, // texColor;.void m
+ 0x61, 0x69, 0x6e, 0x20, 0x28, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x6c, 0x6f, 0x77, 0x70, 0x20, // ain ().{. lowp
+ 0x76, 0x65, 0x63, 0x34, 0x20, 0x72, 0x67, 0x62, 0x61, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x6c, // vec4 rgba_1;. l
+ 0x6f, 0x77, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // owp vec4 tmpvar_
+ 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x20, 0x3d, 0x20, // 2;. tmpvar_2 =
+ 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x44, 0x20, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, // texture2D (s_tex
+ 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, // Color, v_texcoor
+ 0x64, 0x30, 0x2e, 0x78, 0x79, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x67, 0x62, 0x61, 0x5f, 0x31, // d0.xy);. rgba_1
+ 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // .xyz = ((tmpvar_
+ 0x32, 0x2e, 0x78, 0x78, 0x78, 0x20, 0x2a, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, // 2.xxx * v_color0
+ 0x2e, 0x78, 0x79, 0x7a, 0x29, 0x20, 0x2a, 0x20, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // .xyz) * (tmpvar_
+ 0x32, 0x2e, 0x78, 0x20, 0x2a, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x2e, 0x77, // 2.x * v_color0.w
+ 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x67, 0x62, 0x61, 0x5f, 0x31, 0x2e, 0x77, 0x20, 0x3d, // ));. rgba_1.w =
+ 0x20, 0x28, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x2e, 0x78, 0x20, 0x2a, 0x20, // ((tmpvar_2.x *
+ 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x2e, 0x77, 0x29, 0x20, 0x2a, 0x20, 0x28, 0x31, // v_color0.w) * (1
+ 0x2e, 0x30, 0x20, 0x2d, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, // .0 - v_texcoord0
+ 0x2e, 0x7a, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, // .z));. gl_FragC
+ 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x72, 0x67, 0x62, 0x61, 0x5f, 0x31, 0x3b, 0x0a, 0x7d, // olor = rgba_1;.}
+ 0x0a, 0x0a, 0x00, // ...
+};
+static const uint8_t fs_particle_dx9[326] =
+{
+ 0x46, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x01, 0x00, 0x0a, 0x73, 0x5f, 0x74, 0x65, 0x78, // FSH........s_tex
+ 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x01, 0x00, 0x00, 0x01, 0x00, 0x28, 0x01, 0x00, 0x03, 0xff, // Color0.....(....
+ 0xff, 0xfe, 0xff, 0x20, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, // ... .CTAB....S..
+ 0x00, 0x00, 0x03, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x91, 0x00, // ................
+ 0x00, 0x4c, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, // .L...0..........
+ 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, // .<.......s_texCo
+ 0x6c, 0x6f, 0x72, 0x00, 0xab, 0x04, 0x00, 0x0c, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, // lor.............
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x73, 0x5f, 0x33, 0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63, 0x72, // .....ps_3_0.Micr
+ 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, // osoft (R) HLSL S
+ 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x31, // hader Compiler 1
+ 0x30, 0x2e, 0x31, 0x00, 0xab, 0x51, 0x00, 0x00, 0x05, 0x00, 0x00, 0x0f, 0xa0, 0x00, 0x00, 0x80, // 0.1..Q..........
+ 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, // ?...............
+ 0x02, 0x0a, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, // ................
+ 0x80, 0x01, 0x00, 0x07, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x90, 0x00, 0x08, 0x0f, // ................
+ 0xa0, 0x42, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0x80, 0x01, 0x00, 0xe4, 0x90, 0x00, 0x08, 0xe4, // .B..............
+ 0xa0, 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x02, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, // ................
+ 0x80, 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x54, 0x80, 0x00, 0x00, 0x93, // ...........T....
+ 0x90, 0x05, 0x00, 0x00, 0x03, 0x00, 0x08, 0x07, 0x80, 0x00, 0x00, 0xf9, 0x80, 0x00, 0x00, 0xff, // ................
+ 0x90, 0x02, 0x00, 0x00, 0x03, 0x00, 0x00, 0x02, 0x80, 0x00, 0x00, 0x00, 0xa0, 0x01, 0x00, 0xaa, // ................
+ 0x91, 0x05, 0x00, 0x00, 0x03, 0x00, 0x08, 0x08, 0x80, 0x00, 0x00, 0x55, 0x80, 0x00, 0x00, 0x00, // ...........U....
+ 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, // ......
+};
+static const uint8_t fs_particle_dx11[517] =
+{
+ 0x46, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x01, 0x00, 0x0a, 0x73, 0x5f, 0x74, 0x65, 0x78, // FSH........s_tex
+ 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x01, 0x00, 0x00, 0x01, 0x00, 0xe4, 0x01, 0x44, 0x58, 0x42, // Color0.......DXB
+ 0x43, 0xdd, 0x04, 0xf1, 0x4a, 0xaa, 0xb0, 0xdf, 0xe0, 0xf5, 0x18, 0x2f, 0x3b, 0x6e, 0xa9, 0x0e, // C...J....../;n..
+ 0x0a, 0x01, 0x00, 0x00, 0x00, 0xe4, 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, // .............,..
+ 0x00, 0xa0, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x49, 0x53, 0x47, 0x4e, 0x6c, 0x00, 0x00, // .........ISGNl..
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .........P......
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, // ................
+ 0x00, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // ................
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .........b......
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0f, 0x07, 0x00, // ................
+ 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x43, 0x4f, 0x4c, // .SV_POSITION.COL
+ 0x4f, 0x52, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0xab, 0x4f, 0x53, 0x47, // OR.TEXCOORD..OSG
+ 0x4e, 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, // N,........... ..
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
+ 0x00, 0x0f, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x00, 0xab, // .....SV_TARGET..
+ 0xab, 0x53, 0x48, 0x44, 0x52, 0x08, 0x01, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, // .SHDR....@...B..
+ 0x00, 0x5a, 0x00, 0x00, 0x03, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x18, 0x00, // .Z....`......X..
+ 0x04, 0x00, 0x70, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x62, 0x10, 0x00, // ..p......UU..b..
+ 0x03, 0xf2, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x62, 0x10, 0x00, 0x03, 0x72, 0x10, 0x10, // .........b...r..
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, // .....e.... .....
+ 0x00, 0x68, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, // .h.......E......
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, // .....F.......F~.
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, // ......`......8..
+ 0x07, 0x22, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, // ."..............
+ 0x00, 0x0a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, // .........8......
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x05, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x19, 0x10, // .....F.......6..
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x72, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, // .....8...r .....
+ 0x00, 0x96, 0x07, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0x1f, 0x10, 0x00, 0x01, 0x00, 0x00, // ................
+ 0x00, 0x00, 0x00, 0x00, 0x08, 0x22, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x10, 0x10, // .....".......*..
+ 0x80, 0x41, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, // .A........@.....
+ 0x3f, 0x38, 0x00, 0x00, 0x07, 0x82, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, // ?8.... .........
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, // .............>..
+ 0x01, 0x00, 0x00, 0x00, 0x00, // .....
+};
+static const uint8_t fs_particle_mtl[882] =
+{
+ 0x46, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x00, 0x00, 0x63, 0x03, 0x00, 0x00, 0x75, 0x73, // FSH.......c...us
+ 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, // ing namespace me
+ 0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, // tal;.struct xlat
+ 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x7b, // MtlShaderInput {
+ 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, // . float4 v_colo
+ 0x72, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x76, 0x5f, 0x74, // r0;. float4 v_t
+ 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x73, 0x74, 0x72, // excoord0;.};.str
+ 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, // uct xlatMtlShade
+ 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x68, 0x61, 0x6c, 0x66, // rOutput {. half
+ 0x34, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, // 4 gl_FragColor;.
+ 0x7d, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, // };.struct xlatMt
+ 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x7b, // lShaderUniform {
+ 0x0a, 0x7d, 0x3b, 0x0a, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x78, 0x6c, 0x61, // .};.fragment xla
+ 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, // tMtlShaderOutput
+ 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x4d, 0x61, 0x69, 0x6e, 0x20, 0x28, 0x78, 0x6c, // xlatMtlMain (xl
+ 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, // atMtlShaderInput
+ 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x20, 0x5b, 0x5b, 0x73, 0x74, 0x61, 0x67, 0x65, 0x5f, // _mtl_i [[stage_
+ 0x69, 0x6e, 0x5d, 0x5d, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x20, 0x78, // in]], constant x
+ 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x55, 0x6e, 0x69, 0x66, // latMtlShaderUnif
+ 0x6f, 0x72, 0x6d, 0x26, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x20, 0x5b, 0x5b, 0x62, 0x75, // orm& _mtl_u [[bu
+ 0x66, 0x66, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x0a, 0x20, 0x20, 0x2c, 0x20, 0x20, 0x20, // ffer(0)]]. ,
+ 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x64, 0x3c, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3e, // texture2d<float>
+ 0x20, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x5b, 0x5b, 0x74, 0x65, // s_texColor [[te
+ 0x78, 0x74, 0x75, 0x72, 0x65, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70, // xture(0)]], samp
+ 0x6c, 0x65, 0x72, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x73, 0x6d, 0x70, 0x5f, 0x73, 0x5f, 0x74, 0x65, // ler _mtlsmp_s_te
+ 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x5b, 0x5b, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, // xColor [[sampler
+ 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, // (0)]]).{. xlatM
+ 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x5f, // tlShaderOutput _
+ 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x20, 0x20, 0x68, 0x61, 0x6c, 0x66, 0x34, 0x20, 0x72, // mtl_o;. half4 r
+ 0x67, 0x62, 0x61, 0x5f, 0x31, 0x20, 0x3d, 0x20, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x68, 0x61, 0x6c, // gba_1 = 0;. hal
+ 0x66, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x20, 0x3d, 0x20, 0x30, 0x3b, // f4 tmpvar_2 = 0;
+ 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x20, 0x3d, 0x20, 0x68, 0x61, // . tmpvar_2 = ha
+ 0x6c, 0x66, 0x34, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x2e, 0x73, // lf4(s_texColor.s
+ 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x73, 0x6d, 0x70, 0x5f, 0x73, 0x5f, // ample(_mtlsmp_s_
+ 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x28, 0x66, 0x6c, 0x6f, 0x61, 0x74, // texColor, (float
+ 0x32, 0x29, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, // 2)(_mtl_i.v_texc
+ 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x2e, 0x78, 0x79, 0x29, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x72, // oord0.xy)));. r
+ 0x67, 0x62, 0x61, 0x5f, 0x31, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x28, 0x68, // gba_1.xyz = (((h
+ 0x61, 0x6c, 0x66, 0x33, 0x29, 0x28, 0x28, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x29, 0x28, 0x74, // alf3)((float3)(t
+ 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x2e, 0x78, 0x78, 0x78, 0x29, 0x20, 0x2a, 0x20, 0x5f, // mpvar_2.xxx) * _
+ 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x2e, 0x78, // mtl_i.v_color0.x
+ 0x79, 0x7a, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x28, 0x28, // yz)) * ((half)((
+ 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x29, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x2e, // float)(tmpvar_2.
+ 0x78, 0x29, 0x20, 0x2a, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x76, 0x5f, 0x63, 0x6f, // x) * _mtl_i.v_co
+ 0x6c, 0x6f, 0x72, 0x30, 0x2e, 0x77, 0x29, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x67, 0x62, // lor0.w)));. rgb
+ 0x61, 0x5f, 0x31, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x28, // a_1.w = ((half)(
+ 0x28, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x29, 0x28, 0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x29, 0x28, // (float)(((half)(
+ 0x28, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x29, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, // (float)(tmpvar_2
+ 0x2e, 0x78, 0x29, 0x20, 0x2a, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x76, 0x5f, 0x63, // .x) * _mtl_i.v_c
+ 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x2e, 0x77, 0x29, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x28, 0x31, 0x2e, // olor0.w))) * (1.
+ 0x30, 0x20, 0x2d, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x76, 0x5f, 0x74, 0x65, 0x78, // 0 - _mtl_i.v_tex
+ 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x2e, 0x7a, 0x29, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x5f, // coord0.z)));. _
+ 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, // mtl_o.gl_FragCol
+ 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x72, 0x67, 0x62, 0x61, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x72, // or = rgba_1;. r
+ 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x7d, 0x0a, // eturn _mtl_o;.}.
+ 0x0a, 0x00, // ..
+};
+extern const uint8_t* fs_particle_pssl;
+extern const uint32_t fs_particle_pssl_size;
diff --git a/3rdparty/bgfx/examples/common/ps/fs_particle.sc b/3rdparty/bgfx/examples/common/ps/fs_particle.sc
new file mode 100644
index 00000000000..f0b4f569fc6
--- /dev/null
+++ b/3rdparty/bgfx/examples/common/ps/fs_particle.sc
@@ -0,0 +1,19 @@
+$input v_color0, v_texcoord0
+
+/*
+ * Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
+ */
+
+#include <bgfx_shader.sh>
+
+SAMPLER2D(s_texColor, 0);
+
+void main()
+{
+ vec4 rgba = texture2D(s_texColor, v_texcoord0.xy).xxxx;
+
+ rgba.xyz = rgba.xyz * v_color0.xyz * rgba.w * v_color0.w;
+ rgba.w = rgba.w * v_color0.w * (1.0f - v_texcoord0.z);
+ gl_FragColor = rgba;
+}
diff --git a/3rdparty/bgfx/examples/common/ps/makefile b/3rdparty/bgfx/examples/common/ps/makefile
new file mode 100644
index 00000000000..27e6c6bf04d
--- /dev/null
+++ b/3rdparty/bgfx/examples/common/ps/makefile
@@ -0,0 +1,9 @@
+#
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
+#
+
+include ../../../../bgfx/scripts/shader-embeded.mk
+
+rebuild:
+ @make -s --no-print-directory clean all
diff --git a/3rdparty/bgfx/examples/common/ps/particle_system.cpp b/3rdparty/bgfx/examples/common/ps/particle_system.cpp
new file mode 100644
index 00000000000..4e135048dd2
--- /dev/null
+++ b/3rdparty/bgfx/examples/common/ps/particle_system.cpp
@@ -0,0 +1,703 @@
+/*
+ * Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
+ */
+
+#include <bgfx/bgfx.h>
+#include <bgfx/embedded_shader.h>
+
+#include "particle_system.h"
+#include "../bgfx_utils.h"
+
+#include <bx/easing.h>
+#include <bx/crtimpl.h>
+#include <bx/handlealloc.h>
+
+#include "vs_particle.bin.h"
+#include "fs_particle.bin.h"
+
+static const bgfx::EmbeddedShader s_embeddedShaders[] =
+{
+ BGFX_EMBEDDED_SHADER(vs_particle),
+ BGFX_EMBEDDED_SHADER(fs_particle),
+
+ BGFX_EMBEDDED_SHADER_END()
+};
+
+static const bx::EaseFn s_easeFunc[] =
+{
+ bx::easeLinear,
+ bx::easeInQuad,
+ bx::easeOutQuad,
+ bx::easeInOutQuad,
+ bx::easeOutInQuad,
+ bx::easeInCubic,
+ bx::easeOutCubic,
+ bx::easeInOutCubic,
+ bx::easeOutInCubic,
+ bx::easeInQuart,
+ bx::easeOutQuart,
+ bx::easeInOutQuart,
+ bx::easeOutInQuart,
+ bx::easeInQuint,
+ bx::easeOutQuint,
+ bx::easeInOutQuint,
+ bx::easeOutInQuint,
+ bx::easeInSine,
+ bx::easeOutSine,
+ bx::easeInOutSine,
+ bx::easeOutInSine,
+ bx::easeInExpo,
+ bx::easeOutExpo,
+ bx::easeInOutExpo,
+ bx::easeOutInExpo,
+ bx::easeInCirc,
+ bx::easeOutCirc,
+ bx::easeInOutCirc,
+ bx::easeOutInCirc,
+ bx::easeInElastic,
+ bx::easeOutElastic,
+ bx::easeInOutElastic,
+ bx::easeOutInElastic,
+ bx::easeInBack,
+ bx::easeOutBack,
+ bx::easeInOutBack,
+ bx::easeOutInBack,
+ bx::easeInBounce,
+ bx::easeOutBounce,
+ bx::easeInOutBounce,
+ bx::easeOutInBounce,
+};
+BX_STATIC_ASSERT(BX_COUNTOF(s_easeFunc) == bx::Easing::Count);
+
+struct PosColorTexCoord0Vertex
+{
+ float m_x;
+ float m_y;
+ float m_z;
+ uint32_t m_abgr;
+ float m_u;
+ float m_v;
+ float m_blend;
+ float m_angle;
+
+ static void init()
+ {
+ ms_decl
+ .begin()
+ .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float)
+ .add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true)
+ .add(bgfx::Attrib::TexCoord0, 4, bgfx::AttribType::Float)
+ .end();
+ }
+
+ static bgfx::VertexDecl ms_decl;
+};
+
+bgfx::VertexDecl PosColorTexCoord0Vertex::ms_decl;
+
+void EmitterUniforms::reset()
+{
+ m_position[0] = 0.0f;
+ m_position[1] = 0.0f;
+ m_position[2] = 0.0f;
+
+ m_angle[0] = 0.0f;
+ m_angle[1] = 0.0f;
+ m_angle[2] = 0.0f;
+
+ m_particlesPerSecond = 0;
+
+ m_offsetStart[0] = 0.0f;
+ m_offsetStart[1] = 1.0f;
+ m_offsetEnd[0] = 2.0f;
+ m_offsetEnd[1] = 3.0f;
+
+ m_rgba[0] = 0x00ffffff;
+ m_rgba[1] = UINT32_MAX;
+ m_rgba[2] = UINT32_MAX;
+ m_rgba[3] = UINT32_MAX;
+ m_rgba[4] = 0x00ffffff;
+
+ m_blendStart[0] = 0.8f;
+ m_blendStart[1] = 1.0f;
+ m_blendEnd[0] = 0.0f;
+ m_blendEnd[1] = 0.2f;
+
+ m_scaleStart[0] = 0.1f;
+ m_scaleStart[1] = 0.2f;
+ m_scaleEnd[0] = 0.3f;
+ m_scaleEnd[1] = 0.4f;
+
+ m_lifeSpan[0] = 1.0f;
+ m_lifeSpan[1] = 2.0f;
+
+ m_gravityScale = 0.0f;
+
+ m_easePos = bx::Easing::Linear;
+ m_easeRgba = bx::Easing::Linear;
+ m_easeBlend = bx::Easing::Linear;
+ m_easeScale = bx::Easing::Linear;
+}
+
+namespace ps
+{
+ struct Particle
+ {
+ float start[3];
+ float end[2][3];
+ float blendStart;
+ float blendEnd;
+ float scaleStart;
+ float scaleEnd;
+
+ uint32_t rgba[5];
+
+ float life;
+ float lifeSpan;
+ };
+
+ struct ParticleSort
+ {
+ float dist;
+ uint32_t idx;
+ };
+
+ inline uint32_t toAbgr(const float* _rgba)
+ {
+ return 0
+ | (uint8_t(_rgba[0]*255.0f)<< 0)
+ | (uint8_t(_rgba[1]*255.0f)<< 8)
+ | (uint8_t(_rgba[2]*255.0f)<<16)
+ | (uint8_t(_rgba[3]*255.0f)<<24)
+ ;
+ }
+
+ inline uint32_t toAbgr(float _rr, float _gg, float _bb, float _aa)
+ {
+ return 0
+ | (uint8_t(_rr*255.0f)<< 0)
+ | (uint8_t(_gg*255.0f)<< 8)
+ | (uint8_t(_bb*255.0f)<<16)
+ | (uint8_t(_aa*255.0f)<<24)
+ ;
+ }
+
+ struct Emitter
+ {
+ void create(EmitterShape::Enum _shape, EmitterDirection::Enum _direction, uint32_t _maxParticles);
+ void destroy();
+
+ void reset()
+ {
+ m_num = 0;
+ memset(&m_aabb, 0, sizeof(Aabb) );
+ }
+
+ void update(float _dt)
+ {
+ uint32_t num = m_num;
+ for (uint32_t ii = 0; ii < num; ++ii)
+ {
+ Particle& particle = m_particles[ii];
+ particle.life += _dt * 1.0f/particle.lifeSpan;
+
+ if (particle.life > 1.0f)
+ {
+ if (ii != num-1)
+ {
+ memcpy(&particle, &m_particles[num-1], sizeof(Particle) );
+ --ii;
+ }
+
+ --num;
+ }
+ }
+
+ m_num = num;
+
+ if (0 < m_uniforms.m_particlesPerSecond)
+ {
+ spawn(_dt);
+ }
+ }
+
+ void spawn(float _dt)
+ {
+ float mtx[16];
+ bx::mtxSRT(mtx
+ , 1.0f, 1.0f, 1.0f
+ , m_uniforms.m_angle[0], m_uniforms.m_angle[1], m_uniforms.m_angle[2]
+ , m_uniforms.m_position[0], m_uniforms.m_position[1], m_uniforms.m_position[2]
+ );
+
+ const float timePerParticle = 1.0f/m_uniforms.m_particlesPerSecond;
+ m_dt += _dt;
+ const uint32_t numParticles = uint32_t(m_dt / timePerParticle);
+ m_dt -= numParticles * timePerParticle;
+
+ float time = 0.0f;
+ for (uint32_t ii = 0
+ ; ii < numParticles && m_num < m_max
+ ; ++ii
+ )
+ {
+ Particle& particle = m_particles[m_num];
+ m_num++;
+
+ const float up[3] = { 0.0f, 1.0f, 0.0f };
+
+ float pos[3];
+ switch (m_shape)
+ {
+ default:
+ case EmitterShape::Sphere:
+ bx::randUnitSphere(pos, &m_rng);
+ break;
+
+ case EmitterShape::Hemisphere:
+ bx::randUnitHemisphere(pos, &m_rng, up);
+ break;
+
+ case EmitterShape::Circle:
+ bx::randUnitCircle(pos, &m_rng);
+ break;
+
+ case EmitterShape::Disc:
+ {
+ float tmp[3];
+ bx::randUnitCircle(tmp, &m_rng);
+ bx::vec3Mul(pos, tmp, bx::frnd(&m_rng) );
+ }
+ break;
+
+ case EmitterShape::Rect:
+ pos[0] = bx::frndh(&m_rng);
+ pos[1] = 0.0f;
+ pos[2] = bx::frndh(&m_rng);
+ break;
+ }
+
+ float dir[3];
+ switch (m_direction)
+ {
+ default:
+ case EmitterDirection::Up:
+ bx::vec3Move(dir, up);
+ break;
+
+ case EmitterDirection::Outward:
+ bx::vec3Norm(dir, pos);
+ break;
+ }
+
+ float start[3];
+ float end[3];
+ const float startOffset = bx::flerp(m_uniforms.m_offsetStart[0], m_uniforms.m_offsetStart[1], bx::frnd(&m_rng) );
+ bx::vec3Mul(start, pos, startOffset);
+
+ const float endOffset = bx::flerp(m_uniforms.m_offsetEnd[0], m_uniforms.m_offsetEnd[1], bx::frnd(&m_rng) );
+ float tmp1[3];
+ bx::vec3Mul(tmp1, dir, endOffset);
+ bx::vec3Add(end, tmp1, start);
+
+ particle.life = time;
+ particle.lifeSpan = bx::flerp(m_uniforms.m_lifeSpan[0], m_uniforms.m_lifeSpan[1], bx::frnd(&m_rng) );
+
+ float gravity[3] = { 0.0f, -9.81f * m_uniforms.m_gravityScale * bx::fsq(particle.lifeSpan), 0.0f };
+
+ bx::vec3MulMtx(particle.start, start, mtx);
+ bx::vec3MulMtx(particle.end[0], end, mtx);
+ bx::vec3Add(particle.end[1], particle.end[0], gravity);
+
+ memcpy(particle.rgba, m_uniforms.m_rgba, BX_COUNTOF(m_uniforms.m_rgba)*sizeof(uint32_t) );
+
+ particle.blendStart = bx::flerp(m_uniforms.m_blendStart[0], m_uniforms.m_blendStart[1], bx::frnd(&m_rng) );
+ particle.blendEnd = bx::flerp(m_uniforms.m_blendEnd[0], m_uniforms.m_blendEnd[1], bx::frnd(&m_rng) );
+
+ particle.scaleStart = bx::flerp(m_uniforms.m_scaleStart[0], m_uniforms.m_scaleStart[1], bx::frnd(&m_rng) );
+ particle.scaleEnd = bx::flerp(m_uniforms.m_scaleEnd[0], m_uniforms.m_scaleEnd[1], bx::frnd(&m_rng) );
+
+ time += timePerParticle;
+ }
+ }
+
+ uint32_t render(const float* _mtxView, const float* _eye, uint32_t _first, uint32_t _max, ParticleSort* _outSort, PosColorTexCoord0Vertex* _outVertices)
+ {
+ bx::EaseFn easeRgba = s_easeFunc[m_uniforms.m_easeRgba];
+ bx::EaseFn easePos = s_easeFunc[m_uniforms.m_easePos];
+ bx::EaseFn easeBlend = s_easeFunc[m_uniforms.m_easeBlend];
+ bx::EaseFn easeScale = s_easeFunc[m_uniforms.m_easeScale];
+
+ Aabb aabb =
+ {
+ { bx::huge, bx::huge, bx::huge },
+ { -bx::huge, -bx::huge, -bx::huge },
+ };
+
+ for (uint32_t jj = 0, num = m_num, current = _first
+ ; jj < num && current < _max
+ ; ++jj, ++current
+ )
+ {
+ const Particle& particle = m_particles[jj];
+
+ const float ttPos = easePos(particle.life);
+ const float ttScale = easeScale(particle.life);
+ const float ttBlend = bx::fsaturate(easeBlend(particle.life) );
+ const float ttRgba = bx::fsaturate(easeRgba(particle.life) );
+
+ float p0[3];
+ bx::vec3Lerp(p0, particle.start, particle.end[0], ttPos);
+
+ float p1[3];
+ bx::vec3Lerp(p1, particle.end[0], particle.end[1], ttPos);
+
+ float pos[3];
+ bx::vec3Lerp(pos, p0, p1, ttPos);
+
+ ParticleSort& sort = _outSort[current];
+ float tmp[3];
+ bx::vec3Sub(tmp, _eye, pos);
+ sort.dist = bx::fsqrt(bx::vec3Dot(tmp, tmp) );
+ sort.idx = current;
+
+ uint32_t idx = uint32_t(ttRgba*4);
+ float ttmod = bx::fmod(ttRgba, 0.25f)/0.25f;
+ uint32_t rgbaStart = particle.rgba[idx];
+ uint32_t rgbaEnd = particle.rgba[idx+1];
+
+ float rr = bx::flerp( ( (uint8_t*)&rgbaStart)[0], ( (uint8_t*)&rgbaEnd)[0], ttmod)/255.0f;
+ float gg = bx::flerp( ( (uint8_t*)&rgbaStart)[1], ( (uint8_t*)&rgbaEnd)[1], ttmod)/255.0f;
+ float bb = bx::flerp( ( (uint8_t*)&rgbaStart)[2], ( (uint8_t*)&rgbaEnd)[2], ttmod)/255.0f;
+ float aa = bx::flerp( ( (uint8_t*)&rgbaStart)[3], ( (uint8_t*)&rgbaEnd)[3], ttmod)/255.0f;
+
+ float blend = bx::flerp(particle.blendStart, particle.blendEnd, ttBlend);
+ float scale = bx::flerp(particle.scaleStart, particle.scaleEnd, ttScale);
+
+ uint32_t abgr = toAbgr(rr, gg, bb, aa);
+
+ float udir[3] = { _mtxView[0]*scale, _mtxView[4]*scale, _mtxView[8]*scale };
+ float vdir[3] = { _mtxView[1]*scale, _mtxView[5]*scale, _mtxView[9]*scale };
+
+ PosColorTexCoord0Vertex* vertex = &_outVertices[current*4];
+ bx::vec3Sub(tmp, pos, udir);
+ bx::vec3Sub(&vertex->m_x, tmp, vdir);
+ aabbExpand(aabb, &vertex->m_x);
+ vertex->m_abgr = abgr;
+ vertex->m_u = 0.0f;
+ vertex->m_v = 0.0f;
+ vertex->m_blend = blend;
+ ++vertex;
+
+ bx::vec3Add(tmp, pos, udir);
+ bx::vec3Sub(&vertex->m_x, tmp, vdir);
+ aabbExpand(aabb, &vertex->m_x);
+ vertex->m_abgr = abgr;
+ vertex->m_u = 1.0f;
+ vertex->m_v = 0.0f;
+ vertex->m_blend = blend;
+ ++vertex;
+
+ bx::vec3Add(tmp, pos, udir);
+ bx::vec3Add(&vertex->m_x, tmp, vdir);
+ aabbExpand(aabb, &vertex->m_x);
+ vertex->m_abgr = abgr;
+ vertex->m_u = 1.0f;
+ vertex->m_v = 1.0f;
+ vertex->m_blend = blend;
+ ++vertex;
+
+ bx::vec3Sub(tmp, pos, udir);
+ bx::vec3Add(&vertex->m_x, tmp, vdir);
+ aabbExpand(aabb, &vertex->m_x);
+ vertex->m_abgr = abgr;
+ vertex->m_u = 0.0f;
+ vertex->m_v = 1.0f;
+ vertex->m_blend = blend;
+ ++vertex;
+ }
+
+ m_aabb = aabb;
+
+ return m_num;
+ }
+
+ EmitterShape::Enum m_shape;
+ EmitterDirection::Enum m_direction;
+
+ float m_dt;
+ bx::RngMwc m_rng;
+ EmitterUniforms m_uniforms;
+
+ Aabb m_aabb;
+
+ Particle* m_particles;
+ uint32_t m_num;
+ uint32_t m_max;
+ };
+
+ static int32_t particleSortFn(const void* _lhs, const void* _rhs)
+ {
+ const ParticleSort& lhs = *(const ParticleSort*)_lhs;
+ const ParticleSort& rhs = *(const ParticleSort*)_rhs;
+ return lhs.dist > rhs.dist ? -1 : 1;
+ }
+
+ struct ParticleSystem
+ {
+ void init(uint16_t _maxEmitters, bx::AllocatorI* _allocator)
+ {
+ m_allocator = _allocator;
+
+#if BX_CONFIG_ALLOCATOR_CRT
+ if (NULL == _allocator)
+ {
+ static bx::CrtAllocator allocator;
+ m_allocator = &allocator;
+ }
+#endif // BX_CONFIG_ALLOCATOR_CRT
+
+ m_emitterAlloc = bx::createHandleAlloc(m_allocator, _maxEmitters);
+ m_emitter = (Emitter*)BX_ALLOC(m_allocator, sizeof(Emitter)*_maxEmitters);
+
+ PosColorTexCoord0Vertex::init();
+
+ m_num = 0;
+
+ s_texColor = bgfx::createUniform("s_texColor", bgfx::UniformType::Int1);
+ m_particleTexture = loadTexture("textures/particle.ktx");
+
+ bgfx::RendererType::Enum type = bgfx::getRendererType();
+ m_particleProgram = bgfx::createProgram(
+ bgfx::createEmbeddedShader(s_embeddedShaders, type, "vs_particle")
+ , bgfx::createEmbeddedShader(s_embeddedShaders, type, "fs_particle")
+ , true
+ );
+ }
+
+ void shutdown()
+ {
+ bgfx::destroyProgram(m_particleProgram);
+ bgfx::destroyTexture(m_particleTexture);
+ bgfx::destroyUniform(s_texColor);
+
+ bx::destroyHandleAlloc(m_allocator, m_emitterAlloc);
+ BX_FREE(m_allocator, m_emitter);
+
+ m_allocator = NULL;
+ }
+
+ void update(float _dt)
+ {
+ uint32_t numParticles = 0;
+ for (uint16_t ii = 0, num = m_emitterAlloc->getNumHandles(); ii < num; ++ii)
+ {
+ const uint16_t idx = m_emitterAlloc->getHandleAt(ii);
+ Emitter& emitter = m_emitter[idx];
+ emitter.update(_dt);
+ numParticles += emitter.m_num;
+ }
+
+ m_num = numParticles;
+ }
+
+ void render(uint8_t _view, const float* _mtxView, const float* _eye)
+ {
+ if (0 != m_num)
+ {
+ bgfx::TransientVertexBuffer tvb;
+ bgfx::TransientIndexBuffer tib;
+
+ const uint32_t numVertices = bgfx::getAvailTransientVertexBuffer(m_num*4, PosColorTexCoord0Vertex::ms_decl);
+ const uint32_t numIndices = bgfx::getAvailTransientIndexBuffer(m_num*6);
+ const uint32_t max = bx::uint32_min(numVertices/4, numIndices/6);
+ BX_WARN(m_num == max
+ , "Truncating transient buffer for particles to maximum available (requested %d, available %d)."
+ , m_num
+ , max
+ );
+
+ if (0 < max)
+ {
+ bgfx::allocTransientBuffers(&tvb
+ , PosColorTexCoord0Vertex::ms_decl
+ , max*4
+ , &tib
+ , max*6
+ );
+ PosColorTexCoord0Vertex* vertices = (PosColorTexCoord0Vertex*)tvb.data;
+
+ ParticleSort* particleSort = (ParticleSort*)BX_ALLOC(m_allocator, max*sizeof(ParticleSort) );
+
+ uint32_t pos = 0;
+ for (uint16_t ii = 0, numEmitters = m_emitterAlloc->getNumHandles(); ii < numEmitters; ++ii)
+ {
+ const uint16_t idx = m_emitterAlloc->getHandleAt(ii);
+ Emitter& emitter = m_emitter[idx];
+ pos += emitter.render(_mtxView, _eye, pos, max, particleSort, vertices);
+ }
+
+ qsort(particleSort
+ , max
+ , sizeof(ParticleSort)
+ , particleSortFn
+ );
+
+ uint16_t* indices = (uint16_t*)tib.data;
+ for (uint32_t ii = 0; ii < max; ++ii)
+ {
+ const ParticleSort& sort = particleSort[ii];
+ uint16_t* index = &indices[ii*6];
+ uint16_t idx = (uint16_t)sort.idx;
+ index[0] = idx*4+0;
+ index[1] = idx*4+1;
+ index[2] = idx*4+2;
+ index[3] = idx*4+2;
+ index[4] = idx*4+3;
+ index[5] = idx*4+0;
+ }
+
+ BX_FREE(m_allocator, particleSort);
+
+ bgfx::setState(0
+ | BGFX_STATE_RGB_WRITE
+ | BGFX_STATE_ALPHA_WRITE
+ | BGFX_STATE_DEPTH_TEST_LESS
+ | BGFX_STATE_CULL_CW
+ | BGFX_STATE_BLEND_NORMAL
+ );
+ bgfx::setVertexBuffer(&tvb);
+ bgfx::setIndexBuffer(&tib);
+ bgfx::setTexture(0, s_texColor, m_particleTexture);
+ bgfx::submit(_view, m_particleProgram);
+ }
+ }
+ }
+
+ EmitterHandle createEmitter(EmitterShape::Enum _shape, EmitterDirection::Enum _direction, uint32_t _maxParticles)
+ {
+ EmitterHandle handle = { m_emitterAlloc->alloc() };
+
+ if (UINT16_MAX != handle.idx)
+ {
+ m_emitter[handle.idx].create(_shape, _direction, _maxParticles);
+ }
+
+ return handle;
+ }
+
+ void updateEmitter(EmitterHandle _handle, const EmitterUniforms* _uniforms)
+ {
+ BX_CHECK(m_emitterAlloc.isValid(_handle.idx)
+ , "destroyEmitter handle %d is not valid."
+ , _handle.idx
+ );
+
+ Emitter& emitter = m_emitter[_handle.idx];
+
+ if (NULL == _uniforms)
+ {
+ emitter.reset();
+ }
+ else
+ {
+ memcpy(&emitter.m_uniforms, _uniforms, sizeof(EmitterUniforms) );
+ }
+ }
+
+ void getAabb(EmitterHandle _handle, Aabb& _outAabb)
+ {
+ BX_CHECK(m_emitterAlloc.isValid(_handle.idx)
+ , "getAabb handle %d is not valid."
+ , _handle.idx
+ );
+ _outAabb = m_emitter[_handle.idx].m_aabb;
+ }
+
+ void destroyEmitter(EmitterHandle _handle)
+ {
+ BX_CHECK(m_emitterAlloc.isValid(_handle.idx)
+ , "destroyEmitter handle %d is not valid."
+ , _handle.idx
+ );
+
+ m_emitter[_handle.idx].destroy();
+ m_emitterAlloc->free(_handle.idx);
+ }
+
+ bx::AllocatorI* m_allocator;
+
+ bx::HandleAlloc* m_emitterAlloc;
+ Emitter* m_emitter;
+
+ bgfx::UniformHandle s_texColor;
+ bgfx::TextureHandle m_particleTexture;
+ bgfx::ProgramHandle m_particleProgram;
+
+ uint32_t m_num;
+ };
+
+ static ParticleSystem s_ctx;
+
+ void Emitter::create(EmitterShape::Enum _shape, EmitterDirection::Enum _direction, uint32_t _maxParticles)
+ {
+ m_dt = 0.0f;
+ m_uniforms.reset();
+ m_shape = _shape;
+ m_direction = _direction;
+
+ m_num = 0;
+ m_max = _maxParticles;
+ m_particles = (Particle*)BX_ALLOC(s_ctx.m_allocator, m_max*sizeof(Particle) );
+ }
+
+ void Emitter::destroy()
+ {
+ BX_FREE(s_ctx.m_allocator, m_particles);
+ m_particles = NULL;
+ }
+
+} // namespace ps
+
+using namespace ps;
+
+void psInit(uint16_t _maxEmitters, bx::AllocatorI* _allocator)
+{
+ s_ctx.init(_maxEmitters, _allocator);
+}
+
+void psShutdown()
+{
+ s_ctx.shutdown();
+}
+
+EmitterHandle psCreateEmitter(EmitterShape::Enum _shape, EmitterDirection::Enum _direction, uint32_t _maxParticles)
+{
+ return s_ctx.createEmitter(_shape, _direction, _maxParticles);
+}
+
+void psUpdateEmitter(EmitterHandle _handle, const EmitterUniforms* _uniforms)
+{
+ s_ctx.updateEmitter(_handle, _uniforms);
+}
+
+void psGetAabb(EmitterHandle _handle, Aabb& _outAabb)
+{
+ s_ctx.getAabb(_handle, _outAabb);
+}
+
+void psDestroyEmitter(EmitterHandle _handle)
+{
+ s_ctx.destroyEmitter(_handle);
+}
+
+void psUpdate(float _dt)
+{
+ s_ctx.update(_dt);
+}
+
+void psRender(uint8_t _view, const float* _mtxView, const float* _eye)
+{
+ s_ctx.render(_view, _mtxView, _eye);
+}
diff --git a/3rdparty/bgfx/examples/common/ps/particle_system.h b/3rdparty/bgfx/examples/common/ps/particle_system.h
new file mode 100644
index 00000000000..be706582422
--- /dev/null
+++ b/3rdparty/bgfx/examples/common/ps/particle_system.h
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
+ */
+
+#ifndef PARTICLE_SYSTEM_H_HEADER_GUARD
+#define PARTICLE_SYSTEM_H_HEADER_GUARD
+
+#include <bx/allocator.h>
+#include <bx/easing.h>
+#include <bx/rng.h>
+
+#include "../bounds.h"
+
+struct EmitterShape
+{
+ enum Enum
+ {
+ Sphere,
+ Hemisphere,
+ Circle,
+ Disc,
+ Rect,
+
+ Count
+ };
+};
+
+struct EmitterDirection
+{
+ enum Enum
+ {
+ Up,
+ Outward,
+
+ Count
+ };
+};
+
+struct EmitterUniforms
+{
+ void reset();
+
+ float m_position[3];
+ float m_angle[3];
+
+ float m_blendStart[2];
+ float m_blendEnd[2];
+ float m_offsetStart[2];
+ float m_offsetEnd[2];
+ float m_scaleStart[2];
+ float m_scaleEnd[2];
+ float m_lifeSpan[2];
+ float m_gravityScale;
+
+ uint32_t m_rgba[5];
+ uint32_t m_particlesPerSecond;
+
+ bx::Easing::Enum m_easePos;
+ bx::Easing::Enum m_easeRgba;
+ bx::Easing::Enum m_easeBlend;
+ bx::Easing::Enum m_easeScale;
+};
+
+struct EmitterHandle { uint16_t idx; };
+
+///
+void psInit(uint16_t _maxEmitters = 64, bx::AllocatorI* _allocator = NULL);
+
+///
+void psShutdown();
+
+///
+EmitterHandle psCreateEmitter(EmitterShape::Enum _shape, EmitterDirection::Enum _direction, uint32_t _maxParticles);
+
+///
+void psUpdateEmitter(EmitterHandle _handle, const EmitterUniforms* _uniforms = NULL);
+
+///
+void psGetAabb(EmitterHandle _handle, Aabb& _outAabb);
+
+///
+void psDestroyEmitter(EmitterHandle _handle);
+
+///
+void psUpdate(float _dt);
+
+///
+void psRender(uint8_t _view, const float* _mtxView, const float* _eye);
+
+#endif // PARTICLE_SYSTEM_H_HEADER_GUARD
diff --git a/3rdparty/bgfx/examples/common/ps/varying.def.sc b/3rdparty/bgfx/examples/common/ps/varying.def.sc
new file mode 100644
index 00000000000..2218c4b47cf
--- /dev/null
+++ b/3rdparty/bgfx/examples/common/ps/varying.def.sc
@@ -0,0 +1,6 @@
+vec4 v_color0 : COLOR0 = vec4(1.0, 0.0, 0.0, 1.0);
+vec4 v_texcoord0 : TEXCOORD0 = vec4(0.0, 0.0, 0.0, 0.0);
+
+vec3 a_position : POSITION;
+vec4 a_color0 : COLOR0;
+vec4 a_texcoord0 : TEXCOORD0;
diff --git a/3rdparty/bgfx/examples/common/ps/vs_particle.bin.h b/3rdparty/bgfx/examples/common/ps/vs_particle.bin.h
new file mode 100644
index 00000000000..49af4f00fe9
--- /dev/null
+++ b/3rdparty/bgfx/examples/common/ps/vs_particle.bin.h
@@ -0,0 +1,151 @@
+static const uint8_t vs_particle_glsl[420] =
+{
+ 0x56, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x01, 0x00, 0x0f, 0x75, 0x5f, 0x6d, 0x6f, 0x64, // VSH........u_mod
+ 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x04, 0x01, 0x00, 0x00, 0x01, 0x00, // elViewProj......
+ 0x7f, 0x01, 0x00, 0x00, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x68, 0x69, // ....attribute hi
+ 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x61, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, // ghp vec4 a_color
+ 0x30, 0x3b, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x68, 0x69, 0x67, // 0;.attribute hig
+ 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, // hp vec3 a_positi
+ 0x6f, 0x6e, 0x3b, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x68, 0x69, // on;.attribute hi
+ 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x61, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, // ghp vec4 a_texco
+ 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x68, 0x69, // ord0;.varying hi
+ 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, // ghp vec4 v_color
+ 0x30, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, // 0;.varying highp
+ 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, // vec4 v_texcoord
+ 0x30, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, // 0;.uniform highp
+ 0x20, 0x6d, 0x61, 0x74, 0x34, 0x20, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, // mat4 u_modelVie
+ 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x3b, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, // wProj;.void main
+ 0x20, 0x28, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, // ().{. highp ve
+ 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, // c4 tmpvar_1;. t
+ 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x3b, // mpvar_1.w = 1.0;
+ 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x78, 0x79, 0x7a, 0x20, // . tmpvar_1.xyz
+ 0x3d, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, // = a_position;.
+ 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x28, 0x75, // gl_Position = (u
+ 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x20, 0x2a, // _modelViewProj *
+ 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x76, 0x5f, // tmpvar_1);. v_
+ 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x20, 0x3d, 0x20, 0x61, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, // color0 = a_color
+ 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, // 0;. v_texcoord0
+ 0x20, 0x3d, 0x20, 0x61, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, // = a_texcoord0;.
+ 0x7d, 0x0a, 0x0a, 0x00, // }...
+};
+static const uint8_t vs_particle_dx9[347] =
+{
+ 0x56, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x01, 0x00, 0x0f, 0x75, 0x5f, 0x6d, 0x6f, 0x64, // VSH........u_mod
+ 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x04, 0x01, 0x00, 0x00, 0x04, 0x00, // elViewProj......
+ 0x38, 0x01, 0x00, 0x03, 0xfe, 0xff, 0xfe, 0xff, 0x21, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, // 8.......!.CTAB..
+ 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x00, 0x03, 0xfe, 0xff, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, // ..W.............
+ 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, // ......P...0.....
+ 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, // ......@.......u_
+ 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x00, 0x03, 0x00, // modelViewProj...
+ 0x03, 0x00, 0x04, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x73, // ..............vs
+ 0x5f, 0x33, 0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, // _3_0.Microsoft (
+ 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, // R) HLSL Shader C
+ 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2e, 0x31, 0x00, 0xab, 0x1f, 0x00, // ompiler 10.1....
+ 0x00, 0x02, 0x0a, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, // ................
+ 0x00, 0x80, 0x01, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x80, 0x02, 0x00, // ................
+ 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0xe0, 0x1f, 0x00, // ................
+ 0x00, 0x02, 0x0a, 0x00, 0x00, 0x80, 0x01, 0x00, 0x0f, 0xe0, 0x1f, 0x00, 0x00, 0x02, 0x05, 0x00, // ................
+ 0x00, 0x80, 0x02, 0x00, 0x0f, 0xe0, 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0x80, 0x01, 0x00, // ................
+ 0xe4, 0xa0, 0x01, 0x00, 0x55, 0x90, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, // ....U...........
+ 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x90, 0x00, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, // ................
+ 0x0f, 0x80, 0x02, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0xaa, 0x90, 0x00, 0x00, 0xe4, 0x80, 0x02, 0x00, // ................
+ 0x00, 0x03, 0x00, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0xe4, 0x80, 0x03, 0x00, 0xe4, 0xa0, 0x01, 0x00, // ................
+ 0x00, 0x02, 0x01, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0xe4, 0x90, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, // ................
+ 0x0f, 0xe0, 0x02, 0x00, 0xe4, 0x90, 0xff, 0xff, 0x00, 0x00, 0x00, // ...........
+};
+static const uint8_t vs_particle_dx11[620] =
+{
+ 0x56, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x01, 0x00, 0x0f, 0x75, 0x5f, 0x6d, 0x6f, 0x64, // VSH........u_mod
+ 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, // elViewProj......
+ 0x40, 0x02, 0x44, 0x58, 0x42, 0x43, 0x94, 0x83, 0x4e, 0xd2, 0x28, 0xd5, 0xeb, 0x87, 0x3e, 0xf5, // @.DXBC..N.(...>.
+ 0xa1, 0x65, 0x63, 0x87, 0x0e, 0xf7, 0x01, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x03, 0x00, // .ec.......@.....
+ 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x49, 0x53, // ..,...........IS
+ 0x47, 0x4e, 0x68, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x50, 0x00, // GNh...........P.
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
+ 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ......V.........
+ 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, 0x5f, 0x00, // .............._.
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, // ................
+ 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0x50, 0x4f, 0x53, 0x49, // ......COLOR.POSI
+ 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0x4f, 0x53, // TION.TEXCOORD.OS
+ 0x47, 0x4e, 0x6c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x50, 0x00, // GNl...........P.
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
+ 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
+ 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x62, 0x00, // ..............b.
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, // ................
+ 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, // ......SV_POSITIO
+ 0x4e, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, // N.COLOR.TEXCOORD
+ 0x00, 0xab, 0x53, 0x48, 0x44, 0x52, 0x28, 0x01, 0x00, 0x00, 0x40, 0x00, 0x01, 0x00, 0x4a, 0x00, // ..SHDR(...@...J.
+ 0x00, 0x00, 0x59, 0x00, 0x00, 0x04, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, // ..Y...F. .......
+ 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0xf2, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x00, // .._..........._.
+ 0x00, 0x03, 0x72, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0xf2, 0x10, // ..r......._.....
+ 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x04, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, // ......g.... ....
+ 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x01, 0x00, // ......e.... ....
+ 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x68, 0x00, // ..e.... ......h.
+ 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, // ......8.........
+ 0x00, 0x00, 0x56, 0x15, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, // ..V.......F. ...
+ 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, // ......2.........
+ 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, // ..F. ...........
+ 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, // ......F.......2.
+ 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, // ..........F. ...
+ 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x1a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x0e, // ..............F.
+ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, // ........... ....
+ 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, // ..F.......F. ...
+ 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xf2, 0x20, 0x10, 0x00, 0x01, 0x00, // ......6.... ....
+ 0x00, 0x00, 0x46, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xf2, 0x20, // ..F.......6....
+ 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x1e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3e, 0x00, // ......F.......>.
+ 0x00, 0x01, 0x00, 0x03, 0x05, 0x00, 0x01, 0x00, 0x10, 0x00, 0x40, 0x00, // ..........@.
+};
+static const uint8_t vs_particle_mtl[777] =
+{
+ 0x56, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x01, 0x00, 0x0f, 0x75, 0x5f, 0x6d, 0x6f, 0x64, // VSH........u_mod
+ 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x04, 0x01, 0x00, 0x00, 0x01, 0x00, // elViewProj......
+ 0xe4, 0x02, 0x00, 0x00, 0x75, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, // ....using namesp
+ 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, // ace metal;.struc
+ 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x49, // t xlatMtlShaderI
+ 0x6e, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, // nput {. float4
+ 0x61, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, // a_color0 [[attri
+ 0x62, 0x75, 0x74, 0x65, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, // bute(0)]];. flo
+ 0x61, 0x74, 0x33, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x5b, // at3 a_position [
+ 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x28, 0x31, 0x29, 0x5d, 0x5d, 0x3b, // [attribute(1)]];
+ 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x61, 0x5f, 0x74, 0x65, 0x78, 0x63, // . float4 a_texc
+ 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, // oord0 [[attribut
+ 0x65, 0x28, 0x32, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, // e(2)]];.};.struc
+ 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, // t xlatMtlShaderO
+ 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, // utput {. float4
+ 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x70, // gl_Position [[p
+ 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, // osition]];. flo
+ 0x61, 0x74, 0x34, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x3b, 0x0a, 0x20, 0x20, // at4 v_color0;.
+ 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, // float4 v_texcoor
+ 0x64, 0x30, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, // d0;.};.struct xl
+ 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x55, 0x6e, 0x69, 0x66, 0x6f, // atMtlShaderUnifo
+ 0x72, 0x6d, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x78, 0x34, 0x20, // rm {. float4x4
+ 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x3b, // u_modelViewProj;
+ 0x0a, 0x7d, 0x3b, 0x0a, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, // .};.vertex xlatM
+ 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x78, // tlShaderOutput x
+ 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x4d, 0x61, 0x69, 0x6e, 0x20, 0x28, 0x78, 0x6c, 0x61, 0x74, // latMtlMain (xlat
+ 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x5f, // MtlShaderInput _
+ 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x20, 0x5b, 0x5b, 0x73, 0x74, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, // mtl_i [[stage_in
+ 0x5d, 0x5d, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x20, 0x78, 0x6c, 0x61, // ]], constant xla
+ 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, // tMtlShaderUnifor
+ 0x6d, 0x26, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x20, 0x5b, 0x5b, 0x62, 0x75, 0x66, 0x66, // m& _mtl_u [[buff
+ 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x78, 0x6c, 0x61, // er(0)]]).{. xla
+ 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, // tMtlShaderOutput
+ 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, // _mtl_o;. float
+ 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x20, 0x3d, 0x20, 0x30, 0x3b, 0x0a, // 4 tmpvar_1 = 0;.
+ 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31, // tmpvar_1.w = 1
+ 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x78, // .0;. tmpvar_1.x
+ 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x61, 0x5f, 0x70, 0x6f, // yz = _mtl_i.a_po
+ 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, // sition;. _mtl_o
+ 0x2e, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x28, // .gl_Position = (
+ 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x2e, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, // _mtl_u.u_modelVi
+ 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // ewProj * tmpvar_
+ 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x76, 0x5f, 0x63, // 1);. _mtl_o.v_c
+ 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x20, 0x3d, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x61, // olor0 = _mtl_i.a
+ 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, // _color0;. _mtl_
+ 0x6f, 0x2e, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x3d, 0x20, // o.v_texcoord0 =
+ 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x61, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, // _mtl_i.a_texcoor
+ 0x64, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x6d, 0x74, // d0;. return _mt
+ 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // l_o;.}...
+};
+extern const uint8_t* vs_particle_pssl;
+extern const uint32_t vs_particle_pssl_size;
diff --git a/3rdparty/bgfx/examples/common/ps/vs_particle.sc b/3rdparty/bgfx/examples/common/ps/vs_particle.sc
new file mode 100644
index 00000000000..33a2a4639f8
--- /dev/null
+++ b/3rdparty/bgfx/examples/common/ps/vs_particle.sc
@@ -0,0 +1,16 @@
+$input a_position, a_color0, a_texcoord0
+$output v_color0, v_texcoord0
+
+/*
+ * Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
+ */
+
+#include <bgfx_shader.sh>
+
+void main()
+{
+ gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) );
+ v_color0 = a_color0;
+ v_texcoord0 = a_texcoord0;
+}
diff --git a/3rdparty/bgfx/examples/makefile b/3rdparty/bgfx/examples/makefile
index 13ce9f336b8..ec6ea3c4394 100644
--- a/3rdparty/bgfx/examples/makefile
+++ b/3rdparty/bgfx/examples/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
rebuild:
diff --git a/3rdparty/bgfx/examples/runtime/textures/particle.ktx b/3rdparty/bgfx/examples/runtime/textures/particle.ktx
new file mode 100644
index 00000000000..affe202662d
--- /dev/null
+++ b/3rdparty/bgfx/examples/runtime/textures/particle.ktx
Binary files differ
diff --git a/3rdparty/bgfx/include/bgfx/bgfx.h b/3rdparty/bgfx/include/bgfx/bgfx.h
index 02881cac71d..d41ba5915f3 100644
--- a/3rdparty/bgfx/include/bgfx/bgfx.h
+++ b/3rdparty/bgfx/include/bgfx/bgfx.h
@@ -935,40 +935,40 @@ namespace bgfx
/// Swizzle RGBA8 image to BGRA8.
///
+ /// @param[in] _dst Destination image. Must be the same size as input image.
+ /// _dst might be pointer to the same memory as _src.
/// @param[in] _width Width of input image (pixels).
/// @param[in] _height Height of input image (pixels).
/// @param[in] _pitch Pitch of input image (bytes).
/// @param[in] _src Source image.
- /// @param[in] _dst Destination image. Must be the same size as input image.
- /// _dst might be pointer to the same memory as _src.
///
/// @attention C99 equivalent is `bgfx_image_swizzle_bgra8`.
///
void imageSwizzleBgra8(
- uint32_t _width
+ void* _dst
+ , uint32_t _width
, uint32_t _height
, uint32_t _pitch
, const void* _src
- , void* _dst
);
/// Downsample RGBA8 image with 2x2 pixel average filter.
///
+ /// @param[in] _dst Destination image. Must be at least quarter size of
+ /// input image. _dst might be pointer to the same memory as _src.
/// @param[in] _width Width of input image (pixels).
/// @param[in] _height Height of input image (pixels).
/// @param[in] _pitch Pitch of input image (bytes).
/// @param[in] _src Source image.
- /// @param[in] _dst Destination image. Must be at least quarter size of
- /// input image. _dst might be pointer to the same memory as _src.
///
/// @attention C99 equivalent is `bgfx_image_rgba8_downsample_2x2`.
///
void imageRgba8Downsample2x2(
- uint32_t _width
+ void* _dst
+ , uint32_t _width
, uint32_t _height
, uint32_t _pitch
, const void* _src
- , void* _dst
);
/// Returns supported backend API renderers.
@@ -1639,9 +1639,9 @@ namespace bgfx
/// - `BGFX_TEXTURE_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
/// sampling.
///
- /// @param[in] _mem Texture data. If `_mem` is non-NULL, created texture will be immutable.
- /// When `_numLayers` is more than 1, expected memory layout is texture and all mips together
- /// for each array element.
+ /// @param[in] _mem Texture data. If `_mem` is non-NULL, created texture will be immutable. If
+ /// `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than
+ /// 1, expected memory layout is texture and all mips together for each array element.
///
/// @attention C99 equivalent is `bgfx_create_texture_2d`.
///
@@ -1695,7 +1695,8 @@ namespace bgfx
/// - `BGFX_TEXTURE_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
/// sampling.
///
- /// @param[in] _mem Texture data. If `_mem` is non-NULL, created texture will be immutable.
+ /// @param[in] _mem Texture data. If `_mem` is non-NULL, created texture will be immutable. If
+ /// `_mem` is NULL content of the texture is uninitialized.
///
/// @attention C99 equivalent is `bgfx_create_texture_3d`.
///
@@ -1723,9 +1724,9 @@ namespace bgfx
/// - `BGFX_TEXTURE_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
/// sampling.
///
- /// @param[in] _mem Texture data. If `_mem` is non-NULL, created texture will be immutable.
- /// When `_numLayers` is more than 1, expected memory layout is cubemap texture and all mips
- /// together for each array element.
+ /// @param[in] _mem Texture data. If `_mem` is non-NULL, created texture will be immutable. If
+ /// `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than
+ /// 1, expected memory layout is texture and all mips together for each array element.
///
/// @attention C99 equivalent is `bgfx_create_texture_cube`.
///
@@ -1907,7 +1908,7 @@ namespace bgfx
, uint32_t _textureFlags = BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP
);
- /// Create frame buffer.
+ /// Create MRT frame buffer from texture handles (simple).
///
/// @param[in] _num Number of texture attachments.
/// @param[in] _handles Texture attachments.
@@ -1924,7 +1925,8 @@ namespace bgfx
, bool _destroyTextures = false
);
- /// Create frame buffer.
+ /// Create MRT frame buffer from texture handles with specific layer and
+ /// mip level.
///
/// @param[in] _num Number of texture attachments.
/// @param[in] _attachment Attachment texture info. See: `Attachment`.
diff --git a/3rdparty/bgfx/include/bgfx/c99/bgfx.h b/3rdparty/bgfx/include/bgfx/c99/bgfx.h
index 7cc5ee5229d..addf7f7b323 100644
--- a/3rdparty/bgfx/include/bgfx/c99/bgfx.h
+++ b/3rdparty/bgfx/include/bgfx/c99/bgfx.h
@@ -549,10 +549,10 @@ BGFX_C_API uint32_t bgfx_topology_convert(bgfx_topology_convert_t _conversion, v
BGFX_C_API void bgfx_topology_sort_tri_list(bgfx_topology_sort_t _sort, void* _dst, uint32_t _dstSize, const float _dir[3], const float _pos[3], const void* _vertices, uint32_t _stride, const void* _indices, uint32_t _numIndices, bool _index32);
/**/
-BGFX_C_API void bgfx_image_swizzle_bgra8(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst);
+BGFX_C_API void bgfx_image_swizzle_bgra8(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src);
/**/
-BGFX_C_API void bgfx_image_rgba8_downsample_2x2(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst);
+BGFX_C_API void bgfx_image_rgba8_downsample_2x2(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src);
/**/
BGFX_C_API uint8_t bgfx_get_supported_renderers(uint8_t _max, bgfx_renderer_type_t* _enum);
diff --git a/3rdparty/bgfx/include/bgfx/c99/platform.h b/3rdparty/bgfx/include/bgfx/c99/platform.h
index 2422f2422d8..217371bc54b 100644
--- a/3rdparty/bgfx/include/bgfx/c99/platform.h
+++ b/3rdparty/bgfx/include/bgfx/c99/platform.h
@@ -80,8 +80,8 @@ typedef struct bgfx_interface_vtbl
uint16_t (*weld_vertices)(uint16_t* _output, const bgfx_vertex_decl_t* _decl, const void* _data, uint16_t _num, float _epsilon);
uint32_t (*topology_convert)(bgfx_topology_convert_t _conversion, void* _dst, uint32_t _dstSize, const void* _indices, uint32_t _numIndices, bool _index32);
void (*topology_sort_tri_list)(bgfx_topology_sort_t _sort, void* _dst, uint32_t _dstSize, const float _dir[3], const float _pos[3], const void* _vertices, uint32_t _stride, const void* _indices, uint32_t _numIndices, bool _index32);
- void (*image_swizzle_bgra8)(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst);
- void (*image_rgba8_downsample_2x2)(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst);
+ void (*image_swizzle_bgra8)(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src);
+ void (*image_rgba8_downsample_2x2)(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src);
uint8_t (*get_supported_renderers)(uint8_t _max, bgfx_renderer_type_t* _enum);
const char* (*get_renderer_name)(bgfx_renderer_type_t _type);
bool (*init)(bgfx_renderer_type_t _type, uint16_t _vendorId, uint16_t _deviceId, bgfx_callback_interface_t* _callback, bgfx_allocator_interface_t* _allocator);
diff --git a/3rdparty/bgfx/include/bgfx/defines.h b/3rdparty/bgfx/include/bgfx/defines.h
index cc1062845b7..c833856927a 100644
--- a/3rdparty/bgfx/include/bgfx/defines.h
+++ b/3rdparty/bgfx/include/bgfx/defines.h
@@ -6,7 +6,7 @@
#ifndef BGFX_DEFINES_H_HEADER_GUARD
#define BGFX_DEFINES_H_HEADER_GUARD
-#define BGFX_API_VERSION UINT32_C(34)
+#define BGFX_API_VERSION UINT32_C(35)
///
#define BGFX_STATE_RGB_WRITE UINT64_C(0x0000000000000001) //!< Enable RGB write.
diff --git a/3rdparty/bgfx/makefile b/3rdparty/bgfx/makefile
index 4ee32e834c3..d755a10f930 100644
--- a/3rdparty/bgfx/makefile
+++ b/3rdparty/bgfx/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
UNAME := $(shell uname)
diff --git a/3rdparty/bgfx/scripts/bgfx.lua b/3rdparty/bgfx/scripts/bgfx.lua
index 5b0d405770c..f95e99f6d78 100644
--- a/3rdparty/bgfx/scripts/bgfx.lua
+++ b/3rdparty/bgfx/scripts/bgfx.lua
@@ -46,6 +46,10 @@ function bgfxProject(_name, _kind, _defines)
"BGFX_SHARED_LIB_BUILD=1",
}
+ links {
+ "bx",
+ }
+
configuration { "vs20* or mingw*" }
links {
"gdi32",
@@ -75,6 +79,10 @@ function bgfxProject(_name, _kind, _defines)
_defines,
}
+ links {
+ "bx",
+ }
+
if _OPTIONS["with-glfw"] then
defines {
"BGFX_CONFIG_MULTITHREADED=0",
diff --git a/3rdparty/bgfx/scripts/genie.lua b/3rdparty/bgfx/scripts/genie.lua
index c5d5d1d813f..416075b9e00 100644
--- a/3rdparty/bgfx/scripts/genie.lua
+++ b/3rdparty/bgfx/scripts/genie.lua
@@ -142,8 +142,9 @@ function exampleProject(_name)
}
links {
- "bgfx",
"example-common",
+ "bgfx",
+ "bx",
}
if _OPTIONS["with-sdl"] then
@@ -363,6 +364,8 @@ dofile "bgfx.lua"
group "libs"
bgfxProject("", "StaticLib", {})
+dofile(path.join(BX_DIR, "scripts/bx.lua"))
+
if _OPTIONS["with-examples"] or _OPTIONS["with-tools"] then
group "examples"
dofile "example-common.lua"
@@ -401,6 +404,7 @@ if _OPTIONS["with-examples"] then
exampleProject("29-debugdraw")
exampleProject("30-picking")
exampleProject("31-rsm")
+ exampleProject("32-particles")
-- C99 source doesn't compile under WinRT settings
if not premake.vstudio.iswinrt() then
diff --git a/3rdparty/bgfx/scripts/geometryc.lua b/3rdparty/bgfx/scripts/geometryc.lua
index 2663da83d57..902b310caf8 100644
--- a/3rdparty/bgfx/scripts/geometryc.lua
+++ b/3rdparty/bgfx/scripts/geometryc.lua
@@ -25,6 +25,10 @@ project "geometryc"
path.join(BGFX_DIR, "examples/common/bounds.**"),
}
+ links {
+ "bx",
+ }
+
configuration { "mingw-*" }
targetextension ".exe"
diff --git a/3rdparty/bgfx/scripts/shader-embeded.mk b/3rdparty/bgfx/scripts/shader-embeded.mk
index cf949e9bb31..ac9d4d69b4d 100644
--- a/3rdparty/bgfx/scripts/shader-embeded.mk
+++ b/3rdparty/bgfx/scripts/shader-embeded.mk
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
THISDIR:=$(dir $(lastword $(MAKEFILE_LIST)))
@@ -26,6 +26,8 @@ vs_%.bin.h : vs_%.sc
@echo [$(<)]
$(SILENT) $(SHADERC) $(VS_FLAGS) --platform linux -f $(<) -o $(SHADER_TMP) --bin2c $(basename $(<))_glsl
@cat $(SHADER_TMP) > $(@)
+ -$(SILENT) $(SHADERC) $(VS_FLAGS) --platform linux -p spirv -f $(<) -o $(SHADER_TMP) --bin2c $(basename $(<))_spv
+ -@cat $(SHADER_TMP) >> $(@)
-$(SILENT) $(SHADERC) $(VS_FLAGS) --platform windows -p vs_3_0 -O 3 -f $(<) -o $(SHADER_TMP) --bin2c $(basename $(<))_dx9
-@cat $(SHADER_TMP) >> $(@)
-$(SILENT) $(SHADERC) $(VS_FLAGS) --platform windows -p vs_4_0 -O 3 -f $(<) -o $(SHADER_TMP) --bin2c $(basename $(<))_dx11
@@ -39,6 +41,8 @@ fs_%.bin.h : fs_%.sc
@echo [$(<)]
$(SILENT) $(SHADERC) $(FS_FLAGS) --platform linux -f $(<) -o $(SHADER_TMP) --bin2c $(basename $(<))_glsl
@cat $(SHADER_TMP) > $(@)
+ -$(SILENT) $(SHADERC) $(FS_FLAGS) --platform linux -p spirv -f $(<) -o $(SHADER_TMP) --bin2c $(basename $(<))_spv
+ -@cat $(SHADER_TMP) >> $(@)
-$(SILENT) $(SHADERC) $(FS_FLAGS) --platform windows -p ps_3_0 -O 3 -f $(<) -o $(SHADER_TMP) --bin2c $(basename $(<))_dx9
-@cat $(SHADER_TMP) >> $(@)
-$(SILENT) $(SHADERC) $(FS_FLAGS) --platform windows -p ps_4_0 -O 3 -f $(<) -o $(SHADER_TMP) --bin2c $(basename $(<))_dx11
@@ -52,6 +56,8 @@ cs_%.bin.h : cs_%.sc
@echo [$(<)]
$(SILENT) $(SHADERC) $(CS_FLAGS) --platform linux -p 430 -f $(<) -o $(SHADER_TMP) --bin2c $(basename $(<))_glsl
@cat $(SHADER_TMP) > $(@)
+# -$(SILENT) $(SHADERC) $(CS_FLAGS) --platform linux -p spirv -f $(<) -o $(SHADER_TMP) --bin2c $(basename $(<))_spv
+# -@cat $(SHADER_TMP) >> $(@)
-$(SILENT) $(SHADERC) $(CS_FLAGS) --platform windows -p cs_5_0 -O 1 -f $(<) -o $(SHADER_TMP) --bin2c $(basename $(<))_dx11
-@cat $(SHADER_TMP) >> $(@)
-@echo extern const uint8_t* $(basename $(<))_pssl;>> $(@)
diff --git a/3rdparty/bgfx/scripts/shader.mk b/3rdparty/bgfx/scripts/shader.mk
index 56937fb1026..897b280b370 100644
--- a/3rdparty/bgfx/scripts/shader.mk
+++ b/3rdparty/bgfx/scripts/shader.mk
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
THISDIR:=$(dir $(lastword $(MAKEFILE_LIST)))
@@ -23,6 +23,17 @@ all:
@echo " TARGET=5 (metal)"
@echo " TARGET=6 (pssl)"
@echo " TARGET=7 (spriv)"
+
+.PHONY: rebuild
+rebuild:
+ @make -s --no-print-directory TARGET=0 clean all
+ @make -s --no-print-directory TARGET=1 clean all
+ @make -s --no-print-directory TARGET=2 clean all
+ @make -s --no-print-directory TARGET=3 clean all
+ @make -s --no-print-directory TARGET=4 clean all
+ @make -s --no-print-directory TARGET=5 clean all
+ @make -s --no-print-directory TARGET=7 clean all
+
else
ADDITIONAL_INCLUDES?=
diff --git a/3rdparty/bgfx/scripts/shaderc.lua b/3rdparty/bgfx/scripts/shaderc.lua
index 4975e31f288..319062c98fc 100644
--- a/3rdparty/bgfx/scripts/shaderc.lua
+++ b/3rdparty/bgfx/scripts/shaderc.lua
@@ -18,14 +18,17 @@ project "glslang"
configuration { "vs*" }
buildoptions {
"/wd4005", -- warning C4005: '_CRT_SECURE_NO_WARNINGS': macro redefinition
+ "/wd4100", -- error C4100: 'inclusionDepth' : unreferenced formal parameter
}
configuration { "not vs*" }
buildoptions {
+ "-Wno-deprecated-register",
"-Wno-ignored-qualifiers",
"-Wno-inconsistent-missing-override",
"-Wno-missing-field-initializers",
"-Wno-reorder",
+ "-Wno-return-type",
"-Wno-shadow",
"-Wno-sign-compare",
"-Wno-undef",
@@ -46,10 +49,9 @@ project "glslang"
}
configuration {}
-
- flags {
- "Optimize",
- }
+ defines {
+ "ENABLE_HLSL=1",
+ }
includedirs {
GLSLANG,
@@ -98,14 +100,19 @@ project "shaderc"
path.join(GLSL_OPTIMIZER, "src"),
}
- flags {
- "Optimize",
+ links {
+ "bx",
}
- removeflags {
- -- GCC 4.9 -O2 + -fno-strict-aliasing don't work together...
- "OptimizeSpeed",
- }
+ configuration { "Release" }
+ flags {
+ "Optimize",
+ }
+
+ removeflags {
+ -- GCC 4.9 -O2 + -fno-strict-aliasing don't work together...
+ "OptimizeSpeed",
+ }
configuration { "vs*" }
includedirs {
@@ -146,6 +153,11 @@ project "shaderc"
path.join(GLSL_OPTIMIZER, "include/c99"),
}
+ configuration { "vs20* or mingw*" }
+ links {
+ "psapi",
+ }
+
configuration {}
defines { -- fcpp
diff --git a/3rdparty/bgfx/scripts/texturec.lua b/3rdparty/bgfx/scripts/texturec.lua
index aeb22611533..07184ed7d1b 100644
--- a/3rdparty/bgfx/scripts/texturec.lua
+++ b/3rdparty/bgfx/scripts/texturec.lua
@@ -37,6 +37,10 @@ project "texturec"
path.join(BGFX_DIR, "tools/texturec/**.h"),
}
+ links {
+ "bx",
+ }
+
configuration { "mingw-*" }
targetextension ".exe"
@@ -45,4 +49,9 @@ project "texturec"
"Cocoa.framework",
}
+ configuration { "vs20* or mingw*" }
+ links {
+ "psapi",
+ }
+
configuration {}
diff --git a/3rdparty/bgfx/scripts/texturev.lua b/3rdparty/bgfx/scripts/texturev.lua
index 2cfd106a8a7..02103739d31 100644
--- a/3rdparty/bgfx/scripts/texturev.lua
+++ b/3rdparty/bgfx/scripts/texturev.lua
@@ -21,6 +21,7 @@ project ("texturev")
links {
"example-common",
"bgfx",
+ "bx",
}
if _OPTIONS["with-sdl"] then
diff --git a/3rdparty/bgfx/scripts/tools.mk b/3rdparty/bgfx/scripts/tools.mk
index 1c810c0d14d..0cda8ba7c46 100644
--- a/3rdparty/bgfx/scripts/tools.mk
+++ b/3rdparty/bgfx/scripts/tools.mk
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
SILENT?=@
diff --git a/3rdparty/bgfx/src/bgfx.cpp b/3rdparty/bgfx/src/bgfx.cpp
index 08752db59a5..3c008902c1f 100644
--- a/3rdparty/bgfx/src/bgfx.cpp
+++ b/3rdparty/bgfx/src/bgfx.cpp
@@ -116,9 +116,10 @@ namespace bgfx
BX_UNUSED(_filePath, _width, _height, _pitch, _data, _size, _yflip);
#if BX_CONFIG_CRT_FILE_READER_WRITER
- char* filePath = (char*)alloca(strlen(_filePath)+5);
- strcpy(filePath, _filePath);
- strcat(filePath, ".tga");
+ const size_t len = bx::strnlen(_filePath)+5;
+ char* filePath = (char*)alloca(len);
+ bx::strlncpy(filePath, len, _filePath);
+ bx::strlncat(filePath, len, ".tga");
bx::CrtFileWriter writer;
if (bx::open(&writer, filePath) )
@@ -391,7 +392,7 @@ namespace bgfx
if (BX_UNLIKELY(NULL == g_callback) )
{
- dbgPrintfVargs(_format, argList);
+ bx::debugPrintfVargs(_format, argList);
abort();
}
else
@@ -419,7 +420,7 @@ namespace bgfx
if (BX_UNLIKELY(NULL == g_callback) )
{
- dbgPrintfVargs(_format, argList);
+ bx::debugPrintfVargs(_format, argList);
}
else
{
@@ -526,7 +527,7 @@ namespace bgfx
return _default;
}
- if (0 == strncmp(ptr, "0m", 2) )
+ if (0 == bx::strncmp(ptr, "0m", 2) )
{
_ptr = ptr + 2;
return _default;
@@ -544,13 +545,16 @@ namespace bgfx
{
if (_x < m_width && _y < m_height)
{
- char* temp = (char*)alloca(m_width);
-
- uint32_t num = bx::vsnprintf(temp, m_width, _format, _argList);
+ va_list argListCopy;
+ va_copy(argListCopy, _argList);
+ uint32_t num = bx::vsnprintf(NULL, 0, _format, argListCopy) + 1;
+ char* temp = (char*)alloca(num);
+ va_copy(argListCopy, _argList);
+ num = bx::vsnprintf(temp, num, _format, argListCopy);
uint8_t attr = _attr;
uint8_t* mem = &m_mem[(_y*m_width+_x)*2];
- for (uint32_t ii = 0, xx = _x; ii < num && xx < m_width; ++ii, ++xx)
+ for (uint32_t ii = 0, xx = _x; ii < num && xx < m_width; ++ii)
{
char ch = temp[ii];
if (BX_UNLIKELY(ch == '\x1b') )
@@ -564,6 +568,7 @@ namespace bgfx
mem[0] = ch;
mem[1] = attr;
mem += 2;
+ ++xx;
}
}
}
@@ -1067,7 +1072,7 @@ namespace bgfx
void UniformBuffer::writeMarker(const char* _marker)
{
- uint16_t num = (uint16_t)strlen(_marker)+1;
+ uint16_t num = (uint16_t)bx::strnlen(_marker)+1;
uint32_t opcode = encodeOpcode(bgfx::UniformType::Count, 0, num, true);
write(opcode);
write(_marker, num);
@@ -2577,7 +2582,7 @@ namespace bgfx
g_caps.limits.maxDynamicIndexBuffers = BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS;
g_caps.limits.maxDynamicVertexBuffers = BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS;
g_caps.limits.maxUniforms = BGFX_CONFIG_MAX_UNIFORMS;
- g_caps.limits.maxOcclusionQueries = BGFX_CONFIG_MAX_OCCUSION_QUERIES;
+ g_caps.limits.maxOcclusionQueries = BGFX_CONFIG_MAX_OCCLUSION_QUERIES;
g_caps.limits.maxFBAttachments = 1;
g_caps.vendorId = _vendorId;
@@ -3062,8 +3067,8 @@ error:
if (!formatSupported)
{
_err->setError(BGFX_ERROR_TEXTURE_VALIDATION
- , "Texture array is not supported! "
- "Use bgfx::getCaps to check BGFX_CAPS_TEXTURE_2D_ARRAY backend renderer capabilities."
+ , "Texture format is not supported! "
+ "Use bgfx::isTextureValid to check support for texture format before creating it."
);
return;
}
@@ -4067,14 +4072,14 @@ void bgfx_topology_sort_tri_list(bgfx_topology_sort_t _sort, void* _dst, uint32_
bgfx::topologySortTriList(bgfx::TopologySort::Enum(_sort), _dst, _dstSize, _dir, _pos, _vertices, _stride, _indices, _numIndices, _index32);
}
-BGFX_C_API void bgfx_image_swizzle_bgra8(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst)
+BGFX_C_API void bgfx_image_swizzle_bgra8(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src)
{
- bgfx::imageSwizzleBgra8(_width, _height, _pitch, _src, _dst);
+ bgfx::imageSwizzleBgra8(_dst, _width, _height, _pitch, _src);
}
-BGFX_C_API void bgfx_image_rgba8_downsample_2x2(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst)
+BGFX_C_API void bgfx_image_rgba8_downsample_2x2(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src)
{
- bgfx::imageRgba8Downsample2x2(_width, _height, _pitch, _src, _dst);
+ bgfx::imageRgba8Downsample2x2(_dst, _width, _height, _pitch, _src);
}
BGFX_C_API uint8_t bgfx_get_supported_renderers(uint8_t _max, bgfx_renderer_type_t* _enum)
diff --git a/3rdparty/bgfx/src/bgfx_p.h b/3rdparty/bgfx/src/bgfx_p.h
index 2da498f243a..dcef0afdcb3 100644
--- a/3rdparty/bgfx/src/bgfx_p.h
+++ b/3rdparty/bgfx/src/bgfx_p.h
@@ -24,9 +24,6 @@
#include <inttypes.h>
#include <stdarg.h> // va_list
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <alloca.h>
// Check handle, cannot be bgfx::invalidHandle and must be valid.
@@ -86,9 +83,6 @@ namespace bgfx
void trace(const char* _filePath, uint16_t _line, const char* _format, ...);
- void dbgPrintfVargs(const char* _format, va_list _argList);
- void dbgPrintf(const char* _format, ...);
-
inline bool operator==(const VertexDeclHandle& _lhs, const VertexDeclHandle& _rhs) { return _lhs.idx == _rhs.idx; }
inline bool operator==(const UniformHandle& _lhs, const UniformHandle& _rhs) { return _lhs.idx == _rhs.idx; }
}
@@ -293,6 +287,13 @@ namespace bgfx
return UINT64_C(0) == ui64;
}
+ bool isZeroArea() const
+ {
+ return 0 == m_width
+ || 0 == m_height
+ ;
+ }
+
void intersect(const Rect& _a, const Rect& _b)
{
using namespace bx;
@@ -1808,7 +1809,7 @@ namespace bgfx
Matrix4 m_view[BGFX_CONFIG_MAX_VIEWS];
Matrix4 m_proj[2][BGFX_CONFIG_MAX_VIEWS];
uint8_t m_viewFlags[BGFX_CONFIG_MAX_VIEWS];
- uint8_t m_occlusion[BGFX_CONFIG_MAX_OCCUSION_QUERIES];
+ uint8_t m_occlusion[BGFX_CONFIG_MAX_OCCLUSION_QUERIES];
uint64_t m_sortKeys[BGFX_CONFIG_MAX_DRAW_CALLS+1];
RenderItemCount m_sortValues[BGFX_CONFIG_MAX_DRAW_CALLS+1];
@@ -2216,8 +2217,8 @@ namespace bgfx
, _width
, _height
);
- m_resolution.m_width = bx::uint32_min(g_caps.limits.maxTextureSize, _width);
- m_resolution.m_height = bx::uint32_min(g_caps.limits.maxTextureSize, _height);
+ m_resolution.m_width = bx::uint32_clamp(_width, 1, g_caps.limits.maxTextureSize);
+ m_resolution.m_height = bx::uint32_clamp(_height, 1, g_caps.limits.maxTextureSize);
m_resolution.m_flags = 0
| _flags
| (g_platformDataChangedSinceReset ? BGFX_RESET_INTERNAL_FORCE : 0)
@@ -3498,7 +3499,7 @@ namespace bgfx
cmdbuf.write(handle);
cmdbuf.write(uniform.m_type);
cmdbuf.write(uniform.m_num);
- uint8_t len = (uint8_t)strlen(_name)+1;
+ uint8_t len = (uint8_t)bx::strnlen(_name)+1;
cmdbuf.write(len);
cmdbuf.write(_name, len);
}
@@ -3526,7 +3527,7 @@ namespace bgfx
cmdbuf.write(handle);
cmdbuf.write(_type);
cmdbuf.write(_num);
- uint8_t len = (uint8_t)strlen(_name)+1;
+ uint8_t len = (uint8_t)bx::strnlen(_name)+1;
cmdbuf.write(len);
cmdbuf.write(_name, len);
}
@@ -3581,7 +3582,7 @@ namespace bgfx
BGFX_API_FUNC(OcclusionQueryResult::Enum getResult(OcclusionQueryHandle _handle) )
{
- BGFX_CHECK_HANDLE("destroyOcclusionQuery", m_occlusionQueryHandle, _handle);
+ BGFX_CHECK_HANDLE("getResult", m_occlusionQueryHandle, _handle);
switch (m_submit->m_occlusion[_handle.idx])
{
@@ -3602,7 +3603,7 @@ namespace bgfx
BGFX_API_FUNC(void saveScreenShot(const char* _filePath) )
{
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::SaveScreenShot);
- uint16_t len = (uint16_t)strlen(_filePath)+1;
+ uint16_t len = (uint16_t)bx::strnlen(_filePath)+1;
cmdbuf.write(len);
cmdbuf.write(_filePath, len);
}
@@ -3621,7 +3622,7 @@ namespace bgfx
{
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::UpdateViewName);
cmdbuf.write(_id);
- uint16_t len = (uint16_t)strlen(_name)+1;
+ uint16_t len = (uint16_t)bx::strnlen(_name)+1;
cmdbuf.write(len);
cmdbuf.write(_name, len);
}
@@ -4113,7 +4114,7 @@ namespace bgfx
bx::HandleAllocT<BGFX_CONFIG_MAX_TEXTURES> m_textureHandle;
bx::HandleAllocT<BGFX_CONFIG_MAX_FRAME_BUFFERS> m_frameBufferHandle;
bx::HandleAllocT<BGFX_CONFIG_MAX_UNIFORMS> m_uniformHandle;
- bx::HandleAllocT<BGFX_CONFIG_MAX_OCCUSION_QUERIES> m_occlusionQueryHandle;
+ bx::HandleAllocT<BGFX_CONFIG_MAX_OCCLUSION_QUERIES> m_occlusionQueryHandle;
struct ShaderRef
{
diff --git a/3rdparty/bgfx/src/bgfx_shader.sh b/3rdparty/bgfx/src/bgfx_shader.sh
index e7dc8e4a7c6..2cab0ca0d76 100644
--- a/3rdparty/bgfx/src/bgfx_shader.sh
+++ b/3rdparty/bgfx/src/bgfx_shader.sh
@@ -278,9 +278,9 @@ vec4 bgfxTexelFetch(BgfxSampler3D _sampler, ivec3 _coord, int _lod)
# define sampler2DMS BgfxSampler2DMS
# define SAMPLER2DSHADOW(_name, _reg) \
- uniform SamplerComparisonState _name ## Sampler : REGISTER(s, _reg); \
+ uniform SamplerComparisonState _name ## SamplerComparison : REGISTER(s, _reg); \
uniform Texture2D _name ## Texture : REGISTER(t, _reg); \
- static BgfxSampler2DShadow _name = { _name ## Sampler, _name ## Texture }
+ static BgfxSampler2DShadow _name = { _name ## SamplerComparison, _name ## Texture }
# define sampler2DShadow BgfxSampler2DShadow
# define shadow2D(_sampler, _coord) bgfxShadow2D(_sampler, _coord)
# define shadow2DProj(_sampler, _coord) bgfxShadow2DProj(_sampler, _coord)
diff --git a/3rdparty/bgfx/src/config.h b/3rdparty/bgfx/src/config.h
index a14f77f2ad4..6ee68224337 100644
--- a/3rdparty/bgfx/src/config.h
+++ b/3rdparty/bgfx/src/config.h
@@ -297,9 +297,9 @@
# define BGFX_CONFIG_MAX_UNIFORMS 512
#endif // BGFX_CONFIG_MAX_UNIFORMS
-#ifndef BGFX_CONFIG_MAX_OCCUSION_QUERIES
-# define BGFX_CONFIG_MAX_OCCUSION_QUERIES 256
-#endif // BGFX_CONFIG_MAX_OCCUSION_QUERIES
+#ifndef BGFX_CONFIG_MAX_OCCLUSION_QUERIES
+# define BGFX_CONFIG_MAX_OCCLUSION_QUERIES 256
+#endif // BGFX_CONFIG_MAX_OCCLUSION_QUERIES
#ifndef BGFX_CONFIG_MAX_COMMAND_BUFFER_SIZE
# define BGFX_CONFIG_MAX_COMMAND_BUFFER_SIZE (64<<10)
diff --git a/3rdparty/bgfx/src/debug_renderdoc.cpp b/3rdparty/bgfx/src/debug_renderdoc.cpp
index 92522bfd435..a51206b8122 100644
--- a/3rdparty/bgfx/src/debug_renderdoc.cpp
+++ b/3rdparty/bgfx/src/debug_renderdoc.cpp
@@ -43,7 +43,7 @@ namespace bgfx
, BX_COUNTOF(moduleName)
);
if (0 != result
- && 0 == bx::stricmp(_name, moduleName) )
+ && 0 == bx::strincmp(_name, moduleName) )
{
return true;
}
diff --git a/3rdparty/bgfx/src/glcontext_glx.cpp b/3rdparty/bgfx/src/glcontext_glx.cpp
index bfac1ca963b..7afd3ec7c33 100644
--- a/3rdparty/bgfx/src/glcontext_glx.cpp
+++ b/3rdparty/bgfx/src/glcontext_glx.cpp
@@ -155,10 +155,12 @@ namespace bgfx { namespace gl
if (NULL != glXCreateContextAttribsARB)
{
BX_TRACE("Create GL 3.1 context.");
+ int32_t flags = BGFX_CONFIG_DEBUG ? GLX_CONTEXT_DEBUG_BIT_ARB : 0;
const int contextAttrs[] =
{
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
GLX_CONTEXT_MINOR_VERSION_ARB, 1,
+ GLX_CONTEXT_FLAGS_ARB, flags,
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
0,
};
diff --git a/3rdparty/bgfx/src/image.cpp b/3rdparty/bgfx/src/image.cpp
index 7c09b8a7ff4..61cfd413b6d 100644
--- a/3rdparty/bgfx/src/image.cpp
+++ b/3rdparty/bgfx/src/image.cpp
@@ -21,82 +21,82 @@ namespace bgfx
// | | | | | | | | +---+---+---+----- r, g, b, a bits
// | | | | | | | | r g b a +-- encoding type
// | | | | | | | | | | | | |
- { 4, 4, 4, 8, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // BC1
- { 8, 4, 4, 16, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // BC2
- { 8, 4, 4, 16, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // BC3
- { 4, 4, 4, 8, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // BC4
- { 8, 4, 4, 16, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // BC5
- { 8, 4, 4, 16, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // BC6H
- { 8, 4, 4, 16, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // BC7
- { 4, 4, 4, 8, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // ETC1
- { 4, 4, 4, 8, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // ETC2
- { 8, 4, 4, 16, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // ETC2A
- { 4, 4, 4, 8, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // ETC2A1
- { 2, 8, 4, 8, 2, 2, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // PTC12
- { 4, 4, 4, 8, 2, 2, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // PTC14
- { 2, 8, 4, 8, 2, 2, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // PTC12A
- { 4, 4, 4, 8, 2, 2, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // PTC14A
- { 2, 8, 4, 8, 2, 2, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // PTC22
- { 4, 4, 4, 8, 2, 2, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // PTC24
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Count) }, // Unknown
- { 1, 8, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // R1
- { 8, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 8, uint8_t(EncodingType::Unorm) }, // A8
- { 8, 1, 1, 1, 1, 1, 0, 0, 8, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // R8
- { 8, 1, 1, 1, 1, 1, 0, 0, 8, 0, 0, 0, uint8_t(EncodingType::Int ) }, // R8I
- { 8, 1, 1, 1, 1, 1, 0, 0, 8, 0, 0, 0, uint8_t(EncodingType::Uint ) }, // R8U
- { 8, 1, 1, 1, 1, 1, 0, 0, 8, 0, 0, 0, uint8_t(EncodingType::Snorm) }, // R8S
- { 16, 1, 1, 2, 1, 1, 0, 0, 16, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // R16
- { 16, 1, 1, 2, 1, 1, 0, 0, 16, 0, 0, 0, uint8_t(EncodingType::Int ) }, // R16I
- { 16, 1, 1, 2, 1, 1, 0, 0, 16, 0, 0, 0, uint8_t(EncodingType::Uint ) }, // R16U
- { 16, 1, 1, 2, 1, 1, 0, 0, 16, 0, 0, 0, uint8_t(EncodingType::Float) }, // R16F
- { 16, 1, 1, 2, 1, 1, 0, 0, 16, 0, 0, 0, uint8_t(EncodingType::Snorm) }, // R16S
- { 32, 1, 1, 4, 1, 1, 0, 0, 32, 0, 0, 0, uint8_t(EncodingType::Int ) }, // R32I
- { 32, 1, 1, 4, 1, 1, 0, 0, 32, 0, 0, 0, uint8_t(EncodingType::Uint ) }, // R32U
- { 32, 1, 1, 4, 1, 1, 0, 0, 32, 0, 0, 0, uint8_t(EncodingType::Float) }, // R32F
- { 16, 1, 1, 2, 1, 1, 0, 0, 8, 8, 0, 0, uint8_t(EncodingType::Unorm) }, // RG8
- { 16, 1, 1, 2, 1, 1, 0, 0, 8, 8, 0, 0, uint8_t(EncodingType::Int ) }, // RG8I
- { 16, 1, 1, 2, 1, 1, 0, 0, 8, 8, 0, 0, uint8_t(EncodingType::Uint ) }, // RG8U
- { 16, 1, 1, 2, 1, 1, 0, 0, 8, 8, 0, 0, uint8_t(EncodingType::Snorm) }, // RG8S
- { 32, 1, 1, 4, 1, 1, 0, 0, 16, 16, 0, 0, uint8_t(EncodingType::Unorm) }, // RG16
- { 32, 1, 1, 4, 1, 1, 0, 0, 16, 16, 0, 0, uint8_t(EncodingType::Int ) }, // RG16I
- { 32, 1, 1, 4, 1, 1, 0, 0, 16, 16, 0, 0, uint8_t(EncodingType::Uint ) }, // RG16U
- { 32, 1, 1, 4, 1, 1, 0, 0, 16, 16, 0, 0, uint8_t(EncodingType::Float) }, // RG16F
- { 32, 1, 1, 4, 1, 1, 0, 0, 16, 16, 0, 0, uint8_t(EncodingType::Snorm) }, // RG16S
- { 64, 1, 1, 8, 1, 1, 0, 0, 32, 32, 0, 0, uint8_t(EncodingType::Int ) }, // RG32I
- { 64, 1, 1, 8, 1, 1, 0, 0, 32, 32, 0, 0, uint8_t(EncodingType::Uint ) }, // RG32U
- { 64, 1, 1, 8, 1, 1, 0, 0, 32, 32, 0, 0, uint8_t(EncodingType::Float) }, // RG32F
- { 24, 1, 1, 3, 1, 1, 0, 0, 8, 8, 8, 0, uint8_t(EncodingType::Unorm) }, // RGB8
- { 24, 1, 1, 3, 1, 1, 0, 0, 8, 8, 8, 0, uint8_t(EncodingType::Int ) }, // RGB8I
- { 24, 1, 1, 3, 1, 1, 0, 0, 8, 8, 8, 0, uint8_t(EncodingType::Uint ) }, // RGB8U
- { 24, 1, 1, 3, 1, 1, 0, 0, 8, 8, 8, 0, uint8_t(EncodingType::Snorm) }, // RGB8S
- { 32, 1, 1, 4, 1, 1, 0, 0, 9, 9, 9, 5, uint8_t(EncodingType::Float) }, // RGB9E5F
- { 32, 1, 1, 4, 1, 1, 0, 0, 8, 8, 8, 8, uint8_t(EncodingType::Unorm) }, // BGRA8
- { 32, 1, 1, 4, 1, 1, 0, 0, 8, 8, 8, 8, uint8_t(EncodingType::Unorm) }, // RGBA8
- { 32, 1, 1, 4, 1, 1, 0, 0, 8, 8, 8, 8, uint8_t(EncodingType::Int ) }, // RGBA8I
- { 32, 1, 1, 4, 1, 1, 0, 0, 8, 8, 8, 8, uint8_t(EncodingType::Uint ) }, // RGBA8U
- { 32, 1, 1, 4, 1, 1, 0, 0, 8, 8, 8, 8, uint8_t(EncodingType::Snorm) }, // RGBA8S
- { 64, 1, 1, 8, 1, 1, 0, 0, 16, 16, 16, 16, uint8_t(EncodingType::Unorm) }, // RGBA16
- { 64, 1, 1, 8, 1, 1, 0, 0, 16, 16, 16, 16, uint8_t(EncodingType::Int ) }, // RGBA16I
- { 64, 1, 1, 8, 1, 1, 0, 0, 16, 16, 16, 16, uint8_t(EncodingType::Uint ) }, // RGBA16U
- { 64, 1, 1, 8, 1, 1, 0, 0, 16, 16, 16, 16, uint8_t(EncodingType::Float) }, // RGBA16F
- { 64, 1, 1, 8, 1, 1, 0, 0, 16, 16, 16, 16, uint8_t(EncodingType::Snorm) }, // RGBA16S
- { 128, 1, 1, 16, 1, 1, 0, 0, 32, 32, 32, 32, uint8_t(EncodingType::Int ) }, // RGBA32I
- { 128, 1, 1, 16, 1, 1, 0, 0, 32, 32, 32, 32, uint8_t(EncodingType::Uint ) }, // RGBA32U
- { 128, 1, 1, 16, 1, 1, 0, 0, 32, 32, 32, 32, uint8_t(EncodingType::Float) }, // RGBA32F
- { 16, 1, 1, 2, 1, 1, 0, 0, 5, 6, 5, 0, uint8_t(EncodingType::Unorm) }, // R5G6B5
- { 16, 1, 1, 2, 1, 1, 0, 0, 4, 4, 4, 4, uint8_t(EncodingType::Unorm) }, // RGBA4
- { 16, 1, 1, 2, 1, 1, 0, 0, 5, 5, 5, 1, uint8_t(EncodingType::Unorm) }, // RGB5A1
- { 32, 1, 1, 4, 1, 1, 0, 0, 10, 10, 10, 2, uint8_t(EncodingType::Unorm) }, // RGB10A2
- { 32, 1, 1, 4, 1, 1, 0, 0, 11, 11, 10, 0, uint8_t(EncodingType::Unorm) }, // R11G11B10F
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Count) }, // UnknownDepth
- { 16, 1, 1, 2, 1, 1, 16, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // D16
- { 24, 1, 1, 3, 1, 1, 24, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // D24
- { 32, 1, 1, 4, 1, 1, 24, 8, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // D24S8
- { 32, 1, 1, 4, 1, 1, 32, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // D32
- { 16, 1, 1, 2, 1, 1, 16, 0, 0, 0, 0, 0, uint8_t(EncodingType::Float) }, // D16F
- { 24, 1, 1, 3, 1, 1, 24, 0, 0, 0, 0, 0, uint8_t(EncodingType::Float) }, // D24F
- { 32, 1, 1, 4, 1, 1, 32, 0, 0, 0, 0, 0, uint8_t(EncodingType::Float) }, // D32F
- { 8, 1, 1, 1, 1, 1, 0, 8, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // D0S8
+ { 4, 4, 4, 8, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // BC1
+ { 8, 4, 4, 16, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // BC2
+ { 8, 4, 4, 16, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // BC3
+ { 4, 4, 4, 8, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // BC4
+ { 8, 4, 4, 16, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // BC5
+ { 8, 4, 4, 16, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // BC6H
+ { 8, 4, 4, 16, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // BC7
+ { 4, 4, 4, 8, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // ETC1
+ { 4, 4, 4, 8, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // ETC2
+ { 8, 4, 4, 16, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // ETC2A
+ { 4, 4, 4, 8, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // ETC2A1
+ { 2, 8, 4, 8, 2, 2, 0, 0, 0, 0, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // PTC12
+ { 4, 4, 4, 8, 2, 2, 0, 0, 0, 0, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // PTC14
+ { 2, 8, 4, 8, 2, 2, 0, 0, 0, 0, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // PTC12A
+ { 4, 4, 4, 8, 2, 2, 0, 0, 0, 0, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // PTC14A
+ { 2, 8, 4, 8, 2, 2, 0, 0, 0, 0, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // PTC22
+ { 4, 4, 4, 8, 2, 2, 0, 0, 0, 0, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // PTC24
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, uint8_t(bx::EncodingType::Count) }, // Unknown
+ { 1, 8, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // R1
+ { 8, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 8, uint8_t(bx::EncodingType::Unorm) }, // A8
+ { 8, 1, 1, 1, 1, 1, 0, 0, 8, 0, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // R8
+ { 8, 1, 1, 1, 1, 1, 0, 0, 8, 0, 0, 0, uint8_t(bx::EncodingType::Int ) }, // R8I
+ { 8, 1, 1, 1, 1, 1, 0, 0, 8, 0, 0, 0, uint8_t(bx::EncodingType::Uint ) }, // R8U
+ { 8, 1, 1, 1, 1, 1, 0, 0, 8, 0, 0, 0, uint8_t(bx::EncodingType::Snorm) }, // R8S
+ { 16, 1, 1, 2, 1, 1, 0, 0, 16, 0, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // R16
+ { 16, 1, 1, 2, 1, 1, 0, 0, 16, 0, 0, 0, uint8_t(bx::EncodingType::Int ) }, // R16I
+ { 16, 1, 1, 2, 1, 1, 0, 0, 16, 0, 0, 0, uint8_t(bx::EncodingType::Uint ) }, // R16U
+ { 16, 1, 1, 2, 1, 1, 0, 0, 16, 0, 0, 0, uint8_t(bx::EncodingType::Float) }, // R16F
+ { 16, 1, 1, 2, 1, 1, 0, 0, 16, 0, 0, 0, uint8_t(bx::EncodingType::Snorm) }, // R16S
+ { 32, 1, 1, 4, 1, 1, 0, 0, 32, 0, 0, 0, uint8_t(bx::EncodingType::Int ) }, // R32I
+ { 32, 1, 1, 4, 1, 1, 0, 0, 32, 0, 0, 0, uint8_t(bx::EncodingType::Uint ) }, // R32U
+ { 32, 1, 1, 4, 1, 1, 0, 0, 32, 0, 0, 0, uint8_t(bx::EncodingType::Float) }, // R32F
+ { 16, 1, 1, 2, 1, 1, 0, 0, 8, 8, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // RG8
+ { 16, 1, 1, 2, 1, 1, 0, 0, 8, 8, 0, 0, uint8_t(bx::EncodingType::Int ) }, // RG8I
+ { 16, 1, 1, 2, 1, 1, 0, 0, 8, 8, 0, 0, uint8_t(bx::EncodingType::Uint ) }, // RG8U
+ { 16, 1, 1, 2, 1, 1, 0, 0, 8, 8, 0, 0, uint8_t(bx::EncodingType::Snorm) }, // RG8S
+ { 32, 1, 1, 4, 1, 1, 0, 0, 16, 16, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // RG16
+ { 32, 1, 1, 4, 1, 1, 0, 0, 16, 16, 0, 0, uint8_t(bx::EncodingType::Int ) }, // RG16I
+ { 32, 1, 1, 4, 1, 1, 0, 0, 16, 16, 0, 0, uint8_t(bx::EncodingType::Uint ) }, // RG16U
+ { 32, 1, 1, 4, 1, 1, 0, 0, 16, 16, 0, 0, uint8_t(bx::EncodingType::Float) }, // RG16F
+ { 32, 1, 1, 4, 1, 1, 0, 0, 16, 16, 0, 0, uint8_t(bx::EncodingType::Snorm) }, // RG16S
+ { 64, 1, 1, 8, 1, 1, 0, 0, 32, 32, 0, 0, uint8_t(bx::EncodingType::Int ) }, // RG32I
+ { 64, 1, 1, 8, 1, 1, 0, 0, 32, 32, 0, 0, uint8_t(bx::EncodingType::Uint ) }, // RG32U
+ { 64, 1, 1, 8, 1, 1, 0, 0, 32, 32, 0, 0, uint8_t(bx::EncodingType::Float) }, // RG32F
+ { 24, 1, 1, 3, 1, 1, 0, 0, 8, 8, 8, 0, uint8_t(bx::EncodingType::Unorm) }, // RGB8
+ { 24, 1, 1, 3, 1, 1, 0, 0, 8, 8, 8, 0, uint8_t(bx::EncodingType::Int ) }, // RGB8I
+ { 24, 1, 1, 3, 1, 1, 0, 0, 8, 8, 8, 0, uint8_t(bx::EncodingType::Uint ) }, // RGB8U
+ { 24, 1, 1, 3, 1, 1, 0, 0, 8, 8, 8, 0, uint8_t(bx::EncodingType::Snorm) }, // RGB8S
+ { 32, 1, 1, 4, 1, 1, 0, 0, 9, 9, 9, 5, uint8_t(bx::EncodingType::Float) }, // RGB9E5F
+ { 32, 1, 1, 4, 1, 1, 0, 0, 8, 8, 8, 8, uint8_t(bx::EncodingType::Unorm) }, // BGRA8
+ { 32, 1, 1, 4, 1, 1, 0, 0, 8, 8, 8, 8, uint8_t(bx::EncodingType::Unorm) }, // RGBA8
+ { 32, 1, 1, 4, 1, 1, 0, 0, 8, 8, 8, 8, uint8_t(bx::EncodingType::Int ) }, // RGBA8I
+ { 32, 1, 1, 4, 1, 1, 0, 0, 8, 8, 8, 8, uint8_t(bx::EncodingType::Uint ) }, // RGBA8U
+ { 32, 1, 1, 4, 1, 1, 0, 0, 8, 8, 8, 8, uint8_t(bx::EncodingType::Snorm) }, // RGBA8S
+ { 64, 1, 1, 8, 1, 1, 0, 0, 16, 16, 16, 16, uint8_t(bx::EncodingType::Unorm) }, // RGBA16
+ { 64, 1, 1, 8, 1, 1, 0, 0, 16, 16, 16, 16, uint8_t(bx::EncodingType::Int ) }, // RGBA16I
+ { 64, 1, 1, 8, 1, 1, 0, 0, 16, 16, 16, 16, uint8_t(bx::EncodingType::Uint ) }, // RGBA16U
+ { 64, 1, 1, 8, 1, 1, 0, 0, 16, 16, 16, 16, uint8_t(bx::EncodingType::Float) }, // RGBA16F
+ { 64, 1, 1, 8, 1, 1, 0, 0, 16, 16, 16, 16, uint8_t(bx::EncodingType::Snorm) }, // RGBA16S
+ { 128, 1, 1, 16, 1, 1, 0, 0, 32, 32, 32, 32, uint8_t(bx::EncodingType::Int ) }, // RGBA32I
+ { 128, 1, 1, 16, 1, 1, 0, 0, 32, 32, 32, 32, uint8_t(bx::EncodingType::Uint ) }, // RGBA32U
+ { 128, 1, 1, 16, 1, 1, 0, 0, 32, 32, 32, 32, uint8_t(bx::EncodingType::Float) }, // RGBA32F
+ { 16, 1, 1, 2, 1, 1, 0, 0, 5, 6, 5, 0, uint8_t(bx::EncodingType::Unorm) }, // R5G6B5
+ { 16, 1, 1, 2, 1, 1, 0, 0, 4, 4, 4, 4, uint8_t(bx::EncodingType::Unorm) }, // RGBA4
+ { 16, 1, 1, 2, 1, 1, 0, 0, 5, 5, 5, 1, uint8_t(bx::EncodingType::Unorm) }, // RGB5A1
+ { 32, 1, 1, 4, 1, 1, 0, 0, 10, 10, 10, 2, uint8_t(bx::EncodingType::Unorm) }, // RGB10A2
+ { 32, 1, 1, 4, 1, 1, 0, 0, 11, 11, 10, 0, uint8_t(bx::EncodingType::Unorm) }, // R11G11B10F
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, uint8_t(bx::EncodingType::Count) }, // UnknownDepth
+ { 16, 1, 1, 2, 1, 1, 16, 0, 0, 0, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // D16
+ { 24, 1, 1, 3, 1, 1, 24, 0, 0, 0, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // D24
+ { 32, 1, 1, 4, 1, 1, 24, 8, 0, 0, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // D24S8
+ { 32, 1, 1, 4, 1, 1, 32, 0, 0, 0, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // D32
+ { 16, 1, 1, 2, 1, 1, 16, 0, 0, 0, 0, 0, uint8_t(bx::EncodingType::Float) }, // D16F
+ { 24, 1, 1, 3, 1, 1, 24, 0, 0, 0, 0, 0, uint8_t(bx::EncodingType::Float) }, // D24F
+ { 32, 1, 1, 4, 1, 1, 32, 0, 0, 0, 0, 0, uint8_t(bx::EncodingType::Float) }, // D32F
+ { 8, 1, 1, 1, 1, 1, 0, 8, 0, 0, 0, 0, uint8_t(bx::EncodingType::Unorm) }, // D0S8
};
BX_STATIC_ASSERT(TextureFormat::Count == BX_COUNTOF(s_imageBlockInfo) );
@@ -235,7 +235,7 @@ namespace bgfx
const TextureFormat::Enum fmt = TextureFormat::Enum(ii);
if (isValid(fmt) )
{
- if (0 == bx::stricmp(s_textureFormatName[ii], _name) )
+ if (0 == bx::strincmp(s_textureFormatName[ii], _name) )
{
return fmt;
}
@@ -298,7 +298,7 @@ namespace bgfx
return size * _numLayers;
}
- void imageSolid(uint32_t _width, uint32_t _height, uint32_t _solid, void* _dst)
+ void imageSolid(void* _dst, uint32_t _width, uint32_t _height, uint32_t _solid)
{
uint32_t* dst = (uint32_t*)_dst;
for (uint32_t ii = 0, num = _width*_height; ii < num; ++ii)
@@ -307,7 +307,7 @@ namespace bgfx
}
}
- void imageCheckerboard(uint32_t _width, uint32_t _height, uint32_t _step, uint32_t _0, uint32_t _1, void* _dst)
+ void imageCheckerboard(void* _dst, uint32_t _width, uint32_t _height, uint32_t _step, uint32_t _0, uint32_t _1)
{
uint32_t* dst = (uint32_t*)_dst;
for (uint32_t yy = 0; yy < _height; ++yy)
@@ -320,7 +320,7 @@ namespace bgfx
}
}
- void imageRgba8Downsample2x2Ref(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst)
+ void imageRgba8Downsample2x2Ref(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src)
{
const uint32_t dstwidth = _width/2;
const uint32_t dstheight = _height/2;
@@ -371,7 +371,7 @@ namespace bgfx
}
}
- void imageRgba8Downsample2x2(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst)
+ void imageRgba8Downsample2x2(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src)
{
const uint32_t dstwidth = _width/2;
const uint32_t dstheight = _height/2;
@@ -492,7 +492,7 @@ namespace bgfx
}
}
- void imageRgba32fLinearDownsample2x2Ref(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst)
+ void imageRgba32fLinearDownsample2x2Ref(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src)
{
const uint32_t dstwidth = _width/2;
const uint32_t dstheight = _height/2;
@@ -541,12 +541,12 @@ namespace bgfx
}
}
- void imageRgba32fLinearDownsample2x2(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst)
+ void imageRgba32fLinearDownsample2x2(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src)
{
- imageRgba32fLinearDownsample2x2Ref(_width, _height, _pitch, _src, _dst);
+ imageRgba32fLinearDownsample2x2Ref(_dst, _width, _height, _pitch, _src);
}
- void imageRgba32fDownsample2x2NormalMapRef(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst)
+ void imageRgba32fDownsample2x2NormalMapRef(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src)
{
const uint32_t dstwidth = _width/2;
const uint32_t dstheight = _height/2;
@@ -584,12 +584,12 @@ namespace bgfx
}
}
- void imageRgba32fDownsample2x2NormalMap(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst)
+ void imageRgba32fDownsample2x2NormalMap(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src)
{
- imageRgba32fDownsample2x2NormalMapRef(_width, _height, _pitch, _src, _dst);
+ imageRgba32fDownsample2x2NormalMapRef(_dst, _width, _height, _pitch, _src);
}
- void imageSwizzleBgra8Ref(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst)
+ void imageSwizzleBgra8Ref(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src)
{
const uint8_t* src = (uint8_t*) _src;
const uint8_t* next = src + _pitch;
@@ -611,19 +611,19 @@ namespace bgfx
}
}
- void imageSwizzleBgra8(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst)
+ void imageSwizzleBgra8(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src)
{
// Test can we do four 4-byte pixels at the time.
if (0 != (_width&0x3)
|| _width < 4
- || !bx::isPtrAligned(_src, 16)
- || !bx::isPtrAligned(_dst, 16) )
+ || !bx::isAligned(_src, 16)
+ || !bx::isAligned(_dst, 16) )
{
BX_WARN(false, "Image swizzle is taking slow path.");
- BX_WARN(bx::isPtrAligned(_src, 16), "Source %p is not 16-byte aligned.", _src);
- BX_WARN(bx::isPtrAligned(_dst, 16), "Destination %p is not 16-byte aligned.", _dst);
+ BX_WARN(bx::isAligned(_src, 16), "Source %p is not 16-byte aligned.", _src);
+ BX_WARN(bx::isAligned(_dst, 16), "Destination %p is not 16-byte aligned.", _dst);
BX_WARN(_width < 4, "Image width must be multiple of 4 (width %d).", _width);
- imageSwizzleBgra8Ref(_width, _height, _pitch, _src, _dst);
+ imageSwizzleBgra8Ref(_dst, _width, _height, _pitch, _src);
return;
}
@@ -653,7 +653,7 @@ namespace bgfx
}
}
- void imageCopy(uint32_t _height, uint32_t _srcPitch, const void* _src, uint32_t _dstPitch, void* _dst)
+ void imageCopy(void* _dst, uint32_t _height, uint32_t _srcPitch, const void* _src, uint32_t _dstPitch)
{
const uint32_t pitch = bx::uint32_min(_srcPitch, _dstPitch);
const uint8_t* src = (uint8_t*)_src;
@@ -665,1045 +665,109 @@ namespace bgfx
}
}
- void imageCopy(uint32_t _width, uint32_t _height, uint32_t _bpp, uint32_t _pitch, const void* _src, void* _dst)
+ void imageCopy(void* _dst, uint32_t _width, uint32_t _height, uint32_t _bpp, uint32_t _pitch, const void* _src)
{
const uint32_t dstPitch = _width*_bpp/8;
- imageCopy(_height, _pitch, _src, dstPitch, _dst);
- }
-
- uint32_t toUnorm(float _value, float _scale)
- {
- return uint32_t(bx::fround(
- bx::fsaturate(_value) * _scale)
- );
- }
-
- float fromUnorm(uint32_t _value, float _scale)
- {
- return float(_value) / _scale;
- }
-
- int32_t toSnorm(float _value, float _scale)
- {
- return int32_t(bx::fround(
- bx::fclamp(_value, -1.0f, 1.0f) * _scale)
- );
- }
-
- float fromSnorm(int32_t _value, float _scale)
- {
- return bx::fmax(-1.0f, float(_value) / _scale);
- }
-
- // R8
- void packR8(void* _dst, const float* _src)
- {
- uint8_t* dst = (uint8_t*)_dst;
- dst[0] = uint8_t(toUnorm(_src[0], 255.0f) );
- }
-
- void unpackR8(float* _dst, const void* _src)
- {
- const uint8_t* src = (const uint8_t*)_src;
- _dst[0] = fromUnorm(src[0], 255.0f);
- _dst[1] = 0.0f;
- _dst[2] = 0.0f;
- _dst[3] = 1.0f;
- }
-
- // R8S
- void packR8S(void* _dst, const float* _src)
- {
- int8_t* dst = (int8_t*)_dst;
- dst[0] = int8_t(toSnorm(_src[0], 127.0f) );
- }
-
- void unpackR8S(float* _dst, const void* _src)
- {
- const int8_t* src = (const int8_t*)_src;
- _dst[0] = fromSnorm(src[0], 127.0f);
- _dst[1] = 0.0f;
- _dst[2] = 0.0f;
- _dst[3] = 1.0f;
- }
-
- // R8I
- void packR8I(void* _dst, const float* _src)
- {
- int8_t* dst = (int8_t*)_dst;
- dst[0] = int8_t(_src[0]);
- }
-
- void unpackR8I(float* _dst, const void* _src)
- {
- const int8_t* src = (const int8_t*)_src;
- _dst[0] = float(src[0]);
- _dst[1] = 0.0f;
- _dst[2] = 0.0f;
- _dst[3] = 1.0f;
- }
-
- // R8U
- void packR8U(void* _dst, const float* _src)
- {
- uint8_t* dst = (uint8_t*)_dst;
- dst[0] = uint8_t(_src[0]);
- }
-
- void unpackR8U(float* _dst, const void* _src)
- {
- const uint8_t* src = (const uint8_t*)_src;
- _dst[0] = float(src[0]);
- _dst[1] = 0.0f;
- _dst[2] = 0.0f;
- _dst[3] = 1.0f;
- }
-
- // RG8
- void packRg8(void* _dst, const float* _src)
- {
- uint8_t* dst = (uint8_t*)_dst;
- dst[0] = uint8_t(toUnorm(_src[0], 255.0f) );
- dst[1] = uint8_t(toUnorm(_src[1], 255.0f) );
- }
-
- void unpackRg8(float* _dst, const void* _src)
- {
- const uint8_t* src = (const uint8_t*)_src;
- _dst[0] = fromUnorm(src[0], 255.0f);
- _dst[1] = fromUnorm(src[1], 255.0f);
- _dst[2] = 0.0f;
- _dst[3] = 1.0f;
- }
-
- // RG8S
- void packRg8S(void* _dst, const float* _src)
- {
- int8_t* dst = (int8_t*)_dst;
- dst[0] = int8_t(toSnorm(_src[0], 127.0f) );
- dst[1] = int8_t(toSnorm(_src[1], 127.0f) );
- }
-
- void unpackRg8S(float* _dst, const void* _src)
- {
- const int8_t* src = (const int8_t*)_src;
- _dst[0] = fromSnorm(src[0], 127.0f);
- _dst[1] = fromSnorm(src[1], 127.0f);
- _dst[2] = 0.0f;
- _dst[3] = 1.0f;
- }
-
- // RG8I
- void packRg8I(void* _dst, const float* _src)
- {
- int8_t* dst = (int8_t*)_dst;
- dst[0] = int8_t(_src[0]);
- dst[1] = int8_t(_src[1]);
- }
-
- void unpackRg8I(float* _dst, const void* _src)
- {
- const int8_t* src = (const int8_t*)_src;
- _dst[0] = float(src[0]);
- _dst[1] = float(src[1]);
- _dst[2] = 0.0f;
- _dst[3] = 1.0f;
- }
-
- // RG8U
- void packRg8U(void* _dst, const float* _src)
- {
- uint8_t* dst = (uint8_t*)_dst;
- dst[0] = uint8_t(_src[0]);
- dst[1] = uint8_t(_src[1]);
- }
-
- void unpackRg8U(float* _dst, const void* _src)
- {
- const uint8_t* src = (const uint8_t*)_src;
- _dst[0] = float(src[0]);
- _dst[1] = float(src[1]);
- _dst[2] = 0.0f;
- _dst[3] = 1.0f;
- }
-
- // RGB8
- void packRgb8(void* _dst, const float* _src)
- {
- uint8_t* dst = (uint8_t*)_dst;
- dst[0] = uint8_t(toUnorm(_src[0], 255.0f) );
- dst[1] = uint8_t(toUnorm(_src[1], 255.0f) );
- dst[2] = uint8_t(toUnorm(_src[2], 255.0f) );
- }
-
- void unpackRgb8(float* _dst, const void* _src)
- {
- const uint8_t* src = (const uint8_t*)_src;
- _dst[0] = fromUnorm(src[0], 255.0f);
- _dst[1] = fromUnorm(src[1], 255.0f);
- _dst[2] = fromUnorm(src[2], 255.0f);
- _dst[3] = 1.0f;
- }
-
- // RGB8S
- void packRgb8S(void* _dst, const float* _src)
- {
- int8_t* dst = (int8_t*)_dst;
- dst[0] = int8_t(toSnorm(_src[0], 127.0f) );
- dst[1] = int8_t(toSnorm(_src[1], 127.0f) );
- dst[2] = int8_t(toSnorm(_src[2], 127.0f) );
- }
-
- void unpackRgb8S(float* _dst, const void* _src)
- {
- const int8_t* src = (const int8_t*)_src;
- _dst[0] = fromSnorm(src[0], 127.0f);
- _dst[1] = fromSnorm(src[1], 127.0f);
- _dst[2] = fromSnorm(src[2], 127.0f);
- _dst[3] = 1.0f;
- }
-
- // RGB8I
- void packRgb8I(void* _dst, const float* _src)
- {
- int8_t* dst = (int8_t*)_dst;
- dst[0] = int8_t(_src[0]);
- dst[1] = int8_t(_src[1]);
- dst[2] = int8_t(_src[2]);
- }
-
- void unpackRgb8I(float* _dst, const void* _src)
- {
- const int8_t* src = (const int8_t*)_src;
- _dst[0] = float(src[0]);
- _dst[1] = float(src[1]);
- _dst[2] = float(src[2]);
- _dst[3] = 1.0f;
- }
-
- // RGB8U
- void packRgb8U(void* _dst, const float* _src)
- {
- uint8_t* dst = (uint8_t*)_dst;
- dst[0] = uint8_t(_src[0]);
- dst[1] = uint8_t(_src[1]);
- dst[2] = uint8_t(_src[2]);
- }
-
- void unpackRgb8U(float* _dst, const void* _src)
- {
- const uint8_t* src = (const uint8_t*)_src;
- _dst[0] = float(src[0]);
- _dst[1] = float(src[1]);
- _dst[2] = float(src[2]);
- _dst[3] = 1.0f;
- }
-
- // BGRA8
- void packBgra8(void* _dst, const float* _src)
- {
- uint8_t* dst = (uint8_t*)_dst;
- dst[2] = uint8_t(toUnorm(_src[0], 255.0f) );
- dst[1] = uint8_t(toUnorm(_src[1], 255.0f) );
- dst[0] = uint8_t(toUnorm(_src[2], 255.0f) );
- dst[3] = uint8_t(toUnorm(_src[3], 255.0f) );
- }
-
- void unpackBgra8(float* _dst, const void* _src)
- {
- const uint8_t* src = (const uint8_t*)_src;
- _dst[0] = fromUnorm(src[2], 255.0f);
- _dst[1] = fromUnorm(src[1], 255.0f);
- _dst[2] = fromUnorm(src[0], 255.0f);
- _dst[3] = fromUnorm(src[3], 255.0f);
- }
-
- // RGBA8
- void packRgba8(void* _dst, const float* _src)
- {
- uint8_t* dst = (uint8_t*)_dst;
- dst[0] = uint8_t(toUnorm(_src[0], 255.0f) );
- dst[1] = uint8_t(toUnorm(_src[1], 255.0f) );
- dst[2] = uint8_t(toUnorm(_src[2], 255.0f) );
- dst[3] = uint8_t(toUnorm(_src[3], 255.0f) );
- }
-
- void unpackRgba8(float* _dst, const void* _src)
- {
- const uint8_t* src = (const uint8_t*)_src;
- _dst[0] = fromUnorm(src[0], 255.0f);
- _dst[1] = fromUnorm(src[1], 255.0f);
- _dst[2] = fromUnorm(src[2], 255.0f);
- _dst[3] = fromUnorm(src[3], 255.0f);
- }
-
- // RGBA8S
- void packRgba8S(void* _dst, const float* _src)
- {
- int8_t* dst = (int8_t*)_dst;
- dst[0] = int8_t(toSnorm(_src[0], 127.0f) );
- dst[1] = int8_t(toSnorm(_src[1], 127.0f) );
- dst[2] = int8_t(toSnorm(_src[2], 127.0f) );
- dst[3] = int8_t(toSnorm(_src[3], 127.0f) );
- }
-
- void unpackRgba8S(float* _dst, const void* _src)
- {
- const int8_t* src = (const int8_t*)_src;
- _dst[0] = fromSnorm(src[0], 127.0f);
- _dst[1] = fromSnorm(src[1], 127.0f);
- _dst[2] = fromSnorm(src[2], 127.0f);
- _dst[3] = fromSnorm(src[3], 127.0f);
- }
-
- // RGBA8I
- void packRgba8I(void* _dst, const float* _src)
- {
- int8_t* dst = (int8_t*)_dst;
- dst[0] = int8_t(_src[0]);
- dst[1] = int8_t(_src[1]);
- dst[2] = int8_t(_src[2]);
- dst[3] = int8_t(_src[3]);
- }
-
- void unpackRgba8I(float* _dst, const void* _src)
- {
- const int8_t* src = (const int8_t*)_src;
- _dst[0] = float(src[0]);
- _dst[1] = float(src[1]);
- _dst[2] = float(src[2]);
- _dst[3] = float(src[3]);
- }
-
- // RGBA8U
- void packRgba8U(void* _dst, const float* _src)
- {
- uint8_t* dst = (uint8_t*)_dst;
- dst[0] = uint8_t(_src[0]);
- dst[1] = uint8_t(_src[1]);
- dst[2] = uint8_t(_src[2]);
- dst[3] = uint8_t(_src[3]);
- }
-
- void unpackRgba8U(float* _dst, const void* _src)
- {
- const uint8_t* src = (const uint8_t*)_src;
- _dst[0] = float(src[0]);
- _dst[1] = float(src[1]);
- _dst[2] = float(src[2]);
- _dst[3] = float(src[3]);
- }
-
- // R16
- void packR16(void* _dst, const float* _src)
- {
- uint16_t* dst = (uint16_t*)_dst;
- dst[0] = uint16_t(toUnorm(_src[0], 65535.0f) );
- }
-
- void unpackR16(float* _dst, const void* _src)
- {
- const uint16_t* src = (const uint16_t*)_src;
- _dst[0] = fromUnorm(src[0], 65535.0f);
- _dst[1] = 0.0f;
- _dst[2] = 0.0f;
- _dst[3] = 1.0f;
- }
-
- // R16S
- void packR16S(void* _dst, const float* _src)
- {
- int16_t* dst = (int16_t*)_dst;
- dst[0] = int16_t(toSnorm(_src[0], 32767.0f) );
- }
-
- void unpackR16S(float* _dst, const void* _src)
- {
- const int16_t* src = (const int16_t*)_src;
- _dst[0] = fromSnorm(src[0], 32767.0f);
- _dst[1] = 0.0f;
- _dst[2] = 0.0f;
- _dst[3] = 1.0f;
- }
-
- // R16I
- void packR16I(void* _dst, const float* _src)
- {
- int16_t* dst = (int16_t*)_dst;
- dst[0] = int16_t(_src[0]);
- }
-
- void unpackR16I(float* _dst, const void* _src)
- {
- const int16_t* src = (const int16_t*)_src;
- _dst[0] = float(src[0]);
- _dst[1] = 0.0f;
- _dst[2] = 0.0f;
- _dst[3] = 1.0f;
- }
-
- // R16U
- void packR16U(void* _dst, const float* _src)
- {
- uint16_t* dst = (uint16_t*)_dst;
- dst[0] = uint16_t(_src[0]);
- }
-
- void unpackR16U(float* _dst, const void* _src)
- {
- const uint16_t* src = (const uint16_t*)_src;
- _dst[0] = float(src[0]);
- }
-
- // R16F
- void packR16F(void* _dst, const float* _src)
- {
- uint16_t* dst = (uint16_t*)_dst;
- dst[0] = bx::halfFromFloat(_src[0]);
- }
-
- void unpackR16F(float* _dst, const void* _src)
- {
- const uint16_t* src = (const uint16_t*)_src;
- _dst[0] = bx::halfToFloat(src[0]);
- _dst[1] = 0.0f;
- _dst[2] = 0.0f;
- _dst[3] = 1.0f;
- }
-
- // RG16
- void packRg16(void* _dst, const float* _src)
- {
- uint16_t* dst = (uint16_t*)_dst;
- dst[0] = uint16_t(toUnorm(_src[0], 65535.0f) );
- dst[1] = uint16_t(toUnorm(_src[1], 65535.0f) );
- }
-
- void unpackRg16(float* _dst, const void* _src)
- {
- const uint16_t* src = (const uint16_t*)_src;
- _dst[0] = fromUnorm(src[0], 65535.0f);
- _dst[1] = fromUnorm(src[1], 65535.0f);
- _dst[2] = 0.0f;
- _dst[3] = 1.0f;
- }
-
- // RG16S
- void packRg16S(void* _dst, const float* _src)
- {
- int16_t* dst = (int16_t*)_dst;
- dst[0] = int16_t(toSnorm(_src[0], 32767.0f) );
- dst[1] = int16_t(toSnorm(_src[1], 32767.0f) );
- }
-
- void unpackRg16S(float* _dst, const void* _src)
- {
- const int16_t* src = (const int16_t*)_src;
- _dst[0] = fromSnorm(src[0], 32767.0f);
- _dst[1] = fromSnorm(src[1], 32767.0f);
- _dst[2] = 0.0f;
- _dst[3] = 1.0f;
- }
-
- // RG16I
- void packRg16I(void* _dst, const float* _src)
- {
- int16_t* dst = (int16_t*)_dst;
- dst[0] = int16_t(_src[0]);
- dst[1] = int16_t(_src[1]);
- }
-
- void unpackRg16I(float* _dst, const void* _src)
- {
- const int16_t* src = (const int16_t*)_src;
- _dst[0] = float(src[0]);
- _dst[1] = float(src[1]);
- _dst[2] = 0.0f;
- _dst[3] = 1.0f;
- }
-
- // RG16U
- void packRg16U(void* _dst, const float* _src)
- {
- uint16_t* dst = (uint16_t*)_dst;
- dst[0] = uint16_t(_src[0]);
- dst[1] = uint16_t(_src[1]);
- }
-
- void unpackRg16U(float* _dst, const void* _src)
- {
- const uint16_t* src = (const uint16_t*)_src;
- _dst[0] = float(src[0]);
- _dst[1] = float(src[1]);
- _dst[2] = 0.0f;
- _dst[3] = 1.0f;
- }
-
- // RG16F
- void packRg16F(void* _dst, const float* _src)
- {
- uint16_t* dst = (uint16_t*)_dst;
- dst[0] = bx::halfFromFloat(_src[0]);
- dst[1] = bx::halfFromFloat(_src[1]);
- }
-
- void unpackRg16F(float* _dst, const void* _src)
- {
- const uint16_t* src = (const uint16_t*)_src;
- _dst[0] = bx::halfToFloat(src[0]);
- _dst[1] = bx::halfToFloat(src[1]);
- _dst[2] = 0.0f;
- _dst[3] = 1.0f;
- }
-
- // RGBA16
- void packRgba16(void* _dst, const float* _src)
- {
- uint16_t* dst = (uint16_t*)_dst;
- dst[0] = uint16_t(toUnorm(_src[0], 65535.0f) );
- dst[1] = uint16_t(toUnorm(_src[1], 65535.0f) );
- dst[2] = uint16_t(toUnorm(_src[2], 65535.0f) );
- dst[3] = uint16_t(toUnorm(_src[3], 65535.0f) );
- }
-
- void unpackRgba16(float* _dst, const void* _src)
- {
- const uint16_t* src = (const uint16_t*)_src;
- _dst[0] = fromUnorm(src[0], 65535.0f);
- _dst[1] = fromUnorm(src[1], 65535.0f);
- _dst[2] = fromUnorm(src[2], 65535.0f);
- _dst[3] = fromUnorm(src[3], 65535.0f);
- }
-
- // RGBA16S
- void packRgba16S(void* _dst, const float* _src)
- {
- int16_t* dst = (int16_t*)_dst;
- dst[0] = int16_t(toSnorm(_src[0], 32767.0f) );
- dst[1] = int16_t(toSnorm(_src[1], 32767.0f) );
- dst[2] = int16_t(toSnorm(_src[2], 32767.0f) );
- dst[3] = int16_t(toSnorm(_src[3], 32767.0f) );
- }
-
- void unpackRgba16S(float* _dst, const void* _src)
- {
- const int16_t* src = (const int16_t*)_src;
- _dst[0] = fromSnorm(src[0], 32767.0f);
- _dst[1] = fromSnorm(src[1], 32767.0f);
- _dst[2] = fromSnorm(src[2], 32767.0f);
- _dst[3] = fromSnorm(src[3], 32767.0f);
- }
-
- // RGBA16I
- void packRgba16I(void* _dst, const float* _src)
- {
- int16_t* dst = (int16_t*)_dst;
- dst[0] = int16_t(_src[0]);
- dst[1] = int16_t(_src[1]);
- dst[2] = int16_t(_src[2]);
- dst[3] = int16_t(_src[3]);
- }
-
- void unpackRgba16I(float* _dst, const void* _src)
- {
- const int16_t* src = (const int16_t*)_src;
- _dst[0] = float(src[0]);
- _dst[1] = float(src[1]);
- _dst[2] = float(src[2]);
- _dst[3] = float(src[3]);
- }
-
- // RGBA16U
- void packRgba16U(void* _dst, const float* _src)
- {
- uint16_t* dst = (uint16_t*)_dst;
- dst[0] = uint16_t(_src[0]);
- dst[1] = uint16_t(_src[1]);
- dst[2] = uint16_t(_src[2]);
- dst[3] = uint16_t(_src[3]);
- }
-
- void unpackRgba16U(float* _dst, const void* _src)
- {
- const uint16_t* src = (const uint16_t*)_src;
- _dst[0] = float(src[0]);
- _dst[1] = float(src[1]);
- _dst[2] = float(src[2]);
- _dst[3] = float(src[3]);
- }
-
- // RGBA16F
- void packRgba16F(void* _dst, const float* _src)
- {
- uint16_t* dst = (uint16_t*)_dst;
- dst[0] = bx::halfFromFloat(_src[0]);
- dst[1] = bx::halfFromFloat(_src[1]);
- dst[2] = bx::halfFromFloat(_src[2]);
- dst[3] = bx::halfFromFloat(_src[3]);
- }
-
- void unpackRgba16F(float* _dst, const void* _src)
- {
- const uint16_t* src = (const uint16_t*)_src;
- _dst[0] = bx::halfToFloat(src[0]);
- _dst[1] = bx::halfToFloat(src[1]);
- _dst[2] = bx::halfToFloat(src[2]);
- _dst[3] = bx::halfToFloat(src[3]);
- }
-
- // R24
- void packR24(void* _dst, const float* _src)
- {
- uint8_t* dst = (uint8_t*)_dst;
- const uint32_t rr = uint32_t(toUnorm(_src[0], 16777216.0f) );
- dst[0] = uint8_t(rr );
- dst[1] = uint8_t(rr>> 8);
- dst[2] = uint8_t(rr>>16);
- }
-
- void unpackR24(float* _dst, const void* _src)
- {
- const uint8_t* src = (const uint8_t*)_src;
- const uint32_t rr = 0
- | (src[0] )
- | (src[1]<< 8)
- | (src[2]<<16)
- ;
-
- _dst[0] = fromUnorm(rr, 16777216.0f);
- _dst[1] = 0.0f;
- _dst[2] = 0.0f;
- _dst[3] = 1.0f;
- }
-
- // R24G8
- void packR24G8(void* _dst, const float* _src)
- {
- uint8_t* dst = (uint8_t*)_dst;
- const uint32_t rr = uint32_t(toUnorm(_src[0], 16777216.0f) );
- dst[0] = uint8_t(rr );
- dst[1] = uint8_t(rr>> 8);
- dst[2] = uint8_t(rr>>16);
- dst[3] = uint8_t(toUnorm(_src[1], 255.0f) );
- }
-
- void unpackR24G8(float* _dst, const void* _src)
- {
- const uint8_t* src = (const uint8_t*)_src;
- const uint32_t rr = 0
- | (src[0] )
- | (src[1]<< 8)
- | (src[2]<<16)
- ;
-
- _dst[0] = fromUnorm(rr, 16777216.0f);
- _dst[1] = fromUnorm(src[3], 255.0f);
- _dst[2] = 0.0f;
- _dst[3] = 1.0f;
- }
-
- // R32I
- void packR32I(void* _dst, const float* _src)
- {
- memcpy(_dst, _src, 4);
- }
-
- void unpackR32I(float* _dst, const void* _src)
- {
- memcpy(_dst, _src, 4);
- }
-
- // R32U
- void packR32U(void* _dst, const float* _src)
- {
- memcpy(_dst, _src, 4);
- }
-
- void unpackR32U(float* _dst, const void* _src)
- {
- memcpy(_dst, _src, 4);
- }
-
- // R32F
- void packR32F(void* _dst, const float* _src)
- {
- memcpy(_dst, _src, 4);
- }
-
- void unpackR32F(float* _dst, const void* _src)
- {
- memcpy(_dst, _src, 4);
- }
-
- // RG32I
- void packRg32I(void* _dst, const float* _src)
- {
- memcpy(_dst, _src, 8);
- }
-
- void unpackRg32I(float* _dst, const void* _src)
- {
- memcpy(_dst, _src, 8);
- }
-
- // RG32U
- void packRg32U(void* _dst, const float* _src)
- {
- memcpy(_dst, _src, 8);
- }
-
- void unpackRg32U(float* _dst, const void* _src)
- {
- memcpy(_dst, _src, 8);
- }
-
- // RG32F
- void packRg32F(void* _dst, const float* _src)
- {
- memcpy(_dst, _src, 8);
- }
-
- void unpackRg32F(float* _dst, const void* _src)
- {
- memcpy(_dst, _src, 8);
- }
-
- template<int32_t MantissaBits, int32_t ExpBits>
- void encodeRgbE(float* _dst, const float* _src)
- {
- // Reference:
- // https://www.opengl.org/registry/specs/EXT/texture_shared_exponent.txt
- const int32_t expMax = (1<<ExpBits) - 1;
- const int32_t expBias = (1<<(ExpBits - 1) ) - 1;
- const float sharedExpMax = float(expMax) / float(expMax + 1) * float(1 << (expMax - expBias) );
-
- const float rr = bx::fclamp(_src[0], 0.0f, sharedExpMax);
- const float gg = bx::fclamp(_src[1], 0.0f, sharedExpMax);
- const float bb = bx::fclamp(_src[2], 0.0f, sharedExpMax);
- const float max = bx::fmax3(rr, gg, bb);
- union { float ff; uint32_t ui; } cast = { max };
- int32_t expShared = int32_t(bx::uint32_imax(uint32_t(-expBias-1), ( ( (cast.ui>>23) & 0xff) - 127) ) ) + 1 + expBias;
- float denom = bx::fpow(2.0f, float(expShared - expBias - MantissaBits) );
-
- if ( (1<<MantissaBits) == int32_t(bx::fround(max/denom) ) )
- {
- denom *= 2.0f;
- ++expShared;
- }
-
- const float invDenom = 1.0f/denom;
- _dst[0] = bx::fround(rr * invDenom);
- _dst[1] = bx::fround(gg * invDenom);
- _dst[2] = bx::fround(bb * invDenom);
- _dst[3] = float(expShared);
- }
-
- template<int32_t MantissaBits, int32_t ExpBits>
- void decodeRgbE(float* _dst, const float* _src)
- {
- const int32_t expBias = (1<<(ExpBits - 1) ) - 1;
- const float exponent = _src[3]-float(expBias-MantissaBits);
- const float scale = bx::fpow(2.0f, exponent);
- _dst[0] = _src[0] * scale;
- _dst[1] = _src[1] * scale;
- _dst[2] = _src[2] * scale;
- }
-
- // RGB9E5F
- void packRgb9E5F(void* _dst, const float* _src)
- {
- float tmp[4];
- encodeRgbE<9, 5>(tmp, _src);
-
- *( (uint32_t*)_dst) = 0
- | (uint32_t(tmp[0]) )
- | (uint32_t(tmp[1]) << 9)
- | (uint32_t(tmp[2]) <<18)
- | (uint32_t(tmp[3]) <<27)
- ;
- }
-
- void unpackRgb9E5F(float* _dst, const void* _src)
- {
- uint32_t packed = *( (const uint32_t*)_src);
-
- float tmp[4];
- tmp[0] = float( ( (packed ) & 0x1ff) ) / 511.0f;
- tmp[1] = float( ( (packed>> 9) & 0x1ff) ) / 511.0f;
- tmp[2] = float( ( (packed>>18) & 0x1ff) ) / 511.0f;
- tmp[3] = float( ( (packed>>27) & 0x1f) );
-
- decodeRgbE<9, 5>(_dst, tmp);
- }
-
- // RGBA32I
- void packRgba32I(void* _dst, const float* _src)
- {
- memcpy(_dst, _src, 16);
- }
-
- void unpackRgba32I(float* _dst, const void* _src)
- {
- memcpy(_dst, _src, 16);
- }
-
- // RGBA32U
- void packRgba32U(void* _dst, const float* _src)
- {
- memcpy(_dst, _src, 16);
- }
-
- void unpackRgba32U(float* _dst, const void* _src)
- {
- memcpy(_dst, _src, 16);
- }
-
- // RGBA32F
- void packRgba32F(void* _dst, const float* _src)
- {
- memcpy(_dst, _src, 16);
- }
-
- void unpackRgba32F(float* _dst, const void* _src)
- {
- memcpy(_dst, _src, 16);
- }
-
- // R5G6B5
- void packR5G6B5(void* _dst, const float* _src)
- {
- *( (uint16_t*)_dst) = 0
- | uint16_t(toUnorm(_src[0], 31.0f)<<11)
- | uint16_t(toUnorm(_src[1], 63.0f)<< 5)
- | uint16_t(toUnorm(_src[2], 31.0f) )
- ;
- }
-
- void unpackR5G6B5(float* _dst, const void* _src)
- {
- uint16_t packed = *( (const uint16_t*)_src);
- _dst[0] = float( ( (packed>>11) & 0x1f) ) / 31.0f;
- _dst[1] = float( ( (packed>> 5) & 0x3f) ) / 63.0f;
- _dst[2] = float( ( (packed ) & 0x1f) ) / 31.0f;
- _dst[3] = 1.0f;
- }
-
- // RGBA4
- void packRgba4(void* _dst, const float* _src)
- {
- *( (uint16_t*)_dst) = 0
- | uint16_t(toUnorm(_src[0], 15.0f) )
- | uint16_t(toUnorm(_src[1], 15.0f)<< 4)
- | uint16_t(toUnorm(_src[2], 15.0f)<< 8)
- | uint16_t(toUnorm(_src[3], 15.0f)<<12)
- ;
- }
-
- void unpackRgba4(float* _dst, const void* _src)
- {
- uint16_t packed = *( (const uint16_t*)_src);
- _dst[0] = float( ( (packed ) & 0xf) ) / 15.0f;
- _dst[1] = float( ( (packed>> 4) & 0xf) ) / 15.0f;
- _dst[2] = float( ( (packed>> 8) & 0xf) ) / 15.0f;
- _dst[3] = float( ( (packed>>12) & 0xf) ) / 15.0f;
- }
-
- // RGBA4
- void packBgra4(void* _dst, const float* _src)
- {
- *( (uint16_t*)_dst) = 0
- | uint16_t(toUnorm(_src[0], 15.0f)<< 8)
- | uint16_t(toUnorm(_src[1], 15.0f)<< 4)
- | uint16_t(toUnorm(_src[2], 15.0f) )
- | uint16_t(toUnorm(_src[3], 15.0f)<<12)
- ;
- }
-
- void unpackBgra4(float* _dst, const void* _src)
- {
- uint16_t packed = *( (const uint16_t*)_src);
- _dst[0] = float( ( (packed>> 8) & 0xf) ) / 15.0f;
- _dst[1] = float( ( (packed>> 4) & 0xf) ) / 15.0f;
- _dst[2] = float( ( (packed ) & 0xf) ) / 15.0f;
- _dst[3] = float( ( (packed>>12) & 0xf) ) / 15.0f;
- }
-
- // RGB5A1
- void packRgb5a1(void* _dst, const float* _src)
- {
- *( (uint16_t*)_dst) = 0
- | uint16_t(toUnorm(_src[0], 31.0f) )
- | uint16_t(toUnorm(_src[1], 31.0f)<< 5)
- | uint16_t(toUnorm(_src[2], 31.0f)<<10)
- | uint16_t(toUnorm(_src[3], 1.0f)<<15)
- ;
- }
-
- void unpackRgb5a1(float* _dst, const void* _src)
- {
- uint16_t packed = *( (const uint16_t*)_src);
- _dst[0] = float( ( (packed ) & 0x1f) ) / 31.0f;
- _dst[1] = float( ( (packed>> 5) & 0x1f) ) / 31.0f;
- _dst[2] = float( ( (packed>>10) & 0x1f) ) / 31.0f;
- _dst[3] = float( ( (packed>>14) & 0x1) );
- }
-
- // BGR5A1
- void packBgr5a1(void* _dst, const float* _src)
- {
- *( (uint16_t*)_dst) = 0
- | uint16_t(toUnorm(_src[0], 31.0f)<<10)
- | uint16_t(toUnorm(_src[1], 31.0f)<< 5)
- | uint16_t(toUnorm(_src[2], 31.0f) )
- | uint16_t(toUnorm(_src[3], 1.0f)<<15)
- ;
- }
-
- void unpackBgr5a1(float* _dst, const void* _src)
- {
- uint16_t packed = *( (const uint16_t*)_src);
- _dst[0] = float( ( (packed>>10) & 0x1f) ) / 31.0f;
- _dst[1] = float( ( (packed>> 5) & 0x1f) ) / 31.0f;
- _dst[2] = float( ( (packed ) & 0x1f) ) / 31.0f;
- _dst[3] = float( ( (packed>>14) & 0x1) );
- }
-
- // RGB10A2
- void packRgb10A2(void* _dst, const float* _src)
- {
- *( (uint32_t*)_dst) = 0
- | (toUnorm(_src[0], 1023.0f) )
- | (toUnorm(_src[1], 1023.0f)<<10)
- | (toUnorm(_src[2], 1023.0f)<<20)
- | (toUnorm(_src[3], 3.0f)<<30)
- ;
- }
-
- void unpackRgb10A2(float* _dst, const void* _src)
- {
- uint32_t packed = *( (const uint32_t*)_src);
- _dst[0] = float( ( (packed ) & 0x3ff) ) / 1023.0f;
- _dst[1] = float( ( (packed>>10) & 0x3ff) ) / 1023.0f;
- _dst[2] = float( ( (packed>>20) & 0x3ff) ) / 1023.0f;
- _dst[3] = float( ( (packed>>30) & 0x3) ) / 3.0f;
- }
-
- // R11G11B10F
- void packR11G11B10F(void* _dst, const float* _src)
- {
- *( (uint32_t*)_dst) = 0
- | ( (bx::halfFromFloat(_src[0])>> 4) & 0x7ff)
- | ( (bx::halfFromFloat(_src[0])<< 7) & 0x3ff800)
- | ( (bx::halfFromFloat(_src[0])<<17) & 0xffc00000)
- ;
- }
-
- void unpackR11G11B10F(float* _dst, const void* _src)
- {
- uint32_t packed = *( (const uint32_t*)_src);
- _dst[0] = bx::halfToFloat( (packed<< 4) & 0x7ff0);
- _dst[1] = bx::halfToFloat( (packed>> 7) & 0x7ff0);
- _dst[2] = bx::halfToFloat( (packed>>17) & 0x7fe0);
- _dst[3] = 1.0f;
+ imageCopy(_dst, _height, _pitch, _src, dstPitch);
}
struct PackUnpack
{
- PackFn pack;
- UnpackFn unpack;
+ bx::PackFn pack;
+ bx::UnpackFn unpack;
};
static const PackUnpack s_packUnpack[] =
{
- { NULL, NULL }, // BC1
- { NULL, NULL }, // BC2
- { NULL, NULL }, // BC3
- { NULL, NULL }, // BC4
- { NULL, NULL }, // BC5
- { NULL, NULL }, // BC6H
- { NULL, NULL }, // BC7
- { NULL, NULL }, // ETC1
- { NULL, NULL }, // ETC2
- { NULL, NULL }, // ETC2A
- { NULL, NULL }, // ETC2A1
- { NULL, NULL }, // PTC12
- { NULL, NULL }, // PTC14
- { NULL, NULL }, // PTC12A
- { NULL, NULL }, // PTC14A
- { NULL, NULL }, // PTC22
- { NULL, NULL }, // PTC24
- { NULL, NULL }, // Unknown
- { NULL, NULL }, // R1
- { packR8, unpackR8 }, // A8
- { packR8, unpackR8 }, // R8
- { packR8I, unpackR8I }, // R8I
- { packR8U, unpackR8U }, // R8U
- { packR8S, unpackR8S }, // R8S
- { packR16, unpackR16 }, // R16
- { packR16I, unpackR16I }, // R16I
- { packR16U, unpackR16U }, // R16U
- { packR16F, unpackR16F }, // R16F
- { packR16S, unpackR16S }, // R16S
- { packR32I, unpackR32I }, // R32I
- { packR32U, unpackR32U }, // R32U
- { packR32F, unpackR32F }, // R32F
- { packRg8, unpackRg8 }, // RG8
- { packRg8I, unpackRg8I }, // RG8I
- { packRg8U, unpackRg8U }, // RG8U
- { packRg8S, unpackRg8S }, // RG8S
- { packRg16, unpackRg16 }, // RG16
- { packRg16I, unpackRg16I }, // RG16I
- { packRg16U, unpackRg16U }, // RG16U
- { packRg16F, unpackRg16F }, // RG16F
- { packRg16S, unpackRg16S }, // RG16S
- { packRg32I, unpackRg32I }, // RG32I
- { packRg32U, unpackRg32U }, // RG32U
- { packRg32F, unpackRg32F }, // RG32F
- { packRgb8, unpackRgb8 }, // RGB8
- { packRgb8S, unpackRgb8S }, // RGB8S
- { packRgb8I, unpackRgb8I }, // RGB8I
- { packRgb8U, unpackRgb8U }, // RGB8U
- { packRgb9E5F, unpackRgb9E5F }, // RGB9E5F
- { packBgra8, unpackBgra8 }, // BGRA8
- { packRgba8, unpackRgba8 }, // RGBA8
- { packRgba8I, unpackRgba8I }, // RGBA8I
- { packRgba8U, unpackRgba8U }, // RGBA8U
- { packRgba8S, unpackRgba8S }, // RGBA8S
- { packRgba16, unpackRgba16 }, // RGBA16
- { packRgba16I, unpackRgba16I }, // RGBA16I
- { packRgba16U, unpackRgba16U }, // RGBA16U
- { packRgba16F, unpackRgba16F }, // RGBA16F
- { packRgba16S, unpackRgba16S }, // RGBA16S
- { packRgba32I, unpackRgba32I }, // RGBA32I
- { packRgba32U, unpackRgba32U }, // RGBA32U
- { packRgba32F, unpackRgba32F }, // RGBA32F
- { packR5G6B5, unpackR5G6B5 }, // R5G6B5
- { packRgba4, unpackRgba4 }, // RGBA4
- { packRgb5a1, unpackRgb5a1 }, // RGB5A1
- { packRgb10A2, unpackRgb10A2 }, // RGB10A2
- { packR11G11B10F, unpackR11G11B10F }, // R11G11B10F
- { NULL, NULL }, // UnknownDepth
- { packR16, unpackR16 }, // D16
- { packR24, unpackR24 }, // D24
- { packR24G8, unpackR24G8 }, // D24S8
- { NULL, NULL }, // D32
- { packR16F, unpackR16F }, // D16F
- { NULL, NULL }, // D24F
- { packR32F, unpackR32F }, // D32F
- { packR8, unpackR8 }, // D0S8
+ { NULL, NULL }, // BC1
+ { NULL, NULL }, // BC2
+ { NULL, NULL }, // BC3
+ { NULL, NULL }, // BC4
+ { NULL, NULL }, // BC5
+ { NULL, NULL }, // BC6H
+ { NULL, NULL }, // BC7
+ { NULL, NULL }, // ETC1
+ { NULL, NULL }, // ETC2
+ { NULL, NULL }, // ETC2A
+ { NULL, NULL }, // ETC2A1
+ { NULL, NULL }, // PTC12
+ { NULL, NULL }, // PTC14
+ { NULL, NULL }, // PTC12A
+ { NULL, NULL }, // PTC14A
+ { NULL, NULL }, // PTC22
+ { NULL, NULL }, // PTC24
+ { NULL, NULL }, // Unknown
+ { NULL, NULL }, // R1
+ { bx::packR8, bx::unpackR8 }, // A8
+ { bx::packR8, bx::unpackR8 }, // R8
+ { bx::packR8I, bx::unpackR8I }, // R8I
+ { bx::packR8U, bx::unpackR8U }, // R8U
+ { bx::packR8S, bx::unpackR8S }, // R8S
+ { bx::packR16, bx::unpackR16 }, // R16
+ { bx::packR16I, bx::unpackR16I }, // R16I
+ { bx::packR16U, bx::unpackR16U }, // R16U
+ { bx::packR16F, bx::unpackR16F }, // R16F
+ { bx::packR16S, bx::unpackR16S }, // R16S
+ { bx::packR32I, bx::unpackR32I }, // R32I
+ { bx::packR32U, bx::unpackR32U }, // R32U
+ { bx::packR32F, bx::unpackR32F }, // R32F
+ { bx::packRg8, bx::unpackRg8 }, // RG8
+ { bx::packRg8I, bx::unpackRg8I }, // RG8I
+ { bx::packRg8U, bx::unpackRg8U }, // RG8U
+ { bx::packRg8S, bx::unpackRg8S }, // RG8S
+ { bx::packRg16, bx::unpackRg16 }, // RG16
+ { bx::packRg16I, bx::unpackRg16I }, // RG16I
+ { bx::packRg16U, bx::unpackRg16U }, // RG16U
+ { bx::packRg16F, bx::unpackRg16F }, // RG16F
+ { bx::packRg16S, bx::unpackRg16S }, // RG16S
+ { bx::packRg32I, bx::unpackRg32I }, // RG32I
+ { bx::packRg32U, bx::unpackRg32U }, // RG32U
+ { bx::packRg32F, bx::unpackRg32F }, // RG32F
+ { bx::packRgb8, bx::unpackRgb8 }, // RGB8
+ { bx::packRgb8S, bx::unpackRgb8S }, // RGB8S
+ { bx::packRgb8I, bx::unpackRgb8I }, // RGB8I
+ { bx::packRgb8U, bx::unpackRgb8U }, // RGB8U
+ { bx::packRgb9E5F, bx::unpackRgb9E5F }, // RGB9E5F
+ { bx::packBgra8, bx::unpackBgra8 }, // BGRA8
+ { bx::packRgba8, bx::unpackRgba8 }, // RGBA8
+ { bx::packRgba8I, bx::unpackRgba8I }, // RGBA8I
+ { bx::packRgba8U, bx::unpackRgba8U }, // RGBA8U
+ { bx::packRgba8S, bx::unpackRgba8S }, // RGBA8S
+ { bx::packRgba16, bx::unpackRgba16 }, // RGBA16
+ { bx::packRgba16I, bx::unpackRgba16I }, // RGBA16I
+ { bx::packRgba16U, bx::unpackRgba16U }, // RGBA16U
+ { bx::packRgba16F, bx::unpackRgba16F }, // RGBA16F
+ { bx::packRgba16S, bx::unpackRgba16S }, // RGBA16S
+ { bx::packRgba32I, bx::unpackRgba32I }, // RGBA32I
+ { bx::packRgba32U, bx::unpackRgba32U }, // RGBA32U
+ { bx::packRgba32F, bx::unpackRgba32F }, // RGBA32F
+ { bx::packR5G6B5, bx::unpackR5G6B5 }, // R5G6B5
+ { bx::packRgba4, bx::unpackRgba4 }, // RGBA4
+ { bx::packRgb5a1, bx::unpackRgb5a1 }, // RGB5A1
+ { bx::packRgb10A2, bx::unpackRgb10A2 }, // RGB10A2
+ { bx::packR11G11B10F, bx::unpackR11G11B10F }, // R11G11B10F
+ { NULL, NULL }, // UnknownDepth
+ { bx::packR16, bx::unpackR16 }, // D16
+ { bx::packR24, bx::unpackR24 }, // D24
+ { bx::packR24G8, bx::unpackR24G8 }, // D24S8
+ { NULL, NULL }, // D32
+ { bx::packR16F, bx::unpackR16F }, // D16F
+ { NULL, NULL }, // D24F
+ { bx::packR32F, bx::unpackR32F }, // D32F
+ { bx::packR8, bx::unpackR8 }, // D0S8
};
- BX_STATIC_ASSERT(TextureFormat::Count == BX_COUNTOF(s_packUnpack) );
+ BX_STATIC_ASSERT(TextureFormat::Count == BX_COUNTOF(s_packUnpack) );
bool imageConvert(TextureFormat::Enum _dstFormat, TextureFormat::Enum _srcFormat)
{
- UnpackFn unpack = s_packUnpack[_srcFormat].unpack;
- PackFn pack = s_packUnpack[_dstFormat].pack;
+ bx::UnpackFn unpack = s_packUnpack[_srcFormat].unpack;
+ bx::PackFn pack = s_packUnpack[_dstFormat].pack;
return NULL != pack
&& NULL != unpack
;
}
- void imageConvert(void* _dst, uint32_t _bpp, PackFn _pack, const void* _src, UnpackFn _unpack, uint32_t _size)
+ void imageConvert(void* _dst, uint32_t _bpp, bx::PackFn _pack, const void* _src, bx::UnpackFn _unpack, uint32_t _size)
{
const uint8_t* src = (uint8_t*)_src;
uint8_t* dst = (uint8_t*)_dst;
@@ -1718,7 +782,7 @@ namespace bgfx
}
}
- void imageConvert(void* _dst, uint32_t _dstBpp, PackFn _pack, const void* _src, uint32_t _srcBpp, UnpackFn _unpack, uint32_t _width, uint32_t _height, uint32_t _srcPitch)
+ void imageConvert(void* _dst, uint32_t _dstBpp, bx::PackFn _pack, const void* _src, uint32_t _srcBpp, bx::UnpackFn _unpack, uint32_t _width, uint32_t _height, uint32_t _srcPitch)
{
const uint8_t* src = (uint8_t*)_src;
uint8_t* dst = (uint8_t*)_dst;
@@ -1738,8 +802,8 @@ namespace bgfx
bool imageConvert(void* _dst, TextureFormat::Enum _dstFormat, const void* _src, TextureFormat::Enum _srcFormat, uint32_t _width, uint32_t _height, uint32_t _srcPitch)
{
- UnpackFn unpack = s_packUnpack[_srcFormat].unpack;
- PackFn pack = s_packUnpack[_dstFormat].pack;
+ bx::UnpackFn unpack = s_packUnpack[_srcFormat].unpack;
+ bx::PackFn pack = s_packUnpack[_dstFormat].pack;
if (NULL == pack
|| NULL == unpack)
{
@@ -3591,22 +2655,22 @@ namespace bgfx
case TextureFormat::ETC2A:
BX_WARN(false, "ETC2A decoder is not implemented.");
- imageCheckerboard(_width, _height, 16, UINT32_C(0xff000000), UINT32_C(0xff00ff00), _dst);
+ imageCheckerboard(_dst, _width, _height, 16, UINT32_C(0xff000000), UINT32_C(0xff00ff00) );
break;
case TextureFormat::ETC2A1:
BX_WARN(false, "ETC2A1 decoder is not implemented.");
- imageCheckerboard(_width, _height, 16, UINT32_C(0xff000000), UINT32_C(0xffff0000), _dst);
+ imageCheckerboard(_dst, _width, _height, 16, UINT32_C(0xff000000), UINT32_C(0xffff0000) );
break;
case TextureFormat::PTC12:
BX_WARN(false, "PTC12 decoder is not implemented.");
- imageCheckerboard(_width, _height, 16, UINT32_C(0xff000000), UINT32_C(0xffff00ff), _dst);
+ imageCheckerboard(_dst, _width, _height, 16, UINT32_C(0xff000000), UINT32_C(0xffff00ff) );
break;
case TextureFormat::PTC12A:
BX_WARN(false, "PTC12A decoder is not implemented.");
- imageCheckerboard(_width, _height, 16, UINT32_C(0xff000000), UINT32_C(0xffffff00), _dst);
+ imageCheckerboard(_dst, _width, _height, 16, UINT32_C(0xff000000), UINT32_C(0xffffff00) );
break;
case TextureFormat::PTC14:
@@ -3643,16 +2707,16 @@ namespace bgfx
case TextureFormat::PTC22:
BX_WARN(false, "PTC22 decoder is not implemented.");
- imageCheckerboard(_width, _height, 16, UINT32_C(0xff00ff00), UINT32_C(0xff0000ff), _dst);
+ imageCheckerboard(_dst, _width, _height, 16, UINT32_C(0xff00ff00), UINT32_C(0xff0000ff) );
break;
case TextureFormat::PTC24:
BX_WARN(false, "PTC24 decoder is not implemented.");
- imageCheckerboard(_width, _height, 16, UINT32_C(0xff000000), UINT32_C(0xffffffff), _dst);
+ imageCheckerboard(_dst, _width, _height, 16, UINT32_C(0xff000000), UINT32_C(0xffffffff) );
break;
case TextureFormat::RGBA8:
- imageSwizzleBgra8(_width, _height, _pitch, _src, _dst);
+ imageSwizzleBgra8(_dst, _width, _height, _pitch, _src);
break;
case TextureFormat::BGRA8:
@@ -3666,7 +2730,7 @@ namespace bgfx
if (!imageConvert(_dst, TextureFormat::BGRA8, _src, _format, _width, _height, srcPitch) )
{
// Failed to convert, just make ugly red-yellow checkerboard texture.
- imageCheckerboard(_width, _height, 16, UINT32_C(0xffff0000), UINT32_C(0xffffff00), _dst);
+ imageCheckerboard(_dst, _width, _height, 16, UINT32_C(0xffff0000), UINT32_C(0xffffff00) );
}
}
break;
@@ -3682,12 +2746,12 @@ namespace bgfx
break;
case TextureFormat::BGRA8:
- imageSwizzleBgra8(_width, _height, _pitch, _src, _dst);
+ imageSwizzleBgra8(_dst, _width, _height, _pitch, _src);
break;
default:
imageDecodeToBgra8(_dst, _src, _width, _height, _pitch, _format);
- imageSwizzleBgra8(_width, _height, _width*4, _dst, _dst);
+ imageSwizzleBgra8(_dst, _width, _height, _width*4, _dst);
break;
}
}
diff --git a/3rdparty/bgfx/src/image.h b/3rdparty/bgfx/src/image.h
index d998a4bd722..7d708ccb8b0 100644
--- a/3rdparty/bgfx/src/image.h
+++ b/3rdparty/bgfx/src/image.h
@@ -7,6 +7,7 @@
#define BGFX_IMAGE_H_HEADER_GUARD
#include <stdint.h>
+#include <bx/pixelformat.h>
namespace bgfx
{
@@ -40,20 +41,6 @@ namespace bgfx
const uint8_t* m_data;
};
- struct EncodingType
- {
- enum Enum
- {
- Unorm,
- Int,
- Uint,
- Float,
- Snorm,
-
- Count
- };
- };
-
struct ImageBlockInfo
{
uint8_t bitsPerPixel;
@@ -71,205 +58,6 @@ namespace bgfx
uint8_t encoding;
};
- typedef void (*PackFn)(void*, const float*);
- typedef void (*UnpackFn)(float*, const void*);
-
- // R8
- void packR8(void* _dst, const float* _src);
- void unpackR8(float* _dst, const void* _src);
-
- // R8S
- void packR8S(void* _dst, const float* _src);
- void unpackR8S(float* _dst, const void* _src);
-
- // R8I
- void packR8I(void* _dst, const float* _src);
- void unpackR8I(float* _dst, const void* _src);
-
- // R8U
- void packR8U(void* _dst, const float* _src);
- void unpackR8U(float* _dst, const void* _src);
-
- // RG8
- void packRg8(void* _dst, const float* _src);
- void unpackRg8(float* _dst, const void* _src);
-
- // RG8S
- void packRg8S(void* _dst, const float* _src);
- void unpackRg8S(float* _dst, const void* _src);
-
- // RG8I
- void packRg8I(void* _dst, const float* _src);
- void unpackRg8I(float* _dst, const void* _src);
-
- // RG8U
- void packRg8U(void* _dst, const float* _src);
- void unpackRg8U(float* _dst, const void* _src);
-
- // RGB8
- void packRgb8(void* _dst, const float* _src);
- void unpackRgb8(float* _dst, const void* _src);
-
- // RGB8S
- void packRgb8S(void* _dst, const float* _src);
- void unpackRgb8S(float* _dst, const void* _src);
-
- // RGB8I
- void packRgb8I(void* _dst, const float* _src);
- void unpackRgb8I(float* _dst, const void* _src);
-
- // RGB8U
- void packRgb8U(void* _dst, const float* _src);
- void unpackRgb8U(float* _dst, const void* _src);
-
- // RGBA8
- void packRgba8(void* _dst, const float* _src);
- void unpackRgba8(float* _dst, const void* _src);
-
- // BGRA8
- void packBgra8(void* _dst, const float* _src);
- void unpackBgra8(float* _dst, const void* _src);
-
- // RGBA8S
- void packRgba8S(void* _dst, const float* _src);
- void unpackRgba8S(float* _dst, const void* _src);
-
- // RGBA8I
- void packRgba8I(void* _dst, const float* _src);
- void unpackRgba8I(float* _dst, const void* _src);
-
- // RGBA8U
- void packRgba8U(void* _dst, const float* _src);
- void unpackRgba8U(float* _dst, const void* _src);
-
- // R16
- void packR16(void* _dst, const float* _src);
- void unpackR16(float* _dst, const void* _src);
-
- // R16S
- void packR16S(void* _dst, const float* _src);
- void unpackR16S(float* _dst, const void* _src);
-
- // R16I
- void packR16I(void* _dst, const float* _src);
- void unpackR16I(float* _dst, const void* _src);
-
- // R16U
- void packR16U(void* _dst, const float* _src);
- void unpackR16U(float* _dst, const void* _src);
-
- // R16F
- void packR16F(void* _dst, const float* _src);
- void unpackR16F(float* _dst, const void* _src);
-
- // RG16
- void packRg16(void* _dst, const float* _src);
- void unpackRg16(float* _dst, const void* _src);
-
- // RG16S
- void packRg16S(void* _dst, const float* _src);
- void unpackRg16S(float* _dst, const void* _src);
-
- // RG16I
- void packRg16I(void* _dst, const float* _src);
- void unpackRg16I(float* _dst, const void* _src);
-
- // RG16U
- void packRg16U(void* _dst, const float* _src);
- void unpackRg16U(float* _dst, const void* _src);
-
- // RG16F
- void packRg16F(void* _dst, const float* _src);
- void unpackRg16F(float* _dst, const void* _src);
-
- // RGBA16
- void packRgba16(void* _dst, const float* _src);
- void unpackRgba16(float* _dst, const void* _src);
-
- // RGBA16S
- void packRgba16S(void* _dst, const float* _src);
- void unpackRgba16S(float* _dst, const void* _src);
-
- // RGBA16I
- void packRgba16I(void* _dst, const float* _src);
- void unpackRgba16I(float* _dst, const void* _src);
-
- // RGBA16U
- void packRgba16U(void* _dst, const float* _src);
- void unpackRgba16U(float* _dst, const void* _src);
-
- // RGBA16F
- void packRgba16F(void* _dst, const float* _src);
- void unpackRgba16F(float* _dst, const void* _src);
-
- // R32I
- void packR32I(void* _dst, const float* _src);
- void unpackR32I(float* _dst, const void* _src);
-
- // R32U
- void packR32U(void* _dst, const float* _src);
- void unpackR32U(float* _dst, const void* _src);
-
- // R32F
- void packR32F(void* _dst, const float* _src);
- void unpackR32F(float* _dst, const void* _src);
-
- // RG32I
- void packRg32I(void* _dst, const float* _src);
- void unpackRg32I(float* _dst, const void* _src);
-
- // RG32U
- void packRg32U(void* _dst, const float* _src);
- void unpackRg32U(float* _dst, const void* _src);
-
- // RGB9E5F
- void packRgb9E5F(void* _dst, const float* _src);
- void unpackRgb9E5F(float* _dst, const void* _src);
-
- // RGBA32I
- void packRgba32I(void* _dst, const float* _src);
- void unpackRgba32I(float* _dst, const void* _src);
-
- // RGBA32U
- void packRgba32U(void* _dst, const float* _src);
- void unpackRgba32U(float* _dst, const void* _src);
-
- // RGBA32F
- void packRgba32F(void* _dst, const float* _src);
- void unpackRgba32F(float* _dst, const void* _src);
-
- // R5G6B5
- void packR5G6B5(void* _dst, const float* _src);
- void unpackR5G6B5(float* _dst, const void* _src);
-
- // RGBA4
- void packRgba4(void* _dst, const float* _src);
- void unpackRgba4(float* _dst, const void* _src);
-
- // RGBA4
- void packBgra4(void* _dst, const float* _src);
- void unpackBgra4(float* _dst, const void* _src);
-
- // RGB5A1
- void packRgb5a1(void* _dst, const float* _src);
- void unpackRgb5a1(float* _dst, const void* _src);
-
- // BGR5A1
- void packBgr5a1(void* _dst, const float* _src);
- void unpackBgr5a1(float* _dst, const void* _src);
-
- // RGB10A2
- void packRgb10A2(void* _dst, const float* _src);
- void unpackRgb10A2(float* _dst, const void* _src);
-
- // R11G11B10F
- void packR11G11B10F(void* _dst, const float* _src);
- void unpackR11G11B10F(float* _dst, const void* _src);
-
- // RG32F
- void packRg32F(void* _dst, const float* _src);
- void unpackRg32F(float* _dst, const void* _src);
-
/// Returns true if texture format is compressed.
bool isCompressed(TextureFormat::Enum _format);
@@ -314,13 +102,13 @@ namespace bgfx
);
///
- void imageSolid(uint32_t _width, uint32_t _height, uint32_t _solid, void* _dst);
+ void imageSolid(void* _dst, uint32_t _width, uint32_t _height, uint32_t _solid);
///
- void imageCheckerboard(uint32_t _width, uint32_t _height, uint32_t _step, uint32_t _0, uint32_t _1, void* _dst);
+ void imageCheckerboard(void* _dst, uint32_t _width, uint32_t _height, uint32_t _step, uint32_t _0, uint32_t _1);
///
- void imageRgba8Downsample2x2(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst);
+ void imageRgba8Downsample2x2(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src);
///
void imageRgba32fToLinear(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src);
@@ -329,28 +117,28 @@ namespace bgfx
void imageRgba32fToGamma(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src);
///
- void imageRgba32fLinearDownsample2x2(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst);
+ void imageRgba32fLinearDownsample2x2(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src);
///
- void imageRgba32fDownsample2x2NormalMap(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst);
+ void imageRgba32fDownsample2x2NormalMap(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src);
///
- void imageSwizzleBgra8(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst);
+ void imageSwizzleBgra8(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src);
///
- void imageCopy(uint32_t _height, uint32_t _srcPitch, const void* _src, uint32_t _dstPitch, void* _dst);
+ void imageCopy(void* _dst, uint32_t _height, uint32_t _srcPitch, const void* _src, uint32_t _dstPitch);
///
- void imageCopy(uint32_t _width, uint32_t _height, uint32_t _bpp, uint32_t _pitch, const void* _src, void* _dst);
+ void imageCopy(void* _dst, uint32_t _width, uint32_t _height, uint32_t _bpp, uint32_t _pitch, const void* _src);
///
bool imageConvert(TextureFormat::Enum _dstFormat, TextureFormat::Enum _srcFormat);
///
- void imageConvert(void* _dst, uint32_t _bpp, PackFn _pack, const void* _src, UnpackFn _unpack, uint32_t _size);
+ void imageConvert(void* _dst, uint32_t _bpp, bx::PackFn _pack, const void* _src, bx::UnpackFn _unpack, uint32_t _size);
///
- void imageConvert(void* _dst, uint32_t _dstBpp, PackFn _pack, const void* _src, uint32_t _srcBpp, UnpackFn _unpack, uint32_t _width, uint32_t _height, uint32_t _srcPitch);
+ void imageConvert(void* _dst, uint32_t _dstBpp, bx::PackFn _pack, const void* _src, uint32_t _srcBpp, bx::UnpackFn _unpack, uint32_t _width, uint32_t _height, uint32_t _srcPitch);
///
bool imageConvert(void* _dst, TextureFormat::Enum _dstFormat, const void* _src, TextureFormat::Enum _srcFormat, uint32_t _width, uint32_t _height);
diff --git a/3rdparty/bgfx/src/makefile b/3rdparty/bgfx/src/makefile
index 3fade997ed2..2475a5104d4 100644
--- a/3rdparty/bgfx/src/makefile
+++ b/3rdparty/bgfx/src/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
THISDIR:=$(dir $(lastword $(MAKEFILE_LIST)))
@@ -27,6 +27,8 @@ define shader-embedded
@echo [$(<)]
$(SILENT) $(SHADERC) --type $(1) --platform linux -f $(<) -o $(SHADER_TMP) --bin2c $(basename $(<))_glsl
@cat $(SHADER_TMP) > $(@)
+ -$(SILENT) $(SHADERC) --type $(1) --platform windows -p spirv -f $(<) -o $(SHADER_TMP) --bin2c $(basename $(<))_spv
+ -@cat $(SHADER_TMP) >> $(@)
-$(SILENT) $(SHADERC) --type $(1) --platform windows -p $(2) -O 3 -f $(<) -o $(SHADER_TMP) --bin2c $(basename $(<))_dx9
-@cat $(SHADER_TMP) >> $(@)
-$(SILENT) $(SHADERC) --type $(1) --platform windows -p $(3) -O 3 -f $(<) -o $(SHADER_TMP) --bin2c $(basename $(<))_dx11
diff --git a/3rdparty/bgfx/src/renderer.h b/3rdparty/bgfx/src/renderer.h
index 9e95f72eeb7..1beadce2ff9 100644
--- a/3rdparty/bgfx/src/renderer.h
+++ b/3rdparty/bgfx/src/renderer.h
@@ -283,7 +283,7 @@ namespace bgfx
class StateCacheLru
{
public:
- void add(uint64_t _key, Ty _value, uint16_t _parent)
+ Ty* add(uint64_t _key, const Ty& _value, uint16_t _parent)
{
uint16_t handle = m_alloc.alloc();
if (UINT16_MAX == handle)
@@ -300,6 +300,8 @@ namespace bgfx
data.m_value = _value;
data.m_parent = _parent;
m_hashMap.insert(stl::make_pair(_key, handle) );
+
+ return &m_data[handle].m_value;
}
Ty* find(uint64_t _key)
diff --git a/3rdparty/bgfx/src/renderer_d3d11.cpp b/3rdparty/bgfx/src/renderer_d3d11.cpp
index 8cccbcd6d5b..ea8e18bfb37 100644
--- a/3rdparty/bgfx/src/renderer_d3d11.cpp
+++ b/3rdparty/bgfx/src/renderer_d3d11.cpp
@@ -2021,11 +2021,12 @@ BX_PRAGMA_DIAGNOSTIC_POP();
D3D11_MAPPED_SUBRESOURCE mapped;
DX_CHECK(m_deviceCtx->Map(texture, 0, D3D11_MAP_READ, 0, &mapped) );
- imageSwizzleBgra8(backBufferDesc.Width
+ imageSwizzleBgra8(
+ mapped.pData
+ , backBufferDesc.Width
, backBufferDesc.Height
, mapped.RowPitch
, mapped.pData
- , mapped.pData
);
g_callback->screenShot(_filePath
, backBufferDesc.Width
@@ -3283,11 +3284,12 @@ BX_PRAGMA_DIAGNOSTIC_POP();
D3D11_MAPPED_SUBRESOURCE mapped;
DX_CHECK(m_deviceCtx->Map(m_captureTexture, 0, D3D11_MAP_READ, 0, &mapped) );
- imageSwizzleBgra8(getBufferWidth()
+ imageSwizzleBgra8(
+ mapped.pData
+ , getBufferWidth()
, getBufferHeight()
, mapped.RowPitch
, mapped.pData
- , mapped.pData
);
g_callback->captureFrame(mapped.pData, getBufferHeight()*mapped.RowPitch);
@@ -4402,7 +4404,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
if (swizzle)
{
-// imageSwizzleBgra8(width, height, mip.m_width*4, data, temp);
+// imageSwizzleBgra8(temp, width, height, mip.m_width*4, data);
}
srd[kk].SysMemSlicePitch = mip.m_height*srd[kk].SysMemPitch;
@@ -4657,8 +4659,9 @@ BX_PRAGMA_DIAGNOSTIC_POP();
const uint32_t subres = _mip + ( (layer + _side) * m_numMips);
const uint32_t bpp = getBitsPerPixel(TextureFormat::Enum(m_textureFormat) );
- const uint32_t rectpitch = _rect.m_width*bpp/8;
- const uint32_t srcpitch = UINT16_MAX == _pitch ? rectpitch : _pitch;
+ const uint32_t rectpitch = _rect.m_width*bpp/8;
+ const uint32_t srcpitch = UINT16_MAX == _pitch ? rectpitch : _pitch;
+ const uint32_t slicepitch = rectpitch*_rect.m_height;
const bool convert = m_textureFormat != m_requestedFormat;
@@ -4667,12 +4670,19 @@ BX_PRAGMA_DIAGNOSTIC_POP();
if (convert)
{
- temp = (uint8_t*)BX_ALLOC(g_allocator, rectpitch*_rect.m_height);
+ temp = (uint8_t*)BX_ALLOC(g_allocator, slicepitch);
imageDecodeToBgra8(temp, data, _rect.m_width, _rect.m_height, srcpitch, TextureFormat::Enum(m_requestedFormat) );
data = temp;
}
- deviceCtx->UpdateSubresource(m_ptr, subres, &box, data, srcpitch, 0);
+ deviceCtx->UpdateSubresource(
+ m_ptr
+ , subres
+ , &box
+ , data
+ , srcpitch
+ , TextureD3D11::Texture3D == m_type ? slicepitch : 0
+ );
if (NULL != temp)
{
@@ -4727,7 +4737,8 @@ BX_PRAGMA_DIAGNOSTIC_POP();
m_dsv = NULL;
m_swapChain = NULL;
- m_numTh = _num;
+ m_denseIdx = UINT16_MAX;
+ m_numTh = _num;
m_needPresent = false;
memcpy(m_attachment, _attachment, _num*sizeof(Attachment) );
@@ -5744,6 +5755,11 @@ BX_PRAGMA_DIAGNOSTIC_POP();
{
Rect scissorRect;
scissorRect.intersect(viewScissorRect, _render->m_rectCache.m_cache[scissor]);
+ if (scissorRect.isZeroArea() )
+ {
+ continue;
+ }
+
scissorEnabled = true;
D3D11_RECT rc;
rc.left = scissorRect.m_x;
@@ -6195,6 +6211,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
{
PIX_BEGINEVENT(D3DCOLOR_FRAME, L"debugstats");
+ m_needPresent = true;
TextVideoMem& tvm = m_textVideoMem;
static int64_t next = now;
diff --git a/3rdparty/bgfx/src/renderer_d3d11.h b/3rdparty/bgfx/src/renderer_d3d11.h
index 977af8e37e7..2ee0a8787ac 100644
--- a/3rdparty/bgfx/src/renderer_d3d11.h
+++ b/3rdparty/bgfx/src/renderer_d3d11.h
@@ -345,7 +345,7 @@ namespace bgfx { namespace d3d11
OcclusionQueryHandle m_handle;
};
- Query m_query[BGFX_CONFIG_MAX_OCCUSION_QUERIES];
+ Query m_query[BGFX_CONFIG_MAX_OCCLUSION_QUERIES];
bx::RingBufferControl m_control;
};
diff --git a/3rdparty/bgfx/src/renderer_d3d12.cpp b/3rdparty/bgfx/src/renderer_d3d12.cpp
index 2f36d1aa102..3ba3619561c 100644
--- a/3rdparty/bgfx/src/renderer_d3d12.cpp
+++ b/3rdparty/bgfx/src/renderer_d3d12.cpp
@@ -1604,11 +1604,12 @@ namespace bgfx { namespace d3d12
void* data;
readback->Map(0, NULL, (void**)&data);
- imageSwizzleBgra8(width
+ imageSwizzleBgra8(
+ data
+ , width
, height
, (uint32_t)pitch
, data
- , data
);
g_callback->screenShot(_filePath
, width
@@ -2396,8 +2397,8 @@ data.NumQualityLevels = 0;
{
if (0 != memcmp(&program.m_fsh->m_code->data[ii], &temp->data[ii], 16) )
{
-// dbgPrintfData(&program.m_fsh->m_code->data[ii], temp->size-ii, "");
-// dbgPrintfData(&temp->data[ii], temp->size-ii, "");
+// bx::debugPrintfData(&program.m_fsh->m_code->data[ii], temp->size-ii, "");
+// bx::debugPrintfData(&temp->data[ii], temp->size-ii, "");
break;
}
}
@@ -4070,11 +4071,11 @@ data.NumQualityLevels = 0;
uint32_t slice = bx::strideAlign( (mip.m_height/blockInfo.blockHeight)*pitch, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT);
uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, slice);
- imageCopy(mip.m_height/blockInfo.blockHeight
+ imageCopy(temp
+ , mip.m_height/blockInfo.blockHeight
, (mip.m_width /blockInfo.blockWidth )*mip.m_blockSize
, mip.m_data
, pitch
- , temp
);
srd[kk].pData = temp;
@@ -4088,11 +4089,11 @@ data.NumQualityLevels = 0;
const uint32_t slice = bx::strideAlign(pitch * mip.m_height, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT);
uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, slice);
- imageCopy(mip.m_height
+ imageCopy(temp
+ , mip.m_height
, mip.m_width*mip.m_bpp / 8
, mip.m_data
, pitch
- , temp
);
srd[kk].pData = temp;
@@ -4103,7 +4104,7 @@ data.NumQualityLevels = 0;
if (swizzle)
{
-// imageSwizzleBgra8(width, height, mip.m_width*4, data, temp);
+// imageSwizzleBgra8(temp, width, height, mip.m_width*4, data);
}
srd[kk].SlicePitch = mip.m_height*srd[kk].RowPitch;
@@ -4428,6 +4429,7 @@ data.NumQualityLevels = 0;
void FrameBufferD3D12::create(uint8_t _num, const Attachment* _attachment)
{
+ m_denseIdx = UINT16_MAX;
m_numTh = _num;
memcpy(m_attachment, _attachment, _num*sizeof(Attachment) );
@@ -5371,6 +5373,11 @@ data.NumQualityLevels = 0;
restoreScissor = true;
Rect scissorRect;
scissorRect.intersect(viewScissorRect,_render->m_rectCache.m_cache[scissor]);
+ if (scissorRect.isZeroArea() )
+ {
+ continue;
+ }
+
D3D12_RECT rc;
rc.left = scissorRect.m_x;
rc.top = scissorRect.m_y;
@@ -5489,10 +5496,11 @@ data.NumQualityLevels = 0;
perfStats.numCompute = statsKeyType[1];
perfStats.maxGpuLatency = maxGpuLatency;
- if (_render->m_debug & (BGFX_DEBUG_IFH | BGFX_DEBUG_STATS) )
+ if (_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) )
{
// PIX_BEGINEVENT(D3DCOLOR_FRAME, L"debugstats");
+// m_needPresent = true;
TextVideoMem& tvm = m_textVideoMem;
static int64_t next = now;
diff --git a/3rdparty/bgfx/src/renderer_d3d12.h b/3rdparty/bgfx/src/renderer_d3d12.h
index eb0193df7fd..8a490ab7860 100644
--- a/3rdparty/bgfx/src/renderer_d3d12.h
+++ b/3rdparty/bgfx/src/renderer_d3d12.h
@@ -484,7 +484,7 @@ namespace bgfx { namespace d3d12
ID3D12Resource* m_readback;
ID3D12QueryHeap* m_queryHeap;
- OcclusionQueryHandle m_handle[BGFX_CONFIG_MAX_OCCUSION_QUERIES];
+ OcclusionQueryHandle m_handle[BGFX_CONFIG_MAX_OCCLUSION_QUERIES];
uint64_t* m_result;
bx::RingBufferControl m_control;
};
diff --git a/3rdparty/bgfx/src/renderer_d3d9.cpp b/3rdparty/bgfx/src/renderer_d3d9.cpp
index d95d7d93a00..58e45db9032 100644
--- a/3rdparty/bgfx/src/renderer_d3d9.cpp
+++ b/3rdparty/bgfx/src/renderer_d3d9.cpp
@@ -2982,11 +2982,11 @@ namespace bgfx { namespace d3d9
switch (m_textureFormat)
{
case TextureFormat::RGB5A1:
- imageConvert(bits, 16, packBgr5a1, mip.m_data, unpackRgb5a1, size);
+ imageConvert(bits, 16, bx::packBgr5a1, mip.m_data, bx::unpackRgb5a1, size);
break;
case TextureFormat::RGBA4:
- imageConvert(bits, 16, packBgra4, mip.m_data, unpackRgba4, size);
+ imageConvert(bits, 16, bx::packBgra4, mip.m_data, bx::unpackRgba4, size);
break;
default:
@@ -3044,11 +3044,11 @@ namespace bgfx { namespace d3d9
switch (m_textureFormat)
{
case TextureFormat::RGB5A1:
- imageConvert(dst, 16, packBgr5a1, src, unpackRgb5a1, rectpitch);
+ imageConvert(dst, 16, bx::packBgr5a1, src, bx::unpackRgb5a1, rectpitch);
break;
case TextureFormat::RGBA4:
- imageConvert(dst, 16, packBgra4, src, unpackRgba4, rectpitch);
+ imageConvert(dst, 16, bx::packBgra4, src, bx::unpackRgba4, rectpitch);
break;
default:
@@ -3154,6 +3154,7 @@ namespace bgfx { namespace d3d9
m_surface[ii] = NULL;
}
+ m_denseIdx = UINT16_MAX;
m_dsIdx = UINT8_MAX;
m_num = 0;
m_numTh = _num;
@@ -3795,6 +3796,11 @@ namespace bgfx { namespace d3d9
{
Rect scissorRect;
scissorRect.intersect(viewScissorRect, _render->m_rectCache.m_cache[scissor]);
+ if (scissorRect.isZeroArea() )
+ {
+ continue;
+ }
+
DX_CHECK(device->SetRenderState(D3DRS_SCISSORTESTENABLE, true) );
RECT rc;
rc.left = scissorRect.m_x;
@@ -4272,6 +4278,7 @@ namespace bgfx { namespace d3d9
{
PIX_BEGINEVENT(D3DCOLOR_FRAME, L"debugstats");
+ m_needPresent = true;
TextVideoMem& tvm = m_textVideoMem;
static int64_t next = now;
diff --git a/3rdparty/bgfx/src/renderer_d3d9.h b/3rdparty/bgfx/src/renderer_d3d9.h
index 1e16af551b7..93c42c853a1 100644
--- a/3rdparty/bgfx/src/renderer_d3d9.h
+++ b/3rdparty/bgfx/src/renderer_d3d9.h
@@ -475,7 +475,7 @@ namespace bgfx { namespace d3d9
OcclusionQueryHandle m_handle;
};
- Query m_query[BGFX_CONFIG_MAX_OCCUSION_QUERIES];
+ Query m_query[BGFX_CONFIG_MAX_OCCLUSION_QUERIES];
bx::RingBufferControl m_control;
};
diff --git a/3rdparty/bgfx/src/renderer_gl.cpp b/3rdparty/bgfx/src/renderer_gl.cpp
index 3901083ee03..93a714ea194 100644
--- a/3rdparty/bgfx/src/renderer_gl.cpp
+++ b/3rdparty/bgfx/src/renderer_gl.cpp
@@ -980,7 +980,7 @@ namespace bgfx { namespace gl
//
// If <length> is 0 then <marker> is assumed to be null-terminated.
- uint32_t size = (0 == _length ? (uint32_t)strlen(_marker) : _length) + 1;
+ uint32_t size = (0 == _length ? (uint32_t)bx::strnlen(_marker) : _length) + 1;
size *= sizeof(wchar_t);
wchar_t* name = (wchar_t*)alloca(size);
mbstowcs(name, _marker, size-2);
@@ -1039,7 +1039,7 @@ namespace bgfx { namespace gl
glGetError(); // ignore error if glGetString returns NULL.
if (NULL != str)
{
- return bx::hashMurmur2A(str, (uint32_t)strlen(str) );
+ return bx::hashMurmur2A(str, (uint32_t)bx::strnlen(str) );
}
return 0;
@@ -1051,7 +1051,7 @@ namespace bgfx { namespace gl
{
char name[1024];
const char* pos = _extensions;
- const char* end = _extensions + strlen(_extensions);
+ const char* end = _extensions + bx::strnlen(_extensions);
while (pos < end)
{
uint32_t len;
@@ -1062,7 +1062,7 @@ namespace bgfx { namespace gl
}
else
{
- len = bx::uint32_min(sizeof(name), (uint32_t)strlen(pos) );
+ len = bx::uint32_min(sizeof(name), (uint32_t)bx::strnlen(pos) );
}
strncpy(name, pos, len);
@@ -1469,7 +1469,7 @@ namespace bgfx { namespace gl
for (uint32_t ii = 0; ii < BX_COUNTOF(s_vendorIds); ++ii)
{
const VendorId& vendorId = s_vendorIds[ii];
- if (0 == strncmp(vendorId.name, m_vendor, strlen(vendorId.name) ) )
+ if (0 == strncmp(vendorId.name, m_vendor, bx::strnlen(vendorId.name) ) )
{
g_caps.vendorId = vendorId.id;
break;
@@ -1559,7 +1559,7 @@ namespace bgfx { namespace gl
{
char name[1024];
const char* pos = extensions;
- const char* end = extensions + strlen(extensions);
+ const char* end = extensions + bx::strnlen(extensions);
uint32_t index = 0;
while (pos < end)
{
@@ -1571,7 +1571,7 @@ namespace bgfx { namespace gl
}
else
{
- len = bx::uint32_min(sizeof(name), (uint32_t)strlen(pos) );
+ len = bx::uint32_min(sizeof(name), (uint32_t)bx::strnlen(pos) );
}
strncpy(name, pos, len);
@@ -2539,7 +2539,7 @@ namespace bgfx { namespace gl
if (GL_RGBA == m_readPixelsFmt)
{
- imageSwizzleBgra8(width, height, width*4, data, data);
+ imageSwizzleBgra8(data, width, height, width*4, data);
}
g_callback->screenShot(_filePath
@@ -3101,7 +3101,7 @@ namespace bgfx { namespace gl
if (GL_RGBA == m_readPixelsFmt)
{
- imageSwizzleBgra8(m_resolution.m_width, m_resolution.m_height, m_resolution.m_width*4, m_capture, m_capture);
+ imageSwizzleBgra8(m_capture, m_resolution.m_width, m_resolution.m_height, m_resolution.m_width*4, m_capture);
}
g_callback->captureFrame(m_capture, m_captureSize);
@@ -5086,7 +5086,7 @@ namespace bgfx { namespace gl
if (!unpackRowLength)
{
- imageCopy(width, height, bpp, srcpitch, data, temp);
+ imageCopy(temp, width, height, bpp, srcpitch, data);
data = temp;
}
@@ -5117,7 +5117,7 @@ namespace bgfx { namespace gl
if (!unpackRowLength
&& !convert)
{
- imageCopy(width, height, bpp, srcpitch, data, temp);
+ imageCopy(temp, width, height, bpp, srcpitch, data);
data = temp;
}
@@ -5294,7 +5294,7 @@ namespace bgfx { namespace gl
void writeString(bx::WriterI* _writer, const char* _str)
{
- bx::write(_writer, _str, (int32_t)strlen(_str) );
+ bx::write(_writer, _str, (int32_t)bx::strnlen(_str) );
}
void writeStringf(bx::WriterI* _writer, const char* _format, ...)
@@ -5311,8 +5311,8 @@ namespace bgfx { namespace gl
void strins(char* _str, const char* _insert)
{
- size_t len = strlen(_insert);
- memmove(&_str[len], _str, strlen(_str)+1);
+ size_t len = bx::strnlen(_insert);
+ memmove(&_str[len], _str, bx::strnlen(_str)+1);
memcpy(_str, _insert, len);
}
@@ -5382,7 +5382,7 @@ namespace bgfx { namespace gl
{
if (GL_COMPUTE_SHADER != m_type)
{
- int32_t codeLen = (int32_t)strlen(code);
+ int32_t codeLen = (int32_t)bx::strnlen(code);
int32_t tempLen = codeLen + (4<<10);
char* temp = (char*)alloca(tempLen);
bx::StaticMemoryBlockWriter writer(temp, tempLen);
@@ -5812,6 +5812,7 @@ namespace bgfx { namespace gl
{
GL_CHECK(glGenFramebuffers(1, &m_fbo[0]) );
+ m_denseIdx = UINT16_MAX;
m_numTh = _num;
memcpy(m_attachment, _attachment, _num*sizeof(Attachment) );
@@ -6601,6 +6602,11 @@ namespace bgfx { namespace gl
{
Rect scissorRect;
scissorRect.intersect(viewScissorRect, _render->m_rectCache.m_cache[scissor]);
+ if (scissorRect.isZeroArea() )
+ {
+ continue;
+ }
+
GL_CHECK(glEnable(GL_SCISSOR_TEST) );
GL_CHECK(glScissor(scissorRect.m_x
, resolutionHeight-scissorRect.m_height-scissorRect.m_y
@@ -7320,6 +7326,7 @@ namespace bgfx { namespace gl
if (_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) )
{
+ m_needPresent = true;
TextVideoMem& tvm = m_textVideoMem;
static int64_t next = now;
diff --git a/3rdparty/bgfx/src/renderer_gl.h b/3rdparty/bgfx/src/renderer_gl.h
index 9d25ec24948..8dbb24fa2f7 100644
--- a/3rdparty/bgfx/src/renderer_gl.h
+++ b/3rdparty/bgfx/src/renderer_gl.h
@@ -1491,7 +1491,7 @@ namespace bgfx { namespace gl
OcclusionQueryHandle m_handle;
};
- Query m_query[BGFX_CONFIG_MAX_OCCUSION_QUERIES];
+ Query m_query[BGFX_CONFIG_MAX_OCCLUSION_QUERIES];
bx::RingBufferControl m_control;
};
diff --git a/3rdparty/bgfx/src/renderer_mtl.h b/3rdparty/bgfx/src/renderer_mtl.h
index 6bf57a036d5..4aca08a02dd 100644
--- a/3rdparty/bgfx/src/renderer_mtl.h
+++ b/3rdparty/bgfx/src/renderer_mtl.h
@@ -843,7 +843,7 @@ namespace bgfx { namespace mtl
CommandQueueMtl() : m_releaseWriteIndex(0), m_releaseReadIndex(0)
{
}
-
+
void init(Device _device);
void shutdown();
CommandBuffer alloc();
@@ -856,13 +856,13 @@ namespace bgfx { namespace mtl
CommandQueue m_commandQueue;
CommandBuffer m_activeCommandBuffer;
-
+
int m_releaseWriteIndex;
int m_releaseReadIndex;
typedef stl::vector<NSObject*> ResourceArray;
ResourceArray m_release[MTL_MAX_FRAMES_IN_FLIGHT];
};
-
+
struct TimerQueryMtl
{
TimerQueryMtl()
@@ -903,7 +903,7 @@ namespace bgfx { namespace mtl
};
Buffer m_buffer;
- Query m_query[BGFX_CONFIG_MAX_OCCUSION_QUERIES];
+ Query m_query[BGFX_CONFIG_MAX_OCCLUSION_QUERIES];
bx::RingBufferControl m_control;
};
diff --git a/3rdparty/bgfx/src/renderer_mtl.mm b/3rdparty/bgfx/src/renderer_mtl.mm
index 8a9958bbc1c..1c174970073 100644
--- a/3rdparty/bgfx/src/renderer_mtl.mm
+++ b/3rdparty/bgfx/src/renderer_mtl.mm
@@ -1223,7 +1223,9 @@ namespace bgfx { namespace mtl
if (NULL != m_capture)
{
if (NULL == m_screenshotTarget)
+ {
return;
+ }
m_renderCommandEncoder.endEncoding();
@@ -1239,7 +1241,13 @@ namespace bgfx { namespace mtl
if (m_screenshotTarget.pixelFormat() == MTLPixelFormatRGBA8Uint)
{
- imageSwizzleBgra8(m_resolution.m_width, m_resolution.m_height, m_resolution.m_width*4, m_capture, m_capture);
+ imageSwizzleBgra8(
+ m_capture
+ , m_resolution.m_width
+ , m_resolution.m_height
+ , m_resolution.m_width*4
+ , m_capture
+ );
}
g_callback->captureFrame(m_capture, m_captureSize);
@@ -1247,11 +1255,13 @@ namespace bgfx { namespace mtl
RenderPassDescriptor renderPassDescriptor = newRenderPassDescriptor();
setFrameBuffer(renderPassDescriptor, m_renderCommandEncoderFrameBufferHandle);
- for(uint32_t ii = 0; ii < g_caps.limits.maxFBAttachments; ++ii)
+ for (uint32_t ii = 0; ii < g_caps.limits.maxFBAttachments; ++ii)
{
MTLRenderPassColorAttachmentDescriptor* desc = renderPassDescriptor.colorAttachments[ii];
- if ( desc.texture != NULL)
+ if (NULL != desc.texture)
+ {
desc.loadAction = MTLLoadActionLoad;
+ }
}
RenderPassDepthAttachmentDescriptor depthAttachment = renderPassDescriptor.depthAttachment;
@@ -1802,7 +1812,7 @@ namespace bgfx { namespace mtl
void writeString(bx::WriterI* _writer, const char* _str)
{
- bx::write(_writer, _str, (int32_t)strlen(_str) );
+ bx::write(_writer, _str, (int32_t)bx::strnlen(_str) );
}
void ShaderMtl::create(const Memory* _mem)
@@ -2679,6 +2689,7 @@ namespace bgfx { namespace mtl
void FrameBufferMtl::create(uint8_t _num, const Attachment* _attachment)
{
+ m_denseIdx = UINT16_MAX;
m_num = 0;
m_width = 0;
m_height = 0;
@@ -3406,14 +3417,17 @@ namespace bgfx { namespace mtl
{
Rect scissorRect;
scissorRect.intersect(viewScissorRect, _render->m_rectCache.m_cache[scissor]);
- rc.x = scissorRect.m_x;
- rc.y = scissorRect.m_y;
+ if (scissorRect.isZeroArea() )
+ {
+ continue;
+ }
+
+ rc.x = scissorRect.m_x;
+ rc.y = scissorRect.m_y;
rc.width = scissorRect.m_width;
rc.height = scissorRect.m_height;
-
- if ( rc.width == 0 || rc.height == 0 )
- continue;
}
+
rce.setScissorRect(rc);
}
diff --git a/3rdparty/bgfx/src/renderer_vk.cpp b/3rdparty/bgfx/src/renderer_vk.cpp
index d1df4c41bdd..7609b43d506 100644
--- a/3rdparty/bgfx/src/renderer_vk.cpp
+++ b/3rdparty/bgfx/src/renderer_vk.cpp
@@ -4262,6 +4262,11 @@ BX_UNUSED(currentSamplerStateIdx);
restoreScissor = true;
Rect scissorRect;
scissorRect.intersect(viewScissorRect,_render->m_rectCache.m_cache[scissor]);
+ if (scissorRect.isZeroArea() )
+ {
+ continue;
+ }
+
VkRect2D rc;
rc.offset.x = scissorRect.m_x;
rc.offset.x = scissorRect.m_y;
@@ -4435,10 +4440,11 @@ BX_UNUSED(presentMin, presentMax);
// perfStats.numCompute = statsKeyType[1];
// perfStats.maxGpuLatency = maxGpuLatency;
- if (_render->m_debug & (BGFX_DEBUG_IFH | BGFX_DEBUG_STATS) )
+ if (_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) )
{
// PIX_BEGINEVENT(D3DCOLOR_RGBA(0x40, 0x40, 0x40, 0xff), L"debugstats");
+// m_needPresent = true;
TextVideoMem& tvm = m_textVideoMem;
static int64_t next = now;
diff --git a/3rdparty/bgfx/src/shader.cpp b/3rdparty/bgfx/src/shader.cpp
index 03a1d05faa2..76493223590 100644
--- a/3rdparty/bgfx/src/shader.cpp
+++ b/3rdparty/bgfx/src/shader.cpp
@@ -15,7 +15,7 @@ namespace bgfx
bx::WriterI* writer = reinterpret_cast<bx::WriterI*>(_userData);
char temp[512];
toString(temp, sizeof(temp), _instruction);
- bx::write(writer, temp, (int32_t)strlen(temp) );
+ bx::write(writer, temp, (int32_t)bx::strnlen(temp) );
return true;
}
@@ -24,7 +24,7 @@ namespace bgfx
bx::WriterI* writer = reinterpret_cast<bx::WriterI*>(_userData);
char temp[512];
toString(temp, sizeof(temp), _instruction);
- bx::write(writer, temp, (int32_t)strlen(temp) );
+ bx::write(writer, temp, (int32_t)bx::strnlen(temp) );
return true;
}
@@ -33,7 +33,7 @@ namespace bgfx
bx::WriterI* writer = reinterpret_cast<bx::WriterI*>(_userData);
char temp[512];
toString(temp, sizeof(temp), _instruction);
- bx::write(writer, temp, (int32_t)strlen(temp) );
+ bx::write(writer, temp, (int32_t)bx::strnlen(temp) );
return true;
}
@@ -85,7 +85,7 @@ namespace bgfx
for (uint32_t ii = 0; ii < count; ++ii)
{
- uint8_t nameSize;
+ uint8_t nameSize = 0;
bx::read(_reader, nameSize, _err);
if (!_err->isOk() ) { return; }
diff --git a/3rdparty/bgfx/src/vertexdecl.cpp b/3rdparty/bgfx/src/vertexdecl.cpp
index 66793c7dec8..70c3aafc67f 100644
--- a/3rdparty/bgfx/src/vertexdecl.cpp
+++ b/3rdparty/bgfx/src/vertexdecl.cpp
@@ -64,28 +64,6 @@ namespace bgfx
s_attribTypeSize[RendererType::Count] = s_attribTypeSize[_type];
}
- void dbgPrintfVargs(const char* _format, va_list _argList)
- {
- char temp[8192];
- char* out = temp;
- int32_t len = bx::vsnprintf(out, sizeof(temp), _format, _argList);
- if ( (int32_t)sizeof(temp) < len)
- {
- out = (char*)alloca(len+1);
- len = bx::vsnprintf(out, len, _format, _argList);
- }
- out[len] = '\0';
- bx::debugOutput(out);
- }
-
- void dbgPrintf(const char* _format, ...)
- {
- va_list argList;
- va_start(argList, _format);
- dbgPrintfVargs(_format, argList);
- va_end(argList);
- }
-
VertexDecl::VertexDecl()
{
// BK - struct need to have ctor to qualify as non-POD data.
@@ -172,7 +150,7 @@ namespace bgfx
{
if (BX_ENABLED(BGFX_CONFIG_DEBUG) )
{
- dbgPrintf("vertexdecl %08x (%08x), stride %d\n"
+ bx::debugPrintf("vertexdecl %08x (%08x), stride %d\n"
, _decl.m_hash
, bx::hashMurmur2A(_decl.m_attributes)
, _decl.m_stride
@@ -188,7 +166,7 @@ namespace bgfx
bool asInt;
_decl.decode(Attrib::Enum(attr), num, type, normalized, asInt);
- dbgPrintf("\tattr %d - %s, num %d, type %d, norm %d, asint %d, offset %d\n"
+ bx::debugPrintf("\tattr %d - %s, num %d, type %d, norm %d, asint %d, offset %d\n"
, attr
, getAttribName(Attrib::Enum(attr) )
, num
diff --git a/3rdparty/bgfx/tools/geometryc/geometryc.cpp b/3rdparty/bgfx/tools/geometryc/geometryc.cpp
index 7a6a18f3c25..c18a3972352 100644
--- a/3rdparty/bgfx/tools/geometryc/geometryc.cpp
+++ b/3rdparty/bgfx/tools/geometryc/geometryc.cpp
@@ -61,7 +61,6 @@ namespace stl = tinystl;
#include <bx/hash.h>
#include <bx/uint32_t.h>
#include <bx/fpumath.h>
-#include <bx/tokenizecmd.h>
#include <bx/crtimpl.h>
#include "bounds.h"
diff --git a/3rdparty/bgfx/tools/shaderc/shaderc.cpp b/3rdparty/bgfx/tools/shaderc/shaderc.cpp
index c8120e045d9..114ce602cc1 100644
--- a/3rdparty/bgfx/tools/shaderc/shaderc.cpp
+++ b/3rdparty/bgfx/tools/shaderc/shaderc.cpp
@@ -4,7 +4,7 @@
*/
#include "shaderc.h"
-#include <bx/tokenizecmd.h>
+#include <bx/commandline.h>
#define MAX_TAGS 256
extern "C"
@@ -710,7 +710,7 @@ namespace bgfx
"\n"
"Options:\n"
" -f <file path> Input file path.\n"
- " -i <include path> Include path (for multiple paths use semicolon).\n"
+ " -i <include path> Include path (for multiple paths use use -i multiple times).\n"
" -o <file path> Output file path.\n"
" --bin2c <file path> Generate C header file.\n"
" --depends Generate makefile style depends file.\n"
@@ -865,6 +865,10 @@ namespace bgfx
bool preprocessOnly = cmdLine.hasArg("preprocess");
const char* includeDir = cmdLine.findOption('i');
+ BX_TRACE("depends: %d", depends);
+ BX_TRACE("preprocessOnly: %d", preprocessOnly);
+ BX_TRACE("includeDir: %s", includeDir);
+
Preprocessor preprocessor(filePath, 0 != essl);
for (int ii = 1; NULL != includeDir; ++ii)
@@ -927,22 +931,22 @@ namespace bgfx
, essl ? 1 : glsl
);
- if (0 == bx::stricmp(platform, "android") )
+ if (0 == bx::strincmp(platform, "android") )
{
preprocessor.setDefine("BX_PLATFORM_ANDROID=1");
preprocessor.setDefine("BGFX_SHADER_LANGUAGE_GLSL=1");
}
- else if (0 == bx::stricmp(platform, "asm.js") )
+ else if (0 == bx::strincmp(platform, "asm.js") )
{
preprocessor.setDefine("BX_PLATFORM_EMSCRIPTEN=1");
preprocessor.setDefine("BGFX_SHADER_LANGUAGE_GLSL=1");
}
- else if (0 == bx::stricmp(platform, "ios") )
+ else if (0 == bx::strincmp(platform, "ios") )
{
preprocessor.setDefine("BX_PLATFORM_IOS=1");
preprocessor.setDefine("BGFX_SHADER_LANGUAGE_GLSL=1");
}
- else if (0 == bx::stricmp(platform, "linux") )
+ else if (0 == bx::strincmp(platform, "linux") )
{
preprocessor.setDefine("BX_PLATFORM_LINUX=1");
if (0 != spirv)
@@ -954,12 +958,12 @@ namespace bgfx
preprocessor.setDefine(glslDefine);
}
}
- else if (0 == bx::stricmp(platform, "nacl") )
+ else if (0 == bx::strincmp(platform, "nacl") )
{
preprocessor.setDefine("BX_PLATFORM_NACL=1");
preprocessor.setDefine("BGFX_SHADER_LANGUAGE_GLSL=1");
}
- else if (0 == bx::stricmp(platform, "osx") )
+ else if (0 == bx::strincmp(platform, "osx") )
{
preprocessor.setDefine("BX_PLATFORM_OSX=1");
preprocessor.setDefine(glslDefine);
@@ -967,19 +971,19 @@ namespace bgfx
bx::snprintf(temp, sizeof(temp), "BGFX_SHADER_LANGUAGE_METAL=%d", metal);
preprocessor.setDefine(temp);
}
- else if (0 == bx::stricmp(platform, "windows") )
+ else if (0 == bx::strincmp(platform, "windows") )
{
preprocessor.setDefine("BX_PLATFORM_WINDOWS=1");
char temp[256];
bx::snprintf(temp, sizeof(temp), "BGFX_SHADER_LANGUAGE_HLSL=%d", hlsl);
preprocessor.setDefine(temp);
}
- else if (0 == bx::stricmp(platform, "xbox360") )
+ else if (0 == bx::strincmp(platform, "xbox360") )
{
preprocessor.setDefine("BX_PLATFORM_XBOX360=1");
preprocessor.setDefine("BGFX_SHADER_LANGUAGE_HLSL=3");
}
- else if (0 == bx::stricmp(platform, "orbis") )
+ else if (0 == bx::strincmp(platform, "orbis") )
{
preprocessor.setDefine("BX_PLATFORM_PS4=1");
preprocessor.setDefine("BGFX_SHADER_LANGUAGE_PSSL=1");
diff --git a/3rdparty/bgfx/tools/shaderc/shaderc_spirv.cpp b/3rdparty/bgfx/tools/shaderc/shaderc_spirv.cpp
index c730c75c17a..502edddab12 100644
--- a/3rdparty/bgfx/tools/shaderc/shaderc_spirv.cpp
+++ b/3rdparty/bgfx/tools/shaderc/shaderc_spirv.cpp
@@ -6,6 +6,7 @@
#include "shaderc.h"
BX_PRAGMA_DIAGNOSTIC_PUSH()
+BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4100) // error C4100: 'inclusionDepth' : unreferenced formal parameter
BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4265) // error C4265: 'spv::spirvbin_t': class has virtual functions, but destructor is not virtual
#include <ShaderLang.h>
#include <ResourceLimits.h>
diff --git a/3rdparty/bgfx/tools/texturec/texturec.cpp b/3rdparty/bgfx/tools/texturec/texturec.cpp
index 32715c4499b..e1c60ca1da4 100644
--- a/3rdparty/bgfx/tools/texturec/texturec.cpp
+++ b/3rdparty/bgfx/tools/texturec/texturec.cpp
@@ -59,7 +59,9 @@ BX_PRAGMA_DIAGNOSTIC_POP();
BX_PRAGMA_DIAGNOSTIC_PUSH()
BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wtype-limits")
+BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wunused-parameter")
BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wunused-value")
+BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4100) // error C4100: '' : unreferenced formal parameter
#define MINIZ_NO_STDIO
#define TINYEXR_IMPLEMENTATION
#include <tinyexr/tinyexr.h>
@@ -318,7 +320,7 @@ namespace bgfx
return true;
case TextureFormat::BGRA8:
- imageSwizzleBgra8(_width, _height, _width*4, _src, _dst);
+ imageSwizzleBgra8(_dst, _width, _height, _width*4, _src);
return true;
case TextureFormat::RGBA8:
@@ -684,7 +686,7 @@ int main(int _argc, const char* _argv[])
for (uint8_t lod = 1; lod < numMips; ++lod)
{
- imageRgba32fDownsample2x2NormalMap(dstMip.m_width, dstMip.m_height, dstMip.m_width*16, rgba, rgba);
+ imageRgba32fDownsample2x2NormalMap(rgba, dstMip.m_width, dstMip.m_height, dstMip.m_width*16, rgba);
imageRgba32f11to01(rgbaDst, dstMip.m_width, dstMip.m_height, dstMip.m_width*16, rgba);
imageGetRawData(imageContainer, 0, lod, output->data, output->size, dstMip);
uint8_t* data = const_cast<uint8_t*>(dstMip.m_data);
@@ -737,7 +739,7 @@ int main(int _argc, const char* _argv[])
for (uint8_t lod = 1; lod < numMips; ++lod)
{
- imageRgba32fLinearDownsample2x2(dstMip.m_width, dstMip.m_height, dstMip.m_width*16, rgba, rgba);
+ imageRgba32fLinearDownsample2x2(rgba, dstMip.m_width, dstMip.m_height, dstMip.m_width*16, rgba);
imageGetRawData(imageContainer, 0, lod, output->data, output->size, dstMip);
uint8_t* data = const_cast<uint8_t*>(dstMip.m_data);
@@ -797,7 +799,7 @@ int main(int _argc, const char* _argv[])
for (uint8_t lod = 1; lod < numMips; ++lod)
{
- imageRgba8Downsample2x2(dstMip.m_width, dstMip.m_height, dstMip.m_width*4, rgba, rgba);
+ imageRgba8Downsample2x2(rgba, dstMip.m_width, dstMip.m_height, dstMip.m_width*4, rgba);
imageGetRawData(imageContainer, 0, lod, output->data, output->size, dstMip);
uint8_t* data = const_cast<uint8_t*>(dstMip.m_data);
imageEncodeFromRgba8(data, rgba, dstMip.m_width, dstMip.m_height, format);
diff --git a/3rdparty/bgfx/tools/texturev/makefile b/3rdparty/bgfx/tools/texturev/makefile
index 31820c53b37..733ae658a22 100644
--- a/3rdparty/bgfx/tools/texturev/makefile
+++ b/3rdparty/bgfx/tools/texturev/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2015 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
include ../../../bgfx/scripts/shader-embeded.mk
diff --git a/3rdparty/bgfx/tools/texturev/texturev.cpp b/3rdparty/bgfx/tools/texturev/texturev.cpp
index ed1a1b86e70..de60ce6a0ad 100644
--- a/3rdparty/bgfx/tools/texturev/texturev.cpp
+++ b/3rdparty/bgfx/tools/texturev/texturev.cpp
@@ -319,7 +319,7 @@ struct View
bool supported = false;
for (uint32_t ii = 0; ii < BX_COUNTOF(s_supportedExt); ++ii)
{
- if (0 == bx::stricmp(ext, s_supportedExt[ii]) )
+ if (0 == bx::strincmp(ext, s_supportedExt[ii]) )
{
supported = true;
break;
diff --git a/3rdparty/bx/include/bx/allocator.h b/3rdparty/bx/include/bx/allocator.h
index f74b78b2c59..a1ab3e30826 100644
--- a/3rdparty/bx/include/bx/allocator.h
+++ b/3rdparty/bx/include/bx/allocator.h
@@ -8,7 +8,6 @@
#include "bx.h"
-#include <memory.h>
#include <string.h> //::memmove
#include <new>
@@ -42,18 +41,6 @@
namespace bx
{
- /// Aligns pointer to nearest next aligned address. _align must be power of two.
- inline void* alignPtr(void* _ptr, size_t _extra, size_t _align = BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT)
- {
- union { void* ptr; size_t addr; } un;
- un.ptr = _ptr;
- size_t unaligned = un.addr + _extra; // space for header
- size_t mask = _align-1;
- size_t aligned = BX_ALIGN_MASK(unaligned, mask);
- un.addr = aligned;
- return un.ptr;
- }
-
struct BX_NO_VTABLE AllocatorI
{
virtual ~AllocatorI() = 0;
@@ -68,79 +55,84 @@ namespace bx
virtual void* realloc(void* _ptr, size_t _size, size_t _align, const char* _file, uint32_t _line) = 0;
};
- inline AllocatorI::~AllocatorI()
- {
- }
-
- inline void* alloc(AllocatorI* _allocator, size_t _size, size_t _align = 0, const char* _file = NULL, uint32_t _line = 0)
- {
- return _allocator->realloc(NULL, _size, _align, _file, _line);
- }
-
- inline void free(AllocatorI* _allocator, void* _ptr, size_t _align = 0, const char* _file = NULL, uint32_t _line = 0)
- {
- _allocator->realloc(_ptr, 0, _align, _file, _line);
- }
-
- inline void* realloc(AllocatorI* _allocator, void* _ptr, size_t _size, size_t _align = 0, const char* _file = NULL, uint32_t _line = 0)
- {
- return _allocator->realloc(_ptr, _size, _align, _file, _line);
- }
-
- static inline void* alignedAlloc(AllocatorI* _allocator, size_t _size, size_t _align, const char* _file = NULL, uint32_t _line = 0)
- {
- size_t total = _size + _align;
- uint8_t* ptr = (uint8_t*)alloc(_allocator, total, 0, _file, _line);
- uint8_t* aligned = (uint8_t*)alignPtr(ptr, sizeof(uint32_t), _align);
- uint32_t* header = (uint32_t*)aligned - 1;
- *header = uint32_t(aligned - ptr);
- return aligned;
- }
-
- static inline void alignedFree(AllocatorI* _allocator, void* _ptr, size_t /*_align*/, const char* _file = NULL, uint32_t _line = 0)
- {
- uint8_t* aligned = (uint8_t*)_ptr;
- uint32_t* header = (uint32_t*)aligned - 1;
- uint8_t* ptr = aligned - *header;
- free(_allocator, ptr, 0, _file, _line);
- }
-
- static inline void* alignedRealloc(AllocatorI* _allocator, void* _ptr, size_t _size, size_t _align, const char* _file = NULL, uint32_t _line = 0)
- {
- if (NULL == _ptr)
- {
- return alignedAlloc(_allocator, _size, _align, _file, _line);
- }
-
- uint8_t* aligned = (uint8_t*)_ptr;
- uint32_t offset = *( (uint32_t*)aligned - 1);
- uint8_t* ptr = aligned - offset;
- size_t total = _size + _align;
- ptr = (uint8_t*)realloc(_allocator, ptr, total, 0, _file, _line);
- uint8_t* newAligned = (uint8_t*)alignPtr(ptr, sizeof(uint32_t), _align);
-
- if (newAligned == aligned)
- {
- return aligned;
- }
-
- aligned = ptr + offset;
- ::memmove(newAligned, aligned, _size);
- uint32_t* header = (uint32_t*)newAligned - 1;
- *header = uint32_t(newAligned - ptr);
- return newAligned;
- }
+ /// Check if pointer is aligned. _align must be power of two.
+ bool isAligned(const void* _ptr, size_t _align);
+ /// Aligns pointer to nearest next aligned address. _align must be power of two.
+ void* alignPtr(
+ void* _ptr
+ , size_t _extra
+ , size_t _align = BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT
+ );
+
+ ///
+ void* alloc(
+ AllocatorI* _allocator
+ , size_t _size
+ , size_t _align = 0
+ , const char* _file = NULL
+ , uint32_t _line = 0
+ );
+
+ ///
+ void free(
+ AllocatorI* _allocator
+ , void* _ptr
+ , size_t _align = 0
+ , const char* _file = NULL
+ , uint32_t _line = 0
+ );
+
+ ///
+ void* realloc(
+ AllocatorI* _allocator
+ , void* _ptr
+ , size_t _size
+ , size_t _align = 0
+ , const char* _file = NULL
+ , uint32_t _line = 0
+ );
+
+ ///
+ void* alignedAlloc(
+ AllocatorI* _allocator
+ , size_t _size
+ , size_t _align
+ , const char* _file = NULL
+ , uint32_t _line = 0
+ );
+
+ ///
+ void alignedFree(
+ AllocatorI* _allocator
+ , void* _ptr
+ , size_t /*_align*/
+ , const char* _file = NULL
+ , uint32_t _line = 0
+ );
+
+ ///
+ void* alignedRealloc(
+ AllocatorI* _allocator
+ , void* _ptr
+ , size_t _size
+ , size_t _align
+ , const char* _file = NULL
+ , uint32_t _line = 0
+ );
+
+ ///
template <typename ObjectT>
- inline void deleteObject(AllocatorI* _allocator, ObjectT* _object, size_t _align = 0, const char* _file = NULL, uint32_t _line = 0)
- {
- if (NULL != _object)
- {
- _object->~ObjectT();
- free(_allocator, _object, _align, _file, _line);
- }
- }
+ void deleteObject(
+ AllocatorI* _allocator
+ , ObjectT* _object
+ , size_t _align = 0
+ , const char* _file = NULL
+ , uint32_t _line = 0
+ );
} // namespace bx
+#include "allocator.inl"
+
#endif // BX_ALLOCATOR_H_HEADER_GUARD
diff --git a/3rdparty/bx/include/bx/allocator.inl b/3rdparty/bx/include/bx/allocator.inl
new file mode 100644
index 00000000000..67a4a5325c5
--- /dev/null
+++ b/3rdparty/bx/include/bx/allocator.inl
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#ifndef BX_ALLOCATOR_H_HEADER_GUARD
+# error "Must be included from bx/allocator.h"
+#endif // BX_ALLOCATOR_H_HEADER_GUARD
+
+namespace bx
+{
+ inline AllocatorI::~AllocatorI()
+ {
+ }
+
+ inline bool isAligned(const void* _ptr, size_t _align)
+ {
+ union { const void* ptr; uintptr_t addr; } un;
+ un.ptr = _ptr;
+ return 0 == (un.addr & (_align-1) );
+ }
+
+ inline void* alignPtr(void* _ptr, size_t _extra, size_t _align)
+ {
+ union { void* ptr; uintptr_t addr; } un;
+ un.ptr = _ptr;
+ uintptr_t unaligned = un.addr + _extra; // space for header
+ uintptr_t mask = _align-1;
+ uintptr_t aligned = BX_ALIGN_MASK(unaligned, mask);
+ un.addr = aligned;
+ return un.ptr;
+ }
+
+ inline void* alloc(AllocatorI* _allocator, size_t _size, size_t _align, const char* _file, uint32_t _line)
+ {
+ return _allocator->realloc(NULL, _size, _align, _file, _line);
+ }
+
+ inline void free(AllocatorI* _allocator, void* _ptr, size_t _align, const char* _file, uint32_t _line)
+ {
+ _allocator->realloc(_ptr, 0, _align, _file, _line);
+ }
+
+ inline void* realloc(AllocatorI* _allocator, void* _ptr, size_t _size, size_t _align, const char* _file, uint32_t _line)
+ {
+ return _allocator->realloc(_ptr, _size, _align, _file, _line);
+ }
+
+ inline void* alignedAlloc(AllocatorI* _allocator, size_t _size, size_t _align, const char* _file, uint32_t _line)
+ {
+ size_t total = _size + _align;
+ uint8_t* ptr = (uint8_t*)alloc(_allocator, total, 0, _file, _line);
+ uint8_t* aligned = (uint8_t*)alignPtr(ptr, sizeof(uint32_t), _align);
+ uint32_t* header = (uint32_t*)aligned - 1;
+ *header = uint32_t(aligned - ptr);
+ return aligned;
+ }
+
+ inline void alignedFree(AllocatorI* _allocator, void* _ptr, size_t _align, const char* _file, uint32_t _line)
+ {
+ BX_UNUSED(_align);
+ uint8_t* aligned = (uint8_t*)_ptr;
+ uint32_t* header = (uint32_t*)aligned - 1;
+ uint8_t* ptr = aligned - *header;
+ free(_allocator, ptr, 0, _file, _line);
+ }
+
+ inline void* alignedRealloc(AllocatorI* _allocator, void* _ptr, size_t _size, size_t _align, const char* _file, uint32_t _line)
+ {
+ if (NULL == _ptr)
+ {
+ return alignedAlloc(_allocator, _size, _align, _file, _line);
+ }
+
+ uint8_t* aligned = (uint8_t*)_ptr;
+ uint32_t offset = *( (uint32_t*)aligned - 1);
+ uint8_t* ptr = aligned - offset;
+ size_t total = _size + _align;
+ ptr = (uint8_t*)realloc(_allocator, ptr, total, 0, _file, _line);
+ uint8_t* newAligned = (uint8_t*)alignPtr(ptr, sizeof(uint32_t), _align);
+
+ if (newAligned == aligned)
+ {
+ return aligned;
+ }
+
+ aligned = ptr + offset;
+ ::memmove(newAligned, aligned, _size);
+ uint32_t* header = (uint32_t*)newAligned - 1;
+ *header = uint32_t(newAligned - ptr);
+ return newAligned;
+ }
+
+ template <typename ObjectT>
+ inline void deleteObject(AllocatorI* _allocator, ObjectT* _object, size_t _align, const char* _file, uint32_t _line)
+ {
+ if (NULL != _object)
+ {
+ _object->~ObjectT();
+ free(_allocator, _object, _align, _file, _line);
+ }
+ }
+
+} // namespace bx
diff --git a/3rdparty/bx/include/bx/bx.h b/3rdparty/bx/include/bx/bx.h
index 65a50d08cb4..43ccba3cce1 100644
--- a/3rdparty/bx/include/bx/bx.h
+++ b/3rdparty/bx/include/bx/bx.h
@@ -8,7 +8,7 @@
#include <stdint.h> // uint32_t
#include <stdlib.h> // size_t
-#include <string.h> // memcpy
+#include <stddef.h> // ptrdiff_t
#include "config.h"
#include "macros.h"
@@ -45,39 +45,23 @@ namespace bx
Ty tmp = _a; _a = _b; _b = tmp;
}
- /// Check if pointer is aligned. _align must be power of two.
- inline bool isPtrAligned(const void* _ptr, size_t _align)
- {
- union { const void* ptr; size_t addr; } un;
- un.ptr = _ptr;
- return 0 == (un.addr & (_align-1) );
- }
+ ///
+ void* memCopy(void* _dst, const void* _src, size_t _numBytes);
- /// Scatter/gather memcpy.
- inline void memCopy(void* _dst, const void* _src, uint32_t _size, uint32_t _num, uint32_t _srcPitch, uint32_t _dstPitch)
- {
- const uint8_t* src = (const uint8_t*)_src;
- uint8_t* dst = (uint8_t*)_dst;
-
- for (uint32_t ii = 0; ii < _num; ++ii)
- {
- memcpy(dst, src, _size);
- src += _srcPitch;
- dst += _dstPitch;
- }
- }
+ ///
+ void memCopy(void* _dst, const void* _src, uint32_t _size, uint32_t _num, uint32_t _srcPitch, uint32_t _dstPitch);
///
- inline void gather(void* _dst, const void* _src, uint32_t _size, uint32_t _num, uint32_t _srcPitch)
- {
- memCopy(_dst, _src, _size, _num, _srcPitch, _size);
- }
+ void gather(void* _dst, const void* _src, uint32_t _size, uint32_t _num, uint32_t _srcPitch);
///
- inline void scatter(void* _dst, const void* _src, uint32_t _size, uint32_t _num, uint32_t _dstPitch)
- {
- memCopy(_dst, _src, _size, _num, _size, _dstPitch);
- }
+ void scatter(void* _dst, const void* _src, uint32_t _size, uint32_t _num, uint32_t _dstPitch);
+
+ ///
+ void* memMove(void* _dst, const void* _src, size_t _numBytes);
+
+ ///
+ void* memSet(void* _dst, uint8_t _ch, size_t _numBytes);
} // namespace bx
diff --git a/3rdparty/bx/include/bx/commandline.h b/3rdparty/bx/include/bx/commandline.h
index bafd48e3be2..9b9a397360b 100644
--- a/3rdparty/bx/include/bx/commandline.h
+++ b/3rdparty/bx/include/bx/commandline.h
@@ -7,197 +7,64 @@
#define BX_COMMANDLINE_H_HEADER_GUARD
#include "bx.h"
-#include "string.h"
namespace bx
{
+ /// Reference:
+ /// http://msdn.microsoft.com/en-us/library/a1y7w461.aspx
+ const char* tokenizeCommandLine(const char* _commandLine, char* _buffer, uint32_t& _bufferSize, int32_t& _argc, char* _argv[], int32_t _maxArgvs, char _term = '\0');
+
+ ///
class CommandLine
{
public:
- CommandLine(int _argc, char const* const* _argv)
- : m_argc(_argc)
- , m_argv(_argv)
- {
- }
-
- const char* findOption(const char* _long, const char* _default) const
- {
- const char* result = find(0, '\0', _long, 1);
- return result == NULL ? _default : result;
- }
-
- const char* findOption(const char _short, const char* _long, const char* _default) const
- {
- const char* result = find(0, _short, _long, 1);
- return result == NULL ? _default : result;
- }
-
- const char* findOption(const char* _long, int _numParams = 1) const
- {
- const char* result = find(0, '\0', _long, _numParams);
- return result;
- }
-
- const char* findOption(const char _short, const char* _long = NULL, int _numParams = 1) const
- {
- const char* result = find(0, _short, _long, _numParams);
- return result;
- }
-
- const char* findOption(int _skip, const char _short, const char* _long = NULL, int _numParams = 1) const
- {
- const char* result = find(_skip, _short, _long, _numParams);
- return result;
- }
-
- bool hasArg(const char _short, const char* _long = NULL) const
- {
- const char* arg = findOption(_short, _long, 0);
- return NULL != arg;
- }
-
- bool hasArg(const char* _long) const
- {
- const char* arg = findOption('\0', _long, 0);
- return NULL != arg;
- }
-
- bool hasArg(const char*& _value, const char _short, const char* _long = NULL) const
- {
- const char* arg = findOption(_short, _long, 1);
- _value = arg;
- return NULL != arg;
- }
-
- bool hasArg(int& _value, const char _short, const char* _long = NULL) const
- {
- const char* arg = findOption(_short, _long, 1);
- if (NULL != arg)
- {
- _value = atoi(arg);
- return true;
- }
-
- return false;
- }
-
- bool hasArg(unsigned int& _value, const char _short, const char* _long = NULL) const
- {
- const char* arg = findOption(_short, _long, 1);
- if (NULL != arg)
- {
- _value = atoi(arg);
- return true;
- }
-
- return false;
- }
-
- bool hasArg(float& _value, const char _short, const char* _long = NULL) const
- {
- const char* arg = findOption(_short, _long, 1);
- if (NULL != arg)
- {
- _value = float(atof(arg));
- return true;
- }
-
- return false;
- }
-
- bool hasArg(double& _value, const char _short, const char* _long = NULL) const
- {
- const char* arg = findOption(_short, _long, 1);
- if (NULL != arg)
- {
- _value = atof(arg);
- return true;
- }
-
- return false;
- }
-
- bool hasArg(bool& _value, const char _short, const char* _long = NULL) const
- {
- const char* arg = findOption(_short, _long, 1);
- if (NULL != arg)
- {
- if ('0' == *arg || (0 == stricmp(arg, "false") ) )
- {
- _value = false;
- }
- else if ('0' != *arg || (0 == stricmp(arg, "true") ) )
- {
- _value = true;
- }
-
- return true;
- }
-
- return false;
- }
+ ///
+ CommandLine(int32_t _argc, char const* const* _argv);
+
+ ///
+ const char* findOption(const char* _long, const char* _default) const;
+
+ ///
+ const char* findOption(const char _short, const char* _long, const char* _default) const;
+
+ ///
+ const char* findOption(const char* _long, int32_t _numParams = 1) const;
+
+ ///
+ const char* findOption(const char _short, const char* _long = NULL, int32_t _numParams = 1) const;
+
+ ///
+ const char* findOption(int32_t _skip, const char _short, const char* _long = NULL, int32_t _numParams = 1) const;
+
+ ///
+ bool hasArg(const char _short, const char* _long = NULL) const;
+
+ ///
+ bool hasArg(const char* _long) const;
+
+ ///
+ bool hasArg(const char*& _value, const char _short, const char* _long = NULL) const;
+
+ ///
+ bool hasArg(int32_t& _value, const char _short, const char* _long = NULL) const;
+
+ ///
+ bool hasArg(uint32_t& _value, const char _short, const char* _long = NULL) const;
+
+ ///
+ bool hasArg(float& _value, const char _short, const char* _long = NULL) const;
+
+ ///
+ bool hasArg(double& _value, const char _short, const char* _long = NULL) const;
+
+ ///
+ bool hasArg(bool& _value, const char _short, const char* _long = NULL) const;
private:
- const char* find(int _skip, const char _short, const char* _long, int _numParams) const
- {
- for (int ii = 0; ii < m_argc; ++ii)
- {
- const char* arg = m_argv[ii];
- if ('-' == *arg)
- {
- ++arg;
- if (_short == *arg)
- {
- if (1 == strlen(arg) )
- {
- if (0 == _skip)
- {
- if (0 == _numParams)
- {
- return "";
- }
- else if (ii+_numParams < m_argc
- && '-' != *m_argv[ii+1] )
- {
- return m_argv[ii+1];
- }
-
- return NULL;
- }
-
- --_skip;
- ii += _numParams;
- }
- }
- else if (NULL != _long
- && '-' == *arg
- && 0 == stricmp(arg+1, _long) )
- {
- if (0 == _skip)
- {
- if (0 == _numParams)
- {
- return "";
- }
- else if (ii+_numParams < m_argc
- && '-' != *m_argv[ii+1] )
- {
- return m_argv[ii+1];
- }
-
- return NULL;
- }
-
- --_skip;
- ii += _numParams;
- }
- }
- }
-
- return NULL;
- }
-
- int m_argc;
+ ///
+ const char* find(int32_t _skip, const char _short, const char* _long, int32_t _numParams) const;
+
+ int32_t m_argc;
char const* const* m_argv;
};
diff --git a/3rdparty/bx/include/bx/crtimpl.h b/3rdparty/bx/include/bx/crtimpl.h
index b2b3d64c95a..8176c6b9185 100644
--- a/3rdparty/bx/include/bx/crtimpl.h
+++ b/3rdparty/bx/include/bx/crtimpl.h
@@ -9,7 +9,6 @@
#include "bx.h"
#if BX_CONFIG_ALLOCATOR_CRT
-# include <malloc.h>
# include "allocator.h"
#endif // BX_CONFIG_ALLOCATOR_CRT
@@ -20,374 +19,129 @@
namespace bx
{
#if BX_CONFIG_ALLOCATOR_CRT
+ ///
class CrtAllocator : public AllocatorI
{
public:
- CrtAllocator()
- {
- }
-
- virtual ~CrtAllocator()
- {
- }
-
- virtual void* realloc(void* _ptr, size_t _size, size_t _align, const char* _file, uint32_t _line) BX_OVERRIDE
- {
- if (0 == _size)
- {
- if (NULL != _ptr)
- {
- if (BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT >= _align)
- {
- ::free(_ptr);
- return NULL;
- }
-
-# if BX_COMPILER_MSVC
- BX_UNUSED(_file, _line);
- _aligned_free(_ptr);
-# else
- bx::alignedFree(this, _ptr, _align, _file, _line);
-# endif // BX_
- }
-
- return NULL;
- }
- else if (NULL == _ptr)
- {
- if (BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT >= _align)
- {
- return ::malloc(_size);
- }
-
-# if BX_COMPILER_MSVC
- BX_UNUSED(_file, _line);
- return _aligned_malloc(_size, _align);
-# else
- return bx::alignedAlloc(this, _size, _align, _file, _line);
-# endif // BX_
- }
-
- if (BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT >= _align)
- {
- return ::realloc(_ptr, _size);
- }
-
-# if BX_COMPILER_MSVC
- BX_UNUSED(_file, _line);
- return _aligned_realloc(_ptr, _size, _align);
-# else
- return bx::alignedRealloc(this, _ptr, _size, _align, _file, _line);
-# endif // BX_
- }
+ ///
+ CrtAllocator();
+
+ ///
+ virtual ~CrtAllocator();
+
+ ///
+ virtual void* realloc(void* _ptr, size_t _size, size_t _align, const char* _file, uint32_t _line) BX_OVERRIDE;
};
#endif // BX_CONFIG_ALLOCATOR_CRT
#if BX_CONFIG_CRT_FILE_READER_WRITER
-
-# if BX_CRT_MSVC
-# define fseeko64 _fseeki64
-# define ftello64 _ftelli64
-# elif 0 \
- || BX_PLATFORM_ANDROID \
- || BX_PLATFORM_BSD \
- || BX_PLATFORM_IOS \
- || BX_PLATFORM_OSX \
- || BX_PLATFORM_QNX
-# define fseeko64 fseeko
-# define ftello64 ftello
-# elif BX_PLATFORM_PS4
-# define fseeko64 fseek
-# define ftello64 ftell
-# endif // BX_
-
+ ///
class CrtFileReader : public FileReaderI
{
public:
- CrtFileReader()
- : m_file(NULL)
- {
- }
-
- virtual ~CrtFileReader()
- {
- }
-
- virtual bool open(const char* _filePath, Error* _err) BX_OVERRIDE
- {
- BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
-
- if (NULL != m_file)
- {
- BX_ERROR_SET(_err, BX_ERROR_READERWRITER_ALREADY_OPEN, "CrtFileReader: File is already open.");
- return false;
- }
-
- m_file = fopen(_filePath, "rb");
- if (NULL == m_file)
- {
- BX_ERROR_SET(_err, BX_ERROR_READERWRITER_OPEN, "CrtFileReader: Failed to open file.");
- return false;
- }
-
- return true;
- }
-
- virtual void close() BX_OVERRIDE
- {
- BX_CHECK(NULL != m_file, "Reader/Writer file is not open.");
- fclose(m_file);
- m_file = NULL;
- }
-
- virtual int64_t seek(int64_t _offset = 0, Whence::Enum _whence = Whence::Current) BX_OVERRIDE
- {
- BX_CHECK(NULL != m_file, "Reader/Writer file is not open.");
- fseeko64(m_file, _offset, _whence);
- return ftello64(m_file);
- }
-
- virtual int32_t read(void* _data, int32_t _size, Error* _err) BX_OVERRIDE
- {
- BX_CHECK(NULL != m_file, "Reader/Writer file is not open.");
- BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
-
- int32_t size = (int32_t)fread(_data, 1, _size, m_file);
- if (size != _size)
- {
- if (0 != feof(m_file) )
- {
- BX_ERROR_SET(_err, BX_ERROR_READERWRITER_EOF, "CrtFileReader: EOF.");
- }
- else if (0 != ferror(m_file) )
- {
- BX_ERROR_SET(_err, BX_ERROR_READERWRITER_READ, "CrtFileReader: read error.");
- }
-
- return size >= 0 ? size : 0;
- }
-
- return size;
- }
+ ///
+ CrtFileReader();
+
+ ///
+ virtual ~CrtFileReader();
+
+ ///
+ virtual bool open(const char* _filePath, Error* _err) BX_OVERRIDE;
+
+ ///
+ virtual void close() BX_OVERRIDE;
+
+ ///
+ virtual int64_t seek(int64_t _offset = 0, Whence::Enum _whence = Whence::Current) BX_OVERRIDE;
+
+ ///
+ virtual int32_t read(void* _data, int32_t _size, Error* _err) BX_OVERRIDE;
private:
- FILE* m_file;
+ void* m_file;
};
+ ///
class CrtFileWriter : public FileWriterI
{
public:
- CrtFileWriter()
- : m_file(NULL)
- {
- }
-
- virtual ~CrtFileWriter()
- {
- }
-
- virtual bool open(const char* _filePath, bool _append, Error* _err) BX_OVERRIDE
- {
- BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
-
- if (NULL != m_file)
- {
- BX_ERROR_SET(_err, BX_ERROR_READERWRITER_ALREADY_OPEN, "CrtFileReader: File is already open.");
- return false;
- }
-
- m_file = fopen(_filePath, _append ? "ab" : "wb");
-
- if (NULL == m_file)
- {
- BX_ERROR_SET(_err, BX_ERROR_READERWRITER_OPEN, "CrtFileWriter: Failed to open file.");
- return false;
- }
-
- return true;
- }
-
- virtual void close() BX_OVERRIDE
- {
- BX_CHECK(NULL != m_file, "Reader/Writer file is not open.");
- fclose(m_file);
- m_file = NULL;
- }
-
- virtual int64_t seek(int64_t _offset = 0, Whence::Enum _whence = Whence::Current) BX_OVERRIDE
- {
- BX_CHECK(NULL != m_file, "Reader/Writer file is not open.");
- fseeko64(m_file, _offset, _whence);
- return ftello64(m_file);
- }
-
- virtual int32_t write(const void* _data, int32_t _size, Error* _err) BX_OVERRIDE
- {
- BX_CHECK(NULL != m_file, "Reader/Writer file is not open.");
- BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
-
- int32_t size = (int32_t)fwrite(_data, 1, _size, m_file);
- if (size != _size)
- {
- BX_ERROR_SET(_err, BX_ERROR_READERWRITER_WRITE, "CrtFileWriter: write failed.");
- return size >= 0 ? size : 0;
- }
-
- return size;
- }
+ ///
+ CrtFileWriter();
+
+ ///
+ virtual ~CrtFileWriter();
+
+ ///
+ virtual bool open(const char* _filePath, bool _append, Error* _err) BX_OVERRIDE;
+
+ ///
+ virtual void close() BX_OVERRIDE;
+
+ ///
+ virtual int64_t seek(int64_t _offset = 0, Whence::Enum _whence = Whence::Current) BX_OVERRIDE;
+
+ ///
+ virtual int32_t write(const void* _data, int32_t _size, Error* _err) BX_OVERRIDE;
private:
- FILE* m_file;
+ void* m_file;
};
#endif // BX_CONFIG_CRT_FILE_READER_WRITER
#if BX_CONFIG_CRT_PROCESS
-
-#if BX_CRT_MSVC
-# define popen _popen
-# define pclose _pclose
-#endif // BX_CRT_MSVC
-
+ ///
class ProcessReader : public ReaderOpenI, public CloserI, public ReaderI
{
public:
- ProcessReader()
- : m_file(NULL)
- {
- }
-
- ~ProcessReader()
- {
- BX_CHECK(NULL == m_file, "Process not closed!");
- }
-
- virtual bool open(const char* _command, Error* _err) BX_OVERRIDE
- {
- BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
-
- if (NULL != m_file)
- {
- BX_ERROR_SET(_err, BX_ERROR_READERWRITER_ALREADY_OPEN, "ProcessReader: File is already open.");
- return false;
- }
-
- m_file = popen(_command, "r");
- if (NULL == m_file)
- {
- BX_ERROR_SET(_err, BX_ERROR_READERWRITER_OPEN, "ProcessReader: Failed to open process.");
- return false;
- }
-
- return true;
- }
-
- virtual void close() BX_OVERRIDE
- {
- BX_CHECK(NULL != m_file, "Process not open!");
- m_exitCode = pclose(m_file);
- m_file = NULL;
- }
-
- virtual int32_t read(void* _data, int32_t _size, Error* _err) BX_OVERRIDE
- {
- BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors."); BX_UNUSED(_err);
-
- int32_t size = (int32_t)fread(_data, 1, _size, m_file);
- if (size != _size)
- {
- if (0 != feof(m_file) )
- {
- BX_ERROR_SET(_err, BX_ERROR_READERWRITER_EOF, "ProcessReader: EOF.");
- }
- else if (0 != ferror(m_file) )
- {
- BX_ERROR_SET(_err, BX_ERROR_READERWRITER_READ, "ProcessReader: read error.");
- }
-
- return size >= 0 ? size : 0;
- }
-
- return size;
- }
-
- int32_t getExitCode() const
- {
- return m_exitCode;
- }
+ ///
+ ProcessReader();
+
+ ///
+ ~ProcessReader();
+
+ ///
+ virtual bool open(const char* _command, Error* _err) BX_OVERRIDE;
+
+ ///
+ virtual void close() BX_OVERRIDE;
+
+ ///
+ virtual int32_t read(void* _data, int32_t _size, Error* _err) BX_OVERRIDE;
+
+ ///
+ int32_t getExitCode() const;
private:
- FILE* m_file;
+ void* m_file;
int32_t m_exitCode;
};
+ ///
class ProcessWriter : public WriterOpenI, public CloserI, public WriterI
{
public:
- ProcessWriter()
- : m_file(NULL)
- {
- }
-
- ~ProcessWriter()
- {
- BX_CHECK(NULL == m_file, "Process not closed!");
- }
-
- virtual bool open(const char* _command, bool, Error* _err) BX_OVERRIDE
- {
- BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
-
- if (NULL != m_file)
- {
- BX_ERROR_SET(_err, BX_ERROR_READERWRITER_ALREADY_OPEN, "ProcessWriter: File is already open.");
- return false;
- }
-
- m_file = popen(_command, "w");
- if (NULL == m_file)
- {
- BX_ERROR_SET(_err, BX_ERROR_READERWRITER_OPEN, "ProcessWriter: Failed to open process.");
- return false;
- }
-
- return true;
- }
-
- virtual void close() BX_OVERRIDE
- {
- BX_CHECK(NULL != m_file, "Process not open!");
- m_exitCode = pclose(m_file);
- m_file = NULL;
- }
-
- virtual int32_t write(const void* _data, int32_t _size, Error* _err) BX_OVERRIDE
- {
- BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors."); BX_UNUSED(_err);
-
- int32_t size = (int32_t)fwrite(_data, 1, _size, m_file);
- if (size != _size)
- {
- if (0 != ferror(m_file) )
- {
- BX_ERROR_SET(_err, BX_ERROR_READERWRITER_WRITE, "ProcessWriter: write error.");
- }
-
- return size >= 0 ? size : 0;
- }
-
- return size;
- }
-
- int32_t getExitCode() const
- {
- return m_exitCode;
- }
+ ///
+ ProcessWriter();
+
+ ///
+ ~ProcessWriter();
+
+ ///
+ virtual bool open(const char* _command, bool, Error* _err) BX_OVERRIDE;
+
+ ///
+ virtual void close() BX_OVERRIDE;
+
+ ///
+ virtual int32_t write(const void* _data, int32_t _size, Error* _err) BX_OVERRIDE;
+
+ ///
+ int32_t getExitCode() const;
private:
- FILE* m_file;
+ void* m_file;
int32_t m_exitCode;
};
-
#endif // BX_CONFIG_CRT_PROCESS
} // namespace bx
diff --git a/3rdparty/bx/include/bx/debug.h b/3rdparty/bx/include/bx/debug.h
index c94f744aad2..641a0ed82bf 100644
--- a/3rdparty/bx/include/bx/debug.h
+++ b/3rdparty/bx/include/bx/debug.h
@@ -7,69 +7,24 @@
#define BX_DEBUG_H_HEADER_GUARD
#include "bx.h"
-
-#if BX_PLATFORM_ANDROID
-# include <android/log.h>
-#elif BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE
-extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char* _str);
-#elif BX_PLATFORM_IOS || BX_PLATFORM_OSX
-# if defined(__OBJC__)
-# import <Foundation/NSObjCRuntime.h>
-# else
-# include <CoreFoundation/CFString.h>
-extern "C" void NSLog(CFStringRef _format, ...);
-# endif // defined(__OBJC__)
-#elif 0 // BX_PLATFORM_EMSCRIPTEN
-# include <emscripten.h>
-#else
-# include <stdio.h>
-#endif // BX_PLATFORM_WINDOWS
+#include <stdarg.h> // va_list
namespace bx
{
-#if BX_COMPILER_CLANG_ANALYZER
- inline __attribute__((analyzer_noreturn)) void debugBreak();
-#endif // BX_COMPILER_CLANG_ANALYZER
+ ///
+ void debugBreak();
+
+ ///
+ void debugOutput(const char* _out);
+
+ ///
+ void debugPrintfVargs(const char* _format, va_list _argList);
- inline void debugBreak()
- {
-#if BX_COMPILER_MSVC
- __debugbreak();
-#elif BX_CPU_ARM
- __builtin_trap();
-// asm("bkpt 0");
-#elif !BX_PLATFORM_NACL && BX_CPU_X86 && (BX_COMPILER_GCC || BX_COMPILER_CLANG)
- // NaCl doesn't like int 3:
- // NativeClient: NaCl module load failed: Validation failure. File violates Native Client safety rules.
- __asm__ ("int $3");
-#else // cross platform implementation
- int* int3 = (int*)3L;
- *int3 = 3;
-#endif // BX
- }
+ ///
+ void debugPrintf(const char* _format, ...);
- inline void debugOutput(const char* _out)
- {
-#if BX_PLATFORM_ANDROID
-# ifndef BX_ANDROID_LOG_TAG
-# define BX_ANDROID_LOG_TAG ""
-# endif // BX_ANDROID_LOG_TAG
- __android_log_write(ANDROID_LOG_DEBUG, BX_ANDROID_LOG_TAG, _out);
-#elif BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE
- OutputDebugStringA(_out);
-#elif BX_PLATFORM_IOS || BX_PLATFORM_OSX
-# if defined(__OBJC__)
- NSLog(@"%s", _out);
-# else
- NSLog(__CFStringMakeConstantString("%s"), _out);
-# endif // defined(__OBJC__)
-#elif 0 // BX_PLATFORM_EMSCRIPTEN
- emscripten_log(EM_LOG_CONSOLE, "%s", _out);
-#else
- fputs(_out, stdout);
- fflush(stdout);
-#endif // BX_PLATFORM_
- }
+ ///
+ void debugPrintfData(const void* _data, uint32_t _size, const char* _format, ...);
} // namespace bx
diff --git a/3rdparty/bx/include/bx/easing.h b/3rdparty/bx/include/bx/easing.h
index 3db6eec53a2..9efbc515378 100644
--- a/3rdparty/bx/include/bx/easing.h
+++ b/3rdparty/bx/include/bx/easing.h
@@ -14,6 +14,7 @@
namespace bx
{
+ ///
struct Easing
{
enum Enum
@@ -64,252 +65,134 @@ namespace bx
};
};
+ ///
typedef float (*EaseFn)(float _t);
- template<EaseFn ease>
- float easeOut(float _t)
- {
- return 1.0f - ease(1.0f - _t);
- }
+ ///
+ float easeLinear(float _t);
- template<EaseFn easeFrom0toH, EaseFn easeFromHto1>
- float easeMix(float _t)
- {
- return _t < 0.5f
- ? easeFrom0toH(2.0f*_t)*0.5f
- : easeFromHto1(2.0f*_t - 1.0f)*0.5f + 0.5f
- ;
- }
+ ///
+ float easeInQuad(float _t);
- inline float easeLinear(float _t)
- {
- return _t;
- }
+ ///
+ float easeOutQuad(float _t);
- inline float easeInQuad(float _t)
- {
- return fsq(_t);
- }
+ ///
+ float easeInOutQuad(float _t);
- inline float easeOutQuad(float _t)
- {
- return easeOut<easeInQuad>(_t);
- }
+ ///
+ float easeOutInQuad(float _t);
- inline float easeInOutQuad(float _t)
- {
- return easeMix<easeInQuad, easeOutQuad>(_t);
- }
+ ///
+ float easeInCubic(float _t);
- inline float easeOutInQuad(float _t)
- {
- return easeMix<easeOutQuad, easeInQuad>(_t);
- }
+ ///
+ float easeOutCubic(float _t);
- inline float easeInCubic(float _t)
- {
- return _t*_t*_t;
- }
+ ///
+ float easeInOutCubic(float _t);
- inline float easeOutCubic(float _t)
- {
- return easeOut<easeInCubic>(_t);
- }
+ ///
+ float easeOutInCubic(float _t);
- inline float easeInOutCubic(float _t)
- {
- return easeMix<easeInCubic, easeOutCubic>(_t);
- }
+ ///
+ float easeInQuart(float _t);
- inline float easeOutInCubic(float _t)
- {
- return easeMix<easeOutCubic, easeInCubic>(_t);
- }
+ ///
+ float easeOutQuart(float _t);
- inline float easeInQuart(float _t)
- {
- return _t*_t*_t*_t;
- }
+ ///
+ float easeInOutQuart(float _t);
- inline float easeOutQuart(float _t)
- {
- return easeOut<easeInQuart>(_t);
- }
+ ///
+ float easeOutInQuart(float _t);
- inline float easeInOutQuart(float _t)
- {
- return easeMix<easeInQuart, easeOutQuart>(_t);
- }
-
- inline float easeOutInQuart(float _t)
- {
- return easeMix<easeOutQuart, easeInQuart>(_t);
- }
-
- inline float easeInQuint(float _t)
- {
- return _t*_t*_t*_t*_t;
- }
-
- inline float easeOutQuint(float _t)
- {
- return easeOut<easeInQuint>(_t);
- }
+ ///
+ float easeInQuint(float _t);
- inline float easeInOutQuint(float _t)
- {
- return easeMix<easeInQuint, easeOutQuint>(_t);
- }
+ ///
+ float easeOutQuint(float _t);
- inline float easeOutInQuint(float _t)
- {
- return easeMix<easeOutQuint, easeInQuint>(_t);
- }
+ ///
+ float easeInOutQuint(float _t);
- inline float easeInSine(float _t)
- {
- return 1.0f - fcos(_t*piHalf);
- }
+ ///
+ float easeOutInQuint(float _t);
- inline float easeOutSine(float _t)
- {
- return easeOut<easeInSine>(_t);
- }
+ ///
+ float easeInSine(float _t);
- inline float easeInOutSine(float _t)
- {
- return easeMix<easeInSine, easeOutSine>(_t);
- }
+ ///
+ float easeOutSine(float _t);
- inline float easeOutInSine(float _t)
- {
- return easeMix<easeOutSine, easeInSine>(_t);
- }
+ ///
+ float easeInOutSine(float _t);
- inline float easeInExpo(float _t)
- {
- return fpow(2.0f, 10.0f * (_t - 1.0f) ) - 0.001f;
- }
+ ///
+ float easeOutInSine(float _t);
- inline float easeOutExpo(float _t)
- {
- return easeOut<easeInExpo>(_t);
- }
+ ///
+ float easeInExpo(float _t);
- inline float easeInOutExpo(float _t)
- {
- return easeMix<easeInExpo, easeOutExpo>(_t);
- }
+ ///
+ float easeOutExpo(float _t);
- inline float easeOutInExpo(float _t)
- {
- return easeMix<easeOutExpo, easeInExpo>(_t);
- }
+ ///
+ float easeInOutExpo(float _t);
- inline float easeInCirc(float _t)
- {
- return -(fsqrt(1.0f - _t*_t) - 1.0f);
- }
+ ///
+ float easeOutInExpo(float _t);
- inline float easeOutCirc(float _t)
- {
- return easeOut<easeInCirc>(_t);
- }
+ ///
+ float easeInCirc(float _t);
- inline float easeInOutCirc(float _t)
- {
- return easeMix<easeInCirc, easeOutCirc>(_t);
- }
+ ///
+ float easeOutCirc(float _t);
- inline float easeOutInCirc(float _t)
- {
- return easeMix<easeOutCirc, easeInCirc>(_t);
- }
+ ///
+ float easeInOutCirc(float _t);
- inline float easeOutElastic(float _t)
- {
- return fpow(2.0f, -10.0f*_t)*fsin( (_t-0.3f/4.0f)*(2.0f*pi)/0.3f) + 1.0f;
- }
+ ///
+ float easeOutInCirc(float _t);
- inline float easeInElastic(float _t)
- {
- return easeOut<easeOutElastic>(_t);
- }
+ ///
+ float easeOutElastic(float _t);
- inline float easeInOutElastic(float _t)
- {
- return easeMix<easeInElastic, easeOutElastic>(_t);
- }
+ ///
+ float easeInElastic(float _t);
- inline float easeOutInElastic(float _t)
- {
- return easeMix<easeOutElastic, easeInElastic>(_t);
- }
+ ///
+ float easeInOutElastic(float _t);
- inline float easeInBack(float _t)
- {
- return easeInCubic(_t) - _t*fsin(_t*pi);
- }
+ ///
+ float easeOutInElastic(float _t);
- inline float easeOutBack(float _t)
- {
- return easeOut<easeInBack>(_t);
- }
+ ///
+ float easeInBack(float _t);
- inline float easeInOutBack(float _t)
- {
- return easeMix<easeInBack, easeOutBack>(_t);
- }
+ ///
+ float easeOutBack(float _t);
- inline float easeOutInBack(float _t)
- {
- return easeMix<easeOutBack, easeInBack>(_t);
- }
+ ///
+ float easeInOutBack(float _t);
- inline float easeOutBounce(float _t)
- {
- if (4.0f/11.0f > _t)
- {
- return 121.0f/16.0f*_t*_t;
- }
+ ///
+ float easeOutInBack(float _t);
- if (8.0f/11.0f > _t)
- {
- return 363.0f/40.0f*_t*_t
- - 99.0f/10.0f*_t
- + 17.0f/ 5.0f
- ;
- }
+ ///
+ float easeOutBounce(float _t);
- if (9.0f/10.0f > _t)
- {
- return 4356.0f/ 361.0f*_t*_t
- - 35442.0f/1805.0f*_t
- + 16061.0f/1805.0f
- ;
- }
-
- return 54.0f/ 5.0f*_t*_t
- - 513.0f/25.0f*_t
- + 268.0f/25.0f
- ;
- }
-
- inline float easeInBounce(float _t)
- {
- return easeOut<easeOutBounce>(_t);
- }
+ ///
+ float easeInBounce(float _t);
- inline float easeInOutBounce(float _t)
- {
- return easeMix<easeInBounce, easeOutBounce>(_t);
- }
+ ///
+ float easeInOutBounce(float _t);
- inline float easeOutInBounce(float _t)
- {
- return easeMix<easeOutBounce, easeInBounce>(_t);
- }
+ ///
+ float easeOutInBounce(float _t);
} // namespace bx
+#include "easing.inl"
+
#endif // BX_EASING_H_HEADER_GUARD
diff --git a/3rdparty/bx/include/bx/easing.inl b/3rdparty/bx/include/bx/easing.inl
new file mode 100644
index 00000000000..b23edb1128a
--- /dev/null
+++ b/3rdparty/bx/include/bx/easing.inl
@@ -0,0 +1,256 @@
+/*
+ * Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#ifndef BX_EASING_H_HEADER_GUARD
+# error "Must be included from bx/easing.h!"
+#endif // BX_EASING_H_HEADER_GUARD
+
+namespace bx
+{
+ template<EaseFn ease>
+ float easeOut(float _t)
+ {
+ return 1.0f - ease(1.0f - _t);
+ }
+
+ template<EaseFn easeFrom0toH, EaseFn easeFromHto1>
+ float easeMix(float _t)
+ {
+ return _t < 0.5f
+ ? easeFrom0toH(2.0f*_t)*0.5f
+ : easeFromHto1(2.0f*_t - 1.0f)*0.5f + 0.5f
+ ;
+ }
+
+ inline float easeLinear(float _t)
+ {
+ return _t;
+ }
+
+ inline float easeInQuad(float _t)
+ {
+ return fsq(_t);
+ }
+
+ inline float easeOutQuad(float _t)
+ {
+ return easeOut<easeInQuad>(_t);
+ }
+
+ inline float easeInOutQuad(float _t)
+ {
+ return easeMix<easeInQuad, easeOutQuad>(_t);
+ }
+
+ inline float easeOutInQuad(float _t)
+ {
+ return easeMix<easeOutQuad, easeInQuad>(_t);
+ }
+
+ inline float easeInCubic(float _t)
+ {
+ return _t*_t*_t;
+ }
+
+ inline float easeOutCubic(float _t)
+ {
+ return easeOut<easeInCubic>(_t);
+ }
+
+ inline float easeInOutCubic(float _t)
+ {
+ return easeMix<easeInCubic, easeOutCubic>(_t);
+ }
+
+ inline float easeOutInCubic(float _t)
+ {
+ return easeMix<easeOutCubic, easeInCubic>(_t);
+ }
+
+ inline float easeInQuart(float _t)
+ {
+ return _t*_t*_t*_t;
+ }
+
+ inline float easeOutQuart(float _t)
+ {
+ return easeOut<easeInQuart>(_t);
+ }
+
+ inline float easeInOutQuart(float _t)
+ {
+ return easeMix<easeInQuart, easeOutQuart>(_t);
+ }
+
+ inline float easeOutInQuart(float _t)
+ {
+ return easeMix<easeOutQuart, easeInQuart>(_t);
+ }
+
+ inline float easeInQuint(float _t)
+ {
+ return _t*_t*_t*_t*_t;
+ }
+
+ inline float easeOutQuint(float _t)
+ {
+ return easeOut<easeInQuint>(_t);
+ }
+
+ inline float easeInOutQuint(float _t)
+ {
+ return easeMix<easeInQuint, easeOutQuint>(_t);
+ }
+
+ inline float easeOutInQuint(float _t)
+ {
+ return easeMix<easeOutQuint, easeInQuint>(_t);
+ }
+
+ inline float easeInSine(float _t)
+ {
+ return 1.0f - fcos(_t*piHalf);
+ }
+
+ inline float easeOutSine(float _t)
+ {
+ return easeOut<easeInSine>(_t);
+ }
+
+ inline float easeInOutSine(float _t)
+ {
+ return easeMix<easeInSine, easeOutSine>(_t);
+ }
+
+ inline float easeOutInSine(float _t)
+ {
+ return easeMix<easeOutSine, easeInSine>(_t);
+ }
+
+ inline float easeInExpo(float _t)
+ {
+ return fpow(2.0f, 10.0f * (_t - 1.0f) ) - 0.001f;
+ }
+
+ inline float easeOutExpo(float _t)
+ {
+ return easeOut<easeInExpo>(_t);
+ }
+
+ inline float easeInOutExpo(float _t)
+ {
+ return easeMix<easeInExpo, easeOutExpo>(_t);
+ }
+
+ inline float easeOutInExpo(float _t)
+ {
+ return easeMix<easeOutExpo, easeInExpo>(_t);
+ }
+
+ inline float easeInCirc(float _t)
+ {
+ return -(fsqrt(1.0f - _t*_t) - 1.0f);
+ }
+
+ inline float easeOutCirc(float _t)
+ {
+ return easeOut<easeInCirc>(_t);
+ }
+
+ inline float easeInOutCirc(float _t)
+ {
+ return easeMix<easeInCirc, easeOutCirc>(_t);
+ }
+
+ inline float easeOutInCirc(float _t)
+ {
+ return easeMix<easeOutCirc, easeInCirc>(_t);
+ }
+
+ inline float easeOutElastic(float _t)
+ {
+ return fpow(2.0f, -10.0f*_t)*fsin( (_t-0.3f/4.0f)*(2.0f*pi)/0.3f) + 1.0f;
+ }
+
+ inline float easeInElastic(float _t)
+ {
+ return easeOut<easeOutElastic>(_t);
+ }
+
+ inline float easeInOutElastic(float _t)
+ {
+ return easeMix<easeInElastic, easeOutElastic>(_t);
+ }
+
+ inline float easeOutInElastic(float _t)
+ {
+ return easeMix<easeOutElastic, easeInElastic>(_t);
+ }
+
+ inline float easeInBack(float _t)
+ {
+ return easeInCubic(_t) - _t*fsin(_t*pi);
+ }
+
+ inline float easeOutBack(float _t)
+ {
+ return easeOut<easeInBack>(_t);
+ }
+
+ inline float easeInOutBack(float _t)
+ {
+ return easeMix<easeInBack, easeOutBack>(_t);
+ }
+
+ inline float easeOutInBack(float _t)
+ {
+ return easeMix<easeOutBack, easeInBack>(_t);
+ }
+
+ inline float easeOutBounce(float _t)
+ {
+ if (4.0f/11.0f > _t)
+ {
+ return 121.0f/16.0f*_t*_t;
+ }
+
+ if (8.0f/11.0f > _t)
+ {
+ return 363.0f/40.0f*_t*_t
+ - 99.0f/10.0f*_t
+ + 17.0f/ 5.0f
+ ;
+ }
+
+ if (9.0f/10.0f > _t)
+ {
+ return 4356.0f/ 361.0f*_t*_t
+ - 35442.0f/1805.0f*_t
+ + 16061.0f/1805.0f
+ ;
+ }
+
+ return 54.0f/ 5.0f*_t*_t
+ - 513.0f/25.0f*_t
+ + 268.0f/25.0f
+ ;
+ }
+
+ inline float easeInBounce(float _t)
+ {
+ return easeOut<easeOutBounce>(_t);
+ }
+
+ inline float easeInOutBounce(float _t)
+ {
+ return easeMix<easeInBounce, easeOutBounce>(_t);
+ }
+
+ inline float easeOutInBounce(float _t)
+ {
+ return easeMix<easeOutBounce, easeInBounce>(_t);
+ }
+
+} // namespace bx
diff --git a/3rdparty/bx/include/bx/endian.h b/3rdparty/bx/include/bx/endian.h
index 23e9a665b63..c687d4fa0f2 100644
--- a/3rdparty/bx/include/bx/endian.h
+++ b/3rdparty/bx/include/bx/endian.h
@@ -10,78 +10,41 @@
namespace bx
{
- inline uint16_t endianSwap(uint16_t _in)
- {
- return (_in>>8) | (_in<<8);
- }
-
- inline uint32_t endianSwap(uint32_t _in)
- {
- return (_in>>24) | (_in<<24)
- | ( (_in&0x00ff0000)>>8) | ( (_in&0x0000ff00)<<8)
- ;
- }
+ ///
+ int16_t endianSwap(int16_t _in);
- inline uint64_t endianSwap(uint64_t _in)
- {
- return (_in>>56) | (_in<<56)
- | ( (_in&UINT64_C(0x00ff000000000000) )>>40) | ( (_in&UINT64_C(0x000000000000ff00) )<<40)
- | ( (_in&UINT64_C(0x0000ff0000000000) )>>24) | ( (_in&UINT64_C(0x0000000000ff0000) )<<24)
- | ( (_in&UINT64_C(0x000000ff00000000) )>>8) | ( (_in&UINT64_C(0x00000000ff000000) )<<8)
- ;
- }
+ ///
+ uint16_t endianSwap(uint16_t _in);
- inline int16_t endianSwap(int16_t _in)
- {
- return (int16_t)endianSwap( (uint16_t)_in);
- }
+ ///
+ int32_t endianSwap(int32_t _in);
- inline int32_t endianSwap(int32_t _in)
- {
- return (int32_t)endianSwap( (uint32_t)_in);
- }
+ ///
+ uint32_t endianSwap(uint32_t _in);
- inline int64_t endianSwap(int64_t _in)
- {
- return (int64_t)endianSwap( (uint64_t)_in);
- }
+ ///
+ int64_t endianSwap(int64_t _in);
+
+ ///
+ uint64_t endianSwap(uint64_t _in);
/// Input argument is encoded as little endian, convert it if neccessary
/// depending on host CPU endianess.
template <typename Ty>
- inline Ty toLittleEndian(const Ty _in)
- {
-#if BX_CPU_ENDIAN_BIG
- return endianSwap(_in);
-#else
- return _in;
-#endif // BX_CPU_ENDIAN_BIG
- }
+ Ty toLittleEndian(const Ty _in);
/// Input argument is encoded as big endian, convert it if neccessary
/// depending on host CPU endianess.
template <typename Ty>
- inline Ty toBigEndian(const Ty _in)
- {
-#if BX_CPU_ENDIAN_LITTLE
- return endianSwap(_in);
-#else
- return _in;
-#endif // BX_CPU_ENDIAN_LITTLE
- }
+ Ty toBigEndian(const Ty _in);
/// If _littleEndian is true, converts input argument to from little endian
/// to host CPU endiness.
template <typename Ty>
- inline Ty toHostEndian(const Ty _in, bool _fromLittleEndian)
- {
-#if BX_CPU_ENDIAN_LITTLE
- return _fromLittleEndian ? _in : endianSwap(_in);
-#else
- return _fromLittleEndian ? endianSwap(_in) : _in;
-#endif // BX_CPU_ENDIAN_LITTLE
- }
+ Ty toHostEndian(const Ty _in, bool _fromLittleEndian);
} // namespace bx
+#include "endian.inl"
+
#endif // BX_ENDIAN_H_HEADER_GUARD
diff --git a/3rdparty/bx/include/bx/endian.inl b/3rdparty/bx/include/bx/endian.inl
new file mode 100644
index 00000000000..6ec7572c71c
--- /dev/null
+++ b/3rdparty/bx/include/bx/endian.inl
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#ifndef BX_ENDIAN_H_HEADER_GUARD
+# error "Must be included from bx/endian.h!"
+#endif // BX_ENDIAN_H_HEADER_GUARD
+
+namespace bx
+{
+ inline int16_t endianSwap(int16_t _in)
+ {
+ return (int16_t)endianSwap( (uint16_t)_in);
+ }
+
+ inline uint16_t endianSwap(uint16_t _in)
+ {
+ return (_in>>8) | (_in<<8);
+ }
+
+ inline int32_t endianSwap(int32_t _in)
+ {
+ return (int32_t)endianSwap( (uint32_t)_in);
+ }
+
+ inline uint32_t endianSwap(uint32_t _in)
+ {
+ return ( _in >>24) | ( _in <<24)
+ | ( (_in&0x00ff0000)>> 8) | ( (_in&0x0000ff00)<< 8)
+ ;
+ }
+
+ inline int64_t endianSwap(int64_t _in)
+ {
+ return (int64_t)endianSwap( (uint64_t)_in);
+ }
+
+ inline uint64_t endianSwap(uint64_t _in)
+ {
+ return (_in >>56) | ( _in <<56)
+ | ( (_in&UINT64_C(0x00ff000000000000) )>>40) | ( (_in&UINT64_C(0x000000000000ff00) )<<40)
+ | ( (_in&UINT64_C(0x0000ff0000000000) )>>24) | ( (_in&UINT64_C(0x0000000000ff0000) )<<24)
+ | ( (_in&UINT64_C(0x000000ff00000000) )>> 8) | ( (_in&UINT64_C(0x00000000ff000000) )<< 8)
+ ;
+ }
+
+ template <typename Ty>
+ inline Ty toLittleEndian(const Ty _in)
+ {
+#if BX_CPU_ENDIAN_BIG
+ return endianSwap(_in);
+#else
+ return _in;
+#endif // BX_CPU_ENDIAN_BIG
+ }
+
+ template <typename Ty>
+ inline Ty toBigEndian(const Ty _in)
+ {
+#if BX_CPU_ENDIAN_LITTLE
+ return endianSwap(_in);
+#else
+ return _in;
+#endif // BX_CPU_ENDIAN_LITTLE
+ }
+
+ template <typename Ty>
+ inline Ty toHostEndian(const Ty _in, bool _fromLittleEndian)
+ {
+#if BX_CPU_ENDIAN_LITTLE
+ return _fromLittleEndian ? _in : endianSwap(_in);
+#else
+ return _fromLittleEndian ? endianSwap(_in) : _in;
+#endif // BX_CPU_ENDIAN_LITTLE
+ }
+
+} // namespace bx
diff --git a/3rdparty/bx/include/bx/error.h b/3rdparty/bx/include/bx/error.h
index 598d5689c6c..72a8444342c 100644
--- a/3rdparty/bx/include/bx/error.h
+++ b/3rdparty/bx/include/bx/error.h
@@ -44,55 +44,29 @@ namespace bx
);
public:
- Error()
- : m_code(0)
- {
- }
-
- void reset()
- {
- m_code = 0;
- m_msg.clear();
- }
-
- void setError(ErrorResult _errorResult, const StringView& _msg)
- {
- BX_CHECK(0 != _errorResult.code, "Invalid ErrorResult passed to setError!");
-
- if (!isOk() )
- {
- return;
- }
-
- m_code = _errorResult.code;
- m_msg = _msg;
- }
-
- bool isOk() const
- {
- return 0 == m_code;
- }
-
- ErrorResult get() const
- {
- ErrorResult result = { m_code };
- return result;
- }
-
- const StringView& getMessage() const
- {
- return m_msg;
- }
-
- bool operator==(const ErrorResult& _rhs) const
- {
- return _rhs.code == m_code;
- }
-
- bool operator!=(const ErrorResult& _rhs) const
- {
- return _rhs.code != m_code;
- }
+ ///
+ Error();
+
+ ///
+ void reset();
+
+ ///
+ void setError(ErrorResult _errorResult, const StringView& _msg);
+
+ ///
+ bool isOk() const;
+
+ ///
+ ErrorResult get() const;
+
+ ///
+ const StringView& getMessage() const;
+
+ ///
+ bool operator==(const ErrorResult& _rhs) const;
+
+ ///
+ bool operator!=(const ErrorResult& _rhs) const;
private:
StringView m_msg;
@@ -108,16 +82,11 @@ namespace bx
);
public:
- ErrorScope(Error* _err)
- : m_err(_err)
- {
- BX_CHECK(NULL != _err, "_err can't be NULL");
- }
+ ///
+ ErrorScope(Error* _err);
- ~ErrorScope()
- {
- BX_CHECK(m_err->isOk(), "Error: %d", m_err->get().code);
- }
+ ///
+ ~ErrorScope();
private:
Error* m_err;
@@ -125,4 +94,6 @@ namespace bx
} // namespace bx
+#include "error.inl"
+
#endif // BX_ERROR_H_HEADER_GUARD
diff --git a/3rdparty/bx/include/bx/error.inl b/3rdparty/bx/include/bx/error.inl
new file mode 100644
index 00000000000..ac16c6f9841
--- /dev/null
+++ b/3rdparty/bx/include/bx/error.inl
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#ifndef BX_ERROR_H_HEADER_GUARD
+# error "Must be included from bx/error!"
+#endif // BX_ERROR_H_HEADER_GUARD
+
+namespace bx
+{
+ inline Error::Error()
+ : m_code(0)
+ {
+ }
+
+ inline void Error::reset()
+ {
+ m_code = 0;
+ m_msg.clear();
+ }
+
+ inline void Error::setError(ErrorResult _errorResult, const StringView& _msg)
+ {
+ BX_CHECK(0 != _errorResult.code, "Invalid ErrorResult passed to setError!");
+
+ if (!isOk() )
+ {
+ return;
+ }
+
+ m_code = _errorResult.code;
+ m_msg = _msg;
+ }
+
+ inline bool Error::isOk() const
+ {
+ return 0 == m_code;
+ }
+
+ inline ErrorResult Error::get() const
+ {
+ ErrorResult result = { m_code };
+ return result;
+ }
+
+ inline const StringView& Error::getMessage() const
+ {
+ return m_msg;
+ }
+
+ inline bool Error::operator==(const ErrorResult& _rhs) const
+ {
+ return _rhs.code == m_code;
+ }
+
+ inline bool Error::operator!=(const ErrorResult& _rhs) const
+ {
+ return _rhs.code != m_code;
+ }
+
+ inline ErrorScope::ErrorScope(Error* _err)
+ : m_err(_err)
+ {
+ BX_CHECK(NULL != _err, "_err can't be NULL");
+ }
+
+ inline ErrorScope::~ErrorScope()
+ {
+ BX_CHECK(m_err->isOk(), "Error: %d", m_err->get().code);
+ }
+
+} // namespace bx
diff --git a/3rdparty/bx/include/bx/foreach.h b/3rdparty/bx/include/bx/foreach.h
deleted file mode 100644
index 53a6dde7265..00000000000
--- a/3rdparty/bx/include/bx/foreach.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
- */
-
-#ifndef BX_FOREACH_H_HEADER_GUARD
-#define BX_FOREACH_H_HEADER_GUARD
-
-#include "bx.h"
-
-namespace bx
-{
- namespace foreach_ns
- {
- struct ContainerBase
- {
- };
-
- template <typename Ty>
- class Container : public ContainerBase
- {
- public:
- inline Container(const Ty& _container)
- : m_container(_container)
- , m_break(0)
- , m_it( _container.begin() )
- , m_itEnd( _container.end() )
- {
- }
-
- inline bool condition() const
- {
- return (!m_break++ && m_it != m_itEnd);
- }
-
- const Ty& m_container;
- mutable int m_break;
- mutable typename Ty::const_iterator m_it;
- mutable typename Ty::const_iterator m_itEnd;
- };
-
- template <typename Ty>
- inline Ty* pointer(const Ty&)
- {
- return 0;
- }
-
- template <typename Ty>
- inline Container<Ty> containerNew(const Ty& _container)
- {
- return Container<Ty>(_container);
- }
-
- template <typename Ty>
- inline const Container<Ty>* container(const ContainerBase* _base, const Ty*)
- {
- return static_cast<const Container<Ty>*>(_base);
- }
- } // namespace foreach_ns
-
-#define foreach(_variable, _container) \
- for (const bx::foreach_ns::ContainerBase &__temp_container__ = bx::foreach_ns::containerNew(_container); \
- bx::foreach_ns::container(&__temp_container__, true ? 0 : bx::foreach_ns::pointer(_container) )->condition(); \
- ++bx::foreach_ns::container(&__temp_container__, true ? 0 : bx::foreach_ns::pointer(_container) )->m_it) \
- for (_variable = *container(&__temp_container__, true ? 0 : bx::foreach_ns::pointer(_container) )->m_it; \
- bx::foreach_ns::container(&__temp_container__, true ? 0 : bx::foreach_ns::pointer(_container) )->m_break; \
- --bx::foreach_ns::container(&__temp_container__, true ? 0 : bx::foreach_ns::pointer(_container) )->m_break)
-
-} // namespace bx
-
-#endif // BX_FOREACH_H_HEADER_GUARD
diff --git a/3rdparty/bx/include/bx/fpumath.h b/3rdparty/bx/include/bx/fpumath.h
index c7438eb3105..4c04eb6dc52 100644
--- a/3rdparty/bx/include/bx/fpumath.h
+++ b/3rdparty/bx/include/bx/fpumath.h
@@ -14,11 +14,13 @@
namespace bx
{
- static const float pi = 3.14159265358979323846f;
- static const float invPi = 1.0f/3.14159265358979323846f;
- static const float piHalf = 1.57079632679489661923f;
- static const float sqrt2 = 1.41421356237309504880f;
+ extern const float pi;
+ extern const float invPi;
+ extern const float piHalf;
+ extern const float sqrt2;
+ extern const float huge;
+ ///
struct Handness
{
enum Enum
@@ -28,6 +30,7 @@ namespace bx
};
};
+ ///
struct NearFar
{
enum Enum
@@ -37,1425 +40,436 @@ namespace bx
};
};
- inline float toRad(float _deg)
- {
- return _deg * pi / 180.0f;
- }
-
- inline float toDeg(float _rad)
- {
- return _rad * 180.0f / pi;
- }
-
- inline float ffloor(float _f)
- {
- return floorf(_f);
- }
-
- inline float fceil(float _f)
- {
- return ceilf(_f);
- }
-
- inline float fround(float _f)
- {
- return ffloor(_f + 0.5f);
- }
-
- inline float fmin(float _a, float _b)
- {
- return _a < _b ? _a : _b;
- }
+ ///
+ float toRad(float _deg);
- inline float fmax(float _a, float _b)
- {
- return _a > _b ? _a : _b;
- }
+ ///
+ float toDeg(float _rad);
- inline float fmin3(float _a, float _b, float _c)
- {
- return fmin(_a, fmin(_b, _c) );
- }
+ ///
+ uint32_t floatToBits(float _a);
- inline float fmax3(float _a, float _b, float _c)
- {
- return fmax(_a, fmax(_b, _c) );
- }
+ ///
+ float bitsToFloat(uint32_t _a);
- inline float fclamp(float _a, float _min, float _max)
- {
- return fmin(fmax(_a, _min), _max);
- }
+ ///
+ uint64_t doubleToBits(double _a);
- inline float fsaturate(float _a)
- {
- return fclamp(_a, 0.0f, 1.0f);
- }
+ ///
+ double bitsToDouble(uint64_t _a);
- inline float flerp(float _a, float _b, float _t)
- {
- return _a + (_b - _a) * _t;
- }
+ ///
+ bool isNan(float _f);
- inline float fsign(float _a)
- {
- return _a < 0.0f ? -1.0f : 1.0f;
- }
+ ///
+ bool isNan(double _f);
- inline float fabsolute(float _a)
- {
- return fabsf(_a);
- }
+ ///
+ bool isFinite(float _f);
- inline float fsq(float _a)
- {
- return _a * _a;
- }
-
- inline float fsin(float _a)
- {
- return sinf(_a);
- }
+ ///
+ bool isFinite(double _f);
- inline float fasin(float _a)
- {
- return asinf(_a);
- }
+ ///
+ bool isInfinite(float _f);
- inline float fcos(float _a)
- {
- return cosf(_a);
- }
+ ///
+ bool isInfinite(double _f);
- inline float facos(float _a)
- {
- return acosf(_a);
- }
+ ///
+ float ffloor(float _f);
- inline float fpow(float _a, float _b)
- {
- return powf(_a, _b);
- }
+ ///
+ float fceil(float _f);
- inline float fexp2(float _a)
- {
- return fpow(2.0f, _a);
- }
+ ///
+ float fround(float _f);
- inline float flog(float _a)
- {
- return logf(_a);
- }
+ ///
+ float fmin(float _a, float _b);
- inline float flog2(float _a)
- {
- return flog(_a) * 1.442695041f;
- }
+ ///
+ float fmax(float _a, float _b);
- inline float fsqrt(float _a)
- {
- return sqrtf(_a);
- }
+ ///
+ float fmin3(float _a, float _b, float _c);
- inline float frsqrt(float _a)
- {
- return 1.0f/fsqrt(_a);
- }
+ ///
+ float fmax3(float _a, float _b, float _c);
- inline float ffract(float _a)
- {
- return _a - floorf(_a);
- }
+ ///
+ float fclamp(float _a, float _min, float _max);
- inline float fmod(float _a, float _b)
- {
- return fmodf(_a, _b);
- }
+ ///
+ float fsaturate(float _a);
- inline bool fequal(float _a, float _b, float _epsilon)
- {
- // http://realtimecollisiondetection.net/blog/?p=89
- const float lhs = fabsolute(_a - _b);
- const float rhs = _epsilon * fmax3(1.0f, fabsolute(_a), fabsolute(_b) );
- return lhs <= rhs;
- }
+ ///
+ float flerp(float _a, float _b, float _t);
- inline bool fequal(const float* __restrict _a, const float* __restrict _b, uint32_t _num, float _epsilon)
- {
- bool equal = fequal(_a[0], _b[0], _epsilon);
- for (uint32_t ii = 1; equal && ii < _num; ++ii)
- {
- equal = fequal(_a[ii], _b[ii], _epsilon);
- }
- return equal;
- }
+ ///
+ float fsign(float _a);
- inline float fwrap(float _a, float _wrap)
- {
- const float mod = fmod(_a, _wrap);
- const float result = mod < 0.0f ? _wrap + mod : mod;
- return result;
- }
+ ///
+ float fabsolute(float _a);
- inline float fstep(float _edge, float _a)
- {
- return _a < _edge ? 0.0f : 1.0f;
- }
+ ///
+ float fsq(float _a);
- inline float fpulse(float _a, float _start, float _end)
- {
- return fstep(_a, _start) - fstep(_a, _end);
- }
+ ///
+ float fsin(float _a);
- inline float fsmoothstep(float _a)
- {
- return fsq(_a)*(3.0f - 2.0f*_a);
- }
+ ///
+ float fasin(float _a);
- // References:
- // - Bias And Gain Are Your Friend
- // http://blog.demofox.org/2012/09/24/bias-and-gain-are-your-friend/
- // - http://demofox.org/biasgain.html
- inline float fbias(float _time, float _bias)
- {
- return _time / ( ( (1.0f/_bias - 2.0f)*(1.0f - _time) ) + 1.0f);
- }
+ ///
+ float fcos(float _a);
- inline float fgain(float _time, float _gain)
- {
- if (_time < 0.5f)
- {
- return fbias(_time * 2.0f, _gain) * 0.5f;
- }
+ ///
+ float facos(float _a);
- return fbias(_time * 2.0f - 1.0f, 1.0f - _gain) * 0.5f + 0.5f;
- }
+ ///
+ float fatan2(float _y, float _x);
- inline void vec3Move(float* __restrict _result, const float* __restrict _a)
- {
- _result[0] = _a[0];
- _result[1] = _a[1];
- _result[2] = _a[2];
- }
+ ///
+ float fpow(float _a, float _b);
- inline void vec3Abs(float* __restrict _result, const float* __restrict _a)
- {
- _result[0] = fabsolute(_a[0]);
- _result[1] = fabsolute(_a[1]);
- _result[2] = fabsolute(_a[2]);
- }
+ ///
+ float fexp2(float _a);
- inline void vec3Neg(float* __restrict _result, const float* __restrict _a)
- {
- _result[0] = -_a[0];
- _result[1] = -_a[1];
- _result[2] = -_a[2];
- }
+ ///
+ float flog(float _a);
- inline void vec3Add(float* __restrict _result, const float* __restrict _a, const float* __restrict _b)
- {
- _result[0] = _a[0] + _b[0];
- _result[1] = _a[1] + _b[1];
- _result[2] = _a[2] + _b[2];
- }
+ ///
+ float flog2(float _a);
- inline void vec3Add(float* __restrict _result, const float* __restrict _a, float _b)
- {
- _result[0] = _a[0] + _b;
- _result[1] = _a[1] + _b;
- _result[2] = _a[2] + _b;
- }
+ ///
+ float fsqrt(float _a);
- inline void vec3Sub(float* __restrict _result, const float* __restrict _a, const float* __restrict _b)
- {
- _result[0] = _a[0] - _b[0];
- _result[1] = _a[1] - _b[1];
- _result[2] = _a[2] - _b[2];
- }
+ ///
+ float frsqrt(float _a);
- inline void vec3Sub(float* __restrict _result, const float* __restrict _a, float _b)
- {
- _result[0] = _a[0] - _b;
- _result[1] = _a[1] - _b;
- _result[2] = _a[2] - _b;
- }
+ ///
+ float ffract(float _a);
- inline void vec3Mul(float* __restrict _result, const float* __restrict _a, const float* __restrict _b)
- {
- _result[0] = _a[0] * _b[0];
- _result[1] = _a[1] * _b[1];
- _result[2] = _a[2] * _b[2];
- }
+ ///
+ float fmod(float _a, float _b);
- inline void vec3Mul(float* __restrict _result, const float* __restrict _a, float _b)
- {
- _result[0] = _a[0] * _b;
- _result[1] = _a[1] * _b;
- _result[2] = _a[2] * _b;
- }
+ ///
+ bool fequal(float _a, float _b, float _epsilon);
- inline float vec3Dot(const float* __restrict _a, const float* __restrict _b)
- {
- return _a[0]*_b[0] + _a[1]*_b[1] + _a[2]*_b[2];
- }
+ ///
+ bool fequal(const float* __restrict _a, const float* __restrict _b, uint32_t _num, float _epsilon);
- inline void vec3Cross(float* __restrict _result, const float* __restrict _a, const float* __restrict _b)
- {
- _result[0] = _a[1]*_b[2] - _a[2]*_b[1];
- _result[1] = _a[2]*_b[0] - _a[0]*_b[2];
- _result[2] = _a[0]*_b[1] - _a[1]*_b[0];
- }
+ ///
+ float fwrap(float _a, float _wrap);
- inline float vec3Length(const float* _a)
- {
- return fsqrt(vec3Dot(_a, _a) );
- }
+ ///
+ float fstep(float _edge, float _a);
- inline void vec3Lerp(float* __restrict _result, const float* __restrict _a, const float* __restrict _b, float _t)
- {
- _result[0] = flerp(_a[0], _b[0], _t);
- _result[1] = flerp(_a[1], _b[1], _t);
- _result[2] = flerp(_a[2], _b[2], _t);
- }
+ ///
+ float fpulse(float _a, float _start, float _end);
- inline void vec3Lerp(float* __restrict _result, const float* __restrict _a, const float* __restrict _b, const float* __restrict _c)
- {
- _result[0] = flerp(_a[0], _b[0], _c[0]);
- _result[1] = flerp(_a[1], _b[1], _c[1]);
- _result[2] = flerp(_a[2], _b[2], _c[2]);
- }
+ ///
+ float fsmoothstep(float _a);
- inline float vec3Norm(float* __restrict _result, const float* __restrict _a)
- {
- const float len = vec3Length(_a);
- const float invLen = 1.0f/len;
- _result[0] = _a[0] * invLen;
- _result[1] = _a[1] * invLen;
- _result[2] = _a[2] * invLen;
- return len;
- }
-
- inline void vec3Min(float* __restrict _result, const float* __restrict _a, const float* __restrict _b)
- {
- _result[0] = fmin(_a[0], _b[0]);
- _result[1] = fmin(_a[1], _b[1]);
- _result[2] = fmin(_a[2], _b[2]);
- }
+ // References:
+ // - Bias And Gain Are Your Friend
+ // http://blog.demofox.org/2012/09/24/bias-and-gain-are-your-friend/
+ // - http://demofox.org/biasgain.html
+ ///
+ float fbias(float _time, float _bias);
- inline void vec3Max(float* __restrict _result, const float* __restrict _a, const float* __restrict _b)
- {
- _result[0] = fmax(_a[0], _b[0]);
- _result[1] = fmax(_a[1], _b[1]);
- _result[2] = fmax(_a[2], _b[2]);
- }
+ ///
+ float fgain(float _time, float _gain);
- inline void vec3Rcp(float* __restrict _result, const float* __restrict _a)
- {
- _result[0] = 1.0f / _a[0];
- _result[1] = 1.0f / _a[1];
- _result[2] = 1.0f / _a[2];
- }
+ ///
+ void vec3Move(float* __restrict _result, const float* __restrict _a);
- /// Calculate tangent frame from normal.
- inline void vec3TangentFrame(const float* __restrict _n, float* __restrict _t, float* __restrict _b)
- {
- const float nx = _n[0];
- const float ny = _n[1];
- const float nz = _n[2];
+ ///
+ void vec3Abs(float* __restrict _result, const float* __restrict _a);
- if (bx::fabsolute(nx) > bx::fabsolute(nz) )
- {
- float invLen = 1.0f / bx::fsqrt(nx*nx + nz*nz);
- _t[0] = -nz * invLen;
- _t[1] = 0.0f;
- _t[2] = nx * invLen;
- }
- else
- {
- float invLen = 1.0f / bx::fsqrt(ny*ny + nz*nz);
- _t[0] = 0.0f;
- _t[1] = nz * invLen;
- _t[2] = -ny * invLen;
- }
+ ///
+ void vec3Neg(float* __restrict _result, const float* __restrict _a);
- bx::vec3Cross(_b, _n, _t);
- }
+ ///
+ void vec3Add(float* __restrict _result, const float* __restrict _a, const float* __restrict _b);
- /// Calculate tangent frame from normal and angle.
- inline void vec3TangentFrame(const float* __restrict _n, float* __restrict _t, float* __restrict _b, float _angle)
- {
- vec3TangentFrame(_n, _t, _b);
+ ///
+ void vec3Add(float* __restrict _result, const float* __restrict _a, float _b);
- const float sa = fsin(_angle);
- const float ca = fcos(_angle);
+ ///
+ void vec3Sub(float* __restrict _result, const float* __restrict _a, const float* __restrict _b);
- _t[0] = -sa * _b[0] + ca * _t[0];
- _t[1] = -sa * _b[1] + ca * _t[1];
- _t[2] = -sa * _b[2] + ca * _t[2];
+ ///
+ void vec3Sub(float* __restrict _result, const float* __restrict _a, float _b);
- bx::vec3Cross(_b, _n, _t);
- }
+ ///
+ void vec3Mul(float* __restrict _result, const float* __restrict _a, const float* __restrict _b);
- inline void quatIdentity(float* _result)
- {
- _result[0] = 0.0f;
- _result[1] = 0.0f;
- _result[2] = 0.0f;
- _result[3] = 1.0f;
- }
+ ///
+ void vec3Mul(float* __restrict _result, const float* __restrict _a, float _b);
- inline void quatMove(float* __restrict _result, const float* __restrict _a)
- {
- _result[0] = _a[0];
- _result[1] = _a[1];
- _result[2] = _a[2];
- _result[3] = _a[3];
- }
+ ///
+ float vec3Dot(const float* __restrict _a, const float* __restrict _b);
- inline void quatMulXYZ(float* __restrict _result, const float* __restrict _qa, const float* __restrict _qb)
- {
- const float ax = _qa[0];
- const float ay = _qa[1];
- const float az = _qa[2];
- const float aw = _qa[3];
-
- const float bx = _qb[0];
- const float by = _qb[1];
- const float bz = _qb[2];
- const float bw = _qb[3];
-
- _result[0] = aw * bx + ax * bw + ay * bz - az * by;
- _result[1] = aw * by - ax * bz + ay * bw + az * bx;
- _result[2] = aw * bz + ax * by - ay * bx + az * bw;
- }
-
- inline void quatMul(float* __restrict _result, const float* __restrict _qa, const float* __restrict _qb)
- {
- const float ax = _qa[0];
- const float ay = _qa[1];
- const float az = _qa[2];
- const float aw = _qa[3];
-
- const float bx = _qb[0];
- const float by = _qb[1];
- const float bz = _qb[2];
- const float bw = _qb[3];
-
- _result[0] = aw * bx + ax * bw + ay * bz - az * by;
- _result[1] = aw * by - ax * bz + ay * bw + az * bx;
- _result[2] = aw * bz + ax * by - ay * bx + az * bw;
- _result[3] = aw * bw - ax * bx - ay * by - az * bz;
- }
-
- inline void quatInvert(float* __restrict _result, const float* __restrict _quat)
- {
- _result[0] = -_quat[0];
- _result[1] = -_quat[1];
- _result[2] = -_quat[2];
- _result[3] = _quat[3];
- }
+ ///
+ void vec3Cross(float* __restrict _result, const float* __restrict _a, const float* __restrict _b);
- inline float quatDot(const float* __restrict _a, const float* __restrict _b)
- {
- return _a[0]*_b[0]
- + _a[1]*_b[1]
- + _a[2]*_b[2]
- + _a[3]*_b[3]
- ;
- }
-
- inline void quatNorm(float* __restrict _result, const float* __restrict _quat)
- {
- const float norm = quatDot(_quat, _quat);
- if (0.0f < norm)
- {
- const float invNorm = 1.0f / fsqrt(norm);
- _result[0] = _quat[0] * invNorm;
- _result[1] = _quat[1] * invNorm;
- _result[2] = _quat[2] * invNorm;
- _result[3] = _quat[3] * invNorm;
- }
- else
- {
- quatIdentity(_result);
- }
- }
+ ///
+ float vec3Length(const float* _a);
- inline void quatToEuler(float* __restrict _result, const float* __restrict _quat)
- {
- const float x = _quat[0];
- const float y = _quat[1];
- const float z = _quat[2];
- const float w = _quat[3];
+ ///
+ void vec3Lerp(float* __restrict _result, const float* __restrict _a, const float* __restrict _b, float _t);
- const float yy = y * y;
- const float zz = z * z;
+ ///
+ void vec3Lerp(float* __restrict _result, const float* __restrict _a, const float* __restrict _b, const float* __restrict _c);
- const float xx = x * x;
- _result[0] = atan2f(2.0f * (x * w - y * z), 1.0f - 2.0f * (xx + zz) );
- _result[1] = atan2f(2.0f * (y * w + x * z), 1.0f - 2.0f * (yy + zz) );
- _result[2] = asinf (2.0f * (x * y + z * w) );
- }
+ ///
+ float vec3Norm(float* __restrict _result, const float* __restrict _a);
- inline void quatRotateAxis(float* __restrict _result, const float* _axis, float _angle)
- {
- const float ha = _angle * 0.5f;
- const float ca = fcos(ha);
- const float sa = fsin(ha);
- _result[0] = _axis[0] * sa;
- _result[1] = _axis[1] * sa;
- _result[2] = _axis[2] * sa;
- _result[3] = ca;
- }
-
- inline void quatRotateX(float* _result, float _ax)
- {
- const float hx = _ax * 0.5f;
- const float cx = fcos(hx);
- const float sx = fsin(hx);
- _result[0] = sx;
- _result[1] = 0.0f;
- _result[2] = 0.0f;
- _result[3] = cx;
- }
-
- inline void quatRotateY(float* _result, float _ay)
- {
- const float hy = _ay * 0.5f;
- const float cy = fcos(hy);
- const float sy = fsin(hy);
- _result[0] = 0.0f;
- _result[1] = sy;
- _result[2] = 0.0f;
- _result[3] = cy;
- }
-
- inline void quatRotateZ(float* _result, float _az)
- {
- const float hz = _az * 0.5f;
- const float cz = fcos(hz);
- const float sz = fsin(hz);
- _result[0] = 0.0f;
- _result[1] = 0.0f;
- _result[2] = sz;
- _result[3] = cz;
- }
-
- inline void vec3MulQuat(float* __restrict _result, const float* __restrict _vec, const float* __restrict _quat)
- {
- float tmp0[4];
- quatInvert(tmp0, _quat);
+ ///
+ void vec3Min(float* __restrict _result, const float* __restrict _a, const float* __restrict _b);
- float qv[4];
- qv[0] = _vec[0];
- qv[1] = _vec[1];
- qv[2] = _vec[2];
- qv[3] = 0.0f;
+ ///
+ void vec3Max(float* __restrict _result, const float* __restrict _a, const float* __restrict _b);
- float tmp1[4];
- quatMul(tmp1, tmp0, qv);
+ ///
+ void vec3Rcp(float* __restrict _result, const float* __restrict _a);
- quatMulXYZ(_result, tmp1, _quat);
- }
+ /// Calculate tangent frame from normal.
+ ///
+ void vec3TangentFrame(const float* __restrict _n, float* __restrict _t, float* __restrict _b);
- inline void mtxIdentity(float* _result)
- {
- memset(_result, 0, sizeof(float)*16);
- _result[0] = _result[5] = _result[10] = _result[15] = 1.0f;
- }
+ /// Calculate tangent frame from normal and angle.
+ ///
+ void vec3TangentFrame(const float* __restrict _n, float* __restrict _t, float* __restrict _b, float _angle);
- inline void mtxTranslate(float* _result, float _tx, float _ty, float _tz)
- {
- mtxIdentity(_result);
- _result[12] = _tx;
- _result[13] = _ty;
- _result[14] = _tz;
- }
+ ///
+ void quatIdentity(float* _result);
- inline void mtxScale(float* _result, float _sx, float _sy, float _sz)
- {
- memset(_result, 0, sizeof(float) * 16);
- _result[0] = _sx;
- _result[5] = _sy;
- _result[10] = _sz;
- _result[15] = 1.0f;
- }
-
- inline void mtxScale(float* _result, float _scale)
- {
- mtxScale(_result, _scale, _scale, _scale);
- }
+ ///
+ void quatMove(float* __restrict _result, const float* __restrict _a);
- inline void mtxFromNormal(float* __restrict _result, const float* __restrict _normal, float _scale, const float* __restrict _pos)
- {
- float tangent[3];
- float bitangent[3];
- vec3TangentFrame(_normal, tangent, bitangent);
-
- vec3Mul(&_result[ 0], bitangent, _scale);
- vec3Mul(&_result[ 4], _normal, _scale);
- vec3Mul(&_result[ 8], tangent, _scale);
-
- _result[ 3] = 0.0f;
- _result[ 7] = 0.0f;
- _result[11] = 0.0f;
- _result[12] = _pos[0];
- _result[13] = _pos[1];
- _result[14] = _pos[2];
- _result[15] = 1.0f;
- }
-
- inline void mtxFromNormal(float* __restrict _result, const float* __restrict _normal, float _scale, const float* __restrict _pos, float _angle)
- {
- float tangent[3];
- float bitangent[3];
- vec3TangentFrame(_normal, tangent, bitangent, _angle);
-
- vec3Mul(&_result[ 0], bitangent, _scale);
- vec3Mul(&_result[ 4], _normal, _scale);
- vec3Mul(&_result[ 8], tangent, _scale);
-
- _result[ 3] = 0.0f;
- _result[ 7] = 0.0f;
- _result[11] = 0.0f;
- _result[12] = _pos[0];
- _result[13] = _pos[1];
- _result[14] = _pos[2];
- _result[15] = 1.0f;
- }
-
- inline void mtxQuat(float* __restrict _result, const float* __restrict _quat)
- {
- const float x = _quat[0];
- const float y = _quat[1];
- const float z = _quat[2];
- const float w = _quat[3];
-
- const float x2 = x + x;
- const float y2 = y + y;
- const float z2 = z + z;
- const float x2x = x2 * x;
- const float x2y = x2 * y;
- const float x2z = x2 * z;
- const float x2w = x2 * w;
- const float y2y = y2 * y;
- const float y2z = y2 * z;
- const float y2w = y2 * w;
- const float z2z = z2 * z;
- const float z2w = z2 * w;
-
- _result[ 0] = 1.0f - (y2y + z2z);
- _result[ 1] = x2y - z2w;
- _result[ 2] = x2z + y2w;
- _result[ 3] = 0.0f;
-
- _result[ 4] = x2y + z2w;
- _result[ 5] = 1.0f - (x2x + z2z);
- _result[ 6] = y2z - x2w;
- _result[ 7] = 0.0f;
-
- _result[ 8] = x2z - y2w;
- _result[ 9] = y2z + x2w;
- _result[10] = 1.0f - (x2x + y2y);
- _result[11] = 0.0f;
-
- _result[12] = 0.0f;
- _result[13] = 0.0f;
- _result[14] = 0.0f;
- _result[15] = 1.0f;
- }
-
- inline void mtxQuatTranslation(float* __restrict _result, const float* __restrict _quat, const float* __restrict _translation)
- {
- mtxQuat(_result, _quat);
- _result[12] = -(_result[0]*_translation[0] + _result[4]*_translation[1] + _result[ 8]*_translation[2]);
- _result[13] = -(_result[1]*_translation[0] + _result[5]*_translation[1] + _result[ 9]*_translation[2]);
- _result[14] = -(_result[2]*_translation[0] + _result[6]*_translation[1] + _result[10]*_translation[2]);
- }
+ ///
+ void quatMulXYZ(float* __restrict _result, const float* __restrict _qa, const float* __restrict _qb);
- inline void mtxQuatTranslationHMD(float* __restrict _result, const float* __restrict _quat, const float* __restrict _translation)
- {
- float quat[4];
- quat[0] = -_quat[0];
- quat[1] = -_quat[1];
- quat[2] = _quat[2];
- quat[3] = _quat[3];
- mtxQuatTranslation(_result, quat, _translation);
- }
-
- inline void mtxLookAt_Impl(float* __restrict _result, const float* __restrict _eye, const float* __restrict _view, const float* __restrict _up = NULL)
- {
- float up[3] = { 0.0f, 1.0f, 0.0f };
- if (NULL != _up)
- {
- up[0] = _up[0];
- up[1] = _up[1];
- up[2] = _up[2];
- }
+ ///
+ void quatMul(float* __restrict _result, const float* __restrict _qa, const float* __restrict _qb);
- float tmp[4];
- vec3Cross(tmp, up, _view);
+ ///
+ void quatInvert(float* __restrict _result, const float* __restrict _quat);
- float right[4];
- vec3Norm(right, tmp);
+ ///
+ float quatDot(const float* __restrict _a, const float* __restrict _b);
- vec3Cross(up, _view, right);
+ ///
+ void quatNorm(float* __restrict _result, const float* __restrict _quat);
- memset(_result, 0, sizeof(float)*16);
- _result[ 0] = right[0];
- _result[ 1] = up[0];
- _result[ 2] = _view[0];
+ ///
+ void quatToEuler(float* __restrict _result, const float* __restrict _quat);
- _result[ 4] = right[1];
- _result[ 5] = up[1];
- _result[ 6] = _view[1];
+ ///
+ void quatRotateAxis(float* __restrict _result, const float* _axis, float _angle);
- _result[ 8] = right[2];
- _result[ 9] = up[2];
- _result[10] = _view[2];
+ ///
+ void quatRotateX(float* _result, float _ax);
- _result[12] = -vec3Dot(right, _eye);
- _result[13] = -vec3Dot(up, _eye);
- _result[14] = -vec3Dot(_view, _eye);
- _result[15] = 1.0f;
- }
+ ///
+ void quatRotateY(float* _result, float _ay);
- inline void mtxLookAtLh(float* __restrict _result, const float* __restrict _eye, const float* __restrict _at, const float* __restrict _up = NULL)
- {
- float tmp[4];
- vec3Sub(tmp, _at, _eye);
+ ///
+ void quatRotateZ(float* _result, float _az);
- float view[4];
- vec3Norm(view, tmp);
+ ///
+ void vec3MulQuat(float* __restrict _result, const float* __restrict _vec, const float* __restrict _quat);
- mtxLookAt_Impl(_result, _eye, view, _up);
- }
+ ///
+ void mtxIdentity(float* _result);
- inline void mtxLookAtRh(float* __restrict _result, const float* __restrict _eye, const float* __restrict _at, const float* __restrict _up = NULL)
- {
- float tmp[4];
- vec3Sub(tmp, _eye, _at);
+ ///
+ void mtxTranslate(float* _result, float _tx, float _ty, float _tz);
- float view[4];
- vec3Norm(view, tmp);
+ ///
+ void mtxScale(float* _result, float _sx, float _sy, float _sz);
- mtxLookAt_Impl(_result, _eye, view, _up);
- }
+ ///
+ void mtxScale(float* _result, float _scale);
- inline void mtxLookAt(float* __restrict _result, const float* __restrict _eye, const float* __restrict _at, const float* __restrict _up = NULL)
- {
- mtxLookAtLh(_result, _eye, _at, _up);
- }
+ ///
+ void mtxFromNormal(float* __restrict _result, const float* __restrict _normal, float _scale, const float* __restrict _pos);
- template <Handness::Enum HandnessT>
- inline void mtxProjXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, float _far, bool _oglNdc = false)
- {
- const float diff = _far-_near;
- const float aa = _oglNdc ? (_far+_near)/diff : _far/diff;
- const float bb = _oglNdc ? (2.0f*_far*_near)/diff : _near*aa;
-
- memset(_result, 0, sizeof(float)*16);
- _result[ 0] = _width;
- _result[ 5] = _height;
- _result[ 8] = (Handness::Right == HandnessT) ? _x : -_x;
- _result[ 9] = (Handness::Right == HandnessT) ? _y : -_y;
- _result[10] = (Handness::Right == HandnessT) ? -aa : aa;
- _result[11] = (Handness::Right == HandnessT) ? -1.0f : 1.0f;
- _result[14] = -bb;
- }
-
- template <Handness::Enum HandnessT>
- inline void mtxProj_impl(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false)
- {
- const float invDiffRl = 1.0f/(_rt - _lt);
- const float invDiffUd = 1.0f/(_ut - _dt);
- const float width = 2.0f*_near * invDiffRl;
- const float height = 2.0f*_near * invDiffUd;
- const float xx = (_rt + _lt) * invDiffRl;
- const float yy = (_ut + _dt) * invDiffUd;
- mtxProjXYWH<HandnessT>(_result, xx, yy, width, height, _near, _far, _oglNdc);
- }
-
- template <Handness::Enum HandnessT>
- inline void mtxProj_impl(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false)
- {
- mtxProj_impl<HandnessT>(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _far, _oglNdc);
- }
+ ///
+ void mtxFromNormal(float* __restrict _result, const float* __restrict _normal, float _scale, const float* __restrict _pos, float _angle);
- template <Handness::Enum HandnessT>
- inline void mtxProj_impl(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false)
- {
- const float height = 1.0f/tanf(toRad(_fovy)*0.5f);
- const float width = height * 1.0f/_aspect;
- mtxProjXYWH<HandnessT>(_result, 0.0f, 0.0f, width, height, _near, _far, _oglNdc);
- }
+ ///
+ void mtxQuat(float* __restrict _result, const float* __restrict _quat);
- inline void mtxProj(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false)
- {
- mtxProj_impl<Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc);
- }
+ ///
+ void mtxQuatTranslation(float* __restrict _result, const float* __restrict _quat, const float* __restrict _translation);
- inline void mtxProj(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false)
- {
- mtxProj_impl<Handness::Left>(_result, _fov, _near, _far, _oglNdc);
- }
+ ///
+ void mtxQuatTranslationHMD(float* __restrict _result, const float* __restrict _quat, const float* __restrict _translation);
- inline void mtxProj(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false)
- {
- mtxProj_impl<Handness::Left>(_result, _fovy, _aspect, _near, _far, _oglNdc);
- }
+ ///
+ void mtxLookAtLh(float* __restrict _result, const float* __restrict _eye, const float* __restrict _at, const float* __restrict _up = NULL);;
- inline void mtxProjLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false)
- {
- mtxProj_impl<Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc);
- }
+ ///
+ void mtxLookAtRh(float* __restrict _result, const float* __restrict _eye, const float* __restrict _at, const float* __restrict _up = NULL);
- inline void mtxProjLh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false)
- {
- mtxProj_impl<Handness::Left>(_result, _fov, _near, _far, _oglNdc);
- }
+ ///
+ void mtxLookAt(float* __restrict _result, const float* __restrict _eye, const float* __restrict _at, const float* __restrict _up = NULL);
- inline void mtxProjLh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false)
- {
- mtxProj_impl<Handness::Left>(_result, _fovy, _aspect, _near, _far, _oglNdc);
- }
+ ///
+ void mtxProj(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false);
- inline void mtxProjRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false)
- {
- mtxProj_impl<Handness::Right>(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc);
- }
+ ///
+ void mtxProj(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false);
- inline void mtxProjRh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false)
- {
- mtxProj_impl<Handness::Right>(_result, _fov, _near, _far, _oglNdc);
- }
+ ///
+ void mtxProj(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false);
- inline void mtxProjRh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false)
- {
- mtxProj_impl<Handness::Right>(_result, _fovy, _aspect, _near, _far, _oglNdc);
- }
+ ///
+ void mtxProjLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false);
- template <NearFar::Enum NearFarT, Handness::Enum HandnessT>
- inline void mtxProjInfXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, bool _oglNdc = false)
- {
- float aa;
- float bb;
- if (BX_ENABLED(NearFar::Reverse == NearFarT) )
- {
- aa = _oglNdc ? -1.0f : 0.0f;
- bb = _oglNdc ? -2.0f*_near : -_near;
- }
- else
- {
- aa = 1.0f;
- bb = _oglNdc ? 2.0f*_near : _near;
- }
-
- memset(_result, 0, sizeof(float)*16);
- _result[ 0] = _width;
- _result[ 5] = _height;
- _result[ 8] = (Handness::Right == HandnessT) ? _x : -_x;
- _result[ 9] = (Handness::Right == HandnessT) ? _y : -_y;
- _result[10] = (Handness::Right == HandnessT) ? -aa : aa;
- _result[11] = (Handness::Right == HandnessT) ? -1.0f : 1.0f;
- _result[14] = -bb;
- }
-
- template <NearFar::Enum NearFarT, Handness::Enum HandnessT>
- inline void mtxProjInf_impl(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false)
- {
- const float invDiffRl = 1.0f/(_rt - _lt);
- const float invDiffUd = 1.0f/(_ut - _dt);
- const float width = 2.0f*_near * invDiffRl;
- const float height = 2.0f*_near * invDiffUd;
- const float xx = (_rt + _lt) * invDiffRl;
- const float yy = (_ut + _dt) * invDiffUd;
- mtxProjInfXYWH<NearFarT,HandnessT>(_result, xx, yy, width, height, _near, _oglNdc);
- }
-
- template <NearFar::Enum NearFarT, Handness::Enum HandnessT>
- inline void mtxProjInf_impl(float* _result, const float _fov[4], float _near, bool _oglNdc = false)
- {
- mtxProjInf_impl<NearFarT,HandnessT>(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _oglNdc);
- }
+ ///
+ void mtxProjLh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false);
- template <NearFar::Enum NearFarT, Handness::Enum HandnessT>
- inline void mtxProjInf_impl(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false)
- {
- const float height = 1.0f/tanf(toRad(_fovy)*0.5f);
- const float width = height * 1.0f/_aspect;
- mtxProjInfXYWH<NearFarT,HandnessT>(_result, 0.0f, 0.0f, width, height, _near, _oglNdc);
- }
+ ///
+ void mtxProjLh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false);
- inline void mtxProjInf(float* _result, const float _fov[4], float _near, bool _oglNdc = false)
- {
- mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _fov, _near, _oglNdc);
- }
+ ///
+ void mtxProjRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false);
- inline void mtxProjInf(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false)
- {
- mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
- }
+ ///
+ void mtxProjRh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false);
- inline void mtxProjInf(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false)
- {
- mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _fovy, _aspect, _near, _oglNdc);
- }
+ ///
+ void mtxProjRh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false);
- inline void mtxProjInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false)
- {
- mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
- }
+ ///
+ void mtxProjInf(float* _result, const float _fov[4], float _near, bool _oglNdc = false);
- inline void mtxProjInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc = false)
- {
- mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _fov, _near, _oglNdc);
- }
+ ///
+ void mtxProjInf(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false);
- inline void mtxProjInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false)
- {
- mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _fovy, _aspect, _near, _oglNdc);
- }
+ ///
+ void mtxProjInf(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false);
- inline void mtxProjInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false)
- {
- mtxProjInf_impl<NearFar::Default,Handness::Right>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
- }
+ ///
+ void mtxProjInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false);
- inline void mtxProjInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc = false)
- {
- mtxProjInf_impl<NearFar::Default,Handness::Right>(_result, _fov, _near, _oglNdc);
- }
+ ///
+ void mtxProjInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc = false);
- inline void mtxProjInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false)
- {
- mtxProjInf_impl<NearFar::Default,Handness::Right>(_result, _fovy, _aspect, _near, _oglNdc);
- }
+ ///
+ void mtxProjInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false);
- inline void mtxProjRevInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false)
- {
- mtxProjInf_impl<NearFar::Reverse,Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
- }
+ ///
+ void mtxProjInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false);
- inline void mtxProjRevInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc = false)
- {
- mtxProjInf_impl<NearFar::Reverse,Handness::Left>(_result, _fov, _near, _oglNdc);
- }
+ ///
+ void mtxProjInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc = false);
- inline void mtxProjRevInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false)
- {
- mtxProjInf_impl<NearFar::Reverse,Handness::Left>(_result, _fovy, _aspect, _near, _oglNdc);
- }
+ ///
+ void mtxProjInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false);
- inline void mtxProjRevInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false)
- {
- mtxProjInf_impl<NearFar::Reverse,Handness::Right>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
- }
+ ///
+ void mtxProjRevInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false);
- inline void mtxProjRevInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc = false)
- {
- mtxProjInf_impl<NearFar::Reverse,Handness::Right>(_result, _fov, _near, _oglNdc);
- }
+ ///
+ void mtxProjRevInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc = false);
- inline void mtxProjRevInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false)
- {
- mtxProjInf_impl<NearFar::Reverse,Handness::Right>(_result, _fovy, _aspect, _near, _oglNdc);
- }
+ ///
+ void mtxProjRevInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false);
- template <Handness::Enum HandnessT>
- inline void mtxOrtho_impl(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false)
- {
- const float aa = 2.0f/(_right - _left);
- const float bb = 2.0f/(_top - _bottom);
- const float cc = (_oglNdc ? 2.0f : 1.0f) / (_far - _near);
- const float dd = (_left + _right)/(_left - _right);
- const float ee = (_top + _bottom)/(_bottom - _top);
- const float ff = _oglNdc ? (_near + _far)/(_near - _far) : _near/(_near - _far);
-
- memset(_result, 0, sizeof(float)*16);
- _result[ 0] = aa;
- _result[ 5] = bb;
- _result[10] = (Handness::Right == HandnessT) ? -cc : cc;
- _result[12] = dd + _offset;
- _result[13] = ee;
- _result[14] = ff;
- _result[15] = 1.0f;
- }
-
- inline void mtxOrtho(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false)
- {
- mtxOrtho_impl<Handness::Left>(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc);
- }
+ ///
+ void mtxProjRevInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false);
- inline void mtxOrthoLh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false)
- {
- mtxOrtho_impl<Handness::Left>(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc);
- }
+ ///
+ void mtxProjRevInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc = false);
- inline void mtxOrthoRh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false)
- {
- mtxOrtho_impl<Handness::Right>(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc);
- }
+ ///
+ void mtxProjRevInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false);
- inline void mtxRotateX(float* _result, float _ax)
- {
- const float sx = fsin(_ax);
- const float cx = fcos(_ax);
-
- memset(_result, 0, sizeof(float)*16);
- _result[ 0] = 1.0f;
- _result[ 5] = cx;
- _result[ 6] = -sx;
- _result[ 9] = sx;
- _result[10] = cx;
- _result[15] = 1.0f;
- }
-
- inline void mtxRotateY(float* _result, float _ay)
- {
- const float sy = fsin(_ay);
- const float cy = fcos(_ay);
-
- memset(_result, 0, sizeof(float)*16);
- _result[ 0] = cy;
- _result[ 2] = sy;
- _result[ 5] = 1.0f;
- _result[ 8] = -sy;
- _result[10] = cy;
- _result[15] = 1.0f;
- }
-
- inline void mtxRotateZ(float* _result, float _az)
- {
- const float sz = fsin(_az);
- const float cz = fcos(_az);
-
- memset(_result, 0, sizeof(float)*16);
- _result[ 0] = cz;
- _result[ 1] = -sz;
- _result[ 4] = sz;
- _result[ 5] = cz;
- _result[10] = 1.0f;
- _result[15] = 1.0f;
- }
-
- inline void mtxRotateXY(float* _result, float _ax, float _ay)
- {
- const float sx = fsin(_ax);
- const float cx = fcos(_ax);
- const float sy = fsin(_ay);
- const float cy = fcos(_ay);
-
- memset(_result, 0, sizeof(float)*16);
- _result[ 0] = cy;
- _result[ 2] = sy;
- _result[ 4] = sx*sy;
- _result[ 5] = cx;
- _result[ 6] = -sx*cy;
- _result[ 8] = -cx*sy;
- _result[ 9] = sx;
- _result[10] = cx*cy;
- _result[15] = 1.0f;
- }
-
- inline void mtxRotateXYZ(float* _result, float _ax, float _ay, float _az)
- {
- const float sx = fsin(_ax);
- const float cx = fcos(_ax);
- const float sy = fsin(_ay);
- const float cy = fcos(_ay);
- const float sz = fsin(_az);
- const float cz = fcos(_az);
-
- memset(_result, 0, sizeof(float)*16);
- _result[ 0] = cy*cz;
- _result[ 1] = -cy*sz;
- _result[ 2] = sy;
- _result[ 4] = cz*sx*sy + cx*sz;
- _result[ 5] = cx*cz - sx*sy*sz;
- _result[ 6] = -cy*sx;
- _result[ 8] = -cx*cz*sy + sx*sz;
- _result[ 9] = cz*sx + cx*sy*sz;
- _result[10] = cx*cy;
- _result[15] = 1.0f;
- }
-
- inline void mtxRotateZYX(float* _result, float _ax, float _ay, float _az)
- {
- const float sx = fsin(_ax);
- const float cx = fcos(_ax);
- const float sy = fsin(_ay);
- const float cy = fcos(_ay);
- const float sz = fsin(_az);
- const float cz = fcos(_az);
-
- memset(_result, 0, sizeof(float)*16);
- _result[ 0] = cy*cz;
- _result[ 1] = cz*sx*sy-cx*sz;
- _result[ 2] = cx*cz*sy+sx*sz;
- _result[ 4] = cy*sz;
- _result[ 5] = cx*cz + sx*sy*sz;
- _result[ 6] = -cz*sx + cx*sy*sz;
- _result[ 8] = -sy;
- _result[ 9] = cy*sx;
- _result[10] = cx*cy;
- _result[15] = 1.0f;
- };
+ ///
+ void mtxOrtho(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false);
- inline void mtxSRT(float* _result, float _sx, float _sy, float _sz, float _ax, float _ay, float _az, float _tx, float _ty, float _tz)
- {
- const float sx = fsin(_ax);
- const float cx = fcos(_ax);
- const float sy = fsin(_ay);
- const float cy = fcos(_ay);
- const float sz = fsin(_az);
- const float cz = fcos(_az);
-
- const float sxsz = sx*sz;
- const float cycz = cy*cz;
-
- _result[ 0] = _sx * (cycz - sxsz*sy);
- _result[ 1] = _sx * -cx*sz;
- _result[ 2] = _sx * (cz*sy + cy*sxsz);
- _result[ 3] = 0.0f;
-
- _result[ 4] = _sy * (cz*sx*sy + cy*sz);
- _result[ 5] = _sy * cx*cz;
- _result[ 6] = _sy * (sy*sz -cycz*sx);
- _result[ 7] = 0.0f;
-
- _result[ 8] = _sz * -cx*sy;
- _result[ 9] = _sz * sx;
- _result[10] = _sz * cx*cy;
- _result[11] = 0.0f;
-
- _result[12] = _tx;
- _result[13] = _ty;
- _result[14] = _tz;
- _result[15] = 1.0f;
- }
-
- inline void vec3MulMtx(float* __restrict _result, const float* __restrict _vec, const float* __restrict _mat)
- {
- _result[0] = _vec[0] * _mat[ 0] + _vec[1] * _mat[4] + _vec[2] * _mat[ 8] + _mat[12];
- _result[1] = _vec[0] * _mat[ 1] + _vec[1] * _mat[5] + _vec[2] * _mat[ 9] + _mat[13];
- _result[2] = _vec[0] * _mat[ 2] + _vec[1] * _mat[6] + _vec[2] * _mat[10] + _mat[14];
- }
+ ///
+ void mtxOrthoLh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false);
- inline void vec3MulMtxH(float* __restrict _result, const float* __restrict _vec, const float* __restrict _mat)
- {
- float xx = _vec[0] * _mat[ 0] + _vec[1] * _mat[4] + _vec[2] * _mat[ 8] + _mat[12];
- float yy = _vec[0] * _mat[ 1] + _vec[1] * _mat[5] + _vec[2] * _mat[ 9] + _mat[13];
- float zz = _vec[0] * _mat[ 2] + _vec[1] * _mat[6] + _vec[2] * _mat[10] + _mat[14];
- float ww = _vec[0] * _mat[ 3] + _vec[1] * _mat[7] + _vec[2] * _mat[11] + _mat[15];
- float invW = fsign(ww)/ww;
- _result[0] = xx*invW;
- _result[1] = yy*invW;
- _result[2] = zz*invW;
- }
-
- inline void vec4MulMtx(float* __restrict _result, const float* __restrict _vec, const float* __restrict _mat)
- {
- _result[0] = _vec[0] * _mat[ 0] + _vec[1] * _mat[4] + _vec[2] * _mat[ 8] + _vec[3] * _mat[12];
- _result[1] = _vec[0] * _mat[ 1] + _vec[1] * _mat[5] + _vec[2] * _mat[ 9] + _vec[3] * _mat[13];
- _result[2] = _vec[0] * _mat[ 2] + _vec[1] * _mat[6] + _vec[2] * _mat[10] + _vec[3] * _mat[14];
- _result[3] = _vec[0] * _mat[ 3] + _vec[1] * _mat[7] + _vec[2] * _mat[11] + _vec[3] * _mat[15];
- }
+ ///
+ void mtxOrthoRh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false);
- inline void mtxMul(float* __restrict _result, const float* __restrict _a, const float* __restrict _b)
- {
- vec4MulMtx(&_result[ 0], &_a[ 0], _b);
- vec4MulMtx(&_result[ 4], &_a[ 4], _b);
- vec4MulMtx(&_result[ 8], &_a[ 8], _b);
- vec4MulMtx(&_result[12], &_a[12], _b);
- }
+ ///
+ void mtxRotateX(float* _result, float _ax);
- inline void mtxTranspose(float* __restrict _result, const float* __restrict _a)
- {
- _result[ 0] = _a[ 0];
- _result[ 4] = _a[ 1];
- _result[ 8] = _a[ 2];
- _result[12] = _a[ 3];
- _result[ 1] = _a[ 4];
- _result[ 5] = _a[ 5];
- _result[ 9] = _a[ 6];
- _result[13] = _a[ 7];
- _result[ 2] = _a[ 8];
- _result[ 6] = _a[ 9];
- _result[10] = _a[10];
- _result[14] = _a[11];
- _result[ 3] = _a[12];
- _result[ 7] = _a[13];
- _result[11] = _a[14];
- _result[15] = _a[15];
- }
-
- inline void mtx3Inverse(float* __restrict _result, const float* __restrict _a)
- {
- float xx = _a[0];
- float xy = _a[1];
- float xz = _a[2];
- float yx = _a[3];
- float yy = _a[4];
- float yz = _a[5];
- float zx = _a[6];
- float zy = _a[7];
- float zz = _a[8];
-
- float det = 0.0f;
- det += xx * (yy*zz - yz*zy);
- det -= xy * (yx*zz - yz*zx);
- det += xz * (yx*zy - yy*zx);
-
- float invDet = 1.0f/det;
-
- _result[0] = +(yy*zz - yz*zy) * invDet;
- _result[1] = -(xy*zz - xz*zy) * invDet;
- _result[2] = +(xy*yz - xz*yy) * invDet;
-
- _result[3] = -(yx*zz - yz*zx) * invDet;
- _result[4] = +(xx*zz - xz*zx) * invDet;
- _result[5] = -(xx*yz - xz*yx) * invDet;
-
- _result[6] = +(yx*zy - yy*zx) * invDet;
- _result[7] = -(xx*zy - xy*zx) * invDet;
- _result[8] = +(xx*yy - xy*yx) * invDet;
- }
-
- inline void mtxInverse(float* __restrict _result, const float* __restrict _a)
- {
- float xx = _a[ 0];
- float xy = _a[ 1];
- float xz = _a[ 2];
- float xw = _a[ 3];
- float yx = _a[ 4];
- float yy = _a[ 5];
- float yz = _a[ 6];
- float yw = _a[ 7];
- float zx = _a[ 8];
- float zy = _a[ 9];
- float zz = _a[10];
- float zw = _a[11];
- float wx = _a[12];
- float wy = _a[13];
- float wz = _a[14];
- float ww = _a[15];
-
- float det = 0.0f;
- det += xx * (yy*(zz*ww - zw*wz) - yz*(zy*ww - zw*wy) + yw*(zy*wz - zz*wy) );
- det -= xy * (yx*(zz*ww - zw*wz) - yz*(zx*ww - zw*wx) + yw*(zx*wz - zz*wx) );
- det += xz * (yx*(zy*ww - zw*wy) - yy*(zx*ww - zw*wx) + yw*(zx*wy - zy*wx) );
- det -= xw * (yx*(zy*wz - zz*wy) - yy*(zx*wz - zz*wx) + yz*(zx*wy - zy*wx) );
-
- float invDet = 1.0f/det;
-
- _result[ 0] = +(yy*(zz*ww - wz*zw) - yz*(zy*ww - wy*zw) + yw*(zy*wz - wy*zz) ) * invDet;
- _result[ 1] = -(xy*(zz*ww - wz*zw) - xz*(zy*ww - wy*zw) + xw*(zy*wz - wy*zz) ) * invDet;
- _result[ 2] = +(xy*(yz*ww - wz*yw) - xz*(yy*ww - wy*yw) + xw*(yy*wz - wy*yz) ) * invDet;
- _result[ 3] = -(xy*(yz*zw - zz*yw) - xz*(yy*zw - zy*yw) + xw*(yy*zz - zy*yz) ) * invDet;
-
- _result[ 4] = -(yx*(zz*ww - wz*zw) - yz*(zx*ww - wx*zw) + yw*(zx*wz - wx*zz) ) * invDet;
- _result[ 5] = +(xx*(zz*ww - wz*zw) - xz*(zx*ww - wx*zw) + xw*(zx*wz - wx*zz) ) * invDet;
- _result[ 6] = -(xx*(yz*ww - wz*yw) - xz*(yx*ww - wx*yw) + xw*(yx*wz - wx*yz) ) * invDet;
- _result[ 7] = +(xx*(yz*zw - zz*yw) - xz*(yx*zw - zx*yw) + xw*(yx*zz - zx*yz) ) * invDet;
-
- _result[ 8] = +(yx*(zy*ww - wy*zw) - yy*(zx*ww - wx*zw) + yw*(zx*wy - wx*zy) ) * invDet;
- _result[ 9] = -(xx*(zy*ww - wy*zw) - xy*(zx*ww - wx*zw) + xw*(zx*wy - wx*zy) ) * invDet;
- _result[10] = +(xx*(yy*ww - wy*yw) - xy*(yx*ww - wx*yw) + xw*(yx*wy - wx*yy) ) * invDet;
- _result[11] = -(xx*(yy*zw - zy*yw) - xy*(yx*zw - zx*yw) + xw*(yx*zy - zx*yy) ) * invDet;
-
- _result[12] = -(yx*(zy*wz - wy*zz) - yy*(zx*wz - wx*zz) + yz*(zx*wy - wx*zy) ) * invDet;
- _result[13] = +(xx*(zy*wz - wy*zz) - xy*(zx*wz - wx*zz) + xz*(zx*wy - wx*zy) ) * invDet;
- _result[14] = -(xx*(yy*wz - wy*yz) - xy*(yx*wz - wx*yz) + xz*(yx*wy - wx*yy) ) * invDet;
- _result[15] = +(xx*(yy*zz - zy*yz) - xy*(yx*zz - zx*yz) + xz*(yx*zy - zx*yy) ) * invDet;
- }
+ ///
+ void mtxRotateY(float* _result, float _ay);
- /// Convert LH to RH projection matrix and vice versa.
- inline void mtxProjFlipHandedness(float* __restrict _dst, const float* __restrict _src)
- {
- _dst[ 0] = -_src[ 0];
- _dst[ 1] = -_src[ 1];
- _dst[ 2] = -_src[ 2];
- _dst[ 3] = -_src[ 3];
- _dst[ 4] = _src[ 4];
- _dst[ 5] = _src[ 5];
- _dst[ 6] = _src[ 6];
- _dst[ 7] = _src[ 7];
- _dst[ 8] = -_src[ 8];
- _dst[ 9] = -_src[ 9];
- _dst[10] = -_src[10];
- _dst[11] = -_src[11];
- _dst[12] = _src[12];
- _dst[13] = _src[13];
- _dst[14] = _src[14];
- _dst[15] = _src[15];
- }
+ ///
+ void mtxRotateZ(float* _result, float _az);
- /// Convert LH to RH view matrix and vice versa.
- inline void mtxViewFlipHandedness(float* __restrict _dst, const float* __restrict _src)
- {
- _dst[ 0] = -_src[ 0];
- _dst[ 1] = _src[ 1];
- _dst[ 2] = -_src[ 2];
- _dst[ 3] = _src[ 3];
- _dst[ 4] = -_src[ 4];
- _dst[ 5] = _src[ 5];
- _dst[ 6] = -_src[ 6];
- _dst[ 7] = _src[ 7];
- _dst[ 8] = -_src[ 8];
- _dst[ 9] = _src[ 9];
- _dst[10] = -_src[10];
- _dst[11] = _src[11];
- _dst[12] = -_src[12];
- _dst[13] = _src[13];
- _dst[14] = -_src[14];
- _dst[15] = _src[15];
- }
-
- inline void calcNormal(float _result[3], float _va[3], float _vb[3], float _vc[3])
- {
- float ba[3];
- vec3Sub(ba, _vb, _va);
+ ///
+ void mtxRotateXY(float* _result, float _ax, float _ay);
- float ca[3];
- vec3Sub(ca, _vc, _va);
+ ///
+ void mtxRotateXYZ(float* _result, float _ax, float _ay, float _az);
- float baxca[3];
- vec3Cross(baxca, ba, ca);
+ ///
+ void mtxRotateZYX(float* _result, float _ax, float _ay, float _az);
- vec3Norm(_result, baxca);
- }
+ ///
+ void mtxSRT(float* _result, float _sx, float _sy, float _sz, float _ax, float _ay, float _az, float _tx, float _ty, float _tz);
- inline void calcPlane(float _result[4], float _va[3], float _vb[3], float _vc[3])
- {
- float normal[3];
- calcNormal(normal, _va, _vb, _vc);
+ ///
+ void vec3MulMtx(float* __restrict _result, const float* __restrict _vec, const float* __restrict _mat);
- _result[0] = normal[0];
- _result[1] = normal[1];
- _result[2] = normal[2];
- _result[3] = -vec3Dot(normal, _va);
- }
+ ///
+ void vec3MulMtxH(float* __restrict _result, const float* __restrict _vec, const float* __restrict _mat);
- inline void calcLinearFit2D(float _result[2], const void* _points, uint32_t _stride, uint32_t _numPoints)
- {
- float sumX = 0.0f;
- float sumY = 0.0f;
- float sumXX = 0.0f;
- float sumXY = 0.0f;
+ ///
+ void vec4MulMtx(float* __restrict _result, const float* __restrict _vec, const float* __restrict _mat);
- const uint8_t* ptr = (const uint8_t*)_points;
- for (uint32_t ii = 0; ii < _numPoints; ++ii, ptr += _stride)
- {
- const float* point = (const float*)ptr;
- float xx = point[0];
- float yy = point[1];
- sumX += xx;
- sumY += yy;
- sumXX += xx*xx;
- sumXY += xx*yy;
- }
-
- // [ sum(x^2) sum(x) ] [ A ] = [ sum(x*y) ]
- // [ sum(x) numPoints ] [ B ] [ sum(y) ]
-
- float det = (sumXX*_numPoints - sumX*sumX);
- float invDet = 1.0f/det;
-
- _result[0] = (-sumX * sumY + _numPoints * sumXY) * invDet;
- _result[1] = (sumXX * sumY - sumX * sumXY) * invDet;
- }
-
- inline void calcLinearFit3D(float _result[3], const void* _points, uint32_t _stride, uint32_t _numPoints)
- {
- float sumX = 0.0f;
- float sumY = 0.0f;
- float sumZ = 0.0f;
- float sumXX = 0.0f;
- float sumXY = 0.0f;
- float sumXZ = 0.0f;
- float sumYY = 0.0f;
- float sumYZ = 0.0f;
-
- const uint8_t* ptr = (const uint8_t*)_points;
- for (uint32_t ii = 0; ii < _numPoints; ++ii, ptr += _stride)
- {
- const float* point = (const float*)ptr;
- float xx = point[0];
- float yy = point[1];
- float zz = point[2];
-
- sumX += xx;
- sumY += yy;
- sumZ += zz;
- sumXX += xx*xx;
- sumXY += xx*yy;
- sumXZ += xx*zz;
- sumYY += yy*yy;
- sumYZ += yy*zz;
- }
-
- // [ sum(x^2) sum(x*y) sum(x) ] [ A ] [ sum(x*z) ]
- // [ sum(x*y) sum(y^2) sum(y) ] [ B ] = [ sum(y*z) ]
- // [ sum(x) sum(y) numPoints ] [ C ] [ sum(z) ]
-
- float mtx[9] =
- {
- sumXX, sumXY, sumX,
- sumXY, sumYY, sumY,
- sumX, sumY, float(_numPoints),
- };
- float invMtx[9];
- mtx3Inverse(invMtx, mtx);
+ ///
+ void mtxMul(float* __restrict _result, const float* __restrict _a, const float* __restrict _b);
- _result[0] = invMtx[0]*sumXZ + invMtx[1]*sumYZ + invMtx[2]*sumZ;
- _result[1] = invMtx[3]*sumXZ + invMtx[4]*sumYZ + invMtx[5]*sumZ;
- _result[2] = invMtx[6]*sumXZ + invMtx[7]*sumYZ + invMtx[8]*sumZ;
- }
+ ///
+ void mtxTranspose(float* __restrict _result, const float* __restrict _a);
- inline void rgbToHsv(float _hsv[3], const float _rgb[3])
- {
- const float rr = _rgb[0];
- const float gg = _rgb[1];
- const float bb = _rgb[2];
+ ///
+ void mtx3Inverse(float* __restrict _result, const float* __restrict _a);
- const float s0 = fstep(bb, gg);
+ ///
+ void mtxInverse(float* __restrict _result, const float* __restrict _a);
- const float px = flerp(bb, gg, s0);
- const float py = flerp(gg, bb, s0);
- const float pz = flerp(-1.0f, 0.0f, s0);
- const float pw = flerp(2.0f/3.0f, -1.0f/3.0f, s0);
+ /// Convert LH to RH projection matrix and vice versa.
+ ///
+ void mtxProjFlipHandedness(float* __restrict _dst, const float* __restrict _src);
- const float s1 = fstep(px, rr);
+ /// Convert LH to RH view matrix and vice versa.
+ ///
+ void mtxViewFlipHandedness(float* __restrict _dst, const float* __restrict _src);
- const float qx = flerp(px, rr, s1);
- const float qy = py;
- const float qz = flerp(pw, pz, s1);
- const float qw = flerp(rr, px, s1);
+ ///
+ void calcNormal(float _result[3], float _va[3], float _vb[3], float _vc[3]);
- const float dd = qx - fmin(qw, qy);
- const float ee = 1.0e-10f;
+ ///
+ void calcPlane(float _result[4], float _va[3], float _vb[3], float _vc[3]);
- _hsv[0] = fabsolute(qz + (qw - qy) / (6.0f * dd + ee) );
- _hsv[1] = dd / (qx + ee);
- _hsv[2] = qx;
- }
+ ///
+ void calcLinearFit2D(float _result[2], const void* _points, uint32_t _stride, uint32_t _numPoints);
- inline void hsvToRgb(float _rgb[3], const float _hsv[3])
- {
- const float hh = _hsv[0];
- const float ss = _hsv[1];
- const float vv = _hsv[2];
+ ///
+ void calcLinearFit3D(float _result[3], const void* _points, uint32_t _stride, uint32_t _numPoints);
- const float px = fabsolute(ffract(hh + 1.0f ) * 6.0f - 3.0f);
- const float py = fabsolute(ffract(hh + 2.0f/3.0f) * 6.0f - 3.0f);
- const float pz = fabsolute(ffract(hh + 1.0f/3.0f) * 6.0f - 3.0f);
+ ///
+ void rgbToHsv(float _hsv[3], const float _rgb[3]);
- _rgb[0] = vv * flerp(1.0f, fsaturate(px - 1.0f), ss);
- _rgb[1] = vv * flerp(1.0f, fsaturate(py - 1.0f), ss);
- _rgb[2] = vv * flerp(1.0f, fsaturate(pz - 1.0f), ss);
- }
+ ///
+ void hsvToRgb(float _rgb[3], const float _hsv[3]);
} // namespace bx
+#include "fpumath.inl"
+
#endif // BX_FPU_MATH_H_HEADER_GUARD
diff --git a/3rdparty/bx/include/bx/fpumath.inl b/3rdparty/bx/include/bx/fpumath.inl
new file mode 100644
index 00000000000..8a81fc27819
--- /dev/null
+++ b/3rdparty/bx/include/bx/fpumath.inl
@@ -0,0 +1,1416 @@
+/*
+ * Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+// FPU math lib
+
+#ifndef BX_FPU_MATH_H_HEADER_GUARD
+# error "Must be included from bx/fpumath.h!"
+#endif // BX_FPU_MATH_H_HEADER_GUARD
+
+#include "bx.h"
+#include <math.h>
+#include <string.h>
+
+namespace bx
+{
+ inline float toRad(float _deg)
+ {
+ return _deg * pi / 180.0f;
+ }
+
+ inline float toDeg(float _rad)
+ {
+ return _rad * 180.0f / pi;
+ }
+
+ inline uint32_t floatToBits(float _a)
+ {
+ union { float f; uint32_t ui; } u = { _a };
+ return u.ui;
+ }
+
+ inline float bitsToFloat(uint32_t _a)
+ {
+ union { uint32_t ui; float f; } u = { _a };
+ return u.f;
+ }
+
+ inline uint64_t doubleToBits(double _a)
+ {
+ union { double f; uint64_t ui; } u = { _a };
+ return u.ui;
+ }
+
+ inline double bitsToDouble(uint64_t _a)
+ {
+ union { uint64_t ui; double f; } u = { _a };
+ return u.f;
+ }
+
+ inline bool isNan(float _f)
+ {
+ const uint32_t tmp = floatToBits(_f) & INT32_MAX;
+ return tmp > UINT32_C(0x7f800000);
+ }
+
+ inline bool isNan(double _f)
+ {
+ const uint64_t tmp = doubleToBits(_f) & INT64_MAX;
+ return tmp > UINT64_C(0x7ff0000000000000);
+ }
+
+ inline bool isFinite(float _f)
+ {
+ const uint32_t tmp = floatToBits(_f) & INT32_MAX;
+ return tmp < UINT32_C(0x7f800000);
+ }
+
+ inline bool isFinite(double _f)
+ {
+ const uint64_t tmp = doubleToBits(_f) & INT64_MAX;
+ return tmp < UINT64_C(0x7ff0000000000000);
+ }
+
+ inline bool isInfinite(float _f)
+ {
+ const uint32_t tmp = floatToBits(_f) & INT32_MAX;
+ return tmp == UINT32_C(0x7f800000);
+ }
+
+ inline bool isInfinite(double _f)
+ {
+ const uint64_t tmp = doubleToBits(_f) & INT64_MAX;
+ return tmp == UINT64_C(0x7ff0000000000000);
+ }
+
+ inline float ffloor(float _f)
+ {
+ return floorf(_f);
+ }
+
+ inline float fceil(float _f)
+ {
+ return ceilf(_f);
+ }
+
+ inline float fround(float _f)
+ {
+ return ffloor(_f + 0.5f);
+ }
+
+ inline float fmin(float _a, float _b)
+ {
+ return _a < _b ? _a : _b;
+ }
+
+ inline float fmax(float _a, float _b)
+ {
+ return _a > _b ? _a : _b;
+ }
+
+ inline float fmin3(float _a, float _b, float _c)
+ {
+ return fmin(_a, fmin(_b, _c) );
+ }
+
+ inline float fmax3(float _a, float _b, float _c)
+ {
+ return fmax(_a, fmax(_b, _c) );
+ }
+
+ inline float fclamp(float _a, float _min, float _max)
+ {
+ return fmin(fmax(_a, _min), _max);
+ }
+
+ inline float fsaturate(float _a)
+ {
+ return fclamp(_a, 0.0f, 1.0f);
+ }
+
+ inline float flerp(float _a, float _b, float _t)
+ {
+ return _a + (_b - _a) * _t;
+ }
+
+ inline float fsign(float _a)
+ {
+ return _a < 0.0f ? -1.0f : 1.0f;
+ }
+
+ inline float fabsolute(float _a)
+ {
+ return fabsf(_a);
+ }
+
+ inline float fsq(float _a)
+ {
+ return _a * _a;
+ }
+
+ inline float fsin(float _a)
+ {
+ return sinf(_a);
+ }
+
+ inline float fasin(float _a)
+ {
+ return asinf(_a);
+ }
+
+ inline float fcos(float _a)
+ {
+ return cosf(_a);
+ }
+
+ inline float facos(float _a)
+ {
+ return acosf(_a);
+ }
+
+ inline float fatan2(float _y, float _x)
+ {
+ return atan2f(_y, _x);
+ }
+
+ inline float fpow(float _a, float _b)
+ {
+ return powf(_a, _b);
+ }
+
+ inline float fexp2(float _a)
+ {
+ return fpow(2.0f, _a);
+ }
+
+ inline float flog(float _a)
+ {
+ return logf(_a);
+ }
+
+ inline float flog2(float _a)
+ {
+ return flog(_a) * 1.442695041f;
+ }
+
+ inline float fsqrt(float _a)
+ {
+ return sqrtf(_a);
+ }
+
+ inline float frsqrt(float _a)
+ {
+ return 1.0f/fsqrt(_a);
+ }
+
+ inline float ffract(float _a)
+ {
+ return _a - floorf(_a);
+ }
+
+ inline float fmod(float _a, float _b)
+ {
+ return fmodf(_a, _b);
+ }
+
+ inline bool fequal(float _a, float _b, float _epsilon)
+ {
+ // http://realtimecollisiondetection.net/blog/?p=89
+ const float lhs = fabsolute(_a - _b);
+ const float rhs = _epsilon * fmax3(1.0f, fabsolute(_a), fabsolute(_b) );
+ return lhs <= rhs;
+ }
+
+ inline bool fequal(const float* __restrict _a, const float* __restrict _b, uint32_t _num, float _epsilon)
+ {
+ bool equal = fequal(_a[0], _b[0], _epsilon);
+ for (uint32_t ii = 1; equal && ii < _num; ++ii)
+ {
+ equal = fequal(_a[ii], _b[ii], _epsilon);
+ }
+ return equal;
+ }
+
+ inline float fwrap(float _a, float _wrap)
+ {
+ const float mod = fmod(_a, _wrap);
+ const float result = mod < 0.0f ? _wrap + mod : mod;
+ return result;
+ }
+
+ inline float fstep(float _edge, float _a)
+ {
+ return _a < _edge ? 0.0f : 1.0f;
+ }
+
+ inline float fpulse(float _a, float _start, float _end)
+ {
+ return fstep(_a, _start) - fstep(_a, _end);
+ }
+
+ inline float fsmoothstep(float _a)
+ {
+ return fsq(_a)*(3.0f - 2.0f*_a);
+ }
+
+ inline float fbias(float _time, float _bias)
+ {
+ return _time / ( ( (1.0f/_bias - 2.0f)*(1.0f - _time) ) + 1.0f);
+ }
+
+ inline float fgain(float _time, float _gain)
+ {
+ if (_time < 0.5f)
+ {
+ return fbias(_time * 2.0f, _gain) * 0.5f;
+ }
+
+ return fbias(_time * 2.0f - 1.0f, 1.0f - _gain) * 0.5f + 0.5f;
+ }
+
+ inline void vec3Move(float* __restrict _result, const float* __restrict _a)
+ {
+ _result[0] = _a[0];
+ _result[1] = _a[1];
+ _result[2] = _a[2];
+ }
+
+ inline void vec3Abs(float* __restrict _result, const float* __restrict _a)
+ {
+ _result[0] = fabsolute(_a[0]);
+ _result[1] = fabsolute(_a[1]);
+ _result[2] = fabsolute(_a[2]);
+ }
+
+ inline void vec3Neg(float* __restrict _result, const float* __restrict _a)
+ {
+ _result[0] = -_a[0];
+ _result[1] = -_a[1];
+ _result[2] = -_a[2];
+ }
+
+ inline void vec3Add(float* __restrict _result, const float* __restrict _a, const float* __restrict _b)
+ {
+ _result[0] = _a[0] + _b[0];
+ _result[1] = _a[1] + _b[1];
+ _result[2] = _a[2] + _b[2];
+ }
+
+ inline void vec3Add(float* __restrict _result, const float* __restrict _a, float _b)
+ {
+ _result[0] = _a[0] + _b;
+ _result[1] = _a[1] + _b;
+ _result[2] = _a[2] + _b;
+ }
+
+ inline void vec3Sub(float* __restrict _result, const float* __restrict _a, const float* __restrict _b)
+ {
+ _result[0] = _a[0] - _b[0];
+ _result[1] = _a[1] - _b[1];
+ _result[2] = _a[2] - _b[2];
+ }
+
+ inline void vec3Sub(float* __restrict _result, const float* __restrict _a, float _b)
+ {
+ _result[0] = _a[0] - _b;
+ _result[1] = _a[1] - _b;
+ _result[2] = _a[2] - _b;
+ }
+
+ inline void vec3Mul(float* __restrict _result, const float* __restrict _a, const float* __restrict _b)
+ {
+ _result[0] = _a[0] * _b[0];
+ _result[1] = _a[1] * _b[1];
+ _result[2] = _a[2] * _b[2];
+ }
+
+ inline void vec3Mul(float* __restrict _result, const float* __restrict _a, float _b)
+ {
+ _result[0] = _a[0] * _b;
+ _result[1] = _a[1] * _b;
+ _result[2] = _a[2] * _b;
+ }
+
+ inline float vec3Dot(const float* __restrict _a, const float* __restrict _b)
+ {
+ return _a[0]*_b[0] + _a[1]*_b[1] + _a[2]*_b[2];
+ }
+
+ inline void vec3Cross(float* __restrict _result, const float* __restrict _a, const float* __restrict _b)
+ {
+ _result[0] = _a[1]*_b[2] - _a[2]*_b[1];
+ _result[1] = _a[2]*_b[0] - _a[0]*_b[2];
+ _result[2] = _a[0]*_b[1] - _a[1]*_b[0];
+ }
+
+ inline float vec3Length(const float* _a)
+ {
+ return fsqrt(vec3Dot(_a, _a) );
+ }
+
+ inline void vec3Lerp(float* __restrict _result, const float* __restrict _a, const float* __restrict _b, float _t)
+ {
+ _result[0] = flerp(_a[0], _b[0], _t);
+ _result[1] = flerp(_a[1], _b[1], _t);
+ _result[2] = flerp(_a[2], _b[2], _t);
+ }
+
+ inline void vec3Lerp(float* __restrict _result, const float* __restrict _a, const float* __restrict _b, const float* __restrict _c)
+ {
+ _result[0] = flerp(_a[0], _b[0], _c[0]);
+ _result[1] = flerp(_a[1], _b[1], _c[1]);
+ _result[2] = flerp(_a[2], _b[2], _c[2]);
+ }
+
+ inline float vec3Norm(float* __restrict _result, const float* __restrict _a)
+ {
+ const float len = vec3Length(_a);
+ const float invLen = 1.0f/len;
+ _result[0] = _a[0] * invLen;
+ _result[1] = _a[1] * invLen;
+ _result[2] = _a[2] * invLen;
+ return len;
+ }
+
+ inline void vec3Min(float* __restrict _result, const float* __restrict _a, const float* __restrict _b)
+ {
+ _result[0] = fmin(_a[0], _b[0]);
+ _result[1] = fmin(_a[1], _b[1]);
+ _result[2] = fmin(_a[2], _b[2]);
+ }
+
+ inline void vec3Max(float* __restrict _result, const float* __restrict _a, const float* __restrict _b)
+ {
+ _result[0] = fmax(_a[0], _b[0]);
+ _result[1] = fmax(_a[1], _b[1]);
+ _result[2] = fmax(_a[2], _b[2]);
+ }
+
+ inline void vec3Rcp(float* __restrict _result, const float* __restrict _a)
+ {
+ _result[0] = 1.0f / _a[0];
+ _result[1] = 1.0f / _a[1];
+ _result[2] = 1.0f / _a[2];
+ }
+
+ inline void vec3TangentFrame(const float* __restrict _n, float* __restrict _t, float* __restrict _b)
+ {
+ const float nx = _n[0];
+ const float ny = _n[1];
+ const float nz = _n[2];
+
+ if (bx::fabsolute(nx) > bx::fabsolute(nz) )
+ {
+ float invLen = 1.0f / bx::fsqrt(nx*nx + nz*nz);
+ _t[0] = -nz * invLen;
+ _t[1] = 0.0f;
+ _t[2] = nx * invLen;
+ }
+ else
+ {
+ float invLen = 1.0f / bx::fsqrt(ny*ny + nz*nz);
+ _t[0] = 0.0f;
+ _t[1] = nz * invLen;
+ _t[2] = -ny * invLen;
+ }
+
+ bx::vec3Cross(_b, _n, _t);
+ }
+
+ inline void vec3TangentFrame(const float* __restrict _n, float* __restrict _t, float* __restrict _b, float _angle)
+ {
+ vec3TangentFrame(_n, _t, _b);
+
+ const float sa = fsin(_angle);
+ const float ca = fcos(_angle);
+
+ _t[0] = -sa * _b[0] + ca * _t[0];
+ _t[1] = -sa * _b[1] + ca * _t[1];
+ _t[2] = -sa * _b[2] + ca * _t[2];
+
+ bx::vec3Cross(_b, _n, _t);
+ }
+
+ inline void quatIdentity(float* _result)
+ {
+ _result[0] = 0.0f;
+ _result[1] = 0.0f;
+ _result[2] = 0.0f;
+ _result[3] = 1.0f;
+ }
+
+ inline void quatMove(float* __restrict _result, const float* __restrict _a)
+ {
+ _result[0] = _a[0];
+ _result[1] = _a[1];
+ _result[2] = _a[2];
+ _result[3] = _a[3];
+ }
+
+ inline void quatMulXYZ(float* __restrict _result, const float* __restrict _qa, const float* __restrict _qb)
+ {
+ const float ax = _qa[0];
+ const float ay = _qa[1];
+ const float az = _qa[2];
+ const float aw = _qa[3];
+
+ const float bx = _qb[0];
+ const float by = _qb[1];
+ const float bz = _qb[2];
+ const float bw = _qb[3];
+
+ _result[0] = aw * bx + ax * bw + ay * bz - az * by;
+ _result[1] = aw * by - ax * bz + ay * bw + az * bx;
+ _result[2] = aw * bz + ax * by - ay * bx + az * bw;
+ }
+
+ inline void quatMul(float* __restrict _result, const float* __restrict _qa, const float* __restrict _qb)
+ {
+ const float ax = _qa[0];
+ const float ay = _qa[1];
+ const float az = _qa[2];
+ const float aw = _qa[3];
+
+ const float bx = _qb[0];
+ const float by = _qb[1];
+ const float bz = _qb[2];
+ const float bw = _qb[3];
+
+ _result[0] = aw * bx + ax * bw + ay * bz - az * by;
+ _result[1] = aw * by - ax * bz + ay * bw + az * bx;
+ _result[2] = aw * bz + ax * by - ay * bx + az * bw;
+ _result[3] = aw * bw - ax * bx - ay * by - az * bz;
+ }
+
+ inline void quatInvert(float* __restrict _result, const float* __restrict _quat)
+ {
+ _result[0] = -_quat[0];
+ _result[1] = -_quat[1];
+ _result[2] = -_quat[2];
+ _result[3] = _quat[3];
+ }
+
+ inline float quatDot(const float* __restrict _a, const float* __restrict _b)
+ {
+ return _a[0]*_b[0]
+ + _a[1]*_b[1]
+ + _a[2]*_b[2]
+ + _a[3]*_b[3]
+ ;
+ }
+
+ inline void quatNorm(float* __restrict _result, const float* __restrict _quat)
+ {
+ const float norm = quatDot(_quat, _quat);
+ if (0.0f < norm)
+ {
+ const float invNorm = 1.0f / fsqrt(norm);
+ _result[0] = _quat[0] * invNorm;
+ _result[1] = _quat[1] * invNorm;
+ _result[2] = _quat[2] * invNorm;
+ _result[3] = _quat[3] * invNorm;
+ }
+ else
+ {
+ quatIdentity(_result);
+ }
+ }
+
+ inline void quatToEuler(float* __restrict _result, const float* __restrict _quat)
+ {
+ const float x = _quat[0];
+ const float y = _quat[1];
+ const float z = _quat[2];
+ const float w = _quat[3];
+
+ const float yy = y * y;
+ const float zz = z * z;
+
+ const float xx = x * x;
+ _result[0] = fatan2(2.0f * (x * w - y * z), 1.0f - 2.0f * (xx + zz) );
+ _result[1] = fatan2(2.0f * (y * w + x * z), 1.0f - 2.0f * (yy + zz) );
+ _result[2] = fasin (2.0f * (x * y + z * w) );
+ }
+
+ inline void quatRotateAxis(float* __restrict _result, const float* _axis, float _angle)
+ {
+ const float ha = _angle * 0.5f;
+ const float ca = fcos(ha);
+ const float sa = fsin(ha);
+ _result[0] = _axis[0] * sa;
+ _result[1] = _axis[1] * sa;
+ _result[2] = _axis[2] * sa;
+ _result[3] = ca;
+ }
+
+ inline void quatRotateX(float* _result, float _ax)
+ {
+ const float hx = _ax * 0.5f;
+ const float cx = fcos(hx);
+ const float sx = fsin(hx);
+ _result[0] = sx;
+ _result[1] = 0.0f;
+ _result[2] = 0.0f;
+ _result[3] = cx;
+ }
+
+ inline void quatRotateY(float* _result, float _ay)
+ {
+ const float hy = _ay * 0.5f;
+ const float cy = fcos(hy);
+ const float sy = fsin(hy);
+ _result[0] = 0.0f;
+ _result[1] = sy;
+ _result[2] = 0.0f;
+ _result[3] = cy;
+ }
+
+ inline void quatRotateZ(float* _result, float _az)
+ {
+ const float hz = _az * 0.5f;
+ const float cz = fcos(hz);
+ const float sz = fsin(hz);
+ _result[0] = 0.0f;
+ _result[1] = 0.0f;
+ _result[2] = sz;
+ _result[3] = cz;
+ }
+
+ inline void vec3MulQuat(float* __restrict _result, const float* __restrict _vec, const float* __restrict _quat)
+ {
+ float tmp0[4];
+ quatInvert(tmp0, _quat);
+
+ float qv[4];
+ qv[0] = _vec[0];
+ qv[1] = _vec[1];
+ qv[2] = _vec[2];
+ qv[3] = 0.0f;
+
+ float tmp1[4];
+ quatMul(tmp1, tmp0, qv);
+
+ quatMulXYZ(_result, tmp1, _quat);
+ }
+
+ inline void mtxIdentity(float* _result)
+ {
+ memset(_result, 0, sizeof(float)*16);
+ _result[0] = _result[5] = _result[10] = _result[15] = 1.0f;
+ }
+
+ inline void mtxTranslate(float* _result, float _tx, float _ty, float _tz)
+ {
+ mtxIdentity(_result);
+ _result[12] = _tx;
+ _result[13] = _ty;
+ _result[14] = _tz;
+ }
+
+ inline void mtxScale(float* _result, float _sx, float _sy, float _sz)
+ {
+ memset(_result, 0, sizeof(float) * 16);
+ _result[0] = _sx;
+ _result[5] = _sy;
+ _result[10] = _sz;
+ _result[15] = 1.0f;
+ }
+
+ inline void mtxScale(float* _result, float _scale)
+ {
+ mtxScale(_result, _scale, _scale, _scale);
+ }
+
+ inline void mtxFromNormal(float* __restrict _result, const float* __restrict _normal, float _scale, const float* __restrict _pos)
+ {
+ float tangent[3];
+ float bitangent[3];
+ vec3TangentFrame(_normal, tangent, bitangent);
+
+ vec3Mul(&_result[ 0], bitangent, _scale);
+ vec3Mul(&_result[ 4], _normal, _scale);
+ vec3Mul(&_result[ 8], tangent, _scale);
+
+ _result[ 3] = 0.0f;
+ _result[ 7] = 0.0f;
+ _result[11] = 0.0f;
+ _result[12] = _pos[0];
+ _result[13] = _pos[1];
+ _result[14] = _pos[2];
+ _result[15] = 1.0f;
+ }
+
+ inline void mtxFromNormal(float* __restrict _result, const float* __restrict _normal, float _scale, const float* __restrict _pos, float _angle)
+ {
+ float tangent[3];
+ float bitangent[3];
+ vec3TangentFrame(_normal, tangent, bitangent, _angle);
+
+ vec3Mul(&_result[ 0], bitangent, _scale);
+ vec3Mul(&_result[ 4], _normal, _scale);
+ vec3Mul(&_result[ 8], tangent, _scale);
+
+ _result[ 3] = 0.0f;
+ _result[ 7] = 0.0f;
+ _result[11] = 0.0f;
+ _result[12] = _pos[0];
+ _result[13] = _pos[1];
+ _result[14] = _pos[2];
+ _result[15] = 1.0f;
+ }
+
+ inline void mtxQuat(float* __restrict _result, const float* __restrict _quat)
+ {
+ const float x = _quat[0];
+ const float y = _quat[1];
+ const float z = _quat[2];
+ const float w = _quat[3];
+
+ const float x2 = x + x;
+ const float y2 = y + y;
+ const float z2 = z + z;
+ const float x2x = x2 * x;
+ const float x2y = x2 * y;
+ const float x2z = x2 * z;
+ const float x2w = x2 * w;
+ const float y2y = y2 * y;
+ const float y2z = y2 * z;
+ const float y2w = y2 * w;
+ const float z2z = z2 * z;
+ const float z2w = z2 * w;
+
+ _result[ 0] = 1.0f - (y2y + z2z);
+ _result[ 1] = x2y - z2w;
+ _result[ 2] = x2z + y2w;
+ _result[ 3] = 0.0f;
+
+ _result[ 4] = x2y + z2w;
+ _result[ 5] = 1.0f - (x2x + z2z);
+ _result[ 6] = y2z - x2w;
+ _result[ 7] = 0.0f;
+
+ _result[ 8] = x2z - y2w;
+ _result[ 9] = y2z + x2w;
+ _result[10] = 1.0f - (x2x + y2y);
+ _result[11] = 0.0f;
+
+ _result[12] = 0.0f;
+ _result[13] = 0.0f;
+ _result[14] = 0.0f;
+ _result[15] = 1.0f;
+ }
+
+ inline void mtxQuatTranslation(float* __restrict _result, const float* __restrict _quat, const float* __restrict _translation)
+ {
+ mtxQuat(_result, _quat);
+ _result[12] = -(_result[0]*_translation[0] + _result[4]*_translation[1] + _result[ 8]*_translation[2]);
+ _result[13] = -(_result[1]*_translation[0] + _result[5]*_translation[1] + _result[ 9]*_translation[2]);
+ _result[14] = -(_result[2]*_translation[0] + _result[6]*_translation[1] + _result[10]*_translation[2]);
+ }
+
+ inline void mtxQuatTranslationHMD(float* __restrict _result, const float* __restrict _quat, const float* __restrict _translation)
+ {
+ float quat[4];
+ quat[0] = -_quat[0];
+ quat[1] = -_quat[1];
+ quat[2] = _quat[2];
+ quat[3] = _quat[3];
+ mtxQuatTranslation(_result, quat, _translation);
+ }
+
+ inline void mtxLookAt_Impl(float* __restrict _result, const float* __restrict _eye, const float* __restrict _view, const float* __restrict _up)
+ {
+ float up[3] = { 0.0f, 1.0f, 0.0f };
+ if (NULL != _up)
+ {
+ up[0] = _up[0];
+ up[1] = _up[1];
+ up[2] = _up[2];
+ }
+
+ float tmp[4];
+ vec3Cross(tmp, up, _view);
+
+ float right[4];
+ vec3Norm(right, tmp);
+
+ vec3Cross(up, _view, right);
+
+ memset(_result, 0, sizeof(float)*16);
+ _result[ 0] = right[0];
+ _result[ 1] = up[0];
+ _result[ 2] = _view[0];
+
+ _result[ 4] = right[1];
+ _result[ 5] = up[1];
+ _result[ 6] = _view[1];
+
+ _result[ 8] = right[2];
+ _result[ 9] = up[2];
+ _result[10] = _view[2];
+
+ _result[12] = -vec3Dot(right, _eye);
+ _result[13] = -vec3Dot(up, _eye);
+ _result[14] = -vec3Dot(_view, _eye);
+ _result[15] = 1.0f;
+ }
+
+ inline void mtxLookAtLh(float* __restrict _result, const float* __restrict _eye, const float* __restrict _at, const float* __restrict _up)
+ {
+ float tmp[4];
+ vec3Sub(tmp, _at, _eye);
+
+ float view[4];
+ vec3Norm(view, tmp);
+
+ mtxLookAt_Impl(_result, _eye, view, _up);
+ }
+
+ inline void mtxLookAtRh(float* __restrict _result, const float* __restrict _eye, const float* __restrict _at, const float* __restrict _up)
+ {
+ float tmp[4];
+ vec3Sub(tmp, _eye, _at);
+
+ float view[4];
+ vec3Norm(view, tmp);
+
+ mtxLookAt_Impl(_result, _eye, view, _up);
+ }
+
+ inline void mtxLookAt(float* __restrict _result, const float* __restrict _eye, const float* __restrict _at, const float* __restrict _up)
+ {
+ mtxLookAtLh(_result, _eye, _at, _up);
+ }
+
+ template <Handness::Enum HandnessT>
+ inline void mtxProjXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, float _far, bool _oglNdc)
+ {
+ const float diff = _far-_near;
+ const float aa = _oglNdc ? (_far+_near)/diff : _far/diff;
+ const float bb = _oglNdc ? (2.0f*_far*_near)/diff : _near*aa;
+
+ memset(_result, 0, sizeof(float)*16);
+ _result[ 0] = _width;
+ _result[ 5] = _height;
+ _result[ 8] = (Handness::Right == HandnessT) ? _x : -_x;
+ _result[ 9] = (Handness::Right == HandnessT) ? _y : -_y;
+ _result[10] = (Handness::Right == HandnessT) ? -aa : aa;
+ _result[11] = (Handness::Right == HandnessT) ? -1.0f : 1.0f;
+ _result[14] = -bb;
+ }
+
+ template <Handness::Enum HandnessT>
+ inline void mtxProj_impl(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc)
+ {
+ const float invDiffRl = 1.0f/(_rt - _lt);
+ const float invDiffUd = 1.0f/(_ut - _dt);
+ const float width = 2.0f*_near * invDiffRl;
+ const float height = 2.0f*_near * invDiffUd;
+ const float xx = (_rt + _lt) * invDiffRl;
+ const float yy = (_ut + _dt) * invDiffUd;
+ mtxProjXYWH<HandnessT>(_result, xx, yy, width, height, _near, _far, _oglNdc);
+ }
+
+ template <Handness::Enum HandnessT>
+ inline void mtxProj_impl(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc)
+ {
+ mtxProj_impl<HandnessT>(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _far, _oglNdc);
+ }
+
+ template <Handness::Enum HandnessT>
+ inline void mtxProj_impl(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc)
+ {
+ const float height = 1.0f/tanf(toRad(_fovy)*0.5f);
+ const float width = height * 1.0f/_aspect;
+ mtxProjXYWH<HandnessT>(_result, 0.0f, 0.0f, width, height, _near, _far, _oglNdc);
+ }
+
+ inline void mtxProj(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc)
+ {
+ mtxProj_impl<Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc);
+ }
+
+ inline void mtxProj(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc)
+ {
+ mtxProj_impl<Handness::Left>(_result, _fov, _near, _far, _oglNdc);
+ }
+
+ inline void mtxProj(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc)
+ {
+ mtxProj_impl<Handness::Left>(_result, _fovy, _aspect, _near, _far, _oglNdc);
+ }
+
+ inline void mtxProjLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc)
+ {
+ mtxProj_impl<Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc);
+ }
+
+ inline void mtxProjLh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc)
+ {
+ mtxProj_impl<Handness::Left>(_result, _fov, _near, _far, _oglNdc);
+ }
+
+ inline void mtxProjLh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc)
+ {
+ mtxProj_impl<Handness::Left>(_result, _fovy, _aspect, _near, _far, _oglNdc);
+ }
+
+ inline void mtxProjRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc)
+ {
+ mtxProj_impl<Handness::Right>(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc);
+ }
+
+ inline void mtxProjRh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc)
+ {
+ mtxProj_impl<Handness::Right>(_result, _fov, _near, _far, _oglNdc);
+ }
+
+ inline void mtxProjRh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc)
+ {
+ mtxProj_impl<Handness::Right>(_result, _fovy, _aspect, _near, _far, _oglNdc);
+ }
+
+ template <NearFar::Enum NearFarT, Handness::Enum HandnessT>
+ inline void mtxProjInfXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, bool _oglNdc)
+ {
+ float aa;
+ float bb;
+ if (BX_ENABLED(NearFar::Reverse == NearFarT) )
+ {
+ aa = _oglNdc ? -1.0f : 0.0f;
+ bb = _oglNdc ? -2.0f*_near : -_near;
+ }
+ else
+ {
+ aa = 1.0f;
+ bb = _oglNdc ? 2.0f*_near : _near;
+ }
+
+ memset(_result, 0, sizeof(float)*16);
+ _result[ 0] = _width;
+ _result[ 5] = _height;
+ _result[ 8] = (Handness::Right == HandnessT) ? _x : -_x;
+ _result[ 9] = (Handness::Right == HandnessT) ? _y : -_y;
+ _result[10] = (Handness::Right == HandnessT) ? -aa : aa;
+ _result[11] = (Handness::Right == HandnessT) ? -1.0f : 1.0f;
+ _result[14] = -bb;
+ }
+
+ template <NearFar::Enum NearFarT, Handness::Enum HandnessT>
+ inline void mtxProjInf_impl(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc)
+ {
+ const float invDiffRl = 1.0f/(_rt - _lt);
+ const float invDiffUd = 1.0f/(_ut - _dt);
+ const float width = 2.0f*_near * invDiffRl;
+ const float height = 2.0f*_near * invDiffUd;
+ const float xx = (_rt + _lt) * invDiffRl;
+ const float yy = (_ut + _dt) * invDiffUd;
+ mtxProjInfXYWH<NearFarT,HandnessT>(_result, xx, yy, width, height, _near, _oglNdc);
+ }
+
+ template <NearFar::Enum NearFarT, Handness::Enum HandnessT>
+ inline void mtxProjInf_impl(float* _result, const float _fov[4], float _near, bool _oglNdc)
+ {
+ mtxProjInf_impl<NearFarT,HandnessT>(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _oglNdc);
+ }
+
+ template <NearFar::Enum NearFarT, Handness::Enum HandnessT>
+ inline void mtxProjInf_impl(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc)
+ {
+ const float height = 1.0f/tanf(toRad(_fovy)*0.5f);
+ const float width = height * 1.0f/_aspect;
+ mtxProjInfXYWH<NearFarT,HandnessT>(_result, 0.0f, 0.0f, width, height, _near, _oglNdc);
+ }
+
+ inline void mtxProjInf(float* _result, const float _fov[4], float _near, bool _oglNdc)
+ {
+ mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _fov, _near, _oglNdc);
+ }
+
+ inline void mtxProjInf(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc)
+ {
+ mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
+ }
+
+ inline void mtxProjInf(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc)
+ {
+ mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _fovy, _aspect, _near, _oglNdc);
+ }
+
+ inline void mtxProjInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc)
+ {
+ mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
+ }
+
+ inline void mtxProjInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc)
+ {
+ mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _fov, _near, _oglNdc);
+ }
+
+ inline void mtxProjInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc)
+ {
+ mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _fovy, _aspect, _near, _oglNdc);
+ }
+
+ inline void mtxProjInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc)
+ {
+ mtxProjInf_impl<NearFar::Default,Handness::Right>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
+ }
+
+ inline void mtxProjInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc)
+ {
+ mtxProjInf_impl<NearFar::Default,Handness::Right>(_result, _fov, _near, _oglNdc);
+ }
+
+ inline void mtxProjInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc)
+ {
+ mtxProjInf_impl<NearFar::Default,Handness::Right>(_result, _fovy, _aspect, _near, _oglNdc);
+ }
+
+ inline void mtxProjRevInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc)
+ {
+ mtxProjInf_impl<NearFar::Reverse,Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
+ }
+
+ inline void mtxProjRevInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc)
+ {
+ mtxProjInf_impl<NearFar::Reverse,Handness::Left>(_result, _fov, _near, _oglNdc);
+ }
+
+ inline void mtxProjRevInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc)
+ {
+ mtxProjInf_impl<NearFar::Reverse,Handness::Left>(_result, _fovy, _aspect, _near, _oglNdc);
+ }
+
+ inline void mtxProjRevInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc)
+ {
+ mtxProjInf_impl<NearFar::Reverse,Handness::Right>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
+ }
+
+ inline void mtxProjRevInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc)
+ {
+ mtxProjInf_impl<NearFar::Reverse,Handness::Right>(_result, _fov, _near, _oglNdc);
+ }
+
+ inline void mtxProjRevInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc)
+ {
+ mtxProjInf_impl<NearFar::Reverse,Handness::Right>(_result, _fovy, _aspect, _near, _oglNdc);
+ }
+
+ template <Handness::Enum HandnessT>
+ inline void mtxOrtho_impl(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset, bool _oglNdc)
+ {
+ const float aa = 2.0f/(_right - _left);
+ const float bb = 2.0f/(_top - _bottom);
+ const float cc = (_oglNdc ? 2.0f : 1.0f) / (_far - _near);
+ const float dd = (_left + _right)/(_left - _right);
+ const float ee = (_top + _bottom)/(_bottom - _top);
+ const float ff = _oglNdc ? (_near + _far)/(_near - _far) : _near/(_near - _far);
+
+ memset(_result, 0, sizeof(float)*16);
+ _result[ 0] = aa;
+ _result[ 5] = bb;
+ _result[10] = (Handness::Right == HandnessT) ? -cc : cc;
+ _result[12] = dd + _offset;
+ _result[13] = ee;
+ _result[14] = ff;
+ _result[15] = 1.0f;
+ }
+
+ inline void mtxOrtho(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset, bool _oglNdc)
+ {
+ mtxOrtho_impl<Handness::Left>(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc);
+ }
+
+ inline void mtxOrthoLh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset, bool _oglNdc)
+ {
+ mtxOrtho_impl<Handness::Left>(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc);
+ }
+
+ inline void mtxOrthoRh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset, bool _oglNdc)
+ {
+ mtxOrtho_impl<Handness::Right>(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc);
+ }
+
+ inline void mtxRotateX(float* _result, float _ax)
+ {
+ const float sx = fsin(_ax);
+ const float cx = fcos(_ax);
+
+ memset(_result, 0, sizeof(float)*16);
+ _result[ 0] = 1.0f;
+ _result[ 5] = cx;
+ _result[ 6] = -sx;
+ _result[ 9] = sx;
+ _result[10] = cx;
+ _result[15] = 1.0f;
+ }
+
+ inline void mtxRotateY(float* _result, float _ay)
+ {
+ const float sy = fsin(_ay);
+ const float cy = fcos(_ay);
+
+ memset(_result, 0, sizeof(float)*16);
+ _result[ 0] = cy;
+ _result[ 2] = sy;
+ _result[ 5] = 1.0f;
+ _result[ 8] = -sy;
+ _result[10] = cy;
+ _result[15] = 1.0f;
+ }
+
+ inline void mtxRotateZ(float* _result, float _az)
+ {
+ const float sz = fsin(_az);
+ const float cz = fcos(_az);
+
+ memset(_result, 0, sizeof(float)*16);
+ _result[ 0] = cz;
+ _result[ 1] = -sz;
+ _result[ 4] = sz;
+ _result[ 5] = cz;
+ _result[10] = 1.0f;
+ _result[15] = 1.0f;
+ }
+
+ inline void mtxRotateXY(float* _result, float _ax, float _ay)
+ {
+ const float sx = fsin(_ax);
+ const float cx = fcos(_ax);
+ const float sy = fsin(_ay);
+ const float cy = fcos(_ay);
+
+ memset(_result, 0, sizeof(float)*16);
+ _result[ 0] = cy;
+ _result[ 2] = sy;
+ _result[ 4] = sx*sy;
+ _result[ 5] = cx;
+ _result[ 6] = -sx*cy;
+ _result[ 8] = -cx*sy;
+ _result[ 9] = sx;
+ _result[10] = cx*cy;
+ _result[15] = 1.0f;
+ }
+
+ inline void mtxRotateXYZ(float* _result, float _ax, float _ay, float _az)
+ {
+ const float sx = fsin(_ax);
+ const float cx = fcos(_ax);
+ const float sy = fsin(_ay);
+ const float cy = fcos(_ay);
+ const float sz = fsin(_az);
+ const float cz = fcos(_az);
+
+ memset(_result, 0, sizeof(float)*16);
+ _result[ 0] = cy*cz;
+ _result[ 1] = -cy*sz;
+ _result[ 2] = sy;
+ _result[ 4] = cz*sx*sy + cx*sz;
+ _result[ 5] = cx*cz - sx*sy*sz;
+ _result[ 6] = -cy*sx;
+ _result[ 8] = -cx*cz*sy + sx*sz;
+ _result[ 9] = cz*sx + cx*sy*sz;
+ _result[10] = cx*cy;
+ _result[15] = 1.0f;
+ }
+
+ inline void mtxRotateZYX(float* _result, float _ax, float _ay, float _az)
+ {
+ const float sx = fsin(_ax);
+ const float cx = fcos(_ax);
+ const float sy = fsin(_ay);
+ const float cy = fcos(_ay);
+ const float sz = fsin(_az);
+ const float cz = fcos(_az);
+
+ memset(_result, 0, sizeof(float)*16);
+ _result[ 0] = cy*cz;
+ _result[ 1] = cz*sx*sy-cx*sz;
+ _result[ 2] = cx*cz*sy+sx*sz;
+ _result[ 4] = cy*sz;
+ _result[ 5] = cx*cz + sx*sy*sz;
+ _result[ 6] = -cz*sx + cx*sy*sz;
+ _result[ 8] = -sy;
+ _result[ 9] = cy*sx;
+ _result[10] = cx*cy;
+ _result[15] = 1.0f;
+ };
+
+ inline void mtxSRT(float* _result, float _sx, float _sy, float _sz, float _ax, float _ay, float _az, float _tx, float _ty, float _tz)
+ {
+ const float sx = fsin(_ax);
+ const float cx = fcos(_ax);
+ const float sy = fsin(_ay);
+ const float cy = fcos(_ay);
+ const float sz = fsin(_az);
+ const float cz = fcos(_az);
+
+ const float sxsz = sx*sz;
+ const float cycz = cy*cz;
+
+ _result[ 0] = _sx * (cycz - sxsz*sy);
+ _result[ 1] = _sx * -cx*sz;
+ _result[ 2] = _sx * (cz*sy + cy*sxsz);
+ _result[ 3] = 0.0f;
+
+ _result[ 4] = _sy * (cz*sx*sy + cy*sz);
+ _result[ 5] = _sy * cx*cz;
+ _result[ 6] = _sy * (sy*sz -cycz*sx);
+ _result[ 7] = 0.0f;
+
+ _result[ 8] = _sz * -cx*sy;
+ _result[ 9] = _sz * sx;
+ _result[10] = _sz * cx*cy;
+ _result[11] = 0.0f;
+
+ _result[12] = _tx;
+ _result[13] = _ty;
+ _result[14] = _tz;
+ _result[15] = 1.0f;
+ }
+
+ inline void vec3MulMtx(float* __restrict _result, const float* __restrict _vec, const float* __restrict _mat)
+ {
+ _result[0] = _vec[0] * _mat[ 0] + _vec[1] * _mat[4] + _vec[2] * _mat[ 8] + _mat[12];
+ _result[1] = _vec[0] * _mat[ 1] + _vec[1] * _mat[5] + _vec[2] * _mat[ 9] + _mat[13];
+ _result[2] = _vec[0] * _mat[ 2] + _vec[1] * _mat[6] + _vec[2] * _mat[10] + _mat[14];
+ }
+
+ inline void vec3MulMtxH(float* __restrict _result, const float* __restrict _vec, const float* __restrict _mat)
+ {
+ float xx = _vec[0] * _mat[ 0] + _vec[1] * _mat[4] + _vec[2] * _mat[ 8] + _mat[12];
+ float yy = _vec[0] * _mat[ 1] + _vec[1] * _mat[5] + _vec[2] * _mat[ 9] + _mat[13];
+ float zz = _vec[0] * _mat[ 2] + _vec[1] * _mat[6] + _vec[2] * _mat[10] + _mat[14];
+ float ww = _vec[0] * _mat[ 3] + _vec[1] * _mat[7] + _vec[2] * _mat[11] + _mat[15];
+ float invW = fsign(ww)/ww;
+ _result[0] = xx*invW;
+ _result[1] = yy*invW;
+ _result[2] = zz*invW;
+ }
+
+ inline void vec4MulMtx(float* __restrict _result, const float* __restrict _vec, const float* __restrict _mat)
+ {
+ _result[0] = _vec[0] * _mat[ 0] + _vec[1] * _mat[4] + _vec[2] * _mat[ 8] + _vec[3] * _mat[12];
+ _result[1] = _vec[0] * _mat[ 1] + _vec[1] * _mat[5] + _vec[2] * _mat[ 9] + _vec[3] * _mat[13];
+ _result[2] = _vec[0] * _mat[ 2] + _vec[1] * _mat[6] + _vec[2] * _mat[10] + _vec[3] * _mat[14];
+ _result[3] = _vec[0] * _mat[ 3] + _vec[1] * _mat[7] + _vec[2] * _mat[11] + _vec[3] * _mat[15];
+ }
+
+ inline void mtxMul(float* __restrict _result, const float* __restrict _a, const float* __restrict _b)
+ {
+ vec4MulMtx(&_result[ 0], &_a[ 0], _b);
+ vec4MulMtx(&_result[ 4], &_a[ 4], _b);
+ vec4MulMtx(&_result[ 8], &_a[ 8], _b);
+ vec4MulMtx(&_result[12], &_a[12], _b);
+ }
+
+ inline void mtxTranspose(float* __restrict _result, const float* __restrict _a)
+ {
+ _result[ 0] = _a[ 0];
+ _result[ 4] = _a[ 1];
+ _result[ 8] = _a[ 2];
+ _result[12] = _a[ 3];
+ _result[ 1] = _a[ 4];
+ _result[ 5] = _a[ 5];
+ _result[ 9] = _a[ 6];
+ _result[13] = _a[ 7];
+ _result[ 2] = _a[ 8];
+ _result[ 6] = _a[ 9];
+ _result[10] = _a[10];
+ _result[14] = _a[11];
+ _result[ 3] = _a[12];
+ _result[ 7] = _a[13];
+ _result[11] = _a[14];
+ _result[15] = _a[15];
+ }
+
+ /// Convert LH to RH projection matrix and vice versa.
+ inline void mtxProjFlipHandedness(float* __restrict _dst, const float* __restrict _src)
+ {
+ _dst[ 0] = -_src[ 0];
+ _dst[ 1] = -_src[ 1];
+ _dst[ 2] = -_src[ 2];
+ _dst[ 3] = -_src[ 3];
+ _dst[ 4] = _src[ 4];
+ _dst[ 5] = _src[ 5];
+ _dst[ 6] = _src[ 6];
+ _dst[ 7] = _src[ 7];
+ _dst[ 8] = -_src[ 8];
+ _dst[ 9] = -_src[ 9];
+ _dst[10] = -_src[10];
+ _dst[11] = -_src[11];
+ _dst[12] = _src[12];
+ _dst[13] = _src[13];
+ _dst[14] = _src[14];
+ _dst[15] = _src[15];
+ }
+
+ /// Convert LH to RH view matrix and vice versa.
+ inline void mtxViewFlipHandedness(float* __restrict _dst, const float* __restrict _src)
+ {
+ _dst[ 0] = -_src[ 0];
+ _dst[ 1] = _src[ 1];
+ _dst[ 2] = -_src[ 2];
+ _dst[ 3] = _src[ 3];
+ _dst[ 4] = -_src[ 4];
+ _dst[ 5] = _src[ 5];
+ _dst[ 6] = -_src[ 6];
+ _dst[ 7] = _src[ 7];
+ _dst[ 8] = -_src[ 8];
+ _dst[ 9] = _src[ 9];
+ _dst[10] = -_src[10];
+ _dst[11] = _src[11];
+ _dst[12] = -_src[12];
+ _dst[13] = _src[13];
+ _dst[14] = -_src[14];
+ _dst[15] = _src[15];
+ }
+
+ inline void calcNormal(float _result[3], float _va[3], float _vb[3], float _vc[3])
+ {
+ float ba[3];
+ vec3Sub(ba, _vb, _va);
+
+ float ca[3];
+ vec3Sub(ca, _vc, _va);
+
+ float baxca[3];
+ vec3Cross(baxca, ba, ca);
+
+ vec3Norm(_result, baxca);
+ }
+
+ inline void calcPlane(float _result[4], float _va[3], float _vb[3], float _vc[3])
+ {
+ float normal[3];
+ calcNormal(normal, _va, _vb, _vc);
+
+ _result[0] = normal[0];
+ _result[1] = normal[1];
+ _result[2] = normal[2];
+ _result[3] = -vec3Dot(normal, _va);
+ }
+
+ inline void calcLinearFit2D(float _result[2], const void* _points, uint32_t _stride, uint32_t _numPoints)
+ {
+ float sumX = 0.0f;
+ float sumY = 0.0f;
+ float sumXX = 0.0f;
+ float sumXY = 0.0f;
+
+ const uint8_t* ptr = (const uint8_t*)_points;
+ for (uint32_t ii = 0; ii < _numPoints; ++ii, ptr += _stride)
+ {
+ const float* point = (const float*)ptr;
+ float xx = point[0];
+ float yy = point[1];
+ sumX += xx;
+ sumY += yy;
+ sumXX += xx*xx;
+ sumXY += xx*yy;
+ }
+
+ // [ sum(x^2) sum(x) ] [ A ] = [ sum(x*y) ]
+ // [ sum(x) numPoints ] [ B ] [ sum(y) ]
+
+ float det = (sumXX*_numPoints - sumX*sumX);
+ float invDet = 1.0f/det;
+
+ _result[0] = (-sumX * sumY + _numPoints * sumXY) * invDet;
+ _result[1] = (sumXX * sumY - sumX * sumXY) * invDet;
+ }
+
+ inline void calcLinearFit3D(float _result[3], const void* _points, uint32_t _stride, uint32_t _numPoints)
+ {
+ float sumX = 0.0f;
+ float sumY = 0.0f;
+ float sumZ = 0.0f;
+ float sumXX = 0.0f;
+ float sumXY = 0.0f;
+ float sumXZ = 0.0f;
+ float sumYY = 0.0f;
+ float sumYZ = 0.0f;
+
+ const uint8_t* ptr = (const uint8_t*)_points;
+ for (uint32_t ii = 0; ii < _numPoints; ++ii, ptr += _stride)
+ {
+ const float* point = (const float*)ptr;
+ float xx = point[0];
+ float yy = point[1];
+ float zz = point[2];
+
+ sumX += xx;
+ sumY += yy;
+ sumZ += zz;
+ sumXX += xx*xx;
+ sumXY += xx*yy;
+ sumXZ += xx*zz;
+ sumYY += yy*yy;
+ sumYZ += yy*zz;
+ }
+
+ // [ sum(x^2) sum(x*y) sum(x) ] [ A ] [ sum(x*z) ]
+ // [ sum(x*y) sum(y^2) sum(y) ] [ B ] = [ sum(y*z) ]
+ // [ sum(x) sum(y) numPoints ] [ C ] [ sum(z) ]
+
+ float mtx[9] =
+ {
+ sumXX, sumXY, sumX,
+ sumXY, sumYY, sumY,
+ sumX, sumY, float(_numPoints),
+ };
+ float invMtx[9];
+ mtx3Inverse(invMtx, mtx);
+
+ _result[0] = invMtx[0]*sumXZ + invMtx[1]*sumYZ + invMtx[2]*sumZ;
+ _result[1] = invMtx[3]*sumXZ + invMtx[4]*sumYZ + invMtx[5]*sumZ;
+ _result[2] = invMtx[6]*sumXZ + invMtx[7]*sumYZ + invMtx[8]*sumZ;
+ }
+
+ inline void rgbToHsv(float _hsv[3], const float _rgb[3])
+ {
+ const float rr = _rgb[0];
+ const float gg = _rgb[1];
+ const float bb = _rgb[2];
+
+ const float s0 = fstep(bb, gg);
+
+ const float px = flerp(bb, gg, s0);
+ const float py = flerp(gg, bb, s0);
+ const float pz = flerp(-1.0f, 0.0f, s0);
+ const float pw = flerp(2.0f/3.0f, -1.0f/3.0f, s0);
+
+ const float s1 = fstep(px, rr);
+
+ const float qx = flerp(px, rr, s1);
+ const float qy = py;
+ const float qz = flerp(pw, pz, s1);
+ const float qw = flerp(rr, px, s1);
+
+ const float dd = qx - fmin(qw, qy);
+ const float ee = 1.0e-10f;
+
+ _hsv[0] = fabsolute(qz + (qw - qy) / (6.0f * dd + ee) );
+ _hsv[1] = dd / (qx + ee);
+ _hsv[2] = qx;
+ }
+
+ inline void hsvToRgb(float _rgb[3], const float _hsv[3])
+ {
+ const float hh = _hsv[0];
+ const float ss = _hsv[1];
+ const float vv = _hsv[2];
+
+ const float px = fabsolute(ffract(hh + 1.0f ) * 6.0f - 3.0f);
+ const float py = fabsolute(ffract(hh + 2.0f/3.0f) * 6.0f - 3.0f);
+ const float pz = fabsolute(ffract(hh + 1.0f/3.0f) * 6.0f - 3.0f);
+
+ _rgb[0] = vv * flerp(1.0f, fsaturate(px - 1.0f), ss);
+ _rgb[1] = vv * flerp(1.0f, fsaturate(py - 1.0f), ss);
+ _rgb[2] = vv * flerp(1.0f, fsaturate(pz - 1.0f), ss);
+ }
+
+} // namespace bx
diff --git a/3rdparty/bx/include/bx/handlealloc.h b/3rdparty/bx/include/bx/handlealloc.h
index 04303f4f49c..cf8efc585c5 100644
--- a/3rdparty/bx/include/bx/handlealloc.h
+++ b/3rdparty/bx/include/bx/handlealloc.h
@@ -18,130 +18,65 @@ namespace bx
public:
static const uint16_t invalid = UINT16_MAX;
- HandleAlloc(uint16_t _maxHandles)
- : m_numHandles(0)
- , m_maxHandles(_maxHandles)
- {
- reset();
- }
+ ///
+ HandleAlloc(uint16_t _maxHandles);
- ~HandleAlloc()
- {
- }
+ ///
+ ~HandleAlloc();
- const uint16_t* getHandles() const
- {
- return getDensePtr();
- }
+ ///
+ const uint16_t* getHandles() const;
- uint16_t getHandleAt(uint16_t _at) const
- {
- return getDensePtr()[_at];
- }
+ ///
+ uint16_t getHandleAt(uint16_t _at) const;
- uint16_t getNumHandles() const
- {
- return m_numHandles;
- }
+ ///
+ uint16_t getNumHandles() const;
- uint16_t getMaxHandles() const
- {
- return m_maxHandles;
- }
+ ///
+ uint16_t getMaxHandles() const;
- uint16_t alloc()
- {
- if (m_numHandles < m_maxHandles)
- {
- uint16_t index = m_numHandles;
- ++m_numHandles;
-
- uint16_t* dense = getDensePtr();
- uint16_t handle = dense[index];
- uint16_t* sparse = getSparsePtr();
- sparse[handle] = index;
- return handle;
- }
-
- return invalid;
- }
-
- bool isValid(uint16_t _handle) const
- {
- uint16_t* dense = getDensePtr();
- uint16_t* sparse = getSparsePtr();
- uint16_t index = sparse[_handle];
+ ///
+ uint16_t alloc();
- return index < m_numHandles
- && dense[index] == _handle
- ;
- }
+ ///
+ bool isValid(uint16_t _handle) const;
- void free(uint16_t _handle)
- {
- uint16_t* dense = getDensePtr();
- uint16_t* sparse = getSparsePtr();
- uint16_t index = sparse[_handle];
- --m_numHandles;
- uint16_t temp = dense[m_numHandles];
- dense[m_numHandles] = _handle;
- sparse[temp] = index;
- dense[index] = temp;
- }
-
- void reset()
- {
- m_numHandles = 0;
- uint16_t* dense = getDensePtr();
- for (uint16_t ii = 0, num = m_maxHandles; ii < num; ++ii)
- {
- dense[ii] = ii;
- }
- }
+ ///
+ void free(uint16_t _handle);
+
+ ///
+ void reset();
private:
HandleAlloc();
- uint16_t* getDensePtr() const
- {
- uint8_t* ptr = (uint8_t*)reinterpret_cast<const uint8_t*>(this);
- return (uint16_t*)&ptr[sizeof(HandleAlloc)];
- }
+ ///
+ uint16_t* getDensePtr() const;
- uint16_t* getSparsePtr() const
- {
- return &getDensePtr()[m_maxHandles];
- }
+ ///
+ uint16_t* getSparsePtr() const;
uint16_t m_numHandles;
uint16_t m_maxHandles;
};
- inline HandleAlloc* createHandleAlloc(AllocatorI* _allocator, uint16_t _maxHandles)
- {
- uint8_t* ptr = (uint8_t*)BX_ALLOC(_allocator, sizeof(HandleAlloc) + 2*_maxHandles*sizeof(uint16_t) );
- return ::new (ptr) HandleAlloc(_maxHandles);
- }
+ ///
+ HandleAlloc* createHandleAlloc(AllocatorI* _allocator, uint16_t _maxHandles);
- inline void destroyHandleAlloc(AllocatorI* _allocator, HandleAlloc* _handleAlloc)
- {
- _handleAlloc->~HandleAlloc();
- BX_FREE(_allocator, _handleAlloc);
- }
+ ///
+ void destroyHandleAlloc(AllocatorI* _allocator, HandleAlloc* _handleAlloc);
///
template <uint16_t MaxHandlesT>
class HandleAllocT : public HandleAlloc
{
public:
- HandleAllocT()
- : HandleAlloc(MaxHandlesT)
- {
- }
+ ///
+ HandleAllocT();
- ~HandleAllocT()
- {
- }
+ ///
+ ~HandleAllocT();
private:
uint16_t m_padding[2*MaxHandlesT];
@@ -154,170 +89,51 @@ namespace bx
public:
static const uint16_t invalid = UINT16_MAX;
- HandleListT()
- {
- reset();
- }
+ ///
+ HandleListT();
- void pushBack(uint16_t _handle)
- {
- insertAfter(m_back, _handle);
- }
+ ///
+ void pushBack(uint16_t _handle);
- uint16_t popBack()
- {
- uint16_t last = invalid != m_back
- ? m_back
- : m_front
- ;
+ ///
+ uint16_t popBack();
- if (invalid != last)
- {
- remove(last);
- }
+ ///
+ void pushFront(uint16_t _handle);
- return last;
- }
+ ///
+ uint16_t popFront();
- void pushFront(uint16_t _handle)
- {
- insertBefore(m_front, _handle);
- }
-
- uint16_t popFront()
- {
- uint16_t front = m_front;
+ ///
+ uint16_t getFront() const;
- if (invalid != front)
- {
- remove(front);
- }
+ ///
+ uint16_t getBack() const;
- return front;
- }
+ ///
+ uint16_t getNext(uint16_t _handle) const;
- uint16_t getFront() const
- {
- return m_front;
- }
+ ///
+ uint16_t getPrev(uint16_t _handle) const;
- uint16_t getBack() const
- {
- return m_back;
- }
+ ///
+ void remove(uint16_t _handle);
- uint16_t getNext(uint16_t _handle) const
- {
- BX_CHECK(isValid(_handle), "Invalid handle %d!", _handle);
- const Link& curr = m_links[_handle];
- return curr.m_next;
- }
-
- uint16_t getPrev(uint16_t _handle) const
- {
- BX_CHECK(isValid(_handle), "Invalid handle %d!", _handle);
- const Link& curr = m_links[_handle];
- return curr.m_prev;
- }
-
- void remove(uint16_t _handle)
- {
- BX_CHECK(isValid(_handle), "Invalid handle %d!", _handle);
- Link& curr = m_links[_handle];
-
- if (invalid != curr.m_prev)
- {
- Link& prev = m_links[curr.m_prev];
- prev.m_next = curr.m_next;
- }
- else
- {
- m_front = curr.m_next;
- }
-
- if (invalid != curr.m_next)
- {
- Link& next = m_links[curr.m_next];
- next.m_prev = curr.m_prev;
- }
- else
- {
- m_back = curr.m_prev;
- }
-
- curr.m_prev = invalid;
- curr.m_next = invalid;
- }
-
- void reset()
- {
- memset(m_links, 0xff, sizeof(m_links) );
- m_front = invalid;
- m_back = invalid;
- }
+ ///
+ void reset();
private:
- void insertBefore(uint16_t _before, uint16_t _handle)
- {
- Link& curr = m_links[_handle];
- curr.m_next = _before;
-
- if (invalid != _before)
- {
- Link& link = m_links[_before];
- if (invalid != link.m_prev)
- {
- Link& prev = m_links[link.m_prev];
- prev.m_next = _handle;
- }
-
- curr.m_prev = link.m_prev;
- link.m_prev = _handle;
- }
-
- updateFrontBack(_handle);
- }
-
- void insertAfter(uint16_t _after, uint16_t _handle)
- {
- Link& curr = m_links[_handle];
- curr.m_prev = _after;
-
- if (invalid != _after)
- {
- Link& link = m_links[_after];
- if (invalid != link.m_next)
- {
- Link& next = m_links[link.m_next];
- next.m_prev = _handle;
- }
-
- curr.m_next = link.m_next;
- link.m_next = _handle;
- }
-
- updateFrontBack(_handle);
- }
-
- bool isValid(uint16_t _handle) const
- {
- return _handle < MaxHandlesT;
- }
+ ///
+ void insertBefore(uint16_t _before, uint16_t _handle);
- void updateFrontBack(uint16_t _handle)
- {
- Link& curr = m_links[_handle];
+ ///
+ void insertAfter(uint16_t _after, uint16_t _handle);
- if (invalid == curr.m_prev)
- {
- m_front = _handle;
- }
+ ///
+ bool isValid(uint16_t _handle) const;
- if (invalid == curr.m_next)
- {
- m_back = _handle;
- }
- }
+ ///
+ void updateFrontBack(uint16_t _handle);
uint16_t m_front;
uint16_t m_back;
@@ -338,89 +154,50 @@ namespace bx
public:
static const uint16_t invalid = UINT16_MAX;
- HandleAllocLruT()
- {
- reset();
- }
+ ///
+ HandleAllocLruT();
- ~HandleAllocLruT()
- {
- }
+ ///
+ ~HandleAllocLruT();
- const uint16_t* getHandles() const
- {
- return m_alloc.getHandles();
- }
+ ///
+ const uint16_t* getHandles() const;
- uint16_t getHandleAt(uint16_t _at) const
- {
- return m_alloc.getHandleAt(_at);
- }
+ ///
+ uint16_t getHandleAt(uint16_t _at) const;
- uint16_t getNumHandles() const
- {
- return m_alloc.getNumHandles();
- }
+ ///
+ uint16_t getNumHandles() const;
- uint16_t getMaxHandles() const
- {
- return m_alloc.getMaxHandles();
- }
+ ///
+ uint16_t getMaxHandles() const;
- uint16_t alloc()
- {
- uint16_t handle = m_alloc.alloc();
- if (invalid != handle)
- {
- m_list.pushFront(handle);
- }
- return handle;
- }
-
- bool isValid(uint16_t _handle) const
- {
- return m_alloc.isValid(_handle);
- }
+ ///
+ uint16_t alloc();
- void free(uint16_t _handle)
- {
- BX_CHECK(isValid(_handle), "Invalid handle %d!", _handle);
- m_list.remove(_handle);
- m_alloc.free(_handle);
- }
+ ///
+ bool isValid(uint16_t _handle) const;
- void touch(uint16_t _handle)
- {
- BX_CHECK(isValid(_handle), "Invalid handle %d!", _handle);
- m_list.remove(_handle);
- m_list.pushFront(_handle);
- }
+ ///
+ void free(uint16_t _handle);
- uint16_t getFront() const
- {
- return m_list.getFront();
- }
+ ///
+ void touch(uint16_t _handle);
- uint16_t getBack() const
- {
- return m_list.getBack();
- }
+ ///
+ uint16_t getFront() const;
- uint16_t getNext(uint16_t _handle) const
- {
- return m_list.getNext(_handle);
- }
+ ///
+ uint16_t getBack() const;
- uint16_t getPrev(uint16_t _handle) const
- {
- return m_list.getPrev(_handle);
- }
+ ///
+ uint16_t getNext(uint16_t _handle) const;
- void reset()
- {
- m_list.reset();
- m_alloc.reset();
- }
+ ///
+ uint16_t getPrev(uint16_t _handle) const;
+
+ ///
+ void reset();
private:
HandleListT<MaxHandlesT> m_list;
@@ -434,103 +211,34 @@ namespace bx
public:
static const uint16_t invalid = UINT16_MAX;
- HandleHashMapT()
- : m_maxCapacity(MaxCapacityT)
- {
- reset();
- }
+ ///
+ HandleHashMapT();
- ~HandleHashMapT()
- {
- }
+ ///
+ ~HandleHashMapT();
- bool insert(KeyT _key, uint16_t _handle)
- {
- if (invalid == _handle)
- {
- return false;
- }
-
- const KeyT hash = mix(_key);
- const uint32_t firstIdx = hash % MaxCapacityT;
- uint32_t idx = firstIdx;
- do
- {
- if (m_handle[idx] == invalid)
- {
- m_key[idx] = _key;
- m_handle[idx] = _handle;
- ++m_numElements;
- return true;
- }
-
- if (m_key[idx] == _key)
- {
- return false;
- }
-
- idx = (idx + 1) % MaxCapacityT;
-
- } while (idx != firstIdx);
-
- return false;
- }
-
- bool removeByKey(KeyT _key)
- {
- uint32_t idx = findIndex(_key);
- if (UINT32_MAX != idx)
- {
- removeIndex(idx);
- return true;
- }
+ ///
+ bool insert(KeyT _key, uint16_t _handle);
- return false;
- }
+ ///
+ bool removeByKey(KeyT _key);
- bool removeByHandle(uint16_t _handle)
- {
- if (invalid != _handle)
- {
- for (uint32_t idx = 0; idx < MaxCapacityT; ++idx)
- {
- if (m_handle[idx] == _handle)
- {
- removeIndex(idx);
- }
- }
- }
-
- return false;
- }
-
- uint16_t find(KeyT _key) const
- {
- uint32_t idx = findIndex(_key);
- if (UINT32_MAX != idx)
- {
- return m_handle[idx];
- }
+ ///
+ bool removeByHandle(uint16_t _handle);
- return invalid;
- }
+ ///
+ uint16_t find(KeyT _key) const;
- void reset()
- {
- memset(m_handle, 0xff, sizeof(m_handle) );
- m_numElements = 0;
- }
+ ///
+ void reset();
- uint32_t getNumElements() const
- {
- return m_numElements;
- }
+ ///
+ uint32_t getNumElements() const;
- uint32_t getMaxCapacity() const
- {
- return m_maxCapacity;
- }
+ ///
+ uint32_t getMaxCapacity() const;
+ ///
struct Iterator
{
uint16_t handle;
@@ -541,104 +249,24 @@ namespace bx
uint32_t num;
};
- Iterator first() const
- {
- Iterator it;
- it.handle = invalid;
- it.pos = 0;
- it.num = m_numElements;
-
- if (0 == it.num)
- {
- return it;
- }
-
- ++it.num;
- next(it);
- return it;
- }
-
- bool next(Iterator& _it) const
- {
- if (0 == _it.num)
- {
- return false;
- }
-
- for (
- ;_it.pos < MaxCapacityT && invalid == m_handle[_it.pos]
- ; ++_it.pos
- );
- _it.handle = m_handle[_it.pos];
- ++_it.pos;
- --_it.num;
- return true;
- }
+ ///
+ Iterator first() const;
- private:
- uint32_t findIndex(KeyT _key) const
- {
- const KeyT hash = mix(_key);
-
- const uint32_t firstIdx = hash % MaxCapacityT;
- uint32_t idx = firstIdx;
- do
- {
- if (m_handle[idx] == invalid)
- {
- return UINT32_MAX;
- }
-
- if (m_key[idx] == _key)
- {
- return idx;
- }
+ ///
+ bool next(Iterator& _it) const;
- idx = (idx + 1) % MaxCapacityT;
+ private:
+ ///
+ uint32_t findIndex(KeyT _key) const;
- } while (idx != firstIdx);
+ ///
+ void removeIndex(uint32_t _idx);
- return UINT32_MAX;
- }
+ ///
+ uint32_t mix(uint32_t _x) const;
- void removeIndex(uint32_t _idx)
- {
- m_handle[_idx] = invalid;
- --m_numElements;
-
- for (uint32_t idx = (_idx + 1) % MaxCapacityT
- ; m_handle[idx] != invalid
- ; idx = (idx + 1) % MaxCapacityT)
- {
- if (m_handle[idx] != invalid)
- {
- const KeyT key = m_key[idx];
- if (idx != findIndex(key) )
- {
- const uint16_t handle = m_handle[idx];
- m_handle[idx] = invalid;
- --m_numElements;
- insert(key, handle);
- }
- }
- }
- }
-
- uint32_t mix(uint32_t _x) const
- {
- const uint32_t tmp0 = uint32_mul(_x, UINT32_C(2246822519) );
- const uint32_t tmp1 = uint32_rol(tmp0, 13);
- const uint32_t result = uint32_mul(tmp1, UINT32_C(2654435761) );
- return result;
- }
-
- uint64_t mix(uint64_t _x) const
- {
- const uint64_t tmp0 = uint64_mul(_x, UINT64_C(14029467366897019727) );
- const uint64_t tmp1 = uint64_rol(tmp0, 31);
- const uint64_t result = uint64_mul(tmp1, UINT64_C(11400714785074694791) );
- return result;
- }
+ ///
+ uint64_t mix(uint64_t _x) const;
uint32_t m_maxCapacity;
uint32_t m_numElements;
@@ -654,86 +282,41 @@ namespace bx
public:
static const uint16_t invalid = UINT16_MAX;
- HandleHashMapAllocT()
- {
- reset();
- }
+ ///
+ HandleHashMapAllocT();
- ~HandleHashMapAllocT()
- {
- }
+ ///
+ ~HandleHashMapAllocT();
- uint16_t alloc(KeyT _key)
- {
- uint16_t handle = m_alloc.alloc();
- if (invalid == handle)
- {
- return invalid;
- }
-
- bool ok = m_table.insert(_key, handle);
- if (!ok)
- {
- m_alloc.free(handle);
- return invalid;
- }
-
- return handle;
- }
-
- void free(KeyT _key)
- {
- uint16_t handle = m_table.find(_key);
- if (invalid == handle)
- {
- return;
- }
+ ///
+ uint16_t alloc(KeyT _key);
- m_table.removeByKey(_key);
- m_alloc.free(handle);
- }
+ ///
+ void free(KeyT _key);
- void free(uint16_t _handle)
- {
- m_table.removeByHandle(_handle);
- m_alloc.free(_handle);
- }
+ ///
+ void free(uint16_t _handle);
- uint16_t find(KeyT _key) const
- {
- return m_table.find(_key);
- }
+ ///
+ uint16_t find(KeyT _key) const;
- const uint16_t* getHandles() const
- {
- return m_alloc.getHandles();
- }
+ ///
+ const uint16_t* getHandles() const;
- uint16_t getHandleAt(uint16_t _at) const
- {
- return m_alloc.getHandleAt(_at);
- }
+ ///
+ uint16_t getHandleAt(uint16_t _at) const;
- uint16_t getNumHandles() const
- {
- return m_alloc.getNumHandles();
- }
+ ///
+ uint16_t getNumHandles() const;
- uint16_t getMaxHandles() const
- {
- return m_alloc.getMaxHandles();
- }
+ ///
+ uint16_t getMaxHandles() const;
- bool isValid(uint16_t _handle) const
- {
- return m_alloc.isValid(_handle);
- }
+ ///
+ bool isValid(uint16_t _handle) const;
- void reset()
- {
- m_table.reset();
- m_alloc.reset();
- }
+ ///
+ void reset();
private:
HandleHashMapT<MaxHandlesT+MaxHandlesT/2, KeyT> m_table;
@@ -742,4 +325,6 @@ namespace bx
} // namespace bx
+#include "handlealloc.inl"
+
#endif // BX_HANDLE_ALLOC_H_HEADER_GUARD
diff --git a/3rdparty/bx/include/bx/handlealloc.inl b/3rdparty/bx/include/bx/handlealloc.inl
new file mode 100644
index 00000000000..04369b57d78
--- /dev/null
+++ b/3rdparty/bx/include/bx/handlealloc.inl
@@ -0,0 +1,712 @@
+/*
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#ifndef BX_HANDLE_ALLOC_H_HEADER_GUARD
+# error "Must be included from bx/handlealloc.h!"
+#endif // BX_HANDLE_ALLOC_H_HEADER_GUARD
+
+#include "bx.h"
+#include "allocator.h"
+#include "uint32_t.h"
+
+namespace bx
+{
+ inline HandleAlloc::HandleAlloc(uint16_t _maxHandles)
+ : m_numHandles(0)
+ , m_maxHandles(_maxHandles)
+ {
+ reset();
+ }
+
+ inline HandleAlloc::~HandleAlloc()
+ {
+ }
+
+ inline const uint16_t* HandleAlloc::getHandles() const
+ {
+ return getDensePtr();
+ }
+
+ inline uint16_t HandleAlloc::getHandleAt(uint16_t _at) const
+ {
+ return getDensePtr()[_at];
+ }
+
+ inline uint16_t HandleAlloc::getNumHandles() const
+ {
+ return m_numHandles;
+ }
+
+ inline uint16_t HandleAlloc::getMaxHandles() const
+ {
+ return m_maxHandles;
+ }
+
+ inline uint16_t HandleAlloc::alloc()
+ {
+ if (m_numHandles < m_maxHandles)
+ {
+ uint16_t index = m_numHandles;
+ ++m_numHandles;
+
+ uint16_t* dense = getDensePtr();
+ uint16_t handle = dense[index];
+ uint16_t* sparse = getSparsePtr();
+ sparse[handle] = index;
+ return handle;
+ }
+
+ return invalid;
+ }
+
+ inline bool HandleAlloc::isValid(uint16_t _handle) const
+ {
+ uint16_t* dense = getDensePtr();
+ uint16_t* sparse = getSparsePtr();
+ uint16_t index = sparse[_handle];
+
+ return index < m_numHandles
+ && dense[index] == _handle
+ ;
+ }
+
+ inline void HandleAlloc::free(uint16_t _handle)
+ {
+ uint16_t* dense = getDensePtr();
+ uint16_t* sparse = getSparsePtr();
+ uint16_t index = sparse[_handle];
+ --m_numHandles;
+ uint16_t temp = dense[m_numHandles];
+ dense[m_numHandles] = _handle;
+ sparse[temp] = index;
+ dense[index] = temp;
+ }
+
+ inline void HandleAlloc::reset()
+ {
+ m_numHandles = 0;
+ uint16_t* dense = getDensePtr();
+ for (uint16_t ii = 0, num = m_maxHandles; ii < num; ++ii)
+ {
+ dense[ii] = ii;
+ }
+ }
+
+ inline uint16_t* HandleAlloc::getDensePtr() const
+ {
+ uint8_t* ptr = (uint8_t*)reinterpret_cast<const uint8_t*>(this);
+ return (uint16_t*)&ptr[sizeof(HandleAlloc)];
+ }
+
+ inline uint16_t* HandleAlloc::getSparsePtr() const
+ {
+ return &getDensePtr()[m_maxHandles];
+ }
+
+ inline HandleAlloc* createHandleAlloc(AllocatorI* _allocator, uint16_t _maxHandles)
+ {
+ uint8_t* ptr = (uint8_t*)BX_ALLOC(_allocator, sizeof(HandleAlloc) + 2*_maxHandles*sizeof(uint16_t) );
+ return ::new (ptr) HandleAlloc(_maxHandles);
+ }
+
+ inline void destroyHandleAlloc(AllocatorI* _allocator, HandleAlloc* _handleAlloc)
+ {
+ _handleAlloc->~HandleAlloc();
+ BX_FREE(_allocator, _handleAlloc);
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline HandleAllocT<MaxHandlesT>::HandleAllocT()
+ : HandleAlloc(MaxHandlesT)
+ {
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline HandleAllocT<MaxHandlesT>::~HandleAllocT()
+ {
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline HandleListT<MaxHandlesT>::HandleListT()
+ {
+ reset();
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline void HandleListT<MaxHandlesT>::pushBack(uint16_t _handle)
+ {
+ insertAfter(m_back, _handle);
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline uint16_t HandleListT<MaxHandlesT>::popBack()
+ {
+ uint16_t last = invalid != m_back
+ ? m_back
+ : m_front
+ ;
+
+ if (invalid != last)
+ {
+ remove(last);
+ }
+
+ return last;
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline void HandleListT<MaxHandlesT>::pushFront(uint16_t _handle)
+ {
+ insertBefore(m_front, _handle);
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline uint16_t HandleListT<MaxHandlesT>::popFront()
+ {
+ uint16_t front = m_front;
+
+ if (invalid != front)
+ {
+ remove(front);
+ }
+
+ return front;
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline uint16_t HandleListT<MaxHandlesT>::getFront() const
+ {
+ return m_front;
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline uint16_t HandleListT<MaxHandlesT>::getBack() const
+ {
+ return m_back;
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline uint16_t HandleListT<MaxHandlesT>::getNext(uint16_t _handle) const
+ {
+ BX_CHECK(isValid(_handle), "Invalid handle %d!", _handle);
+ const Link& curr = m_links[_handle];
+ return curr.m_next;
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline uint16_t HandleListT<MaxHandlesT>::getPrev(uint16_t _handle) const
+ {
+ BX_CHECK(isValid(_handle), "Invalid handle %d!", _handle);
+ const Link& curr = m_links[_handle];
+ return curr.m_prev;
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline void HandleListT<MaxHandlesT>::remove(uint16_t _handle)
+ {
+ BX_CHECK(isValid(_handle), "Invalid handle %d!", _handle);
+ Link& curr = m_links[_handle];
+
+ if (invalid != curr.m_prev)
+ {
+ Link& prev = m_links[curr.m_prev];
+ prev.m_next = curr.m_next;
+ }
+ else
+ {
+ m_front = curr.m_next;
+ }
+
+ if (invalid != curr.m_next)
+ {
+ Link& next = m_links[curr.m_next];
+ next.m_prev = curr.m_prev;
+ }
+ else
+ {
+ m_back = curr.m_prev;
+ }
+
+ curr.m_prev = invalid;
+ curr.m_next = invalid;
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline void HandleListT<MaxHandlesT>::reset()
+ {
+ memset(m_links, 0xff, sizeof(m_links) );
+ m_front = invalid;
+ m_back = invalid;
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline void HandleListT<MaxHandlesT>::insertBefore(uint16_t _before, uint16_t _handle)
+ {
+ Link& curr = m_links[_handle];
+ curr.m_next = _before;
+
+ if (invalid != _before)
+ {
+ Link& link = m_links[_before];
+ if (invalid != link.m_prev)
+ {
+ Link& prev = m_links[link.m_prev];
+ prev.m_next = _handle;
+ }
+
+ curr.m_prev = link.m_prev;
+ link.m_prev = _handle;
+ }
+
+ updateFrontBack(_handle);
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline void HandleListT<MaxHandlesT>::insertAfter(uint16_t _after, uint16_t _handle)
+ {
+ Link& curr = m_links[_handle];
+ curr.m_prev = _after;
+
+ if (invalid != _after)
+ {
+ Link& link = m_links[_after];
+ if (invalid != link.m_next)
+ {
+ Link& next = m_links[link.m_next];
+ next.m_prev = _handle;
+ }
+
+ curr.m_next = link.m_next;
+ link.m_next = _handle;
+ }
+
+ updateFrontBack(_handle);
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline bool HandleListT<MaxHandlesT>::isValid(uint16_t _handle) const
+ {
+ return _handle < MaxHandlesT;
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline void HandleListT<MaxHandlesT>::updateFrontBack(uint16_t _handle)
+ {
+ Link& curr = m_links[_handle];
+
+ if (invalid == curr.m_prev)
+ {
+ m_front = _handle;
+ }
+
+ if (invalid == curr.m_next)
+ {
+ m_back = _handle;
+ }
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline HandleAllocLruT<MaxHandlesT>::HandleAllocLruT()
+ {
+ reset();
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline HandleAllocLruT<MaxHandlesT>::~HandleAllocLruT()
+ {
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline const uint16_t* HandleAllocLruT<MaxHandlesT>::getHandles() const
+ {
+ return m_alloc.getHandles();
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline uint16_t HandleAllocLruT<MaxHandlesT>::getHandleAt(uint16_t _at) const
+ {
+ return m_alloc.getHandleAt(_at);
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline uint16_t HandleAllocLruT<MaxHandlesT>::getNumHandles() const
+ {
+ return m_alloc.getNumHandles();
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline uint16_t HandleAllocLruT<MaxHandlesT>::getMaxHandles() const
+ {
+ return m_alloc.getMaxHandles();
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline uint16_t HandleAllocLruT<MaxHandlesT>::alloc()
+ {
+ uint16_t handle = m_alloc.alloc();
+ if (invalid != handle)
+ {
+ m_list.pushFront(handle);
+ }
+ return handle;
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline bool HandleAllocLruT<MaxHandlesT>::isValid(uint16_t _handle) const
+ {
+ return m_alloc.isValid(_handle);
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline void HandleAllocLruT<MaxHandlesT>::free(uint16_t _handle)
+ {
+ BX_CHECK(isValid(_handle), "Invalid handle %d!", _handle);
+ m_list.remove(_handle);
+ m_alloc.free(_handle);
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline void HandleAllocLruT<MaxHandlesT>::touch(uint16_t _handle)
+ {
+ BX_CHECK(isValid(_handle), "Invalid handle %d!", _handle);
+ m_list.remove(_handle);
+ m_list.pushFront(_handle);
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline uint16_t HandleAllocLruT<MaxHandlesT>::getFront() const
+ {
+ return m_list.getFront();
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline uint16_t HandleAllocLruT<MaxHandlesT>::getBack() const
+ {
+ return m_list.getBack();
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline uint16_t HandleAllocLruT<MaxHandlesT>::getNext(uint16_t _handle) const
+ {
+ return m_list.getNext(_handle);
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline uint16_t HandleAllocLruT<MaxHandlesT>::getPrev(uint16_t _handle) const
+ {
+ return m_list.getPrev(_handle);
+ }
+
+ template <uint16_t MaxHandlesT>
+ inline void HandleAllocLruT<MaxHandlesT>::reset()
+ {
+ m_list.reset();
+ m_alloc.reset();
+ }
+
+ template <uint32_t MaxCapacityT, typename KeyT>
+ inline HandleHashMapT<MaxCapacityT, KeyT>::HandleHashMapT()
+ : m_maxCapacity(MaxCapacityT)
+ {
+ reset();
+ }
+
+ template <uint32_t MaxCapacityT, typename KeyT>
+ inline HandleHashMapT<MaxCapacityT, KeyT>::~HandleHashMapT()
+ {
+ }
+
+ template <uint32_t MaxCapacityT, typename KeyT>
+ inline bool HandleHashMapT<MaxCapacityT, KeyT>::insert(KeyT _key, uint16_t _handle)
+ {
+ if (invalid == _handle)
+ {
+ return false;
+ }
+
+ const KeyT hash = mix(_key);
+ const uint32_t firstIdx = hash % MaxCapacityT;
+ uint32_t idx = firstIdx;
+ do
+ {
+ if (m_handle[idx] == invalid)
+ {
+ m_key[idx] = _key;
+ m_handle[idx] = _handle;
+ ++m_numElements;
+ return true;
+ }
+
+ if (m_key[idx] == _key)
+ {
+ return false;
+ }
+
+ idx = (idx + 1) % MaxCapacityT;
+
+ } while (idx != firstIdx);
+
+ return false;
+ }
+
+ template <uint32_t MaxCapacityT, typename KeyT>
+ inline bool HandleHashMapT<MaxCapacityT, KeyT>::removeByKey(KeyT _key)
+ {
+ uint32_t idx = findIndex(_key);
+ if (UINT32_MAX != idx)
+ {
+ removeIndex(idx);
+ return true;
+ }
+
+ return false;
+ }
+
+ template <uint32_t MaxCapacityT, typename KeyT>
+ inline bool HandleHashMapT<MaxCapacityT, KeyT>::removeByHandle(uint16_t _handle)
+ {
+ if (invalid != _handle)
+ {
+ for (uint32_t idx = 0; idx < MaxCapacityT; ++idx)
+ {
+ if (m_handle[idx] == _handle)
+ {
+ removeIndex(idx);
+ }
+ }
+ }
+
+ return false;
+ }
+
+ template <uint32_t MaxCapacityT, typename KeyT>
+ inline uint16_t HandleHashMapT<MaxCapacityT, KeyT>::find(KeyT _key) const
+ {
+ uint32_t idx = findIndex(_key);
+ if (UINT32_MAX != idx)
+ {
+ return m_handle[idx];
+ }
+
+ return invalid;
+ }
+
+ template <uint32_t MaxCapacityT, typename KeyT>
+ inline void HandleHashMapT<MaxCapacityT, KeyT>::reset()
+ {
+ memset(m_handle, 0xff, sizeof(m_handle) );
+ m_numElements = 0;
+ }
+
+ template <uint32_t MaxCapacityT, typename KeyT>
+ inline uint32_t HandleHashMapT<MaxCapacityT, KeyT>::getNumElements() const
+ {
+ return m_numElements;
+ }
+
+ template <uint32_t MaxCapacityT, typename KeyT>
+ inline uint32_t HandleHashMapT<MaxCapacityT, KeyT>::getMaxCapacity() const
+ {
+ return m_maxCapacity;
+ }
+
+ template <uint32_t MaxCapacityT, typename KeyT>
+ inline typename HandleHashMapT<MaxCapacityT, KeyT>::Iterator HandleHashMapT<MaxCapacityT, KeyT>::first() const
+ {
+ Iterator it;
+ it.handle = invalid;
+ it.pos = 0;
+ it.num = m_numElements;
+
+ if (0 == it.num)
+ {
+ return it;
+ }
+
+ ++it.num;
+ next(it);
+ return it;
+ }
+
+ template <uint32_t MaxCapacityT, typename KeyT>
+ inline bool HandleHashMapT<MaxCapacityT, KeyT>::next(Iterator& _it) const
+ {
+ if (0 == _it.num)
+ {
+ return false;
+ }
+
+ for (
+ ;_it.pos < MaxCapacityT && invalid == m_handle[_it.pos]
+ ; ++_it.pos
+ );
+ _it.handle = m_handle[_it.pos];
+ ++_it.pos;
+ --_it.num;
+ return true;
+ }
+
+ template <uint32_t MaxCapacityT, typename KeyT>
+ inline uint32_t HandleHashMapT<MaxCapacityT, KeyT>::findIndex(KeyT _key) const
+ {
+ const KeyT hash = mix(_key);
+
+ const uint32_t firstIdx = hash % MaxCapacityT;
+ uint32_t idx = firstIdx;
+ do
+ {
+ if (m_handle[idx] == invalid)
+ {
+ return UINT32_MAX;
+ }
+
+ if (m_key[idx] == _key)
+ {
+ return idx;
+ }
+
+ idx = (idx + 1) % MaxCapacityT;
+
+ } while (idx != firstIdx);
+
+ return UINT32_MAX;
+ }
+
+ template <uint32_t MaxCapacityT, typename KeyT>
+ inline void HandleHashMapT<MaxCapacityT, KeyT>::removeIndex(uint32_t _idx)
+ {
+ m_handle[_idx] = invalid;
+ --m_numElements;
+
+ for (uint32_t idx = (_idx + 1) % MaxCapacityT
+ ; m_handle[idx] != invalid
+ ; idx = (idx + 1) % MaxCapacityT)
+ {
+ if (m_handle[idx] != invalid)
+ {
+ const KeyT key = m_key[idx];
+ if (idx != findIndex(key) )
+ {
+ const uint16_t handle = m_handle[idx];
+ m_handle[idx] = invalid;
+ --m_numElements;
+ insert(key, handle);
+ }
+ }
+ }
+ }
+
+ template <uint32_t MaxCapacityT, typename KeyT>
+ inline uint32_t HandleHashMapT<MaxCapacityT, KeyT>::mix(uint32_t _x) const
+ {
+ const uint32_t tmp0 = uint32_mul(_x, UINT32_C(2246822519) );
+ const uint32_t tmp1 = uint32_rol(tmp0, 13);
+ const uint32_t result = uint32_mul(tmp1, UINT32_C(2654435761) );
+ return result;
+ }
+
+ template <uint32_t MaxCapacityT, typename KeyT>
+ inline uint64_t HandleHashMapT<MaxCapacityT, KeyT>::mix(uint64_t _x) const
+ {
+ const uint64_t tmp0 = uint64_mul(_x, UINT64_C(14029467366897019727) );
+ const uint64_t tmp1 = uint64_rol(tmp0, 31);
+ const uint64_t result = uint64_mul(tmp1, UINT64_C(11400714785074694791) );
+ return result;
+ }
+
+ template <uint16_t MaxHandlesT, typename KeyT>
+ inline HandleHashMapAllocT<MaxHandlesT, KeyT>::HandleHashMapAllocT()
+ {
+ reset();
+ }
+
+ template <uint16_t MaxHandlesT, typename KeyT>
+ inline HandleHashMapAllocT<MaxHandlesT, KeyT>::~HandleHashMapAllocT()
+ {
+ }
+
+ template <uint16_t MaxHandlesT, typename KeyT>
+ inline uint16_t HandleHashMapAllocT<MaxHandlesT, KeyT>::alloc(KeyT _key)
+ {
+ uint16_t handle = m_alloc.alloc();
+ if (invalid == handle)
+ {
+ return invalid;
+ }
+
+ bool ok = m_table.insert(_key, handle);
+ if (!ok)
+ {
+ m_alloc.free(handle);
+ return invalid;
+ }
+
+ return handle;
+ }
+
+ template <uint16_t MaxHandlesT, typename KeyT>
+ inline void HandleHashMapAllocT<MaxHandlesT, KeyT>::free(KeyT _key)
+ {
+ uint16_t handle = m_table.find(_key);
+ if (invalid == handle)
+ {
+ return;
+ }
+
+ m_table.removeByKey(_key);
+ m_alloc.free(handle);
+ }
+
+ template <uint16_t MaxHandlesT, typename KeyT>
+ inline void HandleHashMapAllocT<MaxHandlesT, KeyT>::free(uint16_t _handle)
+ {
+ m_table.removeByHandle(_handle);
+ m_alloc.free(_handle);
+ }
+
+ template <uint16_t MaxHandlesT, typename KeyT>
+ inline uint16_t HandleHashMapAllocT<MaxHandlesT, KeyT>::find(KeyT _key) const
+ {
+ return m_table.find(_key);
+ }
+
+ template <uint16_t MaxHandlesT, typename KeyT>
+ inline const uint16_t* HandleHashMapAllocT<MaxHandlesT, KeyT>::getHandles() const
+ {
+ return m_alloc.getHandles();
+ }
+
+ template <uint16_t MaxHandlesT, typename KeyT>
+ inline uint16_t HandleHashMapAllocT<MaxHandlesT, KeyT>::getHandleAt(uint16_t _at) const
+ {
+ return m_alloc.getHandleAt(_at);
+ }
+
+ template <uint16_t MaxHandlesT, typename KeyT>
+ inline uint16_t HandleHashMapAllocT<MaxHandlesT, KeyT>::getNumHandles() const
+ {
+ return m_alloc.getNumHandles();
+ }
+
+ template <uint16_t MaxHandlesT, typename KeyT>
+ inline uint16_t HandleHashMapAllocT<MaxHandlesT, KeyT>::getMaxHandles() const
+ {
+ return m_alloc.getMaxHandles();
+ }
+
+ template <uint16_t MaxHandlesT, typename KeyT>
+ inline bool HandleHashMapAllocT<MaxHandlesT, KeyT>::isValid(uint16_t _handle) const
+ {
+ return m_alloc.isValid(_handle);
+ }
+
+ template <uint16_t MaxHandlesT, typename KeyT>
+ inline void HandleHashMapAllocT<MaxHandlesT, KeyT>::reset()
+ {
+ m_table.reset();
+ m_alloc.reset();
+ }
+
+} // namespace bx
diff --git a/3rdparty/bx/include/bx/hash.h b/3rdparty/bx/include/bx/hash.h
index d037c30a3c1..ec0b8164bd0 100644
--- a/3rdparty/bx/include/bx/hash.h
+++ b/3rdparty/bx/include/bx/hash.h
@@ -6,139 +6,41 @@
#ifndef BX_HASH_H_HEADER_GUARD
#define BX_HASH_H_HEADER_GUARD
-#include "bx.h"
+#include "allocator.h" // isAligned
namespace bx
{
-// MurmurHash2 was written by Austin Appleby, and is placed in the public
-// domain. The author hereby disclaims copyright to this source code.
-
-#define MURMUR_M 0x5bd1e995
-#define MURMUR_R 24
-#define mmix(_h, _k) { _k *= MURMUR_M; _k ^= _k >> MURMUR_R; _k *= MURMUR_M; _h *= MURMUR_M; _h ^= _k; }
-
+ /// MurmurHash2 was written by Austin Appleby, and is placed in the public
+ /// domain. The author hereby disclaims copyright to this source code.
+ ///
class HashMurmur2A
{
public:
- void begin(uint32_t _seed = 0)
- {
- m_hash = _seed;
- m_tail = 0;
- m_count = 0;
- m_size = 0;
- }
-
- void add(const void* _data, int _len)
- {
- if (BX_UNLIKELY(!isPtrAligned(_data, 4) ) )
- {
- addUnaligned(_data, _len);
- return;
- }
-
- addAligned(_data, _len);
- }
-
- void addAligned(const void* _data, int _len)
- {
- const uint8_t* data = (const uint8_t*)_data;
- m_size += _len;
-
- mixTail(data, _len);
-
- while(_len >= 4)
- {
- uint32_t kk = *(uint32_t*)data;
-
- mmix(m_hash, kk);
-
- data += 4;
- _len -= 4;
- }
-
- mixTail(data, _len);
- }
+ ///
+ void begin(uint32_t _seed = 0);
- void addUnaligned(const void* _data, int _len)
- {
- const uint8_t* data = (const uint8_t*)_data;
- m_size += _len;
+ ///
+ void add(const void* _data, int _len);
- mixTail(data, _len);
+ ///
+ void addAligned(const void* _data, int _len);
- while(_len >= 4)
- {
- uint32_t kk;
- readUnaligned(data, kk);
-
- mmix(m_hash, kk);
-
- data += 4;
- _len -= 4;
- }
-
- mixTail(data, _len);
- }
+ ///
+ void addUnaligned(const void* _data, int _len);
+ ///
template<typename Ty>
- void add(Ty _value)
- {
- add(&_value, sizeof(Ty) );
- }
-
- uint32_t end()
- {
- mmix(m_hash, m_tail);
- mmix(m_hash, m_size);
-
- m_hash ^= m_hash >> 13;
- m_hash *= MURMUR_M;
- m_hash ^= m_hash >> 15;
+ void add(Ty _value);
- return m_hash;
- }
+ ///
+ uint32_t end();
private:
- static void readUnaligned(const void* _data, uint32_t& _out)
- {
- const uint8_t* data = (const uint8_t*)_data;
- if (BX_ENABLED(BX_CPU_ENDIAN_BIG) )
- {
- _out = 0
- | data[0]<<24
- | data[1]<<16
- | data[2]<<8
- | data[3]
- ;
- }
- else
- {
- _out = 0
- | data[0]
- | data[1]<<8
- | data[2]<<16
- | data[3]<<24
- ;
- }
- }
-
- void mixTail(const uint8_t*& _data, int& _len)
- {
- while( _len && ((_len<4) || m_count) )
- {
- m_tail |= (*_data++) << (m_count * 8);
-
- m_count++;
- _len--;
-
- if(m_count == 4)
- {
- mmix(m_hash, m_tail);
- m_tail = 0;
- m_count = 0;
- }
- }
- }
+ ///
+ static void readUnaligned(const void* _data, uint32_t& _out);
+
+ ///
+ void mixTail(const uint8_t*& _data, int& _len);
uint32_t m_hash;
uint32_t m_tail;
@@ -146,25 +48,15 @@ namespace bx
uint32_t m_size;
};
-#undef MURMUR_M
-#undef MURMUR_R
-#undef mmix
-
- inline uint32_t hashMurmur2A(const void* _data, uint32_t _size)
- {
- HashMurmur2A murmur;
- murmur.begin();
- murmur.add(_data, (int)_size);
- return murmur.end();
- }
+ ///
+ uint32_t hashMurmur2A(const void* _data, uint32_t _size);
+ ///
template <typename Ty>
- inline uint32_t hashMurmur2A(const Ty& _data)
- {
- BX_STATIC_ASSERT(BX_TYPE_IS_POD(Ty) );
- return hashMurmur2A(&_data, sizeof(Ty) );
- }
+ uint32_t hashMurmur2A(const Ty& _data);
} // namespace bx
+#include "hash.inl"
+
#endif // BX_HASH_H_HEADER_GUARD
diff --git a/3rdparty/bx/include/bx/hash.inl b/3rdparty/bx/include/bx/hash.inl
new file mode 100644
index 00000000000..cfa3eca252c
--- /dev/null
+++ b/3rdparty/bx/include/bx/hash.inl
@@ -0,0 +1,154 @@
+/*
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#ifndef BX_HASH_H_HEADER_GUARD
+# error "Must be included from bx/hash.h!"
+#endif // BX_HASH_H_HEADER_GUARD
+
+namespace bx
+{
+#define MURMUR_M 0x5bd1e995
+#define MURMUR_R 24
+#define mmix(_h, _k) { _k *= MURMUR_M; _k ^= _k >> MURMUR_R; _k *= MURMUR_M; _h *= MURMUR_M; _h ^= _k; }
+
+ inline void HashMurmur2A::begin(uint32_t _seed)
+ {
+ m_hash = _seed;
+ m_tail = 0;
+ m_count = 0;
+ m_size = 0;
+ }
+
+ inline void HashMurmur2A::add(const void* _data, int _len)
+ {
+ if (BX_UNLIKELY(!isAligned(_data, 4) ) )
+ {
+ addUnaligned(_data, _len);
+ return;
+ }
+
+ addAligned(_data, _len);
+ }
+
+ inline void HashMurmur2A::addAligned(const void* _data, int _len)
+ {
+ const uint8_t* data = (const uint8_t*)_data;
+ m_size += _len;
+
+ mixTail(data, _len);
+
+ while(_len >= 4)
+ {
+ uint32_t kk = *(uint32_t*)data;
+
+ mmix(m_hash, kk);
+
+ data += 4;
+ _len -= 4;
+ }
+
+ mixTail(data, _len);
+ }
+
+ inline void HashMurmur2A::addUnaligned(const void* _data, int _len)
+ {
+ const uint8_t* data = (const uint8_t*)_data;
+ m_size += _len;
+
+ mixTail(data, _len);
+
+ while(_len >= 4)
+ {
+ uint32_t kk;
+ readUnaligned(data, kk);
+
+ mmix(m_hash, kk);
+
+ data += 4;
+ _len -= 4;
+ }
+
+ mixTail(data, _len);
+ }
+
+ template<typename Ty>
+ inline void HashMurmur2A::add(Ty _value)
+ {
+ add(&_value, sizeof(Ty) );
+ }
+
+ inline uint32_t HashMurmur2A::end()
+ {
+ mmix(m_hash, m_tail);
+ mmix(m_hash, m_size);
+
+ m_hash ^= m_hash >> 13;
+ m_hash *= MURMUR_M;
+ m_hash ^= m_hash >> 15;
+
+ return m_hash;
+ }
+
+ inline void HashMurmur2A::readUnaligned(const void* _data, uint32_t& _out)
+ {
+ const uint8_t* data = (const uint8_t*)_data;
+ if (BX_ENABLED(BX_CPU_ENDIAN_BIG) )
+ {
+ _out = 0
+ | data[0]<<24
+ | data[1]<<16
+ | data[2]<<8
+ | data[3]
+ ;
+ }
+ else
+ {
+ _out = 0
+ | data[0]
+ | data[1]<<8
+ | data[2]<<16
+ | data[3]<<24
+ ;
+ }
+ }
+
+ inline void HashMurmur2A::mixTail(const uint8_t*& _data, int& _len)
+ {
+ while( _len && ((_len<4) || m_count) )
+ {
+ m_tail |= (*_data++) << (m_count * 8);
+
+ m_count++;
+ _len--;
+
+ if(m_count == 4)
+ {
+ mmix(m_hash, m_tail);
+ m_tail = 0;
+ m_count = 0;
+ }
+ }
+ }
+
+#undef MURMUR_M
+#undef MURMUR_R
+#undef mmix
+
+ inline uint32_t hashMurmur2A(const void* _data, uint32_t _size)
+ {
+ HashMurmur2A murmur;
+ murmur.begin();
+ murmur.add(_data, (int)_size);
+ return murmur.end();
+ }
+
+ template <typename Ty>
+ inline uint32_t hashMurmur2A(const Ty& _data)
+ {
+ BX_STATIC_ASSERT(BX_TYPE_IS_POD(Ty) );
+ return hashMurmur2A(&_data, sizeof(Ty) );
+ }
+
+} // namespace bx
diff --git a/3rdparty/bx/include/bx/mutex.h b/3rdparty/bx/include/bx/mutex.h
index 76a02e1a7e8..777e577b950 100644
--- a/3rdparty/bx/include/bx/mutex.h
+++ b/3rdparty/bx/include/bx/mutex.h
@@ -13,52 +13,18 @@
#if BX_CONFIG_SUPPORTS_THREADING
-#if BX_PLATFORM_NACL || BX_PLATFORM_LINUX || BX_PLATFORM_ANDROID || BX_PLATFORM_OSX
+#if 0 \
+ || BX_PLATFORM_ANDROID \
+ || BX_PLATFORM_LINUX \
+ || BX_PLATFORM_NACL \
+ || BX_PLATFORM_IOS \
+ || BX_PLATFORM_OSX
# include <pthread.h>
-#elif BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_WINRT
-# include <errno.h>
-#endif // BX_PLATFORM_
+#endif //
namespace bx
{
-#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
- typedef CRITICAL_SECTION pthread_mutex_t;
- typedef unsigned pthread_mutexattr_t;
-
- inline int pthread_mutex_lock(pthread_mutex_t* _mutex)
- {
- EnterCriticalSection(_mutex);
- return 0;
- }
-
- inline int pthread_mutex_unlock(pthread_mutex_t* _mutex)
- {
- LeaveCriticalSection(_mutex);
- return 0;
- }
-
- inline int pthread_mutex_trylock(pthread_mutex_t* _mutex)
- {
- return TryEnterCriticalSection(_mutex) ? 0 : EBUSY;
- }
-
- inline int pthread_mutex_init(pthread_mutex_t* _mutex, pthread_mutexattr_t* /*_attr*/)
- {
-#if BX_PLATFORM_WINRT
- InitializeCriticalSectionEx(_mutex, 4000, 0); // docs recommend 4000 spincount as sane default
-#else
- InitializeCriticalSection(_mutex);
-#endif
- return 0;
- }
-
- inline int pthread_mutex_destroy(pthread_mutex_t* _mutex)
- {
- DeleteCriticalSection(_mutex);
- return 0;
- }
-#endif // BX_PLATFORM_
-
+ ///
class Mutex
{
BX_CLASS(Mutex
@@ -67,36 +33,27 @@ namespace bx
);
public:
- Mutex()
- {
- pthread_mutexattr_t attr;
-#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
-#else
- pthread_mutexattr_init(&attr);
- pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
-#endif // BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_WINRT
- pthread_mutex_init(&m_handle, &attr);
- }
-
- ~Mutex()
- {
- pthread_mutex_destroy(&m_handle);
- }
-
- void lock()
- {
- pthread_mutex_lock(&m_handle);
- }
-
- void unlock()
- {
- pthread_mutex_unlock(&m_handle);
- }
+ ///
+ Mutex();
+
+ ///
+ ~Mutex();
+
+ ///
+ void lock();
+
+ ///
+ void unlock();
private:
+#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
+ CRITICAL_SECTION m_handle;
+#else
pthread_mutex_t m_handle;
+#endif // BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
};
+ ///
class MutexScope
{
BX_CLASS(MutexScope
@@ -106,16 +63,11 @@ namespace bx
);
public:
- MutexScope(Mutex& _mutex)
- : m_mutex(_mutex)
- {
- m_mutex.lock();
- }
+ ///
+ MutexScope(Mutex& _mutex);
- ~MutexScope()
- {
- m_mutex.unlock();
- }
+ ///
+ ~MutexScope();
private:
Mutex& m_mutex;
@@ -123,6 +75,7 @@ namespace bx
typedef Mutex LwMutex;
+ ///
class LwMutexScope
{
BX_CLASS(LwMutexScope
@@ -132,16 +85,11 @@ namespace bx
);
public:
- LwMutexScope(LwMutex& _mutex)
- : m_mutex(_mutex)
- {
- m_mutex.lock();
- }
+ ///
+ LwMutexScope(LwMutex& _mutex);
- ~LwMutexScope()
- {
- m_mutex.unlock();
- }
+ ///
+ ~LwMutexScope();
private:
LwMutex& m_mutex;
@@ -149,6 +97,8 @@ namespace bx
} // namespace bx
+#include "mutex.inl"
+
#endif // BX_CONFIG_SUPPORTS_THREADING
#endif // BX_MUTEX_H_HEADER_GUARD
diff --git a/3rdparty/bx/include/bx/mutex.inl b/3rdparty/bx/include/bx/mutex.inl
new file mode 100644
index 00000000000..0d4140208e1
--- /dev/null
+++ b/3rdparty/bx/include/bx/mutex.inl
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#ifndef BX_MUTEX_H_HEADER_GUARD
+# error "Must be included from bx/mutex.h!"
+#endif // BX_MUTEX_H_HEADER_GUARD
+
+namespace bx
+{
+ inline MutexScope::MutexScope(Mutex& _mutex)
+ : m_mutex(_mutex)
+ {
+ m_mutex.lock();
+ }
+
+ inline MutexScope::~MutexScope()
+ {
+ m_mutex.unlock();
+ }
+
+ inline LwMutexScope::LwMutexScope(LwMutex& _mutex)
+ : m_mutex(_mutex)
+ {
+ m_mutex.lock();
+ }
+
+ inline LwMutexScope::~LwMutexScope()
+ {
+ m_mutex.unlock();
+ }
+
+} // namespace bx
diff --git a/3rdparty/bx/include/bx/os.h b/3rdparty/bx/include/bx/os.h
index 78349ddab4b..d2639756198 100644
--- a/3rdparty/bx/include/bx/os.h
+++ b/3rdparty/bx/include/bx/os.h
@@ -10,57 +10,6 @@
#include "debug.h"
#include <sys/stat.h>
-#if BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT
-# include <windows.h>
-# include <psapi.h>
-#elif BX_PLATFORM_ANDROID \
- || BX_PLATFORM_EMSCRIPTEN \
- || BX_PLATFORM_BSD \
- || BX_PLATFORM_HURD \
- || BX_PLATFORM_IOS \
- || BX_PLATFORM_LINUX \
- || BX_PLATFORM_NACL \
- || BX_PLATFORM_OSX \
- || BX_PLATFORM_PS4 \
- || BX_PLATFORM_RPI \
- || BX_PLATFORM_STEAMLINK
-# include <sched.h> // sched_yield
-# if BX_PLATFORM_BSD \
- || BX_PLATFORM_IOS \
- || BX_PLATFORM_NACL \
- || BX_PLATFORM_OSX \
- || BX_PLATFORM_PS4 \
- || BX_PLATFORM_STEAMLINK
-# include <pthread.h> // mach_port_t
-# endif // BX_PLATFORM_*
-
-# include <time.h> // nanosleep
-# if !BX_PLATFORM_PS4 && !BX_PLATFORM_NACL
-# include <dlfcn.h> // dlopen, dlclose, dlsym
-# endif // !BX_PLATFORM_PS4 && !BX_PLATFORM_NACL
-
-# if BX_PLATFORM_ANDROID
-# include <malloc.h> // mallinfo
-# elif BX_PLATFORM_LINUX \
- || BX_PLATFORM_RPI \
- || BX_PLATFORM_STEAMLINK
-# include <unistd.h> // syscall
-# include <sys/syscall.h>
-# elif BX_PLATFORM_OSX
-# include <mach/mach.h> // mach_task_basic_info
-# elif BX_PLATFORM_HURD
-# include <pthread/pthread.h> // pthread_self
-# elif BX_PLATFORM_ANDROID
-# include "debug.h" // getTid is not implemented...
-# endif // BX_PLATFORM_ANDROID
-#endif // BX_PLATFORM_
-
-#if BX_CRT_MSVC
-# include <direct.h> // _getcwd
-#else
-# include <unistd.h> // getcwd
-#endif // BX_CRT_MSVC
-
#if BX_PLATFORM_OSX
# define BX_DL_EXT "dylib"
#elif BX_PLATFORM_WINDOWS
@@ -71,241 +20,6 @@
namespace bx
{
- inline void sleep(uint32_t _ms)
- {
-#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360
- ::Sleep(_ms);
-#elif BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
- BX_UNUSED(_ms);
- debugOutput("sleep is not implemented"); debugBreak();
-#else
- timespec req = {(time_t)_ms/1000, (long)((_ms%1000)*1000000)};
- timespec rem = {0, 0};
- ::nanosleep(&req, &rem);
-#endif // BX_PLATFORM_
- }
-
- inline void yield()
- {
-#if BX_PLATFORM_WINDOWS
- ::SwitchToThread();
-#elif BX_PLATFORM_XBOX360
- ::Sleep(0);
-#elif BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
- debugOutput("yield is not implemented"); debugBreak();
-#else
- ::sched_yield();
-#endif // BX_PLATFORM_
- }
-
- inline uint32_t getTid()
- {
-#if BX_PLATFORM_WINDOWS
- return ::GetCurrentThreadId();
-#elif BX_PLATFORM_LINUX || BX_PLATFORM_RPI || BX_PLATFORM_STEAMLINK
- return (pid_t)::syscall(SYS_gettid);
-#elif BX_PLATFORM_IOS || BX_PLATFORM_OSX
- return (mach_port_t)::pthread_mach_thread_np(pthread_self() );
-#elif BX_PLATFORM_BSD || BX_PLATFORM_NACL
- // Casting __nc_basic_thread_data*... need better way to do this.
- return *(uint32_t*)::pthread_self();
-#elif BX_PLATFORM_HURD
- return (pthread_t)::pthread_self();
-#else
-//# pragma message "not implemented."
- debugOutput("getTid is not implemented"); debugBreak();
- return 0;
-#endif //
- }
-
- inline size_t getProcessMemoryUsed()
- {
-#if BX_PLATFORM_ANDROID
- struct mallinfo mi = mallinfo();
- return mi.uordblks;
-#elif BX_PLATFORM_LINUX || BX_PLATFORM_HURD
- FILE* file = fopen("/proc/self/statm", "r");
- if (NULL == file)
- {
- return 0;
- }
-
- long pages = 0;
- int items = fscanf(file, "%*s%ld", &pages);
- fclose(file);
- return 1 == items
- ? pages * sysconf(_SC_PAGESIZE)
- : 0
- ;
-#elif BX_PLATFORM_OSX
-# if defined(MACH_TASK_BASIC_INFO)
- mach_task_basic_info info;
- mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT;
-
- int const result = task_info(mach_task_self()
- , MACH_TASK_BASIC_INFO
- , (task_info_t)&info
- , &infoCount
- );
-# else // MACH_TASK_BASIC_INFO
- task_basic_info info;
- mach_msg_type_number_t infoCount = TASK_BASIC_INFO_COUNT;
-
- int const result = task_info(mach_task_self()
- , TASK_BASIC_INFO
- , (task_info_t)&info
- , &infoCount
- );
-# endif // MACH_TASK_BASIC_INFO
- if (KERN_SUCCESS != result)
- {
- return 0;
- }
-
- return info.resident_size;
-#elif BX_PLATFORM_WINDOWS
- PROCESS_MEMORY_COUNTERS pmc;
- GetProcessMemoryInfo(GetCurrentProcess()
- , &pmc
- , sizeof(pmc)
- );
- return pmc.WorkingSetSize;
-#else
- return 0;
-#endif // BX_PLATFORM_*
- }
-
- inline void* dlopen(const char* _filePath)
- {
-#if BX_PLATFORM_WINDOWS
- return (void*)::LoadLibraryA(_filePath);
-#elif BX_PLATFORM_EMSCRIPTEN \
- || BX_PLATFORM_NACL \
- || BX_PLATFORM_PS4 \
- || BX_PLATFORM_XBOXONE \
- || BX_PLATFORM_WINRT
- BX_UNUSED(_filePath);
- return NULL;
-#else
- return ::dlopen(_filePath, RTLD_LOCAL|RTLD_LAZY);
-#endif // BX_PLATFORM_
- }
-
- inline void dlclose(void* _handle)
- {
-#if BX_PLATFORM_WINDOWS
- ::FreeLibrary( (HMODULE)_handle);
-#elif BX_PLATFORM_EMSCRIPTEN \
- || BX_PLATFORM_NACL \
- || BX_PLATFORM_PS4 \
- || BX_PLATFORM_XBOXONE \
- || BX_PLATFORM_WINRT
- BX_UNUSED(_handle);
-#else
- ::dlclose(_handle);
-#endif // BX_PLATFORM_
- }
-
- inline void* dlsym(void* _handle, const char* _symbol)
- {
-#if BX_PLATFORM_WINDOWS
- return (void*)::GetProcAddress( (HMODULE)_handle, _symbol);
-#elif BX_PLATFORM_EMSCRIPTEN \
- || BX_PLATFORM_NACL \
- || BX_PLATFORM_PS4 \
- || BX_PLATFORM_XBOXONE \
- || BX_PLATFORM_WINRT
- BX_UNUSED(_handle, _symbol);
- return NULL;
-#else
- return ::dlsym(_handle, _symbol);
-#endif // BX_PLATFORM_
- }
-
- inline bool getenv(const char* _name, char* _out, uint32_t* _inOutSize)
- {
-#if BX_PLATFORM_WINDOWS
- DWORD len = ::GetEnvironmentVariableA(_name, _out, *_inOutSize);
- bool result = len != 0 && len < *_inOutSize;
- *_inOutSize = len;
- return result;
-#elif BX_PLATFORM_PS4 \
- || BX_PLATFORM_XBOXONE \
- || BX_PLATFORM_WINRT
- BX_UNUSED(_name, _out, _inOutSize);
- return false;
-#else
- const char* ptr = ::getenv(_name);
- uint32_t len = 0;
- if (NULL != ptr)
- {
- len = (uint32_t)strlen(ptr);
- }
- bool result = len != 0 && len < *_inOutSize;
- if (len < *_inOutSize)
- {
- strcpy(_out, ptr);
- }
-
- *_inOutSize = len;
- return result;
-#endif // BX_PLATFORM_
- }
-
- inline void setenv(const char* _name, const char* _value)
- {
-#if BX_PLATFORM_WINDOWS
- ::SetEnvironmentVariableA(_name, _value);
-#elif BX_PLATFORM_PS4 \
- || BX_PLATFORM_XBOXONE \
- || BX_PLATFORM_WINRT
- BX_UNUSED(_name, _value);
-#else
- ::setenv(_name, _value, 1);
-#endif // BX_PLATFORM_
- }
-
- inline void unsetenv(const char* _name)
- {
-#if BX_PLATFORM_WINDOWS
- ::SetEnvironmentVariableA(_name, NULL);
-#elif BX_PLATFORM_PS4 \
- || BX_PLATFORM_XBOXONE \
- || BX_PLATFORM_WINRT
- BX_UNUSED(_name);
-#else
- ::unsetenv(_name);
-#endif // BX_PLATFORM_
- }
-
- inline int chdir(const char* _path)
- {
-#if BX_PLATFORM_PS4 \
- || BX_PLATFORM_XBOXONE \
- || BX_PLATFORM_WINRT
- BX_UNUSED(_path);
- return -1;
-#elif BX_CRT_MSVC
- return ::_chdir(_path);
-#else
- return ::chdir(_path);
-#endif // BX_COMPILER_
- }
-
- inline char* pwd(char* _buffer, uint32_t _size)
- {
-#if BX_PLATFORM_PS4 \
- || BX_PLATFORM_XBOXONE \
- || BX_PLATFORM_WINRT
- BX_UNUSED(_buffer, _size);
- return NULL;
-#elif BX_CRT_MSVC
- return ::_getcwd(_buffer, (int)_size);
-#else
- return ::getcwd(_buffer, _size);
-#endif // BX_COMPILER_
- }
-
struct FileInfo
{
enum Enum
@@ -320,50 +34,50 @@ namespace bx
Enum m_type;
};
- inline bool stat(const char* _filePath, FileInfo& _fileInfo)
- {
- _fileInfo.m_size = 0;
- _fileInfo.m_type = FileInfo::Count;
+ ///
+ void sleep(uint32_t _ms);
-#if BX_COMPILER_MSVC
- struct ::_stat64 st;
- int32_t result = ::_stat64(_filePath, &st);
+ ///
+ void yield();
- if (0 != result)
- {
- return false;
- }
+ ///
+ uint32_t getTid();
- if (0 != (st.st_mode & _S_IFREG) )
- {
- _fileInfo.m_type = FileInfo::Regular;
- }
- else if (0 != (st.st_mode & _S_IFDIR) )
- {
- _fileInfo.m_type = FileInfo::Directory;
- }
-#else
- struct ::stat st;
- int32_t result = ::stat(_filePath, &st);
- if (0 != result)
- {
- return false;
- }
+ ///
+ size_t getProcessMemoryUsed();
- if (0 != (st.st_mode & S_IFREG) )
- {
- _fileInfo.m_type = FileInfo::Regular;
- }
- else if (0 != (st.st_mode & S_IFDIR) )
- {
- _fileInfo.m_type = FileInfo::Directory;
- }
-#endif // BX_COMPILER_MSVC
+ ///
+ void* dlopen(const char* _filePath);
+
+ ///
+ void dlclose(void* _handle);
+
+ ///
+ void* dlsym(void* _handle, const char* _symbol);
+
+ ///
+ bool getenv(const char* _name, char* _out, uint32_t* _inOutSize);
+
+ ///
+ void setenv(const char* _name, const char* _value);
+
+ ///
+ void unsetenv(const char* _name);
+
+ ///
+ int chdir(const char* _path);
+
+ ///
+ char* pwd(char* _buffer, uint32_t _size);
+
+ ///
+ bool getTempPath(char* _out, uint32_t* _inOutSize);
- _fileInfo.m_size = st.st_size;
+ ///
+ bool stat(const char* _filePath, FileInfo& _fileInfo);
- return true;
- }
+ ///
+ void* exec(const char* const* _argv);
} // namespace bx
diff --git a/3rdparty/bx/include/bx/pixelformat.h b/3rdparty/bx/include/bx/pixelformat.h
new file mode 100644
index 00000000000..5b2bf565803
--- /dev/null
+++ b/3rdparty/bx/include/bx/pixelformat.h
@@ -0,0 +1,243 @@
+/*
+ * Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#ifndef BX_PIXEL_FORMAT_H_HEADER_GUARD
+#define BX_PIXEL_FORMAT_H_HEADER_GUARD
+
+#include <bx/fpumath.h>
+#include <bx/uint32_t.h>
+
+namespace bx
+{
+ struct EncodingType
+ {
+ enum Enum
+ {
+ Unorm,
+ Int,
+ Uint,
+ Float,
+ Snorm,
+
+ Count
+ };
+ };
+
+ typedef void (*PackFn)(void*, const float*);
+ typedef void (*UnpackFn)(float*, const void*);
+
+ ///
+ uint32_t toUnorm(float _value, float _scale);
+
+ ///
+ float fromUnorm(uint32_t _value, float _scale);
+
+ ///
+ int32_t toSnorm(float _value, float _scale);
+
+ ///
+ float fromSnorm(int32_t _value, float _scale);
+
+ // R8
+ void packR8(void* _dst, const float* _src);
+ void unpackR8(float* _dst, const void* _src);
+
+ // R8S
+ void packR8S(void* _dst, const float* _src);
+ void unpackR8S(float* _dst, const void* _src);
+
+ // R8I
+ void packR8I(void* _dst, const float* _src);
+ void unpackR8I(float* _dst, const void* _src);
+
+ // R8U
+ void packR8U(void* _dst, const float* _src);
+ void unpackR8U(float* _dst, const void* _src);
+
+ // RG8
+ void packRg8(void* _dst, const float* _src);
+ void unpackRg8(float* _dst, const void* _src);
+
+ // RG8S
+ void packRg8S(void* _dst, const float* _src);
+ void unpackRg8S(float* _dst, const void* _src);
+
+ // RG8I
+ void packRg8I(void* _dst, const float* _src);
+ void unpackRg8I(float* _dst, const void* _src);
+
+ // RG8U
+ void packRg8U(void* _dst, const float* _src);
+ void unpackRg8U(float* _dst, const void* _src);
+
+ // RGB8
+ void packRgb8(void* _dst, const float* _src);
+ void unpackRgb8(float* _dst, const void* _src);
+
+ // RGB8S
+ void packRgb8S(void* _dst, const float* _src);
+ void unpackRgb8S(float* _dst, const void* _src);
+
+ // RGB8I
+ void packRgb8I(void* _dst, const float* _src);
+ void unpackRgb8I(float* _dst, const void* _src);
+
+ // RGB8U
+ void packRgb8U(void* _dst, const float* _src);
+ void unpackRgb8U(float* _dst, const void* _src);
+
+ // RGBA8
+ void packRgba8(void* _dst, const float* _src);
+ void unpackRgba8(float* _dst, const void* _src);
+
+ // BGRA8
+ void packBgra8(void* _dst, const float* _src);
+ void unpackBgra8(float* _dst, const void* _src);
+
+ // RGBA8S
+ void packRgba8S(void* _dst, const float* _src);
+ void unpackRgba8S(float* _dst, const void* _src);
+
+ // RGBA8I
+ void packRgba8I(void* _dst, const float* _src);
+ void unpackRgba8I(float* _dst, const void* _src);
+
+ // RGBA8U
+ void packRgba8U(void* _dst, const float* _src);
+ void unpackRgba8U(float* _dst, const void* _src);
+
+ // R16
+ void packR16(void* _dst, const float* _src);
+ void unpackR16(float* _dst, const void* _src);
+
+ // R16S
+ void packR16S(void* _dst, const float* _src);
+ void unpackR16S(float* _dst, const void* _src);
+
+ // R16I
+ void packR16I(void* _dst, const float* _src);
+ void unpackR16I(float* _dst, const void* _src);
+
+ // R16U
+ void packR16U(void* _dst, const float* _src);
+ void unpackR16U(float* _dst, const void* _src);
+
+ // R16F
+ void packR16F(void* _dst, const float* _src);
+ void unpackR16F(float* _dst, const void* _src);
+
+ // RG16
+ void packRg16(void* _dst, const float* _src);
+ void unpackRg16(float* _dst, const void* _src);
+
+ // RG16S
+ void packRg16S(void* _dst, const float* _src);
+ void unpackRg16S(float* _dst, const void* _src);
+
+ // RG16I
+ void packRg16I(void* _dst, const float* _src);
+ void unpackRg16I(float* _dst, const void* _src);
+
+ // RG16U
+ void packRg16U(void* _dst, const float* _src);
+ void unpackRg16U(float* _dst, const void* _src);
+
+ // RG16F
+ void packRg16F(void* _dst, const float* _src);
+ void unpackRg16F(float* _dst, const void* _src);
+
+ // RGBA16
+ void packRgba16(void* _dst, const float* _src);
+ void unpackRgba16(float* _dst, const void* _src);
+
+ // RGBA16S
+ void packRgba16S(void* _dst, const float* _src);
+ void unpackRgba16S(float* _dst, const void* _src);
+
+ // RGBA16I
+ void packRgba16I(void* _dst, const float* _src);
+ void unpackRgba16I(float* _dst, const void* _src);
+
+ // RGBA16U
+ void packRgba16U(void* _dst, const float* _src);
+ void unpackRgba16U(float* _dst, const void* _src);
+
+ // RGBA16F
+ void packRgba16F(void* _dst, const float* _src);
+ void unpackRgba16F(float* _dst, const void* _src);
+
+ // R32I
+ void packR32I(void* _dst, const float* _src);
+ void unpackR32I(float* _dst, const void* _src);
+
+ // R32U
+ void packR32U(void* _dst, const float* _src);
+ void unpackR32U(float* _dst, const void* _src);
+
+ // R32F
+ void packR32F(void* _dst, const float* _src);
+ void unpackR32F(float* _dst, const void* _src);
+
+ // RG32I
+ void packRg32I(void* _dst, const float* _src);
+ void unpackRg32I(float* _dst, const void* _src);
+
+ // RG32U
+ void packRg32U(void* _dst, const float* _src);
+ void unpackRg32U(float* _dst, const void* _src);
+
+ // RGB9E5F
+ void packRgb9E5F(void* _dst, const float* _src);
+ void unpackRgb9E5F(float* _dst, const void* _src);
+
+ // RGBA32I
+ void packRgba32I(void* _dst, const float* _src);
+ void unpackRgba32I(float* _dst, const void* _src);
+
+ // RGBA32U
+ void packRgba32U(void* _dst, const float* _src);
+ void unpackRgba32U(float* _dst, const void* _src);
+
+ // RGBA32F
+ void packRgba32F(void* _dst, const float* _src);
+ void unpackRgba32F(float* _dst, const void* _src);
+
+ // R5G6B5
+ void packR5G6B5(void* _dst, const float* _src);
+ void unpackR5G6B5(float* _dst, const void* _src);
+
+ // RGBA4
+ void packRgba4(void* _dst, const float* _src);
+ void unpackRgba4(float* _dst, const void* _src);
+
+ // RGBA4
+ void packBgra4(void* _dst, const float* _src);
+ void unpackBgra4(float* _dst, const void* _src);
+
+ // RGB5A1
+ void packRgb5a1(void* _dst, const float* _src);
+ void unpackRgb5a1(float* _dst, const void* _src);
+
+ // BGR5A1
+ void packBgr5a1(void* _dst, const float* _src);
+ void unpackBgr5a1(float* _dst, const void* _src);
+
+ // RGB10A2
+ void packRgb10A2(void* _dst, const float* _src);
+ void unpackRgb10A2(float* _dst, const void* _src);
+
+ // R11G11B10F
+ void packR11G11B10F(void* _dst, const float* _src);
+ void unpackR11G11B10F(float* _dst, const void* _src);
+
+ // RG32F
+ void packRg32F(void* _dst, const float* _src);
+ void unpackRg32F(float* _dst, const void* _src);
+
+} // namespace bx
+
+#include "pixelformat.inl"
+
+#endif // BX_PIXEL_FORMAT_H_HEADER_GUARD
diff --git a/3rdparty/bx/include/bx/pixelformat.inl b/3rdparty/bx/include/bx/pixelformat.inl
new file mode 100644
index 00000000000..be48c85d931
--- /dev/null
+++ b/3rdparty/bx/include/bx/pixelformat.inl
@@ -0,0 +1,945 @@
+/*
+ * Copyright 2010-2016 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#ifndef BX_PIXEL_FORMAT_H_HEADER_GUARD
+# error "Must be included from bx/pixelformat.h"
+#endif // BX_PIXEL_FORMAT_H_HEADER_GUARD
+
+namespace bx
+{
+ inline uint32_t toUnorm(float _value, float _scale)
+ {
+ return uint32_t(fround(fsaturate(_value) * _scale) );
+ }
+
+ inline float fromUnorm(uint32_t _value, float _scale)
+ {
+ return float(_value) / _scale;
+ }
+
+ inline int32_t toSnorm(float _value, float _scale)
+ {
+ return int32_t(fround(
+ fclamp(_value, -1.0f, 1.0f) * _scale)
+ );
+ }
+
+ inline float fromSnorm(int32_t _value, float _scale)
+ {
+ return fmax(-1.0f, float(_value) / _scale);
+ }
+
+ // R8
+ inline void packR8(void* _dst, const float* _src)
+ {
+ uint8_t* dst = (uint8_t*)_dst;
+ dst[0] = uint8_t(toUnorm(_src[0], 255.0f) );
+ }
+
+ inline void unpackR8(float* _dst, const void* _src)
+ {
+ const uint8_t* src = (const uint8_t*)_src;
+ _dst[0] = fromUnorm(src[0], 255.0f);
+ _dst[1] = 0.0f;
+ _dst[2] = 0.0f;
+ _dst[3] = 1.0f;
+ }
+
+ // R8S
+ inline void packR8S(void* _dst, const float* _src)
+ {
+ int8_t* dst = (int8_t*)_dst;
+ dst[0] = int8_t(toSnorm(_src[0], 127.0f) );
+ }
+
+ inline void unpackR8S(float* _dst, const void* _src)
+ {
+ const int8_t* src = (const int8_t*)_src;
+ _dst[0] = fromSnorm(src[0], 127.0f);
+ _dst[1] = 0.0f;
+ _dst[2] = 0.0f;
+ _dst[3] = 1.0f;
+ }
+
+ // R8I
+ inline void packR8I(void* _dst, const float* _src)
+ {
+ int8_t* dst = (int8_t*)_dst;
+ dst[0] = int8_t(_src[0]);
+ }
+
+ inline void unpackR8I(float* _dst, const void* _src)
+ {
+ const int8_t* src = (const int8_t*)_src;
+ _dst[0] = float(src[0]);
+ _dst[1] = 0.0f;
+ _dst[2] = 0.0f;
+ _dst[3] = 1.0f;
+ }
+
+ // R8U
+ inline void packR8U(void* _dst, const float* _src)
+ {
+ uint8_t* dst = (uint8_t*)_dst;
+ dst[0] = uint8_t(_src[0]);
+ }
+
+ inline void unpackR8U(float* _dst, const void* _src)
+ {
+ const uint8_t* src = (const uint8_t*)_src;
+ _dst[0] = float(src[0]);
+ _dst[1] = 0.0f;
+ _dst[2] = 0.0f;
+ _dst[3] = 1.0f;
+ }
+
+ // RG8
+ inline void packRg8(void* _dst, const float* _src)
+ {
+ uint8_t* dst = (uint8_t*)_dst;
+ dst[0] = uint8_t(toUnorm(_src[0], 255.0f) );
+ dst[1] = uint8_t(toUnorm(_src[1], 255.0f) );
+ }
+
+ inline void unpackRg8(float* _dst, const void* _src)
+ {
+ const uint8_t* src = (const uint8_t*)_src;
+ _dst[0] = fromUnorm(src[0], 255.0f);
+ _dst[1] = fromUnorm(src[1], 255.0f);
+ _dst[2] = 0.0f;
+ _dst[3] = 1.0f;
+ }
+
+ // RG8S
+ inline void packRg8S(void* _dst, const float* _src)
+ {
+ int8_t* dst = (int8_t*)_dst;
+ dst[0] = int8_t(toSnorm(_src[0], 127.0f) );
+ dst[1] = int8_t(toSnorm(_src[1], 127.0f) );
+ }
+
+ inline void unpackRg8S(float* _dst, const void* _src)
+ {
+ const int8_t* src = (const int8_t*)_src;
+ _dst[0] = fromSnorm(src[0], 127.0f);
+ _dst[1] = fromSnorm(src[1], 127.0f);
+ _dst[2] = 0.0f;
+ _dst[3] = 1.0f;
+ }
+
+ // RG8I
+ inline void packRg8I(void* _dst, const float* _src)
+ {
+ int8_t* dst = (int8_t*)_dst;
+ dst[0] = int8_t(_src[0]);
+ dst[1] = int8_t(_src[1]);
+ }
+
+ inline void unpackRg8I(float* _dst, const void* _src)
+ {
+ const int8_t* src = (const int8_t*)_src;
+ _dst[0] = float(src[0]);
+ _dst[1] = float(src[1]);
+ _dst[2] = 0.0f;
+ _dst[3] = 1.0f;
+ }
+
+ // RG8U
+ inline void packRg8U(void* _dst, const float* _src)
+ {
+ uint8_t* dst = (uint8_t*)_dst;
+ dst[0] = uint8_t(_src[0]);
+ dst[1] = uint8_t(_src[1]);
+ }
+
+ inline void unpackRg8U(float* _dst, const void* _src)
+ {
+ const uint8_t* src = (const uint8_t*)_src;
+ _dst[0] = float(src[0]);
+ _dst[1] = float(src[1]);
+ _dst[2] = 0.0f;
+ _dst[3] = 1.0f;
+ }
+
+ // RGB8
+ inline void packRgb8(void* _dst, const float* _src)
+ {
+ uint8_t* dst = (uint8_t*)_dst;
+ dst[0] = uint8_t(toUnorm(_src[0], 255.0f) );
+ dst[1] = uint8_t(toUnorm(_src[1], 255.0f) );
+ dst[2] = uint8_t(toUnorm(_src[2], 255.0f) );
+ }
+
+ inline void unpackRgb8(float* _dst, const void* _src)
+ {
+ const uint8_t* src = (const uint8_t*)_src;
+ _dst[0] = fromUnorm(src[0], 255.0f);
+ _dst[1] = fromUnorm(src[1], 255.0f);
+ _dst[2] = fromUnorm(src[2], 255.0f);
+ _dst[3] = 1.0f;
+ }
+
+ // RGB8S
+ inline void packRgb8S(void* _dst, const float* _src)
+ {
+ int8_t* dst = (int8_t*)_dst;
+ dst[0] = int8_t(toSnorm(_src[0], 127.0f) );
+ dst[1] = int8_t(toSnorm(_src[1], 127.0f) );
+ dst[2] = int8_t(toSnorm(_src[2], 127.0f) );
+ }
+
+ inline void unpackRgb8S(float* _dst, const void* _src)
+ {
+ const int8_t* src = (const int8_t*)_src;
+ _dst[0] = fromSnorm(src[0], 127.0f);
+ _dst[1] = fromSnorm(src[1], 127.0f);
+ _dst[2] = fromSnorm(src[2], 127.0f);
+ _dst[3] = 1.0f;
+ }
+
+ // RGB8I
+ inline void packRgb8I(void* _dst, const float* _src)
+ {
+ int8_t* dst = (int8_t*)_dst;
+ dst[0] = int8_t(_src[0]);
+ dst[1] = int8_t(_src[1]);
+ dst[2] = int8_t(_src[2]);
+ }
+
+ inline void unpackRgb8I(float* _dst, const void* _src)
+ {
+ const int8_t* src = (const int8_t*)_src;
+ _dst[0] = float(src[0]);
+ _dst[1] = float(src[1]);
+ _dst[2] = float(src[2]);
+ _dst[3] = 1.0f;
+ }
+
+ // RGB8U
+ inline void packRgb8U(void* _dst, const float* _src)
+ {
+ uint8_t* dst = (uint8_t*)_dst;
+ dst[0] = uint8_t(_src[0]);
+ dst[1] = uint8_t(_src[1]);
+ dst[2] = uint8_t(_src[2]);
+ }
+
+ inline void unpackRgb8U(float* _dst, const void* _src)
+ {
+ const uint8_t* src = (const uint8_t*)_src;
+ _dst[0] = float(src[0]);
+ _dst[1] = float(src[1]);
+ _dst[2] = float(src[2]);
+ _dst[3] = 1.0f;
+ }
+
+ // BGRA8
+ inline void packBgra8(void* _dst, const float* _src)
+ {
+ uint8_t* dst = (uint8_t*)_dst;
+ dst[2] = uint8_t(toUnorm(_src[0], 255.0f) );
+ dst[1] = uint8_t(toUnorm(_src[1], 255.0f) );
+ dst[0] = uint8_t(toUnorm(_src[2], 255.0f) );
+ dst[3] = uint8_t(toUnorm(_src[3], 255.0f) );
+ }
+
+ inline void unpackBgra8(float* _dst, const void* _src)
+ {
+ const uint8_t* src = (const uint8_t*)_src;
+ _dst[0] = fromUnorm(src[2], 255.0f);
+ _dst[1] = fromUnorm(src[1], 255.0f);
+ _dst[2] = fromUnorm(src[0], 255.0f);
+ _dst[3] = fromUnorm(src[3], 255.0f);
+ }
+
+ // RGBA8
+ inline void packRgba8(void* _dst, const float* _src)
+ {
+ uint8_t* dst = (uint8_t*)_dst;
+ dst[0] = uint8_t(toUnorm(_src[0], 255.0f) );
+ dst[1] = uint8_t(toUnorm(_src[1], 255.0f) );
+ dst[2] = uint8_t(toUnorm(_src[2], 255.0f) );
+ dst[3] = uint8_t(toUnorm(_src[3], 255.0f) );
+ }
+
+ inline void unpackRgba8(float* _dst, const void* _src)
+ {
+ const uint8_t* src = (const uint8_t*)_src;
+ _dst[0] = fromUnorm(src[0], 255.0f);
+ _dst[1] = fromUnorm(src[1], 255.0f);
+ _dst[2] = fromUnorm(src[2], 255.0f);
+ _dst[3] = fromUnorm(src[3], 255.0f);
+ }
+
+ // RGBA8S
+ inline void packRgba8S(void* _dst, const float* _src)
+ {
+ int8_t* dst = (int8_t*)_dst;
+ dst[0] = int8_t(toSnorm(_src[0], 127.0f) );
+ dst[1] = int8_t(toSnorm(_src[1], 127.0f) );
+ dst[2] = int8_t(toSnorm(_src[2], 127.0f) );
+ dst[3] = int8_t(toSnorm(_src[3], 127.0f) );
+ }
+
+ inline void unpackRgba8S(float* _dst, const void* _src)
+ {
+ const int8_t* src = (const int8_t*)_src;
+ _dst[0] = fromSnorm(src[0], 127.0f);
+ _dst[1] = fromSnorm(src[1], 127.0f);
+ _dst[2] = fromSnorm(src[2], 127.0f);
+ _dst[3] = fromSnorm(src[3], 127.0f);
+ }
+
+ // RGBA8I
+ inline void packRgba8I(void* _dst, const float* _src)
+ {
+ int8_t* dst = (int8_t*)_dst;
+ dst[0] = int8_t(_src[0]);
+ dst[1] = int8_t(_src[1]);
+ dst[2] = int8_t(_src[2]);
+ dst[3] = int8_t(_src[3]);
+ }
+
+ inline void unpackRgba8I(float* _dst, const void* _src)
+ {
+ const int8_t* src = (const int8_t*)_src;
+ _dst[0] = float(src[0]);
+ _dst[1] = float(src[1]);
+ _dst[2] = float(src[2]);
+ _dst[3] = float(src[3]);
+ }
+
+ // RGBA8U
+ inline void packRgba8U(void* _dst, const float* _src)
+ {
+ uint8_t* dst = (uint8_t*)_dst;
+ dst[0] = uint8_t(_src[0]);
+ dst[1] = uint8_t(_src[1]);
+ dst[2] = uint8_t(_src[2]);
+ dst[3] = uint8_t(_src[3]);
+ }
+
+ inline void unpackRgba8U(float* _dst, const void* _src)
+ {
+ const uint8_t* src = (const uint8_t*)_src;
+ _dst[0] = float(src[0]);
+ _dst[1] = float(src[1]);
+ _dst[2] = float(src[2]);
+ _dst[3] = float(src[3]);
+ }
+
+ // R16
+ inline void packR16(void* _dst, const float* _src)
+ {
+ uint16_t* dst = (uint16_t*)_dst;
+ dst[0] = uint16_t(toUnorm(_src[0], 65535.0f) );
+ }
+
+ inline void unpackR16(float* _dst, const void* _src)
+ {
+ const uint16_t* src = (const uint16_t*)_src;
+ _dst[0] = fromUnorm(src[0], 65535.0f);
+ _dst[1] = 0.0f;
+ _dst[2] = 0.0f;
+ _dst[3] = 1.0f;
+ }
+
+ // R16S
+ inline void packR16S(void* _dst, const float* _src)
+ {
+ int16_t* dst = (int16_t*)_dst;
+ dst[0] = int16_t(toSnorm(_src[0], 32767.0f) );
+ }
+
+ inline void unpackR16S(float* _dst, const void* _src)
+ {
+ const int16_t* src = (const int16_t*)_src;
+ _dst[0] = fromSnorm(src[0], 32767.0f);
+ _dst[1] = 0.0f;
+ _dst[2] = 0.0f;
+ _dst[3] = 1.0f;
+ }
+
+ // R16I
+ inline void packR16I(void* _dst, const float* _src)
+ {
+ int16_t* dst = (int16_t*)_dst;
+ dst[0] = int16_t(_src[0]);
+ }
+
+ inline void unpackR16I(float* _dst, const void* _src)
+ {
+ const int16_t* src = (const int16_t*)_src;
+ _dst[0] = float(src[0]);
+ _dst[1] = 0.0f;
+ _dst[2] = 0.0f;
+ _dst[3] = 1.0f;
+ }
+
+ // R16U
+ inline void packR16U(void* _dst, const float* _src)
+ {
+ uint16_t* dst = (uint16_t*)_dst;
+ dst[0] = uint16_t(_src[0]);
+ }
+
+ inline void unpackR16U(float* _dst, const void* _src)
+ {
+ const uint16_t* src = (const uint16_t*)_src;
+ _dst[0] = float(src[0]);
+ }
+
+ // R16F
+ inline void packR16F(void* _dst, const float* _src)
+ {
+ uint16_t* dst = (uint16_t*)_dst;
+ dst[0] = halfFromFloat(_src[0]);
+ }
+
+ inline void unpackR16F(float* _dst, const void* _src)
+ {
+ const uint16_t* src = (const uint16_t*)_src;
+ _dst[0] = halfToFloat(src[0]);
+ _dst[1] = 0.0f;
+ _dst[2] = 0.0f;
+ _dst[3] = 1.0f;
+ }
+
+ // RG16
+ inline void packRg16(void* _dst, const float* _src)
+ {
+ uint16_t* dst = (uint16_t*)_dst;
+ dst[0] = uint16_t(toUnorm(_src[0], 65535.0f) );
+ dst[1] = uint16_t(toUnorm(_src[1], 65535.0f) );
+ }
+
+ inline void unpackRg16(float* _dst, const void* _src)
+ {
+ const uint16_t* src = (const uint16_t*)_src;
+ _dst[0] = fromUnorm(src[0], 65535.0f);
+ _dst[1] = fromUnorm(src[1], 65535.0f);
+ _dst[2] = 0.0f;
+ _dst[3] = 1.0f;
+ }
+
+ // RG16S
+ inline void packRg16S(void* _dst, const float* _src)
+ {
+ int16_t* dst = (int16_t*)_dst;
+ dst[0] = int16_t(toSnorm(_src[0], 32767.0f) );
+ dst[1] = int16_t(toSnorm(_src[1], 32767.0f) );
+ }
+
+ inline void unpackRg16S(float* _dst, const void* _src)
+ {
+ const int16_t* src = (const int16_t*)_src;
+ _dst[0] = fromSnorm(src[0], 32767.0f);
+ _dst[1] = fromSnorm(src[1], 32767.0f);
+ _dst[2] = 0.0f;
+ _dst[3] = 1.0f;
+ }
+
+ // RG16I
+ inline void packRg16I(void* _dst, const float* _src)
+ {
+ int16_t* dst = (int16_t*)_dst;
+ dst[0] = int16_t(_src[0]);
+ dst[1] = int16_t(_src[1]);
+ }
+
+ inline void unpackRg16I(float* _dst, const void* _src)
+ {
+ const int16_t* src = (const int16_t*)_src;
+ _dst[0] = float(src[0]);
+ _dst[1] = float(src[1]);
+ _dst[2] = 0.0f;
+ _dst[3] = 1.0f;
+ }
+
+ // RG16U
+ inline void packRg16U(void* _dst, const float* _src)
+ {
+ uint16_t* dst = (uint16_t*)_dst;
+ dst[0] = uint16_t(_src[0]);
+ dst[1] = uint16_t(_src[1]);
+ }
+
+ inline void unpackRg16U(float* _dst, const void* _src)
+ {
+ const uint16_t* src = (const uint16_t*)_src;
+ _dst[0] = float(src[0]);
+ _dst[1] = float(src[1]);
+ _dst[2] = 0.0f;
+ _dst[3] = 1.0f;
+ }
+
+ // RG16F
+ inline void packRg16F(void* _dst, const float* _src)
+ {
+ uint16_t* dst = (uint16_t*)_dst;
+ dst[0] = halfFromFloat(_src[0]);
+ dst[1] = halfFromFloat(_src[1]);
+ }
+
+ inline void unpackRg16F(float* _dst, const void* _src)
+ {
+ const uint16_t* src = (const uint16_t*)_src;
+ _dst[0] = halfToFloat(src[0]);
+ _dst[1] = halfToFloat(src[1]);
+ _dst[2] = 0.0f;
+ _dst[3] = 1.0f;
+ }
+
+ // RGBA16
+ inline void packRgba16(void* _dst, const float* _src)
+ {
+ uint16_t* dst = (uint16_t*)_dst;
+ dst[0] = uint16_t(toUnorm(_src[0], 65535.0f) );
+ dst[1] = uint16_t(toUnorm(_src[1], 65535.0f) );
+ dst[2] = uint16_t(toUnorm(_src[2], 65535.0f) );
+ dst[3] = uint16_t(toUnorm(_src[3], 65535.0f) );
+ }
+
+ inline void unpackRgba16(float* _dst, const void* _src)
+ {
+ const uint16_t* src = (const uint16_t*)_src;
+ _dst[0] = fromUnorm(src[0], 65535.0f);
+ _dst[1] = fromUnorm(src[1], 65535.0f);
+ _dst[2] = fromUnorm(src[2], 65535.0f);
+ _dst[3] = fromUnorm(src[3], 65535.0f);
+ }
+
+ // RGBA16S
+ inline void packRgba16S(void* _dst, const float* _src)
+ {
+ int16_t* dst = (int16_t*)_dst;
+ dst[0] = int16_t(toSnorm(_src[0], 32767.0f) );
+ dst[1] = int16_t(toSnorm(_src[1], 32767.0f) );
+ dst[2] = int16_t(toSnorm(_src[2], 32767.0f) );
+ dst[3] = int16_t(toSnorm(_src[3], 32767.0f) );
+ }
+
+ inline void unpackRgba16S(float* _dst, const void* _src)
+ {
+ const int16_t* src = (const int16_t*)_src;
+ _dst[0] = fromSnorm(src[0], 32767.0f);
+ _dst[1] = fromSnorm(src[1], 32767.0f);
+ _dst[2] = fromSnorm(src[2], 32767.0f);
+ _dst[3] = fromSnorm(src[3], 32767.0f);
+ }
+
+ // RGBA16I
+ inline void packRgba16I(void* _dst, const float* _src)
+ {
+ int16_t* dst = (int16_t*)_dst;
+ dst[0] = int16_t(_src[0]);
+ dst[1] = int16_t(_src[1]);
+ dst[2] = int16_t(_src[2]);
+ dst[3] = int16_t(_src[3]);
+ }
+
+ inline void unpackRgba16I(float* _dst, const void* _src)
+ {
+ const int16_t* src = (const int16_t*)_src;
+ _dst[0] = float(src[0]);
+ _dst[1] = float(src[1]);
+ _dst[2] = float(src[2]);
+ _dst[3] = float(src[3]);
+ }
+
+ // RGBA16U
+ inline void packRgba16U(void* _dst, const float* _src)
+ {
+ uint16_t* dst = (uint16_t*)_dst;
+ dst[0] = uint16_t(_src[0]);
+ dst[1] = uint16_t(_src[1]);
+ dst[2] = uint16_t(_src[2]);
+ dst[3] = uint16_t(_src[3]);
+ }
+
+ inline void unpackRgba16U(float* _dst, const void* _src)
+ {
+ const uint16_t* src = (const uint16_t*)_src;
+ _dst[0] = float(src[0]);
+ _dst[1] = float(src[1]);
+ _dst[2] = float(src[2]);
+ _dst[3] = float(src[3]);
+ }
+
+ // RGBA16F
+ inline void packRgba16F(void* _dst, const float* _src)
+ {
+ uint16_t* dst = (uint16_t*)_dst;
+ dst[0] = halfFromFloat(_src[0]);
+ dst[1] = halfFromFloat(_src[1]);
+ dst[2] = halfFromFloat(_src[2]);
+ dst[3] = halfFromFloat(_src[3]);
+ }
+
+ inline void unpackRgba16F(float* _dst, const void* _src)
+ {
+ const uint16_t* src = (const uint16_t*)_src;
+ _dst[0] = halfToFloat(src[0]);
+ _dst[1] = halfToFloat(src[1]);
+ _dst[2] = halfToFloat(src[2]);
+ _dst[3] = halfToFloat(src[3]);
+ }
+
+ // R24
+ inline void packR24(void* _dst, const float* _src)
+ {
+ uint8_t* dst = (uint8_t*)_dst;
+ const uint32_t rr = uint32_t(toUnorm(_src[0], 16777216.0f) );
+ dst[0] = uint8_t(rr );
+ dst[1] = uint8_t(rr>> 8);
+ dst[2] = uint8_t(rr>>16);
+ }
+
+ inline void unpackR24(float* _dst, const void* _src)
+ {
+ const uint8_t* src = (const uint8_t*)_src;
+ const uint32_t rr = 0
+ | (src[0] )
+ | (src[1]<< 8)
+ | (src[2]<<16)
+ ;
+
+ _dst[0] = fromUnorm(rr, 16777216.0f);
+ _dst[1] = 0.0f;
+ _dst[2] = 0.0f;
+ _dst[3] = 1.0f;
+ }
+
+ // R24G8
+ inline void packR24G8(void* _dst, const float* _src)
+ {
+ uint8_t* dst = (uint8_t*)_dst;
+ const uint32_t rr = uint32_t(toUnorm(_src[0], 16777216.0f) );
+ dst[0] = uint8_t(rr );
+ dst[1] = uint8_t(rr>> 8);
+ dst[2] = uint8_t(rr>>16);
+ dst[3] = uint8_t(toUnorm(_src[1], 255.0f) );
+ }
+
+ inline void unpackR24G8(float* _dst, const void* _src)
+ {
+ const uint8_t* src = (const uint8_t*)_src;
+ const uint32_t rr = 0
+ | (src[0] )
+ | (src[1]<< 8)
+ | (src[2]<<16)
+ ;
+
+ _dst[0] = fromUnorm(rr, 16777216.0f);
+ _dst[1] = fromUnorm(src[3], 255.0f);
+ _dst[2] = 0.0f;
+ _dst[3] = 1.0f;
+ }
+
+ // R32I
+ inline void packR32I(void* _dst, const float* _src)
+ {
+ memcpy(_dst, _src, 4);
+ }
+
+ inline void unpackR32I(float* _dst, const void* _src)
+ {
+ memcpy(_dst, _src, 4);
+ }
+
+ // R32U
+ inline void packR32U(void* _dst, const float* _src)
+ {
+ memcpy(_dst, _src, 4);
+ }
+
+ inline void unpackR32U(float* _dst, const void* _src)
+ {
+ memcpy(_dst, _src, 4);
+ }
+
+ // R32F
+ inline void packR32F(void* _dst, const float* _src)
+ {
+ memcpy(_dst, _src, 4);
+ }
+
+ inline void unpackR32F(float* _dst, const void* _src)
+ {
+ memcpy(_dst, _src, 4);
+ }
+
+ // RG32I
+ inline void packRg32I(void* _dst, const float* _src)
+ {
+ memcpy(_dst, _src, 8);
+ }
+
+ inline void unpackRg32I(float* _dst, const void* _src)
+ {
+ memcpy(_dst, _src, 8);
+ }
+
+ // RG32U
+ inline void packRg32U(void* _dst, const float* _src)
+ {
+ memcpy(_dst, _src, 8);
+ }
+
+ inline void unpackRg32U(float* _dst, const void* _src)
+ {
+ memcpy(_dst, _src, 8);
+ }
+
+ // RG32F
+ inline void packRg32F(void* _dst, const float* _src)
+ {
+ memcpy(_dst, _src, 8);
+ }
+
+ inline void unpackRg32F(float* _dst, const void* _src)
+ {
+ memcpy(_dst, _src, 8);
+ }
+
+ template<int32_t MantissaBits, int32_t ExpBits>
+ inline void encodeRgbE(float* _dst, const float* _src)
+ {
+ // Reference:
+ // https://www.opengl.org/registry/specs/EXT/texture_shared_exponent.txt
+ const int32_t expMax = (1<<ExpBits) - 1;
+ const int32_t expBias = (1<<(ExpBits - 1) ) - 1;
+ const float sharedExpMax = float(expMax) / float(expMax + 1) * float(1 << (expMax - expBias) );
+
+ const float rr = fclamp(_src[0], 0.0f, sharedExpMax);
+ const float gg = fclamp(_src[1], 0.0f, sharedExpMax);
+ const float bb = fclamp(_src[2], 0.0f, sharedExpMax);
+ const float max = fmax3(rr, gg, bb);
+ union { float ff; uint32_t ui; } cast = { max };
+ int32_t expShared = int32_t(uint32_imax(uint32_t(-expBias-1), ( ( (cast.ui>>23) & 0xff) - 127) ) ) + 1 + expBias;
+ float denom = fpow(2.0f, float(expShared - expBias - MantissaBits) );
+
+ if ( (1<<MantissaBits) == int32_t(fround(max/denom) ) )
+ {
+ denom *= 2.0f;
+ ++expShared;
+ }
+
+ const float invDenom = 1.0f/denom;
+ _dst[0] = fround(rr * invDenom);
+ _dst[1] = fround(gg * invDenom);
+ _dst[2] = fround(bb * invDenom);
+ _dst[3] = float(expShared);
+ }
+
+ template<int32_t MantissaBits, int32_t ExpBits>
+ inline void decodeRgbE(float* _dst, const float* _src)
+ {
+ const int32_t expBias = (1<<(ExpBits - 1) ) - 1;
+ const float exponent = _src[3]-float(expBias-MantissaBits);
+ const float scale = fpow(2.0f, exponent);
+ _dst[0] = _src[0] * scale;
+ _dst[1] = _src[1] * scale;
+ _dst[2] = _src[2] * scale;
+ }
+
+ // RGB9E5F
+ inline void packRgb9E5F(void* _dst, const float* _src)
+ {
+ float tmp[4];
+ encodeRgbE<9, 5>(tmp, _src);
+
+ *( (uint32_t*)_dst) = 0
+ | (uint32_t(tmp[0]) )
+ | (uint32_t(tmp[1]) << 9)
+ | (uint32_t(tmp[2]) <<18)
+ | (uint32_t(tmp[3]) <<27)
+ ;
+ }
+
+ inline void unpackRgb9E5F(float* _dst, const void* _src)
+ {
+ uint32_t packed = *( (const uint32_t*)_src);
+
+ float tmp[4];
+ tmp[0] = float( ( (packed ) & 0x1ff) ) / 511.0f;
+ tmp[1] = float( ( (packed>> 9) & 0x1ff) ) / 511.0f;
+ tmp[2] = float( ( (packed>>18) & 0x1ff) ) / 511.0f;
+ tmp[3] = float( ( (packed>>27) & 0x1f) );
+
+ decodeRgbE<9, 5>(_dst, tmp);
+ }
+
+ // RGBA32I
+ inline void packRgba32I(void* _dst, const float* _src)
+ {
+ memcpy(_dst, _src, 16);
+ }
+
+ inline void unpackRgba32I(float* _dst, const void* _src)
+ {
+ memcpy(_dst, _src, 16);
+ }
+
+ // RGBA32U
+ inline void packRgba32U(void* _dst, const float* _src)
+ {
+ memcpy(_dst, _src, 16);
+ }
+
+ inline void unpackRgba32U(float* _dst, const void* _src)
+ {
+ memcpy(_dst, _src, 16);
+ }
+
+ // RGBA32F
+ inline void packRgba32F(void* _dst, const float* _src)
+ {
+ memcpy(_dst, _src, 16);
+ }
+
+ inline void unpackRgba32F(float* _dst, const void* _src)
+ {
+ memcpy(_dst, _src, 16);
+ }
+
+ // R5G6B5
+ inline void packR5G6B5(void* _dst, const float* _src)
+ {
+ *( (uint16_t*)_dst) = 0
+ | uint16_t(toUnorm(_src[0], 31.0f)<<11)
+ | uint16_t(toUnorm(_src[1], 63.0f)<< 5)
+ | uint16_t(toUnorm(_src[2], 31.0f) )
+ ;
+ }
+
+ inline void unpackR5G6B5(float* _dst, const void* _src)
+ {
+ uint16_t packed = *( (const uint16_t*)_src);
+ _dst[0] = float( ( (packed>>11) & 0x1f) ) / 31.0f;
+ _dst[1] = float( ( (packed>> 5) & 0x3f) ) / 63.0f;
+ _dst[2] = float( ( (packed ) & 0x1f) ) / 31.0f;
+ _dst[3] = 1.0f;
+ }
+
+ // RGBA4
+ inline void packRgba4(void* _dst, const float* _src)
+ {
+ *( (uint16_t*)_dst) = 0
+ | uint16_t(toUnorm(_src[0], 15.0f) )
+ | uint16_t(toUnorm(_src[1], 15.0f)<< 4)
+ | uint16_t(toUnorm(_src[2], 15.0f)<< 8)
+ | uint16_t(toUnorm(_src[3], 15.0f)<<12)
+ ;
+ }
+
+ inline void unpackRgba4(float* _dst, const void* _src)
+ {
+ uint16_t packed = *( (const uint16_t*)_src);
+ _dst[0] = float( ( (packed ) & 0xf) ) / 15.0f;
+ _dst[1] = float( ( (packed>> 4) & 0xf) ) / 15.0f;
+ _dst[2] = float( ( (packed>> 8) & 0xf) ) / 15.0f;
+ _dst[3] = float( ( (packed>>12) & 0xf) ) / 15.0f;
+ }
+
+ // RGBA4
+ inline void packBgra4(void* _dst, const float* _src)
+ {
+ *( (uint16_t*)_dst) = 0
+ | uint16_t(toUnorm(_src[0], 15.0f)<< 8)
+ | uint16_t(toUnorm(_src[1], 15.0f)<< 4)
+ | uint16_t(toUnorm(_src[2], 15.0f) )
+ | uint16_t(toUnorm(_src[3], 15.0f)<<12)
+ ;
+ }
+
+ inline void unpackBgra4(float* _dst, const void* _src)
+ {
+ uint16_t packed = *( (const uint16_t*)_src);
+ _dst[0] = float( ( (packed>> 8) & 0xf) ) / 15.0f;
+ _dst[1] = float( ( (packed>> 4) & 0xf) ) / 15.0f;
+ _dst[2] = float( ( (packed ) & 0xf) ) / 15.0f;
+ _dst[3] = float( ( (packed>>12) & 0xf) ) / 15.0f;
+ }
+
+ // RGB5A1
+ inline void packRgb5a1(void* _dst, const float* _src)
+ {
+ *( (uint16_t*)_dst) = 0
+ | uint16_t(toUnorm(_src[0], 31.0f) )
+ | uint16_t(toUnorm(_src[1], 31.0f)<< 5)
+ | uint16_t(toUnorm(_src[2], 31.0f)<<10)
+ | uint16_t(toUnorm(_src[3], 1.0f)<<15)
+ ;
+ }
+
+ inline void unpackRgb5a1(float* _dst, const void* _src)
+ {
+ uint16_t packed = *( (const uint16_t*)_src);
+ _dst[0] = float( ( (packed ) & 0x1f) ) / 31.0f;
+ _dst[1] = float( ( (packed>> 5) & 0x1f) ) / 31.0f;
+ _dst[2] = float( ( (packed>>10) & 0x1f) ) / 31.0f;
+ _dst[3] = float( ( (packed>>14) & 0x1) );
+ }
+
+ // BGR5A1
+ inline void packBgr5a1(void* _dst, const float* _src)
+ {
+ *( (uint16_t*)_dst) = 0
+ | uint16_t(toUnorm(_src[0], 31.0f)<<10)
+ | uint16_t(toUnorm(_src[1], 31.0f)<< 5)
+ | uint16_t(toUnorm(_src[2], 31.0f) )
+ | uint16_t(toUnorm(_src[3], 1.0f)<<15)
+ ;
+ }
+
+ inline void unpackBgr5a1(float* _dst, const void* _src)
+ {
+ uint16_t packed = *( (const uint16_t*)_src);
+ _dst[0] = float( ( (packed>>10) & 0x1f) ) / 31.0f;
+ _dst[1] = float( ( (packed>> 5) & 0x1f) ) / 31.0f;
+ _dst[2] = float( ( (packed ) & 0x1f) ) / 31.0f;
+ _dst[3] = float( ( (packed>>14) & 0x1) );
+ }
+
+ // RGB10A2
+ inline void packRgb10A2(void* _dst, const float* _src)
+ {
+ *( (uint32_t*)_dst) = 0
+ | (toUnorm(_src[0], 1023.0f) )
+ | (toUnorm(_src[1], 1023.0f)<<10)
+ | (toUnorm(_src[2], 1023.0f)<<20)
+ | (toUnorm(_src[3], 3.0f)<<30)
+ ;
+ }
+
+ inline void unpackRgb10A2(float* _dst, const void* _src)
+ {
+ uint32_t packed = *( (const uint32_t*)_src);
+ _dst[0] = float( ( (packed ) & 0x3ff) ) / 1023.0f;
+ _dst[1] = float( ( (packed>>10) & 0x3ff) ) / 1023.0f;
+ _dst[2] = float( ( (packed>>20) & 0x3ff) ) / 1023.0f;
+ _dst[3] = float( ( (packed>>30) & 0x3) ) / 3.0f;
+ }
+
+ // R11G11B10F
+ inline void packR11G11B10F(void* _dst, const float* _src)
+ {
+ *( (uint32_t*)_dst) = 0
+ | ( (halfFromFloat(_src[0])>> 4) & 0x7ff)
+ | ( (halfFromFloat(_src[0])<< 7) & 0x3ff800)
+ | ( (halfFromFloat(_src[0])<<17) & 0xffc00000)
+ ;
+ }
+
+ inline void unpackR11G11B10F(float* _dst, const void* _src)
+ {
+ uint32_t packed = *( (const uint32_t*)_src);
+ _dst[0] = halfToFloat( (packed<< 4) & 0x7ff0);
+ _dst[1] = halfToFloat( (packed>> 7) & 0x7ff0);
+ _dst[2] = halfToFloat( (packed>>17) & 0x7fe0);
+ _dst[3] = 1.0f;
+ }
+} // namespace bx
diff --git a/3rdparty/bx/include/bx/platform.h b/3rdparty/bx/include/bx/platform.h
index e976732c031..99d29a037d9 100644
--- a/3rdparty/bx/include/bx/platform.h
+++ b/3rdparty/bx/include/bx/platform.h
@@ -31,6 +31,7 @@
// C Runtime
#define BX_CRT_MSVC 0
#define BX_CRT_GLIBC 0
+#define BX_CRT_LIBCXX 0
#define BX_CRT_NEWLIB 0
#define BX_CRT_MINGW 0
#define BX_CRT_MUSL 0
@@ -68,7 +69,13 @@
# elif defined(__GLIBC__)
# undef BX_CRT_GLIBC
# define BX_CRT_GLIBC (__GLIBC__ * 10000 + __GLIBC_MINOR__ * 100)
-# endif // defined(__GLIBC__)
+# elif defined(__MINGW32__) || defined(__MINGW64__)
+# undef BX_CRT_MINGW
+# define BX_CRT_MINGW 1
+# elif defined(__apple_build_version__) || defined(__ANDROID__)
+# undef BX_CRT_LIBCXX
+# define BX_CRT_LIBCXX 1
+# endif //
#elif defined(_MSC_VER)
# undef BX_COMPILER_MSVC
# define BX_COMPILER_MSVC _MSC_VER
@@ -201,8 +208,7 @@
// RaspberryPi compiler defines __linux__
# undef BX_PLATFORM_RPI
# define BX_PLATFORM_RPI 1
-#elif defined(__linux__) \
- || BX_CPU_RISCV
+#elif defined(__linux__)
# undef BX_PLATFORM_LINUX
# define BX_PLATFORM_LINUX 1
#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) \
@@ -231,24 +237,31 @@
#elif defined(__GNU__)
# undef BX_PLATFORM_HURD
# define BX_PLATFORM_HURD 1
-#else
-# error "BX_PLATFORM_* is not defined!"
#endif //
-#define BX_PLATFORM_POSIX (0 \
- || BX_PLATFORM_ANDROID \
- || BX_PLATFORM_EMSCRIPTEN \
- || BX_PLATFORM_BSD \
- || BX_PLATFORM_HURD \
- || BX_PLATFORM_IOS \
- || BX_PLATFORM_LINUX \
- || BX_PLATFORM_NACL \
- || BX_PLATFORM_OSX \
- || BX_PLATFORM_QNX \
- || BX_PLATFORM_STEAMLINK \
- || BX_PLATFORM_PS4 \
- || BX_PLATFORM_RPI \
- )
+#define BX_PLATFORM_POSIX (0 \
+ || BX_PLATFORM_ANDROID \
+ || BX_PLATFORM_EMSCRIPTEN \
+ || BX_PLATFORM_BSD \
+ || BX_PLATFORM_HURD \
+ || BX_PLATFORM_IOS \
+ || BX_PLATFORM_LINUX \
+ || BX_PLATFORM_NACL \
+ || BX_PLATFORM_OSX \
+ || BX_PLATFORM_QNX \
+ || BX_PLATFORM_STEAMLINK \
+ || BX_PLATFORM_PS4 \
+ || BX_PLATFORM_RPI \
+ )
+
+#define BX_CRT_NONE !(0 \
+ || BX_CRT_MSVC \
+ || BX_CRT_GLIBC \
+ || BX_CRT_LIBCXX \
+ || BX_CRT_NEWLIB \
+ || BX_CRT_MINGW \
+ || BX_CRT_MUSL \
+ )
#ifndef BX_CONFIG_ENABLE_MSVC_LEVEL4_WARNINGS
# define BX_CONFIG_ENABLE_MSVC_LEVEL4_WARNINGS 0
@@ -319,6 +332,8 @@
# define BX_PLATFORM_NAME "Xbox 360"
#elif BX_PLATFORM_XBOXONE
# define BX_PLATFORM_NAME "Xbox One"
+#else
+# define BX_PLATFORM_NAME "None"
#endif // BX_PLATFORM_
#if BX_CPU_ARM
@@ -335,6 +350,20 @@
# define BX_CPU_NAME "x86"
#endif // BX_CPU_
+#if BX_CRT_MSVC
+# define BX_CRT_NAME "MSVC C Runtime"
+#elif BX_CRT_GLIBC
+# define BX_CRT_NAME "GNU C Library"
+#elif BX_CRT_NEWLIB
+# define BX_CRT_NAME "Newlib"
+#elif BX_CRT_MINGW
+# define BX_CRT_NAME "MinGW C Runtime"
+#elif BX_CRT_MUSL
+# define BX_CRT_NAME "musl libc"
+#else
+# define BX_CRT_NAME "None"
+#endif // BX_CRT_
+
#if BX_ARCH_32BIT
# define BX_ARCH_NAME "32-bit"
#elif BX_ARCH_64BIT
diff --git a/3rdparty/bx/include/bx/process.h b/3rdparty/bx/include/bx/process.h
deleted file mode 100644
index 03c8f120624..00000000000
--- a/3rdparty/bx/include/bx/process.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
- */
-
-#ifndef BX_PROCESS_H_HEADER_GUARD
-#define BX_PROCESS_H_HEADER_GUARD
-
-#include "string.h"
-#include "uint32_t.h"
-
-#if BX_PLATFORM_LINUX || BX_PLATFORM_HURD
-# include <unistd.h>
-#endif // BX_PLATFORM_LINUX || BX_PLATFORM_HURD
-
-namespace bx
-{
- ///
- inline void* exec(const char* const* _argv)
- {
-#if BX_PLATFORM_LINUX || BX_PLATFORM_HURD
- pid_t pid = fork();
-
- if (0 == pid)
- {
- int result = execvp(_argv[0], const_cast<char *const*>(&_argv[1]) );
- BX_UNUSED(result);
- return NULL;
- }
-
- return (void*)uintptr_t(pid);
-#elif BX_PLATFORM_WINDOWS
- STARTUPINFO si;
- memset(&si, 0, sizeof(STARTUPINFO) );
- si.cb = sizeof(STARTUPINFO);
-
- PROCESS_INFORMATION pi;
- memset(&pi, 0, sizeof(PROCESS_INFORMATION) );
-
- int32_t total = 0;
- for (uint32_t ii = 0; NULL != _argv[ii]; ++ii)
- {
- total += (int32_t)strlen(_argv[ii]) + 1;
- }
-
- char* temp = (char*)alloca(total);
- int32_t len = 0;
- for(uint32_t ii = 0; NULL != _argv[ii]; ++ii)
- {
- len += snprintf(&temp[len], bx::uint32_imax(0, total-len)
- , "%s "
- , _argv[ii]
- );
- }
-
- bool ok = CreateProcessA(_argv[0]
- , temp
- , NULL
- , NULL
- , false
- , 0
- , NULL
- , NULL
- , &si
- , &pi
- );
- if (ok)
- {
- return pi.hProcess;
- }
-
- return NULL;
-#else
- return NULL;
-#endif // BX_PLATFORM_LINUX || BX_PLATFORM_HURD
- }
-
-} // namespace bx
-
-#endif // BX_PROCESS_H_HEADER_GUARD
diff --git a/3rdparty/bx/include/bx/radixsort.h b/3rdparty/bx/include/bx/radixsort.h
index 2c4dd6a2408..87bd3e310b0 100644
--- a/3rdparty/bx/include/bx/radixsort.h
+++ b/3rdparty/bx/include/bx/radixsort.h
@@ -10,282 +10,42 @@
namespace bx
{
-#define BX_RADIXSORT_BITS 11
-#define BX_RADIXSORT_HISTOGRAM_SIZE (1<<BX_RADIXSORT_BITS)
-#define BX_RADIXSORT_BIT_MASK (BX_RADIXSORT_HISTOGRAM_SIZE-1)
-
- inline void radixSort(uint32_t* __restrict _keys, uint32_t* __restrict _tempKeys, uint32_t _size)
- {
- uint32_t* __restrict keys = _keys;
- uint32_t* __restrict tempKeys = _tempKeys;
-
- uint32_t histogram[BX_RADIXSORT_HISTOGRAM_SIZE];
- uint16_t shift = 0;
- uint32_t pass = 0;
- for (; pass < 3; ++pass)
- {
- memset(histogram, 0, sizeof(uint32_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
-
- bool sorted = true;
- {
- uint32_t key = keys[0];
- uint32_t prevKey = key;
- for (uint32_t ii = 0; ii < _size; ++ii, prevKey = key)
- {
- key = keys[ii];
- uint16_t index = (key>>shift)&BX_RADIXSORT_BIT_MASK;
- ++histogram[index];
- sorted &= prevKey <= key;
- }
- }
-
- if (sorted)
- {
- goto done;
- }
-
- uint32_t offset = 0;
- for (uint32_t ii = 0; ii < BX_RADIXSORT_HISTOGRAM_SIZE; ++ii)
- {
- uint32_t count = histogram[ii];
- histogram[ii] = offset;
- offset += count;
- }
-
- for (uint32_t ii = 0; ii < _size; ++ii)
- {
- uint32_t key = keys[ii];
- uint16_t index = (key>>shift)&BX_RADIXSORT_BIT_MASK;
- uint32_t dest = histogram[index]++;
- tempKeys[dest] = key;
- }
-
- uint32_t* swapKeys = tempKeys;
- tempKeys = keys;
- keys = swapKeys;
-
- shift += BX_RADIXSORT_BITS;
- }
-
-done:
- if (0 != (pass&1) )
- {
- // Odd number of passes needs to do copy to the destination.
- memcpy(_keys, _tempKeys, _size*sizeof(uint32_t) );
- }
- }
-
+ ///
+ void radixSort(
+ uint32_t* __restrict _keys
+ , uint32_t* __restrict _tempKeys
+ , uint32_t _size
+ );
+
+ ///
template <typename Ty>
- inline void radixSort(uint32_t* __restrict _keys, uint32_t* __restrict _tempKeys, Ty* __restrict _values, Ty* __restrict _tempValues, uint32_t _size)
- {
- uint32_t* __restrict keys = _keys;
- uint32_t* __restrict tempKeys = _tempKeys;
- Ty* __restrict values = _values;
- Ty* __restrict tempValues = _tempValues;
-
- uint32_t histogram[BX_RADIXSORT_HISTOGRAM_SIZE];
- uint16_t shift = 0;
- uint32_t pass = 0;
- for (; pass < 3; ++pass)
- {
- memset(histogram, 0, sizeof(uint32_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
-
- bool sorted = true;
- {
- uint32_t key = keys[0];
- uint32_t prevKey = key;
- for (uint32_t ii = 0; ii < _size; ++ii, prevKey = key)
- {
- key = keys[ii];
- uint16_t index = (key>>shift)&BX_RADIXSORT_BIT_MASK;
- ++histogram[index];
- sorted &= prevKey <= key;
- }
- }
-
- if (sorted)
- {
- goto done;
- }
-
- uint32_t offset = 0;
- for (uint32_t ii = 0; ii < BX_RADIXSORT_HISTOGRAM_SIZE; ++ii)
- {
- uint32_t count = histogram[ii];
- histogram[ii] = offset;
- offset += count;
- }
-
- for (uint32_t ii = 0; ii < _size; ++ii)
- {
- uint32_t key = keys[ii];
- uint16_t index = (key>>shift)&BX_RADIXSORT_BIT_MASK;
- uint32_t dest = histogram[index]++;
- tempKeys[dest] = key;
- tempValues[dest] = values[ii];
- }
-
- uint32_t* swapKeys = tempKeys;
- tempKeys = keys;
- keys = swapKeys;
-
- Ty* swapValues = tempValues;
- tempValues = values;
- values = swapValues;
-
- shift += BX_RADIXSORT_BITS;
- }
-
-done:
- if (0 != (pass&1) )
- {
- // Odd number of passes needs to do copy to the destination.
- memcpy(_keys, _tempKeys, _size*sizeof(uint32_t) );
- for (uint32_t ii = 0; ii < _size; ++ii)
- {
- _values[ii] = _tempValues[ii];
- }
- }
- }
-
- inline void radixSort(uint64_t* __restrict _keys, uint64_t* __restrict _tempKeys, uint32_t _size)
- {
- uint64_t* __restrict keys = _keys;
- uint64_t* __restrict tempKeys = _tempKeys;
-
- uint32_t histogram[BX_RADIXSORT_HISTOGRAM_SIZE];
- uint16_t shift = 0;
- uint32_t pass = 0;
- for (; pass < 6; ++pass)
- {
- memset(histogram, 0, sizeof(uint32_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
-
- bool sorted = true;
- {
- uint64_t key = keys[0];
- uint64_t prevKey = key;
- for (uint32_t ii = 0; ii < _size; ++ii, prevKey = key)
- {
- key = keys[ii];
- uint16_t index = (key>>shift)&BX_RADIXSORT_BIT_MASK;
- ++histogram[index];
- sorted &= prevKey <= key;
- }
- }
-
- if (sorted)
- {
- goto done;
- }
-
- uint32_t offset = 0;
- for (uint32_t ii = 0; ii < BX_RADIXSORT_HISTOGRAM_SIZE; ++ii)
- {
- uint32_t count = histogram[ii];
- histogram[ii] = offset;
- offset += count;
- }
-
- for (uint32_t ii = 0; ii < _size; ++ii)
- {
- uint64_t key = keys[ii];
- uint16_t index = (key>>shift)&BX_RADIXSORT_BIT_MASK;
- uint32_t dest = histogram[index]++;
- tempKeys[dest] = key;
- }
-
- uint64_t* swapKeys = tempKeys;
- tempKeys = keys;
- keys = swapKeys;
-
- shift += BX_RADIXSORT_BITS;
- }
-
-done:
- if (0 != (pass&1) )
- {
- // Odd number of passes needs to do copy to the destination.
- memcpy(_keys, _tempKeys, _size*sizeof(uint64_t) );
- }
- }
-
+ void radixSort(
+ uint32_t* __restrict _keys
+ , uint32_t* __restrict _tempKeys
+ , Ty* __restrict _values
+ , Ty* __restrict _tempValues
+ , uint32_t _size
+ );
+
+ ///
+ void radixSort(
+ uint64_t* __restrict _keys
+ , uint64_t* __restrict _tempKeys
+ , uint32_t _size
+ );
+
+ ///
template <typename Ty>
- inline void radixSort(uint64_t* __restrict _keys, uint64_t* __restrict _tempKeys, Ty* __restrict _values, Ty* __restrict _tempValues, uint32_t _size)
- {
- uint64_t* __restrict keys = _keys;
- uint64_t* __restrict tempKeys = _tempKeys;
- Ty* __restrict values = _values;
- Ty* __restrict tempValues = _tempValues;
-
- uint32_t histogram[BX_RADIXSORT_HISTOGRAM_SIZE];
- uint16_t shift = 0;
- uint32_t pass = 0;
- for (; pass < 6; ++pass)
- {
- memset(histogram, 0, sizeof(uint32_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
-
- bool sorted = true;
- {
- uint64_t key = keys[0];
- uint64_t prevKey = key;
- for (uint32_t ii = 0; ii < _size; ++ii, prevKey = key)
- {
- key = keys[ii];
- uint16_t index = (key>>shift)&BX_RADIXSORT_BIT_MASK;
- ++histogram[index];
- sorted &= prevKey <= key;
- }
- }
-
- if (sorted)
- {
- goto done;
- }
-
- uint32_t offset = 0;
- for (uint32_t ii = 0; ii < BX_RADIXSORT_HISTOGRAM_SIZE; ++ii)
- {
- uint32_t count = histogram[ii];
- histogram[ii] = offset;
- offset += count;
- }
-
- for (uint32_t ii = 0; ii < _size; ++ii)
- {
- uint64_t key = keys[ii];
- uint16_t index = (key>>shift)&BX_RADIXSORT_BIT_MASK;
- uint32_t dest = histogram[index]++;
- tempKeys[dest] = key;
- tempValues[dest] = values[ii];
- }
-
- uint64_t* swapKeys = tempKeys;
- tempKeys = keys;
- keys = swapKeys;
-
- Ty* swapValues = tempValues;
- tempValues = values;
- values = swapValues;
-
- shift += BX_RADIXSORT_BITS;
- }
-
-done:
- if (0 != (pass&1) )
- {
- // Odd number of passes needs to do copy to the destination.
- memcpy(_keys, _tempKeys, _size*sizeof(uint64_t) );
- for (uint32_t ii = 0; ii < _size; ++ii)
- {
- _values[ii] = _tempValues[ii];
- }
- }
- }
-
-#undef BX_RADIXSORT_BITS
-#undef BX_RADIXSORT_HISTOGRAM_SIZE
-#undef BX_RADIXSORT_BIT_MASK
+ void radixSort(
+ uint64_t* __restrict _keys
+ , uint64_t* __restrict _tempKeys
+ , Ty* __restrict _values
+ , Ty* __restrict _tempValues
+ , uint32_t _size
+ );
} // namespace bx
+#include "radixsort.inl"
+
#endif // BX_RADIXSORT_H_HEADER_GUARD
diff --git a/3rdparty/bx/include/bx/radixsort.inl b/3rdparty/bx/include/bx/radixsort.inl
new file mode 100644
index 00000000000..2edc5e40fd3
--- /dev/null
+++ b/3rdparty/bx/include/bx/radixsort.inl
@@ -0,0 +1,288 @@
+/*
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#ifndef BX_RADIXSORT_H_HEADER_GUARD
+# error "Must be included from bx/radixsort.h!"
+#endif // BX_RADIXSORT_H_HEADER_GUARD
+
+namespace bx
+{
+#define BX_RADIXSORT_BITS 11
+#define BX_RADIXSORT_HISTOGRAM_SIZE (1<<BX_RADIXSORT_BITS)
+#define BX_RADIXSORT_BIT_MASK (BX_RADIXSORT_HISTOGRAM_SIZE-1)
+
+ inline void radixSort(uint32_t* __restrict _keys, uint32_t* __restrict _tempKeys, uint32_t _size)
+ {
+ uint32_t* __restrict keys = _keys;
+ uint32_t* __restrict tempKeys = _tempKeys;
+
+ uint32_t histogram[BX_RADIXSORT_HISTOGRAM_SIZE];
+ uint16_t shift = 0;
+ uint32_t pass = 0;
+ for (; pass < 3; ++pass)
+ {
+ memset(histogram, 0, sizeof(uint32_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
+
+ bool sorted = true;
+ {
+ uint32_t key = keys[0];
+ uint32_t prevKey = key;
+ for (uint32_t ii = 0; ii < _size; ++ii, prevKey = key)
+ {
+ key = keys[ii];
+ uint16_t index = (key>>shift)&BX_RADIXSORT_BIT_MASK;
+ ++histogram[index];
+ sorted &= prevKey <= key;
+ }
+ }
+
+ if (sorted)
+ {
+ goto done;
+ }
+
+ uint32_t offset = 0;
+ for (uint32_t ii = 0; ii < BX_RADIXSORT_HISTOGRAM_SIZE; ++ii)
+ {
+ uint32_t count = histogram[ii];
+ histogram[ii] = offset;
+ offset += count;
+ }
+
+ for (uint32_t ii = 0; ii < _size; ++ii)
+ {
+ uint32_t key = keys[ii];
+ uint16_t index = (key>>shift)&BX_RADIXSORT_BIT_MASK;
+ uint32_t dest = histogram[index]++;
+ tempKeys[dest] = key;
+ }
+
+ uint32_t* swapKeys = tempKeys;
+ tempKeys = keys;
+ keys = swapKeys;
+
+ shift += BX_RADIXSORT_BITS;
+ }
+
+done:
+ if (0 != (pass&1) )
+ {
+ // Odd number of passes needs to do copy to the destination.
+ memcpy(_keys, _tempKeys, _size*sizeof(uint32_t) );
+ }
+ }
+
+ template <typename Ty>
+ inline void radixSort(uint32_t* __restrict _keys, uint32_t* __restrict _tempKeys, Ty* __restrict _values, Ty* __restrict _tempValues, uint32_t _size)
+ {
+ uint32_t* __restrict keys = _keys;
+ uint32_t* __restrict tempKeys = _tempKeys;
+ Ty* __restrict values = _values;
+ Ty* __restrict tempValues = _tempValues;
+
+ uint32_t histogram[BX_RADIXSORT_HISTOGRAM_SIZE];
+ uint16_t shift = 0;
+ uint32_t pass = 0;
+ for (; pass < 3; ++pass)
+ {
+ memset(histogram, 0, sizeof(uint32_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
+
+ bool sorted = true;
+ {
+ uint32_t key = keys[0];
+ uint32_t prevKey = key;
+ for (uint32_t ii = 0; ii < _size; ++ii, prevKey = key)
+ {
+ key = keys[ii];
+ uint16_t index = (key>>shift)&BX_RADIXSORT_BIT_MASK;
+ ++histogram[index];
+ sorted &= prevKey <= key;
+ }
+ }
+
+ if (sorted)
+ {
+ goto done;
+ }
+
+ uint32_t offset = 0;
+ for (uint32_t ii = 0; ii < BX_RADIXSORT_HISTOGRAM_SIZE; ++ii)
+ {
+ uint32_t count = histogram[ii];
+ histogram[ii] = offset;
+ offset += count;
+ }
+
+ for (uint32_t ii = 0; ii < _size; ++ii)
+ {
+ uint32_t key = keys[ii];
+ uint16_t index = (key>>shift)&BX_RADIXSORT_BIT_MASK;
+ uint32_t dest = histogram[index]++;
+ tempKeys[dest] = key;
+ tempValues[dest] = values[ii];
+ }
+
+ uint32_t* swapKeys = tempKeys;
+ tempKeys = keys;
+ keys = swapKeys;
+
+ Ty* swapValues = tempValues;
+ tempValues = values;
+ values = swapValues;
+
+ shift += BX_RADIXSORT_BITS;
+ }
+
+done:
+ if (0 != (pass&1) )
+ {
+ // Odd number of passes needs to do copy to the destination.
+ memcpy(_keys, _tempKeys, _size*sizeof(uint32_t) );
+ for (uint32_t ii = 0; ii < _size; ++ii)
+ {
+ _values[ii] = _tempValues[ii];
+ }
+ }
+ }
+
+ inline void radixSort(uint64_t* __restrict _keys, uint64_t* __restrict _tempKeys, uint32_t _size)
+ {
+ uint64_t* __restrict keys = _keys;
+ uint64_t* __restrict tempKeys = _tempKeys;
+
+ uint32_t histogram[BX_RADIXSORT_HISTOGRAM_SIZE];
+ uint16_t shift = 0;
+ uint32_t pass = 0;
+ for (; pass < 6; ++pass)
+ {
+ memset(histogram, 0, sizeof(uint32_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
+
+ bool sorted = true;
+ {
+ uint64_t key = keys[0];
+ uint64_t prevKey = key;
+ for (uint32_t ii = 0; ii < _size; ++ii, prevKey = key)
+ {
+ key = keys[ii];
+ uint16_t index = (key>>shift)&BX_RADIXSORT_BIT_MASK;
+ ++histogram[index];
+ sorted &= prevKey <= key;
+ }
+ }
+
+ if (sorted)
+ {
+ goto done;
+ }
+
+ uint32_t offset = 0;
+ for (uint32_t ii = 0; ii < BX_RADIXSORT_HISTOGRAM_SIZE; ++ii)
+ {
+ uint32_t count = histogram[ii];
+ histogram[ii] = offset;
+ offset += count;
+ }
+
+ for (uint32_t ii = 0; ii < _size; ++ii)
+ {
+ uint64_t key = keys[ii];
+ uint16_t index = (key>>shift)&BX_RADIXSORT_BIT_MASK;
+ uint32_t dest = histogram[index]++;
+ tempKeys[dest] = key;
+ }
+
+ uint64_t* swapKeys = tempKeys;
+ tempKeys = keys;
+ keys = swapKeys;
+
+ shift += BX_RADIXSORT_BITS;
+ }
+
+done:
+ if (0 != (pass&1) )
+ {
+ // Odd number of passes needs to do copy to the destination.
+ memcpy(_keys, _tempKeys, _size*sizeof(uint64_t) );
+ }
+ }
+
+ template <typename Ty>
+ inline void radixSort(uint64_t* __restrict _keys, uint64_t* __restrict _tempKeys, Ty* __restrict _values, Ty* __restrict _tempValues, uint32_t _size)
+ {
+ uint64_t* __restrict keys = _keys;
+ uint64_t* __restrict tempKeys = _tempKeys;
+ Ty* __restrict values = _values;
+ Ty* __restrict tempValues = _tempValues;
+
+ uint32_t histogram[BX_RADIXSORT_HISTOGRAM_SIZE];
+ uint16_t shift = 0;
+ uint32_t pass = 0;
+ for (; pass < 6; ++pass)
+ {
+ memset(histogram, 0, sizeof(uint32_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
+
+ bool sorted = true;
+ {
+ uint64_t key = keys[0];
+ uint64_t prevKey = key;
+ for (uint32_t ii = 0; ii < _size; ++ii, prevKey = key)
+ {
+ key = keys[ii];
+ uint16_t index = (key>>shift)&BX_RADIXSORT_BIT_MASK;
+ ++histogram[index];
+ sorted &= prevKey <= key;
+ }
+ }
+
+ if (sorted)
+ {
+ goto done;
+ }
+
+ uint32_t offset = 0;
+ for (uint32_t ii = 0; ii < BX_RADIXSORT_HISTOGRAM_SIZE; ++ii)
+ {
+ uint32_t count = histogram[ii];
+ histogram[ii] = offset;
+ offset += count;
+ }
+
+ for (uint32_t ii = 0; ii < _size; ++ii)
+ {
+ uint64_t key = keys[ii];
+ uint16_t index = (key>>shift)&BX_RADIXSORT_BIT_MASK;
+ uint32_t dest = histogram[index]++;
+ tempKeys[dest] = key;
+ tempValues[dest] = values[ii];
+ }
+
+ uint64_t* swapKeys = tempKeys;
+ tempKeys = keys;
+ keys = swapKeys;
+
+ Ty* swapValues = tempValues;
+ tempValues = values;
+ values = swapValues;
+
+ shift += BX_RADIXSORT_BITS;
+ }
+
+done:
+ if (0 != (pass&1) )
+ {
+ // Odd number of passes needs to do copy to the destination.
+ memcpy(_keys, _tempKeys, _size*sizeof(uint64_t) );
+ for (uint32_t ii = 0; ii < _size; ++ii)
+ {
+ _values[ii] = _tempValues[ii];
+ }
+ }
+ }
+
+#undef BX_RADIXSORT_BITS
+#undef BX_RADIXSORT_HISTOGRAM_SIZE
+#undef BX_RADIXSORT_BIT_MASK
+
+} // namespace bx
diff --git a/3rdparty/bx/include/bx/readerwriter.h b/3rdparty/bx/include/bx/readerwriter.h
index d926628430d..19411a6adb7 100644
--- a/3rdparty/bx/include/bx/readerwriter.h
+++ b/3rdparty/bx/include/bx/readerwriter.h
@@ -24,6 +24,7 @@ BX_ERROR_RESULT(BX_ERROR_READERWRITER_ALREADY_OPEN, BX_MAKEFOURCC('R', 'W', 0, 5
namespace bx
{
+ ///
struct Whence
{
enum Enum
@@ -34,350 +35,111 @@ namespace bx
};
};
+ ///
struct BX_NO_VTABLE ReaderI
{
virtual ~ReaderI() = 0;
virtual int32_t read(void* _data, int32_t _size, Error* _err) = 0;
};
- inline ReaderI::~ReaderI()
- {
- }
-
+ ///
struct BX_NO_VTABLE WriterI
{
virtual ~WriterI() = 0;
virtual int32_t write(const void* _data, int32_t _size, Error* _err) = 0;
};
- inline WriterI::~WriterI()
- {
- }
-
+ ///
struct BX_NO_VTABLE SeekerI
{
virtual ~SeekerI() = 0;
virtual int64_t seek(int64_t _offset = 0, Whence::Enum _whence = Whence::Current) = 0;
};
- inline SeekerI::~SeekerI()
- {
- }
-
- /// Read data.
- inline int32_t read(ReaderI* _reader, void* _data, int32_t _size, Error* _err = NULL)
- {
- BX_ERROR_SCOPE(_err);
- return _reader->read(_data, _size, _err);
- }
-
- /// Read value.
- template<typename Ty>
- inline int32_t read(ReaderI* _reader, Ty& _value, Error* _err = NULL)
- {
- BX_ERROR_SCOPE(_err);
- BX_STATIC_ASSERT(BX_TYPE_IS_POD(Ty) );
- return _reader->read(&_value, sizeof(Ty), _err);
- }
-
- /// Read value and converts it to host endianess. _fromLittleEndian specifies
- /// underlying stream endianess.
- template<typename Ty>
- inline int32_t readHE(ReaderI* _reader, Ty& _value, bool _fromLittleEndian, Error* _err = NULL)
- {
- BX_ERROR_SCOPE(_err);
- BX_STATIC_ASSERT(BX_TYPE_IS_POD(Ty) );
- Ty value;
- int32_t result = _reader->read(&value, sizeof(Ty), _err);
- _value = toHostEndian(value, _fromLittleEndian);
- return result;
- }
-
- /// Write data.
- inline int32_t write(WriterI* _writer, const void* _data, int32_t _size, Error* _err = NULL)
- {
- BX_ERROR_SCOPE(_err);
- return _writer->write(_data, _size, _err);
- }
-
- /// Write repeat the same value.
- inline int32_t writeRep(WriterI* _writer, uint8_t _byte, int32_t _size, Error* _err = NULL)
- {
- BX_ERROR_SCOPE(_err);
-
- const uint32_t tmp0 = uint32_sels(64 - _size, 64, _size);
- const uint32_t tmp1 = uint32_sels(256 - _size, 256, tmp0);
- const uint32_t blockSize = uint32_sels(1024 - _size, 1024, tmp1);
- uint8_t* temp = (uint8_t*)alloca(blockSize);
- memset(temp, _byte, blockSize);
-
- int32_t size = 0;
- while (0 < _size)
- {
- int32_t bytes = write(_writer, temp, uint32_min(blockSize, _size), _err);
- size += bytes;
- _size -= bytes;
- }
-
- return size;
- }
-
- /// Write value.
- template<typename Ty>
- inline int32_t write(WriterI* _writer, const Ty& _value, Error* _err = NULL)
- {
- BX_ERROR_SCOPE(_err);
- BX_STATIC_ASSERT(BX_TYPE_IS_POD(Ty) );
- return _writer->write(&_value, sizeof(Ty), _err);
- }
-
- /// Write value as little endian.
- template<typename Ty>
- inline int32_t writeLE(WriterI* _writer, const Ty& _value, Error* _err = NULL)
- {
- BX_ERROR_SCOPE(_err);
- BX_STATIC_ASSERT(BX_TYPE_IS_POD(Ty) );
- Ty value = toLittleEndian(_value);
- int32_t result = _writer->write(&value, sizeof(Ty), _err);
- return result;
- }
-
- /// Write value as big endian.
- template<typename Ty>
- inline int32_t writeBE(WriterI* _writer, const Ty& _value, Error* _err = NULL)
- {
- BX_ERROR_SCOPE(_err);
- BX_STATIC_ASSERT(BX_TYPE_IS_POD(Ty) );
- Ty value = toBigEndian(_value);
- int32_t result = _writer->write(&value, sizeof(Ty), _err);
- return result;
- }
-
- /// Write formated string.
- inline int32_t writePrintf(WriterI* _writer, const char* _format, ...)
- {
- va_list argList;
- va_start(argList, _format);
-
- char temp[2048];
- char* out = temp;
- int32_t max = sizeof(temp);
- int32_t len = vsnprintf(out, max, _format, argList);
- if (len > max)
- {
- out = (char*)alloca(len);
- len = vsnprintf(out, len, _format, argList);
- }
-
- int32_t size = write(_writer, out, len);
-
- va_end(argList);
-
- return size;
- }
-
- /// Skip _offset bytes forward.
- inline int64_t skip(SeekerI* _seeker, int64_t _offset)
- {
- return _seeker->seek(_offset, Whence::Current);
- }
-
- /// Seek to any position in file.
- inline int64_t seek(SeekerI* _seeker, int64_t _offset = 0, Whence::Enum _whence = Whence::Current)
- {
- return _seeker->seek(_offset, _whence);
- }
-
- /// Returns size of file.
- inline int64_t getSize(SeekerI* _seeker)
- {
- int64_t offset = _seeker->seek();
- int64_t size = _seeker->seek(0, Whence::End);
- _seeker->seek(offset, Whence::Begin);
- return size;
- }
-
+ ///
struct BX_NO_VTABLE ReaderSeekerI : public ReaderI, public SeekerI
{
};
- /// Peek data.
- inline int32_t peek(ReaderSeekerI* _reader, void* _data, int32_t _size, Error* _err = NULL)
- {
- BX_ERROR_SCOPE(_err);
- int64_t offset = bx::seek(_reader);
- int32_t size = _reader->read(_data, _size, _err);
- bx::seek(_reader, offset, bx::Whence::Begin);
- return size;
- }
-
- /// Peek value.
- template<typename Ty>
- inline int32_t peek(ReaderSeekerI* _reader, Ty& _value, Error* _err = NULL)
- {
- BX_ERROR_SCOPE(_err);
- BX_STATIC_ASSERT(BX_TYPE_IS_POD(Ty) );
- return peek(_reader, &_value, sizeof(Ty), _err);
- }
-
+ ///
struct BX_NO_VTABLE WriterSeekerI : public WriterI, public SeekerI
{
};
- /// Align reader stream.
- inline int32_t align(ReaderSeekerI* _reader, uint32_t _alignment, Error* _err = NULL)
- {
- BX_ERROR_SCOPE(_err);
- const int64_t current = bx::seek(_reader);
- const int64_t aligned = ( (current + _alignment-1)/_alignment) * _alignment;
- const int32_t size = int32_t(aligned - current);
- if (0 != size)
- {
- const int64_t offset = bx::seek(_reader, size);
- if (offset != aligned)
- {
- BX_ERROR_SET(_err, BX_ERROR_READERWRITER_WRITE, "Align: read truncated.");
- }
- return int32_t(offset - current);
- }
-
- return 0;
- }
-
- /// Align writer stream (pads stream with zeros).
- inline int32_t align(WriterSeekerI* _writer, uint32_t _alignment, Error* _err = NULL)
- {
- BX_ERROR_SCOPE(_err);
- const int64_t current = bx::seek(_writer);
- const int64_t aligned = ( (current + _alignment-1)/_alignment) * _alignment;
- const int32_t size = int32_t(aligned - current);
- if (0 != size)
- {
- return writeRep(_writer, 0, size, _err);
- }
-
- return 0;
- }
-
+ ///
struct BX_NO_VTABLE ReaderOpenI
{
virtual ~ReaderOpenI() = 0;
virtual bool open(const char* _filePath, Error* _err) = 0;
};
- inline ReaderOpenI::~ReaderOpenI()
- {
- }
-
+ ///
struct BX_NO_VTABLE WriterOpenI
{
virtual ~WriterOpenI() = 0;
virtual bool open(const char* _filePath, bool _append, Error* _err) = 0;
};
- inline WriterOpenI::~WriterOpenI()
- {
- }
-
+ ///
struct BX_NO_VTABLE CloserI
{
virtual ~CloserI() = 0;
virtual void close() = 0;
};
- inline CloserI::~CloserI()
- {
- }
-
+ ///
struct BX_NO_VTABLE FileReaderI : public ReaderOpenI, public CloserI, public ReaderSeekerI
{
};
+ ///
struct BX_NO_VTABLE FileWriterI : public WriterOpenI, public CloserI, public WriterSeekerI
{
};
- inline bool open(ReaderOpenI* _reader, const char* _filePath, Error* _err = NULL)
- {
- BX_ERROR_USE_TEMP_WHEN_NULL(_err);
- return _reader->open(_filePath, _err);
- }
-
- inline bool open(WriterOpenI* _writer, const char* _filePath, bool _append = false, Error* _err = NULL)
- {
- BX_ERROR_USE_TEMP_WHEN_NULL(_err);
- return _writer->open(_filePath, _append, _err);
- }
-
- inline void close(CloserI* _reader)
- {
- _reader->close();
- }
-
+ ///
struct BX_NO_VTABLE MemoryBlockI
{
virtual void* more(uint32_t _size = 0) = 0;
virtual uint32_t getSize() = 0;
};
+ ///
class StaticMemoryBlock : public MemoryBlockI
{
public:
- StaticMemoryBlock(void* _data, uint32_t _size)
- : m_data(_data)
- , m_size(_size)
- {
- }
+ ///
+ StaticMemoryBlock(void* _data, uint32_t _size);
- virtual ~StaticMemoryBlock()
- {
- }
+ ///
+ virtual ~StaticMemoryBlock();
- virtual void* more(uint32_t /*_size*/ = 0) BX_OVERRIDE
- {
- return m_data;
- }
+ ///
+ virtual void* more(uint32_t _size = 0);
- virtual uint32_t getSize() BX_OVERRIDE
- {
- return m_size;
- }
+ ///
+ virtual uint32_t getSize() BX_OVERRIDE;
private:
void* m_data;
uint32_t m_size;
};
+ ///
class MemoryBlock : public MemoryBlockI
{
public:
- MemoryBlock(AllocatorI* _allocator)
- : m_allocator(_allocator)
- , m_data(NULL)
- , m_size(0)
- {
- }
+ ///
+ MemoryBlock(AllocatorI* _allocator);
- virtual ~MemoryBlock()
- {
- BX_FREE(m_allocator, m_data);
- }
+ ///
+ virtual ~MemoryBlock();
- virtual void* more(uint32_t _size = 0) BX_OVERRIDE
- {
- if (0 < _size)
- {
- m_size += _size;
- m_data = BX_REALLOC(m_allocator, m_data, m_size);
- }
+ ///
+ virtual void* more(uint32_t _size = 0) BX_OVERRIDE;
- return m_data;
- }
-
- virtual uint32_t getSize() BX_OVERRIDE
- {
- return m_size;
- }
+ ///
+ virtual uint32_t getSize() BX_OVERRIDE;
private:
AllocatorI* m_allocator;
@@ -385,128 +147,51 @@ namespace bx
uint32_t m_size;
};
+ ///
class SizerWriter : public WriterSeekerI
{
public:
- SizerWriter()
- : m_pos(0)
- , m_top(0)
- {
- }
-
- virtual ~SizerWriter()
- {
- }
-
- virtual int64_t seek(int64_t _offset = 0, Whence::Enum _whence = Whence::Current) BX_OVERRIDE
- {
- switch (_whence)
- {
- case Whence::Begin:
- m_pos = int64_clamp(_offset, 0, m_top);
- break;
-
- case Whence::Current:
- m_pos = int64_clamp(m_pos + _offset, 0, m_top);
- break;
-
- case Whence::End:
- m_pos = int64_clamp(m_top - _offset, 0, m_top);
- break;
- }
-
- return m_pos;
- }
-
- virtual int32_t write(const void* /*_data*/, int32_t _size, Error* _err) BX_OVERRIDE
- {
- BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
+ ///
+ SizerWriter();
- int32_t morecore = int32_t(m_pos - m_top) + _size;
+ ///
+ virtual ~SizerWriter();
- if (0 < morecore)
- {
- m_top += morecore;
- }
+ ///
+ virtual int64_t seek(int64_t _offset = 0, Whence::Enum _whence = Whence::Current) BX_OVERRIDE;
- int64_t remainder = m_top-m_pos;
- int32_t size = uint32_min(_size, uint32_t(int64_min(remainder, INT32_MAX) ) );
- m_pos += size;
- if (size != _size)
- {
- BX_ERROR_SET(_err, BX_ERROR_READERWRITER_WRITE, "SizerWriter: write truncated.");
- }
- return size;
- }
+ ///
+ virtual int32_t write(const void* /*_data*/, int32_t _size, Error* _err) BX_OVERRIDE;
private:
int64_t m_pos;
int64_t m_top;
};
+ ///
class MemoryReader : public ReaderSeekerI
{
public:
- MemoryReader(const void* _data, uint32_t _size)
- : m_data( (const uint8_t*)_data)
- , m_pos(0)
- , m_top(_size)
- {
- }
-
- virtual ~MemoryReader()
- {
- }
-
- virtual int64_t seek(int64_t _offset, Whence::Enum _whence) BX_OVERRIDE
- {
- switch (_whence)
- {
- case Whence::Begin:
- m_pos = int64_clamp(_offset, 0, m_top);
- break;
+ ///
+ MemoryReader(const void* _data, uint32_t _size);
- case Whence::Current:
- m_pos = int64_clamp(m_pos + _offset, 0, m_top);
- break;
+ ///
+ virtual ~MemoryReader();
- case Whence::End:
- m_pos = int64_clamp(m_top - _offset, 0, m_top);
- break;
- }
+ ///
+ virtual int64_t seek(int64_t _offset, Whence::Enum _whence) BX_OVERRIDE;
- return m_pos;
- }
+ ///
+ virtual int32_t read(void* _data, int32_t _size, Error* _err) BX_OVERRIDE;
- virtual int32_t read(void* _data, int32_t _size, Error* _err) BX_OVERRIDE
- {
- BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
-
- int64_t remainder = m_top-m_pos;
- int32_t size = uint32_min(_size, uint32_t(int64_min(remainder, INT32_MAX) ) );
- memcpy(_data, &m_data[m_pos], size);
- m_pos += size;
- if (size != _size)
- {
- BX_ERROR_SET(_err, BX_ERROR_READERWRITER_READ, "MemoryReader: read truncated.");
- }
- return size;
- }
-
- const uint8_t* getDataPtr() const
- {
- return &m_data[m_pos];
- }
+ ///
+ const uint8_t* getDataPtr() const;
- int64_t getPos() const
- {
- return m_pos;
- }
+ ///
+ int64_t getPos() const;
- int64_t remaining() const
- {
- return m_top-m_pos;
- }
+ ///
+ int64_t remaining() const;
private:
const uint8_t* m_data;
@@ -514,66 +199,21 @@ namespace bx
int64_t m_top;
};
+ ///
class MemoryWriter : public WriterSeekerI
{
public:
- MemoryWriter(MemoryBlockI* _memBlock)
- : m_memBlock(_memBlock)
- , m_data(NULL)
- , m_pos(0)
- , m_top(0)
- , m_size(0)
- {
- }
+ ///
+ MemoryWriter(MemoryBlockI* _memBlock);
- virtual ~MemoryWriter()
- {
- }
-
- virtual int64_t seek(int64_t _offset = 0, Whence::Enum _whence = Whence::Current) BX_OVERRIDE
- {
- switch (_whence)
- {
- case Whence::Begin:
- m_pos = int64_clamp(_offset, 0, m_top);
- break;
-
- case Whence::Current:
- m_pos = int64_clamp(m_pos + _offset, 0, m_top);
- break;
-
- case Whence::End:
- m_pos = int64_clamp(m_top - _offset, 0, m_top);
- break;
- }
+ ///
+ virtual ~MemoryWriter();
- return m_pos;
- }
+ ///
+ virtual int64_t seek(int64_t _offset = 0, Whence::Enum _whence = Whence::Current) BX_OVERRIDE;
- virtual int32_t write(const void* _data, int32_t _size, Error* _err) BX_OVERRIDE
- {
- BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
-
- int32_t morecore = int32_t(m_pos - m_size) + _size;
-
- if (0 < morecore)
- {
- morecore = BX_ALIGN_MASK(morecore, 0xfff);
- m_data = (uint8_t*)m_memBlock->more(morecore);
- m_size = m_memBlock->getSize();
- }
-
- int64_t remainder = m_size-m_pos;
- int32_t size = uint32_min(_size, uint32_t(int64_min(remainder, INT32_MAX) ) );
- memcpy(&m_data[m_pos], _data, size);
- m_pos += size;
- m_top = int64_max(m_top, m_pos);
- if (size != _size)
- {
- BX_ERROR_SET(_err, BX_ERROR_READERWRITER_WRITE, "MemoryWriter: write truncated.");
- }
- return size;
- }
+ ///
+ virtual int32_t write(const void* _data, int32_t _size, Error* _err) BX_OVERRIDE;
private:
MemoryBlockI* m_memBlock;
@@ -583,23 +223,86 @@ namespace bx
int64_t m_size;
};
+ ///
class StaticMemoryBlockWriter : public MemoryWriter
{
public:
- StaticMemoryBlockWriter(void* _data, uint32_t _size)
- : MemoryWriter(&m_smb)
- , m_smb(_data, _size)
- {
- }
+ ///
+ StaticMemoryBlockWriter(void* _data, uint32_t _size);
- ~StaticMemoryBlockWriter()
- {
- }
+ ///
+ virtual ~StaticMemoryBlockWriter();
private:
StaticMemoryBlock m_smb;
};
+ /// Read data.
+ int32_t read(ReaderI* _reader, void* _data, int32_t _size, Error* _err = NULL);
+
+ /// Read value.
+ template<typename Ty>
+ int32_t read(ReaderI* _reader, Ty& _value, Error* _err = NULL);
+
+ /// Read value and converts it to host endianess. _fromLittleEndian specifies
+ /// underlying stream endianess.
+ template<typename Ty>
+ int32_t readHE(ReaderI* _reader, Ty& _value, bool _fromLittleEndian, Error* _err = NULL);
+
+ /// Write data.
+ int32_t write(WriterI* _writer, const void* _data, int32_t _size, Error* _err = NULL);
+
+ /// Write repeat the same value.
+ int32_t writeRep(WriterI* _writer, uint8_t _byte, int32_t _size, Error* _err = NULL);
+
+ /// Write value.
+ template<typename Ty>
+ int32_t write(WriterI* _writer, const Ty& _value, Error* _err = NULL);
+
+ /// Write value as little endian.
+ template<typename Ty>
+ int32_t writeLE(WriterI* _writer, const Ty& _value, Error* _err = NULL);
+
+ /// Write value as big endian.
+ template<typename Ty>
+ int32_t writeBE(WriterI* _writer, const Ty& _value, Error* _err = NULL);
+
+ /// Write formated string.
+ int32_t writePrintf(WriterI* _writer, const char* _format, ...);
+
+ /// Skip _offset bytes forward.
+ int64_t skip(SeekerI* _seeker, int64_t _offset);
+
+ /// Seek to any position in file.
+ int64_t seek(SeekerI* _seeker, int64_t _offset = 0, Whence::Enum _whence = Whence::Current);
+
+ /// Returns size of file.
+ int64_t getSize(SeekerI* _seeker);
+
+ /// Peek data.
+ int32_t peek(ReaderSeekerI* _reader, void* _data, int32_t _size, Error* _err = NULL);
+
+ /// Peek value.
+ template<typename Ty>
+ int32_t peek(ReaderSeekerI* _reader, Ty& _value, Error* _err = NULL);
+
+ /// Align reader stream.
+ int32_t align(ReaderSeekerI* _reader, uint32_t _alignment, Error* _err = NULL);
+
+ /// Align writer stream (pads stream with zeros).
+ int32_t align(WriterSeekerI* _writer, uint32_t _alignment, Error* _err = NULL);
+
+ ///
+ bool open(ReaderOpenI* _reader, const char* _filePath, Error* _err = NULL);
+
+ ///
+ bool open(WriterOpenI* _writer, const char* _filePath, bool _append = false, Error* _err = NULL);
+
+ ///
+ void close(CloserI* _reader);
+
} // namespace bx
+#include "readerwriter.inl"
+
#endif // BX_READERWRITER_H_HEADER_GUARD
diff --git a/3rdparty/bx/include/bx/readerwriter.inl b/3rdparty/bx/include/bx/readerwriter.inl
new file mode 100644
index 00000000000..9ba8517776c
--- /dev/null
+++ b/3rdparty/bx/include/bx/readerwriter.inl
@@ -0,0 +1,452 @@
+/*
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#ifndef BX_READERWRITER_H_HEADER_GUARD
+# error "Must be included from bx/readerwriter!"
+#endif // BX_READERWRITER_H_HEADER_GUARD
+
+namespace bx
+{
+ inline ReaderI::~ReaderI()
+ {
+ }
+
+ inline WriterI::~WriterI()
+ {
+ }
+
+ inline SeekerI::~SeekerI()
+ {
+ }
+
+ inline ReaderOpenI::~ReaderOpenI()
+ {
+ }
+
+ inline WriterOpenI::~WriterOpenI()
+ {
+ }
+
+ inline CloserI::~CloserI()
+ {
+ }
+
+ inline StaticMemoryBlock::StaticMemoryBlock(void* _data, uint32_t _size)
+ : m_data(_data)
+ , m_size(_size)
+ {
+ }
+
+ inline StaticMemoryBlock::~StaticMemoryBlock()
+ {
+ }
+
+ inline void* StaticMemoryBlock::more(uint32_t _size)
+ {
+ BX_UNUSED(_size);
+ return m_data;
+ }
+
+ inline uint32_t StaticMemoryBlock::getSize()
+ {
+ return m_size;
+ }
+
+ inline MemoryBlock::MemoryBlock(AllocatorI* _allocator)
+ : m_allocator(_allocator)
+ , m_data(NULL)
+ , m_size(0)
+ {
+ }
+
+ inline MemoryBlock::~MemoryBlock()
+ {
+ BX_FREE(m_allocator, m_data);
+ }
+
+ inline void* MemoryBlock::more(uint32_t _size)
+ {
+ if (0 < _size)
+ {
+ m_size += _size;
+ m_data = BX_REALLOC(m_allocator, m_data, m_size);
+ }
+
+ return m_data;
+ }
+
+ inline uint32_t MemoryBlock::getSize()
+ {
+ return m_size;
+ }
+
+ inline SizerWriter::SizerWriter()
+ : m_pos(0)
+ , m_top(0)
+ {
+ }
+
+ inline SizerWriter::~SizerWriter()
+ {
+ }
+
+ inline int64_t SizerWriter::seek(int64_t _offset, Whence::Enum _whence)
+ {
+ switch (_whence)
+ {
+ case Whence::Begin:
+ m_pos = int64_clamp(_offset, 0, m_top);
+ break;
+
+ case Whence::Current:
+ m_pos = int64_clamp(m_pos + _offset, 0, m_top);
+ break;
+
+ case Whence::End:
+ m_pos = int64_clamp(m_top - _offset, 0, m_top);
+ break;
+ }
+
+ return m_pos;
+ }
+
+ inline int32_t SizerWriter::write(const void* /*_data*/, int32_t _size, Error* _err)
+ {
+ BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
+
+ int32_t morecore = int32_t(m_pos - m_top) + _size;
+
+ if (0 < morecore)
+ {
+ m_top += morecore;
+ }
+
+ int64_t remainder = m_top-m_pos;
+ int32_t size = uint32_min(_size, uint32_t(int64_min(remainder, INT32_MAX) ) );
+ m_pos += size;
+ if (size != _size)
+ {
+ BX_ERROR_SET(_err, BX_ERROR_READERWRITER_WRITE, "SizerWriter: write truncated.");
+ }
+ return size;
+ }
+
+ inline MemoryReader::MemoryReader(const void* _data, uint32_t _size)
+ : m_data( (const uint8_t*)_data)
+ , m_pos(0)
+ , m_top(_size)
+ {
+ }
+
+ inline MemoryReader::~MemoryReader()
+ {
+ }
+
+ inline int64_t MemoryReader::seek(int64_t _offset, Whence::Enum _whence)
+ {
+ switch (_whence)
+ {
+ case Whence::Begin:
+ m_pos = int64_clamp(_offset, 0, m_top);
+ break;
+
+ case Whence::Current:
+ m_pos = int64_clamp(m_pos + _offset, 0, m_top);
+ break;
+
+ case Whence::End:
+ m_pos = int64_clamp(m_top - _offset, 0, m_top);
+ break;
+ }
+
+ return m_pos;
+ }
+
+ inline int32_t MemoryReader::read(void* _data, int32_t _size, Error* _err)
+ {
+ BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
+
+ int64_t remainder = m_top-m_pos;
+ int32_t size = uint32_min(_size, uint32_t(int64_min(remainder, INT32_MAX) ) );
+ memcpy(_data, &m_data[m_pos], size);
+ m_pos += size;
+ if (size != _size)
+ {
+ BX_ERROR_SET(_err, BX_ERROR_READERWRITER_READ, "MemoryReader: read truncated.");
+ }
+ return size;
+ }
+
+ inline const uint8_t* MemoryReader::getDataPtr() const
+ {
+ return &m_data[m_pos];
+ }
+
+ inline int64_t MemoryReader::getPos() const
+ {
+ return m_pos;
+ }
+
+ inline int64_t MemoryReader::remaining() const
+ {
+ return m_top-m_pos;
+ }
+
+ inline MemoryWriter::MemoryWriter(MemoryBlockI* _memBlock)
+ : m_memBlock(_memBlock)
+ , m_data(NULL)
+ , m_pos(0)
+ , m_top(0)
+ , m_size(0)
+ {
+ }
+
+ inline MemoryWriter::~MemoryWriter()
+ {
+ }
+
+ inline int64_t MemoryWriter::seek(int64_t _offset, Whence::Enum _whence)
+ {
+ switch (_whence)
+ {
+ case Whence::Begin:
+ m_pos = int64_clamp(_offset, 0, m_top);
+ break;
+
+ case Whence::Current:
+ m_pos = int64_clamp(m_pos + _offset, 0, m_top);
+ break;
+
+ case Whence::End:
+ m_pos = int64_clamp(m_top - _offset, 0, m_top);
+ break;
+ }
+
+ return m_pos;
+ }
+
+ inline int32_t MemoryWriter::write(const void* _data, int32_t _size, Error* _err)
+ {
+ BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
+
+ int32_t morecore = int32_t(m_pos - m_size) + _size;
+
+ if (0 < morecore)
+ {
+ morecore = BX_ALIGN_MASK(morecore, 0xfff);
+ m_data = (uint8_t*)m_memBlock->more(morecore);
+ m_size = m_memBlock->getSize();
+ }
+
+ int64_t remainder = m_size-m_pos;
+ int32_t size = uint32_min(_size, uint32_t(int64_min(remainder, INT32_MAX) ) );
+ memcpy(&m_data[m_pos], _data, size);
+ m_pos += size;
+ m_top = int64_max(m_top, m_pos);
+ if (size != _size)
+ {
+ BX_ERROR_SET(_err, BX_ERROR_READERWRITER_WRITE, "MemoryWriter: write truncated.");
+ }
+ return size;
+ }
+
+ inline StaticMemoryBlockWriter::StaticMemoryBlockWriter(void* _data, uint32_t _size)
+ : MemoryWriter(&m_smb)
+ , m_smb(_data, _size)
+ {
+ }
+
+ inline StaticMemoryBlockWriter::~StaticMemoryBlockWriter()
+ {
+ }
+
+ inline int32_t read(ReaderI* _reader, void* _data, int32_t _size, Error* _err)
+ {
+ BX_ERROR_SCOPE(_err);
+ return _reader->read(_data, _size, _err);
+ }
+
+ template<typename Ty>
+ int32_t read(ReaderI* _reader, Ty& _value, Error* _err)
+ {
+ BX_ERROR_SCOPE(_err);
+ BX_STATIC_ASSERT(BX_TYPE_IS_POD(Ty) );
+ return _reader->read(&_value, sizeof(Ty), _err);
+ }
+
+ template<typename Ty>
+ int32_t readHE(ReaderI* _reader, Ty& _value, bool _fromLittleEndian, Error* _err)
+ {
+ BX_ERROR_SCOPE(_err);
+ BX_STATIC_ASSERT(BX_TYPE_IS_POD(Ty) );
+ Ty value;
+ int32_t result = _reader->read(&value, sizeof(Ty), _err);
+ _value = toHostEndian(value, _fromLittleEndian);
+ return result;
+ }
+
+ inline int32_t write(WriterI* _writer, const void* _data, int32_t _size, Error* _err)
+ {
+ BX_ERROR_SCOPE(_err);
+ return _writer->write(_data, _size, _err);
+ }
+
+ inline int32_t writeRep(WriterI* _writer, uint8_t _byte, int32_t _size, Error* _err)
+ {
+ BX_ERROR_SCOPE(_err);
+
+ const uint32_t tmp0 = uint32_sels(64 - _size, 64, _size);
+ const uint32_t tmp1 = uint32_sels(256 - _size, 256, tmp0);
+ const uint32_t blockSize = uint32_sels(1024 - _size, 1024, tmp1);
+ uint8_t* temp = (uint8_t*)alloca(blockSize);
+ memset(temp, _byte, blockSize);
+
+ int32_t size = 0;
+ while (0 < _size)
+ {
+ int32_t bytes = write(_writer, temp, uint32_min(blockSize, _size), _err);
+ size += bytes;
+ _size -= bytes;
+ }
+
+ return size;
+ }
+
+ template<typename Ty>
+ int32_t write(WriterI* _writer, const Ty& _value, Error* _err)
+ {
+ BX_ERROR_SCOPE(_err);
+ BX_STATIC_ASSERT(BX_TYPE_IS_POD(Ty) );
+ return _writer->write(&_value, sizeof(Ty), _err);
+ }
+
+ template<typename Ty>
+ int32_t writeLE(WriterI* _writer, const Ty& _value, Error* _err)
+ {
+ BX_ERROR_SCOPE(_err);
+ BX_STATIC_ASSERT(BX_TYPE_IS_POD(Ty) );
+ Ty value = toLittleEndian(_value);
+ int32_t result = _writer->write(&value, sizeof(Ty), _err);
+ return result;
+ }
+
+ template<typename Ty>
+ int32_t writeBE(WriterI* _writer, const Ty& _value, Error* _err)
+ {
+ BX_ERROR_SCOPE(_err);
+ BX_STATIC_ASSERT(BX_TYPE_IS_POD(Ty) );
+ Ty value = toBigEndian(_value);
+ int32_t result = _writer->write(&value, sizeof(Ty), _err);
+ return result;
+ }
+
+ inline int32_t writePrintf(WriterI* _writer, const char* _format, ...)
+ {
+ va_list argList;
+ va_start(argList, _format);
+
+ char temp[2048];
+ char* out = temp;
+ int32_t max = sizeof(temp);
+ int32_t len = vsnprintf(out, max, _format, argList);
+ if (len > max)
+ {
+ out = (char*)alloca(len);
+ len = vsnprintf(out, len, _format, argList);
+ }
+
+ int32_t size = write(_writer, out, len);
+
+ va_end(argList);
+
+ return size;
+ }
+
+ inline int64_t skip(SeekerI* _seeker, int64_t _offset)
+ {
+ return _seeker->seek(_offset, Whence::Current);
+ }
+
+ inline int64_t seek(SeekerI* _seeker, int64_t _offset, Whence::Enum _whence)
+ {
+ return _seeker->seek(_offset, _whence);
+ }
+
+ inline int64_t getSize(SeekerI* _seeker)
+ {
+ int64_t offset = _seeker->seek();
+ int64_t size = _seeker->seek(0, Whence::End);
+ _seeker->seek(offset, Whence::Begin);
+ return size;
+ }
+
+ inline int32_t peek(ReaderSeekerI* _reader, void* _data, int32_t _size, Error* _err)
+ {
+ BX_ERROR_SCOPE(_err);
+ int64_t offset = bx::seek(_reader);
+ int32_t size = _reader->read(_data, _size, _err);
+ bx::seek(_reader, offset, bx::Whence::Begin);
+ return size;
+ }
+
+ template<typename Ty>
+ int32_t peek(ReaderSeekerI* _reader, Ty& _value, Error* _err)
+ {
+ BX_ERROR_SCOPE(_err);
+ BX_STATIC_ASSERT(BX_TYPE_IS_POD(Ty) );
+ return peek(_reader, &_value, sizeof(Ty), _err);
+ }
+
+ inline int32_t align(ReaderSeekerI* _reader, uint32_t _alignment, Error* _err)
+ {
+ BX_ERROR_SCOPE(_err);
+ const int64_t current = bx::seek(_reader);
+ const int64_t aligned = ( (current + _alignment-1)/_alignment) * _alignment;
+ const int32_t size = int32_t(aligned - current);
+ if (0 != size)
+ {
+ const int64_t offset = bx::seek(_reader, size);
+ if (offset != aligned)
+ {
+ BX_ERROR_SET(_err, BX_ERROR_READERWRITER_WRITE, "Align: read truncated.");
+ }
+ return int32_t(offset - current);
+ }
+
+ return 0;
+ }
+
+ inline int32_t align(WriterSeekerI* _writer, uint32_t _alignment, Error* _err)
+ {
+ BX_ERROR_SCOPE(_err);
+ const int64_t current = bx::seek(_writer);
+ const int64_t aligned = ( (current + _alignment-1)/_alignment) * _alignment;
+ const int32_t size = int32_t(aligned - current);
+ if (0 != size)
+ {
+ return writeRep(_writer, 0, size, _err);
+ }
+
+ return 0;
+ }
+
+ inline bool open(ReaderOpenI* _reader, const char* _filePath, Error* _err)
+ {
+ BX_ERROR_USE_TEMP_WHEN_NULL(_err);
+ return _reader->open(_filePath, _err);
+ }
+
+ inline bool open(WriterOpenI* _writer, const char* _filePath, bool _append, Error* _err)
+ {
+ BX_ERROR_USE_TEMP_WHEN_NULL(_err);
+ return _writer->open(_filePath, _append, _err);
+ }
+
+ inline void close(CloserI* _reader)
+ {
+ _reader->close();
+ }
+
+} // namespace bx
diff --git a/3rdparty/bx/include/bx/rng.h b/3rdparty/bx/include/bx/rng.h
index cff323c2f95..91eade62644 100644
--- a/3rdparty/bx/include/bx/rng.h
+++ b/3rdparty/bx/include/bx/rng.h
@@ -12,83 +12,54 @@
namespace bx
{
- // George Marsaglia's MWC
+ /// George Marsaglia's MWC
class RngMwc
{
public:
- RngMwc(uint32_t _z = 12345, uint32_t _w = 65435)
- : m_z(_z)
- , m_w(_w)
- {
- }
-
- void reset(uint32_t _z = 12345, uint32_t _w = 65435)
- {
- m_z = _z;
- m_w = _w;
- }
-
- uint32_t gen()
- {
- m_z = 36969*(m_z&65535)+(m_z>>16);
- m_w = 18000*(m_w&65535)+(m_w>>16);
- return (m_z<<16)+m_w;
- }
+ ///
+ RngMwc(uint32_t _z = 12345, uint32_t _w = 65435);
+
+ ///
+ void reset(uint32_t _z = 12345, uint32_t _w = 65435);
+
+ ///
+ uint32_t gen();
private:
uint32_t m_z;
uint32_t m_w;
};
- // George Marsaglia's FIB
+ /// George Marsaglia's FIB
class RngFib
{
public:
- RngFib()
- : m_a(9983651)
- , m_b(95746118)
- {
- }
-
- void reset()
- {
- m_a = 9983651;
- m_b = 95746118;
- }
-
- uint32_t gen()
- {
- m_b = m_a+m_b;
- m_a = m_b-m_a;
- return m_a;
- }
+ ///
+ RngFib(uint32_t _a = 9983651, uint32_t _b = 95746118);
+
+ ///
+ void reset(uint32_t _a = 9983651, uint32_t _b = 95746118);
+
+ ///
+ uint32_t gen();
private:
uint32_t m_a;
uint32_t m_b;
};
- // George Marsaglia's SHR3
+ /// George Marsaglia's SHR3
class RngShr3
{
public:
- RngShr3(uint32_t _jsr = 34221)
- : m_jsr(_jsr)
- {
- }
-
- void reset(uint32_t _jsr = 34221)
- {
- m_jsr = _jsr;
- }
-
- uint32_t gen()
- {
- m_jsr ^= m_jsr<<17;
- m_jsr ^= m_jsr>>13;
- m_jsr ^= m_jsr<<5;
- return m_jsr;
- }
+ ///
+ RngShr3(uint32_t _jsr = 34221);
+
+ ///
+ void reset(uint32_t _jsr = 34221);
+
+ ///
+ uint32_t gen();
private:
uint32_t m_jsr;
@@ -96,112 +67,35 @@ namespace bx
/// Returns random number between 0.0f and 1.0f.
template <typename Rng>
- inline float frnd(Rng* _rng)
- {
- uint32_t rnd = _rng->gen() & UINT16_MAX;
- return float(rnd) * 1.0f/float(UINT16_MAX);
- }
+ float frnd(Rng* _rng);
/// Returns random number between -1.0f and 1.0f.
template <typename Rng>
- inline float frndh(Rng* _rng)
- {
- return 2.0f * bx::frnd(_rng) - 1.0f;
- }
+ float frndh(Rng* _rng);
/// Generate random point on unit circle.
template <typename Rng>
- inline void randUnitCircle(float _result[3], Rng* _rng)
- {
- const float angle = frnd(_rng) * pi * 2.0f;
-
- _result[0] = fcos(angle);
- _result[1] = 0.0f;
- _result[2] = fsin(angle);
- }
+ void randUnitCircle(float _result[3], Rng* _rng);
/// Generate random point on unit sphere.
template <typename Rng>
- inline void randUnitSphere(float _result[3], Rng* _rng)
- {
- const float rand0 = frnd(_rng) * 2.0f - 1.0f;
- const float rand1 = frnd(_rng) * pi * 2.0f;
- const float sqrtf1 = fsqrt(1.0f - rand0*rand0);
-
- _result[0] = sqrtf1 * fcos(rand1);
- _result[1] = sqrtf1 * fsin(rand1);
- _result[2] = rand0;
- }
+ void randUnitSphere(float _result[3], Rng* _rng);
/// Generate random point on unit hemisphere.
template <typename Ty>
- inline void randUnitHemisphere(float _result[3], Ty* _rng, const float _normal[3])
- {
- float dir[3];
- randUnitSphere(dir, _rng);
-
- float DdotN = dir[0]*_normal[0]
- + dir[1]*_normal[1]
- + dir[2]*_normal[2]
- ;
-
- if (0.0f > DdotN)
- {
- dir[0] = -dir[0];
- dir[1] = -dir[1];
- dir[2] = -dir[2];
- }
-
- _result[0] = dir[0];
- _result[1] = dir[1];
- _result[2] = dir[2];
- }
+ void randUnitHemisphere(float _result[3], Ty* _rng, const float _normal[3]);
/// Sampling with Hammersley and Halton Points
/// http://www.cse.cuhk.edu.hk/~ttwong/papers/udpoint/udpoints.html
///
- inline void generateSphereHammersley(void* _data, uint32_t _stride, uint32_t _num, float _scale = 1.0f)
- {
- uint8_t* data = (uint8_t*)_data;
-
- for (uint32_t ii = 0; ii < _num; ii++)
- {
- float tt = 0.0f;
- float pp = 0.5;
- for (uint32_t jj = ii; jj; jj >>= 1)
- {
- tt += (jj & 1) ? pp : 0.0f;
- pp *= 0.5f;
- }
-
- tt = 2.0f * tt - 1.0f;
-
- const float phi = (ii + 0.5f) / _num;
- const float phirad = phi * 2.0f * pi;
- const float st = fsqrt(1.0f-tt*tt) * _scale;
-
- float* xyz = (float*)data;
- data += _stride;
-
- xyz[0] = st * fcos(phirad);
- xyz[1] = st * fsin(phirad);
- xyz[2] = tt * _scale;
- }
- }
+ void generateSphereHammersley(void* _data, uint32_t _stride, uint32_t _num, float _scale = 1.0f);
/// Fisher-Yates shuffle.
template<typename Rng, typename Ty>
- inline void shuffle(Rng* _rng, Ty* _array, uint32_t _num)
- {
- BX_CHECK(_num != 0, "Number of elements can't be 0!");
-
- for (uint32_t ii = 0, num = _num-1; ii < num; ++ii)
- {
- uint32_t jj = ii + 1 + _rng->gen() % (num - ii);
- bx::xchg(_array[ii], _array[jj]);
- }
- }
+ void shuffle(Rng* _rng, Ty* _array, uint32_t _num);
} // namespace bx
+#include "rng.inl"
+
#endif // BX_RNG_H_HEADER_GUARD
diff --git a/3rdparty/bx/include/bx/rng.inl b/3rdparty/bx/include/bx/rng.inl
new file mode 100644
index 00000000000..02a4d21e5bc
--- /dev/null
+++ b/3rdparty/bx/include/bx/rng.inl
@@ -0,0 +1,171 @@
+/*
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#ifndef BX_RNG_H_HEADER_GUARD
+# error "Must be included from bx/rng.h!"
+#endif // BX_RNG_H_HEADER_GUARD
+
+#include "bx.h"
+#include "fpumath.h"
+#include "uint32_t.h"
+
+namespace bx
+{
+ inline RngMwc::RngMwc(uint32_t _z, uint32_t _w)
+ : m_z(_z)
+ , m_w(_w)
+ {
+ }
+
+ inline void RngMwc::reset(uint32_t _z, uint32_t _w)
+ {
+ m_z = _z;
+ m_w = _w;
+ }
+
+ inline uint32_t RngMwc::gen()
+ {
+ m_z = 36969*(m_z&65535)+(m_z>>16);
+ m_w = 18000*(m_w&65535)+(m_w>>16);
+ return (m_z<<16)+m_w;
+ }
+
+ inline RngFib::RngFib(uint32_t _a, uint32_t _b)
+ : m_a(_a)
+ , m_b(_b)
+ {
+ }
+
+ inline void RngFib::reset(uint32_t _a, uint32_t _b)
+ {
+ m_a = _a;
+ m_b = _b;
+ }
+
+ inline uint32_t RngFib::gen()
+ {
+ m_b = m_a+m_b;
+ m_a = m_b-m_a;
+ return m_a;
+ }
+
+ inline RngShr3::RngShr3(uint32_t _jsr)
+ : m_jsr(_jsr)
+ {
+ }
+
+ inline void RngShr3::reset(uint32_t _jsr)
+ {
+ m_jsr = _jsr;
+ }
+
+ inline uint32_t RngShr3::gen()
+ {
+ m_jsr ^= m_jsr<<17;
+ m_jsr ^= m_jsr>>13;
+ m_jsr ^= m_jsr<<5;
+ return m_jsr;
+ }
+
+ template <typename Rng>
+ inline float frnd(Rng* _rng)
+ {
+ uint32_t rnd = _rng->gen() & UINT16_MAX;
+ return float(rnd) * 1.0f/float(UINT16_MAX);
+ }
+
+ template <typename Rng>
+ inline float frndh(Rng* _rng)
+ {
+ return 2.0f * bx::frnd(_rng) - 1.0f;
+ }
+
+ template <typename Rng>
+ inline void randUnitCircle(float _result[3], Rng* _rng)
+ {
+ const float angle = frnd(_rng) * pi * 2.0f;
+
+ _result[0] = fcos(angle);
+ _result[1] = 0.0f;
+ _result[2] = fsin(angle);
+ }
+
+ template <typename Rng>
+ inline void randUnitSphere(float _result[3], Rng* _rng)
+ {
+ const float rand0 = frnd(_rng) * 2.0f - 1.0f;
+ const float rand1 = frnd(_rng) * pi * 2.0f;
+ const float sqrtf1 = fsqrt(1.0f - rand0*rand0);
+
+ _result[0] = sqrtf1 * fcos(rand1);
+ _result[1] = sqrtf1 * fsin(rand1);
+ _result[2] = rand0;
+ }
+
+ template <typename Ty>
+ inline void randUnitHemisphere(float _result[3], Ty* _rng, const float _normal[3])
+ {
+ float dir[3];
+ randUnitSphere(dir, _rng);
+
+ float DdotN = dir[0]*_normal[0]
+ + dir[1]*_normal[1]
+ + dir[2]*_normal[2]
+ ;
+
+ if (0.0f > DdotN)
+ {
+ dir[0] = -dir[0];
+ dir[1] = -dir[1];
+ dir[2] = -dir[2];
+ }
+
+ _result[0] = dir[0];
+ _result[1] = dir[1];
+ _result[2] = dir[2];
+ }
+
+ inline void generateSphereHammersley(void* _data, uint32_t _stride, uint32_t _num, float _scale)
+ {
+ uint8_t* data = (uint8_t*)_data;
+
+ for (uint32_t ii = 0; ii < _num; ii++)
+ {
+ float tt = 0.0f;
+ float pp = 0.5;
+ for (uint32_t jj = ii; jj; jj >>= 1)
+ {
+ tt += (jj & 1) ? pp : 0.0f;
+ pp *= 0.5f;
+ }
+
+ tt = 2.0f * tt - 1.0f;
+
+ const float phi = (ii + 0.5f) / _num;
+ const float phirad = phi * 2.0f * pi;
+ const float st = fsqrt(1.0f-tt*tt) * _scale;
+
+ float* xyz = (float*)data;
+ data += _stride;
+
+ xyz[0] = st * fcos(phirad);
+ xyz[1] = st * fsin(phirad);
+ xyz[2] = tt * _scale;
+ }
+ }
+
+ template<typename Rng, typename Ty>
+ inline void shuffle(Rng* _rng, Ty* _array, uint32_t _num)
+ {
+ BX_CHECK(_num != 0, "Number of elements can't be 0!");
+
+ for (uint32_t ii = 0, num = _num-1; ii < num; ++ii)
+ {
+ uint32_t jj = ii + 1 + _rng->gen() % (num - ii);
+ bx::xchg(_array[ii], _array[jj]);
+ }
+ }
+
+} // namespace bx
diff --git a/3rdparty/bx/include/bx/sem.h b/3rdparty/bx/include/bx/sem.h
index b33ab3721b0..acc2359c363 100644
--- a/3rdparty/bx/include/bx/sem.h
+++ b/3rdparty/bx/include/bx/sem.h
@@ -7,7 +7,6 @@
#define BX_SEM_H_HEADER_GUARD
#include "bx.h"
-#include "mutex.h"
#if BX_CONFIG_SUPPORTS_THREADING
@@ -16,18 +15,19 @@
# include <semaphore.h>
# include <time.h>
# include <pthread.h>
-#elif BX_PLATFORM_XBOXONE
-# include <synchapi.h>
-#elif BX_PLATFORM_XBOX360 || BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT
+#elif BX_PLATFORM_XBOX360 || BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT || BX_PLATFORM_XBOXONE
# include <windows.h>
# include <limits.h>
+# if BX_PLATFORM_XBOXONE
+# include <synchapi.h>
+# endif // BX_PLATFORM_XBOXONE
#endif // BX_PLATFORM_
+#include "mutex.h"
+
namespace bx
{
-#if BX_PLATFORM_POSIX
-
-# if BX_CONFIG_SEMAPHORE_PTHREAD
+ ///
class Semaphore
{
BX_CLASS(Semaphore
@@ -36,228 +36,31 @@ namespace bx
);
public:
- Semaphore()
- : m_count(0)
- {
- int result;
- result = pthread_mutex_init(&m_mutex, NULL);
- BX_CHECK(0 == result, "pthread_mutex_init %d", result);
-
- result = pthread_cond_init(&m_cond, NULL);
- BX_CHECK(0 == result, "pthread_cond_init %d", result);
-
- BX_UNUSED(result);
- }
-
- ~Semaphore()
- {
- int result;
- result = pthread_cond_destroy(&m_cond);
- BX_CHECK(0 == result, "pthread_cond_destroy %d", result);
-
- result = pthread_mutex_destroy(&m_mutex);
- BX_CHECK(0 == result, "pthread_mutex_destroy %d", result);
-
- BX_UNUSED(result);
- }
-
- void post(uint32_t _count = 1)
- {
- int result = pthread_mutex_lock(&m_mutex);
- BX_CHECK(0 == result, "pthread_mutex_lock %d", result);
-
- for (uint32_t ii = 0; ii < _count; ++ii)
- {
- result = pthread_cond_signal(&m_cond);
- BX_CHECK(0 == result, "pthread_cond_signal %d", result);
- }
-
- m_count += _count;
-
- result = pthread_mutex_unlock(&m_mutex);
- BX_CHECK(0 == result, "pthread_mutex_unlock %d", result);
+ ///
+ Semaphore();
- BX_UNUSED(result);
- }
+ ///
+ ~Semaphore();
- bool wait(int32_t _msecs = -1)
- {
- int result = pthread_mutex_lock(&m_mutex);
- BX_CHECK(0 == result, "pthread_mutex_lock %d", result);
+ ///
+ void post(uint32_t _count = 1);
-# if BX_PLATFORM_NACL || BX_PLATFORM_OSX
- BX_UNUSED(_msecs);
- BX_CHECK(-1 == _msecs, "NaCl and OSX don't support pthread_cond_timedwait at this moment.");
- while (0 == result
- && 0 >= m_count)
- {
- result = pthread_cond_wait(&m_cond, &m_mutex);
- }
-# elif BX_PLATFORM_IOS
- if (-1 == _msecs)
- {
- while (0 == result
- && 0 >= m_count)
- {
- result = pthread_cond_wait(&m_cond, &m_mutex);
- }
- }
- else
- {
- timespec ts;
- ts.tv_sec = _msecs/1000;
- ts.tv_nsec = (_msecs%1000)*1000;
-
- while (0 == result
- && 0 >= m_count)
- {
- result = pthread_cond_timedwait_relative_np(&m_cond, &m_mutex, &ts);
- }
- }
-# else
- timespec ts;
- clock_gettime(CLOCK_REALTIME, &ts);
- ts.tv_sec += _msecs/1000;
- ts.tv_nsec += (_msecs%1000)*1000;
-
- while (0 == result
- && 0 >= m_count)
- {
- result = pthread_cond_timedwait(&m_cond, &m_mutex, &ts);
- }
-# endif // BX_PLATFORM_NACL || BX_PLATFORM_OSX
- bool ok = 0 == result;
-
- if (ok)
- {
- --m_count;
- }
-
- result = pthread_mutex_unlock(&m_mutex);
- BX_CHECK(0 == result, "pthread_mutex_unlock %d", result);
-
- BX_UNUSED(result);
-
- return ok;
- }
+ ///
+ bool wait(int32_t _msecs = -1);
private:
+#if BX_PLATFORM_POSIX
+# if BX_CONFIG_SEMAPHORE_PTHREAD
pthread_mutex_t m_mutex;
pthread_cond_t m_cond;
int32_t m_count;
- };
-
# else
-
- class Semaphore
- {
- BX_CLASS(Semaphore
- , NO_COPY
- , NO_ASSIGNMENT
- );
-
- public:
- Semaphore()
- {
- int32_t result = sem_init(&m_handle, 0, 0);
- BX_CHECK(0 == result, "sem_init failed. errno %d", errno);
- BX_UNUSED(result);
- }
-
- ~Semaphore()
- {
- int32_t result = sem_destroy(&m_handle);
- BX_CHECK(0 == result, "sem_destroy failed. errno %d", errno);
- BX_UNUSED(result);
- }
-
- void post(uint32_t _count = 1)
- {
- int32_t result;
- for (uint32_t ii = 0; ii < _count; ++ii)
- {
- result = sem_post(&m_handle);
- BX_CHECK(0 == result, "sem_post failed. errno %d", errno);
- }
- BX_UNUSED(result);
- }
-
- bool wait(int32_t _msecs = -1)
- {
-# if BX_PLATFORM_NACL || BX_PLATFORM_OSX
- BX_CHECK(-1 == _msecs, "NaCl and OSX don't support sem_timedwait at this moment."); BX_UNUSED(_msecs);
- return 0 == sem_wait(&m_handle);
-# else
- if (0 > _msecs)
- {
- int32_t result;
- do
- {
- result = sem_wait(&m_handle);
- } // keep waiting when interrupted by a signal handler...
- while (-1 == result && EINTR == errno);
- BX_CHECK(0 == result, "sem_wait failed. errno %d", errno);
- return 0 == result;
- }
-
- timespec ts;
- clock_gettime(CLOCK_REALTIME, &ts);
- ts.tv_sec += _msecs/1000;
- ts.tv_nsec += (_msecs%1000)*1000;
- return 0 == sem_timedwait(&m_handle, &ts);
-# endif // BX_PLATFORM_
- }
-
- private:
sem_t m_handle;
- };
# endif // BX_CONFIG_SEMAPHORE_PTHREAD
-
#elif BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT
-
- class Semaphore
- {
- BX_CLASS(Semaphore
- , NO_COPY
- , NO_ASSIGNMENT
- );
-
- public:
- Semaphore()
- {
-#if BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
- m_handle = CreateSemaphoreExW(NULL, 0, LONG_MAX, NULL, 0, SEMAPHORE_ALL_ACCESS);
-#else
- m_handle = CreateSemaphoreA(NULL, 0, LONG_MAX, NULL);
-#endif
- BX_CHECK(NULL != m_handle, "Failed to create Semaphore!");
- }
-
- ~Semaphore()
- {
- CloseHandle(m_handle);
- }
-
- void post(uint32_t _count = 1) const
- {
- ReleaseSemaphore(m_handle, _count, NULL);
- }
-
- bool wait(int32_t _msecs = -1) const
- {
- DWORD milliseconds = (0 > _msecs) ? INFINITE : _msecs;
-#if BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
- return WAIT_OBJECT_0 == WaitForSingleObjectEx(m_handle, milliseconds, FALSE);
-#else
- return WAIT_OBJECT_0 == WaitForSingleObject(m_handle, milliseconds);
-#endif
- }
-
- private:
HANDLE m_handle;
- };
-
#endif // BX_PLATFORM_
+ };
} // namespace bx
diff --git a/3rdparty/bx/include/bx/simd256_avx.inl b/3rdparty/bx/include/bx/simd256_avx.inl
index 2a31c83f5ae..5eed77ba3af 100644
--- a/3rdparty/bx/include/bx/simd256_avx.inl
+++ b/3rdparty/bx/include/bx/simd256_avx.inl
@@ -46,7 +46,7 @@ namespace bx
template<>
BX_SIMD_FORCE_INLINE simd256_avx_t simd_isplat(uint32_t _a)
{
- const __m256i splat = _mm256_set1_epi32(_a);
+ const __m256i splat = _mm256_set1_epi32(_a);
const simd256_avx_t result = _mm256_castsi256_ps(splat);
return result;
@@ -55,7 +55,7 @@ namespace bx
template<>
BX_SIMD_FORCE_INLINE simd256_avx_t simd_itof(simd256_avx_t _a)
{
- const __m256i itof = _mm256_castps_si256(_a);
+ const __m256i itof = _mm256_castps_si256(_a);
const simd256_avx_t result = _mm256_cvtepi32_ps(itof);
return result;
@@ -64,7 +64,7 @@ namespace bx
template<>
BX_SIMD_FORCE_INLINE simd256_avx_t simd_ftoi(simd256_avx_t _a)
{
- const __m256i ftoi = _mm256_cvtps_epi32(_a);
+ const __m256i ftoi = _mm256_cvtps_epi32(_a);
const simd256_avx_t result = _mm256_castsi256_ps(ftoi);
return result;
diff --git a/3rdparty/bx/include/bx/string.h b/3rdparty/bx/include/bx/string.h
index 44002f55250..eaf27bc983c 100644
--- a/3rdparty/bx/include/bx/string.h
+++ b/3rdparty/bx/include/bx/string.h
@@ -8,696 +8,234 @@
#include "bx.h"
#include <alloca.h>
-#include <ctype.h> // tolower
#include <stdarg.h> // va_list
-#include <stdio.h> // vsnprintf, vsnwprintf
-#include <string.h>
#include <wchar.h> // wchar_t
#include <bx/allocator.h>
#include <bx/hash.h>
-#ifndef va_copy
-# define va_copy(_a, _b) (_a) = (_b)
-#endif // va_copy
-
namespace bx
{
- ///
- inline bool toBool(const char* _str)
+ /// Non-zero-terminated string view.
+ class StringView
{
- char ch = (char)::tolower(_str[0]);
- return ch == 't' || ch == '1';
- }
+ public:
+ ///
+ StringView();
- /// Case insensitive string compare.
- inline int32_t stricmp(const char* _a, const char* _b)
+ ///
+ StringView(const StringView& _rhs);
+
+ ///
+ StringView& operator=(const StringView& _rhs);
+
+ ///
+ StringView(const char* _ptr, uint32_t _len = UINT16_MAX);
+
+ ///
+ void set(const char* _ptr, uint32_t _len = UINT16_MAX);
+
+ ///
+ void clear();
+
+ ///
+ const char* getPtr() const;
+
+ ///
+ const char* getTerm() const;
+
+ ///
+ bool isEmpty() const;
+
+ ///
+ uint32_t getLength() const;
+
+ protected:
+ const char* m_ptr;
+ uint32_t m_len;
+ };
+
+ /// ASCII string
+ template<bx::AllocatorI** AllocatorT>
+ class StringT : public StringView
{
-#if BX_CRT_MSVC
- return ::_stricmp(_a, _b);
-#else
- return ::strcasecmp(_a, _b);
-#endif // BX_COMPILER_
- }
+ public:
+ ///
+ StringT();
+
+ ///
+ StringT(const StringT<AllocatorT>& _rhs);
+
+ ///
+ StringT<AllocatorT>& operator=(const StringT<AllocatorT>& _rhs);
+
+ ///
+ StringT(const char* _ptr, uint32_t _len = UINT32_MAX);
+
+ ///
+ StringT(const StringView& _rhs);
+
+ ///
+ ~StringT();
+
+ ///
+ void set(const char* _ptr, uint32_t _len = UINT32_MAX);
+
+ ///
+ void append(const char* _ptr, uint32_t _len = UINT32_MAX);
+
+ ///
+ void clear();
+ };
///
- inline size_t strnlen(const char* _str, size_t _max)
- {
- const char* ptr;
- for (ptr = _str; 0 < _max && *ptr != '\0'; ++ptr, --_max) {};
- return ptr - _str;
- }
+ bool isSpace(char _ch);
+
+ ///
+ bool isUpper(char _ch);
+
+ ///
+ bool isLower(char _ch);
+
+ ///
+ bool isAlpha(char _ch);
+
+ ///
+ bool isNumeric(char _ch);
+
+ ///
+ bool isAlphaNum(char _ch);
+
+ ///
+ bool isPrint(char _ch);
+
+ ///
+ char toLower(char _ch);
+
+ ///
+ char toUpper(char _ch);
+
+ ///
+ bool toBool(const char* _str);
+
+ /// String compare.
+ int32_t strncmp(const char* _lhs, const char* _rhs, size_t _max = INT32_MAX);
+
+ /// Case insensitive string compare.
+ int32_t strincmp(const char* _lhs, const char* _rhs, size_t _max = INT32_MAX);
+
+ ///
+ size_t strnlen(const char* _str, size_t _max = -1);
/// Copy _num characters from string _src to _dst buffer of maximum _dstSize capacity
/// including zero terminator. Copy will be terminated with '\0'.
- inline size_t strlncpy(char* _dst, size_t _dstSize, const char* _src, size_t _num = -1)
- {
- BX_CHECK(NULL != _dst, "_dst can't be NULL!");
- BX_CHECK(NULL != _src, "_src can't be NULL!");
- BX_CHECK(0 < _dstSize, "_dstSize can't be 0!");
+ size_t strlncpy(char* _dst, size_t _dstSize, const char* _src, size_t _num = INT32_MAX);
- const size_t len = strnlen(_src, _num);
- const size_t max = _dstSize-1;
- const size_t num = (len < max ? len : max);
- strncpy(_dst, _src, num);
- _dst[num] = '\0';
+ ///
+ size_t strlncat(char* _dst, size_t _dstSize, const char* _src, size_t _num = INT32_MAX);
+
+ ///
+ const char* strnchr(const char* _str, char _ch, size_t _max = INT32_MAX);
- return num;
- }
+ ///
+ const char* strnrchr(const char* _str, char _ch, size_t _max = INT32_MAX);
/// Find substring in string. Limit search to _size.
- inline const char* strnstr(const char* _str, const char* _find, size_t _size)
- {
- char first = *_find;
- if ('\0' == first)
- {
- return _str;
- }
-
- const char* cmp = _find + 1;
- size_t len = strlen(cmp);
- do
- {
- for (char match = *_str++; match != first && 0 < _size; match = *_str++, --_size)
- {
- if ('\0' == match)
- {
- return NULL;
- }
- }
-
- if (0 == _size)
- {
- return NULL;
- }
-
- } while (0 != strncmp(_str, cmp, len) );
-
- return --_str;
- }
-
- /// Find substring in string. Case insensitive.
- inline const char* stristr(const char* _str, const char* _find)
- {
- const char* ptr = _str;
-
- for (size_t len = strlen(_str), searchLen = strlen(_find)
- ; len >= searchLen
- ; ++ptr, --len)
- {
- // Find start of the string.
- while (tolower(*ptr) != tolower(*_find) )
- {
- ++ptr;
- --len;
-
- // Search pattern lenght can't be longer than the string.
- if (searchLen > len)
- {
- return NULL;
- }
- }
-
- // Set pointers.
- const char* string = ptr;
- const char* search = _find;
-
- // Start comparing.
- while (tolower(*string++) == tolower(*search++) )
- {
- // If end of the 'search' string is reached, all characters match.
- if ('\0' == *search)
- {
- return ptr;
- }
- }
- }
-
- return NULL;
- }
+ const char* strnstr(const char* _str, const char* _find, size_t _max = INT32_MAX);
/// Find substring in string. Case insensitive. Limit search to _max.
- inline const char* stristr(const char* _str, const char* _find, size_t _max)
- {
- const char* ptr = _str;
-
- size_t stringLen = strnlen(_str, _max);
- const size_t findLen = strlen(_find);
-
- for (; stringLen >= findLen; ++ptr, --stringLen)
- {
- // Find start of the string.
- while (tolower(*ptr) != tolower(*_find) )
- {
- ++ptr;
- --stringLen;
-
- // Search pattern lenght can't be longer than the string.
- if (findLen > stringLen)
- {
- return NULL;
- }
- }
-
- // Set pointers.
- const char* string = ptr;
- const char* search = _find;
-
- // Start comparing.
- while (tolower(*string++) == tolower(*search++) )
- {
- // If end of the 'search' string is reached, all characters match.
- if ('\0' == *search)
- {
- return ptr;
- }
- }
- }
-
- return NULL;
- }
+ const char* stristr(const char* _str, const char* _find, size_t _max = INT32_MAX);
/// Find new line. Returns pointer after new line terminator.
- inline const char* strnl(const char* _str)
- {
- for (; '\0' != *_str; _str += strnlen(_str, 1024) )
- {
- const char* eol = strnstr(_str, "\r\n", 1024);
- if (NULL != eol)
- {
- return eol + 2;
- }
-
- eol = strnstr(_str, "\n", 1024);
- if (NULL != eol)
- {
- return eol + 1;
- }
- }
-
- return _str;
- }
+ const char* strnl(const char* _str);
/// Find end of line. Retuns pointer to new line terminator.
- inline const char* streol(const char* _str)
- {
- for (; '\0' != *_str; _str += strnlen(_str, 1024) )
- {
- const char* eol = strnstr(_str, "\r\n", 1024);
- if (NULL != eol)
- {
- return eol;
- }
-
- eol = strnstr(_str, "\n", 1024);
- if (NULL != eol)
- {
- return eol;
- }
- }
-
- return _str;
- }
+ const char* streol(const char* _str);
/// Skip whitespace.
- inline const char* strws(const char* _str)
- {
- for (; isspace(*_str); ++_str) {};
- return _str;
- }
+ const char* strws(const char* _str);
/// Skip non-whitespace.
- inline const char* strnws(const char* _str)
- {
- for (; !isspace(*_str); ++_str) {};
- return _str;
- }
+ const char* strnws(const char* _str);
/// Skip word.
- inline const char* strword(const char* _str)
- {
- for (char ch = *_str++; isalnum(ch) || '_' == ch; ch = *_str++) {};
- return _str-1;
- }
+ const char* strword(const char* _str);
/// Find matching block.
- inline const char* strmb(const char* _str, char _open, char _close)
- {
- int count = 0;
- for (char ch = *_str++; ch != '\0' && count >= 0; ch = *_str++)
- {
- if (ch == _open)
- {
- count++;
- }
- else if (ch == _close)
- {
- count--;
- if (0 == count)
- {
- return _str-1;
- }
- }
- }
-
- return NULL;
- }
+ const char* strmb(const char* _str, char _open, char _close);
// Normalize string to sane line endings.
- inline void eolLF(char* _out, size_t _size, const char* _str)
- {
- if (0 < _size)
- {
- char* end = _out + _size - 1;
- for (char ch = *_str++; ch != '\0' && _out < end; ch = *_str++)
- {
- if ('\r' != ch)
- {
- *_out++ = ch;
- }
- }
-
- *_out = '\0';
- }
- }
+ void eolLF(char* _out, size_t _size, const char* _str);
// Finds identifier.
- inline const char* findIdentifierMatch(const char* _str, const char* _word)
- {
- size_t len = strlen(_word);
- const char* ptr = strstr(_str, _word);
- for (; NULL != ptr; ptr = strstr(ptr + len, _word) )
- {
- if (ptr != _str)
- {
- char ch = *(ptr - 1);
- if (isalnum(ch) || '_' == ch)
- {
- continue;
- }
- }
-
- char ch = ptr[len];
- if (isalnum(ch) || '_' == ch)
- {
- continue;
- }
-
- return ptr;
- }
-
- return ptr;
- }
+ const char* findIdentifierMatch(const char* _str, const char* _word);
// Finds any identifier from NULL terminated array of identifiers.
- inline const char* findIdentifierMatch(const char* _str, const char* _words[])
- {
- for (const char* word = *_words; NULL != word; ++_words, word = *_words)
- {
- const char* match = findIdentifierMatch(_str, word);
- if (NULL != match)
- {
- return match;
- }
- }
-
- return NULL;
- }
+ const char* findIdentifierMatch(const char* _str, const char* _words[]);
/// Cross platform implementation of vsnprintf that returns number of
/// characters which would have been written to the final string if
/// enough space had been available.
- inline int32_t vsnprintf(char* _str, size_t _count, const char* _format, va_list _argList)
- {
-#if BX_COMPILER_MSVC
- va_list argListCopy;
- va_copy(argListCopy, _argList);
- int32_t len = ::vsnprintf_s(_str, _count, size_t(-1), _format, argListCopy);
- va_end(argListCopy);
- return -1 == len ? ::_vscprintf(_format, _argList) : len;
-#else
- return ::vsnprintf(_str, _count, _format, _argList);
-#endif // BX_COMPILER_MSVC
- }
+ int32_t vsnprintf(char* _out, size_t _max, const char* _format, va_list _argList);
/// Cross platform implementation of vsnwprintf that returns number of
/// characters which would have been written to the final string if
/// enough space had been available.
- inline int32_t vsnwprintf(wchar_t* _str, size_t _count, const wchar_t* _format, va_list _argList)
- {
-#if BX_COMPILER_MSVC
- va_list argListCopy;
- va_copy(argListCopy, _argList);
- int32_t len = ::_vsnwprintf_s(_str, _count, size_t(-1), _format, argListCopy);
- va_end(argListCopy);
- return -1 == len ? ::_vscwprintf(_format, _argList) : len;
-#elif defined(__MINGW32__)
- return ::vsnwprintf(_str, _count, _format, _argList);
-#else
- return ::vswprintf(_str, _count, _format, _argList);
-#endif // BX_COMPILER_MSVC
- }
+ int32_t vsnwprintf(wchar_t* _out, size_t _max, const wchar_t* _format, va_list _argList);
///
- inline int32_t snprintf(char* _str, size_t _count, const char* _format, ...) // BX_PRINTF_ARGS(3, 4)
- {
- va_list argList;
- va_start(argList, _format);
- int32_t len = vsnprintf(_str, _count, _format, argList);
- va_end(argList);
- return len;
- }
+ int32_t snprintf(char* _out, size_t _max, const char* _format, ...);
///
- inline int32_t swnprintf(wchar_t* _out, size_t _count, const wchar_t* _format, ...)
- {
- va_list argList;
- va_start(argList, _format);
- int32_t len = vsnwprintf(_out, _count, _format, argList);
- va_end(argList);
- return len;
- }
+ int32_t swnprintf(wchar_t* _out, size_t _max, const wchar_t* _format, ...);
///
template <typename Ty>
- inline void stringPrintfVargs(Ty& _out, const char* _format, va_list _argList)
- {
- char temp[2048];
-
- char* out = temp;
- int32_t len = bx::vsnprintf(out, sizeof(temp), _format, _argList);
- if ( (int32_t)sizeof(temp) < len)
- {
- out = (char*)alloca(len+1);
- len = bx::vsnprintf(out, len, _format, _argList);
- }
- out[len] = '\0';
- _out.append(out);
- }
+ void stringPrintfVargs(Ty& _out, const char* _format, va_list _argList);
///
template <typename Ty>
- inline void stringPrintf(Ty& _out, const char* _format, ...)
- {
- va_list argList;
- va_start(argList, _format);
- stringPrintfVargs(_out, _format, argList);
- va_end(argList);
- }
+ void stringPrintf(Ty& _out, const char* _format, ...);
/// Replace all instances of substring.
template <typename Ty>
- inline Ty replaceAll(const Ty& _str, const char* _from, const char* _to)
- {
- Ty str = _str;
- size_t startPos = 0;
- const size_t fromLen = strlen(_from);
- const size_t toLen = strlen(_to);
- while ( (startPos = str.find(_from, startPos) ) != Ty::npos)
- {
- str.replace(startPos, fromLen, _to);
- startPos += toLen;
- }
-
- return str;
- }
+ Ty replaceAll(const Ty& _str, const char* _from, const char* _to);
/// Extract base file name from file path.
- inline const char* baseName(const char* _filePath)
- {
- const char* bs = strrchr(_filePath, '\\');
- const char* fs = strrchr(_filePath, '/');
- const char* slash = (bs > fs ? bs : fs);
- const char* colon = strrchr(_filePath, ':');
- const char* basename = slash > colon ? slash : colon;
- if (NULL != basename)
- {
- return basename+1;
- }
-
- return _filePath;
- }
+ const char* baseName(const char* _filePath);
/// Convert size in bytes to human readable string.
- inline void prettify(char* _out, size_t _count, uint64_t _size)
- {
- uint8_t idx = 0;
- double size = double(_size);
- while (_size != (_size&0x7ff)
- && idx < 9)
- {
- _size >>= 10;
- size *= 1.0/1024.0;
- ++idx;
- }
-
- snprintf(_out, _count, "%0.2f %c%c", size, "BkMGTPEZY"[idx], idx > 0 ? 'B' : '\0');
- }
-
- /*
- * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
+ void prettify(char* _out, size_t _count, uint64_t _size);
/// Copy src to string dst of size siz. At most siz-1 characters
/// will be copied. Always NUL terminates (unless siz == 0).
/// Returns strlen(src); if retval >= siz, truncation occurred.
- inline size_t strlcpy(char* _dst, const char* _src, size_t _siz)
- {
- char* dd = _dst;
- const char* ss = _src;
- size_t nn = _siz;
-
- /* Copy as many bytes as will fit */
- if (nn != 0)
- {
- while (--nn != 0)
- {
- if ( (*dd++ = *ss++) == '\0')
- {
- break;
- }
- }
- }
-
- /* Not enough room in dst, add NUL and traverse rest of src */
- if (nn == 0)
- {
- if (_siz != 0)
- {
- *dd = '\0'; /* NUL-terminate dst */
- }
-
- while (*ss++)
- {
- }
- }
-
- return(ss - _src - 1); /* count does not include NUL */
- }
+ size_t strlcpy(char* _dst, const char* _src, size_t _max);
/// Appends src to string dst of size siz (unlike strncat, siz is the
/// full size of dst, not space left). At most siz-1 characters
/// will be copied. Always NUL terminates (unless siz <= strlen(dst)).
/// Returns strlen(src) + MIN(siz, strlen(initial dst)).
/// If retval >= siz, truncation occurred.
- inline size_t strlcat(char* _dst, const char* _src, size_t _siz)
- {
- char* dd = _dst;
- const char *s = _src;
- size_t nn = _siz;
- size_t dlen;
-
- /* Find the end of dst and adjust bytes left but don't go past end */
- while (nn-- != 0 && *dd != '\0')
- {
- dd++;
- }
-
- dlen = dd - _dst;
- nn = _siz - dlen;
-
- if (nn == 0)
- {
- return(dlen + strlen(s));
- }
-
- while (*s != '\0')
- {
- if (nn != 1)
- {
- *dd++ = *s;
- nn--;
- }
- s++;
- }
- *dd = '\0';
-
- return(dlen + (s - _src)); /* count does not include NUL */
- }
-
- /// Non-zero-terminated string view.
- class StringView
- {
- public:
- StringView()
- {
- clear();
- }
-
- StringView(const StringView& _rhs)
- {
- set(_rhs.m_ptr, _rhs.m_len);
- }
-
- StringView& operator=(const StringView& _rhs)
- {
- set(_rhs.m_ptr, _rhs.m_len);
- return *this;
- }
-
- StringView(const char* _ptr, uint32_t _len = UINT16_MAX)
- {
- set(_ptr, _len);
- }
-
- void set(const char* _ptr, uint32_t _len = UINT16_MAX)
- {
- clear();
-
- if (NULL != _ptr)
- {
- uint32_t len = uint32_t(strnlen(_ptr, _len) );
- if (0 != len)
- {
- m_len = len;
- m_ptr = _ptr;
- }
- }
- }
-
- void clear()
- {
- m_ptr = "";
- m_len = 0;
- }
-
- const char* getPtr() const
- {
- return m_ptr;
- }
-
- const char* getTerm() const
- {
- return m_ptr + m_len;
- }
-
- bool isEmpty() const
- {
- return 0 == m_len;
- }
-
- uint32_t getLength() const
- {
- return m_len;
- }
+ size_t strlcat(char* _dst, const char* _src, size_t _max);
- protected:
- friend uint32_t hashMurmur2A(const StringView& _data);
+ ///
+ int32_t toString(char* _out, size_t _max, double _value);
- const char* m_ptr;
- uint32_t m_len;
- };
+ ///
+ int32_t toString(char* _out, size_t _max, int32_t _value, uint32_t _base = 10);
- inline uint32_t hashMurmur2A(const StringView& _data)
- {
- return hashMurmur2A(_data.m_ptr, _data.m_len);
- }
+ ///
+ int32_t toString(char* _out, size_t _max, uint32_t _value, uint32_t _base = 10);
- inline uint32_t hashMurmur2A(const char* _data)
- {
- return hashMurmur2A(StringView(_data) );
- }
+ ///
+ uint32_t hashMurmur2A(const StringView& _data);
- /// ASCII string
- template<bx::AllocatorI** AllocatorT>
- class StringT : public StringView
- {
- public:
- StringT()
- : StringView()
- {
- }
-
- StringT(const StringT<AllocatorT>& _rhs)
- : StringView()
- {
- set(_rhs.m_ptr, _rhs.m_len);
- }
-
- StringT<AllocatorT>& operator=(const StringT<AllocatorT>& _rhs)
- {
- set(_rhs.m_ptr, _rhs.m_len);
- return *this;
- }
-
- StringT(const char* _ptr, uint32_t _len = UINT32_MAX)
- {
- set(_ptr, _len);
- }
-
- StringT(const StringView& _rhs)
- {
- set(_rhs.getPtr(), _rhs.getLength() );
- }
-
- ~StringT()
- {
- clear();
- }
-
- void set(const char* _ptr, uint32_t _len = UINT32_MAX)
- {
- clear();
- append(_ptr, _len);
- }
-
- void append(const char* _ptr, uint32_t _len = UINT32_MAX)
- {
- if (0 != _len)
- {
- uint32_t old = m_len;
- uint32_t len = m_len + uint32_t(strnlen(_ptr, _len) );
- char* ptr = (char*)BX_REALLOC(*AllocatorT, 0 != m_len ? const_cast<char*>(m_ptr) : NULL, len+1);
- m_len = len;
- strlncpy(ptr + old, len-old+1, _ptr, _len);
-
- *const_cast<char**>(&m_ptr) = ptr;
- }
- }
-
- void clear()
- {
- if (0 != m_len)
- {
- BX_FREE(*AllocatorT, const_cast<char*>(m_ptr) );
-
- StringView::clear();
- }
- }
- };
+ ///
+ uint32_t hashMurmur2A(const char* _data);
} // namespace bx
+#include "string.inl"
+
#endif // BX_STRING_H_HEADER_GUARD
diff --git a/3rdparty/bx/include/bx/string.inl b/3rdparty/bx/include/bx/string.inl
new file mode 100644
index 00000000000..42f2a6a05b9
--- /dev/null
+++ b/3rdparty/bx/include/bx/string.inl
@@ -0,0 +1,200 @@
+/*
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#ifndef BX_STRING_H_HEADER_GUARD
+# error "Must be included from bx/string.h!"
+#endif // BX_STRING_H_HEADER_GUARD
+
+#if BX_CRT_MSVC && !defined(va_copy)
+# define va_copy(_a, _b) (_a) = (_b)
+#endif // BX_CRT_MSVC && !defined(va_copy)
+
+namespace bx
+{
+ template <typename Ty>
+ inline void stringPrintfVargs(Ty& _out, const char* _format, va_list _argList)
+ {
+ char temp[2048];
+
+ char* out = temp;
+ int32_t len = bx::vsnprintf(out, sizeof(temp), _format, _argList);
+ if ( (int32_t)sizeof(temp) < len)
+ {
+ out = (char*)alloca(len+1);
+ len = bx::vsnprintf(out, len, _format, _argList);
+ }
+ out[len] = '\0';
+ _out.append(out);
+ }
+
+ template <typename Ty>
+ inline void stringPrintf(Ty& _out, const char* _format, ...)
+ {
+ va_list argList;
+ va_start(argList, _format);
+ stringPrintfVargs(_out, _format, argList);
+ va_end(argList);
+ }
+
+ template <typename Ty>
+ inline Ty replaceAll(const Ty& _str, const char* _from, const char* _to)
+ {
+ Ty str = _str;
+ size_t startPos = 0;
+ const size_t fromLen = strlen(_from);
+ const size_t toLen = strlen(_to);
+ while ( (startPos = str.find(_from, startPos) ) != Ty::npos)
+ {
+ str.replace(startPos, fromLen, _to);
+ startPos += toLen;
+ }
+
+ return str;
+ }
+
+ inline StringView::StringView()
+ {
+ clear();
+ }
+
+ inline StringView::StringView(const StringView& _rhs)
+ {
+ set(_rhs.m_ptr, _rhs.m_len);
+ }
+
+ inline StringView& StringView::operator=(const StringView& _rhs)
+ {
+ set(_rhs.m_ptr, _rhs.m_len);
+ return *this;
+ }
+
+ inline StringView::StringView(const char* _ptr, uint32_t _len)
+ {
+ set(_ptr, _len);
+ }
+
+ inline void StringView::set(const char* _ptr, uint32_t _len)
+ {
+ clear();
+
+ if (NULL != _ptr)
+ {
+ uint32_t len = uint32_t(strnlen(_ptr, _len) );
+ if (0 != len)
+ {
+ m_len = len;
+ m_ptr = _ptr;
+ }
+ }
+ }
+
+ inline void StringView::clear()
+ {
+ m_ptr = "";
+ m_len = 0;
+ }
+
+ inline const char* StringView::getPtr() const
+ {
+ return m_ptr;
+ }
+
+ inline const char* StringView::getTerm() const
+ {
+ return m_ptr + m_len;
+ }
+
+ inline bool StringView::isEmpty() const
+ {
+ return 0 == m_len;
+ }
+
+ inline uint32_t StringView::getLength() const
+ {
+ return m_len;
+ }
+
+ inline uint32_t hashMurmur2A(const StringView& _data)
+ {
+ return hashMurmur2A(_data.getPtr(), _data.getLength() );
+ }
+
+ inline uint32_t hashMurmur2A(const char* _data)
+ {
+ return hashMurmur2A(StringView(_data) );
+ }
+
+ template<bx::AllocatorI** AllocatorT>
+ inline StringT<AllocatorT>::StringT()
+ : StringView()
+ {
+ }
+
+ template<bx::AllocatorI** AllocatorT>
+ inline StringT<AllocatorT>::StringT(const StringT<AllocatorT>& _rhs)
+ : StringView()
+ {
+ set(_rhs.m_ptr, _rhs.m_len);
+ }
+
+ template<bx::AllocatorI** AllocatorT>
+ inline StringT<AllocatorT>& StringT<AllocatorT>::operator=(const StringT<AllocatorT>& _rhs)
+ {
+ set(_rhs.m_ptr, _rhs.m_len);
+ return *this;
+ }
+
+ template<bx::AllocatorI** AllocatorT>
+ inline StringT<AllocatorT>::StringT(const char* _ptr, uint32_t _len)
+ {
+ set(_ptr, _len);
+ }
+
+ template<bx::AllocatorI** AllocatorT>
+ inline StringT<AllocatorT>::StringT(const StringView& _rhs)
+ {
+ set(_rhs.getPtr(), _rhs.getLength() );
+ }
+
+ template<bx::AllocatorI** AllocatorT>
+ inline StringT<AllocatorT>::~StringT()
+ {
+ clear();
+ }
+
+ template<bx::AllocatorI** AllocatorT>
+ inline void StringT<AllocatorT>::set(const char* _ptr, uint32_t _len)
+ {
+ clear();
+ append(_ptr, _len);
+ }
+
+ template<bx::AllocatorI** AllocatorT>
+ inline void StringT<AllocatorT>::append(const char* _ptr, uint32_t _len)
+ {
+ if (0 != _len)
+ {
+ uint32_t old = m_len;
+ uint32_t len = m_len + uint32_t(strnlen(_ptr, _len) );
+ char* ptr = (char*)BX_REALLOC(*AllocatorT, 0 != m_len ? const_cast<char*>(m_ptr) : NULL, len+1);
+ m_len = len;
+ strlncpy(ptr + old, len-old+1, _ptr, _len);
+
+ *const_cast<char**>(&m_ptr) = ptr;
+ }
+ }
+
+ template<bx::AllocatorI** AllocatorT>
+ inline void StringT<AllocatorT>::clear()
+ {
+ if (0 != m_len)
+ {
+ BX_FREE(*AllocatorT, const_cast<char*>(m_ptr) );
+
+ StringView::clear();
+ }
+ }
+
+} // namespace bx
diff --git a/3rdparty/bx/include/bx/thread.h b/3rdparty/bx/include/bx/thread.h
index 8514a704280..95152367f02 100644
--- a/3rdparty/bx/include/bx/thread.h
+++ b/3rdparty/bx/include/bx/thread.h
@@ -6,6 +6,8 @@
#ifndef BX_THREAD_H_HEADER_GUARD
#define BX_THREAD_H_HEADER_GUARD
+#include "bx.h"
+
#if BX_PLATFORM_POSIX
# include <pthread.h>
# if defined(__FreeBSD__)
@@ -26,8 +28,10 @@ using namespace Windows::System::Threading;
namespace bx
{
+ ///
typedef int32_t (*ThreadFn)(void* _userData);
+ ///
class Thread
{
BX_CLASS(Thread
@@ -36,205 +40,36 @@ namespace bx
);
public:
- Thread()
-#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
- : m_handle(INVALID_HANDLE_VALUE)
- , m_threadId(UINT32_MAX)
-#elif BX_PLATFORM_POSIX
- : m_handle(0)
-#endif // BX_PLATFORM_
- , m_fn(NULL)
- , m_userData(NULL)
- , m_stackSize(0)
- , m_exitCode(0 /*EXIT_SUCCESS*/)
- , m_running(false)
- {
- }
+ ///
+ Thread();
- virtual ~Thread()
- {
- if (m_running)
- {
- shutdown();
- }
- }
+ ///
+ virtual ~Thread();
- void init(ThreadFn _fn, void* _userData = NULL, uint32_t _stackSize = 0, const char* _name = NULL)
- {
- BX_CHECK(!m_running, "Already running!");
+ ///
+ void init(ThreadFn _fn, void* _userData = NULL, uint32_t _stackSize = 0, const char* _name = NULL);
- m_fn = _fn;
- m_userData = _userData;
- m_stackSize = _stackSize;
- m_running = true;
+ ///
+ void shutdown();
-#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE
- m_handle = ::CreateThread(NULL
- , m_stackSize
- , (LPTHREAD_START_ROUTINE)threadFunc
- , this
- , 0
- , NULL
- );
-#elif BX_PLATFORM_WINRT
- m_handle = CreateEventEx(nullptr, nullptr, CREATE_EVENT_MANUAL_RESET, EVENT_ALL_ACCESS);
- auto workItemHandler = ref new WorkItemHandler([=](IAsyncAction^)
- {
- m_exitCode = threadFunc(this);
- SetEvent(m_handle);
- }, CallbackContext::Any);
+ ///
+ bool isRunning() const;
- ThreadPool::RunAsync(workItemHandler, WorkItemPriority::Normal, WorkItemOptions::TimeSliced);
-#elif BX_PLATFORM_POSIX
- int result;
- BX_UNUSED(result);
-
- pthread_attr_t attr;
- result = pthread_attr_init(&attr);
- BX_CHECK(0 == result, "pthread_attr_init failed! %d", result);
-
- if (0 != m_stackSize)
- {
- result = pthread_attr_setstacksize(&attr, m_stackSize);
- BX_CHECK(0 == result, "pthread_attr_setstacksize failed! %d", result);
- }
-
-// sched_param sched;
-// sched.sched_priority = 0;
-// result = pthread_attr_setschedparam(&attr, &sched);
-// BX_CHECK(0 == result, "pthread_attr_setschedparam failed! %d", result);
-
- result = pthread_create(&m_handle, &attr, &threadFunc, this);
- BX_CHECK(0 == result, "pthread_attr_setschedparam failed! %d", result);
-#else
-# error "Not implemented!"
-#endif // BX_PLATFORM_
+ ///
+ int32_t getExitCode() const;
- m_sem.wait();
-
- if (NULL != _name)
- {
- setThreadName(_name);
- }
- }
-
- void shutdown()
- {
- BX_CHECK(m_running, "Not running!");
-#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360
- WaitForSingleObject(m_handle, INFINITE);
- GetExitCodeThread(m_handle, (DWORD*)&m_exitCode);
- CloseHandle(m_handle);
- m_handle = INVALID_HANDLE_VALUE;
-#elif BX_PLATFORM_WINRT
- WaitForSingleObjectEx(m_handle, INFINITE, FALSE);
- CloseHandle(m_handle);
- m_handle = INVALID_HANDLE_VALUE;
-#elif BX_PLATFORM_POSIX
- union
- {
- void* ptr;
- int32_t i;
- } cast;
- pthread_join(m_handle, &cast.ptr);
- m_exitCode = cast.i;
- m_handle = 0;
-#endif // BX_PLATFORM_
- m_running = false;
- }
-
- bool isRunning() const
- {
- return m_running;
- }
-
- int32_t getExitCode() const
- {
- return m_exitCode;
- }
-
- void setThreadName(const char* _name)
- {
-#if BX_PLATFORM_OSX || BX_PLATFORM_IOS
- pthread_setname_np(_name);
-#elif (BX_CRT_GLIBC >= 21200) && ! BX_PLATFORM_HURD
- pthread_setname_np(m_handle, _name);
-#elif BX_PLATFORM_LINUX
- prctl(PR_SET_NAME,_name, 0, 0, 0);
-#elif BX_PLATFORM_BSD
-# ifdef __NetBSD__
- pthread_setname_np(m_handle, "%s", (void*)_name);
-# else
- pthread_set_name_np(m_handle, _name);
-# endif // __NetBSD__
-#elif BX_PLATFORM_WINDOWS && BX_COMPILER_MSVC
-# pragma pack(push, 8)
- struct ThreadName
- {
- DWORD type;
- LPCSTR name;
- DWORD id;
- DWORD flags;
- };
-# pragma pack(pop)
- ThreadName tn;
- tn.type = 0x1000;
- tn.name = _name;
- tn.id = m_threadId;
- tn.flags = 0;
-
- __try
- {
- RaiseException(0x406d1388
- , 0
- , sizeof(tn)/4
- , reinterpret_cast<ULONG_PTR*>(&tn)
- );
- }
- __except(EXCEPTION_EXECUTE_HANDLER)
- {
- }
-#else
- BX_UNUSED(_name);
-#endif // BX_PLATFORM_
- }
+ ///
+ void setThreadName(const char* _name);
private:
- int32_t entry()
- {
-#if BX_PLATFORM_WINDOWS
- m_threadId = ::GetCurrentThreadId();
-#endif // BX_PLATFORM_WINDOWS
-
- m_sem.post();
- return m_fn(m_userData);
- }
-
-#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_WINRT
- static DWORD WINAPI threadFunc(LPVOID _arg)
- {
- Thread* thread = (Thread*)_arg;
- int32_t result = thread->entry();
- return result;
- }
-#else
- static void* threadFunc(void* _arg)
- {
- Thread* thread = (Thread*)_arg;
- union
- {
- void* ptr;
- int32_t i;
- } cast;
- cast.i = thread->entry();
- return cast.ptr;
- }
-#endif // BX_PLATFORM_
+ int32_t entry();
#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
+ static DWORD WINAPI threadFunc(LPVOID _arg);
HANDLE m_handle;
DWORD m_threadId;
#elif BX_PLATFORM_POSIX
+ static void* threadFunc(void* _arg);
pthread_t m_handle;
#endif // BX_PLATFORM_
@@ -246,71 +81,34 @@ namespace bx
bool m_running;
};
-#if BX_PLATFORM_WINDOWS
+ ///
class TlsData
{
public:
- TlsData()
- {
- m_id = TlsAlloc();
- BX_CHECK(TLS_OUT_OF_INDEXES != m_id, "Failed to allocated TLS index (err: 0x%08x).", GetLastError() );
- }
+ ///
+ TlsData();
- ~TlsData()
- {
- BOOL result = TlsFree(m_id);
- BX_CHECK(0 != result, "Failed to free TLS index (err: 0x%08x).", GetLastError() ); BX_UNUSED(result);
- }
+ ///
+ ~TlsData();
- void* get() const
- {
- return TlsGetValue(m_id);
- }
+ ///
+ void* get() const;
- void set(void* _ptr)
- {
- TlsSetValue(m_id, _ptr);
- }
+ ///
+ void set(void* _ptr);
private:
+#if BX_PLATFORM_WINDOWS
uint32_t m_id;
- };
-
#elif !(BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT)
-
- class TlsData
- {
- public:
- TlsData()
- {
- int result = pthread_key_create(&m_id, NULL);
- BX_CHECK(0 == result, "pthread_key_create failed %d.", result); BX_UNUSED(result);
- }
-
- ~TlsData()
- {
- int result = pthread_key_delete(m_id);
- BX_CHECK(0 == result, "pthread_key_delete failed %d.", result); BX_UNUSED(result);
- }
-
- void* get() const
- {
- return pthread_getspecific(m_id);
- }
-
- void set(void* _ptr)
- {
- int result = pthread_setspecific(m_id, _ptr);
- BX_CHECK(0 == result, "pthread_setspecific failed %d.", result); BX_UNUSED(result);
- }
-
- private:
pthread_key_t m_id;
- };
#endif // BX_PLATFORM_*
+ };
} // namespace bx
#endif // BX_CONFIG_SUPPORTS_THREADING
+#include "thread.inl"
+
#endif // BX_THREAD_H_HEADER_GUARD
diff --git a/3rdparty/bx/include/bx/thread.inl b/3rdparty/bx/include/bx/thread.inl
new file mode 100644
index 00000000000..38fc49d0c3a
--- /dev/null
+++ b/3rdparty/bx/include/bx/thread.inl
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#ifndef BX_THREAD_H_HEADER_GUARD
+# error "Must be included from bx/thread.h!"
+#endif // BX_THREAD_H_HEADER_GUARD
+
+#if BX_CONFIG_SUPPORTS_THREADING
+
+namespace bx
+{
+#if BX_PLATFORM_WINDOWS
+ inline TlsData::TlsData()
+ {
+ m_id = TlsAlloc();
+ BX_CHECK(TLS_OUT_OF_INDEXES != m_id, "Failed to allocated TLS index (err: 0x%08x).", GetLastError() );
+ }
+
+ inline TlsData::~TlsData()
+ {
+ BOOL result = TlsFree(m_id);
+ BX_CHECK(0 != result, "Failed to free TLS index (err: 0x%08x).", GetLastError() ); BX_UNUSED(result);
+ }
+
+ inline void* TlsData::get() const
+ {
+ return TlsGetValue(m_id);
+ }
+
+ inline void TlsData::set(void* _ptr)
+ {
+ TlsSetValue(m_id, _ptr);
+ }
+
+#elif !(BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT)
+
+ inline TlsData::TlsData()
+ {
+ int result = pthread_key_create(&m_id, NULL);
+ BX_CHECK(0 == result, "pthread_key_create failed %d.", result); BX_UNUSED(result);
+ }
+
+ inline TlsData::~TlsData()
+ {
+ int result = pthread_key_delete(m_id);
+ BX_CHECK(0 == result, "pthread_key_delete failed %d.", result); BX_UNUSED(result);
+ }
+
+ inline void* TlsData::get() const
+ {
+ return pthread_getspecific(m_id);
+ }
+
+ inline void TlsData::set(void* _ptr)
+ {
+ int result = pthread_setspecific(m_id, _ptr);
+ BX_CHECK(0 == result, "pthread_setspecific failed %d.", result); BX_UNUSED(result);
+ }
+#endif // BX_PLATFORM_*
+
+} // namespace bx
+
+#endif // BX_CONFIG_SUPPORTS_THREADING
diff --git a/3rdparty/bx/include/bx/timer.h b/3rdparty/bx/include/bx/timer.h
index 622e184e968..7b01e2c9974 100644
--- a/3rdparty/bx/include/bx/timer.h
+++ b/3rdparty/bx/include/bx/timer.h
@@ -8,55 +8,16 @@
#include "bx.h"
-#if BX_PLATFORM_ANDROID
-# include <time.h> // clock, clock_gettime
-#elif BX_PLATFORM_EMSCRIPTEN
-# include <emscripten.h>
-#elif BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
-# include <windows.h>
-#else
-# include <sys/time.h> // gettimeofday
-#endif // BX_PLATFORM_
-
namespace bx
{
- inline int64_t getHPCounter()
- {
-#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
- LARGE_INTEGER li;
- // Performance counter value may unexpectedly leap forward
- // http://support.microsoft.com/kb/274323
- QueryPerformanceCounter(&li);
- int64_t i64 = li.QuadPart;
-#elif BX_PLATFORM_ANDROID
- struct timespec now;
- clock_gettime(CLOCK_MONOTONIC, &now);
- int64_t i64 = now.tv_sec*INT64_C(1000000000) + now.tv_nsec;
-#elif BX_PLATFORM_EMSCRIPTEN
- int64_t i64 = int64_t(1000.0f * emscripten_get_now() );
-#else
- struct timeval now;
- gettimeofday(&now, 0);
- int64_t i64 = now.tv_sec*INT64_C(1000000) + now.tv_usec;
-#endif // BX_PLATFORM_
- return i64;
- }
+ ///
+ int64_t getHPCounter();
- inline int64_t getHPFrequency()
- {
-#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
- LARGE_INTEGER li;
- QueryPerformanceFrequency(&li);
- return li.QuadPart;
-#elif BX_PLATFORM_ANDROID
- return INT64_C(1000000000);
-#elif BX_PLATFORM_EMSCRIPTEN
- return INT64_C(1000000);
-#else
- return INT64_C(1000000);
-#endif // BX_PLATFORM_
- }
+ ///
+ int64_t getHPFrequency();
} // namespace bx
+#include "timer.inl"
+
#endif // BX_TIMER_H_HEADER_GUARD
diff --git a/3rdparty/bx/include/bx/timer.inl b/3rdparty/bx/include/bx/timer.inl
new file mode 100644
index 00000000000..d1c609f571a
--- /dev/null
+++ b/3rdparty/bx/include/bx/timer.inl
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#ifndef BX_TIMER_H_HEADER_GUARD
+# error "Must be included from bx/timer.h!"
+#endif // BX_TIMER_H_HEADER_GUARD
+
+#include "bx.h"
+
+#if BX_PLATFORM_ANDROID
+# include <time.h> // clock, clock_gettime
+#elif BX_PLATFORM_EMSCRIPTEN
+# include <emscripten.h>
+#elif BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
+# include <windows.h>
+#else
+# include <sys/time.h> // gettimeofday
+#endif // BX_PLATFORM_
+
+namespace bx
+{
+ inline int64_t getHPCounter()
+ {
+#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
+ LARGE_INTEGER li;
+ // Performance counter value may unexpectedly leap forward
+ // http://support.microsoft.com/kb/274323
+ QueryPerformanceCounter(&li);
+ int64_t i64 = li.QuadPart;
+#elif BX_PLATFORM_ANDROID
+ struct timespec now;
+ clock_gettime(CLOCK_MONOTONIC, &now);
+ int64_t i64 = now.tv_sec*INT64_C(1000000000) + now.tv_nsec;
+#elif BX_PLATFORM_EMSCRIPTEN
+ int64_t i64 = int64_t(1000.0f * emscripten_get_now() );
+#else
+ struct timeval now;
+ gettimeofday(&now, 0);
+ int64_t i64 = now.tv_sec*INT64_C(1000000) + now.tv_usec;
+#endif // BX_PLATFORM_
+ return i64;
+ }
+
+ inline int64_t getHPFrequency()
+ {
+#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
+ LARGE_INTEGER li;
+ QueryPerformanceFrequency(&li);
+ return li.QuadPart;
+#elif BX_PLATFORM_ANDROID
+ return INT64_C(1000000000);
+#elif BX_PLATFORM_EMSCRIPTEN
+ return INT64_C(1000000);
+#else
+ return INT64_C(1000000);
+#endif // BX_PLATFORM_
+ }
+
+} // namespace bx
diff --git a/3rdparty/bx/include/bx/tokenizecmd.h b/3rdparty/bx/include/bx/tokenizecmd.h
deleted file mode 100644
index 0fe2e00b67a..00000000000
--- a/3rdparty/bx/include/bx/tokenizecmd.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright 2012-2017 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
- */
-
-#ifndef BX_TOKENIZE_CMD_H_HEADER_GUARD
-#define BX_TOKENIZE_CMD_H_HEADER_GUARD
-
-#include <stdint.h>
-#include <stdio.h>
-#include <ctype.h>
-
-namespace bx
-{
- // Reference:
- // http://msdn.microsoft.com/en-us/library/a1y7w461.aspx
- static inline const char* tokenizeCommandLine(const char* _commandLine, char* _buffer, uint32_t& _bufferSize, int& _argc, char* _argv[], int _maxArgvs, char _term = '\0')
- {
- int argc = 0;
- const char* curr = _commandLine;
- char* currOut = _buffer;
- char term = ' ';
- bool sub = false;
-
- enum ParserState
- {
- SkipWhitespace,
- SetTerm,
- Copy,
- Escape,
- End,
- };
-
- ParserState state = SkipWhitespace;
-
- while ('\0' != *curr
- && _term != *curr
- && argc < _maxArgvs)
- {
- switch (state)
- {
- case SkipWhitespace:
- for (; isspace(*curr); ++curr) {}; // skip whitespace
- state = SetTerm;
- break;
-
- case SetTerm:
- if ('"' == *curr)
- {
- term = '"';
- ++curr; // skip begining quote
- }
- else
- {
- term = ' ';
- }
-
- _argv[argc] = currOut;
- ++argc;
-
- state = Copy;
- break;
-
- case Copy:
- if ('\\' == *curr)
- {
- state = Escape;
- }
- else if ('"' == *curr
- && '"' != term)
- {
- sub = !sub;
- }
- else if (isspace(*curr) && !sub)
- {
- state = End;
- }
- else if (term != *curr || sub)
- {
- *currOut = *curr;
- ++currOut;
- }
- else
- {
- state = End;
- }
- ++curr;
- break;
-
- case Escape:
- {
- const char* start = --curr;
- for (; '\\' == *curr; ++curr) {};
-
- if ('"' != *curr)
- {
- int count = (int)(curr-start);
-
- curr = start;
- for (int ii = 0; ii < count; ++ii)
- {
- *currOut = *curr;
- ++currOut;
- ++curr;
- }
- }
- else
- {
- curr = start+1;
- *currOut = *curr;
- ++currOut;
- ++curr;
- }
- }
- state = Copy;
- break;
-
- case End:
- *currOut = '\0';
- ++currOut;
- state = SkipWhitespace;
- break;
- }
- }
-
- *currOut = '\0';
- if (0 < argc
- && '\0' == _argv[argc-1][0])
- {
- --argc;
- }
-
- _bufferSize = (uint32_t)(currOut - _buffer);
- _argc = argc;
-
- if ('\0' != *curr)
- {
- ++curr;
- }
-
- return curr;
- }
-
-} // namespace bx
-
-#endif // TOKENIZE_CMD_H_HEADER_GUARD
diff --git a/3rdparty/bx/include/bx/uint32_t.h b/3rdparty/bx/include/bx/uint32_t.h
index a7d6c45ad90..d3b3069fe92 100644
--- a/3rdparty/bx/include/bx/uint32_t.h
+++ b/3rdparty/bx/include/bx/uint32_t.h
@@ -3,26 +3,6 @@
* License: https://github.com/bkaradzic/bx#license-bsd-2-clause
*/
-// Copyright 2006 Mike Acton <macton@gmail.com>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE
-
#ifndef BX_UINT32_T_H_HEADER_GUARD
#define BX_UINT32_T_H_HEADER_GUARD
@@ -30,9 +10,6 @@
#if BX_COMPILER_MSVC
# if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
-# include <math.h> // math.h is included because VS bitches:
- // warning C4985: 'ceil': attributes not present on previous declaration.
- // must be included before intrin.h.
# include <intrin.h>
# pragma intrinsic(_BitScanForward)
# pragma intrinsic(_BitScanReverse)
@@ -50,756 +27,264 @@
namespace bx
{
- inline uint32_t uint32_li(uint32_t _a)
- {
- return _a;
- }
-
- inline uint32_t uint32_dec(uint32_t _a)
- {
- return _a - 1;
- }
-
- inline uint32_t uint32_inc(uint32_t _a)
- {
- return _a + 1;
- }
-
- inline uint32_t uint32_not(uint32_t _a)
- {
- return ~_a;
- }
-
- inline uint32_t uint32_neg(uint32_t _a)
- {
- return -(int32_t)_a;
- }
-
- inline uint32_t uint32_ext(uint32_t _a)
- {
- return ( (int32_t)_a)>>31;
- }
-
- inline uint32_t uint32_and(uint32_t _a, uint32_t _b)
- {
- return _a & _b;
- }
-
- inline uint32_t uint32_andc(uint32_t _a, uint32_t _b)
- {
- return _a & ~_b;
- }
-
- inline uint32_t uint32_xor(uint32_t _a, uint32_t _b)
- {
- return _a ^ _b;
- }
-
- inline uint32_t uint32_xorl(uint32_t _a, uint32_t _b)
- {
- return !_a != !_b;
- }
-
- inline uint32_t uint32_or(uint32_t _a, uint32_t _b)
- {
- return _a | _b;
- }
-
- inline uint32_t uint32_orc(uint32_t _a, uint32_t _b)
- {
- return _a | ~_b;
- }
-
- inline uint32_t uint32_sll(uint32_t _a, int _sa)
- {
- return _a << _sa;
- }
-
- inline uint32_t uint32_srl(uint32_t _a, int _sa)
- {
- return _a >> _sa;
- }
-
- inline uint32_t uint32_sra(uint32_t _a, int _sa)
- {
- return ( (int32_t)_a) >> _sa;
- }
-
- inline uint32_t uint32_rol(uint32_t _a, int _sa)
- {
- return ( _a << _sa) | (_a >> (32-_sa) );
- }
-
- inline uint32_t uint32_ror(uint32_t _a, int _sa)
- {
- return ( _a >> _sa) | (_a << (32-_sa) );
- }
-
- inline uint32_t uint32_add(uint32_t _a, uint32_t _b)
- {
- return _a + _b;
- }
-
- inline uint32_t uint32_sub(uint32_t _a, uint32_t _b)
- {
- return _a - _b;
- }
-
- inline uint32_t uint32_mul(uint32_t _a, uint32_t _b)
- {
- return _a * _b;
- }
-
- inline uint32_t uint32_div(uint32_t _a, uint32_t _b)
- {
- return (_a / _b);
- }
-
- inline uint32_t uint32_mod(uint32_t _a, uint32_t _b)
- {
- return (_a % _b);
- }
-
- inline uint32_t uint32_cmpeq(uint32_t _a, uint32_t _b)
- {
- return -(_a == _b);
- }
-
- inline uint32_t uint32_cmpneq(uint32_t _a, uint32_t _b)
- {
- return -(_a != _b);
- }
-
- inline uint32_t uint32_cmplt(uint32_t _a, uint32_t _b)
- {
- return -(_a < _b);
- }
-
- inline uint32_t uint32_cmple(uint32_t _a, uint32_t _b)
- {
- return -(_a <= _b);
- }
-
- inline uint32_t uint32_cmpgt(uint32_t _a, uint32_t _b)
- {
- return -(_a > _b);
- }
-
- inline uint32_t uint32_cmpge(uint32_t _a, uint32_t _b)
- {
- return -(_a >= _b);
- }
-
- inline uint32_t uint32_setnz(uint32_t _a)
- {
- return -!!_a;
- }
-
- inline uint32_t uint32_satadd(uint32_t _a, uint32_t _b)
- {
- const uint32_t add = uint32_add(_a, _b);
- const uint32_t lt = uint32_cmplt(add, _a);
- const uint32_t result = uint32_or(add, lt);
-
- return result;
- }
-
- inline uint32_t uint32_satsub(uint32_t _a, uint32_t _b)
- {
- const uint32_t sub = uint32_sub(_a, _b);
- const uint32_t le = uint32_cmple(sub, _a);
- const uint32_t result = uint32_and(sub, le);
-
- return result;
- }
-
- inline uint32_t uint32_satmul(uint32_t _a, uint32_t _b)
- {
- const uint64_t mul = (uint64_t)_a * (uint64_t)_b;
- const uint32_t hi = mul >> 32;
- const uint32_t nz = uint32_setnz(hi);
- const uint32_t result = uint32_or(uint32_t(mul), nz);
-
- return result;
- }
-
- inline uint32_t uint32_sels(uint32_t test, uint32_t _a, uint32_t _b)
- {
- const uint32_t mask = uint32_ext(test);
- const uint32_t sel_a = uint32_and(_a, mask);
- const uint32_t sel_b = uint32_andc(_b, mask);
- const uint32_t result = uint32_or(sel_a, sel_b);
-
- return (result);
- }
-
- inline uint32_t uint32_selb(uint32_t _mask, uint32_t _a, uint32_t _b)
- {
- const uint32_t sel_a = uint32_and(_a, _mask);
- const uint32_t sel_b = uint32_andc(_b, _mask);
- const uint32_t result = uint32_or(sel_a, sel_b);
-
- return (result);
- }
-
- inline uint32_t uint32_imin(uint32_t _a, uint32_t _b)
- {
- const uint32_t a_sub_b = uint32_sub(_a, _b);
- const uint32_t result = uint32_sels(a_sub_b, _a, _b);
-
- return result;
- }
-
- inline uint32_t uint32_imax(uint32_t _a, uint32_t _b)
- {
- const uint32_t b_sub_a = uint32_sub(_b, _a);
- const uint32_t result = uint32_sels(b_sub_a, _a, _b);
-
- return result;
- }
-
- inline uint32_t uint32_min(uint32_t _a, uint32_t _b)
- {
- return _a > _b ? _b : _a;
- }
-
- inline uint32_t uint32_min(uint32_t _a, uint32_t _b, uint32_t _c)
- {
- return uint32_min(_a, uint32_min(_b, _c) );
- }
-
- inline uint32_t uint32_max(uint32_t _a, uint32_t _b)
- {
- return _a > _b ? _a : _b;
- }
-
- inline uint32_t uint32_max(uint32_t _a, uint32_t _b, uint32_t _c)
- {
- return uint32_max(_a, uint32_max(_b, _c) );
- }
-
- inline uint32_t uint32_clamp(uint32_t _a, uint32_t _min, uint32_t _max)
- {
- const uint32_t tmp = uint32_max(_a, _min);
- const uint32_t result = uint32_min(tmp, _max);
-
- return result;
- }
-
- inline uint32_t uint32_iclamp(uint32_t _a, uint32_t _min, uint32_t _max)
- {
- const uint32_t tmp = uint32_imax(_a, _min);
- const uint32_t result = uint32_imin(tmp, _max);
-
- return result;
- }
-
- inline uint32_t uint32_incwrap(uint32_t _val, uint32_t _min, uint32_t _max)
- {
- const uint32_t inc = uint32_inc(_val);
- const uint32_t max_diff = uint32_sub(_max, _val);
- const uint32_t neg_max_diff = uint32_neg(max_diff);
- const uint32_t max_or = uint32_or(max_diff, neg_max_diff);
- const uint32_t max_diff_nz = uint32_ext(max_or);
- const uint32_t result = uint32_selb(max_diff_nz, inc, _min);
-
- return result;
- }
-
- inline uint32_t uint32_decwrap(uint32_t _val, uint32_t _min, uint32_t _max)
- {
- const uint32_t dec = uint32_dec(_val);
- const uint32_t min_diff = uint32_sub(_min, _val);
- const uint32_t neg_min_diff = uint32_neg(min_diff);
- const uint32_t min_or = uint32_or(min_diff, neg_min_diff);
- const uint32_t min_diff_nz = uint32_ext(min_or);
- const uint32_t result = uint32_selb(min_diff_nz, dec, _max);
-
- return result;
- }
-
- inline uint32_t uint32_cntbits_ref(uint32_t _val)
- {
- const uint32_t tmp0 = uint32_srl(_val, 1);
- const uint32_t tmp1 = uint32_and(tmp0, 0x55555555);
- const uint32_t tmp2 = uint32_sub(_val, tmp1);
- const uint32_t tmp3 = uint32_and(tmp2, 0xc30c30c3);
- const uint32_t tmp4 = uint32_srl(tmp2, 2);
- const uint32_t tmp5 = uint32_and(tmp4, 0xc30c30c3);
- const uint32_t tmp6 = uint32_srl(tmp2, 4);
- const uint32_t tmp7 = uint32_and(tmp6, 0xc30c30c3);
- const uint32_t tmp8 = uint32_add(tmp3, tmp5);
- const uint32_t tmp9 = uint32_add(tmp7, tmp8);
- const uint32_t tmpA = uint32_srl(tmp9, 6);
- const uint32_t tmpB = uint32_add(tmp9, tmpA);
- const uint32_t tmpC = uint32_srl(tmpB, 12);
- const uint32_t tmpD = uint32_srl(tmpB, 24);
- const uint32_t tmpE = uint32_add(tmpB, tmpC);
- const uint32_t tmpF = uint32_add(tmpD, tmpE);
- const uint32_t result = uint32_and(tmpF, 0x3f);
-
- return result;
- }
+ ///
+ uint32_t uint32_li(uint32_t _a);
+
+ ///
+ uint32_t uint32_dec(uint32_t _a);
+
+ ///
+ uint32_t uint32_inc(uint32_t _a);
+
+ ///
+ uint32_t uint32_not(uint32_t _a);
+
+ ///
+ uint32_t uint32_neg(uint32_t _a);
+
+ ///
+ uint32_t uint32_ext(uint32_t _a);
+
+ ///
+ uint32_t uint32_and(uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_andc(uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_xor(uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_xorl(uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_or(uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_orc(uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_sll(uint32_t _a, int _sa);
+
+ ///
+ uint32_t uint32_srl(uint32_t _a, int _sa);
+
+ ///
+ uint32_t uint32_sra(uint32_t _a, int _sa);
+
+ ///
+ uint32_t uint32_rol(uint32_t _a, int _sa);
+
+ ///
+ uint32_t uint32_ror(uint32_t _a, int _sa);
+
+ ///
+ uint32_t uint32_add(uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_sub(uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_mul(uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_div(uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_mod(uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_cmpeq(uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_cmpneq(uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_cmplt(uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_cmple(uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_cmpgt(uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_cmpge(uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_setnz(uint32_t _a);
+
+ ///
+ uint32_t uint32_satadd(uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_satsub(uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_satmul(uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_sels(uint32_t test, uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_selb(uint32_t _mask, uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_imin(uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_imax(uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_min(uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_min(uint32_t _a, uint32_t _b, uint32_t _c);
+
+ ///
+ uint32_t uint32_max(uint32_t _a, uint32_t _b);
+
+ ///
+ uint32_t uint32_max(uint32_t _a, uint32_t _b, uint32_t _c);
+
+ ///
+ uint32_t uint32_clamp(uint32_t _a, uint32_t _min, uint32_t _max);
+
+ ///
+ uint32_t uint32_iclamp(uint32_t _a, uint32_t _min, uint32_t _max);
+
+ ///
+ uint32_t uint32_incwrap(uint32_t _val, uint32_t _min, uint32_t _max);
+
+ ///
+ uint32_t uint32_decwrap(uint32_t _val, uint32_t _min, uint32_t _max);
+
+ ///
+ uint32_t uint32_cntbits_ref(uint32_t _val);
/// Count number of bits set.
- inline uint32_t uint32_cntbits(uint32_t _val)
- {
-#if BX_COMPILER_GCC || BX_COMPILER_CLANG
- return __builtin_popcount(_val);
-#elif BX_COMPILER_MSVC && BX_PLATFORM_WINDOWS
- return __popcnt(_val);
-#else
- return uint32_cntbits_ref(_val);
-#endif // BX_COMPILER_
- }
-
- inline uint32_t uint32_cntlz_ref(uint32_t _val)
- {
- const uint32_t tmp0 = uint32_srl(_val, 1);
- const uint32_t tmp1 = uint32_or(tmp0, _val);
- const uint32_t tmp2 = uint32_srl(tmp1, 2);
- const uint32_t tmp3 = uint32_or(tmp2, tmp1);
- const uint32_t tmp4 = uint32_srl(tmp3, 4);
- const uint32_t tmp5 = uint32_or(tmp4, tmp3);
- const uint32_t tmp6 = uint32_srl(tmp5, 8);
- const uint32_t tmp7 = uint32_or(tmp6, tmp5);
- const uint32_t tmp8 = uint32_srl(tmp7, 16);
- const uint32_t tmp9 = uint32_or(tmp8, tmp7);
- const uint32_t tmpA = uint32_not(tmp9);
- const uint32_t result = uint32_cntbits(tmpA);
-
- return result;
- }
+ ///
+ uint32_t uint32_cntbits(uint32_t _val);
+
+ ///
+ uint32_t uint32_cntlz_ref(uint32_t _val);
/// Count number of leading zeros.
- inline uint32_t uint32_cntlz(uint32_t _val)
- {
-#if BX_COMPILER_GCC || BX_COMPILER_CLANG
- return __builtin_clz(_val);
-#elif BX_COMPILER_MSVC && BX_PLATFORM_WINDOWS
- unsigned long index;
- _BitScanReverse(&index, _val);
- return 31 - index;
-#else
- return uint32_cntlz_ref(_val);
-#endif // BX_COMPILER_
- }
-
- inline uint32_t uint32_cnttz_ref(uint32_t _val)
- {
- const uint32_t tmp0 = uint32_not(_val);
- const uint32_t tmp1 = uint32_dec(_val);
- const uint32_t tmp2 = uint32_and(tmp0, tmp1);
- const uint32_t result = uint32_cntbits(tmp2);
-
- return result;
- }
-
- inline uint32_t uint32_cnttz(uint32_t _val)
- {
-#if BX_COMPILER_GCC || BX_COMPILER_CLANG
- return __builtin_ctz(_val);
-#elif BX_COMPILER_MSVC && BX_PLATFORM_WINDOWS
- unsigned long index;
- _BitScanForward(&index, _val);
- return index;
-#else
- return uint32_cnttz_ref(_val);
-#endif // BX_COMPILER_
- }
+ ///
+ uint32_t uint32_cntlz(uint32_t _val);
+
+ ///
+ uint32_t uint32_cnttz_ref(uint32_t _val);
+
+ ///
+ uint32_t uint32_cnttz(uint32_t _val);
// shuffle:
// ---- ---- ---- ---- fedc ba98 7654 3210
// to:
// -f-e -d-c -b-a -9-8 -7-6 -5-4 -3-2 -1-0
- inline uint32_t uint32_part1by1(uint32_t _a)
- {
- const uint32_t val = uint32_and(_a, 0xffff);
+ uint32_t uint32_part1by1(uint32_t _a);
- const uint32_t tmp0 = uint32_sll(val, 8);
- const uint32_t tmp1 = uint32_xor(val, tmp0);
- const uint32_t tmp2 = uint32_and(tmp1, 0x00ff00ff);
+ // shuffle:
+ // ---- ---- ---- ---- ---- --98 7654 3210
+ // to:
+ // ---- 9--8 --7- -6-- 5--4 --3- -2-- 1--0
+ ///
+ uint32_t uint32_part1by2(uint32_t _a);
- const uint32_t tmp3 = uint32_sll(tmp2, 4);
- const uint32_t tmp4 = uint32_xor(tmp2, tmp3);
- const uint32_t tmp5 = uint32_and(tmp4, 0x0f0f0f0f);
+ ///
+ uint32_t uint32_testpow2(uint32_t _a);
- const uint32_t tmp6 = uint32_sll(tmp5, 2);
- const uint32_t tmp7 = uint32_xor(tmp5, tmp6);
- const uint32_t tmp8 = uint32_and(tmp7, 0x33333333);
+ ///
+ uint32_t uint32_nextpow2(uint32_t _a);
- const uint32_t tmp9 = uint32_sll(tmp8, 1);
- const uint32_t tmpA = uint32_xor(tmp8, tmp9);
- const uint32_t result = uint32_and(tmpA, 0x55555555);
+ ///
+ uint16_t halfFromFloat(float _a);
- return result;
- }
+ ///
+ float halfToFloat(uint16_t _a);
- // shuffle:
- // ---- ---- ---- ---- ---- --98 7654 3210
- // to:
- // ---- 9--8 --7- -6-- 5--4 --3- -2-- 1--0
- inline uint32_t uint32_part1by2(uint32_t _a)
- {
- const uint32_t val = uint32_and(_a, 0x3ff);
-
- const uint32_t tmp0 = uint32_sll(val, 16);
- const uint32_t tmp1 = uint32_xor(val, tmp0);
- const uint32_t tmp2 = uint32_and(tmp1, 0xff0000ff);
-
- const uint32_t tmp3 = uint32_sll(tmp2, 8);
- const uint32_t tmp4 = uint32_xor(tmp2, tmp3);
- const uint32_t tmp5 = uint32_and(tmp4, 0x0300f00f);
-
- const uint32_t tmp6 = uint32_sll(tmp5, 4);
- const uint32_t tmp7 = uint32_xor(tmp5, tmp6);
- const uint32_t tmp8 = uint32_and(tmp7, 0x030c30c3);
-
- const uint32_t tmp9 = uint32_sll(tmp8, 2);
- const uint32_t tmpA = uint32_xor(tmp8, tmp9);
- const uint32_t result = uint32_and(tmpA, 0x09249249);
-
- return result;
- }
-
- inline uint32_t uint32_testpow2(uint32_t _a)
- {
- const uint32_t tmp0 = uint32_not(_a);
- const uint32_t tmp1 = uint32_inc(tmp0);
- const uint32_t tmp2 = uint32_and(_a, tmp1);
- const uint32_t tmp3 = uint32_cmpeq(tmp2, _a);
- const uint32_t tmp4 = uint32_cmpneq(_a, 0);
- const uint32_t result = uint32_and(tmp3, tmp4);
-
- return result;
- }
-
- inline uint32_t uint32_nextpow2(uint32_t _a)
- {
- const uint32_t tmp0 = uint32_dec(_a);
- const uint32_t tmp1 = uint32_srl(tmp0, 1);
- const uint32_t tmp2 = uint32_or(tmp0, tmp1);
- const uint32_t tmp3 = uint32_srl(tmp2, 2);
- const uint32_t tmp4 = uint32_or(tmp2, tmp3);
- const uint32_t tmp5 = uint32_srl(tmp4, 4);
- const uint32_t tmp6 = uint32_or(tmp4, tmp5);
- const uint32_t tmp7 = uint32_srl(tmp6, 8);
- const uint32_t tmp8 = uint32_or(tmp6, tmp7);
- const uint32_t tmp9 = uint32_srl(tmp8, 16);
- const uint32_t tmpA = uint32_or(tmp8, tmp9);
- const uint32_t result = uint32_inc(tmpA);
-
- return result;
- }
-
- inline uint16_t halfFromFloat(float _a)
- {
- union { uint32_t ui; float flt; } ftou;
- ftou.flt = _a;
-
- const uint32_t one = uint32_li(0x00000001);
- const uint32_t f_s_mask = uint32_li(0x80000000);
- const uint32_t f_e_mask = uint32_li(0x7f800000);
- const uint32_t f_m_mask = uint32_li(0x007fffff);
- const uint32_t f_m_hidden_bit = uint32_li(0x00800000);
- const uint32_t f_m_round_bit = uint32_li(0x00001000);
- const uint32_t f_snan_mask = uint32_li(0x7fc00000);
- const uint32_t f_e_pos = uint32_li(0x00000017);
- const uint32_t h_e_pos = uint32_li(0x0000000a);
- const uint32_t h_e_mask = uint32_li(0x00007c00);
- const uint32_t h_snan_mask = uint32_li(0x00007e00);
- const uint32_t h_e_mask_value = uint32_li(0x0000001f);
- const uint32_t f_h_s_pos_offset = uint32_li(0x00000010);
- const uint32_t f_h_bias_offset = uint32_li(0x00000070);
- const uint32_t f_h_m_pos_offset = uint32_li(0x0000000d);
- const uint32_t h_nan_min = uint32_li(0x00007c01);
- const uint32_t f_h_e_biased_flag = uint32_li(0x0000008f);
- const uint32_t f_s = uint32_and(ftou.ui, f_s_mask);
- const uint32_t f_e = uint32_and(ftou.ui, f_e_mask);
- const uint16_t h_s = (uint16_t)uint32_srl(f_s, f_h_s_pos_offset);
- const uint32_t f_m = uint32_and(ftou.ui, f_m_mask);
- const uint16_t f_e_amount = (uint16_t)uint32_srl(f_e, f_e_pos);
- const uint32_t f_e_half_bias = uint32_sub(f_e_amount, f_h_bias_offset);
- const uint32_t f_snan = uint32_and(ftou.ui, f_snan_mask);
- const uint32_t f_m_round_mask = uint32_and(f_m, f_m_round_bit);
- const uint32_t f_m_round_offset = uint32_sll(f_m_round_mask, one);
- const uint32_t f_m_rounded = uint32_add(f_m, f_m_round_offset);
- const uint32_t f_m_denorm_sa = uint32_sub(one, f_e_half_bias);
- const uint32_t f_m_with_hidden = uint32_or(f_m_rounded, f_m_hidden_bit);
- const uint32_t f_m_denorm = uint32_srl(f_m_with_hidden, f_m_denorm_sa);
- const uint32_t h_m_denorm = uint32_srl(f_m_denorm, f_h_m_pos_offset);
- const uint32_t f_m_rounded_overflow = uint32_and(f_m_rounded, f_m_hidden_bit);
- const uint32_t m_nan = uint32_srl(f_m, f_h_m_pos_offset);
- const uint32_t h_em_nan = uint32_or(h_e_mask, m_nan);
- const uint32_t h_e_norm_overflow_offset = uint32_inc(f_e_half_bias);
- const uint32_t h_e_norm_overflow = uint32_sll(h_e_norm_overflow_offset, h_e_pos);
- const uint32_t h_e_norm = uint32_sll(f_e_half_bias, h_e_pos);
- const uint32_t h_m_norm = uint32_srl(f_m_rounded, f_h_m_pos_offset);
- const uint32_t h_em_norm = uint32_or(h_e_norm, h_m_norm);
- const uint32_t is_h_ndenorm_msb = uint32_sub(f_h_bias_offset, f_e_amount);
- const uint32_t is_f_e_flagged_msb = uint32_sub(f_h_e_biased_flag, f_e_half_bias);
- const uint32_t is_h_denorm_msb = uint32_not(is_h_ndenorm_msb);
- const uint32_t is_f_m_eqz_msb = uint32_dec(f_m);
- const uint32_t is_h_nan_eqz_msb = uint32_dec(m_nan);
- const uint32_t is_f_inf_msb = uint32_and(is_f_e_flagged_msb, is_f_m_eqz_msb);
- const uint32_t is_f_nan_underflow_msb = uint32_and(is_f_e_flagged_msb, is_h_nan_eqz_msb);
- const uint32_t is_e_overflow_msb = uint32_sub(h_e_mask_value, f_e_half_bias);
- const uint32_t is_h_inf_msb = uint32_or(is_e_overflow_msb, is_f_inf_msb);
- const uint32_t is_f_nsnan_msb = uint32_sub(f_snan, f_snan_mask);
- const uint32_t is_m_norm_overflow_msb = uint32_neg(f_m_rounded_overflow);
- const uint32_t is_f_snan_msb = uint32_not(is_f_nsnan_msb);
- const uint32_t h_em_overflow_result = uint32_sels(is_m_norm_overflow_msb, h_e_norm_overflow, h_em_norm);
- const uint32_t h_em_nan_result = uint32_sels(is_f_e_flagged_msb, h_em_nan, h_em_overflow_result);
- const uint32_t h_em_nan_underflow_result = uint32_sels(is_f_nan_underflow_msb, h_nan_min, h_em_nan_result);
- const uint32_t h_em_inf_result = uint32_sels(is_h_inf_msb, h_e_mask, h_em_nan_underflow_result);
- const uint32_t h_em_denorm_result = uint32_sels(is_h_denorm_msb, h_m_denorm, h_em_inf_result);
- const uint32_t h_em_snan_result = uint32_sels(is_f_snan_msb, h_snan_mask, h_em_denorm_result);
- const uint32_t h_result = uint32_or(h_s, h_em_snan_result);
-
- return (uint16_t)(h_result);
- }
-
- inline float halfToFloat(uint16_t _a)
- {
- const uint32_t h_e_mask = uint32_li(0x00007c00);
- const uint32_t h_m_mask = uint32_li(0x000003ff);
- const uint32_t h_s_mask = uint32_li(0x00008000);
- const uint32_t h_f_s_pos_offset = uint32_li(0x00000010);
- const uint32_t h_f_e_pos_offset = uint32_li(0x0000000d);
- const uint32_t h_f_bias_offset = uint32_li(0x0001c000);
- const uint32_t f_e_mask = uint32_li(0x7f800000);
- const uint32_t f_m_mask = uint32_li(0x007fffff);
- const uint32_t h_f_e_denorm_bias = uint32_li(0x0000007e);
- const uint32_t h_f_m_denorm_sa_bias = uint32_li(0x00000008);
- const uint32_t f_e_pos = uint32_li(0x00000017);
- const uint32_t h_e_mask_minus_one = uint32_li(0x00007bff);
- const uint32_t h_e = uint32_and(_a, h_e_mask);
- const uint32_t h_m = uint32_and(_a, h_m_mask);
- const uint32_t h_s = uint32_and(_a, h_s_mask);
- const uint32_t h_e_f_bias = uint32_add(h_e, h_f_bias_offset);
- const uint32_t h_m_nlz = uint32_cntlz(h_m);
- const uint32_t f_s = uint32_sll(h_s, h_f_s_pos_offset);
- const uint32_t f_e = uint32_sll(h_e_f_bias, h_f_e_pos_offset);
- const uint32_t f_m = uint32_sll(h_m, h_f_e_pos_offset);
- const uint32_t f_em = uint32_or(f_e, f_m);
- const uint32_t h_f_m_sa = uint32_sub(h_m_nlz, h_f_m_denorm_sa_bias);
- const uint32_t f_e_denorm_unpacked = uint32_sub(h_f_e_denorm_bias, h_f_m_sa);
- const uint32_t h_f_m = uint32_sll(h_m, h_f_m_sa);
- const uint32_t f_m_denorm = uint32_and(h_f_m, f_m_mask);
- const uint32_t f_e_denorm = uint32_sll(f_e_denorm_unpacked, f_e_pos);
- const uint32_t f_em_denorm = uint32_or(f_e_denorm, f_m_denorm);
- const uint32_t f_em_nan = uint32_or(f_e_mask, f_m);
- const uint32_t is_e_eqz_msb = uint32_dec(h_e);
- const uint32_t is_m_nez_msb = uint32_neg(h_m);
- const uint32_t is_e_flagged_msb = uint32_sub(h_e_mask_minus_one, h_e);
- const uint32_t is_zero_msb = uint32_andc(is_e_eqz_msb, is_m_nez_msb);
- const uint32_t is_inf_msb = uint32_andc(is_e_flagged_msb, is_m_nez_msb);
- const uint32_t is_denorm_msb = uint32_and(is_m_nez_msb, is_e_eqz_msb);
- const uint32_t is_nan_msb = uint32_and(is_e_flagged_msb, is_m_nez_msb);
- const uint32_t is_zero = uint32_ext(is_zero_msb);
- const uint32_t f_zero_result = uint32_andc(f_em, is_zero);
- const uint32_t f_denorm_result = uint32_sels(is_denorm_msb, f_em_denorm, f_zero_result);
- const uint32_t f_inf_result = uint32_sels(is_inf_msb, f_e_mask, f_denorm_result);
- const uint32_t f_nan_result = uint32_sels(is_nan_msb, f_em_nan, f_inf_result);
- const uint32_t f_result = uint32_or(f_s, f_nan_result);
-
- union { uint32_t ui; float flt; } utof;
- utof.ui = f_result;
- return utof.flt;
- }
-
- inline uint16_t uint16_min(uint16_t _a, uint16_t _b)
- {
- return _a > _b ? _b : _a;
- }
-
- inline uint16_t uint16_max(uint16_t _a, uint16_t _b)
- {
- return _a < _b ? _b : _a;
- }
-
- inline int64_t int64_min(int64_t _a, int64_t _b)
- {
- return _a < _b ? _a : _b;
- }
-
- inline int64_t int64_max(int64_t _a, int64_t _b)
- {
- return _a > _b ? _a : _b;
- }
-
- inline int64_t int64_clamp(int64_t _a, int64_t _min, int64_t _max)
- {
- const int64_t min = int64_min(_a, _max);
- const int64_t result = int64_max(_min, min);
-
- return result;
- }
-
- inline uint64_t uint64_cntbits_ref(uint64_t _val)
- {
- const uint32_t lo = uint32_t(_val&UINT32_MAX);
- const uint32_t hi = uint32_t(_val>>32);
-
- const uint32_t total = bx::uint32_cntbits(lo)
- + bx::uint32_cntbits(hi);
-
- return total;
- }
+ ///
+ uint16_t uint16_min(uint16_t _a, uint16_t _b);
+
+ ///
+ uint16_t uint16_max(uint16_t _a, uint16_t _b);
+
+ ///
+ int64_t int64_min(int64_t _a, int64_t _b);
+
+ ///
+ int64_t int64_max(int64_t _a, int64_t _b);
+
+ ///
+ int64_t int64_clamp(int64_t _a, int64_t _min, int64_t _max);
+
+ ///
+ uint32_t uint64_cntbits_ref(uint64_t _val);
/// Count number of bits set.
- inline uint64_t uint64_cntbits(uint64_t _val)
- {
-#if BX_COMPILER_GCC || BX_COMPILER_CLANG
- return __builtin_popcountll(_val);
-#elif BX_COMPILER_MSVC && BX_ARCH_64BIT
- return __popcnt64(_val);
-#else
- return uint64_cntbits_ref(_val);
-#endif // BX_COMPILER_
- }
-
- inline uint64_t uint64_cntlz_ref(uint64_t _val)
- {
- return _val & UINT64_C(0xffffffff00000000)
- ? uint32_cntlz(uint32_t(_val>>32) )
- : uint32_cntlz(uint32_t(_val) ) + 32
- ;
- }
+ ///
+ uint32_t uint64_cntbits(uint64_t _val);
+
+ ///
+ uint32_t uint64_cntlz_ref(uint64_t _val);
/// Count number of leading zeros.
- inline uint64_t uint64_cntlz(uint64_t _val)
- {
-#if BX_COMPILER_GCC || BX_COMPILER_CLANG
- return __builtin_clzll(_val);
-#elif BX_COMPILER_MSVC && BX_PLATFORM_WINDOWS && BX_ARCH_64BIT
- unsigned long index;
- _BitScanReverse64(&index, _val);
- return 63 - index;
-#else
- return uint64_cntlz_ref(_val);
-#endif // BX_COMPILER_
- }
-
- inline uint64_t uint64_cnttz_ref(uint64_t _val)
- {
- return _val & UINT64_C(0xffffffff)
- ? uint32_cnttz(uint32_t(_val) )
- : uint32_cnttz(uint32_t(_val>>32) ) + 32
- ;
- }
-
- inline uint64_t uint64_cnttz(uint64_t _val)
- {
-#if BX_COMPILER_GCC || BX_COMPILER_CLANG
- return __builtin_ctzll(_val);
-#elif BX_COMPILER_MSVC && BX_PLATFORM_WINDOWS && BX_ARCH_64BIT
- unsigned long index;
- _BitScanForward64(&index, _val);
- return index;
-#else
- return uint64_cnttz_ref(_val);
-#endif // BX_COMPILER_
- }
-
- inline uint64_t uint64_sll(uint64_t _a, int _sa)
- {
- return _a << _sa;
- }
-
- inline uint64_t uint64_srl(uint64_t _a, int _sa)
- {
- return _a >> _sa;
- }
-
- inline uint64_t uint64_sra(uint64_t _a, int _sa)
- {
- return ( (int64_t)_a) >> _sa;
- }
-
- inline uint64_t uint64_rol(uint64_t _a, int _sa)
- {
- return ( _a << _sa) | (_a >> (32-_sa) );
- }
-
- inline uint64_t uint64_ror(uint64_t _a, int _sa)
- {
- return ( _a >> _sa) | (_a << (32-_sa) );
- }
-
- inline uint64_t uint64_add(uint64_t _a, uint64_t _b)
- {
- return _a + _b;
- }
-
- inline uint64_t uint64_sub(uint64_t _a, uint64_t _b)
- {
- return _a - _b;
- }
-
- inline uint64_t uint64_mul(uint64_t _a, uint64_t _b)
- {
- return _a * _b;
- }
+ ///
+ uint32_t uint64_cntlz(uint64_t _val);
+
+ ///
+ uint32_t uint64_cnttz_ref(uint64_t _val);
+
+ ///
+ uint32_t uint64_cnttz(uint64_t _val);
+
+ ///
+ uint64_t uint64_sll(uint64_t _a, int _sa);
+
+ ///
+ uint64_t uint64_srl(uint64_t _a, int _sa);
+
+ ///
+ uint64_t uint64_sra(uint64_t _a, int _sa);
+
+ ///
+ uint64_t uint64_rol(uint64_t _a, int _sa);
+
+ ///
+ uint64_t uint64_ror(uint64_t _a, int _sa);
+
+ ///
+ uint64_t uint64_add(uint64_t _a, uint64_t _b);
+
+ ///
+ uint64_t uint64_sub(uint64_t _a, uint64_t _b);
+
+ ///
+ uint64_t uint64_mul(uint64_t _a, uint64_t _b);
/// Greatest common divisor.
- inline uint32_t uint32_gcd(uint32_t _a, uint32_t _b)
- {
- do
- {
- uint32_t tmp = _a % _b;
- _a = _b;
- _b = tmp;
- }
- while (_b);
-
- return _a;
- }
+ ///
+ uint32_t uint32_gcd(uint32_t _a, uint32_t _b);
/// Least common multiple.
- inline uint32_t uint32_lcm(uint32_t _a, uint32_t _b)
- {
- return _a * (_b / uint32_gcd(_a, _b) );
- }
+ ///
+ uint32_t uint32_lcm(uint32_t _a, uint32_t _b);
/// Align to arbitrary stride.
- inline uint32_t strideAlign(uint32_t _offset, uint32_t _stride)
- {
- const uint32_t mod = uint32_mod(_offset, _stride);
- const uint32_t add = uint32_sub(_stride, mod);
- const uint32_t mask = uint32_cmpeq(mod, 0);
- const uint32_t tmp = uint32_selb(mask, 0, add);
- const uint32_t result = uint32_add(_offset, tmp);
-
- return result;
- }
+ ///
+ uint32_t strideAlign(uint32_t _offset, uint32_t _stride);
/// Align to arbitrary stride and 16-bytes.
- inline uint32_t strideAlign16(uint32_t _offset, uint32_t _stride)
- {
- const uint32_t align = uint32_lcm(16, _stride);
- const uint32_t mod = uint32_mod(_offset, align);
- const uint32_t mask = uint32_cmpeq(mod, 0);
- const uint32_t tmp0 = uint32_selb(mask, 0, align);
- const uint32_t tmp1 = uint32_add(_offset, tmp0);
- const uint32_t result = uint32_sub(tmp1, mod);
-
- return result;
- }
+ ///
+ uint32_t strideAlign16(uint32_t _offset, uint32_t _stride);
/// Align to arbitrary stride and 256-bytes.
- inline uint32_t strideAlign256(uint32_t _offset, uint32_t _stride)
- {
- const uint32_t align = uint32_lcm(256, _stride);
- const uint32_t mod = uint32_mod(_offset, align);
- const uint32_t mask = uint32_cmpeq(mod, 0);
- const uint32_t tmp0 = uint32_selb(mask, 0, align);
- const uint32_t tmp1 = uint32_add(_offset, tmp0);
- const uint32_t result = uint32_sub(tmp1, mod);
-
- return result;
- }
+ ///
+ uint32_t strideAlign256(uint32_t _offset, uint32_t _stride);
} // namespace bx
+#include "uint32_t.inl"
+
#endif // BX_UINT32_T_H_HEADER_GUARD
diff --git a/3rdparty/bx/include/bx/uint32_t.inl b/3rdparty/bx/include/bx/uint32_t.inl
new file mode 100644
index 00000000000..8a66a07ca2d
--- /dev/null
+++ b/3rdparty/bx/include/bx/uint32_t.inl
@@ -0,0 +1,781 @@
+/*
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+// Copyright 2006 Mike Acton <macton@gmail.com>
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE
+
+#ifndef BX_UINT32_T_H_HEADER_GUARD
+# error "Must be included from bx/uint32_t.h"
+#endif // BX_UINT32_T_H_HEADER_GUARD
+
+namespace bx
+{
+ inline uint32_t uint32_li(uint32_t _a)
+ {
+ return _a;
+ }
+
+ inline uint32_t uint32_dec(uint32_t _a)
+ {
+ return _a - 1;
+ }
+
+ inline uint32_t uint32_inc(uint32_t _a)
+ {
+ return _a + 1;
+ }
+
+ inline uint32_t uint32_not(uint32_t _a)
+ {
+ return ~_a;
+ }
+
+ inline uint32_t uint32_neg(uint32_t _a)
+ {
+ return -(int32_t)_a;
+ }
+
+ inline uint32_t uint32_ext(uint32_t _a)
+ {
+ return ( (int32_t)_a)>>31;
+ }
+
+ inline uint32_t uint32_and(uint32_t _a, uint32_t _b)
+ {
+ return _a & _b;
+ }
+
+ inline uint32_t uint32_andc(uint32_t _a, uint32_t _b)
+ {
+ return _a & ~_b;
+ }
+
+ inline uint32_t uint32_xor(uint32_t _a, uint32_t _b)
+ {
+ return _a ^ _b;
+ }
+
+ inline uint32_t uint32_xorl(uint32_t _a, uint32_t _b)
+ {
+ return !_a != !_b;
+ }
+
+ inline uint32_t uint32_or(uint32_t _a, uint32_t _b)
+ {
+ return _a | _b;
+ }
+
+ inline uint32_t uint32_orc(uint32_t _a, uint32_t _b)
+ {
+ return _a | ~_b;
+ }
+
+ inline uint32_t uint32_sll(uint32_t _a, int _sa)
+ {
+ return _a << _sa;
+ }
+
+ inline uint32_t uint32_srl(uint32_t _a, int _sa)
+ {
+ return _a >> _sa;
+ }
+
+ inline uint32_t uint32_sra(uint32_t _a, int _sa)
+ {
+ return ( (int32_t)_a) >> _sa;
+ }
+
+ inline uint32_t uint32_rol(uint32_t _a, int _sa)
+ {
+ return ( _a << _sa) | (_a >> (32-_sa) );
+ }
+
+ inline uint32_t uint32_ror(uint32_t _a, int _sa)
+ {
+ return ( _a >> _sa) | (_a << (32-_sa) );
+ }
+
+ inline uint32_t uint32_add(uint32_t _a, uint32_t _b)
+ {
+ return _a + _b;
+ }
+
+ inline uint32_t uint32_sub(uint32_t _a, uint32_t _b)
+ {
+ return _a - _b;
+ }
+
+ inline uint32_t uint32_mul(uint32_t _a, uint32_t _b)
+ {
+ return _a * _b;
+ }
+
+ inline uint32_t uint32_div(uint32_t _a, uint32_t _b)
+ {
+ return (_a / _b);
+ }
+
+ inline uint32_t uint32_mod(uint32_t _a, uint32_t _b)
+ {
+ return (_a % _b);
+ }
+
+ inline uint32_t uint32_cmpeq(uint32_t _a, uint32_t _b)
+ {
+ return -(_a == _b);
+ }
+
+ inline uint32_t uint32_cmpneq(uint32_t _a, uint32_t _b)
+ {
+ return -(_a != _b);
+ }
+
+ inline uint32_t uint32_cmplt(uint32_t _a, uint32_t _b)
+ {
+ return -(_a < _b);
+ }
+
+ inline uint32_t uint32_cmple(uint32_t _a, uint32_t _b)
+ {
+ return -(_a <= _b);
+ }
+
+ inline uint32_t uint32_cmpgt(uint32_t _a, uint32_t _b)
+ {
+ return -(_a > _b);
+ }
+
+ inline uint32_t uint32_cmpge(uint32_t _a, uint32_t _b)
+ {
+ return -(_a >= _b);
+ }
+
+ inline uint32_t uint32_setnz(uint32_t _a)
+ {
+ return -!!_a;
+ }
+
+ inline uint32_t uint32_satadd(uint32_t _a, uint32_t _b)
+ {
+ const uint32_t add = uint32_add(_a, _b);
+ const uint32_t lt = uint32_cmplt(add, _a);
+ const uint32_t result = uint32_or(add, lt);
+
+ return result;
+ }
+
+ inline uint32_t uint32_satsub(uint32_t _a, uint32_t _b)
+ {
+ const uint32_t sub = uint32_sub(_a, _b);
+ const uint32_t le = uint32_cmple(sub, _a);
+ const uint32_t result = uint32_and(sub, le);
+
+ return result;
+ }
+
+ inline uint32_t uint32_satmul(uint32_t _a, uint32_t _b)
+ {
+ const uint64_t mul = (uint64_t)_a * (uint64_t)_b;
+ const uint32_t hi = mul >> 32;
+ const uint32_t nz = uint32_setnz(hi);
+ const uint32_t result = uint32_or(uint32_t(mul), nz);
+
+ return result;
+ }
+
+ inline uint32_t uint32_sels(uint32_t test, uint32_t _a, uint32_t _b)
+ {
+ const uint32_t mask = uint32_ext(test);
+ const uint32_t sel_a = uint32_and(_a, mask);
+ const uint32_t sel_b = uint32_andc(_b, mask);
+ const uint32_t result = uint32_or(sel_a, sel_b);
+
+ return (result);
+ }
+
+ inline uint32_t uint32_selb(uint32_t _mask, uint32_t _a, uint32_t _b)
+ {
+ const uint32_t sel_a = uint32_and(_a, _mask);
+ const uint32_t sel_b = uint32_andc(_b, _mask);
+ const uint32_t result = uint32_or(sel_a, sel_b);
+
+ return (result);
+ }
+
+ inline uint32_t uint32_imin(uint32_t _a, uint32_t _b)
+ {
+ const uint32_t a_sub_b = uint32_sub(_a, _b);
+ const uint32_t result = uint32_sels(a_sub_b, _a, _b);
+
+ return result;
+ }
+
+ inline uint32_t uint32_imax(uint32_t _a, uint32_t _b)
+ {
+ const uint32_t b_sub_a = uint32_sub(_b, _a);
+ const uint32_t result = uint32_sels(b_sub_a, _a, _b);
+
+ return result;
+ }
+
+ inline uint32_t uint32_min(uint32_t _a, uint32_t _b)
+ {
+ return _a > _b ? _b : _a;
+ }
+
+ inline uint32_t uint32_min(uint32_t _a, uint32_t _b, uint32_t _c)
+ {
+ return uint32_min(_a, uint32_min(_b, _c) );
+ }
+
+ inline uint32_t uint32_max(uint32_t _a, uint32_t _b)
+ {
+ return _a > _b ? _a : _b;
+ }
+
+ inline uint32_t uint32_max(uint32_t _a, uint32_t _b, uint32_t _c)
+ {
+ return uint32_max(_a, uint32_max(_b, _c) );
+ }
+
+ inline uint32_t uint32_clamp(uint32_t _a, uint32_t _min, uint32_t _max)
+ {
+ const uint32_t tmp = uint32_max(_a, _min);
+ const uint32_t result = uint32_min(tmp, _max);
+
+ return result;
+ }
+
+ inline uint32_t uint32_iclamp(uint32_t _a, uint32_t _min, uint32_t _max)
+ {
+ const uint32_t tmp = uint32_imax(_a, _min);
+ const uint32_t result = uint32_imin(tmp, _max);
+
+ return result;
+ }
+
+ inline uint32_t uint32_incwrap(uint32_t _val, uint32_t _min, uint32_t _max)
+ {
+ const uint32_t inc = uint32_inc(_val);
+ const uint32_t max_diff = uint32_sub(_max, _val);
+ const uint32_t neg_max_diff = uint32_neg(max_diff);
+ const uint32_t max_or = uint32_or(max_diff, neg_max_diff);
+ const uint32_t max_diff_nz = uint32_ext(max_or);
+ const uint32_t result = uint32_selb(max_diff_nz, inc, _min);
+
+ return result;
+ }
+
+ inline uint32_t uint32_decwrap(uint32_t _val, uint32_t _min, uint32_t _max)
+ {
+ const uint32_t dec = uint32_dec(_val);
+ const uint32_t min_diff = uint32_sub(_min, _val);
+ const uint32_t neg_min_diff = uint32_neg(min_diff);
+ const uint32_t min_or = uint32_or(min_diff, neg_min_diff);
+ const uint32_t min_diff_nz = uint32_ext(min_or);
+ const uint32_t result = uint32_selb(min_diff_nz, dec, _max);
+
+ return result;
+ }
+
+ inline uint32_t uint32_cntbits_ref(uint32_t _val)
+ {
+ const uint32_t tmp0 = uint32_srl(_val, 1);
+ const uint32_t tmp1 = uint32_and(tmp0, 0x55555555);
+ const uint32_t tmp2 = uint32_sub(_val, tmp1);
+ const uint32_t tmp3 = uint32_and(tmp2, 0xc30c30c3);
+ const uint32_t tmp4 = uint32_srl(tmp2, 2);
+ const uint32_t tmp5 = uint32_and(tmp4, 0xc30c30c3);
+ const uint32_t tmp6 = uint32_srl(tmp2, 4);
+ const uint32_t tmp7 = uint32_and(tmp6, 0xc30c30c3);
+ const uint32_t tmp8 = uint32_add(tmp3, tmp5);
+ const uint32_t tmp9 = uint32_add(tmp7, tmp8);
+ const uint32_t tmpA = uint32_srl(tmp9, 6);
+ const uint32_t tmpB = uint32_add(tmp9, tmpA);
+ const uint32_t tmpC = uint32_srl(tmpB, 12);
+ const uint32_t tmpD = uint32_srl(tmpB, 24);
+ const uint32_t tmpE = uint32_add(tmpB, tmpC);
+ const uint32_t tmpF = uint32_add(tmpD, tmpE);
+ const uint32_t result = uint32_and(tmpF, 0x3f);
+
+ return result;
+ }
+
+ /// Count number of bits set.
+ inline uint32_t uint32_cntbits(uint32_t _val)
+ {
+#if BX_COMPILER_GCC || BX_COMPILER_CLANG
+ return __builtin_popcount(_val);
+#elif BX_COMPILER_MSVC && BX_PLATFORM_WINDOWS
+ return __popcnt(_val);
+#else
+ return uint32_cntbits_ref(_val);
+#endif // BX_COMPILER_
+ }
+
+ inline uint32_t uint32_cntlz_ref(uint32_t _val)
+ {
+ const uint32_t tmp0 = uint32_srl(_val, 1);
+ const uint32_t tmp1 = uint32_or(tmp0, _val);
+ const uint32_t tmp2 = uint32_srl(tmp1, 2);
+ const uint32_t tmp3 = uint32_or(tmp2, tmp1);
+ const uint32_t tmp4 = uint32_srl(tmp3, 4);
+ const uint32_t tmp5 = uint32_or(tmp4, tmp3);
+ const uint32_t tmp6 = uint32_srl(tmp5, 8);
+ const uint32_t tmp7 = uint32_or(tmp6, tmp5);
+ const uint32_t tmp8 = uint32_srl(tmp7, 16);
+ const uint32_t tmp9 = uint32_or(tmp8, tmp7);
+ const uint32_t tmpA = uint32_not(tmp9);
+ const uint32_t result = uint32_cntbits(tmpA);
+
+ return result;
+ }
+
+ /// Count number of leading zeros.
+ inline uint32_t uint32_cntlz(uint32_t _val)
+ {
+#if BX_COMPILER_GCC || BX_COMPILER_CLANG
+ return __builtin_clz(_val);
+#elif BX_COMPILER_MSVC && BX_PLATFORM_WINDOWS
+ unsigned long index;
+ _BitScanReverse(&index, _val);
+ return 31 - index;
+#else
+ return uint32_cntlz_ref(_val);
+#endif // BX_COMPILER_
+ }
+
+ inline uint32_t uint32_cnttz_ref(uint32_t _val)
+ {
+ const uint32_t tmp0 = uint32_not(_val);
+ const uint32_t tmp1 = uint32_dec(_val);
+ const uint32_t tmp2 = uint32_and(tmp0, tmp1);
+ const uint32_t result = uint32_cntbits(tmp2);
+
+ return result;
+ }
+
+ inline uint32_t uint32_cnttz(uint32_t _val)
+ {
+#if BX_COMPILER_GCC || BX_COMPILER_CLANG
+ return __builtin_ctz(_val);
+#elif BX_COMPILER_MSVC && BX_PLATFORM_WINDOWS
+ unsigned long index;
+ _BitScanForward(&index, _val);
+ return index;
+#else
+ return uint32_cnttz_ref(_val);
+#endif // BX_COMPILER_
+ }
+
+ // shuffle:
+ // ---- ---- ---- ---- fedc ba98 7654 3210
+ // to:
+ // -f-e -d-c -b-a -9-8 -7-6 -5-4 -3-2 -1-0
+ inline uint32_t uint32_part1by1(uint32_t _a)
+ {
+ const uint32_t val = uint32_and(_a, 0xffff);
+
+ const uint32_t tmp0 = uint32_sll(val, 8);
+ const uint32_t tmp1 = uint32_xor(val, tmp0);
+ const uint32_t tmp2 = uint32_and(tmp1, 0x00ff00ff);
+
+ const uint32_t tmp3 = uint32_sll(tmp2, 4);
+ const uint32_t tmp4 = uint32_xor(tmp2, tmp3);
+ const uint32_t tmp5 = uint32_and(tmp4, 0x0f0f0f0f);
+
+ const uint32_t tmp6 = uint32_sll(tmp5, 2);
+ const uint32_t tmp7 = uint32_xor(tmp5, tmp6);
+ const uint32_t tmp8 = uint32_and(tmp7, 0x33333333);
+
+ const uint32_t tmp9 = uint32_sll(tmp8, 1);
+ const uint32_t tmpA = uint32_xor(tmp8, tmp9);
+ const uint32_t result = uint32_and(tmpA, 0x55555555);
+
+ return result;
+ }
+
+ // shuffle:
+ // ---- ---- ---- ---- ---- --98 7654 3210
+ // to:
+ // ---- 9--8 --7- -6-- 5--4 --3- -2-- 1--0
+ inline uint32_t uint32_part1by2(uint32_t _a)
+ {
+ const uint32_t val = uint32_and(_a, 0x3ff);
+
+ const uint32_t tmp0 = uint32_sll(val, 16);
+ const uint32_t tmp1 = uint32_xor(val, tmp0);
+ const uint32_t tmp2 = uint32_and(tmp1, 0xff0000ff);
+
+ const uint32_t tmp3 = uint32_sll(tmp2, 8);
+ const uint32_t tmp4 = uint32_xor(tmp2, tmp3);
+ const uint32_t tmp5 = uint32_and(tmp4, 0x0300f00f);
+
+ const uint32_t tmp6 = uint32_sll(tmp5, 4);
+ const uint32_t tmp7 = uint32_xor(tmp5, tmp6);
+ const uint32_t tmp8 = uint32_and(tmp7, 0x030c30c3);
+
+ const uint32_t tmp9 = uint32_sll(tmp8, 2);
+ const uint32_t tmpA = uint32_xor(tmp8, tmp9);
+ const uint32_t result = uint32_and(tmpA, 0x09249249);
+
+ return result;
+ }
+
+ inline uint32_t uint32_testpow2(uint32_t _a)
+ {
+ const uint32_t tmp0 = uint32_not(_a);
+ const uint32_t tmp1 = uint32_inc(tmp0);
+ const uint32_t tmp2 = uint32_and(_a, tmp1);
+ const uint32_t tmp3 = uint32_cmpeq(tmp2, _a);
+ const uint32_t tmp4 = uint32_cmpneq(_a, 0);
+ const uint32_t result = uint32_and(tmp3, tmp4);
+
+ return result;
+ }
+
+ inline uint32_t uint32_nextpow2(uint32_t _a)
+ {
+ const uint32_t tmp0 = uint32_dec(_a);
+ const uint32_t tmp1 = uint32_srl(tmp0, 1);
+ const uint32_t tmp2 = uint32_or(tmp0, tmp1);
+ const uint32_t tmp3 = uint32_srl(tmp2, 2);
+ const uint32_t tmp4 = uint32_or(tmp2, tmp3);
+ const uint32_t tmp5 = uint32_srl(tmp4, 4);
+ const uint32_t tmp6 = uint32_or(tmp4, tmp5);
+ const uint32_t tmp7 = uint32_srl(tmp6, 8);
+ const uint32_t tmp8 = uint32_or(tmp6, tmp7);
+ const uint32_t tmp9 = uint32_srl(tmp8, 16);
+ const uint32_t tmpA = uint32_or(tmp8, tmp9);
+ const uint32_t result = uint32_inc(tmpA);
+
+ return result;
+ }
+
+ inline uint16_t halfFromFloat(float _a)
+ {
+ union { uint32_t ui; float flt; } ftou;
+ ftou.flt = _a;
+
+ const uint32_t one = uint32_li(0x00000001);
+ const uint32_t f_s_mask = uint32_li(0x80000000);
+ const uint32_t f_e_mask = uint32_li(0x7f800000);
+ const uint32_t f_m_mask = uint32_li(0x007fffff);
+ const uint32_t f_m_hidden_bit = uint32_li(0x00800000);
+ const uint32_t f_m_round_bit = uint32_li(0x00001000);
+ const uint32_t f_snan_mask = uint32_li(0x7fc00000);
+ const uint32_t f_e_pos = uint32_li(0x00000017);
+ const uint32_t h_e_pos = uint32_li(0x0000000a);
+ const uint32_t h_e_mask = uint32_li(0x00007c00);
+ const uint32_t h_snan_mask = uint32_li(0x00007e00);
+ const uint32_t h_e_mask_value = uint32_li(0x0000001f);
+ const uint32_t f_h_s_pos_offset = uint32_li(0x00000010);
+ const uint32_t f_h_bias_offset = uint32_li(0x00000070);
+ const uint32_t f_h_m_pos_offset = uint32_li(0x0000000d);
+ const uint32_t h_nan_min = uint32_li(0x00007c01);
+ const uint32_t f_h_e_biased_flag = uint32_li(0x0000008f);
+ const uint32_t f_s = uint32_and(ftou.ui, f_s_mask);
+ const uint32_t f_e = uint32_and(ftou.ui, f_e_mask);
+ const uint16_t h_s = (uint16_t)uint32_srl(f_s, f_h_s_pos_offset);
+ const uint32_t f_m = uint32_and(ftou.ui, f_m_mask);
+ const uint16_t f_e_amount = (uint16_t)uint32_srl(f_e, f_e_pos);
+ const uint32_t f_e_half_bias = uint32_sub(f_e_amount, f_h_bias_offset);
+ const uint32_t f_snan = uint32_and(ftou.ui, f_snan_mask);
+ const uint32_t f_m_round_mask = uint32_and(f_m, f_m_round_bit);
+ const uint32_t f_m_round_offset = uint32_sll(f_m_round_mask, one);
+ const uint32_t f_m_rounded = uint32_add(f_m, f_m_round_offset);
+ const uint32_t f_m_denorm_sa = uint32_sub(one, f_e_half_bias);
+ const uint32_t f_m_with_hidden = uint32_or(f_m_rounded, f_m_hidden_bit);
+ const uint32_t f_m_denorm = uint32_srl(f_m_with_hidden, f_m_denorm_sa);
+ const uint32_t h_m_denorm = uint32_srl(f_m_denorm, f_h_m_pos_offset);
+ const uint32_t f_m_rounded_overflow = uint32_and(f_m_rounded, f_m_hidden_bit);
+ const uint32_t m_nan = uint32_srl(f_m, f_h_m_pos_offset);
+ const uint32_t h_em_nan = uint32_or(h_e_mask, m_nan);
+ const uint32_t h_e_norm_overflow_offset = uint32_inc(f_e_half_bias);
+ const uint32_t h_e_norm_overflow = uint32_sll(h_e_norm_overflow_offset, h_e_pos);
+ const uint32_t h_e_norm = uint32_sll(f_e_half_bias, h_e_pos);
+ const uint32_t h_m_norm = uint32_srl(f_m_rounded, f_h_m_pos_offset);
+ const uint32_t h_em_norm = uint32_or(h_e_norm, h_m_norm);
+ const uint32_t is_h_ndenorm_msb = uint32_sub(f_h_bias_offset, f_e_amount);
+ const uint32_t is_f_e_flagged_msb = uint32_sub(f_h_e_biased_flag, f_e_half_bias);
+ const uint32_t is_h_denorm_msb = uint32_not(is_h_ndenorm_msb);
+ const uint32_t is_f_m_eqz_msb = uint32_dec(f_m);
+ const uint32_t is_h_nan_eqz_msb = uint32_dec(m_nan);
+ const uint32_t is_f_inf_msb = uint32_and(is_f_e_flagged_msb, is_f_m_eqz_msb);
+ const uint32_t is_f_nan_underflow_msb = uint32_and(is_f_e_flagged_msb, is_h_nan_eqz_msb);
+ const uint32_t is_e_overflow_msb = uint32_sub(h_e_mask_value, f_e_half_bias);
+ const uint32_t is_h_inf_msb = uint32_or(is_e_overflow_msb, is_f_inf_msb);
+ const uint32_t is_f_nsnan_msb = uint32_sub(f_snan, f_snan_mask);
+ const uint32_t is_m_norm_overflow_msb = uint32_neg(f_m_rounded_overflow);
+ const uint32_t is_f_snan_msb = uint32_not(is_f_nsnan_msb);
+ const uint32_t h_em_overflow_result = uint32_sels(is_m_norm_overflow_msb, h_e_norm_overflow, h_em_norm);
+ const uint32_t h_em_nan_result = uint32_sels(is_f_e_flagged_msb, h_em_nan, h_em_overflow_result);
+ const uint32_t h_em_nan_underflow_result = uint32_sels(is_f_nan_underflow_msb, h_nan_min, h_em_nan_result);
+ const uint32_t h_em_inf_result = uint32_sels(is_h_inf_msb, h_e_mask, h_em_nan_underflow_result);
+ const uint32_t h_em_denorm_result = uint32_sels(is_h_denorm_msb, h_m_denorm, h_em_inf_result);
+ const uint32_t h_em_snan_result = uint32_sels(is_f_snan_msb, h_snan_mask, h_em_denorm_result);
+ const uint32_t h_result = uint32_or(h_s, h_em_snan_result);
+
+ return (uint16_t)(h_result);
+ }
+
+ inline float halfToFloat(uint16_t _a)
+ {
+ const uint32_t h_e_mask = uint32_li(0x00007c00);
+ const uint32_t h_m_mask = uint32_li(0x000003ff);
+ const uint32_t h_s_mask = uint32_li(0x00008000);
+ const uint32_t h_f_s_pos_offset = uint32_li(0x00000010);
+ const uint32_t h_f_e_pos_offset = uint32_li(0x0000000d);
+ const uint32_t h_f_bias_offset = uint32_li(0x0001c000);
+ const uint32_t f_e_mask = uint32_li(0x7f800000);
+ const uint32_t f_m_mask = uint32_li(0x007fffff);
+ const uint32_t h_f_e_denorm_bias = uint32_li(0x0000007e);
+ const uint32_t h_f_m_denorm_sa_bias = uint32_li(0x00000008);
+ const uint32_t f_e_pos = uint32_li(0x00000017);
+ const uint32_t h_e_mask_minus_one = uint32_li(0x00007bff);
+ const uint32_t h_e = uint32_and(_a, h_e_mask);
+ const uint32_t h_m = uint32_and(_a, h_m_mask);
+ const uint32_t h_s = uint32_and(_a, h_s_mask);
+ const uint32_t h_e_f_bias = uint32_add(h_e, h_f_bias_offset);
+ const uint32_t h_m_nlz = uint32_cntlz(h_m);
+ const uint32_t f_s = uint32_sll(h_s, h_f_s_pos_offset);
+ const uint32_t f_e = uint32_sll(h_e_f_bias, h_f_e_pos_offset);
+ const uint32_t f_m = uint32_sll(h_m, h_f_e_pos_offset);
+ const uint32_t f_em = uint32_or(f_e, f_m);
+ const uint32_t h_f_m_sa = uint32_sub(h_m_nlz, h_f_m_denorm_sa_bias);
+ const uint32_t f_e_denorm_unpacked = uint32_sub(h_f_e_denorm_bias, h_f_m_sa);
+ const uint32_t h_f_m = uint32_sll(h_m, h_f_m_sa);
+ const uint32_t f_m_denorm = uint32_and(h_f_m, f_m_mask);
+ const uint32_t f_e_denorm = uint32_sll(f_e_denorm_unpacked, f_e_pos);
+ const uint32_t f_em_denorm = uint32_or(f_e_denorm, f_m_denorm);
+ const uint32_t f_em_nan = uint32_or(f_e_mask, f_m);
+ const uint32_t is_e_eqz_msb = uint32_dec(h_e);
+ const uint32_t is_m_nez_msb = uint32_neg(h_m);
+ const uint32_t is_e_flagged_msb = uint32_sub(h_e_mask_minus_one, h_e);
+ const uint32_t is_zero_msb = uint32_andc(is_e_eqz_msb, is_m_nez_msb);
+ const uint32_t is_inf_msb = uint32_andc(is_e_flagged_msb, is_m_nez_msb);
+ const uint32_t is_denorm_msb = uint32_and(is_m_nez_msb, is_e_eqz_msb);
+ const uint32_t is_nan_msb = uint32_and(is_e_flagged_msb, is_m_nez_msb);
+ const uint32_t is_zero = uint32_ext(is_zero_msb);
+ const uint32_t f_zero_result = uint32_andc(f_em, is_zero);
+ const uint32_t f_denorm_result = uint32_sels(is_denorm_msb, f_em_denorm, f_zero_result);
+ const uint32_t f_inf_result = uint32_sels(is_inf_msb, f_e_mask, f_denorm_result);
+ const uint32_t f_nan_result = uint32_sels(is_nan_msb, f_em_nan, f_inf_result);
+ const uint32_t f_result = uint32_or(f_s, f_nan_result);
+
+ union { uint32_t ui; float flt; } utof;
+ utof.ui = f_result;
+ return utof.flt;
+ }
+
+ inline uint16_t uint16_min(uint16_t _a, uint16_t _b)
+ {
+ return _a > _b ? _b : _a;
+ }
+
+ inline uint16_t uint16_max(uint16_t _a, uint16_t _b)
+ {
+ return _a < _b ? _b : _a;
+ }
+
+ inline int64_t int64_min(int64_t _a, int64_t _b)
+ {
+ return _a < _b ? _a : _b;
+ }
+
+ inline int64_t int64_max(int64_t _a, int64_t _b)
+ {
+ return _a > _b ? _a : _b;
+ }
+
+ inline int64_t int64_clamp(int64_t _a, int64_t _min, int64_t _max)
+ {
+ const int64_t min = int64_min(_a, _max);
+ const int64_t result = int64_max(_min, min);
+
+ return result;
+ }
+
+ inline uint32_t uint64_cntbits_ref(uint64_t _val)
+ {
+ const uint32_t lo = uint32_t(_val&UINT32_MAX);
+ const uint32_t hi = uint32_t(_val>>32);
+
+ const uint32_t total = bx::uint32_cntbits(lo)
+ + bx::uint32_cntbits(hi);
+ return total;
+ }
+
+ /// Count number of bits set.
+ inline uint32_t uint64_cntbits(uint64_t _val)
+ {
+#if BX_COMPILER_GCC || BX_COMPILER_CLANG
+ return __builtin_popcountll(_val);
+#elif BX_COMPILER_MSVC && BX_ARCH_64BIT
+ return uint32_t(__popcnt64(_val) );
+#else
+ return uint64_cntbits_ref(_val);
+#endif // BX_COMPILER_
+ }
+
+ inline uint32_t uint64_cntlz_ref(uint64_t _val)
+ {
+ return _val & UINT64_C(0xffffffff00000000)
+ ? uint32_cntlz(uint32_t(_val>>32) )
+ : uint32_cntlz(uint32_t(_val) ) + 32
+ ;
+ }
+
+ /// Count number of leading zeros.
+ inline uint32_t uint64_cntlz(uint64_t _val)
+ {
+#if BX_COMPILER_GCC || BX_COMPILER_CLANG
+ return __builtin_clzll(_val);
+#elif BX_COMPILER_MSVC && BX_PLATFORM_WINDOWS && BX_ARCH_64BIT
+ unsigned long index;
+ _BitScanReverse64(&index, _val);
+ return uint32_t(63 - index);
+#else
+ return uint64_cntlz_ref(_val);
+#endif // BX_COMPILER_
+ }
+
+ inline uint32_t uint64_cnttz_ref(uint64_t _val)
+ {
+ return _val & UINT64_C(0xffffffff)
+ ? uint32_cnttz(uint32_t(_val) )
+ : uint32_cnttz(uint32_t(_val>>32) ) + 32
+ ;
+ }
+
+ inline uint32_t uint64_cnttz(uint64_t _val)
+ {
+#if BX_COMPILER_GCC || BX_COMPILER_CLANG
+ return __builtin_ctzll(_val);
+#elif BX_COMPILER_MSVC && BX_PLATFORM_WINDOWS && BX_ARCH_64BIT
+ unsigned long index;
+ _BitScanForward64(&index, _val);
+ return uint32_t(index);
+#else
+ return uint64_cnttz_ref(_val);
+#endif // BX_COMPILER_
+ }
+
+ inline uint64_t uint64_sll(uint64_t _a, int _sa)
+ {
+ return _a << _sa;
+ }
+
+ inline uint64_t uint64_srl(uint64_t _a, int _sa)
+ {
+ return _a >> _sa;
+ }
+
+ inline uint64_t uint64_sra(uint64_t _a, int _sa)
+ {
+ return ( (int64_t)_a) >> _sa;
+ }
+
+ inline uint64_t uint64_rol(uint64_t _a, int _sa)
+ {
+ return ( _a << _sa) | (_a >> (32-_sa) );
+ }
+
+ inline uint64_t uint64_ror(uint64_t _a, int _sa)
+ {
+ return ( _a >> _sa) | (_a << (32-_sa) );
+ }
+
+ inline uint64_t uint64_add(uint64_t _a, uint64_t _b)
+ {
+ return _a + _b;
+ }
+
+ inline uint64_t uint64_sub(uint64_t _a, uint64_t _b)
+ {
+ return _a - _b;
+ }
+
+ inline uint64_t uint64_mul(uint64_t _a, uint64_t _b)
+ {
+ return _a * _b;
+ }
+
+ /// Greatest common divisor.
+ inline uint32_t uint32_gcd(uint32_t _a, uint32_t _b)
+ {
+ do
+ {
+ uint32_t tmp = _a % _b;
+ _a = _b;
+ _b = tmp;
+ }
+ while (_b);
+
+ return _a;
+ }
+
+ /// Least common multiple.
+ inline uint32_t uint32_lcm(uint32_t _a, uint32_t _b)
+ {
+ return _a * (_b / uint32_gcd(_a, _b) );
+ }
+
+ /// Align to arbitrary stride.
+ inline uint32_t strideAlign(uint32_t _offset, uint32_t _stride)
+ {
+ const uint32_t mod = uint32_mod(_offset, _stride);
+ const uint32_t add = uint32_sub(_stride, mod);
+ const uint32_t mask = uint32_cmpeq(mod, 0);
+ const uint32_t tmp = uint32_selb(mask, 0, add);
+ const uint32_t result = uint32_add(_offset, tmp);
+
+ return result;
+ }
+
+ /// Align to arbitrary stride and 16-bytes.
+ inline uint32_t strideAlign16(uint32_t _offset, uint32_t _stride)
+ {
+ const uint32_t align = uint32_lcm(16, _stride);
+ const uint32_t mod = uint32_mod(_offset, align);
+ const uint32_t mask = uint32_cmpeq(mod, 0);
+ const uint32_t tmp0 = uint32_selb(mask, 0, align);
+ const uint32_t tmp1 = uint32_add(_offset, tmp0);
+ const uint32_t result = uint32_sub(tmp1, mod);
+
+ return result;
+ }
+
+ /// Align to arbitrary stride and 256-bytes.
+ inline uint32_t strideAlign256(uint32_t _offset, uint32_t _stride)
+ {
+ const uint32_t align = uint32_lcm(256, _stride);
+ const uint32_t mod = uint32_mod(_offset, align);
+ const uint32_t mask = uint32_cmpeq(mod, 0);
+ const uint32_t tmp0 = uint32_selb(mask, 0, align);
+ const uint32_t tmp1 = uint32_add(_offset, tmp0);
+ const uint32_t result = uint32_sub(tmp1, mod);
+
+ return result;
+ }
+
+} // namespace bx
diff --git a/3rdparty/bx/makefile b/3rdparty/bx/makefile
index 6a6598f80b1..bf8d91167d2 100644
--- a/3rdparty/bx/makefile
+++ b/3rdparty/bx/makefile
@@ -1,6 +1,6 @@
#
-# Copyright 2011-2015 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
+# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
GENIE=../bx/tools/bin/$(OS)/genie
diff --git a/3rdparty/bx/scripts/bin2c.lua b/3rdparty/bx/scripts/bin2c.lua
index 5dbc29d7b14..b308b3eb253 100644
--- a/3rdparty/bx/scripts/bin2c.lua
+++ b/3rdparty/bx/scripts/bin2c.lua
@@ -16,6 +16,10 @@ project "bin2c"
"../tools/bin2c/**.h",
}
+ links {
+ "bx",
+ }
+
configuration { "mingw-*" }
targetextension ".exe"
diff --git a/3rdparty/bx/scripts/bx.lua b/3rdparty/bx/scripts/bx.lua
index 2f1e4e57585..b62ee4bae5f 100644
--- a/3rdparty/bx/scripts/bx.lua
+++ b/3rdparty/bx/scripts/bx.lua
@@ -2,24 +2,23 @@
-- Copyright 2010-2017 Branimir Karadzic. All rights reserved.
-- License: https://github.com/bkaradzic/bx#license-bsd-2-clause
--
-
+
project "bx"
- uuid "4db0b09e-d6df-11e1-a0ec-65ccdd6a022f"
kind "StaticLib"
- configuration { "osx or ios" }
- -- OSX ar doesn't like creating archive without object files
- -- here is object file...
- prebuildcommands {
- "@echo \"void dummy() {}\" > /tmp/dummy.cpp",
- }
- files {
- "/tmp/dummy.cpp",
- }
-
- configuration {}
+ includedirs {
+ "../include",
+ }
files {
"../include/**.h",
"../include/**.inl",
+ "../src/**.cpp",
}
+
+ configuration { "linux-*" }
+ buildoptions {
+ "-fPIC",
+ }
+
+ configuration {}
diff --git a/3rdparty/bx/scripts/genie.lua b/3rdparty/bx/scripts/genie.lua
index 1e8f9028010..e0e634ae716 100644
--- a/3rdparty/bx/scripts/genie.lua
+++ b/3rdparty/bx/scripts/genie.lua
@@ -54,6 +54,10 @@ project "bx.test"
path.join(BX_DIR, "tests/dbg.*"),
}
+ links {
+ "bx",
+ }
+
configuration { "vs* or mingw*" }
links {
"psapi",
@@ -109,6 +113,10 @@ project "bx.bench"
path.join(BX_DIR, "tests/dbg.*"),
}
+ links {
+ "bx",
+ }
+
configuration { "vs* or mingw*" }
links {
"psapi",
diff --git a/3rdparty/bx/scripts/toolchain.lua b/3rdparty/bx/scripts/toolchain.lua
index 5d8573a690e..6a01c92422c 100644
--- a/3rdparty/bx/scripts/toolchain.lua
+++ b/3rdparty/bx/scripts/toolchain.lua
@@ -532,21 +532,27 @@ function toolchain(_buildDir, _libDir)
"__STDC_CONSTANT_MACROS",
}
- configuration { "qbs" }
- flags {
- "ExtraWarnings",
- }
-
configuration { "Debug" }
targetsuffix "Debug"
+ defines {
+ "_DEBUG",
+ }
configuration { "Release" }
flags {
"NoBufferSecurityCheck",
"OptimizeSpeed",
}
+ defines {
+ "NDEBUG",
+ }
targetsuffix "Release"
+ configuration { "qbs" }
+ flags {
+ "ExtraWarnings",
+ }
+
configuration { "vs*", "x32" }
flags {
"EnableSSE2",
diff --git a/3rdparty/bx/src/commandline.cpp b/3rdparty/bx/src/commandline.cpp
new file mode 100644
index 00000000000..400e4965a0e
--- /dev/null
+++ b/3rdparty/bx/src/commandline.cpp
@@ -0,0 +1,322 @@
+/*
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#include <bx/commandline.h>
+#include <bx/string.h>
+
+namespace bx
+{
+ // Reference:
+ // http://msdn.microsoft.com/en-us/library/a1y7w461.aspx
+ const char* tokenizeCommandLine(const char* _commandLine, char* _buffer, uint32_t& _bufferSize, int32_t& _argc, char* _argv[], int32_t _maxArgvs, char _term)
+ {
+ int32_t argc = 0;
+ const char* curr = _commandLine;
+ char* currOut = _buffer;
+ char term = ' ';
+ bool sub = false;
+
+ enum ParserState
+ {
+ SkipWhitespace,
+ SetTerm,
+ Copy,
+ Escape,
+ End,
+ };
+
+ ParserState state = SkipWhitespace;
+
+ while ('\0' != *curr
+ && _term != *curr
+ && argc < _maxArgvs)
+ {
+ switch (state)
+ {
+ case SkipWhitespace:
+ for (; isSpace(*curr); ++curr) {}; // skip whitespace
+ state = SetTerm;
+ break;
+
+ case SetTerm:
+ if ('"' == *curr)
+ {
+ term = '"';
+ ++curr; // skip begining quote
+ }
+ else
+ {
+ term = ' ';
+ }
+
+ _argv[argc] = currOut;
+ ++argc;
+
+ state = Copy;
+ break;
+
+ case Copy:
+ if ('\\' == *curr)
+ {
+ state = Escape;
+ }
+ else if ('"' == *curr
+ && '"' != term)
+ {
+ sub = !sub;
+ }
+ else if (isSpace(*curr) && !sub)
+ {
+ state = End;
+ }
+ else if (term != *curr || sub)
+ {
+ *currOut = *curr;
+ ++currOut;
+ }
+ else
+ {
+ state = End;
+ }
+ ++curr;
+ break;
+
+ case Escape:
+ {
+ const char* start = --curr;
+ for (; '\\' == *curr; ++curr) {};
+
+ if ('"' != *curr)
+ {
+ int32_t count = (int32_t)(curr-start);
+
+ curr = start;
+ for (int32_t ii = 0; ii < count; ++ii)
+ {
+ *currOut = *curr;
+ ++currOut;
+ ++curr;
+ }
+ }
+ else
+ {
+ curr = start+1;
+ *currOut = *curr;
+ ++currOut;
+ ++curr;
+ }
+ }
+ state = Copy;
+ break;
+
+ case End:
+ *currOut = '\0';
+ ++currOut;
+ state = SkipWhitespace;
+ break;
+ }
+ }
+
+ *currOut = '\0';
+ if (0 < argc
+ && '\0' == _argv[argc-1][0])
+ {
+ --argc;
+ }
+
+ _bufferSize = (uint32_t)(currOut - _buffer);
+ _argc = argc;
+
+ if ('\0' != *curr)
+ {
+ ++curr;
+ }
+
+ return curr;
+ }
+
+ CommandLine::CommandLine(int32_t _argc, char const* const* _argv)
+ : m_argc(_argc)
+ , m_argv(_argv)
+ {
+ }
+
+ const char* CommandLine::findOption(const char* _long, const char* _default) const
+ {
+ const char* result = find(0, '\0', _long, 1);
+ return result == NULL ? _default : result;
+ }
+
+ const char* CommandLine::findOption(const char _short, const char* _long, const char* _default) const
+ {
+ const char* result = find(0, _short, _long, 1);
+ return result == NULL ? _default : result;
+ }
+
+ const char* CommandLine::findOption(const char* _long, int32_t _numParams) const
+ {
+ const char* result = find(0, '\0', _long, _numParams);
+ return result;
+ }
+
+ const char* CommandLine::findOption(const char _short, const char* _long, int32_t _numParams) const
+ {
+ const char* result = find(0, _short, _long, _numParams);
+ return result;
+ }
+
+ const char* CommandLine::findOption(int32_t _skip, const char _short, const char* _long, int32_t _numParams) const
+ {
+ const char* result = find(_skip, _short, _long, _numParams);
+ return result;
+ }
+
+ bool CommandLine::hasArg(const char _short, const char* _long) const
+ {
+ const char* arg = findOption(_short, _long, 0);
+ return NULL != arg;
+ }
+
+ bool CommandLine::hasArg(const char* _long) const
+ {
+ const char* arg = findOption('\0', _long, 0);
+ return NULL != arg;
+ }
+
+ bool CommandLine::hasArg(const char*& _value, const char _short, const char* _long) const
+ {
+ const char* arg = findOption(_short, _long, 1);
+ _value = arg;
+ return NULL != arg;
+ }
+
+ bool CommandLine::hasArg(int32_t& _value, const char _short, const char* _long) const
+ {
+ const char* arg = findOption(_short, _long, 1);
+ if (NULL != arg)
+ {
+ _value = atoi(arg);
+ return true;
+ }
+
+ return false;
+ }
+
+ bool CommandLine::hasArg(uint32_t& _value, const char _short, const char* _long) const
+ {
+ const char* arg = findOption(_short, _long, 1);
+ if (NULL != arg)
+ {
+ _value = atoi(arg);
+ return true;
+ }
+
+ return false;
+ }
+
+ bool CommandLine::hasArg(float& _value, const char _short, const char* _long) const
+ {
+ const char* arg = findOption(_short, _long, 1);
+ if (NULL != arg)
+ {
+ _value = float(atof(arg));
+ return true;
+ }
+
+ return false;
+ }
+
+ bool CommandLine::hasArg(double& _value, const char _short, const char* _long) const
+ {
+ const char* arg = findOption(_short, _long, 1);
+ if (NULL != arg)
+ {
+ _value = atof(arg);
+ return true;
+ }
+
+ return false;
+ }
+
+ bool CommandLine::hasArg(bool& _value, const char _short, const char* _long) const
+ {
+ const char* arg = findOption(_short, _long, 1);
+ if (NULL != arg)
+ {
+ if ('0' == *arg || (0 == strincmp(arg, "false") ) )
+ {
+ _value = false;
+ }
+ else if ('0' != *arg || (0 == strincmp(arg, "true") ) )
+ {
+ _value = true;
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ const char* CommandLine::find(int32_t _skip, const char _short, const char* _long, int32_t _numParams) const
+ {
+ for (int32_t ii = 0; ii < m_argc; ++ii)
+ {
+ const char* arg = m_argv[ii];
+ if ('-' == *arg)
+ {
+ ++arg;
+ if (_short == *arg)
+ {
+ if (1 == strnlen(arg) )
+ {
+ if (0 == _skip)
+ {
+ if (0 == _numParams)
+ {
+ return "";
+ }
+ else if (ii+_numParams < m_argc
+ && '-' != *m_argv[ii+1] )
+ {
+ return m_argv[ii+1];
+ }
+
+ return NULL;
+ }
+
+ --_skip;
+ ii += _numParams;
+ }
+ }
+ else if (NULL != _long
+ && '-' == *arg
+ && 0 == strincmp(arg+1, _long) )
+ {
+ if (0 == _skip)
+ {
+ if (0 == _numParams)
+ {
+ return "";
+ }
+ else if (ii+_numParams < m_argc
+ && '-' != *m_argv[ii+1] )
+ {
+ return m_argv[ii+1];
+ }
+
+ return NULL;
+ }
+
+ --_skip;
+ ii += _numParams;
+ }
+ }
+ }
+
+ return NULL;
+ }
+
+} // namespace bx
diff --git a/3rdparty/bx/src/crt.cpp b/3rdparty/bx/src/crt.cpp
new file mode 100644
index 00000000000..8686f03d267
--- /dev/null
+++ b/3rdparty/bx/src/crt.cpp
@@ -0,0 +1,362 @@
+/*
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#include <bx/bx.h>
+#include <bx/readerwriter.h>
+#include <bx/debug.h>
+
+namespace bx
+{
+ void* memCopyRef(void* _dst, const void* _src, size_t _numBytes)
+ {
+ uint8_t* dst = (uint8_t*)_dst;
+ const uint8_t* end = dst + _numBytes;
+ const uint8_t* src = (const uint8_t*)_src;
+ while (dst != end)
+ {
+ *dst++ = *src++;
+ }
+
+ return _dst;
+ }
+
+ void* memCopy(void* _dst, const void* _src, size_t _numBytes)
+ {
+#if BX_CRT_NONE
+ return memCopyRef(_dst, _src, _numBytes);
+#else
+ return ::memcpy(_dst, _src, _numBytes);
+#endif // BX_CRT_NONE
+ }
+
+ void memCopy(void* _dst, const void* _src, uint32_t _size, uint32_t _num, uint32_t _srcPitch, uint32_t _dstPitch)
+ {
+ const uint8_t* src = (const uint8_t*)_src;
+ uint8_t* dst = (uint8_t*)_dst;
+
+ for (uint32_t ii = 0; ii < _num; ++ii)
+ {
+ memCopy(dst, src, _size);
+ src += _srcPitch;
+ dst += _dstPitch;
+ }
+ }
+
+ ///
+ void gather(void* _dst, const void* _src, uint32_t _size, uint32_t _num, uint32_t _srcPitch)
+ {
+ memCopy(_dst, _src, _size, _num, _srcPitch, _size);
+ }
+
+ ///
+ void scatter(void* _dst, const void* _src, uint32_t _size, uint32_t _num, uint32_t _dstPitch)
+ {
+ memCopy(_dst, _src, _size, _num, _size, _dstPitch);
+ }
+
+ void* memMoveRef(void* _dst, const void* _src, size_t _numBytes)
+ {
+ uint8_t* dst = (uint8_t*)_dst;
+ const uint8_t* src = (const uint8_t*)_src;
+
+ if (_numBytes == 0
+ || dst == src)
+ {
+ return dst;
+ }
+
+ // if (src+_numBytes <= dst || end <= src)
+ if (dst < src)
+ {
+ return memcpy(_dst, _src, _numBytes);
+ }
+
+ for (intptr_t ii = _numBytes-1; ii >= 0; --ii)
+ {
+ dst[ii] = src[ii];
+ }
+
+ return _dst;
+ }
+
+ void* memMove(void* _dst, const void* _src, size_t _numBytes)
+ {
+#if BX_CRT_NONE
+ return memMoveRef(_dst, _src, _numBytes);
+#else
+ return ::memmove(_dst, _src, _numBytes);
+#endif // BX_CRT_NONE
+ }
+
+ void* memSetRef(void* _dst, uint8_t _ch, size_t _numBytes)
+ {
+ uint8_t* dst = (uint8_t*)_dst;
+ const uint8_t* end = dst + _numBytes;
+ while (dst != end)
+ {
+ *dst++ = char(_ch);
+ }
+
+ return _dst;
+ }
+
+ void* memSet(void* _dst, uint8_t _ch, size_t _numBytes)
+ {
+#if BX_CRT_NONE
+ return memSetRef(_dst, _ch, _numBytes);
+#else
+ return ::memset(_dst, _ch, _numBytes);
+#endif // BX_CRT_NONE
+ }
+
+ namespace
+ {
+ struct Param
+ {
+ int32_t width;
+ uint32_t base;
+ uint32_t prec;
+ char fill;
+ bool left;
+ };
+
+ static int32_t write(WriterI* _writer, const char* _str, int32_t _len, const Param& _param, Error* _err)
+ {
+ int32_t size = 0;
+ int32_t len = (int32_t)strnlen(_str, _len);
+ int32_t padding = _param.width > len ? _param.width - len : 0;
+
+ if (!_param.left)
+ {
+ size += writeRep(_writer, _param.fill, padding, _err);
+ }
+
+ size += write(_writer, _str, len, _err);
+
+ if (_param.left)
+ {
+ size += writeRep(_writer, _param.fill, padding, _err);
+ }
+
+ return size;
+ }
+
+ static int32_t write(WriterI* _writer, const char* _str, const Param& _param, Error* _err)
+ {
+ return write(_writer, _str, INT32_MAX, _param, _err);
+ }
+
+ static int32_t write(WriterI* _writer, int32_t _i, const Param& _param, Error* _err)
+ {
+ char str[33];
+ int32_t len = toString(str, sizeof(str), _i, _param.base);
+
+ if (len == 0)
+ {
+ return 0;
+ }
+
+ return write(_writer, str, len, _param, _err);
+ }
+
+ static int32_t write(WriterI* _writer, uint32_t _i, const Param& _param, Error* _err)
+ {
+ char str[33];
+ int32_t len = toString(str, sizeof(str), _i, _param.base);
+
+ if (len == 0)
+ {
+ return 0;
+ }
+
+ return write(_writer, str, len, _param, _err);
+ }
+
+ static int32_t write(WriterI* _writer, double _d, const Param& _param, Error* _err)
+ {
+ char str[1024];
+ int32_t len = toString(str, sizeof(str), _d);
+
+ if (len == 0)
+ {
+ return 0;
+ }
+
+ const char* dot = strnchr(str, '.');
+ const int32_t precLen = int32_t(dot + 1 + _param.prec - str);
+ if (precLen > len)
+ {
+ for (int32_t ii = len; ii < precLen; ++ii)
+ {
+ str[ii] = '0';
+ }
+ str[precLen] = '\0';
+ }
+ len = precLen;
+
+ return write(_writer, str, len, _param, _err);
+ }
+
+ static int32_t write(WriterI* _writer, const void* _ptr, const Param& _param, Error* _err)
+ {
+ char str[35] = "0x";
+ int32_t len = toString(str + 2, sizeof(str) - 2, uint32_t(uintptr_t(_ptr) ), 16);
+
+ if (len == 0)
+ {
+ return 0;
+ }
+
+ len += 2;
+ return write(_writer, str, len, _param, _err);
+ }
+ } // anonymous namespace
+
+ int32_t write(WriterI* _writer, const char* _format, va_list _argList, Error* _err)
+ {
+ MemoryReader reader(_format, strnlen(_format) );
+
+ int32_t size = 0;
+
+ while (_err->isOk() )
+ {
+ char ch = '\0';
+ read(&reader, ch, _err);
+
+ if (!_err->isOk() )
+ {
+ break;
+ }
+ else if ('%' == ch)
+ {
+ // %[ -0][<width>][.<precision>]
+ read(&reader, ch);
+
+ Param param;
+ param.base = 10;
+ param.prec = 6;
+ param.left = false;
+ param.fill = ' ';
+ param.width = 0;
+
+ while (' ' == ch
+ || '-' == ch
+ || '0' == ch)
+ {
+ switch (ch)
+ {
+ case '-': param.left = true; break;
+ case ' ': param.fill = ' '; break;
+ case '0': param.fill = '0'; break;
+ }
+
+ if (param.left)
+ {
+ param.fill = ' ';
+ }
+
+ read(&reader, ch);
+ }
+
+ if ('*' == ch)
+ {
+ read(&reader, ch);
+ param.width = va_arg(_argList, int32_t);
+
+ if (0 > param.width)
+ {
+ param.left = true;
+ param.width = -param.width;
+ }
+
+ }
+ else
+ {
+ while (isNumeric(ch) )
+ {
+ param.width = param.width * 10 + ch - '0';
+ read(&reader, ch);
+ }
+ }
+
+ if ('.' == ch)
+ {
+ read(&reader, ch);
+
+ if ('*' == ch)
+ {
+ read(&reader, ch);
+ param.prec = va_arg(_argList, int32_t);
+ }
+ else
+ {
+ param.prec = 0;
+ while (isNumeric(ch) )
+ {
+ param.prec = param.prec * 10 + ch - '0';
+ read(&reader, ch);
+ }
+ }
+ }
+
+ switch (toLower(ch) )
+ {
+ case 'c':
+ size += write(_writer, char(va_arg(_argList, int32_t) ), _err);
+ break;
+
+ case 's':
+ size += write(_writer, va_arg(_argList, const char*), param, _err);
+ break;
+
+ case 'd':
+ param.base = 10;
+ size += write(_writer, va_arg(_argList, int32_t), param, _err);
+ break;
+
+ case 'f':
+ size += write(_writer, va_arg(_argList, double), param, _err);
+ break;
+
+ case 'p':
+ size += write(_writer, va_arg(_argList, void*), param, _err);
+ break;
+
+ case 'x':
+ param.base = 16;
+ size += write(_writer, va_arg(_argList, uint32_t), param, _err);
+ break;
+
+ case 'u':
+ param.base = 10;
+ size += write(_writer, va_arg(_argList, uint32_t), param, _err);
+ break;
+
+ default:
+ size += write(_writer, ch, _err);
+ break;
+ }
+ }
+ else
+ {
+ size += write(_writer, ch, _err);
+ }
+ }
+
+ size += write(_writer, '\0', _err);
+
+ return size;
+ }
+
+ int32_t write(WriterI* _writer, Error* _err, const char* _format, ...)
+ {
+ va_list argList;
+ va_start(argList, _format);
+ int32_t size = write(_writer, _format, argList, _err);
+ va_end(argList);
+ return size;
+ }
+
+} // namespace bx
diff --git a/3rdparty/bx/src/crtimpl.cpp b/3rdparty/bx/src/crtimpl.cpp
new file mode 100644
index 00000000000..7adb74bb8ee
--- /dev/null
+++ b/3rdparty/bx/src/crtimpl.cpp
@@ -0,0 +1,360 @@
+/*
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#include <bx/crtimpl.h>
+
+#if BX_CONFIG_ALLOCATOR_CRT
+# include <malloc.h>
+#endif // BX_CONFIG_ALLOCATOR_CRT
+
+namespace bx
+{
+#if BX_CONFIG_ALLOCATOR_CRT
+ CrtAllocator::CrtAllocator()
+ {
+ }
+
+ CrtAllocator::~CrtAllocator()
+ {
+ }
+
+ void* CrtAllocator::realloc(void* _ptr, size_t _size, size_t _align, const char* _file, uint32_t _line)
+ {
+ if (0 == _size)
+ {
+ if (NULL != _ptr)
+ {
+ if (BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT >= _align)
+ {
+ ::free(_ptr);
+ return NULL;
+ }
+
+# if BX_COMPILER_MSVC
+ BX_UNUSED(_file, _line);
+ _aligned_free(_ptr);
+# else
+ bx::alignedFree(this, _ptr, _align, _file, _line);
+# endif // BX_
+ }
+
+ return NULL;
+ }
+ else if (NULL == _ptr)
+ {
+ if (BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT >= _align)
+ {
+ return ::malloc(_size);
+ }
+
+# if BX_COMPILER_MSVC
+ BX_UNUSED(_file, _line);
+ return _aligned_malloc(_size, _align);
+# else
+ return bx::alignedAlloc(this, _size, _align, _file, _line);
+# endif // BX_
+ }
+
+ if (BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT >= _align)
+ {
+ return ::realloc(_ptr, _size);
+ }
+
+# if BX_COMPILER_MSVC
+ BX_UNUSED(_file, _line);
+ return _aligned_realloc(_ptr, _size, _align);
+# else
+ return bx::alignedRealloc(this, _ptr, _size, _align, _file, _line);
+# endif // BX_
+ }
+#endif // BX_CONFIG_ALLOCATOR_CRT
+
+#if BX_CONFIG_CRT_FILE_READER_WRITER
+
+# if BX_CRT_MSVC
+# define fseeko64 _fseeki64
+# define ftello64 _ftelli64
+# elif 0 \
+ || BX_PLATFORM_ANDROID \
+ || BX_PLATFORM_BSD \
+ || BX_PLATFORM_IOS \
+ || BX_PLATFORM_OSX \
+ || BX_PLATFORM_QNX
+# define fseeko64 fseeko
+# define ftello64 ftello
+# elif BX_PLATFORM_PS4
+# define fseeko64 fseek
+# define ftello64 ftell
+# endif // BX_
+
+ CrtFileReader::CrtFileReader()
+ : m_file(NULL)
+ {
+ }
+
+ CrtFileReader::~CrtFileReader()
+ {
+ }
+
+ bool CrtFileReader::open(const char* _filePath, Error* _err)
+ {
+ BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
+
+ if (NULL != m_file)
+ {
+ BX_ERROR_SET(_err, BX_ERROR_READERWRITER_ALREADY_OPEN, "CrtFileReader: File is already open.");
+ return false;
+ }
+
+ m_file = fopen(_filePath, "rb");
+ if (NULL == m_file)
+ {
+ BX_ERROR_SET(_err, BX_ERROR_READERWRITER_OPEN, "CrtFileReader: Failed to open file.");
+ return false;
+ }
+
+ return true;
+ }
+
+ void CrtFileReader::close()
+ {
+ BX_CHECK(NULL != m_file, "Reader/Writer file is not open.");
+ FILE* file = (FILE*)m_file;
+ fclose(file);
+ m_file = NULL;
+ }
+
+ int64_t CrtFileReader::seek(int64_t _offset, Whence::Enum _whence)
+ {
+ BX_CHECK(NULL != m_file, "Reader/Writer file is not open.");
+ FILE* file = (FILE*)m_file;
+ fseeko64(file, _offset, _whence);
+ return ftello64(file);
+ }
+
+ int32_t CrtFileReader::read(void* _data, int32_t _size, Error* _err)
+ {
+ BX_CHECK(NULL != m_file, "Reader/Writer file is not open.");
+ BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
+
+ FILE* file = (FILE*)m_file;
+ int32_t size = (int32_t)fread(_data, 1, _size, file);
+ if (size != _size)
+ {
+ if (0 != feof(file) )
+ {
+ BX_ERROR_SET(_err, BX_ERROR_READERWRITER_EOF, "CrtFileReader: EOF.");
+ }
+ else if (0 != ferror(file) )
+ {
+ BX_ERROR_SET(_err, BX_ERROR_READERWRITER_READ, "CrtFileReader: read error.");
+ }
+
+ return size >= 0 ? size : 0;
+ }
+
+ return size;
+ }
+
+ CrtFileWriter::CrtFileWriter()
+ : m_file(NULL)
+ {
+ }
+
+ CrtFileWriter::~CrtFileWriter()
+ {
+ }
+
+ bool CrtFileWriter::open(const char* _filePath, bool _append, Error* _err)
+ {
+ BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
+
+ if (NULL != m_file)
+ {
+ BX_ERROR_SET(_err, BX_ERROR_READERWRITER_ALREADY_OPEN, "CrtFileReader: File is already open.");
+ return false;
+ }
+
+ m_file = fopen(_filePath, _append ? "ab" : "wb");
+
+ if (NULL == m_file)
+ {
+ BX_ERROR_SET(_err, BX_ERROR_READERWRITER_OPEN, "CrtFileWriter: Failed to open file.");
+ return false;
+ }
+
+ return true;
+ }
+
+ void CrtFileWriter::close()
+ {
+ BX_CHECK(NULL != m_file, "Reader/Writer file is not open.");
+ FILE* file = (FILE*)m_file;
+ fclose(file);
+ m_file = NULL;
+ }
+
+ int64_t CrtFileWriter::seek(int64_t _offset, Whence::Enum _whence)
+ {
+ BX_CHECK(NULL != m_file, "Reader/Writer file is not open.");
+ FILE* file = (FILE*)m_file;
+ fseeko64(file, _offset, _whence);
+ return ftello64(file);
+ }
+
+ int32_t CrtFileWriter::write(const void* _data, int32_t _size, Error* _err)
+ {
+ BX_CHECK(NULL != m_file, "Reader/Writer file is not open.");
+ BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
+
+ FILE* file = (FILE*)m_file;
+ int32_t size = (int32_t)fwrite(_data, 1, _size, file);
+ if (size != _size)
+ {
+ BX_ERROR_SET(_err, BX_ERROR_READERWRITER_WRITE, "CrtFileWriter: write failed.");
+ return size >= 0 ? size : 0;
+ }
+
+ return size;
+ }
+#endif // BX_CONFIG_CRT_FILE_READER_WRITER
+
+#if BX_CONFIG_CRT_PROCESS
+
+#if BX_CRT_MSVC
+# define popen _popen
+# define pclose _pclose
+#endif // BX_CRT_MSVC
+
+ ProcessReader::ProcessReader()
+ : m_file(NULL)
+ {
+ }
+
+ ProcessReader::~ProcessReader()
+ {
+ BX_CHECK(NULL == m_file, "Process not closed!");
+ }
+
+ bool ProcessReader::open(const char* _command, Error* _err)
+ {
+ BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
+
+ if (NULL != m_file)
+ {
+ BX_ERROR_SET(_err, BX_ERROR_READERWRITER_ALREADY_OPEN, "ProcessReader: File is already open.");
+ return false;
+ }
+
+ m_file = popen(_command, "r");
+ if (NULL == m_file)
+ {
+ BX_ERROR_SET(_err, BX_ERROR_READERWRITER_OPEN, "ProcessReader: Failed to open process.");
+ return false;
+ }
+
+ return true;
+ }
+
+ void ProcessReader::close()
+ {
+ BX_CHECK(NULL != m_file, "Process not open!");
+ FILE* file = (FILE*)m_file;
+ m_exitCode = pclose(file);
+ m_file = NULL;
+ }
+
+ int32_t ProcessReader::read(void* _data, int32_t _size, Error* _err)
+ {
+ BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors."); BX_UNUSED(_err);
+
+ FILE* file = (FILE*)m_file;
+ int32_t size = (int32_t)fread(_data, 1, _size, file);
+ if (size != _size)
+ {
+ if (0 != feof(file) )
+ {
+ BX_ERROR_SET(_err, BX_ERROR_READERWRITER_EOF, "ProcessReader: EOF.");
+ }
+ else if (0 != ferror(file) )
+ {
+ BX_ERROR_SET(_err, BX_ERROR_READERWRITER_READ, "ProcessReader: read error.");
+ }
+
+ return size >= 0 ? size : 0;
+ }
+
+ return size;
+ }
+
+ int32_t ProcessReader::getExitCode() const
+ {
+ return m_exitCode;
+ }
+
+ ProcessWriter::ProcessWriter()
+ : m_file(NULL)
+ {
+ }
+
+ ProcessWriter::~ProcessWriter()
+ {
+ BX_CHECK(NULL == m_file, "Process not closed!");
+ }
+
+ bool ProcessWriter::open(const char* _command, bool, Error* _err)
+ {
+ BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
+
+ if (NULL != m_file)
+ {
+ BX_ERROR_SET(_err, BX_ERROR_READERWRITER_ALREADY_OPEN, "ProcessWriter: File is already open.");
+ return false;
+ }
+
+ m_file = popen(_command, "w");
+ if (NULL == m_file)
+ {
+ BX_ERROR_SET(_err, BX_ERROR_READERWRITER_OPEN, "ProcessWriter: Failed to open process.");
+ return false;
+ }
+
+ return true;
+ }
+
+ void ProcessWriter::close()
+ {
+ BX_CHECK(NULL != m_file, "Process not open!");
+ FILE* file = (FILE*)m_file;
+ m_exitCode = pclose(file);
+ m_file = NULL;
+ }
+
+ int32_t ProcessWriter::write(const void* _data, int32_t _size, Error* _err)
+ {
+ BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors."); BX_UNUSED(_err);
+
+ FILE* file = (FILE*)m_file;
+ int32_t size = (int32_t)fwrite(_data, 1, _size, file);
+ if (size != _size)
+ {
+ if (0 != ferror(file) )
+ {
+ BX_ERROR_SET(_err, BX_ERROR_READERWRITER_WRITE, "ProcessWriter: write error.");
+ }
+
+ return size >= 0 ? size : 0;
+ }
+
+ return size;
+ }
+
+ int32_t ProcessWriter::getExitCode() const
+ {
+ return m_exitCode;
+ }
+#endif // BX_CONFIG_CRT_PROCESS
+
+} // namespace bx
diff --git a/3rdparty/bx/src/debug.cpp b/3rdparty/bx/src/debug.cpp
new file mode 100644
index 00000000000..550eef6e5f6
--- /dev/null
+++ b/3rdparty/bx/src/debug.cpp
@@ -0,0 +1,143 @@
+/*
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#include <bx/debug.h>
+#include <bx/string.h> // isPrint
+#include <inttypes.h> // PRIx*
+
+#if BX_PLATFORM_ANDROID
+# include <android/log.h>
+#elif BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE
+extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char* _str);
+#elif BX_PLATFORM_IOS || BX_PLATFORM_OSX
+# if defined(__OBJC__)
+# import <Foundation/NSObjCRuntime.h>
+# else
+# include <CoreFoundation/CFString.h>
+extern "C" void NSLog(CFStringRef _format, ...);
+# endif // defined(__OBJC__)
+#elif 0 // BX_PLATFORM_EMSCRIPTEN
+# include <emscripten.h>
+#else
+# include <stdio.h> // fputs, fflush
+#endif // BX_PLATFORM_WINDOWS
+
+namespace bx
+{
+ void debugBreak()
+ {
+#if BX_COMPILER_MSVC
+ __debugbreak();
+#elif BX_CPU_ARM
+ __builtin_trap();
+// asm("bkpt 0");
+#elif !BX_PLATFORM_NACL && BX_CPU_X86 && (BX_COMPILER_GCC || BX_COMPILER_CLANG)
+ // NaCl doesn't like int 3:
+ // NativeClient: NaCl module load failed: Validation failure. File violates Native Client safety rules.
+ __asm__ ("int $3");
+#else // cross platform implementation
+ int* int3 = (int*)3L;
+ *int3 = 3;
+#endif // BX
+ }
+
+ void debugOutput(const char* _out)
+ {
+#if BX_PLATFORM_ANDROID
+# ifndef BX_ANDROID_LOG_TAG
+# define BX_ANDROID_LOG_TAG ""
+# endif // BX_ANDROID_LOG_TAG
+ __android_log_write(ANDROID_LOG_DEBUG, BX_ANDROID_LOG_TAG, _out);
+#elif BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE
+ OutputDebugStringA(_out);
+#elif BX_PLATFORM_IOS || BX_PLATFORM_OSX
+# if defined(__OBJC__)
+ NSLog(@"%s", _out);
+# else
+ NSLog(__CFStringMakeConstantString("%s"), _out);
+# endif // defined(__OBJC__)
+#elif 0 // BX_PLATFORM_EMSCRIPTEN
+ emscripten_log(EM_LOG_CONSOLE, "%s", _out);
+#else
+ fputs(_out, stdout);
+ fflush(stdout);
+#endif // BX_PLATFORM_
+ }
+
+ void debugPrintfVargs(const char* _format, va_list _argList)
+ {
+ char temp[8192];
+ char* out = temp;
+ int32_t len = vsnprintf(out, sizeof(temp), _format, _argList);
+ if ( (int32_t)sizeof(temp) < len)
+ {
+ out = (char*)alloca(len+1);
+ len = vsnprintf(out, len, _format, _argList);
+ }
+ out[len] = '\0';
+ debugOutput(out);
+ }
+
+ void debugPrintf(const char* _format, ...)
+ {
+ va_list argList;
+ va_start(argList, _format);
+ debugPrintfVargs(_format, argList);
+ va_end(argList);
+ }
+
+#define DBG_ADDRESS "%" PRIxPTR
+
+ void debugPrintfData(const void* _data, uint32_t _size, const char* _format, ...)
+ {
+#define HEX_DUMP_WIDTH 16
+#define HEX_DUMP_SPACE_WIDTH 48
+#define HEX_DUMP_FORMAT "%-" BX_STRINGIZE(HEX_DUMP_SPACE_WIDTH) "." BX_STRINGIZE(HEX_DUMP_SPACE_WIDTH) "s"
+
+ va_list argList;
+ va_start(argList, _format);
+ debugPrintfVargs(_format, argList);
+ va_end(argList);
+
+ debugPrintf("\ndata: " DBG_ADDRESS ", size: %d\n", _data, _size);
+
+ if (NULL != _data)
+ {
+ const uint8_t* data = reinterpret_cast<const uint8_t*>(_data);
+ char hex[HEX_DUMP_WIDTH*3+1];
+ char ascii[HEX_DUMP_WIDTH+1];
+ uint32_t hexPos = 0;
+ uint32_t asciiPos = 0;
+ for (uint32_t ii = 0; ii < _size; ++ii)
+ {
+ snprintf(&hex[hexPos], sizeof(hex)-hexPos, "%02x ", data[asciiPos]);
+ hexPos += 3;
+
+ ascii[asciiPos] = isPrint(data[asciiPos]) ? data[asciiPos] : '.';
+ asciiPos++;
+
+ if (HEX_DUMP_WIDTH == asciiPos)
+ {
+ ascii[asciiPos] = '\0';
+ debugPrintf("\t" DBG_ADDRESS "\t" HEX_DUMP_FORMAT "\t%s\n", data, hex, ascii);
+ data += asciiPos;
+ hexPos = 0;
+ asciiPos = 0;
+ }
+ }
+
+ if (0 != asciiPos)
+ {
+ ascii[asciiPos] = '\0';
+ debugPrintf("\t" DBG_ADDRESS "\t" HEX_DUMP_FORMAT "\t%s\n", data, hex, ascii);
+ }
+ }
+
+#undef HEX_DUMP_WIDTH
+#undef HEX_DUMP_SPACE_WIDTH
+#undef HEX_DUMP_FORMAT
+ }
+
+} // namespace bx
diff --git a/3rdparty/bx/src/dtoa.cpp b/3rdparty/bx/src/dtoa.cpp
new file mode 100644
index 00000000000..05ac387fec2
--- /dev/null
+++ b/3rdparty/bx/src/dtoa.cpp
@@ -0,0 +1,528 @@
+/*
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#include <bx/cpu.h>
+#include <bx/fpumath.h>
+#include <bx/string.h>
+#include <bx/uint32_t.h>
+
+namespace bx
+{
+ // https://github.com/miloyip/dtoa-benchmark
+ //
+ // Copyright (C) 2014 Milo Yip
+ //
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
+ // of this software and associated documentation files (the "Software"), to deal
+ // in the Software without restriction, including without limitation the rights
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ // copies of the Software, and to permit persons to whom the Software is
+ // furnished to do so, subject to the following conditions:
+ //
+ // The above copyright notice and this permission notice shall be included in
+ // all copies or substantial portions of the Software.
+ //
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ // THE SOFTWARE.
+ //
+ struct DiyFp
+ {
+ DiyFp()
+ {
+ }
+
+ DiyFp(uint64_t _f, int32_t _e)
+ : f(_f)
+ , e(_e)
+ {
+ }
+
+ DiyFp(double d)
+ {
+ union
+ {
+ double d;
+ uint64_t u64;
+ } u = { d };
+
+ int32_t biased_e = (u.u64 & kDpExponentMask) >> kDpSignificandSize;
+ uint64_t significand = (u.u64 & kDpSignificandMask);
+ if (biased_e != 0)
+ {
+ f = significand + kDpHiddenBit;
+ e = biased_e - kDpExponentBias;
+ }
+ else
+ {
+ f = significand;
+ e = kDpMinExponent + 1;
+ }
+ }
+
+ DiyFp operator-(const DiyFp& rhs) const
+ {
+ BX_CHECK(e == rhs.e, "");
+ BX_CHECK(f >= rhs.f, "");
+ return DiyFp(f - rhs.f, e);
+ }
+
+ DiyFp operator*(const DiyFp& rhs) const
+ {
+ const uint64_t M32 = 0xFFFFFFFF;
+ const uint64_t a = f >> 32;
+ const uint64_t b = f & M32;
+ const uint64_t c = rhs.f >> 32;
+ const uint64_t d = rhs.f & M32;
+ const uint64_t ac = a * c;
+ const uint64_t bc = b * c;
+ const uint64_t ad = a * d;
+ const uint64_t bd = b * d;
+ uint64_t tmp = (bd >> 32) + (ad & M32) + (bc & M32);
+ tmp += 1U << 31; /// mult_round
+ return DiyFp(ac + (ad >> 32) + (bc >> 32) + (tmp >> 32), e + rhs.e + 64);
+ }
+
+ DiyFp Normalize() const
+ {
+ uint32_t s = uint64_cntlz(f);
+ return DiyFp(f << s, e - s);
+ }
+
+ DiyFp NormalizeBoundary() const
+ {
+ uint32_t index = uint64_cntlz(f);
+ return DiyFp (f << index, e - index);
+ }
+
+ void NormalizedBoundaries(DiyFp* minus, DiyFp* plus) const
+ {
+ DiyFp pl = DiyFp((f << 1) + 1, e - 1).NormalizeBoundary();
+ DiyFp mi = (f == kDpHiddenBit) ? DiyFp((f << 2) - 1, e - 2) : DiyFp((f << 1) - 1, e - 1);
+ mi.f <<= mi.e - pl.e;
+ mi.e = pl.e;
+ *plus = pl;
+ *minus = mi;
+ }
+
+#define UINT64_C2(h, l) ((static_cast<uint64_t>(h) << 32) | static_cast<uint64_t>(l))
+
+ static const int32_t kDiySignificandSize = 64;
+ static const int32_t kDpSignificandSize = 52;
+ static const int32_t kDpExponentBias = 0x3FF + kDpSignificandSize;
+ static const int32_t kDpMinExponent = -kDpExponentBias;
+ static const uint64_t kDpExponentMask = UINT64_C2(0x7FF00000, 0x00000000);
+ static const uint64_t kDpSignificandMask = UINT64_C2(0x000FFFFF, 0xFFFFFFFF);
+ static const uint64_t kDpHiddenBit = UINT64_C2(0x00100000, 0x00000000);
+
+ uint64_t f;
+ int32_t e;
+ };
+
+ // 10^-348, 10^-340, ..., 10^340
+ static const uint64_t s_kCachedPowers_F[] =
+ {
+ UINT64_C2(0xfa8fd5a0, 0x081c0288), UINT64_C2(0xbaaee17f, 0xa23ebf76),
+ UINT64_C2(0x8b16fb20, 0x3055ac76), UINT64_C2(0xcf42894a, 0x5dce35ea),
+ UINT64_C2(0x9a6bb0aa, 0x55653b2d), UINT64_C2(0xe61acf03, 0x3d1a45df),
+ UINT64_C2(0xab70fe17, 0xc79ac6ca), UINT64_C2(0xff77b1fc, 0xbebcdc4f),
+ UINT64_C2(0xbe5691ef, 0x416bd60c), UINT64_C2(0x8dd01fad, 0x907ffc3c),
+ UINT64_C2(0xd3515c28, 0x31559a83), UINT64_C2(0x9d71ac8f, 0xada6c9b5),
+ UINT64_C2(0xea9c2277, 0x23ee8bcb), UINT64_C2(0xaecc4991, 0x4078536d),
+ UINT64_C2(0x823c1279, 0x5db6ce57), UINT64_C2(0xc2109436, 0x4dfb5637),
+ UINT64_C2(0x9096ea6f, 0x3848984f), UINT64_C2(0xd77485cb, 0x25823ac7),
+ UINT64_C2(0xa086cfcd, 0x97bf97f4), UINT64_C2(0xef340a98, 0x172aace5),
+ UINT64_C2(0xb23867fb, 0x2a35b28e), UINT64_C2(0x84c8d4df, 0xd2c63f3b),
+ UINT64_C2(0xc5dd4427, 0x1ad3cdba), UINT64_C2(0x936b9fce, 0xbb25c996),
+ UINT64_C2(0xdbac6c24, 0x7d62a584), UINT64_C2(0xa3ab6658, 0x0d5fdaf6),
+ UINT64_C2(0xf3e2f893, 0xdec3f126), UINT64_C2(0xb5b5ada8, 0xaaff80b8),
+ UINT64_C2(0x87625f05, 0x6c7c4a8b), UINT64_C2(0xc9bcff60, 0x34c13053),
+ UINT64_C2(0x964e858c, 0x91ba2655), UINT64_C2(0xdff97724, 0x70297ebd),
+ UINT64_C2(0xa6dfbd9f, 0xb8e5b88f), UINT64_C2(0xf8a95fcf, 0x88747d94),
+ UINT64_C2(0xb9447093, 0x8fa89bcf), UINT64_C2(0x8a08f0f8, 0xbf0f156b),
+ UINT64_C2(0xcdb02555, 0x653131b6), UINT64_C2(0x993fe2c6, 0xd07b7fac),
+ UINT64_C2(0xe45c10c4, 0x2a2b3b06), UINT64_C2(0xaa242499, 0x697392d3),
+ UINT64_C2(0xfd87b5f2, 0x8300ca0e), UINT64_C2(0xbce50864, 0x92111aeb),
+ UINT64_C2(0x8cbccc09, 0x6f5088cc), UINT64_C2(0xd1b71758, 0xe219652c),
+ UINT64_C2(0x9c400000, 0x00000000), UINT64_C2(0xe8d4a510, 0x00000000),
+ UINT64_C2(0xad78ebc5, 0xac620000), UINT64_C2(0x813f3978, 0xf8940984),
+ UINT64_C2(0xc097ce7b, 0xc90715b3), UINT64_C2(0x8f7e32ce, 0x7bea5c70),
+ UINT64_C2(0xd5d238a4, 0xabe98068), UINT64_C2(0x9f4f2726, 0x179a2245),
+ UINT64_C2(0xed63a231, 0xd4c4fb27), UINT64_C2(0xb0de6538, 0x8cc8ada8),
+ UINT64_C2(0x83c7088e, 0x1aab65db), UINT64_C2(0xc45d1df9, 0x42711d9a),
+ UINT64_C2(0x924d692c, 0xa61be758), UINT64_C2(0xda01ee64, 0x1a708dea),
+ UINT64_C2(0xa26da399, 0x9aef774a), UINT64_C2(0xf209787b, 0xb47d6b85),
+ UINT64_C2(0xb454e4a1, 0x79dd1877), UINT64_C2(0x865b8692, 0x5b9bc5c2),
+ UINT64_C2(0xc83553c5, 0xc8965d3d), UINT64_C2(0x952ab45c, 0xfa97a0b3),
+ UINT64_C2(0xde469fbd, 0x99a05fe3), UINT64_C2(0xa59bc234, 0xdb398c25),
+ UINT64_C2(0xf6c69a72, 0xa3989f5c), UINT64_C2(0xb7dcbf53, 0x54e9bece),
+ UINT64_C2(0x88fcf317, 0xf22241e2), UINT64_C2(0xcc20ce9b, 0xd35c78a5),
+ UINT64_C2(0x98165af3, 0x7b2153df), UINT64_C2(0xe2a0b5dc, 0x971f303a),
+ UINT64_C2(0xa8d9d153, 0x5ce3b396), UINT64_C2(0xfb9b7cd9, 0xa4a7443c),
+ UINT64_C2(0xbb764c4c, 0xa7a44410), UINT64_C2(0x8bab8eef, 0xb6409c1a),
+ UINT64_C2(0xd01fef10, 0xa657842c), UINT64_C2(0x9b10a4e5, 0xe9913129),
+ UINT64_C2(0xe7109bfb, 0xa19c0c9d), UINT64_C2(0xac2820d9, 0x623bf429),
+ UINT64_C2(0x80444b5e, 0x7aa7cf85), UINT64_C2(0xbf21e440, 0x03acdd2d),
+ UINT64_C2(0x8e679c2f, 0x5e44ff8f), UINT64_C2(0xd433179d, 0x9c8cb841),
+ UINT64_C2(0x9e19db92, 0xb4e31ba9), UINT64_C2(0xeb96bf6e, 0xbadf77d9),
+ UINT64_C2(0xaf87023b, 0x9bf0ee6b)
+ };
+
+ static const int16_t s_kCachedPowers_E[] =
+ {
+ -1220, -1193, -1166, -1140, -1113, -1087, -1060, -1034, -1007, -980,
+ -954, -927, -901, -874, -847, -821, -794, -768, -741, -715,
+ -688, -661, -635, -608, -582, -555, -529, -502, -475, -449,
+ -422, -396, -369, -343, -316, -289, -263, -236, -210, -183,
+ -157, -130, -103, -77, -50, -24, 3, 30, 56, 83,
+ 109, 136, 162, 189, 216, 242, 269, 295, 322, 348,
+ 375, 402, 428, 455, 481, 508, 534, 561, 588, 614,
+ 641, 667, 694, 720, 747, 774, 800, 827, 853, 880,
+ 907, 933, 960, 986, 1013, 1039, 1066
+ };
+
+ static const char s_cDigitsLut[200] =
+ {
+ '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9',
+ '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '1', '8', '1', '9',
+ '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9',
+ '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '3', '8', '3', '9',
+ '4', '0', '4', '1', '4', '2', '4', '3', '4', '4', '4', '5', '4', '6', '4', '7', '4', '8', '4', '9',
+ '5', '0', '5', '1', '5', '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9',
+ '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6', '7', '6', '8', '6', '9',
+ '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7', '7', '8', '7', '9',
+ '8', '0', '8', '1', '8', '2', '8', '3', '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9',
+ '9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9', '5', '9', '6', '9', '7', '9', '8', '9', '9'
+ };
+
+ static const uint32_t s_kPow10[] =
+ {
+ 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000
+ };
+
+ DiyFp GetCachedPower(int32_t e, int32_t* K)
+ {
+ double dk = (-61 - e) * 0.30102999566398114 + 347; // dk must be positive, so can do ceiling in positive
+ int32_t k = static_cast<int32_t>(dk);
+ if (k != dk)
+ {
+ k++;
+ }
+
+ uint32_t index = static_cast<uint32_t>((k >> 3) + 1);
+ *K = -(-348 + static_cast<int32_t>(index << 3)); // decimal exponent no need lookup table
+
+ BX_CHECK(index < sizeof(s_kCachedPowers_F) / sizeof(s_kCachedPowers_F[0]));
+ return DiyFp(s_kCachedPowers_F[index], s_kCachedPowers_E[index]);
+ }
+
+ void GrisuRound(char* buffer, int32_t len, uint64_t delta, uint64_t rest, uint64_t ten_kappa, uint64_t wp_w)
+ {
+ while (rest < wp_w
+ && delta - rest >= ten_kappa
+ && (rest + ten_kappa < wp_w || wp_w - rest > rest + ten_kappa - wp_w))
+ {
+ buffer[len - 1]--;
+ rest += ten_kappa;
+ }
+ }
+
+ uint32_t CountDecimalDigit32(uint32_t n)
+ {
+ // Simple pure C++ implementation was faster than __builtin_clz version in this situation.
+ if (n < 10) return 1;
+ if (n < 100) return 2;
+ if (n < 1000) return 3;
+ if (n < 10000) return 4;
+ if (n < 100000) return 5;
+ if (n < 1000000) return 6;
+ if (n < 10000000) return 7;
+ if (n < 100000000) return 8;
+ if (n < 1000000000) return 9;
+ return 10;
+ }
+
+ void DigitGen(const DiyFp& W, const DiyFp& Mp, uint64_t delta, char* buffer, int32_t* len, int32_t* K)
+ {
+ const DiyFp one(uint64_t(1) << -Mp.e, Mp.e);
+ const DiyFp wp_w = Mp - W;
+ uint32_t p1 = static_cast<uint32_t>(Mp.f >> -one.e);
+ uint64_t p2 = Mp.f & (one.f - 1);
+ int32_t kappa = static_cast<int32_t>(CountDecimalDigit32(p1));
+ *len = 0;
+
+ while (kappa > 0)
+ {
+ uint32_t d;
+ switch (kappa)
+ {
+ case 10: d = p1 / 1000000000; p1 %= 1000000000; break;
+ case 9: d = p1 / 100000000; p1 %= 100000000; break;
+ case 8: d = p1 / 10000000; p1 %= 10000000; break;
+ case 7: d = p1 / 1000000; p1 %= 1000000; break;
+ case 6: d = p1 / 100000; p1 %= 100000; break;
+ case 5: d = p1 / 10000; p1 %= 10000; break;
+ case 4: d = p1 / 1000; p1 %= 1000; break;
+ case 3: d = p1 / 100; p1 %= 100; break;
+ case 2: d = p1 / 10; p1 %= 10; break;
+ case 1: d = p1; p1 = 0; break;
+ default:
+ d = 0;
+ break;
+ }
+
+ if (d || *len)
+ {
+ buffer[(*len)++] = '0' + static_cast<char>(d);
+ }
+
+ kappa--;
+ uint64_t tmp = (static_cast<uint64_t>(p1) << -one.e) + p2;
+ if (tmp <= delta)
+ {
+ *K += kappa;
+ GrisuRound(buffer, *len, delta, tmp, static_cast<uint64_t>(s_kPow10[kappa]) << -one.e, wp_w.f);
+ return;
+ }
+ }
+
+ // kappa = 0
+ for (;;)
+ {
+ p2 *= 10;
+ delta *= 10;
+ char d = static_cast<char>(p2 >> -one.e);
+ if (d || *len)
+ {
+ buffer[(*len)++] = '0' + d;
+ }
+
+ p2 &= one.f - 1;
+ kappa--;
+ if (p2 < delta)
+ {
+ *K += kappa;
+ GrisuRound(buffer, *len, delta, p2, one.f, wp_w.f * s_kPow10[-kappa]);
+ return;
+ }
+ }
+ }
+
+ void Grisu2(double value, char* buffer, int32_t* length, int32_t* K)
+ {
+ const DiyFp v(value);
+ DiyFp w_m, w_p;
+ v.NormalizedBoundaries(&w_m, &w_p);
+
+ const DiyFp c_mk = GetCachedPower(w_p.e, K);
+ const DiyFp W = v.Normalize() * c_mk;
+ DiyFp Wp = w_p * c_mk;
+ DiyFp Wm = w_m * c_mk;
+ Wm.f++;
+ Wp.f--;
+ DigitGen(W, Wp, Wp.f - Wm.f, buffer, length, K);
+ }
+
+ int32_t WriteExponent(int32_t K, char* buffer)
+ {
+ const char* ptr = buffer;
+
+ if (K < 0)
+ {
+ *buffer++ = '-';
+ K = -K;
+ }
+
+ if (K >= 100)
+ {
+ *buffer++ = '0' + static_cast<char>(K / 100);
+ K %= 100;
+ const char* d = s_cDigitsLut + K * 2;
+ *buffer++ = d[0];
+ *buffer++ = d[1];
+ }
+ else if (K >= 10)
+ {
+ const char* d = s_cDigitsLut + K * 2;
+ *buffer++ = d[0];
+ *buffer++ = d[1];
+ }
+ else
+ {
+ *buffer++ = '0' + static_cast<char>(K);
+ }
+
+ *buffer = '\0';
+
+ return int32_t(buffer - ptr);
+ }
+
+ int32_t Prettify(char* buffer, int32_t length, int32_t k)
+ {
+ const int32_t kk = length + k; // 10^(kk-1) <= v < 10^kk
+
+ if (length <= kk && kk <= 21)
+ {
+ // 1234e7 -> 12340000000
+ for (int32_t i = length; i < kk; i++)
+ {
+ buffer[i] = '0';
+ }
+
+ buffer[kk] = '.';
+ buffer[kk + 1] = '0';
+ buffer[kk + 2] = '\0';
+ return kk + 2;
+ }
+
+ if (0 < kk && kk <= 21)
+ {
+ // 1234e-2 -> 12.34
+ memmove(&buffer[kk + 1], &buffer[kk], length - kk);
+ buffer[kk] = '.';
+ buffer[length + 1] = '\0';
+ return length + 1;
+ }
+
+ if (-6 < kk && kk <= 0)
+ {
+ // 1234e-6 -> 0.001234
+ const int32_t offset = 2 - kk;
+ memmove(&buffer[offset], &buffer[0], length);
+ buffer[0] = '0';
+ buffer[1] = '.';
+ for (int32_t i = 2; i < offset; i++)
+ {
+ buffer[i] = '0';
+ }
+
+ buffer[length + offset] = '\0';
+ return length + offset;
+ }
+
+ if (length == 1)
+ {
+ // 1e30
+ buffer[1] = 'e';
+ int32_t exp = WriteExponent(kk - 1, &buffer[2]);
+ return 2 + exp;
+ }
+
+ // 1234e30 -> 1.234e33
+ memmove(&buffer[2], &buffer[1], length - 1);
+ buffer[1] = '.';
+ buffer[length + 1] = 'e';
+ int32_t exp = WriteExponent(kk - 1, &buffer[length + 2]);
+ return length + 2 + exp;
+ }
+
+ int32_t toString(char* _dst, size_t _max, double value)
+ {
+ if (isNan(value) )
+ {
+ return (int32_t)strlncpy(_dst, _max, "NaN");
+ }
+ else if (isInfinite(value) )
+ {
+ return (int32_t)strlncpy(_dst, _max, "Inf");
+ }
+
+ int32_t sign = 0.0 > value ? 1 : 0;
+ if (1 == sign)
+ {
+ *_dst++ = '-';
+ --_max;
+ value = -value;
+ }
+
+ int32_t len;
+ if (0.0 == value)
+ {
+ len = (int32_t)strlncpy(_dst, _max, "0.0");
+ }
+ else
+ {
+ int32_t kk;
+ Grisu2(value, _dst, &len, &kk);
+ len = Prettify(_dst, len, kk);
+ }
+
+ return len + sign;
+ }
+
+ static void reverse(char* _dst, size_t _len)
+ {
+ for (size_t ii = 0, jj = _len - 1; ii < jj; ++ii, --jj)
+ {
+ xchg(_dst[ii], _dst[jj]);
+ }
+ }
+
+ int32_t toString(char* _dst, size_t _max, int32_t _value, uint32_t _base)
+ {
+ if (_base == 10
+ && _value < 0)
+ {
+ if (_max < 1)
+ {
+ return 0;
+ }
+
+ _max = toString(_dst + 1, _max - 1, uint32_t(-_value), _base);
+ if (_max == 0)
+ {
+ return 0;
+ }
+
+ *_dst = '-';
+ return int32_t(_max + 1);
+ }
+
+ return toString(_dst, _max, uint32_t(_value), _base);
+ }
+
+ int32_t toString(char* _dst, size_t _max, uint32_t _value, uint32_t _base)
+ {
+ char data[32];
+ size_t len = 0;
+
+ if (_base > 16
+ || _base < 2)
+ {
+ return 0;
+ }
+
+ do
+ {
+ const uint32_t rem = _value % _base;
+ _value /= _base;
+ if (rem < 10)
+ {
+ data[len++] = char('0' + rem);
+ }
+ else
+ {
+ data[len++] = char('a' + rem - 10);
+ }
+
+ } while (_value != 0);
+
+ if (_max < len + 1)
+ {
+ return 0;
+ }
+
+ reverse(data, len);
+
+ memcpy(_dst, data, len);
+ _dst[len] = '\0';
+ return int32_t(len);
+ }
+
+} // namespace bx
diff --git a/3rdparty/bx/src/fpumath.cpp b/3rdparty/bx/src/fpumath.cpp
new file mode 100644
index 00000000000..da463e08767
--- /dev/null
+++ b/3rdparty/bx/src/fpumath.cpp
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2011-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#include <bx/fpumath.h>
+
+namespace bx
+{
+ const float pi = 3.14159265358979323846f;
+ const float invPi = 1.0f/3.14159265358979323846f;
+ const float piHalf = 1.57079632679489661923f;
+ const float sqrt2 = 1.41421356237309504880f;
+#if BX_COMPILER_MSVC
+ const float huge = float(HUGE_VAL);
+#else
+ const float huge = HUGE_VALF;
+#endif // BX_COMPILER_MSVC
+
+ void mtx3Inverse(float* __restrict _result, const float* __restrict _a)
+ {
+ float xx = _a[0];
+ float xy = _a[1];
+ float xz = _a[2];
+ float yx = _a[3];
+ float yy = _a[4];
+ float yz = _a[5];
+ float zx = _a[6];
+ float zy = _a[7];
+ float zz = _a[8];
+
+ float det = 0.0f;
+ det += xx * (yy*zz - yz*zy);
+ det -= xy * (yx*zz - yz*zx);
+ det += xz * (yx*zy - yy*zx);
+
+ float invDet = 1.0f/det;
+
+ _result[0] = +(yy*zz - yz*zy) * invDet;
+ _result[1] = -(xy*zz - xz*zy) * invDet;
+ _result[2] = +(xy*yz - xz*yy) * invDet;
+
+ _result[3] = -(yx*zz - yz*zx) * invDet;
+ _result[4] = +(xx*zz - xz*zx) * invDet;
+ _result[5] = -(xx*yz - xz*yx) * invDet;
+
+ _result[6] = +(yx*zy - yy*zx) * invDet;
+ _result[7] = -(xx*zy - xy*zx) * invDet;
+ _result[8] = +(xx*yy - xy*yx) * invDet;
+ }
+
+ void mtxInverse(float* __restrict _result, const float* __restrict _a)
+ {
+ float xx = _a[ 0];
+ float xy = _a[ 1];
+ float xz = _a[ 2];
+ float xw = _a[ 3];
+ float yx = _a[ 4];
+ float yy = _a[ 5];
+ float yz = _a[ 6];
+ float yw = _a[ 7];
+ float zx = _a[ 8];
+ float zy = _a[ 9];
+ float zz = _a[10];
+ float zw = _a[11];
+ float wx = _a[12];
+ float wy = _a[13];
+ float wz = _a[14];
+ float ww = _a[15];
+
+ float det = 0.0f;
+ det += xx * (yy*(zz*ww - zw*wz) - yz*(zy*ww - zw*wy) + yw*(zy*wz - zz*wy) );
+ det -= xy * (yx*(zz*ww - zw*wz) - yz*(zx*ww - zw*wx) + yw*(zx*wz - zz*wx) );
+ det += xz * (yx*(zy*ww - zw*wy) - yy*(zx*ww - zw*wx) + yw*(zx*wy - zy*wx) );
+ det -= xw * (yx*(zy*wz - zz*wy) - yy*(zx*wz - zz*wx) + yz*(zx*wy - zy*wx) );
+
+ float invDet = 1.0f/det;
+
+ _result[ 0] = +(yy*(zz*ww - wz*zw) - yz*(zy*ww - wy*zw) + yw*(zy*wz - wy*zz) ) * invDet;
+ _result[ 1] = -(xy*(zz*ww - wz*zw) - xz*(zy*ww - wy*zw) + xw*(zy*wz - wy*zz) ) * invDet;
+ _result[ 2] = +(xy*(yz*ww - wz*yw) - xz*(yy*ww - wy*yw) + xw*(yy*wz - wy*yz) ) * invDet;
+ _result[ 3] = -(xy*(yz*zw - zz*yw) - xz*(yy*zw - zy*yw) + xw*(yy*zz - zy*yz) ) * invDet;
+
+ _result[ 4] = -(yx*(zz*ww - wz*zw) - yz*(zx*ww - wx*zw) + yw*(zx*wz - wx*zz) ) * invDet;
+ _result[ 5] = +(xx*(zz*ww - wz*zw) - xz*(zx*ww - wx*zw) + xw*(zx*wz - wx*zz) ) * invDet;
+ _result[ 6] = -(xx*(yz*ww - wz*yw) - xz*(yx*ww - wx*yw) + xw*(yx*wz - wx*yz) ) * invDet;
+ _result[ 7] = +(xx*(yz*zw - zz*yw) - xz*(yx*zw - zx*yw) + xw*(yx*zz - zx*yz) ) * invDet;
+
+ _result[ 8] = +(yx*(zy*ww - wy*zw) - yy*(zx*ww - wx*zw) + yw*(zx*wy - wx*zy) ) * invDet;
+ _result[ 9] = -(xx*(zy*ww - wy*zw) - xy*(zx*ww - wx*zw) + xw*(zx*wy - wx*zy) ) * invDet;
+ _result[10] = +(xx*(yy*ww - wy*yw) - xy*(yx*ww - wx*yw) + xw*(yx*wy - wx*yy) ) * invDet;
+ _result[11] = -(xx*(yy*zw - zy*yw) - xy*(yx*zw - zx*yw) + xw*(yx*zy - zx*yy) ) * invDet;
+
+ _result[12] = -(yx*(zy*wz - wy*zz) - yy*(zx*wz - wx*zz) + yz*(zx*wy - wx*zy) ) * invDet;
+ _result[13] = +(xx*(zy*wz - wy*zz) - xy*(zx*wz - wx*zz) + xz*(zx*wy - wx*zy) ) * invDet;
+ _result[14] = -(xx*(yy*wz - wy*yz) - xy*(yx*wz - wx*yz) + xz*(yx*wy - wx*yy) ) * invDet;
+ _result[15] = +(xx*(yy*zz - zy*yz) - xy*(yx*zz - zx*yz) + xz*(yx*zy - zx*yy) ) * invDet;
+ }
+
+} // namespace bx
diff --git a/3rdparty/bx/src/mutex.cpp b/3rdparty/bx/src/mutex.cpp
new file mode 100644
index 00000000000..00e517684e2
--- /dev/null
+++ b/3rdparty/bx/src/mutex.cpp
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#include <bx/mutex.h>
+
+#if BX_CONFIG_SUPPORTS_THREADING
+
+#if 0 \
+ || BX_PLATFORM_ANDROID \
+ || BX_PLATFORM_LINUX \
+ || BX_PLATFORM_NACL \
+ || BX_PLATFORM_IOS \
+ || BX_PLATFORM_OSX
+# include <pthread.h>
+#elif 0 \
+ || BX_PLATFORM_WINDOWS \
+ || BX_PLATFORM_WINRT \
+ || BX_PLATFORM_XBOX360
+# include <errno.h>
+#endif // BX_PLATFORM_
+
+namespace bx
+{
+#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
+ typedef CRITICAL_SECTION pthread_mutex_t;
+ typedef unsigned pthread_mutexattr_t;
+
+ inline int pthread_mutex_lock(pthread_mutex_t* _mutex)
+ {
+ EnterCriticalSection(_mutex);
+ return 0;
+ }
+
+ inline int pthread_mutex_unlock(pthread_mutex_t* _mutex)
+ {
+ LeaveCriticalSection(_mutex);
+ return 0;
+ }
+
+ inline int pthread_mutex_trylock(pthread_mutex_t* _mutex)
+ {
+ return TryEnterCriticalSection(_mutex) ? 0 : EBUSY;
+ }
+
+ inline int pthread_mutex_init(pthread_mutex_t* _mutex, pthread_mutexattr_t* /*_attr*/)
+ {
+#if BX_PLATFORM_WINRT
+ InitializeCriticalSectionEx(_mutex, 4000, 0); // docs recommend 4000 spincount as sane default
+#else
+ InitializeCriticalSection(_mutex);
+#endif
+ return 0;
+ }
+
+ inline int pthread_mutex_destroy(pthread_mutex_t* _mutex)
+ {
+ DeleteCriticalSection(_mutex);
+ return 0;
+ }
+#endif // BX_PLATFORM_
+
+ Mutex::Mutex()
+ {
+ pthread_mutexattr_t attr;
+#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
+#else
+ pthread_mutexattr_init(&attr);
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+#endif // BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_WINRT
+ pthread_mutex_init(&m_handle, &attr);
+ }
+
+ Mutex::~Mutex()
+ {
+ pthread_mutex_destroy(&m_handle);
+ }
+
+ void Mutex::lock()
+ {
+ pthread_mutex_lock(&m_handle);
+ }
+
+ void Mutex::unlock()
+ {
+ pthread_mutex_unlock(&m_handle);
+ }
+
+} // namespace bx
+
+#endif // BX_MUTEX_H_HEADER_GUARD
diff --git a/3rdparty/bx/src/os.cpp b/3rdparty/bx/src/os.cpp
new file mode 100644
index 00000000000..5f1d45945b7
--- /dev/null
+++ b/3rdparty/bx/src/os.cpp
@@ -0,0 +1,454 @@
+/*
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#include <bx/os.h>
+#include <bx/uint32_t.h>
+#include <bx/string.h>
+
+#include <stdio.h>
+
+#if BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT
+# include <windows.h>
+# include <psapi.h>
+#elif BX_PLATFORM_ANDROID \
+ || BX_PLATFORM_EMSCRIPTEN \
+ || BX_PLATFORM_BSD \
+ || BX_PLATFORM_HURD \
+ || BX_PLATFORM_IOS \
+ || BX_PLATFORM_LINUX \
+ || BX_PLATFORM_NACL \
+ || BX_PLATFORM_OSX \
+ || BX_PLATFORM_PS4 \
+ || BX_PLATFORM_RPI \
+ || BX_PLATFORM_STEAMLINK
+# include <sched.h> // sched_yield
+# if BX_PLATFORM_BSD \
+ || BX_PLATFORM_IOS \
+ || BX_PLATFORM_NACL \
+ || BX_PLATFORM_OSX \
+ || BX_PLATFORM_PS4 \
+ || BX_PLATFORM_STEAMLINK
+# include <pthread.h> // mach_port_t
+# endif // BX_PLATFORM_*
+
+# include <time.h> // nanosleep
+# if !BX_PLATFORM_PS4 && !BX_PLATFORM_NACL
+# include <dlfcn.h> // dlopen, dlclose, dlsym
+# endif // !BX_PLATFORM_PS4 && !BX_PLATFORM_NACL
+
+# if BX_PLATFORM_ANDROID
+# include <malloc.h> // mallinfo
+# elif BX_PLATFORM_LINUX \
+ || BX_PLATFORM_RPI \
+ || BX_PLATFORM_STEAMLINK
+# include <unistd.h> // syscall
+# include <sys/syscall.h>
+# elif BX_PLATFORM_OSX
+# include <mach/mach.h> // mach_task_basic_info
+# elif BX_PLATFORM_HURD
+# include <pthread/pthread.h> // pthread_self
+# elif BX_PLATFORM_ANDROID
+# include "debug.h" // getTid is not implemented...
+# endif // BX_PLATFORM_ANDROID
+#endif // BX_PLATFORM_
+
+#if BX_CRT_MSVC
+# include <direct.h> // _getcwd
+#else
+# include <unistd.h> // getcwd
+#endif // BX_CRT_MSVC
+
+namespace bx
+{
+
+ void sleep(uint32_t _ms)
+ {
+#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360
+ ::Sleep(_ms);
+#elif BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
+ BX_UNUSED(_ms);
+ debugOutput("sleep is not implemented"); debugBreak();
+#else
+ timespec req = {(time_t)_ms/1000, (long)((_ms%1000)*1000000)};
+ timespec rem = {0, 0};
+ ::nanosleep(&req, &rem);
+#endif // BX_PLATFORM_
+ }
+
+ void yield()
+ {
+#if BX_PLATFORM_WINDOWS
+ ::SwitchToThread();
+#elif BX_PLATFORM_XBOX360
+ ::Sleep(0);
+#elif BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
+ debugOutput("yield is not implemented"); debugBreak();
+#else
+ ::sched_yield();
+#endif // BX_PLATFORM_
+ }
+
+ uint32_t getTid()
+ {
+#if BX_PLATFORM_WINDOWS
+ return ::GetCurrentThreadId();
+#elif BX_PLATFORM_LINUX || BX_PLATFORM_RPI || BX_PLATFORM_STEAMLINK
+ return (pid_t)::syscall(SYS_gettid);
+#elif BX_PLATFORM_IOS || BX_PLATFORM_OSX
+ return (mach_port_t)::pthread_mach_thread_np(pthread_self() );
+#elif BX_PLATFORM_BSD || BX_PLATFORM_NACL
+ // Casting __nc_basic_thread_data*... need better way to do this.
+ return *(uint32_t*)::pthread_self();
+#elif BX_PLATFORM_HURD
+ return (pthread_t)::pthread_self();
+#else
+//# pragma message "not implemented."
+ debugOutput("getTid is not implemented"); debugBreak();
+ return 0;
+#endif //
+ }
+
+ size_t getProcessMemoryUsed()
+ {
+#if BX_PLATFORM_ANDROID
+ struct mallinfo mi = mallinfo();
+ return mi.uordblks;
+#elif BX_PLATFORM_LINUX || BX_PLATFORM_HURD
+ FILE* file = fopen("/proc/self/statm", "r");
+ if (NULL == file)
+ {
+ return 0;
+ }
+
+ long pages = 0;
+ int items = fscanf(file, "%*s%ld", &pages);
+ fclose(file);
+ return 1 == items
+ ? pages * sysconf(_SC_PAGESIZE)
+ : 0
+ ;
+#elif BX_PLATFORM_OSX
+# if defined(MACH_TASK_BASIC_INFO)
+ mach_task_basic_info info;
+ mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT;
+
+ int const result = task_info(mach_task_self()
+ , MACH_TASK_BASIC_INFO
+ , (task_info_t)&info
+ , &infoCount
+ );
+# else // MACH_TASK_BASIC_INFO
+ task_basic_info info;
+ mach_msg_type_number_t infoCount = TASK_BASIC_INFO_COUNT;
+
+ int const result = task_info(mach_task_self()
+ , TASK_BASIC_INFO
+ , (task_info_t)&info
+ , &infoCount
+ );
+# endif // MACH_TASK_BASIC_INFO
+ if (KERN_SUCCESS != result)
+ {
+ return 0;
+ }
+
+ return info.resident_size;
+#elif BX_PLATFORM_WINDOWS
+ PROCESS_MEMORY_COUNTERS pmc;
+ GetProcessMemoryInfo(GetCurrentProcess()
+ , &pmc
+ , sizeof(pmc)
+ );
+ return pmc.WorkingSetSize;
+#else
+ return 0;
+#endif // BX_PLATFORM_*
+ }
+
+ void* dlopen(const char* _filePath)
+ {
+#if BX_PLATFORM_WINDOWS
+ return (void*)::LoadLibraryA(_filePath);
+#elif BX_PLATFORM_EMSCRIPTEN \
+ || BX_PLATFORM_NACL \
+ || BX_PLATFORM_PS4 \
+ || BX_PLATFORM_XBOXONE \
+ || BX_PLATFORM_WINRT
+ BX_UNUSED(_filePath);
+ return NULL;
+#else
+ return ::dlopen(_filePath, RTLD_LOCAL|RTLD_LAZY);
+#endif // BX_PLATFORM_
+ }
+
+ void dlclose(void* _handle)
+ {
+#if BX_PLATFORM_WINDOWS
+ ::FreeLibrary( (HMODULE)_handle);
+#elif BX_PLATFORM_EMSCRIPTEN \
+ || BX_PLATFORM_NACL \
+ || BX_PLATFORM_PS4 \
+ || BX_PLATFORM_XBOXONE \
+ || BX_PLATFORM_WINRT
+ BX_UNUSED(_handle);
+#else
+ ::dlclose(_handle);
+#endif // BX_PLATFORM_
+ }
+
+ void* dlsym(void* _handle, const char* _symbol)
+ {
+#if BX_PLATFORM_WINDOWS
+ return (void*)::GetProcAddress( (HMODULE)_handle, _symbol);
+#elif BX_PLATFORM_EMSCRIPTEN \
+ || BX_PLATFORM_NACL \
+ || BX_PLATFORM_PS4 \
+ || BX_PLATFORM_XBOXONE \
+ || BX_PLATFORM_WINRT
+ BX_UNUSED(_handle, _symbol);
+ return NULL;
+#else
+ return ::dlsym(_handle, _symbol);
+#endif // BX_PLATFORM_
+ }
+
+ bool getenv(const char* _name, char* _out, uint32_t* _inOutSize)
+ {
+#if BX_PLATFORM_WINDOWS
+ DWORD len = ::GetEnvironmentVariableA(_name, _out, *_inOutSize);
+ bool result = len != 0 && len < *_inOutSize;
+ *_inOutSize = len;
+ return result;
+#elif BX_PLATFORM_PS4 \
+ || BX_PLATFORM_XBOXONE \
+ || BX_PLATFORM_WINRT
+ BX_UNUSED(_name, _out, _inOutSize);
+ return false;
+#else
+ const char* ptr = ::getenv(_name);
+ uint32_t len = 0;
+ bool result = false;
+ if (NULL != ptr)
+ {
+ len = (uint32_t)strnlen(ptr);
+
+ result = len != 0 && len < *_inOutSize;
+ if (len < *_inOutSize)
+ {
+ strcpy(_out, ptr);
+ }
+ }
+
+ *_inOutSize = len;
+ return result;
+#endif // BX_PLATFORM_
+ }
+
+ void setenv(const char* _name, const char* _value)
+ {
+#if BX_PLATFORM_WINDOWS
+ ::SetEnvironmentVariableA(_name, _value);
+#elif BX_PLATFORM_PS4 \
+ || BX_PLATFORM_XBOXONE \
+ || BX_PLATFORM_WINRT
+ BX_UNUSED(_name, _value);
+#else
+ ::setenv(_name, _value, 1);
+#endif // BX_PLATFORM_
+ }
+
+ void unsetenv(const char* _name)
+ {
+#if BX_PLATFORM_WINDOWS
+ ::SetEnvironmentVariableA(_name, NULL);
+#elif BX_PLATFORM_PS4 \
+ || BX_PLATFORM_XBOXONE \
+ || BX_PLATFORM_WINRT
+ BX_UNUSED(_name);
+#else
+ ::unsetenv(_name);
+#endif // BX_PLATFORM_
+ }
+
+ int chdir(const char* _path)
+ {
+#if BX_PLATFORM_PS4 \
+ || BX_PLATFORM_XBOXONE \
+ || BX_PLATFORM_WINRT
+ BX_UNUSED(_path);
+ return -1;
+#elif BX_CRT_MSVC
+ return ::_chdir(_path);
+#else
+ return ::chdir(_path);
+#endif // BX_COMPILER_
+ }
+
+ char* pwd(char* _buffer, uint32_t _size)
+ {
+#if BX_PLATFORM_PS4 \
+ || BX_PLATFORM_XBOXONE \
+ || BX_PLATFORM_WINRT
+ BX_UNUSED(_buffer, _size);
+ return NULL;
+#elif BX_CRT_MSVC
+ return ::_getcwd(_buffer, (int)_size);
+#else
+ return ::getcwd(_buffer, _size);
+#endif // BX_COMPILER_
+ }
+
+ bool getTempPath(char* _out, uint32_t* _inOutSize)
+ {
+#if BX_PLATFORM_WINDOWS
+ uint32_t len = ::GetTempPathA(*_inOutSize, _out);
+ bool result = len != 0 && len < *_inOutSize;
+ *_inOutSize = len;
+ return result;
+#else
+ static const char* s_tmp[] =
+ {
+ "TMPDIR",
+ "TMP",
+ "TEMP",
+ "TEMPDIR",
+
+ NULL
+ };
+
+ for (const char** tmp = s_tmp; *tmp != NULL; ++tmp)
+ {
+ uint32_t len = *_inOutSize;
+ *_out = '\0';
+ bool result = getenv(*tmp, _out, &len);
+
+ if (result
+ && len != 0
+ && len < *_inOutSize)
+ {
+ *_inOutSize = len;
+ return result;
+ }
+ }
+
+ FileInfo fi;
+ if (stat("/tmp", fi)
+ && FileInfo::Directory == fi.m_type)
+ {
+ strlncpy(_out, *_inOutSize, "/tmp");
+ *_inOutSize = 4;
+ return true;
+ }
+
+ return false;
+#endif // BX_PLATFORM_*
+ }
+
+ bool stat(const char* _filePath, FileInfo& _fileInfo)
+ {
+ _fileInfo.m_size = 0;
+ _fileInfo.m_type = FileInfo::Count;
+
+#if BX_COMPILER_MSVC
+ struct ::_stat64 st;
+ int32_t result = ::_stat64(_filePath, &st);
+
+ if (0 != result)
+ {
+ return false;
+ }
+
+ if (0 != (st.st_mode & _S_IFREG) )
+ {
+ _fileInfo.m_type = FileInfo::Regular;
+ }
+ else if (0 != (st.st_mode & _S_IFDIR) )
+ {
+ _fileInfo.m_type = FileInfo::Directory;
+ }
+#else
+ struct ::stat st;
+ int32_t result = ::stat(_filePath, &st);
+ if (0 != result)
+ {
+ return false;
+ }
+
+ if (0 != (st.st_mode & S_IFREG) )
+ {
+ _fileInfo.m_type = FileInfo::Regular;
+ }
+ else if (0 != (st.st_mode & S_IFDIR) )
+ {
+ _fileInfo.m_type = FileInfo::Directory;
+ }
+#endif // BX_COMPILER_MSVC
+
+ _fileInfo.m_size = st.st_size;
+
+ return true;
+ }
+
+ void* exec(const char* const* _argv)
+ {
+#if BX_PLATFORM_LINUX || BX_PLATFORM_HURD
+ pid_t pid = fork();
+
+ if (0 == pid)
+ {
+ int result = execvp(_argv[0], const_cast<char *const*>(&_argv[1]) );
+ BX_UNUSED(result);
+ return NULL;
+ }
+
+ return (void*)uintptr_t(pid);
+#elif BX_PLATFORM_WINDOWS
+ STARTUPINFO si;
+ memset(&si, 0, sizeof(STARTUPINFO) );
+ si.cb = sizeof(STARTUPINFO);
+
+ PROCESS_INFORMATION pi;
+ memset(&pi, 0, sizeof(PROCESS_INFORMATION) );
+
+ int32_t total = 0;
+ for (uint32_t ii = 0; NULL != _argv[ii]; ++ii)
+ {
+ total += (int32_t)strnlen(_argv[ii]) + 1;
+ }
+
+ char* temp = (char*)alloca(total);
+ int32_t len = 0;
+ for(uint32_t ii = 0; NULL != _argv[ii]; ++ii)
+ {
+ len += snprintf(&temp[len], bx::uint32_imax(0, total-len)
+ , "%s "
+ , _argv[ii]
+ );
+ }
+
+ bool ok = !!CreateProcessA(_argv[0]
+ , temp
+ , NULL
+ , NULL
+ , false
+ , 0
+ , NULL
+ , NULL
+ , &si
+ , &pi
+ );
+ if (ok)
+ {
+ return pi.hProcess;
+ }
+
+ return NULL;
+#else
+ BX_UNUSED(_argv);
+ return NULL;
+#endif // BX_PLATFORM_LINUX || BX_PLATFORM_HURD
+ }
+
+} // namespace bx
diff --git a/3rdparty/bx/src/sem.cpp b/3rdparty/bx/src/sem.cpp
new file mode 100644
index 00000000000..2d3ca1574f8
--- /dev/null
+++ b/3rdparty/bx/src/sem.cpp
@@ -0,0 +1,221 @@
+/*
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#include <bx/sem.h>
+
+#if BX_CONFIG_SUPPORTS_THREADING
+
+#if BX_PLATFORM_POSIX
+# include <errno.h>
+# include <semaphore.h>
+# include <time.h>
+# include <pthread.h>
+#elif BX_PLATFORM_XBOXONE
+# include <synchapi.h>
+#elif BX_PLATFORM_XBOX360 || BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT
+# include <windows.h>
+# include <limits.h>
+#endif // BX_PLATFORM_
+
+namespace bx
+{
+#if BX_PLATFORM_POSIX
+
+# if BX_CONFIG_SEMAPHORE_PTHREAD
+ Semaphore::Semaphore()
+ : m_count(0)
+ {
+ int result;
+ result = pthread_mutex_init(&m_mutex, NULL);
+ BX_CHECK(0 == result, "pthread_mutex_init %d", result);
+
+ result = pthread_cond_init(&m_cond, NULL);
+ BX_CHECK(0 == result, "pthread_cond_init %d", result);
+
+ BX_UNUSED(result);
+ }
+
+ Semaphore::~Semaphore()
+ {
+ int result;
+ result = pthread_cond_destroy(&m_cond);
+ BX_CHECK(0 == result, "pthread_cond_destroy %d", result);
+
+ result = pthread_mutex_destroy(&m_mutex);
+ BX_CHECK(0 == result, "pthread_mutex_destroy %d", result);
+
+ BX_UNUSED(result);
+ }
+
+ void Semaphore::post(uint32_t _count)
+ {
+ int result = pthread_mutex_lock(&m_mutex);
+ BX_CHECK(0 == result, "pthread_mutex_lock %d", result);
+
+ for (uint32_t ii = 0; ii < _count; ++ii)
+ {
+ result = pthread_cond_signal(&m_cond);
+ BX_CHECK(0 == result, "pthread_cond_signal %d", result);
+ }
+
+ m_count += _count;
+
+ result = pthread_mutex_unlock(&m_mutex);
+ BX_CHECK(0 == result, "pthread_mutex_unlock %d", result);
+
+ BX_UNUSED(result);
+ }
+
+ bool Semaphore::wait(int32_t _msecs)
+ {
+ int result = pthread_mutex_lock(&m_mutex);
+ BX_CHECK(0 == result, "pthread_mutex_lock %d", result);
+
+# if BX_PLATFORM_NACL || BX_PLATFORM_OSX
+ BX_UNUSED(_msecs);
+ BX_CHECK(-1 == _msecs, "NaCl and OSX don't support pthread_cond_timedwait at this moment.");
+ while (0 == result
+ && 0 >= m_count)
+ {
+ result = pthread_cond_wait(&m_cond, &m_mutex);
+ }
+# elif BX_PLATFORM_IOS
+ if (-1 == _msecs)
+ {
+ while (0 == result
+ && 0 >= m_count)
+ {
+ result = pthread_cond_wait(&m_cond, &m_mutex);
+ }
+ }
+ else
+ {
+ timespec ts;
+ ts.tv_sec = _msecs/1000;
+ ts.tv_nsec = (_msecs%1000)*1000;
+
+ while (0 == result
+ && 0 >= m_count)
+ {
+ result = pthread_cond_timedwait_relative_np(&m_cond, &m_mutex, &ts);
+ }
+ }
+# else
+ timespec ts;
+ clock_gettime(CLOCK_REALTIME, &ts);
+ ts.tv_sec += _msecs/1000;
+ ts.tv_nsec += (_msecs%1000)*1000;
+
+ while (0 == result
+ && 0 >= m_count)
+ {
+ result = pthread_cond_timedwait(&m_cond, &m_mutex, &ts);
+ }
+# endif // BX_PLATFORM_NACL || BX_PLATFORM_OSX
+ bool ok = 0 == result;
+
+ if (ok)
+ {
+ --m_count;
+ }
+
+ result = pthread_mutex_unlock(&m_mutex);
+ BX_CHECK(0 == result, "pthread_mutex_unlock %d", result);
+
+ BX_UNUSED(result);
+
+ return ok;
+ }
+
+# else
+
+ Semaphore::Semaphore()
+ {
+ int32_t result = sem_init(&m_handle, 0, 0);
+ BX_CHECK(0 == result, "sem_init failed. errno %d", errno);
+ BX_UNUSED(result);
+ }
+
+ Semaphore::~Semaphore()
+ {
+ int32_t result = sem_destroy(&m_handle);
+ BX_CHECK(0 == result, "sem_destroy failed. errno %d", errno);
+ BX_UNUSED(result);
+ }
+
+ void Semaphore::post(uint32_t _count)
+ {
+ int32_t result;
+ for (uint32_t ii = 0; ii < _count; ++ii)
+ {
+ result = sem_post(&m_handle);
+ BX_CHECK(0 == result, "sem_post failed. errno %d", errno);
+ }
+ BX_UNUSED(result);
+ }
+
+ bool Semaphore::wait(int32_t _msecs)
+ {
+# if BX_PLATFORM_NACL || BX_PLATFORM_OSX
+ BX_CHECK(-1 == _msecs, "NaCl and OSX don't support sem_timedwait at this moment."); BX_UNUSED(_msecs);
+ return 0 == sem_wait(&m_handle);
+# else
+ if (0 > _msecs)
+ {
+ int32_t result;
+ do
+ {
+ result = sem_wait(&m_handle);
+ } // keep waiting when interrupted by a signal handler...
+ while (-1 == result && EINTR == errno);
+ BX_CHECK(0 == result, "sem_wait failed. errno %d", errno);
+ return 0 == result;
+ }
+
+ timespec ts;
+ clock_gettime(CLOCK_REALTIME, &ts);
+ ts.tv_sec += _msecs/1000;
+ ts.tv_nsec += (_msecs%1000)*1000;
+ return 0 == sem_timedwait(&m_handle, &ts);
+# endif // BX_PLATFORM_
+ }
+# endif // BX_CONFIG_SEMAPHORE_PTHREAD
+
+#elif BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT
+
+ Semaphore::Semaphore()
+ {
+#if BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
+ m_handle = CreateSemaphoreExW(NULL, 0, LONG_MAX, NULL, 0, SEMAPHORE_ALL_ACCESS);
+#else
+ m_handle = CreateSemaphoreA(NULL, 0, LONG_MAX, NULL);
+#endif
+ BX_CHECK(NULL != m_handle, "Failed to create Semaphore!");
+ }
+
+ Semaphore::~Semaphore()
+ {
+ CloseHandle(m_handle);
+ }
+
+ void Semaphore::post(uint32_t _count)
+ {
+ ReleaseSemaphore(m_handle, _count, NULL);
+ }
+
+ bool Semaphore::wait(int32_t _msecs)
+ {
+ DWORD milliseconds = (0 > _msecs) ? INFINITE : _msecs;
+#if BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
+ return WAIT_OBJECT_0 == WaitForSingleObjectEx(m_handle, milliseconds, FALSE);
+#else
+ return WAIT_OBJECT_0 == WaitForSingleObject(m_handle, milliseconds);
+#endif
+ }
+#endif // BX_PLATFORM_
+
+} // namespace bx
+
+#endif // BX_CONFIG_SUPPORTS_THREADING
diff --git a/3rdparty/bx/src/string.cpp b/3rdparty/bx/src/string.cpp
new file mode 100644
index 00000000000..c53a9de1155
--- /dev/null
+++ b/3rdparty/bx/src/string.cpp
@@ -0,0 +1,515 @@
+/*
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#include <bx/allocator.h>
+#include <bx/hash.h>
+#include <bx/readerwriter.h>
+#include <bx/string.h>
+
+#if !BX_CRT_NONE
+# include <stdio.h> // vsnprintf, vsnwprintf
+#endif // !BX_CRT_NONE
+
+namespace bx
+{
+ bool isSpace(char _ch)
+ {
+ return ' ' == _ch
+ || '\t' == _ch
+ || '\n' == _ch
+ || '\v' == _ch
+ || '\f' == _ch
+ || '\r' == _ch
+ ;
+ }
+
+ bool isUpper(char _ch)
+ {
+ return _ch >= 'A' && _ch <= 'Z';
+ }
+
+ bool isLower(char _ch)
+ {
+ return _ch >= 'a' && _ch <= 'z';
+ }
+
+ bool isAlpha(char _ch)
+ {
+ return isLower(_ch) || isUpper(_ch);
+ }
+
+ bool isNumeric(char _ch)
+ {
+ return _ch >= '0' && _ch <= '9';
+ }
+
+ bool isAlphaNum(char _ch)
+ {
+ return isAlpha(_ch) || isNumeric(_ch);
+ }
+
+ bool isPrint(char _ch)
+ {
+ return isAlphaNum(_ch) || isSpace(_ch);
+ }
+
+ char toLower(char _ch)
+ {
+ return _ch + (isUpper(_ch) ? 0x20 : 0);
+ }
+
+ char toUpper(char _ch)
+ {
+ return _ch - (isLower(_ch) ? 0x20 : 0);
+ }
+
+ bool toBool(const char* _str)
+ {
+ char ch = toLower(_str[0]);
+ return ch == 't' || ch == '1';
+ }
+
+ int32_t strncmp(const char* _lhs, const char* _rhs, size_t _max)
+ {
+ for (
+ ; 0 < _max && *_lhs == *_rhs
+ ; ++_lhs, ++_rhs, --_max
+ )
+ {
+ if (*_lhs == '\0'
+ || *_rhs == '\0')
+ {
+ break;
+ }
+ }
+
+ return 0 == _max ? 0 : *_lhs - *_rhs;
+ }
+
+ int32_t strincmp(const char* _lhs, const char* _rhs, size_t _max)
+ {
+ for (
+ ; 0 < _max && toLower(*_lhs) == toLower(*_rhs)
+ ; ++_lhs, ++_rhs, --_max
+ )
+ {
+ if (*_lhs == '\0'
+ || *_rhs == '\0')
+ {
+ break;
+ }
+ }
+
+ return 0 == _max ? 0 : *_lhs - *_rhs;
+ }
+
+ size_t strnlen(const char* _str, size_t _max)
+ {
+ const char* ptr;
+ for (ptr = _str; 0 < _max && *ptr != '\0'; ++ptr, --_max) {};
+ return ptr - _str;
+ }
+
+ size_t strlncpy(char* _dst, size_t _dstSize, const char* _src, size_t _num)
+ {
+ BX_CHECK(NULL != _dst, "_dst can't be NULL!");
+ BX_CHECK(NULL != _src, "_src can't be NULL!");
+ BX_CHECK(0 < _dstSize, "_dstSize can't be 0!");
+
+ const size_t len = strnlen(_src, _num);
+ const size_t max = _dstSize-1;
+ const size_t num = (len < max ? len : max);
+ memcpy(_dst, _src, num);
+ _dst[num] = '\0';
+
+ return num;
+ }
+
+ size_t strlncat(char* _dst, size_t _dstSize, const char* _src, size_t _num)
+ {
+ BX_CHECK(NULL != _dst, "_dst can't be NULL!");
+ BX_CHECK(NULL != _src, "_src can't be NULL!");
+ BX_CHECK(0 < _dstSize, "_dstSize can't be 0!");
+
+ const size_t max = _dstSize;
+ const size_t len = strnlen(_dst, max);
+ return strlncpy(&_dst[len], max-len, _src, _num);
+ }
+
+ const char* strnchr(const char* _str, char _ch, size_t _max)
+ {
+ for (size_t ii = 0, len = strnlen(_str, _max); ii < len; ++ii)
+ {
+ if (_str[ii] == _ch)
+ {
+ return &_str[ii];
+ }
+ }
+
+ return NULL;
+ }
+
+ const char* strnrchr(const char* _str, char _ch, size_t _max)
+ {
+ for (size_t ii = strnlen(_str, _max); 0 < ii; --ii)
+ {
+ if (_str[ii] == _ch)
+ {
+ return &_str[ii];
+ }
+ }
+
+ return NULL;
+ }
+
+ const char* strnstr(const char* _str, const char* _find, size_t _max)
+ {
+ const char* ptr = _str;
+
+ size_t stringLen = strnlen(_str, _max);
+ const size_t findLen = strnlen(_find);
+
+ for (; stringLen >= findLen; ++ptr, --stringLen)
+ {
+ // Find start of the string.
+ while (*ptr != *_find)
+ {
+ ++ptr;
+ --stringLen;
+
+ // Search pattern lenght can't be longer than the string.
+ if (findLen > stringLen)
+ {
+ return NULL;
+ }
+ }
+
+ // Set pointers.
+ const char* string = ptr;
+ const char* search = _find;
+
+ // Start comparing.
+ while (*string++ == *search++)
+ {
+ // If end of the 'search' string is reached, all characters match.
+ if ('\0' == *search)
+ {
+ return ptr;
+ }
+ }
+ }
+
+ return NULL;
+ }
+
+ const char* stristr(const char* _str, const char* _find, size_t _max)
+ {
+ const char* ptr = _str;
+
+ size_t stringLen = strnlen(_str, _max);
+ const size_t findLen = strnlen(_find);
+
+ for (; stringLen >= findLen; ++ptr, --stringLen)
+ {
+ // Find start of the string.
+ while (toLower(*ptr) != toLower(*_find) )
+ {
+ ++ptr;
+ --stringLen;
+
+ // Search pattern lenght can't be longer than the string.
+ if (findLen > stringLen)
+ {
+ return NULL;
+ }
+ }
+
+ // Set pointers.
+ const char* string = ptr;
+ const char* search = _find;
+
+ // Start comparing.
+ while (toLower(*string++) == toLower(*search++) )
+ {
+ // If end of the 'search' string is reached, all characters match.
+ if ('\0' == *search)
+ {
+ return ptr;
+ }
+ }
+ }
+
+ return NULL;
+ }
+
+ const char* strnl(const char* _str)
+ {
+ for (; '\0' != *_str; _str += strnlen(_str, 1024) )
+ {
+ const char* eol = strnstr(_str, "\r\n", 1024);
+ if (NULL != eol)
+ {
+ return eol + 2;
+ }
+
+ eol = strnstr(_str, "\n", 1024);
+ if (NULL != eol)
+ {
+ return eol + 1;
+ }
+ }
+
+ return _str;
+ }
+
+ const char* streol(const char* _str)
+ {
+ for (; '\0' != *_str; _str += strnlen(_str, 1024) )
+ {
+ const char* eol = strnstr(_str, "\r\n", 1024);
+ if (NULL != eol)
+ {
+ return eol;
+ }
+
+ eol = strnstr(_str, "\n", 1024);
+ if (NULL != eol)
+ {
+ return eol;
+ }
+ }
+
+ return _str;
+ }
+
+ const char* strws(const char* _str)
+ {
+ for (; isSpace(*_str); ++_str) {};
+ return _str;
+ }
+
+ const char* strnws(const char* _str)
+ {
+ for (; !isSpace(*_str); ++_str) {};
+ return _str;
+ }
+
+ const char* strword(const char* _str)
+ {
+ for (char ch = *_str++; isAlphaNum(ch) || '_' == ch; ch = *_str++) {};
+ return _str-1;
+ }
+
+ const char* strmb(const char* _str, char _open, char _close)
+ {
+ int count = 0;
+ for (char ch = *_str++; ch != '\0' && count >= 0; ch = *_str++)
+ {
+ if (ch == _open)
+ {
+ count++;
+ }
+ else if (ch == _close)
+ {
+ count--;
+ if (0 == count)
+ {
+ return _str-1;
+ }
+ }
+ }
+
+ return NULL;
+ }
+
+ void eolLF(char* _out, size_t _size, const char* _str)
+ {
+ if (0 < _size)
+ {
+ char* end = _out + _size - 1;
+ for (char ch = *_str++; ch != '\0' && _out < end; ch = *_str++)
+ {
+ if ('\r' != ch)
+ {
+ *_out++ = ch;
+ }
+ }
+
+ *_out = '\0';
+ }
+ }
+
+ const char* findIdentifierMatch(const char* _str, const char* _word)
+ {
+ size_t len = strnlen(_word);
+ const char* ptr = strnstr(_str, _word);
+ for (; NULL != ptr; ptr = strnstr(ptr + len, _word) )
+ {
+ if (ptr != _str)
+ {
+ char ch = *(ptr - 1);
+ if (isAlphaNum(ch) || '_' == ch)
+ {
+ continue;
+ }
+ }
+
+ char ch = ptr[len];
+ if (isAlphaNum(ch) || '_' == ch)
+ {
+ continue;
+ }
+
+ return ptr;
+ }
+
+ return ptr;
+ }
+
+ const char* findIdentifierMatch(const char* _str, const char* _words[])
+ {
+ for (const char* word = *_words; NULL != word; ++_words, word = *_words)
+ {
+ const char* match = findIdentifierMatch(_str, word);
+ if (NULL != match)
+ {
+ return match;
+ }
+ }
+
+ return NULL;
+ }
+
+ int32_t write(WriterI* _writer, const char* _format, va_list _argList, Error* _err);
+
+ int32_t vsnprintfRef(char* _out, size_t _max, const char* _format, va_list _argList)
+ {
+ if (1 < _max)
+ {
+ StaticMemoryBlockWriter writer(_out, _max-1);
+ _out[_max-1] = '\0';
+
+ Error err;
+ va_list argListCopy;
+ va_copy(argListCopy, _argList);
+ int32_t size = write(&writer, _format, argListCopy, &err);
+ va_end(argListCopy);
+
+ if (err.isOk() )
+ {
+ return size;
+ }
+ }
+
+ Error err;
+ SizerWriter sizer;
+ va_list argListCopy;
+ va_copy(argListCopy, _argList);
+ int32_t size = write(&sizer, _format, argListCopy, &err);
+ va_end(argListCopy);
+
+ return size - 1 /* size without '\0' terminator */;
+ }
+
+ int32_t vsnprintf(char* _out, size_t _max, const char* _format, va_list _argList)
+ {
+#if BX_CRT_NONE
+ return vsnprintfRef(_out, _max, _format, _argList);
+#elif BX_CRT_MSVC
+ int32_t len = -1;
+ if (NULL != _out)
+ {
+ va_list argListCopy;
+ va_copy(argListCopy, _argList);
+ len = ::vsnprintf_s(_out, _max, size_t(-1), _format, argListCopy);
+ va_end(argListCopy);
+ }
+ return -1 == len ? ::_vscprintf(_format, _argList) : len;
+#else
+ return ::vsnprintf(_out, _max, _format, _argList);
+#endif // BX_COMPILER_MSVC
+ }
+
+ int32_t snprintf(char* _out, size_t _max, const char* _format, ...)
+ {
+ va_list argList;
+ va_start(argList, _format);
+ int32_t len = vsnprintf(_out, _max, _format, argList);
+ va_end(argList);
+ return len;
+ }
+
+ int32_t vsnwprintf(wchar_t* _out, size_t _max, const wchar_t* _format, va_list _argList)
+ {
+#if BX_CRT_NONE
+ BX_UNUSED(_out, _max, _format, _argList);
+ return 0;
+#elif BX_CRT_MSVC
+ int32_t len = -1;
+ if (NULL != _out)
+ {
+ va_list argListCopy;
+ va_copy(argListCopy, _argList);
+ len = ::_vsnwprintf_s(_out, _max, size_t(-1), _format, argListCopy);
+ va_end(argListCopy);
+ }
+ return -1 == len ? ::_vscwprintf(_format, _argList) : len;
+#elif BX_CRT_MINGW
+ return ::vsnwprintf(_out, _max, _format, _argList);
+#else
+ return ::vswprintf(_out, _max, _format, _argList);
+#endif // BX_COMPILER_MSVC
+ }
+
+ int32_t swnprintf(wchar_t* _out, size_t _max, const wchar_t* _format, ...)
+ {
+ va_list argList;
+ va_start(argList, _format);
+ int32_t len = vsnwprintf(_out, _max, _format, argList);
+ va_end(argList);
+ return len;
+ }
+
+ const char* baseName(const char* _filePath)
+ {
+ const char* bs = strnrchr(_filePath, '\\');
+ const char* fs = strnrchr(_filePath, '/');
+ const char* slash = (bs > fs ? bs : fs);
+ const char* colon = strnrchr(_filePath, ':');
+ const char* basename = slash > colon ? slash : colon;
+ if (NULL != basename)
+ {
+ return basename+1;
+ }
+
+ return _filePath;
+ }
+
+ void prettify(char* _out, size_t _count, uint64_t _size)
+ {
+ uint8_t idx = 0;
+ double size = double(_size);
+ while (_size != (_size&0x7ff)
+ && idx < 9)
+ {
+ _size >>= 10;
+ size *= 1.0/1024.0;
+ ++idx;
+ }
+
+ snprintf(_out, _count, "%0.2f %c%c", size, "BkMGTPEZY"[idx], idx > 0 ? 'B' : '\0');
+ }
+
+ size_t strlcpy(char* _dst, const char* _src, size_t _max)
+ {
+ return strlncpy(_dst, _max, _src);
+ }
+
+ size_t strlcat(char* _dst, const char* _src, size_t _max)
+ {
+ return strlncat(_dst, _max, _src);
+ }
+
+} // namespace bx
diff --git a/3rdparty/bx/src/thread.cpp b/3rdparty/bx/src/thread.cpp
new file mode 100644
index 00000000000..fea7e8b606c
--- /dev/null
+++ b/3rdparty/bx/src/thread.cpp
@@ -0,0 +1,208 @@
+/*
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#include <bx/thread.h>
+
+#if BX_CONFIG_SUPPORTS_THREADING
+
+namespace bx
+{
+ Thread::Thread()
+#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
+ : m_handle(INVALID_HANDLE_VALUE)
+ , m_threadId(UINT32_MAX)
+#elif BX_PLATFORM_POSIX
+ : m_handle(0)
+#endif // BX_PLATFORM_
+ , m_fn(NULL)
+ , m_userData(NULL)
+ , m_stackSize(0)
+ , m_exitCode(0 /*EXIT_SUCCESS*/)
+ , m_running(false)
+ {
+ }
+
+ Thread::~Thread()
+ {
+ if (m_running)
+ {
+ shutdown();
+ }
+ }
+
+ void Thread::init(ThreadFn _fn, void* _userData, uint32_t _stackSize, const char* _name)
+ {
+ BX_CHECK(!m_running, "Already running!");
+
+ m_fn = _fn;
+ m_userData = _userData;
+ m_stackSize = _stackSize;
+ m_running = true;
+
+#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE
+ m_handle = ::CreateThread(NULL
+ , m_stackSize
+ , (LPTHREAD_START_ROUTINE)threadFunc
+ , this
+ , 0
+ , NULL
+ );
+#elif BX_PLATFORM_WINRT
+ m_handle = CreateEventEx(nullptr, nullptr, CREATE_EVENT_MANUAL_RESET, EVENT_ALL_ACCESS);
+ auto workItemHandler = ref new WorkItemHandler([=](IAsyncAction^)
+ {
+ m_exitCode = threadFunc(this);
+ SetEvent(m_handle);
+ }, CallbackContext::Any);
+
+ ThreadPool::RunAsync(workItemHandler, WorkItemPriority::Normal, WorkItemOptions::TimeSliced);
+#elif BX_PLATFORM_POSIX
+ int result;
+ BX_UNUSED(result);
+
+ pthread_attr_t attr;
+ result = pthread_attr_init(&attr);
+ BX_CHECK(0 == result, "pthread_attr_init failed! %d", result);
+
+ if (0 != m_stackSize)
+ {
+ result = pthread_attr_setstacksize(&attr, m_stackSize);
+ BX_CHECK(0 == result, "pthread_attr_setstacksize failed! %d", result);
+ }
+
+ // sched_param sched;
+ // sched.sched_priority = 0;
+ // result = pthread_attr_setschedparam(&attr, &sched);
+ // BX_CHECK(0 == result, "pthread_attr_setschedparam failed! %d", result);
+
+ result = pthread_create(&m_handle, &attr, &threadFunc, this);
+ BX_CHECK(0 == result, "pthread_attr_setschedparam failed! %d", result);
+#else
+# error "Not implemented!"
+#endif // BX_PLATFORM_
+
+ m_sem.wait();
+
+ if (NULL != _name)
+ {
+ setThreadName(_name);
+ }
+ }
+
+ void Thread::shutdown()
+ {
+ BX_CHECK(m_running, "Not running!");
+#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360
+ WaitForSingleObject(m_handle, INFINITE);
+ GetExitCodeThread(m_handle, (DWORD*)&m_exitCode);
+ CloseHandle(m_handle);
+ m_handle = INVALID_HANDLE_VALUE;
+#elif BX_PLATFORM_WINRT
+ WaitForSingleObjectEx(m_handle, INFINITE, FALSE);
+ CloseHandle(m_handle);
+ m_handle = INVALID_HANDLE_VALUE;
+#elif BX_PLATFORM_POSIX
+ union
+ {
+ void* ptr;
+ int32_t i;
+ } cast;
+ pthread_join(m_handle, &cast.ptr);
+ m_exitCode = cast.i;
+ m_handle = 0;
+#endif // BX_PLATFORM_
+ m_running = false;
+ }
+
+ bool Thread::isRunning() const
+ {
+ return m_running;
+ }
+
+ int32_t Thread::getExitCode() const
+ {
+ return m_exitCode;
+ }
+
+ void Thread::setThreadName(const char* _name)
+ {
+#if BX_PLATFORM_OSX || BX_PLATFORM_IOS
+ pthread_setname_np(_name);
+#elif (BX_CRT_GLIBC >= 21200) && ! BX_PLATFORM_HURD
+ pthread_setname_np(m_handle, _name);
+#elif BX_PLATFORM_LINUX
+ prctl(PR_SET_NAME,_name, 0, 0, 0);
+#elif BX_PLATFORM_BSD
+# ifdef __NetBSD__
+ pthread_setname_np(m_handle, "%s", (void*)_name);
+# else
+ pthread_set_name_np(m_handle, _name);
+# endif // __NetBSD__
+#elif BX_PLATFORM_WINDOWS && BX_COMPILER_MSVC
+# pragma pack(push, 8)
+ struct ThreadName
+ {
+ DWORD type;
+ LPCSTR name;
+ DWORD id;
+ DWORD flags;
+ };
+# pragma pack(pop)
+ ThreadName tn;
+ tn.type = 0x1000;
+ tn.name = _name;
+ tn.id = m_threadId;
+ tn.flags = 0;
+
+ __try
+ {
+ RaiseException(0x406d1388
+ , 0
+ , sizeof(tn)/4
+ , reinterpret_cast<ULONG_PTR*>(&tn)
+ );
+ }
+ __except(EXCEPTION_EXECUTE_HANDLER)
+ {
+ }
+#else
+ BX_UNUSED(_name);
+#endif // BX_PLATFORM_
+ }
+
+ int32_t Thread::entry()
+ {
+#if BX_PLATFORM_WINDOWS
+ m_threadId = ::GetCurrentThreadId();
+#endif // BX_PLATFORM_WINDOWS
+
+ m_sem.post();
+ return m_fn(m_userData);
+ }
+
+#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
+ DWORD WINAPI Thread::threadFunc(LPVOID _arg)
+ {
+ Thread* thread = (Thread*)_arg;
+ int32_t result = thread->entry();
+ return result;
+ }
+#else
+ void* Thread::threadFunc(void* _arg)
+ {
+ Thread* thread = (Thread*)_arg;
+ union
+ {
+ void* ptr;
+ int32_t i;
+ } cast;
+ cast.i = thread->entry();
+ return cast.ptr;
+ }
+#endif // BX_PLATFORM_
+
+} // namespace bx
+
+#endif // BX_CONFIG_SUPPORTS_THREADING
diff --git a/3rdparty/bx/tests/dbg.cpp b/3rdparty/bx/tests/dbg.cpp
deleted file mode 100644
index 58e3f034a86..00000000000
--- a/3rdparty/bx/tests/dbg.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2011-2017 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
- */
-
-#include <stdio.h>
-#include <stdint.h>
-#include <inttypes.h>
-#include <ctype.h> // isprint
-
-#include "dbg.h"
-#include <bx/string.h>
-#include <bx/debug.h>
-
-void dbgPrintfVargs(const char* _format, va_list _argList)
-{
- char temp[8192];
- char* out = temp;
- int32_t len = bx::vsnprintf(out, sizeof(temp), _format, _argList);
- if ( (int32_t)sizeof(temp) < len)
- {
- out = (char*)alloca(len+1);
- len = bx::vsnprintf(out, len, _format, _argList);
- }
- out[len] = '\0';
- bx::debugOutput(out);
-}
-
-void dbgPrintf(const char* _format, ...)
-{
- va_list argList;
- va_start(argList, _format);
- dbgPrintfVargs(_format, argList);
- va_end(argList);
-}
-
-#define DBG_ADDRESS "%" PRIxPTR
-
-void dbgPrintfData(const void* _data, uint32_t _size, const char* _format, ...)
-{
-#define HEX_DUMP_WIDTH 16
-#define HEX_DUMP_SPACE_WIDTH 48
-#define HEX_DUMP_FORMAT "%-" DBG_STRINGIZE(HEX_DUMP_SPACE_WIDTH) "." DBG_STRINGIZE(HEX_DUMP_SPACE_WIDTH) "s"
-
- va_list argList;
- va_start(argList, _format);
- dbgPrintfVargs(_format, argList);
- va_end(argList);
-
- dbgPrintf("\ndata: " DBG_ADDRESS ", size: %d\n", _data, _size);
-
- if (NULL != _data)
- {
- const uint8_t* data = reinterpret_cast<const uint8_t*>(_data);
- char hex[HEX_DUMP_WIDTH*3+1];
- char ascii[HEX_DUMP_WIDTH+1];
- uint32_t hexPos = 0;
- uint32_t asciiPos = 0;
- for (uint32_t ii = 0; ii < _size; ++ii)
- {
- bx::snprintf(&hex[hexPos], sizeof(hex)-hexPos, "%02x ", data[asciiPos]);
- hexPos += 3;
-
- ascii[asciiPos] = isprint(data[asciiPos]) ? data[asciiPos] : '.';
- asciiPos++;
-
- if (HEX_DUMP_WIDTH == asciiPos)
- {
- ascii[asciiPos] = '\0';
- dbgPrintf("\t" DBG_ADDRESS "\t" HEX_DUMP_FORMAT "\t%s\n", data, hex, ascii);
- data += asciiPos;
- hexPos = 0;
- asciiPos = 0;
- }
- }
-
- if (0 != asciiPos)
- {
- ascii[asciiPos] = '\0';
- dbgPrintf("\t" DBG_ADDRESS "\t" HEX_DUMP_FORMAT "\t%s\n", data, hex, ascii);
- }
- }
-
-#undef HEX_DUMP_WIDTH
-#undef HEX_DUMP_SPACE_WIDTH
-#undef HEX_DUMP_FORMAT
-}
diff --git a/3rdparty/bx/tests/dbg.h b/3rdparty/bx/tests/dbg.h
index 21f4433820b..9ae46b35bbe 100644
--- a/3rdparty/bx/tests/dbg.h
+++ b/3rdparty/bx/tests/dbg.h
@@ -6,16 +6,11 @@
#ifndef DBG_H_HEADER_GUARD
#define DBG_H_HEADER_GUARD
-#include <stdarg.h> // va_list
-#include <stdint.h>
+#include <bx/debug.h>
#define DBG_STRINGIZE(_x) DBG_STRINGIZE_(_x)
#define DBG_STRINGIZE_(_x) #_x
#define DBG_FILE_LINE_LITERAL "" __FILE__ "(" DBG_STRINGIZE(__LINE__) "): "
-#define DBG(_format, ...) dbgPrintf(DBG_FILE_LINE_LITERAL "" _format "\n", ##__VA_ARGS__)
-
-extern void dbgPrintfVargs(const char* _format, va_list _argList);
-extern void dbgPrintf(const char* _format, ...);
-extern void dbgPrintfData(const void* _data, uint32_t _size, const char* _format, ...);
+#define DBG(_format, ...) bx::debugPrintf(DBG_FILE_LINE_LITERAL "" _format "\n", ##__VA_ARGS__)
#endif // DBG_H_HEADER_GUARD
diff --git a/3rdparty/bx/tests/fpumath_test.cpp b/3rdparty/bx/tests/fpumath_test.cpp
index f41cea8ba91..ae843872e43 100644
--- a/3rdparty/bx/tests/fpumath_test.cpp
+++ b/3rdparty/bx/tests/fpumath_test.cpp
@@ -6,6 +6,26 @@
#include "test.h"
#include <bx/fpumath.h>
+#if !BX_COMPILER_MSVC || BX_COMPILER_MSVC >= 1800
+#include <cmath>
+TEST_CASE("isFinite, isInfinite, isNan", "")
+{
+ for (uint64_t ii = 0; ii < UINT32_MAX; ii += rand()%(1<<13)+1)
+ {
+ union { uint32_t ui; float f; } u = { uint32_t(ii) };
+ REQUIRE(std::isnan(u.f) == bx::isNan(u.f) );
+ REQUIRE(std::isfinite(u.f) == bx::isFinite(u.f) );
+ REQUIRE(std::isinf(u.f) == bx::isInfinite(u.f) );
+ }
+}
+#endif // !BX_COMPILER_MSVC || BX_COMPILER_MSVC >= 1800
+
+TEST_CASE("ToBits", "")
+{
+ REQUIRE(UINT32_C(0x12345678) == bx::floatToBits( bx::bitsToFloat( UINT32_C(0x12345678) ) ) );
+ REQUIRE(UINT64_C(0x123456789abcdef0) == bx::doubleToBits(bx::bitsToDouble(UINT32_C(0x123456789abcdef0) ) ) );
+}
+
void mtxCheck(const float* _a, const float* _b)
{
if (!bx::fequal(_a, _b, 16, 0.01f) )
@@ -35,7 +55,7 @@ void mtxCheck(const float* _a, const float* _b)
}
}
-TEST(Quaternion)
+TEST_CASE("quaternion", "")
{
float mtxQ[16];
float mtx[16];
diff --git a/3rdparty/bx/tests/handle_bench.cpp b/3rdparty/bx/tests/handle_bench.cpp
index a882cbe635d..6169bc45c53 100644
--- a/3rdparty/bx/tests/handle_bench.cpp
+++ b/3rdparty/bx/tests/handle_bench.cpp
@@ -28,13 +28,13 @@ int main()
for (uint32_t jj = 0; jj < numElements; ++jj)
{
tinystl::pair<TinyStlUnorderedMap::iterator, bool> ok = map.insert(tinystl::make_pair(uint64_t(jj), uint16_t(jj) ) );
- assert(ok.second);
+ assert(ok.second); BX_UNUSED(ok);
}
for (uint32_t jj = 0; jj < numElements; ++jj)
{
bool ok = bx::mapRemove(map, uint64_t(jj) );
- assert(ok);
+ assert(ok); BX_UNUSED(ok);
}
assert(map.size() == 0);
@@ -56,13 +56,13 @@ int main()
for (uint32_t jj = 0; jj < numElements; ++jj)
{
std::pair<StdUnorderedMap::iterator, bool> ok = map.insert(std::make_pair(uint64_t(jj), uint16_t(jj) ) );
- assert(ok.second);
+ assert(ok.second); BX_UNUSED(ok);
}
for (uint32_t jj = 0; jj < numElements; ++jj)
{
bool ok = bx::mapRemove(map, uint64_t(jj) );
- assert(ok);
+ assert(ok); BX_UNUSED(ok);
}
assert(map.size() == 0);
@@ -83,13 +83,13 @@ int main()
for (uint32_t jj = 0; jj < numElements; ++jj)
{
bool ok = map.insert(jj, uint16_t(jj) );
- assert(ok);
+ assert(ok); BX_UNUSED(ok);
}
for (uint32_t jj = 0; jj < numElements; ++jj)
{
bool ok = map.removeByKey(uint64_t(jj) );
- assert(ok);
+ assert(ok); BX_UNUSED(ok);
}
assert(map.getNumElements() == 0);
diff --git a/3rdparty/bx/tests/misc_test.cpp b/3rdparty/bx/tests/misc_test.cpp
deleted file mode 100644
index aec1067a022..00000000000
--- a/3rdparty/bx/tests/misc_test.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "test.h"
-#include <bx/os.h>
-
-TEST(getProcessMemoryUsed)
-{
- CHECK(0 != bx::getProcessMemoryUsed() );
-// DBG("bx::getProcessMemoryUsed %d", bx::getProcessMemoryUsed() );
-}
diff --git a/3rdparty/bx/tests/os_test.cpp b/3rdparty/bx/tests/os_test.cpp
new file mode 100644
index 00000000000..e6aeb314fbe
--- /dev/null
+++ b/3rdparty/bx/tests/os_test.cpp
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#include "test.h"
+#include <bx/os.h>
+
+TEST_CASE("getProcessMemoryUsed", "")
+{
+ REQUIRE(0 != bx::getProcessMemoryUsed() );
+// DBG("bx::getProcessMemoryUsed %d", bx::getProcessMemoryUsed() );
+}
+
+TEST_CASE("getTempPath", "")
+{
+ char tmpDir[512];
+ uint32_t len = BX_COUNTOF(tmpDir);
+ REQUIRE(bx::getTempPath(tmpDir, &len) );
+}
diff --git a/3rdparty/bx/tests/string_test.cpp b/3rdparty/bx/tests/string_test.cpp
index ed83e86cc4d..bea72044e54 100644
--- a/3rdparty/bx/tests/string_test.cpp
+++ b/3rdparty/bx/tests/string_test.cpp
@@ -10,6 +10,19 @@
bx::AllocatorI* g_allocator;
+TEST_CASE("chars", "")
+{
+ for (char ch = 'A'; ch <= 'Z'; ++ch)
+ {
+ REQUIRE(!bx::isLower(ch) );
+ REQUIRE(!bx::isNumeric(ch) );
+ REQUIRE(bx::isUpper(ch) );
+ REQUIRE(bx::isAlpha(ch) );
+ REQUIRE(bx::isAlphaNum(ch) );
+ REQUIRE(bx::isLower(bx::toLower(ch) ) );
+ }
+}
+
TEST_CASE("strnlen", "")
{
const char* test = "test";
@@ -40,6 +53,129 @@ TEST_CASE("strlncpy", "")
REQUIRE(num == 4);
}
+TEST_CASE("strlncat", "")
+{
+ char dst[128] = { '\0' };
+
+ REQUIRE(0 == bx::strlncat(dst, 1, "cat") );
+
+ REQUIRE(4 == bx::strlncpy(dst, 5, "copy") );
+ REQUIRE(3 == bx::strlncat(dst, 8, "cat") );
+ REQUIRE(0 == bx::strncmp(dst, "copycat") );
+
+ REQUIRE(1 == bx::strlncat(dst, BX_COUNTOF(dst), "------", 1) );
+ REQUIRE(3 == bx::strlncat(dst, BX_COUNTOF(dst), "cat") );
+ REQUIRE(0 == bx::strncmp(dst, "copycat-cat") );
+}
+
+TEST_CASE("strincmp", "")
+{
+ REQUIRE(0 == bx::strincmp("test", "test") );
+ REQUIRE(0 == bx::strincmp("test", "testestes", 4) );
+ REQUIRE(0 == bx::strincmp("testestes", "test", 4) );
+ REQUIRE(0 != bx::strincmp("preprocess", "platform") );
+
+ const char* abvgd = "abvgd";
+ const char* abvgx = "abvgx";
+ const char* empty = "";
+ REQUIRE(0 == bx::strincmp(abvgd, abvgd) );
+ REQUIRE(0 == bx::strincmp(abvgd, abvgx, 4) );
+
+ REQUIRE(0 > bx::strincmp(abvgd, abvgx) );
+ REQUIRE(0 > bx::strincmp(empty, abvgd) );
+
+ REQUIRE(0 < bx::strincmp(abvgx, abvgd) );
+ REQUIRE(0 < bx::strincmp(abvgd, empty) );
+}
+
+TEST_CASE("strnchr", "")
+{
+ const char* test = "test";
+ REQUIRE(NULL == bx::strnchr(test, 's', 0) );
+ REQUIRE(NULL == bx::strnchr(test, 's', 2) );
+ REQUIRE(&test[2] == bx::strnchr(test, 's') );
+}
+
+TEST_CASE("strnrchr", "")
+{
+ const char* test = "test";
+ REQUIRE(NULL == bx::strnrchr(test, 's', 0) );
+ REQUIRE(NULL == bx::strnrchr(test, 's', 1) );
+ REQUIRE(&test[2] == bx::strnrchr(test, 's') );
+}
+
+TEST_CASE("stristr", "")
+{
+ const char* test = "The Quick Brown Fox Jumps Over The Lazy Dog.";
+
+ REQUIRE(NULL == bx::stristr(test, "quick", 8) );
+ REQUIRE(NULL == bx::stristr(test, "quick1") );
+ REQUIRE(&test[4] == bx::stristr(test, "quick", 9) );
+ REQUIRE(&test[4] == bx::stristr(test, "quick") );
+}
+
+TEST_CASE("strnstr", "")
+{
+ const char* test = "The Quick Brown Fox Jumps Over The Lazy Dog.";
+
+ REQUIRE(NULL == bx::strnstr(test, "quick", 8) );
+ REQUIRE(NULL == bx::strnstr(test, "quick1") );
+ REQUIRE(NULL == bx::strnstr(test, "quick", 9) );
+ REQUIRE(NULL == bx::strnstr(test, "quick") );
+
+ REQUIRE(NULL == bx::strnstr(test, "Quick", 8) );
+ REQUIRE(NULL == bx::strnstr(test, "Quick1") );
+ REQUIRE(&test[4] == bx::strnstr(test, "Quick", 9) );
+ REQUIRE(&test[4] == bx::strnstr(test, "Quick") );
+}
+
+template<typename Ty>
+static bool testToString(Ty _value, const char* _expected)
+{
+ char tmp[1024];
+ int32_t num = bx::toString(tmp, BX_COUNTOF(tmp), _value);
+ int32_t len = (int32_t)bx::strnlen(_expected);
+ return true
+ && 0 == bx::strncmp(tmp, _expected)
+ && num == len
+ ;
+}
+
+TEST_CASE("toString int32_t/uint32_t", "")
+{
+ REQUIRE(testToString(0, "0") );
+ REQUIRE(testToString(-256, "-256") );
+ REQUIRE(testToString(INT32_MAX, "2147483647") );
+ REQUIRE(testToString(UINT32_MAX, "4294967295") );
+}
+
+TEST_CASE("toString double", "")
+{
+ REQUIRE(testToString(0.0, "0.0") );
+ REQUIRE(testToString(-0.0, "0.0") );
+ REQUIRE(testToString(1.0, "1.0") );
+ REQUIRE(testToString(-1.0, "-1.0") );
+ REQUIRE(testToString(1.2345, "1.2345") );
+ REQUIRE(testToString(1.2345678, "1.2345678") );
+ REQUIRE(testToString(0.123456789012, "0.123456789012") );
+ REQUIRE(testToString(1234567.8, "1234567.8") );
+ REQUIRE(testToString(-79.39773355813419, "-79.39773355813419") );
+ REQUIRE(testToString(0.000001, "0.000001") );
+ REQUIRE(testToString(0.0000001, "1e-7") );
+ REQUIRE(testToString(1e30, "1e30") );
+ REQUIRE(testToString(1.234567890123456e30, "1.234567890123456e30") );
+ REQUIRE(testToString(-5e-324, "-5e-324") );
+ REQUIRE(testToString(2.225073858507201e-308, "2.225073858507201e-308") );
+ REQUIRE(testToString(2.2250738585072014e-308, "2.2250738585072014e-308") );
+ REQUIRE(testToString(1.7976931348623157e308, "1.7976931348623157e308") );
+ REQUIRE(testToString(0.00000123123123, "0.00000123123123") );
+ REQUIRE(testToString(0.000000123123123, "1.23123123e-7") );
+ REQUIRE(testToString(123123.123, "123123.123") );
+ REQUIRE(testToString(1231231.23, "1231231.23") );
+ REQUIRE(testToString(0.000000000123123, "1.23123e-10") );
+ REQUIRE(testToString(0.0000000001, "1e-10") );
+}
+
TEST_CASE("StringView", "")
{
bx::StringView sv("test");
diff --git a/3rdparty/bx/tests/test.h b/3rdparty/bx/tests/test.h
index 33c3cf7cbc0..db710195023 100644
--- a/3rdparty/bx/tests/test.h
+++ b/3rdparty/bx/tests/test.h
@@ -13,8 +13,4 @@
#include "dbg.h"
-#if !BX_COMPILER_MSVC
-# define _strdup strdup
-#endif // !BX_COMPILER_MSVC
-
#endif // __TEST_H__
diff --git a/3rdparty/bx/tests/tokenizecmd_test.cpp b/3rdparty/bx/tests/tokenizecmd_test.cpp
index 12502502a1a..7d35ac7484c 100644
--- a/3rdparty/bx/tests/tokenizecmd_test.cpp
+++ b/3rdparty/bx/tests/tokenizecmd_test.cpp
@@ -4,7 +4,6 @@
*/
#include "test.h"
-#include <bx/tokenizecmd.h>
#include <bx/commandline.h>
#include <string.h>
@@ -14,6 +13,8 @@ TEST(commandLine)
{
"-s",
"--long",
+ "--platform",
+ "x",
};
bx::CommandLine cmdLine(BX_COUNTOF(args), args);
@@ -23,6 +24,7 @@ TEST(commandLine)
// non-existing argument
CHECK(!cmdLine.hasArg('x') );
+ CHECK(!cmdLine.hasArg("preprocess") );
}
TEST(tokenizeCommandLine)
diff --git a/3rdparty/bx/tests/uint32_test.cpp b/3rdparty/bx/tests/uint32_test.cpp
index 0c2be1e9cb7..ae214b88c22 100644
--- a/3rdparty/bx/tests/uint32_test.cpp
+++ b/3rdparty/bx/tests/uint32_test.cpp
@@ -6,47 +6,66 @@
#include "test.h"
#include <bx/uint32_t.h>
-TEST(StrideAlign)
+TEST_CASE("StrideAlign")
{
- CHECK(0 == bx::strideAlign(0, 12) );
+ REQUIRE(0 == bx::strideAlign(0, 12) );
for (uint32_t ii = 0; ii < 12; ++ii)
{
- CHECK(12 == bx::strideAlign(ii+1, 12) );
+ REQUIRE(12 == bx::strideAlign(ii+1, 12) );
}
- CHECK(0 == bx::strideAlign16(0, 12) );
+ REQUIRE(0 == bx::strideAlign16(0, 12) );
for (uint32_t ii = 0; ii < 12; ++ii)
{
- CHECK(48 == bx::strideAlign16(ii+1, 12) );
+ REQUIRE(48 == bx::strideAlign16(ii+1, 12) );
}
}
-TEST(uint32_cnt)
+TEST_CASE("uint32_cnt")
{
- CHECK( 0 == bx::uint32_cnttz(UINT32_C(1) ) );
- CHECK( 0 == bx::uint32_cnttz_ref(UINT32_C(1) ) );
+ REQUIRE( 0 == bx::uint32_cnttz(UINT32_C(1) ) );
+ REQUIRE( 0 == bx::uint32_cnttz_ref(UINT32_C(1) ) );
- CHECK(31 == bx::uint32_cntlz(UINT32_C(1) ) );
- CHECK(31 == bx::uint32_cntlz_ref(UINT32_C(1) ) );
+ REQUIRE(31 == bx::uint32_cntlz(UINT32_C(1) ) );
+ REQUIRE(31 == bx::uint32_cntlz_ref(UINT32_C(1) ) );
- CHECK( 0 == bx::uint64_cnttz(UINT64_C(1) ) );
- CHECK( 0 == bx::uint64_cnttz_ref(UINT64_C(1) ) );
+ REQUIRE( 0 == bx::uint64_cnttz(UINT64_C(1) ) );
+ REQUIRE( 0 == bx::uint64_cnttz_ref(UINT64_C(1) ) );
- CHECK(63 == bx::uint64_cntlz(UINT64_C(1) ) );
- CHECK(63 == bx::uint64_cntlz_ref(UINT64_C(1) ) );
+ REQUIRE(63 == bx::uint64_cntlz(UINT64_C(1) ) );
+ REQUIRE(63 == bx::uint64_cntlz_ref(UINT64_C(1) ) );
- CHECK( 1 == bx::uint32_cntbits(1) );
- CHECK( 1 == bx::uint32_cntbits_ref(1) );
+ REQUIRE( 1 == bx::uint32_cntbits(1) );
+ REQUIRE( 1 == bx::uint32_cntbits_ref(1) );
- CHECK(16 == bx::uint32_cntbits(UINT16_MAX) );
- CHECK(16 == bx::uint32_cntbits_ref(UINT16_MAX) );
+ REQUIRE(16 == bx::uint32_cntbits(UINT16_MAX) );
+ REQUIRE(16 == bx::uint32_cntbits_ref(UINT16_MAX) );
- CHECK(32 == bx::uint32_cntbits(UINT32_MAX) );
- CHECK(32 == bx::uint32_cntbits_ref(UINT32_MAX) );
+ REQUIRE(32 == bx::uint32_cntbits(UINT32_MAX) );
+ REQUIRE(32 == bx::uint32_cntbits_ref(UINT32_MAX) );
}
-TEST(uint32_part)
+TEST_CASE("uint32_part")
{
- CHECK(UINT32_C(0x55555555) == bx::uint32_part1by1(UINT16_MAX) );
- CHECK(UINT32_C(0x09249249) == bx::uint32_part1by2(0x3ff) );
+ REQUIRE(UINT32_C(0x55555555) == bx::uint32_part1by1(UINT16_MAX) );
+ REQUIRE(UINT32_C(0x09249249) == bx::uint32_part1by2(0x3ff) );
+}
+
+TEST_CASE("halfTo/FromFloat", "")
+{
+ for (uint32_t ii = 0; ii < 0x7c00; ++ii)
+ {
+ const uint16_t orig = uint16_t(ii);
+ const float htf = bx::halfToFloat(orig);
+ const uint16_t hff = bx::halfFromFloat(htf);
+ REQUIRE(orig == hff);
+ }
+
+ for (uint32_t ii = 0x8000; ii < 0xfc00; ++ii)
+ {
+ const uint16_t orig = uint16_t(ii);
+ const float htf = bx::halfToFloat(orig);
+ const uint16_t hff = bx::halfFromFloat(htf);
+ REQUIRE(orig == hff);
+ }
}
diff --git a/3rdparty/bx/tests/vector_complex_test.cpp b/3rdparty/bx/tests/vector_complex_test.cpp
index 8deaa3fd3ff..a540ece8a40 100644
--- a/3rdparty/bx/tests/vector_complex_test.cpp
+++ b/3rdparty/bx/tests/vector_complex_test.cpp
@@ -33,6 +33,10 @@
#include <string.h>
#include <stdlib.h>
+#if !BX_COMPILER_MSVC
+# define _strdup strdup
+#endif // !BX_COMPILER_MSVC
+
struct complex {
complex() {data = 0;}
complex(const char* s) { data = strdup(s); }
@@ -156,7 +160,7 @@ TEST(vector_complex_popback) {
v.push_back("24");
CHECK(v.back() == "24");
-
+
v.pop_back();
CHECK(v.back() == "12");
diff --git a/3rdparty/bx/tests/vsnprintf_test.cpp b/3rdparty/bx/tests/vsnprintf_test.cpp
new file mode 100644
index 00000000000..db1fba6fdad
--- /dev/null
+++ b/3rdparty/bx/tests/vsnprintf_test.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ */
+
+#include "test.h"
+#include <bx/string.h>
+
+TEST_CASE("vsnprintf NULL buffer", "No output buffer provided.")
+{
+ REQUIRE(4 == bx::snprintf(NULL, 0, "test") );
+
+ REQUIRE(1 == bx::snprintf(NULL, 0, "%d", 1) );
+}
+
+TEST_CASE("vsnprintf truncated", "Truncated output buffer.")
+{
+ char buffer[7];
+
+ REQUIRE(10 == bx::snprintf(buffer, BX_COUNTOF(buffer), "Ten chars!") );
+ REQUIRE(0 == strcmp(buffer, "Ten ch") );
+}
+
+static bool test(const char* _expected, const char* _format, ...)
+{
+ int32_t max = (int32_t)strlen(_expected) + 1;
+ char* temp = (char*)alloca(max);
+
+ va_list argList;
+ va_start(argList, _format);
+ int32_t len = bx::vsnprintf(temp, max, _format, argList);
+ va_end(argList);
+
+ bool result = true
+ && len == max-1
+ && 0 == strcmp(_expected, temp)
+ ;
+
+ if (!result)
+ {
+ printf("result (%d) %s, expected (%d) %s\n", len, temp, max-1, _expected);
+ }
+
+ return result;
+}
+
+TEST_CASE("vsnprintf f", "")
+{
+ REQUIRE(test("1.337", "%0.3f", 1.337) );
+ REQUIRE(test(" 13.370", "%8.3f", 13.37) );
+ REQUIRE(test(" 13.370", "%*.*f", 8, 3, 13.37) );
+ REQUIRE(test("13.370 ", "%-8.3f", 13.37) );
+ REQUIRE(test("13.370 ", "%*.*f", -8, 3, 13.37) );
+}
+
+TEST_CASE("vsnprintf d/u/x", "")
+{
+ REQUIRE(test("1337", "%d", 1337) );
+
+ REQUIRE(test("1337", "%x", 0x1337) );
+}
+
+TEST_CASE("vsnprintf", "")
+{
+ REQUIRE(test("x", "%c", 'x') );
+
+ REQUIRE(test("hello, world!", "%s, %s!", "hello", "world") );
+}
diff --git a/3rdparty/bx/tools/bin/darwin/genie b/3rdparty/bx/tools/bin/darwin/genie
index 842ca082bdf..97c6f1279b9 100755
--- a/3rdparty/bx/tools/bin/darwin/genie
+++ b/3rdparty/bx/tools/bin/darwin/genie
Binary files differ
diff --git a/3rdparty/bx/tools/bin/linux/genie b/3rdparty/bx/tools/bin/linux/genie
index 7feeebbd006..3fa52f00f4f 100755
--- a/3rdparty/bx/tools/bin/linux/genie
+++ b/3rdparty/bx/tools/bin/linux/genie
Binary files differ
diff --git a/3rdparty/bx/tools/bin/windows/genie.exe b/3rdparty/bx/tools/bin/windows/genie.exe
index ad7d65824d6..19d6f15c6cd 100644
--- a/3rdparty/bx/tools/bin/windows/genie.exe
+++ b/3rdparty/bx/tools/bin/windows/genie.exe
Binary files differ