├── .clang-format ├── .gitattributes ├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── BuildAll.py ├── CI └── AzurePipelines │ └── ContinuousBuild.yml ├── CMakeLists.txt ├── CONTRIBUTING.md ├── Doc └── Arch.svg ├── External ├── CMakeLists.txt ├── DirectXShaderCompiler.cmake ├── SPIRV-Cross.cmake ├── SPIRV-Header.cmake ├── SPIRV-Tools.cmake ├── cxxopts.cmake └── googletest.cmake ├── Include └── ShaderConductor │ └── ShaderConductor.hpp ├── LICENSE ├── README.md ├── SECURITY.md ├── Source ├── CMakeLists.txt ├── Core │ ├── CMakeLists.txt │ └── ShaderConductor.cpp ├── Tests │ ├── CMakeLists.txt │ ├── Data │ │ ├── Expected │ │ │ ├── CalcLight+Diffuse.Debug.dxilasm │ │ │ ├── CalcLight+Diffuse.Release.dxilasm │ │ │ ├── CalcLight+DiffuseSpecular.Debug.dxilasm │ │ │ ├── CalcLight+DiffuseSpecular.Release.dxilasm │ │ │ ├── Constant_PS.30.hlsl │ │ │ ├── Constant_PS.300.essl │ │ │ ├── Constant_PS.300.glsl │ │ │ ├── Constant_PS.310.essl │ │ │ ├── Constant_PS.40.hlsl │ │ │ ├── Constant_PS.410.glsl │ │ │ ├── Constant_PS.50.hlsl │ │ │ ├── Constant_PS.msl │ │ │ ├── Constant_VS.30.hlsl │ │ │ ├── Constant_VS.300.essl │ │ │ ├── Constant_VS.300.glsl │ │ │ ├── Constant_VS.310.essl │ │ │ ├── Constant_VS.40.hlsl │ │ │ ├── Constant_VS.410.glsl │ │ │ ├── Constant_VS.50.hlsl │ │ │ ├── Constant_VS.msl │ │ │ ├── DetailTessellation_HS.300.essl │ │ │ ├── DetailTessellation_HS.300.glsl │ │ │ ├── DetailTessellation_HS.310.essl │ │ │ ├── DetailTessellation_HS.410.glsl │ │ │ ├── DetailTessellation_HS.msl │ │ │ ├── DotHalfPS.glsl │ │ │ ├── Fluid_CS.300.glsl │ │ │ ├── Fluid_CS.310.essl │ │ │ ├── Fluid_CS.410.glsl │ │ │ ├── Fluid_CS.50.hlsl │ │ │ ├── Fluid_CS.msl │ │ │ ├── HalfOutParamPS.glsl │ │ │ ├── IncludeEmptyHeader.glsl │ │ │ ├── IncludeExist.glsl │ │ │ ├── PNTriangles_DS.300.essl │ │ │ ├── PNTriangles_DS.300.glsl │ │ │ ├── PNTriangles_DS.310.essl │ │ │ ├── PNTriangles_DS.410.glsl │ │ │ ├── PNTriangles_DS.msl │ │ │ ├── Particle_GS.300.essl │ │ │ ├── Particle_GS.300.glsl │ │ │ ├── Particle_GS.310.essl │ │ │ ├── Particle_GS.410.glsl │ │ │ ├── PassThrough_PS.30.hlsl │ │ │ ├── PassThrough_PS.300.essl │ │ │ ├── PassThrough_PS.300.glsl │ │ │ ├── PassThrough_PS.310.essl │ │ │ ├── PassThrough_PS.40.hlsl │ │ │ ├── PassThrough_PS.410.glsl │ │ │ ├── PassThrough_PS.50.hlsl │ │ │ ├── PassThrough_PS.msl │ │ │ ├── PassThrough_VS.30.hlsl │ │ │ ├── PassThrough_VS.300.essl │ │ │ ├── PassThrough_VS.300.glsl │ │ │ ├── PassThrough_VS.310.essl │ │ │ ├── PassThrough_VS.40.hlsl │ │ │ ├── PassThrough_VS.410.glsl │ │ │ ├── PassThrough_VS.50.hlsl │ │ │ ├── PassThrough_VS.msl │ │ │ ├── ToneMapping_PS.30.hlsl │ │ │ ├── ToneMapping_PS.300.essl │ │ │ ├── ToneMapping_PS.300.glsl │ │ │ ├── ToneMapping_PS.310.essl │ │ │ ├── ToneMapping_PS.40.hlsl │ │ │ ├── ToneMapping_PS.410.glsl │ │ │ ├── ToneMapping_PS.50.hlsl │ │ │ ├── ToneMapping_PS.msl │ │ │ ├── Transform_VS.30.hlsl │ │ │ ├── Transform_VS.300.essl │ │ │ ├── Transform_VS.300.glsl │ │ │ ├── Transform_VS.310.essl │ │ │ ├── Transform_VS.40.hlsl │ │ │ ├── Transform_VS.410.glsl │ │ │ ├── Transform_VS.50.hlsl │ │ │ ├── Transform_VS.msl │ │ │ └── Transform_VS_ColumnMajor.300.glsl │ │ ├── Input │ │ │ ├── CalcLight.hlsl │ │ │ ├── CalcLightDiffuse.hlsl │ │ │ ├── CalcLightDiffuseSpecular.hlsl │ │ │ ├── Common.hlsli │ │ │ ├── Constant_PS.hlsl │ │ │ ├── Constant_VS.hlsl │ │ │ ├── DetailTessellation_HS.hlsl │ │ │ ├── Fluid_CS.hlsl │ │ │ ├── HalfDataType.hlsl │ │ │ ├── Inc │ │ │ │ ├── HeaderA.hlsli │ │ │ │ ├── HeaderB.hlsli │ │ │ │ └── HeaderEmpty.hlsli │ │ │ ├── IncludeEmptyHeader.hlsl │ │ │ ├── IncludeExist.hlsl │ │ │ ├── IncludeNotExist.hlsl │ │ │ ├── PNTriangles_DS.hlsl │ │ │ ├── Particle_GS.hlsl │ │ │ ├── PassThrough_PS.hlsl │ │ │ ├── PassThrough_VS.hlsl │ │ │ ├── ToneMapping_PS.hlsl │ │ │ └── Transform_VS.hlsl │ │ └── Result │ │ │ └── .gitignore │ └── ShaderConductorTest.cpp ├── Tools │ ├── CMakeLists.txt │ └── ShaderConductorCmd.cpp └── Wrapper │ ├── CMakeLists.txt │ ├── Native.cpp │ ├── Native.h │ ├── Program.cs │ ├── Wrapper.cs │ └── shader.hlsl └── azure-pipelines.yml /.clang-format: -------------------------------------------------------------------------------- 1 | AccessModifierOffset: -4 2 | AllowShortFunctionsOnASingleLine: None 3 | AllowShortIfStatementsOnASingleLine: false 4 | AllowShortLoopsOnASingleLine: false 5 | AlwaysBreakTemplateDeclarations: true 6 | BreakBeforeBraces: Allman 7 | ColumnLimit: 140 8 | Cpp11BracedListStyle: true 9 | IndentWidth: 4 10 | Language: Cpp 11 | MaxEmptyLinesToKeep: 2 12 | NamespaceIndentation: All 13 | PointerAlignment: Left 14 | SpaceBeforeParens: ControlStatements 15 | Standard: Cpp11 16 | TabWidth: 4 17 | UseTab: Never 18 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.hpp text 3 | *.cpp text 4 | *.hlsl text 5 | *.glsl text 6 | *.msl text 7 | *.dxil binary 8 | *.spv binary 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | A clear and concise description of what the bug is. 9 | 10 | **To Reproduce** 11 | Steps to reproduce the behavior: 12 | 1. Your input shader 13 | 2. Full parameters 14 | 15 | **Expected behavior** 16 | A clear and concise description of what you expected to happen. 17 | 18 | **Additional context** 19 | Add any other context about the problem here. 20 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015/2017 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # Visual Studio 2017 auto generated files 33 | Generated\ Files/ 34 | 35 | # MSTest test Results 36 | [Tt]est[Rr]esult*/ 37 | [Bb]uild[Ll]og.* 38 | 39 | # NUNIT 40 | *.VisualState.xml 41 | TestResult.xml 42 | 43 | # Build Results of an ATL Project 44 | [Dd]ebugPS/ 45 | [Rr]eleasePS/ 46 | dlldata.c 47 | 48 | # Benchmark Results 49 | BenchmarkDotNet.Artifacts/ 50 | 51 | # .NET Core 52 | project.lock.json 53 | project.fragment.lock.json 54 | artifacts/ 55 | **/Properties/launchSettings.json 56 | 57 | # StyleCop 58 | StyleCopReport.xml 59 | 60 | # Files built by Visual Studio 61 | *_i.c 62 | *_p.c 63 | *_i.h 64 | *.ilk 65 | *.meta 66 | *.obj 67 | *.iobj 68 | *.pch 69 | *.pdb 70 | *.ipdb 71 | *.pgc 72 | *.pgd 73 | *.rsp 74 | *.sbr 75 | *.tlb 76 | *.tli 77 | *.tlh 78 | *.tmp 79 | *.tmp_proj 80 | *.log 81 | *.vspscc 82 | *.vssscc 83 | .builds 84 | *.pidb 85 | *.svclog 86 | *.scc 87 | 88 | # Chutzpah Test files 89 | _Chutzpah* 90 | 91 | # Visual C++ cache files 92 | ipch/ 93 | *.aps 94 | *.ncb 95 | *.opendb 96 | *.opensdf 97 | *.sdf 98 | *.cachefile 99 | *.VC.db 100 | *.VC.VC.opendb 101 | 102 | # Visual Studio profiler 103 | *.psess 104 | *.vsp 105 | *.vspx 106 | *.sap 107 | 108 | # Visual Studio Trace Files 109 | *.e2e 110 | 111 | # TFS 2012 Local Workspace 112 | $tf/ 113 | 114 | # Guidance Automation Toolkit 115 | *.gpState 116 | 117 | # ReSharper is a .NET coding add-in 118 | _ReSharper*/ 119 | *.[Rr]e[Ss]harper 120 | *.DotSettings.user 121 | 122 | # JustCode is a .NET coding add-in 123 | .JustCode 124 | 125 | # TeamCity is a build add-in 126 | _TeamCity* 127 | 128 | # DotCover is a Code Coverage Tool 129 | *.dotCover 130 | 131 | # AxoCover is a Code Coverage Tool 132 | .axoCover/* 133 | !.axoCover/settings.json 134 | 135 | # Visual Studio code coverage results 136 | *.coverage 137 | *.coveragexml 138 | 139 | # NCrunch 140 | _NCrunch_* 141 | .*crunch*.local.xml 142 | nCrunchTemp_* 143 | 144 | # MightyMoose 145 | *.mm.* 146 | AutoTest.Net/ 147 | 148 | # Web workbench (sass) 149 | .sass-cache/ 150 | 151 | # Installshield output folder 152 | [Ee]xpress/ 153 | 154 | # DocProject is a documentation generator add-in 155 | DocProject/buildhelp/ 156 | DocProject/Help/*.HxT 157 | DocProject/Help/*.HxC 158 | DocProject/Help/*.hhc 159 | DocProject/Help/*.hhk 160 | DocProject/Help/*.hhp 161 | DocProject/Help/Html2 162 | DocProject/Help/html 163 | 164 | # Click-Once directory 165 | publish/ 166 | 167 | # Publish Web Output 168 | *.[Pp]ublish.xml 169 | *.azurePubxml 170 | # Note: Comment the next line if you want to checkin your web deploy settings, 171 | # but database connection strings (with potential passwords) will be unencrypted 172 | *.pubxml 173 | *.publishproj 174 | 175 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 176 | # checkin your Azure Web App publish settings, but sensitive information contained 177 | # in these scripts will be unencrypted 178 | PublishScripts/ 179 | 180 | # NuGet Packages 181 | *.nupkg 182 | # The packages folder can be ignored because of Package Restore 183 | **/[Pp]ackages/* 184 | # except build/, which is used as an MSBuild target. 185 | !**/[Pp]ackages/build/ 186 | # Uncomment if necessary however generally it will be regenerated when needed 187 | #!**/[Pp]ackages/repositories.config 188 | # NuGet v3's project.json files produces more ignorable files 189 | *.nuget.props 190 | *.nuget.targets 191 | 192 | # Microsoft Azure Build Output 193 | csx/ 194 | *.build.csdef 195 | 196 | # Microsoft Azure Emulator 197 | ecf/ 198 | rcf/ 199 | 200 | # Windows Store app package directories and files 201 | AppPackages/ 202 | BundleArtifacts/ 203 | Package.StoreAssociation.xml 204 | _pkginfo.txt 205 | *.appx 206 | 207 | # Visual Studio cache files 208 | # files ending in .cache can be ignored 209 | *.[Cc]ache 210 | # but keep track of directories ending in .cache 211 | !*.[Cc]ache/ 212 | 213 | # Others 214 | ClientBin/ 215 | ~$* 216 | *~ 217 | *.dbmdl 218 | *.dbproj.schemaview 219 | *.jfm 220 | *.pfx 221 | *.publishsettings 222 | orleans.codegen.cs 223 | 224 | # Including strong name files can present a security risk 225 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 226 | #*.snk 227 | 228 | # Since there are multiple workflows, uncomment next line to ignore bower_components 229 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 230 | #bower_components/ 231 | 232 | # RIA/Silverlight projects 233 | Generated_Code/ 234 | 235 | # Backup & report files from converting an old project file 236 | # to a newer Visual Studio version. Backup files are not needed, 237 | # because we have git ;-) 238 | _UpgradeReport_Files/ 239 | Backup*/ 240 | UpgradeLog*.XML 241 | UpgradeLog*.htm 242 | ServiceFabricBackup/ 243 | *.rptproj.bak 244 | 245 | # SQL Server files 246 | *.mdf 247 | *.ldf 248 | *.ndf 249 | 250 | # Business Intelligence projects 251 | *.rdl.data 252 | *.bim.layout 253 | *.bim_*.settings 254 | *.rptproj.rsuser 255 | 256 | # Microsoft Fakes 257 | FakesAssemblies/ 258 | 259 | # GhostDoc plugin setting file 260 | *.GhostDoc.xml 261 | 262 | # Node.js Tools for Visual Studio 263 | .ntvs_analysis.dat 264 | node_modules/ 265 | 266 | # Visual Studio 6 build log 267 | *.plg 268 | 269 | # Visual Studio 6 workspace options file 270 | *.opt 271 | 272 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 273 | *.vbw 274 | 275 | # Visual Studio LightSwitch build output 276 | **/*.HTMLClient/GeneratedArtifacts 277 | **/*.DesktopClient/GeneratedArtifacts 278 | **/*.DesktopClient/ModelManifest.xml 279 | **/*.Server/GeneratedArtifacts 280 | **/*.Server/ModelManifest.xml 281 | _Pvt_Extensions 282 | 283 | # Paket dependency manager 284 | .paket/paket.exe 285 | paket-files/ 286 | 287 | # FAKE - F# Make 288 | .fake/ 289 | 290 | # JetBrains Rider 291 | .idea/ 292 | *.sln.iml 293 | 294 | # CodeRush 295 | .cr/ 296 | 297 | # Python Tools for Visual Studio (PTVS) 298 | __pycache__/ 299 | *.pyc 300 | 301 | # Cake - Uncomment if you are using it 302 | # tools/** 303 | # !tools/packages.config 304 | 305 | # Tabs Studio 306 | *.tss 307 | 308 | # Telerik's JustMock configuration file 309 | *.jmconfig 310 | 311 | # BizTalk build output 312 | *.btp.cs 313 | *.btm.cs 314 | *.odx.cs 315 | *.xsd.cs 316 | 317 | # OpenCover UI analysis results 318 | OpenCover/ 319 | 320 | # Azure Stream Analytics local run output 321 | ASALocalRun/ 322 | 323 | # MSBuild Binary and Structured Log 324 | *.binlog 325 | 326 | # NVidia Nsight GPU debugger configuration file 327 | *.nvuser 328 | 329 | # MFractors (Xamarin productivity tool) working folder 330 | .mfractor/ 331 | 332 | # 333 | /External/ 334 | /Build/ 335 | -------------------------------------------------------------------------------- /BuildAll.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #-*- coding: ascii -*- 3 | 4 | # ShaderConductor 5 | # Copyright (c) Microsoft Corporation. All rights reserved. 6 | # Licensed under the MIT License. 7 | 8 | import multiprocessing, os, platform, subprocess, sys 9 | 10 | def LogError(message): 11 | print("[E] %s" % message) 12 | sys.stdout.flush() 13 | if 0 == sys.platform.find("win"): 14 | pauseCmd = "pause" 15 | else: 16 | pauseCmd = "read" 17 | subprocess.call(pauseCmd, shell = True) 18 | sys.exit(1) 19 | 20 | def LogInfo(message): 21 | print("[I] %s" % message) 22 | sys.stdout.flush() 23 | 24 | def LogWarning(message): 25 | print("[W] %s" % message) 26 | sys.stdout.flush() 27 | 28 | def FindProgramFilesFolder(): 29 | env = os.environ 30 | if "64bit" == platform.architecture()[0]: 31 | if "ProgramFiles(x86)" in env: 32 | programFilesFolder = env["ProgramFiles(x86)"] 33 | else: 34 | programFilesFolder = "C:\Program Files (x86)" 35 | else: 36 | if "ProgramFiles" in env: 37 | programFilesFolder = env["ProgramFiles"] 38 | else: 39 | programFilesFolder = "C:\Program Files" 40 | return programFilesFolder 41 | 42 | def FindVS2017OrUpFolder(programFilesFolder, vsVersion, vsName): 43 | tryVswhereLocation = programFilesFolder + "\\Microsoft Visual Studio\\Installer\\vswhere.exe" 44 | if os.path.exists(tryVswhereLocation): 45 | vsLocation = subprocess.check_output([tryVswhereLocation, 46 | "-latest", 47 | "-requires", "Microsoft.VisualStudio.Component.VC.Tools.x86.x64", 48 | "-property", "installationPath", 49 | "-version", "[%d.0,%d.0)" % (vsVersion, vsVersion + 1), 50 | "-prerelease"]).decode().split("\r\n")[0] 51 | tryFolder = vsLocation + "\\VC\\Auxiliary\\Build\\" 52 | tryVcvarsall = "VCVARSALL.BAT" 53 | if os.path.exists(tryFolder + tryVcvarsall): 54 | return tryFolder 55 | else: 56 | names = ("Preview", vsName) 57 | skus = ("Community", "Professional", "Enterprise") 58 | for name in names: 59 | for sku in skus: 60 | tryFolder = programFilesFolder + "\\Microsoft Visual Studio\\%s\\%s\\VC\\Auxiliary\\Build\\" % (name, sku) 61 | tryVcvarsall = "VCVARSALL.BAT" 62 | if os.path.exists(tryFolder + tryVcvarsall): 63 | return tryFolder 64 | LogError("Could NOT find VS%s.\n" % vsName) 65 | return "" 66 | 67 | def FindVS2019Folder(programFilesFolder): 68 | return FindVS2017OrUpFolder(programFilesFolder, 16, "2019") 69 | 70 | def FindVS2017Folder(programFilesFolder): 71 | return FindVS2017OrUpFolder(programFilesFolder, 15, "2017") 72 | 73 | def FindVS2015Folder(programFilesFolder): 74 | env = os.environ 75 | if "VS140COMNTOOLS" in env: 76 | return env["VS140COMNTOOLS"] + "..\\..\\VC\\" 77 | else: 78 | tryFolder = programFilesFolder + "\\Microsoft Visual Studio 14.0\\VC\\" 79 | tryVcvarsall = "VCVARSALL.BAT" 80 | if os.path.exists(tryFolder + tryVcvarsall): 81 | return tryFolder 82 | else: 83 | LogError("Could NOT find VS2015.\n") 84 | 85 | class BatchCommand: 86 | def __init__(self, hostPlatform): 87 | self.commands = [] 88 | self.hostPlatform = hostPlatform 89 | 90 | def AddCommand(self, cmd): 91 | self.commands += [cmd] 92 | 93 | def Execute(self): 94 | batchFileName = "scBuild." 95 | if "win" == self.hostPlatform: 96 | batchFileName += "bat" 97 | else: 98 | batchFileName += "sh" 99 | batchFile = open(batchFileName, "w") 100 | batchFile.writelines([cmd_line + "\n" for cmd_line in self.commands]) 101 | batchFile.close() 102 | if "win" == self.hostPlatform: 103 | retCode = subprocess.call(batchFileName, shell = True) 104 | else: 105 | subprocess.call("chmod 777 " + batchFileName, shell = True) 106 | retCode = subprocess.call("./" + batchFileName, shell = True) 107 | os.remove(batchFileName) 108 | return retCode 109 | 110 | def Build(hostPlatform, hostArch, buildSys, compiler, arch, configuration, tblgenMode, tblgenPath): 111 | originalDir = os.path.abspath(os.curdir) 112 | 113 | if not os.path.exists("Build"): 114 | os.mkdir("Build") 115 | 116 | multiConfig = (buildSys.find("vs") == 0) 117 | 118 | buildDir = "Build/%s-%s-%s-%s" % (buildSys, hostPlatform, compiler, arch) 119 | if (not multiConfig) or (configuration == "clangformat"): 120 | buildDir += "-%s" % configuration; 121 | if not os.path.exists(buildDir): 122 | os.mkdir(buildDir) 123 | os.chdir(buildDir) 124 | buildDir = os.path.abspath(os.curdir) 125 | 126 | tblgenOptions = "" 127 | if (tblgenPath != None): 128 | tblgenOptions = " -DCLANG_TABLEGEN=\"%s\" -DLLVM_TABLEGEN=\"%s\"" % tblgenPath 129 | 130 | parallel = multiprocessing.cpu_count() 131 | 132 | batCmd = BatchCommand(hostPlatform) 133 | if hostPlatform == "win": 134 | programFilesFolder = FindProgramFilesFolder() 135 | if (buildSys == "vs2019") or ((buildSys == "ninja") and (compiler == "vc142")): 136 | vsFolder = FindVS2019Folder(programFilesFolder) 137 | elif (buildSys == "vs2017") or ((buildSys == "ninja") and (compiler == "vc141")): 138 | vsFolder = FindVS2017Folder(programFilesFolder) 139 | elif (buildSys == "vs2015") or ((buildSys == "ninja") and (compiler == "vc140")): 140 | vsFolder = FindVS2015Folder(programFilesFolder) 141 | if "x64" == arch: 142 | vcOption = "amd64" 143 | vcArch = "x64" 144 | elif "x86" == arch: 145 | vcOption = "x86" 146 | vcArch = "Win32" 147 | elif "arm64" == arch: 148 | vcOption = "amd64_arm64" 149 | vcArch = "ARM64" 150 | elif "arm" == arch: 151 | vcOption = "amd64_arm" 152 | vcArch = "ARM" 153 | else: 154 | LogError("Unsupported architecture.\n") 155 | vcToolset = "" 156 | if (buildSys == "vs2019") and (compiler == "vc141"): 157 | vcOption += " -vcvars_ver=14.1" 158 | vcToolset = "v141," 159 | elif ((buildSys == "vs2019") or (buildSys == "vs2017")) and (compiler == "vc140"): 160 | vcOption += " -vcvars_ver=14.0" 161 | vcToolset = "v140," 162 | batCmd.AddCommand("@call \"%sVCVARSALL.BAT\" %s" % (vsFolder, vcOption)) 163 | batCmd.AddCommand("@cd /d \"%s\"" % buildDir) 164 | if (buildSys == "ninja"): 165 | if hostPlatform == "win": 166 | batCmd.AddCommand("set CC=cl.exe") 167 | batCmd.AddCommand("set CXX=cl.exe") 168 | if (configuration == "clangformat"): 169 | options = "-DSC_CLANGFORMAT=\"ON\"" 170 | else: 171 | options = "-DCMAKE_BUILD_TYPE=\"%s\" -DSC_ARCH_NAME=\"%s\" %s" % (configuration, arch, tblgenOptions) 172 | batCmd.AddCommand("cmake -G Ninja %s ../../" % options) 173 | if tblgenMode: 174 | batCmd.AddCommand("ninja clang-tblgen -j%d" % parallel) 175 | batCmd.AddCommand("ninja llvm-tblgen -j%d" % parallel) 176 | else: 177 | batCmd.AddCommand("ninja -j%d" % parallel) 178 | else: 179 | if buildSys == "vs2019": 180 | generator = "\"Visual Studio 16\"" 181 | elif buildSys == "vs2017": 182 | generator = "\"Visual Studio 15\"" 183 | elif buildSys == "vs2015": 184 | generator = "\"Visual Studio 14\"" 185 | if (configuration == "clangformat"): 186 | cmake_options = "-DSC_CLANGFORMAT=\"ON\"" 187 | msbuild_options = "" 188 | else: 189 | cmake_options = "-T %shost=x64 -A %s %s" % (vcToolset, vcArch, tblgenOptions) 190 | msbuild_options = "/m:%d /v:m /p:Configuration=%s,Platform=%s" % (parallel, configuration, vcArch) 191 | batCmd.AddCommand("cmake -G %s %s ../../" % (generator, cmake_options)) 192 | if tblgenMode: 193 | batCmd.AddCommand("MSBuild External\\DirectXShaderCompiler\\tools\\clang\\utils\\TableGen\\clang-tblgen.vcxproj /nologo %s" % msbuild_options) 194 | batCmd.AddCommand("MSBuild External\\DirectXShaderCompiler\\utils\\TableGen\\llvm-tblgen.vcxproj /nologo %s" % msbuild_options) 195 | else: 196 | batCmd.AddCommand("MSBuild ALL_BUILD.vcxproj /nologo %s" % msbuild_options) 197 | if batCmd.Execute() != 0: 198 | LogError("Build failed.\n") 199 | 200 | os.chdir(originalDir) 201 | 202 | tblGenPath = buildDir + "/External/DirectXShaderCompiler" 203 | if multiConfig: 204 | tblGenPath += "/" + configuration 205 | tblGenPath += "/bin/" 206 | clangTblgenPath = tblGenPath + "clang-tblgen" 207 | llvmTblGenPath = tblGenPath + "llvm-tblgen" 208 | if (hostPlatform == "win"): 209 | clangTblgenPath += ".exe" 210 | llvmTblGenPath += ".exe" 211 | return (clangTblgenPath, llvmTblGenPath) 212 | 213 | if __name__ == "__main__": 214 | hostPlatform = sys.platform 215 | if 0 == hostPlatform.find("win"): 216 | hostPlatform = "win" 217 | elif 0 == hostPlatform.find("linux"): 218 | hostPlatform = "linux" 219 | elif 0 == hostPlatform.find("darwin"): 220 | hostPlatform = "osx" 221 | 222 | hostArch = platform.machine() 223 | if (hostArch == "AMD64") or (hostArch == "x86_64"): 224 | hostArch = "x64" 225 | elif (hostArch == "i386"): 226 | hostArch = "x86" 227 | elif (hostArch == "ARM64"): 228 | hostArch = "arm64" 229 | else: 230 | LogError("Unknown host architecture %s.\n" % hostArch) 231 | 232 | argc = len(sys.argv); 233 | if (argc > 1): 234 | buildSys = sys.argv[1] 235 | else: 236 | if hostPlatform == "win": 237 | buildSys = "vs2019" 238 | else: 239 | buildSys = "ninja" 240 | if (argc > 2): 241 | compiler = sys.argv[2] 242 | else: 243 | if buildSys == "vs2019": 244 | compiler = "vc142" 245 | elif buildSys == "vs2017": 246 | compiler = "vc141" 247 | elif buildSys == "vs2015": 248 | compiler = "vc140" 249 | else: 250 | compiler = "gcc" 251 | if (argc > 3): 252 | arch = sys.argv[3] 253 | else: 254 | arch = "x64" 255 | if (argc > 4): 256 | configuration = sys.argv[4] 257 | else: 258 | configuration = "Release" 259 | 260 | tblgenPath = None 261 | if (configuration != "clangformat") and (hostArch != arch) and (not ((hostArch == "x64") and (arch == "x86"))): 262 | # Cross compiling: 263 | # Generate a project with host architecture, build clang-tblgen and llvm-tblgen, and keep the path of clang-tblgen and llvm-tblgen 264 | tblgenPath = Build(hostPlatform, hostArch, buildSys, compiler, hostArch, configuration, True, None) 265 | 266 | Build(hostPlatform, hostArch, buildSys, compiler, arch, configuration, False, tblgenPath) 267 | -------------------------------------------------------------------------------- /CI/AzurePipelines/ContinuousBuild.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - bash: eval '$(installCommand)' 3 | displayName: 'Install' 4 | 5 | - script: | 6 | git config --global user.email "dummy@example.com" 7 | git config --global user.name "Dummy Name" 8 | displayName: 'Config git' 9 | 10 | - task: PythonScript@0 11 | displayName: 'Build' 12 | inputs: 13 | scriptPath: BuildAll.py 14 | arguments: 'ninja $(compiler) $(platform) $(configuration)' 15 | 16 | - bash: eval '$(testCommand)' 17 | displayName: 'Test' 18 | condition: not(eq('$(testCommand)', '')) 19 | 20 | - bash: 'echo $BUILD_SOURCEVERSION > $BUILD_ARTIFACTSTAGINGDIRECTORY/GIT-COMMIT.txt' 21 | displayName: 'Add commit info' 22 | 23 | - task: CopyFiles@2 24 | displayName: 'Copy Headers' 25 | inputs: 26 | SourceFolder: '$(Build.SourcesDirectory)' 27 | Contents: Include/ShaderConductor/ShaderConductor.hpp 28 | TargetFolder: '$(Build.ArtifactStagingDirectory)' 29 | 30 | - task: CopyFiles@2 31 | displayName: 'Copy Binaries' 32 | inputs: 33 | SourceFolder: '$(Build.SourcesDirectory)/$(buildFolder)' 34 | Contents: $(artifactBinaries) 35 | TargetFolder: '$(Build.ArtifactStagingDirectory)' 36 | 37 | - task: PublishBuildArtifacts@1 38 | inputs: 39 | pathtoPublish: '$(Build.ArtifactStagingDirectory)' 40 | artifactName: ShaderConductor-$(combination) 41 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | cmake_minimum_required(VERSION 3.9) 5 | 6 | if(WIN32 AND (${CMAKE_GENERATOR} MATCHES "Visual Studio ([^9]|[9][0-9])") AND (NOT SC_CLANGFORMAT)) 7 | set(SC_WITH_CSHARP ON) 8 | else() 9 | set(SC_WITH_CSHARP OFF) 10 | endif() 11 | 12 | set(PROJECT_NAME ShaderConductor) 13 | project(${PROJECT_NAME}) 14 | if(SC_WITH_CSHARP) 15 | project(${PROJECT_NAME} LANGUAGES CSharp) 16 | set(CMAKE_CSharp_FLAGS "/langversion:7") 17 | endif() 18 | 19 | set(SC_MAJOR_VERSION 0) 20 | set(SC_MINOR_VERSION 3) 21 | set(SC_PATCH_VERSION 0) 22 | set(SC_VERSION ${SC_MAJOR_VERSION}.${SC_MINOR_VERSION}.${SC_PATCH_VERSION}) 23 | 24 | set(SC_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 25 | set(SC_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}) 26 | mark_as_advanced(SC_ROOT_DIR) 27 | 28 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) 29 | 30 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${SC_BUILD_DIR}/Bin) 31 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${SC_BUILD_DIR}/Lib) 32 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${SC_BUILD_DIR}/Lib) 33 | 34 | if((CMAKE_C_COMPILER_ID MATCHES GNU) OR (CMAKE_C_COMPILER_ID MATCHES Clang)) 35 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z") 36 | endif() 37 | if (CMAKE_C_COMPILER_ID MATCHES Clang) 38 | foreach(flagVar 39 | CMAKE_C_FLAGS CMAKE_CXX_FLAGS) 40 | set(${flagVar} "${${flagVar}} -fms-extensions -Wno-language-extension-token") 41 | endforeach() 42 | endif() 43 | 44 | set(Python_ADDITIONAL_VERSIONS 3.5 3.6 3.7 3.8) 45 | 46 | if(SC_CLANGFORMAT) 47 | find_program(CLANG_FORMAT 48 | NAMES 49 | clang-format-9 50 | clang-format 51 | ) 52 | 53 | if(${CLANG_FORMAT} STREQUAL "CLANG_FORMAT-NOTFOUND") 54 | message(FATAL_ERROR "No clang-format tool found") 55 | endif() 56 | 57 | message(STATUS "Generating clangformat target using ${CLANG_FORMAT}") 58 | file(GLOB_RECURSE ALL_SOURCE_FILES *.cpp *.h *.hpp) 59 | add_custom_target(clangformat 60 | COMMAND ${CLANG_FORMAT} -i ${ALL_SOURCE_FILES}) 61 | 62 | return() 63 | endif() 64 | 65 | # Handle a compiling issue of SPIR-V 66 | if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") 67 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") 68 | if(CMAKE_C_COMPILER_ID MATCHES Clang) 69 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") 70 | endif() 71 | 72 | foreach(flagVar 73 | CMAKE_SHARED_LINKER_FLAGS_RELEASE CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL 74 | CMAKE_MODULE_LINKER_FLAGS_RELEASE CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL 75 | CMAKE_EXE_LINKER_FLAGS_RELEASE CMAKE_EXE_LINKER_FLAGS_MINSIZEREL) 76 | set(${flagVar} "${${flagVar}} -s") 77 | endforeach() 78 | endif() 79 | 80 | if(WIN32) 81 | if(MSVC AND (CMAKE_GENERATOR MATCHES "^Visual Studio")) 82 | if((CMAKE_GENERATOR_PLATFORM STREQUAL "x64") OR (CMAKE_GENERATOR MATCHES "Win64")) 83 | set(SC_ARCH_NAME "x64") 84 | elseif((CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64") OR (CMAKE_GENERATOR MATCHES "ARM64")) 85 | set(SC_ARCH_NAME "arm64") 86 | elseif((CMAKE_GENERATOR_PLATFORM STREQUAL "ARM") OR (CMAKE_GENERATOR MATCHES "ARM")) 87 | set(SC_ARCH_NAME "arm") 88 | else() 89 | set(SC_ARCH_NAME "x86") 90 | endif() 91 | endif() 92 | else() 93 | if(NOT SC_ARCH_NAME) 94 | if((CMAKE_SYSTEM_PROCESSOR MATCHES "AMD64") OR (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")) 95 | set(SC_ARCH_NAME "x64") 96 | else() 97 | set(SC_ARCH_NAME "x86") 98 | endif() 99 | endif() 100 | endif() 101 | 102 | add_subdirectory(Source) 103 | add_subdirectory(External) 104 | 105 | set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT "ShaderConductorCmd") 106 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | One of the easiest ways to contribute is to participate in discussions and discuss issues. You can also contribute by submitting pull requests with code changes. 4 | 5 | ## General feedback and discussions? 6 | Please start a discussion on the repo issue tracker. 7 | 8 | ## Bugs and feature requests? 9 | For non-security related bugs please log a new issue in the GitHub repo. 10 | 11 | ## Reporting Security Issues 12 | 13 | Security issues and bugs should be reported privately, via email, to the Microsoft Security 14 | Response Center (MSRC) at [secure@microsoft.com](mailto:secure@microsoft.com). You should 15 | receive a response within 24 hours. If for some reason you do not, please follow up via 16 | email to ensure we received your original message. Further information, including the 17 | [MSRC PGP](https://technet.microsoft.com/en-us/security/dn606155) key, can be found in 18 | the [Security TechCenter](https://technet.microsoft.com/en-us/security/default). 19 | 20 | ## Filing issues 21 | When filing issues, please use our [bug filing templates](https://github.com/aspnet/Home/wiki/Functional-bug-template). 22 | The best way to get your bug fixed is to be as detailed as you can be about the problem. 23 | Providing a minimal project with steps to reproduce the problem is ideal. 24 | Here are questions you can answer before you file a bug to make sure you're not missing any important information. 25 | 26 | 1. Did you read the documentation? 27 | 2. Did you include the snippet of broken code in the issue? 28 | 3. What are the *EXACT* steps to reproduce this problem? 29 | 4. What version are you using? 30 | 31 | GitHub supports [markdown](https://help.github.com/articles/github-flavored-markdown/), so when filing bugs make sure you check the formatting before clicking submit. 32 | 33 | ## Contributing 34 | 35 | This project welcomes contributions and suggestions. Most contributions require you to agree to a 36 | Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us 37 | the rights to use your contribution. For details, visit https://cla.microsoft.com. 38 | 39 | When you submit a pull request, a CLA-bot will automatically determine whether you need to provide 40 | a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions 41 | provided by the bot. You will only need to do this once across all repos using our CLA. 42 | -------------------------------------------------------------------------------- /External/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | find_program(git_executable NAMES git git.exe git.cmd) 5 | if(NOT git_executable) 6 | message(FATAL_ERROR "Failed to find git.") 7 | endif() 8 | 9 | function(UpdateExternalLib name url rev) 10 | set(need_checkout FALSE) 11 | set(external_folder "${SC_ROOT_DIR}/External") 12 | set(external_lib_folder "${external_folder}/${name}") 13 | if(EXISTS "${external_lib_folder}/.git") 14 | message(STATUS "Updating ${name} to revision ${rev}...") 15 | execute_process(COMMAND "${git_executable}" "fetch" "origin" WORKING_DIRECTORY "${external_lib_folder}") 16 | execute_process(COMMAND "${git_executable}" "rev-parse" "HEAD" WORKING_DIRECTORY "${external_lib_folder}" OUTPUT_VARIABLE head_rev) 17 | string(STRIP ${head_rev} head_rev) 18 | if (${head_rev} STREQUAL ${rev}) 19 | set(need_checkout FALSE) 20 | else() 21 | set(need_checkout TRUE) 22 | endif() 23 | else() 24 | message(STATUS "Cloning ${name} revision...") 25 | execute_process(COMMAND "${git_executable}" "clone" ${url} "-n" WORKING_DIRECTORY "${external_folder}") 26 | set(need_checkout TRUE) 27 | endif() 28 | if(need_checkout) 29 | message(STATUS "Checking out to revision ${rev}...") 30 | execute_process(COMMAND "${git_executable}" "checkout" "-q" ${rev} WORKING_DIRECTORY "${external_lib_folder}") 31 | endif() 32 | 33 | set(${ARGV3} ${need_checkout} PARENT_SCOPE) 34 | endfunction() 35 | 36 | function(ApplyPatch name patch) 37 | set(external_folder "${SC_ROOT_DIR}/External") 38 | set(external_lib_folder "${external_folder}/${name}") 39 | 40 | execute_process(COMMAND "${git_executable}" "apply" "--check" "--ignore-space-change" "${patch}" WORKING_DIRECTORY ${external_lib_folder} RESULT_VARIABLE checkout_err) 41 | if(NOT checkout_err) 42 | message(STATUS "Applying ${patch}...") 43 | execute_process(COMMAND "${git_executable}" "am" "--ignore-space-change" "${patch}" WORKING_DIRECTORY ${external_lib_folder}) 44 | endif() 45 | endfunction() 46 | 47 | include(cxxopts.cmake) 48 | include(googletest.cmake) 49 | include(SPIRV-Header.cmake) 50 | include(SPIRV-Tools.cmake) 51 | include(DirectXShaderCompiler.cmake) 52 | include(SPIRV-Cross.cmake) 53 | -------------------------------------------------------------------------------- /External/DirectXShaderCompiler.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | set(DirectXShaderCompiler_REV "634a23537df7e85512437a4976f9bf9fcd095e18") 5 | 6 | UpdateExternalLib("DirectXShaderCompiler" "https://github.com/Microsoft/DirectXShaderCompiler.git" ${DirectXShaderCompiler_REV}) 7 | 8 | set(ENABLE_SPIRV_CODEGEN ON CACHE BOOL "" FORCE) 9 | set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "" FORCE) 10 | set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "" FORCE) 11 | set(CLANG_INCLUDE_TESTS OFF CACHE BOOL "" FORCE) 12 | set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "" FORCE) 13 | set(HLSL_INCLUDE_TESTS OFF CACHE BOOL "" FORCE) 14 | set(HLSL_BUILD_DXILCONV OFF CACHE BOOL "" FORCE) 15 | set(HLSL_SUPPORT_QUERY_GIT_COMMIT_INFO OFF CACHE BOOL "" FORCE) 16 | set(HLSL_ENABLE_DEBUG_ITERATORS ON CACHE BOOL "" FORCE) 17 | set(LLVM_TARGETS_TO_BUILD "None" CACHE STRING "" FORCE) 18 | set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "" FORCE) 19 | set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "" FORCE) 20 | set(LIBCLANG_BUILD_STATIC ON CACHE BOOL "" FORCE) 21 | set(LLVM_OPTIMIZED_TABLEGEN OFF CACHE BOOL "" FORCE) 22 | set(LLVM_REQUIRES_EH ON CACHE BOOL "" FORCE) 23 | set(LLVM_APPEND_VC_REV ON CACHE BOOL "" FORCE) 24 | set(LLVM_ENABLE_RTTI ON CACHE BOOL "" FORCE) 25 | set(LLVM_ENABLE_EH ON CACHE BOOL "" FORCE) 26 | set(LLVM_ENABLE_TERMINFO OFF CACHE BOOL "" FORCE) 27 | set(LLVM_DEFAULT_TARGET_TRIPLE "dxil-ms-dx" CACHE STRING "" FORCE) 28 | set(CLANG_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) 29 | set(LLVM_REQUIRES_RTTI ON CACHE BOOL "" FORCE) 30 | set(CLANG_CL OFF CACHE BOOL "" FORCE) 31 | if(SC_ARCH_NAME STREQUAL "x86") 32 | set(DXC_BUILD_ARCH "Win32" CACHE STRING "" FORCE) 33 | elseif(SC_ARCH_NAME STREQUAL "arm") 34 | set(DXC_BUILD_ARCH "ARM" CACHE STRING "" FORCE) 35 | elseif(SC_ARCH_NAME STREQUAL "arm64") 36 | set(DXC_BUILD_ARCH "ARM64" CACHE STRING "" FORCE) 37 | else() 38 | set(DXC_BUILD_ARCH "${SC_ARCH_NAME}" CACHE STRING "" FORCE) 39 | endif() 40 | set(SPIRV_BUILD_TESTS OFF CACHE BOOL "" FORCE) 41 | set(SPIRV_SKIP_EXECUTABLES ON CACHE BOOL "" FORCE) 42 | set(SPIRV_SKIP_TESTS ON CACHE BOOL "" FORCE) 43 | add_subdirectory(DirectXShaderCompiler EXCLUDE_FROM_ALL) 44 | foreach(target 45 | "clang" "dxc" 46 | "clangAnalysis" "clangAST" "clangASTMatchers" "clangBasic" "clangCodeGen" "clangDriver" "clangEdit" "clangFormat" "clangFrontend" 47 | "clangFrontendTool" "clangIndex" "clangLex" "clangParse" "clangRewrite" "clangRewriteFrontend" "clangSema" "clangSPIRV" "clangTooling" 48 | "clangToolingCore" "dxcompiler" "libclang" 49 | "ClangAttrClasses" "ClangAttrDump" "ClangAttrHasAttributeImpl" "ClangAttrImpl" "ClangAttrList" "ClangAttrParsedAttrImpl" 50 | "ClangAttrParsedAttrKinds" "ClangAttrParsedAttrList" "ClangAttrParserStringSwitches" "ClangAttrPCHRead" "ClangAttrPCHWrite" 51 | "ClangAttrSpellingListIndex" "ClangAttrTemplateInstantiate" "ClangAttrVisitor" "ClangCommentCommandInfo" "ClangCommentCommandList" 52 | "ClangCommentHTMLNamedCharacterReferences" "ClangCommentHTMLTags" "ClangCommentHTMLTagsProperties" "ClangCommentNodes" "ClangDeclNodes" 53 | "ClangDiagnosticAnalysis" "ClangDiagnosticAST" "ClangDiagnosticComment" "ClangDiagnosticCommon" "ClangDiagnosticDriver" 54 | "ClangDiagnosticFrontend" "ClangDiagnosticGroups" "ClangDiagnosticIndexName" "ClangDiagnosticLex" "ClangDiagnosticParse" 55 | "ClangDiagnosticSema" "ClangDiagnosticSerialization" "ClangStmtNodes" 56 | "LLVMAnalysis" "LLVMAsmParser" "LLVMBitReader" "LLVMBitWriter" "LLVMCore" "LLVMDxcSupport" "LLVMDXIL" "LLVMDxilContainer" 57 | "LLVMDxilPIXPasses" "LLVMDxilRootSignature" "LLVMDxrFallback" "LLVMHLSL" "LLVMInstCombine" "LLVMipa" "LLVMipo" "LLVMIRReader" 58 | "LLVMLinker" "LLVMLTO" "LLVMMSSupport" "LLVMOption" "LLVMPasses" "LLVMPassPrinters" "LLVMProfileData" "LLVMScalarOpts" "LLVMSupport" 59 | "LLVMTableGen" "LLVMTarget" "LLVMTransformUtils" "LLVMVectorize" 60 | "ClangDriverOptions" "DxcEtw" "intrinsics_gen" "TablegenHLSLOptions" 61 | "clang-tblgen" "llvm-tblgen" "hlsl_dxcversion_autogen" "hlsl_version_autogen") 62 | get_target_property(vsFolder ${target} FOLDER) 63 | if(NOT vsFolder) 64 | set(vsFolder "") 65 | endif() 66 | set_target_properties(${target} PROPERTIES FOLDER "External/DirectXShaderCompiler/${vsFolder}") 67 | endforeach() 68 | if(WIN32) 69 | foreach(target 70 | "dndxc" "dxa" "dxl" "dxopt" "dxr" "dxv" 71 | "d3dcompiler_dxc_bridge" "dxlib_sample" "dxrfallbackcompiler" 72 | "dxexp" "LLVMDxilDia") 73 | get_target_property(vsFolder ${target} FOLDER) 74 | if(NOT vsFolder) 75 | set(vsFolder "") 76 | endif() 77 | set_target_properties(${target} PROPERTIES FOLDER "External/DirectXShaderCompiler/${vsFolder}") 78 | endforeach() 79 | endif() 80 | -------------------------------------------------------------------------------- /External/SPIRV-Cross.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | set(SPIRV_Cross_REV "8891bd35120ca91c252a66ccfdc3f9a9d03c70cd") 5 | 6 | UpdateExternalLib("SPIRV-Cross" "https://github.com/KhronosGroup/SPIRV-Cross.git" ${SPIRV_Cross_REV}) 7 | 8 | add_subdirectory(SPIRV-Cross EXCLUDE_FROM_ALL) 9 | foreach(target 10 | "spirv-cross" "spirv-cross-core" "spirv-cross-cpp" "spirv-cross-glsl" "spirv-cross-hlsl" "spirv-cross-msl" "spirv-cross-reflect" 11 | "spirv-cross-util") 12 | set_target_properties(${target} PROPERTIES FOLDER "External/SPIRV-Cross") 13 | endforeach() 14 | 15 | foreach(target 16 | "SPIRV-Tools-static" "SPIRV-Tools-opt") 17 | set_target_properties(${target} PROPERTIES FOLDER "External/SPIRV-Tools/SPIRV-Tools libraries") 18 | endforeach() 19 | -------------------------------------------------------------------------------- /External/SPIRV-Header.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | set(SPIRV_Headers_REV "3fdabd0da2932c276b25b9b4a988ba134eba1aa6") 5 | 6 | UpdateExternalLib("SPIRV-Headers" "https://github.com/KhronosGroup/SPIRV-Headers.git" ${SPIRV_Headers_REV}) 7 | 8 | add_subdirectory(SPIRV-Headers EXCLUDE_FROM_ALL) 9 | foreach(target 10 | "install-headers" "SPIRV-Headers-example") 11 | set_target_properties(${target} PROPERTIES FOLDER "External/SPIRV-Headers") 12 | endforeach() 13 | -------------------------------------------------------------------------------- /External/SPIRV-Tools.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | set(SPIRV_Tools_REV "c341f7a6cd441d05ca1347ee39f2f03f32225c59") 5 | 6 | UpdateExternalLib("SPIRV-Tools" "https://github.com/KhronosGroup/SPIRV-Tools.git" ${SPIRV_Tools_REV}) 7 | 8 | set(SPIRV_SKIP_EXECUTABLES ON CACHE BOOL "" FORCE) 9 | add_subdirectory(SPIRV-Tools EXCLUDE_FROM_ALL) 10 | foreach(target 11 | "core_tables" "enum_string_mapping" "extinst_tables" 12 | "spirv-tools-pkg-config" "spirv-tools-shared-pkg-config" 13 | "spirv-tools-build-version" "spirv-tools-header-DebugInfo" 14 | "SPIRV-Tools-link" "SPIRV-Tools-shared" 15 | "spirv-tools-header-OpenCLDebugInfo100" "spirv-tools-vimsyntax" "spv-tools-cldi100" "spv-tools-clspvreflection" "spv-tools-debuginfo" "spv-tools-spv-amd-gs" 16 | "spv-tools-spv-amd-sb" "spv-tools-spv-amd-sevp" "spv-tools-spv-amd-stm") 17 | get_target_property(vsFolder ${target} FOLDER) 18 | if(NOT vsFolder) 19 | set(vsFolder "") 20 | endif() 21 | set_target_properties(${target} PROPERTIES FOLDER "External/SPIRV-Tools/${vsFolder}") 22 | endforeach() 23 | -------------------------------------------------------------------------------- /External/cxxopts.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | set(cxxopts_REV "3f2d70530219e09fe7e563f86126b0d3b228a60d") 5 | 6 | UpdateExternalLib("cxxopts" "https://github.com/jarro2783/cxxopts.git" ${cxxopts_REV}) 7 | 8 | set(CXXOPTS_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) 9 | set(CXXOPTS_BUILD_TESTS OFF CACHE BOOL "" FORCE) 10 | 11 | add_subdirectory(cxxopts EXCLUDE_FROM_ALL) 12 | -------------------------------------------------------------------------------- /External/googletest.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | set(googletest_REV "dcc92d0ab6c4ce022162a23566d44f673251eee4") 5 | 6 | UpdateExternalLib("googletest" "https://github.com/google/googletest.git" ${googletest_REV}) 7 | 8 | set(INSTALL_GTEST OFF CACHE BOOL "" FORCE) 9 | set(BUILD_GMOCK OFF CACHE BOOL "" FORCE) 10 | set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) 11 | add_subdirectory(googletest EXCLUDE_FROM_ALL) 12 | foreach(target 13 | "gtest" "gtest_main") 14 | set_target_properties(${target} PROPERTIES FOLDER "External/googletest") 15 | endforeach() 16 | -------------------------------------------------------------------------------- /Include/ShaderConductor/ShaderConductor.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ShaderConductor 3 | * 4 | * Copyright (c) Microsoft Corporation. All rights reserved. 5 | * Licensed under the MIT License. 6 | * 7 | * MIT License 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this 10 | * software and associated documentation files (the "Software"), to deal in the Software 11 | * without restriction, including without limitation the rights to use, copy, modify, merge, 12 | * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all copies or 16 | * substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 19 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 20 | * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 21 | * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 22 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | #ifndef SHADER_CONDUCTOR_HPP 27 | #define SHADER_CONDUCTOR_HPP 28 | 29 | #pragma once 30 | 31 | #include 32 | 33 | #if defined(__clang__) 34 | #define SC_SYMBOL_EXPORT __attribute__((__visibility__("default"))) 35 | #define SC_SYMBOL_IMPORT 36 | #elif defined(__GNUC__) 37 | #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) 38 | #define SC_SYMBOL_EXPORT __attribute__((__dllexport__)) 39 | #define SC_SYMBOL_IMPORT __attribute__((__dllimport__)) 40 | #else 41 | #define SC_SYMBOL_EXPORT __attribute__((__visibility__("default"))) 42 | #define SC_SYMBOL_IMPORT 43 | #endif 44 | #elif defined(_MSC_VER) 45 | #define SC_SYMBOL_EXPORT __declspec(dllexport) 46 | #define SC_SYMBOL_IMPORT __declspec(dllimport) 47 | #endif 48 | 49 | #ifdef SHADER_CONDUCTOR_SOURCE 50 | #define SC_API SC_SYMBOL_EXPORT 51 | #else 52 | #define SC_API SC_SYMBOL_IMPORT 53 | #endif 54 | 55 | namespace ShaderConductor 56 | { 57 | enum class ShaderStage : uint32_t 58 | { 59 | VertexShader, 60 | PixelShader, 61 | GeometryShader, 62 | HullShader, 63 | DomainShader, 64 | ComputeShader, 65 | 66 | NumShaderStages, 67 | }; 68 | 69 | enum class ShadingLanguage : uint32_t 70 | { 71 | Dxil = 0, 72 | SpirV, 73 | 74 | Hlsl, 75 | Glsl, 76 | Essl, 77 | Msl_macOS, 78 | Msl_iOS, 79 | 80 | NumShadingLanguages, 81 | }; 82 | 83 | enum class ShaderResourceType : uint32_t 84 | { 85 | ConstantBuffer, 86 | Parameter, 87 | Texture, 88 | Sampler, 89 | ShaderResourceView, 90 | UnorderedAccessView, 91 | 92 | NumShaderResourceType, 93 | }; 94 | 95 | struct MacroDefine 96 | { 97 | const char* name; 98 | const char* value; 99 | }; 100 | 101 | class SC_API Blob 102 | { 103 | public: 104 | Blob() noexcept; 105 | Blob(const void* data, uint32_t size); 106 | Blob(const Blob& other); 107 | Blob(Blob&& other) noexcept; 108 | ~Blob() noexcept; 109 | 110 | Blob& operator=(const Blob& other); 111 | Blob& operator=(Blob&& other) noexcept; 112 | 113 | void Reset(); 114 | void Reset(const void* data, uint32_t size); 115 | 116 | const void* Data() const noexcept; 117 | uint32_t Size() const noexcept; 118 | 119 | private: 120 | class BlobImpl; 121 | BlobImpl* m_impl = nullptr; 122 | }; 123 | 124 | class SC_API Compiler 125 | { 126 | public: 127 | struct ShaderModel 128 | { 129 | uint8_t major_ver : 6; 130 | uint8_t minor_ver : 2; 131 | 132 | uint32_t FullVersion() const noexcept 133 | { 134 | return (major_ver << 2) | minor_ver; 135 | } 136 | 137 | bool operator<(const ShaderModel& other) const noexcept 138 | { 139 | return this->FullVersion() < other.FullVersion(); 140 | } 141 | bool operator==(const ShaderModel& other) const noexcept 142 | { 143 | return this->FullVersion() == other.FullVersion(); 144 | } 145 | bool operator>(const ShaderModel& other) const noexcept 146 | { 147 | return other < *this; 148 | } 149 | bool operator<=(const ShaderModel& other) const noexcept 150 | { 151 | return (*this < other) || (*this == other); 152 | } 153 | bool operator>=(const ShaderModel& other) const noexcept 154 | { 155 | return (*this > other) || (*this == other); 156 | } 157 | }; 158 | 159 | struct SourceDesc 160 | { 161 | const char* source; 162 | const char* fileName; 163 | const char* entryPoint; 164 | ShaderStage stage; 165 | const MacroDefine* defines; 166 | uint32_t numDefines; 167 | std::function loadIncludeCallback; 168 | }; 169 | 170 | struct Options 171 | { 172 | bool packMatricesInRowMajor = true; // Experimental: Decide how a matrix get packed 173 | bool enable16bitTypes = false; // Enable 16-bit types, such as half, uint16_t. Requires shader model 6.2+ 174 | bool enableDebugInfo = false; // Embed debug info into the binary 175 | bool disableOptimizations = false; // Force to turn off optimizations. Ignore optimizationLevel below. 176 | bool inheritCombinedSamplerBindings = false; // If textures and samplers are combined, inherit the binding of the texture 177 | 178 | int optimizationLevel = 3; // 0 to 3, no optimization to most optimization 179 | ShaderModel shaderModel = {6, 0}; 180 | 181 | int shiftAllTexturesBindings = 0; 182 | int shiftAllSamplersBindings = 0; 183 | int shiftAllCBuffersBindings = 0; 184 | int shiftAllUABuffersBindings = 0; 185 | }; 186 | 187 | struct TargetDesc 188 | { 189 | ShadingLanguage language; 190 | const char* version; 191 | bool asModule; 192 | }; 193 | 194 | struct ReflectionDesc 195 | { 196 | char name[256]; // Name of the resource 197 | ShaderResourceType type; // Type of resource (e.g. texture, cbuffer, etc.) 198 | uint32_t bufferBindPoint; // Buffer's starting bind point 199 | uint32_t bindPoint; // Starting bind point 200 | uint32_t bindCount; // Number of contiguous bind points (for arrays) 201 | }; 202 | 203 | struct ReflectionResultDesc 204 | { 205 | Blob descs; // The underneath type is ReflectionDesc 206 | uint32_t descCount = 0; 207 | uint32_t instructionCount = 0; 208 | }; 209 | 210 | struct ResultDesc 211 | { 212 | Blob target; 213 | bool isText; 214 | 215 | Blob errorWarningMsg; 216 | bool hasError; 217 | 218 | ReflectionResultDesc reflection; 219 | }; 220 | 221 | struct DisassembleDesc 222 | { 223 | ShadingLanguage language; 224 | const uint8_t* binary; 225 | uint32_t binarySize; 226 | }; 227 | 228 | struct ModuleDesc 229 | { 230 | const char* name; 231 | Blob target; 232 | }; 233 | 234 | struct LinkDesc 235 | { 236 | const char* entryPoint; 237 | ShaderStage stage; 238 | 239 | const ModuleDesc** modules; 240 | uint32_t numModules; 241 | }; 242 | 243 | public: 244 | static ResultDesc Compile(const SourceDesc& source, const Options& options, const TargetDesc& target); 245 | static void Compile(const SourceDesc& source, const Options& options, const TargetDesc* targets, uint32_t numTargets, 246 | ResultDesc* results); 247 | static ResultDesc Disassemble(const DisassembleDesc& source); 248 | 249 | // Currently only Dxil on Windows supports linking 250 | static bool LinkSupport(); 251 | static ResultDesc Link(const LinkDesc& modules, const Options& options, const TargetDesc& target); 252 | }; 253 | } // namespace ShaderConductor 254 | 255 | #endif // SHADER_CONDUCTOR_HPP 256 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ShaderConductor 2 | 3 | [![Build Status](https://dev.azure.com/msft-ShaderConductor/public/_apis/build/status/ShaderConductor-CI)](https://dev.azure.com/msft-ShaderConductor/public/_build/latest?definitionId=1) 4 | [![License](https://img.shields.io/github/license/mashape/apistatus.svg)](LICENSE) 5 | 6 | 7 | ShaderConductor is a tool designed for cross-compiling HLSL to other shading languages. 8 | 9 | ## Features 10 | 11 | * Converts HLSL to readable, usable and efficient GLSL 12 | * Converts HLSL to readable, usable and efficient ESSL 13 | * Converts HLSL to readable, usable and efficient Metal Shading Language (MSL) 14 | * Converts HLSL to readable, usable and efficient old shader model HLSL 15 | * Supports all stages of shaders, vertex, pixel, hull, domain, geometry, and compute. 16 | 17 | Note that this project is still in an early stage, and it is under active development. 18 | 19 | ## Architecture 20 | 21 | ShaderConductor is not a real compiler. Instead, it glues existing open source components to do the cross-compiling. 22 | 1. [DirectX Shader Compiler](https://github.com/Microsoft/DirectXShaderCompiler) to compile HLSL to [DXIL](https://github.com/Microsoft/DirectXShaderCompiler/blob/master/docs/DXIL.rst) or [SPIR-V](https://www.khronos.org/registry/spir-v/), 23 | 1. [SPIRV-Cross](https://github.com/KhronosGroup/SPIRV-Cross) to convert SPIR-V to target shading languages. 24 | 25 | ![Architecture](Doc/Arch.svg) 26 | 27 | ## Prerequisites 28 | 29 | * [Git](http://git-scm.com/downloads). Put git into the PATH is recommended. 30 | * [Visual Studio 2017](https://www.visualstudio.com/downloads). Select the following workloads: Universal Windows Platform Development and Desktop Development with C++. 31 | * [CMake](https://www.cmake.org/download/). Version 3.9 or up. It's highly recommended to choose "Add CMake to the system PATH for all users" during installation. 32 | * [Python](https://www.python.org/downloads/). Version 2.7 or up. You need not change your PATH variable during installation. 33 | 34 | ## Building 35 | 36 | ShaderConductor has been tested on Windows, Linux, and macOS. 37 | 38 | ### The script way: 39 | 40 | ``` 41 | BuildAll.py 42 | ``` 43 | where, 44 | * \ can be ninja or vs2017. Default is vs2017. 45 | * \ can be vc141 on Windows, gcc or clang on Linux, clang on macOS. 46 | * \ must be x64 (for now). 47 | * \ can be Debug, Release, RelWithDebInfo, or MinSizeRel. Default is Release. 48 | 49 | This script automatically grabs external dependencies to External folder, generates project file in Build/\-\-\-\[-\], and builds it. 50 | 51 | ### The manual way: 52 | 53 | ``` 54 | mkdir Build 55 | cd Build 56 | cmake -G "Visual Studio 15" -T host=x64 -A x64 ../ 57 | cmake --build . 58 | ``` 59 | 60 | After building, the output file ShaderConductor.dll can be located in \/Bin/\/. It depends on dxcompiler.dll in the same folder. 61 | 62 | ### Artifacts 63 | 64 | You can download [the prebuilt binaries generated by CI system](https://dev.azure.com/msft-ShaderConductor/public/_build/latest?definitionId=1&view=results). Currently, artifacts for Windows, Linux, macOS are published every commit. 65 | 66 | ## License 67 | 68 | ShaderConductor is distributed under the terms of MIT License. See [LICENSE](LICENSE) for details. 69 | 70 | ## Code of Conduct 71 | 72 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 73 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or 74 | contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 75 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd). 40 | 41 | 42 | -------------------------------------------------------------------------------- /Source/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | if(CMAKE_C_COMPILER_ID MATCHES MSVC) 5 | set(CMAKE_CXX_FLAGS "/W4 /WX /EHsc /MP /bigobj /Zc:throwingNew /Zc:strictStrings /Zc:rvalueCast /Gw") 6 | if(MSVC_VERSION GREATER 1910) 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17") 8 | else() 9 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++14") 10 | endif() 11 | if(MSVC_VERSION GREATER 1900) 12 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive-") 13 | if(MSVC_VERSION GREATER 1912) 14 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:externConstexpr") 15 | endif() 16 | endif() 17 | set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS}) 18 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /fp:fast /Ob2 /GL /Qpar") 19 | set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /fp:fast /Ob2 /GL /Qpar") 20 | set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /fp:fast /Ob1 /GL /Qpar") 21 | foreach(flagVar 22 | CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_MINSIZEREL) 23 | set(${flagVar} "${${flagVar}} /GS-") 24 | endforeach() 25 | 26 | foreach(flagVar 27 | CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS) 28 | set(${flagVar} "/pdbcompress") 29 | endforeach() 30 | foreach(flagVar 31 | CMAKE_EXE_LINKER_FLAGS_DEBUG CMAKE_SHARED_LINKER_FLAGS_DEBUG) 32 | set(${flagVar} "/DEBUG:FASTLINK") 33 | endforeach() 34 | foreach(flagVar 35 | CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO) 36 | set(${flagVar} "/DEBUG:FASTLINK /INCREMENTAL:NO /LTCG:incremental /OPT:REF /OPT:ICF") 37 | endforeach() 38 | foreach(flagVar 39 | CMAKE_EXE_LINKER_FLAGS_MINSIZEREL CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL CMAKE_EXE_LINKER_FLAGS_RELEASE CMAKE_SHARED_LINKER_FLAGS_RELEASE) 40 | set(${flagVar} "/INCREMENTAL:NO /LTCG /OPT:REF /OPT:ICF") 41 | endforeach() 42 | foreach(flagVar 43 | CMAKE_MODULE_LINKER_FLAGS_RELEASE CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL) 44 | set(${flagVar} "/INCREMENTAL:NO /LTCG") 45 | endforeach() 46 | foreach(flagVar 47 | CMAKE_STATIC_LINKER_FLAGS_RELEASE CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL) 48 | set(${flagVar} "${${flagVar}} /LTCG") 49 | endforeach() 50 | set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /LTCG:incremental") 51 | 52 | add_definitions(-DWIN32 -D_WINDOWS) 53 | else() 54 | foreach(flagVar 55 | CMAKE_C_FLAGS CMAKE_CXX_FLAGS) 56 | set(${flagVar} "${${flagVar}} -W -Wall -Werror") 57 | if(NOT (ANDROID OR IOS)) 58 | set(${flagVar} "${${flagVar}} -march=core2 -msse2") 59 | endif() 60 | endforeach() 61 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers") 62 | if(MINGW) 63 | foreach(flagVar 64 | CMAKE_C_FLAGS CMAKE_CXX_FLAGS) 65 | set(${flagVar} "${${flagVar}} -Wa,-mbig-obj") 66 | endforeach() 67 | endif() 68 | set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -g -O0") 69 | set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O2") 70 | set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-DNDEBUG -g -O2") 71 | set(CMAKE_CXX_FLAGS_MINSIZEREL "-DNDEBUG -Os") 72 | 73 | if(NOT SC_ARCH_NAME) 74 | if((CMAKE_SYSTEM_PROCESSOR MATCHES "AMD64") OR (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")) 75 | set(SC_ARCH_NAME "x64") 76 | else() 77 | set(SC_ARCH_NAME "x86") 78 | endif() 79 | endif() 80 | 81 | if(SC_ARCH_NAME STREQUAL "x64") 82 | foreach(flagVar 83 | CMAKE_C_FLAGS CMAKE_CXX_FLAGS) 84 | set(${flagVar} "${${flagVar}} -m64") 85 | endforeach() 86 | if(NOT MSVC) 87 | foreach(flagVar 88 | CMAKE_SHARED_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_EXE_LINKER_FLAGS) 89 | set(${flagVar} "${${flagVar}} -m64") 90 | endforeach() 91 | if(WIN32) 92 | set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} --target=pe-x86-64") 93 | else() 94 | set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} --target=elf64-x86-64") 95 | endif() 96 | endif() 97 | else() 98 | foreach(flagVar 99 | CMAKE_C_FLAGS CMAKE_CXX_FLAGS) 100 | set(${flagVar} "${${flagVar}} -m32") 101 | endforeach() 102 | if(NOT MSVC) 103 | foreach(flagVar 104 | CMAKE_SHARED_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_EXE_LINKER_FLAGS) 105 | set(${flagVar} "${${flagVar}} -m32") 106 | if(WIN32) 107 | set(${flagVar} "${${flagVar}} -Wl,--large-address-aware") 108 | endif() 109 | endforeach() 110 | if(WIN32) 111 | set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} --target=pe-i386") 112 | else() 113 | set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} --target=elf32-i386") 114 | endif() 115 | endif() 116 | endif() 117 | endif() 118 | 119 | set(CMAKE_C_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) 120 | set(CMAKE_C_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) 121 | set(CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}) 122 | set(CMAKE_C_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_MINSIZEREL}) 123 | 124 | add_subdirectory(Core) 125 | add_subdirectory(Tests) 126 | add_subdirectory(Tools) 127 | if(SC_WITH_CSHARP) 128 | add_subdirectory(Wrapper) 129 | endif() 130 | -------------------------------------------------------------------------------- /Source/Core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | if(WIN32) 5 | set(dxcompilerName "dxcompiler.dll") 6 | set(runtimeOutputFolder "bin") 7 | set(copyTargetFolder ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) 8 | else() 9 | if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") 10 | set(dxcompilerName "libdxcompiler.dylib") 11 | else() 12 | set(dxcompilerName "libdxcompiler.so") 13 | endif() 14 | set(runtimeOutputFolder "lib") 15 | set(copyTargetFolder ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) 16 | endif() 17 | 18 | set(dxcompilerOutput "${copyTargetFolder}/${CMAKE_CFG_INTDIR}/${dxcompilerName}") 19 | add_custom_target(CopyDxcompiler ALL 20 | COMMAND ${CMAKE_COMMAND} -E copy 21 | ${SC_BUILD_DIR}/External/DirectXShaderCompiler/${CMAKE_CFG_INTDIR}/${runtimeOutputFolder}/${dxcompilerName} 22 | ${dxcompilerOutput} 23 | COMMENT "Copying dxcompiler...") 24 | add_dependencies(CopyDxcompiler dxcompiler) 25 | 26 | set_target_properties(CopyDxcompiler PROPERTIES FOLDER "Core") 27 | 28 | 29 | set(LIB_NAME ShaderConductor) 30 | 31 | set(SOURCE_FILES 32 | ${SC_ROOT_DIR}/Source/Core/ShaderConductor.cpp 33 | ) 34 | 35 | set(HEADER_FILES 36 | ${SC_ROOT_DIR}/Include/ShaderConductor/ShaderConductor.hpp 37 | ) 38 | 39 | source_group("Source Files" FILES ${SOURCE_FILES}) 40 | source_group("Header Files" FILES ${HEADER_FILES}) 41 | 42 | add_library(${LIB_NAME} "SHARED" 43 | ${SOURCE_FILES} ${HEADER_FILES} 44 | ) 45 | 46 | target_include_directories(${LIB_NAME} 47 | PUBLIC 48 | ${SC_ROOT_DIR}/Include 49 | 50 | PRIVATE 51 | ${SC_BUILD_DIR}/External/DirectXShaderCompiler/include 52 | ${SC_ROOT_DIR}/External/DirectXShaderCompiler/include 53 | ) 54 | target_compile_definitions(${LIB_NAME} 55 | PRIVATE 56 | -DSHADER_CONDUCTOR_SOURCE 57 | ) 58 | if(MSVC) 59 | target_compile_definitions(${LIB_NAME} 60 | PRIVATE 61 | -D_CRT_SECURE_NO_DEPRECATE 62 | -D_CRT_SECURE_NO_WARNINGS 63 | -D_SCL_SECURE_NO_DEPRECATE 64 | -D_SCL_SECURE_NO_WARNINGS 65 | -D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING 66 | ) 67 | endif() 68 | target_link_libraries(${LIB_NAME} 69 | PRIVATE 70 | dxcompiler 71 | LLVMDxcSupport 72 | LLVMSupport 73 | spirv-cross-core 74 | spirv-cross-glsl 75 | spirv-cross-hlsl 76 | spirv-cross-msl 77 | spirv-cross-util 78 | SPIRV-Tools 79 | ) 80 | 81 | add_dependencies(${LIB_NAME} spirv-cross-core spirv-cross-glsl spirv-cross-hlsl spirv-cross-msl) 82 | add_dependencies(${LIB_NAME} CopyDxcompiler) 83 | add_dependencies(${LIB_NAME} SPIRV-Tools) 84 | 85 | set_target_properties(${LIB_NAME} PROPERTIES FOLDER "Core") 86 | -------------------------------------------------------------------------------- /Source/Tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | set(EXE_NAME ShaderConductorTest) 5 | 6 | set(SOURCE_FILES 7 | ShaderConductorTest.cpp 8 | ) 9 | 10 | set(DATA_INC_FILES 11 | Data/Input/Inc/HeaderA.hlsli 12 | Data/Input/Inc/HeaderB.hlsli 13 | Data/Input/Inc/HeaderEmpty.hlsli 14 | ) 15 | 16 | set(DATA_FILES 17 | Data/Input/CalcLight.hlsl 18 | Data/Input/CalcLightDiffuse.hlsl 19 | Data/Input/CalcLightDiffuseSpecular.hlsl 20 | Data/Input/Common.hlsli 21 | Data/Input/Constant_PS.hlsl 22 | Data/Input/Constant_VS.hlsl 23 | Data/Input/DetailTessellation_HS.hlsl 24 | Data/Input/Fluid_CS.hlsl 25 | Data/Input/IncludeEmptyHeader.hlsl 26 | Data/Input/IncludeExist.hlsl 27 | Data/Input/IncludeNotExist.hlsl 28 | Data/Input/HalfDataType.hlsl 29 | Data/Input/Particle_GS.hlsl 30 | Data/Input/PassThrough_PS.hlsl 31 | Data/Input/PassThrough_VS.hlsl 32 | Data/Input/PNTriangles_DS.hlsl 33 | Data/Input/ToneMapping_PS.hlsl 34 | Data/Input/Transform_VS.hlsl 35 | ) 36 | 37 | set_source_files_properties(${DATA_FILES} 38 | PROPERTIES VS_TOOL_OVERRIDE "None" 39 | ) 40 | 41 | source_group("Source Files" FILES ${SOURCE_FILES}) 42 | source_group("Data Files\\Input" FILES ${DATA_FILES}) 43 | source_group("Data Files\\Input\\Inc" FILES ${DATA_INC_FILES}) 44 | 45 | add_executable(${EXE_NAME} ${SOURCE_FILES} ${DATA_FILES} ${DATA_INC_FILES}) 46 | 47 | target_compile_definitions(${EXE_NAME} 48 | PRIVATE 49 | -DTEST_DATA_DIR="${SC_ROOT_DIR}/Source/Tests/Data/" 50 | ) 51 | target_link_libraries(${EXE_NAME} 52 | PRIVATE 53 | ShaderConductor 54 | gtest 55 | ) 56 | 57 | add_dependencies(${EXE_NAME} ShaderConductor gtest) 58 | 59 | set_target_properties(${EXE_NAME} PROPERTIES FOLDER "Tests") 60 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/CalcLight+Diffuse.Debug.dxilasm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Input signature: 3 | ; 4 | ; Name Index Mask Register SysValue Format Used 5 | ; -------------------- ----- ------ -------- -------- ------- ------ 6 | ; SV_Position 0 xyzw 0 POS float 7 | ; NORMAL 0 xyz 1 NONE float xyz 8 | ; TEXCOORD 0 xyz 2 NONE float xyz 9 | ; TEXCOORD 1 xyz 3 NONE float 10 | ; 11 | ; 12 | ; Output signature: 13 | ; 14 | ; Name Index Mask Register SysValue Format Used 15 | ; -------------------- ----- ------ -------- -------- ------- ------ 16 | ; SV_Target 0 xyzw 0 TARGET float xyzw 17 | ; 18 | ; shader debug name: d81432b398a9151e6a076b6b827882eb.pdb 19 | ; shader hash: d81432b398a9151e6a076b6b827882eb 20 | ; 21 | ; Pipeline Runtime Information: 22 | ; 23 | ; Pixel Shader 24 | ; DepthOutput=0 25 | ; SampleFrequency=0 26 | ; 27 | ; 28 | ; Input signature: 29 | ; 30 | ; Name Index InterpMode DynIdx 31 | ; -------------------- ----- ---------------------- ------ 32 | ; SV_Position 0 noperspective 33 | ; NORMAL 0 linear 34 | ; TEXCOORD 0 linear 35 | ; TEXCOORD 1 linear 36 | ; 37 | ; Output signature: 38 | ; 39 | ; Name Index InterpMode DynIdx 40 | ; -------------------- ----- ---------------------- ------ 41 | ; SV_Target 0 42 | ; 43 | ; Buffer Definitions: 44 | ; 45 | ; cbuffer cbPS 46 | ; { 47 | ; 48 | ; struct cbPS 49 | ; { 50 | ; 51 | ; float3 diffColor; ; Offset: 0 52 | ; float3 specColor; ; Offset: 16 53 | ; float shininess; ; Offset: 28 54 | ; 55 | ; } cbPS; ; Offset: 0 Size: 32 56 | ; 57 | ; } 58 | ; 59 | ; 60 | ; Resource Bindings: 61 | ; 62 | ; Name Type Format Dim ID HLSL Bind Count 63 | ; ------------------------------ ---------- ------- ----------- ------- -------------- ------ 64 | ; cbPS cbuffer NA NA CB0 cb0 1 65 | ; 66 | ; 67 | ; ViewId state: 68 | ; 69 | ; Number of inputs: 15, outputs: 4 70 | ; Outputs dependent on ViewId: { } 71 | ; Inputs contributing to computation of Outputs: 72 | ; output 0 depends on inputs: { 4, 5, 6, 8, 9, 10 } 73 | ; output 1 depends on inputs: { 4, 5, 6, 8, 9, 10 } 74 | ; output 2 depends on inputs: { 4, 5, 6, 8, 9, 10 } 75 | ; 76 | target triple = "dxil-ms-dx" 77 | 78 | %cbPS = type { <3 x float>, <3 x float>, float } 79 | %dx.types.CBufRet.f32 = type { float, float, float, float } 80 | %dx.types.Handle = type { i8* } 81 | 82 | @cbPS = external constant %cbPS 83 | 84 | ; Function Attrs: nounwind readnone 85 | declare float @dx.op.loadInput.f32(i32, i32, i32, i8, i32) #0 86 | 87 | ; Function Attrs: nounwind readonly 88 | declare %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32, %dx.types.Handle, i32) #1 89 | 90 | ; Function Attrs: nounwind 91 | declare void @dx.op.storeOutput.f32(i32, i32, i32, i8, float) #2 92 | 93 | ; Function Attrs: nounwind readnone 94 | declare float @dx.op.dot3.f32(i32, float, float, float, float, float, float) #0 95 | 96 | ; Function Attrs: nounwind readnone 97 | declare float @dx.op.binary.f32(i32, float, float) #0 98 | 99 | define void @main() { 100 | entry: 101 | %cbPS_cbuffer = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 2, i32 0, i32 0, i1 false) ; CreateHandle(resourceClass,rangeId,index,nonUniformIndex) 102 | %0 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 0, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis) 103 | %1 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 1, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis) 104 | %2 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 2, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis) 105 | %3 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 0, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis) 106 | %4 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 1, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis) 107 | %5 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 2, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis) 108 | %6 = call %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %cbPS_cbuffer, i32 0) ; CBufferLoadLegacy(handle,regIndex) 109 | %7 = extractvalue %dx.types.CBufRet.f32 %6, 0 110 | %8 = extractvalue %dx.types.CBufRet.f32 %6, 1 111 | %9 = extractvalue %dx.types.CBufRet.f32 %6, 2 112 | %10 = call float @dx.op.dot3.f32(i32 55, float %3, float %4, float %5, float %0, float %1, float %2) #2 ; Dot3(ax,ay,az,bx,by,bz) 113 | %mul.i0.i = fmul fast float %10, %7 114 | %mul.i1.i = fmul fast float %10, %8 115 | %mul.i2.i = fmul fast float %10, %9 116 | %FMax.i = call float @dx.op.binary.f32(i32 35, float %mul.i0.i, float 0.000000e+00) #2 ; FMax(a,b) 117 | %FMax2.i = call float @dx.op.binary.f32(i32 35, float %mul.i1.i, float 0.000000e+00) #2 ; FMax(a,b) 118 | %FMax3.i = call float @dx.op.binary.f32(i32 35, float %mul.i2.i, float 0.000000e+00) #2 ; FMax(a,b) 119 | call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 0, float %FMax.i) ; StoreOutput(outputSigId,rowIndex,colIndex,value) 120 | call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 1, float %FMax2.i) ; StoreOutput(outputSigId,rowIndex,colIndex,value) 121 | call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 2, float %FMax3.i) ; StoreOutput(outputSigId,rowIndex,colIndex,value) 122 | call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 3, float 1.000000e+00) ; StoreOutput(outputSigId,rowIndex,colIndex,value) 123 | ret void 124 | } 125 | 126 | ; Function Attrs: nounwind readonly 127 | declare %dx.types.Handle @dx.op.createHandle(i32, i8, i32, i32, i1) #1 128 | 129 | attributes #0 = { nounwind readnone } 130 | attributes #1 = { nounwind readonly } 131 | attributes #2 = { nounwind } 132 | 133 | !llvm.ident = !{!0, !0} 134 | !dx.version = !{!1} 135 | !dx.valver = !{!2} 136 | !dx.shaderModel = !{!3} 137 | !dx.resources = !{!4} 138 | !dx.typeAnnotations = !{!7, !12} 139 | !dx.viewIdState = !{!16} 140 | !dx.entryPoints = !{!17} 141 | 142 | !0 = !{!"clang version 3.7 (tags/RELEASE_370/final)"} 143 | !1 = !{i32 1, i32 0} 144 | !2 = !{i32 1, i32 6} 145 | !3 = !{!"ps", i32 6, i32 0} 146 | !4 = !{null, null, !5, null} 147 | !5 = !{!6} 148 | !6 = !{i32 0, %cbPS* undef, !"cbPS", i32 0, i32 0, i32 1, i32 32, null} 149 | !7 = !{i32 0, %cbPS undef, !8} 150 | !8 = !{i32 32, !9, !10, !11} 151 | !9 = !{i32 6, !"diffColor", i32 3, i32 0, i32 7, i32 9} 152 | !10 = !{i32 6, !"specColor", i32 3, i32 16, i32 7, i32 9} 153 | !11 = !{i32 6, !"shininess", i32 3, i32 28, i32 7, i32 9} 154 | !12 = !{i32 1, void ()* @main, !13} 155 | !13 = !{!14} 156 | !14 = !{i32 0, !15, !15} 157 | !15 = !{} 158 | !16 = !{[17 x i32] [i32 15, i32 4, i32 0, i32 0, i32 0, i32 0, i32 7, i32 7, i32 7, i32 0, i32 7, i32 7, i32 7, i32 0, i32 0, i32 0, i32 0]} 159 | !17 = !{void ()* @main, !"main", !18, !4, null} 160 | !18 = !{!19, !27, null} 161 | !19 = !{!20, !22, !24, !25} 162 | !20 = !{i32 0, !"SV_Position", i8 9, i8 3, !21, i8 4, i32 1, i8 4, i32 0, i8 0, null} 163 | !21 = !{i32 0} 164 | !22 = !{i32 1, !"NORMAL", i8 9, i8 0, !21, i8 2, i32 1, i8 3, i32 1, i8 0, !23} 165 | !23 = !{i32 3, i32 7} 166 | !24 = !{i32 2, !"TEXCOORD", i8 9, i8 0, !21, i8 2, i32 1, i8 3, i32 2, i8 0, !23} 167 | !25 = !{i32 3, !"TEXCOORD", i8 9, i8 0, !26, i8 2, i32 1, i8 3, i32 3, i8 0, null} 168 | !26 = !{i32 1} 169 | !27 = !{!28} 170 | !28 = !{i32 0, !"SV_Target", i8 9, i8 16, !21, i8 0, i32 1, i8 4, i32 0, i8 0, !29} 171 | !29 = !{i32 3, i32 15} 172 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/CalcLight+Diffuse.Release.dxilasm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Input signature: 3 | ; 4 | ; Name Index Mask Register SysValue Format Used 5 | ; -------------------- ----- ------ -------- -------- ------- ------ 6 | ; SV_Position 0 xyzw 0 POS float 7 | ; NORMAL 0 xyz 1 NONE float xyz 8 | ; TEXCOORD 0 xyz 2 NONE float xyz 9 | ; TEXCOORD 1 xyz 3 NONE float 10 | ; 11 | ; 12 | ; Output signature: 13 | ; 14 | ; Name Index Mask Register SysValue Format Used 15 | ; -------------------- ----- ------ -------- -------- ------- ------ 16 | ; SV_Target 0 xyzw 0 TARGET float xyzw 17 | ; 18 | ; shader debug name: ad90c6ff56d81fd333e64a2bf70453fc.pdb 19 | ; shader hash: ad90c6ff56d81fd333e64a2bf70453fc 20 | ; 21 | ; Pipeline Runtime Information: 22 | ; 23 | ; Pixel Shader 24 | ; DepthOutput=0 25 | ; SampleFrequency=0 26 | ; 27 | ; 28 | ; Input signature: 29 | ; 30 | ; Name Index InterpMode DynIdx 31 | ; -------------------- ----- ---------------------- ------ 32 | ; SV_Position 0 noperspective 33 | ; NORMAL 0 linear 34 | ; TEXCOORD 0 linear 35 | ; TEXCOORD 1 linear 36 | ; 37 | ; Output signature: 38 | ; 39 | ; Name Index InterpMode DynIdx 40 | ; -------------------- ----- ---------------------- ------ 41 | ; SV_Target 0 42 | ; 43 | ; Buffer Definitions: 44 | ; 45 | ; cbuffer cbPS 46 | ; { 47 | ; 48 | ; struct cbPS 49 | ; { 50 | ; 51 | ; float3 diffColor; ; Offset: 0 52 | ; float3 specColor; ; Offset: 16 53 | ; float shininess; ; Offset: 28 54 | ; 55 | ; } cbPS; ; Offset: 0 Size: 32 56 | ; 57 | ; } 58 | ; 59 | ; 60 | ; Resource Bindings: 61 | ; 62 | ; Name Type Format Dim ID HLSL Bind Count 63 | ; ------------------------------ ---------- ------- ----------- ------- -------------- ------ 64 | ; cbPS cbuffer NA NA CB0 cb0 1 65 | ; 66 | ; 67 | ; ViewId state: 68 | ; 69 | ; Number of inputs: 15, outputs: 4 70 | ; Outputs dependent on ViewId: { } 71 | ; Inputs contributing to computation of Outputs: 72 | ; output 0 depends on inputs: { 4, 5, 6, 8, 9, 10 } 73 | ; output 1 depends on inputs: { 4, 5, 6, 8, 9, 10 } 74 | ; output 2 depends on inputs: { 4, 5, 6, 8, 9, 10 } 75 | ; 76 | target triple = "dxil-ms-dx" 77 | 78 | %cbPS = type { <3 x float>, <3 x float>, float } 79 | %dx.types.CBufRet.f32 = type { float, float, float, float } 80 | %dx.types.Handle = type { i8* } 81 | 82 | @cbPS = external constant %cbPS 83 | 84 | ; Function Attrs: nounwind readnone 85 | declare float @dx.op.loadInput.f32(i32, i32, i32, i8, i32) #0 86 | 87 | ; Function Attrs: nounwind readonly 88 | declare %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32, %dx.types.Handle, i32) #1 89 | 90 | ; Function Attrs: nounwind 91 | declare void @dx.op.storeOutput.f32(i32, i32, i32, i8, float) #2 92 | 93 | ; Function Attrs: nounwind readnone 94 | declare float @dx.op.dot3.f32(i32, float, float, float, float, float, float) #0 95 | 96 | ; Function Attrs: nounwind readnone 97 | declare float @dx.op.binary.f32(i32, float, float) #0 98 | 99 | define void @main() { 100 | %cbPS_cbuffer = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 2, i32 0, i32 0, i1 false) ; CreateHandle(resourceClass,rangeId,index,nonUniformIndex) 101 | %1 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 0, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis) 102 | %2 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 1, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis) 103 | %3 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 2, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis) 104 | %4 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 0, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis) 105 | %5 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 1, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis) 106 | %6 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 2, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis) 107 | %7 = call %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %cbPS_cbuffer, i32 0) ; CBufferLoadLegacy(handle,regIndex) 108 | %8 = extractvalue %dx.types.CBufRet.f32 %7, 0 109 | %9 = extractvalue %dx.types.CBufRet.f32 %7, 1 110 | %10 = extractvalue %dx.types.CBufRet.f32 %7, 2 111 | %11 = call float @dx.op.dot3.f32(i32 55, float %4, float %5, float %6, float %1, float %2, float %3) #2 ; Dot3(ax,ay,az,bx,by,bz) 112 | %.i0.i = fmul fast float %11, %8 113 | %.i1.i = fmul fast float %11, %9 114 | %.i2.i = fmul fast float %11, %10 115 | %FMax.i = call float @dx.op.binary.f32(i32 35, float %.i0.i, float 0.000000e+00) #2 ; FMax(a,b) 116 | %FMax1.i = call float @dx.op.binary.f32(i32 35, float %.i1.i, float 0.000000e+00) #2 ; FMax(a,b) 117 | %FMax2.i = call float @dx.op.binary.f32(i32 35, float %.i2.i, float 0.000000e+00) #2 ; FMax(a,b) 118 | call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 0, float %FMax.i) ; StoreOutput(outputSigId,rowIndex,colIndex,value) 119 | call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 1, float %FMax1.i) ; StoreOutput(outputSigId,rowIndex,colIndex,value) 120 | call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 2, float %FMax2.i) ; StoreOutput(outputSigId,rowIndex,colIndex,value) 121 | call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 3, float 1.000000e+00) ; StoreOutput(outputSigId,rowIndex,colIndex,value) 122 | ret void 123 | } 124 | 125 | ; Function Attrs: nounwind readonly 126 | declare %dx.types.Handle @dx.op.createHandle(i32, i8, i32, i32, i1) #1 127 | 128 | attributes #0 = { nounwind readnone } 129 | attributes #1 = { nounwind readonly } 130 | attributes #2 = { nounwind } 131 | 132 | !llvm.ident = !{!0, !0} 133 | !dx.version = !{!1} 134 | !dx.valver = !{!2} 135 | !dx.shaderModel = !{!3} 136 | !dx.resources = !{!4} 137 | !dx.typeAnnotations = !{!7, !12} 138 | !dx.viewIdState = !{!16} 139 | !dx.entryPoints = !{!17} 140 | 141 | !0 = !{!"clang version 3.7 (tags/RELEASE_370/final)"} 142 | !1 = !{i32 1, i32 0} 143 | !2 = !{i32 1, i32 6} 144 | !3 = !{!"ps", i32 6, i32 0} 145 | !4 = !{null, null, !5, null} 146 | !5 = !{!6} 147 | !6 = !{i32 0, %cbPS* undef, !"cbPS", i32 0, i32 0, i32 1, i32 32, null} 148 | !7 = !{i32 0, %cbPS undef, !8} 149 | !8 = !{i32 32, !9, !10, !11} 150 | !9 = !{i32 6, !"diffColor", i32 3, i32 0, i32 7, i32 9} 151 | !10 = !{i32 6, !"specColor", i32 3, i32 16, i32 7, i32 9} 152 | !11 = !{i32 6, !"shininess", i32 3, i32 28, i32 7, i32 9} 153 | !12 = !{i32 1, void ()* @main, !13} 154 | !13 = !{!14} 155 | !14 = !{i32 0, !15, !15} 156 | !15 = !{} 157 | !16 = !{[17 x i32] [i32 15, i32 4, i32 0, i32 0, i32 0, i32 0, i32 7, i32 7, i32 7, i32 0, i32 7, i32 7, i32 7, i32 0, i32 0, i32 0, i32 0]} 158 | !17 = !{void ()* @main, !"main", !18, !4, null} 159 | !18 = !{!19, !27, null} 160 | !19 = !{!20, !22, !24, !25} 161 | !20 = !{i32 0, !"SV_Position", i8 9, i8 3, !21, i8 4, i32 1, i8 4, i32 0, i8 0, null} 162 | !21 = !{i32 0} 163 | !22 = !{i32 1, !"NORMAL", i8 9, i8 0, !21, i8 2, i32 1, i8 3, i32 1, i8 0, !23} 164 | !23 = !{i32 3, i32 7} 165 | !24 = !{i32 2, !"TEXCOORD", i8 9, i8 0, !21, i8 2, i32 1, i8 3, i32 2, i8 0, !23} 166 | !25 = !{i32 3, !"TEXCOORD", i8 9, i8 0, !26, i8 2, i32 1, i8 3, i32 3, i8 0, null} 167 | !26 = !{i32 1} 168 | !27 = !{!28} 169 | !28 = !{i32 0, !"SV_Target", i8 9, i8 16, !21, i8 0, i32 1, i8 4, i32 0, i8 0, !29} 170 | !29 = !{i32 3, i32 15} 171 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Constant_PS.30.hlsl: -------------------------------------------------------------------------------- 1 | static float4 out_var_SV_Target; 2 | 3 | struct SPIRV_Cross_Output 4 | { 5 | float4 out_var_SV_Target : COLOR0; 6 | }; 7 | 8 | void frag_main() 9 | { 10 | out_var_SV_Target = float4(0.20000000298023223876953125f, 0.4000000059604644775390625f, 0.60000002384185791015625f, 1.0f); 11 | } 12 | 13 | SPIRV_Cross_Output main() 14 | { 15 | frag_main(); 16 | SPIRV_Cross_Output stage_output; 17 | stage_output.out_var_SV_Target = float4(out_var_SV_Target); 18 | return stage_output; 19 | } 20 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Constant_PS.300.essl: -------------------------------------------------------------------------------- 1 | #version 300 es 2 | precision mediump float; 3 | precision highp int; 4 | 5 | layout(location = 0) out highp vec4 out_var_SV_Target; 6 | 7 | void main() 8 | { 9 | out_var_SV_Target = vec4(0.20000000298023223876953125, 0.4000000059604644775390625, 0.60000002384185791015625, 1.0); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Constant_PS.300.glsl: -------------------------------------------------------------------------------- 1 | #version 300 2 | #extension GL_ARB_separate_shader_objects : require 3 | 4 | out vec4 out_var_SV_Target; 5 | 6 | void main() 7 | { 8 | out_var_SV_Target = vec4(0.20000000298023223876953125, 0.4000000059604644775390625, 0.60000002384185791015625, 1.0); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Constant_PS.310.essl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | precision mediump float; 3 | precision highp int; 4 | 5 | layout(location = 0) out highp vec4 out_var_SV_Target; 6 | 7 | void main() 8 | { 9 | out_var_SV_Target = vec4(0.20000000298023223876953125, 0.4000000059604644775390625, 0.60000002384185791015625, 1.0); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Constant_PS.40.hlsl: -------------------------------------------------------------------------------- 1 | static float4 out_var_SV_Target; 2 | 3 | struct SPIRV_Cross_Output 4 | { 5 | float4 out_var_SV_Target : SV_Target0; 6 | }; 7 | 8 | void frag_main() 9 | { 10 | out_var_SV_Target = float4(0.20000000298023223876953125f, 0.4000000059604644775390625f, 0.60000002384185791015625f, 1.0f); 11 | } 12 | 13 | SPIRV_Cross_Output main() 14 | { 15 | frag_main(); 16 | SPIRV_Cross_Output stage_output; 17 | stage_output.out_var_SV_Target = out_var_SV_Target; 18 | return stage_output; 19 | } 20 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Constant_PS.410.glsl: -------------------------------------------------------------------------------- 1 | #version 410 2 | 3 | layout(location = 0) out vec4 out_var_SV_Target; 4 | 5 | void main() 6 | { 7 | out_var_SV_Target = vec4(0.20000000298023223876953125, 0.4000000059604644775390625, 0.60000002384185791015625, 1.0); 8 | } 9 | 10 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Constant_PS.50.hlsl: -------------------------------------------------------------------------------- 1 | static float4 out_var_SV_Target; 2 | 3 | struct SPIRV_Cross_Output 4 | { 5 | float4 out_var_SV_Target : SV_Target0; 6 | }; 7 | 8 | void frag_main() 9 | { 10 | out_var_SV_Target = float4(0.20000000298023223876953125f, 0.4000000059604644775390625f, 0.60000002384185791015625f, 1.0f); 11 | } 12 | 13 | SPIRV_Cross_Output main() 14 | { 15 | frag_main(); 16 | SPIRV_Cross_Output stage_output; 17 | stage_output.out_var_SV_Target = out_var_SV_Target; 18 | return stage_output; 19 | } 20 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Constant_PS.msl: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace metal; 5 | 6 | struct PSMain_out 7 | { 8 | float4 out_var_SV_Target [[color(0)]]; 9 | }; 10 | 11 | fragment PSMain_out PSMain() 12 | { 13 | PSMain_out out = {}; 14 | out.out_var_SV_Target = float4(0.20000000298023223876953125, 0.4000000059604644775390625, 0.60000002384185791015625, 1.0); 15 | return out; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Constant_VS.30.hlsl: -------------------------------------------------------------------------------- 1 | uniform float4 gl_HalfPixel; 2 | 3 | static float4 gl_Position; 4 | struct SPIRV_Cross_Output 5 | { 6 | float4 gl_Position : POSITION; 7 | }; 8 | 9 | void vert_main() 10 | { 11 | gl_Position = float4(1.0f, 2.0f, 3.0f, 4.0f); 12 | gl_Position.x = gl_Position.x - gl_HalfPixel.x * gl_Position.w; 13 | gl_Position.y = gl_Position.y + gl_HalfPixel.y * gl_Position.w; 14 | } 15 | 16 | SPIRV_Cross_Output main() 17 | { 18 | vert_main(); 19 | SPIRV_Cross_Output stage_output; 20 | stage_output.gl_Position = gl_Position; 21 | return stage_output; 22 | } 23 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Constant_VS.300.essl: -------------------------------------------------------------------------------- 1 | #version 300 es 2 | 3 | void main() 4 | { 5 | gl_Position = vec4(1.0, 2.0, 3.0, 4.0); 6 | } 7 | 8 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Constant_VS.300.glsl: -------------------------------------------------------------------------------- 1 | #version 300 2 | #extension GL_ARB_separate_shader_objects : require 3 | 4 | out gl_PerVertex 5 | { 6 | vec4 gl_Position; 7 | }; 8 | 9 | void main() 10 | { 11 | gl_Position = vec4(1.0, 2.0, 3.0, 4.0); 12 | } 13 | 14 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Constant_VS.310.essl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | 3 | void main() 4 | { 5 | gl_Position = vec4(1.0, 2.0, 3.0, 4.0); 6 | } 7 | 8 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Constant_VS.40.hlsl: -------------------------------------------------------------------------------- 1 | static float4 gl_Position; 2 | struct SPIRV_Cross_Output 3 | { 4 | float4 gl_Position : SV_Position; 5 | }; 6 | 7 | void vert_main() 8 | { 9 | gl_Position = float4(1.0f, 2.0f, 3.0f, 4.0f); 10 | } 11 | 12 | SPIRV_Cross_Output main() 13 | { 14 | vert_main(); 15 | SPIRV_Cross_Output stage_output; 16 | stage_output.gl_Position = gl_Position; 17 | return stage_output; 18 | } 19 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Constant_VS.410.glsl: -------------------------------------------------------------------------------- 1 | #version 410 2 | 3 | out gl_PerVertex 4 | { 5 | vec4 gl_Position; 6 | }; 7 | 8 | void main() 9 | { 10 | gl_Position = vec4(1.0, 2.0, 3.0, 4.0); 11 | } 12 | 13 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Constant_VS.50.hlsl: -------------------------------------------------------------------------------- 1 | static float4 gl_Position; 2 | struct SPIRV_Cross_Output 3 | { 4 | float4 gl_Position : SV_Position; 5 | }; 6 | 7 | void vert_main() 8 | { 9 | gl_Position = float4(1.0f, 2.0f, 3.0f, 4.0f); 10 | } 11 | 12 | SPIRV_Cross_Output main() 13 | { 14 | vert_main(); 15 | SPIRV_Cross_Output stage_output; 16 | stage_output.gl_Position = gl_Position; 17 | return stage_output; 18 | } 19 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Constant_VS.msl: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace metal; 5 | 6 | struct VSMain_out 7 | { 8 | float4 gl_Position [[position]]; 9 | }; 10 | 11 | vertex VSMain_out VSMain() 12 | { 13 | VSMain_out out = {}; 14 | out.gl_Position = float4(1.0, 2.0, 3.0, 4.0); 15 | return out; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/DetailTessellation_HS.300.essl: -------------------------------------------------------------------------------- 1 | #version 300 es 2 | #extension GL_EXT_tessellation_shader : require 3 | layout(vertices = 3) out; 4 | 5 | struct VS_OUTPUT_HS_INPUT 6 | { 7 | vec3 worldPos; 8 | vec3 normal; 9 | vec2 texCoord; 10 | vec3 lightTS; 11 | }; 12 | 13 | layout(std140) uniform type_cbMain 14 | { 15 | vec4 tessellationFactor; 16 | } cbMain; 17 | 18 | in vec3 in_var_WORLDPOS[]; 19 | in vec3 in_var_NORMAL[]; 20 | in vec2 in_var_TEXCOORD0[]; 21 | in vec3 in_var_LIGHTVECTORTS[]; 22 | out vec3 out_var_WORLDPOS[3]; 23 | out vec3 out_var_NORMAL[3]; 24 | out vec2 out_var_TEXCOORD0[3]; 25 | out vec3 out_var_LIGHTVECTORTS[3]; 26 | 27 | void main() 28 | { 29 | vec3 _58_unrolled[3]; 30 | for (int i = 0; i < int(3); i++) 31 | { 32 | _58_unrolled[i] = in_var_WORLDPOS[i]; 33 | } 34 | vec3 _59_unrolled[3]; 35 | for (int i = 0; i < int(3); i++) 36 | { 37 | _59_unrolled[i] = in_var_NORMAL[i]; 38 | } 39 | vec2 _60_unrolled[3]; 40 | for (int i = 0; i < int(3); i++) 41 | { 42 | _60_unrolled[i] = in_var_TEXCOORD0[i]; 43 | } 44 | vec3 _61_unrolled[3]; 45 | for (int i = 0; i < int(3); i++) 46 | { 47 | _61_unrolled[i] = in_var_LIGHTVECTORTS[i]; 48 | } 49 | VS_OUTPUT_HS_INPUT param_var_inputPatch[3] = VS_OUTPUT_HS_INPUT[](VS_OUTPUT_HS_INPUT(_58_unrolled[0], _59_unrolled[0], _60_unrolled[0], _61_unrolled[0]), VS_OUTPUT_HS_INPUT(_58_unrolled[1], _59_unrolled[1], _60_unrolled[1], _61_unrolled[1]), VS_OUTPUT_HS_INPUT(_58_unrolled[2], _59_unrolled[2], _60_unrolled[2], _61_unrolled[2])); 50 | out_var_WORLDPOS[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].worldPos; 51 | out_var_NORMAL[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].normal; 52 | out_var_TEXCOORD0[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].texCoord; 53 | out_var_LIGHTVECTORTS[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].lightTS; 54 | barrier(); 55 | if (gl_InvocationID == 0u) 56 | { 57 | gl_TessLevelOuter[0u] = cbMain.tessellationFactor.x; 58 | gl_TessLevelOuter[1u] = cbMain.tessellationFactor.y; 59 | gl_TessLevelOuter[2u] = cbMain.tessellationFactor.z; 60 | gl_TessLevelInner[0u] = cbMain.tessellationFactor.w; 61 | } 62 | } 63 | 64 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/DetailTessellation_HS.300.glsl: -------------------------------------------------------------------------------- 1 | #version 300 2 | #extension GL_ARB_tessellation_shader : require 3 | #extension GL_ARB_separate_shader_objects : require 4 | layout(vertices = 3) out; 5 | 6 | struct VS_OUTPUT_HS_INPUT 7 | { 8 | vec3 worldPos; 9 | vec3 normal; 10 | vec2 texCoord; 11 | vec3 lightTS; 12 | }; 13 | 14 | layout(std140) uniform type_cbMain 15 | { 16 | vec4 tessellationFactor; 17 | } cbMain; 18 | 19 | layout(location = 0) in vec3 in_var_WORLDPOS[]; 20 | layout(location = 1) in vec3 in_var_NORMAL[]; 21 | layout(location = 2) in vec2 in_var_TEXCOORD0[]; 22 | layout(location = 3) in vec3 in_var_LIGHTVECTORTS[]; 23 | layout(location = 3) out vec3 out_var_WORLDPOS[3]; 24 | layout(location = 1) out vec3 out_var_NORMAL[3]; 25 | layout(location = 2) out vec2 out_var_TEXCOORD0[3]; 26 | layout(location = 0) out vec3 out_var_LIGHTVECTORTS[3]; 27 | 28 | void main() 29 | { 30 | vec3 _58_unrolled[3]; 31 | for (int i = 0; i < int(3); i++) 32 | { 33 | _58_unrolled[i] = in_var_WORLDPOS[i]; 34 | } 35 | vec3 _59_unrolled[3]; 36 | for (int i = 0; i < int(3); i++) 37 | { 38 | _59_unrolled[i] = in_var_NORMAL[i]; 39 | } 40 | vec2 _60_unrolled[3]; 41 | for (int i = 0; i < int(3); i++) 42 | { 43 | _60_unrolled[i] = in_var_TEXCOORD0[i]; 44 | } 45 | vec3 _61_unrolled[3]; 46 | for (int i = 0; i < int(3); i++) 47 | { 48 | _61_unrolled[i] = in_var_LIGHTVECTORTS[i]; 49 | } 50 | VS_OUTPUT_HS_INPUT param_var_inputPatch[3] = VS_OUTPUT_HS_INPUT[](VS_OUTPUT_HS_INPUT(_58_unrolled[0], _59_unrolled[0], _60_unrolled[0], _61_unrolled[0]), VS_OUTPUT_HS_INPUT(_58_unrolled[1], _59_unrolled[1], _60_unrolled[1], _61_unrolled[1]), VS_OUTPUT_HS_INPUT(_58_unrolled[2], _59_unrolled[2], _60_unrolled[2], _61_unrolled[2])); 51 | out_var_WORLDPOS[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].worldPos; 52 | out_var_NORMAL[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].normal; 53 | out_var_TEXCOORD0[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].texCoord; 54 | out_var_LIGHTVECTORTS[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].lightTS; 55 | barrier(); 56 | if (gl_InvocationID == 0u) 57 | { 58 | gl_TessLevelOuter[0u] = cbMain.tessellationFactor.x; 59 | gl_TessLevelOuter[1u] = cbMain.tessellationFactor.y; 60 | gl_TessLevelOuter[2u] = cbMain.tessellationFactor.z; 61 | gl_TessLevelInner[0u] = cbMain.tessellationFactor.w; 62 | } 63 | } 64 | 65 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/DetailTessellation_HS.310.essl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | #extension GL_EXT_tessellation_shader : require 3 | layout(vertices = 3) out; 4 | 5 | struct VS_OUTPUT_HS_INPUT 6 | { 7 | vec3 worldPos; 8 | vec3 normal; 9 | vec2 texCoord; 10 | vec3 lightTS; 11 | }; 12 | 13 | layout(binding = 0, std140) uniform type_cbMain 14 | { 15 | vec4 tessellationFactor; 16 | } cbMain; 17 | 18 | layout(location = 0) in vec3 in_var_WORLDPOS[]; 19 | layout(location = 1) in vec3 in_var_NORMAL[]; 20 | layout(location = 2) in vec2 in_var_TEXCOORD0[]; 21 | layout(location = 3) in vec3 in_var_LIGHTVECTORTS[]; 22 | layout(location = 3) out vec3 out_var_WORLDPOS[3]; 23 | layout(location = 1) out vec3 out_var_NORMAL[3]; 24 | layout(location = 2) out vec2 out_var_TEXCOORD0[3]; 25 | layout(location = 0) out vec3 out_var_LIGHTVECTORTS[3]; 26 | 27 | void main() 28 | { 29 | vec3 _58_unrolled[3]; 30 | for (int i = 0; i < int(3); i++) 31 | { 32 | _58_unrolled[i] = in_var_WORLDPOS[i]; 33 | } 34 | vec3 _59_unrolled[3]; 35 | for (int i = 0; i < int(3); i++) 36 | { 37 | _59_unrolled[i] = in_var_NORMAL[i]; 38 | } 39 | vec2 _60_unrolled[3]; 40 | for (int i = 0; i < int(3); i++) 41 | { 42 | _60_unrolled[i] = in_var_TEXCOORD0[i]; 43 | } 44 | vec3 _61_unrolled[3]; 45 | for (int i = 0; i < int(3); i++) 46 | { 47 | _61_unrolled[i] = in_var_LIGHTVECTORTS[i]; 48 | } 49 | VS_OUTPUT_HS_INPUT param_var_inputPatch[3] = VS_OUTPUT_HS_INPUT[](VS_OUTPUT_HS_INPUT(_58_unrolled[0], _59_unrolled[0], _60_unrolled[0], _61_unrolled[0]), VS_OUTPUT_HS_INPUT(_58_unrolled[1], _59_unrolled[1], _60_unrolled[1], _61_unrolled[1]), VS_OUTPUT_HS_INPUT(_58_unrolled[2], _59_unrolled[2], _60_unrolled[2], _61_unrolled[2])); 50 | out_var_WORLDPOS[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].worldPos; 51 | out_var_NORMAL[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].normal; 52 | out_var_TEXCOORD0[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].texCoord; 53 | out_var_LIGHTVECTORTS[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].lightTS; 54 | barrier(); 55 | if (gl_InvocationID == 0u) 56 | { 57 | gl_TessLevelOuter[0u] = cbMain.tessellationFactor.x; 58 | gl_TessLevelOuter[1u] = cbMain.tessellationFactor.y; 59 | gl_TessLevelOuter[2u] = cbMain.tessellationFactor.z; 60 | gl_TessLevelInner[0u] = cbMain.tessellationFactor.w; 61 | } 62 | } 63 | 64 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/DetailTessellation_HS.410.glsl: -------------------------------------------------------------------------------- 1 | #version 410 2 | layout(vertices = 3) out; 3 | 4 | struct VS_OUTPUT_HS_INPUT 5 | { 6 | vec3 worldPos; 7 | vec3 normal; 8 | vec2 texCoord; 9 | vec3 lightTS; 10 | }; 11 | 12 | layout(std140) uniform type_cbMain 13 | { 14 | vec4 tessellationFactor; 15 | } cbMain; 16 | 17 | layout(location = 0) in vec3 in_var_WORLDPOS[]; 18 | layout(location = 1) in vec3 in_var_NORMAL[]; 19 | layout(location = 2) in vec2 in_var_TEXCOORD0[]; 20 | layout(location = 3) in vec3 in_var_LIGHTVECTORTS[]; 21 | layout(location = 3) out vec3 out_var_WORLDPOS[3]; 22 | layout(location = 1) out vec3 out_var_NORMAL[3]; 23 | layout(location = 2) out vec2 out_var_TEXCOORD0[3]; 24 | layout(location = 0) out vec3 out_var_LIGHTVECTORTS[3]; 25 | 26 | void main() 27 | { 28 | vec3 _58_unrolled[3]; 29 | for (int i = 0; i < int(3); i++) 30 | { 31 | _58_unrolled[i] = in_var_WORLDPOS[i]; 32 | } 33 | vec3 _59_unrolled[3]; 34 | for (int i = 0; i < int(3); i++) 35 | { 36 | _59_unrolled[i] = in_var_NORMAL[i]; 37 | } 38 | vec2 _60_unrolled[3]; 39 | for (int i = 0; i < int(3); i++) 40 | { 41 | _60_unrolled[i] = in_var_TEXCOORD0[i]; 42 | } 43 | vec3 _61_unrolled[3]; 44 | for (int i = 0; i < int(3); i++) 45 | { 46 | _61_unrolled[i] = in_var_LIGHTVECTORTS[i]; 47 | } 48 | VS_OUTPUT_HS_INPUT param_var_inputPatch[3] = VS_OUTPUT_HS_INPUT[](VS_OUTPUT_HS_INPUT(_58_unrolled[0], _59_unrolled[0], _60_unrolled[0], _61_unrolled[0]), VS_OUTPUT_HS_INPUT(_58_unrolled[1], _59_unrolled[1], _60_unrolled[1], _61_unrolled[1]), VS_OUTPUT_HS_INPUT(_58_unrolled[2], _59_unrolled[2], _60_unrolled[2], _61_unrolled[2])); 49 | out_var_WORLDPOS[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].worldPos; 50 | out_var_NORMAL[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].normal; 51 | out_var_TEXCOORD0[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].texCoord; 52 | out_var_LIGHTVECTORTS[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].lightTS; 53 | barrier(); 54 | if (gl_InvocationID == 0u) 55 | { 56 | gl_TessLevelOuter[0u] = cbMain.tessellationFactor.x; 57 | gl_TessLevelOuter[1u] = cbMain.tessellationFactor.y; 58 | gl_TessLevelOuter[2u] = cbMain.tessellationFactor.z; 59 | gl_TessLevelInner[0u] = cbMain.tessellationFactor.w; 60 | } 61 | } 62 | 63 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/DetailTessellation_HS.msl: -------------------------------------------------------------------------------- 1 | #pragma clang diagnostic ignored "-Wmissing-prototypes" 2 | #pragma clang diagnostic ignored "-Wmissing-braces" 3 | 4 | #include 5 | #include 6 | 7 | using namespace metal; 8 | 9 | template 10 | struct spvUnsafeArray 11 | { 12 | T elements[Num ? Num : 1]; 13 | 14 | thread T& operator [] (size_t pos) thread 15 | { 16 | return elements[pos]; 17 | } 18 | constexpr const thread T& operator [] (size_t pos) const thread 19 | { 20 | return elements[pos]; 21 | } 22 | 23 | device T& operator [] (size_t pos) device 24 | { 25 | return elements[pos]; 26 | } 27 | constexpr const device T& operator [] (size_t pos) const device 28 | { 29 | return elements[pos]; 30 | } 31 | 32 | constexpr const constant T& operator [] (size_t pos) const constant 33 | { 34 | return elements[pos]; 35 | } 36 | 37 | threadgroup T& operator [] (size_t pos) threadgroup 38 | { 39 | return elements[pos]; 40 | } 41 | constexpr const threadgroup T& operator [] (size_t pos) const threadgroup 42 | { 43 | return elements[pos]; 44 | } 45 | }; 46 | 47 | struct type_cbMain 48 | { 49 | float4 tessellationFactor; 50 | }; 51 | 52 | struct VS_OUTPUT_HS_INPUT 53 | { 54 | float3 worldPos; 55 | float3 normal; 56 | float2 texCoord; 57 | float3 lightTS; 58 | }; 59 | 60 | struct main0_out 61 | { 62 | float3 out_var_LIGHTVECTORTS; 63 | float3 out_var_NORMAL; 64 | float2 out_var_TEXCOORD0; 65 | float3 out_var_WORLDPOS; 66 | }; 67 | 68 | struct main0_in 69 | { 70 | float3 in_var_WORLDPOS [[attribute(0)]]; 71 | float3 in_var_NORMAL [[attribute(1)]]; 72 | float2 in_var_TEXCOORD0 [[attribute(2)]]; 73 | float3 in_var_LIGHTVECTORTS [[attribute(3)]]; 74 | }; 75 | 76 | kernel void main0(main0_in in [[stage_in]], constant type_cbMain& cbMain [[buffer(0)]], uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLTriangleTessellationFactorsHalf* spvTessLevel [[buffer(26)]], threadgroup main0_in* gl_in [[threadgroup(0)]]) 77 | { 78 | device main0_out* gl_out = &spvOut[gl_PrimitiveID * 3]; 79 | if (gl_InvocationID < spvIndirectParams[0]) 80 | gl_in[gl_InvocationID] = in; 81 | threadgroup_barrier(mem_flags::mem_threadgroup); 82 | if (gl_InvocationID >= 3) 83 | return; 84 | spvUnsafeArray _58 = spvUnsafeArray({ gl_in[0].in_var_WORLDPOS, gl_in[1].in_var_WORLDPOS, gl_in[2].in_var_WORLDPOS }); 85 | spvUnsafeArray _59 = spvUnsafeArray({ gl_in[0].in_var_NORMAL, gl_in[1].in_var_NORMAL, gl_in[2].in_var_NORMAL }); 86 | spvUnsafeArray _60 = spvUnsafeArray({ gl_in[0].in_var_TEXCOORD0, gl_in[1].in_var_TEXCOORD0, gl_in[2].in_var_TEXCOORD0 }); 87 | spvUnsafeArray _61 = spvUnsafeArray({ gl_in[0].in_var_LIGHTVECTORTS, gl_in[1].in_var_LIGHTVECTORTS, gl_in[2].in_var_LIGHTVECTORTS }); 88 | spvUnsafeArray _77 = spvUnsafeArray({ VS_OUTPUT_HS_INPUT{ _58[0], _59[0], _60[0], _61[0] }, VS_OUTPUT_HS_INPUT{ _58[1], _59[1], _60[1], _61[1] }, VS_OUTPUT_HS_INPUT{ _58[2], _59[2], _60[2], _61[2] } }); 89 | spvUnsafeArray param_var_inputPatch; 90 | param_var_inputPatch = _77; 91 | gl_out[gl_InvocationID].out_var_WORLDPOS = param_var_inputPatch[gl_InvocationID].worldPos; 92 | gl_out[gl_InvocationID].out_var_NORMAL = param_var_inputPatch[gl_InvocationID].normal; 93 | gl_out[gl_InvocationID].out_var_TEXCOORD0 = param_var_inputPatch[gl_InvocationID].texCoord; 94 | gl_out[gl_InvocationID].out_var_LIGHTVECTORTS = param_var_inputPatch[gl_InvocationID].lightTS; 95 | threadgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup); 96 | if (gl_InvocationID == 0u) 97 | { 98 | spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0u] = half(cbMain.tessellationFactor.x); 99 | spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1u] = half(cbMain.tessellationFactor.y); 100 | spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2u] = half(cbMain.tessellationFactor.z); 101 | spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(cbMain.tessellationFactor.w); 102 | } 103 | } 104 | 105 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/DotHalfPS.glsl: -------------------------------------------------------------------------------- 1 | #version 30 2 | #if defined(GL_AMD_gpu_shader_half_float) 3 | #extension GL_AMD_gpu_shader_half_float : require 4 | #elif defined(GL_NV_gpu_shader5) 5 | #extension GL_NV_gpu_shader5 : require 6 | #else 7 | #error No extension available for FP16. 8 | #endif 9 | #extension GL_ARB_separate_shader_objects : require 10 | 11 | void main() 12 | { 13 | gl_FragData[0] = vec4(float(dot(f16vec3(float16_t(0.0), float16_t(0.0), float16_t(1.0)), f16vec3(float16_t(0.0), float16_t(0.0), float16_t(1.0))))); 14 | } 15 | 16 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Fluid_CS.300.glsl: -------------------------------------------------------------------------------- 1 | #version 300 2 | #extension GL_ARB_compute_shader : require 3 | #extension GL_ARB_separate_shader_objects : require 4 | layout(local_size_x = 256, local_size_y = 1, local_size_z = 1) in; 5 | 6 | struct Particle 7 | { 8 | vec2 position; 9 | vec2 velocity; 10 | }; 11 | 12 | struct ParticleForces 13 | { 14 | vec2 acceleration; 15 | }; 16 | 17 | layout(std140) uniform type_cbSimulationConstants 18 | { 19 | float timeStep; 20 | float wallStiffness; 21 | vec4 gravity; 22 | vec3 planes[4]; 23 | } cbSimulationConstants; 24 | 25 | layout(std430) buffer type_RWStructuredBuffer_Particle 26 | { 27 | Particle _m0[]; 28 | } particlesRW; 29 | 30 | layout(std430) readonly buffer type_StructuredBuffer_Particle 31 | { 32 | Particle _m0[]; 33 | } particlesRO; 34 | 35 | layout(std430) readonly buffer type_StructuredBuffer_ParticleForces 36 | { 37 | ParticleForces _m0[]; 38 | } particlesForcesRO; 39 | 40 | void main() 41 | { 42 | vec2 _52 = particlesRO._m0[gl_GlobalInvocationID.x].position; 43 | vec2 _54 = particlesRO._m0[gl_GlobalInvocationID.x].velocity; 44 | vec2 _56 = particlesForcesRO._m0[gl_GlobalInvocationID.x].acceleration; 45 | vec3 _59 = vec3(_52, 1.0); 46 | float _67 = -cbSimulationConstants.wallStiffness; 47 | vec2 _102 = _54 + ((((((_56 + (cbSimulationConstants.planes[0u].xy * (min(dot(_59, cbSimulationConstants.planes[0u]), 0.0) * _67))) + (cbSimulationConstants.planes[1u].xy * (min(dot(_59, cbSimulationConstants.planes[1u]), 0.0) * _67))) + (cbSimulationConstants.planes[2u].xy * (min(dot(_59, cbSimulationConstants.planes[2u]), 0.0) * _67))) + (cbSimulationConstants.planes[3u].xy * (min(dot(_59, cbSimulationConstants.planes[3u]), 0.0) * _67))) + cbSimulationConstants.gravity.xy) * cbSimulationConstants.timeStep); 48 | particlesRW._m0[gl_GlobalInvocationID.x].position = _52 + (_102 * cbSimulationConstants.timeStep); 49 | particlesRW._m0[gl_GlobalInvocationID.x].velocity = _102; 50 | } 51 | 52 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Fluid_CS.310.essl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | layout(local_size_x = 256, local_size_y = 1, local_size_z = 1) in; 3 | 4 | struct Particle 5 | { 6 | vec2 position; 7 | vec2 velocity; 8 | }; 9 | 10 | struct ParticleForces 11 | { 12 | vec2 acceleration; 13 | }; 14 | 15 | layout(binding = 0, std140) uniform type_cbSimulationConstants 16 | { 17 | float timeStep; 18 | float wallStiffness; 19 | vec4 gravity; 20 | vec3 planes[4]; 21 | } cbSimulationConstants; 22 | 23 | layout(binding = 0, std430) buffer type_RWStructuredBuffer_Particle 24 | { 25 | Particle _m0[]; 26 | } particlesRW; 27 | 28 | layout(binding = 0, std430) readonly buffer type_StructuredBuffer_Particle 29 | { 30 | Particle _m0[]; 31 | } particlesRO; 32 | 33 | layout(binding = 2, std430) readonly buffer type_StructuredBuffer_ParticleForces 34 | { 35 | ParticleForces _m0[]; 36 | } particlesForcesRO; 37 | 38 | void main() 39 | { 40 | vec2 _52 = particlesRO._m0[gl_GlobalInvocationID.x].position; 41 | vec2 _54 = particlesRO._m0[gl_GlobalInvocationID.x].velocity; 42 | vec2 _56 = particlesForcesRO._m0[gl_GlobalInvocationID.x].acceleration; 43 | vec3 _59 = vec3(_52, 1.0); 44 | float _67 = -cbSimulationConstants.wallStiffness; 45 | vec2 _102 = _54 + ((((((_56 + (cbSimulationConstants.planes[0u].xy * (min(dot(_59, cbSimulationConstants.planes[0u]), 0.0) * _67))) + (cbSimulationConstants.planes[1u].xy * (min(dot(_59, cbSimulationConstants.planes[1u]), 0.0) * _67))) + (cbSimulationConstants.planes[2u].xy * (min(dot(_59, cbSimulationConstants.planes[2u]), 0.0) * _67))) + (cbSimulationConstants.planes[3u].xy * (min(dot(_59, cbSimulationConstants.planes[3u]), 0.0) * _67))) + cbSimulationConstants.gravity.xy) * cbSimulationConstants.timeStep); 46 | particlesRW._m0[gl_GlobalInvocationID.x].position = _52 + (_102 * cbSimulationConstants.timeStep); 47 | particlesRW._m0[gl_GlobalInvocationID.x].velocity = _102; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Fluid_CS.410.glsl: -------------------------------------------------------------------------------- 1 | #version 410 2 | #extension GL_ARB_compute_shader : require 3 | layout(local_size_x = 256, local_size_y = 1, local_size_z = 1) in; 4 | 5 | struct Particle 6 | { 7 | vec2 position; 8 | vec2 velocity; 9 | }; 10 | 11 | struct ParticleForces 12 | { 13 | vec2 acceleration; 14 | }; 15 | 16 | layout(std140) uniform type_cbSimulationConstants 17 | { 18 | float timeStep; 19 | float wallStiffness; 20 | vec4 gravity; 21 | vec3 planes[4]; 22 | } cbSimulationConstants; 23 | 24 | layout(std430) buffer type_RWStructuredBuffer_Particle 25 | { 26 | Particle _m0[]; 27 | } particlesRW; 28 | 29 | layout(std430) readonly buffer type_StructuredBuffer_Particle 30 | { 31 | Particle _m0[]; 32 | } particlesRO; 33 | 34 | layout(std430) readonly buffer type_StructuredBuffer_ParticleForces 35 | { 36 | ParticleForces _m0[]; 37 | } particlesForcesRO; 38 | 39 | void main() 40 | { 41 | vec2 _52 = particlesRO._m0[gl_GlobalInvocationID.x].position; 42 | vec2 _54 = particlesRO._m0[gl_GlobalInvocationID.x].velocity; 43 | vec2 _56 = particlesForcesRO._m0[gl_GlobalInvocationID.x].acceleration; 44 | vec3 _59 = vec3(_52, 1.0); 45 | float _67 = -cbSimulationConstants.wallStiffness; 46 | vec2 _102 = _54 + ((((((_56 + (cbSimulationConstants.planes[0u].xy * (min(dot(_59, cbSimulationConstants.planes[0u]), 0.0) * _67))) + (cbSimulationConstants.planes[1u].xy * (min(dot(_59, cbSimulationConstants.planes[1u]), 0.0) * _67))) + (cbSimulationConstants.planes[2u].xy * (min(dot(_59, cbSimulationConstants.planes[2u]), 0.0) * _67))) + (cbSimulationConstants.planes[3u].xy * (min(dot(_59, cbSimulationConstants.planes[3u]), 0.0) * _67))) + cbSimulationConstants.gravity.xy) * cbSimulationConstants.timeStep); 47 | particlesRW._m0[gl_GlobalInvocationID.x].position = _52 + (_102 * cbSimulationConstants.timeStep); 48 | particlesRW._m0[gl_GlobalInvocationID.x].velocity = _102; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Fluid_CS.50.hlsl: -------------------------------------------------------------------------------- 1 | struct Particle 2 | { 3 | float2 position; 4 | float2 velocity; 5 | }; 6 | 7 | struct ParticleForces 8 | { 9 | float2 acceleration; 10 | }; 11 | 12 | cbuffer type_cbSimulationConstants : register(b0) 13 | { 14 | float cbSimulationConstants_timeStep : packoffset(c0); 15 | float cbSimulationConstants_wallStiffness : packoffset(c0.y); 16 | float4 cbSimulationConstants_gravity : packoffset(c1); 17 | float3 cbSimulationConstants_planes[4] : packoffset(c2); 18 | }; 19 | 20 | RWByteAddressBuffer particlesRW : register(u0); 21 | ByteAddressBuffer particlesRO : register(t0); 22 | ByteAddressBuffer particlesForcesRO : register(t2); 23 | 24 | static uint3 gl_GlobalInvocationID; 25 | struct SPIRV_Cross_Input 26 | { 27 | uint3 gl_GlobalInvocationID : SV_DispatchThreadID; 28 | }; 29 | 30 | void comp_main() 31 | { 32 | float2 _52 = asfloat(particlesRO.Load2(gl_GlobalInvocationID.x * 16 + 0)); 33 | float2 _54 = asfloat(particlesRO.Load2(gl_GlobalInvocationID.x * 16 + 8)); 34 | float2 _56 = asfloat(particlesForcesRO.Load2(gl_GlobalInvocationID.x * 8 + 0)); 35 | float3 _59 = float3(_52, 1.0f); 36 | float _67 = -cbSimulationConstants_wallStiffness; 37 | float2 _102 = _54 + ((((((_56 + (cbSimulationConstants_planes[0u].xy * (min(dot(_59, cbSimulationConstants_planes[0u]), 0.0f) * _67))) + (cbSimulationConstants_planes[1u].xy * (min(dot(_59, cbSimulationConstants_planes[1u]), 0.0f) * _67))) + (cbSimulationConstants_planes[2u].xy * (min(dot(_59, cbSimulationConstants_planes[2u]), 0.0f) * _67))) + (cbSimulationConstants_planes[3u].xy * (min(dot(_59, cbSimulationConstants_planes[3u]), 0.0f) * _67))) + cbSimulationConstants_gravity.xy) * cbSimulationConstants_timeStep); 38 | particlesRW.Store2(gl_GlobalInvocationID.x * 16 + 0, asuint(_52 + (_102 * cbSimulationConstants_timeStep))); 39 | particlesRW.Store2(gl_GlobalInvocationID.x * 16 + 8, asuint(_102)); 40 | } 41 | 42 | [numthreads(256, 1, 1)] 43 | void main(SPIRV_Cross_Input stage_input) 44 | { 45 | gl_GlobalInvocationID = stage_input.gl_GlobalInvocationID; 46 | comp_main(); 47 | } 48 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Fluid_CS.msl: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace metal; 5 | 6 | struct type_cbSimulationConstants 7 | { 8 | float timeStep; 9 | float wallStiffness; 10 | float4 gravity; 11 | float3 planes[4]; 12 | }; 13 | 14 | struct Particle 15 | { 16 | float2 position; 17 | float2 velocity; 18 | }; 19 | 20 | struct type_RWStructuredBuffer_Particle 21 | { 22 | Particle _m0[1]; 23 | }; 24 | 25 | struct type_StructuredBuffer_Particle 26 | { 27 | Particle _m0[1]; 28 | }; 29 | 30 | struct ParticleForces 31 | { 32 | float2 acceleration; 33 | }; 34 | 35 | struct type_StructuredBuffer_ParticleForces 36 | { 37 | ParticleForces _m0[1]; 38 | }; 39 | 40 | kernel void main0(constant type_cbSimulationConstants& cbSimulationConstants [[buffer(0)]], device type_RWStructuredBuffer_Particle& particlesRW [[buffer(1)]], const device type_StructuredBuffer_Particle& particlesRO [[buffer(2)]], const device type_StructuredBuffer_ParticleForces& particlesForcesRO [[buffer(3)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) 41 | { 42 | float2 _52 = particlesRO._m0[gl_GlobalInvocationID.x].position; 43 | float2 _54 = particlesRO._m0[gl_GlobalInvocationID.x].velocity; 44 | float2 _56 = particlesForcesRO._m0[gl_GlobalInvocationID.x].acceleration; 45 | float3 _59 = float3(_52, 1.0); 46 | float _67 = -cbSimulationConstants.wallStiffness; 47 | float2 _102 = _54 + ((((((_56 + (cbSimulationConstants.planes[0u].xy * (fast::min(dot(_59, cbSimulationConstants.planes[0u]), 0.0) * _67))) + (cbSimulationConstants.planes[1u].xy * (fast::min(dot(_59, cbSimulationConstants.planes[1u]), 0.0) * _67))) + (cbSimulationConstants.planes[2u].xy * (fast::min(dot(_59, cbSimulationConstants.planes[2u]), 0.0) * _67))) + (cbSimulationConstants.planes[3u].xy * (fast::min(dot(_59, cbSimulationConstants.planes[3u]), 0.0) * _67))) + cbSimulationConstants.gravity.xy) * cbSimulationConstants.timeStep); 48 | particlesRW._m0[gl_GlobalInvocationID.x].position = _52 + (_102 * cbSimulationConstants.timeStep); 49 | particlesRW._m0[gl_GlobalInvocationID.x].velocity = _102; 50 | } 51 | 52 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/HalfOutParamPS.glsl: -------------------------------------------------------------------------------- 1 | #version 30 2 | #if defined(GL_AMD_gpu_shader_half_float) 3 | #extension GL_AMD_gpu_shader_half_float : require 4 | #elif defined(GL_NV_gpu_shader5) 5 | #extension GL_NV_gpu_shader5 : require 6 | #else 7 | #error No extension available for FP16. 8 | #endif 9 | #extension GL_ARB_separate_shader_objects : require 10 | 11 | void main() 12 | { 13 | gl_FragData[0] = vec4(vec3(cross(f16vec3(float16_t(1.0), float16_t(0.0), float16_t(0.0)), f16vec3(float16_t(0.0), float16_t(1.0), float16_t(0.0)))), 1.0); 14 | } 15 | 16 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/IncludeEmptyHeader.glsl: -------------------------------------------------------------------------------- 1 | #version 30 2 | #extension GL_ARB_separate_shader_objects : require 3 | 4 | void main() 5 | { 6 | gl_FragData[0] = vec4(0.0); 7 | } 8 | 9 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/IncludeExist.glsl: -------------------------------------------------------------------------------- 1 | #version 30 2 | #extension GL_ARB_separate_shader_objects : require 3 | 4 | uniform sampler2D SPIRV_Cross_CombinedcolorTexpointSampler; 5 | uniform sampler2D SPIRV_Cross_CombinedcolorTexlinearSampler; 6 | 7 | varying vec2 varying_TEXCOORD0; 8 | 9 | void main() 10 | { 11 | gl_FragData[0] = texture2D(SPIRV_Cross_CombinedcolorTexpointSampler, varying_TEXCOORD0) + texture2D(SPIRV_Cross_CombinedcolorTexlinearSampler, varying_TEXCOORD0); 12 | } 13 | 14 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/PNTriangles_DS.300.essl: -------------------------------------------------------------------------------- 1 | #version 300 es 2 | #extension GL_EXT_tessellation_shader : require 3 | layout(triangles) in; 4 | 5 | layout(std140) uniform type_cbPNTriangles 6 | { 7 | mat4 viewProj; 8 | vec4 lightDir; 9 | } cbPNTriangles; 10 | 11 | patch in vec3 in_var_POSITION3; 12 | patch in vec3 in_var_POSITION4; 13 | patch in vec3 in_var_POSITION5; 14 | patch in vec3 in_var_POSITION6; 15 | patch in vec3 in_var_POSITION7; 16 | patch in vec3 in_var_POSITION8; 17 | patch in vec3 in_var_CENTER; 18 | in vec3 in_var_POSITION[]; 19 | in vec2 in_var_TEXCOORD[]; 20 | out vec2 out_var_TEXCOORD0; 21 | 22 | void main() 23 | { 24 | vec3 _55_unrolled[3]; 25 | for (int i = 0; i < int(3); i++) 26 | { 27 | _55_unrolled[i] = in_var_POSITION[i]; 28 | } 29 | vec2 _56_unrolled[3]; 30 | for (int i = 0; i < int(3); i++) 31 | { 32 | _56_unrolled[i] = in_var_TEXCOORD[i]; 33 | } 34 | float _67 = gl_TessCoord.x * gl_TessCoord.x; 35 | float _68 = gl_TessCoord.y * gl_TessCoord.y; 36 | float _69 = gl_TessCoord.z * gl_TessCoord.z; 37 | float _70 = _67 * 3.0; 38 | float _71 = _68 * 3.0; 39 | float _72 = _69 * 3.0; 40 | gl_Position = cbPNTriangles.viewProj * vec4(((((((((((_55_unrolled[0] * _69) * gl_TessCoord.z) + ((_55_unrolled[1] * _67) * gl_TessCoord.x)) + ((_55_unrolled[2] * _68) * gl_TessCoord.y)) + ((in_var_POSITION3 * _72) * gl_TessCoord.x)) + ((in_var_POSITION4 * gl_TessCoord.z) * _70)) + ((in_var_POSITION8 * _72) * gl_TessCoord.y)) + ((in_var_POSITION5 * _70) * gl_TessCoord.y)) + ((in_var_POSITION7 * gl_TessCoord.z) * _71)) + ((in_var_POSITION6 * gl_TessCoord.x) * _71)) + ((((in_var_CENTER * 6.0) * gl_TessCoord.z) * gl_TessCoord.x) * gl_TessCoord.y), 1.0); 41 | out_var_TEXCOORD0 = ((_56_unrolled[0] * gl_TessCoord.z) + (_56_unrolled[1] * gl_TessCoord.x)) + (_56_unrolled[2] * gl_TessCoord.y); 42 | } 43 | 44 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/PNTriangles_DS.300.glsl: -------------------------------------------------------------------------------- 1 | #version 300 2 | #extension GL_ARB_tessellation_shader : require 3 | #extension GL_ARB_separate_shader_objects : require 4 | layout(triangles) in; 5 | 6 | out gl_PerVertex 7 | { 8 | vec4 gl_Position; 9 | }; 10 | 11 | layout(std140) uniform type_cbPNTriangles 12 | { 13 | mat4 viewProj; 14 | vec4 lightDir; 15 | } cbPNTriangles; 16 | 17 | layout(location = 2) patch in vec3 in_var_POSITION3; 18 | layout(location = 3) patch in vec3 in_var_POSITION4; 19 | layout(location = 4) patch in vec3 in_var_POSITION5; 20 | layout(location = 5) patch in vec3 in_var_POSITION6; 21 | layout(location = 6) patch in vec3 in_var_POSITION7; 22 | layout(location = 7) patch in vec3 in_var_POSITION8; 23 | layout(location = 0) patch in vec3 in_var_CENTER; 24 | layout(location = 1) in vec3 in_var_POSITION[]; 25 | layout(location = 8) in vec2 in_var_TEXCOORD[]; 26 | layout(location = 0) out vec2 out_var_TEXCOORD0; 27 | 28 | void main() 29 | { 30 | vec3 _55_unrolled[3]; 31 | for (int i = 0; i < int(3); i++) 32 | { 33 | _55_unrolled[i] = in_var_POSITION[i]; 34 | } 35 | vec2 _56_unrolled[3]; 36 | for (int i = 0; i < int(3); i++) 37 | { 38 | _56_unrolled[i] = in_var_TEXCOORD[i]; 39 | } 40 | float _67 = gl_TessCoord.x * gl_TessCoord.x; 41 | float _68 = gl_TessCoord.y * gl_TessCoord.y; 42 | float _69 = gl_TessCoord.z * gl_TessCoord.z; 43 | float _70 = _67 * 3.0; 44 | float _71 = _68 * 3.0; 45 | float _72 = _69 * 3.0; 46 | gl_Position = cbPNTriangles.viewProj * vec4(((((((((((_55_unrolled[0] * _69) * gl_TessCoord.z) + ((_55_unrolled[1] * _67) * gl_TessCoord.x)) + ((_55_unrolled[2] * _68) * gl_TessCoord.y)) + ((in_var_POSITION3 * _72) * gl_TessCoord.x)) + ((in_var_POSITION4 * gl_TessCoord.z) * _70)) + ((in_var_POSITION8 * _72) * gl_TessCoord.y)) + ((in_var_POSITION5 * _70) * gl_TessCoord.y)) + ((in_var_POSITION7 * gl_TessCoord.z) * _71)) + ((in_var_POSITION6 * gl_TessCoord.x) * _71)) + ((((in_var_CENTER * 6.0) * gl_TessCoord.z) * gl_TessCoord.x) * gl_TessCoord.y), 1.0); 47 | out_var_TEXCOORD0 = ((_56_unrolled[0] * gl_TessCoord.z) + (_56_unrolled[1] * gl_TessCoord.x)) + (_56_unrolled[2] * gl_TessCoord.y); 48 | } 49 | 50 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/PNTriangles_DS.310.essl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | #extension GL_EXT_tessellation_shader : require 3 | layout(triangles) in; 4 | 5 | layout(binding = 0, std140) uniform type_cbPNTriangles 6 | { 7 | mat4 viewProj; 8 | vec4 lightDir; 9 | } cbPNTriangles; 10 | 11 | layout(location = 2) patch in vec3 in_var_POSITION3; 12 | layout(location = 3) patch in vec3 in_var_POSITION4; 13 | layout(location = 4) patch in vec3 in_var_POSITION5; 14 | layout(location = 5) patch in vec3 in_var_POSITION6; 15 | layout(location = 6) patch in vec3 in_var_POSITION7; 16 | layout(location = 7) patch in vec3 in_var_POSITION8; 17 | layout(location = 0) patch in vec3 in_var_CENTER; 18 | layout(location = 1) in vec3 in_var_POSITION[]; 19 | layout(location = 8) in vec2 in_var_TEXCOORD[]; 20 | layout(location = 0) out vec2 out_var_TEXCOORD0; 21 | 22 | void main() 23 | { 24 | vec3 _55_unrolled[3]; 25 | for (int i = 0; i < int(3); i++) 26 | { 27 | _55_unrolled[i] = in_var_POSITION[i]; 28 | } 29 | vec2 _56_unrolled[3]; 30 | for (int i = 0; i < int(3); i++) 31 | { 32 | _56_unrolled[i] = in_var_TEXCOORD[i]; 33 | } 34 | float _67 = gl_TessCoord.x * gl_TessCoord.x; 35 | float _68 = gl_TessCoord.y * gl_TessCoord.y; 36 | float _69 = gl_TessCoord.z * gl_TessCoord.z; 37 | float _70 = _67 * 3.0; 38 | float _71 = _68 * 3.0; 39 | float _72 = _69 * 3.0; 40 | gl_Position = cbPNTriangles.viewProj * vec4(((((((((((_55_unrolled[0] * _69) * gl_TessCoord.z) + ((_55_unrolled[1] * _67) * gl_TessCoord.x)) + ((_55_unrolled[2] * _68) * gl_TessCoord.y)) + ((in_var_POSITION3 * _72) * gl_TessCoord.x)) + ((in_var_POSITION4 * gl_TessCoord.z) * _70)) + ((in_var_POSITION8 * _72) * gl_TessCoord.y)) + ((in_var_POSITION5 * _70) * gl_TessCoord.y)) + ((in_var_POSITION7 * gl_TessCoord.z) * _71)) + ((in_var_POSITION6 * gl_TessCoord.x) * _71)) + ((((in_var_CENTER * 6.0) * gl_TessCoord.z) * gl_TessCoord.x) * gl_TessCoord.y), 1.0); 41 | out_var_TEXCOORD0 = ((_56_unrolled[0] * gl_TessCoord.z) + (_56_unrolled[1] * gl_TessCoord.x)) + (_56_unrolled[2] * gl_TessCoord.y); 42 | } 43 | 44 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/PNTriangles_DS.410.glsl: -------------------------------------------------------------------------------- 1 | #version 410 2 | layout(triangles) in; 3 | 4 | out gl_PerVertex 5 | { 6 | vec4 gl_Position; 7 | }; 8 | 9 | layout(std140) uniform type_cbPNTriangles 10 | { 11 | mat4 viewProj; 12 | vec4 lightDir; 13 | } cbPNTriangles; 14 | 15 | layout(location = 2) patch in vec3 in_var_POSITION3; 16 | layout(location = 3) patch in vec3 in_var_POSITION4; 17 | layout(location = 4) patch in vec3 in_var_POSITION5; 18 | layout(location = 5) patch in vec3 in_var_POSITION6; 19 | layout(location = 6) patch in vec3 in_var_POSITION7; 20 | layout(location = 7) patch in vec3 in_var_POSITION8; 21 | layout(location = 0) patch in vec3 in_var_CENTER; 22 | layout(location = 1) in vec3 in_var_POSITION[]; 23 | layout(location = 8) in vec2 in_var_TEXCOORD[]; 24 | layout(location = 0) out vec2 out_var_TEXCOORD0; 25 | 26 | void main() 27 | { 28 | vec3 _55_unrolled[3]; 29 | for (int i = 0; i < int(3); i++) 30 | { 31 | _55_unrolled[i] = in_var_POSITION[i]; 32 | } 33 | vec2 _56_unrolled[3]; 34 | for (int i = 0; i < int(3); i++) 35 | { 36 | _56_unrolled[i] = in_var_TEXCOORD[i]; 37 | } 38 | float _67 = gl_TessCoord.x * gl_TessCoord.x; 39 | float _68 = gl_TessCoord.y * gl_TessCoord.y; 40 | float _69 = gl_TessCoord.z * gl_TessCoord.z; 41 | float _70 = _67 * 3.0; 42 | float _71 = _68 * 3.0; 43 | float _72 = _69 * 3.0; 44 | gl_Position = cbPNTriangles.viewProj * vec4(((((((((((_55_unrolled[0] * _69) * gl_TessCoord.z) + ((_55_unrolled[1] * _67) * gl_TessCoord.x)) + ((_55_unrolled[2] * _68) * gl_TessCoord.y)) + ((in_var_POSITION3 * _72) * gl_TessCoord.x)) + ((in_var_POSITION4 * gl_TessCoord.z) * _70)) + ((in_var_POSITION8 * _72) * gl_TessCoord.y)) + ((in_var_POSITION5 * _70) * gl_TessCoord.y)) + ((in_var_POSITION7 * gl_TessCoord.z) * _71)) + ((in_var_POSITION6 * gl_TessCoord.x) * _71)) + ((((in_var_CENTER * 6.0) * gl_TessCoord.z) * gl_TessCoord.x) * gl_TessCoord.y), 1.0); 45 | out_var_TEXCOORD0 = ((_56_unrolled[0] * gl_TessCoord.z) + (_56_unrolled[1] * gl_TessCoord.x)) + (_56_unrolled[2] * gl_TessCoord.y); 46 | } 47 | 48 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/PNTriangles_DS.msl: -------------------------------------------------------------------------------- 1 | #pragma clang diagnostic ignored "-Wmissing-prototypes" 2 | #pragma clang diagnostic ignored "-Wmissing-braces" 3 | 4 | #include 5 | #include 6 | 7 | using namespace metal; 8 | 9 | template 10 | struct spvUnsafeArray 11 | { 12 | T elements[Num ? Num : 1]; 13 | 14 | thread T& operator [] (size_t pos) thread 15 | { 16 | return elements[pos]; 17 | } 18 | constexpr const thread T& operator [] (size_t pos) const thread 19 | { 20 | return elements[pos]; 21 | } 22 | 23 | device T& operator [] (size_t pos) device 24 | { 25 | return elements[pos]; 26 | } 27 | constexpr const device T& operator [] (size_t pos) const device 28 | { 29 | return elements[pos]; 30 | } 31 | 32 | constexpr const constant T& operator [] (size_t pos) const constant 33 | { 34 | return elements[pos]; 35 | } 36 | 37 | threadgroup T& operator [] (size_t pos) threadgroup 38 | { 39 | return elements[pos]; 40 | } 41 | constexpr const threadgroup T& operator [] (size_t pos) const threadgroup 42 | { 43 | return elements[pos]; 44 | } 45 | }; 46 | 47 | struct type_cbPNTriangles 48 | { 49 | float4x4 viewProj; 50 | float4 lightDir; 51 | }; 52 | 53 | struct main0_out 54 | { 55 | float2 out_var_TEXCOORD0 [[user(locn0)]]; 56 | float4 gl_Position [[position]]; 57 | }; 58 | 59 | struct main0_in 60 | { 61 | float3 in_var_POSITION [[attribute(1)]]; 62 | float2 in_var_TEXCOORD [[attribute(8)]]; 63 | }; 64 | 65 | struct main0_patchIn 66 | { 67 | float3 in_var_CENTER [[attribute(0)]]; 68 | float3 in_var_POSITION3 [[attribute(2)]]; 69 | float3 in_var_POSITION4 [[attribute(3)]]; 70 | float3 in_var_POSITION5 [[attribute(4)]]; 71 | float3 in_var_POSITION6 [[attribute(5)]]; 72 | float3 in_var_POSITION7 [[attribute(6)]]; 73 | float3 in_var_POSITION8 [[attribute(7)]]; 74 | patch_control_point gl_in; 75 | }; 76 | 77 | [[ patch(triangle, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]], constant type_cbPNTriangles& cbPNTriangles [[buffer(0)]], float3 gl_TessCoord [[position_in_patch]]) 78 | { 79 | main0_out out = {}; 80 | spvUnsafeArray _55 = spvUnsafeArray({ patchIn.gl_in[0].in_var_POSITION, patchIn.gl_in[1].in_var_POSITION, patchIn.gl_in[2].in_var_POSITION }); 81 | spvUnsafeArray _56 = spvUnsafeArray({ patchIn.gl_in[0].in_var_TEXCOORD, patchIn.gl_in[1].in_var_TEXCOORD, patchIn.gl_in[2].in_var_TEXCOORD }); 82 | float _67 = gl_TessCoord.x * gl_TessCoord.x; 83 | float _68 = gl_TessCoord.y * gl_TessCoord.y; 84 | float _69 = gl_TessCoord.z * gl_TessCoord.z; 85 | float _70 = _67 * 3.0; 86 | float _71 = _68 * 3.0; 87 | float _72 = _69 * 3.0; 88 | out.gl_Position = cbPNTriangles.viewProj * float4(((((((((((_55[0] * _69) * gl_TessCoord.z) + ((_55[1] * _67) * gl_TessCoord.x)) + ((_55[2] * _68) * gl_TessCoord.y)) + ((patchIn.in_var_POSITION3 * _72) * gl_TessCoord.x)) + ((patchIn.in_var_POSITION4 * gl_TessCoord.z) * _70)) + ((patchIn.in_var_POSITION8 * _72) * gl_TessCoord.y)) + ((patchIn.in_var_POSITION5 * _70) * gl_TessCoord.y)) + ((patchIn.in_var_POSITION7 * gl_TessCoord.z) * _71)) + ((patchIn.in_var_POSITION6 * gl_TessCoord.x) * _71)) + ((((patchIn.in_var_CENTER * 6.0) * gl_TessCoord.z) * gl_TessCoord.x) * gl_TessCoord.y), 1.0); 89 | out.out_var_TEXCOORD0 = ((_56[0] * gl_TessCoord.z) + (_56[1] * gl_TessCoord.x)) + (_56[2] * gl_TessCoord.y); 90 | return out; 91 | } 92 | 93 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Particle_GS.300.essl: -------------------------------------------------------------------------------- 1 | #version 300 es 2 | #extension GL_EXT_geometry_shader : require 3 | layout(points) in; 4 | layout(max_vertices = 4, triangle_strip) out; 5 | 6 | layout(std140) uniform type_cbMain 7 | { 8 | mat4 invView; 9 | mat4 viewProj; 10 | } cbMain; 11 | 12 | in vec4 in_var_POSITION[1]; 13 | out vec2 out_var_TEXCOORD0; 14 | 15 | void main() 16 | { 17 | mat3 _49 = mat3(cbMain.invView[0].xyz, cbMain.invView[1].xyz, cbMain.invView[2].xyz); 18 | gl_Position = cbMain.viewProj * vec4((_49 * vec3(-5.0, 5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0); 19 | out_var_TEXCOORD0 = vec2(0.0, 1.0); 20 | EmitVertex(); 21 | gl_Position = cbMain.viewProj * vec4((_49 * vec3(5.0, 5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0); 22 | out_var_TEXCOORD0 = vec2(1.0); 23 | EmitVertex(); 24 | gl_Position = cbMain.viewProj * vec4((_49 * vec3(-5.0, -5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0); 25 | out_var_TEXCOORD0 = vec2(0.0); 26 | EmitVertex(); 27 | gl_Position = cbMain.viewProj * vec4((_49 * vec3(5.0, -5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0); 28 | out_var_TEXCOORD0 = vec2(1.0, 0.0); 29 | EmitVertex(); 30 | EndPrimitive(); 31 | } 32 | 33 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Particle_GS.300.glsl: -------------------------------------------------------------------------------- 1 | #version 300 2 | #extension GL_ARB_separate_shader_objects : require 3 | layout(points) in; 4 | layout(max_vertices = 4, triangle_strip) out; 5 | 6 | out gl_PerVertex 7 | { 8 | vec4 gl_Position; 9 | }; 10 | 11 | layout(std140) uniform type_cbMain 12 | { 13 | mat4 invView; 14 | mat4 viewProj; 15 | } cbMain; 16 | 17 | layout(location = 0) in vec4 in_var_POSITION[1]; 18 | layout(location = 0) out vec2 out_var_TEXCOORD0; 19 | 20 | void main() 21 | { 22 | mat3 _49 = mat3(cbMain.invView[0].xyz, cbMain.invView[1].xyz, cbMain.invView[2].xyz); 23 | gl_Position = cbMain.viewProj * vec4((_49 * vec3(-5.0, 5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0); 24 | out_var_TEXCOORD0 = vec2(0.0, 1.0); 25 | EmitVertex(); 26 | gl_Position = cbMain.viewProj * vec4((_49 * vec3(5.0, 5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0); 27 | out_var_TEXCOORD0 = vec2(1.0); 28 | EmitVertex(); 29 | gl_Position = cbMain.viewProj * vec4((_49 * vec3(-5.0, -5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0); 30 | out_var_TEXCOORD0 = vec2(0.0); 31 | EmitVertex(); 32 | gl_Position = cbMain.viewProj * vec4((_49 * vec3(5.0, -5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0); 33 | out_var_TEXCOORD0 = vec2(1.0, 0.0); 34 | EmitVertex(); 35 | EndPrimitive(); 36 | } 37 | 38 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Particle_GS.310.essl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | #extension GL_EXT_geometry_shader : require 3 | layout(points) in; 4 | layout(max_vertices = 4, triangle_strip) out; 5 | 6 | layout(binding = 0, std140) uniform type_cbMain 7 | { 8 | mat4 invView; 9 | mat4 viewProj; 10 | } cbMain; 11 | 12 | layout(location = 0) in vec4 in_var_POSITION[1]; 13 | layout(location = 0) out vec2 out_var_TEXCOORD0; 14 | 15 | void main() 16 | { 17 | mat3 _49 = mat3(cbMain.invView[0].xyz, cbMain.invView[1].xyz, cbMain.invView[2].xyz); 18 | gl_Position = cbMain.viewProj * vec4((_49 * vec3(-5.0, 5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0); 19 | out_var_TEXCOORD0 = vec2(0.0, 1.0); 20 | EmitVertex(); 21 | gl_Position = cbMain.viewProj * vec4((_49 * vec3(5.0, 5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0); 22 | out_var_TEXCOORD0 = vec2(1.0); 23 | EmitVertex(); 24 | gl_Position = cbMain.viewProj * vec4((_49 * vec3(-5.0, -5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0); 25 | out_var_TEXCOORD0 = vec2(0.0); 26 | EmitVertex(); 27 | gl_Position = cbMain.viewProj * vec4((_49 * vec3(5.0, -5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0); 28 | out_var_TEXCOORD0 = vec2(1.0, 0.0); 29 | EmitVertex(); 30 | EndPrimitive(); 31 | } 32 | 33 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Particle_GS.410.glsl: -------------------------------------------------------------------------------- 1 | #version 410 2 | layout(points) in; 3 | layout(max_vertices = 4, triangle_strip) out; 4 | 5 | out gl_PerVertex 6 | { 7 | vec4 gl_Position; 8 | }; 9 | 10 | layout(std140) uniform type_cbMain 11 | { 12 | mat4 invView; 13 | mat4 viewProj; 14 | } cbMain; 15 | 16 | layout(location = 0) in vec4 in_var_POSITION[1]; 17 | layout(location = 0) out vec2 out_var_TEXCOORD0; 18 | 19 | void main() 20 | { 21 | mat3 _49 = mat3(cbMain.invView[0].xyz, cbMain.invView[1].xyz, cbMain.invView[2].xyz); 22 | gl_Position = cbMain.viewProj * vec4((_49 * vec3(-5.0, 5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0); 23 | out_var_TEXCOORD0 = vec2(0.0, 1.0); 24 | EmitVertex(); 25 | gl_Position = cbMain.viewProj * vec4((_49 * vec3(5.0, 5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0); 26 | out_var_TEXCOORD0 = vec2(1.0); 27 | EmitVertex(); 28 | gl_Position = cbMain.viewProj * vec4((_49 * vec3(-5.0, -5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0); 29 | out_var_TEXCOORD0 = vec2(0.0); 30 | EmitVertex(); 31 | gl_Position = cbMain.viewProj * vec4((_49 * vec3(5.0, -5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0); 32 | out_var_TEXCOORD0 = vec2(1.0, 0.0); 33 | EmitVertex(); 34 | EndPrimitive(); 35 | } 36 | 37 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/PassThrough_PS.30.hlsl: -------------------------------------------------------------------------------- 1 | static float4 in_var_COLOR; 2 | static float4 out_var_SV_Target; 3 | 4 | struct SPIRV_Cross_Input 5 | { 6 | float4 in_var_COLOR : TEXCOORD0; 7 | }; 8 | 9 | struct SPIRV_Cross_Output 10 | { 11 | float4 out_var_SV_Target : COLOR0; 12 | }; 13 | 14 | void frag_main() 15 | { 16 | out_var_SV_Target = in_var_COLOR; 17 | } 18 | 19 | SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) 20 | { 21 | in_var_COLOR = stage_input.in_var_COLOR; 22 | frag_main(); 23 | SPIRV_Cross_Output stage_output; 24 | stage_output.out_var_SV_Target = float4(out_var_SV_Target); 25 | return stage_output; 26 | } 27 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/PassThrough_PS.300.essl: -------------------------------------------------------------------------------- 1 | #version 300 es 2 | precision mediump float; 3 | precision highp int; 4 | 5 | in highp vec4 varying_COLOR; 6 | layout(location = 0) out highp vec4 out_var_SV_Target; 7 | 8 | void main() 9 | { 10 | out_var_SV_Target = varying_COLOR; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/PassThrough_PS.300.glsl: -------------------------------------------------------------------------------- 1 | #version 300 2 | #extension GL_ARB_separate_shader_objects : require 3 | 4 | layout(location = 0) in vec4 varying_COLOR; 5 | out vec4 out_var_SV_Target; 6 | 7 | void main() 8 | { 9 | out_var_SV_Target = varying_COLOR; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/PassThrough_PS.310.essl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | precision mediump float; 3 | precision highp int; 4 | 5 | layout(location = 0) in highp vec4 in_var_COLOR; 6 | layout(location = 0) out highp vec4 out_var_SV_Target; 7 | 8 | void main() 9 | { 10 | out_var_SV_Target = in_var_COLOR; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/PassThrough_PS.40.hlsl: -------------------------------------------------------------------------------- 1 | static float4 in_var_COLOR; 2 | static float4 out_var_SV_Target; 3 | 4 | struct SPIRV_Cross_Input 5 | { 6 | float4 in_var_COLOR : TEXCOORD0; 7 | }; 8 | 9 | struct SPIRV_Cross_Output 10 | { 11 | float4 out_var_SV_Target : SV_Target0; 12 | }; 13 | 14 | void frag_main() 15 | { 16 | out_var_SV_Target = in_var_COLOR; 17 | } 18 | 19 | SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) 20 | { 21 | in_var_COLOR = stage_input.in_var_COLOR; 22 | frag_main(); 23 | SPIRV_Cross_Output stage_output; 24 | stage_output.out_var_SV_Target = out_var_SV_Target; 25 | return stage_output; 26 | } 27 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/PassThrough_PS.410.glsl: -------------------------------------------------------------------------------- 1 | #version 410 2 | 3 | layout(location = 0) in vec4 in_var_COLOR; 4 | layout(location = 0) out vec4 out_var_SV_Target; 5 | 6 | void main() 7 | { 8 | out_var_SV_Target = in_var_COLOR; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/PassThrough_PS.50.hlsl: -------------------------------------------------------------------------------- 1 | static float4 in_var_COLOR; 2 | static float4 out_var_SV_Target; 3 | 4 | struct SPIRV_Cross_Input 5 | { 6 | float4 in_var_COLOR : TEXCOORD0; 7 | }; 8 | 9 | struct SPIRV_Cross_Output 10 | { 11 | float4 out_var_SV_Target : SV_Target0; 12 | }; 13 | 14 | void frag_main() 15 | { 16 | out_var_SV_Target = in_var_COLOR; 17 | } 18 | 19 | SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) 20 | { 21 | in_var_COLOR = stage_input.in_var_COLOR; 22 | frag_main(); 23 | SPIRV_Cross_Output stage_output; 24 | stage_output.out_var_SV_Target = out_var_SV_Target; 25 | return stage_output; 26 | } 27 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/PassThrough_PS.msl: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace metal; 5 | 6 | struct PSMain_out 7 | { 8 | float4 out_var_SV_Target [[color(0)]]; 9 | }; 10 | 11 | struct PSMain_in 12 | { 13 | float4 in_var_COLOR [[user(locn0)]]; 14 | }; 15 | 16 | fragment PSMain_out PSMain(PSMain_in in [[stage_in]]) 17 | { 18 | PSMain_out out = {}; 19 | out.out_var_SV_Target = in.in_var_COLOR; 20 | return out; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/PassThrough_VS.30.hlsl: -------------------------------------------------------------------------------- 1 | uniform float4 gl_HalfPixel; 2 | 3 | static float4 gl_Position; 4 | static float4 in_var_POSITION; 5 | static float2 in_var_TEXCOORD0; 6 | static float2 out_var_TEXCOORD0; 7 | 8 | struct SPIRV_Cross_Input 9 | { 10 | float4 in_var_POSITION : TEXCOORD0; 11 | float2 in_var_TEXCOORD0 : TEXCOORD1; 12 | }; 13 | 14 | struct SPIRV_Cross_Output 15 | { 16 | float2 out_var_TEXCOORD0 : TEXCOORD0; 17 | float4 gl_Position : POSITION; 18 | }; 19 | 20 | void vert_main() 21 | { 22 | out_var_TEXCOORD0 = in_var_TEXCOORD0; 23 | gl_Position = in_var_POSITION; 24 | gl_Position.x = gl_Position.x - gl_HalfPixel.x * gl_Position.w; 25 | gl_Position.y = gl_Position.y + gl_HalfPixel.y * gl_Position.w; 26 | } 27 | 28 | SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) 29 | { 30 | in_var_POSITION = stage_input.in_var_POSITION; 31 | in_var_TEXCOORD0 = stage_input.in_var_TEXCOORD0; 32 | vert_main(); 33 | SPIRV_Cross_Output stage_output; 34 | stage_output.gl_Position = gl_Position; 35 | stage_output.out_var_TEXCOORD0 = out_var_TEXCOORD0; 36 | return stage_output; 37 | } 38 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/PassThrough_VS.300.essl: -------------------------------------------------------------------------------- 1 | #version 300 es 2 | 3 | layout(location = 0) in vec4 in_var_POSITION; 4 | layout(location = 1) in vec2 in_var_TEXCOORD0; 5 | out vec2 varying_TEXCOORD0; 6 | 7 | void main() 8 | { 9 | varying_TEXCOORD0 = in_var_TEXCOORD0; 10 | gl_Position = in_var_POSITION; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/PassThrough_VS.300.glsl: -------------------------------------------------------------------------------- 1 | #version 300 2 | #extension GL_ARB_separate_shader_objects : require 3 | 4 | out gl_PerVertex 5 | { 6 | vec4 gl_Position; 7 | }; 8 | 9 | in vec4 in_var_POSITION; 10 | in vec2 in_var_TEXCOORD0; 11 | layout(location = 0) out vec2 varying_TEXCOORD0; 12 | 13 | void main() 14 | { 15 | varying_TEXCOORD0 = in_var_TEXCOORD0; 16 | gl_Position = in_var_POSITION; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/PassThrough_VS.310.essl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | 3 | layout(location = 0) in vec4 in_var_POSITION; 4 | layout(location = 1) in vec2 in_var_TEXCOORD0; 5 | layout(location = 0) out vec2 out_var_TEXCOORD0; 6 | 7 | void main() 8 | { 9 | out_var_TEXCOORD0 = in_var_TEXCOORD0; 10 | gl_Position = in_var_POSITION; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/PassThrough_VS.40.hlsl: -------------------------------------------------------------------------------- 1 | static float4 gl_Position; 2 | static float4 in_var_POSITION; 3 | static float2 in_var_TEXCOORD0; 4 | static float2 out_var_TEXCOORD0; 5 | 6 | struct SPIRV_Cross_Input 7 | { 8 | float4 in_var_POSITION : TEXCOORD0; 9 | float2 in_var_TEXCOORD0 : TEXCOORD1; 10 | }; 11 | 12 | struct SPIRV_Cross_Output 13 | { 14 | float2 out_var_TEXCOORD0 : TEXCOORD0; 15 | float4 gl_Position : SV_Position; 16 | }; 17 | 18 | void vert_main() 19 | { 20 | out_var_TEXCOORD0 = in_var_TEXCOORD0; 21 | gl_Position = in_var_POSITION; 22 | } 23 | 24 | SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) 25 | { 26 | in_var_POSITION = stage_input.in_var_POSITION; 27 | in_var_TEXCOORD0 = stage_input.in_var_TEXCOORD0; 28 | vert_main(); 29 | SPIRV_Cross_Output stage_output; 30 | stage_output.gl_Position = gl_Position; 31 | stage_output.out_var_TEXCOORD0 = out_var_TEXCOORD0; 32 | return stage_output; 33 | } 34 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/PassThrough_VS.410.glsl: -------------------------------------------------------------------------------- 1 | #version 410 2 | 3 | out gl_PerVertex 4 | { 5 | vec4 gl_Position; 6 | }; 7 | 8 | layout(location = 0) in vec4 in_var_POSITION; 9 | layout(location = 1) in vec2 in_var_TEXCOORD0; 10 | layout(location = 0) out vec2 out_var_TEXCOORD0; 11 | 12 | void main() 13 | { 14 | out_var_TEXCOORD0 = in_var_TEXCOORD0; 15 | gl_Position = in_var_POSITION; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/PassThrough_VS.50.hlsl: -------------------------------------------------------------------------------- 1 | static float4 gl_Position; 2 | static float4 in_var_POSITION; 3 | static float2 in_var_TEXCOORD0; 4 | static float2 out_var_TEXCOORD0; 5 | 6 | struct SPIRV_Cross_Input 7 | { 8 | float4 in_var_POSITION : TEXCOORD0; 9 | float2 in_var_TEXCOORD0 : TEXCOORD1; 10 | }; 11 | 12 | struct SPIRV_Cross_Output 13 | { 14 | float2 out_var_TEXCOORD0 : TEXCOORD0; 15 | float4 gl_Position : SV_Position; 16 | }; 17 | 18 | void vert_main() 19 | { 20 | out_var_TEXCOORD0 = in_var_TEXCOORD0; 21 | gl_Position = in_var_POSITION; 22 | } 23 | 24 | SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) 25 | { 26 | in_var_POSITION = stage_input.in_var_POSITION; 27 | in_var_TEXCOORD0 = stage_input.in_var_TEXCOORD0; 28 | vert_main(); 29 | SPIRV_Cross_Output stage_output; 30 | stage_output.gl_Position = gl_Position; 31 | stage_output.out_var_TEXCOORD0 = out_var_TEXCOORD0; 32 | return stage_output; 33 | } 34 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/PassThrough_VS.msl: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace metal; 5 | 6 | struct VSMain_out 7 | { 8 | float2 out_var_TEXCOORD0 [[user(locn0)]]; 9 | float4 gl_Position [[position]]; 10 | }; 11 | 12 | struct VSMain_in 13 | { 14 | float4 in_var_POSITION [[attribute(0)]]; 15 | float2 in_var_TEXCOORD0 [[attribute(1)]]; 16 | }; 17 | 18 | vertex VSMain_out VSMain(VSMain_in in [[stage_in]]) 19 | { 20 | VSMain_out out = {}; 21 | out.out_var_TEXCOORD0 = in.in_var_TEXCOORD0; 22 | out.gl_Position = in.in_var_POSITION; 23 | return out; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/ToneMapping_PS.30.hlsl: -------------------------------------------------------------------------------- 1 | cbuffer type_cbPS : register(b0) 2 | { 3 | float cbPS_lumStrength : packoffset(c0); 4 | }; 5 | 6 | uniform sampler2D SPIRV_Cross_CombinedcolorTexpointSampler; 7 | uniform sampler2D SPIRV_Cross_CombinedbloomTexlinearSampler; 8 | uniform sampler2D SPIRV_Cross_CombinedlumTexpointSampler; 9 | 10 | static float2 in_var_TEXCOORD0; 11 | static float4 out_var_SV_Target; 12 | 13 | struct SPIRV_Cross_Input 14 | { 15 | float2 in_var_TEXCOORD0 : TEXCOORD0; 16 | }; 17 | 18 | struct SPIRV_Cross_Output 19 | { 20 | float4 out_var_SV_Target : COLOR0; 21 | }; 22 | 23 | void frag_main() 24 | { 25 | float4 _45 = tex2D(SPIRV_Cross_CombinedcolorTexpointSampler, in_var_TEXCOORD0); 26 | float3 _62 = (_45.xyz * (0.7200000286102294921875f / ((tex2D(SPIRV_Cross_CombinedlumTexpointSampler, 0.5f.xx).x * cbPS_lumStrength) + 0.001000000047497451305389404296875f))).xyz; 27 | float3 _66 = (_62 * (1.0f.xxx + (_62 * 0.666666686534881591796875f.xxx))).xyz; 28 | float3 _71 = (_66 / (1.0f.xxx + _66)).xyz + (tex2D(SPIRV_Cross_CombinedbloomTexlinearSampler, in_var_TEXCOORD0).xyz * 0.60000002384185791015625f); 29 | float4 _73 = float4(_71.x, _71.y, _71.z, _45.w); 30 | _73.w = 1.0f; 31 | out_var_SV_Target = _73; 32 | } 33 | 34 | SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) 35 | { 36 | in_var_TEXCOORD0 = stage_input.in_var_TEXCOORD0; 37 | frag_main(); 38 | SPIRV_Cross_Output stage_output; 39 | stage_output.out_var_SV_Target = float4(out_var_SV_Target); 40 | return stage_output; 41 | } 42 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/ToneMapping_PS.300.essl: -------------------------------------------------------------------------------- 1 | #version 300 es 2 | precision mediump float; 3 | precision highp int; 4 | 5 | layout(std140) uniform type_cbPS 6 | { 7 | highp float lumStrength; 8 | } cbPS; 9 | 10 | uniform highp sampler2D SPIRV_Cross_CombinedcolorTexpointSampler; 11 | uniform highp sampler2D SPIRV_Cross_CombinedbloomTexlinearSampler; 12 | uniform highp sampler2D SPIRV_Cross_CombinedlumTexpointSampler; 13 | 14 | in highp vec2 varying_TEXCOORD0; 15 | layout(location = 0) out highp vec4 out_var_SV_Target; 16 | 17 | void main() 18 | { 19 | highp vec4 _45 = texture(SPIRV_Cross_CombinedcolorTexpointSampler, varying_TEXCOORD0); 20 | highp vec3 _62 = (_45.xyz * (0.7200000286102294921875 / ((texture(SPIRV_Cross_CombinedlumTexpointSampler, vec2(0.5)).x * cbPS.lumStrength) + 0.001000000047497451305389404296875))).xyz; 21 | highp vec3 _66 = (_62 * (vec3(1.0) + (_62 * vec3(0.666666686534881591796875)))).xyz; 22 | highp vec3 _71 = (_66 / (vec3(1.0) + _66)).xyz + (texture(SPIRV_Cross_CombinedbloomTexlinearSampler, varying_TEXCOORD0).xyz * 0.60000002384185791015625); 23 | highp vec4 _73 = vec4(_71.x, _71.y, _71.z, _45.w); 24 | _73.w = 1.0; 25 | out_var_SV_Target = _73; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/ToneMapping_PS.300.glsl: -------------------------------------------------------------------------------- 1 | #version 300 2 | #extension GL_ARB_separate_shader_objects : require 3 | 4 | layout(std140) uniform type_cbPS 5 | { 6 | float lumStrength; 7 | } cbPS; 8 | 9 | uniform sampler2D SPIRV_Cross_CombinedcolorTexpointSampler; 10 | uniform sampler2D SPIRV_Cross_CombinedbloomTexlinearSampler; 11 | uniform sampler2D SPIRV_Cross_CombinedlumTexpointSampler; 12 | 13 | layout(location = 0) in vec2 varying_TEXCOORD0; 14 | out vec4 out_var_SV_Target; 15 | 16 | void main() 17 | { 18 | vec4 _45 = texture(SPIRV_Cross_CombinedcolorTexpointSampler, varying_TEXCOORD0); 19 | vec3 _62 = (_45.xyz * (0.7200000286102294921875 / ((texture(SPIRV_Cross_CombinedlumTexpointSampler, vec2(0.5)).x * cbPS.lumStrength) + 0.001000000047497451305389404296875))).xyz; 20 | vec3 _66 = (_62 * (vec3(1.0) + (_62 * vec3(0.666666686534881591796875)))).xyz; 21 | vec3 _71 = (_66 / (vec3(1.0) + _66)).xyz + (texture(SPIRV_Cross_CombinedbloomTexlinearSampler, varying_TEXCOORD0).xyz * 0.60000002384185791015625); 22 | vec4 _73 = vec4(_71.x, _71.y, _71.z, _45.w); 23 | _73.w = 1.0; 24 | out_var_SV_Target = _73; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/ToneMapping_PS.310.essl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | precision mediump float; 3 | precision highp int; 4 | 5 | layout(binding = 0, std140) uniform type_cbPS 6 | { 7 | highp float lumStrength; 8 | } cbPS; 9 | 10 | uniform highp sampler2D SPIRV_Cross_CombinedcolorTexpointSampler; 11 | uniform highp sampler2D SPIRV_Cross_CombinedbloomTexlinearSampler; 12 | uniform highp sampler2D SPIRV_Cross_CombinedlumTexpointSampler; 13 | 14 | layout(location = 0) in highp vec2 in_var_TEXCOORD0; 15 | layout(location = 0) out highp vec4 out_var_SV_Target; 16 | 17 | void main() 18 | { 19 | highp vec4 _45 = texture(SPIRV_Cross_CombinedcolorTexpointSampler, in_var_TEXCOORD0); 20 | highp vec3 _62 = (_45.xyz * (0.7200000286102294921875 / ((texture(SPIRV_Cross_CombinedlumTexpointSampler, vec2(0.5)).x * cbPS.lumStrength) + 0.001000000047497451305389404296875))).xyz; 21 | highp vec3 _66 = (_62 * (vec3(1.0) + (_62 * vec3(0.666666686534881591796875)))).xyz; 22 | highp vec3 _71 = (_66 / (vec3(1.0) + _66)).xyz + (texture(SPIRV_Cross_CombinedbloomTexlinearSampler, in_var_TEXCOORD0).xyz * 0.60000002384185791015625); 23 | highp vec4 _73 = vec4(_71.x, _71.y, _71.z, _45.w); 24 | _73.w = 1.0; 25 | out_var_SV_Target = _73; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/ToneMapping_PS.40.hlsl: -------------------------------------------------------------------------------- 1 | cbuffer type_cbPS : register(b0) 2 | { 3 | float cbPS_lumStrength : packoffset(c0); 4 | }; 5 | 6 | SamplerState pointSampler : register(s0); 7 | SamplerState linearSampler : register(s1); 8 | Texture2D colorTex : register(t0); 9 | Texture2D lumTex : register(t1); 10 | Texture2D bloomTex : register(t2); 11 | 12 | static float2 in_var_TEXCOORD0; 13 | static float4 out_var_SV_Target; 14 | 15 | struct SPIRV_Cross_Input 16 | { 17 | float2 in_var_TEXCOORD0 : TEXCOORD0; 18 | }; 19 | 20 | struct SPIRV_Cross_Output 21 | { 22 | float4 out_var_SV_Target : SV_Target0; 23 | }; 24 | 25 | void frag_main() 26 | { 27 | float4 _45 = colorTex.Sample(pointSampler, in_var_TEXCOORD0); 28 | float3 _62 = (_45.xyz * (0.7200000286102294921875f / ((lumTex.Sample(pointSampler, 0.5f.xx).x * cbPS_lumStrength) + 0.001000000047497451305389404296875f))).xyz; 29 | float3 _66 = (_62 * (1.0f.xxx + (_62 * 0.666666686534881591796875f.xxx))).xyz; 30 | float3 _71 = (_66 / (1.0f.xxx + _66)).xyz + (bloomTex.Sample(linearSampler, in_var_TEXCOORD0).xyz * 0.60000002384185791015625f); 31 | float4 _73 = float4(_71.x, _71.y, _71.z, _45.w); 32 | _73.w = 1.0f; 33 | out_var_SV_Target = _73; 34 | } 35 | 36 | SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) 37 | { 38 | in_var_TEXCOORD0 = stage_input.in_var_TEXCOORD0; 39 | frag_main(); 40 | SPIRV_Cross_Output stage_output; 41 | stage_output.out_var_SV_Target = out_var_SV_Target; 42 | return stage_output; 43 | } 44 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/ToneMapping_PS.410.glsl: -------------------------------------------------------------------------------- 1 | #version 410 2 | 3 | layout(std140) uniform type_cbPS 4 | { 5 | float lumStrength; 6 | } cbPS; 7 | 8 | uniform sampler2D SPIRV_Cross_CombinedcolorTexpointSampler; 9 | uniform sampler2D SPIRV_Cross_CombinedbloomTexlinearSampler; 10 | uniform sampler2D SPIRV_Cross_CombinedlumTexpointSampler; 11 | 12 | layout(location = 0) in vec2 in_var_TEXCOORD0; 13 | layout(location = 0) out vec4 out_var_SV_Target; 14 | 15 | void main() 16 | { 17 | vec4 _45 = texture(SPIRV_Cross_CombinedcolorTexpointSampler, in_var_TEXCOORD0); 18 | vec3 _62 = (_45.xyz * (0.7200000286102294921875 / ((texture(SPIRV_Cross_CombinedlumTexpointSampler, vec2(0.5)).x * cbPS.lumStrength) + 0.001000000047497451305389404296875))).xyz; 19 | vec3 _66 = (_62 * (vec3(1.0) + (_62 * vec3(0.666666686534881591796875)))).xyz; 20 | vec3 _71 = (_66 / (vec3(1.0) + _66)).xyz + (texture(SPIRV_Cross_CombinedbloomTexlinearSampler, in_var_TEXCOORD0).xyz * 0.60000002384185791015625); 21 | vec4 _73 = vec4(_71.x, _71.y, _71.z, _45.w); 22 | _73.w = 1.0; 23 | out_var_SV_Target = _73; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/ToneMapping_PS.50.hlsl: -------------------------------------------------------------------------------- 1 | cbuffer type_cbPS : register(b0) 2 | { 3 | float cbPS_lumStrength : packoffset(c0); 4 | }; 5 | 6 | SamplerState pointSampler : register(s0); 7 | SamplerState linearSampler : register(s1); 8 | Texture2D colorTex : register(t0); 9 | Texture2D lumTex : register(t1); 10 | Texture2D bloomTex : register(t2); 11 | 12 | static float2 in_var_TEXCOORD0; 13 | static float4 out_var_SV_Target; 14 | 15 | struct SPIRV_Cross_Input 16 | { 17 | float2 in_var_TEXCOORD0 : TEXCOORD0; 18 | }; 19 | 20 | struct SPIRV_Cross_Output 21 | { 22 | float4 out_var_SV_Target : SV_Target0; 23 | }; 24 | 25 | void frag_main() 26 | { 27 | float4 _45 = colorTex.Sample(pointSampler, in_var_TEXCOORD0); 28 | float3 _62 = (_45.xyz * (0.7200000286102294921875f / ((lumTex.Sample(pointSampler, 0.5f.xx).x * cbPS_lumStrength) + 0.001000000047497451305389404296875f))).xyz; 29 | float3 _66 = (_62 * (1.0f.xxx + (_62 * 0.666666686534881591796875f.xxx))).xyz; 30 | float3 _71 = (_66 / (1.0f.xxx + _66)).xyz + (bloomTex.Sample(linearSampler, in_var_TEXCOORD0).xyz * 0.60000002384185791015625f); 31 | float4 _73 = float4(_71.x, _71.y, _71.z, _45.w); 32 | _73.w = 1.0f; 33 | out_var_SV_Target = _73; 34 | } 35 | 36 | SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) 37 | { 38 | in_var_TEXCOORD0 = stage_input.in_var_TEXCOORD0; 39 | frag_main(); 40 | SPIRV_Cross_Output stage_output; 41 | stage_output.out_var_SV_Target = out_var_SV_Target; 42 | return stage_output; 43 | } 44 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/ToneMapping_PS.msl: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace metal; 5 | 6 | struct type_cbPS 7 | { 8 | float lumStrength; 9 | }; 10 | 11 | struct main0_out 12 | { 13 | float4 out_var_SV_Target [[color(0)]]; 14 | }; 15 | 16 | struct main0_in 17 | { 18 | float2 in_var_TEXCOORD0 [[user(locn0)]]; 19 | }; 20 | 21 | fragment main0_out main0(main0_in in [[stage_in]], constant type_cbPS& cbPS [[buffer(0)]], texture2d colorTex [[texture(0)]], texture2d lumTex [[texture(1)]], texture2d bloomTex [[texture(2)]], sampler pointSampler [[sampler(0)]], sampler linearSampler [[sampler(1)]]) 22 | { 23 | main0_out out = {}; 24 | float4 _45 = colorTex.sample(pointSampler, in.in_var_TEXCOORD0); 25 | float3 _62 = (_45.xyz * (0.7200000286102294921875 / ((lumTex.sample(pointSampler, float2(0.5)).x * cbPS.lumStrength) + 0.001000000047497451305389404296875))).xyz; 26 | float3 _66 = (_62 * (float3(1.0) + (_62 * float3(0.666666686534881591796875)))).xyz; 27 | float3 _71 = (_66 / (float3(1.0) + _66)).xyz + (bloomTex.sample(linearSampler, in.in_var_TEXCOORD0).xyz * 0.60000002384185791015625); 28 | float4 _73 = float4(_71.x, _71.y, _71.z, _45.w); 29 | _73.w = 1.0; 30 | out.out_var_SV_Target = _73; 31 | return out; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Transform_VS.30.hlsl: -------------------------------------------------------------------------------- 1 | cbuffer type_cbVS : register(b0) 2 | { 3 | row_major float4x4 cbVS_wvp : packoffset(c0); 4 | }; 5 | 6 | uniform float4 gl_HalfPixel; 7 | 8 | static float4 gl_Position; 9 | static float4 in_var_POSITION; 10 | 11 | struct SPIRV_Cross_Input 12 | { 13 | float4 in_var_POSITION : TEXCOORD0; 14 | }; 15 | 16 | struct SPIRV_Cross_Output 17 | { 18 | float4 gl_Position : POSITION; 19 | }; 20 | 21 | void vert_main() 22 | { 23 | gl_Position = mul(in_var_POSITION, cbVS_wvp); 24 | gl_Position.x = gl_Position.x - gl_HalfPixel.x * gl_Position.w; 25 | gl_Position.y = gl_Position.y + gl_HalfPixel.y * gl_Position.w; 26 | } 27 | 28 | SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) 29 | { 30 | in_var_POSITION = stage_input.in_var_POSITION; 31 | vert_main(); 32 | SPIRV_Cross_Output stage_output; 33 | stage_output.gl_Position = gl_Position; 34 | return stage_output; 35 | } 36 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Transform_VS.300.essl: -------------------------------------------------------------------------------- 1 | #version 300 es 2 | 3 | layout(std140) uniform type_cbVS 4 | { 5 | mat4 wvp; 6 | } cbVS; 7 | 8 | layout(location = 0) in vec4 in_var_POSITION; 9 | 10 | void main() 11 | { 12 | gl_Position = cbVS.wvp * in_var_POSITION; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Transform_VS.300.glsl: -------------------------------------------------------------------------------- 1 | #version 300 2 | #extension GL_ARB_separate_shader_objects : require 3 | 4 | out gl_PerVertex 5 | { 6 | vec4 gl_Position; 7 | }; 8 | 9 | layout(std140) uniform type_cbVS 10 | { 11 | mat4 wvp; 12 | } cbVS; 13 | 14 | in vec4 in_var_POSITION; 15 | 16 | void main() 17 | { 18 | gl_Position = cbVS.wvp * in_var_POSITION; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Transform_VS.310.essl: -------------------------------------------------------------------------------- 1 | #version 310 es 2 | 3 | layout(binding = 0, std140) uniform type_cbVS 4 | { 5 | mat4 wvp; 6 | } cbVS; 7 | 8 | layout(location = 0) in vec4 in_var_POSITION; 9 | 10 | void main() 11 | { 12 | gl_Position = cbVS.wvp * in_var_POSITION; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Transform_VS.40.hlsl: -------------------------------------------------------------------------------- 1 | cbuffer type_cbVS : register(b0) 2 | { 3 | row_major float4x4 cbVS_wvp : packoffset(c0); 4 | }; 5 | 6 | 7 | static float4 gl_Position; 8 | static float4 in_var_POSITION; 9 | 10 | struct SPIRV_Cross_Input 11 | { 12 | float4 in_var_POSITION : TEXCOORD0; 13 | }; 14 | 15 | struct SPIRV_Cross_Output 16 | { 17 | float4 gl_Position : SV_Position; 18 | }; 19 | 20 | void vert_main() 21 | { 22 | gl_Position = mul(in_var_POSITION, cbVS_wvp); 23 | } 24 | 25 | SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) 26 | { 27 | in_var_POSITION = stage_input.in_var_POSITION; 28 | vert_main(); 29 | SPIRV_Cross_Output stage_output; 30 | stage_output.gl_Position = gl_Position; 31 | return stage_output; 32 | } 33 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Transform_VS.410.glsl: -------------------------------------------------------------------------------- 1 | #version 410 2 | 3 | out gl_PerVertex 4 | { 5 | vec4 gl_Position; 6 | }; 7 | 8 | layout(std140) uniform type_cbVS 9 | { 10 | mat4 wvp; 11 | } cbVS; 12 | 13 | layout(location = 0) in vec4 in_var_POSITION; 14 | 15 | void main() 16 | { 17 | gl_Position = cbVS.wvp * in_var_POSITION; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Transform_VS.50.hlsl: -------------------------------------------------------------------------------- 1 | cbuffer type_cbVS : register(b0) 2 | { 3 | row_major float4x4 cbVS_wvp : packoffset(c0); 4 | }; 5 | 6 | 7 | static float4 gl_Position; 8 | static float4 in_var_POSITION; 9 | 10 | struct SPIRV_Cross_Input 11 | { 12 | float4 in_var_POSITION : TEXCOORD0; 13 | }; 14 | 15 | struct SPIRV_Cross_Output 16 | { 17 | float4 gl_Position : SV_Position; 18 | }; 19 | 20 | void vert_main() 21 | { 22 | gl_Position = mul(in_var_POSITION, cbVS_wvp); 23 | } 24 | 25 | SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) 26 | { 27 | in_var_POSITION = stage_input.in_var_POSITION; 28 | vert_main(); 29 | SPIRV_Cross_Output stage_output; 30 | stage_output.gl_Position = gl_Position; 31 | return stage_output; 32 | } 33 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Transform_VS.msl: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace metal; 5 | 6 | struct type_cbVS 7 | { 8 | float4x4 wvp; 9 | }; 10 | 11 | struct main0_out 12 | { 13 | float4 gl_Position [[position]]; 14 | }; 15 | 16 | struct main0_in 17 | { 18 | float4 in_var_POSITION [[attribute(0)]]; 19 | }; 20 | 21 | vertex main0_out main0(main0_in in [[stage_in]], constant type_cbVS& cbVS [[buffer(0)]]) 22 | { 23 | main0_out out = {}; 24 | out.gl_Position = cbVS.wvp * in.in_var_POSITION; 25 | return out; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /Source/Tests/Data/Expected/Transform_VS_ColumnMajor.300.glsl: -------------------------------------------------------------------------------- 1 | #version 300 2 | #extension GL_ARB_separate_shader_objects : require 3 | 4 | out gl_PerVertex 5 | { 6 | vec4 gl_Position; 7 | }; 8 | 9 | layout(std140) uniform type_cbVS 10 | { 11 | layout(row_major) mat4 wvp; 12 | } cbVS; 13 | 14 | in vec4 in_var_POSITION; 15 | 16 | void main() 17 | { 18 | gl_Position = cbVS.wvp * in_var_POSITION; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /Source/Tests/Data/Input/CalcLight.hlsl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | struct PSInput 5 | { 6 | float4 pos : SV_Position; 7 | float3 normal : NORMAL; 8 | float3 lightVec : TEXCOORD0; 9 | float3 halfway : TEXCOORD1; 10 | }; 11 | 12 | cbuffer cbPS : register(b0) 13 | { 14 | float3 diffColor; 15 | float3 specColor; 16 | float shininess; 17 | }; 18 | 19 | float3 CalcBrdf(float3 diffColor, float3 specColor, float shininess, float3 lightVec, float3 halfway, float3 normal); 20 | 21 | [shader("pixel")] 22 | float4 main(PSInput input) : SV_Target 23 | { 24 | float4 color; 25 | color.rgb = CalcBrdf(diffColor, specColor, shininess, input.lightVec, input.halfway, input.normal); 26 | color.a = 1.0f; 27 | 28 | return color; 29 | } 30 | -------------------------------------------------------------------------------- /Source/Tests/Data/Input/CalcLightDiffuse.hlsl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | // Diffuse only 5 | float3 CalcBrdf(float3 diffColor, float3 specColor, float shininess, float3 lightVec, float3 halfway, float3 normal) 6 | { 7 | return max(diffColor * dot(normal, lightVec), 0); 8 | } 9 | -------------------------------------------------------------------------------- /Source/Tests/Data/Input/CalcLightDiffuseSpecular.hlsl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | float SpecularNormalizeFactor(float shininess) 5 | { 6 | return (shininess + 2) / 8; 7 | } 8 | 9 | float3 DistributionTerm(float3 halfway, float3 normal, float shininess) 10 | { 11 | return pow(max(dot(halfway, normal), 0.0f), shininess); 12 | } 13 | 14 | float3 FresnelTerm(float3 lightVec, float3 halfway, float3 specColor) 15 | { 16 | float eN = saturate(dot(lightVec, halfway)); 17 | return specColor > 0 ? specColor + (1 - specColor) * pow(1 - eN, 5) : 0; 18 | } 19 | 20 | float3 SpecularTerm(float3 specColor, float3 lightVec, float3 halfway, float3 normal, float shininess) 21 | { 22 | return SpecularNormalizeFactor(shininess) * DistributionTerm(halfway, normal, shininess) * FresnelTerm(lightVec, halfway, specColor); 23 | } 24 | 25 | // Diffuse and specular 26 | float3 CalcBrdf(float3 diffColor, float3 specColor, float shininess, float3 lightVec, float3 halfway, float3 normal) 27 | { 28 | return max((diffColor + SpecularTerm(specColor, lightVec, halfway, normal, shininess)) * dot(normal, lightVec), 0); 29 | } 30 | -------------------------------------------------------------------------------- /Source/Tests/Data/Input/Common.hlsli: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | SamplerState pointSampler : register(s0); 5 | SamplerState linearSampler : register(s1); 6 | -------------------------------------------------------------------------------- /Source/Tests/Data/Input/Constant_PS.hlsl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | float4 PSMain() : SV_Target 5 | { 6 | return float4(0.2f, 0.4f, 0.6f, 1.0f); 7 | } 8 | -------------------------------------------------------------------------------- /Source/Tests/Data/Input/Constant_VS.hlsl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | float4 VSMain() : SV_Position 5 | { 6 | return float4(1, 2, 3, 4); 7 | } 8 | -------------------------------------------------------------------------------- /Source/Tests/Data/Input/DetailTessellation_HS.hlsl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | cbuffer cbMain : register(b0) 5 | { 6 | float4 tessellationFactor; 7 | }; 8 | 9 | struct VS_OUTPUT_HS_INPUT 10 | { 11 | float3 worldPos : WORLDPOS; 12 | float3 normal : NORMAL; 13 | float2 texCoord : TEXCOORD0; 14 | float3 lightTS : LIGHTVECTORTS; 15 | }; 16 | 17 | struct HS_CONSTANT_DATA_OUTPUT 18 | { 19 | float edges[3] : SV_TessFactor; 20 | float inside : SV_InsideTessFactor; 21 | }; 22 | 23 | struct HS_CONTROL_POINT_OUTPUT 24 | { 25 | float3 worldPos : WORLDPOS; 26 | float3 normal : NORMAL; 27 | float2 texCoord : TEXCOORD0; 28 | float3 lightTS : LIGHTVECTORTS; 29 | }; 30 | 31 | HS_CONSTANT_DATA_OUTPUT ConstantsHS(InputPatch p, uint patchID : SV_PrimitiveID) 32 | { 33 | HS_CONSTANT_DATA_OUTPUT output; 34 | 35 | output.edges[0] = tessellationFactor.x; 36 | output.edges[1] = tessellationFactor.y; 37 | output.edges[2] = tessellationFactor.z; 38 | output.inside = tessellationFactor.w; 39 | 40 | return output; 41 | } 42 | 43 | [domain("tri")] 44 | [partitioning("fractional_odd")] 45 | [outputtopology("triangle_cw")] 46 | [outputcontrolpoints(3)] 47 | [patchconstantfunc("ConstantsHS")] 48 | [maxtessfactor(15.0)] 49 | HS_CONTROL_POINT_OUTPUT main(InputPatch inputPatch, uint uCPID : SV_OutputControlPointID) 50 | { 51 | HS_CONTROL_POINT_OUTPUT output; 52 | 53 | output.worldPos = inputPatch[uCPID].worldPos.xyz; 54 | output.normal = inputPatch[uCPID].normal; 55 | output.texCoord = inputPatch[uCPID].texCoord; 56 | output.lightTS = inputPatch[uCPID].lightTS; 57 | 58 | return output; 59 | } 60 | -------------------------------------------------------------------------------- /Source/Tests/Data/Input/Fluid_CS.hlsl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | struct Particle 5 | { 6 | float2 position; 7 | float2 velocity; 8 | }; 9 | 10 | struct ParticleForces 11 | { 12 | float2 acceleration; 13 | }; 14 | 15 | cbuffer cbSimulationConstants : register(b0) 16 | { 17 | float timeStep; 18 | float wallStiffness; 19 | 20 | float4 gravity; 21 | float3 planes[4]; 22 | }; 23 | 24 | RWStructuredBuffer particlesRW : register(u0); 25 | StructuredBuffer particlesRO : register(t0); 26 | 27 | StructuredBuffer particlesForcesRO : register(t2); 28 | 29 | [numthreads(256, 1, 1)] 30 | void main(uint3 dtid : SV_DispatchThreadID, uint gi : SV_GroupIndex) 31 | { 32 | const uint p_id = dtid.x; 33 | 34 | float2 position = particlesRO[p_id].position; 35 | float2 velocity = particlesRO[p_id].velocity; 36 | float2 acceleration = particlesForcesRO[p_id].acceleration; 37 | 38 | [unroll] 39 | for (uint i = 0 ; i < 4 ; ++i) 40 | { 41 | float dist = dot(float3(position, 1), planes[i]); 42 | acceleration += min(dist, 0) * -wallStiffness * planes[i].xy; 43 | } 44 | 45 | acceleration += gravity.xy; 46 | 47 | velocity += timeStep * acceleration; 48 | position += timeStep * velocity; 49 | 50 | particlesRW[p_id].position = position; 51 | particlesRW[p_id].velocity = velocity; 52 | } 53 | -------------------------------------------------------------------------------- /Source/Tests/Data/Input/HalfDataType.hlsl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | float4 DotHalfPS() : SV_Target0 5 | { 6 | half3 v0 = half3(0, 0, 1); 7 | float ret = dot(v0, v0); 8 | return ret; 9 | } 10 | 11 | void Func(half3 input, out half3 output) 12 | { 13 | output = input; 14 | } 15 | 16 | float4 HalfOutParamPS() : SV_Target0 17 | { 18 | float3 output; 19 | Func(cross(half3(1, 0, 0), half3(0, 1, 0)), output); 20 | return float4(output, 1.0f); 21 | } 22 | -------------------------------------------------------------------------------- /Source/Tests/Data/Input/Inc/HeaderA.hlsli: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #include "HeaderB.hlsli" 5 | 6 | SamplerState pointSampler : register(s0); 7 | -------------------------------------------------------------------------------- /Source/Tests/Data/Input/Inc/HeaderB.hlsli: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | SamplerState linearSampler : register(s1); 5 | -------------------------------------------------------------------------------- /Source/Tests/Data/Input/Inc/HeaderEmpty.hlsli: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/ShaderConductor/f18f7b5c370bae157a6b7377155f758f6441cfea/Source/Tests/Data/Input/Inc/HeaderEmpty.hlsli -------------------------------------------------------------------------------- /Source/Tests/Data/Input/IncludeEmptyHeader.hlsl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #include "Inc/HeaderEmpty.hlsli" 5 | 6 | float4 main() : SV_Target 7 | { 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /Source/Tests/Data/Input/IncludeExist.hlsl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #include "Inc/HeaderA.hlsli" 5 | 6 | Texture2D colorTex : register(t0); 7 | 8 | float4 main(float2 tex : TEXCOORD0) : SV_Target 9 | { 10 | return colorTex.Sample(pointSampler, tex) + colorTex.Sample(linearSampler, tex); 11 | } 12 | -------------------------------------------------------------------------------- /Source/Tests/Data/Input/IncludeNotExist.hlsl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #include "Header.hlsli" 5 | #include "IncludeExist.hlsli" 6 | -------------------------------------------------------------------------------- /Source/Tests/Data/Input/PNTriangles_DS.hlsl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | cbuffer cbPNTriangles : register(b0) 5 | { 6 | float4x4 viewProj; 7 | float4 lightDir; 8 | } 9 | 10 | struct HS_ConstantOutput 11 | { 12 | float tessFactor[3] : SV_TessFactor; 13 | float insideTessFactor : SV_InsideTessFactor; 14 | 15 | float3 b210 : POSITION3; 16 | float3 b120 : POSITION4; 17 | float3 b021 : POSITION5; 18 | float3 b012 : POSITION6; 19 | float3 b102 : POSITION7; 20 | float3 b201 : POSITION8; 21 | float3 b111 : CENTER; 22 | }; 23 | 24 | struct HS_ControlPointOutput 25 | { 26 | float3 position : POSITION; 27 | float2 texCoord : TEXCOORD; 28 | }; 29 | 30 | struct DS_Output 31 | { 32 | float4 position : SV_Position; 33 | float2 texCoord : TEXCOORD0; 34 | }; 35 | 36 | [domain("tri")] 37 | DS_Output main(HS_ConstantOutput hsConstantData, const OutputPatch input, 38 | float3 barycentricCoords : SV_DomainLocation) 39 | { 40 | DS_Output output; 41 | 42 | float u = barycentricCoords.x; 43 | float v = barycentricCoords.y; 44 | float w = barycentricCoords.z; 45 | 46 | float uu = u * u; 47 | float vv = v * v; 48 | float ww = w * w; 49 | float uu3 = uu * 3; 50 | float vv3 = vv * 3; 51 | float ww3 = ww * 3; 52 | 53 | float3 position = input[0].position * ww * w + 54 | input[1].position * uu * u + 55 | input[2].position * vv * v + 56 | hsConstantData.b210 * ww3 * u + 57 | hsConstantData.b120 * w * uu3 + 58 | hsConstantData.b201 * ww3 * v + 59 | hsConstantData.b021 * uu3 * v + 60 | hsConstantData.b102 * w * vv3 + 61 | hsConstantData.b012 * u * vv3 + 62 | hsConstantData.b111 * 6 * w * u * v; 63 | 64 | output.position = mul(float4(position, 1), viewProj); 65 | 66 | output.texCoord = input[0].texCoord * w + input[1].texCoord * u + input[2].texCoord * v; 67 | 68 | return output; 69 | } 70 | -------------------------------------------------------------------------------- /Source/Tests/Data/Input/Particle_GS.hlsl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | cbuffer cbMain : register(b0) 5 | { 6 | matrix invView; 7 | matrix viewProj; 8 | }; 9 | 10 | struct GS_PARTICLE_INPUT 11 | { 12 | float4 wsPos : POSITION; 13 | }; 14 | 15 | struct PS_PARTICLE_INPUT 16 | { 17 | float4 pos : SV_POSITION; 18 | float2 tex : TEXCOORD0; 19 | }; 20 | 21 | [maxvertexcount(4)] 22 | void main(point GS_PARTICLE_INPUT input[1], inout TriangleStream spriteStream) 23 | { 24 | const float3 quadPositions[4] = 25 | { 26 | float3(-1, 1, 0), 27 | float3( 1, 1, 0), 28 | float3(-1, -1, 0), 29 | float3( 1, -1, 0), 30 | }; 31 | const float2 quadTexcoords[4] = 32 | { 33 | float2(0, 1), 34 | float2(1, 1), 35 | float2(0, 0), 36 | float2(1, 0), 37 | }; 38 | 39 | PS_PARTICLE_INPUT output; 40 | 41 | [unroll] 42 | for (int i = 0; i < 4; ++i) 43 | { 44 | float3 position = quadPositions[i] * FIXED_VERTEX_RADIUS; 45 | position = mul(position, (float3x3)invView) + input[0].wsPos.xyz; 46 | output.pos = mul(float4(position, 1.0f), viewProj); 47 | 48 | output.tex = quadTexcoords[i]; 49 | 50 | spriteStream.Append(output); 51 | } 52 | spriteStream.RestartStrip(); 53 | } 54 | -------------------------------------------------------------------------------- /Source/Tests/Data/Input/PassThrough_PS.hlsl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | float4 PSMain(float4 color : COLOR) : SV_Target 5 | { 6 | return color; 7 | } 8 | -------------------------------------------------------------------------------- /Source/Tests/Data/Input/PassThrough_VS.hlsl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | void VSMain(float4 pos : POSITION, 5 | float2 tex : TEXCOORD0, 6 | out float2 oTex : TEXCOORD0, 7 | out float4 oPos : SV_Position) 8 | { 9 | oTex = tex; 10 | oPos = pos; 11 | } 12 | -------------------------------------------------------------------------------- /Source/Tests/Data/Input/ToneMapping_PS.hlsl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #include "Common.hlsli" 5 | 6 | struct PSInput 7 | { 8 | float4 pos : SV_Position; 9 | float2 tex : TEXCOORD0; 10 | }; 11 | 12 | Texture2D colorTex : register(t0); 13 | Texture2D lumTex : register(t1); 14 | Texture2D bloomTex : register(t2); 15 | 16 | static const float MIDDLE_GRAY = 0.72f; 17 | static const float LUM_WHITE = 1.5f; 18 | 19 | cbuffer cbPS : register(b0) 20 | { 21 | float lumStrength; 22 | }; 23 | 24 | float4 main(PSInput input) : SV_Target 25 | { 26 | float4 color = colorTex.Sample(pointSampler, input.tex); 27 | float3 bloom = bloomTex.Sample(linearSampler, input.tex).xyz; 28 | float lum = lumTex.Sample(pointSampler, 0.5f).x * lumStrength; 29 | 30 | color.rgb *= MIDDLE_GRAY / (lum + 0.001f); 31 | color.rgb *= (1.0f + color.rgb / LUM_WHITE); 32 | color.rgb /= (1.0f + color.rgb); 33 | 34 | color.rgb += 0.6f * bloom; 35 | color.a = 1.0f; 36 | 37 | return color; 38 | } 39 | -------------------------------------------------------------------------------- /Source/Tests/Data/Input/Transform_VS.hlsl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | cbuffer cbVS : register(b0) 5 | { 6 | float4x4 wvp; 7 | }; 8 | 9 | void main(float4 pos : POSITION, 10 | out float4 oPos : SV_Position) 11 | { 12 | oPos = mul(pos, wvp); 13 | } 14 | -------------------------------------------------------------------------------- /Source/Tests/Data/Result/.gitignore: -------------------------------------------------------------------------------- 1 | # All files and folders in this folder should be ignored 2 | * -------------------------------------------------------------------------------- /Source/Tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | set(EXE_NAME ShaderConductorCmd) 5 | 6 | set(SOURCE_FILES 7 | ShaderConductorCmd.cpp 8 | ) 9 | 10 | source_group("Source Files" FILES ${SOURCE_FILES}) 11 | 12 | add_executable(${EXE_NAME} ${SOURCE_FILES}) 13 | 14 | target_link_libraries(${EXE_NAME} 15 | PRIVATE 16 | ShaderConductor 17 | cxxopts 18 | ) 19 | 20 | add_dependencies(${EXE_NAME} ShaderConductor) 21 | 22 | set_target_properties(${EXE_NAME} PROPERTIES FOLDER "Tools") 23 | -------------------------------------------------------------------------------- /Source/Tools/ShaderConductorCmd.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ShaderConductor 3 | * 4 | * Copyright (c) Microsoft Corporation. All rights reserved. 5 | * Licensed under the MIT License. 6 | * 7 | * MIT License 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this 10 | * software and associated documentation files (the "Software"), to deal in the Software 11 | * without restriction, including without limitation the rights to use, copy, modify, merge, 12 | * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all copies or 16 | * substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 19 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 20 | * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 21 | * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 22 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #ifdef _MSC_VER 34 | #pragma warning(push) 35 | #pragma warning(disable : 4819) 36 | #endif 37 | #include 38 | #ifdef _MSC_VER 39 | #pragma warning(pop) 40 | #endif 41 | 42 | int main(int argc, char** argv) 43 | { 44 | cxxopts::Options options("ShaderConductorCmd", "A tool for compiling HLSL to many shader languages."); 45 | // clang-format off 46 | options.add_options() 47 | ("E,entry", "Entry point of the shader", cxxopts::value()->default_value("main")) 48 | ("I,input", "Input file name", cxxopts::value())("O,output", "Output file name", cxxopts::value()) 49 | ("S,stage", "Shader stage: vs, ps, gs, hs, ds, cs", cxxopts::value()) 50 | ("T,target", "Target shading language: dxil, spirv, hlsl, glsl, essl, msl_macos, msl_ios", cxxopts::value()->default_value("dxil")) 51 | ("V,version", "The version of target shading language", cxxopts::value()->default_value("")) 52 | ("D,define", "Macro define as name=value", cxxopts::value>()); 53 | 54 | // clang-format on 55 | 56 | auto opts = options.parse(argc, argv); 57 | 58 | if ((opts.count("input") == 0) || (opts.count("stage") == 0)) 59 | { 60 | std::cerr << "COULDN'T find or in command line parameters." << std::endl; 61 | std::cerr << options.help() << std::endl; 62 | return 1; 63 | } 64 | 65 | using namespace ShaderConductor; 66 | 67 | Compiler::SourceDesc sourceDesc{}; 68 | Compiler::TargetDesc targetDesc{}; 69 | 70 | const auto fileName = opts["input"].as(); 71 | const auto targetName = opts["target"].as(); 72 | const auto targetVersion = opts["version"].as(); 73 | 74 | sourceDesc.fileName = fileName.c_str(); 75 | targetDesc.version = targetVersion.empty() ? nullptr : targetVersion.c_str(); 76 | 77 | const auto stageName = opts["stage"].as(); 78 | if (stageName == "vs") 79 | { 80 | sourceDesc.stage = ShaderStage::VertexShader; 81 | } 82 | else if (stageName == "ps") 83 | { 84 | sourceDesc.stage = ShaderStage::PixelShader; 85 | } 86 | else if (stageName == "gs") 87 | { 88 | sourceDesc.stage = ShaderStage::GeometryShader; 89 | } 90 | else if (stageName == "hs") 91 | { 92 | sourceDesc.stage = ShaderStage::HullShader; 93 | } 94 | else if (stageName == "ds") 95 | { 96 | sourceDesc.stage = ShaderStage::DomainShader; 97 | } 98 | else if (stageName == "cs") 99 | { 100 | sourceDesc.stage = ShaderStage::ComputeShader; 101 | } 102 | else 103 | { 104 | std::cerr << "Invalid shader stage: " << stageName << std::endl; 105 | return 1; 106 | } 107 | 108 | const auto entryPoint = opts["entry"].as(); 109 | sourceDesc.entryPoint = entryPoint.c_str(); 110 | 111 | if (targetName == "dxil") 112 | { 113 | targetDesc.language = ShadingLanguage::Dxil; 114 | } 115 | else if (targetName == "spirv") 116 | { 117 | targetDesc.language = ShadingLanguage::SpirV; 118 | } 119 | else if (targetName == "hlsl") 120 | { 121 | targetDesc.language = ShadingLanguage::Hlsl; 122 | } 123 | else if (targetName == "glsl") 124 | { 125 | targetDesc.language = ShadingLanguage::Glsl; 126 | } 127 | else if (targetName == "essl") 128 | { 129 | targetDesc.language = ShadingLanguage::Essl; 130 | } 131 | else if (targetName == "msl_macos") 132 | { 133 | targetDesc.language = ShadingLanguage::Msl_macOS; 134 | } 135 | else if (targetName == "msl_ios") 136 | { 137 | targetDesc.language = ShadingLanguage::Msl_iOS; 138 | } 139 | else 140 | { 141 | std::cerr << "Invalid target shading language: " << targetName << std::endl; 142 | return 1; 143 | } 144 | 145 | std::string outputName; 146 | if (opts.count("output") == 0) 147 | { 148 | static const std::string extMap[] = {"dxil", "spv", "hlsl", "glsl", "essl", "msl", "msl"}; 149 | static_assert(sizeof(extMap) / sizeof(extMap[0]) == static_cast(ShadingLanguage::NumShadingLanguages), 150 | "extMap doesn't match with the number of shading languages."); 151 | outputName = fileName + "." + extMap[static_cast(targetDesc.language)]; 152 | } 153 | else 154 | { 155 | outputName = opts["output"].as(); 156 | } 157 | 158 | std::string source; 159 | { 160 | std::ifstream inputFile(sourceDesc.fileName, std::ios_base::binary); 161 | if (!inputFile) 162 | { 163 | std::cerr << "COULDN'T load the input file: " << sourceDesc.fileName << std::endl; 164 | return 1; 165 | } 166 | 167 | inputFile.seekg(0, std::ios::end); 168 | source.resize(static_cast(inputFile.tellg())); 169 | inputFile.seekg(0, std::ios::beg); 170 | inputFile.read(&source[0], source.size()); 171 | } 172 | sourceDesc.source = source.c_str(); 173 | 174 | size_t numberOfDefines = opts.count("define"); 175 | std::vector macroDefines; 176 | std::vector macroStrings; 177 | if (numberOfDefines > 0) 178 | { 179 | macroDefines.reserve(numberOfDefines); 180 | macroStrings.reserve(numberOfDefines * 2); 181 | auto& defines = opts["define"].as>(); 182 | for (const auto& define : defines) 183 | { 184 | MacroDefine macroDefine; 185 | macroDefine.name = nullptr; 186 | macroDefine.value = nullptr; 187 | 188 | size_t splitPosition = define.find('='); 189 | if (splitPosition != std::string::npos) 190 | { 191 | std::string macroName = define.substr(0, splitPosition); 192 | std::string macroValue = define.substr(splitPosition + 1, define.size() - splitPosition - 1); 193 | 194 | macroStrings.push_back(macroName); 195 | macroDefine.name = macroStrings.back().c_str(); 196 | macroStrings.push_back(macroValue); 197 | macroDefine.value = macroStrings.back().c_str(); 198 | } 199 | else 200 | { 201 | macroStrings.push_back(define); 202 | macroDefine.name = macroStrings.back().c_str(); 203 | } 204 | 205 | macroDefines.push_back(macroDefine); 206 | } 207 | 208 | sourceDesc.defines = macroDefines.data(); 209 | sourceDesc.numDefines = static_cast(macroDefines.size()); 210 | } 211 | 212 | try 213 | { 214 | const auto result = Compiler::Compile(sourceDesc, {}, targetDesc); 215 | 216 | if (result.errorWarningMsg.Size() > 0) 217 | { 218 | const char* msg = reinterpret_cast(result.errorWarningMsg.Data()); 219 | std::cerr << "Error or warning from shader compiler: " << std::endl 220 | << std::string(msg, msg + result.errorWarningMsg.Size()) << std::endl; 221 | } 222 | if (result.target.Size() > 0) 223 | { 224 | std::ofstream outputFile(outputName, std::ios_base::binary); 225 | if (!outputFile) 226 | { 227 | std::cerr << "COULDN'T open the output file: " << outputName << std::endl; 228 | return 1; 229 | } 230 | 231 | outputFile.write(reinterpret_cast(result.target.Data()), result.target.Size()); 232 | 233 | std::cout << "The compiled file is saved to " << outputName << std::endl; 234 | } 235 | } 236 | catch (std::exception& ex) 237 | { 238 | std::cerr << ex.what() << std::endl; 239 | } 240 | 241 | return 0; 242 | } 243 | -------------------------------------------------------------------------------- /Source/Wrapper/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | set(DLL_NAME ShaderConductorWrapper) 5 | 6 | set(SOURCE_FILES 7 | Native.cpp 8 | Native.h 9 | ) 10 | 11 | source_group("Source Files" FILES ${SOURCE_FILES}) 12 | 13 | add_library(${DLL_NAME} SHARED ${SOURCE_FILES}) 14 | 15 | target_link_libraries(${DLL_NAME} 16 | PRIVATE 17 | ShaderConductor 18 | ) 19 | 20 | add_dependencies(${DLL_NAME} ShaderConductor) 21 | 22 | set_target_properties(${DLL_NAME} PROPERTIES FOLDER "Wrapper") 23 | 24 | set(CSHARP_TEST CSharpPinvoke) 25 | 26 | set(SOURCE_FILES 27 | Program.cs 28 | Wrapper.cs 29 | ) 30 | 31 | set(DATA_FILES 32 | shader.hlsl 33 | ) 34 | 35 | set_source_files_properties(${DATA_FILES} 36 | PROPERTIES VS_TOOL_OVERRIDE "None" 37 | VS_COPY_TO_OUT_DIR "PreserveNewest" 38 | ) 39 | 40 | add_executable(${CSHARP_TEST} ${SOURCE_FILES} ${DATA_FILES}) 41 | add_dependencies(${CSHARP_TEST} ShaderConductorWrapper) 42 | 43 | set_target_properties(${CSHARP_TEST} PROPERTIES FOLDER "Wrapper") 44 | -------------------------------------------------------------------------------- /Source/Wrapper/Native.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ShaderConductor 3 | * 4 | * Copyright (c) Microsoft Corporation. All rights reserved. 5 | * Licensed under the MIT License. 6 | * 7 | * MIT License 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this 10 | * software and associated documentation files (the "Software"), to deal in the Software 11 | * without restriction, including without limitation the rights to use, copy, modify, merge, 12 | * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all copies or 16 | * substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 19 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 20 | * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 21 | * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 22 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | #include "Native.h" 27 | #include 28 | #include 29 | 30 | using namespace ShaderConductor; 31 | 32 | void Compile(SourceDescription* source, OptionsDescription* optionsDesc, TargetDescription* target, ResultDescription* result) 33 | { 34 | Compiler::SourceDesc sourceDesc; 35 | sourceDesc.entryPoint = source->entryPoint; 36 | sourceDesc.source = source->source; 37 | sourceDesc.stage = source->stage; 38 | sourceDesc.fileName = nullptr; 39 | sourceDesc.defines = nullptr; 40 | sourceDesc.numDefines = 0; 41 | 42 | Compiler::Options options; 43 | options.packMatricesInRowMajor = optionsDesc->packMatricesInRowMajor; 44 | options.enable16bitTypes = optionsDesc->enable16bitTypes; 45 | options.enableDebugInfo = optionsDesc->enableDebugInfo; 46 | options.disableOptimizations = optionsDesc->disableOptimizations; 47 | options.optimizationLevel = optionsDesc->optimizationLevel; 48 | options.shaderModel = {static_cast(optionsDesc->shaderModel.major), static_cast(optionsDesc->shaderModel.minor)}; 49 | options.shiftAllTexturesBindings = optionsDesc->shiftAllTexturesBindings; 50 | options.shiftAllSamplersBindings = optionsDesc->shiftAllSamplersBindings; 51 | options.shiftAllCBuffersBindings = optionsDesc->shiftAllCBuffersBindings; 52 | options.shiftAllUABuffersBindings = optionsDesc->shiftAllUABuffersBindings; 53 | 54 | Compiler::TargetDesc targetDesc{}; 55 | targetDesc.language = target->shadingLanguage; 56 | targetDesc.version = target->version; 57 | 58 | try 59 | { 60 | const auto translation = Compiler::Compile(sourceDesc, options, targetDesc); 61 | 62 | if (translation.errorWarningMsg.Size() > 0) 63 | { 64 | result->errorWarningMsg = CreateShaderConductorBlob(translation.errorWarningMsg.Data(), translation.errorWarningMsg.Size()); 65 | } 66 | if (translation.target.Size() > 0) 67 | { 68 | result->target = CreateShaderConductorBlob(translation.target.Data(), translation.target.Size()); 69 | } 70 | 71 | result->hasError = translation.hasError; 72 | result->isText = translation.isText; 73 | } 74 | catch (std::exception& ex) 75 | { 76 | const char* exception = ex.what(); 77 | result->errorWarningMsg = CreateShaderConductorBlob(exception, static_cast(strlen(exception))); 78 | result->hasError = true; 79 | } 80 | } 81 | 82 | void Disassemble(DisassembleDescription* source, ResultDescription* result) 83 | { 84 | Compiler::DisassembleDesc disassembleSource; 85 | disassembleSource.language = source->language; 86 | disassembleSource.binary = reinterpret_cast(source->binary); 87 | disassembleSource.binarySize = source->binarySize; 88 | 89 | const auto disassembleResult = Compiler::Disassemble(disassembleSource); 90 | 91 | if (disassembleResult.errorWarningMsg.Size() > 0) 92 | { 93 | result->errorWarningMsg = 94 | CreateShaderConductorBlob(disassembleResult.errorWarningMsg.Data(), disassembleResult.errorWarningMsg.Size()); 95 | } 96 | if (disassembleResult.target.Size() > 0) 97 | { 98 | result->target = CreateShaderConductorBlob(disassembleResult.target.Data(), disassembleResult.target.Size()); 99 | } 100 | 101 | result->hasError = disassembleResult.hasError; 102 | result->isText = disassembleResult.isText; 103 | } 104 | 105 | ShaderConductorBlob* CreateShaderConductorBlob(const void* data, int size) 106 | { 107 | return reinterpret_cast(new ShaderConductor::Blob(data, size)); 108 | } 109 | 110 | void DestroyShaderConductorBlob(ShaderConductorBlob* blob) 111 | { 112 | delete reinterpret_cast(blob); 113 | } 114 | 115 | const void* GetShaderConductorBlobData(ShaderConductorBlob* blob) 116 | { 117 | return reinterpret_cast(blob)->Data(); 118 | } 119 | 120 | int GetShaderConductorBlobSize(ShaderConductorBlob* blob) 121 | { 122 | return reinterpret_cast(blob)->Size(); 123 | } 124 | -------------------------------------------------------------------------------- /Source/Wrapper/Native.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ShaderConductor 3 | * 4 | * Copyright (c) Microsoft Corporation. All rights reserved. 5 | * Licensed under the MIT License. 6 | * 7 | * MIT License 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this 10 | * software and associated documentation files (the "Software"), to deal in the Software 11 | * without restriction, including without limitation the rights to use, copy, modify, merge, 12 | * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all copies or 16 | * substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 19 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 20 | * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 21 | * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 22 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | #pragma once 27 | 28 | #include 29 | 30 | using namespace ShaderConductor; 31 | 32 | struct ShaderConductorBlob; 33 | 34 | struct SourceDescription 35 | { 36 | const char* source; 37 | const char* entryPoint; 38 | ShaderStage stage; 39 | }; 40 | 41 | struct ShaderModel 42 | { 43 | int major; 44 | int minor; 45 | }; 46 | 47 | struct OptionsDescription 48 | { 49 | bool packMatricesInRowMajor = true; // Experimental: Decide how a matrix get packed 50 | bool enable16bitTypes = false; // Enable 16-bit types, such as half, uint16_t. Requires shader model 6.2+ 51 | bool enableDebugInfo = false; // Embed debug info into the binary 52 | bool disableOptimizations = false; // Force to turn off optimizations. Ignore optimizationLevel below. 53 | int optimizationLevel = 3; // 0 to 3, no optimization to most optimization 54 | 55 | ShaderModel shaderModel = {6, 0}; 56 | 57 | int shiftAllTexturesBindings; 58 | int shiftAllSamplersBindings; 59 | int shiftAllCBuffersBindings; 60 | int shiftAllUABuffersBindings; 61 | }; 62 | 63 | struct TargetDescription 64 | { 65 | ShadingLanguage shadingLanguage; 66 | const char* version; 67 | }; 68 | 69 | struct ResultDescription 70 | { 71 | ShaderConductorBlob* target; 72 | bool isText; 73 | 74 | ShaderConductorBlob* errorWarningMsg; 75 | bool hasError; 76 | }; 77 | 78 | struct DisassembleDescription 79 | { 80 | ShadingLanguage language; 81 | char* binary; 82 | int binarySize; 83 | }; 84 | 85 | #define DLLEXPORT extern "C" __declspec(dllexport) 86 | 87 | DLLEXPORT void Compile(SourceDescription* source, OptionsDescription* optionsDesc, TargetDescription* target, ResultDescription* result); 88 | DLLEXPORT void Disassemble(DisassembleDescription* source, ResultDescription* result); 89 | 90 | DLLEXPORT ShaderConductorBlob* CreateShaderConductorBlob(const void* data, int size); 91 | DLLEXPORT void DestroyShaderConductorBlob(ShaderConductorBlob* blob); 92 | DLLEXPORT const void* GetShaderConductorBlobData(ShaderConductorBlob* blob); 93 | DLLEXPORT int GetShaderConductorBlobSize(ShaderConductorBlob* blob); 94 | -------------------------------------------------------------------------------- /Source/Wrapper/Program.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * ShaderConductor 3 | * 4 | * Copyright (c) Microsoft Corporation. All rights reserved. 5 | * Licensed under the MIT License. 6 | * 7 | * MIT License 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this 10 | * software and associated documentation files (the "Software"), to deal in the Software 11 | * without restriction, including without limitation the rights to use, copy, modify, merge, 12 | * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all copies or 16 | * substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 19 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 20 | * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 21 | * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 22 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | using System; 27 | using System.IO; 28 | using System.Runtime.InteropServices; 29 | 30 | namespace CSharpConsole 31 | { 32 | class Program 33 | { 34 | static void Main(string[] args) 35 | { 36 | string source = File.ReadAllText("shader.hlsl"); 37 | 38 | Wrapper.SourceDesc sourceDesc = new Wrapper.SourceDesc() 39 | { 40 | entryPoint = "PS", 41 | 42 | stage = Wrapper.ShaderStage.PixelShader, 43 | source = source, 44 | }; 45 | 46 | Wrapper.OptionsDesc optionsDesc = Wrapper.OptionsDesc.Default; 47 | //optionsDesc.packMatricesInRowMajor = true; 48 | //optionsDesc.enable16bitTypes = true; 49 | //optionsDesc.enableDebugInfo = true; 50 | //optionsDesc.disableOptimizations = true; 51 | //optionsDesc.optimizationLevel = 3; 52 | //optionsDesc.shaderModel = new Wrapper.ShaderModel(6, 2); 53 | //optionsDesc.shiftAllCBuffersBindings = 10; 54 | //optionsDesc.shiftAllTexturesBindings = 20; 55 | //optionsDesc.shiftAllSamplersBindings = 30; 56 | //optionsDesc.shiftAllUABuffersBindings = 40; 57 | 58 | Wrapper.TargetDesc targetDesc = new Wrapper.TargetDesc() 59 | { 60 | language = Wrapper.ShadingLanguage.Glsl, 61 | version = "460", 62 | asModule = false, 63 | }; 64 | 65 | Wrapper.Compile(ref sourceDesc, ref optionsDesc, ref targetDesc, out Wrapper.ResultDesc result); 66 | 67 | if (result.hasError) 68 | { 69 | string warning = Marshal.PtrToStringAnsi(Wrapper.GetShaderConductorBlobData(result.errorWarningMsg), 70 | Wrapper.GetShaderConductorBlobSize(result.errorWarningMsg)); 71 | Console.WriteLine("*************************\n" + 72 | "** Error output **\n" + 73 | "*************************\n"); 74 | Console.WriteLine(warning); 75 | } 76 | else 77 | { 78 | if (!result.isText) 79 | { 80 | Wrapper.DisassembleDesc disassembleDesc = new Wrapper.DisassembleDesc() 81 | { 82 | language = targetDesc.language, 83 | binarySize = Wrapper.GetShaderConductorBlobSize(result.target), 84 | binary = Wrapper.GetShaderConductorBlobData(result.target), 85 | }; 86 | 87 | Wrapper.Disassemble(ref disassembleDesc, out Wrapper.ResultDesc disassembleResult); 88 | Wrapper.DestroyShaderConductorBlob(result.target); 89 | Wrapper.DestroyShaderConductorBlob(result.errorWarningMsg); 90 | result = disassembleResult; 91 | } 92 | 93 | if (result.isText) 94 | { 95 | string translation = Marshal.PtrToStringAnsi(Wrapper.GetShaderConductorBlobData(result.target), 96 | Wrapper.GetShaderConductorBlobSize(result.target)); 97 | Console.WriteLine("*************************\n" + 98 | "** Translation **\n" + 99 | "*************************\n"); 100 | Console.WriteLine(translation); 101 | } 102 | } 103 | 104 | Wrapper.DestroyShaderConductorBlob(result.target); 105 | Wrapper.DestroyShaderConductorBlob(result.errorWarningMsg); 106 | 107 | Console.Read(); 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /Source/Wrapper/Wrapper.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * ShaderConductor 3 | * 4 | * Copyright (c) Microsoft Corporation. All rights reserved. 5 | * Licensed under the MIT License. 6 | * 7 | * MIT License 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this 10 | * software and associated documentation files (the "Software"), to deal in the Software 11 | * without restriction, including without limitation the rights to use, copy, modify, merge, 12 | * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 13 | * to whom the Software is furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in all copies or 16 | * substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 19 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 20 | * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 21 | * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 22 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | using System; 27 | using System.Collections.Generic; 28 | using System.Linq; 29 | using System.Runtime.InteropServices; 30 | using System.Text; 31 | using System.Threading.Tasks; 32 | 33 | namespace CSharpConsole 34 | { 35 | public class Wrapper 36 | { 37 | [DllImport("ShaderConductorWrapper.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] 38 | public static extern void Compile([In] ref SourceDesc source, [In] ref OptionsDesc options, [In] ref TargetDesc target, out ResultDesc result); 39 | 40 | [DllImport("ShaderConductorWrapper.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] 41 | public static extern void Disassemble([In] ref DisassembleDesc source, out ResultDesc result); 42 | 43 | [DllImport("ShaderConductorWrapper.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] 44 | public static extern IntPtr CreateShaderConductorBlob(IntPtr data, int size); 45 | 46 | [DllImport("ShaderConductorWrapper.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] 47 | public static extern void DestroyShaderConductorBlob(IntPtr blob); 48 | 49 | [DllImport("ShaderConductorWrapper.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] 50 | public static extern IntPtr GetShaderConductorBlobData(IntPtr blob); 51 | 52 | [DllImport("ShaderConductorWrapper.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] 53 | public static extern int GetShaderConductorBlobSize(IntPtr blob); 54 | 55 | public enum ShaderStage 56 | { 57 | VertexShader, 58 | PixelShader, 59 | GeometryShader, 60 | HullShader, 61 | DomainShader, 62 | ComputeShader, 63 | 64 | NumShaderStages, 65 | }; 66 | 67 | public enum ShadingLanguage 68 | { 69 | Dxil = 0, 70 | SpirV, 71 | 72 | Hlsl, 73 | Glsl, 74 | Essl, 75 | Msl_macOS, 76 | Msl_iOS, 77 | 78 | NumShadingLanguages, 79 | } 80 | 81 | [StructLayout(LayoutKind.Sequential)] 82 | public struct MacroDefine 83 | { 84 | public string name; 85 | public string value; 86 | }; 87 | 88 | [StructLayout(LayoutKind.Sequential)] 89 | public struct SourceDesc 90 | { 91 | public string source; 92 | public string entryPoint; 93 | public ShaderStage stage; 94 | } 95 | 96 | [StructLayout(LayoutKind.Sequential)] 97 | public struct ShaderModel 98 | { 99 | public int major; 100 | public int minor; 101 | 102 | public ShaderModel(int major, int minor) 103 | { 104 | this.major = major; 105 | this.minor = minor; 106 | } 107 | } 108 | 109 | [StructLayout(LayoutKind.Sequential)] 110 | public struct OptionsDesc 111 | { 112 | [MarshalAs(UnmanagedType.I1)] 113 | public bool packMatricesInRowMajor; // Experimental: Decide how a matrix get packed 114 | [MarshalAs(UnmanagedType.I1)] 115 | public bool enable16bitTypes; // Enable 16-bit types, such as half, uint16_t. Requires shader model 6.2+ 116 | [MarshalAs(UnmanagedType.I1)] 117 | public bool enableDebugInfo; // Embed debug info into the binary 118 | [MarshalAs(UnmanagedType.I1)] 119 | public bool disableOptimizations; // Force to turn off optimizations. Ignore optimizationLevel below. 120 | public int optimizationLevel; // 0 to 3, no optimization to most optimization 121 | 122 | public ShaderModel shaderModel; 123 | 124 | public int shiftAllTexturesBindings; 125 | public int shiftAllSamplersBindings; 126 | public int shiftAllCBuffersBindings; 127 | public int shiftAllUABuffersBindings; 128 | 129 | public static OptionsDesc Default 130 | { 131 | get 132 | { 133 | var defaultInstance = new OptionsDesc(); 134 | 135 | defaultInstance.packMatricesInRowMajor = true; 136 | defaultInstance.enable16bitTypes = false; 137 | defaultInstance.enableDebugInfo = false; 138 | defaultInstance.disableOptimizations = false; 139 | defaultInstance.optimizationLevel = 3; 140 | defaultInstance.shaderModel = new ShaderModel(6, 0); 141 | 142 | return defaultInstance; 143 | } 144 | } 145 | } 146 | 147 | [StructLayout(LayoutKind.Sequential)] 148 | public struct TargetDesc 149 | { 150 | public ShadingLanguage language; 151 | public string version; 152 | public bool asModule; 153 | } 154 | 155 | [StructLayout(LayoutKind.Sequential)] 156 | public struct ResultDesc 157 | { 158 | public IntPtr target; 159 | public bool isText; 160 | public IntPtr errorWarningMsg; 161 | public bool hasError; 162 | } 163 | 164 | [StructLayout(LayoutKind.Sequential)] 165 | public struct DisassembleDesc 166 | { 167 | public ShadingLanguage language; 168 | public IntPtr binary; 169 | public int binarySize; 170 | } 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /Source/Wrapper/shader.hlsl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | cbuffer Matrices : register(b0) 5 | { 6 | float4x4 worldViewProj; 7 | }; 8 | 9 | Texture2D DiffuseTexture : register(t0); 10 | SamplerState Sampler : register(s0); 11 | 12 | struct VS_IN 13 | { 14 | float4 pos : POSITION; 15 | float4 col : COLOR; 16 | float2 tex : TEXCOORD; 17 | }; 18 | 19 | struct PS_IN 20 | { 21 | float4 pos : SV_POSITION; 22 | float4 col : COLOR; 23 | float2 tex : TEXCOORD; 24 | }; 25 | 26 | PS_IN VS(VS_IN input) 27 | { 28 | PS_IN output = (PS_IN)0; 29 | 30 | output.pos = mul(input.pos, worldViewProj); 31 | output.col = input.col; 32 | output.tex = input.tex; 33 | 34 | return output; 35 | } 36 | 37 | float4 PS(PS_IN input) : SV_Target 38 | { 39 | return DiffuseTexture.Sample(Sampler, input.tex); 40 | } -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | variables: 2 | configuration: Release 3 | platform: x64 4 | 5 | resources: 6 | - repo: self 7 | fetchDepth: 5 8 | 9 | stages: 10 | - stage: ClangFormat 11 | jobs: 12 | - job: ClangFormat 13 | pool: 14 | vmImage: Ubuntu-18.04 15 | 16 | variables: 17 | CC: gcc 18 | CXX: g++ 19 | 20 | steps: 21 | - bash: | 22 | sudo add-apt-repository ppa:ubuntu-toolchain-r/test 23 | sudo apt-get update 24 | sudo apt-get install clang-format-9 ninja-build python3 25 | displayName: 'Install' 26 | - task: PythonScript@0 27 | displayName: 'Build' 28 | inputs: 29 | scriptPath: BuildAll.py 30 | arguments: 'ninja gcc linux clangformat' 31 | - script: | 32 | git diff --exit-code $(Build.SourceVersion) 33 | failOnStderr: true 34 | displayName: 'Clang-Format' 35 | 36 | - stage: Build 37 | condition: succeeded('ClangFormat') 38 | jobs: 39 | - job: Windows_vc140_x64 40 | pool: 41 | vmImage: VS2017-Win2016 42 | 43 | variables: 44 | compiler: vc140 45 | combination: 'win-$(compiler)-$(platform)-$(configuration)' 46 | buildFolder: 'Build/ninja-$(combination)' 47 | installCommand: 'choco install ninja python3' 48 | testCommand: './$(buildFolder)/Bin/ShaderConductorTest.exe' 49 | artifactBinaries: | 50 | Bin/ShaderConductor.dll 51 | Bin/ShaderConductorCmd.exe 52 | Bin/dxcompiler.dll 53 | Lib/ShaderConductor.lib 54 | 55 | steps: 56 | - template: CI/AzurePipelines/ContinuousBuild.yml 57 | 58 | - job: Windows_vc141_x86 59 | pool: 60 | vmImage: VS2017-Win2016 61 | 62 | variables: 63 | compiler: vc141 64 | platform: x86 65 | combination: 'win-$(compiler)-$(platform)-$(configuration)' 66 | buildFolder: 'Build/ninja-$(combination)' 67 | installCommand: 'choco install ninja python3' 68 | testCommand: './$(buildFolder)/Bin/ShaderConductorTest.exe' 69 | artifactBinaries: | 70 | Bin/ShaderConductor.dll 71 | Bin/ShaderConductorCmd.exe 72 | Bin/dxcompiler.dll 73 | Lib/ShaderConductor.lib 74 | 75 | steps: 76 | - template: CI/AzurePipelines/ContinuousBuild.yml 77 | 78 | - job: Windows_vc141_x64 79 | pool: 80 | vmImage: VS2017-Win2016 81 | 82 | variables: 83 | compiler: vc141 84 | combination: 'win-$(compiler)-$(platform)-$(configuration)' 85 | buildFolder: 'Build/ninja-$(combination)' 86 | installCommand: 'choco install ninja python3' 87 | testCommand: './$(buildFolder)/Bin/ShaderConductorTest.exe' 88 | artifactBinaries: | 89 | Bin/ShaderConductor.dll 90 | Bin/ShaderConductorCmd.exe 91 | Bin/dxcompiler.dll 92 | Lib/ShaderConductor.lib 93 | 94 | steps: 95 | - template: CI/AzurePipelines/ContinuousBuild.yml 96 | 97 | - job: Windows_vc142_x86 98 | pool: 99 | vmImage: windows-2019 100 | 101 | variables: 102 | compiler: vc142 103 | platform: x86 104 | combination: 'win-$(compiler)-$(platform)-$(configuration)' 105 | buildFolder: 'Build/ninja-$(combination)' 106 | installCommand: 'choco install ninja' 107 | testCommand: './$(buildFolder)/Bin/ShaderConductorTest.exe' 108 | artifactBinaries: | 109 | Bin/ShaderConductor.dll 110 | Bin/ShaderConductorCmd.exe 111 | Bin/dxcompiler.dll 112 | Lib/ShaderConductor.lib 113 | 114 | steps: 115 | - template: CI/AzurePipelines/ContinuousBuild.yml 116 | 117 | - job: Windows_vc142_x64 118 | pool: 119 | vmImage: windows-2019 120 | 121 | variables: 122 | compiler: vc142 123 | combination: 'win-$(compiler)-$(platform)-$(configuration)' 124 | buildFolder: 'Build/ninja-$(combination)' 125 | installCommand: 'choco install ninja' 126 | testCommand: './$(buildFolder)/Bin/ShaderConductorTest.exe' 127 | artifactBinaries: | 128 | Bin/ShaderConductor.dll 129 | Bin/ShaderConductorCmd.exe 130 | Bin/dxcompiler.dll 131 | Lib/ShaderConductor.lib 132 | 133 | steps: 134 | - template: CI/AzurePipelines/ContinuousBuild.yml 135 | 136 | - job: Windows_vc142_arm64 137 | pool: 138 | vmImage: windows-2019 139 | 140 | variables: 141 | compiler: vc142 142 | platform: arm64 143 | combination: 'win-$(compiler)-$(platform)-$(configuration)' 144 | buildFolder: 'Build/ninja-$(combination)' 145 | installCommand: 'choco install ninja' 146 | testCommand: '' 147 | artifactBinaries: | 148 | Bin/ShaderConductor.dll 149 | Bin/ShaderConductorCmd.exe 150 | Bin/dxcompiler.dll 151 | Lib/ShaderConductor.lib 152 | 153 | steps: 154 | - template: CI/AzurePipelines/ContinuousBuild.yml 155 | 156 | - job: Linux_gcc7 157 | pool: 158 | vmImage: Ubuntu-18.04 159 | 160 | variables: 161 | compiler: gcc7 162 | combination: 'linux-$(compiler)-$(platform)-$(configuration)' 163 | buildFolder: 'Build/ninja-$(combination)' 164 | installCommand: | 165 | sudo add-apt-repository ppa:ubuntu-toolchain-r/test 166 | sudo apt-get update 167 | sudo apt-get install g++-7 ninja-build python3 168 | testCommand: './$(buildFolder)/Bin/ShaderConductorTest' 169 | artifactBinaries: | 170 | Bin/ShaderConductorCmd 171 | Lib/libdxcompiler.so 172 | Lib/libShaderConductor.so 173 | CC: gcc-7 174 | CXX: g++-7 175 | 176 | steps: 177 | - template: CI/AzurePipelines/ContinuousBuild.yml 178 | 179 | - job: Linux_gcc8 180 | pool: 181 | vmImage: Ubuntu-18.04 182 | 183 | variables: 184 | compiler: gcc8 185 | combination: 'linux-$(compiler)-$(platform)-$(configuration)' 186 | buildFolder: 'Build/ninja-$(combination)' 187 | installCommand: | 188 | sudo add-apt-repository ppa:ubuntu-toolchain-r/test 189 | sudo apt-get update 190 | sudo apt-get install g++-8 ninja-build python3 191 | testCommand: './$(buildFolder)/Bin/ShaderConductorTest' 192 | artifactBinaries: | 193 | Bin/ShaderConductorCmd 194 | Lib/libdxcompiler.so 195 | Lib/libShaderConductor.so 196 | CC: gcc-8 197 | CXX: g++-8 198 | 199 | steps: 200 | - template: CI/AzurePipelines/ContinuousBuild.yml 201 | 202 | - job: Linux_clang7 203 | pool: 204 | vmImage: Ubuntu-18.04 205 | 206 | variables: 207 | compiler: clang7 208 | combination: 'linux-$(compiler)-$(platform)-$(configuration)' 209 | buildFolder: 'Build/ninja-$(combination)' 210 | installCommand: | 211 | wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - 212 | sudo add-apt-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main" 213 | sudo add-apt-repository ppa:ubuntu-toolchain-r/test 214 | sudo apt-get update 215 | sudo apt-get install clang-7 libc++-7-dev libc++abi-7-dev lld-7 ninja-build python3 216 | testCommand: './$(buildFolder)/Bin/ShaderConductorTest' 217 | artifactBinaries: | 218 | Bin/ShaderConductorCmd 219 | Lib/libdxcompiler.so 220 | Lib/libShaderConductor.so 221 | CC: clang-7 222 | CXX: clang++-7 223 | 224 | steps: 225 | - template: CI/AzurePipelines/ContinuousBuild.yml 226 | 227 | - job: Linux_clang8 228 | pool: 229 | vmImage: Ubuntu-18.04 230 | 231 | variables: 232 | compiler: clang8 233 | combination: 'linux-$(compiler)-$(platform)-$(configuration)' 234 | buildFolder: 'Build/ninja-$(combination)' 235 | installCommand: | 236 | wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - 237 | sudo add-apt-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main" 238 | sudo add-apt-repository ppa:ubuntu-toolchain-r/test 239 | sudo apt-get update 240 | sudo apt-get install clang-8 libc++-8-dev libc++abi-8-dev lld-8 ninja-build python3 241 | testCommand: './$(buildFolder)/Bin/ShaderConductorTest' 242 | artifactBinaries: | 243 | Bin/ShaderConductorCmd 244 | Lib/libdxcompiler.so 245 | Lib/libShaderConductor.so 246 | CC: clang-8 247 | CXX: clang++-8 248 | 249 | steps: 250 | - template: CI/AzurePipelines/ContinuousBuild.yml 251 | 252 | - job: macOS_10_clang 253 | pool: 254 | vmImage: macOS 10.14 255 | 256 | variables: 257 | compiler: clang9 258 | combination: 'osx-$(compiler)-$(platform)-$(configuration)' 259 | buildFolder: 'Build/ninja-$(combination)' 260 | installCommand: | 261 | brew update 262 | brew install ninja 263 | testCommand: './$(buildFolder)/Bin/ShaderConductorTest' 264 | artifactBinaries: | 265 | Bin/ShaderConductorCmd 266 | Lib/libdxcompiler.dylib 267 | Lib/libShaderConductor.dylib 268 | CC: clang 269 | CXX: clang++ 270 | 271 | steps: 272 | - template: CI/AzurePipelines/ContinuousBuild.yml 273 | --------------------------------------------------------------------------------