Full Code of Microsoft/ShaderConductor for AI

master f18f7b5c370b cached
124 files
249.8 KB
75.8k tokens
136 symbols
1 requests
Download .txt
Showing preview only (281K chars total). Download the full file or copy to clipboard to get everything.
Repository: Microsoft/ShaderConductor
Branch: master
Commit: f18f7b5c370b
Files: 124
Total size: 249.8 KB

Directory structure:
gitextract_2m09pj0m/

├── .clang-format
├── .gitattributes
├── .github/
│   └── ISSUE_TEMPLATE/
│       ├── bug_report.md
│       └── feature_request.md
├── .gitignore
├── BuildAll.py
├── CI/
│   └── AzurePipelines/
│       └── ContinuousBuild.yml
├── CMakeLists.txt
├── CONTRIBUTING.md
├── Include/
│   └── ShaderConductor/
│       └── ShaderConductor.hpp
├── LICENSE
├── README.md
├── SECURITY.md
├── Source/
│   ├── CMakeLists.txt
│   ├── Core/
│   │   ├── CMakeLists.txt
│   │   └── ShaderConductor.cpp
│   ├── Tests/
│   │   ├── CMakeLists.txt
│   │   ├── Data/
│   │   │   ├── Expected/
│   │   │   │   ├── CalcLight+Diffuse.Debug.dxilasm
│   │   │   │   ├── CalcLight+Diffuse.Release.dxilasm
│   │   │   │   ├── CalcLight+DiffuseSpecular.Debug.dxilasm
│   │   │   │   ├── CalcLight+DiffuseSpecular.Release.dxilasm
│   │   │   │   ├── Constant_PS.30.hlsl
│   │   │   │   ├── Constant_PS.300.essl
│   │   │   │   ├── Constant_PS.300.glsl
│   │   │   │   ├── Constant_PS.310.essl
│   │   │   │   ├── Constant_PS.40.hlsl
│   │   │   │   ├── Constant_PS.410.glsl
│   │   │   │   ├── Constant_PS.50.hlsl
│   │   │   │   ├── Constant_PS.msl
│   │   │   │   ├── Constant_VS.30.hlsl
│   │   │   │   ├── Constant_VS.300.essl
│   │   │   │   ├── Constant_VS.300.glsl
│   │   │   │   ├── Constant_VS.310.essl
│   │   │   │   ├── Constant_VS.40.hlsl
│   │   │   │   ├── Constant_VS.410.glsl
│   │   │   │   ├── Constant_VS.50.hlsl
│   │   │   │   ├── Constant_VS.msl
│   │   │   │   ├── DetailTessellation_HS.300.essl
│   │   │   │   ├── DetailTessellation_HS.300.glsl
│   │   │   │   ├── DetailTessellation_HS.310.essl
│   │   │   │   ├── DetailTessellation_HS.410.glsl
│   │   │   │   ├── DetailTessellation_HS.msl
│   │   │   │   ├── DotHalfPS.glsl
│   │   │   │   ├── Fluid_CS.300.glsl
│   │   │   │   ├── Fluid_CS.310.essl
│   │   │   │   ├── Fluid_CS.410.glsl
│   │   │   │   ├── Fluid_CS.50.hlsl
│   │   │   │   ├── Fluid_CS.msl
│   │   │   │   ├── HalfOutParamPS.glsl
│   │   │   │   ├── IncludeEmptyHeader.glsl
│   │   │   │   ├── IncludeExist.glsl
│   │   │   │   ├── PNTriangles_DS.300.essl
│   │   │   │   ├── PNTriangles_DS.300.glsl
│   │   │   │   ├── PNTriangles_DS.310.essl
│   │   │   │   ├── PNTriangles_DS.410.glsl
│   │   │   │   ├── PNTriangles_DS.msl
│   │   │   │   ├── Particle_GS.300.essl
│   │   │   │   ├── Particle_GS.300.glsl
│   │   │   │   ├── Particle_GS.310.essl
│   │   │   │   ├── Particle_GS.410.glsl
│   │   │   │   ├── PassThrough_PS.30.hlsl
│   │   │   │   ├── PassThrough_PS.300.essl
│   │   │   │   ├── PassThrough_PS.300.glsl
│   │   │   │   ├── PassThrough_PS.310.essl
│   │   │   │   ├── PassThrough_PS.40.hlsl
│   │   │   │   ├── PassThrough_PS.410.glsl
│   │   │   │   ├── PassThrough_PS.50.hlsl
│   │   │   │   ├── PassThrough_PS.msl
│   │   │   │   ├── PassThrough_VS.30.hlsl
│   │   │   │   ├── PassThrough_VS.300.essl
│   │   │   │   ├── PassThrough_VS.300.glsl
│   │   │   │   ├── PassThrough_VS.310.essl
│   │   │   │   ├── PassThrough_VS.40.hlsl
│   │   │   │   ├── PassThrough_VS.410.glsl
│   │   │   │   ├── PassThrough_VS.50.hlsl
│   │   │   │   ├── PassThrough_VS.msl
│   │   │   │   ├── ToneMapping_PS.30.hlsl
│   │   │   │   ├── ToneMapping_PS.300.essl
│   │   │   │   ├── ToneMapping_PS.300.glsl
│   │   │   │   ├── ToneMapping_PS.310.essl
│   │   │   │   ├── ToneMapping_PS.40.hlsl
│   │   │   │   ├── ToneMapping_PS.410.glsl
│   │   │   │   ├── ToneMapping_PS.50.hlsl
│   │   │   │   ├── ToneMapping_PS.msl
│   │   │   │   ├── Transform_VS.30.hlsl
│   │   │   │   ├── Transform_VS.300.essl
│   │   │   │   ├── Transform_VS.300.glsl
│   │   │   │   ├── Transform_VS.310.essl
│   │   │   │   ├── Transform_VS.40.hlsl
│   │   │   │   ├── Transform_VS.410.glsl
│   │   │   │   ├── Transform_VS.50.hlsl
│   │   │   │   ├── Transform_VS.msl
│   │   │   │   └── Transform_VS_ColumnMajor.300.glsl
│   │   │   └── Input/
│   │   │       ├── CalcLight.hlsl
│   │   │       ├── CalcLightDiffuse.hlsl
│   │   │       ├── CalcLightDiffuseSpecular.hlsl
│   │   │       ├── Common.hlsli
│   │   │       ├── Constant_PS.hlsl
│   │   │       ├── Constant_VS.hlsl
│   │   │       ├── DetailTessellation_HS.hlsl
│   │   │       ├── Fluid_CS.hlsl
│   │   │       ├── HalfDataType.hlsl
│   │   │       ├── Inc/
│   │   │       │   ├── HeaderA.hlsli
│   │   │       │   ├── HeaderB.hlsli
│   │   │       │   └── HeaderEmpty.hlsli
│   │   │       ├── IncludeEmptyHeader.hlsl
│   │   │       ├── IncludeExist.hlsl
│   │   │       ├── IncludeNotExist.hlsl
│   │   │       ├── PNTriangles_DS.hlsl
│   │   │       ├── Particle_GS.hlsl
│   │   │       ├── PassThrough_PS.hlsl
│   │   │       ├── PassThrough_VS.hlsl
│   │   │       ├── ToneMapping_PS.hlsl
│   │   │       └── Transform_VS.hlsl
│   │   └── ShaderConductorTest.cpp
│   ├── Tools/
│   │   ├── CMakeLists.txt
│   │   └── ShaderConductorCmd.cpp
│   └── Wrapper/
│       ├── CMakeLists.txt
│       ├── Native.cpp
│       ├── Native.h
│       ├── Program.cs
│       ├── Wrapper.cs
│       └── shader.hlsl
└── azure-pipelines.yml

================================================
FILE CONTENTS
================================================

================================================
FILE: .clang-format
================================================
AccessModifierOffset: -4
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakTemplateDeclarations: true
BreakBeforeBraces: Allman
ColumnLimit: 140
Cpp11BracedListStyle: true
IndentWidth: 4
Language: Cpp
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
PointerAlignment: Left
SpaceBeforeParens: ControlStatements
Standard: Cpp11
TabWidth: 4
UseTab: Never


================================================
FILE: .gitattributes
================================================
* text=auto
*.hpp text
*.cpp text
*.hlsl text
*.glsl text
*.msl text
*.dxil binary
*.spv binary


================================================
FILE: .github/ISSUE_TEMPLATE/bug_report.md
================================================
---
name: Bug report
about: Create a report to help us improve

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Your input shader
2. Full parameters

**Expected behavior**
A clear and concise description of what you expected to happen.

**Additional context**
Add any other context about the problem here.


================================================
FILE: .github/ISSUE_TEMPLATE/feature_request.md
================================================
---
name: Feature request
about: Suggest an idea for this project

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.


================================================
FILE: .gitignore
================================================
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/

# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/

# Visual Studio 2017 auto generated files
Generated\ Files/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

# NUNIT
*.VisualState.xml
TestResult.xml

# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c

# Benchmark Results
BenchmarkDotNet.Artifacts/

# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
**/Properties/launchSettings.json

# StyleCop
StyleCopReport.xml

# Files built by Visual Studio
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc

# Chutzpah Test files
_Chutzpah*

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb

# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap

# Visual Studio Trace Files
*.e2e

# TFS 2012 Local Workspace
$tf/

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# JustCode is a .NET coding add-in
.JustCode

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json

# Visual Studio code coverage results
*.coverage
*.coveragexml

# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*

# MightyMoose
*.mm.*
AutoTest.Net/

# Web workbench (sass)
.sass-cache/

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj

# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/

# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets

# Microsoft Azure Build Output
csx/
*.build.csdef

# Microsoft Azure Emulator
ecf/
rcf/

# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx

# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/

# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs

# Including strong name files can present a security risk 
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk

# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak

# SQL Server files
*.mdf
*.ldf
*.ndf

# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser

# Microsoft Fakes
FakesAssemblies/

# GhostDoc plugin setting file
*.GhostDoc.xml

# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/

# Visual Studio 6 build log
*.plg

# Visual Studio 6 workspace options file
*.opt

# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw

# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions

# Paket dependency manager
.paket/paket.exe
paket-files/

# FAKE - F# Make
.fake/

# JetBrains Rider
.idea/
*.sln.iml

# CodeRush
.cr/

# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc

# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config

# Tabs Studio
*.tss

# Telerik's JustMock configuration file
*.jmconfig

# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs

# OpenCover UI analysis results
OpenCover/

# Azure Stream Analytics local run output 
ASALocalRun/

# MSBuild Binary and Structured Log
*.binlog

# NVidia Nsight GPU debugger configuration file
*.nvuser

# MFractors (Xamarin productivity tool) working folder 
.mfractor/

#
/External/
/Build/


================================================
FILE: BuildAll.py
================================================
#!/usr/bin/env python
#-*- coding: ascii -*-

# ShaderConductor
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

import multiprocessing, os, platform, subprocess, sys

def LogError(message):
	print("[E] %s" % message)
	sys.stdout.flush()
	if 0 == sys.platform.find("win"):
		pauseCmd = "pause"
	else:
		pauseCmd = "read"
	subprocess.call(pauseCmd, shell = True)
	sys.exit(1)

def LogInfo(message):
	print("[I] %s" % message)
	sys.stdout.flush()

def LogWarning(message):
	print("[W] %s" % message)
	sys.stdout.flush()

def FindProgramFilesFolder():
	env = os.environ
	if "64bit" == platform.architecture()[0]:
		if "ProgramFiles(x86)" in env:
			programFilesFolder = env["ProgramFiles(x86)"]
		else:
			programFilesFolder = "C:\Program Files (x86)"
	else:
		if "ProgramFiles" in env:
			programFilesFolder = env["ProgramFiles"]
		else:
			programFilesFolder = "C:\Program Files"
	return programFilesFolder

def FindVS2017OrUpFolder(programFilesFolder, vsVersion, vsName):
	tryVswhereLocation = programFilesFolder + "\\Microsoft Visual Studio\\Installer\\vswhere.exe"
	if os.path.exists(tryVswhereLocation):
		vsLocation = subprocess.check_output([tryVswhereLocation,
			"-latest",
			"-requires", "Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
			"-property", "installationPath",
			"-version", "[%d.0,%d.0)" % (vsVersion, vsVersion + 1),
			"-prerelease"]).decode().split("\r\n")[0]
		tryFolder = vsLocation + "\\VC\\Auxiliary\\Build\\"
		tryVcvarsall = "VCVARSALL.BAT"
		if os.path.exists(tryFolder + tryVcvarsall):
			return tryFolder
	else:
		names = ("Preview", vsName)
		skus = ("Community", "Professional", "Enterprise")
		for name in names:
			for sku in skus:
				tryFolder = programFilesFolder + "\\Microsoft Visual Studio\\%s\\%s\\VC\\Auxiliary\\Build\\" % (name, sku)
				tryVcvarsall = "VCVARSALL.BAT"
				if os.path.exists(tryFolder + tryVcvarsall):
					return tryFolder
	LogError("Could NOT find VS%s.\n" % vsName)
	return ""

def FindVS2019Folder(programFilesFolder):
	return FindVS2017OrUpFolder(programFilesFolder, 16, "2019")

def FindVS2017Folder(programFilesFolder):
	return FindVS2017OrUpFolder(programFilesFolder, 15, "2017")

def FindVS2015Folder(programFilesFolder):
	env = os.environ
	if "VS140COMNTOOLS" in env:
		return env["VS140COMNTOOLS"] + "..\\..\\VC\\"
	else:
		tryFolder = programFilesFolder + "\\Microsoft Visual Studio 14.0\\VC\\"
		tryVcvarsall = "VCVARSALL.BAT"
		if os.path.exists(tryFolder + tryVcvarsall):
			return tryFolder
		else:
			LogError("Could NOT find VS2015.\n")

class BatchCommand:
	def __init__(self, hostPlatform):
		self.commands = []
		self.hostPlatform = hostPlatform

	def AddCommand(self, cmd):
		self.commands += [cmd]

	def Execute(self):
		batchFileName = "scBuild."
		if "win" == self.hostPlatform:
			batchFileName += "bat"
		else:
			batchFileName += "sh"
		batchFile = open(batchFileName, "w")
		batchFile.writelines([cmd_line + "\n" for cmd_line in self.commands])
		batchFile.close()
		if "win" == self.hostPlatform:
			retCode = subprocess.call(batchFileName, shell = True)
		else:
			subprocess.call("chmod 777 " + batchFileName, shell = True)
			retCode = subprocess.call("./" + batchFileName, shell = True)
		os.remove(batchFileName)
		return retCode

def Build(hostPlatform, hostArch, buildSys, compiler, arch, configuration, tblgenMode, tblgenPath):
	originalDir = os.path.abspath(os.curdir)

	if not os.path.exists("Build"):
		os.mkdir("Build")

	multiConfig = (buildSys.find("vs") == 0)

	buildDir = "Build/%s-%s-%s-%s" % (buildSys, hostPlatform, compiler, arch)
	if (not multiConfig) or (configuration == "clangformat"):
		buildDir += "-%s" % configuration;
	if not os.path.exists(buildDir):
		os.mkdir(buildDir)
	os.chdir(buildDir)
	buildDir = os.path.abspath(os.curdir)

	tblgenOptions = ""
	if (tblgenPath != None):
		tblgenOptions = " -DCLANG_TABLEGEN=\"%s\" -DLLVM_TABLEGEN=\"%s\"" % tblgenPath

	parallel = multiprocessing.cpu_count()

	batCmd = BatchCommand(hostPlatform)
	if hostPlatform == "win":
		programFilesFolder = FindProgramFilesFolder()
		if (buildSys == "vs2019") or ((buildSys == "ninja") and (compiler == "vc142")):
			vsFolder = FindVS2019Folder(programFilesFolder)
		elif (buildSys == "vs2017") or ((buildSys == "ninja") and (compiler == "vc141")):
			vsFolder = FindVS2017Folder(programFilesFolder)
		elif (buildSys == "vs2015") or ((buildSys == "ninja") and (compiler == "vc140")):
			vsFolder = FindVS2015Folder(programFilesFolder)
		if "x64" == arch:
			vcOption = "amd64"
			vcArch = "x64"
		elif "x86" == arch:
			vcOption = "x86"
			vcArch = "Win32"
		elif "arm64" == arch:
			vcOption = "amd64_arm64"
			vcArch = "ARM64"
		elif "arm" == arch:
			vcOption = "amd64_arm"
			vcArch = "ARM"
		else:
			LogError("Unsupported architecture.\n")
		vcToolset = ""
		if (buildSys == "vs2019") and (compiler == "vc141"):
			vcOption += " -vcvars_ver=14.1"
			vcToolset = "v141,"
		elif ((buildSys == "vs2019") or (buildSys == "vs2017")) and (compiler == "vc140"):
			vcOption += " -vcvars_ver=14.0"
			vcToolset = "v140,"
		batCmd.AddCommand("@call \"%sVCVARSALL.BAT\" %s" % (vsFolder, vcOption))
		batCmd.AddCommand("@cd /d \"%s\"" % buildDir)
	if (buildSys == "ninja"):
		if hostPlatform == "win":
			batCmd.AddCommand("set CC=cl.exe")
			batCmd.AddCommand("set CXX=cl.exe")
		if (configuration == "clangformat"):
			options = "-DSC_CLANGFORMAT=\"ON\""
		else:
			options = "-DCMAKE_BUILD_TYPE=\"%s\" -DSC_ARCH_NAME=\"%s\" %s" % (configuration, arch, tblgenOptions)
		batCmd.AddCommand("cmake -G Ninja %s ../../" % options)
		if tblgenMode:
			batCmd.AddCommand("ninja clang-tblgen -j%d" % parallel)
			batCmd.AddCommand("ninja llvm-tblgen -j%d" % parallel)
		else:
			batCmd.AddCommand("ninja -j%d" % parallel)
	else:
		if buildSys == "vs2019":
			generator = "\"Visual Studio 16\""
		elif buildSys == "vs2017":
			generator = "\"Visual Studio 15\""
		elif buildSys == "vs2015":
			generator = "\"Visual Studio 14\""
		if (configuration == "clangformat"):
			cmake_options = "-DSC_CLANGFORMAT=\"ON\""
			msbuild_options = ""
		else:
			cmake_options = "-T %shost=x64 -A %s %s" % (vcToolset, vcArch, tblgenOptions)
			msbuild_options = "/m:%d /v:m /p:Configuration=%s,Platform=%s" % (parallel, configuration, vcArch)
		batCmd.AddCommand("cmake -G %s %s ../../" % (generator, cmake_options))
		if tblgenMode:
			batCmd.AddCommand("MSBuild External\\DirectXShaderCompiler\\tools\\clang\\utils\\TableGen\\clang-tblgen.vcxproj /nologo %s" % msbuild_options)
			batCmd.AddCommand("MSBuild External\\DirectXShaderCompiler\\utils\\TableGen\\llvm-tblgen.vcxproj /nologo %s" % msbuild_options)
		else:
			batCmd.AddCommand("MSBuild ALL_BUILD.vcxproj /nologo %s" % msbuild_options)
	if batCmd.Execute() != 0:
		LogError("Build failed.\n")

	os.chdir(originalDir)

	tblGenPath = buildDir + "/External/DirectXShaderCompiler"
	if multiConfig:
		tblGenPath += "/" + configuration
	tblGenPath += "/bin/"
	clangTblgenPath = tblGenPath + "clang-tblgen"
	llvmTblGenPath = tblGenPath + "llvm-tblgen"
	if (hostPlatform == "win"):
		clangTblgenPath += ".exe"
		llvmTblGenPath += ".exe"
	return (clangTblgenPath, llvmTblGenPath)

if __name__ == "__main__":
	hostPlatform = sys.platform
	if 0 == hostPlatform.find("win"):
		hostPlatform = "win"
	elif 0 == hostPlatform.find("linux"):
		hostPlatform = "linux"
	elif 0 == hostPlatform.find("darwin"):
		hostPlatform = "osx"

	hostArch = platform.machine()
	if (hostArch == "AMD64") or (hostArch == "x86_64"):
		hostArch = "x64"
	elif (hostArch == "i386"):
		hostArch = "x86"
	elif (hostArch == "ARM64"):
		hostArch = "arm64"
	else:
		LogError("Unknown host architecture %s.\n" % hostArch)

	argc = len(sys.argv);
	if (argc > 1):
		buildSys = sys.argv[1]
	else:
		if hostPlatform == "win":
			buildSys = "vs2019"
		else:
			buildSys = "ninja"
	if (argc > 2):
		compiler = sys.argv[2]
	else:
		if buildSys == "vs2019":
			compiler = "vc142"
		elif buildSys == "vs2017":
			compiler = "vc141"
		elif buildSys == "vs2015":
			compiler = "vc140"
		else:
			compiler = "gcc"
	if (argc > 3):
		arch = sys.argv[3]
	else:
		arch = "x64"
	if (argc > 4):
		configuration = sys.argv[4]
	else:
		configuration = "Release"

	tblgenPath = None
	if (configuration != "clangformat") and (hostArch != arch) and (not ((hostArch == "x64") and (arch == "x86"))):
		# Cross compiling:
		# Generate a project with host architecture, build clang-tblgen and llvm-tblgen, and keep the path of clang-tblgen and llvm-tblgen
		tblgenPath = Build(hostPlatform, hostArch, buildSys, compiler, hostArch, configuration, True, None)

	Build(hostPlatform, hostArch, buildSys, compiler, arch, configuration, False, tblgenPath)


================================================
FILE: CI/AzurePipelines/ContinuousBuild.yml
================================================
steps:
- bash: eval '$(installCommand)'
  displayName: 'Install'

- script: |
    git config --global user.email "dummy@example.com"
    git config --global user.name "Dummy Name"
  displayName: 'Config git'

- task: PythonScript@0
  displayName: 'Build'
  inputs:
    scriptPath: BuildAll.py
    arguments: 'ninja $(compiler) $(platform) $(configuration)'

- bash: eval '$(testCommand)'
  displayName: 'Test'
  condition: not(eq('$(testCommand)', ''))

- bash: 'echo $BUILD_SOURCEVERSION > $BUILD_ARTIFACTSTAGINGDIRECTORY/GIT-COMMIT.txt'
  displayName: 'Add commit info'

- task: CopyFiles@2
  displayName: 'Copy Headers'
  inputs:
    SourceFolder: '$(Build.SourcesDirectory)'
    Contents: Include/ShaderConductor/ShaderConductor.hpp
    TargetFolder: '$(Build.ArtifactStagingDirectory)'

- task: CopyFiles@2
  displayName: 'Copy Binaries'
  inputs:
    SourceFolder: '$(Build.SourcesDirectory)/$(buildFolder)'
    Contents: $(artifactBinaries)
    TargetFolder: '$(Build.ArtifactStagingDirectory)'

- task: PublishBuildArtifacts@1
  inputs:
    pathtoPublish: '$(Build.ArtifactStagingDirectory)'
    artifactName: ShaderConductor-$(combination)


================================================
FILE: CMakeLists.txt
================================================
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

cmake_minimum_required(VERSION 3.9)

if(WIN32 AND (${CMAKE_GENERATOR} MATCHES "Visual Studio ([^9]|[9][0-9])") AND (NOT SC_CLANGFORMAT))
    set(SC_WITH_CSHARP ON)
else()
    set(SC_WITH_CSHARP OFF)
endif()

set(PROJECT_NAME ShaderConductor)
project(${PROJECT_NAME})
if(SC_WITH_CSHARP)
    project(${PROJECT_NAME} LANGUAGES CSharp)
    set(CMAKE_CSharp_FLAGS "/langversion:7")
endif()

set(SC_MAJOR_VERSION 0)
set(SC_MINOR_VERSION 3)
set(SC_PATCH_VERSION 0)
set(SC_VERSION ${SC_MAJOR_VERSION}.${SC_MINOR_VERSION}.${SC_PATCH_VERSION})

set(SC_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(SC_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
mark_as_advanced(SC_ROOT_DIR)

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${SC_BUILD_DIR}/Bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${SC_BUILD_DIR}/Lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${SC_BUILD_DIR}/Lib)

if((CMAKE_C_COMPILER_ID MATCHES GNU) OR (CMAKE_C_COMPILER_ID MATCHES Clang))
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z")
endif()
if (CMAKE_C_COMPILER_ID MATCHES Clang)
    foreach(flagVar
        CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
        set(${flagVar} "${${flagVar}} -fms-extensions -Wno-language-extension-token")
    endforeach()
endif()

set(Python_ADDITIONAL_VERSIONS 3.5 3.6 3.7 3.8)

if(SC_CLANGFORMAT)
    find_program(CLANG_FORMAT
        NAMES
            clang-format-9
            clang-format
    )

    if(${CLANG_FORMAT} STREQUAL "CLANG_FORMAT-NOTFOUND")
        message(FATAL_ERROR "No clang-format tool found")
    endif()

    message(STATUS "Generating clangformat target using ${CLANG_FORMAT}")
    file(GLOB_RECURSE ALL_SOURCE_FILES *.cpp *.h *.hpp)
    add_custom_target(clangformat
        COMMAND ${CLANG_FORMAT} -i ${ALL_SOURCE_FILES})

    return()
endif()

# Handle a compiling issue of SPIR-V
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
    if(CMAKE_C_COMPILER_ID MATCHES Clang)
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
    endif()

    foreach(flagVar
        CMAKE_SHARED_LINKER_FLAGS_RELEASE CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL
        CMAKE_MODULE_LINKER_FLAGS_RELEASE CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL
        CMAKE_EXE_LINKER_FLAGS_RELEASE CMAKE_EXE_LINKER_FLAGS_MINSIZEREL)
        set(${flagVar} "${${flagVar}} -s")
    endforeach()
endif()

if(WIN32)
    if(MSVC AND (CMAKE_GENERATOR MATCHES "^Visual Studio"))
        if((CMAKE_GENERATOR_PLATFORM STREQUAL "x64") OR (CMAKE_GENERATOR MATCHES "Win64"))
            set(SC_ARCH_NAME "x64")
        elseif((CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64") OR (CMAKE_GENERATOR MATCHES "ARM64"))
            set(SC_ARCH_NAME "arm64")
        elseif((CMAKE_GENERATOR_PLATFORM STREQUAL "ARM") OR (CMAKE_GENERATOR MATCHES "ARM"))
            set(SC_ARCH_NAME "arm")
        else()
            set(SC_ARCH_NAME "x86")
        endif()
    endif()
else()
    if(NOT SC_ARCH_NAME)
        if((CMAKE_SYSTEM_PROCESSOR MATCHES "AMD64") OR (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64"))
            set(SC_ARCH_NAME "x64")
        else()
            set(SC_ARCH_NAME "x86")
        endif()
    endif()
endif()

add_subdirectory(Source)
add_subdirectory(External)

set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT "ShaderConductorCmd")


================================================
FILE: CONTRIBUTING.md
================================================
# How to contribute

One of the easiest ways to contribute is to participate in discussions and discuss issues. You can also contribute by submitting pull requests with code changes.

## General feedback and discussions?
Please start a discussion on the repo issue tracker.

## Bugs and feature requests?
For non-security related bugs please log a new issue in the GitHub repo.

## Reporting Security Issues

Security issues and bugs should be reported privately, via email, to the Microsoft Security
Response Center (MSRC) at [secure@microsoft.com](mailto:secure@microsoft.com). You should
receive a response within 24 hours. If for some reason you do not, please follow up via
email to ensure we received your original message. Further information, including the
[MSRC PGP](https://technet.microsoft.com/en-us/security/dn606155) key, can be found in
the [Security TechCenter](https://technet.microsoft.com/en-us/security/default).

## Filing issues
When filing issues, please use our [bug filing templates](https://github.com/aspnet/Home/wiki/Functional-bug-template).
The best way to get your bug fixed is to be as detailed as you can be about the problem.
Providing a minimal project with steps to reproduce the problem is ideal.
Here are questions you can answer before you file a bug to make sure you're not missing any important information.

1. Did you read the documentation?
2. Did you include the snippet of broken code in the issue?
3. What are the *EXACT* steps to reproduce this problem?
4. What version are you using?

GitHub supports [markdown](https://help.github.com/articles/github-flavored-markdown/), so when filing bugs make sure you check the formatting before clicking submit.

## Contributing

This project welcomes contributions and suggestions.  Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.


================================================
FILE: Include/ShaderConductor/ShaderConductor.hpp
================================================
/*
 * ShaderConductor
 *
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License.
 *
 * MIT License
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this
 * software and associated documentation files (the "Software"), to deal in the Software
 * without restriction, including without limitation the rights to use, copy, modify, merge,
 * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
 * to whom the Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or
 * substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
 * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

#ifndef SHADER_CONDUCTOR_HPP
#define SHADER_CONDUCTOR_HPP

#pragma once

#include <functional>

#if defined(__clang__)
#define SC_SYMBOL_EXPORT __attribute__((__visibility__("default")))
#define SC_SYMBOL_IMPORT
#elif defined(__GNUC__)
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
#define SC_SYMBOL_EXPORT __attribute__((__dllexport__))
#define SC_SYMBOL_IMPORT __attribute__((__dllimport__))
#else
#define SC_SYMBOL_EXPORT __attribute__((__visibility__("default")))
#define SC_SYMBOL_IMPORT
#endif
#elif defined(_MSC_VER)
#define SC_SYMBOL_EXPORT __declspec(dllexport)
#define SC_SYMBOL_IMPORT __declspec(dllimport)
#endif

#ifdef SHADER_CONDUCTOR_SOURCE
#define SC_API SC_SYMBOL_EXPORT
#else
#define SC_API SC_SYMBOL_IMPORT
#endif

namespace ShaderConductor
{
    enum class ShaderStage : uint32_t
    {
        VertexShader,
        PixelShader,
        GeometryShader,
        HullShader,
        DomainShader,
        ComputeShader,

        NumShaderStages,
    };

    enum class ShadingLanguage : uint32_t
    {
        Dxil = 0,
        SpirV,

        Hlsl,
        Glsl,
        Essl,
        Msl_macOS,
        Msl_iOS,

        NumShadingLanguages,
    };

    enum class ShaderResourceType : uint32_t
    {
        ConstantBuffer,
        Parameter,
        Texture,
        Sampler,
        ShaderResourceView,
        UnorderedAccessView,

        NumShaderResourceType,
    };

    struct MacroDefine
    {
        const char* name;
        const char* value;
    };

    class SC_API Blob
    {
    public:
        Blob() noexcept;
        Blob(const void* data, uint32_t size);
        Blob(const Blob& other);
        Blob(Blob&& other) noexcept;
        ~Blob() noexcept;

        Blob& operator=(const Blob& other);
        Blob& operator=(Blob&& other) noexcept;

        void Reset();
        void Reset(const void* data, uint32_t size);

        const void* Data() const noexcept;
        uint32_t Size() const noexcept;

    private:
        class BlobImpl;
        BlobImpl* m_impl = nullptr;
    };

    class SC_API Compiler
    {
    public:
        struct ShaderModel
        {
            uint8_t major_ver : 6;
            uint8_t minor_ver : 2;

            uint32_t FullVersion() const noexcept
            {
                return (major_ver << 2) | minor_ver;
            }

            bool operator<(const ShaderModel& other) const noexcept
            {
                return this->FullVersion() < other.FullVersion();
            }
            bool operator==(const ShaderModel& other) const noexcept
            {
                return this->FullVersion() == other.FullVersion();
            }
            bool operator>(const ShaderModel& other) const noexcept
            {
                return other < *this;
            }
            bool operator<=(const ShaderModel& other) const noexcept
            {
                return (*this < other) || (*this == other);
            }
            bool operator>=(const ShaderModel& other) const noexcept
            {
                return (*this > other) || (*this == other);
            }
        };

        struct SourceDesc
        {
            const char* source;
            const char* fileName;
            const char* entryPoint;
            ShaderStage stage;
            const MacroDefine* defines;
            uint32_t numDefines;
            std::function<Blob(const char* includeName)> loadIncludeCallback;
        };

        struct Options
        {
            bool packMatricesInRowMajor = true;          // Experimental: Decide how a matrix get packed
            bool enable16bitTypes = false;               // Enable 16-bit types, such as half, uint16_t. Requires shader model 6.2+
            bool enableDebugInfo = false;                // Embed debug info into the binary
            bool disableOptimizations = false;           // Force to turn off optimizations. Ignore optimizationLevel below.
            bool inheritCombinedSamplerBindings = false; // If textures and samplers are combined, inherit the binding of the texture

            int optimizationLevel = 3; // 0 to 3, no optimization to most optimization
            ShaderModel shaderModel = {6, 0};

            int shiftAllTexturesBindings = 0;
            int shiftAllSamplersBindings = 0;
            int shiftAllCBuffersBindings = 0;
            int shiftAllUABuffersBindings = 0;
        };

        struct TargetDesc
        {
            ShadingLanguage language;
            const char* version;
            bool asModule;
        };

        struct ReflectionDesc
        {
            char name[256];           // Name of the resource
            ShaderResourceType type;  // Type of resource (e.g. texture, cbuffer, etc.)
            uint32_t bufferBindPoint; // Buffer's starting bind point
            uint32_t bindPoint;       // Starting bind point
            uint32_t bindCount;       // Number of contiguous bind points (for arrays)
        };

        struct ReflectionResultDesc
        {
            Blob descs; // The underneath type is ReflectionDesc
            uint32_t descCount = 0;
            uint32_t instructionCount = 0;
        };

        struct ResultDesc
        {
            Blob target;
            bool isText;

            Blob errorWarningMsg;
            bool hasError;

            ReflectionResultDesc reflection;
        };

        struct DisassembleDesc
        {
            ShadingLanguage language;
            const uint8_t* binary;
            uint32_t binarySize;
        };

        struct ModuleDesc
        {
            const char* name;
            Blob target;
        };

        struct LinkDesc
        {
            const char* entryPoint;
            ShaderStage stage;

            const ModuleDesc** modules;
            uint32_t numModules;
        };

    public:
        static ResultDesc Compile(const SourceDesc& source, const Options& options, const TargetDesc& target);
        static void Compile(const SourceDesc& source, const Options& options, const TargetDesc* targets, uint32_t numTargets,
                            ResultDesc* results);
        static ResultDesc Disassemble(const DisassembleDesc& source);

        // Currently only Dxil on Windows supports linking
        static bool LinkSupport();
        static ResultDesc Link(const LinkDesc& modules, const Options& options, const TargetDesc& target);
    };
} // namespace ShaderConductor

#endif // SHADER_CONDUCTOR_HPP


================================================
FILE: LICENSE
================================================
    MIT License

    Copyright (c) Microsoft Corporation. All rights reserved.

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE


================================================
FILE: README.md
================================================
# ShaderConductor

[![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)
[![License](https://img.shields.io/github/license/mashape/apistatus.svg)](LICENSE)


ShaderConductor is a tool designed for cross-compiling HLSL to other shading languages.

## Features

* Converts HLSL to readable, usable and efficient GLSL
* Converts HLSL to readable, usable and efficient ESSL
* Converts HLSL to readable, usable and efficient Metal Shading Language (MSL)
* Converts HLSL to readable, usable and efficient old shader model HLSL
* Supports all stages of shaders, vertex, pixel, hull, domain, geometry, and compute.

Note that this project is still in an early stage, and it is under active development.

## Architecture

ShaderConductor is not a real compiler. Instead, it glues existing open source components to do the cross-compiling.
1. [DirectX Shader Compiler](https://github.com/Microsoft/DirectXShaderCompiler) to compile HLSL to [DXIL](https://github.com/Microsoft/DirectXShaderCompiler/blob/master/docs/DXIL.rst) or [SPIR-V](https://www.khronos.org/registry/spir-v/),
1. [SPIRV-Cross](https://github.com/KhronosGroup/SPIRV-Cross) to convert SPIR-V to target shading languages.

![Architecture](Doc/Arch.svg)

## Prerequisites

* [Git](http://git-scm.com/downloads). Put git into the PATH is recommended.
* [Visual Studio 2017](https://www.visualstudio.com/downloads). Select the following workloads: Universal Windows Platform Development and Desktop Development with C++.
* [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.
* [Python](https://www.python.org/downloads/). Version 2.7 or up. You need not change your PATH variable during installation.

## Building

ShaderConductor has been tested on Windows, Linux, and macOS.

### The script way:

```
  BuildAll.py <BuildSystem> <Compiler> <Architecture> <Configuration>
```
where,
* \<BuildSystem\> can be ninja or vs2017. Default is vs2017.
* \<Compiler\> can be vc141 on Windows, gcc or clang on Linux, clang on macOS.
* \<Architecture\> must be x64 (for now).
* \<Configuration\> can be Debug, Release, RelWithDebInfo, or MinSizeRel. Default is Release.
 
This script automatically grabs external dependencies to External folder, generates project file in Build/\<BuildSystem\>-\<Compiler\>-\<Platform\>-\<Architecture\>[-\<Configuration\>], and builds it.

### The manual way:

```
  mkdir Build
  cd Build
  cmake -G "Visual Studio 15" -T host=x64 -A x64 ../
  cmake --build .
```

After building, the output file ShaderConductor.dll can be located in \<YourCMakeTargetFolder\>/Bin/\<Configuration\>/. It depends on dxcompiler.dll in the same folder.

### Artifacts

You can download [the prebuilt binaries generated by CI system](https://dev.azure.com/msft-ShaderConductor/public/_build/latest?definitionId=1&view=results). Currently, artifacts for Windows, Linux, macOS are published every commit.

## License

ShaderConductor is distributed under the terms of MIT License. See [LICENSE](LICENSE) for details.

## Code of Conduct

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.


================================================
FILE: SECURITY.md
================================================
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.8 BLOCK -->

## Security

Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).

If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below.

## Reporting Security Issues

**Please do not report security vulnerabilities through public GitHub issues.**

Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report).

If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com).  If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey).

You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc). 

Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:

  * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
  * Full paths of source file(s) related to the manifestation of the issue
  * The location of the affected source code (tag/branch/commit or direct URL)
  * Any special configuration required to reproduce the issue
  * Step-by-step instructions to reproduce the issue
  * Proof-of-concept or exploit code (if possible)
  * Impact of the issue, including how an attacker might exploit the issue

This information will help us triage your report more quickly.

If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs.

## Preferred Languages

We prefer all communications to be in English.

## Policy

Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd).

<!-- END MICROSOFT SECURITY.MD BLOCK -->


================================================
FILE: Source/CMakeLists.txt
================================================
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

if(CMAKE_C_COMPILER_ID MATCHES MSVC)
	set(CMAKE_CXX_FLAGS "/W4 /WX /EHsc /MP /bigobj /Zc:throwingNew /Zc:strictStrings /Zc:rvalueCast /Gw")
	if(MSVC_VERSION GREATER 1910)
		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17")
	else()
		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++14")
	endif()
	if(MSVC_VERSION GREATER 1900)
		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive-")
		if(MSVC_VERSION GREATER 1912)
			set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:externConstexpr")
		endif()
	endif()
	set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS})
	set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /fp:fast /Ob2 /GL /Qpar")
	set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /fp:fast /Ob2 /GL /Qpar")
	set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /fp:fast /Ob1 /GL /Qpar")
	foreach(flagVar
		CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_MINSIZEREL)
		set(${flagVar} "${${flagVar}} /GS-")
	endforeach()

	foreach(flagVar
		CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS)
		set(${flagVar} "/pdbcompress")
	endforeach()
	foreach(flagVar
		CMAKE_EXE_LINKER_FLAGS_DEBUG CMAKE_SHARED_LINKER_FLAGS_DEBUG)
		set(${flagVar} "/DEBUG:FASTLINK")
	endforeach()
	foreach(flagVar
		CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO)
		set(${flagVar} "/DEBUG:FASTLINK /INCREMENTAL:NO /LTCG:incremental /OPT:REF /OPT:ICF")
	endforeach()
	foreach(flagVar
		CMAKE_EXE_LINKER_FLAGS_MINSIZEREL CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL CMAKE_EXE_LINKER_FLAGS_RELEASE CMAKE_SHARED_LINKER_FLAGS_RELEASE)
		set(${flagVar} "/INCREMENTAL:NO /LTCG /OPT:REF /OPT:ICF")
	endforeach()
	foreach(flagVar
		CMAKE_MODULE_LINKER_FLAGS_RELEASE CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL)
		set(${flagVar} "/INCREMENTAL:NO /LTCG")
	endforeach()
	foreach(flagVar
		CMAKE_STATIC_LINKER_FLAGS_RELEASE CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL)
		set(${flagVar} "${${flagVar}} /LTCG")
	endforeach()
	set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /LTCG:incremental")

	add_definitions(-DWIN32 -D_WINDOWS)
else()
	foreach(flagVar
		CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
		set(${flagVar} "${${flagVar}} -W -Wall -Werror")
		if(NOT (ANDROID OR IOS))
			set(${flagVar} "${${flagVar}} -march=core2 -msse2")
		endif()
	endforeach()
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers")
	if(MINGW)
		foreach(flagVar
			CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
			set(${flagVar} "${${flagVar}} -Wa,-mbig-obj")
		endforeach()
	endif()
	set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -g -O0")
	set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O2")
	set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-DNDEBUG -g -O2")
	set(CMAKE_CXX_FLAGS_MINSIZEREL "-DNDEBUG -Os")

	if(NOT SC_ARCH_NAME)
		if((CMAKE_SYSTEM_PROCESSOR MATCHES "AMD64") OR (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64"))
			set(SC_ARCH_NAME "x64")
		else()
			set(SC_ARCH_NAME "x86")
		endif()
	endif()

	if(SC_ARCH_NAME STREQUAL "x64")
		foreach(flagVar
			CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
			set(${flagVar} "${${flagVar}} -m64")
		endforeach()
		if(NOT MSVC)
			foreach(flagVar
				CMAKE_SHARED_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_EXE_LINKER_FLAGS)
				set(${flagVar} "${${flagVar}} -m64")
			endforeach()
			if(WIN32)
				set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} --target=pe-x86-64")
			else()
				set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} --target=elf64-x86-64")
			endif()
		endif()
	else()
		foreach(flagVar
			CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
			set(${flagVar} "${${flagVar}} -m32")
		endforeach()
		if(NOT MSVC)
			foreach(flagVar
				CMAKE_SHARED_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_EXE_LINKER_FLAGS)
				set(${flagVar} "${${flagVar}} -m32")
				if(WIN32)
					set(${flagVar} "${${flagVar}} -Wl,--large-address-aware")
				endif()
			endforeach()
			if(WIN32)
				set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} --target=pe-i386")
			else()
				set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} --target=elf32-i386")
			endif()
		endif()
	endif()
endif()

set(CMAKE_C_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
set(CMAKE_C_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
set(CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
set(CMAKE_C_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_MINSIZEREL})

add_subdirectory(Core)
add_subdirectory(Tests)
add_subdirectory(Tools)
if(SC_WITH_CSHARP)
    add_subdirectory(Wrapper)
endif()


================================================
FILE: Source/Core/CMakeLists.txt
================================================
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

if(WIN32)
    set(dxcompilerName "dxcompiler.dll")
    set(runtimeOutputFolder "bin")
    set(copyTargetFolder ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
else()
    if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
        set(dxcompilerName "libdxcompiler.dylib")
    else()
        set(dxcompilerName "libdxcompiler.so")
    endif()
    set(runtimeOutputFolder "lib")
    set(copyTargetFolder ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
endif()

set(dxcompilerOutput "${copyTargetFolder}/${CMAKE_CFG_INTDIR}/${dxcompilerName}")
add_custom_target(CopyDxcompiler ALL
    COMMAND ${CMAKE_COMMAND} -E copy
        ${SC_BUILD_DIR}/External/DirectXShaderCompiler/${CMAKE_CFG_INTDIR}/${runtimeOutputFolder}/${dxcompilerName}
        ${dxcompilerOutput}
    COMMENT "Copying dxcompiler...")
add_dependencies(CopyDxcompiler dxcompiler)

set_target_properties(CopyDxcompiler PROPERTIES FOLDER "Core")


set(LIB_NAME ShaderConductor)

set(SOURCE_FILES
    ${SC_ROOT_DIR}/Source/Core/ShaderConductor.cpp
)

set(HEADER_FILES
    ${SC_ROOT_DIR}/Include/ShaderConductor/ShaderConductor.hpp
)

source_group("Source Files" FILES ${SOURCE_FILES})
source_group("Header Files" FILES ${HEADER_FILES})

add_library(${LIB_NAME} "SHARED"
    ${SOURCE_FILES} ${HEADER_FILES}
)

target_include_directories(${LIB_NAME}
    PUBLIC
        ${SC_ROOT_DIR}/Include

    PRIVATE
        ${SC_BUILD_DIR}/External/DirectXShaderCompiler/include
        ${SC_ROOT_DIR}/External/DirectXShaderCompiler/include
)
target_compile_definitions(${LIB_NAME}
    PRIVATE
        -DSHADER_CONDUCTOR_SOURCE
)
if(MSVC)
    target_compile_definitions(${LIB_NAME}
        PRIVATE
            -D_CRT_SECURE_NO_DEPRECATE
            -D_CRT_SECURE_NO_WARNINGS
            -D_SCL_SECURE_NO_DEPRECATE
            -D_SCL_SECURE_NO_WARNINGS
            -D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING
    )
endif()
target_link_libraries(${LIB_NAME}
    PRIVATE
        dxcompiler
        LLVMDxcSupport
        LLVMSupport
        spirv-cross-core
        spirv-cross-glsl
        spirv-cross-hlsl
        spirv-cross-msl
        spirv-cross-util
        SPIRV-Tools
)

add_dependencies(${LIB_NAME} spirv-cross-core spirv-cross-glsl spirv-cross-hlsl spirv-cross-msl)
add_dependencies(${LIB_NAME} CopyDxcompiler)
add_dependencies(${LIB_NAME} SPIRV-Tools)

set_target_properties(${LIB_NAME} PROPERTIES FOLDER "Core")


================================================
FILE: Source/Core/ShaderConductor.cpp
================================================
/*
 * ShaderConductor
 *
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License.
 *
 * MIT License
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this
 * software and associated documentation files (the "Software"), to deal in the Software
 * without restriction, including without limitation the rights to use, copy, modify, merge,
 * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
 * to whom the Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or
 * substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
 * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

#include <ShaderConductor/ShaderConductor.hpp>

#include <dxc/Support/Global.h>
#include <dxc/Support/Unicode.h>
#include <dxc/Support/WinAdapter.h>
#include <dxc/Support/WinIncludes.h>

#include <algorithm>
#include <atomic>
#include <cassert>
#include <fstream>
#include <memory>

#include <dxc/DxilContainer/DxilContainer.h>
#include <dxc/dxcapi.h>
#include <llvm/Support/ErrorHandling.h>

#include <spirv-tools/libspirv.h>
#include <spirv.hpp>
#include <spirv_cross.hpp>
#include <spirv_glsl.hpp>
#include <spirv_hlsl.hpp>
#include <spirv_msl.hpp>
#include <spirv_cross_util.hpp>

#ifdef LLVM_ON_WIN32
#include <d3d12shader.h>
#endif

#define SC_UNUSED(x) (void)(x);

using namespace ShaderConductor;

namespace
{
    bool dllDetaching = false;

    class Dxcompiler
    {
    public:
        ~Dxcompiler()
        {
            this->Destroy();
        }

        static Dxcompiler& Instance()
        {
            static Dxcompiler instance;
            return instance;
        }

        IDxcLibrary* Library() const
        {
            return m_library;
        }

        IDxcCompiler* Compiler() const
        {
            return m_compiler;
        }

        IDxcContainerReflection* ContainerReflection() const
        {
            return m_containerReflection;
        }

        CComPtr<IDxcLinker> CreateLinker() const
        {
            CComPtr<IDxcLinker> linker;
            IFT(m_createInstanceFunc(CLSID_DxcLinker, __uuidof(IDxcLinker), reinterpret_cast<void**>(&linker)));
            return linker;
        }

        bool LinkerSupport() const
        {
            return m_linkerSupport;
        }

        void Destroy()
        {
            if (m_dxcompilerDll)
            {
                m_compiler = nullptr;
                m_library = nullptr;
                m_containerReflection = nullptr;

                m_createInstanceFunc = nullptr;

#ifdef _WIN32
                ::FreeLibrary(m_dxcompilerDll);
#else
                ::dlclose(m_dxcompilerDll);
#endif

                m_dxcompilerDll = nullptr;
            }
        }

        void Terminate()
        {
            if (m_dxcompilerDll)
            {
                m_compiler.Detach();
                m_library.Detach();
                m_containerReflection.Detach();

                m_createInstanceFunc = nullptr;

                m_dxcompilerDll = nullptr;
            }
        }

    private:
        Dxcompiler()
        {
            if (dllDetaching)
            {
                return;
            }

#ifdef _WIN32
            const char* dllName = "dxcompiler.dll";
#elif __APPLE__
            const char* dllName = "libdxcompiler.dylib";
#else
            const char* dllName = "libdxcompiler.so";
#endif
            const char* functionName = "DxcCreateInstance";

#ifdef _WIN32
            m_dxcompilerDll = ::LoadLibraryA(dllName);
#else
            m_dxcompilerDll = ::dlopen(dllName, RTLD_LAZY);
#endif

            if (m_dxcompilerDll != nullptr)
            {
#ifdef _WIN32
                m_createInstanceFunc = (DxcCreateInstanceProc)::GetProcAddress(m_dxcompilerDll, functionName);
#else
                m_createInstanceFunc = (DxcCreateInstanceProc)::dlsym(m_dxcompilerDll, functionName);
#endif

                if (m_createInstanceFunc != nullptr)
                {
                    IFT(m_createInstanceFunc(CLSID_DxcLibrary, __uuidof(IDxcLibrary), reinterpret_cast<void**>(&m_library)));
                    IFT(m_createInstanceFunc(CLSID_DxcCompiler, __uuidof(IDxcCompiler), reinterpret_cast<void**>(&m_compiler)));
                    IFT(m_createInstanceFunc(CLSID_DxcContainerReflection, __uuidof(IDxcContainerReflection),
                                             reinterpret_cast<void**>(&m_containerReflection)));
                }
                else
                {
                    this->Destroy();

                    throw std::runtime_error(std::string("COULDN'T get ") + functionName + " from dxcompiler.");
                }
            }
            else
            {
                throw std::runtime_error("COULDN'T load dxcompiler.");
            }

            m_linkerSupport = (CreateLinker() != nullptr);
        }

    private:
        HMODULE m_dxcompilerDll = nullptr;
        DxcCreateInstanceProc m_createInstanceFunc = nullptr;

        CComPtr<IDxcLibrary> m_library;
        CComPtr<IDxcCompiler> m_compiler;
        CComPtr<IDxcContainerReflection> m_containerReflection;

        bool m_linkerSupport;
    };

    class ScIncludeHandler : public IDxcIncludeHandler
    {
    public:
        explicit ScIncludeHandler(std::function<Blob(const char* includeName)> loadCallback) : m_loadCallback(std::move(loadCallback))
        {
        }

        HRESULT STDMETHODCALLTYPE LoadSource(LPCWSTR fileName, IDxcBlob** includeSource) override
        {
            if ((fileName[0] == L'.') && (fileName[1] == L'/'))
            {
                fileName += 2;
            }

            std::string utf8FileName;
            if (!Unicode::UTF16ToUTF8String(fileName, &utf8FileName))
            {
                return E_FAIL;
            }

            Blob source;
            try
            {
                source = m_loadCallback(utf8FileName.c_str());
            }
            catch (...)
            {
                return E_FAIL;
            }

            *includeSource = nullptr;
            return Dxcompiler::Instance().Library()->CreateBlobWithEncodingOnHeapCopy(source.Data(), source.Size(), CP_UTF8,
                                                                                      reinterpret_cast<IDxcBlobEncoding**>(includeSource));
        }

        ULONG STDMETHODCALLTYPE AddRef() override
        {
            ++m_ref;
            return m_ref;
        }

        ULONG STDMETHODCALLTYPE Release() override
        {
            --m_ref;
            ULONG result = m_ref;
            if (result == 0)
            {
                delete this;
            }
            return result;
        }

        HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void** object) override
        {
            if (IsEqualIID(iid, __uuidof(IDxcIncludeHandler)))
            {
                *object = dynamic_cast<IDxcIncludeHandler*>(this);
                this->AddRef();
                return S_OK;
            }
            else if (IsEqualIID(iid, __uuidof(IUnknown)))
            {
                *object = dynamic_cast<IUnknown*>(this);
                this->AddRef();
                return S_OK;
            }
            else
            {
                return E_NOINTERFACE;
            }
        }

    private:
        std::function<Blob(const char* includeName)> m_loadCallback;

        std::atomic<ULONG> m_ref = 0;
    };

    Blob DefaultLoadCallback(const char* includeName)
    {
        std::vector<char> ret;
        std::ifstream includeFile(includeName, std::ios_base::in);
        if (includeFile)
        {
            includeFile.seekg(0, std::ios::end);
            ret.resize(static_cast<size_t>(includeFile.tellg()));
            includeFile.seekg(0, std::ios::beg);
            includeFile.read(ret.data(), ret.size());
            ret.resize(static_cast<size_t>(includeFile.gcount()));
        }
        else
        {
            throw std::runtime_error(std::string("COULDN'T load included file ") + includeName + ".");
        }
        return Blob(ret.data(), static_cast<uint32_t>(ret.size()));
    }

    void AppendError(Compiler::ResultDesc& result, const std::string& msg)
    {
        std::string errorMSg;
        if (result.errorWarningMsg.Size() != 0)
        {
            errorMSg.assign(reinterpret_cast<const char*>(result.errorWarningMsg.Data()), result.errorWarningMsg.Size());
        }
        if (!errorMSg.empty())
        {
            errorMSg += "\n";
        }
        errorMSg += msg;
        result.errorWarningMsg.Reset(errorMSg.data(), static_cast<uint32_t>(errorMSg.size()));
        result.hasError = true;
    }

#ifdef LLVM_ON_WIN32
    template <typename T>
    HRESULT CreateDxcReflectionFromBlob(IDxcBlob* dxilBlob, CComPtr<T>& outReflection)
    {
        IDxcContainerReflection* containReflection = Dxcompiler::Instance().ContainerReflection();
        IFT(containReflection->Load(dxilBlob));

        uint32_t dxilPartIndex = ~0u;
        IFT(containReflection->FindFirstPartKind(hlsl::DFCC_DXIL, &dxilPartIndex));
        HRESULT result = containReflection->GetPartReflection(dxilPartIndex, __uuidof(T), reinterpret_cast<void**>(&outReflection));

        return result;
    }

    void ShaderReflection(Compiler::ReflectionResultDesc& result, IDxcBlob* dxilBlob)
    {
        CComPtr<ID3D12ShaderReflection> shaderReflection;
        IFT(CreateDxcReflectionFromBlob(dxilBlob, shaderReflection));

        D3D12_SHADER_DESC shaderDesc;
        shaderReflection->GetDesc(&shaderDesc);

        std::vector<Compiler::ReflectionDesc> vecReflectionDescs;
        for (uint32_t resourceIndex = 0; resourceIndex < shaderDesc.BoundResources; ++resourceIndex)
        {
            D3D12_SHADER_INPUT_BIND_DESC bindDesc;
            shaderReflection->GetResourceBindingDesc(resourceIndex, &bindDesc);

            Compiler::ReflectionDesc reflectionDesc{};

            if (bindDesc.Type == D3D_SIT_CBUFFER || bindDesc.Type == D3D_SIT_TBUFFER)
            {
                ID3D12ShaderReflectionConstantBuffer* constantBuffer = shaderReflection->GetConstantBufferByName(bindDesc.Name);

                D3D12_SHADER_BUFFER_DESC bufferDesc;
                constantBuffer->GetDesc(&bufferDesc);

                if (strcmp(bufferDesc.Name, "$Globals") == 0)
                {
                    for (uint32_t variableIndex = 0; variableIndex < bufferDesc.Variables; ++variableIndex)
                    {
                        ID3D12ShaderReflectionVariable* variable = constantBuffer->GetVariableByIndex(variableIndex);
                        D3D12_SHADER_VARIABLE_DESC variableDesc;
                        variable->GetDesc(&variableDesc);

                        std::strncpy(reflectionDesc.name, variableDesc.Name,
                                     std::min(std::strlen(variableDesc.Name) + 1, sizeof(reflectionDesc.name)));

                        reflectionDesc.type = ShaderResourceType::Parameter;
                        reflectionDesc.bufferBindPoint = bindDesc.BindPoint;
                        reflectionDesc.bindPoint = variableDesc.StartOffset;
                        reflectionDesc.bindCount = variableDesc.Size;
                    }
                }
                else
                {
                    std::strncpy(reflectionDesc.name, bufferDesc.Name,
                                 std::min(std::strlen(bufferDesc.Name) + 1, sizeof(reflectionDesc.name)));

                    reflectionDesc.type = ShaderResourceType::ConstantBuffer;
                    reflectionDesc.bufferBindPoint = bindDesc.BindPoint;
                    reflectionDesc.bindPoint = 0;
                    reflectionDesc.bindCount = 0;
                }
            }
            else
            {
                switch (bindDesc.Type)
                {
                case D3D_SIT_TEXTURE:
                    reflectionDesc.type = ShaderResourceType::Texture;
                    break;

                case D3D_SIT_SAMPLER:
                    reflectionDesc.type = ShaderResourceType::Sampler;
                    break;

                case D3D_SIT_STRUCTURED:
                case D3D_SIT_BYTEADDRESS:
                    reflectionDesc.type = ShaderResourceType::ShaderResourceView;
                    break;

                case D3D_SIT_UAV_RWTYPED:
                case D3D_SIT_UAV_RWSTRUCTURED:
                case D3D_SIT_UAV_RWBYTEADDRESS:
                case D3D_SIT_UAV_APPEND_STRUCTURED:
                case D3D_SIT_UAV_CONSUME_STRUCTURED:
                case D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER:
                    reflectionDesc.type = ShaderResourceType::UnorderedAccessView;
                    break;

                default:
                    llvm_unreachable("Unknown bind type.");
                    break;
                }

                std::strncpy(reflectionDesc.name, bindDesc.Name, std::min(std::strlen(bindDesc.Name) + 1, sizeof(reflectionDesc.name)));

                reflectionDesc.bufferBindPoint = 0;
                reflectionDesc.bindPoint = bindDesc.BindPoint;
                reflectionDesc.bindCount = bindDesc.BindCount;
            }

            vecReflectionDescs.push_back(reflectionDesc);
        }

        result.descCount = static_cast<uint32_t>(vecReflectionDescs.size());
        result.descs.Reset(vecReflectionDescs.data(), sizeof(Compiler::ReflectionDesc) * result.descCount);
        result.instructionCount = shaderDesc.InstructionCount;
    }
#endif

    std::wstring ShaderProfileName(ShaderStage stage, Compiler::ShaderModel shaderModel)
    {
        std::wstring shaderProfile;
        switch (stage)
        {
        case ShaderStage::VertexShader:
            shaderProfile = L"vs";
            break;

        case ShaderStage::PixelShader:
            shaderProfile = L"ps";
            break;

        case ShaderStage::GeometryShader:
            shaderProfile = L"gs";
            break;

        case ShaderStage::HullShader:
            shaderProfile = L"hs";
            break;

        case ShaderStage::DomainShader:
            shaderProfile = L"ds";
            break;

        case ShaderStage::ComputeShader:
            shaderProfile = L"cs";
            break;

        default:
            llvm_unreachable("Invalid shader stage.");
        }

        shaderProfile.push_back(L'_');
        shaderProfile.push_back(L'0' + shaderModel.major_ver);
        shaderProfile.push_back(L'_');
        shaderProfile.push_back(L'0' + shaderModel.minor_ver);

        return shaderProfile;
    }

    void ConvertDxcResult(Compiler::ResultDesc& result, IDxcOperationResult* dxcResult, ShadingLanguage targetLanguage, bool asModule)
    {
        HRESULT status;
        IFT(dxcResult->GetStatus(&status));

        result.target.Reset();
        result.errorWarningMsg.Reset();

        CComPtr<IDxcBlobEncoding> errors;
        IFT(dxcResult->GetErrorBuffer(&errors));
        if (errors != nullptr)
        {
            result.errorWarningMsg.Reset(errors->GetBufferPointer(), static_cast<uint32_t>(errors->GetBufferSize()));
            errors = nullptr;
        }

        result.hasError = true;
        if (SUCCEEDED(status))
        {
            CComPtr<IDxcBlob> program;
            IFT(dxcResult->GetResult(&program));
            dxcResult = nullptr;
            if (program != nullptr)
            {
                result.target.Reset(program->GetBufferPointer(), static_cast<uint32_t>(program->GetBufferSize()));
                result.hasError = false;
            }

#ifdef LLVM_ON_WIN32
            if ((targetLanguage == ShadingLanguage::Dxil) && !asModule)
            {
                // Gather reflection information only for ShadingLanguage::Dxil
                ShaderReflection(result.reflection, program);
            }
#else
            SC_UNUSED(targetLanguage);
            SC_UNUSED(asModule);
#endif
        }
    }

    Compiler::ResultDesc CompileToBinary(const Compiler::SourceDesc& source, const Compiler::Options& options,
                                         ShadingLanguage targetLanguage, bool asModule)
    {
        assert((targetLanguage == ShadingLanguage::Dxil) || (targetLanguage == ShadingLanguage::SpirV));

        std::wstring shaderProfile;
        if (asModule)
        {
            if (targetLanguage == ShadingLanguage::Dxil)
            {
                shaderProfile = L"lib_6_x";
            }
            else
            {
                llvm_unreachable("Spir-V module is not supported.");
            }
        }
        else
        {
            shaderProfile = ShaderProfileName(source.stage, options.shaderModel);
        }

        std::vector<DxcDefine> dxcDefines;
        std::vector<std::wstring> dxcDefineStrings;
        // Need to reserve capacity so that small-string optimization does not
        // invalidate the pointers to internal string data while resizing.
        dxcDefineStrings.reserve(source.numDefines * 2);
        for (size_t i = 0; i < source.numDefines; ++i)
        {
            const auto& define = source.defines[i];

            std::wstring nameUtf16Str;
            Unicode::UTF8ToUTF16String(define.name, &nameUtf16Str);
            dxcDefineStrings.emplace_back(std::move(nameUtf16Str));
            const wchar_t* nameUtf16 = dxcDefineStrings.back().c_str();

            const wchar_t* valueUtf16;
            if (define.value != nullptr)
            {
                std::wstring valueUtf16Str;
                Unicode::UTF8ToUTF16String(define.value, &valueUtf16Str);
                dxcDefineStrings.emplace_back(std::move(valueUtf16Str));
                valueUtf16 = dxcDefineStrings.back().c_str();
            }
            else
            {
                valueUtf16 = nullptr;
            }

            dxcDefines.push_back({nameUtf16, valueUtf16});
        }

        CComPtr<IDxcBlobEncoding> sourceBlob;
        IFT(Dxcompiler::Instance().Library()->CreateBlobWithEncodingOnHeapCopy(
            source.source, static_cast<UINT32>(std::strlen(source.source)), CP_UTF8, &sourceBlob));
        IFTARG(sourceBlob->GetBufferSize() >= 4);

        std::wstring shaderNameUtf16;
        Unicode::UTF8ToUTF16String(source.fileName, &shaderNameUtf16);

        std::wstring entryPointUtf16;
        Unicode::UTF8ToUTF16String(source.entryPoint, &entryPointUtf16);

        std::vector<std::wstring> dxcArgStrings;

        // HLSL matrices are translated into SPIR-V OpTypeMatrixs in a transposed manner,
        // See also https://antiagainst.github.io/post/hlsl-for-vulkan-matrices/
        if (options.packMatricesInRowMajor)
        {
            dxcArgStrings.push_back(L"-Zpr");
        }
        else
        {
            dxcArgStrings.push_back(L"-Zpc");
        }

        if (options.enable16bitTypes)
        {
            if (options.shaderModel >= Compiler::ShaderModel{6, 2})
            {
                dxcArgStrings.push_back(L"-enable-16bit-types");
            }
            else
            {
                throw std::runtime_error("16-bit types requires shader model 6.2 or up.");
            }
        }

        if (options.enableDebugInfo)
        {
            dxcArgStrings.push_back(L"-Zi");
        }

        if (options.disableOptimizations)
        {
            dxcArgStrings.push_back(L"-Od");
        }
        else
        {
            if (options.optimizationLevel < 4)
            {
                dxcArgStrings.push_back(std::wstring(L"-O") + static_cast<wchar_t>(L'0' + options.optimizationLevel));
            }
            else
            {
                llvm_unreachable("Invalid optimization level.");
            }
        }

        if (options.shiftAllCBuffersBindings > 0)
        {
            dxcArgStrings.push_back(L"-fvk-b-shift");
            dxcArgStrings.push_back(std::to_wstring(options.shiftAllCBuffersBindings));
            dxcArgStrings.push_back(L"all");
        }

        if (options.shiftAllUABuffersBindings > 0)
        {
            dxcArgStrings.push_back(L"-fvk-u-shift");
            dxcArgStrings.push_back(std::to_wstring(options.shiftAllUABuffersBindings));
            dxcArgStrings.push_back(L"all");
        }

        if (options.shiftAllSamplersBindings > 0)
        {
            dxcArgStrings.push_back(L"-fvk-s-shift");
            dxcArgStrings.push_back(std::to_wstring(options.shiftAllSamplersBindings));
            dxcArgStrings.push_back(L"all");
        }

        if (options.shiftAllTexturesBindings > 0)
        {
            dxcArgStrings.push_back(L"-fvk-t-shift");
            dxcArgStrings.push_back(std::to_wstring(options.shiftAllTexturesBindings));
            dxcArgStrings.push_back(L"all");
        }

        switch (targetLanguage)
        {
        case ShadingLanguage::Dxil:
            break;

        case ShadingLanguage::SpirV:
        case ShadingLanguage::Hlsl:
        case ShadingLanguage::Glsl:
        case ShadingLanguage::Essl:
        case ShadingLanguage::Msl_macOS:
        case ShadingLanguage::Msl_iOS:
            dxcArgStrings.push_back(L"-spirv");
            break;

        default:
            llvm_unreachable("Invalid shading language.");
        }

        std::vector<const wchar_t*> dxcArgs;
        dxcArgs.reserve(dxcArgStrings.size());
        for (const auto& arg : dxcArgStrings)
        {
            dxcArgs.push_back(arg.c_str());
        }

        CComPtr<IDxcIncludeHandler> includeHandler = new ScIncludeHandler(std::move(source.loadIncludeCallback));
        CComPtr<IDxcOperationResult> compileResult;
        IFT(Dxcompiler::Instance().Compiler()->Compile(sourceBlob, shaderNameUtf16.c_str(), entryPointUtf16.c_str(), shaderProfile.c_str(),
                                                       dxcArgs.data(), static_cast<UINT32>(dxcArgs.size()), dxcDefines.data(),
                                                       static_cast<UINT32>(dxcDefines.size()), includeHandler, &compileResult));

        Compiler::ResultDesc ret{};
        ConvertDxcResult(ret, compileResult, targetLanguage, asModule);

        return ret;
    }

    Compiler::ResultDesc CrossCompile(const Compiler::ResultDesc& binaryResult, const Compiler::SourceDesc& source,
                                      const Compiler::Options& options, const Compiler::TargetDesc& target)
    {
        assert((target.language != ShadingLanguage::Dxil) && (target.language != ShadingLanguage::SpirV));
        assert((binaryResult.target.Size() & (sizeof(uint32_t) - 1)) == 0);

        Compiler::ResultDesc ret;

        ret.errorWarningMsg = binaryResult.errorWarningMsg;
        ret.isText = true;

        uint32_t intVersion = 0;
        if (target.version != nullptr)
        {
            intVersion = std::stoi(target.version);
        }

        const uint32_t* spirvIr = reinterpret_cast<const uint32_t*>(binaryResult.target.Data());
        const size_t spirvSize = binaryResult.target.Size() / sizeof(uint32_t);

        std::unique_ptr<spirv_cross::CompilerGLSL> compiler;
        bool combinedImageSamplers = false;
        bool buildDummySampler = false;

        switch (target.language)
        {
        case ShadingLanguage::Hlsl:
            if ((source.stage == ShaderStage::GeometryShader) || (source.stage == ShaderStage::HullShader) ||
                (source.stage == ShaderStage::DomainShader))
            {
                // Check https://github.com/KhronosGroup/SPIRV-Cross/issues/121 for details
                AppendError(ret, "GS, HS, and DS has not been supported yet.");
                return ret;
            }
            if ((source.stage == ShaderStage::GeometryShader) && (intVersion < 40))
            {
                AppendError(ret, "HLSL shader model earlier than 4.0 doesn't have GS or CS.");
                return ret;
            }
            if ((source.stage == ShaderStage::ComputeShader) && (intVersion < 50))
            {
                AppendError(ret, "CS in HLSL shader model earlier than 5.0 is not supported.");
                return ret;
            }
            if (((source.stage == ShaderStage::HullShader) || (source.stage == ShaderStage::DomainShader)) && (intVersion < 50))
            {
                AppendError(ret, "HLSL shader model earlier than 5.0 doesn't have HS or DS.");
                return ret;
            }
            compiler = std::make_unique<spirv_cross::CompilerHLSL>(spirvIr, spirvSize);
            break;

        case ShadingLanguage::Glsl:
        case ShadingLanguage::Essl:
            compiler = std::make_unique<spirv_cross::CompilerGLSL>(spirvIr, spirvSize);
            combinedImageSamplers = true;
            buildDummySampler = true;

            // Legacy GLSL fixups
            if (intVersion <= 300)
            {
                auto vars = compiler->get_active_interface_variables();
                for (auto& var : vars)
                {
                    auto varClass = compiler->get_storage_class(var);

                    // Make VS out and PS in variable names match
                    if ((source.stage == ShaderStage::VertexShader) && (varClass == spv::StorageClass::StorageClassOutput))
                    {
                        auto name = compiler->get_name(var);
                        if ((name.find("out_var_") == 0) || (name.find("out.var.") == 0))
                        {
                            name.replace(0, 8, "varying_");
                            compiler->set_name(var, name);
                        }
                    }
                    else if ((source.stage == ShaderStage::PixelShader) && (varClass == spv::StorageClass::StorageClassInput))
                    {
                        auto name = compiler->get_name(var);
                        if ((name.find("in_var_") == 0) || (name.find("in.var.") == 0))
                        {
                            name.replace(0, 7, "varying_");
                            compiler->set_name(var, name);
                        }
                    }
                }
            }
            break;

        case ShadingLanguage::Msl_macOS:
        case ShadingLanguage::Msl_iOS:
            if (source.stage == ShaderStage::GeometryShader)
            {
                AppendError(ret, "MSL doesn't have GS.");
                return ret;
            }
            compiler = std::make_unique<spirv_cross::CompilerMSL>(spirvIr, spirvSize);
            break;

        default:
            llvm_unreachable("Invalid target language.");
        }

        spv::ExecutionModel model;
        switch (source.stage)
        {
        case ShaderStage::VertexShader:
            model = spv::ExecutionModelVertex;
            break;

        case ShaderStage::HullShader:
            model = spv::ExecutionModelTessellationControl;
            break;

        case ShaderStage::DomainShader:
            model = spv::ExecutionModelTessellationEvaluation;
            break;

        case ShaderStage::GeometryShader:
            model = spv::ExecutionModelGeometry;
            break;

        case ShaderStage::PixelShader:
            model = spv::ExecutionModelFragment;
            break;

        case ShaderStage::ComputeShader:
            model = spv::ExecutionModelGLCompute;
            break;

        default:
            llvm_unreachable("Invalid shader stage.");
        }
        compiler->set_entry_point(source.entryPoint, model);

        spirv_cross::CompilerGLSL::Options opts = compiler->get_common_options();
        if (target.version != nullptr)
        {
            opts.version = intVersion;
        }
        opts.es = (target.language == ShadingLanguage::Essl);
        opts.force_temporary = false;
        opts.separate_shader_objects = true;
        opts.flatten_multidimensional_arrays = false;
        opts.enable_420pack_extension =
            (target.language == ShadingLanguage::Glsl) && ((target.version == nullptr) || (opts.version >= 420));
        opts.vulkan_semantics = false;
        opts.vertex.fixup_clipspace = false;
        opts.vertex.flip_vert_y = false;
        opts.vertex.support_nonzero_base_instance = true;
        compiler->set_common_options(opts);

        if (target.language == ShadingLanguage::Hlsl)
        {
            auto* hlslCompiler = static_cast<spirv_cross::CompilerHLSL*>(compiler.get());
            auto hlslOpts = hlslCompiler->get_hlsl_options();
            if (target.version != nullptr)
            {
                if (opts.version < 30)
                {
                    AppendError(ret, "HLSL shader model earlier than 3.0 is not supported.");
                    return ret;
                }
                hlslOpts.shader_model = opts.version;
            }

            if (hlslOpts.shader_model <= 30)
            {
                combinedImageSamplers = true;
                buildDummySampler = true;
            }

            hlslCompiler->set_hlsl_options(hlslOpts);
        }
        else if ((target.language == ShadingLanguage::Msl_macOS) || (target.language == ShadingLanguage::Msl_iOS))
        {
            auto* mslCompiler = static_cast<spirv_cross::CompilerMSL*>(compiler.get());
            auto mslOpts = mslCompiler->get_msl_options();
            if (target.version != nullptr)
            {
                mslOpts.msl_version = opts.version;
            }
            mslOpts.swizzle_texture_samples = false;
            mslOpts.platform = (target.language == ShadingLanguage::Msl_iOS) ? spirv_cross::CompilerMSL::Options::iOS
                                                                             : spirv_cross::CompilerMSL::Options::macOS;

            mslCompiler->set_msl_options(mslOpts);

            const auto& resources = mslCompiler->get_shader_resources();

            uint32_t textureBinding = 0;
            for (const auto& image : resources.separate_images)
            {
                mslCompiler->set_decoration(image.id, spv::DecorationBinding, textureBinding);
                ++textureBinding;
            }

            uint32_t samplerBinding = 0;
            for (const auto& sampler : resources.separate_samplers)
            {
                mslCompiler->set_decoration(sampler.id, spv::DecorationBinding, samplerBinding);
                ++samplerBinding;
            }
        }

        if (buildDummySampler)
        {
            const uint32_t sampler = compiler->build_dummy_sampler_for_combined_images();
            if (sampler != 0)
            {
                compiler->set_decoration(sampler, spv::DecorationDescriptorSet, 0);
                compiler->set_decoration(sampler, spv::DecorationBinding, 0);
            }
        }

        if (combinedImageSamplers)
        {
            compiler->build_combined_image_samplers();

            if (options.inheritCombinedSamplerBindings)
            {
                spirv_cross_util::inherit_combined_sampler_bindings(*compiler);
            }

            for (auto& remap : compiler->get_combined_image_samplers())
            {
                compiler->set_name(remap.combined_id,
                                   "SPIRV_Cross_Combined" + compiler->get_name(remap.image_id) + compiler->get_name(remap.sampler_id));
            }
        }

        if (target.language == ShadingLanguage::Hlsl)
        {
            auto* hlslCompiler = static_cast<spirv_cross::CompilerHLSL*>(compiler.get());
            const uint32_t newBuiltin = hlslCompiler->remap_num_workgroups_builtin();
            if (newBuiltin)
            {
                compiler->set_decoration(newBuiltin, spv::DecorationDescriptorSet, 0);
                compiler->set_decoration(newBuiltin, spv::DecorationBinding, 0);
            }
        }

        try
        {
            const std::string targetStr = compiler->compile();
            ret.target.Reset(targetStr.data(), static_cast<uint32_t>(targetStr.size()));
            ret.hasError = false;
            ret.reflection.descs.Reset(binaryResult.reflection.descs.Data(),
                                       sizeof(Compiler::ReflectionDesc) * binaryResult.reflection.descCount);
            ret.reflection.descCount = binaryResult.reflection.descCount;
            ret.reflection.instructionCount = binaryResult.reflection.instructionCount;
        }
        catch (spirv_cross::CompilerError& error)
        {
            const char* errorMsg = error.what();
            ret.errorWarningMsg.Reset(errorMsg, static_cast<uint32_t>(std::strlen(errorMsg)));
            ret.hasError = true;
        }

        return ret;
    }

    Compiler::ResultDesc ConvertBinary(const Compiler::ResultDesc& binaryResult, const Compiler::SourceDesc& source,
                                       const Compiler::Options& options, const Compiler::TargetDesc& target)
    {
        if (!binaryResult.hasError)
        {
            if (target.asModule)
            {
                return binaryResult;
            }
            else
            {
                switch (target.language)
                {
                case ShadingLanguage::Dxil:
                case ShadingLanguage::SpirV:
                    return binaryResult;

                case ShadingLanguage::Hlsl:
                case ShadingLanguage::Glsl:
                case ShadingLanguage::Essl:
                case ShadingLanguage::Msl_macOS:
                case ShadingLanguage::Msl_iOS:
                    return CrossCompile(binaryResult, source, options, target);

                default:
                    llvm_unreachable("Invalid shading language.");
                    break;
                }
            }
        }
        else
        {
            return binaryResult;
        }
    }
} // namespace

namespace ShaderConductor
{
    class Blob::BlobImpl
    {
    public:
        BlobImpl(const void* data, uint32_t size) noexcept
            : m_data(reinterpret_cast<const uint8_t*>(data), reinterpret_cast<const uint8_t*>(data) + size)
        {
        }

        const void* Data() const noexcept
        {
            return m_data.data();
        }

        uint32_t Size() const noexcept
        {
            return static_cast<uint32_t>(m_data.size());
        }

    private:
        std::vector<uint8_t> m_data;
    };

    Blob::Blob() noexcept = default;

    Blob::Blob(const void* data, uint32_t size)
    {
        this->Reset(data, size);
    }

    Blob::Blob(const Blob& other)
    {
        this->Reset(other.Data(), other.Size());
    }

    Blob::Blob(Blob&& other) noexcept : m_impl(std::move(other.m_impl))
    {
        other.m_impl = nullptr;
    }

    Blob::~Blob() noexcept
    {
        delete m_impl;
    }

    Blob& Blob::operator=(const Blob& other)
    {
        if (this != &other)
        {
            this->Reset(other.Data(), other.Size());
        }
        return *this;
    }

    Blob& Blob::operator=(Blob&& other) noexcept
    {
        if (this != &other)
        {
            m_impl = std::move(other.m_impl);
            other.m_impl = nullptr;
        }
        return *this;
    }

    void Blob::Reset()
    {
        delete m_impl;
        m_impl = nullptr;
    }

    void Blob::Reset(const void* data, uint32_t size)
    {
        this->Reset();
        if ((data != nullptr) && (size > 0))
        {
            m_impl = new BlobImpl(data, size);
        }
    }

    const void* Blob::Data() const noexcept
    {
        return m_impl ? m_impl->Data() : nullptr;
    }

    uint32_t Blob::Size() const noexcept
    {
        return m_impl ? m_impl->Size() : 0;
    }


    Compiler::ResultDesc Compiler::Compile(const SourceDesc& source, const Options& options, const TargetDesc& target)
    {
        ResultDesc result;
        Compiler::Compile(source, options, &target, 1, &result);
        return result;
    }

    void Compiler::Compile(const SourceDesc& source, const Options& options, const TargetDesc* targets, uint32_t numTargets,
                           ResultDesc* results)
    {
        SourceDesc sourceOverride = source;
        if (!sourceOverride.entryPoint || (std::strlen(sourceOverride.entryPoint) == 0))
        {
            sourceOverride.entryPoint = "main";
        }
        if (!sourceOverride.loadIncludeCallback)
        {
            sourceOverride.loadIncludeCallback = DefaultLoadCallback;
        }

        bool hasDxil = false;
        bool hasDxilModule = false;
        bool hasSpirV = false;
        for (uint32_t i = 0; i < numTargets; ++i)
        {
            if (targets[i].language == ShadingLanguage::Dxil)
            {
                hasDxil = true;
                if (targets[i].asModule)
                {
                    hasDxilModule = true;
                }
            }
            else
            {
                hasSpirV = true;
            }
        }

        ResultDesc dxilBinaryResult{};
        if (hasDxil)
        {
            dxilBinaryResult = CompileToBinary(sourceOverride, options, ShadingLanguage::Dxil, false);
        }

        ResultDesc dxilModuleBinaryResult{};
        if (hasDxilModule)
        {
            dxilModuleBinaryResult = CompileToBinary(sourceOverride, options, ShadingLanguage::Dxil, true);
        }

        ResultDesc spirvBinaryResult{};
        if (hasSpirV)
        {
            spirvBinaryResult = CompileToBinary(sourceOverride, options, ShadingLanguage::SpirV, false);
        }

        for (uint32_t i = 0; i < numTargets; ++i)
        {
            ResultDesc binaryResult;
            if (targets[i].language == ShadingLanguage::Dxil)
            {
                if (targets[i].asModule)
                {
                    binaryResult = dxilModuleBinaryResult;
                }
                else
                {
                    binaryResult = dxilBinaryResult;
                }
            }
            else
            {
                binaryResult = spirvBinaryResult;
            }

            results[i] = ConvertBinary(binaryResult, sourceOverride, options, targets[i]);
        }
    }

    Compiler::ResultDesc Compiler::Disassemble(const DisassembleDesc& source)
    {
        assert((source.language == ShadingLanguage::SpirV) || (source.language == ShadingLanguage::Dxil));

        Compiler::ResultDesc ret;

        ret.isText = true;

        if (source.language == ShadingLanguage::SpirV)
        {
            const uint32_t* spirvIr = reinterpret_cast<const uint32_t*>(source.binary);
            const size_t spirvSize = source.binarySize / sizeof(uint32_t);

            spv_context context = spvContextCreate(SPV_ENV_UNIVERSAL_1_3);
            uint32_t options = SPV_BINARY_TO_TEXT_OPTION_NONE | SPV_BINARY_TO_TEXT_OPTION_INDENT | SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES;
            spv_text text = nullptr;
            spv_diagnostic diagnostic = nullptr;

            spv_result_t error = spvBinaryToText(context, spirvIr, spirvSize, options, &text, &diagnostic);
            spvContextDestroy(context);

            if (error)
            {
                ret.errorWarningMsg.Reset(diagnostic->error, static_cast<uint32_t>(std::strlen(diagnostic->error)));
                ret.hasError = true;
                spvDiagnosticDestroy(diagnostic);
            }
            else
            {
                const std::string disassemble = text->str;
                ret.target.Reset(disassemble.data(), static_cast<uint32_t>(disassemble.size()));
                ret.hasError = false;
            }

            spvTextDestroy(text);
        }
        else
        {
            CComPtr<IDxcBlobEncoding> blob;
            CComPtr<IDxcBlobEncoding> disassembly;
            IFT(Dxcompiler::Instance().Library()->CreateBlobWithEncodingOnHeapCopy(source.binary, source.binarySize, CP_UTF8, &blob));
            IFT(Dxcompiler::Instance().Compiler()->Disassemble(blob, &disassembly));

            if (disassembly != nullptr)
            {
                // Remove the tailing \0
                ret.target.Reset(disassembly->GetBufferPointer(), static_cast<uint32_t>(disassembly->GetBufferSize() - 1));
                ret.hasError = false;
            }
            else
            {
                ret.hasError = true;
            }
        }

        return ret;
    }

    bool Compiler::LinkSupport()
    {
        return Dxcompiler::Instance().LinkerSupport();
    }

    Compiler::ResultDesc Compiler::Link(const LinkDesc& modules, const Compiler::Options& options, const TargetDesc& target)
    {
        auto linker = Dxcompiler::Instance().CreateLinker();
        IFTPTR(linker);

        auto* library = Dxcompiler::Instance().Library();

        std::vector<std::wstring> moduleNames(modules.numModules);
        std::vector<const wchar_t*> moduleNamesUtf16(modules.numModules);
        std::vector<CComPtr<IDxcBlobEncoding>> moduleBlobs(modules.numModules);
        for (uint32_t i = 0; i < modules.numModules; ++i)
        {
            IFTARG(modules.modules[i] != nullptr);

            IFT(library->CreateBlobWithEncodingOnHeapCopy(modules.modules[i]->target.Data(), modules.modules[i]->target.Size(), CP_UTF8,
                                                          &moduleBlobs[i]));
            IFTARG(moduleBlobs[i]->GetBufferSize() >= 4);

            Unicode::UTF8ToUTF16String(modules.modules[i]->name, &moduleNames[i]);
            moduleNamesUtf16[i] = moduleNames[i].c_str();
            IFT(linker->RegisterLibrary(moduleNamesUtf16[i], moduleBlobs[i]));
        }

        std::wstring entryPointUtf16;
        Unicode::UTF8ToUTF16String(modules.entryPoint, &entryPointUtf16);

        const std::wstring shaderProfile = ShaderProfileName(modules.stage, options.shaderModel);
        CComPtr<IDxcOperationResult> linkResult;
        IFT(linker->Link(entryPointUtf16.c_str(), shaderProfile.c_str(), moduleNamesUtf16.data(),
                         static_cast<UINT32>(moduleNamesUtf16.size()), nullptr, 0, &linkResult));

        Compiler::ResultDesc binaryResult{};
        ConvertDxcResult(binaryResult, linkResult, ShadingLanguage::Dxil, false);

        Compiler::SourceDesc source{};
        source.entryPoint = modules.entryPoint;
        source.stage = modules.stage;
        return ConvertBinary(binaryResult, source, options, target);
    }
} // namespace ShaderConductor

#ifdef _WIN32
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
{
    SC_UNUSED(instance);

    BOOL result = TRUE;
    if (reason == DLL_PROCESS_DETACH)
    {
        dllDetaching = true;

        if (reserved == 0)
        {
            // FreeLibrary has been called or the DLL load failed
            Dxcompiler::Instance().Destroy();
        }
        else
        {
            // Process termination. We should not call FreeLibrary()
            Dxcompiler::Instance().Terminate();
        }
    }

    return result;
}
#endif


================================================
FILE: Source/Tests/CMakeLists.txt
================================================
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

set(EXE_NAME ShaderConductorTest)

set(SOURCE_FILES
    ShaderConductorTest.cpp
)

set(DATA_INC_FILES
    Data/Input/Inc/HeaderA.hlsli
    Data/Input/Inc/HeaderB.hlsli
    Data/Input/Inc/HeaderEmpty.hlsli
)

set(DATA_FILES
    Data/Input/CalcLight.hlsl
    Data/Input/CalcLightDiffuse.hlsl
    Data/Input/CalcLightDiffuseSpecular.hlsl
    Data/Input/Common.hlsli
    Data/Input/Constant_PS.hlsl
    Data/Input/Constant_VS.hlsl
    Data/Input/DetailTessellation_HS.hlsl
    Data/Input/Fluid_CS.hlsl
    Data/Input/IncludeEmptyHeader.hlsl
    Data/Input/IncludeExist.hlsl
    Data/Input/IncludeNotExist.hlsl
    Data/Input/HalfDataType.hlsl
    Data/Input/Particle_GS.hlsl
    Data/Input/PassThrough_PS.hlsl
    Data/Input/PassThrough_VS.hlsl
    Data/Input/PNTriangles_DS.hlsl
    Data/Input/ToneMapping_PS.hlsl
    Data/Input/Transform_VS.hlsl
)

set_source_files_properties(${DATA_FILES}
    PROPERTIES VS_TOOL_OVERRIDE "None"
)

source_group("Source Files" FILES ${SOURCE_FILES})
source_group("Data Files\\Input" FILES ${DATA_FILES})
source_group("Data Files\\Input\\Inc" FILES ${DATA_INC_FILES})

add_executable(${EXE_NAME} ${SOURCE_FILES} ${DATA_FILES} ${DATA_INC_FILES})

target_compile_definitions(${EXE_NAME}
    PRIVATE
        -DTEST_DATA_DIR="${SC_ROOT_DIR}/Source/Tests/Data/"
)
target_link_libraries(${EXE_NAME}
    PRIVATE
        ShaderConductor
        gtest
)

add_dependencies(${EXE_NAME} ShaderConductor gtest)

set_target_properties(${EXE_NAME} PROPERTIES FOLDER "Tests")


================================================
FILE: Source/Tests/Data/Expected/CalcLight+Diffuse.Debug.dxilasm
================================================
;
; Input signature:
;
; Name                 Index   Mask Register SysValue  Format   Used
; -------------------- ----- ------ -------- -------- ------- ------
; SV_Position              0   xyzw        0      POS   float       
; NORMAL                   0   xyz         1     NONE   float   xyz 
; TEXCOORD                 0   xyz         2     NONE   float   xyz 
; TEXCOORD                 1   xyz         3     NONE   float       
;
;
; Output signature:
;
; Name                 Index   Mask Register SysValue  Format   Used
; -------------------- ----- ------ -------- -------- ------- ------
; SV_Target                0   xyzw        0   TARGET   float   xyzw
;
; shader debug name: d81432b398a9151e6a076b6b827882eb.pdb
; shader hash: d81432b398a9151e6a076b6b827882eb
;
; Pipeline Runtime Information: 
;
; Pixel Shader
; DepthOutput=0
; SampleFrequency=0
;
;
; Input signature:
;
; Name                 Index             InterpMode DynIdx
; -------------------- ----- ---------------------- ------
; SV_Position              0          noperspective       
; NORMAL                   0                 linear       
; TEXCOORD                 0                 linear       
; TEXCOORD                 1                 linear       
;
; Output signature:
;
; Name                 Index             InterpMode DynIdx
; -------------------- ----- ---------------------- ------
; SV_Target                0                              
;
; Buffer Definitions:
;
; cbuffer cbPS
; {
;
;   struct cbPS
;   {
;
;       float3 diffColor;                             ; Offset:    0
;       float3 specColor;                             ; Offset:   16
;       float shininess;                              ; Offset:   28
;   
;   } cbPS;                                           ; Offset:    0 Size:    32
;
; }
;
;
; Resource Bindings:
;
; Name                                 Type  Format         Dim      ID      HLSL Bind  Count
; ------------------------------ ---------- ------- ----------- ------- -------------- ------
; cbPS                              cbuffer      NA          NA     CB0            cb0     1
;
;
; ViewId state:
;
; Number of inputs: 15, outputs: 4
; Outputs dependent on ViewId: {  }
; Inputs contributing to computation of Outputs:
;   output 0 depends on inputs: { 4, 5, 6, 8, 9, 10 }
;   output 1 depends on inputs: { 4, 5, 6, 8, 9, 10 }
;   output 2 depends on inputs: { 4, 5, 6, 8, 9, 10 }
;
target triple = "dxil-ms-dx"

%cbPS = type { <3 x float>, <3 x float>, float }
%dx.types.CBufRet.f32 = type { float, float, float, float }
%dx.types.Handle = type { i8* }

@cbPS = external constant %cbPS

; Function Attrs: nounwind readnone
declare float @dx.op.loadInput.f32(i32, i32, i32, i8, i32) #0

; Function Attrs: nounwind readonly
declare %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32, %dx.types.Handle, i32) #1

; Function Attrs: nounwind
declare void @dx.op.storeOutput.f32(i32, i32, i32, i8, float) #2

; Function Attrs: nounwind readnone
declare float @dx.op.dot3.f32(i32, float, float, float, float, float, float) #0

; Function Attrs: nounwind readnone
declare float @dx.op.binary.f32(i32, float, float) #0

define void @main() {
entry:
  %cbPS_cbuffer = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 2, i32 0, i32 0, i1 false)  ; CreateHandle(resourceClass,rangeId,index,nonUniformIndex)
  %0 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 0, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %1 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 1, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %2 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 2, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %3 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 0, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %4 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 1, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %5 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 2, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %6 = call %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %cbPS_cbuffer, i32 0)  ; CBufferLoadLegacy(handle,regIndex)
  %7 = extractvalue %dx.types.CBufRet.f32 %6, 0
  %8 = extractvalue %dx.types.CBufRet.f32 %6, 1
  %9 = extractvalue %dx.types.CBufRet.f32 %6, 2
  %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)
  %mul.i0.i = fmul fast float %10, %7
  %mul.i1.i = fmul fast float %10, %8
  %mul.i2.i = fmul fast float %10, %9
  %FMax.i = call float @dx.op.binary.f32(i32 35, float %mul.i0.i, float 0.000000e+00) #2  ; FMax(a,b)
  %FMax2.i = call float @dx.op.binary.f32(i32 35, float %mul.i1.i, float 0.000000e+00) #2  ; FMax(a,b)
  %FMax3.i = call float @dx.op.binary.f32(i32 35, float %mul.i2.i, float 0.000000e+00) #2  ; FMax(a,b)
  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 0, float %FMax.i)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)
  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 1, float %FMax2.i)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)
  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 2, float %FMax3.i)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)
  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 3, float 1.000000e+00)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)
  ret void
}

; Function Attrs: nounwind readonly
declare %dx.types.Handle @dx.op.createHandle(i32, i8, i32, i32, i1) #1

attributes #0 = { nounwind readnone }
attributes #1 = { nounwind readonly }
attributes #2 = { nounwind }

!llvm.ident = !{!0, !0}
!dx.version = !{!1}
!dx.valver = !{!2}
!dx.shaderModel = !{!3}
!dx.resources = !{!4}
!dx.typeAnnotations = !{!7, !12}
!dx.viewIdState = !{!16}
!dx.entryPoints = !{!17}

!0 = !{!"clang version 3.7 (tags/RELEASE_370/final)"}
!1 = !{i32 1, i32 0}
!2 = !{i32 1, i32 6}
!3 = !{!"ps", i32 6, i32 0}
!4 = !{null, null, !5, null}
!5 = !{!6}
!6 = !{i32 0, %cbPS* undef, !"cbPS", i32 0, i32 0, i32 1, i32 32, null}
!7 = !{i32 0, %cbPS undef, !8}
!8 = !{i32 32, !9, !10, !11}
!9 = !{i32 6, !"diffColor", i32 3, i32 0, i32 7, i32 9}
!10 = !{i32 6, !"specColor", i32 3, i32 16, i32 7, i32 9}
!11 = !{i32 6, !"shininess", i32 3, i32 28, i32 7, i32 9}
!12 = !{i32 1, void ()* @main, !13}
!13 = !{!14}
!14 = !{i32 0, !15, !15}
!15 = !{}
!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]}
!17 = !{void ()* @main, !"main", !18, !4, null}
!18 = !{!19, !27, null}
!19 = !{!20, !22, !24, !25}
!20 = !{i32 0, !"SV_Position", i8 9, i8 3, !21, i8 4, i32 1, i8 4, i32 0, i8 0, null}
!21 = !{i32 0}
!22 = !{i32 1, !"NORMAL", i8 9, i8 0, !21, i8 2, i32 1, i8 3, i32 1, i8 0, !23}
!23 = !{i32 3, i32 7}
!24 = !{i32 2, !"TEXCOORD", i8 9, i8 0, !21, i8 2, i32 1, i8 3, i32 2, i8 0, !23}
!25 = !{i32 3, !"TEXCOORD", i8 9, i8 0, !26, i8 2, i32 1, i8 3, i32 3, i8 0, null}
!26 = !{i32 1}
!27 = !{!28}
!28 = !{i32 0, !"SV_Target", i8 9, i8 16, !21, i8 0, i32 1, i8 4, i32 0, i8 0, !29}
!29 = !{i32 3, i32 15}


================================================
FILE: Source/Tests/Data/Expected/CalcLight+Diffuse.Release.dxilasm
================================================
;
; Input signature:
;
; Name                 Index   Mask Register SysValue  Format   Used
; -------------------- ----- ------ -------- -------- ------- ------
; SV_Position              0   xyzw        0      POS   float       
; NORMAL                   0   xyz         1     NONE   float   xyz 
; TEXCOORD                 0   xyz         2     NONE   float   xyz 
; TEXCOORD                 1   xyz         3     NONE   float       
;
;
; Output signature:
;
; Name                 Index   Mask Register SysValue  Format   Used
; -------------------- ----- ------ -------- -------- ------- ------
; SV_Target                0   xyzw        0   TARGET   float   xyzw
;
; shader debug name: ad90c6ff56d81fd333e64a2bf70453fc.pdb
; shader hash: ad90c6ff56d81fd333e64a2bf70453fc
;
; Pipeline Runtime Information: 
;
; Pixel Shader
; DepthOutput=0
; SampleFrequency=0
;
;
; Input signature:
;
; Name                 Index             InterpMode DynIdx
; -------------------- ----- ---------------------- ------
; SV_Position              0          noperspective       
; NORMAL                   0                 linear       
; TEXCOORD                 0                 linear       
; TEXCOORD                 1                 linear       
;
; Output signature:
;
; Name                 Index             InterpMode DynIdx
; -------------------- ----- ---------------------- ------
; SV_Target                0                              
;
; Buffer Definitions:
;
; cbuffer cbPS
; {
;
;   struct cbPS
;   {
;
;       float3 diffColor;                             ; Offset:    0
;       float3 specColor;                             ; Offset:   16
;       float shininess;                              ; Offset:   28
;   
;   } cbPS;                                           ; Offset:    0 Size:    32
;
; }
;
;
; Resource Bindings:
;
; Name                                 Type  Format         Dim      ID      HLSL Bind  Count
; ------------------------------ ---------- ------- ----------- ------- -------------- ------
; cbPS                              cbuffer      NA          NA     CB0            cb0     1
;
;
; ViewId state:
;
; Number of inputs: 15, outputs: 4
; Outputs dependent on ViewId: {  }
; Inputs contributing to computation of Outputs:
;   output 0 depends on inputs: { 4, 5, 6, 8, 9, 10 }
;   output 1 depends on inputs: { 4, 5, 6, 8, 9, 10 }
;   output 2 depends on inputs: { 4, 5, 6, 8, 9, 10 }
;
target triple = "dxil-ms-dx"

%cbPS = type { <3 x float>, <3 x float>, float }
%dx.types.CBufRet.f32 = type { float, float, float, float }
%dx.types.Handle = type { i8* }

@cbPS = external constant %cbPS

; Function Attrs: nounwind readnone
declare float @dx.op.loadInput.f32(i32, i32, i32, i8, i32) #0

; Function Attrs: nounwind readonly
declare %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32, %dx.types.Handle, i32) #1

; Function Attrs: nounwind
declare void @dx.op.storeOutput.f32(i32, i32, i32, i8, float) #2

; Function Attrs: nounwind readnone
declare float @dx.op.dot3.f32(i32, float, float, float, float, float, float) #0

; Function Attrs: nounwind readnone
declare float @dx.op.binary.f32(i32, float, float) #0

define void @main() {
  %cbPS_cbuffer = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 2, i32 0, i32 0, i1 false)  ; CreateHandle(resourceClass,rangeId,index,nonUniformIndex)
  %1 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 0, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %2 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 1, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %3 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 2, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %4 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 0, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %5 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 1, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %6 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 2, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %7 = call %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %cbPS_cbuffer, i32 0)  ; CBufferLoadLegacy(handle,regIndex)
  %8 = extractvalue %dx.types.CBufRet.f32 %7, 0
  %9 = extractvalue %dx.types.CBufRet.f32 %7, 1
  %10 = extractvalue %dx.types.CBufRet.f32 %7, 2
  %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)
  %.i0.i = fmul fast float %11, %8
  %.i1.i = fmul fast float %11, %9
  %.i2.i = fmul fast float %11, %10
  %FMax.i = call float @dx.op.binary.f32(i32 35, float %.i0.i, float 0.000000e+00) #2  ; FMax(a,b)
  %FMax1.i = call float @dx.op.binary.f32(i32 35, float %.i1.i, float 0.000000e+00) #2  ; FMax(a,b)
  %FMax2.i = call float @dx.op.binary.f32(i32 35, float %.i2.i, float 0.000000e+00) #2  ; FMax(a,b)
  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 0, float %FMax.i)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)
  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 1, float %FMax1.i)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)
  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 2, float %FMax2.i)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)
  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 3, float 1.000000e+00)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)
  ret void
}

; Function Attrs: nounwind readonly
declare %dx.types.Handle @dx.op.createHandle(i32, i8, i32, i32, i1) #1

attributes #0 = { nounwind readnone }
attributes #1 = { nounwind readonly }
attributes #2 = { nounwind }

!llvm.ident = !{!0, !0}
!dx.version = !{!1}
!dx.valver = !{!2}
!dx.shaderModel = !{!3}
!dx.resources = !{!4}
!dx.typeAnnotations = !{!7, !12}
!dx.viewIdState = !{!16}
!dx.entryPoints = !{!17}

!0 = !{!"clang version 3.7 (tags/RELEASE_370/final)"}
!1 = !{i32 1, i32 0}
!2 = !{i32 1, i32 6}
!3 = !{!"ps", i32 6, i32 0}
!4 = !{null, null, !5, null}
!5 = !{!6}
!6 = !{i32 0, %cbPS* undef, !"cbPS", i32 0, i32 0, i32 1, i32 32, null}
!7 = !{i32 0, %cbPS undef, !8}
!8 = !{i32 32, !9, !10, !11}
!9 = !{i32 6, !"diffColor", i32 3, i32 0, i32 7, i32 9}
!10 = !{i32 6, !"specColor", i32 3, i32 16, i32 7, i32 9}
!11 = !{i32 6, !"shininess", i32 3, i32 28, i32 7, i32 9}
!12 = !{i32 1, void ()* @main, !13}
!13 = !{!14}
!14 = !{i32 0, !15, !15}
!15 = !{}
!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]}
!17 = !{void ()* @main, !"main", !18, !4, null}
!18 = !{!19, !27, null}
!19 = !{!20, !22, !24, !25}
!20 = !{i32 0, !"SV_Position", i8 9, i8 3, !21, i8 4, i32 1, i8 4, i32 0, i8 0, null}
!21 = !{i32 0}
!22 = !{i32 1, !"NORMAL", i8 9, i8 0, !21, i8 2, i32 1, i8 3, i32 1, i8 0, !23}
!23 = !{i32 3, i32 7}
!24 = !{i32 2, !"TEXCOORD", i8 9, i8 0, !21, i8 2, i32 1, i8 3, i32 2, i8 0, !23}
!25 = !{i32 3, !"TEXCOORD", i8 9, i8 0, !26, i8 2, i32 1, i8 3, i32 3, i8 0, null}
!26 = !{i32 1}
!27 = !{!28}
!28 = !{i32 0, !"SV_Target", i8 9, i8 16, !21, i8 0, i32 1, i8 4, i32 0, i8 0, !29}
!29 = !{i32 3, i32 15}


================================================
FILE: Source/Tests/Data/Expected/CalcLight+DiffuseSpecular.Debug.dxilasm
================================================
;
; Input signature:
;
; Name                 Index   Mask Register SysValue  Format   Used
; -------------------- ----- ------ -------- -------- ------- ------
; SV_Position              0   xyzw        0      POS   float       
; NORMAL                   0   xyz         1     NONE   float   xyz 
; TEXCOORD                 0   xyz         2     NONE   float   xyz 
; TEXCOORD                 1   xyz         3     NONE   float   xyz 
;
;
; Output signature:
;
; Name                 Index   Mask Register SysValue  Format   Used
; -------------------- ----- ------ -------- -------- ------- ------
; SV_Target                0   xyzw        0   TARGET   float   xyzw
;
; shader debug name: 65620ef187dc1e38cb91d8208665ef7d.pdb
; shader hash: 65620ef187dc1e38cb91d8208665ef7d
;
; Pipeline Runtime Information: 
;
; Pixel Shader
; DepthOutput=0
; SampleFrequency=0
;
;
; Input signature:
;
; Name                 Index             InterpMode DynIdx
; -------------------- ----- ---------------------- ------
; SV_Position              0          noperspective       
; NORMAL                   0                 linear       
; TEXCOORD                 0                 linear       
; TEXCOORD                 1                 linear       
;
; Output signature:
;
; Name                 Index             InterpMode DynIdx
; -------------------- ----- ---------------------- ------
; SV_Target                0                              
;
; Buffer Definitions:
;
; cbuffer cbPS
; {
;
;   struct cbPS
;   {
;
;       float3 diffColor;                             ; Offset:    0
;       float3 specColor;                             ; Offset:   16
;       float shininess;                              ; Offset:   28
;   
;   } cbPS;                                           ; Offset:    0 Size:    32
;
; }
;
;
; Resource Bindings:
;
; Name                                 Type  Format         Dim      ID      HLSL Bind  Count
; ------------------------------ ---------- ------- ----------- ------- -------------- ------
; cbPS                              cbuffer      NA          NA     CB0            cb0     1
;
;
; ViewId state:
;
; Number of inputs: 15, outputs: 4
; Outputs dependent on ViewId: {  }
; Inputs contributing to computation of Outputs:
;   output 0 depends on inputs: { 4, 5, 6, 8, 9, 10, 12, 13, 14 }
;   output 1 depends on inputs: { 4, 5, 6, 8, 9, 10, 12, 13, 14 }
;   output 2 depends on inputs: { 4, 5, 6, 8, 9, 10, 12, 13, 14 }
;
target triple = "dxil-ms-dx"

%cbPS = type { <3 x float>, <3 x float>, float }
%dx.types.CBufRet.f32 = type { float, float, float, float }
%dx.types.Handle = type { i8* }

@cbPS = external constant %cbPS

; Function Attrs: nounwind readnone
declare float @dx.op.loadInput.f32(i32, i32, i32, i8, i32) #0

; Function Attrs: nounwind readonly
declare %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32, %dx.types.Handle, i32) #1

; Function Attrs: nounwind
declare void @dx.op.storeOutput.f32(i32, i32, i32, i8, float) #2

; Function Attrs: nounwind readnone
declare float @dx.op.dot3.f32(i32, float, float, float, float, float, float) #0

; Function Attrs: nounwind readnone
declare float @dx.op.binary.f32(i32, float, float) #0

; Function Attrs: nounwind readnone
declare float @dx.op.unary.f32(i32, float) #0

define void @main() {
entry:
  %cbPS_cbuffer = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 2, i32 0, i32 0, i1 false)  ; CreateHandle(resourceClass,rangeId,index,nonUniformIndex)
  %0 = call float @dx.op.loadInput.f32(i32 4, i32 3, i32 0, i8 0, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %1 = call float @dx.op.loadInput.f32(i32 4, i32 3, i32 0, i8 1, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %2 = call float @dx.op.loadInput.f32(i32 4, i32 3, i32 0, i8 2, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %3 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 0, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %4 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 1, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %5 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 2, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %6 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 0, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %7 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 1, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %8 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 2, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %9 = call %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %cbPS_cbuffer, i32 1)  ; CBufferLoadLegacy(handle,regIndex)
  %10 = extractvalue %dx.types.CBufRet.f32 %9, 3
  %11 = extractvalue %dx.types.CBufRet.f32 %9, 0
  %12 = extractvalue %dx.types.CBufRet.f32 %9, 1
  %13 = extractvalue %dx.types.CBufRet.f32 %9, 2
  %14 = call %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %cbPS_cbuffer, i32 0)  ; CBufferLoadLegacy(handle,regIndex)
  %15 = extractvalue %dx.types.CBufRet.f32 %14, 0
  %16 = extractvalue %dx.types.CBufRet.f32 %14, 1
  %17 = extractvalue %dx.types.CBufRet.f32 %14, 2
  %add.i.i.i = fadd fast float %10, 2.000000e+00
  %div.i.i.i = fmul fast float %add.i.i.i, 1.250000e-01
  %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)
  %FMax.i = call float @dx.op.binary.f32(i32 35, float %18, float 0.000000e+00) #2  ; FMax(a,b)
  %Log3.i = call float @dx.op.unary.f32(i32 23, float %FMax.i) #2  ; Log(value)
  %19 = fmul fast float %Log3.i, %10
  %Exp4.i = call float @dx.op.unary.f32(i32 21, float %19) #2  ; Exp(value)
  %mul.i.i0.i = fmul fast float %Exp4.i, %div.i.i.i
  %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)
  %Saturate.i = call float @dx.op.unary.f32(i32 7, float %20) #2  ; Saturate(value)
  %cmp.i.i.i0.i = fcmp fast ogt float %11, 0.000000e+00
  %cmp.i.i.i1.i = fcmp fast ogt float %12, 0.000000e+00
  %cmp.i.i.i2.i = fcmp fast ogt float %13, 0.000000e+00
  %sub.i.i.i0.i = fsub fast float 1.000000e+00, %11
  %sub.i.i.i1.i = fsub fast float 1.000000e+00, %12
  %sub.i.i.i2.i = fsub fast float 1.000000e+00, %13
  %sub2.i.i.i = fsub fast float 1.000000e+00, %Saturate.i
  %Log.i = call float @dx.op.unary.f32(i32 23, float %sub2.i.i.i) #2  ; Log(value)
  %21 = fmul fast float %Log.i, 5.000000e+00
  %Exp.i = call float @dx.op.unary.f32(i32 21, float %21) #2  ; Exp(value)
  %mul.i.i.i0.i = fmul fast float %Exp.i, %sub.i.i.i0.i
  %mul.i.i.i1.i = fmul fast float %Exp.i, %sub.i.i.i1.i
  %mul.i.i.i2.i = fmul fast float %Exp.i, %sub.i.i.i2.i
  %add.i.4.i.i0.i = fadd fast float %mul.i.i.i0.i, %11
  %add.i.4.i.i1.i = fadd fast float %mul.i.i.i1.i, %12
  %add.i.4.i.i2.i = fadd fast float %mul.i.i.i2.i, %13
  %22 = select i1 %cmp.i.i.i0.i, float %add.i.4.i.i0.i, float 0.000000e+00
  %23 = select i1 %cmp.i.i.i1.i, float %add.i.4.i.i1.i, float 0.000000e+00
  %24 = select i1 %cmp.i.i.i2.i, float %add.i.4.i.i2.i, float 0.000000e+00
  %mul3.i.i0.i = fmul fast float %mul.i.i0.i, %22
  %mul3.i.i1.i = fmul fast float %mul.i.i0.i, %23
  %mul3.i.i2.i = fmul fast float %mul.i.i0.i, %24
  %add.i0.i = fadd fast float %mul3.i.i0.i, %15
  %add.i1.i = fadd fast float %mul3.i.i1.i, %16
  %add.i2.i = fadd fast float %mul3.i.i2.i, %17
  %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)
  %mul.i0.i = fmul fast float %add.i0.i, %25
  %mul.i1.i = fmul fast float %add.i1.i, %25
  %mul.i2.i = fmul fast float %add.i2.i, %25
  %FMax5.i = call float @dx.op.binary.f32(i32 35, float %mul.i0.i, float 0.000000e+00) #2  ; FMax(a,b)
  %FMax6.i = call float @dx.op.binary.f32(i32 35, float %mul.i1.i, float 0.000000e+00) #2  ; FMax(a,b)
  %FMax7.i = call float @dx.op.binary.f32(i32 35, float %mul.i2.i, float 0.000000e+00) #2  ; FMax(a,b)
  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 0, float %FMax5.i)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)
  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 1, float %FMax6.i)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)
  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 2, float %FMax7.i)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)
  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 3, float 1.000000e+00)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)
  ret void
}

; Function Attrs: nounwind readonly
declare %dx.types.Handle @dx.op.createHandle(i32, i8, i32, i32, i1) #1

attributes #0 = { nounwind readnone }
attributes #1 = { nounwind readonly }
attributes #2 = { nounwind }

!llvm.ident = !{!0, !0}
!dx.version = !{!1}
!dx.valver = !{!2}
!dx.shaderModel = !{!3}
!dx.resources = !{!4}
!dx.typeAnnotations = !{!7, !12}
!dx.viewIdState = !{!16}
!dx.entryPoints = !{!17}

!0 = !{!"clang version 3.7 (tags/RELEASE_370/final)"}
!1 = !{i32 1, i32 0}
!2 = !{i32 1, i32 6}
!3 = !{!"ps", i32 6, i32 0}
!4 = !{null, null, !5, null}
!5 = !{!6}
!6 = !{i32 0, %cbPS* undef, !"cbPS", i32 0, i32 0, i32 1, i32 32, null}
!7 = !{i32 0, %cbPS undef, !8}
!8 = !{i32 32, !9, !10, !11}
!9 = !{i32 6, !"diffColor", i32 3, i32 0, i32 7, i32 9}
!10 = !{i32 6, !"specColor", i32 3, i32 16, i32 7, i32 9}
!11 = !{i32 6, !"shininess", i32 3, i32 28, i32 7, i32 9}
!12 = !{i32 1, void ()* @main, !13}
!13 = !{!14}
!14 = !{i32 0, !15, !15}
!15 = !{}
!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]}
!17 = !{void ()* @main, !"main", !18, !4, null}
!18 = !{!19, !27, null}
!19 = !{!20, !22, !24, !25}
!20 = !{i32 0, !"SV_Position", i8 9, i8 3, !21, i8 4, i32 1, i8 4, i32 0, i8 0, null}
!21 = !{i32 0}
!22 = !{i32 1, !"NORMAL", i8 9, i8 0, !21, i8 2, i32 1, i8 3, i32 1, i8 0, !23}
!23 = !{i32 3, i32 7}
!24 = !{i32 2, !"TEXCOORD", i8 9, i8 0, !21, i8 2, i32 1, i8 3, i32 2, i8 0, !23}
!25 = !{i32 3, !"TEXCOORD", i8 9, i8 0, !26, i8 2, i32 1, i8 3, i32 3, i8 0, !23}
!26 = !{i32 1}
!27 = !{!28}
!28 = !{i32 0, !"SV_Target", i8 9, i8 16, !21, i8 0, i32 1, i8 4, i32 0, i8 0, !29}
!29 = !{i32 3, i32 15}


================================================
FILE: Source/Tests/Data/Expected/CalcLight+DiffuseSpecular.Release.dxilasm
================================================
;
; Input signature:
;
; Name                 Index   Mask Register SysValue  Format   Used
; -------------------- ----- ------ -------- -------- ------- ------
; SV_Position              0   xyzw        0      POS   float       
; NORMAL                   0   xyz         1     NONE   float   xyz 
; TEXCOORD                 0   xyz         2     NONE   float   xyz 
; TEXCOORD                 1   xyz         3     NONE   float   xyz 
;
;
; Output signature:
;
; Name                 Index   Mask Register SysValue  Format   Used
; -------------------- ----- ------ -------- -------- ------- ------
; SV_Target                0   xyzw        0   TARGET   float   xyzw
;
; shader debug name: 7f14de892298c5aa041b655c7a09b6e5.pdb
; shader hash: 7f14de892298c5aa041b655c7a09b6e5
;
; Pipeline Runtime Information: 
;
; Pixel Shader
; DepthOutput=0
; SampleFrequency=0
;
;
; Input signature:
;
; Name                 Index             InterpMode DynIdx
; -------------------- ----- ---------------------- ------
; SV_Position              0          noperspective       
; NORMAL                   0                 linear       
; TEXCOORD                 0                 linear       
; TEXCOORD                 1                 linear       
;
; Output signature:
;
; Name                 Index             InterpMode DynIdx
; -------------------- ----- ---------------------- ------
; SV_Target                0                              
;
; Buffer Definitions:
;
; cbuffer cbPS
; {
;
;   struct cbPS
;   {
;
;       float3 diffColor;                             ; Offset:    0
;       float3 specColor;                             ; Offset:   16
;       float shininess;                              ; Offset:   28
;   
;   } cbPS;                                           ; Offset:    0 Size:    32
;
; }
;
;
; Resource Bindings:
;
; Name                                 Type  Format         Dim      ID      HLSL Bind  Count
; ------------------------------ ---------- ------- ----------- ------- -------------- ------
; cbPS                              cbuffer      NA          NA     CB0            cb0     1
;
;
; ViewId state:
;
; Number of inputs: 15, outputs: 4
; Outputs dependent on ViewId: {  }
; Inputs contributing to computation of Outputs:
;   output 0 depends on inputs: { 4, 5, 6, 8, 9, 10, 12, 13, 14 }
;   output 1 depends on inputs: { 4, 5, 6, 8, 9, 10, 12, 13, 14 }
;   output 2 depends on inputs: { 4, 5, 6, 8, 9, 10, 12, 13, 14 }
;
target triple = "dxil-ms-dx"

%cbPS = type { <3 x float>, <3 x float>, float }
%dx.types.CBufRet.f32 = type { float, float, float, float }
%dx.types.Handle = type { i8* }

@cbPS = external constant %cbPS

; Function Attrs: nounwind readnone
declare float @dx.op.loadInput.f32(i32, i32, i32, i8, i32) #0

; Function Attrs: nounwind readonly
declare %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32, %dx.types.Handle, i32) #1

; Function Attrs: nounwind
declare void @dx.op.storeOutput.f32(i32, i32, i32, i8, float) #2

; Function Attrs: nounwind readnone
declare float @dx.op.dot3.f32(i32, float, float, float, float, float, float) #0

; Function Attrs: nounwind readnone
declare float @dx.op.binary.f32(i32, float, float) #0

; Function Attrs: nounwind readnone
declare float @dx.op.unary.f32(i32, float) #0

define void @main() {
  %cbPS_cbuffer = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 2, i32 0, i32 0, i1 false)  ; CreateHandle(resourceClass,rangeId,index,nonUniformIndex)
  %1 = call float @dx.op.loadInput.f32(i32 4, i32 3, i32 0, i8 0, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %2 = call float @dx.op.loadInput.f32(i32 4, i32 3, i32 0, i8 1, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %3 = call float @dx.op.loadInput.f32(i32 4, i32 3, i32 0, i8 2, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %4 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 0, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %5 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 1, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %6 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 2, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %7 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 0, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %8 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 1, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %9 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 2, i32 undef)  ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)
  %10 = call %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %cbPS_cbuffer, i32 1)  ; CBufferLoadLegacy(handle,regIndex)
  %11 = extractvalue %dx.types.CBufRet.f32 %10, 3
  %12 = extractvalue %dx.types.CBufRet.f32 %10, 0
  %13 = extractvalue %dx.types.CBufRet.f32 %10, 1
  %14 = extractvalue %dx.types.CBufRet.f32 %10, 2
  %15 = call %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %cbPS_cbuffer, i32 0)  ; CBufferLoadLegacy(handle,regIndex)
  %16 = extractvalue %dx.types.CBufRet.f32 %15, 0
  %17 = extractvalue %dx.types.CBufRet.f32 %15, 1
  %18 = extractvalue %dx.types.CBufRet.f32 %15, 2
  %19 = fadd fast float %11, 2.000000e+00
  %20 = fmul fast float %19, 1.250000e-01
  %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)
  %FMax.i = call float @dx.op.binary.f32(i32 35, float %21, float 0.000000e+00) #2  ; FMax(a,b)
  %Log1.i = call float @dx.op.unary.f32(i32 23, float %FMax.i) #2  ; Log(value)
  %22 = fmul fast float %Log1.i, %11
  %Exp2.i = call float @dx.op.unary.f32(i32 21, float %22) #2  ; Exp(value)
  %.i0.i = fmul fast float %Exp2.i, %20
  %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)
  %Saturate.i = call float @dx.op.unary.f32(i32 7, float %23) #2  ; Saturate(value)
  %.i06.i = fcmp fast ogt float %12, 0.000000e+00
  %.i17.i = fcmp fast ogt float %13, 0.000000e+00
  %.i28.i = fcmp fast ogt float %14, 0.000000e+00
  %.i010.i = fsub fast float 1.000000e+00, %12
  %.i112.i = fsub fast float 1.000000e+00, %13
  %.i214.i = fsub fast float 1.000000e+00, %14
  %24 = fsub fast float 1.000000e+00, %Saturate.i
  %Log.i = call float @dx.op.unary.f32(i32 23, float %24) #2  ; Log(value)
  %25 = fmul fast float %Log.i, 5.000000e+00
  %Exp.i = call float @dx.op.unary.f32(i32 21, float %25) #2  ; Exp(value)
  %.i015.i = fmul fast float %Exp.i, %.i010.i
  %.i116.i = fmul fast float %Exp.i, %.i112.i
  %.i217.i = fmul fast float %Exp.i, %.i214.i
  %.i019.i = fadd fast float %.i015.i, %12
  %.i121.i = fadd fast float %.i116.i, %13
  %.i223.i = fadd fast float %.i217.i, %14
  %26 = select i1 %.i06.i, float %.i019.i, float 0.000000e+00
  %27 = select i1 %.i17.i, float %.i121.i, float 0.000000e+00
  %28 = select i1 %.i28.i, float %.i223.i, float 0.000000e+00
  %.i024.i = fmul fast float %.i0.i, %26
  %.i125.i = fmul fast float %.i0.i, %27
  %.i226.i = fmul fast float %.i0.i, %28
  %.i027.i = fadd fast float %.i024.i, %16
  %.i128.i = fadd fast float %.i125.i, %17
  %.i229.i = fadd fast float %.i226.i, %18
  %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)
  %.i030.i = fmul fast float %.i027.i, %29
  %.i131.i = fmul fast float %.i128.i, %29
  %.i232.i = fmul fast float %.i229.i, %29
  %FMax3.i = call float @dx.op.binary.f32(i32 35, float %.i030.i, float 0.000000e+00) #2  ; FMax(a,b)
  %FMax4.i = call float @dx.op.binary.f32(i32 35, float %.i131.i, float 0.000000e+00) #2  ; FMax(a,b)
  %FMax5.i = call float @dx.op.binary.f32(i32 35, float %.i232.i, float 0.000000e+00) #2  ; FMax(a,b)
  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 0, float %FMax3.i)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)
  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 1, float %FMax4.i)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)
  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 2, float %FMax5.i)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)
  call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 3, float 1.000000e+00)  ; StoreOutput(outputSigId,rowIndex,colIndex,value)
  ret void
}

; Function Attrs: nounwind readonly
declare %dx.types.Handle @dx.op.createHandle(i32, i8, i32, i32, i1) #1

attributes #0 = { nounwind readnone }
attributes #1 = { nounwind readonly }
attributes #2 = { nounwind }

!llvm.ident = !{!0, !0}
!dx.version = !{!1}
!dx.valver = !{!2}
!dx.shaderModel = !{!3}
!dx.resources = !{!4}
!dx.typeAnnotations = !{!7, !12}
!dx.viewIdState = !{!16}
!dx.entryPoints = !{!17}

!0 = !{!"clang version 3.7 (tags/RELEASE_370/final)"}
!1 = !{i32 1, i32 0}
!2 = !{i32 1, i32 6}
!3 = !{!"ps", i32 6, i32 0}
!4 = !{null, null, !5, null}
!5 = !{!6}
!6 = !{i32 0, %cbPS* undef, !"cbPS", i32 0, i32 0, i32 1, i32 32, null}
!7 = !{i32 0, %cbPS undef, !8}
!8 = !{i32 32, !9, !10, !11}
!9 = !{i32 6, !"diffColor", i32 3, i32 0, i32 7, i32 9}
!10 = !{i32 6, !"specColor", i32 3, i32 16, i32 7, i32 9}
!11 = !{i32 6, !"shininess", i32 3, i32 28, i32 7, i32 9}
!12 = !{i32 1, void ()* @main, !13}
!13 = !{!14}
!14 = !{i32 0, !15, !15}
!15 = !{}
!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]}
!17 = !{void ()* @main, !"main", !18, !4, null}
!18 = !{!19, !27, null}
!19 = !{!20, !22, !24, !25}
!20 = !{i32 0, !"SV_Position", i8 9, i8 3, !21, i8 4, i32 1, i8 4, i32 0, i8 0, null}
!21 = !{i32 0}
!22 = !{i32 1, !"NORMAL", i8 9, i8 0, !21, i8 2, i32 1, i8 3, i32 1, i8 0, !23}
!23 = !{i32 3, i32 7}
!24 = !{i32 2, !"TEXCOORD", i8 9, i8 0, !21, i8 2, i32 1, i8 3, i32 2, i8 0, !23}
!25 = !{i32 3, !"TEXCOORD", i8 9, i8 0, !26, i8 2, i32 1, i8 3, i32 3, i8 0, !23}
!26 = !{i32 1}
!27 = !{!28}
!28 = !{i32 0, !"SV_Target", i8 9, i8 16, !21, i8 0, i32 1, i8 4, i32 0, i8 0, !29}
!29 = !{i32 3, i32 15}


================================================
FILE: Source/Tests/Data/Expected/Constant_PS.30.hlsl
================================================
static float4 out_var_SV_Target;

struct SPIRV_Cross_Output
{
    float4 out_var_SV_Target : COLOR0;
};

void frag_main()
{
    out_var_SV_Target = float4(0.20000000298023223876953125f, 0.4000000059604644775390625f, 0.60000002384185791015625f, 1.0f);
}

SPIRV_Cross_Output main()
{
    frag_main();
    SPIRV_Cross_Output stage_output;
    stage_output.out_var_SV_Target = float4(out_var_SV_Target);
    return stage_output;
}


================================================
FILE: Source/Tests/Data/Expected/Constant_PS.300.essl
================================================
#version 300 es
precision mediump float;
precision highp int;

layout(location = 0) out highp vec4 out_var_SV_Target;

void main()
{
    out_var_SV_Target = vec4(0.20000000298023223876953125, 0.4000000059604644775390625, 0.60000002384185791015625, 1.0);
}



================================================
FILE: Source/Tests/Data/Expected/Constant_PS.300.glsl
================================================
#version 300
#extension GL_ARB_separate_shader_objects : require

out vec4 out_var_SV_Target;

void main()
{
    out_var_SV_Target = vec4(0.20000000298023223876953125, 0.4000000059604644775390625, 0.60000002384185791015625, 1.0);
}



================================================
FILE: Source/Tests/Data/Expected/Constant_PS.310.essl
================================================
#version 310 es
precision mediump float;
precision highp int;

layout(location = 0) out highp vec4 out_var_SV_Target;

void main()
{
    out_var_SV_Target = vec4(0.20000000298023223876953125, 0.4000000059604644775390625, 0.60000002384185791015625, 1.0);
}



================================================
FILE: Source/Tests/Data/Expected/Constant_PS.40.hlsl
================================================
static float4 out_var_SV_Target;

struct SPIRV_Cross_Output
{
    float4 out_var_SV_Target : SV_Target0;
};

void frag_main()
{
    out_var_SV_Target = float4(0.20000000298023223876953125f, 0.4000000059604644775390625f, 0.60000002384185791015625f, 1.0f);
}

SPIRV_Cross_Output main()
{
    frag_main();
    SPIRV_Cross_Output stage_output;
    stage_output.out_var_SV_Target = out_var_SV_Target;
    return stage_output;
}


================================================
FILE: Source/Tests/Data/Expected/Constant_PS.410.glsl
================================================
#version 410

layout(location = 0) out vec4 out_var_SV_Target;

void main()
{
    out_var_SV_Target = vec4(0.20000000298023223876953125, 0.4000000059604644775390625, 0.60000002384185791015625, 1.0);
}



================================================
FILE: Source/Tests/Data/Expected/Constant_PS.50.hlsl
================================================
static float4 out_var_SV_Target;

struct SPIRV_Cross_Output
{
    float4 out_var_SV_Target : SV_Target0;
};

void frag_main()
{
    out_var_SV_Target = float4(0.20000000298023223876953125f, 0.4000000059604644775390625f, 0.60000002384185791015625f, 1.0f);
}

SPIRV_Cross_Output main()
{
    frag_main();
    SPIRV_Cross_Output stage_output;
    stage_output.out_var_SV_Target = out_var_SV_Target;
    return stage_output;
}


================================================
FILE: Source/Tests/Data/Expected/Constant_PS.msl
================================================
#include <metal_stdlib>
#include <simd/simd.h>

using namespace metal;

struct PSMain_out
{
    float4 out_var_SV_Target [[color(0)]];
};

fragment PSMain_out PSMain()
{
    PSMain_out out = {};
    out.out_var_SV_Target = float4(0.20000000298023223876953125, 0.4000000059604644775390625, 0.60000002384185791015625, 1.0);
    return out;
}



================================================
FILE: Source/Tests/Data/Expected/Constant_VS.30.hlsl
================================================
uniform float4 gl_HalfPixel;

static float4 gl_Position;
struct SPIRV_Cross_Output
{
    float4 gl_Position : POSITION;
};

void vert_main()
{
    gl_Position = float4(1.0f, 2.0f, 3.0f, 4.0f);
    gl_Position.x = gl_Position.x - gl_HalfPixel.x * gl_Position.w;
    gl_Position.y = gl_Position.y + gl_HalfPixel.y * gl_Position.w;
}

SPIRV_Cross_Output main()
{
    vert_main();
    SPIRV_Cross_Output stage_output;
    stage_output.gl_Position = gl_Position;
    return stage_output;
}


================================================
FILE: Source/Tests/Data/Expected/Constant_VS.300.essl
================================================
#version 300 es

void main()
{
    gl_Position = vec4(1.0, 2.0, 3.0, 4.0);
}



================================================
FILE: Source/Tests/Data/Expected/Constant_VS.300.glsl
================================================
#version 300
#extension GL_ARB_separate_shader_objects : require

out gl_PerVertex
{
    vec4 gl_Position;
};

void main()
{
    gl_Position = vec4(1.0, 2.0, 3.0, 4.0);
}



================================================
FILE: Source/Tests/Data/Expected/Constant_VS.310.essl
================================================
#version 310 es

void main()
{
    gl_Position = vec4(1.0, 2.0, 3.0, 4.0);
}



================================================
FILE: Source/Tests/Data/Expected/Constant_VS.40.hlsl
================================================
static float4 gl_Position;
struct SPIRV_Cross_Output
{
    float4 gl_Position : SV_Position;
};

void vert_main()
{
    gl_Position = float4(1.0f, 2.0f, 3.0f, 4.0f);
}

SPIRV_Cross_Output main()
{
    vert_main();
    SPIRV_Cross_Output stage_output;
    stage_output.gl_Position = gl_Position;
    return stage_output;
}


================================================
FILE: Source/Tests/Data/Expected/Constant_VS.410.glsl
================================================
#version 410

out gl_PerVertex
{
    vec4 gl_Position;
};

void main()
{
    gl_Position = vec4(1.0, 2.0, 3.0, 4.0);
}



================================================
FILE: Source/Tests/Data/Expected/Constant_VS.50.hlsl
================================================
static float4 gl_Position;
struct SPIRV_Cross_Output
{
    float4 gl_Position : SV_Position;
};

void vert_main()
{
    gl_Position = float4(1.0f, 2.0f, 3.0f, 4.0f);
}

SPIRV_Cross_Output main()
{
    vert_main();
    SPIRV_Cross_Output stage_output;
    stage_output.gl_Position = gl_Position;
    return stage_output;
}


================================================
FILE: Source/Tests/Data/Expected/Constant_VS.msl
================================================
#include <metal_stdlib>
#include <simd/simd.h>

using namespace metal;

struct VSMain_out
{
    float4 gl_Position [[position]];
};

vertex VSMain_out VSMain()
{
    VSMain_out out = {};
    out.gl_Position = float4(1.0, 2.0, 3.0, 4.0);
    return out;
}



================================================
FILE: Source/Tests/Data/Expected/DetailTessellation_HS.300.essl
================================================
#version 300 es
#extension GL_EXT_tessellation_shader : require
layout(vertices = 3) out;

struct VS_OUTPUT_HS_INPUT
{
    vec3 worldPos;
    vec3 normal;
    vec2 texCoord;
    vec3 lightTS;
};

layout(std140) uniform type_cbMain
{
    vec4 tessellationFactor;
} cbMain;

in vec3 in_var_WORLDPOS[];
in vec3 in_var_NORMAL[];
in vec2 in_var_TEXCOORD0[];
in vec3 in_var_LIGHTVECTORTS[];
out vec3 out_var_WORLDPOS[3];
out vec3 out_var_NORMAL[3];
out vec2 out_var_TEXCOORD0[3];
out vec3 out_var_LIGHTVECTORTS[3];

void main()
{
    vec3 _58_unrolled[3];
    for (int i = 0; i < int(3); i++)
    {
        _58_unrolled[i] = in_var_WORLDPOS[i];
    }
    vec3 _59_unrolled[3];
    for (int i = 0; i < int(3); i++)
    {
        _59_unrolled[i] = in_var_NORMAL[i];
    }
    vec2 _60_unrolled[3];
    for (int i = 0; i < int(3); i++)
    {
        _60_unrolled[i] = in_var_TEXCOORD0[i];
    }
    vec3 _61_unrolled[3];
    for (int i = 0; i < int(3); i++)
    {
        _61_unrolled[i] = in_var_LIGHTVECTORTS[i];
    }
    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]));
    out_var_WORLDPOS[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].worldPos;
    out_var_NORMAL[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].normal;
    out_var_TEXCOORD0[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].texCoord;
    out_var_LIGHTVECTORTS[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].lightTS;
    barrier();
    if (gl_InvocationID == 0u)
    {
        gl_TessLevelOuter[0u] = cbMain.tessellationFactor.x;
        gl_TessLevelOuter[1u] = cbMain.tessellationFactor.y;
        gl_TessLevelOuter[2u] = cbMain.tessellationFactor.z;
        gl_TessLevelInner[0u] = cbMain.tessellationFactor.w;
    }
}



================================================
FILE: Source/Tests/Data/Expected/DetailTessellation_HS.300.glsl
================================================
#version 300
#extension GL_ARB_tessellation_shader : require
#extension GL_ARB_separate_shader_objects : require
layout(vertices = 3) out;

struct VS_OUTPUT_HS_INPUT
{
    vec3 worldPos;
    vec3 normal;
    vec2 texCoord;
    vec3 lightTS;
};

layout(std140) uniform type_cbMain
{
    vec4 tessellationFactor;
} cbMain;

layout(location = 0) in vec3 in_var_WORLDPOS[];
layout(location = 1) in vec3 in_var_NORMAL[];
layout(location = 2) in vec2 in_var_TEXCOORD0[];
layout(location = 3) in vec3 in_var_LIGHTVECTORTS[];
layout(location = 3) out vec3 out_var_WORLDPOS[3];
layout(location = 1) out vec3 out_var_NORMAL[3];
layout(location = 2) out vec2 out_var_TEXCOORD0[3];
layout(location = 0) out vec3 out_var_LIGHTVECTORTS[3];

void main()
{
    vec3 _58_unrolled[3];
    for (int i = 0; i < int(3); i++)
    {
        _58_unrolled[i] = in_var_WORLDPOS[i];
    }
    vec3 _59_unrolled[3];
    for (int i = 0; i < int(3); i++)
    {
        _59_unrolled[i] = in_var_NORMAL[i];
    }
    vec2 _60_unrolled[3];
    for (int i = 0; i < int(3); i++)
    {
        _60_unrolled[i] = in_var_TEXCOORD0[i];
    }
    vec3 _61_unrolled[3];
    for (int i = 0; i < int(3); i++)
    {
        _61_unrolled[i] = in_var_LIGHTVECTORTS[i];
    }
    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]));
    out_var_WORLDPOS[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].worldPos;
    out_var_NORMAL[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].normal;
    out_var_TEXCOORD0[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].texCoord;
    out_var_LIGHTVECTORTS[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].lightTS;
    barrier();
    if (gl_InvocationID == 0u)
    {
        gl_TessLevelOuter[0u] = cbMain.tessellationFactor.x;
        gl_TessLevelOuter[1u] = cbMain.tessellationFactor.y;
        gl_TessLevelOuter[2u] = cbMain.tessellationFactor.z;
        gl_TessLevelInner[0u] = cbMain.tessellationFactor.w;
    }
}



================================================
FILE: Source/Tests/Data/Expected/DetailTessellation_HS.310.essl
================================================
#version 310 es
#extension GL_EXT_tessellation_shader : require
layout(vertices = 3) out;

struct VS_OUTPUT_HS_INPUT
{
    vec3 worldPos;
    vec3 normal;
    vec2 texCoord;
    vec3 lightTS;
};

layout(binding = 0, std140) uniform type_cbMain
{
    vec4 tessellationFactor;
} cbMain;

layout(location = 0) in vec3 in_var_WORLDPOS[];
layout(location = 1) in vec3 in_var_NORMAL[];
layout(location = 2) in vec2 in_var_TEXCOORD0[];
layout(location = 3) in vec3 in_var_LIGHTVECTORTS[];
layout(location = 3) out vec3 out_var_WORLDPOS[3];
layout(location = 1) out vec3 out_var_NORMAL[3];
layout(location = 2) out vec2 out_var_TEXCOORD0[3];
layout(location = 0) out vec3 out_var_LIGHTVECTORTS[3];

void main()
{
    vec3 _58_unrolled[3];
    for (int i = 0; i < int(3); i++)
    {
        _58_unrolled[i] = in_var_WORLDPOS[i];
    }
    vec3 _59_unrolled[3];
    for (int i = 0; i < int(3); i++)
    {
        _59_unrolled[i] = in_var_NORMAL[i];
    }
    vec2 _60_unrolled[3];
    for (int i = 0; i < int(3); i++)
    {
        _60_unrolled[i] = in_var_TEXCOORD0[i];
    }
    vec3 _61_unrolled[3];
    for (int i = 0; i < int(3); i++)
    {
        _61_unrolled[i] = in_var_LIGHTVECTORTS[i];
    }
    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]));
    out_var_WORLDPOS[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].worldPos;
    out_var_NORMAL[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].normal;
    out_var_TEXCOORD0[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].texCoord;
    out_var_LIGHTVECTORTS[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].lightTS;
    barrier();
    if (gl_InvocationID == 0u)
    {
        gl_TessLevelOuter[0u] = cbMain.tessellationFactor.x;
        gl_TessLevelOuter[1u] = cbMain.tessellationFactor.y;
        gl_TessLevelOuter[2u] = cbMain.tessellationFactor.z;
        gl_TessLevelInner[0u] = cbMain.tessellationFactor.w;
    }
}



================================================
FILE: Source/Tests/Data/Expected/DetailTessellation_HS.410.glsl
================================================
#version 410
layout(vertices = 3) out;

struct VS_OUTPUT_HS_INPUT
{
    vec3 worldPos;
    vec3 normal;
    vec2 texCoord;
    vec3 lightTS;
};

layout(std140) uniform type_cbMain
{
    vec4 tessellationFactor;
} cbMain;

layout(location = 0) in vec3 in_var_WORLDPOS[];
layout(location = 1) in vec3 in_var_NORMAL[];
layout(location = 2) in vec2 in_var_TEXCOORD0[];
layout(location = 3) in vec3 in_var_LIGHTVECTORTS[];
layout(location = 3) out vec3 out_var_WORLDPOS[3];
layout(location = 1) out vec3 out_var_NORMAL[3];
layout(location = 2) out vec2 out_var_TEXCOORD0[3];
layout(location = 0) out vec3 out_var_LIGHTVECTORTS[3];

void main()
{
    vec3 _58_unrolled[3];
    for (int i = 0; i < int(3); i++)
    {
        _58_unrolled[i] = in_var_WORLDPOS[i];
    }
    vec3 _59_unrolled[3];
    for (int i = 0; i < int(3); i++)
    {
        _59_unrolled[i] = in_var_NORMAL[i];
    }
    vec2 _60_unrolled[3];
    for (int i = 0; i < int(3); i++)
    {
        _60_unrolled[i] = in_var_TEXCOORD0[i];
    }
    vec3 _61_unrolled[3];
    for (int i = 0; i < int(3); i++)
    {
        _61_unrolled[i] = in_var_LIGHTVECTORTS[i];
    }
    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]));
    out_var_WORLDPOS[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].worldPos;
    out_var_NORMAL[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].normal;
    out_var_TEXCOORD0[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].texCoord;
    out_var_LIGHTVECTORTS[gl_InvocationID] = param_var_inputPatch[gl_InvocationID].lightTS;
    barrier();
    if (gl_InvocationID == 0u)
    {
        gl_TessLevelOuter[0u] = cbMain.tessellationFactor.x;
        gl_TessLevelOuter[1u] = cbMain.tessellationFactor.y;
        gl_TessLevelOuter[2u] = cbMain.tessellationFactor.z;
        gl_TessLevelInner[0u] = cbMain.tessellationFactor.w;
    }
}



================================================
FILE: Source/Tests/Data/Expected/DetailTessellation_HS.msl
================================================
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#pragma clang diagnostic ignored "-Wmissing-braces"

#include <metal_stdlib>
#include <simd/simd.h>

using namespace metal;

template<typename T, size_t Num>
struct spvUnsafeArray
{
    T elements[Num ? Num : 1];
    
    thread T& operator [] (size_t pos) thread
    {
        return elements[pos];
    }
    constexpr const thread T& operator [] (size_t pos) const thread
    {
        return elements[pos];
    }
    
    device T& operator [] (size_t pos) device
    {
        return elements[pos];
    }
    constexpr const device T& operator [] (size_t pos) const device
    {
        return elements[pos];
    }
    
    constexpr const constant T& operator [] (size_t pos) const constant
    {
        return elements[pos];
    }
    
    threadgroup T& operator [] (size_t pos) threadgroup
    {
        return elements[pos];
    }
    constexpr const threadgroup T& operator [] (size_t pos) const threadgroup
    {
        return elements[pos];
    }
};

struct type_cbMain
{
    float4 tessellationFactor;
};

struct VS_OUTPUT_HS_INPUT
{
    float3 worldPos;
    float3 normal;
    float2 texCoord;
    float3 lightTS;
};

struct main0_out
{
    float3 out_var_LIGHTVECTORTS;
    float3 out_var_NORMAL;
    float2 out_var_TEXCOORD0;
    float3 out_var_WORLDPOS;
};

struct main0_in
{
    float3 in_var_WORLDPOS [[attribute(0)]];
    float3 in_var_NORMAL [[attribute(1)]];
    float2 in_var_TEXCOORD0 [[attribute(2)]];
    float3 in_var_LIGHTVECTORTS [[attribute(3)]];
};

kernel void main0(main0_in in [[stage_in]], constant type_cbMain& cbMain [[buffer(0)]], uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLTriangleTessellationFactorsHalf* spvTessLevel [[buffer(26)]], threadgroup main0_in* gl_in [[threadgroup(0)]])
{
    device main0_out* gl_out = &spvOut[gl_PrimitiveID * 3];
    if (gl_InvocationID < spvIndirectParams[0])
        gl_in[gl_InvocationID] = in;
    threadgroup_barrier(mem_flags::mem_threadgroup);
    if (gl_InvocationID >= 3)
        return;
    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 });
    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 });
    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 });
    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 });
    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] } });
    spvUnsafeArray<VS_OUTPUT_HS_INPUT, 3> param_var_inputPatch;
    param_var_inputPatch = _77;
    gl_out[gl_InvocationID].out_var_WORLDPOS = param_var_inputPatch[gl_InvocationID].worldPos;
    gl_out[gl_InvocationID].out_var_NORMAL = param_var_inputPatch[gl_InvocationID].normal;
    gl_out[gl_InvocationID].out_var_TEXCOORD0 = param_var_inputPatch[gl_InvocationID].texCoord;
    gl_out[gl_InvocationID].out_var_LIGHTVECTORTS = param_var_inputPatch[gl_InvocationID].lightTS;
    threadgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup);
    if (gl_InvocationID == 0u)
    {
        spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0u] = half(cbMain.tessellationFactor.x);
        spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1u] = half(cbMain.tessellationFactor.y);
        spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2u] = half(cbMain.tessellationFactor.z);
        spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(cbMain.tessellationFactor.w);
    }
}



================================================
FILE: Source/Tests/Data/Expected/DotHalfPS.glsl
================================================
#version 30
#if defined(GL_AMD_gpu_shader_half_float)
#extension GL_AMD_gpu_shader_half_float : require
#elif defined(GL_NV_gpu_shader5)
#extension GL_NV_gpu_shader5 : require
#else
#error No extension available for FP16.
#endif
#extension GL_ARB_separate_shader_objects : require

void main()
{
    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)))));
}



================================================
FILE: Source/Tests/Data/Expected/Fluid_CS.300.glsl
================================================
#version 300
#extension GL_ARB_compute_shader : require
#extension GL_ARB_separate_shader_objects : require
layout(local_size_x = 256, local_size_y = 1, local_size_z = 1) in;

struct Particle
{
    vec2 position;
    vec2 velocity;
};

struct ParticleForces
{
    vec2 acceleration;
};

layout(std140) uniform type_cbSimulationConstants
{
    float timeStep;
    float wallStiffness;
    vec4 gravity;
    vec3 planes[4];
} cbSimulationConstants;

layout(std430) buffer type_RWStructuredBuffer_Particle
{
    Particle _m0[];
} particlesRW;

layout(std430) readonly buffer type_StructuredBuffer_Particle
{
    Particle _m0[];
} particlesRO;

layout(std430) readonly buffer type_StructuredBuffer_ParticleForces
{
    ParticleForces _m0[];
} particlesForcesRO;

void main()
{
    vec2 _52 = particlesRO._m0[gl_GlobalInvocationID.x].position;
    vec2 _54 = particlesRO._m0[gl_GlobalInvocationID.x].velocity;
    vec2 _56 = particlesForcesRO._m0[gl_GlobalInvocationID.x].acceleration;
    vec3 _59 = vec3(_52, 1.0);
    float _67 = -cbSimulationConstants.wallStiffness;
    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);
    particlesRW._m0[gl_GlobalInvocationID.x].position = _52 + (_102 * cbSimulationConstants.timeStep);
    particlesRW._m0[gl_GlobalInvocationID.x].velocity = _102;
}



================================================
FILE: Source/Tests/Data/Expected/Fluid_CS.310.essl
================================================
#version 310 es
layout(local_size_x = 256, local_size_y = 1, local_size_z = 1) in;

struct Particle
{
    vec2 position;
    vec2 velocity;
};

struct ParticleForces
{
    vec2 acceleration;
};

layout(binding = 0, std140) uniform type_cbSimulationConstants
{
    float timeStep;
    float wallStiffness;
    vec4 gravity;
    vec3 planes[4];
} cbSimulationConstants;

layout(binding = 0, std430) buffer type_RWStructuredBuffer_Particle
{
    Particle _m0[];
} particlesRW;

layout(binding = 0, std430) readonly buffer type_StructuredBuffer_Particle
{
    Particle _m0[];
} particlesRO;

layout(binding = 2, std430) readonly buffer type_StructuredBuffer_ParticleForces
{
    ParticleForces _m0[];
} particlesForcesRO;

void main()
{
    vec2 _52 = particlesRO._m0[gl_GlobalInvocationID.x].position;
    vec2 _54 = particlesRO._m0[gl_GlobalInvocationID.x].velocity;
    vec2 _56 = particlesForcesRO._m0[gl_GlobalInvocationID.x].acceleration;
    vec3 _59 = vec3(_52, 1.0);
    float _67 = -cbSimulationConstants.wallStiffness;
    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);
    particlesRW._m0[gl_GlobalInvocationID.x].position = _52 + (_102 * cbSimulationConstants.timeStep);
    particlesRW._m0[gl_GlobalInvocationID.x].velocity = _102;
}



================================================
FILE: Source/Tests/Data/Expected/Fluid_CS.410.glsl
================================================
#version 410
#extension GL_ARB_compute_shader : require
layout(local_size_x = 256, local_size_y = 1, local_size_z = 1) in;

struct Particle
{
    vec2 position;
    vec2 velocity;
};

struct ParticleForces
{
    vec2 acceleration;
};

layout(std140) uniform type_cbSimulationConstants
{
    float timeStep;
    float wallStiffness;
    vec4 gravity;
    vec3 planes[4];
} cbSimulationConstants;

layout(std430) buffer type_RWStructuredBuffer_Particle
{
    Particle _m0[];
} particlesRW;

layout(std430) readonly buffer type_StructuredBuffer_Particle
{
    Particle _m0[];
} particlesRO;

layout(std430) readonly buffer type_StructuredBuffer_ParticleForces
{
    ParticleForces _m0[];
} particlesForcesRO;

void main()
{
    vec2 _52 = particlesRO._m0[gl_GlobalInvocationID.x].position;
    vec2 _54 = particlesRO._m0[gl_GlobalInvocationID.x].velocity;
    vec2 _56 = particlesForcesRO._m0[gl_GlobalInvocationID.x].acceleration;
    vec3 _59 = vec3(_52, 1.0);
    float _67 = -cbSimulationConstants.wallStiffness;
    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);
    particlesRW._m0[gl_GlobalInvocationID.x].position = _52 + (_102 * cbSimulationConstants.timeStep);
    particlesRW._m0[gl_GlobalInvocationID.x].velocity = _102;
}



================================================
FILE: Source/Tests/Data/Expected/Fluid_CS.50.hlsl
================================================
struct Particle
{
    float2 position;
    float2 velocity;
};

struct ParticleForces
{
    float2 acceleration;
};

cbuffer type_cbSimulationConstants : register(b0)
{
    float cbSimulationConstants_timeStep : packoffset(c0);
    float cbSimulationConstants_wallStiffness : packoffset(c0.y);
    float4 cbSimulationConstants_gravity : packoffset(c1);
    float3 cbSimulationConstants_planes[4] : packoffset(c2);
};

RWByteAddressBuffer particlesRW : register(u0);
ByteAddressBuffer particlesRO : register(t0);
ByteAddressBuffer particlesForcesRO : register(t2);

static uint3 gl_GlobalInvocationID;
struct SPIRV_Cross_Input
{
    uint3 gl_GlobalInvocationID : SV_DispatchThreadID;
};

void comp_main()
{
    float2 _52 = asfloat(particlesRO.Load2(gl_GlobalInvocationID.x * 16 + 0));
    float2 _54 = asfloat(particlesRO.Load2(gl_GlobalInvocationID.x * 16 + 8));
    float2 _56 = asfloat(particlesForcesRO.Load2(gl_GlobalInvocationID.x * 8 + 0));
    float3 _59 = float3(_52, 1.0f);
    float _67 = -cbSimulationConstants_wallStiffness;
    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);
    particlesRW.Store2(gl_GlobalInvocationID.x * 16 + 0, asuint(_52 + (_102 * cbSimulationConstants_timeStep)));
    particlesRW.Store2(gl_GlobalInvocationID.x * 16 + 8, asuint(_102));
}

[numthreads(256, 1, 1)]
void main(SPIRV_Cross_Input stage_input)
{
    gl_GlobalInvocationID = stage_input.gl_GlobalInvocationID;
    comp_main();
}


================================================
FILE: Source/Tests/Data/Expected/Fluid_CS.msl
================================================
#include <metal_stdlib>
#include <simd/simd.h>

using namespace metal;

struct type_cbSimulationConstants
{
    float timeStep;
    float wallStiffness;
    float4 gravity;
    float3 planes[4];
};

struct Particle
{
    float2 position;
    float2 velocity;
};

struct type_RWStructuredBuffer_Particle
{
    Particle _m0[1];
};

struct type_StructuredBuffer_Particle
{
    Particle _m0[1];
};

struct ParticleForces
{
    float2 acceleration;
};

struct type_StructuredBuffer_ParticleForces
{
    ParticleForces _m0[1];
};

kernel void main0(constant type_cbSimulationConstants& cbSimulationConstants [[buffer(0)]], device type_RWStructuredBuffer_Particle& particlesRW [[buffer(1)]], const device type_StructuredBuffer_Particle& particlesRO [[buffer(2)]], const device type_StructuredBuffer_ParticleForces& particlesForcesRO [[buffer(3)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
    float2 _52 = particlesRO._m0[gl_GlobalInvocationID.x].position;
    float2 _54 = particlesRO._m0[gl_GlobalInvocationID.x].velocity;
    float2 _56 = particlesForcesRO._m0[gl_GlobalInvocationID.x].acceleration;
    float3 _59 = float3(_52, 1.0);
    float _67 = -cbSimulationConstants.wallStiffness;
    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);
    particlesRW._m0[gl_GlobalInvocationID.x].position = _52 + (_102 * cbSimulationConstants.timeStep);
    particlesRW._m0[gl_GlobalInvocationID.x].velocity = _102;
}



================================================
FILE: Source/Tests/Data/Expected/HalfOutParamPS.glsl
================================================
#version 30
#if defined(GL_AMD_gpu_shader_half_float)
#extension GL_AMD_gpu_shader_half_float : require
#elif defined(GL_NV_gpu_shader5)
#extension GL_NV_gpu_shader5 : require
#else
#error No extension available for FP16.
#endif
#extension GL_ARB_separate_shader_objects : require

void main()
{
    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);
}



================================================
FILE: Source/Tests/Data/Expected/IncludeEmptyHeader.glsl
================================================
#version 30
#extension GL_ARB_separate_shader_objects : require

void main()
{
    gl_FragData[0] = vec4(0.0);
}



================================================
FILE: Source/Tests/Data/Expected/IncludeExist.glsl
================================================
#version 30
#extension GL_ARB_separate_shader_objects : require

uniform sampler2D SPIRV_Cross_CombinedcolorTexpointSampler;
uniform sampler2D SPIRV_Cross_CombinedcolorTexlinearSampler;

varying vec2 varying_TEXCOORD0;

void main()
{
    gl_FragData[0] = texture2D(SPIRV_Cross_CombinedcolorTexpointSampler, varying_TEXCOORD0) + texture2D(SPIRV_Cross_CombinedcolorTexlinearSampler, varying_TEXCOORD0);
}



================================================
FILE: Source/Tests/Data/Expected/PNTriangles_DS.300.essl
================================================
#version 300 es
#extension GL_EXT_tessellation_shader : require
layout(triangles) in;

layout(std140) uniform type_cbPNTriangles
{
    mat4 viewProj;
    vec4 lightDir;
} cbPNTriangles;

patch in vec3 in_var_POSITION3;
patch in vec3 in_var_POSITION4;
patch in vec3 in_var_POSITION5;
patch in vec3 in_var_POSITION6;
patch in vec3 in_var_POSITION7;
patch in vec3 in_var_POSITION8;
patch in vec3 in_var_CENTER;
in vec3 in_var_POSITION[];
in vec2 in_var_TEXCOORD[];
out vec2 out_var_TEXCOORD0;

void main()
{
    vec3 _55_unrolled[3];
    for (int i = 0; i < int(3); i++)
    {
        _55_unrolled[i] = in_var_POSITION[i];
    }
    vec2 _56_unrolled[3];
    for (int i = 0; i < int(3); i++)
    {
        _56_unrolled[i] = in_var_TEXCOORD[i];
    }
    float _67 = gl_TessCoord.x * gl_TessCoord.x;
    float _68 = gl_TessCoord.y * gl_TessCoord.y;
    float _69 = gl_TessCoord.z * gl_TessCoord.z;
    float _70 = _67 * 3.0;
    float _71 = _68 * 3.0;
    float _72 = _69 * 3.0;
    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);
    out_var_TEXCOORD0 = ((_56_unrolled[0] * gl_TessCoord.z) + (_56_unrolled[1] * gl_TessCoord.x)) + (_56_unrolled[2] * gl_TessCoord.y);
}



================================================
FILE: Source/Tests/Data/Expected/PNTriangles_DS.300.glsl
================================================
#version 300
#extension GL_ARB_tessellation_shader : require
#extension GL_ARB_separate_shader_objects : require
layout(triangles) in;

out gl_PerVertex
{
    vec4 gl_Position;
};

layout(std140) uniform type_cbPNTriangles
{
    mat4 viewProj;
    vec4 lightDir;
} cbPNTriangles;

layout(location = 2) patch in vec3 in_var_POSITION3;
layout(location = 3) patch in vec3 in_var_POSITION4;
layout(location = 4) patch in vec3 in_var_POSITION5;
layout(location = 5) patch in vec3 in_var_POSITION6;
layout(location = 6) patch in vec3 in_var_POSITION7;
layout(location = 7) patch in vec3 in_var_POSITION8;
layout(location = 0) patch in vec3 in_var_CENTER;
layout(location = 1) in vec3 in_var_POSITION[];
layout(location = 8) in vec2 in_var_TEXCOORD[];
layout(location = 0) out vec2 out_var_TEXCOORD0;

void main()
{
    vec3 _55_unrolled[3];
    for (int i = 0; i < int(3); i++)
    {
        _55_unrolled[i] = in_var_POSITION[i];
    }
    vec2 _56_unrolled[3];
    for (int i = 0; i < int(3); i++)
    {
        _56_unrolled[i] = in_var_TEXCOORD[i];
    }
    float _67 = gl_TessCoord.x * gl_TessCoord.x;
    float _68 = gl_TessCoord.y * gl_TessCoord.y;
    float _69 = gl_TessCoord.z * gl_TessCoord.z;
    float _70 = _67 * 3.0;
    float _71 = _68 * 3.0;
    float _72 = _69 * 3.0;
    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);
    out_var_TEXCOORD0 = ((_56_unrolled[0] * gl_TessCoord.z) + (_56_unrolled[1] * gl_TessCoord.x)) + (_56_unrolled[2] * gl_TessCoord.y);
}



================================================
FILE: Source/Tests/Data/Expected/PNTriangles_DS.310.essl
================================================
#version 310 es
#extension GL_EXT_tessellation_shader : require
layout(triangles) in;

layout(binding = 0, std140) uniform type_cbPNTriangles
{
    mat4 viewProj;
    vec4 lightDir;
} cbPNTriangles;

layout(location = 2) patch in vec3 in_var_POSITION3;
layout(location = 3) patch in vec3 in_var_POSITION4;
layout(location = 4) patch in vec3 in_var_POSITION5;
layout(location = 5) patch in vec3 in_var_POSITION6;
layout(location = 6) patch in vec3 in_var_POSITION7;
layout(location = 7) patch in vec3 in_var_POSITION8;
layout(location = 0) patch in vec3 in_var_CENTER;
layout(location = 1) in vec3 in_var_POSITION[];
layout(location = 8) in vec2 in_var_TEXCOORD[];
layout(location = 0) out vec2 out_var_TEXCOORD0;

void main()
{
    vec3 _55_unrolled[3];
    for (int i = 0; i < int(3); i++)
    {
        _55_unrolled[i] = in_var_POSITION[i];
    }
    vec2 _56_unrolled[3];
    for (int i = 0; i < int(3); i++)
    {
        _56_unrolled[i] = in_var_TEXCOORD[i];
    }
    float _67 = gl_TessCoord.x * gl_TessCoord.x;
    float _68 = gl_TessCoord.y * gl_TessCoord.y;
    float _69 = gl_TessCoord.z * gl_TessCoord.z;
    float _70 = _67 * 3.0;
    float _71 = _68 * 3.0;
    float _72 = _69 * 3.0;
    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);
    out_var_TEXCOORD0 = ((_56_unrolled[0] * gl_TessCoord.z) + (_56_unrolled[1] * gl_TessCoord.x)) + (_56_unrolled[2] * gl_TessCoord.y);
}



================================================
FILE: Source/Tests/Data/Expected/PNTriangles_DS.410.glsl
================================================
#version 410
layout(triangles) in;

out gl_PerVertex
{
    vec4 gl_Position;
};

layout(std140) uniform type_cbPNTriangles
{
    mat4 viewProj;
    vec4 lightDir;
} cbPNTriangles;

layout(location = 2) patch in vec3 in_var_POSITION3;
layout(location = 3) patch in vec3 in_var_POSITION4;
layout(location = 4) patch in vec3 in_var_POSITION5;
layout(location = 5) patch in vec3 in_var_POSITION6;
layout(location = 6) patch in vec3 in_var_POSITION7;
layout(location = 7) patch in vec3 in_var_POSITION8;
layout(location = 0) patch in vec3 in_var_CENTER;
layout(location = 1) in vec3 in_var_POSITION[];
layout(location = 8) in vec2 in_var_TEXCOORD[];
layout(location = 0) out vec2 out_var_TEXCOORD0;

void main()
{
    vec3 _55_unrolled[3];
    for (int i = 0; i < int(3); i++)
    {
        _55_unrolled[i] = in_var_POSITION[i];
    }
    vec2 _56_unrolled[3];
    for (int i = 0; i < int(3); i++)
    {
        _56_unrolled[i] = in_var_TEXCOORD[i];
    }
    float _67 = gl_TessCoord.x * gl_TessCoord.x;
    float _68 = gl_TessCoord.y * gl_TessCoord.y;
    float _69 = gl_TessCoord.z * gl_TessCoord.z;
    float _70 = _67 * 3.0;
    float _71 = _68 * 3.0;
    float _72 = _69 * 3.0;
    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);
    out_var_TEXCOORD0 = ((_56_unrolled[0] * gl_TessCoord.z) + (_56_unrolled[1] * gl_TessCoord.x)) + (_56_unrolled[2] * gl_TessCoord.y);
}



================================================
FILE: Source/Tests/Data/Expected/PNTriangles_DS.msl
================================================
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#pragma clang diagnostic ignored "-Wmissing-braces"

#include <metal_stdlib>
#include <simd/simd.h>

using namespace metal;

template<typename T, size_t Num>
struct spvUnsafeArray
{
    T elements[Num ? Num : 1];
    
    thread T& operator [] (size_t pos) thread
    {
        return elements[pos];
    }
    constexpr const thread T& operator [] (size_t pos) const thread
    {
        return elements[pos];
    }
    
    device T& operator [] (size_t pos) device
    {
        return elements[pos];
    }
    constexpr const device T& operator [] (size_t pos) const device
    {
        return elements[pos];
    }
    
    constexpr const constant T& operator [] (size_t pos) const constant
    {
        return elements[pos];
    }
    
    threadgroup T& operator [] (size_t pos) threadgroup
    {
        return elements[pos];
    }
    constexpr const threadgroup T& operator [] (size_t pos) const threadgroup
    {
        return elements[pos];
    }
};

struct type_cbPNTriangles
{
    float4x4 viewProj;
    float4 lightDir;
};

struct main0_out
{
    float2 out_var_TEXCOORD0 [[user(locn0)]];
    float4 gl_Position [[position]];
};

struct main0_in
{
    float3 in_var_POSITION [[attribute(1)]];
    float2 in_var_TEXCOORD [[attribute(8)]];
};

struct main0_patchIn
{
    float3 in_var_CENTER [[attribute(0)]];
    float3 in_var_POSITION3 [[attribute(2)]];
    float3 in_var_POSITION4 [[attribute(3)]];
    float3 in_var_POSITION5 [[attribute(4)]];
    float3 in_var_POSITION6 [[attribute(5)]];
    float3 in_var_POSITION7 [[attribute(6)]];
    float3 in_var_POSITION8 [[attribute(7)]];
    patch_control_point<main0_in> gl_in;
};

[[ patch(triangle, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]], constant type_cbPNTriangles& cbPNTriangles [[buffer(0)]], float3 gl_TessCoord [[position_in_patch]])
{
    main0_out out = {};
    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 });
    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 });
    float _67 = gl_TessCoord.x * gl_TessCoord.x;
    float _68 = gl_TessCoord.y * gl_TessCoord.y;
    float _69 = gl_TessCoord.z * gl_TessCoord.z;
    float _70 = _67 * 3.0;
    float _71 = _68 * 3.0;
    float _72 = _69 * 3.0;
    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);
    out.out_var_TEXCOORD0 = ((_56[0] * gl_TessCoord.z) + (_56[1] * gl_TessCoord.x)) + (_56[2] * gl_TessCoord.y);
    return out;
}



================================================
FILE: Source/Tests/Data/Expected/Particle_GS.300.essl
================================================
#version 300 es
#extension GL_EXT_geometry_shader : require
layout(points) in;
layout(max_vertices = 4, triangle_strip) out;

layout(std140) uniform type_cbMain
{
    mat4 invView;
    mat4 viewProj;
} cbMain;

in vec4 in_var_POSITION[1];
out vec2 out_var_TEXCOORD0;

void main()
{
    mat3 _49 = mat3(cbMain.invView[0].xyz, cbMain.invView[1].xyz, cbMain.invView[2].xyz);
    gl_Position = cbMain.viewProj * vec4((_49 * vec3(-5.0, 5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);
    out_var_TEXCOORD0 = vec2(0.0, 1.0);
    EmitVertex();
    gl_Position = cbMain.viewProj * vec4((_49 * vec3(5.0, 5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);
    out_var_TEXCOORD0 = vec2(1.0);
    EmitVertex();
    gl_Position = cbMain.viewProj * vec4((_49 * vec3(-5.0, -5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);
    out_var_TEXCOORD0 = vec2(0.0);
    EmitVertex();
    gl_Position = cbMain.viewProj * vec4((_49 * vec3(5.0, -5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);
    out_var_TEXCOORD0 = vec2(1.0, 0.0);
    EmitVertex();
    EndPrimitive();
}



================================================
FILE: Source/Tests/Data/Expected/Particle_GS.300.glsl
================================================
#version 300
#extension GL_ARB_separate_shader_objects : require
layout(points) in;
layout(max_vertices = 4, triangle_strip) out;

out gl_PerVertex
{
    vec4 gl_Position;
};

layout(std140) uniform type_cbMain
{
    mat4 invView;
    mat4 viewProj;
} cbMain;

layout(location = 0) in vec4 in_var_POSITION[1];
layout(location = 0) out vec2 out_var_TEXCOORD0;

void main()
{
    mat3 _49 = mat3(cbMain.invView[0].xyz, cbMain.invView[1].xyz, cbMain.invView[2].xyz);
    gl_Position = cbMain.viewProj * vec4((_49 * vec3(-5.0, 5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);
    out_var_TEXCOORD0 = vec2(0.0, 1.0);
    EmitVertex();
    gl_Position = cbMain.viewProj * vec4((_49 * vec3(5.0, 5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);
    out_var_TEXCOORD0 = vec2(1.0);
    EmitVertex();
    gl_Position = cbMain.viewProj * vec4((_49 * vec3(-5.0, -5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);
    out_var_TEXCOORD0 = vec2(0.0);
    EmitVertex();
    gl_Position = cbMain.viewProj * vec4((_49 * vec3(5.0, -5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);
    out_var_TEXCOORD0 = vec2(1.0, 0.0);
    EmitVertex();
    EndPrimitive();
}



================================================
FILE: Source/Tests/Data/Expected/Particle_GS.310.essl
================================================
#version 310 es
#extension GL_EXT_geometry_shader : require
layout(points) in;
layout(max_vertices = 4, triangle_strip) out;

layout(binding = 0, std140) uniform type_cbMain
{
    mat4 invView;
    mat4 viewProj;
} cbMain;

layout(location = 0) in vec4 in_var_POSITION[1];
layout(location = 0) out vec2 out_var_TEXCOORD0;

void main()
{
    mat3 _49 = mat3(cbMain.invView[0].xyz, cbMain.invView[1].xyz, cbMain.invView[2].xyz);
    gl_Position = cbMain.viewProj * vec4((_49 * vec3(-5.0, 5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);
    out_var_TEXCOORD0 = vec2(0.0, 1.0);
    EmitVertex();
    gl_Position = cbMain.viewProj * vec4((_49 * vec3(5.0, 5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);
    out_var_TEXCOORD0 = vec2(1.0);
    EmitVertex();
    gl_Position = cbMain.viewProj * vec4((_49 * vec3(-5.0, -5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);
    out_var_TEXCOORD0 = vec2(0.0);
    EmitVertex();
    gl_Position = cbMain.viewProj * vec4((_49 * vec3(5.0, -5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);
    out_var_TEXCOORD0 = vec2(1.0, 0.0);
    EmitVertex();
    EndPrimitive();
}



================================================
FILE: Source/Tests/Data/Expected/Particle_GS.410.glsl
================================================
#version 410
layout(points) in;
layout(max_vertices = 4, triangle_strip) out;

out gl_PerVertex
{
    vec4 gl_Position;
};

layout(std140) uniform type_cbMain
{
    mat4 invView;
    mat4 viewProj;
} cbMain;

layout(location = 0) in vec4 in_var_POSITION[1];
layout(location = 0) out vec2 out_var_TEXCOORD0;

void main()
{
    mat3 _49 = mat3(cbMain.invView[0].xyz, cbMain.invView[1].xyz, cbMain.invView[2].xyz);
    gl_Position = cbMain.viewProj * vec4((_49 * vec3(-5.0, 5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);
    out_var_TEXCOORD0 = vec2(0.0, 1.0);
    EmitVertex();
    gl_Position = cbMain.viewProj * vec4((_49 * vec3(5.0, 5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);
    out_var_TEXCOORD0 = vec2(1.0);
    EmitVertex();
    gl_Position = cbMain.viewProj * vec4((_49 * vec3(-5.0, -5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);
    out_var_TEXCOORD0 = vec2(0.0);
    EmitVertex();
    gl_Position = cbMain.viewProj * vec4((_49 * vec3(5.0, -5.0, 0.0)) + in_var_POSITION[0].xyz, 1.0);
    out_var_TEXCOORD0 = vec2(1.0, 0.0);
    EmitVertex();
    EndPrimitive();
}



================================================
FILE: Source/Tests/Data/Expected/PassThrough_PS.30.hlsl
================================================
static float4 in_var_COLOR;
static float4 out_var_SV_Target;

struct SPIRV_Cross_Input
{
    float4 in_var_COLOR : TEXCOORD0;
};

struct SPIRV_Cross_Output
{
    float4 out_var_SV_Target : COLOR0;
};

void frag_main()
{
    out_var_SV_Target = in_var_COLOR;
}

SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
    in_var_COLOR = stage_input.in_var_COLOR;
    frag_main();
    SPIRV_Cross_Output stage_output;
    stage_output.out_var_SV_Target = float4(out_var_SV_Target);
    return stage_output;
}


================================================
FILE: Source/Tests/Data/Expected/PassThrough_PS.300.essl
================================================
#version 300 es
precision mediump float;
precision highp int;

in highp vec4 varying_COLOR;
layout(location = 0) out highp vec4 out_var_SV_Target;

void main()
{
    out_var_SV_Target = varying_COLOR;
}



================================================
FILE: Source/Tests/Data/Expected/PassThrough_PS.300.glsl
================================================
#version 300
#extension GL_ARB_separate_shader_objects : require

layout(location = 0) in vec4 varying_COLOR;
out vec4 out_var_SV_Target;

void main()
{
    out_var_SV_Target = varying_COLOR;
}



================================================
FILE: Source/Tests/Data/Expected/PassThrough_PS.310.essl
================================================
#version 310 es
precision mediump float;
precision highp int;

layout(location = 0) in highp vec4 in_var_COLOR;
layout(location = 0) out highp vec4 out_var_SV_Target;

void main()
{
    out_var_SV_Target = in_var_COLOR;
}



================================================
FILE: Source/Tests/Data/Expected/PassThrough_PS.40.hlsl
================================================
static float4 in_var_COLOR;
static float4 out_var_SV_Target;

struct SPIRV_Cross_Input
{
    float4 in_var_COLOR : TEXCOORD0;
};

struct SPIRV_Cross_Output
{
    float4 out_var_SV_Target : SV_Target0;
};

void frag_main()
{
    out_var_SV_Target = in_var_COLOR;
}

SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
    in_var_COLOR = stage_input.in_var_COLOR;
    frag_main();
    SPIRV_Cross_Output stage_output;
    stage_output.out_var_SV_Target = out_var_SV_Target;
    return stage_output;
}


================================================
FILE: Source/Tests/Data/Expected/PassThrough_PS.410.glsl
================================================
#version 410

layout(location = 0) in vec4 in_var_COLOR;
layout(location = 0) out vec4 out_var_SV_Target;

void main()
{
    out_var_SV_Target = in_var_COLOR;
}



================================================
FILE: Source/Tests/Data/Expected/PassThrough_PS.50.hlsl
================================================
static float4 in_var_COLOR;
static float4 out_var_SV_Target;

struct SPIRV_Cross_Input
{
    float4 in_var_COLOR : TEXCOORD0;
};

struct SPIRV_Cross_Output
{
    float4 out_var_SV_Target : SV_Target0;
};

void frag_main()
{
    out_var_SV_Target = in_var_COLOR;
}

SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
    in_var_COLOR = stage_input.in_var_COLOR;
    frag_main();
    SPIRV_Cross_Output stage_output;
    stage_output.out_var_SV_Target = out_var_SV_Target;
    return stage_output;
}


================================================
FILE: Source/Tests/Data/Expected/PassThrough_PS.msl
================================================
#include <metal_stdlib>
#include <simd/simd.h>

using namespace metal;

struct PSMain_out
{
    float4 out_var_SV_Target [[color(0)]];
};

struct PSMain_in
{
    float4 in_var_COLOR [[user(locn0)]];
};

fragment PSMain_out PSMain(PSMain_in in [[stage_in]])
{
    PSMain_out out = {};
    out.out_var_SV_Target = in.in_var_COLOR;
    return out;
}



================================================
FILE: Source/Tests/Data/Expected/PassThrough_VS.30.hlsl
================================================
uniform float4 gl_HalfPixel;

static float4 gl_Position;
static float4 in_var_POSITION;
static float2 in_var_TEXCOORD0;
static float2 out_var_TEXCOORD0;

struct SPIRV_Cross_Input
{
    float4 in_var_POSITION : TEXCOORD0;
    float2 in_var_TEXCOORD0 : TEXCOORD1;
};

struct SPIRV_Cross_Output
{
    float2 out_var_TEXCOORD0 : TEXCOORD0;
    float4 gl_Position : POSITION;
};

void vert_main()
{
    out_var_TEXCOORD0 = in_var_TEXCOORD0;
    gl_Position = in_var_POSITION;
    gl_Position.x = gl_Position.x - gl_HalfPixel.x * gl_Position.w;
    gl_Position.y = gl_Position.y + gl_HalfPixel.y * gl_Position.w;
}

SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
    in_var_POSITION = stage_input.in_var_POSITION;
    in_var_TEXCOORD0 = stage_input.in_var_TEXCOORD0;
    vert_main();
    SPIRV_Cross_Output stage_output;
    stage_output.gl_Position = gl_Position;
    stage_output.out_var_TEXCOORD0 = out_var_TEXCOORD0;
    return stage_output;
}


================================================
FILE: Source/Tests/Data/Expected/PassThrough_VS.300.essl
================================================
#version 300 es

layout(location = 0) in vec4 in_var_POSITION;
layout(location = 1) in vec2 in_var_TEXCOORD0;
out vec2 varying_TEXCOORD0;

void main()
{
    varying_TEXCOORD0 = in_var_TEXCOORD0;
    gl_Position = in_var_POSITION;
}



================================================
FILE: Source/Tests/Data/Expected/PassThrough_VS.300.glsl
================================================
#version 300
#extension GL_ARB_separate_shader_objects : require

out gl_PerVertex
{
    vec4 gl_Position;
};

in vec4 in_var_POSITION;
in vec2 in_var_TEXCOORD0;
layout(location = 0) out vec2 varying_TEXCOORD0;

void main()
{
    varying_TEXCOORD0 = in_var_TEXCOORD0;
    gl_Position = in_var_POSITION;
}



================================================
FILE: Source/Tests/Data/Expected/PassThrough_VS.310.essl
================================================
#version 310 es

layout(location = 0) in vec4 in_var_POSITION;
layout(location = 1) in vec2 in_var_TEXCOORD0;
layout(location = 0) out vec2 out_var_TEXCOORD0;

void main()
{
    out_var_TEXCOORD0 = in_var_TEXCOORD0;
    gl_Position = in_var_POSITION;
}



================================================
FILE: Source/Tests/Data/Expected/PassThrough_VS.40.hlsl
================================================
static float4 gl_Position;
static float4 in_var_POSITION;
static float2 in_var_TEXCOORD0;
static float2 out_var_TEXCOORD0;

struct SPIRV_Cross_Input
{
    float4 in_var_POSITION : TEXCOORD0;
    float2 in_var_TEXCOORD0 : TEXCOORD1;
};

struct SPIRV_Cross_Output
{
    float2 out_var_TEXCOORD0 : TEXCOORD0;
    float4 gl_Position : SV_Position;
};

void vert_main()
{
    out_var_TEXCOORD0 = in_var_TEXCOORD0;
    gl_Position = in_var_POSITION;
}

SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
    in_var_POSITION = stage_input.in_var_POSITION;
    in_var_TEXCOORD0 = stage_input.in_var_TEXCOORD0;
    vert_main();
    SPIRV_Cross_Output stage_output;
    stage_output.gl_Position = gl_Position;
    stage_output.out_var_TEXCOORD0 = out_var_TEXCOORD0;
    return stage_output;
}


================================================
FILE: Source/Tests/Data/Expected/PassThrough_VS.410.glsl
================================================
#version 410

out gl_PerVertex
{
    vec4 gl_Position;
};

layout(location = 0) in vec4 in_var_POSITION;
layout(location = 1) in vec2 in_var_TEXCOORD0;
layout(location = 0) out vec2 out_var_TEXCOORD0;

void main()
{
    out_var_TEXCOORD0 = in_var_TEXCOORD0;
    gl_Position = in_var_POSITION;
}



================================================
FILE: Source/Tests/Data/Expected/PassThrough_VS.50.hlsl
================================================
static float4 gl_Position;
static float4 in_var_POSITION;
static float2 in_var_TEXCOORD0;
static float2 out_var_TEXCOORD0;

struct SPIRV_Cross_Input
{
    float4 in_var_POSITION : TEXCOORD0;
    float2 in_var_TEXCOORD0 : TEXCOORD1;
};

struct SPIRV_Cross_Output
{
    float2 out_var_TEXCOORD0 : TEXCOORD0;
    float4 gl_Position : SV_Position;
};

void vert_main()
{
    out_var_TEXCOORD0 = in_var_TEXCOORD0;
    gl_Position = in_var_POSITION;
}

SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
    in_var_POSITION = stage_input.in_var_POSITION;
    in_var_TEXCOORD0 = stage_input.in_var_TEXCOORD0;
    vert_main();
    SPIRV_Cross_Output stage_output;
    stage_output.gl_Position = gl_Position;
    stage_output.out_var_TEXCOORD0 = out_var_TEXCOORD0;
    return stage_output;
}


================================================
FILE: Source/Tests/Data/Expected/PassThrough_VS.msl
================================================
#include <metal_stdlib>
#include <simd/simd.h>

using namespace metal;

struct VSMain_out
{
    float2 out_var_TEXCOORD0 [[user(locn0)]];
    float4 gl_Position [[position]];
};

struct VSMain_in
{
    float4 in_var_POSITION [[attribute(0)]];
    float2 in_var_TEXCOORD0 [[attribute(1)]];
};

vertex VSMain_out VSMain(VSMain_in in [[stage_in]])
{
    VSMain_out out = {};
    out.out_var_TEXCOORD0 = in.in_var_TEXCOORD0;
    out.gl_Position = in.in_var_POSITION;
    return out;
}



================================================
FILE: Source/Tests/Data/Expected/ToneMapping_PS.30.hlsl
================================================
cbuffer type_cbPS : register(b0)
{
    float cbPS_lumStrength : packoffset(c0);
};

uniform sampler2D SPIRV_Cross_CombinedcolorTexpointSampler;
uniform sampler2D SPIRV_Cross_CombinedbloomTexlinearSampler;
uniform sampler2D SPIRV_Cross_CombinedlumTexpointSampler;

static float2 in_var_TEXCOORD0;
static float4 out_var_SV_Target;

struct SPIRV_Cross_Input
{
    float2 in_var_TEXCOORD0 : TEXCOORD0;
};

struct SPIRV_Cross_Output
{
    float4 out_var_SV_Target : COLOR0;
};

void frag_main()
{
    float4 _45 = tex2D(SPIRV_Cross_CombinedcolorTexpointSampler, in_var_TEXCOORD0);
    float3 _62 = (_45.xyz * (0.7200000286102294921875f / ((tex2D(SPIRV_Cross_CombinedlumTexpointSampler, 0.5f.xx).x * cbPS_lumStrength) + 0.001000000047497451305389404296875f))).xyz;
    float3 _66 = (_62 * (1.0f.xxx + (_62 * 0.666666686534881591796875f.xxx))).xyz;
    float3 _71 = (_66 / (1.0f.xxx + _66)).xyz + (tex2D(SPIRV_Cross_CombinedbloomTexlinearSampler, in_var_TEXCOORD0).xyz * 0.60000002384185791015625f);
    float4 _73 = float4(_71.x, _71.y, _71.z, _45.w);
    _73.w = 1.0f;
    out_var_SV_Target = _73;
}

SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
    in_var_TEXCOORD0 = stage_input.in_var_TEXCOORD0;
    frag_main();
    SPIRV_Cross_Output stage_output;
    stage_output.out_var_SV_Target = float4(out_var_SV_Target);
    return stage_output;
}


================================================
FILE: Source/Tests/Data/Expected/ToneMapping_PS.300.essl
================================================
#version 300 es
precision mediump float;
precision highp int;

layout(std140) uniform type_cbPS
{
    highp float lumStrength;
} cbPS;

uniform highp sampler2D SPIRV_Cross_CombinedcolorTexpointSampler;
uniform highp sampler2D SPIRV_Cross_CombinedbloomTexlinearSampler;
uniform highp sampler2D SPIRV_Cross_CombinedlumTexpointSampler;

in highp vec2 varying_TEXCOORD0;
layout(location = 0) out highp vec4 out_var_SV_Target;

void main()
{
    highp vec4 _45 = texture(SPIRV_Cross_CombinedcolorTexpointSampler, varying_TEXCOORD0);
    highp vec3 _62 = (_45.xyz * (0.7200000286102294921875 / ((texture(SPIRV_Cross_CombinedlumTexpointSampler, vec2(0.5)).x * cbPS.lumStrength) + 0.001000000047497451305389404296875))).xyz;
    highp vec3 _66 = (_62 * (vec3(1.0) + (_62 * vec3(0.666666686534881591796875)))).xyz;
    highp vec3 _71 = (_66 / (vec3(1.0) + _66)).xyz + (texture(SPIRV_Cross_CombinedbloomTexlinearSampler, varying_TEXCOORD0).xyz * 0.60000002384185791015625);
    highp vec4 _73 = vec4(_71.x, _71.y, _71.z, _45.w);
    _73.w = 1.0;
    out_var_SV_Target = _73;
}



================================================
FILE: Source/Tests/Data/Expected/ToneMapping_PS.300.glsl
================================================
#version 300
#extension GL_ARB_separate_shader_objects : require

layout(std140) uniform type_cbPS
{
    float lumStrength;
} cbPS;

uniform sampler2D SPIRV_Cross_CombinedcolorTexpointSampler;
uniform sampler2D SPIRV_Cross_CombinedbloomTexlinearSampler;
uniform sampler2D SPIRV_Cross_CombinedlumTexpointSampler;

layout(location = 0) in vec2 varying_TEXCOORD0;
out vec4 out_var_SV_Target;

void main()
{
    vec4 _45 = texture(SPIRV_Cross_CombinedcolorTexpointSampler, varying_TEXCOORD0);
    vec3 _62 = (_45.xyz * (0.7200000286102294921875 / ((texture(SPIRV_Cross_CombinedlumTexpointSampler, vec2(0.5)).x * cbPS.lumStrength) + 0.001000000047497451305389404296875))).xyz;
    vec3 _66 = (_62 * (vec3(1.0) + (_62 * vec3(0.666666686534881591796875)))).xyz;
    vec3 _71 = (_66 / (vec3(1.0) + _66)).xyz + (texture(SPIRV_Cross_CombinedbloomTexlinearSampler, varying_TEXCOORD0).xyz * 0.60000002384185791015625);
    vec4 _73 = vec4(_71.x, _71.y, _71.z, _45.w);
    _73.w = 1.0;
    out_var_SV_Target = _73;
}



================================================
FILE: Source/Tests/Data/Expected/ToneMapping_PS.310.essl
================================================
#version 310 es
precision mediump float;
precision highp int;

layout(binding = 0, std140) uniform type_cbPS
{
    highp float lumStrength;
} cbPS;

uniform highp sampler2D SPIRV_Cross_CombinedcolorTexpointSampler;
uniform highp sampler2D SPIRV_Cross_CombinedbloomTexlinearSampler;
uniform highp sampler2D SPIRV_Cross_CombinedlumTexpointSampler;

layout(location = 0) in highp vec2 in_var_TEXCOORD0;
layout(location = 0) out highp vec4 out_var_SV_Target;

void main()
{
    highp vec4 _45 = texture(SPIRV_Cross_CombinedcolorTexpointSampler, in_var_TEXCOORD0);
    highp vec3 _62 = (_45.xyz * (0.7200000286102294921875 / ((texture(SPIRV_Cross_CombinedlumTexpointSampler, vec2(0.5)).x * cbPS.lumStrength) + 0.001000000047497451305389404296875))).xyz;
    highp vec3 _66 = (_62 * (vec3(1.0) + (_62 * vec3(0.666666686534881591796875)))).xyz;
    highp vec3 _71 = (_66 / (vec3(1.0) + _66)).xyz + (texture(SPIRV_Cross_CombinedbloomTexlinearSampler, in_var_TEXCOORD0).xyz * 0.60000002384185791015625);
    highp vec4 _73 = vec4(_71.x, _71.y, _71.z, _45.w);
    _73.w = 1.0;
    out_var_SV_Target = _73;
}



================================================
FILE: Source/Tests/Data/Expected/ToneMapping_PS.40.hlsl
================================================
cbuffer type_cbPS : register(b0)
{
    float cbPS_lumStrength : packoffset(c0);
};

SamplerState pointSampler : register(s0);
SamplerState linearSampler : register(s1);
Texture2D<float4> colorTex : register(t0);
Texture2D<float4> lumTex : register(t1);
Texture2D<float4> bloomTex : register(t2);

static float2 in_var_TEXCOORD0;
static float4 out_var_SV_Target;

struct SPIRV_Cross_Input
{
    float2 in_var_TEXCOORD0 : TEXCOORD0;
};

struct SPIRV_Cross_Output
{
    float4 out_var_SV_Target : SV_Target0;
};

void frag_main()
{
    float4 _45 = colorTex.Sample(pointSampler, in_var_TEXCOORD0);
    float3 _62 = (_45.xyz * (0.7200000286102294921875f / ((lumTex.Sample(pointSampler, 0.5f.xx).x * cbPS_lumStrength) + 0.001000000047497451305389404296875f))).xyz;
    float3 _66 = (_62 * (1.0f.xxx + (_62 * 0.666666686534881591796875f.xxx))).xyz;
    float3 _71 = (_66 / (1.0f.xxx + _66)).xyz + (bloomTex.Sample(linearSampler, in_var_TEXCOORD0).xyz * 0.60000002384185791015625f);
    float4 _73 = float4(_71.x, _71.y, _71.z, _45.w);
    _73.w = 1.0f;
    out_var_SV_Target = _73;
}

SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
    in_var_TEXCOORD0 = stage_input.in_var_TEXCOORD0;
    frag_main();
    SPIRV_Cross_Output stage_output;
    stage_output.out_var_SV_Target = out_var_SV_Target;
    return stage_output;
}


================================================
FILE: Source/Tests/Data/Expected/ToneMapping_PS.410.glsl
================================================
#version 410

layout(std140) uniform type_cbPS
{
    float lumStrength;
} cbPS;

uniform sampler2D SPIRV_Cross_CombinedcolorTexpointSampler;
uniform sampler2D SPIRV_Cross_CombinedbloomTexlinearSampler;
uniform sampler2D SPIRV_Cross_CombinedlumTexpointSampler;

layout(location = 0) in vec2 in_var_TEXCOORD0;
layout(location = 0) out vec4 out_var_SV_Target;

void main()
{
    vec4 _45 = texture(SPIRV_Cross_CombinedcolorTexpointSampler, in_var_TEXCOORD0);
    vec3 _62 = (_45.xyz * (0.7200000286102294921875 / ((texture(SPIRV_Cross_CombinedlumTexpointSampler, vec2(0.5)).x * cbPS.lumStrength) + 0.001000000047497451305389404296875))).xyz;
    vec3 _66 = (_62 * (vec3(1.0) + (_62 * vec3(0.666666686534881591796875)))).xyz;
    vec3 _71 = (_66 / (vec3(1.0) + _66)).xyz + (texture(SPIRV_Cross_CombinedbloomTexlinearSampler, in_var_TEXCOORD0).xyz * 0.60000002384185791015625);
    vec4 _73 = vec4(_71.x, _71.y, _71.z, _45.w);
    _73.w = 1.0;
    out_var_SV_Target = _73;
}



================================================
FILE: Source/Tests/Data/Expected/ToneMapping_PS.50.hlsl
================================================
cbuffer type_cbPS : register(b0)
{
    float cbPS_lumStrength : packoffset(c0);
};

SamplerState pointSampler : register(s0);
SamplerState linearSampler : register(s1);
Texture2D<float4> colorTex : register(t0);
Texture2D<float4> lumTex : register(t1);
Texture2D<float4> bloomTex : register(t2);

static float2 in_var_TEXCOORD0;
static float4 out_var_SV_Target;

struct SPIRV_Cross_Input
{
    float2 in_var_TEXCOORD0 : TEXCOORD0;
};

struct SPIRV_Cross_Output
{
    float4 out_var_SV_Target : SV_Target0;
};

void frag_main()
{
    float4 _45 = colorTex.Sample(pointSampler, in_var_TEXCOORD0);
    float3 _62 = (_45.xyz * (0.7200000286102294921875f / ((lumTex.Sample(pointSampler, 0.5f.xx).x * cbPS_lumStrength) + 0.001000000047497451305389404296875f))).xyz;
    float3 _66 = (_62 * (1.0f.xxx + (_62 * 0.666666686534881591796875f.xxx))).xyz;
    float3 _71 = (_66 / (1.0f.xxx + _66)).xyz + (bloomTex.Sample(linearSampler, in_var_TEXCOORD0).xyz * 0.60000002384185791015625f);
    float4 _73 = float4(_71.x, _71.y, _71.z, _45.w);
    _73.w = 1.0f;
    out_var_SV_Target = _73;
}

SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
    in_var_TEXCOORD0 = stage_input.in_var_TEXCOORD0;
    frag_main();
    SPIRV_Cross_Output stage_output;
    stage_output.out_var_SV_Target = out_var_SV_Target;
    return stage_output;
}


================================================
FILE: Source/Tests/Data/Expected/ToneMapping_PS.msl
================================================
#include <metal_stdlib>
#include <simd/simd.h>

using namespace metal;

struct type_cbPS
{
    float lumStrength;
};

struct main0_out
{
    float4 out_var_SV_Target [[color(0)]];
};

struct main0_in
{
    float2 in_var_TEXCOORD0 [[user(locn0)]];
};

fragment 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)]])
{
    main0_out out = {};
    float4 _45 = colorTex.sample(pointSampler, in.in_var_TEXCOORD0);
    float3 _62 = (_45.xyz * (0.7200000286102294921875 / ((lumTex.sample(pointSampler, float2(0.5)).x * cbPS.lumStrength) + 0.001000000047497451305389404296875))).xyz;
    float3 _66 = (_62 * (float3(1.0) + (_62 * float3(0.666666686534881591796875)))).xyz;
    float3 _71 = (_66 / (float3(1.0) + _66)).xyz + (bloomTex.sample(linearSampler, in.in_var_TEXCOORD0).xyz * 0.60000002384185791015625);
    float4 _73 = float4(_71.x, _71.y, _71.z, _45.w);
    _73.w = 1.0;
    out.out_var_SV_Target = _73;
    return out;
}



================================================
FILE: Source/Tests/Data/Expected/Transform_VS.30.hlsl
================================================
cbuffer type_cbVS : register(b0)
{
    row_major float4x4 cbVS_wvp : packoffset(c0);
};

uniform float4 gl_HalfPixel;

static float4 gl_Position;
static float4 in_var_POSITION;

struct SPIRV_Cross_Input
{
    float4 in_var_POSITION : TEXCOORD0;
};

struct SPIRV_Cross_Output
{
    float4 gl_Position : POSITION;
};

void vert_main()
{
    gl_Position = mul(in_var_POSITION, cbVS_wvp);
    gl_Position.x = gl_Position.x - gl_HalfPixel.x * gl_Position.w;
    gl_Position.y = gl_Position.y + gl_HalfPixel.y * gl_Position.w;
}

SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
    in_var_POSITION = stage_input.in_var_POSITION;
    vert_main();
    SPIRV_Cross_Output stage_output;
    stage_output.gl_Position = gl_Position;
    return stage_output;
}


================================================
FILE: Source/Tests/Data/Expected/Transform_VS.300.essl
================================================
#version 300 es

layout(std140) uniform type_cbVS
{
    mat4 wvp;
} cbVS;

layout(location = 0) in vec4 in_var_POSITION;

void main()
{
    gl_Position = cbVS.wvp * in_var_POSITION;
}



================================================
FILE: Source/Tests/Data/Expected/Transform_VS.300.glsl
================================================
#version 300
#extension GL_ARB_separate_shader_objects : require

out gl_PerVertex
{
    vec4 gl_Position;
};

layout(std140) uniform type_cbVS
{
    mat4 wvp;
} cbVS;

in vec4 in_var_POSITION;

void main()
{
    gl_Position = cbVS.wvp * in_var_POSITION;
}



================================================
FILE: Source/Tests/Data/Expected/Transform_VS.310.essl
================================================
#version 310 es

layout(binding = 0, std140) uniform type_cbVS
{
    mat4 wvp;
} cbVS;

layout(location = 0) in vec4 in_var_POSITION;

void main()
{
    gl_Position = cbVS.wvp * in_var_POSITION;
}



================================================
FILE: Source/Tests/Data/Expected/Transform_VS.40.hlsl
================================================
cbuffer type_cbVS : register(b0)
{
    row_major float4x4 cbVS_wvp : packoffset(c0);
};


static float4 gl_Position;
static float4 in_var_POSITION;

struct SPIRV_Cross_Input
{
    float4 in_var_POSITION : TEXCOORD0;
};

struct SPIRV_Cross_Output
{
    float4 gl_Position : SV_Position;
};

void vert_main()
{
    gl_Position = mul(in_var_POSITION, cbVS_wvp);
}

SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
    in_var_POSITION = stage_input.in_var_POSITION;
    vert_main();
    SPIRV_Cross_Output stage_output;
    stage_output.gl_Position = gl_Position;
    return stage_output;
}


================================================
FILE: Source/Tests/Data/Expected/Transform_VS.410.glsl
================================================
#version 410

out gl_PerVertex
{
    vec4 gl_Position;
};

layout(std140) uniform type_cbVS
{
    mat4 wvp;
} cbVS;

layout(location = 0) in vec4 in_var_POSITION;

void main()
{
    gl_Position = cbVS.wvp * in_var_POSITION;
}



================================================
FILE: Source/Tests/Data/Expected/Transform_VS.50.hlsl
================================================
cbuffer type_cbVS : register(b0)
{
    row_major float4x4 cbVS_wvp : packoffset(c0);
};


static float4 gl_Position;
static float4 in_var_POSITION;

struct SPIRV_Cross_Input
{
    float4 in_var_POSITION : TEXCOORD0;
};

struct SPIRV_Cross_Output
{
    float4 gl_Position : SV_Position;
};

void vert_main()
{
    gl_Position = mul(in_var_POSITION, cbVS_wvp);
}

SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
    in_var_POSITION = stage_input.in_var_POSITION;
    vert_main();
    SPIRV_Cross_Output stage_output;
    stage_output.gl_Position = gl_Position;
    return stage_output;
}


================================================
FILE: Source/Tests/Data/Expected/Transform_VS.msl
================================================
#include <metal_stdlib>
#include <simd/simd.h>

using namespace metal;

struct type_cbVS
{
    float4x4 wvp;
};

struct main0_out
{
    float4 gl_Position [[position]];
};

struct main0_in
{
    float4 in_var_POSITION [[attribute(0)]];
};

vertex main0_out main0(main0_in in [[stage_in]], constant type_cbVS& cbVS [[buffer(0)]])
{
    main0_out out = {};
    out.gl_Position = cbVS.wvp * in.in_var_POSITION;
    return out;
}



================================================
FILE: Source/Tests/Data/Expected/Transform_VS_ColumnMajor.300.glsl
=========================
Download .txt
gitextract_2m09pj0m/

├── .clang-format
├── .gitattributes
├── .github/
│   └── ISSUE_TEMPLATE/
│       ├── bug_report.md
│       └── feature_request.md
├── .gitignore
├── BuildAll.py
├── CI/
│   └── AzurePipelines/
│       └── ContinuousBuild.yml
├── CMakeLists.txt
├── CONTRIBUTING.md
├── Include/
│   └── ShaderConductor/
│       └── ShaderConductor.hpp
├── LICENSE
├── README.md
├── SECURITY.md
├── Source/
│   ├── CMakeLists.txt
│   ├── Core/
│   │   ├── CMakeLists.txt
│   │   └── ShaderConductor.cpp
│   ├── Tests/
│   │   ├── CMakeLists.txt
│   │   ├── Data/
│   │   │   ├── Expected/
│   │   │   │   ├── CalcLight+Diffuse.Debug.dxilasm
│   │   │   │   ├── CalcLight+Diffuse.Release.dxilasm
│   │   │   │   ├── CalcLight+DiffuseSpecular.Debug.dxilasm
│   │   │   │   ├── CalcLight+DiffuseSpecular.Release.dxilasm
│   │   │   │   ├── Constant_PS.30.hlsl
│   │   │   │   ├── Constant_PS.300.essl
│   │   │   │   ├── Constant_PS.300.glsl
│   │   │   │   ├── Constant_PS.310.essl
│   │   │   │   ├── Constant_PS.40.hlsl
│   │   │   │   ├── Constant_PS.410.glsl
│   │   │   │   ├── Constant_PS.50.hlsl
│   │   │   │   ├── Constant_PS.msl
│   │   │   │   ├── Constant_VS.30.hlsl
│   │   │   │   ├── Constant_VS.300.essl
│   │   │   │   ├── Constant_VS.300.glsl
│   │   │   │   ├── Constant_VS.310.essl
│   │   │   │   ├── Constant_VS.40.hlsl
│   │   │   │   ├── Constant_VS.410.glsl
│   │   │   │   ├── Constant_VS.50.hlsl
│   │   │   │   ├── Constant_VS.msl
│   │   │   │   ├── DetailTessellation_HS.300.essl
│   │   │   │   ├── DetailTessellation_HS.300.glsl
│   │   │   │   ├── DetailTessellation_HS.310.essl
│   │   │   │   ├── DetailTessellation_HS.410.glsl
│   │   │   │   ├── DetailTessellation_HS.msl
│   │   │   │   ├── DotHalfPS.glsl
│   │   │   │   ├── Fluid_CS.300.glsl
│   │   │   │   ├── Fluid_CS.310.essl
│   │   │   │   ├── Fluid_CS.410.glsl
│   │   │   │   ├── Fluid_CS.50.hlsl
│   │   │   │   ├── Fluid_CS.msl
│   │   │   │   ├── HalfOutParamPS.glsl
│   │   │   │   ├── IncludeEmptyHeader.glsl
│   │   │   │   ├── IncludeExist.glsl
│   │   │   │   ├── PNTriangles_DS.300.essl
│   │   │   │   ├── PNTriangles_DS.300.glsl
│   │   │   │   ├── PNTriangles_DS.310.essl
│   │   │   │   ├── PNTriangles_DS.410.glsl
│   │   │   │   ├── PNTriangles_DS.msl
│   │   │   │   ├── Particle_GS.300.essl
│   │   │   │   ├── Particle_GS.300.glsl
│   │   │   │   ├── Particle_GS.310.essl
│   │   │   │   ├── Particle_GS.410.glsl
│   │   │   │   ├── PassThrough_PS.30.hlsl
│   │   │   │   ├── PassThrough_PS.300.essl
│   │   │   │   ├── PassThrough_PS.300.glsl
│   │   │   │   ├── PassThrough_PS.310.essl
│   │   │   │   ├── PassThrough_PS.40.hlsl
│   │   │   │   ├── PassThrough_PS.410.glsl
│   │   │   │   ├── PassThrough_PS.50.hlsl
│   │   │   │   ├── PassThrough_PS.msl
│   │   │   │   ├── PassThrough_VS.30.hlsl
│   │   │   │   ├── PassThrough_VS.300.essl
│   │   │   │   ├── PassThrough_VS.300.glsl
│   │   │   │   ├── PassThrough_VS.310.essl
│   │   │   │   ├── PassThrough_VS.40.hlsl
│   │   │   │   ├── PassThrough_VS.410.glsl
│   │   │   │   ├── PassThrough_VS.50.hlsl
│   │   │   │   ├── PassThrough_VS.msl
│   │   │   │   ├── ToneMapping_PS.30.hlsl
│   │   │   │   ├── ToneMapping_PS.300.essl
│   │   │   │   ├── ToneMapping_PS.300.glsl
│   │   │   │   ├── ToneMapping_PS.310.essl
│   │   │   │   ├── ToneMapping_PS.40.hlsl
│   │   │   │   ├── ToneMapping_PS.410.glsl
│   │   │   │   ├── ToneMapping_PS.50.hlsl
│   │   │   │   ├── ToneMapping_PS.msl
│   │   │   │   ├── Transform_VS.30.hlsl
│   │   │   │   ├── Transform_VS.300.essl
│   │   │   │   ├── Transform_VS.300.glsl
│   │   │   │   ├── Transform_VS.310.essl
│   │   │   │   ├── Transform_VS.40.hlsl
│   │   │   │   ├── Transform_VS.410.glsl
│   │   │   │   ├── Transform_VS.50.hlsl
│   │   │   │   ├── Transform_VS.msl
│   │   │   │   └── Transform_VS_ColumnMajor.300.glsl
│   │   │   └── Input/
│   │   │       ├── CalcLight.hlsl
│   │   │       ├── CalcLightDiffuse.hlsl
│   │   │       ├── CalcLightDiffuseSpecular.hlsl
│   │   │       ├── Common.hlsli
│   │   │       ├── Constant_PS.hlsl
│   │   │       ├── Constant_VS.hlsl
│   │   │       ├── DetailTessellation_HS.hlsl
│   │   │       ├── Fluid_CS.hlsl
│   │   │       ├── HalfDataType.hlsl
│   │   │       ├── Inc/
│   │   │       │   ├── HeaderA.hlsli
│   │   │       │   ├── HeaderB.hlsli
│   │   │       │   └── HeaderEmpty.hlsli
│   │   │       ├── IncludeEmptyHeader.hlsl
│   │   │       ├── IncludeExist.hlsl
│   │   │       ├── IncludeNotExist.hlsl
│   │   │       ├── PNTriangles_DS.hlsl
│   │   │       ├── Particle_GS.hlsl
│   │   │       ├── PassThrough_PS.hlsl
│   │   │       ├── PassThrough_VS.hlsl
│   │   │       ├── ToneMapping_PS.hlsl
│   │   │       └── Transform_VS.hlsl
│   │   └── ShaderConductorTest.cpp
│   ├── Tools/
│   │   ├── CMakeLists.txt
│   │   └── ShaderConductorCmd.cpp
│   └── Wrapper/
│       ├── CMakeLists.txt
│       ├── Native.cpp
│       ├── Native.h
│       ├── Program.cs
│       ├── Wrapper.cs
│       └── shader.hlsl
└── azure-pipelines.yml
Download .txt
SYMBOL INDEX (136 symbols across 9 files)

FILE: BuildAll.py
  function LogError (line 10) | def LogError(message):
  function LogInfo (line 20) | def LogInfo(message):
  function LogWarning (line 24) | def LogWarning(message):
  function FindProgramFilesFolder (line 28) | def FindProgramFilesFolder():
  function FindVS2017OrUpFolder (line 42) | def FindVS2017OrUpFolder(programFilesFolder, vsVersion, vsName):
  function FindVS2019Folder (line 67) | def FindVS2019Folder(programFilesFolder):
  function FindVS2017Folder (line 70) | def FindVS2017Folder(programFilesFolder):
  function FindVS2015Folder (line 73) | def FindVS2015Folder(programFilesFolder):
  class BatchCommand (line 85) | class BatchCommand:
    method __init__ (line 86) | def __init__(self, hostPlatform):
    method AddCommand (line 90) | def AddCommand(self, cmd):
    method Execute (line 93) | def Execute(self):
  function Build (line 110) | def Build(hostPlatform, hostArch, buildSys, compiler, arch, configuratio...

FILE: Include/ShaderConductor/ShaderConductor.hpp
  type ShaderConductor (line 55) | namespace ShaderConductor
    type ShaderStage (line 57) | enum class ShaderStage : uint32_t
    type ShadingLanguage (line 69) | enum class ShadingLanguage : uint32_t
    type ShaderResourceType (line 83) | enum class ShaderResourceType : uint32_t
    type MacroDefine (line 95) | struct MacroDefine
    function Blob (line 101) | class SC_API Blob
    function Compiler (line 124) | class SC_API Compiler

FILE: Source/Core/ShaderConductor.cpp
  class Dxcompiler (line 63) | class Dxcompiler
    method Dxcompiler (line 71) | static Dxcompiler& Instance()
    method IDxcLibrary (line 77) | IDxcLibrary* Library() const
    method IDxcCompiler (line 82) | IDxcCompiler* Compiler() const
    method IDxcContainerReflection (line 87) | IDxcContainerReflection* ContainerReflection() const
    method CreateLinker (line 92) | CComPtr<IDxcLinker> CreateLinker() const
    method LinkerSupport (line 99) | bool LinkerSupport() const
    method Destroy (line 104) | void Destroy()
    method Terminate (line 124) | void Terminate()
    method Dxcompiler (line 139) | Dxcompiler()
  class ScIncludeHandler (line 202) | class ScIncludeHandler : public IDxcIncludeHandler
    method ScIncludeHandler (line 205) | explicit ScIncludeHandler(std::function<Blob(const char* includeName)>...
    method LoadSource (line 209) | LoadSource(LPCWSTR fileName, IDxcBlob** includeSource) override
    method AddRef (line 237) | AddRef() override
    method Release (line 243) | Release() override
    method QueryInterface (line 254) | QueryInterface(REFIID iid, void** object) override
  function Blob (line 280) | Blob DefaultLoadCallback(const char* includeName)
  function AppendError (line 299) | void AppendError(Compiler::ResultDesc& result, const std::string& msg)
  function HRESULT (line 317) | HRESULT CreateDxcReflectionFromBlob(IDxcBlob* dxilBlob, CComPtr<T>& outR...
  function ShaderReflection (line 329) | void ShaderReflection(Compiler::ReflectionResultDesc& result, IDxcBlob* ...
  function ShaderProfileName (line 427) | std::wstring ShaderProfileName(ShaderStage stage, Compiler::ShaderModel ...
  function ConvertDxcResult (line 468) | void ConvertDxcResult(Compiler::ResultDesc& result, IDxcOperationResult*...
  function CompileToBinary (line 509) | Compiler::ResultDesc CompileToBinary(const Compiler::SourceDesc& source,...
  function CrossCompile (line 683) | Compiler::ResultDesc CrossCompile(const Compiler::ResultDesc& binaryResu...
  function ConvertBinary (line 945) | Compiler::ResultDesc ConvertBinary(const Compiler::ResultDesc& binaryRes...
  type ShaderConductor (line 982) | namespace ShaderConductor
    class Blob::BlobImpl (line 984) | class Blob::BlobImpl
      method BlobImpl (line 987) | BlobImpl(const void* data, uint32_t size) noexcept
      method Size (line 997) | uint32_t Size() const noexcept
    function Blob (line 1028) | Blob& Blob::operator=(const Blob& other)
    function Blob (line 1037) | Blob& Blob::operator=(Blob&& other) noexcept
  function BOOL (line 1258) | BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)

FILE: Source/Tests/ShaderConductorTest.cpp
  function LoadFile (line 40) | std::vector<uint8_t> LoadFile(const std::string& name, bool isText)
  function CompareWithExpected (line 60) | void CompareWithExpected(const std::vector<uint8_t>& actual, bool isText...
  function HlslToAnyTest (line 80) | void HlslToAnyTest(const std::string& name, const Compiler::SourceDesc& ...
  function CompileToModule (line 116) | Compiler::ModuleDesc CompileToModule(const char* moduleName, const std::...
  class TestBase (line 129) | class TestBase : public testing::Test
    method TestBase (line 132) | TestBase()
    method SetUp (line 137) | void SetUp() override
    method RunTests (line 153) | void RunTests(ShadingLanguage targetSl, const Compiler::Options& optio...
  class VertexShaderTest (line 196) | class VertexShaderTest : public TestBase
    method SetUp (line 199) | void SetUp() override
  class PixelShaderTest (line 229) | class PixelShaderTest : public TestBase
    method SetUp (line 232) | void SetUp() override
  class GeometryShaderTest (line 262) | class GeometryShaderTest : public TestBase
    method SetUp (line 265) | void SetUp() override
  class HullShaderTest (line 291) | class HullShaderTest : public TestBase
    method SetUp (line 294) | void SetUp() override
  class DomainShaderTest (line 316) | class DomainShaderTest : public TestBase
    method SetUp (line 319) | void SetUp() override
  class ComputeShaderTest (line 341) | class ComputeShaderTest : public TestBase
    method SetUp (line 344) | void SetUp() override
  function TEST_F (line 367) | TEST_F(VertexShaderTest, ToHlsl)
  function TEST_F (line 372) | TEST_F(VertexShaderTest, ToGlsl)
  function TEST_F (line 377) | TEST_F(VertexShaderTest, ToGlslColumnMajor)
  function TEST_F (line 391) | TEST_F(VertexShaderTest, ToEssl)
  function TEST_F (line 396) | TEST_F(VertexShaderTest, ToMsl)
  function TEST_F (line 402) | TEST_F(PixelShaderTest, ToHlsl)
  function TEST_F (line 407) | TEST_F(PixelShaderTest, ToGlsl)
  function TEST_F (line 412) | TEST_F(PixelShaderTest, ToEssl)
  function TEST_F (line 417) | TEST_F(PixelShaderTest, ToMsl)
  function TEST_F (line 423) | TEST_F(GeometryShaderTest, ToHlsl)
  function TEST_F (line 428) | TEST_F(GeometryShaderTest, ToGlsl)
  function TEST_F (line 433) | TEST_F(GeometryShaderTest, ToEssl)
  function TEST_F (line 438) | TEST_F(GeometryShaderTest, ToMsl)
  function TEST_F (line 444) | TEST_F(HullShaderTest, ToHlsl)
  function TEST_F (line 449) | TEST_F(HullShaderTest, ToGlsl)
  function TEST_F (line 454) | TEST_F(HullShaderTest, ToEssl)
  function TEST_F (line 459) | TEST_F(HullShaderTest, ToMsl)
  function TEST_F (line 465) | TEST_F(DomainShaderTest, ToHlsl)
  function TEST_F (line 470) | TEST_F(DomainShaderTest, ToGlsl)
  function TEST_F (line 475) | TEST_F(DomainShaderTest, ToEssl)
  function TEST_F (line 480) | TEST_F(DomainShaderTest, ToMsl)
  function TEST_F (line 486) | TEST_F(ComputeShaderTest, ToHlsl)
  function TEST_F (line 491) | TEST_F(ComputeShaderTest, ToGlsl)
  function TEST_F (line 496) | TEST_F(ComputeShaderTest, ToEssl)
  function TEST_F (line 501) | TEST_F(ComputeShaderTest, ToMsl)
  function TEST (line 506) | TEST(IncludeTest, IncludeExist)
  function TEST (line 524) | TEST(IncludeTest, IncludeNotExist)
  function TEST (line 539) | TEST(IncludeTest, IncludeEmptyFile)
  function TEST (line 557) | TEST(HalfDataTypeTest, DotHalf)
  function TEST (line 578) | TEST(HalfDataTypeTest, HalfOutParam)
  function TEST (line 599) | TEST(LinkTest, LinkDxil)
  function main (line 646) | int main(int argc, char** argv)

FILE: Source/Tools/ShaderConductorCmd.cpp
  function main (line 42) | int main(int argc, char** argv)

FILE: Source/Wrapper/Native.cpp
  function Compile (line 32) | void Compile(SourceDescription* source, OptionsDescription* optionsDesc,...
  function Disassemble (line 82) | void Disassemble(DisassembleDescription* source, ResultDescription* result)
  function ShaderConductorBlob (line 105) | ShaderConductorBlob* CreateShaderConductorBlob(const void* data, int size)
  function DestroyShaderConductorBlob (line 110) | void DestroyShaderConductorBlob(ShaderConductorBlob* blob)
  function GetShaderConductorBlobSize (line 120) | int GetShaderConductorBlobSize(ShaderConductorBlob* blob)

FILE: Source/Wrapper/Native.h
  type ShaderConductorBlob (line 32) | struct ShaderConductorBlob
  type SourceDescription (line 34) | struct SourceDescription
  type ShaderModel (line 41) | struct ShaderModel
  type OptionsDescription (line 47) | struct OptionsDescription
  type TargetDescription (line 63) | struct TargetDescription
  type ResultDescription (line 69) | struct ResultDescription
  type DisassembleDescription (line 78) | struct DisassembleDescription

FILE: Source/Wrapper/Program.cs
  class Program (line 32) | class Program
    method Main (line 34) | static void Main(string[] args)

FILE: Source/Wrapper/Wrapper.cs
  class Wrapper (line 35) | public class Wrapper
    method Compile (line 37) | [DllImport("ShaderConductorWrapper.dll", CharSet = CharSet.Ansi, Calli...
    method Disassemble (line 40) | [DllImport("ShaderConductorWrapper.dll", CharSet = CharSet.Ansi, Calli...
    method CreateShaderConductorBlob (line 43) | [DllImport("ShaderConductorWrapper.dll", CharSet = CharSet.Ansi, Calli...
    method DestroyShaderConductorBlob (line 46) | [DllImport("ShaderConductorWrapper.dll", CharSet = CharSet.Ansi, Calli...
    method GetShaderConductorBlobData (line 49) | [DllImport("ShaderConductorWrapper.dll", CharSet = CharSet.Ansi, Calli...
    method GetShaderConductorBlobSize (line 52) | [DllImport("ShaderConductorWrapper.dll", CharSet = CharSet.Ansi, Calli...
    type ShaderStage (line 55) | public enum ShaderStage
    type ShadingLanguage (line 67) | public enum ShadingLanguage
    type MacroDefine (line 81) | [StructLayout(LayoutKind.Sequential)]
    type SourceDesc (line 88) | [StructLayout(LayoutKind.Sequential)]
    type ShaderModel (line 96) | [StructLayout(LayoutKind.Sequential)]
      method ShaderModel (line 102) | public ShaderModel(int major, int minor)
    type OptionsDesc (line 109) | [StructLayout(LayoutKind.Sequential)]
    type TargetDesc (line 147) | [StructLayout(LayoutKind.Sequential)]
    type ResultDesc (line 155) | [StructLayout(LayoutKind.Sequential)]
    type DisassembleDesc (line 164) | [StructLayout(LayoutKind.Sequential)]
Condensed preview — 124 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (275K chars).
[
  {
    "path": ".clang-format",
    "chars": 431,
    "preview": "AccessModifierOffset: -4\nAllowShortFunctionsOnASingleLine: None\nAllowShortIfStatementsOnASingleLine: false\nAllowShortLoo"
  },
  {
    "path": ".gitattributes",
    "chars": 96,
    "preview": "* 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",
    "chars": 390,
    "preview": "---\nname: Bug report\nabout: Create a report to help us improve\n\n---\n\n**Describe the bug**\nA clear and concise descriptio"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/feature_request.md",
    "chars": 560,
    "preview": "---\nname: Feature request\nabout: Suggest an idea for this project\n\n---\n\n**Is your feature request related to a problem? "
  },
  {
    "path": ".gitignore",
    "chars": 5604,
    "preview": "## Ignore Visual Studio temporary files, build results, and\n## files generated by popular Visual Studio add-ons.\n##\n## G"
  },
  {
    "path": "BuildAll.py",
    "chars": 8669,
    "preview": "#!/usr/bin/env python\n#-*- coding: ascii -*-\n\n# ShaderConductor\n# Copyright (c) Microsoft Corporation. All rights reserv"
  },
  {
    "path": "CI/AzurePipelines/ContinuousBuild.yml",
    "chars": 1149,
    "preview": "steps:\n- bash: eval '$(installCommand)'\n  displayName: 'Install'\n\n- script: |\n    git config --global user.email \"dummy@"
  },
  {
    "path": "CMakeLists.txt",
    "chars": 3380,
    "preview": "# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the MIT License.\n\ncmake_minimum_required(VE"
  },
  {
    "path": "CONTRIBUTING.md",
    "chars": 2284,
    "preview": "# How to contribute\n\nOne of the easiest ways to contribute is to participate in discussions and discuss issues. You can "
  },
  {
    "path": "Include/ShaderConductor/ShaderConductor.hpp",
    "chars": 7676,
    "preview": "/*\n * ShaderConductor\n *\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License."
  },
  {
    "path": "LICENSE",
    "chars": 1162,
    "preview": "    MIT License\n\n    Copyright (c) Microsoft Corporation. All rights reserved.\n\n    Permission is hereby granted, free o"
  },
  {
    "path": "README.md",
    "chars": 3570,
    "preview": "# ShaderConductor\n\n[![Build Status](https://dev.azure.com/msft-ShaderConductor/public/_apis/build/status/ShaderConductor"
  },
  {
    "path": "SECURITY.md",
    "chars": 2757,
    "preview": "<!-- BEGIN MICROSOFT SECURITY.MD V0.0.8 BLOCK -->\n\n## Security\n\nMicrosoft takes the security of our software products an"
  },
  {
    "path": "Source/CMakeLists.txt",
    "chars": 4429,
    "preview": "# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the MIT License.\n\nif(CMAKE_C_COMPILER_ID MA"
  },
  {
    "path": "Source/Core/CMakeLists.txt",
    "chars": 2438,
    "preview": "# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the MIT License.\n\nif(WIN32)\n    set(dxcompi"
  },
  {
    "path": "Source/Core/ShaderConductor.cpp",
    "chars": 43301,
    "preview": "/*\n * ShaderConductor\n *\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License."
  },
  {
    "path": "Source/Tests/CMakeLists.txt",
    "chars": 1586,
    "preview": "# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the MIT License.\n\nset(EXE_NAME ShaderConduc"
  },
  {
    "path": "Source/Tests/Data/Expected/CalcLight+Diffuse.Debug.dxilasm",
    "chars": 7235,
    "preview": ";\n; Input signature:\n;\n; Name                 Index   Mask Register SysValue  Format   Used\n; -------------------- -----"
  },
  {
    "path": "Source/Tests/Data/Expected/CalcLight+Diffuse.Release.dxilasm",
    "chars": 7212,
    "preview": ";\n; Input signature:\n;\n; Name                 Index   Mask Register SysValue  Format   Used\n; -------------------- -----"
  },
  {
    "path": "Source/Tests/Data/Expected/CalcLight+DiffuseSpecular.Debug.dxilasm",
    "chars": 10359,
    "preview": ";\n; Input signature:\n;\n; Name                 Index   Mask Register SysValue  Format   Used\n; -------------------- -----"
  },
  {
    "path": "Source/Tests/Data/Expected/CalcLight+DiffuseSpecular.Release.dxilasm",
    "chars": 10119,
    "preview": ";\n; Input signature:\n;\n; Name                 Index   Mask Register SysValue  Format   Used\n; -------------------- -----"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_PS.30.hlsl",
    "chars": 427,
    "preview": "static float4 out_var_SV_Target;\n\nstruct SPIRV_Cross_Output\n{\n    float4 out_var_SV_Target : COLOR0;\n};\n\nvoid frag_main("
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_PS.300.essl",
    "chars": 257,
    "preview": "#version 300 es\nprecision mediump float;\nprecision highp int;\n\nlayout(location = 0) out highp vec4 out_var_SV_Target;\n\nv"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_PS.300.glsl",
    "chars": 233,
    "preview": "#version 300\n#extension GL_ARB_separate_shader_objects : require\n\nout vec4 out_var_SV_Target;\n\nvoid main()\n{\n    out_var"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_PS.310.essl",
    "chars": 257,
    "preview": "#version 310 es\nprecision mediump float;\nprecision highp int;\n\nlayout(location = 0) out highp vec4 out_var_SV_Target;\n\nv"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_PS.40.hlsl",
    "chars": 423,
    "preview": "static float4 out_var_SV_Target;\n\nstruct SPIRV_Cross_Output\n{\n    float4 out_var_SV_Target : SV_Target0;\n};\n\nvoid frag_m"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_PS.410.glsl",
    "chars": 202,
    "preview": "#version 410\n\nlayout(location = 0) out vec4 out_var_SV_Target;\n\nvoid main()\n{\n    out_var_SV_Target = vec4(0.20000000298"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_PS.50.hlsl",
    "chars": 423,
    "preview": "static float4 out_var_SV_Target;\n\nstruct SPIRV_Cross_Output\n{\n    float4 out_var_SV_Target : SV_Target0;\n};\n\nvoid frag_m"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_PS.msl",
    "chars": 341,
    "preview": "#include <metal_stdlib>\n#include <simd/simd.h>\n\nusing namespace metal;\n\nstruct PSMain_out\n{\n    float4 out_var_SV_Target"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_VS.30.hlsl",
    "chars": 485,
    "preview": "uniform float4 gl_HalfPixel;\n\nstatic float4 gl_Position;\nstruct SPIRV_Cross_Output\n{\n    float4 gl_Position : POSITION;\n"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_VS.300.essl",
    "chars": 78,
    "preview": "#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",
    "chars": 172,
    "preview": "#version 300\n#extension GL_ARB_separate_shader_objects : require\n\nout gl_PerVertex\n{\n    vec4 gl_Position;\n};\n\nvoid main"
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_VS.310.essl",
    "chars": 78,
    "preview": "#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",
    "chars": 322,
    "preview": "static float4 gl_Position;\nstruct SPIRV_Cross_Output\n{\n    float4 gl_Position : SV_Position;\n};\n\nvoid vert_main()\n{\n    "
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_VS.410.glsl",
    "chars": 120,
    "preview": "#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",
    "chars": 322,
    "preview": "static float4 gl_Position;\nstruct SPIRV_Cross_Output\n{\n    float4 gl_Position : SV_Position;\n};\n\nvoid vert_main()\n{\n    "
  },
  {
    "path": "Source/Tests/Data/Expected/Constant_VS.msl",
    "chars": 256,
    "preview": "#include <metal_stdlib>\n#include <simd/simd.h>\n\nusing namespace metal;\n\nstruct VSMain_out\n{\n    float4 gl_Position [[pos"
  },
  {
    "path": "Source/Tests/Data/Expected/DetailTessellation_HS.300.essl",
    "chars": 2005,
    "preview": "#version 300 es\n#extension GL_EXT_tessellation_shader : require\nlayout(vertices = 3) out;\n\nstruct VS_OUTPUT_HS_INPUT\n{\n "
  },
  {
    "path": "Source/Tests/Data/Expected/DetailTessellation_HS.300.glsl",
    "chars": 2222,
    "preview": "#version 300\n#extension GL_ARB_tessellation_shader : require\n#extension GL_ARB_separate_shader_objects : require\nlayout("
  },
  {
    "path": "Source/Tests/Data/Expected/DetailTessellation_HS.310.essl",
    "chars": 2186,
    "preview": "#version 310 es\n#extension GL_EXT_tessellation_shader : require\nlayout(vertices = 3) out;\n\nstruct VS_OUTPUT_HS_INPUT\n{\n "
  },
  {
    "path": "Source/Tests/Data/Expected/DetailTessellation_HS.410.glsl",
    "chars": 2122,
    "preview": "#version 410\nlayout(vertices = 3) out;\n\nstruct VS_OUTPUT_HS_INPUT\n{\n    vec3 worldPos;\n    vec3 normal;\n    vec2 texCoor"
  },
  {
    "path": "Source/Tests/Data/Expected/DetailTessellation_HS.msl",
    "chars": 4038,
    "preview": "#pragma clang diagnostic ignored \"-Wmissing-prototypes\"\n#pragma clang diagnostic ignored \"-Wmissing-braces\"\n\n#include <m"
  },
  {
    "path": "Source/Tests/Data/Expected/DotHalfPS.glsl",
    "chars": 452,
    "preview": "#version 30\n#if defined(GL_AMD_gpu_shader_half_float)\n#extension GL_AMD_gpu_shader_half_float : require\n#elif defined(GL"
  },
  {
    "path": "Source/Tests/Data/Expected/Fluid_CS.300.glsl",
    "chars": 1753,
    "preview": "#version 300\n#extension GL_ARB_compute_shader : require\n#extension GL_ARB_separate_shader_objects : require\nlayout(local"
  },
  {
    "path": "Source/Tests/Data/Expected/Fluid_CS.310.essl",
    "chars": 1713,
    "preview": "#version 310 es\nlayout(local_size_x = 256, local_size_y = 1, local_size_z = 1) in;\n\nstruct Particle\n{\n    vec2 position;"
  },
  {
    "path": "Source/Tests/Data/Expected/Fluid_CS.410.glsl",
    "chars": 1701,
    "preview": "#version 410\n#extension GL_ARB_compute_shader : require\nlayout(local_size_x = 256, local_size_y = 1, local_size_z = 1) i"
  },
  {
    "path": "Source/Tests/Data/Expected/Fluid_CS.50.hlsl",
    "chars": 1900,
    "preview": "struct Particle\n{\n    float2 position;\n    float2 velocity;\n};\n\nstruct ParticleForces\n{\n    float2 acceleration;\n};\n\ncbu"
  },
  {
    "path": "Source/Tests/Data/Expected/Fluid_CS.msl",
    "chars": 1916,
    "preview": "#include <metal_stdlib>\n#include <simd/simd.h>\n\nusing namespace metal;\n\nstruct type_cbSimulationConstants\n{\n    float ti"
  },
  {
    "path": "Source/Tests/Data/Expected/HalfOutParamPS.glsl",
    "chars": 458,
    "preview": "#version 30\n#if defined(GL_AMD_gpu_shader_half_float)\n#extension GL_AMD_gpu_shader_half_float : require\n#elif defined(GL"
  },
  {
    "path": "Source/Tests/Data/Expected/IncludeEmptyHeader.glsl",
    "chars": 114,
    "preview": "#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",
    "chars": 404,
    "preview": "#version 30\n#extension GL_ARB_separate_shader_objects : require\n\nuniform sampler2D SPIRV_Cross_CombinedcolorTexpointSamp"
  },
  {
    "path": "Source/Tests/Data/Expected/PNTriangles_DS.300.essl",
    "chars": 1675,
    "preview": "#version 300 es\n#extension GL_EXT_tessellation_shader : require\nlayout(triangles) in;\n\nlayout(std140) uniform type_cbPNT"
  },
  {
    "path": "Source/Tests/Data/Expected/PNTriangles_DS.300.glsl",
    "chars": 1979,
    "preview": "#version 300\n#extension GL_ARB_tessellation_shader : require\n#extension GL_ARB_separate_shader_objects : require\nlayout("
  },
  {
    "path": "Source/Tests/Data/Expected/PNTriangles_DS.310.essl",
    "chars": 1898,
    "preview": "#version 310 es\n#extension GL_EXT_tessellation_shader : require\nlayout(triangles) in;\n\nlayout(binding = 0, std140) unifo"
  },
  {
    "path": "Source/Tests/Data/Expected/PNTriangles_DS.410.glsl",
    "chars": 1879,
    "preview": "#version 410\nlayout(triangles) in;\n\nout gl_PerVertex\n{\n    vec4 gl_Position;\n};\n\nlayout(std140) uniform type_cbPNTriangl"
  },
  {
    "path": "Source/Tests/Data/Expected/PNTriangles_DS.msl",
    "chars": 3207,
    "preview": "#pragma clang diagnostic ignored \"-Wmissing-prototypes\"\n#pragma clang diagnostic ignored \"-Wmissing-braces\"\n\n#include <m"
  },
  {
    "path": "Source/Tests/Data/Expected/Particle_GS.300.essl",
    "chars": 1025,
    "preview": "#version 300 es\n#extension GL_EXT_geometry_shader : require\nlayout(points) in;\nlayout(max_vertices = 4, triangle_strip) "
  },
  {
    "path": "Source/Tests/Data/Expected/Particle_GS.300.glsl",
    "chars": 1117,
    "preview": "#version 300\n#extension GL_ARB_separate_shader_objects : require\nlayout(points) in;\nlayout(max_vertices = 4, triangle_st"
  },
  {
    "path": "Source/Tests/Data/Expected/Particle_GS.310.essl",
    "chars": 1080,
    "preview": "#version 310 es\n#extension GL_EXT_geometry_shader : require\nlayout(points) in;\nlayout(max_vertices = 4, triangle_strip) "
  },
  {
    "path": "Source/Tests/Data/Expected/Particle_GS.410.glsl",
    "chars": 1065,
    "preview": "#version 410\nlayout(points) in;\nlayout(max_vertices = 4, triangle_strip) out;\n\nout gl_PerVertex\n{\n    vec4 gl_Position;\n"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_PS.30.hlsl",
    "chars": 508,
    "preview": "static float4 in_var_COLOR;\nstatic float4 out_var_SV_Target;\n\nstruct SPIRV_Cross_Input\n{\n    float4 in_var_COLOR : TEXCO"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_PS.300.essl",
    "chars": 204,
    "preview": "#version 300 es\nprecision mediump float;\nprecision highp int;\n\nin highp vec4 varying_COLOR;\nlayout(location = 0) out hig"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_PS.300.glsl",
    "chars": 195,
    "preview": "#version 300\n#extension GL_ARB_separate_shader_objects : require\n\nlayout(location = 0) in vec4 varying_COLOR;\nout vec4 o"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_PS.310.essl",
    "chars": 223,
    "preview": "#version 310 es\nprecision mediump float;\nprecision highp int;\n\nlayout(location = 0) in highp vec4 in_var_COLOR;\nlayout(l"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_PS.40.hlsl",
    "chars": 504,
    "preview": "static float4 in_var_COLOR;\nstatic float4 out_var_SV_Target;\n\nstruct SPIRV_Cross_Input\n{\n    float4 in_var_COLOR : TEXCO"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_PS.410.glsl",
    "chars": 162,
    "preview": "#version 410\n\nlayout(location = 0) in vec4 in_var_COLOR;\nlayout(location = 0) out vec4 out_var_SV_Target;\n\nvoid main()\n{"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_PS.50.hlsl",
    "chars": 504,
    "preview": "static float4 in_var_COLOR;\nstatic float4 out_var_SV_Target;\n\nstruct SPIRV_Cross_Input\n{\n    float4 in_var_COLOR : TEXCO"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_PS.msl",
    "chars": 348,
    "preview": "#include <metal_stdlib>\n#include <simd/simd.h>\n\nusing namespace metal;\n\nstruct PSMain_out\n{\n    float4 out_var_SV_Target"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_VS.30.hlsl",
    "chars": 952,
    "preview": "uniform float4 gl_HalfPixel;\n\nstatic float4 gl_Position;\nstatic float4 in_var_POSITION;\nstatic float2 in_var_TEXCOORD0;\n"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_VS.300.essl",
    "chars": 233,
    "preview": "#version 300 es\n\nlayout(location = 0) in vec4 in_var_POSITION;\nlayout(location = 1) in vec2 in_var_TEXCOORD0;\nout vec2 v"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_VS.300.glsl",
    "chars": 306,
    "preview": "#version 300\n#extension GL_ARB_separate_shader_objects : require\n\nout gl_PerVertex\n{\n    vec4 gl_Position;\n};\n\nin vec4 i"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_VS.310.essl",
    "chars": 254,
    "preview": "#version 310 es\n\nlayout(location = 0) in vec4 in_var_POSITION;\nlayout(location = 1) in vec2 in_var_TEXCOORD0;\nlayout(loc"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_VS.40.hlsl",
    "chars": 789,
    "preview": "static float4 gl_Position;\nstatic float4 in_var_POSITION;\nstatic float2 in_var_TEXCOORD0;\nstatic float2 out_var_TEXCOORD"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_VS.410.glsl",
    "chars": 296,
    "preview": "#version 410\n\nout gl_PerVertex\n{\n    vec4 gl_Position;\n};\n\nlayout(location = 0) in vec4 in_var_POSITION;\nlayout(location"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_VS.50.hlsl",
    "chars": 789,
    "preview": "static float4 gl_Position;\nstatic float4 in_var_POSITION;\nstatic float2 in_var_TEXCOORD0;\nstatic float2 out_var_TEXCOORD"
  },
  {
    "path": "Source/Tests/Data/Expected/PassThrough_VS.msl",
    "chars": 482,
    "preview": "#include <metal_stdlib>\n#include <simd/simd.h>\n\nusing namespace metal;\n\nstruct VSMain_out\n{\n    float2 out_var_TEXCOORD0"
  },
  {
    "path": "Source/Tests/Data/Expected/ToneMapping_PS.30.hlsl",
    "chars": 1351,
    "preview": "cbuffer type_cbPS : register(b0)\n{\n    float cbPS_lumStrength : packoffset(c0);\n};\n\nuniform sampler2D SPIRV_Cross_Combin"
  },
  {
    "path": "Source/Tests/Data/Expected/ToneMapping_PS.300.essl",
    "chars": 1068,
    "preview": "#version 300 es\nprecision mediump float;\nprecision highp int;\n\nlayout(std140) uniform type_cbPS\n{\n    highp float lumStr"
  },
  {
    "path": "Source/Tests/Data/Expected/ToneMapping_PS.300.glsl",
    "chars": 1005,
    "preview": "#version 300\n#extension GL_ARB_separate_shader_objects : require\n\nlayout(std140) uniform type_cbPS\n{\n    float lumStreng"
  },
  {
    "path": "Source/Tests/Data/Expected/ToneMapping_PS.310.essl",
    "chars": 1099,
    "preview": "#version 310 es\nprecision mediump float;\nprecision highp int;\n\nlayout(binding = 0, std140) uniform type_cbPS\n{\n    highp"
  },
  {
    "path": "Source/Tests/Data/Expected/ToneMapping_PS.40.hlsl",
    "chars": 1326,
    "preview": "cbuffer type_cbPS : register(b0)\n{\n    float cbPS_lumStrength : packoffset(c0);\n};\n\nSamplerState pointSampler : register"
  },
  {
    "path": "Source/Tests/Data/Expected/ToneMapping_PS.410.glsl",
    "chars": 971,
    "preview": "#version 410\n\nlayout(std140) uniform type_cbPS\n{\n    float lumStrength;\n} cbPS;\n\nuniform sampler2D SPIRV_Cross_Combinedc"
  },
  {
    "path": "Source/Tests/Data/Expected/ToneMapping_PS.50.hlsl",
    "chars": 1326,
    "preview": "cbuffer type_cbPS : register(b0)\n{\n    float cbPS_lumStrength : packoffset(c0);\n};\n\nSamplerState pointSampler : register"
  },
  {
    "path": "Source/Tests/Data/Expected/ToneMapping_PS.msl",
    "chars": 1152,
    "preview": "#include <metal_stdlib>\n#include <simd/simd.h>\n\nusing namespace metal;\n\nstruct type_cbPS\n{\n    float lumStrength;\n};\n\nst"
  },
  {
    "path": "Source/Tests/Data/Expected/Transform_VS.30.hlsl",
    "chars": 757,
    "preview": "cbuffer type_cbVS : register(b0)\n{\n    row_major float4x4 cbVS_wvp : packoffset(c0);\n};\n\nuniform float4 gl_HalfPixel;\n\ns"
  },
  {
    "path": "Source/Tests/Data/Expected/Transform_VS.300.essl",
    "chars": 185,
    "preview": "#version 300 es\n\nlayout(std140) uniform type_cbVS\n{\n    mat4 wvp;\n} cbVS;\n\nlayout(location = 0) in vec4 in_var_POSITION;"
  },
  {
    "path": "Source/Tests/Data/Expected/Transform_VS.300.glsl",
    "chars": 258,
    "preview": "#version 300\n#extension GL_ARB_separate_shader_objects : require\n\nout gl_PerVertex\n{\n    vec4 gl_Position;\n};\n\nlayout(st"
  },
  {
    "path": "Source/Tests/Data/Expected/Transform_VS.310.essl",
    "chars": 198,
    "preview": "#version 310 es\n\nlayout(binding = 0, std140) uniform type_cbVS\n{\n    mat4 wvp;\n} cbVS;\n\nlayout(location = 0) in vec4 in_"
  },
  {
    "path": "Source/Tests/Data/Expected/Transform_VS.40.hlsl",
    "chars": 595,
    "preview": "cbuffer type_cbVS : register(b0)\n{\n    row_major float4x4 cbVS_wvp : packoffset(c0);\n};\n\n\nstatic float4 gl_Position;\nsta"
  },
  {
    "path": "Source/Tests/Data/Expected/Transform_VS.410.glsl",
    "chars": 227,
    "preview": "#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\nlay"
  },
  {
    "path": "Source/Tests/Data/Expected/Transform_VS.50.hlsl",
    "chars": 595,
    "preview": "cbuffer type_cbVS : register(b0)\n{\n    row_major float4x4 cbVS_wvp : packoffset(c0);\n};\n\n\nstatic float4 gl_Position;\nsta"
  },
  {
    "path": "Source/Tests/Data/Expected/Transform_VS.msl",
    "chars": 427,
    "preview": "#include <metal_stdlib>\n#include <simd/simd.h>\n\nusing namespace metal;\n\nstruct type_cbVS\n{\n    float4x4 wvp;\n};\n\nstruct "
  },
  {
    "path": "Source/Tests/Data/Expected/Transform_VS_ColumnMajor.300.glsl",
    "chars": 276,
    "preview": "#version 300\n#extension GL_ARB_separate_shader_objects : require\n\nout gl_PerVertex\n{\n    vec4 gl_Position;\n};\n\nlayout(st"
  },
  {
    "path": "Source/Tests/Data/Input/CalcLight.hlsl",
    "chars": 681,
    "preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nstruct PSInput\n{\n    fl"
  },
  {
    "path": "Source/Tests/Data/Input/CalcLightDiffuse.hlsl",
    "chars": 288,
    "preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\n// Diffuse only\nfloat3 "
  },
  {
    "path": "Source/Tests/Data/Input/CalcLightDiffuseSpecular.hlsl",
    "chars": 1030,
    "preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nfloat SpecularNormalize"
  },
  {
    "path": "Source/Tests/Data/Input/Common.hlsli",
    "chars": 182,
    "preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nSamplerState pointSampl"
  },
  {
    "path": "Source/Tests/Data/Input/Constant_PS.hlsl",
    "chars": 172,
    "preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nfloat4 PSMain() : SV_Ta"
  },
  {
    "path": "Source/Tests/Data/Input/Constant_VS.hlsl",
    "chars": 162,
    "preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nfloat4 VSMain() : SV_Po"
  },
  {
    "path": "Source/Tests/Data/Input/DetailTessellation_HS.hlsl",
    "chars": 1487,
    "preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\ncbuffer cbMain : regist"
  },
  {
    "path": "Source/Tests/Data/Input/Fluid_CS.hlsl",
    "chars": 1215,
    "preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nstruct Particle\n{\n    "
  },
  {
    "path": "Source/Tests/Data/Input/HalfDataType.hlsl",
    "chars": 405,
    "preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nfloat4 DotHalfPS() : SV"
  },
  {
    "path": "Source/Tests/Data/Input/Inc/HeaderA.hlsli",
    "chars": 165,
    "preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\n#include \"HeaderB.hlsli"
  },
  {
    "path": "Source/Tests/Data/Input/Inc/HeaderB.hlsli",
    "chars": 140,
    "preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nSamplerState linearSamp"
  },
  {
    "path": "Source/Tests/Data/Input/Inc/HeaderEmpty.hlsli",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "Source/Tests/Data/Input/IncludeEmptyHeader.hlsl",
    "chars": 175,
    "preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\n#include \"Inc/HeaderEmp"
  },
  {
    "path": "Source/Tests/Data/Input/IncludeExist.hlsl",
    "chars": 300,
    "preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\n#include \"Inc/HeaderA.h"
  },
  {
    "path": "Source/Tests/Data/Input/IncludeNotExist.hlsl",
    "chars": 151,
    "preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\n#include \"Header.hlsli\""
  },
  {
    "path": "Source/Tests/Data/Input/PNTriangles_DS.hlsl",
    "chars": 1854,
    "preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\ncbuffer cbPNTriangles :"
  },
  {
    "path": "Source/Tests/Data/Input/Particle_GS.hlsl",
    "chars": 1142,
    "preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\ncbuffer cbMain : regist"
  },
  {
    "path": "Source/Tests/Data/Input/PassThrough_PS.hlsl",
    "chars": 167,
    "preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nfloat4 PSMain(float4 co"
  },
  {
    "path": "Source/Tests/Data/Input/PassThrough_VS.hlsl",
    "chars": 288,
    "preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\nvoid VSMain(float4 pos "
  },
  {
    "path": "Source/Tests/Data/Input/ToneMapping_PS.hlsl",
    "chars": 886,
    "preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\n#include \"Common.hlsli\""
  },
  {
    "path": "Source/Tests/Data/Input/Transform_VS.hlsl",
    "chars": 253,
    "preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\ncbuffer cbVS : register"
  },
  {
    "path": "Source/Tests/ShaderConductorTest.cpp",
    "chars": 21375,
    "preview": "/*\n * ShaderConductor\n *\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License."
  },
  {
    "path": "Source/Tools/CMakeLists.txt",
    "chars": 470,
    "preview": "# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the MIT License.\n\nset(EXE_NAME ShaderConduc"
  },
  {
    "path": "Source/Tools/ShaderConductorCmd.cpp",
    "chars": 8320,
    "preview": "/*\n * ShaderConductor\n *\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License."
  },
  {
    "path": "Source/Wrapper/CMakeLists.txt",
    "chars": 904,
    "preview": "# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the MIT License.\n\nset(DLL_NAME ShaderConduc"
  },
  {
    "path": "Source/Wrapper/Native.cpp",
    "chars": 4888,
    "preview": "/*\n * ShaderConductor\n *\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License."
  },
  {
    "path": "Source/Wrapper/Native.h",
    "chars": 3103,
    "preview": "/*\n * ShaderConductor\n *\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License."
  },
  {
    "path": "Source/Wrapper/Program.cs",
    "chars": 4649,
    "preview": "/*\n * ShaderConductor\n *\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License."
  },
  {
    "path": "Source/Wrapper/Wrapper.cs",
    "chars": 6190,
    "preview": "/*\n * ShaderConductor\n *\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License."
  },
  {
    "path": "Source/Wrapper/shader.hlsl",
    "chars": 712,
    "preview": "// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT License.\n\ncbuffer Matrices : regi"
  },
  {
    "path": "azure-pipelines.yml",
    "chars": 7766,
    "preview": "variables:\n  configuration: Release\n  platform: x64\n\nresources:\n- repo: self\n  fetchDepth: 5\n\nstages:\n- stage: ClangForm"
  }
]

About this extraction

This page contains the full source code of the Microsoft/ShaderConductor GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 124 files (249.8 KB), approximately 75.8k tokens, and a symbol index with 136 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!