[
  {
    "path": ".clang-format",
    "content": "AccessModifierOffset: -4\nAllowShortFunctionsOnASingleLine: None\nAllowShortIfStatementsOnASingleLine: false\nAllowShortLoopsOnASingleLine: false\nAlwaysBreakTemplateDeclarations: true\nBreakBeforeBraces: Allman\nColumnLimit: 140\nCpp11BracedListStyle: true\nIndentWidth: 4\nLanguage: Cpp\nMaxEmptyLinesToKeep: 2\nNamespaceIndentation: All\nPointerAlignment: Left\nSpaceBeforeParens: ControlStatements\nStandard: Cpp11\nTabWidth: 4\nUseTab: Never\n"
  },
  {
    "path": ".gitattributes",
    "content": "* text=auto\n*.hpp text\n*.cpp text\n*.hlsl text\n*.glsl text\n*.msl text\n*.dxil binary\n*.spv binary\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/bug_report.md",
    "content": "---\nname: Bug report\nabout: Create a report to help us improve\n\n---\n\n**Describe the bug**\nA clear and concise description of what the bug is.\n\n**To Reproduce**\nSteps to reproduce the behavior:\n1. Your input shader\n2. Full parameters\n\n**Expected behavior**\nA clear and concise description of what you expected to happen.\n\n**Additional context**\nAdd any other context about the problem here.\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/feature_request.md",
    "content": "---\nname: Feature request\nabout: Suggest an idea for this project\n\n---\n\n**Is your feature request related to a problem? Please describe.**\nA clear and concise description of what the problem is. Ex. I'm always frustrated when [...]\n\n**Describe the solution you'd like**\nA clear and concise description of what you want to happen.\n\n**Describe alternatives you've considered**\nA clear and concise description of any alternative solutions or features you've considered.\n\n**Additional context**\nAdd any other context or screenshots about the feature request here.\n"
  },
  {
    "path": ".gitignore",
    "content": "## Ignore Visual Studio temporary files, build results, and\n## files generated by popular Visual Studio add-ons.\n##\n## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore\n\n# User-specific files\n*.suo\n*.user\n*.userosscache\n*.sln.docstates\n\n# User-specific files (MonoDevelop/Xamarin Studio)\n*.userprefs\n\n# Build results\n[Dd]ebug/\n[Dd]ebugPublic/\n[Rr]elease/\n[Rr]eleases/\nx64/\nx86/\nbld/\n[Bb]in/\n[Oo]bj/\n[Ll]og/\n\n# Visual Studio 2015/2017 cache/options directory\n.vs/\n# Uncomment if you have tasks that create the project's static files in wwwroot\n#wwwroot/\n\n# Visual Studio 2017 auto generated files\nGenerated\\ Files/\n\n# MSTest test Results\n[Tt]est[Rr]esult*/\n[Bb]uild[Ll]og.*\n\n# NUNIT\n*.VisualState.xml\nTestResult.xml\n\n# Build Results of an ATL Project\n[Dd]ebugPS/\n[Rr]eleasePS/\ndlldata.c\n\n# Benchmark Results\nBenchmarkDotNet.Artifacts/\n\n# .NET Core\nproject.lock.json\nproject.fragment.lock.json\nartifacts/\n**/Properties/launchSettings.json\n\n# StyleCop\nStyleCopReport.xml\n\n# Files built by Visual Studio\n*_i.c\n*_p.c\n*_i.h\n*.ilk\n*.meta\n*.obj\n*.iobj\n*.pch\n*.pdb\n*.ipdb\n*.pgc\n*.pgd\n*.rsp\n*.sbr\n*.tlb\n*.tli\n*.tlh\n*.tmp\n*.tmp_proj\n*.log\n*.vspscc\n*.vssscc\n.builds\n*.pidb\n*.svclog\n*.scc\n\n# Chutzpah Test files\n_Chutzpah*\n\n# Visual C++ cache files\nipch/\n*.aps\n*.ncb\n*.opendb\n*.opensdf\n*.sdf\n*.cachefile\n*.VC.db\n*.VC.VC.opendb\n\n# Visual Studio profiler\n*.psess\n*.vsp\n*.vspx\n*.sap\n\n# Visual Studio Trace Files\n*.e2e\n\n# TFS 2012 Local Workspace\n$tf/\n\n# Guidance Automation Toolkit\n*.gpState\n\n# ReSharper is a .NET coding add-in\n_ReSharper*/\n*.[Rr]e[Ss]harper\n*.DotSettings.user\n\n# JustCode is a .NET coding add-in\n.JustCode\n\n# TeamCity is a build add-in\n_TeamCity*\n\n# DotCover is a Code Coverage Tool\n*.dotCover\n\n# AxoCover is a Code Coverage Tool\n.axoCover/*\n!.axoCover/settings.json\n\n# Visual Studio code coverage results\n*.coverage\n*.coveragexml\n\n# NCrunch\n_NCrunch_*\n.*crunch*.local.xml\nnCrunchTemp_*\n\n# MightyMoose\n*.mm.*\nAutoTest.Net/\n\n# Web workbench (sass)\n.sass-cache/\n\n# Installshield output folder\n[Ee]xpress/\n\n# DocProject is a documentation generator add-in\nDocProject/buildhelp/\nDocProject/Help/*.HxT\nDocProject/Help/*.HxC\nDocProject/Help/*.hhc\nDocProject/Help/*.hhk\nDocProject/Help/*.hhp\nDocProject/Help/Html2\nDocProject/Help/html\n\n# Click-Once directory\npublish/\n\n# Publish Web Output\n*.[Pp]ublish.xml\n*.azurePubxml\n# Note: Comment the next line if you want to checkin your web deploy settings,\n# but database connection strings (with potential passwords) will be unencrypted\n*.pubxml\n*.publishproj\n\n# Microsoft Azure Web App publish settings. Comment the next line if you want to\n# checkin your Azure Web App publish settings, but sensitive information contained\n# in these scripts will be unencrypted\nPublishScripts/\n\n# NuGet Packages\n*.nupkg\n# The packages folder can be ignored because of Package Restore\n**/[Pp]ackages/*\n# except build/, which is used as an MSBuild target.\n!**/[Pp]ackages/build/\n# Uncomment if necessary however generally it will be regenerated when needed\n#!**/[Pp]ackages/repositories.config\n# NuGet v3's project.json files produces more ignorable files\n*.nuget.props\n*.nuget.targets\n\n# Microsoft Azure Build Output\ncsx/\n*.build.csdef\n\n# Microsoft Azure Emulator\necf/\nrcf/\n\n# Windows Store app package directories and files\nAppPackages/\nBundleArtifacts/\nPackage.StoreAssociation.xml\n_pkginfo.txt\n*.appx\n\n# Visual Studio cache files\n# files ending in .cache can be ignored\n*.[Cc]ache\n# but keep track of directories ending in .cache\n!*.[Cc]ache/\n\n# Others\nClientBin/\n~$*\n*~\n*.dbmdl\n*.dbproj.schemaview\n*.jfm\n*.pfx\n*.publishsettings\norleans.codegen.cs\n\n# Including strong name files can present a security risk \n# (https://github.com/github/gitignore/pull/2483#issue-259490424)\n#*.snk\n\n# Since there are multiple workflows, uncomment next line to ignore bower_components\n# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)\n#bower_components/\n\n# RIA/Silverlight projects\nGenerated_Code/\n\n# Backup & report files from converting an old project file\n# to a newer Visual Studio version. Backup files are not needed,\n# because we have git ;-)\n_UpgradeReport_Files/\nBackup*/\nUpgradeLog*.XML\nUpgradeLog*.htm\nServiceFabricBackup/\n*.rptproj.bak\n\n# SQL Server files\n*.mdf\n*.ldf\n*.ndf\n\n# Business Intelligence projects\n*.rdl.data\n*.bim.layout\n*.bim_*.settings\n*.rptproj.rsuser\n\n# Microsoft Fakes\nFakesAssemblies/\n\n# GhostDoc plugin setting file\n*.GhostDoc.xml\n\n# Node.js Tools for Visual Studio\n.ntvs_analysis.dat\nnode_modules/\n\n# Visual Studio 6 build log\n*.plg\n\n# Visual Studio 6 workspace options file\n*.opt\n\n# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)\n*.vbw\n\n# Visual Studio LightSwitch build output\n**/*.HTMLClient/GeneratedArtifacts\n**/*.DesktopClient/GeneratedArtifacts\n**/*.DesktopClient/ModelManifest.xml\n**/*.Server/GeneratedArtifacts\n**/*.Server/ModelManifest.xml\n_Pvt_Extensions\n\n# Paket dependency manager\n.paket/paket.exe\npaket-files/\n\n# FAKE - F# Make\n.fake/\n\n# JetBrains Rider\n.idea/\n*.sln.iml\n\n# CodeRush\n.cr/\n\n# Python Tools for Visual Studio (PTVS)\n__pycache__/\n*.pyc\n\n# Cake - Uncomment if you are using it\n# tools/**\n# !tools/packages.config\n\n# Tabs Studio\n*.tss\n\n# Telerik's JustMock configuration file\n*.jmconfig\n\n# BizTalk build output\n*.btp.cs\n*.btm.cs\n*.odx.cs\n*.xsd.cs\n\n# OpenCover UI analysis results\nOpenCover/\n\n# Azure Stream Analytics local run output \nASALocalRun/\n\n# MSBuild Binary and Structured Log\n*.binlog\n\n# NVidia Nsight GPU debugger configuration file\n*.nvuser\n\n# MFractors (Xamarin productivity tool) working folder \n.mfractor/\n\n#\n/External/\n/Build/\n"
  },
  {
    "path": "BuildAll.py",
    "content": "#!/usr/bin/env python\n#-*- coding: ascii -*-\n\n# ShaderConductor\n# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the MIT License.\n\nimport multiprocessing, os, platform, subprocess, sys\n\ndef LogError(message):\n\tprint(\"[E] %s\" % message)\n\tsys.stdout.flush()\n\tif 0 == sys.platform.find(\"win\"):\n\t\tpauseCmd = \"pause\"\n\telse:\n\t\tpauseCmd = \"read\"\n\tsubprocess.call(pauseCmd, shell = True)\n\tsys.exit(1)\n\ndef LogInfo(message):\n\tprint(\"[I] %s\" % message)\n\tsys.stdout.flush()\n\ndef LogWarning(message):\n\tprint(\"[W] %s\" % message)\n\tsys.stdout.flush()\n\ndef FindProgramFilesFolder():\n\tenv = os.environ\n\tif \"64bit\" == platform.architecture()[0]:\n\t\tif \"ProgramFiles(x86)\" in env:\n\t\t\tprogramFilesFolder = env[\"ProgramFiles(x86)\"]\n\t\telse:\n\t\t\tprogramFilesFolder = \"C:\\Program Files (x86)\"\n\telse:\n\t\tif \"ProgramFiles\" in env:\n\t\t\tprogramFilesFolder = env[\"ProgramFiles\"]\n\t\telse:\n\t\t\tprogramFilesFolder = \"C:\\Program Files\"\n\treturn programFilesFolder\n\ndef FindVS2017OrUpFolder(programFilesFolder, vsVersion, vsName):\n\ttryVswhereLocation = programFilesFolder + \"\\\\Microsoft Visual Studio\\\\Installer\\\\vswhere.exe\"\n\tif os.path.exists(tryVswhereLocation):\n\t\tvsLocation = subprocess.check_output([tryVswhereLocation,\n\t\t\t\"-latest\",\n\t\t\t\"-requires\", \"Microsoft.VisualStudio.Component.VC.Tools.x86.x64\",\n\t\t\t\"-property\", \"installationPath\",\n\t\t\t\"-version\", \"[%d.0,%d.0)\" % (vsVersion, vsVersion + 1),\n\t\t\t\"-prerelease\"]).decode().split(\"\\r\\n\")[0]\n\t\ttryFolder = vsLocation + \"\\\\VC\\\\Auxiliary\\\\Build\\\\\"\n\t\ttryVcvarsall = \"VCVARSALL.BAT\"\n\t\tif os.path.exists(tryFolder + tryVcvarsall):\n\t\t\treturn tryFolder\n\telse:\n\t\tnames = (\"Preview\", vsName)\n\t\tskus = (\"Community\", \"Professional\", \"Enterprise\")\n\t\tfor name in names:\n\t\t\tfor sku in skus:\n\t\t\t\ttryFolder = programFilesFolder + \"\\\\Microsoft Visual Studio\\\\%s\\\\%s\\\\VC\\\\Auxiliary\\\\Build\\\\\" % (name, sku)\n\t\t\t\ttryVcvarsall = \"VCVARSALL.BAT\"\n\t\t\t\tif os.path.exists(tryFolder + tryVcvarsall):\n\t\t\t\t\treturn tryFolder\n\tLogError(\"Could NOT find VS%s.\\n\" % vsName)\n\treturn \"\"\n\ndef FindVS2019Folder(programFilesFolder):\n\treturn FindVS2017OrUpFolder(programFilesFolder, 16, \"2019\")\n\ndef FindVS2017Folder(programFilesFolder):\n\treturn FindVS2017OrUpFolder(programFilesFolder, 15, \"2017\")\n\ndef FindVS2015Folder(programFilesFolder):\n\tenv = os.environ\n\tif \"VS140COMNTOOLS\" in env:\n\t\treturn env[\"VS140COMNTOOLS\"] + \"..\\\\..\\\\VC\\\\\"\n\telse:\n\t\ttryFolder = programFilesFolder + \"\\\\Microsoft Visual Studio 14.0\\\\VC\\\\\"\n\t\ttryVcvarsall = \"VCVARSALL.BAT\"\n\t\tif os.path.exists(tryFolder + tryVcvarsall):\n\t\t\treturn tryFolder\n\t\telse:\n\t\t\tLogError(\"Could NOT find VS2015.\\n\")\n\nclass BatchCommand:\n\tdef __init__(self, hostPlatform):\n\t\tself.commands = []\n\t\tself.hostPlatform = hostPlatform\n\n\tdef AddCommand(self, cmd):\n\t\tself.commands += [cmd]\n\n\tdef Execute(self):\n\t\tbatchFileName = \"scBuild.\"\n\t\tif \"win\" == self.hostPlatform:\n\t\t\tbatchFileName += \"bat\"\n\t\telse:\n\t\t\tbatchFileName += \"sh\"\n\t\tbatchFile = open(batchFileName, \"w\")\n\t\tbatchFile.writelines([cmd_line + \"\\n\" for cmd_line in self.commands])\n\t\tbatchFile.close()\n\t\tif \"win\" == self.hostPlatform:\n\t\t\tretCode = subprocess.call(batchFileName, shell = True)\n\t\telse:\n\t\t\tsubprocess.call(\"chmod 777 \" + batchFileName, shell = True)\n\t\t\tretCode = subprocess.call(\"./\" + batchFileName, shell = True)\n\t\tos.remove(batchFileName)\n\t\treturn retCode\n\ndef Build(hostPlatform, hostArch, buildSys, compiler, arch, configuration, tblgenMode, tblgenPath):\n\toriginalDir = os.path.abspath(os.curdir)\n\n\tif not os.path.exists(\"Build\"):\n\t\tos.mkdir(\"Build\")\n\n\tmultiConfig = (buildSys.find(\"vs\") == 0)\n\n\tbuildDir = \"Build/%s-%s-%s-%s\" % (buildSys, hostPlatform, compiler, arch)\n\tif (not multiConfig) or (configuration == \"clangformat\"):\n\t\tbuildDir += \"-%s\" % configuration;\n\tif not os.path.exists(buildDir):\n\t\tos.mkdir(buildDir)\n\tos.chdir(buildDir)\n\tbuildDir = os.path.abspath(os.curdir)\n\n\ttblgenOptions = \"\"\n\tif (tblgenPath != None):\n\t\ttblgenOptions = \" -DCLANG_TABLEGEN=\\\"%s\\\" -DLLVM_TABLEGEN=\\\"%s\\\"\" % tblgenPath\n\n\tparallel = multiprocessing.cpu_count()\n\n\tbatCmd = BatchCommand(hostPlatform)\n\tif hostPlatform == \"win\":\n\t\tprogramFilesFolder = FindProgramFilesFolder()\n\t\tif (buildSys == \"vs2019\") or ((buildSys == \"ninja\") and (compiler == \"vc142\")):\n\t\t\tvsFolder = FindVS2019Folder(programFilesFolder)\n\t\telif (buildSys == \"vs2017\") or ((buildSys == \"ninja\") and (compiler == \"vc141\")):\n\t\t\tvsFolder = FindVS2017Folder(programFilesFolder)\n\t\telif (buildSys == \"vs2015\") or ((buildSys == \"ninja\") and (compiler == \"vc140\")):\n\t\t\tvsFolder = FindVS2015Folder(programFilesFolder)\n\t\tif \"x64\" == arch:\n\t\t\tvcOption = \"amd64\"\n\t\t\tvcArch = \"x64\"\n\t\telif \"x86\" == arch:\n\t\t\tvcOption = \"x86\"\n\t\t\tvcArch = \"Win32\"\n\t\telif \"arm64\" == arch:\n\t\t\tvcOption = \"amd64_arm64\"\n\t\t\tvcArch = \"ARM64\"\n\t\telif \"arm\" == arch:\n\t\t\tvcOption = \"amd64_arm\"\n\t\t\tvcArch = \"ARM\"\n\t\telse:\n\t\t\tLogError(\"Unsupported architecture.\\n\")\n\t\tvcToolset = \"\"\n\t\tif (buildSys == \"vs2019\") and (compiler == \"vc141\"):\n\t\t\tvcOption += \" -vcvars_ver=14.1\"\n\t\t\tvcToolset = \"v141,\"\n\t\telif ((buildSys == \"vs2019\") or (buildSys == \"vs2017\")) and (compiler == \"vc140\"):\n\t\t\tvcOption += \" -vcvars_ver=14.0\"\n\t\t\tvcToolset = \"v140,\"\n\t\tbatCmd.AddCommand(\"@call \\\"%sVCVARSALL.BAT\\\" %s\" % (vsFolder, vcOption))\n\t\tbatCmd.AddCommand(\"@cd /d \\\"%s\\\"\" % buildDir)\n\tif (buildSys == \"ninja\"):\n\t\tif hostPlatform == \"win\":\n\t\t\tbatCmd.AddCommand(\"set CC=cl.exe\")\n\t\t\tbatCmd.AddCommand(\"set CXX=cl.exe\")\n\t\tif (configuration == \"clangformat\"):\n\t\t\toptions = \"-DSC_CLANGFORMAT=\\\"ON\\\"\"\n\t\telse:\n\t\t\toptions = \"-DCMAKE_BUILD_TYPE=\\\"%s\\\" -DSC_ARCH_NAME=\\\"%s\\\" %s\" % (configuration, arch, tblgenOptions)\n\t\tbatCmd.AddCommand(\"cmake -G Ninja %s ../../\" % options)\n\t\tif tblgenMode:\n\t\t\tbatCmd.AddCommand(\"ninja clang-tblgen -j%d\" % parallel)\n\t\t\tbatCmd.AddCommand(\"ninja llvm-tblgen -j%d\" % parallel)\n\t\telse:\n\t\t\tbatCmd.AddCommand(\"ninja -j%d\" % parallel)\n\telse:\n\t\tif buildSys == \"vs2019\":\n\t\t\tgenerator = \"\\\"Visual Studio 16\\\"\"\n\t\telif buildSys == \"vs2017\":\n\t\t\tgenerator = \"\\\"Visual Studio 15\\\"\"\n\t\telif buildSys == \"vs2015\":\n\t\t\tgenerator = \"\\\"Visual Studio 14\\\"\"\n\t\tif (configuration == \"clangformat\"):\n\t\t\tcmake_options = \"-DSC_CLANGFORMAT=\\\"ON\\\"\"\n\t\t\tmsbuild_options = \"\"\n\t\telse:\n\t\t\tcmake_options = \"-T %shost=x64 -A %s %s\" % (vcToolset, vcArch, tblgenOptions)\n\t\t\tmsbuild_options = \"/m:%d /v:m /p:Configuration=%s,Platform=%s\" % (parallel, configuration, vcArch)\n\t\tbatCmd.AddCommand(\"cmake -G %s %s ../../\" % (generator, cmake_options))\n\t\tif tblgenMode:\n\t\t\tbatCmd.AddCommand(\"MSBuild External\\\\DirectXShaderCompiler\\\\tools\\\\clang\\\\utils\\\\TableGen\\\\clang-tblgen.vcxproj /nologo %s\" % msbuild_options)\n\t\t\tbatCmd.AddCommand(\"MSBuild External\\\\DirectXShaderCompiler\\\\utils\\\\TableGen\\\\llvm-tblgen.vcxproj /nologo %s\" % msbuild_options)\n\t\telse:\n\t\t\tbatCmd.AddCommand(\"MSBuild ALL_BUILD.vcxproj /nologo %s\" % msbuild_options)\n\tif batCmd.Execute() != 0:\n\t\tLogError(\"Build failed.\\n\")\n\n\tos.chdir(originalDir)\n\n\ttblGenPath = buildDir + \"/External/DirectXShaderCompiler\"\n\tif multiConfig:\n\t\ttblGenPath += \"/\" + configuration\n\ttblGenPath += \"/bin/\"\n\tclangTblgenPath = tblGenPath + \"clang-tblgen\"\n\tllvmTblGenPath = tblGenPath + \"llvm-tblgen\"\n\tif (hostPlatform == \"win\"):\n\t\tclangTblgenPath += \".exe\"\n\t\tllvmTblGenPath += \".exe\"\n\treturn (clangTblgenPath, llvmTblGenPath)\n\nif __name__ == \"__main__\":\n\thostPlatform = sys.platform\n\tif 0 == hostPlatform.find(\"win\"):\n\t\thostPlatform = \"win\"\n\telif 0 == hostPlatform.find(\"linux\"):\n\t\thostPlatform = \"linux\"\n\telif 0 == hostPlatform.find(\"darwin\"):\n\t\thostPlatform = \"osx\"\n\n\thostArch = platform.machine()\n\tif (hostArch == \"AMD64\") or (hostArch == \"x86_64\"):\n\t\thostArch = \"x64\"\n\telif (hostArch == \"i386\"):\n\t\thostArch = \"x86\"\n\telif (hostArch == \"ARM64\"):\n\t\thostArch = \"arm64\"\n\telse:\n\t\tLogError(\"Unknown host architecture %s.\\n\" % hostArch)\n\n\targc = len(sys.argv);\n\tif (argc > 1):\n\t\tbuildSys = sys.argv[1]\n\telse:\n\t\tif hostPlatform == \"win\":\n\t\t\tbuildSys = \"vs2019\"\n\t\telse:\n\t\t\tbuildSys = \"ninja\"\n\tif (argc > 2):\n\t\tcompiler = sys.argv[2]\n\telse:\n\t\tif buildSys == \"vs2019\":\n\t\t\tcompiler = \"vc142\"\n\t\telif buildSys == \"vs2017\":\n\t\t\tcompiler = \"vc141\"\n\t\telif buildSys == \"vs2015\":\n\t\t\tcompiler = \"vc140\"\n\t\telse:\n\t\t\tcompiler = \"gcc\"\n\tif (argc > 3):\n\t\tarch = sys.argv[3]\n\telse:\n\t\tarch = \"x64\"\n\tif (argc > 4):\n\t\tconfiguration = sys.argv[4]\n\telse:\n\t\tconfiguration = \"Release\"\n\n\ttblgenPath = None\n\tif (configuration != \"clangformat\") and (hostArch != arch) and (not ((hostArch == \"x64\") and (arch == \"x86\"))):\n\t\t# Cross compiling:\n\t\t# Generate a project with host architecture, build clang-tblgen and llvm-tblgen, and keep the path of clang-tblgen and llvm-tblgen\n\t\ttblgenPath = Build(hostPlatform, hostArch, buildSys, compiler, hostArch, configuration, True, None)\n\n\tBuild(hostPlatform, hostArch, buildSys, compiler, arch, configuration, False, tblgenPath)\n"
  },
  {
    "path": "CI/AzurePipelines/ContinuousBuild.yml",
    "content": "steps:\n- bash: eval '$(installCommand)'\n  displayName: 'Install'\n\n- script: |\n    git config --global user.email \"dummy@example.com\"\n    git config --global user.name \"Dummy Name\"\n  displayName: 'Config git'\n\n- task: PythonScript@0\n  displayName: 'Build'\n  inputs:\n    scriptPath: BuildAll.py\n    arguments: 'ninja $(compiler) $(platform) $(configuration)'\n\n- bash: eval '$(testCommand)'\n  displayName: 'Test'\n  condition: not(eq('$(testCommand)', ''))\n\n- bash: 'echo $BUILD_SOURCEVERSION > $BUILD_ARTIFACTSTAGINGDIRECTORY/GIT-COMMIT.txt'\n  displayName: 'Add commit info'\n\n- task: CopyFiles@2\n  displayName: 'Copy Headers'\n  inputs:\n    SourceFolder: '$(Build.SourcesDirectory)'\n    Contents: Include/ShaderConductor/ShaderConductor.hpp\n    TargetFolder: '$(Build.ArtifactStagingDirectory)'\n\n- task: CopyFiles@2\n  displayName: 'Copy Binaries'\n  inputs:\n    SourceFolder: '$(Build.SourcesDirectory)/$(buildFolder)'\n    Contents: $(artifactBinaries)\n    TargetFolder: '$(Build.ArtifactStagingDirectory)'\n\n- task: PublishBuildArtifacts@1\n  inputs:\n    pathtoPublish: '$(Build.ArtifactStagingDirectory)'\n    artifactName: ShaderConductor-$(combination)\n"
  },
  {
    "path": "CMakeLists.txt",
    "content": "# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the MIT License.\n\ncmake_minimum_required(VERSION 3.9)\n\nif(WIN32 AND (${CMAKE_GENERATOR} MATCHES \"Visual Studio ([^9]|[9][0-9])\") AND (NOT SC_CLANGFORMAT))\n    set(SC_WITH_CSHARP ON)\nelse()\n    set(SC_WITH_CSHARP OFF)\nendif()\n\nset(PROJECT_NAME ShaderConductor)\nproject(${PROJECT_NAME})\nif(SC_WITH_CSHARP)\n    project(${PROJECT_NAME} LANGUAGES CSharp)\n    set(CMAKE_CSharp_FLAGS \"/langversion:7\")\nendif()\n\nset(SC_MAJOR_VERSION 0)\nset(SC_MINOR_VERSION 3)\nset(SC_PATCH_VERSION 0)\nset(SC_VERSION ${SC_MAJOR_VERSION}.${SC_MINOR_VERSION}.${SC_PATCH_VERSION})\n\nset(SC_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})\nset(SC_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})\nmark_as_advanced(SC_ROOT_DIR)\n\nset_property(GLOBAL PROPERTY USE_FOLDERS ON)\n\nset(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${SC_BUILD_DIR}/Bin)\nset(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${SC_BUILD_DIR}/Lib)\nset(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${SC_BUILD_DIR}/Lib)\n\nif((CMAKE_C_COMPILER_ID MATCHES GNU) OR (CMAKE_C_COMPILER_ID MATCHES Clang))\n    set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -std=c++1z\")\nendif()\nif (CMAKE_C_COMPILER_ID MATCHES Clang)\n    foreach(flagVar\n        CMAKE_C_FLAGS CMAKE_CXX_FLAGS)\n        set(${flagVar} \"${${flagVar}} -fms-extensions -Wno-language-extension-token\")\n    endforeach()\nendif()\n\nset(Python_ADDITIONAL_VERSIONS 3.5 3.6 3.7 3.8)\n\nif(SC_CLANGFORMAT)\n    find_program(CLANG_FORMAT\n        NAMES\n            clang-format-9\n            clang-format\n    )\n\n    if(${CLANG_FORMAT} STREQUAL \"CLANG_FORMAT-NOTFOUND\")\n        message(FATAL_ERROR \"No clang-format tool found\")\n    endif()\n\n    message(STATUS \"Generating clangformat target using ${CLANG_FORMAT}\")\n    file(GLOB_RECURSE ALL_SOURCE_FILES *.cpp *.h *.hpp)\n    add_custom_target(clangformat\n        COMMAND ${CLANG_FORMAT} -i ${ALL_SOURCE_FILES})\n\n    return()\nendif()\n\n# Handle a compiling issue of SPIR-V\nif(${CMAKE_SYSTEM_NAME} MATCHES \"Linux\")\n    set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -fPIC\")\n    if(CMAKE_C_COMPILER_ID MATCHES Clang)\n        set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -stdlib=libc++\")\n    endif()\n\n    foreach(flagVar\n        CMAKE_SHARED_LINKER_FLAGS_RELEASE CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL\n        CMAKE_MODULE_LINKER_FLAGS_RELEASE CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL\n        CMAKE_EXE_LINKER_FLAGS_RELEASE CMAKE_EXE_LINKER_FLAGS_MINSIZEREL)\n        set(${flagVar} \"${${flagVar}} -s\")\n    endforeach()\nendif()\n\nif(WIN32)\n    if(MSVC AND (CMAKE_GENERATOR MATCHES \"^Visual Studio\"))\n        if((CMAKE_GENERATOR_PLATFORM STREQUAL \"x64\") OR (CMAKE_GENERATOR MATCHES \"Win64\"))\n            set(SC_ARCH_NAME \"x64\")\n        elseif((CMAKE_GENERATOR_PLATFORM STREQUAL \"ARM64\") OR (CMAKE_GENERATOR MATCHES \"ARM64\"))\n            set(SC_ARCH_NAME \"arm64\")\n        elseif((CMAKE_GENERATOR_PLATFORM STREQUAL \"ARM\") OR (CMAKE_GENERATOR MATCHES \"ARM\"))\n            set(SC_ARCH_NAME \"arm\")\n        else()\n            set(SC_ARCH_NAME \"x86\")\n        endif()\n    endif()\nelse()\n    if(NOT SC_ARCH_NAME)\n        if((CMAKE_SYSTEM_PROCESSOR MATCHES \"AMD64\") OR (CMAKE_SYSTEM_PROCESSOR MATCHES \"x86_64\"))\n            set(SC_ARCH_NAME \"x64\")\n        else()\n            set(SC_ARCH_NAME \"x86\")\n        endif()\n    endif()\nendif()\n\nadd_subdirectory(Source)\nadd_subdirectory(External)\n\nset_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT \"ShaderConductorCmd\")\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# How to contribute\n\nOne 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.\n\n## General feedback and discussions?\nPlease start a discussion on the repo issue tracker.\n\n## Bugs and feature requests?\nFor non-security related bugs please log a new issue in the GitHub repo.\n\n## Reporting Security Issues\n\nSecurity issues and bugs should be reported privately, via email, to the Microsoft Security\nResponse Center (MSRC) at [secure@microsoft.com](mailto:secure@microsoft.com). You should\nreceive a response within 24 hours. If for some reason you do not, please follow up via\nemail to ensure we received your original message. Further information, including the\n[MSRC PGP](https://technet.microsoft.com/en-us/security/dn606155) key, can be found in\nthe [Security TechCenter](https://technet.microsoft.com/en-us/security/default).\n\n## Filing issues\nWhen filing issues, please use our [bug filing templates](https://github.com/aspnet/Home/wiki/Functional-bug-template).\nThe best way to get your bug fixed is to be as detailed as you can be about the problem.\nProviding a minimal project with steps to reproduce the problem is ideal.\nHere are questions you can answer before you file a bug to make sure you're not missing any important information.\n\n1. Did you read the documentation?\n2. Did you include the snippet of broken code in the issue?\n3. What are the *EXACT* steps to reproduce this problem?\n4. What version are you using?\n\nGitHub supports [markdown](https://help.github.com/articles/github-flavored-markdown/), so when filing bugs make sure you check the formatting before clicking submit.\n\n## Contributing\n\nThis project welcomes contributions and suggestions.  Most contributions require you to agree to a\nContributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us\nthe rights to use your contribution. For details, visit https://cla.microsoft.com.\n\nWhen you submit a pull request, a CLA-bot will automatically determine whether you need to provide\na CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions\nprovided by the bot. You will only need to do this once across all repos using our CLA.\n"
  },
  {
    "path": "Include/ShaderConductor/ShaderConductor.hpp",
    "content": "/*\n * ShaderConductor\n *\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n *\n * MIT License\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this\n * software and associated documentation files (the \"Software\"), to deal in the Software\n * without restriction, including without limitation the rights to use, copy, modify, merge,\n * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons\n * to whom the Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all copies or\n * substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR\n * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE\n * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\n#ifndef SHADER_CONDUCTOR_HPP\n#define SHADER_CONDUCTOR_HPP\n\n#pragma once\n\n#include <functional>\n\n#if defined(__clang__)\n#define SC_SYMBOL_EXPORT __attribute__((__visibility__(\"default\")))\n#define SC_SYMBOL_IMPORT\n#elif defined(__GNUC__)\n#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)\n#define SC_SYMBOL_EXPORT __attribute__((__dllexport__))\n#define SC_SYMBOL_IMPORT __attribute__((__dllimport__))\n#else\n#define SC_SYMBOL_EXPORT __attribute__((__visibility__(\"default\")))\n#define SC_SYMBOL_IMPORT\n#endif\n#elif defined(_MSC_VER)\n#define SC_SYMBOL_EXPORT __declspec(dllexport)\n#define SC_SYMBOL_IMPORT __declspec(dllimport)\n#endif\n\n#ifdef SHADER_CONDUCTOR_SOURCE\n#define SC_API SC_SYMBOL_EXPORT\n#else\n#define SC_API SC_SYMBOL_IMPORT\n#endif\n\nnamespace ShaderConductor\n{\n    enum class ShaderStage : uint32_t\n    {\n        VertexShader,\n        PixelShader,\n        GeometryShader,\n        HullShader,\n        DomainShader,\n        ComputeShader,\n\n        NumShaderStages,\n    };\n\n    enum class ShadingLanguage : uint32_t\n    {\n        Dxil = 0,\n        SpirV,\n\n        Hlsl,\n        Glsl,\n        Essl,\n        Msl_macOS,\n        Msl_iOS,\n\n        NumShadingLanguages,\n    };\n\n    enum class ShaderResourceType : uint32_t\n    {\n        ConstantBuffer,\n        Parameter,\n        Texture,\n        Sampler,\n        ShaderResourceView,\n        UnorderedAccessView,\n\n        NumShaderResourceType,\n    };\n\n    struct MacroDefine\n    {\n        const char* name;\n        const char* value;\n    };\n\n    class SC_API Blob\n    {\n    public:\n        Blob() noexcept;\n        Blob(const void* data, uint32_t size);\n        Blob(const Blob& other);\n        Blob(Blob&& other) noexcept;\n        ~Blob() noexcept;\n\n        Blob& operator=(const Blob& other);\n        Blob& operator=(Blob&& other) noexcept;\n\n        void Reset();\n        void Reset(const void* data, uint32_t size);\n\n        const void* Data() const noexcept;\n        uint32_t Size() const noexcept;\n\n    private:\n        class BlobImpl;\n        BlobImpl* m_impl = nullptr;\n    };\n\n    class SC_API Compiler\n    {\n    public:\n        struct ShaderModel\n        {\n            uint8_t major_ver : 6;\n            uint8_t minor_ver : 2;\n\n            uint32_t FullVersion() const noexcept\n            {\n                return (major_ver << 2) | minor_ver;\n            }\n\n            bool operator<(const ShaderModel& other) const noexcept\n            {\n                return this->FullVersion() < other.FullVersion();\n            }\n            bool operator==(const ShaderModel& other) const noexcept\n            {\n                return this->FullVersion() == other.FullVersion();\n            }\n            bool operator>(const ShaderModel& other) const noexcept\n            {\n                return other < *this;\n            }\n            bool operator<=(const ShaderModel& other) const noexcept\n            {\n                return (*this < other) || (*this == other);\n            }\n            bool operator>=(const ShaderModel& other) const noexcept\n            {\n                return (*this > other) || (*this == other);\n            }\n        };\n\n        struct SourceDesc\n        {\n            const char* source;\n            const char* fileName;\n            const char* entryPoint;\n            ShaderStage stage;\n            const MacroDefine* defines;\n            uint32_t numDefines;\n            std::function<Blob(const char* includeName)> loadIncludeCallback;\n        };\n\n        struct Options\n        {\n            bool packMatricesInRowMajor = true;          // Experimental: Decide how a matrix get packed\n            bool enable16bitTypes = false;               // Enable 16-bit types, such as half, uint16_t. Requires shader model 6.2+\n            bool enableDebugInfo = false;                // Embed debug info into the binary\n            bool disableOptimizations = false;           // Force to turn off optimizations. Ignore optimizationLevel below.\n            bool inheritCombinedSamplerBindings = false; // If textures and samplers are combined, inherit the binding of the texture\n\n            int optimizationLevel = 3; // 0 to 3, no optimization to most optimization\n            ShaderModel shaderModel = {6, 0};\n\n            int shiftAllTexturesBindings = 0;\n            int shiftAllSamplersBindings = 0;\n            int shiftAllCBuffersBindings = 0;\n            int shiftAllUABuffersBindings = 0;\n        };\n\n        struct TargetDesc\n        {\n            ShadingLanguage language;\n            const char* version;\n            bool asModule;\n        };\n\n        struct ReflectionDesc\n        {\n            char name[256];           // Name of the resource\n            ShaderResourceType type;  // Type of resource (e.g. texture, cbuffer, etc.)\n            uint32_t bufferBindPoint; // Buffer's starting bind point\n            uint32_t bindPoint;       // Starting bind point\n            uint32_t bindCount;       // Number of contiguous bind points (for arrays)\n        };\n\n        struct ReflectionResultDesc\n        {\n            Blob descs; // The underneath type is ReflectionDesc\n            uint32_t descCount = 0;\n            uint32_t instructionCount = 0;\n        };\n\n        struct ResultDesc\n        {\n            Blob target;\n            bool isText;\n\n            Blob errorWarningMsg;\n            bool hasError;\n\n            ReflectionResultDesc reflection;\n        };\n\n        struct DisassembleDesc\n        {\n            ShadingLanguage language;\n            const uint8_t* binary;\n            uint32_t binarySize;\n        };\n\n        struct ModuleDesc\n        {\n            const char* name;\n            Blob target;\n        };\n\n        struct LinkDesc\n        {\n            const char* entryPoint;\n            ShaderStage stage;\n\n            const ModuleDesc** modules;\n            uint32_t numModules;\n        };\n\n    public:\n        static ResultDesc Compile(const SourceDesc& source, const Options& options, const TargetDesc& target);\n        static void Compile(const SourceDesc& source, const Options& options, const TargetDesc* targets, uint32_t numTargets,\n                            ResultDesc* results);\n        static ResultDesc Disassemble(const DisassembleDesc& source);\n\n        // Currently only Dxil on Windows supports linking\n        static bool LinkSupport();\n        static ResultDesc Link(const LinkDesc& modules, const Options& options, const TargetDesc& target);\n    };\n} // namespace ShaderConductor\n\n#endif // SHADER_CONDUCTOR_HPP\n"
  },
  {
    "path": "LICENSE",
    "content": "    MIT License\n\n    Copyright (c) Microsoft Corporation. All rights reserved.\n\n    Permission is hereby granted, free of charge, to any person obtaining a copy\n    of this software and associated documentation files (the \"Software\"), to deal\n    in the Software without restriction, including without limitation the rights\n    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n    copies of the Software, and to permit persons to whom the Software is\n    furnished to do so, subject to the following conditions:\n\n    The above copyright notice and this permission notice shall be included in all\n    copies or substantial portions of the Software.\n\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n    SOFTWARE\n"
  },
  {
    "path": "README.md",
    "content": "# ShaderConductor\n\n[![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)\n[![License](https://img.shields.io/github/license/mashape/apistatus.svg)](LICENSE)\n\n\nShaderConductor is a tool designed for cross-compiling HLSL to other shading languages.\n\n## Features\n\n* Converts HLSL to readable, usable and efficient GLSL\n* Converts HLSL to readable, usable and efficient ESSL\n* Converts HLSL to readable, usable and efficient Metal Shading Language (MSL)\n* Converts HLSL to readable, usable and efficient old shader model HLSL\n* Supports all stages of shaders, vertex, pixel, hull, domain, geometry, and compute.\n\nNote that this project is still in an early stage, and it is under active development.\n\n## Architecture\n\nShaderConductor is not a real compiler. Instead, it glues existing open source components to do the cross-compiling.\n1. [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/),\n1. [SPIRV-Cross](https://github.com/KhronosGroup/SPIRV-Cross) to convert SPIR-V to target shading languages.\n\n![Architecture](Doc/Arch.svg)\n\n## Prerequisites\n\n* [Git](http://git-scm.com/downloads). Put git into the PATH is recommended.\n* [Visual Studio 2017](https://www.visualstudio.com/downloads). Select the following workloads: Universal Windows Platform Development and Desktop Development with C++.\n* [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.\n* [Python](https://www.python.org/downloads/). Version 2.7 or up. You need not change your PATH variable during installation.\n\n## Building\n\nShaderConductor has been tested on Windows, Linux, and macOS.\n\n### The script way:\n\n```\n  BuildAll.py <BuildSystem> <Compiler> <Architecture> <Configuration>\n```\nwhere,\n* \\<BuildSystem\\> can be ninja or vs2017. Default is vs2017.\n* \\<Compiler\\> can be vc141 on Windows, gcc or clang on Linux, clang on macOS.\n* \\<Architecture\\> must be x64 (for now).\n* \\<Configuration\\> can be Debug, Release, RelWithDebInfo, or MinSizeRel. Default is Release.\n \nThis script automatically grabs external dependencies to External folder, generates project file in Build/\\<BuildSystem\\>-\\<Compiler\\>-\\<Platform\\>-\\<Architecture\\>[-\\<Configuration\\>], and builds it.\n\n### The manual way:\n\n```\n  mkdir Build\n  cd Build\n  cmake -G \"Visual Studio 15\" -T host=x64 -A x64 ../\n  cmake --build .\n```\n\nAfter building, the output file ShaderConductor.dll can be located in \\<YourCMakeTargetFolder\\>/Bin/\\<Configuration\\>/. It depends on dxcompiler.dll in the same folder.\n\n### Artifacts\n\nYou 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.\n\n## License\n\nShaderConductor is distributed under the terms of MIT License. See [LICENSE](LICENSE) for details.\n\n## Code of Conduct\n\nThis project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).\nFor more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or\ncontact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\n"
  },
  {
    "path": "SECURITY.md",
    "content": "<!-- BEGIN MICROSOFT SECURITY.MD V0.0.8 BLOCK -->\n\n## Security\n\nMicrosoft 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/).\n\nIf 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.\n\n## Reporting Security Issues\n\n**Please do not report security vulnerabilities through public GitHub issues.**\n\nInstead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report).\n\nIf 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).\n\nYou 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). \n\nPlease 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:\n\n  * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)\n  * Full paths of source file(s) related to the manifestation of the issue\n  * The location of the affected source code (tag/branch/commit or direct URL)\n  * Any special configuration required to reproduce the issue\n  * Step-by-step instructions to reproduce the issue\n  * Proof-of-concept or exploit code (if possible)\n  * Impact of the issue, including how an attacker might exploit the issue\n\nThis information will help us triage your report more quickly.\n\nIf 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.\n\n## Preferred Languages\n\nWe prefer all communications to be in English.\n\n## Policy\n\nMicrosoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd).\n\n<!-- END MICROSOFT SECURITY.MD BLOCK -->\n"
  },
  {
    "path": "Source/CMakeLists.txt",
    "content": "# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the MIT License.\n\nif(CMAKE_C_COMPILER_ID MATCHES MSVC)\n\tset(CMAKE_CXX_FLAGS \"/W4 /WX /EHsc /MP /bigobj /Zc:throwingNew /Zc:strictStrings /Zc:rvalueCast /Gw\")\n\tif(MSVC_VERSION GREATER 1910)\n\t\tset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} /std:c++17\")\n\telse()\n\t\tset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} /std:c++14\")\n\tendif()\n\tif(MSVC_VERSION GREATER 1900)\n\t\tset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} /permissive-\")\n\t\tif(MSVC_VERSION GREATER 1912)\n\t\t\tset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} /Zc:externConstexpr\")\n\t\tendif()\n\tendif()\n\tset(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS})\n\tset(CMAKE_CXX_FLAGS_RELEASE \"${CMAKE_CXX_FLAGS_RELEASE} /fp:fast /Ob2 /GL /Qpar\")\n\tset(CMAKE_CXX_FLAGS_RELWITHDEBINFO \"${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /fp:fast /Ob2 /GL /Qpar\")\n\tset(CMAKE_CXX_FLAGS_MINSIZEREL \"${CMAKE_CXX_FLAGS_MINSIZEREL} /fp:fast /Ob1 /GL /Qpar\")\n\tforeach(flagVar\n\t\tCMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_MINSIZEREL)\n\t\tset(${flagVar} \"${${flagVar}} /GS-\")\n\tendforeach()\n\n\tforeach(flagVar\n\t\tCMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS)\n\t\tset(${flagVar} \"/pdbcompress\")\n\tendforeach()\n\tforeach(flagVar\n\t\tCMAKE_EXE_LINKER_FLAGS_DEBUG CMAKE_SHARED_LINKER_FLAGS_DEBUG)\n\t\tset(${flagVar} \"/DEBUG:FASTLINK\")\n\tendforeach()\n\tforeach(flagVar\n\t\tCMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO)\n\t\tset(${flagVar} \"/DEBUG:FASTLINK /INCREMENTAL:NO /LTCG:incremental /OPT:REF /OPT:ICF\")\n\tendforeach()\n\tforeach(flagVar\n\t\tCMAKE_EXE_LINKER_FLAGS_MINSIZEREL CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL CMAKE_EXE_LINKER_FLAGS_RELEASE CMAKE_SHARED_LINKER_FLAGS_RELEASE)\n\t\tset(${flagVar} \"/INCREMENTAL:NO /LTCG /OPT:REF /OPT:ICF\")\n\tendforeach()\n\tforeach(flagVar\n\t\tCMAKE_MODULE_LINKER_FLAGS_RELEASE CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL)\n\t\tset(${flagVar} \"/INCREMENTAL:NO /LTCG\")\n\tendforeach()\n\tforeach(flagVar\n\t\tCMAKE_STATIC_LINKER_FLAGS_RELEASE CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL)\n\t\tset(${flagVar} \"${${flagVar}} /LTCG\")\n\tendforeach()\n\tset(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO \"${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /LTCG:incremental\")\n\n\tadd_definitions(-DWIN32 -D_WINDOWS)\nelse()\n\tforeach(flagVar\n\t\tCMAKE_C_FLAGS CMAKE_CXX_FLAGS)\n\t\tset(${flagVar} \"${${flagVar}} -W -Wall -Werror\")\n\t\tif(NOT (ANDROID OR IOS))\n\t\t\tset(${flagVar} \"${${flagVar}} -march=core2 -msse2\")\n\t\tendif()\n\tendforeach()\n\tset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers\")\n\tif(MINGW)\n\t\tforeach(flagVar\n\t\t\tCMAKE_C_FLAGS CMAKE_CXX_FLAGS)\n\t\t\tset(${flagVar} \"${${flagVar}} -Wa,-mbig-obj\")\n\t\tendforeach()\n\tendif()\n\tset(CMAKE_CXX_FLAGS_DEBUG \"-DDEBUG -g -O0\")\n\tset(CMAKE_CXX_FLAGS_RELEASE \"-DNDEBUG -O2\")\n\tset(CMAKE_CXX_FLAGS_RELWITHDEBINFO \"-DNDEBUG -g -O2\")\n\tset(CMAKE_CXX_FLAGS_MINSIZEREL \"-DNDEBUG -Os\")\n\n\tif(NOT SC_ARCH_NAME)\n\t\tif((CMAKE_SYSTEM_PROCESSOR MATCHES \"AMD64\") OR (CMAKE_SYSTEM_PROCESSOR MATCHES \"x86_64\"))\n\t\t\tset(SC_ARCH_NAME \"x64\")\n\t\telse()\n\t\t\tset(SC_ARCH_NAME \"x86\")\n\t\tendif()\n\tendif()\n\n\tif(SC_ARCH_NAME STREQUAL \"x64\")\n\t\tforeach(flagVar\n\t\t\tCMAKE_C_FLAGS CMAKE_CXX_FLAGS)\n\t\t\tset(${flagVar} \"${${flagVar}} -m64\")\n\t\tendforeach()\n\t\tif(NOT MSVC)\n\t\t\tforeach(flagVar\n\t\t\t\tCMAKE_SHARED_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_EXE_LINKER_FLAGS)\n\t\t\t\tset(${flagVar} \"${${flagVar}} -m64\")\n\t\t\tendforeach()\n\t\t\tif(WIN32)\n\t\t\t\tset(CMAKE_RC_FLAGS \"${CMAKE_RC_FLAGS} --target=pe-x86-64\")\n\t\t\telse()\n\t\t\t\tset(CMAKE_RC_FLAGS \"${CMAKE_RC_FLAGS} --target=elf64-x86-64\")\n\t\t\tendif()\n\t\tendif()\n\telse()\n\t\tforeach(flagVar\n\t\t\tCMAKE_C_FLAGS CMAKE_CXX_FLAGS)\n\t\t\tset(${flagVar} \"${${flagVar}} -m32\")\n\t\tendforeach()\n\t\tif(NOT MSVC)\n\t\t\tforeach(flagVar\n\t\t\t\tCMAKE_SHARED_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_EXE_LINKER_FLAGS)\n\t\t\t\tset(${flagVar} \"${${flagVar}} -m32\")\n\t\t\t\tif(WIN32)\n\t\t\t\t\tset(${flagVar} \"${${flagVar}} -Wl,--large-address-aware\")\n\t\t\t\tendif()\n\t\t\tendforeach()\n\t\t\tif(WIN32)\n\t\t\t\tset(CMAKE_RC_FLAGS \"${CMAKE_RC_FLAGS} --target=pe-i386\")\n\t\t\telse()\n\t\t\t\tset(CMAKE_RC_FLAGS \"${CMAKE_RC_FLAGS} --target=elf32-i386\")\n\t\t\tendif()\n\t\tendif()\n\tendif()\nendif()\n\nset(CMAKE_C_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})\nset(CMAKE_C_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})\nset(CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})\nset(CMAKE_C_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_MINSIZEREL})\n\nadd_subdirectory(Core)\nadd_subdirectory(Tests)\nadd_subdirectory(Tools)\nif(SC_WITH_CSHARP)\n    add_subdirectory(Wrapper)\nendif()\n"
  },
  {
    "path": "Source/Core/CMakeLists.txt",
    "content": "# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the MIT License.\n\nif(WIN32)\n    set(dxcompilerName \"dxcompiler.dll\")\n    set(runtimeOutputFolder \"bin\")\n    set(copyTargetFolder ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})\nelse()\n    if(${CMAKE_SYSTEM_NAME} MATCHES \"Darwin\")\n        set(dxcompilerName \"libdxcompiler.dylib\")\n    else()\n        set(dxcompilerName \"libdxcompiler.so\")\n    endif()\n    set(runtimeOutputFolder \"lib\")\n    set(copyTargetFolder ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})\nendif()\n\nset(dxcompilerOutput \"${copyTargetFolder}/${CMAKE_CFG_INTDIR}/${dxcompilerName}\")\nadd_custom_target(CopyDxcompiler ALL\n    COMMAND ${CMAKE_COMMAND} -E copy\n        ${SC_BUILD_DIR}/External/DirectXShaderCompiler/${CMAKE_CFG_INTDIR}/${runtimeOutputFolder}/${dxcompilerName}\n        ${dxcompilerOutput}\n    COMMENT \"Copying dxcompiler...\")\nadd_dependencies(CopyDxcompiler dxcompiler)\n\nset_target_properties(CopyDxcompiler PROPERTIES FOLDER \"Core\")\n\n\nset(LIB_NAME ShaderConductor)\n\nset(SOURCE_FILES\n    ${SC_ROOT_DIR}/Source/Core/ShaderConductor.cpp\n)\n\nset(HEADER_FILES\n    ${SC_ROOT_DIR}/Include/ShaderConductor/ShaderConductor.hpp\n)\n\nsource_group(\"Source Files\" FILES ${SOURCE_FILES})\nsource_group(\"Header Files\" FILES ${HEADER_FILES})\n\nadd_library(${LIB_NAME} \"SHARED\"\n    ${SOURCE_FILES} ${HEADER_FILES}\n)\n\ntarget_include_directories(${LIB_NAME}\n    PUBLIC\n        ${SC_ROOT_DIR}/Include\n\n    PRIVATE\n        ${SC_BUILD_DIR}/External/DirectXShaderCompiler/include\n        ${SC_ROOT_DIR}/External/DirectXShaderCompiler/include\n)\ntarget_compile_definitions(${LIB_NAME}\n    PRIVATE\n        -DSHADER_CONDUCTOR_SOURCE\n)\nif(MSVC)\n    target_compile_definitions(${LIB_NAME}\n        PRIVATE\n            -D_CRT_SECURE_NO_DEPRECATE\n            -D_CRT_SECURE_NO_WARNINGS\n            -D_SCL_SECURE_NO_DEPRECATE\n            -D_SCL_SECURE_NO_WARNINGS\n            -D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING\n    )\nendif()\ntarget_link_libraries(${LIB_NAME}\n    PRIVATE\n        dxcompiler\n        LLVMDxcSupport\n        LLVMSupport\n        spirv-cross-core\n        spirv-cross-glsl\n        spirv-cross-hlsl\n        spirv-cross-msl\n        spirv-cross-util\n        SPIRV-Tools\n)\n\nadd_dependencies(${LIB_NAME} spirv-cross-core spirv-cross-glsl spirv-cross-hlsl spirv-cross-msl)\nadd_dependencies(${LIB_NAME} CopyDxcompiler)\nadd_dependencies(${LIB_NAME} SPIRV-Tools)\n\nset_target_properties(${LIB_NAME} PROPERTIES FOLDER \"Core\")\n"
  },
  {
    "path": "Source/Core/ShaderConductor.cpp",
    "content": "/*\n * ShaderConductor\n *\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n *\n * MIT License\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this\n * software and associated documentation files (the \"Software\"), to deal in the Software\n * without restriction, including without limitation the rights to use, copy, modify, merge,\n * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons\n * to whom the Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all copies or\n * substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR\n * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE\n * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\n#include <ShaderConductor/ShaderConductor.hpp>\n\n#include <dxc/Support/Global.h>\n#include <dxc/Support/Unicode.h>\n#include <dxc/Support/WinAdapter.h>\n#include <dxc/Support/WinIncludes.h>\n\n#include <algorithm>\n#include <atomic>\n#include <cassert>\n#include <fstream>\n#include <memory>\n\n#include <dxc/DxilContainer/DxilContainer.h>\n#include <dxc/dxcapi.h>\n#include <llvm/Support/ErrorHandling.h>\n\n#include <spirv-tools/libspirv.h>\n#include <spirv.hpp>\n#include <spirv_cross.hpp>\n#include <spirv_glsl.hpp>\n#include <spirv_hlsl.hpp>\n#include <spirv_msl.hpp>\n#include <spirv_cross_util.hpp>\n\n#ifdef LLVM_ON_WIN32\n#include <d3d12shader.h>\n#endif\n\n#define SC_UNUSED(x) (void)(x);\n\nusing namespace ShaderConductor;\n\nnamespace\n{\n    bool dllDetaching = false;\n\n    class Dxcompiler\n    {\n    public:\n        ~Dxcompiler()\n        {\n            this->Destroy();\n        }\n\n        static Dxcompiler& Instance()\n        {\n            static Dxcompiler instance;\n            return instance;\n        }\n\n        IDxcLibrary* Library() const\n        {\n            return m_library;\n        }\n\n        IDxcCompiler* Compiler() const\n        {\n            return m_compiler;\n        }\n\n        IDxcContainerReflection* ContainerReflection() const\n        {\n            return m_containerReflection;\n        }\n\n        CComPtr<IDxcLinker> CreateLinker() const\n        {\n            CComPtr<IDxcLinker> linker;\n            IFT(m_createInstanceFunc(CLSID_DxcLinker, __uuidof(IDxcLinker), reinterpret_cast<void**>(&linker)));\n            return linker;\n        }\n\n        bool LinkerSupport() const\n        {\n            return m_linkerSupport;\n        }\n\n        void Destroy()\n        {\n            if (m_dxcompilerDll)\n            {\n                m_compiler = nullptr;\n                m_library = nullptr;\n                m_containerReflection = nullptr;\n\n                m_createInstanceFunc = nullptr;\n\n#ifdef _WIN32\n                ::FreeLibrary(m_dxcompilerDll);\n#else\n                ::dlclose(m_dxcompilerDll);\n#endif\n\n                m_dxcompilerDll = nullptr;\n            }\n        }\n\n        void Terminate()\n        {\n            if (m_dxcompilerDll)\n            {\n                m_compiler.Detach();\n                m_library.Detach();\n                m_containerReflection.Detach();\n\n                m_createInstanceFunc = nullptr;\n\n                m_dxcompilerDll = nullptr;\n            }\n        }\n\n    private:\n        Dxcompiler()\n        {\n            if (dllDetaching)\n            {\n                return;\n            }\n\n#ifdef _WIN32\n            const char* dllName = \"dxcompiler.dll\";\n#elif __APPLE__\n            const char* dllName = \"libdxcompiler.dylib\";\n#else\n            const char* dllName = \"libdxcompiler.so\";\n#endif\n            const char* functionName = \"DxcCreateInstance\";\n\n#ifdef _WIN32\n            m_dxcompilerDll = ::LoadLibraryA(dllName);\n#else\n            m_dxcompilerDll = ::dlopen(dllName, RTLD_LAZY);\n#endif\n\n            if (m_dxcompilerDll != nullptr)\n            {\n#ifdef _WIN32\n                m_createInstanceFunc = (DxcCreateInstanceProc)::GetProcAddress(m_dxcompilerDll, functionName);\n#else\n                m_createInstanceFunc = (DxcCreateInstanceProc)::dlsym(m_dxcompilerDll, functionName);\n#endif\n\n                if (m_createInstanceFunc != nullptr)\n                {\n                    IFT(m_createInstanceFunc(CLSID_DxcLibrary, __uuidof(IDxcLibrary), reinterpret_cast<void**>(&m_library)));\n                    IFT(m_createInstanceFunc(CLSID_DxcCompiler, __uuidof(IDxcCompiler), reinterpret_cast<void**>(&m_compiler)));\n                    IFT(m_createInstanceFunc(CLSID_DxcContainerReflection, __uuidof(IDxcContainerReflection),\n                                             reinterpret_cast<void**>(&m_containerReflection)));\n                }\n                else\n                {\n                    this->Destroy();\n\n                    throw std::runtime_error(std::string(\"COULDN'T get \") + functionName + \" from dxcompiler.\");\n                }\n            }\n            else\n            {\n                throw std::runtime_error(\"COULDN'T load dxcompiler.\");\n            }\n\n            m_linkerSupport = (CreateLinker() != nullptr);\n        }\n\n    private:\n        HMODULE m_dxcompilerDll = nullptr;\n        DxcCreateInstanceProc m_createInstanceFunc = nullptr;\n\n        CComPtr<IDxcLibrary> m_library;\n        CComPtr<IDxcCompiler> m_compiler;\n        CComPtr<IDxcContainerReflection> m_containerReflection;\n\n        bool m_linkerSupport;\n    };\n\n    class ScIncludeHandler : public IDxcIncludeHandler\n    {\n    public:\n        explicit ScIncludeHandler(std::function<Blob(const char* includeName)> loadCallback) : m_loadCallback(std::move(loadCallback))\n        {\n        }\n\n        HRESULT STDMETHODCALLTYPE LoadSource(LPCWSTR fileName, IDxcBlob** includeSource) override\n        {\n            if ((fileName[0] == L'.') && (fileName[1] == L'/'))\n            {\n                fileName += 2;\n            }\n\n            std::string utf8FileName;\n            if (!Unicode::UTF16ToUTF8String(fileName, &utf8FileName))\n            {\n                return E_FAIL;\n            }\n\n            Blob source;\n            try\n            {\n                source = m_loadCallback(utf8FileName.c_str());\n            }\n            catch (...)\n            {\n                return E_FAIL;\n            }\n\n            *includeSource = nullptr;\n            return Dxcompiler::Instance().Library()->CreateBlobWithEncodingOnHeapCopy(source.Data(), source.Size(), CP_UTF8,\n                                                                                      reinterpret_cast<IDxcBlobEncoding**>(includeSource));\n        }\n\n        ULONG STDMETHODCALLTYPE AddRef() override\n        {\n            ++m_ref;\n            return m_ref;\n        }\n\n        ULONG STDMETHODCALLTYPE Release() override\n        {\n            --m_ref;\n            ULONG result = m_ref;\n            if (result == 0)\n            {\n                delete this;\n            }\n            return result;\n        }\n\n        HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void** object) override\n        {\n            if (IsEqualIID(iid, __uuidof(IDxcIncludeHandler)))\n            {\n                *object = dynamic_cast<IDxcIncludeHandler*>(this);\n                this->AddRef();\n                return S_OK;\n            }\n            else if (IsEqualIID(iid, __uuidof(IUnknown)))\n            {\n                *object = dynamic_cast<IUnknown*>(this);\n                this->AddRef();\n                return S_OK;\n            }\n            else\n            {\n                return E_NOINTERFACE;\n            }\n        }\n\n    private:\n        std::function<Blob(const char* includeName)> m_loadCallback;\n\n        std::atomic<ULONG> m_ref = 0;\n    };\n\n    Blob DefaultLoadCallback(const char* includeName)\n    {\n        std::vector<char> ret;\n        std::ifstream includeFile(includeName, std::ios_base::in);\n        if (includeFile)\n        {\n            includeFile.seekg(0, std::ios::end);\n            ret.resize(static_cast<size_t>(includeFile.tellg()));\n            includeFile.seekg(0, std::ios::beg);\n            includeFile.read(ret.data(), ret.size());\n            ret.resize(static_cast<size_t>(includeFile.gcount()));\n        }\n        else\n        {\n            throw std::runtime_error(std::string(\"COULDN'T load included file \") + includeName + \".\");\n        }\n        return Blob(ret.data(), static_cast<uint32_t>(ret.size()));\n    }\n\n    void AppendError(Compiler::ResultDesc& result, const std::string& msg)\n    {\n        std::string errorMSg;\n        if (result.errorWarningMsg.Size() != 0)\n        {\n            errorMSg.assign(reinterpret_cast<const char*>(result.errorWarningMsg.Data()), result.errorWarningMsg.Size());\n        }\n        if (!errorMSg.empty())\n        {\n            errorMSg += \"\\n\";\n        }\n        errorMSg += msg;\n        result.errorWarningMsg.Reset(errorMSg.data(), static_cast<uint32_t>(errorMSg.size()));\n        result.hasError = true;\n    }\n\n#ifdef LLVM_ON_WIN32\n    template <typename T>\n    HRESULT CreateDxcReflectionFromBlob(IDxcBlob* dxilBlob, CComPtr<T>& outReflection)\n    {\n        IDxcContainerReflection* containReflection = Dxcompiler::Instance().ContainerReflection();\n        IFT(containReflection->Load(dxilBlob));\n\n        uint32_t dxilPartIndex = ~0u;\n        IFT(containReflection->FindFirstPartKind(hlsl::DFCC_DXIL, &dxilPartIndex));\n        HRESULT result = containReflection->GetPartReflection(dxilPartIndex, __uuidof(T), reinterpret_cast<void**>(&outReflection));\n\n        return result;\n    }\n\n    void ShaderReflection(Compiler::ReflectionResultDesc& result, IDxcBlob* dxilBlob)\n    {\n        CComPtr<ID3D12ShaderReflection> shaderReflection;\n        IFT(CreateDxcReflectionFromBlob(dxilBlob, shaderReflection));\n\n        D3D12_SHADER_DESC shaderDesc;\n        shaderReflection->GetDesc(&shaderDesc);\n\n        std::vector<Compiler::ReflectionDesc> vecReflectionDescs;\n        for (uint32_t resourceIndex = 0; resourceIndex < shaderDesc.BoundResources; ++resourceIndex)\n        {\n            D3D12_SHADER_INPUT_BIND_DESC bindDesc;\n            shaderReflection->GetResourceBindingDesc(resourceIndex, &bindDesc);\n\n            Compiler::ReflectionDesc reflectionDesc{};\n\n            if (bindDesc.Type == D3D_SIT_CBUFFER || bindDesc.Type == D3D_SIT_TBUFFER)\n            {\n                ID3D12ShaderReflectionConstantBuffer* constantBuffer = shaderReflection->GetConstantBufferByName(bindDesc.Name);\n\n                D3D12_SHADER_BUFFER_DESC bufferDesc;\n                constantBuffer->GetDesc(&bufferDesc);\n\n                if (strcmp(bufferDesc.Name, \"$Globals\") == 0)\n                {\n                    for (uint32_t variableIndex = 0; variableIndex < bufferDesc.Variables; ++variableIndex)\n                    {\n                        ID3D12ShaderReflectionVariable* variable = constantBuffer->GetVariableByIndex(variableIndex);\n                        D3D12_SHADER_VARIABLE_DESC variableDesc;\n                        variable->GetDesc(&variableDesc);\n\n                        std::strncpy(reflectionDesc.name, variableDesc.Name,\n                                     std::min(std::strlen(variableDesc.Name) + 1, sizeof(reflectionDesc.name)));\n\n                        reflectionDesc.type = ShaderResourceType::Parameter;\n                        reflectionDesc.bufferBindPoint = bindDesc.BindPoint;\n                        reflectionDesc.bindPoint = variableDesc.StartOffset;\n                        reflectionDesc.bindCount = variableDesc.Size;\n                    }\n                }\n                else\n                {\n                    std::strncpy(reflectionDesc.name, bufferDesc.Name,\n                                 std::min(std::strlen(bufferDesc.Name) + 1, sizeof(reflectionDesc.name)));\n\n                    reflectionDesc.type = ShaderResourceType::ConstantBuffer;\n                    reflectionDesc.bufferBindPoint = bindDesc.BindPoint;\n                    reflectionDesc.bindPoint = 0;\n                    reflectionDesc.bindCount = 0;\n                }\n            }\n            else\n            {\n                switch (bindDesc.Type)\n                {\n                case D3D_SIT_TEXTURE:\n                    reflectionDesc.type = ShaderResourceType::Texture;\n                    break;\n\n                case D3D_SIT_SAMPLER:\n                    reflectionDesc.type = ShaderResourceType::Sampler;\n                    break;\n\n                case D3D_SIT_STRUCTURED:\n                case D3D_SIT_BYTEADDRESS:\n                    reflectionDesc.type = ShaderResourceType::ShaderResourceView;\n                    break;\n\n                case D3D_SIT_UAV_RWTYPED:\n                case D3D_SIT_UAV_RWSTRUCTURED:\n                case D3D_SIT_UAV_RWBYTEADDRESS:\n                case D3D_SIT_UAV_APPEND_STRUCTURED:\n                case D3D_SIT_UAV_CONSUME_STRUCTURED:\n                case D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER:\n                    reflectionDesc.type = ShaderResourceType::UnorderedAccessView;\n                    break;\n\n                default:\n                    llvm_unreachable(\"Unknown bind type.\");\n                    break;\n                }\n\n                std::strncpy(reflectionDesc.name, bindDesc.Name, std::min(std::strlen(bindDesc.Name) + 1, sizeof(reflectionDesc.name)));\n\n                reflectionDesc.bufferBindPoint = 0;\n                reflectionDesc.bindPoint = bindDesc.BindPoint;\n                reflectionDesc.bindCount = bindDesc.BindCount;\n            }\n\n            vecReflectionDescs.push_back(reflectionDesc);\n        }\n\n        result.descCount = static_cast<uint32_t>(vecReflectionDescs.size());\n        result.descs.Reset(vecReflectionDescs.data(), sizeof(Compiler::ReflectionDesc) * result.descCount);\n        result.instructionCount = shaderDesc.InstructionCount;\n    }\n#endif\n\n    std::wstring ShaderProfileName(ShaderStage stage, Compiler::ShaderModel shaderModel)\n    {\n        std::wstring shaderProfile;\n        switch (stage)\n        {\n        case ShaderStage::VertexShader:\n            shaderProfile = L\"vs\";\n            break;\n\n        case ShaderStage::PixelShader:\n            shaderProfile = L\"ps\";\n            break;\n\n        case ShaderStage::GeometryShader:\n            shaderProfile = L\"gs\";\n            break;\n\n        case ShaderStage::HullShader:\n            shaderProfile = L\"hs\";\n            break;\n\n        case ShaderStage::DomainShader:\n            shaderProfile = L\"ds\";\n            break;\n\n        case ShaderStage::ComputeShader:\n            shaderProfile = L\"cs\";\n            break;\n\n        default:\n            llvm_unreachable(\"Invalid shader stage.\");\n        }\n\n        shaderProfile.push_back(L'_');\n        shaderProfile.push_back(L'0' + shaderModel.major_ver);\n        shaderProfile.push_back(L'_');\n        shaderProfile.push_back(L'0' + shaderModel.minor_ver);\n\n        return shaderProfile;\n    }\n\n    void ConvertDxcResult(Compiler::ResultDesc& result, IDxcOperationResult* dxcResult, ShadingLanguage targetLanguage, bool asModule)\n    {\n        HRESULT status;\n        IFT(dxcResult->GetStatus(&status));\n\n        result.target.Reset();\n        result.errorWarningMsg.Reset();\n\n        CComPtr<IDxcBlobEncoding> errors;\n        IFT(dxcResult->GetErrorBuffer(&errors));\n        if (errors != nullptr)\n        {\n            result.errorWarningMsg.Reset(errors->GetBufferPointer(), static_cast<uint32_t>(errors->GetBufferSize()));\n            errors = nullptr;\n        }\n\n        result.hasError = true;\n        if (SUCCEEDED(status))\n        {\n            CComPtr<IDxcBlob> program;\n            IFT(dxcResult->GetResult(&program));\n            dxcResult = nullptr;\n            if (program != nullptr)\n            {\n                result.target.Reset(program->GetBufferPointer(), static_cast<uint32_t>(program->GetBufferSize()));\n                result.hasError = false;\n            }\n\n#ifdef LLVM_ON_WIN32\n            if ((targetLanguage == ShadingLanguage::Dxil) && !asModule)\n            {\n                // Gather reflection information only for ShadingLanguage::Dxil\n                ShaderReflection(result.reflection, program);\n            }\n#else\n            SC_UNUSED(targetLanguage);\n            SC_UNUSED(asModule);\n#endif\n        }\n    }\n\n    Compiler::ResultDesc CompileToBinary(const Compiler::SourceDesc& source, const Compiler::Options& options,\n                                         ShadingLanguage targetLanguage, bool asModule)\n    {\n        assert((targetLanguage == ShadingLanguage::Dxil) || (targetLanguage == ShadingLanguage::SpirV));\n\n        std::wstring shaderProfile;\n        if (asModule)\n        {\n            if (targetLanguage == ShadingLanguage::Dxil)\n            {\n                shaderProfile = L\"lib_6_x\";\n            }\n            else\n            {\n                llvm_unreachable(\"Spir-V module is not supported.\");\n            }\n        }\n        else\n        {\n            shaderProfile = ShaderProfileName(source.stage, options.shaderModel);\n        }\n\n        std::vector<DxcDefine> dxcDefines;\n        std::vector<std::wstring> dxcDefineStrings;\n        // Need to reserve capacity so that small-string optimization does not\n        // invalidate the pointers to internal string data while resizing.\n        dxcDefineStrings.reserve(source.numDefines * 2);\n        for (size_t i = 0; i < source.numDefines; ++i)\n        {\n            const auto& define = source.defines[i];\n\n            std::wstring nameUtf16Str;\n            Unicode::UTF8ToUTF16String(define.name, &nameUtf16Str);\n            dxcDefineStrings.emplace_back(std::move(nameUtf16Str));\n            const wchar_t* nameUtf16 = dxcDefineStrings.back().c_str();\n\n            const wchar_t* valueUtf16;\n            if (define.value != nullptr)\n            {\n                std::wstring valueUtf16Str;\n                Unicode::UTF8ToUTF16String(define.value, &valueUtf16Str);\n                dxcDefineStrings.emplace_back(std::move(valueUtf16Str));\n                valueUtf16 = dxcDefineStrings.back().c_str();\n            }\n            else\n            {\n                valueUtf16 = nullptr;\n            }\n\n            dxcDefines.push_back({nameUtf16, valueUtf16});\n        }\n\n        CComPtr<IDxcBlobEncoding> sourceBlob;\n        IFT(Dxcompiler::Instance().Library()->CreateBlobWithEncodingOnHeapCopy(\n            source.source, static_cast<UINT32>(std::strlen(source.source)), CP_UTF8, &sourceBlob));\n        IFTARG(sourceBlob->GetBufferSize() >= 4);\n\n        std::wstring shaderNameUtf16;\n        Unicode::UTF8ToUTF16String(source.fileName, &shaderNameUtf16);\n\n        std::wstring entryPointUtf16;\n        Unicode::UTF8ToUTF16String(source.entryPoint, &entryPointUtf16);\n\n        std::vector<std::wstring> dxcArgStrings;\n\n        // HLSL matrices are translated into SPIR-V OpTypeMatrixs in a transposed manner,\n        // See also https://antiagainst.github.io/post/hlsl-for-vulkan-matrices/\n        if (options.packMatricesInRowMajor)\n        {\n            dxcArgStrings.push_back(L\"-Zpr\");\n        }\n        else\n        {\n            dxcArgStrings.push_back(L\"-Zpc\");\n        }\n\n        if (options.enable16bitTypes)\n        {\n            if (options.shaderModel >= Compiler::ShaderModel{6, 2})\n            {\n                dxcArgStrings.push_back(L\"-enable-16bit-types\");\n            }\n            else\n            {\n                throw std::runtime_error(\"16-bit types requires shader model 6.2 or up.\");\n            }\n        }\n\n        if (options.enableDebugInfo)\n        {\n            dxcArgStrings.push_back(L\"-Zi\");\n        }\n\n        if (options.disableOptimizations)\n        {\n            dxcArgStrings.push_back(L\"-Od\");\n        }\n        else\n        {\n            if (options.optimizationLevel < 4)\n            {\n                dxcArgStrings.push_back(std::wstring(L\"-O\") + static_cast<wchar_t>(L'0' + options.optimizationLevel));\n            }\n            else\n            {\n                llvm_unreachable(\"Invalid optimization level.\");\n            }\n        }\n\n        if (options.shiftAllCBuffersBindings > 0)\n        {\n            dxcArgStrings.push_back(L\"-fvk-b-shift\");\n            dxcArgStrings.push_back(std::to_wstring(options.shiftAllCBuffersBindings));\n            dxcArgStrings.push_back(L\"all\");\n        }\n\n        if (options.shiftAllUABuffersBindings > 0)\n        {\n            dxcArgStrings.push_back(L\"-fvk-u-shift\");\n            dxcArgStrings.push_back(std::to_wstring(options.shiftAllUABuffersBindings));\n            dxcArgStrings.push_back(L\"all\");\n        }\n\n        if (options.shiftAllSamplersBindings > 0)\n        {\n            dxcArgStrings.push_back(L\"-fvk-s-shift\");\n            dxcArgStrings.push_back(std::to_wstring(options.shiftAllSamplersBindings));\n            dxcArgStrings.push_back(L\"all\");\n        }\n\n        if (options.shiftAllTexturesBindings > 0)\n        {\n            dxcArgStrings.push_back(L\"-fvk-t-shift\");\n            dxcArgStrings.push_back(std::to_wstring(options.shiftAllTexturesBindings));\n            dxcArgStrings.push_back(L\"all\");\n        }\n\n        switch (targetLanguage)\n        {\n        case ShadingLanguage::Dxil:\n            break;\n\n        case ShadingLanguage::SpirV:\n        case ShadingLanguage::Hlsl:\n        case ShadingLanguage::Glsl:\n        case ShadingLanguage::Essl:\n        case ShadingLanguage::Msl_macOS:\n        case ShadingLanguage::Msl_iOS:\n            dxcArgStrings.push_back(L\"-spirv\");\n            break;\n\n        default:\n            llvm_unreachable(\"Invalid shading language.\");\n        }\n\n        std::vector<const wchar_t*> dxcArgs;\n        dxcArgs.reserve(dxcArgStrings.size());\n        for (const auto& arg : dxcArgStrings)\n        {\n            dxcArgs.push_back(arg.c_str());\n        }\n\n        CComPtr<IDxcIncludeHandler> includeHandler = new ScIncludeHandler(std::move(source.loadIncludeCallback));\n        CComPtr<IDxcOperationResult> compileResult;\n        IFT(Dxcompiler::Instance().Compiler()->Compile(sourceBlob, shaderNameUtf16.c_str(), entryPointUtf16.c_str(), shaderProfile.c_str(),\n                                                       dxcArgs.data(), static_cast<UINT32>(dxcArgs.size()), dxcDefines.data(),\n                                                       static_cast<UINT32>(dxcDefines.size()), includeHandler, &compileResult));\n\n        Compiler::ResultDesc ret{};\n        ConvertDxcResult(ret, compileResult, targetLanguage, asModule);\n\n        return ret;\n    }\n\n    Compiler::ResultDesc CrossCompile(const Compiler::ResultDesc& binaryResult, const Compiler::SourceDesc& source,\n                                      const Compiler::Options& options, const Compiler::TargetDesc& target)\n    {\n        assert((target.language != ShadingLanguage::Dxil) && (target.language != ShadingLanguage::SpirV));\n        assert((binaryResult.target.Size() & (sizeof(uint32_t) - 1)) == 0);\n\n        Compiler::ResultDesc ret;\n\n        ret.errorWarningMsg = binaryResult.errorWarningMsg;\n        ret.isText = true;\n\n        uint32_t intVersion = 0;\n        if (target.version != nullptr)\n        {\n            intVersion = std::stoi(target.version);\n        }\n\n        const uint32_t* spirvIr = reinterpret_cast<const uint32_t*>(binaryResult.target.Data());\n        const size_t spirvSize = binaryResult.target.Size() / sizeof(uint32_t);\n\n        std::unique_ptr<spirv_cross::CompilerGLSL> compiler;\n        bool combinedImageSamplers = false;\n        bool buildDummySampler = false;\n\n        switch (target.language)\n        {\n        case ShadingLanguage::Hlsl:\n            if ((source.stage == ShaderStage::GeometryShader) || (source.stage == ShaderStage::HullShader) ||\n                (source.stage == ShaderStage::DomainShader))\n            {\n                // Check https://github.com/KhronosGroup/SPIRV-Cross/issues/121 for details\n                AppendError(ret, \"GS, HS, and DS has not been supported yet.\");\n                return ret;\n            }\n            if ((source.stage == ShaderStage::GeometryShader) && (intVersion < 40))\n            {\n                AppendError(ret, \"HLSL shader model earlier than 4.0 doesn't have GS or CS.\");\n                return ret;\n            }\n            if ((source.stage == ShaderStage::ComputeShader) && (intVersion < 50))\n            {\n                AppendError(ret, \"CS in HLSL shader model earlier than 5.0 is not supported.\");\n                return ret;\n            }\n            if (((source.stage == ShaderStage::HullShader) || (source.stage == ShaderStage::DomainShader)) && (intVersion < 50))\n            {\n                AppendError(ret, \"HLSL shader model earlier than 5.0 doesn't have HS or DS.\");\n                return ret;\n            }\n            compiler = std::make_unique<spirv_cross::CompilerHLSL>(spirvIr, spirvSize);\n            break;\n\n        case ShadingLanguage::Glsl:\n        case ShadingLanguage::Essl:\n            compiler = std::make_unique<spirv_cross::CompilerGLSL>(spirvIr, spirvSize);\n            combinedImageSamplers = true;\n            buildDummySampler = true;\n\n            // Legacy GLSL fixups\n            if (intVersion <= 300)\n            {\n                auto vars = compiler->get_active_interface_variables();\n                for (auto& var : vars)\n                {\n                    auto varClass = compiler->get_storage_class(var);\n\n                    // Make VS out and PS in variable names match\n                    if ((source.stage == ShaderStage::VertexShader) && (varClass == spv::StorageClass::StorageClassOutput))\n                    {\n                        auto name = compiler->get_name(var);\n                        if ((name.find(\"out_var_\") == 0) || (name.find(\"out.var.\") == 0))\n                        {\n                            name.replace(0, 8, \"varying_\");\n                            compiler->set_name(var, name);\n                        }\n                    }\n                    else if ((source.stage == ShaderStage::PixelShader) && (varClass == spv::StorageClass::StorageClassInput))\n                    {\n                        auto name = compiler->get_name(var);\n                        if ((name.find(\"in_var_\") == 0) || (name.find(\"in.var.\") == 0))\n                        {\n                            name.replace(0, 7, \"varying_\");\n                            compiler->set_name(var, name);\n                        }\n                    }\n                }\n            }\n            break;\n\n        case ShadingLanguage::Msl_macOS:\n        case ShadingLanguage::Msl_iOS:\n            if (source.stage == ShaderStage::GeometryShader)\n            {\n                AppendError(ret, \"MSL doesn't have GS.\");\n                return ret;\n            }\n            compiler = std::make_unique<spirv_cross::CompilerMSL>(spirvIr, spirvSize);\n            break;\n\n        default:\n            llvm_unreachable(\"Invalid target language.\");\n        }\n\n        spv::ExecutionModel model;\n        switch (source.stage)\n        {\n        case ShaderStage::VertexShader:\n            model = spv::ExecutionModelVertex;\n            break;\n\n        case ShaderStage::HullShader:\n            model = spv::ExecutionModelTessellationControl;\n            break;\n\n        case ShaderStage::DomainShader:\n            model = spv::ExecutionModelTessellationEvaluation;\n            break;\n\n        case ShaderStage::GeometryShader:\n            model = spv::ExecutionModelGeometry;\n            break;\n\n        case ShaderStage::PixelShader:\n            model = spv::ExecutionModelFragment;\n            break;\n\n        case ShaderStage::ComputeShader:\n            model = spv::ExecutionModelGLCompute;\n            break;\n\n        default:\n            llvm_unreachable(\"Invalid shader stage.\");\n        }\n        compiler->set_entry_point(source.entryPoint, model);\n\n        spirv_cross::CompilerGLSL::Options opts = compiler->get_common_options();\n        if (target.version != nullptr)\n        {\n            opts.version = intVersion;\n        }\n        opts.es = (target.language == ShadingLanguage::Essl);\n        opts.force_temporary = false;\n        opts.separate_shader_objects = true;\n        opts.flatten_multidimensional_arrays = false;\n        opts.enable_420pack_extension =\n            (target.language == ShadingLanguage::Glsl) && ((target.version == nullptr) || (opts.version >= 420));\n        opts.vulkan_semantics = false;\n        opts.vertex.fixup_clipspace = false;\n        opts.vertex.flip_vert_y = false;\n        opts.vertex.support_nonzero_base_instance = true;\n        compiler->set_common_options(opts);\n\n        if (target.language == ShadingLanguage::Hlsl)\n        {\n            auto* hlslCompiler = static_cast<spirv_cross::CompilerHLSL*>(compiler.get());\n            auto hlslOpts = hlslCompiler->get_hlsl_options();\n            if (target.version != nullptr)\n            {\n                if (opts.version < 30)\n                {\n                    AppendError(ret, \"HLSL shader model earlier than 3.0 is not supported.\");\n                    return ret;\n                }\n                hlslOpts.shader_model = opts.version;\n            }\n\n            if (hlslOpts.shader_model <= 30)\n            {\n                combinedImageSamplers = true;\n                buildDummySampler = true;\n            }\n\n            hlslCompiler->set_hlsl_options(hlslOpts);\n        }\n        else if ((target.language == ShadingLanguage::Msl_macOS) || (target.language == ShadingLanguage::Msl_iOS))\n        {\n            auto* mslCompiler = static_cast<spirv_cross::CompilerMSL*>(compiler.get());\n            auto mslOpts = mslCompiler->get_msl_options();\n            if (target.version != nullptr)\n            {\n                mslOpts.msl_version = opts.version;\n            }\n            mslOpts.swizzle_texture_samples = false;\n            mslOpts.platform = (target.language == ShadingLanguage::Msl_iOS) ? spirv_cross::CompilerMSL::Options::iOS\n                                                                             : spirv_cross::CompilerMSL::Options::macOS;\n\n            mslCompiler->set_msl_options(mslOpts);\n\n            const auto& resources = mslCompiler->get_shader_resources();\n\n            uint32_t textureBinding = 0;\n            for (const auto& image : resources.separate_images)\n            {\n                mslCompiler->set_decoration(image.id, spv::DecorationBinding, textureBinding);\n                ++textureBinding;\n            }\n\n            uint32_t samplerBinding = 0;\n            for (const auto& sampler : resources.separate_samplers)\n            {\n                mslCompiler->set_decoration(sampler.id, spv::DecorationBinding, samplerBinding);\n                ++samplerBinding;\n            }\n        }\n\n        if (buildDummySampler)\n        {\n            const uint32_t sampler = compiler->build_dummy_sampler_for_combined_images();\n            if (sampler != 0)\n            {\n                compiler->set_decoration(sampler, spv::DecorationDescriptorSet, 0);\n                compiler->set_decoration(sampler, spv::DecorationBinding, 0);\n            }\n        }\n\n        if (combinedImageSamplers)\n        {\n            compiler->build_combined_image_samplers();\n\n            if (options.inheritCombinedSamplerBindings)\n            {\n                spirv_cross_util::inherit_combined_sampler_bindings(*compiler);\n            }\n\n            for (auto& remap : compiler->get_combined_image_samplers())\n            {\n                compiler->set_name(remap.combined_id,\n                                   \"SPIRV_Cross_Combined\" + compiler->get_name(remap.image_id) + compiler->get_name(remap.sampler_id));\n            }\n        }\n\n        if (target.language == ShadingLanguage::Hlsl)\n        {\n            auto* hlslCompiler = static_cast<spirv_cross::CompilerHLSL*>(compiler.get());\n            const uint32_t newBuiltin = hlslCompiler->remap_num_workgroups_builtin();\n            if (newBuiltin)\n            {\n                compiler->set_decoration(newBuiltin, spv::DecorationDescriptorSet, 0);\n                compiler->set_decoration(newBuiltin, spv::DecorationBinding, 0);\n            }\n        }\n\n        try\n        {\n            const std::string targetStr = compiler->compile();\n            ret.target.Reset(targetStr.data(), static_cast<uint32_t>(targetStr.size()));\n            ret.hasError = false;\n            ret.reflection.descs.Reset(binaryResult.reflection.descs.Data(),\n                                       sizeof(Compiler::ReflectionDesc) * binaryResult.reflection.descCount);\n            ret.reflection.descCount = binaryResult.reflection.descCount;\n            ret.reflection.instructionCount = binaryResult.reflection.instructionCount;\n        }\n        catch (spirv_cross::CompilerError& error)\n        {\n            const char* errorMsg = error.what();\n            ret.errorWarningMsg.Reset(errorMsg, static_cast<uint32_t>(std::strlen(errorMsg)));\n            ret.hasError = true;\n        }\n\n        return ret;\n    }\n\n    Compiler::ResultDesc ConvertBinary(const Compiler::ResultDesc& binaryResult, const Compiler::SourceDesc& source,\n                                       const Compiler::Options& options, const Compiler::TargetDesc& target)\n    {\n        if (!binaryResult.hasError)\n        {\n            if (target.asModule)\n            {\n                return binaryResult;\n            }\n            else\n            {\n                switch (target.language)\n                {\n                case ShadingLanguage::Dxil:\n                case ShadingLanguage::SpirV:\n                    return binaryResult;\n\n                case ShadingLanguage::Hlsl:\n                case ShadingLanguage::Glsl:\n                case ShadingLanguage::Essl:\n                case ShadingLanguage::Msl_macOS:\n                case ShadingLanguage::Msl_iOS:\n                    return CrossCompile(binaryResult, source, options, target);\n\n                default:\n                    llvm_unreachable(\"Invalid shading language.\");\n                    break;\n                }\n            }\n        }\n        else\n        {\n            return binaryResult;\n        }\n    }\n} // namespace\n\nnamespace ShaderConductor\n{\n    class Blob::BlobImpl\n    {\n    public:\n        BlobImpl(const void* data, uint32_t size) noexcept\n            : m_data(reinterpret_cast<const uint8_t*>(data), reinterpret_cast<const uint8_t*>(data) + size)\n        {\n        }\n\n        const void* Data() const noexcept\n        {\n            return m_data.data();\n        }\n\n        uint32_t Size() const noexcept\n        {\n            return static_cast<uint32_t>(m_data.size());\n        }\n\n    private:\n        std::vector<uint8_t> m_data;\n    };\n\n    Blob::Blob() noexcept = default;\n\n    Blob::Blob(const void* data, uint32_t size)\n    {\n        this->Reset(data, size);\n    }\n\n    Blob::Blob(const Blob& other)\n    {\n        this->Reset(other.Data(), other.Size());\n    }\n\n    Blob::Blob(Blob&& other) noexcept : m_impl(std::move(other.m_impl))\n    {\n        other.m_impl = nullptr;\n    }\n\n    Blob::~Blob() noexcept\n    {\n        delete m_impl;\n    }\n\n    Blob& Blob::operator=(const Blob& other)\n    {\n        if (this != &other)\n        {\n            this->Reset(other.Data(), other.Size());\n        }\n        return *this;\n    }\n\n    Blob& Blob::operator=(Blob&& other) noexcept\n    {\n        if (this != &other)\n        {\n            m_impl = std::move(other.m_impl);\n            other.m_impl = nullptr;\n        }\n        return *this;\n    }\n\n    void Blob::Reset()\n    {\n        delete m_impl;\n        m_impl = nullptr;\n    }\n\n    void Blob::Reset(const void* data, uint32_t size)\n    {\n        this->Reset();\n        if ((data != nullptr) && (size > 0))\n        {\n            m_impl = new BlobImpl(data, size);\n        }\n    }\n\n    const void* Blob::Data() const noexcept\n    {\n        return m_impl ? m_impl->Data() : nullptr;\n    }\n\n    uint32_t Blob::Size() const noexcept\n    {\n        return m_impl ? m_impl->Size() : 0;\n    }\n\n\n    Compiler::ResultDesc Compiler::Compile(const SourceDesc& source, const Options& options, const TargetDesc& target)\n    {\n        ResultDesc result;\n        Compiler::Compile(source, options, &target, 1, &result);\n        return result;\n    }\n\n    void Compiler::Compile(const SourceDesc& source, const Options& options, const TargetDesc* targets, uint32_t numTargets,\n                           ResultDesc* results)\n    {\n        SourceDesc sourceOverride = source;\n        if (!sourceOverride.entryPoint || (std::strlen(sourceOverride.entryPoint) == 0))\n        {\n            sourceOverride.entryPoint = \"main\";\n        }\n        if (!sourceOverride.loadIncludeCallback)\n        {\n            sourceOverride.loadIncludeCallback = DefaultLoadCallback;\n        }\n\n        bool hasDxil = false;\n        bool hasDxilModule = false;\n        bool hasSpirV = false;\n        for (uint32_t i = 0; i < numTargets; ++i)\n        {\n            if (targets[i].language == ShadingLanguage::Dxil)\n            {\n                hasDxil = true;\n                if (targets[i].asModule)\n                {\n                    hasDxilModule = true;\n                }\n            }\n            else\n            {\n                hasSpirV = true;\n            }\n        }\n\n        ResultDesc dxilBinaryResult{};\n        if (hasDxil)\n        {\n            dxilBinaryResult = CompileToBinary(sourceOverride, options, ShadingLanguage::Dxil, false);\n        }\n\n        ResultDesc dxilModuleBinaryResult{};\n        if (hasDxilModule)\n        {\n            dxilModuleBinaryResult = CompileToBinary(sourceOverride, options, ShadingLanguage::Dxil, true);\n        }\n\n        ResultDesc spirvBinaryResult{};\n        if (hasSpirV)\n        {\n            spirvBinaryResult = CompileToBinary(sourceOverride, options, ShadingLanguage::SpirV, false);\n        }\n\n        for (uint32_t i = 0; i < numTargets; ++i)\n        {\n            ResultDesc binaryResult;\n            if (targets[i].language == ShadingLanguage::Dxil)\n            {\n                if (targets[i].asModule)\n                {\n                    binaryResult = dxilModuleBinaryResult;\n                }\n                else\n                {\n                    binaryResult = dxilBinaryResult;\n                }\n            }\n            else\n            {\n                binaryResult = spirvBinaryResult;\n            }\n\n            results[i] = ConvertBinary(binaryResult, sourceOverride, options, targets[i]);\n        }\n    }\n\n    Compiler::ResultDesc Compiler::Disassemble(const DisassembleDesc& source)\n    {\n        assert((source.language == ShadingLanguage::SpirV) || (source.language == ShadingLanguage::Dxil));\n\n        Compiler::ResultDesc ret;\n\n        ret.isText = true;\n\n        if (source.language == ShadingLanguage::SpirV)\n        {\n            const uint32_t* spirvIr = reinterpret_cast<const uint32_t*>(source.binary);\n            const size_t spirvSize = source.binarySize / sizeof(uint32_t);\n\n            spv_context context = spvContextCreate(SPV_ENV_UNIVERSAL_1_3);\n            uint32_t options = SPV_BINARY_TO_TEXT_OPTION_NONE | SPV_BINARY_TO_TEXT_OPTION_INDENT | SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES;\n            spv_text text = nullptr;\n            spv_diagnostic diagnostic = nullptr;\n\n            spv_result_t error = spvBinaryToText(context, spirvIr, spirvSize, options, &text, &diagnostic);\n            spvContextDestroy(context);\n\n            if (error)\n            {\n                ret.errorWarningMsg.Reset(diagnostic->error, static_cast<uint32_t>(std::strlen(diagnostic->error)));\n                ret.hasError = true;\n                spvDiagnosticDestroy(diagnostic);\n            }\n            else\n            {\n                const std::string disassemble = text->str;\n                ret.target.Reset(disassemble.data(), static_cast<uint32_t>(disassemble.size()));\n                ret.hasError = false;\n            }\n\n            spvTextDestroy(text);\n        }\n        else\n        {\n            CComPtr<IDxcBlobEncoding> blob;\n            CComPtr<IDxcBlobEncoding> disassembly;\n            IFT(Dxcompiler::Instance().Library()->CreateBlobWithEncodingOnHeapCopy(source.binary, source.binarySize, CP_UTF8, &blob));\n            IFT(Dxcompiler::Instance().Compiler()->Disassemble(blob, &disassembly));\n\n            if (disassembly != nullptr)\n            {\n                // Remove the tailing \\0\n                ret.target.Reset(disassembly->GetBufferPointer(), static_cast<uint32_t>(disassembly->GetBufferSize() - 1));\n                ret.hasError = false;\n            }\n            else\n            {\n                ret.hasError = true;\n            }\n        }\n\n        return ret;\n    }\n\n    bool Compiler::LinkSupport()\n    {\n        return Dxcompiler::Instance().LinkerSupport();\n    }\n\n    Compiler::ResultDesc Compiler::Link(const LinkDesc& modules, const Compiler::Options& options, const TargetDesc& target)\n    {\n        auto linker = Dxcompiler::Instance().CreateLinker();\n        IFTPTR(linker);\n\n        auto* library = Dxcompiler::Instance().Library();\n\n        std::vector<std::wstring> moduleNames(modules.numModules);\n        std::vector<const wchar_t*> moduleNamesUtf16(modules.numModules);\n        std::vector<CComPtr<IDxcBlobEncoding>> moduleBlobs(modules.numModules);\n        for (uint32_t i = 0; i < modules.numModules; ++i)\n        {\n            IFTARG(modules.modules[i] != nullptr);\n\n            IFT(library->CreateBlobWithEncodingOnHeapCopy(modules.modules[i]->target.Data(), modules.modules[i]->target.Size(), CP_UTF8,\n                                                          &moduleBlobs[i]));\n            IFTARG(moduleBlobs[i]->GetBufferSize() >= 4);\n\n            Unicode::UTF8ToUTF16String(modules.modules[i]->name, &moduleNames[i]);\n            moduleNamesUtf16[i] = moduleNames[i].c_str();\n            IFT(linker->RegisterLibrary(moduleNamesUtf16[i], moduleBlobs[i]));\n        }\n\n        std::wstring entryPointUtf16;\n        Unicode::UTF8ToUTF16String(modules.entryPoint, &entryPointUtf16);\n\n        const std::wstring shaderProfile = ShaderProfileName(modules.stage, options.shaderModel);\n        CComPtr<IDxcOperationResult> linkResult;\n        IFT(linker->Link(entryPointUtf16.c_str(), shaderProfile.c_str(), moduleNamesUtf16.data(),\n                         static_cast<UINT32>(moduleNamesUtf16.size()), nullptr, 0, &linkResult));\n\n        Compiler::ResultDesc binaryResult{};\n        ConvertDxcResult(binaryResult, linkResult, ShadingLanguage::Dxil, false);\n\n        Compiler::SourceDesc source{};\n        source.entryPoint = modules.entryPoint;\n        source.stage = modules.stage;\n        return ConvertBinary(binaryResult, source, options, target);\n    }\n} // namespace ShaderConductor\n\n#ifdef _WIN32\nBOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)\n{\n    SC_UNUSED(instance);\n\n    BOOL result = TRUE;\n    if (reason == DLL_PROCESS_DETACH)\n    {\n        dllDetaching = true;\n\n        if (reserved == 0)\n        {\n            // FreeLibrary has been called or the DLL load failed\n            Dxcompiler::Instance().Destroy();\n        }\n        else\n        {\n            // Process termination. We should not call FreeLibrary()\n            Dxcompiler::Instance().Terminate();\n        }\n    }\n\n    return result;\n}\n#endif\n"
  },
  {
    "path": "Source/Tests/CMakeLists.txt",
    "content": "# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the MIT License.\n\nset(EXE_NAME ShaderConductorTest)\n\nset(SOURCE_FILES\n    ShaderConductorTest.cpp\n)\n\nset(DATA_INC_FILES\n    Data/Input/Inc/HeaderA.hlsli\n    Data/Input/Inc/HeaderB.hlsli\n    Data/Input/Inc/HeaderEmpty.hlsli\n)\n\nset(DATA_FILES\n    Data/Input/CalcLight.hlsl\n    Data/Input/CalcLightDiffuse.hlsl\n    Data/Input/CalcLightDiffuseSpecular.hlsl\n    Data/Input/Common.hlsli\n    Data/Input/Constant_PS.hlsl\n    Data/Input/Constant_VS.hlsl\n    Data/Input/DetailTessellation_HS.hlsl\n    Data/Input/Fluid_CS.hlsl\n    Data/Input/IncludeEmptyHeader.hlsl\n    Data/Input/IncludeExist.hlsl\n    Data/Input/IncludeNotExist.hlsl\n    Data/Input/HalfDataType.hlsl\n    Data/Input/Particle_GS.hlsl\n    Data/Input/PassThrough_PS.hlsl\n    Data/Input/PassThrough_VS.hlsl\n    Data/Input/PNTriangles_DS.hlsl\n    Data/Input/ToneMapping_PS.hlsl\n    Data/Input/Transform_VS.hlsl\n)\n\nset_source_files_properties(${DATA_FILES}\n    PROPERTIES VS_TOOL_OVERRIDE \"None\"\n)\n\nsource_group(\"Source Files\" FILES ${SOURCE_FILES})\nsource_group(\"Data Files\\\\Input\" FILES ${DATA_FILES})\nsource_group(\"Data Files\\\\Input\\\\Inc\" FILES ${DATA_INC_FILES})\n\nadd_executable(${EXE_NAME} ${SOURCE_FILES} ${DATA_FILES} ${DATA_INC_FILES})\n\ntarget_compile_definitions(${EXE_NAME}\n    PRIVATE\n        -DTEST_DATA_DIR=\"${SC_ROOT_DIR}/Source/Tests/Data/\"\n)\ntarget_link_libraries(${EXE_NAME}\n    PRIVATE\n        ShaderConductor\n        gtest\n)\n\nadd_dependencies(${EXE_NAME} ShaderConductor gtest)\n\nset_target_properties(${EXE_NAME} PROPERTIES FOLDER \"Tests\")\n"
  },
  {
    "path": "Source/Tests/Data/Expected/CalcLight+Diffuse.Debug.dxilasm",
    "content": ";\n; Input signature:\n;\n; Name                 Index   Mask Register SysValue  Format   Used\n; -------------------- ----- ------ -------- -------- ------- ------\n; SV_Position              0   xyzw        0      POS   float       \n; NORMAL                   0   xyz         1     NONE   float   xyz \n; TEXCOORD                 0   xyz         2     NONE   float   xyz \n; TEXCOORD                 1   xyz         3     NONE   float       \n;\n;\n; Output signature:\n;\n; Name                 Index   Mask Register SysValue  Format   Used\n; -------------------- ----- ------ -------- -------- ------- ------\n; SV_Target                0   xyzw        0   TARGET   float   xyzw\n;\n; shader debug name: d81432b398a9151e6a076b6b827882eb.pdb\n; shader hash: d81432b398a9151e6a076b6b827882eb\n;\n; Pipeline Runtime Information: \n;\n; Pixel Shader\n; DepthOutput=0\n; SampleFrequency=0\n;\n;\n; Input signature:\n;\n; Name                 Index             InterpMode DynIdx\n; -------------------- ----- ---------------------- ------\n; SV_Position              0          noperspective       \n; NORMAL                   0                 linear       \n; TEXCOORD                 0                 linear       \n; TEXCOORD                 1                 linear       \n;\n; Output signature:\n;\n; Name                 Index             InterpMode DynIdx\n; -------------------- ----- ---------------------- ------\n; SV_Target                0                              \n;\n; Buffer Definitions:\n;\n; cbuffer cbPS\n; {\n;\n;   struct cbPS\n;   {\n;\n;       float3 diffColor;                             ; Offset:    0\n;       float3 specColor;                             ; Offset:   16\n;       float shininess;                              ; Offset:   28\n;   \n;   } cbPS;                                           ; Offset:    0 Size:    32\n;\n; }\n;\n;\n; Resource Bindings:\n;\n; Name                                 Type  Format         Dim      ID      HLSL Bind  Count\n; ------------------------------ ---------- ------- ----------- ------- -------------- ------\n; cbPS                              cbuffer      NA          NA     CB0            cb0     1\n;\n;\n; ViewId state:\n;\n; Number of inputs: 15, outputs: 4\n; Outputs dependent on ViewId: {  }\n; Inputs contributing to computation of Outputs:\n;   output 0 depends on inputs: { 4, 5, 6, 8, 9, 10 }\n;   output 1 depends on inputs: { 4, 5, 6, 8, 9, 10 }\n;   output 2 depends on inputs: { 4, 5, 6, 8, 9, 10 }\n;\ntarget triple = \"dxil-ms-dx\"\n\n%cbPS = type { <3 x float>, <3 x float>, float }\n%dx.types.CBufRet.f32 = type { float, float, float, float }\n%dx.types.Handle = type { i8* }\n\n@cbPS = external constant %cbPS\n\n; Function Attrs: nounwind readnone\ndeclare float @dx.op.loadInput.f32(i32, i32, i32, i8, i32) #0\n\n; Function Attrs: nounwind readonly\ndeclare %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32, %dx.types.Handle, i32) #1\n\n; Function Attrs: nounwind\ndeclare void @dx.op.storeOutput.f32(i32, i32, i32, i8, float) #2\n\n; Function Attrs: nounwind readnone\ndeclare float @dx.op.dot3.f32(i32, float, float, float, float, float, float) #0\n\n; Function Attrs: nounwind readnone\ndeclare float @dx.op.binary.f32(i32, float, float) #0\n\ndefine void @main() {\nentry:\n  %cbPS_cbuffer = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 2, i32 0, i32 0, i1 false)  ; CreateHandle(resourceClass,rangeId,index,nonUniformIndex)\n  %0 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 0, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %1 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 1, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %2 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 2, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %3 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 0, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %4 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 1, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %5 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 2, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %6 = call %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %cbPS_cbuffer, i32 0)  ; CBufferLoadLegacy(handle,regIndex)\n  %7 = extractvalue %dx.types.CBufRet.f32 %6, 0\n  %8 = extractvalue %dx.types.CBufRet.f32 %6, 1\n  %9 = extractvalue %dx.types.CBufRet.f32 %6, 2\n  %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)\n  %mul.i0.i = fmul fast float %10, %7\n  %mul.i1.i = fmul fast float %10, %8\n  %mul.i2.i = fmul fast float %10, %9\n  %FMax.i = call float @dx.op.binary.f32(i32 35, float %mul.i0.i, float 0.000000e+00) #2  ; FMax(a,b)\n  %FMax2.i = call float @dx.op.binary.f32(i32 35, float %mul.i1.i, float 0.000000e+00) #2  ; FMax(a,b)\n  %FMax3.i = call float @dx.op.binary.f32(i32 35, float %mul.i2.i, float 0.000000e+00) #2  ; FMax(a,b)\n  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 0, float %FMax.i)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)\n  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 1, float %FMax2.i)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)\n  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 2, float %FMax3.i)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)\n  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 3, float 1.000000e+00)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)\n  ret void\n}\n\n; Function Attrs: nounwind readonly\ndeclare %dx.types.Handle @dx.op.createHandle(i32, i8, i32, i32, i1) #1\n\nattributes #0 = { nounwind readnone }\nattributes #1 = { nounwind readonly }\nattributes #2 = { nounwind }\n\n!llvm.ident = !{!0, !0}\n!dx.version = !{!1}\n!dx.valver = !{!2}\n!dx.shaderModel = !{!3}\n!dx.resources = !{!4}\n!dx.typeAnnotations = !{!7, !12}\n!dx.viewIdState = !{!16}\n!dx.entryPoints = !{!17}\n\n!0 = !{!\"clang version 3.7 (tags/RELEASE_370/final)\"}\n!1 = !{i32 1, i32 0}\n!2 = !{i32 1, i32 6}\n!3 = !{!\"ps\", i32 6, i32 0}\n!4 = !{null, null, !5, null}\n!5 = !{!6}\n!6 = !{i32 0, %cbPS* undef, !\"cbPS\", i32 0, i32 0, i32 1, i32 32, null}\n!7 = !{i32 0, %cbPS undef, !8}\n!8 = !{i32 32, !9, !10, !11}\n!9 = !{i32 6, !\"diffColor\", i32 3, i32 0, i32 7, i32 9}\n!10 = !{i32 6, !\"specColor\", i32 3, i32 16, i32 7, i32 9}\n!11 = !{i32 6, !\"shininess\", i32 3, i32 28, i32 7, i32 9}\n!12 = !{i32 1, void ()* @main, !13}\n!13 = !{!14}\n!14 = !{i32 0, !15, !15}\n!15 = !{}\n!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]}\n!17 = !{void ()* @main, !\"main\", !18, !4, null}\n!18 = !{!19, !27, null}\n!19 = !{!20, !22, !24, !25}\n!20 = !{i32 0, !\"SV_Position\", i8 9, i8 3, !21, i8 4, i32 1, i8 4, i32 0, i8 0, null}\n!21 = !{i32 0}\n!22 = !{i32 1, !\"NORMAL\", i8 9, i8 0, !21, i8 2, i32 1, i8 3, i32 1, i8 0, !23}\n!23 = !{i32 3, i32 7}\n!24 = !{i32 2, !\"TEXCOORD\", i8 9, i8 0, !21, i8 2, i32 1, i8 3, i32 2, i8 0, !23}\n!25 = !{i32 3, !\"TEXCOORD\", i8 9, i8 0, !26, i8 2, i32 1, i8 3, i32 3, i8 0, null}\n!26 = !{i32 1}\n!27 = !{!28}\n!28 = !{i32 0, !\"SV_Target\", i8 9, i8 16, !21, i8 0, i32 1, i8 4, i32 0, i8 0, !29}\n!29 = !{i32 3, i32 15}\n"
  },
  {
    "path": "Source/Tests/Data/Expected/CalcLight+Diffuse.Release.dxilasm",
    "content": ";\n; Input signature:\n;\n; Name                 Index   Mask Register SysValue  Format   Used\n; -------------------- ----- ------ -------- -------- ------- ------\n; SV_Position              0   xyzw        0      POS   float       \n; NORMAL                   0   xyz         1     NONE   float   xyz \n; TEXCOORD                 0   xyz         2     NONE   float   xyz \n; TEXCOORD                 1   xyz         3     NONE   float       \n;\n;\n; Output signature:\n;\n; Name                 Index   Mask Register SysValue  Format   Used\n; -------------------- ----- ------ -------- -------- ------- ------\n; SV_Target                0   xyzw        0   TARGET   float   xyzw\n;\n; shader debug name: ad90c6ff56d81fd333e64a2bf70453fc.pdb\n; shader hash: ad90c6ff56d81fd333e64a2bf70453fc\n;\n; Pipeline Runtime Information: \n;\n; Pixel Shader\n; DepthOutput=0\n; SampleFrequency=0\n;\n;\n; Input signature:\n;\n; Name                 Index             InterpMode DynIdx\n; -------------------- ----- ---------------------- ------\n; SV_Position              0          noperspective       \n; NORMAL                   0                 linear       \n; TEXCOORD                 0                 linear       \n; TEXCOORD                 1                 linear       \n;\n; Output signature:\n;\n; Name                 Index             InterpMode DynIdx\n; -------------------- ----- ---------------------- ------\n; SV_Target                0                              \n;\n; Buffer Definitions:\n;\n; cbuffer cbPS\n; {\n;\n;   struct cbPS\n;   {\n;\n;       float3 diffColor;                             ; Offset:    0\n;       float3 specColor;                             ; Offset:   16\n;       float shininess;                              ; Offset:   28\n;   \n;   } cbPS;                                           ; Offset:    0 Size:    32\n;\n; }\n;\n;\n; Resource Bindings:\n;\n; Name                                 Type  Format         Dim      ID      HLSL Bind  Count\n; ------------------------------ ---------- ------- ----------- ------- -------------- ------\n; cbPS                              cbuffer      NA          NA     CB0            cb0     1\n;\n;\n; ViewId state:\n;\n; Number of inputs: 15, outputs: 4\n; Outputs dependent on ViewId: {  }\n; Inputs contributing to computation of Outputs:\n;   output 0 depends on inputs: { 4, 5, 6, 8, 9, 10 }\n;   output 1 depends on inputs: { 4, 5, 6, 8, 9, 10 }\n;   output 2 depends on inputs: { 4, 5, 6, 8, 9, 10 }\n;\ntarget triple = \"dxil-ms-dx\"\n\n%cbPS = type { <3 x float>, <3 x float>, float }\n%dx.types.CBufRet.f32 = type { float, float, float, float }\n%dx.types.Handle = type { i8* }\n\n@cbPS = external constant %cbPS\n\n; Function Attrs: nounwind readnone\ndeclare float @dx.op.loadInput.f32(i32, i32, i32, i8, i32) #0\n\n; Function Attrs: nounwind readonly\ndeclare %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32, %dx.types.Handle, i32) #1\n\n; Function Attrs: nounwind\ndeclare void @dx.op.storeOutput.f32(i32, i32, i32, i8, float) #2\n\n; Function Attrs: nounwind readnone\ndeclare float @dx.op.dot3.f32(i32, float, float, float, float, float, float) #0\n\n; Function Attrs: nounwind readnone\ndeclare float @dx.op.binary.f32(i32, float, float) #0\n\ndefine void @main() {\n  %cbPS_cbuffer = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 2, i32 0, i32 0, i1 false)  ; CreateHandle(resourceClass,rangeId,index,nonUniformIndex)\n  %1 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 0, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %2 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 1, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %3 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 2, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %4 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 0, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %5 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 1, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %6 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 2, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %7 = call %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %cbPS_cbuffer, i32 0)  ; CBufferLoadLegacy(handle,regIndex)\n  %8 = extractvalue %dx.types.CBufRet.f32 %7, 0\n  %9 = extractvalue %dx.types.CBufRet.f32 %7, 1\n  %10 = extractvalue %dx.types.CBufRet.f32 %7, 2\n  %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)\n  %.i0.i = fmul fast float %11, %8\n  %.i1.i = fmul fast float %11, %9\n  %.i2.i = fmul fast float %11, %10\n  %FMax.i = call float @dx.op.binary.f32(i32 35, float %.i0.i, float 0.000000e+00) #2  ; FMax(a,b)\n  %FMax1.i = call float @dx.op.binary.f32(i32 35, float %.i1.i, float 0.000000e+00) #2  ; FMax(a,b)\n  %FMax2.i = call float @dx.op.binary.f32(i32 35, float %.i2.i, float 0.000000e+00) #2  ; FMax(a,b)\n  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 0, float %FMax.i)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)\n  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 1, float %FMax1.i)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)\n  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 2, float %FMax2.i)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)\n  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 3, float 1.000000e+00)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)\n  ret void\n}\n\n; Function Attrs: nounwind readonly\ndeclare %dx.types.Handle @dx.op.createHandle(i32, i8, i32, i32, i1) #1\n\nattributes #0 = { nounwind readnone }\nattributes #1 = { nounwind readonly }\nattributes #2 = { nounwind }\n\n!llvm.ident = !{!0, !0}\n!dx.version = !{!1}\n!dx.valver = !{!2}\n!dx.shaderModel = !{!3}\n!dx.resources = !{!4}\n!dx.typeAnnotations = !{!7, !12}\n!dx.viewIdState = !{!16}\n!dx.entryPoints = !{!17}\n\n!0 = !{!\"clang version 3.7 (tags/RELEASE_370/final)\"}\n!1 = !{i32 1, i32 0}\n!2 = !{i32 1, i32 6}\n!3 = !{!\"ps\", i32 6, i32 0}\n!4 = !{null, null, !5, null}\n!5 = !{!6}\n!6 = !{i32 0, %cbPS* undef, !\"cbPS\", i32 0, i32 0, i32 1, i32 32, null}\n!7 = !{i32 0, %cbPS undef, !8}\n!8 = !{i32 32, !9, !10, !11}\n!9 = !{i32 6, !\"diffColor\", i32 3, i32 0, i32 7, i32 9}\n!10 = !{i32 6, !\"specColor\", i32 3, i32 16, i32 7, i32 9}\n!11 = !{i32 6, !\"shininess\", i32 3, i32 28, i32 7, i32 9}\n!12 = !{i32 1, void ()* @main, !13}\n!13 = !{!14}\n!14 = !{i32 0, !15, !15}\n!15 = !{}\n!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]}\n!17 = !{void ()* @main, !\"main\", !18, !4, null}\n!18 = !{!19, !27, null}\n!19 = !{!20, !22, !24, !25}\n!20 = !{i32 0, !\"SV_Position\", i8 9, i8 3, !21, i8 4, i32 1, i8 4, i32 0, i8 0, null}\n!21 = !{i32 0}\n!22 = !{i32 1, !\"NORMAL\", i8 9, i8 0, !21, i8 2, i32 1, i8 3, i32 1, i8 0, !23}\n!23 = !{i32 3, i32 7}\n!24 = !{i32 2, !\"TEXCOORD\", i8 9, i8 0, !21, i8 2, i32 1, i8 3, i32 2, i8 0, !23}\n!25 = !{i32 3, !\"TEXCOORD\", i8 9, i8 0, !26, i8 2, i32 1, i8 3, i32 3, i8 0, null}\n!26 = !{i32 1}\n!27 = !{!28}\n!28 = !{i32 0, !\"SV_Target\", i8 9, i8 16, !21, i8 0, i32 1, i8 4, i32 0, i8 0, !29}\n!29 = !{i32 3, i32 15}\n"
  },
  {
    "path": "Source/Tests/Data/Expected/CalcLight+DiffuseSpecular.Debug.dxilasm",
    "content": ";\n; Input signature:\n;\n; Name                 Index   Mask Register SysValue  Format   Used\n; -------------------- ----- ------ -------- -------- ------- ------\n; SV_Position              0   xyzw        0      POS   float       \n; NORMAL                   0   xyz         1     NONE   float   xyz \n; TEXCOORD                 0   xyz         2     NONE   float   xyz \n; TEXCOORD                 1   xyz         3     NONE   float   xyz \n;\n;\n; Output signature:\n;\n; Name                 Index   Mask Register SysValue  Format   Used\n; -------------------- ----- ------ -------- -------- ------- ------\n; SV_Target                0   xyzw        0   TARGET   float   xyzw\n;\n; shader debug name: 65620ef187dc1e38cb91d8208665ef7d.pdb\n; shader hash: 65620ef187dc1e38cb91d8208665ef7d\n;\n; Pipeline Runtime Information: \n;\n; Pixel Shader\n; DepthOutput=0\n; SampleFrequency=0\n;\n;\n; Input signature:\n;\n; Name                 Index             InterpMode DynIdx\n; -------------------- ----- ---------------------- ------\n; SV_Position              0          noperspective       \n; NORMAL                   0                 linear       \n; TEXCOORD                 0                 linear       \n; TEXCOORD                 1                 linear       \n;\n; Output signature:\n;\n; Name                 Index             InterpMode DynIdx\n; -------------------- ----- ---------------------- ------\n; SV_Target                0                              \n;\n; Buffer Definitions:\n;\n; cbuffer cbPS\n; {\n;\n;   struct cbPS\n;   {\n;\n;       float3 diffColor;                             ; Offset:    0\n;       float3 specColor;                             ; Offset:   16\n;       float shininess;                              ; Offset:   28\n;   \n;   } cbPS;                                           ; Offset:    0 Size:    32\n;\n; }\n;\n;\n; Resource Bindings:\n;\n; Name                                 Type  Format         Dim      ID      HLSL Bind  Count\n; ------------------------------ ---------- ------- ----------- ------- -------------- ------\n; cbPS                              cbuffer      NA          NA     CB0            cb0     1\n;\n;\n; ViewId state:\n;\n; Number of inputs: 15, outputs: 4\n; Outputs dependent on ViewId: {  }\n; Inputs contributing to computation of Outputs:\n;   output 0 depends on inputs: { 4, 5, 6, 8, 9, 10, 12, 13, 14 }\n;   output 1 depends on inputs: { 4, 5, 6, 8, 9, 10, 12, 13, 14 }\n;   output 2 depends on inputs: { 4, 5, 6, 8, 9, 10, 12, 13, 14 }\n;\ntarget triple = \"dxil-ms-dx\"\n\n%cbPS = type { <3 x float>, <3 x float>, float }\n%dx.types.CBufRet.f32 = type { float, float, float, float }\n%dx.types.Handle = type { i8* }\n\n@cbPS = external constant %cbPS\n\n; Function Attrs: nounwind readnone\ndeclare float @dx.op.loadInput.f32(i32, i32, i32, i8, i32) #0\n\n; Function Attrs: nounwind readonly\ndeclare %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32, %dx.types.Handle, i32) #1\n\n; Function Attrs: nounwind\ndeclare void @dx.op.storeOutput.f32(i32, i32, i32, i8, float) #2\n\n; Function Attrs: nounwind readnone\ndeclare float @dx.op.dot3.f32(i32, float, float, float, float, float, float) #0\n\n; Function Attrs: nounwind readnone\ndeclare float @dx.op.binary.f32(i32, float, float) #0\n\n; Function Attrs: nounwind readnone\ndeclare float @dx.op.unary.f32(i32, float) #0\n\ndefine void @main() {\nentry:\n  %cbPS_cbuffer = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 2, i32 0, i32 0, i1 false)  ; CreateHandle(resourceClass,rangeId,index,nonUniformIndex)\n  %0 = call float @dx.op.loadInput.f32(i32 4, i32 3, i32 0, i8 0, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %1 = call float @dx.op.loadInput.f32(i32 4, i32 3, i32 0, i8 1, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %2 = call float @dx.op.loadInput.f32(i32 4, i32 3, i32 0, i8 2, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %3 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 0, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %4 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 1, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %5 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 2, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %6 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 0, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %7 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 1, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %8 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 2, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %9 = call %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %cbPS_cbuffer, i32 1)  ; CBufferLoadLegacy(handle,regIndex)\n  %10 = extractvalue %dx.types.CBufRet.f32 %9, 3\n  %11 = extractvalue %dx.types.CBufRet.f32 %9, 0\n  %12 = extractvalue %dx.types.CBufRet.f32 %9, 1\n  %13 = extractvalue %dx.types.CBufRet.f32 %9, 2\n  %14 = call %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %cbPS_cbuffer, i32 0)  ; CBufferLoadLegacy(handle,regIndex)\n  %15 = extractvalue %dx.types.CBufRet.f32 %14, 0\n  %16 = extractvalue %dx.types.CBufRet.f32 %14, 1\n  %17 = extractvalue %dx.types.CBufRet.f32 %14, 2\n  %add.i.i.i = fadd fast float %10, 2.000000e+00\n  %div.i.i.i = fmul fast float %add.i.i.i, 1.250000e-01\n  %18 = call float @dx.op.dot3.f32(i32 55, float %0, float %1, float %2, float %6, float %7, float %8) #2  ; Dot3(ax,ay,az,bx,by,bz)\n  %FMax.i = call float @dx.op.binary.f32(i32 35, float %18, float 0.000000e+00) #2  ; FMax(a,b)\n  %Log3.i = call float @dx.op.unary.f32(i32 23, float %FMax.i) #2  ; Log(value)\n  %19 = fmul fast float %Log3.i, %10\n  %Exp4.i = call float @dx.op.unary.f32(i32 21, float %19) #2  ; Exp(value)\n  %mul.i.i0.i = fmul fast float %Exp4.i, %div.i.i.i\n  %20 = 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)\n  %Saturate.i = call float @dx.op.unary.f32(i32 7, float %20) #2  ; Saturate(value)\n  %cmp.i.i.i0.i = fcmp fast ogt float %11, 0.000000e+00\n  %cmp.i.i.i1.i = fcmp fast ogt float %12, 0.000000e+00\n  %cmp.i.i.i2.i = fcmp fast ogt float %13, 0.000000e+00\n  %sub.i.i.i0.i = fsub fast float 1.000000e+00, %11\n  %sub.i.i.i1.i = fsub fast float 1.000000e+00, %12\n  %sub.i.i.i2.i = fsub fast float 1.000000e+00, %13\n  %sub2.i.i.i = fsub fast float 1.000000e+00, %Saturate.i\n  %Log.i = call float @dx.op.unary.f32(i32 23, float %sub2.i.i.i) #2  ; Log(value)\n  %21 = fmul fast float %Log.i, 5.000000e+00\n  %Exp.i = call float @dx.op.unary.f32(i32 21, float %21) #2  ; Exp(value)\n  %mul.i.i.i0.i = fmul fast float %Exp.i, %sub.i.i.i0.i\n  %mul.i.i.i1.i = fmul fast float %Exp.i, %sub.i.i.i1.i\n  %mul.i.i.i2.i = fmul fast float %Exp.i, %sub.i.i.i2.i\n  %add.i.4.i.i0.i = fadd fast float %mul.i.i.i0.i, %11\n  %add.i.4.i.i1.i = fadd fast float %mul.i.i.i1.i, %12\n  %add.i.4.i.i2.i = fadd fast float %mul.i.i.i2.i, %13\n  %22 = select i1 %cmp.i.i.i0.i, float %add.i.4.i.i0.i, float 0.000000e+00\n  %23 = select i1 %cmp.i.i.i1.i, float %add.i.4.i.i1.i, float 0.000000e+00\n  %24 = select i1 %cmp.i.i.i2.i, float %add.i.4.i.i2.i, float 0.000000e+00\n  %mul3.i.i0.i = fmul fast float %mul.i.i0.i, %22\n  %mul3.i.i1.i = fmul fast float %mul.i.i0.i, %23\n  %mul3.i.i2.i = fmul fast float %mul.i.i0.i, %24\n  %add.i0.i = fadd fast float %mul3.i.i0.i, %15\n  %add.i1.i = fadd fast float %mul3.i.i1.i, %16\n  %add.i2.i = fadd fast float %mul3.i.i2.i, %17\n  %25 = call float @dx.op.dot3.f32(i32 55, float %6, float %7, float %8, float %3, float %4, float %5) #2  ; Dot3(ax,ay,az,bx,by,bz)\n  %mul.i0.i = fmul fast float %add.i0.i, %25\n  %mul.i1.i = fmul fast float %add.i1.i, %25\n  %mul.i2.i = fmul fast float %add.i2.i, %25\n  %FMax5.i = call float @dx.op.binary.f32(i32 35, float %mul.i0.i, float 0.000000e+00) #2  ; FMax(a,b)\n  %FMax6.i = call float @dx.op.binary.f32(i32 35, float %mul.i1.i, float 0.000000e+00) #2  ; FMax(a,b)\n  %FMax7.i = call float @dx.op.binary.f32(i32 35, float %mul.i2.i, float 0.000000e+00) #2  ; FMax(a,b)\n  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 0, float %FMax5.i)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)\n  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 1, float %FMax6.i)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)\n  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 2, float %FMax7.i)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)\n  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 3, float 1.000000e+00)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)\n  ret void\n}\n\n; Function Attrs: nounwind readonly\ndeclare %dx.types.Handle @dx.op.createHandle(i32, i8, i32, i32, i1) #1\n\nattributes #0 = { nounwind readnone }\nattributes #1 = { nounwind readonly }\nattributes #2 = { nounwind }\n\n!llvm.ident = !{!0, !0}\n!dx.version = !{!1}\n!dx.valver = !{!2}\n!dx.shaderModel = !{!3}\n!dx.resources = !{!4}\n!dx.typeAnnotations = !{!7, !12}\n!dx.viewIdState = !{!16}\n!dx.entryPoints = !{!17}\n\n!0 = !{!\"clang version 3.7 (tags/RELEASE_370/final)\"}\n!1 = !{i32 1, i32 0}\n!2 = !{i32 1, i32 6}\n!3 = !{!\"ps\", i32 6, i32 0}\n!4 = !{null, null, !5, null}\n!5 = !{!6}\n!6 = !{i32 0, %cbPS* undef, !\"cbPS\", i32 0, i32 0, i32 1, i32 32, null}\n!7 = !{i32 0, %cbPS undef, !8}\n!8 = !{i32 32, !9, !10, !11}\n!9 = !{i32 6, !\"diffColor\", i32 3, i32 0, i32 7, i32 9}\n!10 = !{i32 6, !\"specColor\", i32 3, i32 16, i32 7, i32 9}\n!11 = !{i32 6, !\"shininess\", i32 3, i32 28, i32 7, i32 9}\n!12 = !{i32 1, void ()* @main, !13}\n!13 = !{!14}\n!14 = !{i32 0, !15, !15}\n!15 = !{}\n!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 7, i32 7, i32 7]}\n!17 = !{void ()* @main, !\"main\", !18, !4, null}\n!18 = !{!19, !27, null}\n!19 = !{!20, !22, !24, !25}\n!20 = !{i32 0, !\"SV_Position\", i8 9, i8 3, !21, i8 4, i32 1, i8 4, i32 0, i8 0, null}\n!21 = !{i32 0}\n!22 = !{i32 1, !\"NORMAL\", i8 9, i8 0, !21, i8 2, i32 1, i8 3, i32 1, i8 0, !23}\n!23 = !{i32 3, i32 7}\n!24 = !{i32 2, !\"TEXCOORD\", i8 9, i8 0, !21, i8 2, i32 1, i8 3, i32 2, i8 0, !23}\n!25 = !{i32 3, !\"TEXCOORD\", i8 9, i8 0, !26, i8 2, i32 1, i8 3, i32 3, i8 0, !23}\n!26 = !{i32 1}\n!27 = !{!28}\n!28 = !{i32 0, !\"SV_Target\", i8 9, i8 16, !21, i8 0, i32 1, i8 4, i32 0, i8 0, !29}\n!29 = !{i32 3, i32 15}\n"
  },
  {
    "path": "Source/Tests/Data/Expected/CalcLight+DiffuseSpecular.Release.dxilasm",
    "content": ";\n; Input signature:\n;\n; Name                 Index   Mask Register SysValue  Format   Used\n; -------------------- ----- ------ -------- -------- ------- ------\n; SV_Position              0   xyzw        0      POS   float       \n; NORMAL                   0   xyz         1     NONE   float   xyz \n; TEXCOORD                 0   xyz         2     NONE   float   xyz \n; TEXCOORD                 1   xyz         3     NONE   float   xyz \n;\n;\n; Output signature:\n;\n; Name                 Index   Mask Register SysValue  Format   Used\n; -------------------- ----- ------ -------- -------- ------- ------\n; SV_Target                0   xyzw        0   TARGET   float   xyzw\n;\n; shader debug name: 7f14de892298c5aa041b655c7a09b6e5.pdb\n; shader hash: 7f14de892298c5aa041b655c7a09b6e5\n;\n; Pipeline Runtime Information: \n;\n; Pixel Shader\n; DepthOutput=0\n; SampleFrequency=0\n;\n;\n; Input signature:\n;\n; Name                 Index             InterpMode DynIdx\n; -------------------- ----- ---------------------- ------\n; SV_Position              0          noperspective       \n; NORMAL                   0                 linear       \n; TEXCOORD                 0                 linear       \n; TEXCOORD                 1                 linear       \n;\n; Output signature:\n;\n; Name                 Index             InterpMode DynIdx\n; -------------------- ----- ---------------------- ------\n; SV_Target                0                              \n;\n; Buffer Definitions:\n;\n; cbuffer cbPS\n; {\n;\n;   struct cbPS\n;   {\n;\n;       float3 diffColor;                             ; Offset:    0\n;       float3 specColor;                             ; Offset:   16\n;       float shininess;                              ; Offset:   28\n;   \n;   } cbPS;                                           ; Offset:    0 Size:    32\n;\n; }\n;\n;\n; Resource Bindings:\n;\n; Name                                 Type  Format         Dim      ID      HLSL Bind  Count\n; ------------------------------ ---------- ------- ----------- ------- -------------- ------\n; cbPS                              cbuffer      NA          NA     CB0            cb0     1\n;\n;\n; ViewId state:\n;\n; Number of inputs: 15, outputs: 4\n; Outputs dependent on ViewId: {  }\n; Inputs contributing to computation of Outputs:\n;   output 0 depends on inputs: { 4, 5, 6, 8, 9, 10, 12, 13, 14 }\n;   output 1 depends on inputs: { 4, 5, 6, 8, 9, 10, 12, 13, 14 }\n;   output 2 depends on inputs: { 4, 5, 6, 8, 9, 10, 12, 13, 14 }\n;\ntarget triple = \"dxil-ms-dx\"\n\n%cbPS = type { <3 x float>, <3 x float>, float }\n%dx.types.CBufRet.f32 = type { float, float, float, float }\n%dx.types.Handle = type { i8* }\n\n@cbPS = external constant %cbPS\n\n; Function Attrs: nounwind readnone\ndeclare float @dx.op.loadInput.f32(i32, i32, i32, i8, i32) #0\n\n; Function Attrs: nounwind readonly\ndeclare %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32, %dx.types.Handle, i32) #1\n\n; Function Attrs: nounwind\ndeclare void @dx.op.storeOutput.f32(i32, i32, i32, i8, float) #2\n\n; Function Attrs: nounwind readnone\ndeclare float @dx.op.dot3.f32(i32, float, float, float, float, float, float) #0\n\n; Function Attrs: nounwind readnone\ndeclare float @dx.op.binary.f32(i32, float, float) #0\n\n; Function Attrs: nounwind readnone\ndeclare float @dx.op.unary.f32(i32, float) #0\n\ndefine void @main() {\n  %cbPS_cbuffer = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 2, i32 0, i32 0, i1 false)  ; CreateHandle(resourceClass,rangeId,index,nonUniformIndex)\n  %1 = call float @dx.op.loadInput.f32(i32 4, i32 3, i32 0, i8 0, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %2 = call float @dx.op.loadInput.f32(i32 4, i32 3, i32 0, i8 1, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %3 = call float @dx.op.loadInput.f32(i32 4, i32 3, i32 0, i8 2, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %4 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 0, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %5 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 1, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %6 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 2, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %7 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 0, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %8 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 1, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %9 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 2, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)\n  %10 = call %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %cbPS_cbuffer, i32 1)  ; CBufferLoadLegacy(handle,regIndex)\n  %11 = extractvalue %dx.types.CBufRet.f32 %10, 3\n  %12 = extractvalue %dx.types.CBufRet.f32 %10, 0\n  %13 = extractvalue %dx.types.CBufRet.f32 %10, 1\n  %14 = extractvalue %dx.types.CBufRet.f32 %10, 2\n  %15 = call %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %cbPS_cbuffer, i32 0)  ; CBufferLoadLegacy(handle,regIndex)\n  %16 = extractvalue %dx.types.CBufRet.f32 %15, 0\n  %17 = extractvalue %dx.types.CBufRet.f32 %15, 1\n  %18 = extractvalue %dx.types.CBufRet.f32 %15, 2\n  %19 = fadd fast float %11, 2.000000e+00\n  %20 = fmul fast float %19, 1.250000e-01\n  %21 = call float @dx.op.dot3.f32(i32 55, float %1, float %2, float %3, float %7, float %8, float %9) #2  ; Dot3(ax,ay,az,bx,by,bz)\n  %FMax.i = call float @dx.op.binary.f32(i32 35, float %21, float 0.000000e+00) #2  ; FMax(a,b)\n  %Log1.i = call float @dx.op.unary.f32(i32 23, float %FMax.i) #2  ; Log(value)\n  %22 = fmul fast float %Log1.i, %11\n  %Exp2.i = call float @dx.op.unary.f32(i32 21, float %22) #2  ; Exp(value)\n  %.i0.i = fmul fast float %Exp2.i, %20\n  %23 = 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)\n  %Saturate.i = call float @dx.op.unary.f32(i32 7, float %23) #2  ; Saturate(value)\n  %.i06.i = fcmp fast ogt float %12, 0.000000e+00\n  %.i17.i = fcmp fast ogt float %13, 0.000000e+00\n  %.i28.i = fcmp fast ogt float %14, 0.000000e+00\n  %.i010.i = fsub fast float 1.000000e+00, %12\n  %.i112.i = fsub fast float 1.000000e+00, %13\n  %.i214.i = fsub fast float 1.000000e+00, %14\n  %24 = fsub fast float 1.000000e+00, %Saturate.i\n  %Log.i = call float @dx.op.unary.f32(i32 23, float %24) #2  ; Log(value)\n  %25 = fmul fast float %Log.i, 5.000000e+00\n  %Exp.i = call float @dx.op.unary.f32(i32 21, float %25) #2  ; Exp(value)\n  %.i015.i = fmul fast float %Exp.i, %.i010.i\n  %.i116.i = fmul fast float %Exp.i, %.i112.i\n  %.i217.i = fmul fast float %Exp.i, %.i214.i\n  %.i019.i = fadd fast float %.i015.i, %12\n  %.i121.i = fadd fast float %.i116.i, %13\n  %.i223.i = fadd fast float %.i217.i, %14\n  %26 = select i1 %.i06.i, float %.i019.i, float 0.000000e+00\n  %27 = select i1 %.i17.i, float %.i121.i, float 0.000000e+00\n  %28 = select i1 %.i28.i, float %.i223.i, float 0.000000e+00\n  %.i024.i = fmul fast float %.i0.i, %26\n  %.i125.i = fmul fast float %.i0.i, %27\n  %.i226.i = fmul fast float %.i0.i, %28\n  %.i027.i = fadd fast float %.i024.i, %16\n  %.i128.i = fadd fast float %.i125.i, %17\n  %.i229.i = fadd fast float %.i226.i, %18\n  %29 = call float @dx.op.dot3.f32(i32 55, float %7, float %8, float %9, float %4, float %5, float %6) #2  ; Dot3(ax,ay,az,bx,by,bz)\n  %.i030.i = fmul fast float %.i027.i, %29\n  %.i131.i = fmul fast float %.i128.i, %29\n  %.i232.i = fmul fast float %.i229.i, %29\n  %FMax3.i = call float @dx.op.binary.f32(i32 35, float %.i030.i, float 0.000000e+00) #2  ; FMax(a,b)\n  %FMax4.i = call float @dx.op.binary.f32(i32 35, float %.i131.i, float 0.000000e+00) #2  ; FMax(a,b)\n  %FMax5.i = call float @dx.op.binary.f32(i32 35, float %.i232.i, float 0.000000e+00) #2  ; FMax(a,b)\n  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 0, float %FMax3.i)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)\n  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 1, float %FMax4.i)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)\n  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 2, float %FMax5.i)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)\n  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 3, float 1.000000e+00)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)\n  ret void\n}\n\n; Function Attrs: nounwind readonly\ndeclare %dx.types.Handle @dx.op.createHandle(i32, i8, i32, i32, i1) #1\n\nattributes #0 = { nounwind readnone }\nattributes #1 = { nounwind readonly }\nattributes #2 = { nounwind }\n\n!llvm.ident = !{!0, !0}\n!dx.version = !{!1}\n!dx.valver = !{!2}\n!dx.shaderModel = !{!3}\n!dx.resources = !{!4}\n!dx.typeAnnotations = !{!7, !12}\n!dx.viewIdState = !{!16}\n!dx.entryPoints = !{!17}\n\n!0 = !{!\"clang version 3.7 (tags/RELEASE_370/final)\"}\n!1 = !{i32 1, i32 0}\n!2 = !{i32 1, i32 6}\n!3 = !{!\"ps\", i32 6, i32 0}\n!4 = !{null, null, !5, null}\n!5 = !{!6}\n!6 = !{i32 0, %cbPS* undef, !\"cbPS\", i32 0, i32 0, i32 1, i32 32, null}\n!7 = !{i32 0, %cbPS undef, !8}\n!8 = !{i32 32, !9, !10, !11}\n!9 = !{i32 6, !\"diffColor\", i32 3, i32 0, i32 7, i32 9}\n!10 = !{i32 6, !\"specColor\", i32 3, i32 16, i32 7, i32 9}\n!11 = !{i32 6, !\"shininess\", i32 3, i32 28, i32 7, i32 9}\n!12 = !{i32 1, void ()* @main, !13}\n!13 = !{!14}\n!14 = !{i32 0, !15, !15}\n!15 = !{}\n!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 7, i32 7, i32 7]}\n!17 = !{void ()* @main, !\"main\", !18, !4, null}\n!18 = !{!19, !27, null}\n!19 = !{!20, !22, !24, !25}\n!20 = !{i32 0, !\"SV_Position\", i8 9, i8 3, !21, i8 4, i32 1, i8 4, i32 0, i8 0, null}\n!21 = !{i32 0}\n!22 = !{i32 1, !\"NORMAL\", i8 9, i8 0, !21, i8 2, i32 1, i8 3, i32 1, i8 0, !23}\n!23 = !{i32 3, i32 7}\n!24 = !{i32 2, !\"TEXCOORD\", i8 9, i8 0, !21, i8 2, i32 1, i8 3, i32 2, i8 0, !23}\n!25 = !{i32 3, !\"TEXCOORD\", i8 9, i8 0, !26, i8 2, i32 1, i8 3, i32 3, i8 0, !23}\n!26 = !{i32 1}\n!27 = !{!28}\n!28 = !{i32 0, !\"SV_Target\", i8 9, i8 16, !21, i8 0, i32 1, i8 4, i32 0, i8 0, !29}\n!29 = !{i32 3, i32 15}\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_PS.30.hlsl",
    "content": "static float4 out_var_SV_Target;\n\nstruct SPIRV_Cross_Output\n{\n    float4 out_var_SV_Target : COLOR0;\n};\n\nvoid frag_main()\n{\n    out_var_SV_Target = float4(0.20000000298023223876953125f, 0.4000000059604644775390625f, 0.60000002384185791015625f, 1.0f);\n}\n\nSPIRV_Cross_Output main()\n{\n    frag_main();\n    SPIRV_Cross_Output stage_output;\n    stage_output.out_var_SV_Target = float4(out_var_SV_Target);\n    return stage_output;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_PS.300.essl",
    "content": "#version 300 es\nprecision mediump float;\nprecision highp int;\n\nlayout(location = 0) out highp vec4 out_var_SV_Target;\n\nvoid main()\n{\n    out_var_SV_Target = vec4(0.20000000298023223876953125, 0.4000000059604644775390625, 0.60000002384185791015625, 1.0);\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_PS.300.glsl",
    "content": "#version 300\n#extension GL_ARB_separate_shader_objects : require\n\nout vec4 out_var_SV_Target;\n\nvoid main()\n{\n    out_var_SV_Target = vec4(0.20000000298023223876953125, 0.4000000059604644775390625, 0.60000002384185791015625, 1.0);\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_PS.310.essl",
    "content": "#version 310 es\nprecision mediump float;\nprecision highp int;\n\nlayout(location = 0) out highp vec4 out_var_SV_Target;\n\nvoid main()\n{\n    out_var_SV_Target = vec4(0.20000000298023223876953125, 0.4000000059604644775390625, 0.60000002384185791015625, 1.0);\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_PS.40.hlsl",
    "content": "static float4 out_var_SV_Target;\n\nstruct SPIRV_Cross_Output\n{\n    float4 out_var_SV_Target : SV_Target0;\n};\n\nvoid frag_main()\n{\n    out_var_SV_Target = float4(0.20000000298023223876953125f, 0.4000000059604644775390625f, 0.60000002384185791015625f, 1.0f);\n}\n\nSPIRV_Cross_Output main()\n{\n    frag_main();\n    SPIRV_Cross_Output stage_output;\n    stage_output.out_var_SV_Target = out_var_SV_Target;\n    return stage_output;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_PS.410.glsl",
    "content": "#version 410\n\nlayout(location = 0) out vec4 out_var_SV_Target;\n\nvoid main()\n{\n    out_var_SV_Target = vec4(0.20000000298023223876953125, 0.4000000059604644775390625, 0.60000002384185791015625, 1.0);\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_PS.50.hlsl",
    "content": "static float4 out_var_SV_Target;\n\nstruct SPIRV_Cross_Output\n{\n    float4 out_var_SV_Target : SV_Target0;\n};\n\nvoid frag_main()\n{\n    out_var_SV_Target = float4(0.20000000298023223876953125f, 0.4000000059604644775390625f, 0.60000002384185791015625f, 1.0f);\n}\n\nSPIRV_Cross_Output main()\n{\n    frag_main();\n    SPIRV_Cross_Output stage_output;\n    stage_output.out_var_SV_Target = out_var_SV_Target;\n    return stage_output;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_PS.msl",
    "content": "#include <metal_stdlib>\n#include <simd/simd.h>\n\nusing namespace metal;\n\nstruct PSMain_out\n{\n    float4 out_var_SV_Target [[color(0)]];\n};\n\nfragment PSMain_out PSMain()\n{\n    PSMain_out out = {};\n    out.out_var_SV_Target = float4(0.20000000298023223876953125, 0.4000000059604644775390625, 0.60000002384185791015625, 1.0);\n    return out;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_VS.30.hlsl",
    "content": "uniform float4 gl_HalfPixel;\n\nstatic float4 gl_Position;\nstruct SPIRV_Cross_Output\n{\n    float4 gl_Position : POSITION;\n};\n\nvoid vert_main()\n{\n    gl_Position = float4(1.0f, 2.0f, 3.0f, 4.0f);\n    gl_Position.x = gl_Position.x - gl_HalfPixel.x * gl_Position.w;\n    gl_Position.y = gl_Position.y + gl_HalfPixel.y * gl_Position.w;\n}\n\nSPIRV_Cross_Output main()\n{\n    vert_main();\n    SPIRV_Cross_Output stage_output;\n    stage_output.gl_Position = gl_Position;\n    return stage_output;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_VS.300.essl",
    "content": "#version 300 es\n\nvoid main()\n{\n    gl_Position = vec4(1.0, 2.0, 3.0, 4.0);\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_VS.300.glsl",
    "content": "#version 300\n#extension GL_ARB_separate_shader_objects : require\n\nout gl_PerVertex\n{\n    vec4 gl_Position;\n};\n\nvoid main()\n{\n    gl_Position = vec4(1.0, 2.0, 3.0, 4.0);\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_VS.310.essl",
    "content": "#version 310 es\n\nvoid main()\n{\n    gl_Position = vec4(1.0, 2.0, 3.0, 4.0);\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_VS.40.hlsl",
    "content": "static float4 gl_Position;\nstruct SPIRV_Cross_Output\n{\n    float4 gl_Position : SV_Position;\n};\n\nvoid vert_main()\n{\n    gl_Position = float4(1.0f, 2.0f, 3.0f, 4.0f);\n}\n\nSPIRV_Cross_Output main()\n{\n    vert_main();\n    SPIRV_Cross_Output stage_output;\n    stage_output.gl_Position = gl_Position;\n    return stage_output;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_VS.410.glsl",
    "content": "#version 410\n\nout gl_PerVertex\n{\n    vec4 gl_Position;\n};\n\nvoid main()\n{\n    gl_Position = vec4(1.0, 2.0, 3.0, 4.0);\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_VS.50.hlsl",
    "content": "static float4 gl_Position;\nstruct SPIRV_Cross_Output\n{\n    float4 gl_Position : SV_Position;\n};\n\nvoid vert_main()\n{\n    gl_Position = float4(1.0f, 2.0f, 3.0f, 4.0f);\n}\n\nSPIRV_Cross_Output main()\n{\n    vert_main();\n    SPIRV_Cross_Output stage_output;\n    stage_output.gl_Position = gl_Position;\n    return stage_output;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_VS.msl",
    "content": "#include <metal_stdlib>\n#include <simd/simd.h>\n\nusing namespace metal;\n\nstruct VSMain_out\n{\n    float4 gl_Position [[position]];\n};\n\nvertex VSMain_out VSMain()\n{\n    VSMain_out out = {};\n    out.gl_Position = float4(1.0, 2.0, 3.0, 4.0);\n    return out;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/DetailTessellation_HS.300.essl",
    "content": "#version 300 es\n#extension GL_EXT_tessellation_shader : require\nlayout(vertices = 3) out;\n\nstruct VS_OUTPUT_HS_INPUT\n{\n    vec3 worldPos;\n    vec3 normal;\n    vec2 texCoord;\n    vec3 lightTS;\n};\n\nlayout(std140) uniform type_cbMain\n{\n    vec4 tessellationFactor;\n} cbMain;\n\nin vec3 in_var_WORLDPOS[];\nin vec3 in_var_NORMAL[];\nin vec2 in_var_TEXCOORD0[];\nin vec3 in_var_LIGHTVECTORTS[];\nout vec3 out_var_WORLDPOS[3];\nout vec3 out_var_NORMAL[3];\nout vec2 out_var_TEXCOORD0[3];\nout vec3 out_var_LIGHTVECTORTS[3];\n\nvoid main()\n{\n    vec3 _58_unrolled[3];\n    for (int i = 0; i < int(3); i++)\n    {\n        _58_unrolled[i] = in_var_WORLDPOS[i];\n    }\n    vec3 _59_unrolled[3];\n    for (int i = 0; i < int(3); i++)\n    {\n        _59_unrolled[i] = in_var_NORMAL[i];\n    }\n    vec2 _60_unrolled[3];\n    for (int i = 0; i < int(3); i++)\n    {\n        _60_unrolled[i] = in_var_TEXCOORD0[i];\n    }\n    vec3 _61_unrolled[3];\n    for (int i = 0; i < int(3); i++)\n    {\n        _61_unrolled[i] = in_var_LIGHTVECTORTS[i];\n    }\n    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]));\n    out_var_WORLDPOS[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].worldPos;\n    out_var_NORMAL[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].normal;\n    out_var_TEXCOORD0[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].texCoord;\n    out_var_LIGHTVECTORTS[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].lightTS;\n    barrier();\n    if (gl_InvocationID == 0u)\n    {\n        gl_TessLevelOuter[0u] = cbMain.tessellationFactor.x;\n        gl_TessLevelOuter[1u] = cbMain.tessellationFactor.y;\n        gl_TessLevelOuter[2u] = cbMain.tessellationFactor.z;\n        gl_TessLevelInner[0u] = cbMain.tessellationFactor.w;\n    }\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/DetailTessellation_HS.300.glsl",
    "content": "#version 300\n#extension GL_ARB_tessellation_shader : require\n#extension GL_ARB_separate_shader_objects : require\nlayout(vertices = 3) out;\n\nstruct VS_OUTPUT_HS_INPUT\n{\n    vec3 worldPos;\n    vec3 normal;\n    vec2 texCoord;\n    vec3 lightTS;\n};\n\nlayout(std140) uniform type_cbMain\n{\n    vec4 tessellationFactor;\n} cbMain;\n\nlayout(location = 0) in vec3 in_var_WORLDPOS[];\nlayout(location = 1) in vec3 in_var_NORMAL[];\nlayout(location = 2) in vec2 in_var_TEXCOORD0[];\nlayout(location = 3) in vec3 in_var_LIGHTVECTORTS[];\nlayout(location = 3) out vec3 out_var_WORLDPOS[3];\nlayout(location = 1) out vec3 out_var_NORMAL[3];\nlayout(location = 2) out vec2 out_var_TEXCOORD0[3];\nlayout(location = 0) out vec3 out_var_LIGHTVECTORTS[3];\n\nvoid main()\n{\n    vec3 _58_unrolled[3];\n    for (int i = 0; i < int(3); i++)\n    {\n        _58_unrolled[i] = in_var_WORLDPOS[i];\n    }\n    vec3 _59_unrolled[3];\n    for (int i = 0; i < int(3); i++)\n    {\n        _59_unrolled[i] = in_var_NORMAL[i];\n    }\n    vec2 _60_unrolled[3];\n    for (int i = 0; i < int(3); i++)\n    {\n        _60_unrolled[i] = in_var_TEXCOORD0[i];\n    }\n    vec3 _61_unrolled[3];\n    for (int i = 0; i < int(3); i++)\n    {\n        _61_unrolled[i] = in_var_LIGHTVECTORTS[i];\n    }\n    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]));\n    out_var_WORLDPOS[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].worldPos;\n    out_var_NORMAL[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].normal;\n    out_var_TEXCOORD0[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].texCoord;\n    out_var_LIGHTVECTORTS[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].lightTS;\n    barrier();\n    if (gl_InvocationID == 0u)\n    {\n        gl_TessLevelOuter[0u] = cbMain.tessellationFactor.x;\n        gl_TessLevelOuter[1u] = cbMain.tessellationFactor.y;\n        gl_TessLevelOuter[2u] = cbMain.tessellationFactor.z;\n        gl_TessLevelInner[0u] = cbMain.tessellationFactor.w;\n    }\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/DetailTessellation_HS.310.essl",
    "content": "#version 310 es\n#extension GL_EXT_tessellation_shader : require\nlayout(vertices = 3) out;\n\nstruct VS_OUTPUT_HS_INPUT\n{\n    vec3 worldPos;\n    vec3 normal;\n    vec2 texCoord;\n    vec3 lightTS;\n};\n\nlayout(binding = 0, std140) uniform type_cbMain\n{\n    vec4 tessellationFactor;\n} cbMain;\n\nlayout(location = 0) in vec3 in_var_WORLDPOS[];\nlayout(location = 1) in vec3 in_var_NORMAL[];\nlayout(location = 2) in vec2 in_var_TEXCOORD0[];\nlayout(location = 3) in vec3 in_var_LIGHTVECTORTS[];\nlayout(location = 3) out vec3 out_var_WORLDPOS[3];\nlayout(location = 1) out vec3 out_var_NORMAL[3];\nlayout(location = 2) out vec2 out_var_TEXCOORD0[3];\nlayout(location = 0) out vec3 out_var_LIGHTVECTORTS[3];\n\nvoid main()\n{\n    vec3 _58_unrolled[3];\n    for (int i = 0; i < int(3); i++)\n    {\n        _58_unrolled[i] = in_var_WORLDPOS[i];\n    }\n    vec3 _59_unrolled[3];\n    for (int i = 0; i < int(3); i++)\n    {\n        _59_unrolled[i] = in_var_NORMAL[i];\n    }\n    vec2 _60_unrolled[3];\n    for (int i = 0; i < int(3); i++)\n    {\n        _60_unrolled[i] = in_var_TEXCOORD0[i];\n    }\n    vec3 _61_unrolled[3];\n    for (int i = 0; i < int(3); i++)\n    {\n        _61_unrolled[i] = in_var_LIGHTVECTORTS[i];\n    }\n    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]));\n    out_var_WORLDPOS[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].worldPos;\n    out_var_NORMAL[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].normal;\n    out_var_TEXCOORD0[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].texCoord;\n    out_var_LIGHTVECTORTS[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].lightTS;\n    barrier();\n    if (gl_InvocationID == 0u)\n    {\n        gl_TessLevelOuter[0u] = cbMain.tessellationFactor.x;\n        gl_TessLevelOuter[1u] = cbMain.tessellationFactor.y;\n        gl_TessLevelOuter[2u] = cbMain.tessellationFactor.z;\n        gl_TessLevelInner[0u] = cbMain.tessellationFactor.w;\n    }\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/DetailTessellation_HS.410.glsl",
    "content": "#version 410\nlayout(vertices = 3) out;\n\nstruct VS_OUTPUT_HS_INPUT\n{\n    vec3 worldPos;\n    vec3 normal;\n    vec2 texCoord;\n    vec3 lightTS;\n};\n\nlayout(std140) uniform type_cbMain\n{\n    vec4 tessellationFactor;\n} cbMain;\n\nlayout(location = 0) in vec3 in_var_WORLDPOS[];\nlayout(location = 1) in vec3 in_var_NORMAL[];\nlayout(location = 2) in vec2 in_var_TEXCOORD0[];\nlayout(location = 3) in vec3 in_var_LIGHTVECTORTS[];\nlayout(location = 3) out vec3 out_var_WORLDPOS[3];\nlayout(location = 1) out vec3 out_var_NORMAL[3];\nlayout(location = 2) out vec2 out_var_TEXCOORD0[3];\nlayout(location = 0) out vec3 out_var_LIGHTVECTORTS[3];\n\nvoid main()\n{\n    vec3 _58_unrolled[3];\n    for (int i = 0; i < int(3); i++)\n    {\n        _58_unrolled[i] = in_var_WORLDPOS[i];\n    }\n    vec3 _59_unrolled[3];\n    for (int i = 0; i < int(3); i++)\n    {\n        _59_unrolled[i] = in_var_NORMAL[i];\n    }\n    vec2 _60_unrolled[3];\n    for (int i = 0; i < int(3); i++)\n    {\n        _60_unrolled[i] = in_var_TEXCOORD0[i];\n    }\n    vec3 _61_unrolled[3];\n    for (int i = 0; i < int(3); i++)\n    {\n        _61_unrolled[i] = in_var_LIGHTVECTORTS[i];\n    }\n    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]));\n    out_var_WORLDPOS[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].worldPos;\n    out_var_NORMAL[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].normal;\n    out_var_TEXCOORD0[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].texCoord;\n    out_var_LIGHTVECTORTS[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].lightTS;\n    barrier();\n    if (gl_InvocationID == 0u)\n    {\n        gl_TessLevelOuter[0u] = cbMain.tessellationFactor.x;\n        gl_TessLevelOuter[1u] = cbMain.tessellationFactor.y;\n        gl_TessLevelOuter[2u] = cbMain.tessellationFactor.z;\n        gl_TessLevelInner[0u] = cbMain.tessellationFactor.w;\n    }\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/DetailTessellation_HS.msl",
    "content": "#pragma clang diagnostic ignored \"-Wmissing-prototypes\"\n#pragma clang diagnostic ignored \"-Wmissing-braces\"\n\n#include <metal_stdlib>\n#include <simd/simd.h>\n\nusing namespace metal;\n\ntemplate<typename T, size_t Num>\nstruct spvUnsafeArray\n{\n    T elements[Num ? Num : 1];\n    \n    thread T& operator [] (size_t pos) thread\n    {\n        return elements[pos];\n    }\n    constexpr const thread T& operator [] (size_t pos) const thread\n    {\n        return elements[pos];\n    }\n    \n    device T& operator [] (size_t pos) device\n    {\n        return elements[pos];\n    }\n    constexpr const device T& operator [] (size_t pos) const device\n    {\n        return elements[pos];\n    }\n    \n    constexpr const constant T& operator [] (size_t pos) const constant\n    {\n        return elements[pos];\n    }\n    \n    threadgroup T& operator [] (size_t pos) threadgroup\n    {\n        return elements[pos];\n    }\n    constexpr const threadgroup T& operator [] (size_t pos) const threadgroup\n    {\n        return elements[pos];\n    }\n};\n\nstruct type_cbMain\n{\n    float4 tessellationFactor;\n};\n\nstruct VS_OUTPUT_HS_INPUT\n{\n    float3 worldPos;\n    float3 normal;\n    float2 texCoord;\n    float3 lightTS;\n};\n\nstruct main0_out\n{\n    float3 out_var_LIGHTVECTORTS;\n    float3 out_var_NORMAL;\n    float2 out_var_TEXCOORD0;\n    float3 out_var_WORLDPOS;\n};\n\nstruct main0_in\n{\n    float3 in_var_WORLDPOS [[attribute(0)]];\n    float3 in_var_NORMAL [[attribute(1)]];\n    float2 in_var_TEXCOORD0 [[attribute(2)]];\n    float3 in_var_LIGHTVECTORTS [[attribute(3)]];\n};\n\nkernel 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)]])\n{\n    device main0_out* gl_out = &spvOut[gl_PrimitiveID * 3];\n    if (gl_InvocationID < spvIndirectParams[0])\n        gl_in[gl_InvocationID] = in;\n    threadgroup_barrier(mem_flags::mem_threadgroup);\n    if (gl_InvocationID >= 3)\n        return;\n    spvUnsafeArray<float3, 3> _58 = spvUnsafeArray<float3, 3>({ gl_in[0].in_var_WORLDPOS, gl_in[1].in_var_WORLDPOS, gl_in[2].in_var_WORLDPOS });\n    spvUnsafeArray<float3, 3> _59 = spvUnsafeArray<float3, 3>({ gl_in[0].in_var_NORMAL, gl_in[1].in_var_NORMAL, gl_in[2].in_var_NORMAL });\n    spvUnsafeArray<float2, 3> _60 = spvUnsafeArray<float2, 3>({ gl_in[0].in_var_TEXCOORD0, gl_in[1].in_var_TEXCOORD0, gl_in[2].in_var_TEXCOORD0 });\n    spvUnsafeArray<float3, 3> _61 = spvUnsafeArray<float3, 3>({ gl_in[0].in_var_LIGHTVECTORTS, gl_in[1].in_var_LIGHTVECTORTS, gl_in[2].in_var_LIGHTVECTORTS });\n    spvUnsafeArray<VS_OUTPUT_HS_INPUT, 3> _77 = spvUnsafeArray<VS_OUTPUT_HS_INPUT, 3>({ 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] } });\n    spvUnsafeArray<VS_OUTPUT_HS_INPUT, 3> param_var_inputPatch;\n    param_var_inputPatch = _77;\n    gl_out[gl_InvocationID].out_var_WORLDPOS = param_var_inputPatch[gl_InvocationID].worldPos;\n    gl_out[gl_InvocationID].out_var_NORMAL = param_var_inputPatch[gl_InvocationID].normal;\n    gl_out[gl_InvocationID].out_var_TEXCOORD0 = param_var_inputPatch[gl_InvocationID].texCoord;\n    gl_out[gl_InvocationID].out_var_LIGHTVECTORTS = param_var_inputPatch[gl_InvocationID].lightTS;\n    threadgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup);\n    if (gl_InvocationID == 0u)\n    {\n        spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0u] = half(cbMain.tessellationFactor.x);\n        spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1u] = half(cbMain.tessellationFactor.y);\n        spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2u] = half(cbMain.tessellationFactor.z);\n        spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(cbMain.tessellationFactor.w);\n    }\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/DotHalfPS.glsl",
    "content": "#version 30\n#if defined(GL_AMD_gpu_shader_half_float)\n#extension GL_AMD_gpu_shader_half_float : require\n#elif defined(GL_NV_gpu_shader5)\n#extension GL_NV_gpu_shader5 : require\n#else\n#error No extension available for FP16.\n#endif\n#extension GL_ARB_separate_shader_objects : require\n\nvoid main()\n{\n    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)))));\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Fluid_CS.300.glsl",
    "content": "#version 300\n#extension GL_ARB_compute_shader : require\n#extension GL_ARB_separate_shader_objects : require\nlayout(local_size_x = 256, local_size_y = 1, local_size_z = 1) in;\n\nstruct Particle\n{\n    vec2 position;\n    vec2 velocity;\n};\n\nstruct ParticleForces\n{\n    vec2 acceleration;\n};\n\nlayout(std140) uniform type_cbSimulationConstants\n{\n    float timeStep;\n    float wallStiffness;\n    vec4 gravity;\n    vec3 planes[4];\n} cbSimulationConstants;\n\nlayout(std430) buffer type_RWStructuredBuffer_Particle\n{\n    Particle _m0[];\n} particlesRW;\n\nlayout(std430) readonly buffer type_StructuredBuffer_Particle\n{\n    Particle _m0[];\n} particlesRO;\n\nlayout(std430) readonly buffer type_StructuredBuffer_ParticleForces\n{\n    ParticleForces _m0[];\n} particlesForcesRO;\n\nvoid main()\n{\n    vec2 _52 = particlesRO._m0[gl_GlobalInvocationID.x].position;\n    vec2 _54 = particlesRO._m0[gl_GlobalInvocationID.x].velocity;\n    vec2 _56 = particlesForcesRO._m0[gl_GlobalInvocationID.x].acceleration;\n    vec3 _59 = vec3(_52, 1.0);\n    float _67 = -cbSimulationConstants.wallStiffness;\n    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);\n    particlesRW._m0[gl_GlobalInvocationID.x].position = _52 + (_102 * cbSimulationConstants.timeStep);\n    particlesRW._m0[gl_GlobalInvocationID.x].velocity = _102;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Fluid_CS.310.essl",
    "content": "#version 310 es\nlayout(local_size_x = 256, local_size_y = 1, local_size_z = 1) in;\n\nstruct Particle\n{\n    vec2 position;\n    vec2 velocity;\n};\n\nstruct ParticleForces\n{\n    vec2 acceleration;\n};\n\nlayout(binding = 0, std140) uniform type_cbSimulationConstants\n{\n    float timeStep;\n    float wallStiffness;\n    vec4 gravity;\n    vec3 planes[4];\n} cbSimulationConstants;\n\nlayout(binding = 0, std430) buffer type_RWStructuredBuffer_Particle\n{\n    Particle _m0[];\n} particlesRW;\n\nlayout(binding = 0, std430) readonly buffer type_StructuredBuffer_Particle\n{\n    Particle _m0[];\n} particlesRO;\n\nlayout(binding = 2, std430) readonly buffer type_StructuredBuffer_ParticleForces\n{\n    ParticleForces _m0[];\n} particlesForcesRO;\n\nvoid main()\n{\n    vec2 _52 = particlesRO._m0[gl_GlobalInvocationID.x].position;\n    vec2 _54 = particlesRO._m0[gl_GlobalInvocationID.x].velocity;\n    vec2 _56 = particlesForcesRO._m0[gl_GlobalInvocationID.x].acceleration;\n    vec3 _59 = vec3(_52, 1.0);\n    float _67 = -cbSimulationConstants.wallStiffness;\n    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);\n    particlesRW._m0[gl_GlobalInvocationID.x].position = _52 + (_102 * cbSimulationConstants.timeStep);\n    particlesRW._m0[gl_GlobalInvocationID.x].velocity = _102;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Fluid_CS.410.glsl",
    "content": "#version 410\n#extension GL_ARB_compute_shader : require\nlayout(local_size_x = 256, local_size_y = 1, local_size_z = 1) in;\n\nstruct Particle\n{\n    vec2 position;\n    vec2 velocity;\n};\n\nstruct ParticleForces\n{\n    vec2 acceleration;\n};\n\nlayout(std140) uniform type_cbSimulationConstants\n{\n    float timeStep;\n    float wallStiffness;\n    vec4 gravity;\n    vec3 planes[4];\n} cbSimulationConstants;\n\nlayout(std430) buffer type_RWStructuredBuffer_Particle\n{\n    Particle _m0[];\n} particlesRW;\n\nlayout(std430) readonly buffer type_StructuredBuffer_Particle\n{\n    Particle _m0[];\n} particlesRO;\n\nlayout(std430) readonly buffer type_StructuredBuffer_ParticleForces\n{\n    ParticleForces _m0[];\n} particlesForcesRO;\n\nvoid main()\n{\n    vec2 _52 = particlesRO._m0[gl_GlobalInvocationID.x].position;\n    vec2 _54 = particlesRO._m0[gl_GlobalInvocationID.x].velocity;\n    vec2 _56 = particlesForcesRO._m0[gl_GlobalInvocationID.x].acceleration;\n    vec3 _59 = vec3(_52, 1.0);\n    float _67 = -cbSimulationConstants.wallStiffness;\n    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);\n    particlesRW._m0[gl_GlobalInvocationID.x].position = _52 + (_102 * cbSimulationConstants.timeStep);\n    particlesRW._m0[gl_GlobalInvocationID.x].velocity = _102;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Fluid_CS.50.hlsl",
    "content": "struct Particle\n{\n    float2 position;\n    float2 velocity;\n};\n\nstruct ParticleForces\n{\n    float2 acceleration;\n};\n\ncbuffer type_cbSimulationConstants : register(b0)\n{\n    float cbSimulationConstants_timeStep : packoffset(c0);\n    float cbSimulationConstants_wallStiffness : packoffset(c0.y);\n    float4 cbSimulationConstants_gravity : packoffset(c1);\n    float3 cbSimulationConstants_planes[4] : packoffset(c2);\n};\n\nRWByteAddressBuffer particlesRW : register(u0);\nByteAddressBuffer particlesRO : register(t0);\nByteAddressBuffer particlesForcesRO : register(t2);\n\nstatic uint3 gl_GlobalInvocationID;\nstruct SPIRV_Cross_Input\n{\n    uint3 gl_GlobalInvocationID : SV_DispatchThreadID;\n};\n\nvoid comp_main()\n{\n    float2 _52 = asfloat(particlesRO.Load2(gl_GlobalInvocationID.x * 16 + 0));\n    float2 _54 = asfloat(particlesRO.Load2(gl_GlobalInvocationID.x * 16 + 8));\n    float2 _56 = asfloat(particlesForcesRO.Load2(gl_GlobalInvocationID.x * 8 + 0));\n    float3 _59 = float3(_52, 1.0f);\n    float _67 = -cbSimulationConstants_wallStiffness;\n    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);\n    particlesRW.Store2(gl_GlobalInvocationID.x * 16 + 0, asuint(_52 + (_102 * cbSimulationConstants_timeStep)));\n    particlesRW.Store2(gl_GlobalInvocationID.x * 16 + 8, asuint(_102));\n}\n\n[numthreads(256, 1, 1)]\nvoid main(SPIRV_Cross_Input stage_input)\n{\n    gl_GlobalInvocationID = stage_input.gl_GlobalInvocationID;\n    comp_main();\n}\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Fluid_CS.msl",
    "content": "#include <metal_stdlib>\n#include <simd/simd.h>\n\nusing namespace metal;\n\nstruct type_cbSimulationConstants\n{\n    float timeStep;\n    float wallStiffness;\n    float4 gravity;\n    float3 planes[4];\n};\n\nstruct Particle\n{\n    float2 position;\n    float2 velocity;\n};\n\nstruct type_RWStructuredBuffer_Particle\n{\n    Particle _m0[1];\n};\n\nstruct type_StructuredBuffer_Particle\n{\n    Particle _m0[1];\n};\n\nstruct ParticleForces\n{\n    float2 acceleration;\n};\n\nstruct type_StructuredBuffer_ParticleForces\n{\n    ParticleForces _m0[1];\n};\n\nkernel 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]])\n{\n    float2 _52 = particlesRO._m0[gl_GlobalInvocationID.x].position;\n    float2 _54 = particlesRO._m0[gl_GlobalInvocationID.x].velocity;\n    float2 _56 = particlesForcesRO._m0[gl_GlobalInvocationID.x].acceleration;\n    float3 _59 = float3(_52, 1.0);\n    float _67 = -cbSimulationConstants.wallStiffness;\n    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);\n    particlesRW._m0[gl_GlobalInvocationID.x].position = _52 + (_102 * cbSimulationConstants.timeStep);\n    particlesRW._m0[gl_GlobalInvocationID.x].velocity = _102;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/HalfOutParamPS.glsl",
    "content": "#version 30\n#if defined(GL_AMD_gpu_shader_half_float)\n#extension GL_AMD_gpu_shader_half_float : require\n#elif defined(GL_NV_gpu_shader5)\n#extension GL_NV_gpu_shader5 : require\n#else\n#error No extension available for FP16.\n#endif\n#extension GL_ARB_separate_shader_objects : require\n\nvoid main()\n{\n    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);\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/IncludeEmptyHeader.glsl",
    "content": "#version 30\n#extension GL_ARB_separate_shader_objects : require\n\nvoid main()\n{\n    gl_FragData[0] = vec4(0.0);\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/IncludeExist.glsl",
    "content": "#version 30\n#extension GL_ARB_separate_shader_objects : require\n\nuniform sampler2D SPIRV_Cross_CombinedcolorTexpointSampler;\nuniform sampler2D SPIRV_Cross_CombinedcolorTexlinearSampler;\n\nvarying vec2 varying_TEXCOORD0;\n\nvoid main()\n{\n    gl_FragData[0] = texture2D(SPIRV_Cross_CombinedcolorTexpointSampler, varying_TEXCOORD0) + texture2D(SPIRV_Cross_CombinedcolorTexlinearSampler, varying_TEXCOORD0);\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/PNTriangles_DS.300.essl",
    "content": "#version 300 es\n#extension GL_EXT_tessellation_shader : require\nlayout(triangles) in;\n\nlayout(std140) uniform type_cbPNTriangles\n{\n    mat4 viewProj;\n    vec4 lightDir;\n} cbPNTriangles;\n\npatch in vec3 in_var_POSITION3;\npatch in vec3 in_var_POSITION4;\npatch in vec3 in_var_POSITION5;\npatch in vec3 in_var_POSITION6;\npatch in vec3 in_var_POSITION7;\npatch in vec3 in_var_POSITION8;\npatch in vec3 in_var_CENTER;\nin vec3 in_var_POSITION[];\nin vec2 in_var_TEXCOORD[];\nout vec2 out_var_TEXCOORD0;\n\nvoid main()\n{\n    vec3 _55_unrolled[3];\n    for (int i = 0; i < int(3); i++)\n    {\n        _55_unrolled[i] = in_var_POSITION[i];\n    }\n    vec2 _56_unrolled[3];\n    for (int i = 0; i < int(3); i++)\n    {\n        _56_unrolled[i] = in_var_TEXCOORD[i];\n    }\n    float _67 = gl_TessCoord.x * gl_TessCoord.x;\n    float _68 = gl_TessCoord.y * gl_TessCoord.y;\n    float _69 = gl_TessCoord.z * gl_TessCoord.z;\n    float _70 = _67 * 3.0;\n    float _71 = _68 * 3.0;\n    float _72 = _69 * 3.0;\n    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);\n    out_var_TEXCOORD0 = ((_56_unrolled[0] * gl_TessCoord.z) + (_56_unrolled[1] * gl_TessCoord.x)) + (_56_unrolled[2] * gl_TessCoord.y);\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/PNTriangles_DS.300.glsl",
    "content": "#version 300\n#extension GL_ARB_tessellation_shader : require\n#extension GL_ARB_separate_shader_objects : require\nlayout(triangles) in;\n\nout gl_PerVertex\n{\n    vec4 gl_Position;\n};\n\nlayout(std140) uniform type_cbPNTriangles\n{\n    mat4 viewProj;\n    vec4 lightDir;\n} cbPNTriangles;\n\nlayout(location = 2) patch in vec3 in_var_POSITION3;\nlayout(location = 3) patch in vec3 in_var_POSITION4;\nlayout(location = 4) patch in vec3 in_var_POSITION5;\nlayout(location = 5) patch in vec3 in_var_POSITION6;\nlayout(location = 6) patch in vec3 in_var_POSITION7;\nlayout(location = 7) patch in vec3 in_var_POSITION8;\nlayout(location = 0) patch in vec3 in_var_CENTER;\nlayout(location = 1) in vec3 in_var_POSITION[];\nlayout(location = 8) in vec2 in_var_TEXCOORD[];\nlayout(location = 0) out vec2 out_var_TEXCOORD0;\n\nvoid main()\n{\n    vec3 _55_unrolled[3];\n    for (int i = 0; i < int(3); i++)\n    {\n        _55_unrolled[i] = in_var_POSITION[i];\n    }\n    vec2 _56_unrolled[3];\n    for (int i = 0; i < int(3); i++)\n    {\n        _56_unrolled[i] = in_var_TEXCOORD[i];\n    }\n    float _67 = gl_TessCoord.x * gl_TessCoord.x;\n    float _68 = gl_TessCoord.y * gl_TessCoord.y;\n    float _69 = gl_TessCoord.z * gl_TessCoord.z;\n    float _70 = _67 * 3.0;\n    float _71 = _68 * 3.0;\n    float _72 = _69 * 3.0;\n    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);\n    out_var_TEXCOORD0 = ((_56_unrolled[0] * gl_TessCoord.z) + (_56_unrolled[1] * gl_TessCoord.x)) + (_56_unrolled[2] * gl_TessCoord.y);\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/PNTriangles_DS.310.essl",
    "content": "#version 310 es\n#extension GL_EXT_tessellation_shader : require\nlayout(triangles) in;\n\nlayout(binding = 0, std140) uniform type_cbPNTriangles\n{\n    mat4 viewProj;\n    vec4 lightDir;\n} cbPNTriangles;\n\nlayout(location = 2) patch in vec3 in_var_POSITION3;\nlayout(location = 3) patch in vec3 in_var_POSITION4;\nlayout(location = 4) patch in vec3 in_var_POSITION5;\nlayout(location = 5) patch in vec3 in_var_POSITION6;\nlayout(location = 6) patch in vec3 in_var_POSITION7;\nlayout(location = 7) patch in vec3 in_var_POSITION8;\nlayout(location = 0) patch in vec3 in_var_CENTER;\nlayout(location = 1) in vec3 in_var_POSITION[];\nlayout(location = 8) in vec2 in_var_TEXCOORD[];\nlayout(location = 0) out vec2 out_var_TEXCOORD0;\n\nvoid main()\n{\n    vec3 _55_unrolled[3];\n    for (int i = 0; i < int(3); i++)\n    {\n        _55_unrolled[i] = in_var_POSITION[i];\n    }\n    vec2 _56_unrolled[3];\n    for (int i = 0; i < int(3); i++)\n    {\n        _56_unrolled[i] = in_var_TEXCOORD[i];\n    }\n    float _67 = gl_TessCoord.x * gl_TessCoord.x;\n    float _68 = gl_TessCoord.y * gl_TessCoord.y;\n    float _69 = gl_TessCoord.z * gl_TessCoord.z;\n    float _70 = _67 * 3.0;\n    float _71 = _68 * 3.0;\n    float _72 = _69 * 3.0;\n    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);\n    out_var_TEXCOORD0 = ((_56_unrolled[0] * gl_TessCoord.z) + (_56_unrolled[1] * gl_TessCoord.x)) + (_56_unrolled[2] * gl_TessCoord.y);\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/PNTriangles_DS.410.glsl",
    "content": "#version 410\nlayout(triangles) in;\n\nout gl_PerVertex\n{\n    vec4 gl_Position;\n};\n\nlayout(std140) uniform type_cbPNTriangles\n{\n    mat4 viewProj;\n    vec4 lightDir;\n} cbPNTriangles;\n\nlayout(location = 2) patch in vec3 in_var_POSITION3;\nlayout(location = 3) patch in vec3 in_var_POSITION4;\nlayout(location = 4) patch in vec3 in_var_POSITION5;\nlayout(location = 5) patch in vec3 in_var_POSITION6;\nlayout(location = 6) patch in vec3 in_var_POSITION7;\nlayout(location = 7) patch in vec3 in_var_POSITION8;\nlayout(location = 0) patch in vec3 in_var_CENTER;\nlayout(location = 1) in vec3 in_var_POSITION[];\nlayout(location = 8) in vec2 in_var_TEXCOORD[];\nlayout(location = 0) out vec2 out_var_TEXCOORD0;\n\nvoid main()\n{\n    vec3 _55_unrolled[3];\n    for (int i = 0; i < int(3); i++)\n    {\n        _55_unrolled[i] = in_var_POSITION[i];\n    }\n    vec2 _56_unrolled[3];\n    for (int i = 0; i < int(3); i++)\n    {\n        _56_unrolled[i] = in_var_TEXCOORD[i];\n    }\n    float _67 = gl_TessCoord.x * gl_TessCoord.x;\n    float _68 = gl_TessCoord.y * gl_TessCoord.y;\n    float _69 = gl_TessCoord.z * gl_TessCoord.z;\n    float _70 = _67 * 3.0;\n    float _71 = _68 * 3.0;\n    float _72 = _69 * 3.0;\n    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);\n    out_var_TEXCOORD0 = ((_56_unrolled[0] * gl_TessCoord.z) + (_56_unrolled[1] * gl_TessCoord.x)) + (_56_unrolled[2] * gl_TessCoord.y);\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/PNTriangles_DS.msl",
    "content": "#pragma clang diagnostic ignored \"-Wmissing-prototypes\"\n#pragma clang diagnostic ignored \"-Wmissing-braces\"\n\n#include <metal_stdlib>\n#include <simd/simd.h>\n\nusing namespace metal;\n\ntemplate<typename T, size_t Num>\nstruct spvUnsafeArray\n{\n    T elements[Num ? Num : 1];\n    \n    thread T& operator [] (size_t pos) thread\n    {\n        return elements[pos];\n    }\n    constexpr const thread T& operator [] (size_t pos) const thread\n    {\n        return elements[pos];\n    }\n    \n    device T& operator [] (size_t pos) device\n    {\n        return elements[pos];\n    }\n    constexpr const device T& operator [] (size_t pos) const device\n    {\n        return elements[pos];\n    }\n    \n    constexpr const constant T& operator [] (size_t pos) const constant\n    {\n        return elements[pos];\n    }\n    \n    threadgroup T& operator [] (size_t pos) threadgroup\n    {\n        return elements[pos];\n    }\n    constexpr const threadgroup T& operator [] (size_t pos) const threadgroup\n    {\n        return elements[pos];\n    }\n};\n\nstruct type_cbPNTriangles\n{\n    float4x4 viewProj;\n    float4 lightDir;\n};\n\nstruct main0_out\n{\n    float2 out_var_TEXCOORD0 [[user(locn0)]];\n    float4 gl_Position [[position]];\n};\n\nstruct main0_in\n{\n    float3 in_var_POSITION [[attribute(1)]];\n    float2 in_var_TEXCOORD [[attribute(8)]];\n};\n\nstruct main0_patchIn\n{\n    float3 in_var_CENTER [[attribute(0)]];\n    float3 in_var_POSITION3 [[attribute(2)]];\n    float3 in_var_POSITION4 [[attribute(3)]];\n    float3 in_var_POSITION5 [[attribute(4)]];\n    float3 in_var_POSITION6 [[attribute(5)]];\n    float3 in_var_POSITION7 [[attribute(6)]];\n    float3 in_var_POSITION8 [[attribute(7)]];\n    patch_control_point<main0_in> gl_in;\n};\n\n[[ patch(triangle, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]], constant type_cbPNTriangles& cbPNTriangles [[buffer(0)]], float3 gl_TessCoord [[position_in_patch]])\n{\n    main0_out out = {};\n    spvUnsafeArray<float3, 3> _55 = spvUnsafeArray<float3, 3>({ patchIn.gl_in[0].in_var_POSITION, patchIn.gl_in[1].in_var_POSITION, patchIn.gl_in[2].in_var_POSITION });\n    spvUnsafeArray<float2, 3> _56 = spvUnsafeArray<float2, 3>({ patchIn.gl_in[0].in_var_TEXCOORD, patchIn.gl_in[1].in_var_TEXCOORD, patchIn.gl_in[2].in_var_TEXCOORD });\n    float _67 = gl_TessCoord.x * gl_TessCoord.x;\n    float _68 = gl_TessCoord.y * gl_TessCoord.y;\n    float _69 = gl_TessCoord.z * gl_TessCoord.z;\n    float _70 = _67 * 3.0;\n    float _71 = _68 * 3.0;\n    float _72 = _69 * 3.0;\n    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);\n    out.out_var_TEXCOORD0 = ((_56[0] * gl_TessCoord.z) + (_56[1] * gl_TessCoord.x)) + (_56[2] * gl_TessCoord.y);\n    return out;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Particle_GS.300.essl",
    "content": "#version 300 es\n#extension GL_EXT_geometry_shader : require\nlayout(points) in;\nlayout(max_vertices = 4, triangle_strip) out;\n\nlayout(std140) uniform type_cbMain\n{\n    mat4 invView;\n    mat4 viewProj;\n} cbMain;\n\nin vec4 in_var_POSITION[1];\nout vec2 out_var_TEXCOORD0;\n\nvoid main()\n{\n    mat3 _49 = mat3(cbMain.invView[0].xyz, cbMain.invView[1].xyz, cbMain.invView[2].xyz);\n    gl_Position = cbMain.viewProj * vec4((_49 * vec3(-5.0, 5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);\n    out_var_TEXCOORD0 = vec2(0.0, 1.0);\n    EmitVertex();\n    gl_Position = cbMain.viewProj * vec4((_49 * vec3(5.0, 5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);\n    out_var_TEXCOORD0 = vec2(1.0);\n    EmitVertex();\n    gl_Position = cbMain.viewProj * vec4((_49 * vec3(-5.0, -5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);\n    out_var_TEXCOORD0 = vec2(0.0);\n    EmitVertex();\n    gl_Position = cbMain.viewProj * vec4((_49 * vec3(5.0, -5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);\n    out_var_TEXCOORD0 = vec2(1.0, 0.0);\n    EmitVertex();\n    EndPrimitive();\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Particle_GS.300.glsl",
    "content": "#version 300\n#extension GL_ARB_separate_shader_objects : require\nlayout(points) in;\nlayout(max_vertices = 4, triangle_strip) out;\n\nout gl_PerVertex\n{\n    vec4 gl_Position;\n};\n\nlayout(std140) uniform type_cbMain\n{\n    mat4 invView;\n    mat4 viewProj;\n} cbMain;\n\nlayout(location = 0) in vec4 in_var_POSITION[1];\nlayout(location = 0) out vec2 out_var_TEXCOORD0;\n\nvoid main()\n{\n    mat3 _49 = mat3(cbMain.invView[0].xyz, cbMain.invView[1].xyz, cbMain.invView[2].xyz);\n    gl_Position = cbMain.viewProj * vec4((_49 * vec3(-5.0, 5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);\n    out_var_TEXCOORD0 = vec2(0.0, 1.0);\n    EmitVertex();\n    gl_Position = cbMain.viewProj * vec4((_49 * vec3(5.0, 5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);\n    out_var_TEXCOORD0 = vec2(1.0);\n    EmitVertex();\n    gl_Position = cbMain.viewProj * vec4((_49 * vec3(-5.0, -5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);\n    out_var_TEXCOORD0 = vec2(0.0);\n    EmitVertex();\n    gl_Position = cbMain.viewProj * vec4((_49 * vec3(5.0, -5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);\n    out_var_TEXCOORD0 = vec2(1.0, 0.0);\n    EmitVertex();\n    EndPrimitive();\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Particle_GS.310.essl",
    "content": "#version 310 es\n#extension GL_EXT_geometry_shader : require\nlayout(points) in;\nlayout(max_vertices = 4, triangle_strip) out;\n\nlayout(binding = 0, std140) uniform type_cbMain\n{\n    mat4 invView;\n    mat4 viewProj;\n} cbMain;\n\nlayout(location = 0) in vec4 in_var_POSITION[1];\nlayout(location = 0) out vec2 out_var_TEXCOORD0;\n\nvoid main()\n{\n    mat3 _49 = mat3(cbMain.invView[0].xyz, cbMain.invView[1].xyz, cbMain.invView[2].xyz);\n    gl_Position = cbMain.viewProj * vec4((_49 * vec3(-5.0, 5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);\n    out_var_TEXCOORD0 = vec2(0.0, 1.0);\n    EmitVertex();\n    gl_Position = cbMain.viewProj * vec4((_49 * vec3(5.0, 5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);\n    out_var_TEXCOORD0 = vec2(1.0);\n    EmitVertex();\n    gl_Position = cbMain.viewProj * vec4((_49 * vec3(-5.0, -5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);\n    out_var_TEXCOORD0 = vec2(0.0);\n    EmitVertex();\n    gl_Position = cbMain.viewProj * vec4((_49 * vec3(5.0, -5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);\n    out_var_TEXCOORD0 = vec2(1.0, 0.0);\n    EmitVertex();\n    EndPrimitive();\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Particle_GS.410.glsl",
    "content": "#version 410\nlayout(points) in;\nlayout(max_vertices = 4, triangle_strip) out;\n\nout gl_PerVertex\n{\n    vec4 gl_Position;\n};\n\nlayout(std140) uniform type_cbMain\n{\n    mat4 invView;\n    mat4 viewProj;\n} cbMain;\n\nlayout(location = 0) in vec4 in_var_POSITION[1];\nlayout(location = 0) out vec2 out_var_TEXCOORD0;\n\nvoid main()\n{\n    mat3 _49 = mat3(cbMain.invView[0].xyz, cbMain.invView[1].xyz, cbMain.invView[2].xyz);\n    gl_Position = cbMain.viewProj * vec4((_49 * vec3(-5.0, 5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);\n    out_var_TEXCOORD0 = vec2(0.0, 1.0);\n    EmitVertex();\n    gl_Position = cbMain.viewProj * vec4((_49 * vec3(5.0, 5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);\n    out_var_TEXCOORD0 = vec2(1.0);\n    EmitVertex();\n    gl_Position = cbMain.viewProj * vec4((_49 * vec3(-5.0, -5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);\n    out_var_TEXCOORD0 = vec2(0.0);\n    EmitVertex();\n    gl_Position = cbMain.viewProj * vec4((_49 * vec3(5.0, -5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);\n    out_var_TEXCOORD0 = vec2(1.0, 0.0);\n    EmitVertex();\n    EndPrimitive();\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_PS.30.hlsl",
    "content": "static float4 in_var_COLOR;\nstatic float4 out_var_SV_Target;\n\nstruct SPIRV_Cross_Input\n{\n    float4 in_var_COLOR : TEXCOORD0;\n};\n\nstruct SPIRV_Cross_Output\n{\n    float4 out_var_SV_Target : COLOR0;\n};\n\nvoid frag_main()\n{\n    out_var_SV_Target = in_var_COLOR;\n}\n\nSPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)\n{\n    in_var_COLOR = stage_input.in_var_COLOR;\n    frag_main();\n    SPIRV_Cross_Output stage_output;\n    stage_output.out_var_SV_Target = float4(out_var_SV_Target);\n    return stage_output;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_PS.300.essl",
    "content": "#version 300 es\nprecision mediump float;\nprecision highp int;\n\nin highp vec4 varying_COLOR;\nlayout(location = 0) out highp vec4 out_var_SV_Target;\n\nvoid main()\n{\n    out_var_SV_Target = varying_COLOR;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_PS.300.glsl",
    "content": "#version 300\n#extension GL_ARB_separate_shader_objects : require\n\nlayout(location = 0) in vec4 varying_COLOR;\nout vec4 out_var_SV_Target;\n\nvoid main()\n{\n    out_var_SV_Target = varying_COLOR;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_PS.310.essl",
    "content": "#version 310 es\nprecision mediump float;\nprecision highp int;\n\nlayout(location = 0) in highp vec4 in_var_COLOR;\nlayout(location = 0) out highp vec4 out_var_SV_Target;\n\nvoid main()\n{\n    out_var_SV_Target = in_var_COLOR;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_PS.40.hlsl",
    "content": "static float4 in_var_COLOR;\nstatic float4 out_var_SV_Target;\n\nstruct SPIRV_Cross_Input\n{\n    float4 in_var_COLOR : TEXCOORD0;\n};\n\nstruct SPIRV_Cross_Output\n{\n    float4 out_var_SV_Target : SV_Target0;\n};\n\nvoid frag_main()\n{\n    out_var_SV_Target = in_var_COLOR;\n}\n\nSPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)\n{\n    in_var_COLOR = stage_input.in_var_COLOR;\n    frag_main();\n    SPIRV_Cross_Output stage_output;\n    stage_output.out_var_SV_Target = out_var_SV_Target;\n    return stage_output;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_PS.410.glsl",
    "content": "#version 410\n\nlayout(location = 0) in vec4 in_var_COLOR;\nlayout(location = 0) out vec4 out_var_SV_Target;\n\nvoid main()\n{\n    out_var_SV_Target = in_var_COLOR;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_PS.50.hlsl",
    "content": "static float4 in_var_COLOR;\nstatic float4 out_var_SV_Target;\n\nstruct SPIRV_Cross_Input\n{\n    float4 in_var_COLOR : TEXCOORD0;\n};\n\nstruct SPIRV_Cross_Output\n{\n    float4 out_var_SV_Target : SV_Target0;\n};\n\nvoid frag_main()\n{\n    out_var_SV_Target = in_var_COLOR;\n}\n\nSPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)\n{\n    in_var_COLOR = stage_input.in_var_COLOR;\n    frag_main();\n    SPIRV_Cross_Output stage_output;\n    stage_output.out_var_SV_Target = out_var_SV_Target;\n    return stage_output;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_PS.msl",
    "content": "#include <metal_stdlib>\n#include <simd/simd.h>\n\nusing namespace metal;\n\nstruct PSMain_out\n{\n    float4 out_var_SV_Target [[color(0)]];\n};\n\nstruct PSMain_in\n{\n    float4 in_var_COLOR [[user(locn0)]];\n};\n\nfragment PSMain_out PSMain(PSMain_in in [[stage_in]])\n{\n    PSMain_out out = {};\n    out.out_var_SV_Target = in.in_var_COLOR;\n    return out;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_VS.30.hlsl",
    "content": "uniform float4 gl_HalfPixel;\n\nstatic float4 gl_Position;\nstatic float4 in_var_POSITION;\nstatic float2 in_var_TEXCOORD0;\nstatic float2 out_var_TEXCOORD0;\n\nstruct SPIRV_Cross_Input\n{\n    float4 in_var_POSITION : TEXCOORD0;\n    float2 in_var_TEXCOORD0 : TEXCOORD1;\n};\n\nstruct SPIRV_Cross_Output\n{\n    float2 out_var_TEXCOORD0 : TEXCOORD0;\n    float4 gl_Position : POSITION;\n};\n\nvoid vert_main()\n{\n    out_var_TEXCOORD0 = in_var_TEXCOORD0;\n    gl_Position = in_var_POSITION;\n    gl_Position.x = gl_Position.x - gl_HalfPixel.x * gl_Position.w;\n    gl_Position.y = gl_Position.y + gl_HalfPixel.y * gl_Position.w;\n}\n\nSPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)\n{\n    in_var_POSITION = stage_input.in_var_POSITION;\n    in_var_TEXCOORD0 = stage_input.in_var_TEXCOORD0;\n    vert_main();\n    SPIRV_Cross_Output stage_output;\n    stage_output.gl_Position = gl_Position;\n    stage_output.out_var_TEXCOORD0 = out_var_TEXCOORD0;\n    return stage_output;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_VS.300.essl",
    "content": "#version 300 es\n\nlayout(location = 0) in vec4 in_var_POSITION;\nlayout(location = 1) in vec2 in_var_TEXCOORD0;\nout vec2 varying_TEXCOORD0;\n\nvoid main()\n{\n    varying_TEXCOORD0 = in_var_TEXCOORD0;\n    gl_Position = in_var_POSITION;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_VS.300.glsl",
    "content": "#version 300\n#extension GL_ARB_separate_shader_objects : require\n\nout gl_PerVertex\n{\n    vec4 gl_Position;\n};\n\nin vec4 in_var_POSITION;\nin vec2 in_var_TEXCOORD0;\nlayout(location = 0) out vec2 varying_TEXCOORD0;\n\nvoid main()\n{\n    varying_TEXCOORD0 = in_var_TEXCOORD0;\n    gl_Position = in_var_POSITION;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_VS.310.essl",
    "content": "#version 310 es\n\nlayout(location = 0) in vec4 in_var_POSITION;\nlayout(location = 1) in vec2 in_var_TEXCOORD0;\nlayout(location = 0) out vec2 out_var_TEXCOORD0;\n\nvoid main()\n{\n    out_var_TEXCOORD0 = in_var_TEXCOORD0;\n    gl_Position = in_var_POSITION;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_VS.40.hlsl",
    "content": "static float4 gl_Position;\nstatic float4 in_var_POSITION;\nstatic float2 in_var_TEXCOORD0;\nstatic float2 out_var_TEXCOORD0;\n\nstruct SPIRV_Cross_Input\n{\n    float4 in_var_POSITION : TEXCOORD0;\n    float2 in_var_TEXCOORD0 : TEXCOORD1;\n};\n\nstruct SPIRV_Cross_Output\n{\n    float2 out_var_TEXCOORD0 : TEXCOORD0;\n    float4 gl_Position : SV_Position;\n};\n\nvoid vert_main()\n{\n    out_var_TEXCOORD0 = in_var_TEXCOORD0;\n    gl_Position = in_var_POSITION;\n}\n\nSPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)\n{\n    in_var_POSITION = stage_input.in_var_POSITION;\n    in_var_TEXCOORD0 = stage_input.in_var_TEXCOORD0;\n    vert_main();\n    SPIRV_Cross_Output stage_output;\n    stage_output.gl_Position = gl_Position;\n    stage_output.out_var_TEXCOORD0 = out_var_TEXCOORD0;\n    return stage_output;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_VS.410.glsl",
    "content": "#version 410\n\nout gl_PerVertex\n{\n    vec4 gl_Position;\n};\n\nlayout(location = 0) in vec4 in_var_POSITION;\nlayout(location = 1) in vec2 in_var_TEXCOORD0;\nlayout(location = 0) out vec2 out_var_TEXCOORD0;\n\nvoid main()\n{\n    out_var_TEXCOORD0 = in_var_TEXCOORD0;\n    gl_Position = in_var_POSITION;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_VS.50.hlsl",
    "content": "static float4 gl_Position;\nstatic float4 in_var_POSITION;\nstatic float2 in_var_TEXCOORD0;\nstatic float2 out_var_TEXCOORD0;\n\nstruct SPIRV_Cross_Input\n{\n    float4 in_var_POSITION : TEXCOORD0;\n    float2 in_var_TEXCOORD0 : TEXCOORD1;\n};\n\nstruct SPIRV_Cross_Output\n{\n    float2 out_var_TEXCOORD0 : TEXCOORD0;\n    float4 gl_Position : SV_Position;\n};\n\nvoid vert_main()\n{\n    out_var_TEXCOORD0 = in_var_TEXCOORD0;\n    gl_Position = in_var_POSITION;\n}\n\nSPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)\n{\n    in_var_POSITION = stage_input.in_var_POSITION;\n    in_var_TEXCOORD0 = stage_input.in_var_TEXCOORD0;\n    vert_main();\n    SPIRV_Cross_Output stage_output;\n    stage_output.gl_Position = gl_Position;\n    stage_output.out_var_TEXCOORD0 = out_var_TEXCOORD0;\n    return stage_output;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_VS.msl",
    "content": "#include <metal_stdlib>\n#include <simd/simd.h>\n\nusing namespace metal;\n\nstruct VSMain_out\n{\n    float2 out_var_TEXCOORD0 [[user(locn0)]];\n    float4 gl_Position [[position]];\n};\n\nstruct VSMain_in\n{\n    float4 in_var_POSITION [[attribute(0)]];\n    float2 in_var_TEXCOORD0 [[attribute(1)]];\n};\n\nvertex VSMain_out VSMain(VSMain_in in [[stage_in]])\n{\n    VSMain_out out = {};\n    out.out_var_TEXCOORD0 = in.in_var_TEXCOORD0;\n    out.gl_Position = in.in_var_POSITION;\n    return out;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/ToneMapping_PS.30.hlsl",
    "content": "cbuffer type_cbPS : register(b0)\n{\n    float cbPS_lumStrength : packoffset(c0);\n};\n\nuniform sampler2D SPIRV_Cross_CombinedcolorTexpointSampler;\nuniform sampler2D SPIRV_Cross_CombinedbloomTexlinearSampler;\nuniform sampler2D SPIRV_Cross_CombinedlumTexpointSampler;\n\nstatic float2 in_var_TEXCOORD0;\nstatic float4 out_var_SV_Target;\n\nstruct SPIRV_Cross_Input\n{\n    float2 in_var_TEXCOORD0 : TEXCOORD0;\n};\n\nstruct SPIRV_Cross_Output\n{\n    float4 out_var_SV_Target : COLOR0;\n};\n\nvoid frag_main()\n{\n    float4 _45 = tex2D(SPIRV_Cross_CombinedcolorTexpointSampler, in_var_TEXCOORD0);\n    float3 _62 = (_45.xyz * (0.7200000286102294921875f / ((tex2D(SPIRV_Cross_CombinedlumTexpointSampler, 0.5f.xx).x * cbPS_lumStrength) + 0.001000000047497451305389404296875f))).xyz;\n    float3 _66 = (_62 * (1.0f.xxx + (_62 * 0.666666686534881591796875f.xxx))).xyz;\n    float3 _71 = (_66 / (1.0f.xxx + _66)).xyz + (tex2D(SPIRV_Cross_CombinedbloomTexlinearSampler, in_var_TEXCOORD0).xyz * 0.60000002384185791015625f);\n    float4 _73 = float4(_71.x, _71.y, _71.z, _45.w);\n    _73.w = 1.0f;\n    out_var_SV_Target = _73;\n}\n\nSPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)\n{\n    in_var_TEXCOORD0 = stage_input.in_var_TEXCOORD0;\n    frag_main();\n    SPIRV_Cross_Output stage_output;\n    stage_output.out_var_SV_Target = float4(out_var_SV_Target);\n    return stage_output;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Expected/ToneMapping_PS.300.essl",
    "content": "#version 300 es\nprecision mediump float;\nprecision highp int;\n\nlayout(std140) uniform type_cbPS\n{\n    highp float lumStrength;\n} cbPS;\n\nuniform highp sampler2D SPIRV_Cross_CombinedcolorTexpointSampler;\nuniform highp sampler2D SPIRV_Cross_CombinedbloomTexlinearSampler;\nuniform highp sampler2D SPIRV_Cross_CombinedlumTexpointSampler;\n\nin highp vec2 varying_TEXCOORD0;\nlayout(location = 0) out highp vec4 out_var_SV_Target;\n\nvoid main()\n{\n    highp vec4 _45 = texture(SPIRV_Cross_CombinedcolorTexpointSampler, varying_TEXCOORD0);\n    highp vec3 _62 = (_45.xyz * (0.7200000286102294921875 / ((texture(SPIRV_Cross_CombinedlumTexpointSampler, vec2(0.5)).x * cbPS.lumStrength) + 0.001000000047497451305389404296875))).xyz;\n    highp vec3 _66 = (_62 * (vec3(1.0) + (_62 * vec3(0.666666686534881591796875)))).xyz;\n    highp vec3 _71 = (_66 / (vec3(1.0) + _66)).xyz + (texture(SPIRV_Cross_CombinedbloomTexlinearSampler, varying_TEXCOORD0).xyz * 0.60000002384185791015625);\n    highp vec4 _73 = vec4(_71.x, _71.y, _71.z, _45.w);\n    _73.w = 1.0;\n    out_var_SV_Target = _73;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/ToneMapping_PS.300.glsl",
    "content": "#version 300\n#extension GL_ARB_separate_shader_objects : require\n\nlayout(std140) uniform type_cbPS\n{\n    float lumStrength;\n} cbPS;\n\nuniform sampler2D SPIRV_Cross_CombinedcolorTexpointSampler;\nuniform sampler2D SPIRV_Cross_CombinedbloomTexlinearSampler;\nuniform sampler2D SPIRV_Cross_CombinedlumTexpointSampler;\n\nlayout(location = 0) in vec2 varying_TEXCOORD0;\nout vec4 out_var_SV_Target;\n\nvoid main()\n{\n    vec4 _45 = texture(SPIRV_Cross_CombinedcolorTexpointSampler, varying_TEXCOORD0);\n    vec3 _62 = (_45.xyz * (0.7200000286102294921875 / ((texture(SPIRV_Cross_CombinedlumTexpointSampler, vec2(0.5)).x * cbPS.lumStrength) + 0.001000000047497451305389404296875))).xyz;\n    vec3 _66 = (_62 * (vec3(1.0) + (_62 * vec3(0.666666686534881591796875)))).xyz;\n    vec3 _71 = (_66 / (vec3(1.0) + _66)).xyz + (texture(SPIRV_Cross_CombinedbloomTexlinearSampler, varying_TEXCOORD0).xyz * 0.60000002384185791015625);\n    vec4 _73 = vec4(_71.x, _71.y, _71.z, _45.w);\n    _73.w = 1.0;\n    out_var_SV_Target = _73;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/ToneMapping_PS.310.essl",
    "content": "#version 310 es\nprecision mediump float;\nprecision highp int;\n\nlayout(binding = 0, std140) uniform type_cbPS\n{\n    highp float lumStrength;\n} cbPS;\n\nuniform highp sampler2D SPIRV_Cross_CombinedcolorTexpointSampler;\nuniform highp sampler2D SPIRV_Cross_CombinedbloomTexlinearSampler;\nuniform highp sampler2D SPIRV_Cross_CombinedlumTexpointSampler;\n\nlayout(location = 0) in highp vec2 in_var_TEXCOORD0;\nlayout(location = 0) out highp vec4 out_var_SV_Target;\n\nvoid main()\n{\n    highp vec4 _45 = texture(SPIRV_Cross_CombinedcolorTexpointSampler, in_var_TEXCOORD0);\n    highp vec3 _62 = (_45.xyz * (0.7200000286102294921875 / ((texture(SPIRV_Cross_CombinedlumTexpointSampler, vec2(0.5)).x * cbPS.lumStrength) + 0.001000000047497451305389404296875))).xyz;\n    highp vec3 _66 = (_62 * (vec3(1.0) + (_62 * vec3(0.666666686534881591796875)))).xyz;\n    highp vec3 _71 = (_66 / (vec3(1.0) + _66)).xyz + (texture(SPIRV_Cross_CombinedbloomTexlinearSampler, in_var_TEXCOORD0).xyz * 0.60000002384185791015625);\n    highp vec4 _73 = vec4(_71.x, _71.y, _71.z, _45.w);\n    _73.w = 1.0;\n    out_var_SV_Target = _73;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/ToneMapping_PS.40.hlsl",
    "content": "cbuffer type_cbPS : register(b0)\n{\n    float cbPS_lumStrength : packoffset(c0);\n};\n\nSamplerState pointSampler : register(s0);\nSamplerState linearSampler : register(s1);\nTexture2D<float4> colorTex : register(t0);\nTexture2D<float4> lumTex : register(t1);\nTexture2D<float4> bloomTex : register(t2);\n\nstatic float2 in_var_TEXCOORD0;\nstatic float4 out_var_SV_Target;\n\nstruct SPIRV_Cross_Input\n{\n    float2 in_var_TEXCOORD0 : TEXCOORD0;\n};\n\nstruct SPIRV_Cross_Output\n{\n    float4 out_var_SV_Target : SV_Target0;\n};\n\nvoid frag_main()\n{\n    float4 _45 = colorTex.Sample(pointSampler, in_var_TEXCOORD0);\n    float3 _62 = (_45.xyz * (0.7200000286102294921875f / ((lumTex.Sample(pointSampler, 0.5f.xx).x * cbPS_lumStrength) + 0.001000000047497451305389404296875f))).xyz;\n    float3 _66 = (_62 * (1.0f.xxx + (_62 * 0.666666686534881591796875f.xxx))).xyz;\n    float3 _71 = (_66 / (1.0f.xxx + _66)).xyz + (bloomTex.Sample(linearSampler, in_var_TEXCOORD0).xyz * 0.60000002384185791015625f);\n    float4 _73 = float4(_71.x, _71.y, _71.z, _45.w);\n    _73.w = 1.0f;\n    out_var_SV_Target = _73;\n}\n\nSPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)\n{\n    in_var_TEXCOORD0 = stage_input.in_var_TEXCOORD0;\n    frag_main();\n    SPIRV_Cross_Output stage_output;\n    stage_output.out_var_SV_Target = out_var_SV_Target;\n    return stage_output;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Expected/ToneMapping_PS.410.glsl",
    "content": "#version 410\n\nlayout(std140) uniform type_cbPS\n{\n    float lumStrength;\n} cbPS;\n\nuniform sampler2D SPIRV_Cross_CombinedcolorTexpointSampler;\nuniform sampler2D SPIRV_Cross_CombinedbloomTexlinearSampler;\nuniform sampler2D SPIRV_Cross_CombinedlumTexpointSampler;\n\nlayout(location = 0) in vec2 in_var_TEXCOORD0;\nlayout(location = 0) out vec4 out_var_SV_Target;\n\nvoid main()\n{\n    vec4 _45 = texture(SPIRV_Cross_CombinedcolorTexpointSampler, in_var_TEXCOORD0);\n    vec3 _62 = (_45.xyz * (0.7200000286102294921875 / ((texture(SPIRV_Cross_CombinedlumTexpointSampler, vec2(0.5)).x * cbPS.lumStrength) + 0.001000000047497451305389404296875))).xyz;\n    vec3 _66 = (_62 * (vec3(1.0) + (_62 * vec3(0.666666686534881591796875)))).xyz;\n    vec3 _71 = (_66 / (vec3(1.0) + _66)).xyz + (texture(SPIRV_Cross_CombinedbloomTexlinearSampler, in_var_TEXCOORD0).xyz * 0.60000002384185791015625);\n    vec4 _73 = vec4(_71.x, _71.y, _71.z, _45.w);\n    _73.w = 1.0;\n    out_var_SV_Target = _73;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/ToneMapping_PS.50.hlsl",
    "content": "cbuffer type_cbPS : register(b0)\n{\n    float cbPS_lumStrength : packoffset(c0);\n};\n\nSamplerState pointSampler : register(s0);\nSamplerState linearSampler : register(s1);\nTexture2D<float4> colorTex : register(t0);\nTexture2D<float4> lumTex : register(t1);\nTexture2D<float4> bloomTex : register(t2);\n\nstatic float2 in_var_TEXCOORD0;\nstatic float4 out_var_SV_Target;\n\nstruct SPIRV_Cross_Input\n{\n    float2 in_var_TEXCOORD0 : TEXCOORD0;\n};\n\nstruct SPIRV_Cross_Output\n{\n    float4 out_var_SV_Target : SV_Target0;\n};\n\nvoid frag_main()\n{\n    float4 _45 = colorTex.Sample(pointSampler, in_var_TEXCOORD0);\n    float3 _62 = (_45.xyz * (0.7200000286102294921875f / ((lumTex.Sample(pointSampler, 0.5f.xx).x * cbPS_lumStrength) + 0.001000000047497451305389404296875f))).xyz;\n    float3 _66 = (_62 * (1.0f.xxx + (_62 * 0.666666686534881591796875f.xxx))).xyz;\n    float3 _71 = (_66 / (1.0f.xxx + _66)).xyz + (bloomTex.Sample(linearSampler, in_var_TEXCOORD0).xyz * 0.60000002384185791015625f);\n    float4 _73 = float4(_71.x, _71.y, _71.z, _45.w);\n    _73.w = 1.0f;\n    out_var_SV_Target = _73;\n}\n\nSPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)\n{\n    in_var_TEXCOORD0 = stage_input.in_var_TEXCOORD0;\n    frag_main();\n    SPIRV_Cross_Output stage_output;\n    stage_output.out_var_SV_Target = out_var_SV_Target;\n    return stage_output;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Expected/ToneMapping_PS.msl",
    "content": "#include <metal_stdlib>\n#include <simd/simd.h>\n\nusing namespace metal;\n\nstruct type_cbPS\n{\n    float lumStrength;\n};\n\nstruct main0_out\n{\n    float4 out_var_SV_Target [[color(0)]];\n};\n\nstruct main0_in\n{\n    float2 in_var_TEXCOORD0 [[user(locn0)]];\n};\n\nfragment main0_out main0(main0_in in [[stage_in]], constant type_cbPS& cbPS [[buffer(0)]], texture2d<float> colorTex [[texture(0)]], texture2d<float> lumTex [[texture(1)]], texture2d<float> bloomTex [[texture(2)]], sampler pointSampler [[sampler(0)]], sampler linearSampler [[sampler(1)]])\n{\n    main0_out out = {};\n    float4 _45 = colorTex.sample(pointSampler, in.in_var_TEXCOORD0);\n    float3 _62 = (_45.xyz * (0.7200000286102294921875 / ((lumTex.sample(pointSampler, float2(0.5)).x * cbPS.lumStrength) + 0.001000000047497451305389404296875))).xyz;\n    float3 _66 = (_62 * (float3(1.0) + (_62 * float3(0.666666686534881591796875)))).xyz;\n    float3 _71 = (_66 / (float3(1.0) + _66)).xyz + (bloomTex.sample(linearSampler, in.in_var_TEXCOORD0).xyz * 0.60000002384185791015625);\n    float4 _73 = float4(_71.x, _71.y, _71.z, _45.w);\n    _73.w = 1.0;\n    out.out_var_SV_Target = _73;\n    return out;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Transform_VS.30.hlsl",
    "content": "cbuffer type_cbVS : register(b0)\n{\n    row_major float4x4 cbVS_wvp : packoffset(c0);\n};\n\nuniform float4 gl_HalfPixel;\n\nstatic float4 gl_Position;\nstatic float4 in_var_POSITION;\n\nstruct SPIRV_Cross_Input\n{\n    float4 in_var_POSITION : TEXCOORD0;\n};\n\nstruct SPIRV_Cross_Output\n{\n    float4 gl_Position : POSITION;\n};\n\nvoid vert_main()\n{\n    gl_Position = mul(in_var_POSITION, cbVS_wvp);\n    gl_Position.x = gl_Position.x - gl_HalfPixel.x * gl_Position.w;\n    gl_Position.y = gl_Position.y + gl_HalfPixel.y * gl_Position.w;\n}\n\nSPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)\n{\n    in_var_POSITION = stage_input.in_var_POSITION;\n    vert_main();\n    SPIRV_Cross_Output stage_output;\n    stage_output.gl_Position = gl_Position;\n    return stage_output;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Transform_VS.300.essl",
    "content": "#version 300 es\n\nlayout(std140) uniform type_cbVS\n{\n    mat4 wvp;\n} cbVS;\n\nlayout(location = 0) in vec4 in_var_POSITION;\n\nvoid main()\n{\n    gl_Position = cbVS.wvp * in_var_POSITION;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Transform_VS.300.glsl",
    "content": "#version 300\n#extension GL_ARB_separate_shader_objects : require\n\nout gl_PerVertex\n{\n    vec4 gl_Position;\n};\n\nlayout(std140) uniform type_cbVS\n{\n    mat4 wvp;\n} cbVS;\n\nin vec4 in_var_POSITION;\n\nvoid main()\n{\n    gl_Position = cbVS.wvp * in_var_POSITION;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Transform_VS.310.essl",
    "content": "#version 310 es\n\nlayout(binding = 0, std140) uniform type_cbVS\n{\n    mat4 wvp;\n} cbVS;\n\nlayout(location = 0) in vec4 in_var_POSITION;\n\nvoid main()\n{\n    gl_Position = cbVS.wvp * in_var_POSITION;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Transform_VS.40.hlsl",
    "content": "cbuffer type_cbVS : register(b0)\n{\n    row_major float4x4 cbVS_wvp : packoffset(c0);\n};\n\n\nstatic float4 gl_Position;\nstatic float4 in_var_POSITION;\n\nstruct SPIRV_Cross_Input\n{\n    float4 in_var_POSITION : TEXCOORD0;\n};\n\nstruct SPIRV_Cross_Output\n{\n    float4 gl_Position : SV_Position;\n};\n\nvoid vert_main()\n{\n    gl_Position = mul(in_var_POSITION, cbVS_wvp);\n}\n\nSPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)\n{\n    in_var_POSITION = stage_input.in_var_POSITION;\n    vert_main();\n    SPIRV_Cross_Output stage_output;\n    stage_output.gl_Position = gl_Position;\n    return stage_output;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Transform_VS.410.glsl",
    "content": "#version 410\n\nout gl_PerVertex\n{\n    vec4 gl_Position;\n};\n\nlayout(std140) uniform type_cbVS\n{\n    mat4 wvp;\n} cbVS;\n\nlayout(location = 0) in vec4 in_var_POSITION;\n\nvoid main()\n{\n    gl_Position = cbVS.wvp * in_var_POSITION;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Transform_VS.50.hlsl",
    "content": "cbuffer type_cbVS : register(b0)\n{\n    row_major float4x4 cbVS_wvp : packoffset(c0);\n};\n\n\nstatic float4 gl_Position;\nstatic float4 in_var_POSITION;\n\nstruct SPIRV_Cross_Input\n{\n    float4 in_var_POSITION : TEXCOORD0;\n};\n\nstruct SPIRV_Cross_Output\n{\n    float4 gl_Position : SV_Position;\n};\n\nvoid vert_main()\n{\n    gl_Position = mul(in_var_POSITION, cbVS_wvp);\n}\n\nSPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)\n{\n    in_var_POSITION = stage_input.in_var_POSITION;\n    vert_main();\n    SPIRV_Cross_Output stage_output;\n    stage_output.gl_Position = gl_Position;\n    return stage_output;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Transform_VS.msl",
    "content": "#include <metal_stdlib>\n#include <simd/simd.h>\n\nusing namespace metal;\n\nstruct type_cbVS\n{\n    float4x4 wvp;\n};\n\nstruct main0_out\n{\n    float4 gl_Position [[position]];\n};\n\nstruct main0_in\n{\n    float4 in_var_POSITION [[attribute(0)]];\n};\n\nvertex main0_out main0(main0_in in [[stage_in]], constant type_cbVS& cbVS [[buffer(0)]])\n{\n    main0_out out = {};\n    out.gl_Position = cbVS.wvp * in.in_var_POSITION;\n    return out;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Transform_VS_ColumnMajor.300.glsl",
    "content": "#version 300\n#extension GL_ARB_separate_shader_objects : require\n\nout gl_PerVertex\n{\n    vec4 gl_Position;\n};\n\nlayout(std140) uniform type_cbVS\n{\n    layout(row_major) mat4 wvp;\n} cbVS;\n\nin vec4 in_var_POSITION;\n\nvoid main()\n{\n    gl_Position = cbVS.wvp * in_var_POSITION;\n}\n\n"
  },
  {
    "path": "Source/Tests/Data/Input/CalcLight.hlsl",
    "content": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nstruct PSInput\n{\n    float4 pos : SV_Position;\n    float3 normal : NORMAL;\n    float3 lightVec : TEXCOORD0;\n    float3 halfway : TEXCOORD1;\n};\n\ncbuffer cbPS : register(b0)\n{\n    float3 diffColor;\n    float3 specColor;\n    float shininess;\n};\n\nfloat3 CalcBrdf(float3 diffColor, float3 specColor, float shininess, float3 lightVec, float3 halfway, float3 normal);\n\n[shader(\"pixel\")]\nfloat4 main(PSInput input) : SV_Target\n{\n    float4 color;\n    color.rgb = CalcBrdf(diffColor, specColor, shininess, input.lightVec, input.halfway, input.normal);\n    color.a = 1.0f;\n\n    return color;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Input/CalcLightDiffuse.hlsl",
    "content": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\n// Diffuse only\nfloat3 CalcBrdf(float3 diffColor, float3 specColor, float shininess, float3 lightVec, float3 halfway, float3 normal)\n{\n    return max(diffColor * dot(normal, lightVec), 0);\n}\n"
  },
  {
    "path": "Source/Tests/Data/Input/CalcLightDiffuseSpecular.hlsl",
    "content": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nfloat SpecularNormalizeFactor(float shininess)\n{\n    return (shininess + 2) / 8;\n}\n\nfloat3 DistributionTerm(float3 halfway, float3 normal, float shininess)\n{\n    return pow(max(dot(halfway, normal), 0.0f), shininess);\n}\n\nfloat3 FresnelTerm(float3 lightVec, float3 halfway, float3 specColor)\n{\n    float eN = saturate(dot(lightVec, halfway));\n    return specColor > 0 ? specColor + (1 - specColor) * pow(1 - eN, 5) : 0;\n}\n\nfloat3 SpecularTerm(float3 specColor, float3 lightVec, float3 halfway, float3 normal, float shininess)\n{\n    return SpecularNormalizeFactor(shininess) * DistributionTerm(halfway, normal, shininess) * FresnelTerm(lightVec, halfway, specColor);\n}\n\n// Diffuse and specular\nfloat3 CalcBrdf(float3 diffColor, float3 specColor, float shininess, float3 lightVec, float3 halfway, float3 normal)\n{\n    return max((diffColor + SpecularTerm(specColor, lightVec, halfway, normal, shininess)) * dot(normal, lightVec), 0);\n}\n"
  },
  {
    "path": "Source/Tests/Data/Input/Common.hlsli",
    "content": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nSamplerState pointSampler : register(s0);\nSamplerState linearSampler : register(s1);\n"
  },
  {
    "path": "Source/Tests/Data/Input/Constant_PS.hlsl",
    "content": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nfloat4 PSMain() : SV_Target\n{\n    return float4(0.2f, 0.4f, 0.6f, 1.0f);\n}\n"
  },
  {
    "path": "Source/Tests/Data/Input/Constant_VS.hlsl",
    "content": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nfloat4 VSMain() : SV_Position\n{\n    return float4(1, 2, 3, 4);\n}\n"
  },
  {
    "path": "Source/Tests/Data/Input/DetailTessellation_HS.hlsl",
    "content": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\ncbuffer cbMain : register(b0)\n{\n    float4 tessellationFactor;\n};\n\nstruct VS_OUTPUT_HS_INPUT\n{\n    float3 worldPos : WORLDPOS;\n    float3 normal : NORMAL;\n    float2 texCoord : TEXCOORD0;\n    float3 lightTS : LIGHTVECTORTS;\n};\n\nstruct HS_CONSTANT_DATA_OUTPUT\n{\n    float edges[3] : SV_TessFactor;\n    float inside : SV_InsideTessFactor;\n};\n\nstruct HS_CONTROL_POINT_OUTPUT\n{\n    float3 worldPos : WORLDPOS;\n    float3 normal : NORMAL;\n    float2 texCoord : TEXCOORD0;\n    float3 lightTS : LIGHTVECTORTS;\n};\n\nHS_CONSTANT_DATA_OUTPUT ConstantsHS(InputPatch<VS_OUTPUT_HS_INPUT, 3> p, uint patchID : SV_PrimitiveID)\n{\n    HS_CONSTANT_DATA_OUTPUT output;\n    \n    output.edges[0] = tessellationFactor.x;\n    output.edges[1] = tessellationFactor.y;\n    output.edges[2] = tessellationFactor.z;\n    output.inside = tessellationFactor.w;\n    \n    return output;\n}\n\n[domain(\"tri\")]\n[partitioning(\"fractional_odd\")]\n[outputtopology(\"triangle_cw\")]\n[outputcontrolpoints(3)]\n[patchconstantfunc(\"ConstantsHS\")]\n[maxtessfactor(15.0)]\nHS_CONTROL_POINT_OUTPUT main(InputPatch<VS_OUTPUT_HS_INPUT, 3> inputPatch, uint uCPID : SV_OutputControlPointID)\n{\n    HS_CONTROL_POINT_OUTPUT output;\n\n    output.worldPos = inputPatch[uCPID].worldPos.xyz;\n    output.normal = inputPatch[uCPID].normal;\n    output.texCoord = inputPatch[uCPID].texCoord;\n    output.lightTS = inputPatch[uCPID].lightTS;\n\n    return output;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Input/Fluid_CS.hlsl",
    "content": "﻿// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nstruct Particle\n{\n    float2 position;\n    float2 velocity;\n};\n\nstruct ParticleForces\n{\n    float2 acceleration;\n};\n\ncbuffer cbSimulationConstants : register(b0)\n{\n    float timeStep;\n    float wallStiffness;\n\n    float4 gravity;\n    float3 planes[4];\n};\n\nRWStructuredBuffer<Particle> particlesRW : register(u0);\nStructuredBuffer<Particle> particlesRO : register(t0);\n\nStructuredBuffer<ParticleForces> particlesForcesRO : register(t2);\n\n[numthreads(256, 1, 1)]\nvoid main(uint3 dtid : SV_DispatchThreadID, uint gi : SV_GroupIndex)\n{\n    const uint p_id = dtid.x;\n\n    float2 position = particlesRO[p_id].position;\n    float2 velocity = particlesRO[p_id].velocity;\n    float2 acceleration = particlesForcesRO[p_id].acceleration;\n\n    [unroll]\n    for (uint i = 0 ; i < 4 ; ++i)\n    {\n        float dist = dot(float3(position, 1), planes[i]);\n        acceleration += min(dist, 0) * -wallStiffness * planes[i].xy;\n    }\n\n    acceleration += gravity.xy;\n\n    velocity += timeStep * acceleration;\n    position += timeStep * velocity;\n\n    particlesRW[p_id].position = position;\n    particlesRW[p_id].velocity = velocity;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Input/HalfDataType.hlsl",
    "content": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nfloat4 DotHalfPS() : SV_Target0\n{\n\thalf3 v0 = half3(0, 0, 1);\n\tfloat ret = dot(v0, v0);\n\treturn ret;\n}\n\nvoid Func(half3 input, out half3 output)\n{\n\toutput = input;\n}\n\nfloat4 HalfOutParamPS() : SV_Target0\n{\n\tfloat3 output;\n\tFunc(cross(half3(1, 0, 0), half3(0, 1, 0)), output);\n\treturn float4(output, 1.0f);\n}\n"
  },
  {
    "path": "Source/Tests/Data/Input/Inc/HeaderA.hlsli",
    "content": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\n#include \"HeaderB.hlsli\"\n\nSamplerState pointSampler : register(s0);\n"
  },
  {
    "path": "Source/Tests/Data/Input/Inc/HeaderB.hlsli",
    "content": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nSamplerState linearSampler : register(s1);\n"
  },
  {
    "path": "Source/Tests/Data/Input/Inc/HeaderEmpty.hlsli",
    "content": ""
  },
  {
    "path": "Source/Tests/Data/Input/IncludeEmptyHeader.hlsl",
    "content": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\n#include \"Inc/HeaderEmpty.hlsli\"\n\nfloat4 main() : SV_Target\n{\n    return 0;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Input/IncludeExist.hlsl",
    "content": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\n#include \"Inc/HeaderA.hlsli\"\n\nTexture2D colorTex : register(t0);\n\nfloat4 main(float2 tex : TEXCOORD0) : SV_Target\n{\n    return colorTex.Sample(pointSampler, tex) + colorTex.Sample(linearSampler, tex);\n}\n"
  },
  {
    "path": "Source/Tests/Data/Input/IncludeNotExist.hlsl",
    "content": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\n#include \"Header.hlsli\"\n#include \"IncludeExist.hlsli\"\n"
  },
  {
    "path": "Source/Tests/Data/Input/PNTriangles_DS.hlsl",
    "content": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\ncbuffer cbPNTriangles : register(b0)\n{\n    float4x4 viewProj;\n    float4 lightDir;\n}\n\nstruct HS_ConstantOutput\n{\n    float tessFactor[3] : SV_TessFactor;\n    float insideTessFactor : SV_InsideTessFactor;\n\n    float3 b210 : POSITION3;\n    float3 b120 : POSITION4;\n    float3 b021 : POSITION5;\n    float3 b012 : POSITION6;\n    float3 b102 : POSITION7;\n    float3 b201 : POSITION8;\n    float3 b111 : CENTER;\n};\n\nstruct HS_ControlPointOutput\n{\n    float3 position : POSITION;\n    float2 texCoord : TEXCOORD;\n};\n\nstruct DS_Output\n{\n    float4 position : SV_Position;\n    float2 texCoord : TEXCOORD0;\n};\n\n[domain(\"tri\")]\nDS_Output main(HS_ConstantOutput hsConstantData, const OutputPatch<HS_ControlPointOutput, 3> input,\n               float3 barycentricCoords : SV_DomainLocation)\n{\n    DS_Output output;\n\n    float u = barycentricCoords.x;\n    float v = barycentricCoords.y;\n    float w = barycentricCoords.z;\n\n    float uu = u * u;\n    float vv = v * v;\n    float ww = w * w;\n    float uu3 = uu * 3;\n    float vv3 = vv * 3;\n    float ww3 = ww * 3;\n\n    float3 position = input[0].position * ww * w +\n                      input[1].position * uu * u +\n                      input[2].position * vv * v +\n                      hsConstantData.b210 * ww3 * u +\n                      hsConstantData.b120 * w * uu3 +\n                      hsConstantData.b201 * ww3 * v +\n                      hsConstantData.b021 * uu3 * v +\n                      hsConstantData.b102 * w * vv3 +\n                      hsConstantData.b012 * u * vv3 +\n                      hsConstantData.b111 * 6 * w * u * v;\n\n    output.position = mul(float4(position, 1), viewProj);\n\n    output.texCoord = input[0].texCoord * w + input[1].texCoord * u + input[2].texCoord * v;\n\n    return output;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Input/Particle_GS.hlsl",
    "content": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\ncbuffer cbMain : register(b0)\n{\n    matrix invView;\n    matrix viewProj;\n};\n\nstruct GS_PARTICLE_INPUT\n{\n    float4 wsPos : POSITION;\n};\n\nstruct PS_PARTICLE_INPUT\n{\n    float4 pos : SV_POSITION;\n    float2 tex : TEXCOORD0;\n};\n\n[maxvertexcount(4)]\nvoid main(point GS_PARTICLE_INPUT input[1], inout TriangleStream<PS_PARTICLE_INPUT> spriteStream)\n{\n    const float3 quadPositions[4] =\n    {\n        float3(-1,  1, 0),\n        float3( 1,  1, 0),\n        float3(-1, -1, 0),\n        float3( 1, -1, 0),\n    };\n    const float2 quadTexcoords[4] = \n    { \n        float2(0, 1), \n        float2(1, 1),\n        float2(0, 0),\n        float2(1, 0),\n    };\n\n    PS_PARTICLE_INPUT output;\n\n    [unroll]\n    for (int i = 0; i < 4; ++i)\n    {\n        float3 position = quadPositions[i] * FIXED_VERTEX_RADIUS;\n        position = mul(position, (float3x3)invView) + input[0].wsPos.xyz;\n        output.pos = mul(float4(position, 1.0f), viewProj);\n\n        output.tex = quadTexcoords[i];\n\n        spriteStream.Append(output);\n    }\n    spriteStream.RestartStrip();\n}\n"
  },
  {
    "path": "Source/Tests/Data/Input/PassThrough_PS.hlsl",
    "content": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nfloat4 PSMain(float4 color : COLOR) : SV_Target\n{\n    return color;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Input/PassThrough_VS.hlsl",
    "content": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nvoid VSMain(float4 pos : POSITION,\n            float2 tex : TEXCOORD0,\n            out float2 oTex : TEXCOORD0,\n            out float4 oPos : SV_Position)\n{\n    oTex = tex;\n    oPos = pos;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Input/ToneMapping_PS.hlsl",
    "content": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\n#include \"Common.hlsli\"\n\nstruct PSInput\n{\n    float4 pos : SV_Position;\n    float2 tex : TEXCOORD0;\n};\n\nTexture2D colorTex : register(t0);\nTexture2D lumTex : register(t1);\nTexture2D bloomTex : register(t2);\n\nstatic const float MIDDLE_GRAY = 0.72f;\nstatic const float LUM_WHITE = 1.5f;\n\ncbuffer cbPS : register(b0)\n{\n    float lumStrength;\n};\n\nfloat4 main(PSInput input) : SV_Target\n{\n    float4 color = colorTex.Sample(pointSampler, input.tex);\n    float3 bloom = bloomTex.Sample(linearSampler, input.tex).xyz;\n    float lum = lumTex.Sample(pointSampler, 0.5f).x * lumStrength;\n\n    color.rgb *= MIDDLE_GRAY / (lum + 0.001f);\n    color.rgb *= (1.0f + color.rgb / LUM_WHITE);\n    color.rgb /= (1.0f + color.rgb);\n    \n    color.rgb += 0.6f * bloom;\n    color.a = 1.0f;\n\n    return color;\n}\n"
  },
  {
    "path": "Source/Tests/Data/Input/Transform_VS.hlsl",
    "content": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\ncbuffer cbVS : register(b0)\n{\n    float4x4 wvp;\n};\n\nvoid main(float4 pos : POSITION,\n          out float4 oPos : SV_Position)\n{\n    oPos = mul(pos, wvp);\n}\n"
  },
  {
    "path": "Source/Tests/ShaderConductorTest.cpp",
    "content": "/*\n * ShaderConductor\n *\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n *\n * MIT License\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this\n * software and associated documentation files (the \"Software\"), to deal in the Software\n * without restriction, including without limitation the rights to use, copy, modify, merge,\n * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons\n * to whom the Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all copies or\n * substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR\n * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE\n * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\n#include <ShaderConductor/ShaderConductor.hpp>\n\n#include <gtest/gtest.h>\n\n#include <cassert>\n#include <fstream>\n#include <string>\n#include <tuple>\n#include <vector>\n\nusing namespace ShaderConductor;\n\nnamespace\n{\n    std::vector<uint8_t> LoadFile(const std::string& name, bool isText)\n    {\n        std::vector<uint8_t> ret;\n        std::ios_base::openmode mode = std::ios_base::in;\n        if (!isText)\n        {\n            mode |= std::ios_base::binary;\n        }\n        std::ifstream file(name, mode);\n        if (file)\n        {\n            file.seekg(0, std::ios::end);\n            ret.resize(static_cast<size_t>(file.tellg()));\n            file.seekg(0, std::ios::beg);\n            file.read(reinterpret_cast<char*>(ret.data()), ret.size());\n            ret.resize(static_cast<size_t>(file.gcount()));\n        }\n        return ret;\n    }\n\n    void CompareWithExpected(const std::vector<uint8_t>& actual, bool isText, const std::string& compareName)\n    {\n        std::vector<uint8_t> expected = LoadFile(TEST_DATA_DIR \"Expected/\" + compareName, isText);\n        if (expected != actual)\n        {\n            if (!actual.empty())\n            {\n                std::ios_base::openmode mode = std::ios_base::out;\n                if (!isText)\n                {\n                    mode |= std::ios_base::binary;\n                }\n                std::ofstream actualFile(TEST_DATA_DIR \"Result/\" + compareName, mode);\n                actualFile.write(reinterpret_cast<const char*>(actual.data()), actual.size());\n            }\n        }\n\n        EXPECT_EQ(std::string(expected.begin(), expected.end()), std::string(actual.begin(), actual.end()));\n    }\n\n    void HlslToAnyTest(const std::string& name, const Compiler::SourceDesc& source, const Compiler::Options& options,\n                       const std::vector<Compiler::TargetDesc>& targets, const std::vector<bool>& expectSuccessFlags)\n    {\n        static const std::string extMap[] = {\"dxil\", \"spv\", \"hlsl\", \"glsl\", \"essl\", \"msl\", \"msl\"};\n        static_assert(sizeof(extMap) / sizeof(extMap[0]) == static_cast<uint32_t>(ShadingLanguage::NumShadingLanguages),\n                      \"extMap doesn't match with the number of shading languages.\");\n\n        std::vector<Compiler::ResultDesc> results(targets.size());\n        Compiler::Compile(source, options, targets.data(), static_cast<uint32_t>(targets.size()), results.data());\n        for (size_t i = 0; i < targets.size(); ++i)\n        {\n            const auto& result = results[i];\n            if (expectSuccessFlags[i])\n            {\n                EXPECT_FALSE(result.hasError);\n                EXPECT_EQ(result.errorWarningMsg.Size(), 0U);\n                EXPECT_TRUE(result.isText);\n\n                std::string compareName = name;\n                if (targets[i].version != nullptr)\n                {\n                    compareName += \".\" + std::string(targets[i].version);\n                }\n                compareName += \".\" + extMap[static_cast<uint32_t>(targets[i].language)];\n\n                const uint8_t* target_ptr = reinterpret_cast<const uint8_t*>(result.target.Data());\n                CompareWithExpected(std::vector<uint8_t>(target_ptr, target_ptr + result.target.Size()), result.isText, compareName);\n            }\n            else\n            {\n                EXPECT_TRUE(result.hasError);\n                EXPECT_EQ(result.target.Size(), 0U);\n            }\n        }\n    }\n\n    Compiler::ModuleDesc CompileToModule(const char* moduleName, const std::string& inputFileName, const Compiler::TargetDesc& target)\n    {\n        std::vector<uint8_t> input = LoadFile(inputFileName, true);\n        const std::string source = std::string(reinterpret_cast<char*>(input.data()), input.size());\n\n        const auto result = Compiler::Compile({source.c_str(), inputFileName.c_str(), \"\", ShaderStage::PixelShader}, {}, target);\n\n        EXPECT_FALSE(result.hasError);\n        EXPECT_FALSE(result.isText);\n\n        return {moduleName, std::move(result.target)};\n    }\n\n    class TestBase : public testing::Test\n    {\n    public:\n        TestBase()\n        {\n            m_expectSuccessFlags.assign(m_testTargets.size(), true);\n        }\n\n        void SetUp() override\n        {\n            for (auto& src : m_testSources)\n            {\n                const std::string& name = std::get<0>(src);\n                Compiler::SourceDesc& source = std::get<1>(src);\n\n                std::get<2>(src) = TEST_DATA_DIR \"Input/\" + name + \".hlsl\";\n                source.fileName = std::get<2>(src).c_str();\n\n                std::vector<uint8_t> input = LoadFile(source.fileName, true);\n                std::get<3>(src) = std::string(reinterpret_cast<char*>(input.data()), input.size());\n                source.source = std::get<3>(src).c_str();\n            }\n        }\n\n        void RunTests(ShadingLanguage targetSl, const Compiler::Options& options = {})\n        {\n            for (const auto& combination : m_testSources)\n            {\n                std::vector<Compiler::TargetDesc> targetSubset;\n                std::vector<bool> expectSuccessSubset;\n                for (size_t i = 0; i < m_testTargets.size(); ++i)\n                {\n                    if (m_testTargets[i].language == targetSl)\n                    {\n                        targetSubset.push_back(m_testTargets[i]);\n                        expectSuccessSubset.push_back(m_expectSuccessFlags[i]);\n                    }\n                }\n\n                HlslToAnyTest(std::get<0>(combination), std::get<1>(combination), options, targetSubset, expectSuccessSubset);\n            }\n        }\n\n    protected:\n        // test name, source desc, input file name, input source\n        std::vector<std::tuple<std::string, Compiler::SourceDesc, std::string, std::string>> m_testSources;\n\n        // clang-format off\n        const std::vector<Compiler::TargetDesc> m_testTargets =\n        {\n            { ShadingLanguage::Hlsl, \"30\" },\n            { ShadingLanguage::Hlsl, \"40\" },\n            { ShadingLanguage::Hlsl, \"50\" },\n\n            { ShadingLanguage::Glsl, \"300\" },\n            { ShadingLanguage::Glsl, \"410\" },\n\n            { ShadingLanguage::Essl, \"300\" },\n            { ShadingLanguage::Essl, \"310\" },\n\n            { ShadingLanguage::Msl_macOS },\n        };\n        // clang-format on\n\n        std::vector<bool> m_expectSuccessFlags;\n    };\n\n    class VertexShaderTest : public TestBase\n    {\n    public:\n        void SetUp() override\n        {\n            // clang-format off\n            m_testSources =\n            {\n                {\n                    \"Constant_VS\",\n                    { \"\", \"\", \"VSMain\", ShaderStage::VertexShader },\n                    \"\",\n                    \"\"\n                },\n                {\n                    \"PassThrough_VS\",\n                    { \"\", \"\", \"VSMain\", ShaderStage::VertexShader },\n                    \"\",\n                    \"\"\n                },\n                {\n                    \"Transform_VS\",\n                    { \"\", \"\", \"\", ShaderStage::VertexShader },\n                    \"\",\n                    \"\"\n                },\n            };\n            // clang-format on\n\n            TestBase::SetUp();\n        }\n    };\n\n    class PixelShaderTest : public TestBase\n    {\n    public:\n        void SetUp() override\n        {\n            // clang-format off\n            m_testSources =\n            {\n                {\n                    \"Constant_PS\",\n                    { \"\", \"\", \"PSMain\", ShaderStage::PixelShader },\n                    \"\",\n                    \"\"\n                },\n                {\n                    \"PassThrough_PS\",\n                    { \"\", \"\", \"PSMain\", ShaderStage::PixelShader },\n                    \"\",\n                    \"\"\n                },\n                {\n                    \"ToneMapping_PS\",\n                    { \"\", \"\", \"\", ShaderStage::PixelShader },\n                    \"\",\n                    \"\"\n                },\n            };\n            // clang-format on\n\n            TestBase::SetUp();\n        }\n    };\n\n    class GeometryShaderTest : public TestBase\n    {\n    public:\n        void SetUp() override\n        {\n            // clang-format off\n            m_testSources =\n            {\n                {\n                    \"Particle_GS\",\n                    { \"\", \"\", \"\", ShaderStage::GeometryShader, defines_.data(), static_cast<uint32_t>(defines_.size()) },\n                    \"\",\n                    \"\"\n                },\n            };\n            // clang-format on\n\n            m_expectSuccessFlags[0] = false; // No GS in HLSL SM3\n            m_expectSuccessFlags[1] = false; // GS not supported yet\n            m_expectSuccessFlags[2] = false; // GS not supported yet\n            m_expectSuccessFlags[7] = false; // No GS in MSL\n\n            TestBase::SetUp();\n        }\n\n    private:\n        std::vector<MacroDefine> defines_ = {{\"FIXED_VERTEX_RADIUS\", \"5.0\"}};\n    };\n\n    class HullShaderTest : public TestBase\n    {\n    public:\n        void SetUp() override\n        {\n            // clang-format off\n            m_testSources =\n            {\n                {\n                    \"DetailTessellation_HS\",\n                    { \"\", \"\", \"\", ShaderStage::HullShader },\n                    \"\",\n                    \"\"\n                },\n            };\n            // clang-format on\n\n            m_expectSuccessFlags[0] = false; // No HS in HLSL SM3\n            m_expectSuccessFlags[1] = false; // No HS in HLSL SM4\n            m_expectSuccessFlags[2] = false; // HS not supported yet\n\n            TestBase::SetUp();\n        }\n    };\n\n    class DomainShaderTest : public TestBase\n    {\n    public:\n        void SetUp() override\n        {\n            // clang-format off\n            m_testSources =\n            {\n                {\n                    \"PNTriangles_DS\",\n                    { \"\", \"\", \"\", ShaderStage::DomainShader },\n                    \"\",\n                    \"\"\n                },\n            };\n            // clang-format on\n\n            m_expectSuccessFlags[0] = false; // No HS in HLSL SM3\n            m_expectSuccessFlags[1] = false; // No HS in HLSL SM4\n            m_expectSuccessFlags[2] = false; // DS not supported yet\n\n            TestBase::SetUp();\n        }\n    };\n\n    class ComputeShaderTest : public TestBase\n    {\n    public:\n        void SetUp() override\n        {\n            // clang-format off\n            m_testSources =\n            {\n                {\n                    \"Fluid_CS\",\n                    { \"\", \"\", \"\", ShaderStage::ComputeShader },\n                    \"\",\n                    \"\"\n                },\n            };\n            // clang-format on\n\n            m_expectSuccessFlags[0] = false; // No CS in HLSL SM3\n            m_expectSuccessFlags[1] = false; // CS in HLSL SM4 is not supported\n            m_expectSuccessFlags[5] = false; // No CS in OpenGL ES 3.0\n\n            TestBase::SetUp();\n        }\n    };\n\n\n    TEST_F(VertexShaderTest, ToHlsl)\n    {\n        RunTests(ShadingLanguage::Hlsl);\n    }\n\n    TEST_F(VertexShaderTest, ToGlsl)\n    {\n        RunTests(ShadingLanguage::Glsl);\n    }\n\n    TEST_F(VertexShaderTest, ToGlslColumnMajor)\n    {\n        const std::string fileName = TEST_DATA_DIR \"Input/Transform_VS.hlsl\";\n\n        std::vector<uint8_t> input = LoadFile(fileName, true);\n        const std::string source = std::string(reinterpret_cast<char*>(input.data()), input.size());\n\n        Compiler::Options options;\n        options.packMatricesInRowMajor = false;\n\n        HlslToAnyTest(\"Transform_VS_ColumnMajor\", {source.c_str(), fileName.c_str(), nullptr, ShaderStage::VertexShader}, options,\n                      {{ShadingLanguage::Glsl, \"300\"}}, {true});\n    }\n\n    TEST_F(VertexShaderTest, ToEssl)\n    {\n        RunTests(ShadingLanguage::Essl);\n    }\n\n    TEST_F(VertexShaderTest, ToMsl)\n    {\n        RunTests(ShadingLanguage::Msl_macOS);\n    }\n\n\n    TEST_F(PixelShaderTest, ToHlsl)\n    {\n        RunTests(ShadingLanguage::Hlsl);\n    }\n\n    TEST_F(PixelShaderTest, ToGlsl)\n    {\n        RunTests(ShadingLanguage::Glsl);\n    }\n\n    TEST_F(PixelShaderTest, ToEssl)\n    {\n        RunTests(ShadingLanguage::Essl);\n    }\n\n    TEST_F(PixelShaderTest, ToMsl)\n    {\n        RunTests(ShadingLanguage::Msl_macOS);\n    }\n\n\n    TEST_F(GeometryShaderTest, ToHlsl)\n    {\n        RunTests(ShadingLanguage::Hlsl);\n    }\n\n    TEST_F(GeometryShaderTest, ToGlsl)\n    {\n        RunTests(ShadingLanguage::Glsl);\n    }\n\n    TEST_F(GeometryShaderTest, ToEssl)\n    {\n        RunTests(ShadingLanguage::Essl);\n    }\n\n    TEST_F(GeometryShaderTest, ToMsl)\n    {\n        RunTests(ShadingLanguage::Msl_macOS);\n    }\n\n\n    TEST_F(HullShaderTest, ToHlsl)\n    {\n        RunTests(ShadingLanguage::Hlsl);\n    }\n\n    TEST_F(HullShaderTest, ToGlsl)\n    {\n        RunTests(ShadingLanguage::Glsl);\n    }\n\n    TEST_F(HullShaderTest, ToEssl)\n    {\n        RunTests(ShadingLanguage::Essl);\n    }\n\n    TEST_F(HullShaderTest, ToMsl)\n    {\n        RunTests(ShadingLanguage::Msl_macOS);\n    }\n\n\n    TEST_F(DomainShaderTest, ToHlsl)\n    {\n        RunTests(ShadingLanguage::Hlsl);\n    }\n\n    TEST_F(DomainShaderTest, ToGlsl)\n    {\n        RunTests(ShadingLanguage::Glsl);\n    }\n\n    TEST_F(DomainShaderTest, ToEssl)\n    {\n        RunTests(ShadingLanguage::Essl);\n    }\n\n    TEST_F(DomainShaderTest, ToMsl)\n    {\n        RunTests(ShadingLanguage::Msl_macOS);\n    }\n\n\n    TEST_F(ComputeShaderTest, ToHlsl)\n    {\n        RunTests(ShadingLanguage::Hlsl);\n    }\n\n    TEST_F(ComputeShaderTest, ToGlsl)\n    {\n        RunTests(ShadingLanguage::Glsl);\n    }\n\n    TEST_F(ComputeShaderTest, ToEssl)\n    {\n        RunTests(ShadingLanguage::Essl);\n    }\n\n    TEST_F(ComputeShaderTest, ToMsl)\n    {\n        RunTests(ShadingLanguage::Msl_macOS);\n    }\n\n    TEST(IncludeTest, IncludeExist)\n    {\n        const std::string fileName = TEST_DATA_DIR \"Input/IncludeExist.hlsl\";\n\n        std::vector<uint8_t> input = LoadFile(fileName, true);\n        const std::string source = std::string(reinterpret_cast<char*>(input.data()), input.size());\n\n        const auto result =\n            Compiler::Compile({source.c_str(), fileName.c_str(), \"main\", ShaderStage::PixelShader}, {}, {ShadingLanguage::Glsl, \"30\"});\n\n        EXPECT_FALSE(result.hasError);\n        EXPECT_EQ(result.errorWarningMsg.Size(), 0U);\n        EXPECT_TRUE(result.isText);\n\n        const uint8_t* target_ptr = reinterpret_cast<const uint8_t*>(result.target.Data());\n        CompareWithExpected(std::vector<uint8_t>(target_ptr, target_ptr + result.target.Size()), result.isText, \"IncludeExist.glsl\");\n    }\n\n    TEST(IncludeTest, IncludeNotExist)\n    {\n        const std::string fileName = TEST_DATA_DIR \"Input/IncludeNotExist.hlsl\";\n\n        std::vector<uint8_t> input = LoadFile(fileName, true);\n        const std::string source = std::string(reinterpret_cast<char*>(input.data()), input.size());\n\n        const auto result =\n            Compiler::Compile({source.c_str(), fileName.c_str(), \"main\", ShaderStage::PixelShader}, {}, {ShadingLanguage::Glsl, \"30\"});\n\n        EXPECT_TRUE(result.hasError);\n        const char* errorStr = reinterpret_cast<const char*>(result.errorWarningMsg.Data());\n        EXPECT_GE(std::string(errorStr, errorStr + result.errorWarningMsg.Size()).find(\"fatal error: 'Header.hlsli' file not found\"), 0U);\n    }\n\n    TEST(IncludeTest, IncludeEmptyFile)\n    {\n        const std::string fileName = TEST_DATA_DIR \"Input/IncludeEmptyHeader.hlsl\";\n\n        std::vector<uint8_t> input = LoadFile(fileName, true);\n        const std::string source = std::string(reinterpret_cast<char*>(input.data()), input.size());\n\n        const auto result =\n            Compiler::Compile({source.c_str(), fileName.c_str(), \"main\", ShaderStage::PixelShader}, {}, {ShadingLanguage::Glsl, \"30\"});\n\n        EXPECT_FALSE(result.hasError);\n        EXPECT_EQ(result.errorWarningMsg.Size(), 0U);\n        EXPECT_TRUE(result.isText);\n\n        const uint8_t* target_ptr = reinterpret_cast<const uint8_t*>(result.target.Data());\n        CompareWithExpected(std::vector<uint8_t>(target_ptr, target_ptr + result.target.Size()), result.isText, \"IncludeEmptyHeader.glsl\");\n    }\n\n    TEST(HalfDataTypeTest, DotHalf)\n    {\n        const std::string fileName = TEST_DATA_DIR \"Input/HalfDataType.hlsl\";\n\n        std::vector<uint8_t> input = LoadFile(fileName, true);\n        const std::string source = std::string(reinterpret_cast<char*>(input.data()), input.size());\n\n        Compiler::Options option;\n        option.shaderModel = {6, 2};\n        option.enable16bitTypes = true;\n\n        const auto result = Compiler::Compile({source.c_str(), fileName.c_str(), \"DotHalfPS\", ShaderStage::PixelShader}, option,\n                                              {ShadingLanguage::Glsl, \"30\"});\n\n        EXPECT_FALSE(result.hasError);\n        EXPECT_TRUE(result.isText);\n\n        const uint8_t* target_ptr = reinterpret_cast<const uint8_t*>(result.target.Data());\n        CompareWithExpected(std::vector<uint8_t>(target_ptr, target_ptr + result.target.Size()), result.isText, \"DotHalfPS.glsl\");\n    }\n\n    TEST(HalfDataTypeTest, HalfOutParam)\n    {\n        const std::string fileName = TEST_DATA_DIR \"Input/HalfDataType.hlsl\";\n\n        std::vector<uint8_t> input = LoadFile(fileName, true);\n        const std::string source = std::string(reinterpret_cast<char*>(input.data()), input.size());\n\n        Compiler::Options option;\n        option.shaderModel = {6, 2};\n        option.enable16bitTypes = true;\n\n        const auto result = Compiler::Compile({source.c_str(), fileName.c_str(), \"HalfOutParamPS\", ShaderStage::PixelShader}, option,\n                                              {ShadingLanguage::Glsl, \"30\"});\n\n        EXPECT_FALSE(result.hasError);\n        EXPECT_TRUE(result.isText);\n\n        const uint8_t* target_ptr = reinterpret_cast<const uint8_t*>(result.target.Data());\n        CompareWithExpected(std::vector<uint8_t>(target_ptr, target_ptr + result.target.Size()), result.isText, \"HalfOutParamPS.glsl\");\n    }\n\n    TEST(LinkTest, LinkDxil)\n    {\n        if (!Compiler::LinkSupport())\n        {\n            GTEST_SKIP_(\"Link is not supported on this platform\");\n        }\n\n        const Compiler::TargetDesc target = {ShadingLanguage::Dxil, \"\", true};\n        const Compiler::ModuleDesc dxilModules[] = {\n            CompileToModule(\"CalcLight\", TEST_DATA_DIR \"Input/CalcLight.hlsl\", target),\n            CompileToModule(\"CalcLightDiffuse\", TEST_DATA_DIR \"Input/CalcLightDiffuse.hlsl\", target),\n            CompileToModule(\"CalcLightDiffuseSpecular\", TEST_DATA_DIR \"Input/CalcLightDiffuseSpecular.hlsl\", target),\n        };\n\n        const Compiler::ModuleDesc* testModules[][2] = {\n            {&dxilModules[0], &dxilModules[1]},\n            {&dxilModules[0], &dxilModules[2]},\n        };\n\n#ifdef NDEBUG\n        const std::string expectedNames[] = {\"CalcLight+Diffuse.Release.dxilasm\", \"CalcLight+DiffuseSpecular.Release.dxilasm\"};\n#else\n        const std::string expectedNames[] = {\"CalcLight+Diffuse.Debug.dxilasm\", \"CalcLight+DiffuseSpecular.Debug.dxilasm\"};\n#endif\n\n        for (size_t i = 0; i < 2; ++i)\n        {\n            const auto linkedResult =\n                Compiler::Link({\"main\", ShaderStage::PixelShader, testModules[i], sizeof(testModules[i]) / sizeof(testModules[i][0])}, {},\n                               {ShadingLanguage::Dxil, \"\"});\n\n            EXPECT_FALSE(linkedResult.hasError);\n            EXPECT_FALSE(linkedResult.isText);\n\n            Compiler::DisassembleDesc disasmDesc;\n            disasmDesc.binary = reinterpret_cast<const uint8_t*>(linkedResult.target.Data());\n            disasmDesc.binarySize = linkedResult.target.Size();\n            disasmDesc.language = ShadingLanguage::Dxil;\n            const auto disasmResult = Compiler::Disassemble(disasmDesc);\n\n            const uint8_t* target_ptr = reinterpret_cast<const uint8_t*>(disasmResult.target.Data());\n            CompareWithExpected(std::vector<uint8_t>(target_ptr, target_ptr + disasmResult.target.Size()), disasmResult.isText,\n                                expectedNames[i]);\n        }\n    }\n} // namespace\n\nint main(int argc, char** argv)\n{\n    testing::InitGoogleTest(&argc, argv);\n\n    int retVal = RUN_ALL_TESTS();\n    if (retVal != 0)\n    {\n        getchar();\n    }\n\n    return retVal;\n}\n"
  },
  {
    "path": "Source/Tools/CMakeLists.txt",
    "content": "# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the MIT License.\n\nset(EXE_NAME ShaderConductorCmd)\n\nset(SOURCE_FILES\n    ShaderConductorCmd.cpp\n)\n\nsource_group(\"Source Files\" FILES ${SOURCE_FILES})\n\nadd_executable(${EXE_NAME} ${SOURCE_FILES})\n\ntarget_link_libraries(${EXE_NAME}\n    PRIVATE\n        ShaderConductor\n        cxxopts\n)\n\nadd_dependencies(${EXE_NAME} ShaderConductor)\n\nset_target_properties(${EXE_NAME} PROPERTIES FOLDER \"Tools\")\n"
  },
  {
    "path": "Source/Tools/ShaderConductorCmd.cpp",
    "content": "/*\n * ShaderConductor\n *\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n *\n * MIT License\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this\n * software and associated documentation files (the \"Software\"), to deal in the Software\n * without restriction, including without limitation the rights to use, copy, modify, merge,\n * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons\n * to whom the Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all copies or\n * substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR\n * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE\n * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\n#include <ShaderConductor/ShaderConductor.hpp>\n\n#include <fstream>\n#include <iostream>\n#include <string>\n#include <vector>\n\n#ifdef _MSC_VER\n#pragma warning(push)\n#pragma warning(disable : 4819)\n#endif\n#include <cxxopts.hpp>\n#ifdef _MSC_VER\n#pragma warning(pop)\n#endif\n\nint main(int argc, char** argv)\n{\n    cxxopts::Options options(\"ShaderConductorCmd\", \"A tool for compiling HLSL to many shader languages.\");\n    // clang-format off\n    options.add_options()\n        (\"E,entry\", \"Entry point of the shader\", cxxopts::value<std::string>()->default_value(\"main\"))\n        (\"I,input\", \"Input file name\", cxxopts::value<std::string>())(\"O,output\", \"Output file name\", cxxopts::value<std::string>())\n        (\"S,stage\", \"Shader stage: vs, ps, gs, hs, ds, cs\", cxxopts::value<std::string>())\n        (\"T,target\", \"Target shading language: dxil, spirv, hlsl, glsl, essl, msl_macos, msl_ios\", cxxopts::value<std::string>()->default_value(\"dxil\"))\n        (\"V,version\", \"The version of target shading language\", cxxopts::value<std::string>()->default_value(\"\"))\n        (\"D,define\", \"Macro define as name=value\", cxxopts::value<std::vector<std::string>>());\n\n    // clang-format on\n\n    auto opts = options.parse(argc, argv);\n\n    if ((opts.count(\"input\") == 0) || (opts.count(\"stage\") == 0))\n    {\n        std::cerr << \"COULDN'T find <input> or <stage> in command line parameters.\" << std::endl;\n        std::cerr << options.help() << std::endl;\n        return 1;\n    }\n\n    using namespace ShaderConductor;\n\n    Compiler::SourceDesc sourceDesc{};\n    Compiler::TargetDesc targetDesc{};\n\n    const auto fileName = opts[\"input\"].as<std::string>();\n    const auto targetName = opts[\"target\"].as<std::string>();\n    const auto targetVersion = opts[\"version\"].as<std::string>();\n\n    sourceDesc.fileName = fileName.c_str();\n    targetDesc.version = targetVersion.empty() ? nullptr : targetVersion.c_str();\n\n    const auto stageName = opts[\"stage\"].as<std::string>();\n    if (stageName == \"vs\")\n    {\n        sourceDesc.stage = ShaderStage::VertexShader;\n    }\n    else if (stageName == \"ps\")\n    {\n        sourceDesc.stage = ShaderStage::PixelShader;\n    }\n    else if (stageName == \"gs\")\n    {\n        sourceDesc.stage = ShaderStage::GeometryShader;\n    }\n    else if (stageName == \"hs\")\n    {\n        sourceDesc.stage = ShaderStage::HullShader;\n    }\n    else if (stageName == \"ds\")\n    {\n        sourceDesc.stage = ShaderStage::DomainShader;\n    }\n    else if (stageName == \"cs\")\n    {\n        sourceDesc.stage = ShaderStage::ComputeShader;\n    }\n    else\n    {\n        std::cerr << \"Invalid shader stage: \" << stageName << std::endl;\n        return 1;\n    }\n\n    const auto entryPoint = opts[\"entry\"].as<std::string>();\n    sourceDesc.entryPoint = entryPoint.c_str();\n\n    if (targetName == \"dxil\")\n    {\n        targetDesc.language = ShadingLanguage::Dxil;\n    }\n    else if (targetName == \"spirv\")\n    {\n        targetDesc.language = ShadingLanguage::SpirV;\n    }\n    else if (targetName == \"hlsl\")\n    {\n        targetDesc.language = ShadingLanguage::Hlsl;\n    }\n    else if (targetName == \"glsl\")\n    {\n        targetDesc.language = ShadingLanguage::Glsl;\n    }\n    else if (targetName == \"essl\")\n    {\n        targetDesc.language = ShadingLanguage::Essl;\n    }\n    else if (targetName == \"msl_macos\")\n    {\n        targetDesc.language = ShadingLanguage::Msl_macOS;\n    }\n    else if (targetName == \"msl_ios\")\n    {\n        targetDesc.language = ShadingLanguage::Msl_iOS;\n    }\n    else\n    {\n        std::cerr << \"Invalid target shading language: \" << targetName << std::endl;\n        return 1;\n    }\n\n    std::string outputName;\n    if (opts.count(\"output\") == 0)\n    {\n        static const std::string extMap[] = {\"dxil\", \"spv\", \"hlsl\", \"glsl\", \"essl\", \"msl\", \"msl\"};\n        static_assert(sizeof(extMap) / sizeof(extMap[0]) == static_cast<uint32_t>(ShadingLanguage::NumShadingLanguages),\n                      \"extMap doesn't match with the number of shading languages.\");\n        outputName = fileName + \".\" + extMap[static_cast<uint32_t>(targetDesc.language)];\n    }\n    else\n    {\n        outputName = opts[\"output\"].as<std::string>();\n    }\n\n    std::string source;\n    {\n        std::ifstream inputFile(sourceDesc.fileName, std::ios_base::binary);\n        if (!inputFile)\n        {\n            std::cerr << \"COULDN'T load the input file: \" << sourceDesc.fileName << std::endl;\n            return 1;\n        }\n\n        inputFile.seekg(0, std::ios::end);\n        source.resize(static_cast<size_t>(inputFile.tellg()));\n        inputFile.seekg(0, std::ios::beg);\n        inputFile.read(&source[0], source.size());\n    }\n    sourceDesc.source = source.c_str();\n\n    size_t numberOfDefines = opts.count(\"define\");\n    std::vector<MacroDefine> macroDefines;\n    std::vector<std::string> macroStrings;\n    if (numberOfDefines > 0)\n    {\n        macroDefines.reserve(numberOfDefines);\n        macroStrings.reserve(numberOfDefines * 2);\n        auto& defines = opts[\"define\"].as<std::vector<std::string>>();\n        for (const auto& define : defines)\n        {\n            MacroDefine macroDefine;\n            macroDefine.name = nullptr;\n            macroDefine.value = nullptr;\n\n            size_t splitPosition = define.find('=');\n            if (splitPosition != std::string::npos)\n            {\n                std::string macroName = define.substr(0, splitPosition);\n                std::string macroValue = define.substr(splitPosition + 1, define.size() - splitPosition - 1);\n\n                macroStrings.push_back(macroName);\n                macroDefine.name = macroStrings.back().c_str();\n                macroStrings.push_back(macroValue);\n                macroDefine.value = macroStrings.back().c_str();\n            }\n            else\n            {\n                macroStrings.push_back(define);\n                macroDefine.name = macroStrings.back().c_str();\n            }\n\n            macroDefines.push_back(macroDefine);\n        }\n\n        sourceDesc.defines = macroDefines.data();\n        sourceDesc.numDefines = static_cast<uint32_t>(macroDefines.size());\n    }\n\n    try\n    {\n        const auto result = Compiler::Compile(sourceDesc, {}, targetDesc);\n\n        if (result.errorWarningMsg.Size() > 0)\n        {\n            const char* msg = reinterpret_cast<const char*>(result.errorWarningMsg.Data());\n            std::cerr << \"Error or warning from shader compiler: \" << std::endl\n                      << std::string(msg, msg + result.errorWarningMsg.Size()) << std::endl;\n        }\n        if (result.target.Size() > 0)\n        {\n            std::ofstream outputFile(outputName, std::ios_base::binary);\n            if (!outputFile)\n            {\n                std::cerr << \"COULDN'T open the output file: \" << outputName << std::endl;\n                return 1;\n            }\n\n            outputFile.write(reinterpret_cast<const char*>(result.target.Data()), result.target.Size());\n\n            std::cout << \"The compiled file is saved to \" << outputName << std::endl;\n        }\n    }\n    catch (std::exception& ex)\n    {\n        std::cerr << ex.what() << std::endl;\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "Source/Wrapper/CMakeLists.txt",
    "content": "# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the MIT License.\n\nset(DLL_NAME ShaderConductorWrapper)\n\nset(SOURCE_FILES\n    Native.cpp\n    Native.h\n)\n\nsource_group(\"Source Files\" FILES ${SOURCE_FILES})\n\nadd_library(${DLL_NAME} SHARED ${SOURCE_FILES})\n\ntarget_link_libraries(${DLL_NAME}\n    PRIVATE\n        ShaderConductor\n)\n\nadd_dependencies(${DLL_NAME} ShaderConductor)\n\nset_target_properties(${DLL_NAME} PROPERTIES FOLDER \"Wrapper\")\n\nset(CSHARP_TEST CSharpPinvoke)\n\nset(SOURCE_FILES\n    Program.cs\n    Wrapper.cs    \n)\n\nset(DATA_FILES\n    shader.hlsl \n)\n\nset_source_files_properties(${DATA_FILES}\n    PROPERTIES VS_TOOL_OVERRIDE \"None\"    \n    \t\t   VS_COPY_TO_OUT_DIR \"PreserveNewest\"\n)\n\nadd_executable(${CSHARP_TEST} ${SOURCE_FILES} ${DATA_FILES})\nadd_dependencies(${CSHARP_TEST} ShaderConductorWrapper)\n\nset_target_properties(${CSHARP_TEST} PROPERTIES FOLDER \"Wrapper\")\n"
  },
  {
    "path": "Source/Wrapper/Native.cpp",
    "content": "/*\n * ShaderConductor\n *\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n *\n * MIT License\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this\n * software and associated documentation files (the \"Software\"), to deal in the Software\n * without restriction, including without limitation the rights to use, copy, modify, merge,\n * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons\n * to whom the Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all copies or\n * substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR\n * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE\n * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\n#include \"Native.h\"\n#include <ShaderConductor/ShaderConductor.hpp>\n#include <iostream>\n\nusing namespace ShaderConductor;\n\nvoid Compile(SourceDescription* source, OptionsDescription* optionsDesc, TargetDescription* target, ResultDescription* result)\n{\n    Compiler::SourceDesc sourceDesc;\n    sourceDesc.entryPoint = source->entryPoint;\n    sourceDesc.source = source->source;\n    sourceDesc.stage = source->stage;\n    sourceDesc.fileName = nullptr;\n    sourceDesc.defines = nullptr;\n    sourceDesc.numDefines = 0;\n\n    Compiler::Options options;\n    options.packMatricesInRowMajor = optionsDesc->packMatricesInRowMajor;\n    options.enable16bitTypes = optionsDesc->enable16bitTypes;\n    options.enableDebugInfo = optionsDesc->enableDebugInfo;\n    options.disableOptimizations = optionsDesc->disableOptimizations;\n    options.optimizationLevel = optionsDesc->optimizationLevel;\n    options.shaderModel = {static_cast<uint8_t>(optionsDesc->shaderModel.major), static_cast<uint8_t>(optionsDesc->shaderModel.minor)};\n    options.shiftAllTexturesBindings = optionsDesc->shiftAllTexturesBindings;\n    options.shiftAllSamplersBindings = optionsDesc->shiftAllSamplersBindings;\n    options.shiftAllCBuffersBindings = optionsDesc->shiftAllCBuffersBindings;\n    options.shiftAllUABuffersBindings = optionsDesc->shiftAllUABuffersBindings;\n\n    Compiler::TargetDesc targetDesc{};\n    targetDesc.language = target->shadingLanguage;\n    targetDesc.version = target->version;\n\n    try\n    {\n        const auto translation = Compiler::Compile(sourceDesc, options, targetDesc);\n\n        if (translation.errorWarningMsg.Size() > 0)\n        {\n            result->errorWarningMsg = CreateShaderConductorBlob(translation.errorWarningMsg.Data(), translation.errorWarningMsg.Size());\n        }\n        if (translation.target.Size() > 0)\n        {\n            result->target = CreateShaderConductorBlob(translation.target.Data(), translation.target.Size());\n        }\n\n        result->hasError = translation.hasError;\n        result->isText = translation.isText;\n    }\n    catch (std::exception& ex)\n    {\n        const char* exception = ex.what();\n        result->errorWarningMsg = CreateShaderConductorBlob(exception, static_cast<uint32_t>(strlen(exception)));\n        result->hasError = true;\n    }\n}\n\nvoid Disassemble(DisassembleDescription* source, ResultDescription* result)\n{\n    Compiler::DisassembleDesc disassembleSource;\n    disassembleSource.language = source->language;\n    disassembleSource.binary = reinterpret_cast<uint8_t*>(source->binary);\n    disassembleSource.binarySize = source->binarySize;\n\n    const auto disassembleResult = Compiler::Disassemble(disassembleSource);\n\n    if (disassembleResult.errorWarningMsg.Size() > 0)\n    {\n        result->errorWarningMsg =\n            CreateShaderConductorBlob(disassembleResult.errorWarningMsg.Data(), disassembleResult.errorWarningMsg.Size());\n    }\n    if (disassembleResult.target.Size() > 0)\n    {\n        result->target = CreateShaderConductorBlob(disassembleResult.target.Data(), disassembleResult.target.Size());\n    }\n\n    result->hasError = disassembleResult.hasError;\n    result->isText = disassembleResult.isText;\n}\n\nShaderConductorBlob* CreateShaderConductorBlob(const void* data, int size)\n{\n    return reinterpret_cast<ShaderConductorBlob*>(new ShaderConductor::Blob(data, size));\n}\n\nvoid DestroyShaderConductorBlob(ShaderConductorBlob* blob)\n{\n    delete reinterpret_cast<Blob*>(blob);\n}\n\nconst void* GetShaderConductorBlobData(ShaderConductorBlob* blob)\n{\n    return reinterpret_cast<Blob*>(blob)->Data();\n}\n\nint GetShaderConductorBlobSize(ShaderConductorBlob* blob)\n{\n    return reinterpret_cast<Blob*>(blob)->Size();\n}\n"
  },
  {
    "path": "Source/Wrapper/Native.h",
    "content": "/*\n * ShaderConductor\n *\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n *\n * MIT License\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this\n * software and associated documentation files (the \"Software\"), to deal in the Software\n * without restriction, including without limitation the rights to use, copy, modify, merge,\n * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons\n * to whom the Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all copies or\n * substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR\n * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE\n * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\n#pragma once\n\n#include <ShaderConductor/ShaderConductor.hpp>\n\nusing namespace ShaderConductor;\n\nstruct ShaderConductorBlob;\n\nstruct SourceDescription\n{\n    const char* source;\n    const char* entryPoint;\n    ShaderStage stage;\n};\n\nstruct ShaderModel\n{\n    int major;\n    int minor;\n};\n\nstruct OptionsDescription\n{\n    bool packMatricesInRowMajor = true; // Experimental: Decide how a matrix get packed\n    bool enable16bitTypes = false;      // Enable 16-bit types, such as half, uint16_t. Requires shader model 6.2+\n    bool enableDebugInfo = false;       // Embed debug info into the binary\n    bool disableOptimizations = false;  // Force to turn off optimizations. Ignore optimizationLevel below.\n    int optimizationLevel = 3;          // 0 to 3, no optimization to most optimization\n\n    ShaderModel shaderModel = {6, 0};\n\n    int shiftAllTexturesBindings;\n    int shiftAllSamplersBindings;\n    int shiftAllCBuffersBindings;\n    int shiftAllUABuffersBindings;\n};\n\nstruct TargetDescription\n{\n    ShadingLanguage shadingLanguage;\n    const char* version;\n};\n\nstruct ResultDescription\n{\n    ShaderConductorBlob* target;\n    bool isText;\n\n    ShaderConductorBlob* errorWarningMsg;\n    bool hasError;\n};\n\nstruct DisassembleDescription\n{\n    ShadingLanguage language;\n    char* binary;\n    int binarySize;\n};\n\n#define DLLEXPORT extern \"C\" __declspec(dllexport)\n\nDLLEXPORT void Compile(SourceDescription* source, OptionsDescription* optionsDesc, TargetDescription* target, ResultDescription* result);\nDLLEXPORT void Disassemble(DisassembleDescription* source, ResultDescription* result);\n\nDLLEXPORT ShaderConductorBlob* CreateShaderConductorBlob(const void* data, int size);\nDLLEXPORT void DestroyShaderConductorBlob(ShaderConductorBlob* blob);\nDLLEXPORT const void* GetShaderConductorBlobData(ShaderConductorBlob* blob);\nDLLEXPORT int GetShaderConductorBlobSize(ShaderConductorBlob* blob);\n"
  },
  {
    "path": "Source/Wrapper/Program.cs",
    "content": "/*\n * ShaderConductor\n *\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n *\n * MIT License\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this\n * software and associated documentation files (the \"Software\"), to deal in the Software\n * without restriction, including without limitation the rights to use, copy, modify, merge,\n * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons\n * to whom the Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all copies or\n * substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR\n * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE\n * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\nusing System;\nusing System.IO;\nusing System.Runtime.InteropServices;\n\nnamespace CSharpConsole\n{\n    class Program\n    {\n        static void Main(string[] args)\n        {\n            string source = File.ReadAllText(\"shader.hlsl\");\n\n            Wrapper.SourceDesc sourceDesc = new Wrapper.SourceDesc()\n            {\n                entryPoint = \"PS\",\n\n                stage = Wrapper.ShaderStage.PixelShader,\n                source = source,\n            };\n\n            Wrapper.OptionsDesc optionsDesc = Wrapper.OptionsDesc.Default;\n            //optionsDesc.packMatricesInRowMajor = true;\n            //optionsDesc.enable16bitTypes = true;\n            //optionsDesc.enableDebugInfo = true;\n            //optionsDesc.disableOptimizations = true;\n            //optionsDesc.optimizationLevel = 3;\n            //optionsDesc.shaderModel = new Wrapper.ShaderModel(6, 2);\n            //optionsDesc.shiftAllCBuffersBindings = 10;\n            //optionsDesc.shiftAllTexturesBindings = 20;\n            //optionsDesc.shiftAllSamplersBindings = 30;\n            //optionsDesc.shiftAllUABuffersBindings = 40;\n\n            Wrapper.TargetDesc targetDesc = new Wrapper.TargetDesc()\n            {\n                language = Wrapper.ShadingLanguage.Glsl,\n                version = \"460\",\n                asModule = false,\n            };\n\n            Wrapper.Compile(ref sourceDesc, ref optionsDesc, ref targetDesc, out Wrapper.ResultDesc result);\n\n            if (result.hasError)\n            {\n                string warning = Marshal.PtrToStringAnsi(Wrapper.GetShaderConductorBlobData(result.errorWarningMsg),\n                    Wrapper.GetShaderConductorBlobSize(result.errorWarningMsg));\n                Console.WriteLine(\"*************************\\n\" +\n                                  \"**  Error output       **\\n\" +\n                                  \"*************************\\n\");\n                Console.WriteLine(warning);\n            }\n            else\n            {\n                if (!result.isText)\n                {\n                    Wrapper.DisassembleDesc disassembleDesc = new Wrapper.DisassembleDesc()\n                    {\n                        language = targetDesc.language,\n                        binarySize = Wrapper.GetShaderConductorBlobSize(result.target),\n                        binary = Wrapper.GetShaderConductorBlobData(result.target),\n                    };\n\n                    Wrapper.Disassemble(ref disassembleDesc, out Wrapper.ResultDesc disassembleResult);\n                    Wrapper.DestroyShaderConductorBlob(result.target);\n                    Wrapper.DestroyShaderConductorBlob(result.errorWarningMsg);\n                    result = disassembleResult;\n                }\n\n                if (result.isText)\n                {\n                    string translation = Marshal.PtrToStringAnsi(Wrapper.GetShaderConductorBlobData(result.target),\n                        Wrapper.GetShaderConductorBlobSize(result.target));\n                    Console.WriteLine(\"*************************\\n\" +\n                                      \"**  Translation        **\\n\" +\n                                      \"*************************\\n\");\n                    Console.WriteLine(translation);\n                }\n            }            \n\n            Wrapper.DestroyShaderConductorBlob(result.target);\n            Wrapper.DestroyShaderConductorBlob(result.errorWarningMsg);\n\n            Console.Read();\n        }\n    }\n}\n"
  },
  {
    "path": "Source/Wrapper/Wrapper.cs",
    "content": "/*\n * ShaderConductor\n *\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n *\n * MIT License\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this\n * software and associated documentation files (the \"Software\"), to deal in the Software\n * without restriction, including without limitation the rights to use, copy, modify, merge,\n * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons\n * to whom the Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all copies or\n * substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR\n * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE\n * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Runtime.InteropServices;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace CSharpConsole\n{\n    public class Wrapper\n    {\n        [DllImport(\"ShaderConductorWrapper.dll\", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]\n        public static extern void Compile([In] ref SourceDesc source, [In] ref OptionsDesc options, [In] ref TargetDesc target, out ResultDesc result);\n\n        [DllImport(\"ShaderConductorWrapper.dll\", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]\n        public static extern void Disassemble([In] ref DisassembleDesc source, out ResultDesc result);\n\n        [DllImport(\"ShaderConductorWrapper.dll\", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]\n        public static extern IntPtr CreateShaderConductorBlob(IntPtr data, int size);\n\n        [DllImport(\"ShaderConductorWrapper.dll\", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]\n        public static extern void DestroyShaderConductorBlob(IntPtr blob);\n\n        [DllImport(\"ShaderConductorWrapper.dll\", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]\n        public static extern IntPtr GetShaderConductorBlobData(IntPtr blob);\n\n        [DllImport(\"ShaderConductorWrapper.dll\", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]\n        public static extern int GetShaderConductorBlobSize(IntPtr blob);\n\n        public enum ShaderStage\n        {\n            VertexShader,\n            PixelShader,\n            GeometryShader,\n            HullShader,\n            DomainShader,\n            ComputeShader,\n\n            NumShaderStages,\n        };\n\n        public enum ShadingLanguage\n        {\n            Dxil = 0,\n            SpirV,\n\n            Hlsl,\n            Glsl,\n            Essl,\n            Msl_macOS,\n            Msl_iOS,\n\n            NumShadingLanguages,\n        }\n\n        [StructLayout(LayoutKind.Sequential)]\n        public struct MacroDefine\n        {\n            public string name;\n            public string value;\n        };\n\n        [StructLayout(LayoutKind.Sequential)]\n        public struct SourceDesc\n        {\n            public string source;\n            public string entryPoint;\n            public ShaderStage stage;\n        }\n\n        [StructLayout(LayoutKind.Sequential)]\n        public struct ShaderModel\n        {\n            public int major;\n            public int minor;\n\n            public ShaderModel(int major, int minor)\n            {\n                this.major = major;\n                this.minor = minor;\n            }\n        }\n\n        [StructLayout(LayoutKind.Sequential)]\n        public struct OptionsDesc\n        {\n            [MarshalAs(UnmanagedType.I1)]\n            public bool packMatricesInRowMajor; // Experimental: Decide how a matrix get packed\n            [MarshalAs(UnmanagedType.I1)]\n            public bool enable16bitTypes; // Enable 16-bit types, such as half, uint16_t. Requires shader model 6.2+\n            [MarshalAs(UnmanagedType.I1)]\n            public bool enableDebugInfo; // Embed debug info into the binary\n            [MarshalAs(UnmanagedType.I1)]\n            public bool disableOptimizations; // Force to turn off optimizations. Ignore optimizationLevel below.\n            public int optimizationLevel; // 0 to 3, no optimization to most optimization\n\n            public ShaderModel shaderModel;\n\n            public int shiftAllTexturesBindings;\n            public int shiftAllSamplersBindings;\n            public int shiftAllCBuffersBindings;\n            public int shiftAllUABuffersBindings;\n\n            public static OptionsDesc Default\n            {\n                get\n                {\n                    var defaultInstance = new OptionsDesc();\n\n                    defaultInstance.packMatricesInRowMajor = true;\n                    defaultInstance.enable16bitTypes = false;\n                    defaultInstance.enableDebugInfo = false;\n                    defaultInstance.disableOptimizations = false;\n                    defaultInstance.optimizationLevel = 3;\n                    defaultInstance.shaderModel = new ShaderModel(6, 0);\n\n                    return defaultInstance;\n                }\n            }\n        }\n\n        [StructLayout(LayoutKind.Sequential)]\n        public struct TargetDesc\n        {\n            public ShadingLanguage language;\n            public string version;\n            public bool asModule;\n        }\n\n        [StructLayout(LayoutKind.Sequential)]\n        public struct ResultDesc\n        {\n            public IntPtr target;\n            public bool isText;\n            public IntPtr errorWarningMsg;\n            public bool hasError;\n        }\n\n        [StructLayout(LayoutKind.Sequential)]\n        public struct DisassembleDesc\n        {\n            public ShadingLanguage language;\n            public IntPtr binary;\n            public int binarySize;\n        }\n    }\n}\n"
  },
  {
    "path": "Source/Wrapper/shader.hlsl",
    "content": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\ncbuffer Matrices : register(b0)\n{\n    float4x4 worldViewProj;\n};\n\nTexture2D DiffuseTexture : register(t0);\nSamplerState Sampler : register(s0);\n\nstruct VS_IN\n{\n    float4 pos : POSITION;\n    float4 col : COLOR;\n    float2 tex : TEXCOORD;\n};\n\nstruct PS_IN\n{\n    float4 pos : SV_POSITION;\n    float4 col : COLOR;\n    float2 tex : TEXCOORD;\n};\n\nPS_IN VS(VS_IN input)\n{\n    PS_IN output = (PS_IN)0;\n\n    output.pos = mul(input.pos, worldViewProj);\n    output.col = input.col;\n    output.tex = input.tex;\n\n    return output;\n}\n\nfloat4 PS(PS_IN input) : SV_Target\n{\n    return DiffuseTexture.Sample(Sampler, input.tex);\n}"
  },
  {
    "path": "azure-pipelines.yml",
    "content": "variables:\n  configuration: Release\n  platform: x64\n\nresources:\n- repo: self\n  fetchDepth: 5\n\nstages:\n- stage: ClangFormat\n  jobs:\n  - job: ClangFormat\n    pool:\n      vmImage: Ubuntu-18.04\n\n    variables:\n      CC: gcc\n      CXX: g++\n\n    steps:\n    - bash: |\n        sudo add-apt-repository ppa:ubuntu-toolchain-r/test\n        sudo apt-get update\n        sudo apt-get install clang-format-9 ninja-build python3\n      displayName: 'Install'\n    - task: PythonScript@0\n      displayName: 'Build'\n      inputs:\n        scriptPath: BuildAll.py\n        arguments: 'ninja gcc linux clangformat'\n    - script: |\n        git diff --exit-code $(Build.SourceVersion)\n      failOnStderr: true\n      displayName: 'Clang-Format'\n\n- stage: Build\n  condition: succeeded('ClangFormat')\n  jobs:\n  - job: Windows_vc140_x64\n    pool:\n      vmImage: VS2017-Win2016\n\n    variables:\n      compiler: vc140\n      combination: 'win-$(compiler)-$(platform)-$(configuration)'\n      buildFolder: 'Build/ninja-$(combination)'\n      installCommand: 'choco install ninja python3'\n      testCommand: './$(buildFolder)/Bin/ShaderConductorTest.exe'\n      artifactBinaries: |\n        Bin/ShaderConductor.dll\n        Bin/ShaderConductorCmd.exe\n        Bin/dxcompiler.dll\n        Lib/ShaderConductor.lib\n\n    steps:\n    - template: CI/AzurePipelines/ContinuousBuild.yml\n\n  - job: Windows_vc141_x86\n    pool:\n      vmImage: VS2017-Win2016\n\n    variables:\n      compiler: vc141\n      platform: x86\n      combination: 'win-$(compiler)-$(platform)-$(configuration)'\n      buildFolder: 'Build/ninja-$(combination)'\n      installCommand: 'choco install ninja python3'\n      testCommand: './$(buildFolder)/Bin/ShaderConductorTest.exe'\n      artifactBinaries: |\n        Bin/ShaderConductor.dll\n        Bin/ShaderConductorCmd.exe\n        Bin/dxcompiler.dll\n        Lib/ShaderConductor.lib\n\n    steps:\n    - template: CI/AzurePipelines/ContinuousBuild.yml\n\n  - job: Windows_vc141_x64\n    pool:\n      vmImage: VS2017-Win2016\n\n    variables:\n      compiler: vc141\n      combination: 'win-$(compiler)-$(platform)-$(configuration)'\n      buildFolder: 'Build/ninja-$(combination)'\n      installCommand: 'choco install ninja python3'\n      testCommand: './$(buildFolder)/Bin/ShaderConductorTest.exe'\n      artifactBinaries: |\n        Bin/ShaderConductor.dll\n        Bin/ShaderConductorCmd.exe\n        Bin/dxcompiler.dll\n        Lib/ShaderConductor.lib\n\n    steps:\n    - template: CI/AzurePipelines/ContinuousBuild.yml\n\n  - job: Windows_vc142_x86\n    pool:\n      vmImage: windows-2019\n\n    variables:\n      compiler: vc142\n      platform: x86\n      combination: 'win-$(compiler)-$(platform)-$(configuration)'\n      buildFolder: 'Build/ninja-$(combination)'\n      installCommand: 'choco install ninja'\n      testCommand: './$(buildFolder)/Bin/ShaderConductorTest.exe'\n      artifactBinaries: |\n        Bin/ShaderConductor.dll\n        Bin/ShaderConductorCmd.exe\n        Bin/dxcompiler.dll\n        Lib/ShaderConductor.lib\n\n    steps:\n    - template: CI/AzurePipelines/ContinuousBuild.yml\n\n  - job: Windows_vc142_x64\n    pool:\n      vmImage: windows-2019\n\n    variables:\n      compiler: vc142\n      combination: 'win-$(compiler)-$(platform)-$(configuration)'\n      buildFolder: 'Build/ninja-$(combination)'\n      installCommand: 'choco install ninja'\n      testCommand: './$(buildFolder)/Bin/ShaderConductorTest.exe'\n      artifactBinaries: |\n        Bin/ShaderConductor.dll\n        Bin/ShaderConductorCmd.exe\n        Bin/dxcompiler.dll\n        Lib/ShaderConductor.lib\n\n    steps:\n    - template: CI/AzurePipelines/ContinuousBuild.yml\n\n  - job: Windows_vc142_arm64\n    pool:\n      vmImage: windows-2019\n\n    variables:\n      compiler: vc142\n      platform: arm64\n      combination: 'win-$(compiler)-$(platform)-$(configuration)'\n      buildFolder: 'Build/ninja-$(combination)'\n      installCommand: 'choco install ninja'\n      testCommand: ''\n      artifactBinaries: |\n        Bin/ShaderConductor.dll\n        Bin/ShaderConductorCmd.exe\n        Bin/dxcompiler.dll\n        Lib/ShaderConductor.lib\n\n    steps:\n    - template: CI/AzurePipelines/ContinuousBuild.yml\n\n  - job: Linux_gcc7\n    pool:\n      vmImage: Ubuntu-18.04\n\n    variables:\n      compiler: gcc7\n      combination: 'linux-$(compiler)-$(platform)-$(configuration)'\n      buildFolder: 'Build/ninja-$(combination)'\n      installCommand: |\n        sudo add-apt-repository ppa:ubuntu-toolchain-r/test\n        sudo apt-get update\n        sudo apt-get install g++-7 ninja-build python3\n      testCommand: './$(buildFolder)/Bin/ShaderConductorTest'\n      artifactBinaries: |\n        Bin/ShaderConductorCmd\n        Lib/libdxcompiler.so\n        Lib/libShaderConductor.so\n      CC: gcc-7\n      CXX: g++-7\n\n    steps:\n    - template: CI/AzurePipelines/ContinuousBuild.yml\n\n  - job: Linux_gcc8\n    pool:\n      vmImage: Ubuntu-18.04\n\n    variables:\n      compiler: gcc8\n      combination: 'linux-$(compiler)-$(platform)-$(configuration)'\n      buildFolder: 'Build/ninja-$(combination)'\n      installCommand: |\n        sudo add-apt-repository ppa:ubuntu-toolchain-r/test\n        sudo apt-get update\n        sudo apt-get install g++-8 ninja-build python3\n      testCommand: './$(buildFolder)/Bin/ShaderConductorTest'\n      artifactBinaries: |\n        Bin/ShaderConductorCmd\n        Lib/libdxcompiler.so\n        Lib/libShaderConductor.so\n      CC: gcc-8\n      CXX: g++-8\n\n    steps:\n    - template: CI/AzurePipelines/ContinuousBuild.yml\n\n  - job: Linux_clang7\n    pool:\n      vmImage: Ubuntu-18.04\n\n    variables:\n      compiler: clang7\n      combination: 'linux-$(compiler)-$(platform)-$(configuration)'\n      buildFolder: 'Build/ninja-$(combination)'\n      installCommand: |\n        wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -\n        sudo add-apt-repository \"deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main\"\n        sudo add-apt-repository ppa:ubuntu-toolchain-r/test\n        sudo apt-get update\n        sudo apt-get install clang-7 libc++-7-dev libc++abi-7-dev lld-7 ninja-build python3\n      testCommand: './$(buildFolder)/Bin/ShaderConductorTest'\n      artifactBinaries: |\n        Bin/ShaderConductorCmd\n        Lib/libdxcompiler.so\n        Lib/libShaderConductor.so\n      CC: clang-7\n      CXX: clang++-7\n\n    steps:\n    - template: CI/AzurePipelines/ContinuousBuild.yml\n\n  - job: Linux_clang8\n    pool:\n      vmImage: Ubuntu-18.04\n\n    variables:\n      compiler: clang8\n      combination: 'linux-$(compiler)-$(platform)-$(configuration)'\n      buildFolder: 'Build/ninja-$(combination)'\n      installCommand: |\n        wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -\n        sudo add-apt-repository \"deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main\"\n        sudo add-apt-repository ppa:ubuntu-toolchain-r/test\n        sudo apt-get update\n        sudo apt-get install clang-8 libc++-8-dev libc++abi-8-dev lld-8 ninja-build python3\n      testCommand: './$(buildFolder)/Bin/ShaderConductorTest'\n      artifactBinaries: |\n        Bin/ShaderConductorCmd\n        Lib/libdxcompiler.so\n        Lib/libShaderConductor.so\n      CC: clang-8\n      CXX: clang++-8\n\n    steps:\n    - template: CI/AzurePipelines/ContinuousBuild.yml\n\n  - job: macOS_10_clang\n    pool:\n      vmImage: macOS 10.14\n\n    variables:\n      compiler: clang9\n      combination: 'osx-$(compiler)-$(platform)-$(configuration)'\n      buildFolder: 'Build/ninja-$(combination)'\n      installCommand: |\n        brew update\n        brew install ninja\n      testCommand: './$(buildFolder)/Bin/ShaderConductorTest'\n      artifactBinaries: |\n        Bin/ShaderConductorCmd\n        Lib/libdxcompiler.dylib\n        Lib/libShaderConductor.dylib\n      CC: clang\n      CXX: clang++\n\n    steps:\n    - template: CI/AzurePipelines/ContinuousBuild.yml\n"
  }
]