Browse Source

Enable DXIL compilation

Panagiotis Christopoulos Charitos 1 year ago
parent
commit
111f22a381
39 changed files with 3331 additions and 157 deletions
  1. 10 0
      AnKi/Gr/BackendCommon/Functions.cpp
  2. 1 1
      AnKi/Gr/CommandBuffer.h
  3. 1 1
      AnKi/Gr/Common.cpp
  4. 72 9
      AnKi/Gr/Common.h
  5. 1 1
      AnKi/Gr/D3D/D3DCommandBuffer.cpp
  6. 2 2
      AnKi/Gr/Vulkan/VkCommandBuffer.cpp
  7. 4 10
      AnKi/Gr/Vulkan/VkCommon.h
  8. 28 29
      AnKi/Gr/Vulkan/VkDescriptorSetFactory.cpp
  9. 13 12
      AnKi/Gr/Vulkan/VkDescriptorSetFactory.h
  10. 4 4
      AnKi/Gr/Vulkan/VkPipelineFactory.cpp
  11. 14 14
      AnKi/Gr/Vulkan/VkPipelineFactory.h
  12. 1 1
      AnKi/Gr/Vulkan/VkShaderProgram.cpp
  13. 1 1
      AnKi/Renderer/Dbg.cpp
  14. 1 1
      AnKi/Renderer/Utils/Drawer.cpp
  15. 2 2
      AnKi/Resource/MeshBinary.h
  16. 2 2
      AnKi/Resource/MeshBinary.xml
  17. 6 1
      AnKi/ShaderCompiler/CMakeLists.txt
  18. 33 13
      AnKi/ShaderCompiler/Dxc.cpp
  19. 4 0
      AnKi/ShaderCompiler/Dxc.h
  20. 294 36
      AnKi/ShaderCompiler/ShaderProgramCompiler.cpp
  21. 1 1
      AnKi/ShaderCompiler/ShaderProgramCompiler.h
  22. 4 4
      AnKi/ShaderCompiler/ShaderProgramParser.cpp
  23. 7 0
      AnKi/ShaderCompiler/ShaderProgramParser.h
  24. 8 0
      AnKi/Shaders/CMakeLists.txt
  25. 1 1
      AnKi/Shaders/ClusterBinningPackVisibles.ankiprog
  26. 1 1
      AnKi/Shaders/GBufferGeneric.ankiprog
  27. 1 0
      AnKi/Shaders/GpuVisibility.ankiprog
  28. 3 3
      AnKi/Ui/Canvas.cpp
  29. 4 4
      Tests/Gr/Gr.cpp
  30. 2 2
      Tests/ShaderCompiler/ShaderProgramCompiler.cpp
  31. BIN
      ThirdParty/Bin/Windows64/dxc.exe
  32. BIN
      ThirdParty/Bin/Windows64/dxcompiler.dll
  33. BIN
      ThirdParty/Bin/Windows64/dxil.dll
  34. 487 0
      ThirdParty/Dxc/d3d12shader.h
  35. 1309 0
      ThirdParty/Dxc/dxcapi.h
  36. 30 0
      ThirdParty/Dxc/dxcerrors.h
  37. 959 0
      ThirdParty/Dxc/dxcisense.h
  38. BIN
      ThirdParty/Dxc/dxcompiler.lib
  39. 20 1
      Tools/Shader/ShaderProgramCompilerMain.cpp

+ 10 - 0
AnKi/Gr/BackendCommon/Functions.cpp

@@ -176,8 +176,18 @@ Error linkShaderReflection(const ShaderReflection& a, const ShaderReflection& b,
 				return Error::kFunctionFailed;
 				return Error::kFunctionFailed;
 			}
 			}
 
 
+			const Bool flagsCorrect = a.m_descriptorFlags[set][binding] == DescriptorFlag::kNone
+									  || b.m_descriptorFlags[set][binding] == DescriptorFlag::kNone
+									  || a.m_descriptorFlags[set][binding] == b.m_descriptorFlags[set][binding];
+			if(!flagsCorrect)
+			{
+				ANKI_GR_LOGE("Can't link shader reflection because of different discriptor flags. Set %u binding %u", set, binding);
+				return Error::kFunctionFailed;
+			}
+
 			c.m_descriptorArraySizes[set][binding] = max(a.m_descriptorArraySizes[set][binding], b.m_descriptorArraySizes[set][binding]);
 			c.m_descriptorArraySizes[set][binding] = max(a.m_descriptorArraySizes[set][binding], b.m_descriptorArraySizes[set][binding]);
 			c.m_descriptorTypes[set][binding] = min(a.m_descriptorTypes[set][binding], b.m_descriptorTypes[set][binding]);
 			c.m_descriptorTypes[set][binding] = min(a.m_descriptorTypes[set][binding], b.m_descriptorTypes[set][binding]);
+			c.m_descriptorFlags[set][binding] = max(a.m_descriptorFlags[set][binding], b.m_descriptorFlags[set][binding]);
 		}
 		}
 	}
 	}
 
 

+ 1 - 1
AnKi/Gr/CommandBuffer.h

@@ -116,7 +116,7 @@ public:
 	void bindVertexBuffer(U32 binding, const BufferView& buff, PtrSize stride, VertexStepRate stepRate = VertexStepRate::kVertex);
 	void bindVertexBuffer(U32 binding, const BufferView& buff, PtrSize stride, VertexStepRate stepRate = VertexStepRate::kVertex);
 
 
 	/// Setup a vertex attribute.
 	/// Setup a vertex attribute.
-	void setVertexAttribute(VertexAttribute attribute, U32 buffBinding, Format fmt, PtrSize relativeOffset);
+	void setVertexAttribute(VertexAttributeSemantic attribute, U32 buffBinding, Format fmt, PtrSize relativeOffset);
 
 
 	/// Bind index buffer.
 	/// Bind index buffer.
 	void bindIndexBuffer(const BufferView& buff, IndexType type);
 	void bindIndexBuffer(const BufferView& buff, IndexType type);

+ 1 - 1
AnKi/Gr/Common.cpp

@@ -149,7 +149,7 @@ void ShaderReflection::validate() const
 		}
 		}
 	}
 	}
 
 
-	for(VertexAttribute semantic : EnumIterable<VertexAttribute>())
+	for(VertexAttributeSemantic semantic : EnumIterable<VertexAttributeSemantic>())
 	{
 	{
 		ANKI_ASSERT(!m_vertexAttributeMask.get(semantic) || m_vertexAttributeLocations[semantic] != kMaxU8);
 		ANKI_ASSERT(!m_vertexAttributeMask.get(semantic) || m_vertexAttributeLocations[semantic] != kMaxU8);
 	}
 	}

+ 72 - 9
AnKi/Gr/Common.h

@@ -842,7 +842,7 @@ enum class GpuQueueType : U8
 };
 };
 ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(GpuQueueType)
 ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(GpuQueueType)
 
 
-enum class VertexAttribute : U8
+enum class VertexAttributeSemantic : U8
 {
 {
 	kPosition,
 	kPosition,
 	kNormal,
 	kNormal,
@@ -856,17 +856,16 @@ enum class VertexAttribute : U8
 	kCount,
 	kCount,
 	kFirst = 0
 	kFirst = 0
 };
 };
-ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(VertexAttribute)
+ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(VertexAttributeSemantic)
 
 
+/// This doesn't match Vulkan or D3D.
 enum class DescriptorType : U8
 enum class DescriptorType : U8
 {
 {
-	kTexture,
+	kTexture, ///< Vulkan: Image (sampled or storage). D3D: Textures
 	kSampler,
 	kSampler,
 	kUniformBuffer,
 	kUniformBuffer,
-	kStorageBuffer,
-	kStorageImage,
-	kReadTexelBuffer,
-	kReadWriteTexelBuffer,
+	kStorageBuffer, ///< Vulkan: Storage buffers. D3D: Structured, ByteAddressBuffer
+	kTexelBuffer,
 	kAccelerationStructure,
 	kAccelerationStructure,
 
 
 	kCount,
 	kCount,
@@ -874,15 +873,74 @@ enum class DescriptorType : U8
 };
 };
 ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(DescriptorType)
 ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(DescriptorType)
 
 
+enum class DescriptorFlag : U8
+{
+	kNone,
+	kRead = 1 << 0,
+	kWrite = 1 << 1,
+	kReadWrite = kRead | kWrite,
+	kByteAddressBuffer = 1 << 2
+};
+ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(DescriptorFlag)
+
+/// HLSL binding semantic
+class BindingSemantic
+{
+public:
+	U16 m_number = kMaxU16;
+	Char m_class = '\0'; // It can be 'c', 'u', 's', 't'
+	U8 m_padding = 0;
+
+	BindingSemantic(Char c, U32 n)
+		: m_class(c)
+		, m_number(U16(n))
+	{
+		ANKI_ASSERT(c == 'c' || c == 'b' || c == 'u' || c == 's');
+		ANKI_ASSERT(n < kMaxU16);
+	}
+
+	/// Construct using a string like "t0" "c99" "s3"
+	BindingSemantic(const Char* str)
+	{
+		ANKI_ASSERT(str);
+		ANKI_ASSERT(str[0] == 'c' || str[0] == 'b' || str[0] == 'u' || str[0] == 's');
+		m_class = str[0];
+		m_number = 0;
+		while(*str != '\0')
+		{
+			ANKI_ASSERT(*str >= '0' && *str <= '9');
+			m_number *= 10;
+			m_number += *str - '0';
+			++str;
+		}
+	}
+};
+
+class ShaderReflectionBinding
+{
+public:
+	BindingSemantic m_semantic = {'c', 1};
+	DescriptorType m_type = DescriptorType::kCount;
+	DescriptorFlag m_flags = DescriptorFlag::kNone;
+	U16 m_arraySize = 0;
+	U16 m_vkBinding = kMaxU8;
+};
+
 class ShaderReflection
 class ShaderReflection
 {
 {
 public:
 public:
+	// !!OLD!!
 	Array2d<U16, kMaxDescriptorSets, kMaxBindingsPerDescriptorSet> m_descriptorArraySizes;
 	Array2d<U16, kMaxDescriptorSets, kMaxBindingsPerDescriptorSet> m_descriptorArraySizes;
 	Array2d<DescriptorType, kMaxDescriptorSets, kMaxBindingsPerDescriptorSet> m_descriptorTypes;
 	Array2d<DescriptorType, kMaxDescriptorSets, kMaxBindingsPerDescriptorSet> m_descriptorTypes;
+	Array2d<DescriptorFlag, kMaxDescriptorSets, kMaxBindingsPerDescriptorSet> m_descriptorFlags;
 	BitSet<kMaxDescriptorSets, U8> m_descriptorSetMask = {false};
 	BitSet<kMaxDescriptorSets, U8> m_descriptorSetMask = {false};
 
 
-	Array<U8, U32(VertexAttribute::kCount)> m_vertexAttributeLocations; ///< Only for Vulkan.
-	BitSet<U32(VertexAttribute::kCount), U8> m_vertexAttributeMask = {false};
+	// !!NEW!!
+	Array2d<ShaderReflectionBinding, kMaxDescriptorSets, kMaxBindingsPerDescriptorSet> m_bindings;
+	Array<U8, kMaxDescriptorSets> m_bindingCounts = {};
+
+	Array<U8, U32(VertexAttributeSemantic::kCount)> m_vertexAttributeLocations; ///< Only for Vulkan.
+	BitSet<U32(VertexAttributeSemantic::kCount), U8> m_vertexAttributeMask = {false};
 
 
 	BitSet<kMaxColorRenderTargets, U8> m_colorAttachmentWritemask = {false};
 	BitSet<kMaxColorRenderTargets, U8> m_colorAttachmentWritemask = {false};
 
 
@@ -901,6 +959,11 @@ public:
 			it.fill(DescriptorType::kCount);
 			it.fill(DescriptorType::kCount);
 		}
 		}
 
 
+		for(auto& it : m_descriptorFlags)
+		{
+			it.fill(DescriptorFlag::kNone);
+		}
+
 		m_vertexAttributeLocations.fill(kMaxU8);
 		m_vertexAttributeLocations.fill(kMaxU8);
 	}
 	}
 
 

+ 1 - 1
AnKi/Gr/D3D/D3DCommandBuffer.cpp

@@ -34,7 +34,7 @@ void CommandBuffer::bindVertexBuffer(U32 binding, const BufferView& buff, PtrSiz
 	ANKI_ASSERT(!"TODO");
 	ANKI_ASSERT(!"TODO");
 }
 }
 
 
-void CommandBuffer::setVertexAttribute(VertexAttribute attribute, U32 buffBinding, Format fmt, PtrSize relativeOffset)
+void CommandBuffer::setVertexAttribute(VertexAttributeSemantic attribute, U32 buffBinding, Format fmt, PtrSize relativeOffset)
 {
 {
 	ANKI_ASSERT(!"TODO");
 	ANKI_ASSERT(!"TODO");
 }
 }

+ 2 - 2
AnKi/Gr/Vulkan/VkCommandBuffer.cpp

@@ -50,7 +50,7 @@ void CommandBuffer::bindVertexBuffer(U32 binding, const BufferView& buff, PtrSiz
 	vkCmdBindVertexBuffers(self.m_handle, binding, 1, &vkbuff, &buff.getOffset());
 	vkCmdBindVertexBuffers(self.m_handle, binding, 1, &vkbuff, &buff.getOffset());
 }
 }
 
 
-void CommandBuffer::setVertexAttribute(VertexAttribute attribute, U32 buffBinding, Format fmt, PtrSize relativeOffset)
+void CommandBuffer::setVertexAttribute(VertexAttributeSemantic attribute, U32 buffBinding, Format fmt, PtrSize relativeOffset)
 {
 {
 	ANKI_VK_SELF(CommandBufferImpl);
 	ANKI_VK_SELF(CommandBufferImpl);
 	self.commandCommon();
 	self.commandCommon();
@@ -927,7 +927,7 @@ void CommandBuffer::copyBufferToTexture(const BufferView& buff, const TextureVie
 
 
 	const TextureImpl& tex = static_cast<const TextureImpl&>(texView.getTexture());
 	const TextureImpl& tex = static_cast<const TextureImpl&>(texView.getTexture());
 	ANKI_ASSERT(tex.usageValid(TextureUsageBit::kTransferDestination));
 	ANKI_ASSERT(tex.usageValid(TextureUsageBit::kTransferDestination));
-	ANKI_ASSERT(texView.isGoodForCopyFromBuffer());
+	ANKI_ASSERT(texView.isGoodForCopyBufferToTexture());
 	const VkImageLayout layout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
 	const VkImageLayout layout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
 	const VkImageSubresourceRange range = tex.computeVkImageSubresourceRange(texView.getSubresource());
 	const VkImageSubresourceRange range = tex.computeVkImageSubresourceRange(texView.getSubresource());
 
 

+ 4 - 10
AnKi/Gr/Vulkan/VkCommon.h

@@ -239,13 +239,13 @@ static_assert(!(BufferUsageBit::kAll & PrivateBufferUsageBit::kAllPrivate), "Upd
 	return out;
 	return out;
 }
 }
 
 
-[[nodiscard]] inline VkDescriptorType convertDescriptorType(DescriptorType ak)
+[[nodiscard]] inline VkDescriptorType convertDescriptorType(DescriptorType ak, DescriptorFlag flags)
 {
 {
 	VkDescriptorType out;
 	VkDescriptorType out;
 	switch(ak)
 	switch(ak)
 	{
 	{
 	case DescriptorType::kTexture:
 	case DescriptorType::kTexture:
-		out = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
+		out = !!(flags & DescriptorFlag::kWrite) ? VK_DESCRIPTOR_TYPE_STORAGE_IMAGE : VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
 		break;
 		break;
 	case DescriptorType::kSampler:
 	case DescriptorType::kSampler:
 		out = VK_DESCRIPTOR_TYPE_SAMPLER;
 		out = VK_DESCRIPTOR_TYPE_SAMPLER;
@@ -253,18 +253,12 @@ static_assert(!(BufferUsageBit::kAll & PrivateBufferUsageBit::kAllPrivate), "Upd
 	case DescriptorType::kUniformBuffer:
 	case DescriptorType::kUniformBuffer:
 		out = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
 		out = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
 		break;
 		break;
-	case DescriptorType::kReadTexelBuffer:
-		out = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
-		break;
-	case DescriptorType::kReadWriteTexelBuffer:
-		out = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER;
+	case DescriptorType::kTexelBuffer:
+		out = !!(flags & DescriptorFlag::kWrite) ? VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER : VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
 		break;
 		break;
 	case DescriptorType::kStorageBuffer:
 	case DescriptorType::kStorageBuffer:
 		out = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
 		out = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
 		break;
 		break;
-	case DescriptorType::kStorageImage:
-		out = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
-		break;
 	case DescriptorType::kAccelerationStructure:
 	case DescriptorType::kAccelerationStructure:
 		out = VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR;
 		out = VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR;
 		break;
 		break;

+ 28 - 29
AnKi/Gr/Vulkan/VkDescriptorSetFactory.cpp

@@ -16,21 +16,20 @@ static StatCounter g_descriptorSetsAllocated(StatCategory::kMisc, "DescriptorSet
 class DSAllocatorConstants
 class DSAllocatorConstants
 {
 {
 public:
 public:
-	Array<U32, U32(DescriptorType::kCount)> m_descriptorCount;
+	Array<std::pair<VkDescriptorType, U32>, 8> m_descriptorCount;
 
 
 	U32 m_maxSets;
 	U32 m_maxSets;
 
 
 	DSAllocatorConstants()
 	DSAllocatorConstants()
 	{
 	{
-		m_descriptorCount[DescriptorType::kTexture] = 64;
-		m_descriptorCount[DescriptorType::kSampler] = 8;
-		m_descriptorCount[DescriptorType::kUniformBuffer] = 8;
-		m_descriptorCount[DescriptorType::kStorageBuffer] = 64;
-		m_descriptorCount[DescriptorType::kStorageImage] = 8;
-		m_descriptorCount[DescriptorType::kReadTexelBuffer] = 32;
-		m_descriptorCount[DescriptorType::kReadWriteTexelBuffer] = 8;
-		m_descriptorCount[DescriptorType::kAccelerationStructure] = 8;
-		static_assert(decltype(m_descriptorCount)::getSize() == 8);
+		m_descriptorCount[0] = {VK_DESCRIPTOR_TYPE_SAMPLER, 8};
+		m_descriptorCount[1] = {VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 64};
+		m_descriptorCount[2] = {VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 8};
+		m_descriptorCount[3] = {VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, 32};
+		m_descriptorCount[4] = {VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, 8};
+		m_descriptorCount[5] = {VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 8};
+		m_descriptorCount[6] = {VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 64};
+		m_descriptorCount[7] = {VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, 4};
 
 
 		m_maxSets = 64;
 		m_maxSets = 64;
 	}
 	}
@@ -59,14 +58,14 @@ void DSAllocator::createNewBlock()
 
 
 	const Bool rtEnabled = GrManager::getSingleton().getDeviceCapabilities().m_rayTracingEnabled;
 	const Bool rtEnabled = GrManager::getSingleton().getDeviceCapabilities().m_rayTracingEnabled;
 
 
-	Array<VkDescriptorPoolSize, U32(DescriptorType::kCount)> poolSizes;
+	Array<VkDescriptorPoolSize, g_dsAllocatorConsts.m_descriptorCount.getSize()> poolSizes;
 
 
-	for(DescriptorType type = DescriptorType::kFirst; type < DescriptorType::kCount; ++type)
+	for(U32 i = 0; i < g_dsAllocatorConsts.m_descriptorCount.getSize(); ++i)
 	{
 	{
-		VkDescriptorPoolSize& size = poolSizes[type];
+		VkDescriptorPoolSize& size = poolSizes[i];
 
 
-		size.descriptorCount = g_dsAllocatorConsts.m_descriptorCount[type] * powu(kDescriptorSetGrowScale, m_blocks.getSize());
-		size.type = convertDescriptorType(type);
+		size.descriptorCount = g_dsAllocatorConsts.m_descriptorCount[i].second * powu(kDescriptorSetGrowScale, m_blocks.getSize());
+		size.type = g_dsAllocatorConsts.m_descriptorCount[i].first;
 	}
 	}
 
 
 	VkDescriptorPoolCreateInfo inf = {};
 	VkDescriptorPoolCreateInfo inf = {};
@@ -478,35 +477,35 @@ Bool DSStateTracker::flush(DSAllocator& allocator, VkDescriptorSet& dsHandle)
 				ANKI_ASSERT(m_bindings[bindingIdx].m_count < kMaxU32);
 				ANKI_ASSERT(m_bindings[bindingIdx].m_count < kMaxU32);
 				const Binding& b = (m_bindings[bindingIdx].m_count == 1) ? m_bindings[bindingIdx].m_single : m_bindings[bindingIdx].m_array[arrIdx];
 				const Binding& b = (m_bindings[bindingIdx].m_count == 1) ? m_bindings[bindingIdx].m_single : m_bindings[bindingIdx].m_array[arrIdx];
 
 
-				ANKI_ASSERT(b.m_type == m_layout->m_bindingType[bindingIdx] && "Bound the wrong type");
+				ANKI_ASSERT(b.m_type == m_layout->m_bindingDsType[bindingIdx] && "Bound the wrong type");
 
 
 				writeInfo = writeTemplate;
 				writeInfo = writeTemplate;
-				writeInfo.descriptorType = convertDescriptorType(b.m_type);
+				writeInfo.descriptorType = b.m_type;
 				writeInfo.dstArrayElement = arrIdx;
 				writeInfo.dstArrayElement = arrIdx;
 				writeInfo.dstBinding = bindingIdx;
 				writeInfo.dstBinding = bindingIdx;
 
 
 				switch(b.m_type)
 				switch(b.m_type)
 				{
 				{
-				case DescriptorType::kTexture:
-				case DescriptorType::kSampler:
-				case DescriptorType::kStorageImage:
+				case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
+				case VK_DESCRIPTOR_TYPE_SAMPLER:
+				case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
 				{
 				{
 					writeInfo.pImageInfo = &b.m_image;
 					writeInfo.pImageInfo = &b.m_image;
 					break;
 					break;
 				}
 				}
-				case DescriptorType::kUniformBuffer:
-				case DescriptorType::kStorageBuffer:
+				case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
+				case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
 				{
 				{
 					writeInfo.pBufferInfo = &b.m_buffer;
 					writeInfo.pBufferInfo = &b.m_buffer;
 					break;
 					break;
 				}
 				}
-				case DescriptorType::kReadTexelBuffer:
-				case DescriptorType::kReadWriteTexelBuffer:
+				case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
+				case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
 				{
 				{
 					writeInfo.pTexelBufferView = &b.m_bufferView;
 					writeInfo.pTexelBufferView = &b.m_bufferView;
 					break;
 					break;
 				}
 				}
-				case DescriptorType::kAccelerationStructure:
+				case VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR:
 				{
 				{
 					writeInfo.pNext = &b.m_as;
 					writeInfo.pNext = &b.m_as;
 					break;
 					break;
@@ -584,12 +583,12 @@ Error DSLayoutFactory::getOrCreateDescriptorSetLayout(const WeakArray<DSBinding>
 		for(U32 i = 0; i < bindingCount; ++i)
 		for(U32 i = 0; i < bindingCount; ++i)
 		{
 		{
 			const DSBinding& binding = bindings[i];
 			const DSBinding& binding = bindings[i];
-			if(binding.m_binding == 0 && binding.m_type == DescriptorType::kTexture
+			if(binding.m_binding == 0 && binding.m_type == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE
 			   && binding.m_arraySize == DSBindless::getSingleton().getMaxTextureCount())
 			   && binding.m_arraySize == DSBindless::getSingleton().getMaxTextureCount())
 			{
 			{
 				// All good
 				// All good
 			}
 			}
-			else if(binding.m_binding == 1 && binding.m_type == DescriptorType::kReadTexelBuffer
+			else if(binding.m_binding == 1 && binding.m_type == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER
 					&& binding.m_arraySize == DSBindless::getSingleton().getMaxTexelBufferCount())
 					&& binding.m_arraySize == DSBindless::getSingleton().getMaxTexelBufferCount())
 			{
 			{
 				// All good
 				// All good
@@ -640,13 +639,13 @@ Error DSLayoutFactory::getOrCreateDescriptorSetLayout(const WeakArray<DSBinding>
 
 
 				vk.binding = ak.m_binding;
 				vk.binding = ak.m_binding;
 				vk.descriptorCount = ak.m_arraySize;
 				vk.descriptorCount = ak.m_arraySize;
-				vk.descriptorType = convertDescriptorType(ak.m_type);
+				vk.descriptorType = ak.m_type;
 				vk.pImmutableSamplers = nullptr;
 				vk.pImmutableSamplers = nullptr;
 				vk.stageFlags = VK_SHADER_STAGE_ALL;
 				vk.stageFlags = VK_SHADER_STAGE_ALL;
 
 
 				ANKI_ASSERT(layout->m_activeBindings.get(ak.m_binding) == false);
 				ANKI_ASSERT(layout->m_activeBindings.get(ak.m_binding) == false);
 				layout->m_activeBindings.set(ak.m_binding);
 				layout->m_activeBindings.set(ak.m_binding);
-				layout->m_bindingType[ak.m_binding] = ak.m_type;
+				layout->m_bindingDsType[ak.m_binding] = ak.m_type;
 				layout->m_bindingArraySize[ak.m_binding] = ak.m_arraySize;
 				layout->m_bindingArraySize[ak.m_binding] = ak.m_arraySize;
 				layout->m_minBinding = min<U32>(layout->m_minBinding, ak.m_binding);
 				layout->m_minBinding = min<U32>(layout->m_minBinding, ak.m_binding);
 				layout->m_maxBinding = max<U32>(layout->m_maxBinding, ak.m_binding);
 				layout->m_maxBinding = max<U32>(layout->m_maxBinding, ak.m_binding);

+ 13 - 12
AnKi/Gr/Vulkan/VkDescriptorSetFactory.h

@@ -34,7 +34,7 @@ private:
 	U64 m_hash = 0;
 	U64 m_hash = 0;
 	BitSet<kMaxBindingsPerDescriptorSet, U32> m_activeBindings = {false};
 	BitSet<kMaxBindingsPerDescriptorSet, U32> m_activeBindings = {false};
 	Array<U32, kMaxBindingsPerDescriptorSet> m_bindingArraySize = {};
 	Array<U32, kMaxBindingsPerDescriptorSet> m_bindingArraySize = {};
-	Array<DescriptorType, kMaxBindingsPerDescriptorSet> m_bindingType = {};
+	Array<VkDescriptorType, kMaxBindingsPerDescriptorSet> m_bindingDsType = {};
 	U32 m_minBinding = kMaxU32;
 	U32 m_minBinding = kMaxU32;
 	U32 m_maxBinding = 0;
 	U32 m_maxBinding = 0;
 	U32 m_descriptorCount = 0;
 	U32 m_descriptorCount = 0;
@@ -172,7 +172,7 @@ public:
 		ANKI_ASSERT(handle);
 		ANKI_ASSERT(handle);
 		Binding b;
 		Binding b;
 		zeroMemory(b);
 		zeroMemory(b);
-		b.m_type = DescriptorType::kTexture;
+		b.m_type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
 		b.m_image.imageView = handle;
 		b.m_image.imageView = handle;
 		b.m_image.imageLayout = layout;
 		b.m_image.imageLayout = layout;
 		b.m_image.sampler = VK_NULL_HANDLE;
 		b.m_image.sampler = VK_NULL_HANDLE;
@@ -184,7 +184,7 @@ public:
 		ANKI_ASSERT(sampler);
 		ANKI_ASSERT(sampler);
 		Binding b;
 		Binding b;
 		zeroMemory(b);
 		zeroMemory(b);
-		b.m_type = DescriptorType::kSampler;
+		b.m_type = VK_DESCRIPTOR_TYPE_SAMPLER;
 		b.m_image.sampler = static_cast<const SamplerImpl*>(sampler)->m_sampler->getHandle();
 		b.m_image.sampler = static_cast<const SamplerImpl*>(sampler)->m_sampler->getHandle();
 		setBinding(binding, arrayIdx, b);
 		setBinding(binding, arrayIdx, b);
 	}
 	}
@@ -194,7 +194,7 @@ public:
 		ANKI_ASSERT(buff && range > 0);
 		ANKI_ASSERT(buff && range > 0);
 		Binding b;
 		Binding b;
 		zeroMemory(b);
 		zeroMemory(b);
-		b.m_type = DescriptorType::kUniformBuffer;
+		b.m_type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
 		b.m_buffer.buffer = static_cast<const BufferImpl*>(buff)->getHandle();
 		b.m_buffer.buffer = static_cast<const BufferImpl*>(buff)->getHandle();
 		b.m_buffer.offset = offset;
 		b.m_buffer.offset = offset;
 		b.m_buffer.range = (range == kMaxPtrSize) ? VK_WHOLE_SIZE : range;
 		b.m_buffer.range = (range == kMaxPtrSize) ? VK_WHOLE_SIZE : range;
@@ -206,7 +206,7 @@ public:
 		ANKI_ASSERT(buff && range > 0);
 		ANKI_ASSERT(buff && range > 0);
 		Binding b;
 		Binding b;
 		zeroMemory(b);
 		zeroMemory(b);
-		b.m_type = DescriptorType::kStorageBuffer;
+		b.m_type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
 		b.m_buffer.buffer = static_cast<const BufferImpl*>(buff)->getHandle();
 		b.m_buffer.buffer = static_cast<const BufferImpl*>(buff)->getHandle();
 		b.m_buffer.offset = offset;
 		b.m_buffer.offset = offset;
 		b.m_buffer.range = (range == kMaxPtrSize) ? VK_WHOLE_SIZE : range;
 		b.m_buffer.range = (range == kMaxPtrSize) ? VK_WHOLE_SIZE : range;
@@ -218,7 +218,7 @@ public:
 		ANKI_ASSERT(buff && range > 0);
 		ANKI_ASSERT(buff && range > 0);
 		Binding b;
 		Binding b;
 		zeroMemory(b);
 		zeroMemory(b);
-		b.m_type = DescriptorType::kReadTexelBuffer;
+		b.m_type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
 		b.m_bufferView = static_cast<const BufferImpl*>(buff)->getOrCreateBufferView(fmt, offset, range);
 		b.m_bufferView = static_cast<const BufferImpl*>(buff)->getOrCreateBufferView(fmt, offset, range);
 		setBinding(binding, arrayIdx, b);
 		setBinding(binding, arrayIdx, b);
 	}
 	}
@@ -228,7 +228,7 @@ public:
 		ANKI_ASSERT(handle);
 		ANKI_ASSERT(handle);
 		Binding b;
 		Binding b;
 		zeroMemory(b);
 		zeroMemory(b);
-		b.m_type = DescriptorType::kStorageImage;
+		b.m_type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
 		b.m_image.imageView = handle;
 		b.m_image.imageView = handle;
 		b.m_image.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
 		b.m_image.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
 		setBinding(binding, arrayIdx, b);
 		setBinding(binding, arrayIdx, b);
@@ -239,7 +239,7 @@ public:
 		ANKI_ASSERT(as);
 		ANKI_ASSERT(as);
 		Binding b;
 		Binding b;
 		zeroMemory(b);
 		zeroMemory(b);
-		b.m_type = DescriptorType::kAccelerationStructure;
+		b.m_type = VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR;
 		b.m_as.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR;
 		b.m_as.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR;
 		b.m_as.accelerationStructureCount = 1;
 		b.m_as.accelerationStructureCount = 1;
 		b.m_as.pAccelerationStructures = &static_cast<const AccelerationStructureImpl*>(as)->getHandle();
 		b.m_as.pAccelerationStructures = &static_cast<const AccelerationStructureImpl*>(as)->getHandle();
@@ -272,7 +272,7 @@ private:
 			VkBufferView m_bufferView;
 			VkBufferView m_bufferView;
 		};
 		};
 
 
-		DescriptorType m_type;
+		VkDescriptorType m_type;
 
 
 		Binding()
 		Binding()
 		{
 		{
@@ -320,14 +320,15 @@ private:
 	void setBinding(U32 bindingIdx, U32 arrayIdx, const Binding& b);
 	void setBinding(U32 bindingIdx, U32 arrayIdx, const Binding& b);
 };
 };
 
 
-class alignas(4) DSBinding
+class DSBinding
 {
 {
 public:
 public:
+	VkDescriptorType m_type = VK_DESCRIPTOR_TYPE_MAX_ENUM;
 	U16 m_arraySize = 0;
 	U16 m_arraySize = 0;
-	DescriptorType m_type = DescriptorType::kCount;
 	U8 m_binding = kMaxU8;
 	U8 m_binding = kMaxU8;
+	U8 m_padding = 0;
 };
 };
-static_assert(sizeof(DSBinding) == 4, "Should be packed because it will be hashed");
+static_assert(sizeof(DSBinding) == 8, "Should be packed because it will be hashed");
 
 
 class DSLayoutFactory : public MakeSingleton<DSLayoutFactory>
 class DSLayoutFactory : public MakeSingleton<DSLayoutFactory>
 {
 {

+ 4 - 4
AnKi/Gr/Vulkan/VkPipelineFactory.cpp

@@ -43,7 +43,7 @@ Bool PipelineStateTracker::updateHashes()
 	// Vertex
 	// Vertex
 	if(m_dirty.m_attribs.getAnySet() || m_dirty.m_vertBindings.getAnySet())
 	if(m_dirty.m_attribs.getAnySet() || m_dirty.m_vertBindings.getAnySet())
 	{
 	{
-		for(VertexAttribute i : EnumIterable<VertexAttribute>())
+		for(VertexAttributeSemantic i : EnumIterable<VertexAttributeSemantic>())
 		{
 		{
 			if(m_shaderVertexAttributeMask.get(i))
 			if(m_shaderVertexAttributeMask.get(i))
 			{
 			{
@@ -158,7 +158,7 @@ void PipelineStateTracker::updateSuperHash()
 	// Vertex
 	// Vertex
 	if(!!m_shaderVertexAttributeMask)
 	if(!!m_shaderVertexAttributeMask)
 	{
 	{
-		for(VertexAttribute i : EnumIterable<VertexAttribute>())
+		for(VertexAttributeSemantic i : EnumIterable<VertexAttributeSemantic>())
 		{
 		{
 			if(m_shaderVertexAttributeMask.get(i))
 			if(m_shaderVertexAttributeMask.get(i))
 			{
 			{
@@ -222,8 +222,8 @@ const VkGraphicsPipelineCreateInfo& PipelineStateTracker::updatePipelineCreateIn
 	vertCi.pVertexAttributeDescriptions = &m_ci.m_attribs[0];
 	vertCi.pVertexAttributeDescriptions = &m_ci.m_attribs[0];
 	vertCi.pVertexBindingDescriptions = &m_ci.m_vertBindings[0];
 	vertCi.pVertexBindingDescriptions = &m_ci.m_vertBindings[0];
 
 
-	BitSet<U32(VertexAttribute::kCount), U8> bindingSet = {false};
-	for(VertexAttribute semantic : EnumIterable<VertexAttribute>())
+	BitSet<U32(VertexAttributeSemantic::kCount), U8> bindingSet = {false};
+	for(VertexAttributeSemantic semantic : EnumIterable<VertexAttributeSemantic>())
 	{
 	{
 		if(m_shaderVertexAttributeMask.get(semantic))
 		if(m_shaderVertexAttributeMask.get(semantic))
 		{
 		{

+ 14 - 14
AnKi/Gr/Vulkan/VkPipelineFactory.h

@@ -56,12 +56,12 @@ static_assert(sizeof(VertexAttributeBindingPipelineState) == 2 * sizeof(PtrSize)
 class VertexPipelineState
 class VertexPipelineState
 {
 {
 public:
 public:
-	Array<VertexBufferBindingPipelineState, U32(VertexAttribute::kCount)> m_bindings;
-	Array<VertexAttributeBindingPipelineState, U32(VertexAttribute::kCount)> m_attributes;
+	Array<VertexBufferBindingPipelineState, U32(VertexAttributeSemantic::kCount)> m_bindings;
+	Array<VertexAttributeBindingPipelineState, U32(VertexAttributeSemantic::kCount)> m_attributes;
 };
 };
 static_assert(sizeof(VertexPipelineState)
 static_assert(sizeof(VertexPipelineState)
-				  == sizeof(VertexBufferBindingPipelineState) * U32(VertexAttribute::kCount)
-						 + sizeof(VertexAttributeBindingPipelineState) * U32(VertexAttribute::kCount),
+				  == sizeof(VertexBufferBindingPipelineState) * U32(VertexAttributeSemantic::kCount)
+						 + sizeof(VertexAttributeBindingPipelineState) * U32(VertexAttributeSemantic::kCount),
 			  "Packed because it will be hashed");
 			  "Packed because it will be hashed");
 
 
 class InputAssemblerPipelineState
 class InputAssemblerPipelineState
@@ -174,7 +174,7 @@ public:
 		m_set.m_vertBindings.set(binding);
 		m_set.m_vertBindings.set(binding);
 	}
 	}
 
 
-	void setVertexAttribute(VertexAttribute semantic, U32 buffBinding, const Format fmt, PtrSize relativeOffset)
+	void setVertexAttribute(VertexAttributeSemantic semantic, U32 buffBinding, const Format fmt, PtrSize relativeOffset)
 	{
 	{
 		VertexAttributeBindingPipelineState b;
 		VertexAttributeBindingPipelineState b;
 		b.m_binding = U8(buffBinding);
 		b.m_binding = U8(buffBinding);
@@ -457,8 +457,8 @@ private:
 		Bool m_color : 1 = true;
 		Bool m_color : 1 = true;
 
 
 		// Vertex
 		// Vertex
-		BitSet<U32(VertexAttribute::kCount), U8> m_attribs = {true};
-		BitSet<U32(VertexAttribute::kCount), U8> m_vertBindings = {true};
+		BitSet<U32(VertexAttributeSemantic::kCount), U8> m_attribs = {true};
+		BitSet<U32(VertexAttributeSemantic::kCount), U8> m_vertBindings = {true};
 
 
 		BitSet<kMaxColorRenderTargets, U8> m_colAttachments = {true};
 		BitSet<kMaxColorRenderTargets, U8> m_colAttachments = {true};
 	} m_dirty;
 	} m_dirty;
@@ -466,14 +466,14 @@ private:
 	class SetBits
 	class SetBits
 	{
 	{
 	public:
 	public:
-		BitSet<U32(VertexAttribute::kCount), U8> m_attribs = {false};
-		BitSet<U32(VertexAttribute::kCount), U8> m_vertBindings = {false};
+		BitSet<U32(VertexAttributeSemantic::kCount), U8> m_attribs = {false};
+		BitSet<U32(VertexAttributeSemantic::kCount), U8> m_vertBindings = {false};
 	} m_set;
 	} m_set;
 
 
 	// Shader info
 	// Shader info
-	BitSet<U32(VertexAttribute::kCount), U8> m_shaderVertexAttributeMask = {false};
+	BitSet<U32(VertexAttributeSemantic::kCount), U8> m_shaderVertexAttributeMask = {false};
 	BitSet<kMaxColorRenderTargets, U8> m_shaderColorAttachmentWritemask = {false};
 	BitSet<kMaxColorRenderTargets, U8> m_shaderColorAttachmentWritemask = {false};
-	Array<U8, U32(VertexAttribute::kCount)> m_semanticToVertexAttributeLocation;
+	Array<U8, U32(VertexAttributeSemantic::kCount)> m_semanticToVertexAttributeLocation;
 
 
 	// Renderpass info
 	// Renderpass info
 	Bool m_fbDepth : 1 = false;
 	Bool m_fbDepth : 1 = false;
@@ -489,7 +489,7 @@ private:
 	public:
 	public:
 		U64 m_prog;
 		U64 m_prog;
 		U64 m_rpass;
 		U64 m_rpass;
-		Array<U64, U32(VertexAttribute::kCount)> m_vertexAttribs;
+		Array<U64, U32(VertexAttributeSemantic::kCount)> m_vertexAttribs;
 		U64 m_ia;
 		U64 m_ia;
 		U64 m_raster;
 		U64 m_raster;
 		U64 m_depth;
 		U64 m_depth;
@@ -510,8 +510,8 @@ private:
 	class CreateInfo
 	class CreateInfo
 	{
 	{
 	public:
 	public:
-		Array<VkVertexInputBindingDescription, U32(VertexAttribute::kCount)> m_vertBindings;
-		Array<VkVertexInputAttributeDescription, U32(VertexAttribute::kCount)> m_attribs;
+		Array<VkVertexInputBindingDescription, U32(VertexAttributeSemantic::kCount)> m_vertBindings;
+		Array<VkVertexInputAttributeDescription, U32(VertexAttributeSemantic::kCount)> m_attribs;
 		VkPipelineVertexInputStateCreateInfo m_vert;
 		VkPipelineVertexInputStateCreateInfo m_vert;
 		VkPipelineInputAssemblyStateCreateInfo m_ia;
 		VkPipelineInputAssemblyStateCreateInfo m_ia;
 		VkPipelineViewportStateCreateInfo m_vp;
 		VkPipelineViewportStateCreateInfo m_vp;

+ 1 - 1
AnKi/Gr/Vulkan/VkShaderProgram.cpp

@@ -153,7 +153,7 @@ Error ShaderProgramImpl::init(const ShaderProgramInitInfo& inf)
 				DSBinding b;
 				DSBinding b;
 				b.m_arraySize = m_refl.m_descriptorArraySizes[set][binding];
 				b.m_arraySize = m_refl.m_descriptorArraySizes[set][binding];
 				b.m_binding = binding;
 				b.m_binding = binding;
-				b.m_type = m_refl.m_descriptorTypes[set][binding];
+				b.m_type = convertDescriptorType(m_refl.m_descriptorTypes[set][binding], m_refl.m_descriptorFlags[set][binding]);
 
 
 				bindings[set][counts[set]++] = b;
 				bindings[set][counts[set]++] = b;
 			}
 			}

+ 1 - 1
AnKi/Renderer/Dbg.cpp

@@ -184,7 +184,7 @@ void Dbg::run(RenderPassWorkContext& rgraphCtx, const RenderingContext& ctx)
 
 
 		cmdb.setPushConstants(&unis, sizeof(unis));
 		cmdb.setPushConstants(&unis, sizeof(unis));
 		cmdb.bindVertexBuffer(0, BufferView(m_cubeVertsBuffer.get()), sizeof(Vec3));
 		cmdb.bindVertexBuffer(0, BufferView(m_cubeVertsBuffer.get()), sizeof(Vec3));
-		cmdb.setVertexAttribute(VertexAttribute::kPosition, 0, Format::kR32G32B32_Sfloat, 0);
+		cmdb.setVertexAttribute(VertexAttributeSemantic::kPosition, 0, Format::kR32G32B32_Sfloat, 0);
 		cmdb.bindIndexBuffer(BufferView(m_cubeIndicesBuffer.get()), IndexType::kU16);
 		cmdb.bindIndexBuffer(BufferView(m_cubeIndicesBuffer.get()), IndexType::kU16);
 
 
 		cmdb.bindStorageBuffer(0, 2, GpuSceneArrays::RenderableBoundingVolumeGBuffer::getSingleton().getBufferView());
 		cmdb.bindStorageBuffer(0, 2, GpuSceneArrays::RenderableBoundingVolumeGBuffer::getSingleton().getBufferView());

+ 1 - 1
AnKi/Renderer/Utils/Drawer.cpp

@@ -109,7 +109,7 @@ void RenderableDrawer::drawMdi(const RenderableDrawerArguments& args, CommandBuf
 
 
 	const Bool meshShaderHwSupport = GrManager::getSingleton().getDeviceCapabilities().m_meshShaders;
 	const Bool meshShaderHwSupport = GrManager::getSingleton().getDeviceCapabilities().m_meshShaders;
 
 
-	cmdb.setVertexAttribute(VertexAttribute::kMisc0, 0, Format::kR32G32B32A32_Uint, 0);
+	cmdb.setVertexAttribute(VertexAttributeSemantic::kMisc0, 0, Format::kR32G32B32A32_Uint, 0);
 
 
 	RenderStateBucketContainer::getSingleton().iterateBucketsPerformanceOrder(
 	RenderStateBucketContainer::getSingleton().iterateBucketsPerformanceOrder(
 		args.m_renderingTechinuqe,
 		args.m_renderingTechinuqe,

+ 2 - 2
AnKi/Resource/MeshBinary.h

@@ -170,8 +170,8 @@ class MeshBinaryHeader
 public:
 public:
 	Array<U8, 8> m_magic;
 	Array<U8, 8> m_magic;
 	MeshBinaryFlag m_flags;
 	MeshBinaryFlag m_flags;
-	Array<MeshBinaryVertexBuffer, U32(VertexAttribute::kCount)> m_vertexBuffers;
-	Array<MeshBinaryVertexAttribute, U32(VertexAttribute::kCount)> m_vertexAttributes;
+	Array<MeshBinaryVertexBuffer, U32(VertexAttributeSemantic::kCount)> m_vertexBuffers;
+	Array<MeshBinaryVertexAttribute, U32(VertexAttributeSemantic::kCount)> m_vertexAttributes;
 	IndexType m_indexType;
 	IndexType m_indexType;
 	Array<U8, 3> m_padding;
 	Array<U8, 3> m_padding;
 
 

+ 2 - 2
AnKi/Resource/MeshBinary.xml

@@ -59,8 +59,8 @@ ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(MeshBinaryFlag)
 			<members>
 			<members>
 				<member name="m_magic" type="U8" array_size="8"/>
 				<member name="m_magic" type="U8" array_size="8"/>
 				<member name="m_flags" type="MeshBinaryFlag"/>
 				<member name="m_flags" type="MeshBinaryFlag"/>
-				<member name="m_vertexBuffers" type="MeshBinaryVertexBuffer" array_size="U32(VertexAttribute::kCount)"/>
-				<member name="m_vertexAttributes" type="MeshBinaryVertexAttribute" array_size="U32(VertexAttribute::kCount)"/>
+				<member name="m_vertexBuffers" type="MeshBinaryVertexBuffer" array_size="U32(VertexAttributeSemantic::kCount)"/>
+				<member name="m_vertexAttributes" type="MeshBinaryVertexAttribute" array_size="U32(VertexAttributeSemantic::kCount)"/>
 				<member name="m_indexType" type="IndexType"/>
 				<member name="m_indexType" type="IndexType"/>
 				<member name="m_padding" type="U8" array_size="3"/>
 				<member name="m_padding" type="U8" array_size="3"/>
 				<member name="m_meshletPrimitiveFormat" type="Format" comment="The format of the 3 indices that make a primitive"/>
 				<member name="m_meshletPrimitiveFormat" type="Format" comment="The format of the 3 indices that make a primitive"/>

+ 6 - 1
AnKi/ShaderCompiler/CMakeLists.txt

@@ -2,4 +2,9 @@ file(GLOB_RECURSE sources *.cpp)
 file(GLOB_RECURSE headers *.h)
 file(GLOB_RECURSE headers *.h)
 add_library(AnKiShaderCompiler ${sources} ${headers})
 add_library(AnKiShaderCompiler ${sources} ${headers})
 target_compile_definitions(AnKiShaderCompiler PRIVATE -DANKI_SOURCE_FILE)
 target_compile_definitions(AnKiShaderCompiler PRIVATE -DANKI_SOURCE_FILE)
-target_link_libraries(AnKiShaderCompiler AnKiGrCommon AnKiSpirvCross SPIRV-Tools)
+
+if(WINDOWS)
+	#set(libs ../../../ThirdParty/Dxc/dxcompiler)
+endif()
+
+target_link_libraries(AnKiShaderCompiler AnKiGrCommon AnKiSpirvCross SPIRV-Tools ${libs})

+ 33 - 13
AnKi/ShaderCompiler/Dxc.cpp

@@ -56,7 +56,7 @@ static CString profile(ShaderType shaderType)
 	return "";
 	return "";
 }
 }
 
 
-Error compileHlslToSpirv(CString src, ShaderType shaderType, Bool compileWith16bitTypes, ShaderCompilerDynamicArray<U8>& spirv,
+static Error compileHlsl(CString src, ShaderType shaderType, Bool compileWith16bitTypes, Bool spirv, ShaderCompilerDynamicArray<U8>& bin,
 						 ShaderCompilerString& errorMessage)
 						 ShaderCompilerString& errorMessage)
 {
 {
 	Array<U64, 3> toHash = {g_nextFileId.fetchAdd(1), getCurrentProcessId(), getRandom() & kMaxU32};
 	Array<U64, 3> toHash = {g_nextFileId.fetchAdd(1), getCurrentProcessId(), getRandom() & kMaxU32};
@@ -76,12 +76,12 @@ Error compileHlslToSpirv(CString src, ShaderType shaderType, Bool compileWith16b
 	hlslFile.close();
 	hlslFile.close();
 
 
 	// Call DXC
 	// Call DXC
-	ShaderCompilerString spvFilename;
-	spvFilename.sprintf("%s/%" PRIu64 ".spv", tmpDir.cstr(), rand);
+	ShaderCompilerString binFilename;
+	binFilename.sprintf("%s/%" PRIu64 ".spvdxil", tmpDir.cstr(), rand);
 
 
 	ShaderCompilerDynamicArray<ShaderCompilerString> dxcArgs;
 	ShaderCompilerDynamicArray<ShaderCompilerString> dxcArgs;
 	dxcArgs.emplaceBack("-Fo");
 	dxcArgs.emplaceBack("-Fo");
-	dxcArgs.emplaceBack(spvFilename);
+	dxcArgs.emplaceBack(binFilename);
 	dxcArgs.emplaceBack("-Wall");
 	dxcArgs.emplaceBack("-Wall");
 	dxcArgs.emplaceBack("-Wextra");
 	dxcArgs.emplaceBack("-Wextra");
 	dxcArgs.emplaceBack("-Wno-conversion");
 	dxcArgs.emplaceBack("-Wno-conversion");
@@ -97,9 +97,17 @@ Error compileHlslToSpirv(CString src, ShaderType shaderType, Bool compileWith16b
 	dxcArgs.emplaceBack("main");
 	dxcArgs.emplaceBack("main");
 	dxcArgs.emplaceBack("-T");
 	dxcArgs.emplaceBack("-T");
 	dxcArgs.emplaceBack(profile(shaderType));
 	dxcArgs.emplaceBack(profile(shaderType));
-	dxcArgs.emplaceBack("-spirv");
-	dxcArgs.emplaceBack("-fspv-target-env=vulkan1.1spirv1.4");
-	// dxcArgs.emplaceBack("-fvk-support-nonzero-base-instance"); // Match DX12's behavior, SV_INSTANCEID starts from zero
+	if(spirv)
+	{
+		dxcArgs.emplaceBack("-spirv");
+		dxcArgs.emplaceBack("-fspv-target-env=vulkan1.1spirv1.4");
+		// dxcArgs.emplaceBack("-fvk-support-nonzero-base-instance"); // Match DX12's behavior, SV_INSTANCEID starts from zero
+	}
+	else
+	{
+		dxcArgs.emplaceBack("-Wno-ignored-attributes"); // TODO rm that eventually
+		dxcArgs.emplaceBack("-Wno-inline-asm"); // TODO rm that eventually
+	}
 	// dxcArgs.emplaceBack("-Zi"); // Debug info
 	// dxcArgs.emplaceBack("-Zi"); // Debug info
 	dxcArgs.emplaceBack(hlslFilename);
 	dxcArgs.emplaceBack(hlslFilename);
 
 
@@ -162,16 +170,28 @@ Error compileHlslToSpirv(CString src, ShaderType shaderType, Bool compileWith16b
 		}
 		}
 	}
 	}
 
 
-	CleanupFile spvFileCleanup(spvFilename);
+	CleanupFile binFileCleanup(binFilename);
 
 
 	// Read the spirv back
 	// Read the spirv back
-	File spvFile;
-	ANKI_CHECK(spvFile.open(spvFilename, FileOpenFlag::kRead));
-	spirv.resize(U32(spvFile.getSize()));
-	ANKI_CHECK(spvFile.read(&spirv[0], spirv.getSizeInBytes()));
-	spvFile.close();
+	File binFile;
+	ANKI_CHECK(binFile.open(binFilename, FileOpenFlag::kRead));
+	bin.resize(U32(binFile.getSize()));
+	ANKI_CHECK(binFile.read(&bin[0], bin.getSizeInBytes()));
+	binFile.close();
 
 
 	return Error::kNone;
 	return Error::kNone;
 }
 }
 
 
+Error compileHlslToSpirv(CString src, ShaderType shaderType, Bool compileWith16bitTypes, ShaderCompilerDynamicArray<U8>& spirv,
+						 ShaderCompilerString& errorMessage)
+{
+	return compileHlsl(src, shaderType, compileWith16bitTypes, true, spirv, errorMessage);
+}
+
+Error compileHlslToDxil(CString src, ShaderType shaderType, Bool compileWith16bitTypes, ShaderCompilerDynamicArray<U8>& dxil,
+						ShaderCompilerString& errorMessage)
+{
+	return compileHlsl(src, shaderType, compileWith16bitTypes, false, dxil, errorMessage);
+}
+
 } // end namespace anki
 } // end namespace anki

+ 4 - 0
AnKi/ShaderCompiler/Dxc.h

@@ -16,6 +16,10 @@ namespace anki {
 /// Compile HLSL to SPIR-V.
 /// Compile HLSL to SPIR-V.
 Error compileHlslToSpirv(CString src, ShaderType shaderType, Bool compileWith16bitTypes, ShaderCompilerDynamicArray<U8>& spirv,
 Error compileHlslToSpirv(CString src, ShaderType shaderType, Bool compileWith16bitTypes, ShaderCompilerDynamicArray<U8>& spirv,
 						 ShaderCompilerString& errorMessage);
 						 ShaderCompilerString& errorMessage);
+
+/// Compile HLSL to DXIL.
+Error compileHlslToDxil(CString src, ShaderType shaderType, Bool compileWith16bitTypes, ShaderCompilerDynamicArray<U8>& dxil,
+						ShaderCompilerString& errorMessage);
 /// @}
 /// @}
 
 
 } // end namespace anki
 } // end namespace anki

+ 294 - 36
AnKi/ShaderCompiler/ShaderProgramCompiler.cpp

@@ -10,6 +10,19 @@
 #include <AnKi/Util/HashMap.h>
 #include <AnKi/Util/HashMap.h>
 #include <SpirvCross/spirv_cross.hpp>
 #include <SpirvCross/spirv_cross.hpp>
 
 
+#define ANKI_DIXL_REFLECTION (ANKI_OS_WINDOWS)
+
+#if ANKI_DIXL_REFLECTION
+#	include <windows.h>
+#	include <ThirdParty/Dxc/dxcapi.h>
+#	include <ThirdParty/Dxc/d3d12shader.h>
+#	include <wrl.h>
+#	include <AnKi/Util/CleanupWindows.h>
+
+static HMODULE g_dxcLib = 0;
+static DxcCreateInstanceProc g_DxcCreateInstance = nullptr;
+#endif
+
 namespace anki {
 namespace anki {
 
 
 void freeShaderProgramBinary(ShaderProgramBinary*& binary)
 void freeShaderProgramBinary(ShaderProgramBinary*& binary)
@@ -119,7 +132,8 @@ static Error doReflectionSpirv(ConstWeakArray<U8> spirv, ShaderType type, Shader
 	spirv_cross::ShaderResources rsrc = spvc.get_shader_resources();
 	spirv_cross::ShaderResources rsrc = spvc.get_shader_resources();
 	spirv_cross::ShaderResources rsrcActive = spvc.get_shader_resources(spvc.get_active_interface_variables());
 	spirv_cross::ShaderResources rsrcActive = spvc.get_shader_resources(spvc.get_active_interface_variables());
 
 
-	auto func = [&](const spirv_cross::SmallVector<spirv_cross::Resource>& resources, const DescriptorType origType) -> Error {
+	auto func = [&](const spirv_cross::SmallVector<spirv_cross::Resource>& resources, const DescriptorType origType,
+					const DescriptorFlag origFlags) -> Error {
 		for(const spirv_cross::Resource& r : resources)
 		for(const spirv_cross::Resource& r : resources)
 		{
 		{
 			const U32 id = r.id;
 			const U32 id = r.id;
@@ -147,15 +161,22 @@ static Error doReflectionSpirv(ConstWeakArray<U8> spirv, ShaderType type, Shader
 
 
 			// Images are special, they might be texel buffers
 			// Images are special, they might be texel buffers
 			DescriptorType type = origType;
 			DescriptorType type = origType;
+			DescriptorFlag flags = origFlags;
 			if(type == DescriptorType::kTexture)
 			if(type == DescriptorType::kTexture)
 			{
 			{
-				if(typeInfo.image.dim == spv::DimBuffer && typeInfo.image.sampled == 1)
+				if(typeInfo.image.dim == spv::DimBuffer)
 				{
 				{
-					type = DescriptorType::kReadTexelBuffer;
-				}
-				else if(typeInfo.image.dim == spv::DimBuffer && typeInfo.image.sampled == 2)
-				{
-					type = DescriptorType::kReadWriteTexelBuffer;
+					type = DescriptorType::kTexelBuffer;
+
+					if(typeInfo.image.sampled == 1)
+					{
+						flags = DescriptorFlag::kRead;
+					}
+					else
+					{
+						ANKI_ASSERT(typeInfo.image.sampled == 2);
+						flags = DescriptorFlag::kReadWrite;
+					}
 				}
 				}
 			}
 			}
 
 
@@ -165,11 +186,13 @@ static Error doReflectionSpirv(ConstWeakArray<U8> spirv, ShaderType type, Shader
 				// New binding, init it
 				// New binding, init it
 				refl.m_descriptorTypes[set][binding] = type;
 				refl.m_descriptorTypes[set][binding] = type;
 				refl.m_descriptorArraySizes[set][binding] = U16(arraySize);
 				refl.m_descriptorArraySizes[set][binding] = U16(arraySize);
+				refl.m_descriptorFlags[set][binding] = flags;
 			}
 			}
 			else
 			else
 			{
 			{
 				// Same binding, make sure the type is compatible
 				// Same binding, make sure the type is compatible
-				if(refl.m_descriptorTypes[set][binding] != type || refl.m_descriptorArraySizes[set][binding] != arraySize)
+				if(refl.m_descriptorTypes[set][binding] != type || refl.m_descriptorArraySizes[set][binding] != arraySize
+				   || refl.m_descriptorFlags[set][binding] != flags)
 				{
 				{
 					errorStr.sprintf("Descriptor with same binding but different type or array size: %s", r.name.c_str());
 					errorStr.sprintf("Descriptor with same binding but different type or array size: %s", r.name.c_str());
 					return Error::kUserData;
 					return Error::kUserData;
@@ -181,26 +204,26 @@ static Error doReflectionSpirv(ConstWeakArray<U8> spirv, ShaderType type, Shader
 	};
 	};
 
 
 	Error err = Error::kNone;
 	Error err = Error::kNone;
-	err = func(rsrc.uniform_buffers, DescriptorType::kUniformBuffer);
+	err = func(rsrc.uniform_buffers, DescriptorType::kUniformBuffer, DescriptorFlag::kRead);
 	if(!err)
 	if(!err)
 	{
 	{
-		err = func(rsrc.separate_images, DescriptorType::kTexture); // This also handles texture buffers
+		err = func(rsrc.separate_images, DescriptorType::kTexture, DescriptorFlag::kRead); // This also handles texel buffers
 	}
 	}
 	if(!err)
 	if(!err)
 	{
 	{
-		err = func(rsrc.separate_samplers, DescriptorType::kSampler);
+		err = func(rsrc.separate_samplers, DescriptorType::kSampler, DescriptorFlag::kRead);
 	}
 	}
 	if(!err)
 	if(!err)
 	{
 	{
-		err = func(rsrc.storage_buffers, DescriptorType::kStorageBuffer);
+		err = func(rsrc.storage_buffers, DescriptorType::kStorageBuffer, DescriptorFlag::kReadWrite);
 	}
 	}
 	if(!err)
 	if(!err)
 	{
 	{
-		err = func(rsrc.storage_images, DescriptorType::kStorageImage);
+		err = func(rsrc.storage_images, DescriptorType::kTexture, DescriptorFlag::kReadWrite);
 	}
 	}
 	if(!err)
 	if(!err)
 	{
 	{
-		err = func(rsrc.acceleration_structures, DescriptorType::kAccelerationStructure);
+		err = func(rsrc.acceleration_structures, DescriptorType::kAccelerationStructure, DescriptorFlag::kRead);
 	}
 	}
 
 
 	// Color attachments
 	// Color attachments
@@ -233,39 +256,39 @@ static Error doReflectionSpirv(ConstWeakArray<U8> spirv, ShaderType type, Shader
 	{
 	{
 		for(const spirv_cross::Resource& r : rsrcActive.stage_inputs)
 		for(const spirv_cross::Resource& r : rsrcActive.stage_inputs)
 		{
 		{
-			VertexAttribute a = VertexAttribute::kCount;
+			VertexAttributeSemantic a = VertexAttributeSemantic::kCount;
 #define ANKI_ATTRIB_NAME(x) "in.var." #x
 #define ANKI_ATTRIB_NAME(x) "in.var." #x
 			if(r.name == ANKI_ATTRIB_NAME(POSITION))
 			if(r.name == ANKI_ATTRIB_NAME(POSITION))
 			{
 			{
-				a = VertexAttribute::kPosition;
+				a = VertexAttributeSemantic::kPosition;
 			}
 			}
 			else if(r.name == ANKI_ATTRIB_NAME(NORMAL))
 			else if(r.name == ANKI_ATTRIB_NAME(NORMAL))
 			{
 			{
-				a = VertexAttribute::kNormal;
+				a = VertexAttributeSemantic::kNormal;
 			}
 			}
 			else if(r.name == ANKI_ATTRIB_NAME(TEXCOORD0) || r.name == ANKI_ATTRIB_NAME(TEXCOORD))
 			else if(r.name == ANKI_ATTRIB_NAME(TEXCOORD0) || r.name == ANKI_ATTRIB_NAME(TEXCOORD))
 			{
 			{
-				a = VertexAttribute::kTexCoord;
+				a = VertexAttributeSemantic::kTexCoord;
 			}
 			}
 			else if(r.name == ANKI_ATTRIB_NAME(COLOR))
 			else if(r.name == ANKI_ATTRIB_NAME(COLOR))
 			{
 			{
-				a = VertexAttribute::kColor;
+				a = VertexAttributeSemantic::kColor;
 			}
 			}
 			else if(r.name == ANKI_ATTRIB_NAME(MISC0) || r.name == ANKI_ATTRIB_NAME(MISC))
 			else if(r.name == ANKI_ATTRIB_NAME(MISC0) || r.name == ANKI_ATTRIB_NAME(MISC))
 			{
 			{
-				a = VertexAttribute::kMisc0;
+				a = VertexAttributeSemantic::kMisc0;
 			}
 			}
 			else if(r.name == ANKI_ATTRIB_NAME(MISC1))
 			else if(r.name == ANKI_ATTRIB_NAME(MISC1))
 			{
 			{
-				a = VertexAttribute::kMisc1;
+				a = VertexAttributeSemantic::kMisc1;
 			}
 			}
 			else if(r.name == ANKI_ATTRIB_NAME(MISC2))
 			else if(r.name == ANKI_ATTRIB_NAME(MISC2))
 			{
 			{
-				a = VertexAttribute::kMisc2;
+				a = VertexAttributeSemantic::kMisc2;
 			}
 			}
 			else if(r.name == ANKI_ATTRIB_NAME(MISC3))
 			else if(r.name == ANKI_ATTRIB_NAME(MISC3))
 			{
 			{
-				a = VertexAttribute::kMisc3;
+				a = VertexAttributeSemantic::kMisc3;
 			}
 			}
 			else
 			else
 			{
 			{
@@ -302,7 +325,191 @@ static Error doReflectionSpirv(ConstWeakArray<U8> spirv, ShaderType type, Shader
 	return Error::kNone;
 	return Error::kNone;
 }
 }
 
 
-static void compileVariantAsync(const ShaderProgramParser& parser, ShaderProgramBinaryMutation& mutation,
+#if ANKI_DIXL_REFLECTION
+#	define ANKI_REFL_CHECK(x) \
+		do \
+		{ \
+			HRESULT rez; \
+			if((rez = (x)) < 0) [[unlikely]] \
+			{ \
+				errorStr.sprintf("DXC function failed (HRESULT: %d): %s", rez, #x); \
+				return Error::kFunctionFailed; \
+			} \
+		} while(0)
+
+static Error doReflectionDxil(ConstWeakArray<U8> dxil, ShaderType type, ShaderReflection& refl, ShaderCompilerString& errorStr)
+{
+	using Microsoft::WRL::ComPtr;
+
+	ComPtr<IDxcUtils> utils;
+	ANKI_REFL_CHECK(g_DxcCreateInstance(CLSID_DxcUtils, IID_PPV_ARGS(&utils)));
+
+	const DxcBuffer buff = {dxil.getBegin(), dxil.getSizeInBytes(), 0};
+	ComPtr<ID3D12ShaderReflection> dxRefl;
+	ANKI_REFL_CHECK(utils->CreateReflection(&buff, IID_PPV_ARGS(&dxRefl)));
+
+	D3D12_SHADER_DESC shaderDesc = {};
+	dxRefl->GetDesc(&shaderDesc);
+
+	for(U32 i = 0; i < shaderDesc.BoundResources; ++i)
+	{
+		D3D12_SHADER_INPUT_BIND_DESC bind;
+		ANKI_REFL_CHECK(dxRefl->GetResourceBindingDesc(i, &bind));
+
+		ShaderReflectionBinding akBinding;
+
+		akBinding.m_type = DescriptorType::kCount;
+		akBinding.m_flags = DescriptorFlag::kNone;
+		akBinding.m_arraySize = U16(bind.BindCount);
+
+		if(bind.Type == D3D_SIT_CBUFFER)
+		{
+			// ConstantBuffer
+			akBinding.m_type = DescriptorType::kUniformBuffer;
+			akBinding.m_flags = DescriptorFlag::kRead;
+			akBinding.m_semantic = BindingSemantic('b', bind.BindPoint);
+		}
+		else if(bind.Type == D3D_SIT_TEXTURE && bind.Dimension != D3D_SRV_DIMENSION_BUFFER)
+		{
+			// Texture2D etc
+			akBinding.m_type = DescriptorType::kTexture;
+			akBinding.m_flags = DescriptorFlag::kRead;
+			akBinding.m_semantic = BindingSemantic('t', bind.BindPoint);
+		}
+		else if(bind.Type == D3D_SIT_TEXTURE && bind.Dimension == D3D_SRV_DIMENSION_BUFFER)
+		{
+			// Buffer
+			akBinding.m_type = DescriptorType::kTexelBuffer;
+			akBinding.m_flags = DescriptorFlag::kRead;
+			akBinding.m_semantic = BindingSemantic('t', bind.BindPoint);
+		}
+		else if(bind.Type == D3D_SIT_SAMPLER)
+		{
+			// SamplerState
+			akBinding.m_type = DescriptorType::kSampler;
+			akBinding.m_flags = DescriptorFlag::kRead;
+			akBinding.m_semantic = BindingSemantic('s', bind.BindPoint);
+		}
+		else if(bind.Type == D3D_SIT_UAV_RWTYPED && bind.Dimension == D3D_SRV_DIMENSION_BUFFER)
+		{
+			// RWBuffer
+			akBinding.m_type = DescriptorType::kTexelBuffer;
+			akBinding.m_flags = DescriptorFlag::kReadWrite;
+			akBinding.m_semantic = BindingSemantic('u', bind.BindPoint);
+		}
+		else if(bind.Type == D3D_SIT_UAV_RWTYPED && bind.Dimension != D3D_SRV_DIMENSION_BUFFER)
+		{
+			// RWTexture2D etc
+			akBinding.m_type = DescriptorType::kTexture;
+			akBinding.m_flags = DescriptorFlag::kReadWrite;
+			akBinding.m_semantic = BindingSemantic('u', bind.BindPoint);
+		}
+		else if(bind.Type == D3D_SIT_BYTEADDRESS)
+		{
+			// ByteAddressBuffer
+			akBinding.m_type = DescriptorType::kStorageBuffer;
+			akBinding.m_flags = DescriptorFlag::kRead | DescriptorFlag::kByteAddressBuffer;
+			akBinding.m_semantic = BindingSemantic('t', bind.BindPoint);
+		}
+		else if(bind.Type == D3D_SIT_UAV_RWBYTEADDRESS)
+		{
+			// RWByteAddressBuffer
+			akBinding.m_type = DescriptorType::kStorageBuffer;
+			akBinding.m_flags = DescriptorFlag::kReadWrite | DescriptorFlag::kByteAddressBuffer;
+			akBinding.m_semantic = BindingSemantic('u', bind.BindPoint);
+		}
+		else if(bind.Type == D3D_SIT_RTACCELERATIONSTRUCTURE)
+		{
+			// RaytracingAccelerationStructure
+			akBinding.m_type = DescriptorType::kAccelerationStructure;
+			akBinding.m_flags = DescriptorFlag::kRead;
+			akBinding.m_semantic = BindingSemantic('t', bind.BindPoint);
+		}
+		else
+		{
+			ANKI_SHADER_COMPILER_LOGE("Unrecognized type for binding: %s", bind.Name);
+			return Error::kUserData;
+		}
+
+		refl.m_bindings[bind.Space][refl.m_bindingCounts[bind.Space++]] = akBinding;
+	}
+
+	if(type == ShaderType::kVertex)
+	{
+		for(U32 i = 0; i < shaderDesc.InputParameters; ++i)
+		{
+			D3D12_SIGNATURE_PARAMETER_DESC in;
+			ANKI_REFL_CHECK(dxRefl->GetInputParameterDesc(i, &in));
+
+			VertexAttributeSemantic a = VertexAttributeSemantic::kCount;
+#	define ANKI_ATTRIB_NAME(x, idx) CString(in.SemanticName) == #    x&& in.SemanticIndex == idx
+			if(ANKI_ATTRIB_NAME(POSITION, 0))
+			{
+				a = VertexAttributeSemantic::kPosition;
+			}
+			else if(ANKI_ATTRIB_NAME(NORMAL, 0))
+			{
+				a = VertexAttributeSemantic::kNormal;
+			}
+			else if(ANKI_ATTRIB_NAME(TEXCOORD, 0))
+			{
+				a = VertexAttributeSemantic::kTexCoord;
+			}
+			else if(ANKI_ATTRIB_NAME(COLOR, 0))
+			{
+				a = VertexAttributeSemantic::kColor;
+			}
+			else if(ANKI_ATTRIB_NAME(MISC, 0))
+			{
+				a = VertexAttributeSemantic::kMisc0;
+			}
+			else if(ANKI_ATTRIB_NAME(MISC, 1))
+			{
+				a = VertexAttributeSemantic::kMisc1;
+			}
+			else if(ANKI_ATTRIB_NAME(MISC, 2))
+			{
+				a = VertexAttributeSemantic::kMisc2;
+			}
+			else if(ANKI_ATTRIB_NAME(MISC, 3))
+			{
+				a = VertexAttributeSemantic::kMisc3;
+			}
+			else if(ANKI_ATTRIB_NAME(SV_VERTEXID, 0))
+			{
+				// Ignore
+			}
+			else
+			{
+				errorStr.sprintf("Unexpected attribute name: %s", in.SemanticName);
+				return Error::kUserData;
+			}
+#	undef ANKI_ATTRIB_NAME
+
+			refl.m_vertexAttributeMask.set(a);
+			refl.m_vertexAttributeLocations[a] = U8(i);
+		}
+	}
+
+	if(type == ShaderType::kFragment)
+	{
+		for(U32 i = 0; i < shaderDesc.OutputParameters; ++i)
+		{
+			D3D12_SIGNATURE_PARAMETER_DESC desc;
+			ANKI_REFL_CHECK(dxRefl->GetOutputParameterDesc(i, &desc));
+
+			if(CString(desc.SemanticName) == "SV_TARGET")
+			{
+				refl.m_colorAttachmentWritemask.set(desc.SemanticIndex);
+			}
+		}
+	}
+
+	return Error::kNone;
+}
+#endif // #if ANKI_DIXL_REFLECTION
+
+static void compileVariantAsync(const ShaderProgramParser& parser, Bool spirv, ShaderProgramBinaryMutation& mutation,
 								ShaderCompilerDynamicArray<ShaderProgramBinaryVariant>& variants,
 								ShaderCompilerDynamicArray<ShaderProgramBinaryVariant>& variants,
 								ShaderCompilerDynamicArray<ShaderProgramBinaryCodeBlock>& codeBlocks,
 								ShaderCompilerDynamicArray<ShaderProgramBinaryCodeBlock>& codeBlocks,
 								ShaderCompilerDynamicArray<U64>& sourceCodeHashes, ShaderProgramAsyncTaskInterface& taskManager, Mutex& mtx,
 								ShaderCompilerDynamicArray<U64>& sourceCodeHashes, ShaderProgramAsyncTaskInterface& taskManager, Mutex& mtx,
@@ -318,6 +525,7 @@ static void compileVariantAsync(const ShaderProgramParser& parser, ShaderProgram
 		ShaderCompilerDynamicArray<U64>* m_sourceCodeHashes;
 		ShaderCompilerDynamicArray<U64>* m_sourceCodeHashes;
 		Mutex* m_mtx;
 		Mutex* m_mtx;
 		Atomic<I32>* m_err;
 		Atomic<I32>* m_err;
+		Bool m_spirv;
 	};
 	};
 
 
 	Ctx* ctx = newInstance<Ctx>(ShaderCompilerMemoryPool::getSingleton());
 	Ctx* ctx = newInstance<Ctx>(ShaderCompilerMemoryPool::getSingleton());
@@ -328,6 +536,7 @@ static void compileVariantAsync(const ShaderProgramParser& parser, ShaderProgram
 	ctx->m_sourceCodeHashes = &sourceCodeHashes;
 	ctx->m_sourceCodeHashes = &sourceCodeHashes;
 	ctx->m_mtx = &mtx;
 	ctx->m_mtx = &mtx;
 	ctx->m_err = &error;
 	ctx->m_err = &error;
+	ctx->m_spirv = spirv;
 
 
 	auto callback = [](void* userData) {
 	auto callback = [](void* userData) {
 		Ctx& ctx = *static_cast<Ctx*>(userData);
 		Ctx& ctx = *static_cast<Ctx*>(userData);
@@ -395,17 +604,38 @@ static void compileVariantAsync(const ShaderProgramParser& parser, ShaderProgram
 					}
 					}
 				}
 				}
 
 
-				ShaderCompilerDynamicArray<U8> spirv;
-				err = compileHlslToSpirv(source, shaderType, ctx.m_parser->compileWith16bitTypes(), spirv, compilerErrorLog);
+				ShaderCompilerDynamicArray<U8> il;
+				if(ctx.m_spirv)
+				{
+					err = compileHlslToSpirv(source, shaderType, ctx.m_parser->compileWith16bitTypes(), il, compilerErrorLog);
+				}
+				else
+				{
+					err = compileHlslToDxil(source, shaderType, ctx.m_parser->compileWith16bitTypes(), il, compilerErrorLog);
+				}
+
 				if(err)
 				if(err)
 				{
 				{
 					break;
 					break;
 				}
 				}
 
 
-				const U64 newHash = computeHash(spirv.getBegin(), spirv.getSizeInBytes());
+				const U64 newHash = computeHash(il.getBegin(), il.getSizeInBytes());
 
 
 				ShaderReflection refl;
 				ShaderReflection refl;
-				err = doReflectionSpirv(spirv, shaderType, refl, compilerErrorLog);
+				if(ctx.m_spirv)
+				{
+					err = doReflectionSpirv(il, shaderType, refl, compilerErrorLog);
+				}
+				else
+				{
+#if ANKI_DIXL_REFLECTION
+					err = doReflectionDxil(il, shaderType, refl, compilerErrorLog);
+#else
+					ANKI_SHADER_COMPILER_LOGE("Can't generate shader compilation on non-windows platforms");
+					err = Error::kFunctionFailed;
+#endif
+				}
+
 				if(err)
 				if(err)
 				{
 				{
 					break;
 					break;
@@ -431,7 +661,7 @@ static void compileVariantAsync(const ShaderProgramParser& parser, ShaderProgram
 						codeBlockIndices[t].m_codeBlockIndices[shaderType] = ctx.m_codeBlocks->getSize();
 						codeBlockIndices[t].m_codeBlockIndices[shaderType] = ctx.m_codeBlocks->getSize();
 
 
 						auto& codeBlock = *ctx.m_codeBlocks->emplaceBack();
 						auto& codeBlock = *ctx.m_codeBlocks->emplaceBack();
-						spirv.moveAndReset(codeBlock.m_binary);
+						il.moveAndReset(codeBlock.m_binary);
 						codeBlock.m_hash = newHash;
 						codeBlock.m_hash = newHash;
 						codeBlock.m_reflection = refl;
 						codeBlock.m_reflection = refl;
 
 
@@ -505,12 +735,40 @@ static void compileVariantAsync(const ShaderProgramParser& parser, ShaderProgram
 	taskManager.enqueueTask(callback, ctx);
 	taskManager.enqueueTask(callback, ctx);
 }
 }
 
 
-Error compileShaderProgramInternal(CString fname, ShaderProgramFilesystemInterface& fsystem, ShaderProgramPostParseInterface* postParseCallback,
-								   ShaderProgramAsyncTaskInterface* taskManager_, ConstWeakArray<ShaderCompilerDefine> defines,
-								   ShaderProgramBinary*& binary)
+static Error compileShaderProgramInternal(CString fname, Bool spirv, ShaderProgramFilesystemInterface& fsystem,
+										  ShaderProgramPostParseInterface* postParseCallback, ShaderProgramAsyncTaskInterface* taskManager_,
+										  ConstWeakArray<ShaderCompilerDefine> defines_, ShaderProgramBinary*& binary)
 {
 {
+#if ANKI_DIXL_REFLECTION
+	if(!spirv)
+	{
+		// Init DXC
+		g_dxcLib = LoadLibraryA(ANKI_SOURCE_DIRECTORY "/ThirdParty/Bin/Windows64/dxcompiler.dll");
+		if(g_dxcLib == 0)
+		{
+			ANKI_SHADER_COMPILER_LOGE("dxcompiler.dll missing or wrong architecture");
+			return Error::kFunctionFailed;
+		}
+
+		g_DxcCreateInstance = reinterpret_cast<DxcCreateInstanceProc>(GetProcAddress(g_dxcLib, "DxcCreateInstance"));
+		if(g_DxcCreateInstance == nullptr)
+		{
+			ANKI_SHADER_COMPILER_LOGE("DxcCreateInstance was not found in the dxcompiler.dll");
+			return Error::kFunctionFailed;
+		}
+	}
+#endif
+
 	ShaderCompilerMemoryPool& memPool = ShaderCompilerMemoryPool::getSingleton();
 	ShaderCompilerMemoryPool& memPool = ShaderCompilerMemoryPool::getSingleton();
 
 
+	ShaderCompilerDynamicArray<ShaderCompilerDefine> defines;
+	for(const ShaderCompilerDefine& d : defines_)
+	{
+		defines.emplaceBack(d);
+	}
+	defines.emplaceBack(ShaderCompilerDefine{"ANKI_TARGET_SPIRV", spirv});
+	defines.emplaceBack(ShaderCompilerDefine{"ANKI_TARGET_DXIL", !spirv});
+
 	// Initialize the binary
 	// Initialize the binary
 	binary = newInstance<ShaderProgramBinary>(memPool);
 	binary = newInstance<ShaderProgramBinary>(memPool);
 	memcpy(&binary->m_magic[0], kShaderBinaryMagic, 8);
 	memcpy(&binary->m_magic[0], kShaderBinaryMagic, 8);
@@ -615,7 +873,7 @@ Error compileShaderProgramInternal(CString fname, ShaderProgramFilesystemInterfa
 			{
 			{
 				// New and unique mutation and thus variant, add it
 				// New and unique mutation and thus variant, add it
 
 
-				compileVariantAsync(parser, mutation, variants, codeBlocks, sourceCodeHashes, taskManager, mtx, errorAtomic);
+				compileVariantAsync(parser, spirv, mutation, variants, codeBlocks, sourceCodeHashes, taskManager, mtx, errorAtomic);
 
 
 				ANKI_ASSERT(mutationHashToIdx.find(mutation.m_hash) == mutationHashToIdx.getEnd());
 				ANKI_ASSERT(mutationHashToIdx.find(mutation.m_hash) == mutationHashToIdx.getEnd());
 				mutationHashToIdx.emplace(mutation.m_hash, mutationCount - 1);
 				mutationHashToIdx.emplace(mutation.m_hash, mutationCount - 1);
@@ -642,7 +900,7 @@ Error compileShaderProgramInternal(CString fname, ShaderProgramFilesystemInterfa
 		ShaderCompilerDynamicArray<ShaderProgramBinaryCodeBlock> codeBlocks;
 		ShaderCompilerDynamicArray<ShaderProgramBinaryCodeBlock> codeBlocks;
 		ShaderCompilerDynamicArray<U64> sourceCodeHashes;
 		ShaderCompilerDynamicArray<U64> sourceCodeHashes;
 
 
-		compileVariantAsync(parser, binary->m_mutations[0], variants, codeBlocks, sourceCodeHashes, taskManager, mtx, errorAtomic);
+		compileVariantAsync(parser, spirv, binary->m_mutations[0], variants, codeBlocks, sourceCodeHashes, taskManager, mtx, errorAtomic);
 
 
 		ANKI_CHECK(taskManager.joinTasks());
 		ANKI_CHECK(taskManager.joinTasks());
 		ANKI_CHECK(Error(errorAtomic.getNonAtomically()));
 		ANKI_CHECK(Error(errorAtomic.getNonAtomically()));
@@ -708,10 +966,10 @@ Error compileShaderProgramInternal(CString fname, ShaderProgramFilesystemInterfa
 	return Error::kNone;
 	return Error::kNone;
 }
 }
 
 
-Error compileShaderProgram(CString fname, ShaderProgramFilesystemInterface& fsystem, ShaderProgramPostParseInterface* postParseCallback,
+Error compileShaderProgram(CString fname, Bool spirv, ShaderProgramFilesystemInterface& fsystem, ShaderProgramPostParseInterface* postParseCallback,
 						   ShaderProgramAsyncTaskInterface* taskManager, ConstWeakArray<ShaderCompilerDefine> defines, ShaderProgramBinary*& binary)
 						   ShaderProgramAsyncTaskInterface* taskManager, ConstWeakArray<ShaderCompilerDefine> defines, ShaderProgramBinary*& binary)
 {
 {
-	const Error err = compileShaderProgramInternal(fname, fsystem, postParseCallback, taskManager, defines, binary);
+	const Error err = compileShaderProgramInternal(fname, spirv, fsystem, postParseCallback, taskManager, defines, binary);
 	if(err)
 	if(err)
 	{
 	{
 		ANKI_SHADER_COMPILER_LOGE("Failed to compile: %s", fname.cstr());
 		ANKI_SHADER_COMPILER_LOGE("Failed to compile: %s", fname.cstr());

+ 1 - 1
AnKi/ShaderCompiler/ShaderProgramCompiler.h

@@ -40,7 +40,7 @@ inline Error deserializeShaderProgramBinaryFromFile(CString fname, ShaderProgram
 }
 }
 
 
 /// Takes an AnKi special shader program and spits a binary.
 /// Takes an AnKi special shader program and spits a binary.
-Error compileShaderProgram(CString fname, ShaderProgramFilesystemInterface& fsystem, ShaderProgramPostParseInterface* postParseCallback,
+Error compileShaderProgram(CString fname, Bool spirv, ShaderProgramFilesystemInterface& fsystem, ShaderProgramPostParseInterface* postParseCallback,
 						   ShaderProgramAsyncTaskInterface* taskManager, ConstWeakArray<ShaderCompilerDefine> defines, ShaderProgramBinary*& binary);
 						   ShaderProgramAsyncTaskInterface* taskManager, ConstWeakArray<ShaderCompilerDefine> defines, ShaderProgramBinary*& binary);
 
 
 /// Free the binary created ONLY by compileShaderProgram.
 /// Free the binary created ONLY by compileShaderProgram.

+ 4 - 4
AnKi/ShaderCompiler/ShaderProgramParser.cpp

@@ -492,7 +492,7 @@ Error ShaderProgramParser::parseLine(CString line, CString fname, Bool& foundPra
 		// We _must_ have an #include
 		// We _must_ have an #include
 		ANKI_CHECK(parseInclude(token + 1, end, line, fname, depth));
 		ANKI_CHECK(parseInclude(token + 1, end, line, fname, depth));
 
 
-		getAppendSourceList().pushBackSprintf("#line %u \"%s\"", lineNo + 1, fname.cstr());
+		getAppendSourceList().pushBackSprintf("#line %u \"%s\"", lineNo + 1, sanitizeFilename(fname).cstr());
 	}
 	}
 	else if((token < end) && ((foundAloneHash && *token == "pragma") || *token == "#pragma"))
 	else if((token < end) && ((foundAloneHash && *token == "pragma") || *token == "#pragma"))
 	{
 	{
@@ -520,7 +520,7 @@ Error ShaderProgramParser::parseLine(CString line, CString fname, Bool& foundPra
 												  "#define _ANKI_INCL_GUARD_%" PRIu64,
 												  "#define _ANKI_INCL_GUARD_%" PRIu64,
 												  hash, hash);
 												  hash, hash);
 
 
-			getAppendSourceList().pushBackSprintf("#line %u \"%s\"", lineNo + 1, fname.cstr());
+			getAppendSourceList().pushBackSprintf("#line %u \"%s\"", lineNo + 1, sanitizeFilename(fname).cstr());
 		}
 		}
 		else if(*token == "anki")
 		else if(*token == "anki")
 		{
 		{
@@ -573,7 +573,7 @@ Error ShaderProgramParser::parseLine(CString line, CString fname, Bool& foundPra
 			}
 			}
 
 
 			// For good measure
 			// For good measure
-			getAppendSourceList().pushBackSprintf("#line %u \"%s\"", lineNo + 1, fname.cstr());
+			getAppendSourceList().pushBackSprintf("#line %u \"%s\"", lineNo + 1, sanitizeFilename(fname).cstr());
 		}
 		}
 		else
 		else
 		{
 		{
@@ -748,7 +748,7 @@ Error ShaderProgramParser::parseFile(CString fname, U32 depth)
 		ANKI_SHADER_COMPILER_LOGE("Source is empty");
 		ANKI_SHADER_COMPILER_LOGE("Source is empty");
 	}
 	}
 
 
-	getAppendSourceList().pushBackSprintf("#line 0 \"%s\"", fname.cstr());
+	getAppendSourceList().pushBackSprintf("#line 0 \"%s\"", sanitizeFilename(fname).cstr());
 
 
 	// Parse lines
 	// Parse lines
 	U32 lineNo = 1;
 	U32 lineNo = 1;

+ 7 - 0
AnKi/ShaderCompiler/ShaderProgramParser.h

@@ -196,6 +196,13 @@ private:
 
 
 	static Bool mutatorHasValue(const ShaderProgramParserMutator& mutator, MutatorValue value);
 	static Bool mutatorHasValue(const ShaderProgramParserMutator& mutator, MutatorValue value);
 
 
+	static ShaderCompilerString sanitizeFilename(CString fname)
+	{
+		ShaderCompilerString s = fname;
+		s.replaceAll("\\", "\\\\");
+		return s;
+	}
+
 	Error checkNoActiveStruct() const
 	Error checkNoActiveStruct() const
 	{
 	{
 		if(m_insideStruct)
 		if(m_insideStruct)

+ 8 - 0
AnKi/Shaders/CMakeLists.txt

@@ -34,6 +34,14 @@ else()
 	set(extra_compiler_args ${extra_compiler_args} "-DANKI_FORCE_FULL_FP_PRECISION=0")
 	set(extra_compiler_args ${extra_compiler_args} "-DANKI_FORCE_FULL_FP_PRECISION=0")
 endif()
 endif()
 
 
+if(VULKAN)
+	message("++ Compiling shaders in SPIR-V")
+	set(extra_compiler_args ${extra_compiler_args} "-spirv")
+else()
+	message("++ Compiling shaders in DXIL")
+	set(extra_compiler_args ${extra_compiler_args} "-dxil")
+endif()
+
 include(FindPythonInterp)
 include(FindPythonInterp)
 
 
 foreach(prog_fname ${prog_fnames})
 foreach(prog_fname ${prog_fnames})

+ 1 - 1
AnKi/Shaders/ClusterBinningPackVisibles.ankiprog

@@ -49,7 +49,7 @@ typedef GpuSceneGlobalIlluminationProbe GpuSceneType;
 
 
 	const Bool isPoint = ((U32)input.m_flags & (U32)GpuSceneLightFlag::kPointLight) ? true : false;
 	const Bool isPoint = ((U32)input.m_flags & (U32)GpuSceneLightFlag::kPointLight) ? true : false;
 
 
-	LightUnion output;
+	LightUnion output = (LightUnion)0;
 	output.m_position = input.m_position;
 	output.m_position = input.m_position;
 	output.m_radius = input.m_radius;
 	output.m_radius = input.m_radius;
 
 

+ 1 - 1
AnKi/Shaders/GBufferGeneric.ankiprog

@@ -150,7 +150,7 @@ struct MeshPerPrimitiveOut
 	U32 m_meshletIndex : MESHLET_INDEX;
 	U32 m_meshletIndex : MESHLET_INDEX;
 #endif
 #endif
 
 
-	I32 m_cullPrimitive : SV_CULLPRIMITIVE; // TODO: Make it Bool when https://github.com/microsoft/DirectXShaderCompiler/issues/6042 is fixed
+	Bool m_cullPrimitive : SV_CULLPRIMITIVE;
 };
 };
 
 
 struct FragOut
 struct FragOut

+ 1 - 0
AnKi/Shaders/GpuVisibility.ankiprog

@@ -245,6 +245,7 @@ struct DrawIndirectArgsWithPadding
 				indirect.m_instanceCount = 1;
 				indirect.m_instanceCount = 1;
 				indirect.m_firstVertex = 0;
 				indirect.m_firstVertex = 0;
 				indirect.m_firstInstance = bucketDrawcallIdx;
 				indirect.m_firstInstance = bucketDrawcallIdx;
+				indirect.m_padding = 0;
 				g_drawIndirectArgs[indirectIdx] = indirect;
 				g_drawIndirectArgs[indirectIdx] = indirect;
 
 
 				UVec4 instanceVertex;
 				UVec4 instanceVertex;

+ 3 - 3
AnKi/Ui/Canvas.cpp

@@ -220,9 +220,9 @@ void Canvas::appendToCommandBufferInternal(CommandBuffer& cmdb)
 	cmdb.setViewport(0, 0, U32(fbWidth), U32(fbHeight));
 	cmdb.setViewport(0, 0, U32(fbWidth), U32(fbHeight));
 
 
 	cmdb.bindVertexBuffer(0, vertsToken, sizeof(ImDrawVert));
 	cmdb.bindVertexBuffer(0, vertsToken, sizeof(ImDrawVert));
-	cmdb.setVertexAttribute(VertexAttribute::kPosition, 0, Format::kR32G32_Sfloat, 0);
-	cmdb.setVertexAttribute(VertexAttribute::kColor, 0, Format::kR8G8B8A8_Unorm, sizeof(Vec2) * 2);
-	cmdb.setVertexAttribute(VertexAttribute::kTexCoord, 0, Format::kR32G32_Sfloat, sizeof(Vec2));
+	cmdb.setVertexAttribute(VertexAttributeSemantic::kPosition, 0, Format::kR32G32_Sfloat, 0);
+	cmdb.setVertexAttribute(VertexAttributeSemantic::kColor, 0, Format::kR8G8B8A8_Unorm, sizeof(Vec2) * 2);
+	cmdb.setVertexAttribute(VertexAttributeSemantic::kTexCoord, 0, Format::kR32G32_Sfloat, sizeof(Vec2));
 
 
 	cmdb.bindIndexBuffer(indicesToken, IndexType::kU16);
 	cmdb.bindIndexBuffer(indicesToken, IndexType::kU16);
 
 

+ 4 - 4
Tests/Gr/Gr.cpp

@@ -628,9 +628,9 @@ ANKI_TEST(Gr, DrawWithVertex)
 
 
 		cmdb->bindVertexBuffer(0, b.get(), 0, sizeof(Vert));
 		cmdb->bindVertexBuffer(0, b.get(), 0, sizeof(Vert));
 		cmdb->bindVertexBuffer(1, c.get(), 0, sizeof(Vec3));
 		cmdb->bindVertexBuffer(1, c.get(), 0, sizeof(Vec3));
-		cmdb->setVertexAttribute(VertexAttribute::kPosition, 0, Format::kR32G32B32_Sfloat, 0);
-		cmdb->setVertexAttribute(VertexAttribute::kColor, 0, Format::kR8G8B8_Unorm, sizeof(Vec3));
-		cmdb->setVertexAttribute(VertexAttribute::kMisc0, 1, Format::kR32G32B32_Sfloat, 0);
+		cmdb->setVertexAttribute(VertexAttributeSemantic::kPosition, 0, Format::kR32G32B32_Sfloat, 0);
+		cmdb->setVertexAttribute(VertexAttributeSemantic::kColor, 0, Format::kR8G8B8_Unorm, sizeof(Vec3));
+		cmdb->setVertexAttribute(VertexAttributeSemantic::kMisc0, 1, Format::kR32G32B32_Sfloat, 0);
 
 
 		cmdb->setViewport(0, 0, g_win->getWidth(), g_win->getHeight());
 		cmdb->setViewport(0, 0, g_win->getWidth(), g_win->getHeight());
 		cmdb->setPolygonOffset(0.0, 0.0);
 		cmdb->setPolygonOffset(0.0, 0.0);
@@ -903,7 +903,7 @@ static void drawOffscreenDrawcalls([[maybe_unused]] GrManager& gr, ShaderProgram
 	*color = Vec4(0.0, 1.0, 0.0, 0.0);
 	*color = Vec4(0.0, 1.0, 0.0, 0.0);
 
 
 	cmdb->bindVertexBuffer(0, BufferView(vertBuff.get()), sizeof(Vec3));
 	cmdb->bindVertexBuffer(0, BufferView(vertBuff.get()), sizeof(Vec3));
-	cmdb->setVertexAttribute(VertexAttribute::kPosition, 0, Format::kR32G32B32_Sfloat, 0);
+	cmdb->setVertexAttribute(VertexAttributeSemantic::kPosition, 0, Format::kR32G32B32_Sfloat, 0);
 	cmdb->bindShaderProgram(prog.get());
 	cmdb->bindShaderProgram(prog.get());
 	cmdb->bindIndexBuffer(BufferView(indexBuff.get()), IndexType::kU16);
 	cmdb->bindIndexBuffer(BufferView(indexBuff.get()), IndexType::kU16);
 	cmdb->setViewport(0, 0, viewPortSize, viewPortSize);
 	cmdb->setViewport(0, 0, viewPortSize, viewPortSize);

+ 2 - 2
Tests/ShaderCompiler/ShaderProgramCompiler.cpp

@@ -137,7 +137,7 @@ void main()
 	taskManager.m_pool = &pool;
 	taskManager.m_pool = &pool;
 
 
 	ShaderProgramBinary* binary;
 	ShaderProgramBinary* binary;
-	ANKI_TEST_EXPECT_NO_ERR(compileShaderProgram("test.glslp", fsystem, nullptr, &taskManager, {}, binary));
+	ANKI_TEST_EXPECT_NO_ERR(compileShaderProgram("test.glslp", true, fsystem, nullptr, &taskManager, {}, binary));
 
 
 #if 1
 #if 1
 	ShaderCompilerString dis;
 	ShaderCompilerString dis;
@@ -332,7 +332,7 @@ void main()
 	taskManager.m_pool = &pool;
 	taskManager.m_pool = &pool;
 
 
 	ShaderProgramBinary* binary;
 	ShaderProgramBinary* binary;
-	ANKI_TEST_EXPECT_NO_ERR(compileShaderProgram("test.glslp", fsystem, nullptr, &taskManager, {}, binary));
+	ANKI_TEST_EXPECT_NO_ERR(compileShaderProgram("test.glslp", true, fsystem, nullptr, &taskManager, {}, binary));
 
 
 #if 1
 #if 1
 	ShaderCompilerString dis;
 	ShaderCompilerString dis;

BIN
ThirdParty/Bin/Windows64/dxc.exe


BIN
ThirdParty/Bin/Windows64/dxcompiler.dll


BIN
ThirdParty/Bin/Windows64/dxil.dll


+ 487 - 0
ThirdParty/Dxc/d3d12shader.h

@@ -0,0 +1,487 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+//  Copyright (c) Microsoft Corporation.
+//  Licensed under the MIT license.
+//
+//  File:       D3D12Shader.h
+//  Content:    D3D12 Shader Types and APIs
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef __D3D12SHADER_H__
+#define __D3D12SHADER_H__
+
+#include "d3dcommon.h"
+
+typedef enum D3D12_SHADER_VERSION_TYPE
+{
+    D3D12_SHVER_PIXEL_SHADER          = 0,
+    D3D12_SHVER_VERTEX_SHADER         = 1,
+    D3D12_SHVER_GEOMETRY_SHADER       = 2,
+    
+    // D3D11 Shaders
+    D3D12_SHVER_HULL_SHADER           = 3,
+    D3D12_SHVER_DOMAIN_SHADER         = 4,
+    D3D12_SHVER_COMPUTE_SHADER        = 5,
+
+    // D3D12 Shaders
+    D3D12_SHVER_LIBRARY               = 6,
+
+    D3D12_SHVER_RAY_GENERATION_SHADER = 7,
+    D3D12_SHVER_INTERSECTION_SHADER   = 8,
+    D3D12_SHVER_ANY_HIT_SHADER        = 9,
+    D3D12_SHVER_CLOSEST_HIT_SHADER    = 10,
+    D3D12_SHVER_MISS_SHADER           = 11,
+    D3D12_SHVER_CALLABLE_SHADER       = 12,
+
+    D3D12_SHVER_MESH_SHADER           = 13,
+    D3D12_SHVER_AMPLIFICATION_SHADER  = 14,
+
+    D3D12_SHVER_RESERVED0             = 0xFFF0,
+} D3D12_SHADER_VERSION_TYPE;
+
+#define D3D12_SHVER_GET_TYPE(_Version) \
+    (((_Version) >> 16) & 0xffff)
+#define D3D12_SHVER_GET_MAJOR(_Version) \
+    (((_Version) >> 4) & 0xf)
+#define D3D12_SHVER_GET_MINOR(_Version) \
+    (((_Version) >> 0) & 0xf)
+
+// Slot ID for library function return
+#define D3D_RETURN_PARAMETER_INDEX (-1)
+
+typedef D3D_RESOURCE_RETURN_TYPE D3D12_RESOURCE_RETURN_TYPE;
+
+typedef D3D_CBUFFER_TYPE D3D12_CBUFFER_TYPE;
+
+
+typedef struct _D3D12_SIGNATURE_PARAMETER_DESC
+{
+    LPCSTR                      SemanticName;   // Name of the semantic
+    UINT                        SemanticIndex;  // Index of the semantic
+    UINT                        Register;       // Number of member variables
+    D3D_NAME                    SystemValueType;// A predefined system value, or D3D_NAME_UNDEFINED if not applicable
+    D3D_REGISTER_COMPONENT_TYPE ComponentType;  // Scalar type (e.g. uint, float, etc.)
+    BYTE                        Mask;           // Mask to indicate which components of the register
+                                                // are used (combination of D3D10_COMPONENT_MASK values)
+    BYTE                        ReadWriteMask;  // Mask to indicate whether a given component is 
+                                                // never written (if this is an output signature) or
+                                                // always read (if this is an input signature).
+                                                // (combination of D3D_MASK_* values)
+    UINT                        Stream;         // Stream index
+    D3D_MIN_PRECISION           MinPrecision;   // Minimum desired interpolation precision
+} D3D12_SIGNATURE_PARAMETER_DESC;
+
+typedef struct _D3D12_SHADER_BUFFER_DESC
+{
+    LPCSTR                  Name;           // Name of the constant buffer
+    D3D_CBUFFER_TYPE        Type;           // Indicates type of buffer content
+    UINT                    Variables;      // Number of member variables
+    UINT                    Size;           // Size of CB (in bytes)
+    UINT                    uFlags;         // Buffer description flags
+} D3D12_SHADER_BUFFER_DESC;
+
+typedef struct _D3D12_SHADER_VARIABLE_DESC
+{
+    LPCSTR                  Name;           // Name of the variable
+    UINT                    StartOffset;    // Offset in constant buffer's backing store
+    UINT                    Size;           // Size of variable (in bytes)
+    UINT                    uFlags;         // Variable flags
+    LPVOID                  DefaultValue;   // Raw pointer to default value
+    UINT                    StartTexture;   // First texture index (or -1 if no textures used)
+    UINT                    TextureSize;    // Number of texture slots possibly used.
+    UINT                    StartSampler;   // First sampler index (or -1 if no textures used)
+    UINT                    SamplerSize;    // Number of sampler slots possibly used.
+} D3D12_SHADER_VARIABLE_DESC;
+
+typedef struct _D3D12_SHADER_TYPE_DESC
+{
+    D3D_SHADER_VARIABLE_CLASS   Class;          // Variable class (e.g. object, matrix, etc.)
+    D3D_SHADER_VARIABLE_TYPE    Type;           // Variable type (e.g. float, sampler, etc.)
+    UINT                        Rows;           // Number of rows (for matrices, 1 for other numeric, 0 if not applicable)
+    UINT                        Columns;        // Number of columns (for vectors & matrices, 1 for other numeric, 0 if not applicable)
+    UINT                        Elements;       // Number of elements (0 if not an array)
+    UINT                        Members;        // Number of members (0 if not a structure)
+    UINT                        Offset;         // Offset from the start of structure (0 if not a structure member)
+    LPCSTR                      Name;           // Name of type, can be NULL
+} D3D12_SHADER_TYPE_DESC;
+
+typedef D3D_TESSELLATOR_DOMAIN D3D12_TESSELLATOR_DOMAIN;
+
+typedef D3D_TESSELLATOR_PARTITIONING D3D12_TESSELLATOR_PARTITIONING;
+
+typedef D3D_TESSELLATOR_OUTPUT_PRIMITIVE D3D12_TESSELLATOR_OUTPUT_PRIMITIVE;
+
+typedef struct _D3D12_SHADER_DESC
+{
+    UINT                    Version;                     // Shader version
+    LPCSTR                  Creator;                     // Creator string
+    UINT                    Flags;                       // Shader compilation/parse flags
+    
+    UINT                    ConstantBuffers;             // Number of constant buffers
+    UINT                    BoundResources;              // Number of bound resources
+    UINT                    InputParameters;             // Number of parameters in the input signature
+    UINT                    OutputParameters;            // Number of parameters in the output signature
+
+    UINT                    InstructionCount;            // Number of emitted instructions
+    UINT                    TempRegisterCount;           // Number of temporary registers used 
+    UINT                    TempArrayCount;              // Number of temporary arrays used
+    UINT                    DefCount;                    // Number of constant defines 
+    UINT                    DclCount;                    // Number of declarations (input + output)
+    UINT                    TextureNormalInstructions;   // Number of non-categorized texture instructions
+    UINT                    TextureLoadInstructions;     // Number of texture load instructions
+    UINT                    TextureCompInstructions;     // Number of texture comparison instructions
+    UINT                    TextureBiasInstructions;     // Number of texture bias instructions
+    UINT                    TextureGradientInstructions; // Number of texture gradient instructions
+    UINT                    FloatInstructionCount;       // Number of floating point arithmetic instructions used
+    UINT                    IntInstructionCount;         // Number of signed integer arithmetic instructions used
+    UINT                    UintInstructionCount;        // Number of unsigned integer arithmetic instructions used
+    UINT                    StaticFlowControlCount;      // Number of static flow control instructions used
+    UINT                    DynamicFlowControlCount;     // Number of dynamic flow control instructions used
+    UINT                    MacroInstructionCount;       // Number of macro instructions used
+    UINT                    ArrayInstructionCount;       // Number of array instructions used
+    UINT                    CutInstructionCount;         // Number of cut instructions used
+    UINT                    EmitInstructionCount;        // Number of emit instructions used
+    D3D_PRIMITIVE_TOPOLOGY  GSOutputTopology;            // Geometry shader output topology
+    UINT                    GSMaxOutputVertexCount;      // Geometry shader maximum output vertex count
+    D3D_PRIMITIVE           InputPrimitive;              // GS/HS input primitive
+    UINT                    PatchConstantParameters;     // Number of parameters in the patch constant signature
+    UINT                    cGSInstanceCount;            // Number of Geometry shader instances
+    UINT                    cControlPoints;              // Number of control points in the HS->DS stage
+    D3D_TESSELLATOR_OUTPUT_PRIMITIVE HSOutputPrimitive;  // Primitive output by the tessellator
+    D3D_TESSELLATOR_PARTITIONING HSPartitioning;         // Partitioning mode of the tessellator
+    D3D_TESSELLATOR_DOMAIN  TessellatorDomain;           // Domain of the tessellator (quad, tri, isoline)
+    // instruction counts
+    UINT cBarrierInstructions;                           // Number of barrier instructions in a compute shader
+    UINT cInterlockedInstructions;                       // Number of interlocked instructions
+    UINT cTextureStoreInstructions;                      // Number of texture writes
+} D3D12_SHADER_DESC;
+
+typedef struct _D3D12_SHADER_INPUT_BIND_DESC
+{
+    LPCSTR                      Name;           // Name of the resource
+    D3D_SHADER_INPUT_TYPE       Type;           // Type of resource (e.g. texture, cbuffer, etc.)
+    UINT                        BindPoint;      // Starting bind point
+    UINT                        BindCount;      // Number of contiguous bind points (for arrays)
+
+    UINT                        uFlags;         // Input binding flags
+    D3D_RESOURCE_RETURN_TYPE    ReturnType;     // Return type (if texture)
+    D3D_SRV_DIMENSION           Dimension;      // Dimension (if texture)
+    UINT                        NumSamples;     // Number of samples (0 if not MS texture)
+    UINT                        Space;          // Register space
+    UINT uID;                                   // Range ID in the bytecode
+} D3D12_SHADER_INPUT_BIND_DESC;
+
+#define D3D_SHADER_REQUIRES_DOUBLES                                                         0x00000001
+#define D3D_SHADER_REQUIRES_EARLY_DEPTH_STENCIL                                             0x00000002
+#define D3D_SHADER_REQUIRES_UAVS_AT_EVERY_STAGE                                             0x00000004
+#define D3D_SHADER_REQUIRES_64_UAVS                                                         0x00000008
+#define D3D_SHADER_REQUIRES_MINIMUM_PRECISION                                               0x00000010
+#define D3D_SHADER_REQUIRES_11_1_DOUBLE_EXTENSIONS                                          0x00000020
+#define D3D_SHADER_REQUIRES_11_1_SHADER_EXTENSIONS                                          0x00000040
+#define D3D_SHADER_REQUIRES_LEVEL_9_COMPARISON_FILTERING                                    0x00000080
+#define D3D_SHADER_REQUIRES_TILED_RESOURCES                                                 0x00000100
+#define D3D_SHADER_REQUIRES_STENCIL_REF                                                     0x00000200
+#define D3D_SHADER_REQUIRES_INNER_COVERAGE                                                  0x00000400
+#define D3D_SHADER_REQUIRES_TYPED_UAV_LOAD_ADDITIONAL_FORMATS                               0x00000800
+#define D3D_SHADER_REQUIRES_ROVS                                                            0x00001000
+#define D3D_SHADER_REQUIRES_VIEWPORT_AND_RT_ARRAY_INDEX_FROM_ANY_SHADER_FEEDING_RASTERIZER  0x00002000
+#define D3D_SHADER_REQUIRES_WAVE_OPS                                                        0x00004000
+#define D3D_SHADER_REQUIRES_INT64_OPS                                                       0x00008000
+#define D3D_SHADER_REQUIRES_VIEW_ID                                                         0x00010000
+#define D3D_SHADER_REQUIRES_BARYCENTRICS                                                    0x00020000
+#define D3D_SHADER_REQUIRES_NATIVE_16BIT_OPS                                                0x00040000
+#define D3D_SHADER_REQUIRES_SHADING_RATE                                                    0x00080000
+#define D3D_SHADER_REQUIRES_RAYTRACING_TIER_1_1                                             0x00100000
+#define D3D_SHADER_REQUIRES_SAMPLER_FEEDBACK                                                0x00200000
+#define D3D_SHADER_REQUIRES_ATOMIC_INT64_ON_TYPED_RESOURCE                                  0x00400000
+#define D3D_SHADER_REQUIRES_ATOMIC_INT64_ON_GROUP_SHARED                                    0x00800000
+#define D3D_SHADER_REQUIRES_DERIVATIVES_IN_MESH_AND_AMPLIFICATION_SHADERS                   0x01000000
+#define D3D_SHADER_REQUIRES_RESOURCE_DESCRIPTOR_HEAP_INDEXING                               0x02000000
+#define D3D_SHADER_REQUIRES_SAMPLER_DESCRIPTOR_HEAP_INDEXING                                0x04000000
+#define D3D_SHADER_REQUIRES_WAVE_MMA                                                        0x08000000
+#define D3D_SHADER_REQUIRES_ATOMIC_INT64_ON_DESCRIPTOR_HEAP_RESOURCE                        0x10000000
+
+typedef struct _D3D12_LIBRARY_DESC
+{
+    LPCSTR    Creator;           // The name of the originator of the library.
+    UINT      Flags;             // Compilation flags.
+    UINT      FunctionCount;     // Number of functions exported from the library.
+} D3D12_LIBRARY_DESC;
+
+typedef struct _D3D12_FUNCTION_DESC
+{
+    UINT                    Version;                     // Shader version
+    LPCSTR                  Creator;                     // Creator string
+    UINT                    Flags;                       // Shader compilation/parse flags
+    
+    UINT                    ConstantBuffers;             // Number of constant buffers
+    UINT                    BoundResources;              // Number of bound resources
+
+    UINT                    InstructionCount;            // Number of emitted instructions
+    UINT                    TempRegisterCount;           // Number of temporary registers used 
+    UINT                    TempArrayCount;              // Number of temporary arrays used
+    UINT                    DefCount;                    // Number of constant defines 
+    UINT                    DclCount;                    // Number of declarations (input + output)
+    UINT                    TextureNormalInstructions;   // Number of non-categorized texture instructions
+    UINT                    TextureLoadInstructions;     // Number of texture load instructions
+    UINT                    TextureCompInstructions;     // Number of texture comparison instructions
+    UINT                    TextureBiasInstructions;     // Number of texture bias instructions
+    UINT                    TextureGradientInstructions; // Number of texture gradient instructions
+    UINT                    FloatInstructionCount;       // Number of floating point arithmetic instructions used
+    UINT                    IntInstructionCount;         // Number of signed integer arithmetic instructions used
+    UINT                    UintInstructionCount;        // Number of unsigned integer arithmetic instructions used
+    UINT                    StaticFlowControlCount;      // Number of static flow control instructions used
+    UINT                    DynamicFlowControlCount;     // Number of dynamic flow control instructions used
+    UINT                    MacroInstructionCount;       // Number of macro instructions used
+    UINT                    ArrayInstructionCount;       // Number of array instructions used
+    UINT                    MovInstructionCount;         // Number of mov instructions used
+    UINT                    MovcInstructionCount;        // Number of movc instructions used
+    UINT                    ConversionInstructionCount;  // Number of type conversion instructions used
+    UINT                    BitwiseInstructionCount;     // Number of bitwise arithmetic instructions used
+    D3D_FEATURE_LEVEL       MinFeatureLevel;             // Min target of the function byte code
+    UINT64                  RequiredFeatureFlags;        // Required feature flags
+
+    LPCSTR                  Name;                        // Function name
+    INT                     FunctionParameterCount;      // Number of logical parameters in the function signature (not including return)
+    BOOL                    HasReturn;                   // TRUE, if function returns a value, false - it is a subroutine
+    BOOL                    Has10Level9VertexShader;     // TRUE, if there is a 10L9 VS blob
+    BOOL                    Has10Level9PixelShader;      // TRUE, if there is a 10L9 PS blob
+} D3D12_FUNCTION_DESC;
+
+typedef struct _D3D12_PARAMETER_DESC
+{
+    LPCSTR                      Name;               // Parameter name.
+    LPCSTR                      SemanticName;       // Parameter semantic name (+index).
+    D3D_SHADER_VARIABLE_TYPE    Type;               // Element type.
+    D3D_SHADER_VARIABLE_CLASS   Class;              // Scalar/Vector/Matrix.
+    UINT                        Rows;               // Rows are for matrix parameters.
+    UINT                        Columns;            // Components or Columns in matrix.
+    D3D_INTERPOLATION_MODE      InterpolationMode;  // Interpolation mode.
+    D3D_PARAMETER_FLAGS         Flags;              // Parameter modifiers.
+
+    UINT                        FirstInRegister;    // The first input register for this parameter.
+    UINT                        FirstInComponent;   // The first input register component for this parameter.
+    UINT                        FirstOutRegister;   // The first output register for this parameter.
+    UINT                        FirstOutComponent;  // The first output register component for this parameter.
+} D3D12_PARAMETER_DESC;
+
+
+//////////////////////////////////////////////////////////////////////////////
+// Interfaces ////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+typedef interface ID3D12ShaderReflectionType ID3D12ShaderReflectionType;
+typedef interface ID3D12ShaderReflectionType *LPD3D12SHADERREFLECTIONTYPE;
+
+typedef interface ID3D12ShaderReflectionVariable ID3D12ShaderReflectionVariable;
+typedef interface ID3D12ShaderReflectionVariable *LPD3D12SHADERREFLECTIONVARIABLE;
+
+typedef interface ID3D12ShaderReflectionConstantBuffer ID3D12ShaderReflectionConstantBuffer;
+typedef interface ID3D12ShaderReflectionConstantBuffer *LPD3D12SHADERREFLECTIONCONSTANTBUFFER;
+
+typedef interface ID3D12ShaderReflection ID3D12ShaderReflection;
+typedef interface ID3D12ShaderReflection *LPD3D12SHADERREFLECTION;
+
+typedef interface ID3D12LibraryReflection ID3D12LibraryReflection;
+typedef interface ID3D12LibraryReflection *LPD3D12LIBRARYREFLECTION;
+
+typedef interface ID3D12FunctionReflection ID3D12FunctionReflection;
+typedef interface ID3D12FunctionReflection *LPD3D12FUNCTIONREFLECTION;
+
+typedef interface ID3D12FunctionParameterReflection ID3D12FunctionParameterReflection;
+typedef interface ID3D12FunctionParameterReflection *LPD3D12FUNCTIONPARAMETERREFLECTION;
+
+
+// {E913C351-783D-48CA-A1D1-4F306284AD56}
+interface DECLSPEC_UUID("E913C351-783D-48CA-A1D1-4F306284AD56") ID3D12ShaderReflectionType;
+DEFINE_GUID(IID_ID3D12ShaderReflectionType, 
+0xe913c351, 0x783d, 0x48ca, 0xa1, 0xd1, 0x4f, 0x30, 0x62, 0x84, 0xad, 0x56);
+
+#undef INTERFACE
+#define INTERFACE ID3D12ShaderReflectionType
+
+DECLARE_INTERFACE(ID3D12ShaderReflectionType)
+{
+    STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_SHADER_TYPE_DESC *pDesc) PURE;
+    
+    STDMETHOD_(ID3D12ShaderReflectionType*, GetMemberTypeByIndex)(THIS_ _In_ UINT Index) PURE;
+    STDMETHOD_(ID3D12ShaderReflectionType*, GetMemberTypeByName)(THIS_ _In_ LPCSTR Name) PURE;
+    STDMETHOD_(LPCSTR, GetMemberTypeName)(THIS_ _In_ UINT Index) PURE;
+
+    STDMETHOD(IsEqual)(THIS_ _In_ ID3D12ShaderReflectionType* pType) PURE;
+    STDMETHOD_(ID3D12ShaderReflectionType*, GetSubType)(THIS) PURE;
+    STDMETHOD_(ID3D12ShaderReflectionType*, GetBaseClass)(THIS) PURE;
+    STDMETHOD_(UINT, GetNumInterfaces)(THIS) PURE;
+    STDMETHOD_(ID3D12ShaderReflectionType*, GetInterfaceByIndex)(THIS_ _In_ UINT uIndex) PURE;
+    STDMETHOD(IsOfType)(THIS_ _In_ ID3D12ShaderReflectionType* pType) PURE;
+    STDMETHOD(ImplementsInterface)(THIS_ _In_ ID3D12ShaderReflectionType* pBase) PURE;
+};
+
+// {8337A8A6-A216-444A-B2F4-314733A73AEA}
+interface DECLSPEC_UUID("8337A8A6-A216-444A-B2F4-314733A73AEA") ID3D12ShaderReflectionVariable;
+DEFINE_GUID(IID_ID3D12ShaderReflectionVariable, 
+0x8337a8a6, 0xa216, 0x444a, 0xb2, 0xf4, 0x31, 0x47, 0x33, 0xa7, 0x3a, 0xea);
+
+#undef INTERFACE
+#define INTERFACE ID3D12ShaderReflectionVariable
+
+DECLARE_INTERFACE(ID3D12ShaderReflectionVariable)
+{
+    STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_SHADER_VARIABLE_DESC *pDesc) PURE;
+    
+    STDMETHOD_(ID3D12ShaderReflectionType*, GetType)(THIS) PURE;
+    STDMETHOD_(ID3D12ShaderReflectionConstantBuffer*, GetBuffer)(THIS) PURE;
+
+    STDMETHOD_(UINT, GetInterfaceSlot)(THIS_ _In_ UINT uArrayIndex) PURE;
+};
+
+// {C59598B4-48B3-4869-B9B1-B1618B14A8B7}
+interface DECLSPEC_UUID("C59598B4-48B3-4869-B9B1-B1618B14A8B7") ID3D12ShaderReflectionConstantBuffer;
+DEFINE_GUID(IID_ID3D12ShaderReflectionConstantBuffer, 
+0xc59598b4, 0x48b3, 0x4869, 0xb9, 0xb1, 0xb1, 0x61, 0x8b, 0x14, 0xa8, 0xb7);
+
+#undef INTERFACE
+#define INTERFACE ID3D12ShaderReflectionConstantBuffer
+
+DECLARE_INTERFACE(ID3D12ShaderReflectionConstantBuffer)
+{
+    STDMETHOD(GetDesc)(THIS_ D3D12_SHADER_BUFFER_DESC *pDesc) PURE;
+    
+    STDMETHOD_(ID3D12ShaderReflectionVariable*, GetVariableByIndex)(THIS_ _In_ UINT Index) PURE;
+    STDMETHOD_(ID3D12ShaderReflectionVariable*, GetVariableByName)(THIS_ _In_ LPCSTR Name) PURE;
+};
+
+// The ID3D12ShaderReflection IID may change from SDK version to SDK version
+// if the reflection API changes.  This prevents new code with the new API
+// from working with an old binary.  Recompiling with the new header
+// will pick up the new IID.
+
+// {5A58797D-A72C-478D-8BA2-EFC6B0EFE88E}
+interface DECLSPEC_UUID("5A58797D-A72C-478D-8BA2-EFC6B0EFE88E") ID3D12ShaderReflection;
+DEFINE_GUID(IID_ID3D12ShaderReflection, 
+0x5a58797d, 0xa72c, 0x478d, 0x8b, 0xa2, 0xef, 0xc6, 0xb0, 0xef, 0xe8, 0x8e);
+
+#undef INTERFACE
+#define INTERFACE ID3D12ShaderReflection
+
+DECLARE_INTERFACE_(ID3D12ShaderReflection, IUnknown)
+{
+    STDMETHOD(QueryInterface)(THIS_ _In_ REFIID iid,
+                              _Out_ LPVOID *ppv) PURE;
+    STDMETHOD_(ULONG, AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG, Release)(THIS) PURE;
+
+    STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_SHADER_DESC *pDesc) PURE;
+    
+    STDMETHOD_(ID3D12ShaderReflectionConstantBuffer*, GetConstantBufferByIndex)(THIS_ _In_ UINT Index) PURE;
+    STDMETHOD_(ID3D12ShaderReflectionConstantBuffer*, GetConstantBufferByName)(THIS_ _In_ LPCSTR Name) PURE;
+    
+    STDMETHOD(GetResourceBindingDesc)(THIS_ _In_ UINT ResourceIndex,
+                                      _Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc) PURE;
+    
+    STDMETHOD(GetInputParameterDesc)(THIS_ _In_ UINT ParameterIndex,
+                                     _Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
+    STDMETHOD(GetOutputParameterDesc)(THIS_ _In_ UINT ParameterIndex,
+                                      _Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
+    STDMETHOD(GetPatchConstantParameterDesc)(THIS_ _In_ UINT ParameterIndex,
+                                             _Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
+
+    STDMETHOD_(ID3D12ShaderReflectionVariable*, GetVariableByName)(THIS_ _In_ LPCSTR Name) PURE;
+
+    STDMETHOD(GetResourceBindingDescByName)(THIS_ _In_ LPCSTR Name,
+                                            _Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc) PURE;
+
+    STDMETHOD_(UINT, GetMovInstructionCount)(THIS) PURE;
+    STDMETHOD_(UINT, GetMovcInstructionCount)(THIS) PURE;
+    STDMETHOD_(UINT, GetConversionInstructionCount)(THIS) PURE;
+    STDMETHOD_(UINT, GetBitwiseInstructionCount)(THIS) PURE;
+    
+    STDMETHOD_(D3D_PRIMITIVE, GetGSInputPrimitive)(THIS) PURE;
+    STDMETHOD_(BOOL, IsSampleFrequencyShader)(THIS) PURE;
+
+    STDMETHOD_(UINT, GetNumInterfaceSlots)(THIS) PURE;
+    STDMETHOD(GetMinFeatureLevel)(THIS_ _Out_ enum D3D_FEATURE_LEVEL* pLevel) PURE;
+
+    STDMETHOD_(UINT, GetThreadGroupSize)(THIS_
+                                         _Out_opt_ UINT* pSizeX,
+                                         _Out_opt_ UINT* pSizeY,
+                                         _Out_opt_ UINT* pSizeZ) PURE;
+
+    STDMETHOD_(UINT64, GetRequiresFlags)(THIS) PURE;
+};
+
+// {8E349D19-54DB-4A56-9DC9-119D87BDB804}
+interface DECLSPEC_UUID("8E349D19-54DB-4A56-9DC9-119D87BDB804") ID3D12LibraryReflection;
+DEFINE_GUID(IID_ID3D12LibraryReflection, 
+0x8e349d19, 0x54db, 0x4a56, 0x9d, 0xc9, 0x11, 0x9d, 0x87, 0xbd, 0xb8, 0x4);
+
+#undef INTERFACE
+#define INTERFACE ID3D12LibraryReflection
+
+DECLARE_INTERFACE_(ID3D12LibraryReflection, IUnknown)
+{
+    STDMETHOD(QueryInterface)(THIS_ _In_ REFIID iid, _Out_ LPVOID * ppv) PURE;
+    STDMETHOD_(ULONG, AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG, Release)(THIS) PURE;
+
+    STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_LIBRARY_DESC * pDesc) PURE;
+    
+    STDMETHOD_(ID3D12FunctionReflection *, GetFunctionByIndex)(THIS_ _In_ INT FunctionIndex) PURE;
+};
+
+// {1108795C-2772-4BA9-B2A8-D464DC7E2799}
+interface DECLSPEC_UUID("1108795C-2772-4BA9-B2A8-D464DC7E2799") ID3D12FunctionReflection;
+DEFINE_GUID(IID_ID3D12FunctionReflection, 
+0x1108795c, 0x2772, 0x4ba9, 0xb2, 0xa8, 0xd4, 0x64, 0xdc, 0x7e, 0x27, 0x99);
+
+#undef INTERFACE
+#define INTERFACE ID3D12FunctionReflection
+
+DECLARE_INTERFACE(ID3D12FunctionReflection)
+{
+    STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_FUNCTION_DESC * pDesc) PURE;
+    
+    STDMETHOD_(ID3D12ShaderReflectionConstantBuffer *, GetConstantBufferByIndex)(THIS_ _In_ UINT BufferIndex) PURE;
+    STDMETHOD_(ID3D12ShaderReflectionConstantBuffer *, GetConstantBufferByName)(THIS_ _In_ LPCSTR Name) PURE;
+    
+    STDMETHOD(GetResourceBindingDesc)(THIS_ _In_ UINT ResourceIndex,
+                                      _Out_ D3D12_SHADER_INPUT_BIND_DESC * pDesc) PURE;
+    
+    STDMETHOD_(ID3D12ShaderReflectionVariable *, GetVariableByName)(THIS_ _In_ LPCSTR Name) PURE;
+
+    STDMETHOD(GetResourceBindingDescByName)(THIS_ _In_ LPCSTR Name,
+                                            _Out_ D3D12_SHADER_INPUT_BIND_DESC * pDesc) PURE;
+
+    // Use D3D_RETURN_PARAMETER_INDEX to get description of the return value.
+    STDMETHOD_(ID3D12FunctionParameterReflection *, GetFunctionParameter)(THIS_ _In_ INT ParameterIndex) PURE;
+};
+
+// {EC25F42D-7006-4F2B-B33E-02CC3375733F}
+interface DECLSPEC_UUID("EC25F42D-7006-4F2B-B33E-02CC3375733F") ID3D12FunctionParameterReflection;
+DEFINE_GUID(IID_ID3D12FunctionParameterReflection, 
+0xec25f42d, 0x7006, 0x4f2b, 0xb3, 0x3e, 0x2, 0xcc, 0x33, 0x75, 0x73, 0x3f);
+
+#undef INTERFACE
+#define INTERFACE ID3D12FunctionParameterReflection
+
+DECLARE_INTERFACE(ID3D12FunctionParameterReflection)
+{
+    STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_PARAMETER_DESC * pDesc) PURE;
+};
+
+
+//////////////////////////////////////////////////////////////////////////////
+// APIs //////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+#ifdef __cplusplus
+extern "C" {
+#endif //__cplusplus
+
+#ifdef __cplusplus
+}
+#endif //__cplusplus
+    
+#endif //__D3D12SHADER_H__
+

+ 1309 - 0
ThirdParty/Dxc/dxcapi.h

@@ -0,0 +1,1309 @@
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// dxcapi.h                                                                  //
+// Copyright (C) Microsoft Corporation. All rights reserved.                 //
+// This file is distributed under the University of Illinois Open Source     //
+// License. See LICENSE.TXT for details.                                     //
+//                                                                           //
+// Provides declarations for the DirectX Compiler API entry point.           //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef __DXC_API__
+#define __DXC_API__
+
+#ifdef _WIN32
+#ifndef DXC_API_IMPORT
+#define DXC_API_IMPORT __declspec(dllimport)
+#endif
+#else
+#ifndef DXC_API_IMPORT
+#define DXC_API_IMPORT __attribute__((visibility("default")))
+#endif
+#endif
+
+#ifdef _WIN32
+
+#ifndef CROSS_PLATFORM_UUIDOF
+// Warning: This macro exists in WinAdapter.h as well
+#define CROSS_PLATFORM_UUIDOF(interface, spec)                                 \
+  struct __declspec(uuid(spec)) interface;
+#endif
+
+#else
+
+#include "WinAdapter.h"
+#include <dlfcn.h>
+#endif
+
+struct IMalloc;
+
+struct IDxcIncludeHandler;
+
+/// \brief Typedef for DxcCreateInstance function pointer.
+///
+/// This can be used with GetProcAddress to get the DxcCreateInstance function.
+typedef HRESULT(__stdcall *DxcCreateInstanceProc)(_In_ REFCLSID rclsid,
+                                                  _In_ REFIID riid,
+                                                  _Out_ LPVOID *ppv);
+
+/// \brief Typedef for DxcCreateInstance2 function pointer.
+///
+/// This can be used with GetProcAddress to get the DxcCreateInstance2 function.
+typedef HRESULT(__stdcall *DxcCreateInstance2Proc)(_In_ IMalloc *pMalloc,
+                                                   _In_ REFCLSID rclsid,
+                                                   _In_ REFIID riid,
+                                                   _Out_ LPVOID *ppv);
+
+/// \brief Creates a single uninitialized object of the class associated with a
+/// specified CLSID.
+///
+/// \param rclsid The CLSID associated with the data and code that will be used
+/// to create the object.
+///
+/// \param riid A reference to the identifier of the interface to be used to
+/// communicate with the object.
+///
+/// \param ppv Address of pointer variable that receives the interface pointer
+/// requested in riid.  Upon successful return, *ppv contains the requested
+/// interface pointer. Upon failure, *ppv contains NULL.
+///
+/// While this function is similar to CoCreateInstance, there is no COM
+/// involvement.
+extern "C" DXC_API_IMPORT
+    HRESULT __stdcall DxcCreateInstance(_In_ REFCLSID rclsid, _In_ REFIID riid,
+                                        _Out_ LPVOID *ppv);
+
+/// \brief Version of DxcCreateInstance that takes an IMalloc interface.
+///
+/// This can be used to create an instance of the compiler with a custom memory
+/// allocator.
+extern "C" DXC_API_IMPORT
+    HRESULT __stdcall DxcCreateInstance2(_In_ IMalloc *pMalloc,
+                                         _In_ REFCLSID rclsid, _In_ REFIID riid,
+                                         _Out_ LPVOID *ppv);
+
+// For convenience, equivalent definitions to CP_UTF8 and CP_UTF16.
+#define DXC_CP_UTF8 65001
+#define DXC_CP_UTF16 1200
+#define DXC_CP_UTF32 12000
+// Use DXC_CP_ACP for: Binary;  ANSI Text;  Autodetect UTF with BOM
+#define DXC_CP_ACP 0
+
+/// Codepage for "wide" characters - UTF16 on Windows, UTF32 on other platforms.
+#ifdef _WIN32
+#define DXC_CP_WIDE DXC_CP_UTF16
+#else
+#define DXC_CP_WIDE DXC_CP_UTF32
+#endif
+
+/// Indicates that the shader hash was computed taking into account source
+/// information (-Zss).
+#define DXC_HASHFLAG_INCLUDES_SOURCE 1
+
+/// Hash digest type for ShaderHash.
+typedef struct DxcShaderHash {
+  UINT32 Flags;        ///< DXC_HASHFLAG_*
+  BYTE HashDigest[16]; ///< The hash digest
+} DxcShaderHash;
+
+#define DXC_FOURCC(ch0, ch1, ch2, ch3)                                         \
+  ((UINT32)(UINT8)(ch0) | (UINT32)(UINT8)(ch1) << 8 |                          \
+   (UINT32)(UINT8)(ch2) << 16 | (UINT32)(UINT8)(ch3) << 24)
+#define DXC_PART_PDB DXC_FOURCC('I', 'L', 'D', 'B')
+#define DXC_PART_PDB_NAME DXC_FOURCC('I', 'L', 'D', 'N')
+#define DXC_PART_PRIVATE_DATA DXC_FOURCC('P', 'R', 'I', 'V')
+#define DXC_PART_ROOT_SIGNATURE DXC_FOURCC('R', 'T', 'S', '0')
+#define DXC_PART_DXIL DXC_FOURCC('D', 'X', 'I', 'L')
+#define DXC_PART_REFLECTION_DATA DXC_FOURCC('S', 'T', 'A', 'T')
+#define DXC_PART_SHADER_HASH DXC_FOURCC('H', 'A', 'S', 'H')
+#define DXC_PART_INPUT_SIGNATURE DXC_FOURCC('I', 'S', 'G', '1')
+#define DXC_PART_OUTPUT_SIGNATURE DXC_FOURCC('O', 'S', 'G', '1')
+#define DXC_PART_PATCH_CONSTANT_SIGNATURE DXC_FOURCC('P', 'S', 'G', '1')
+
+// Some option arguments are defined here for continuity with D3DCompile
+// interface.
+#define DXC_ARG_DEBUG L"-Zi"
+#define DXC_ARG_SKIP_VALIDATION L"-Vd"
+#define DXC_ARG_SKIP_OPTIMIZATIONS L"-Od"
+#define DXC_ARG_PACK_MATRIX_ROW_MAJOR L"-Zpr"
+#define DXC_ARG_PACK_MATRIX_COLUMN_MAJOR L"-Zpc"
+#define DXC_ARG_AVOID_FLOW_CONTROL L"-Gfa"
+#define DXC_ARG_PREFER_FLOW_CONTROL L"-Gfp"
+#define DXC_ARG_ENABLE_STRICTNESS L"-Ges"
+#define DXC_ARG_ENABLE_BACKWARDS_COMPATIBILITY L"-Gec"
+#define DXC_ARG_IEEE_STRICTNESS L"-Gis"
+#define DXC_ARG_OPTIMIZATION_LEVEL0 L"-O0"
+#define DXC_ARG_OPTIMIZATION_LEVEL1 L"-O1"
+#define DXC_ARG_OPTIMIZATION_LEVEL2 L"-O2"
+#define DXC_ARG_OPTIMIZATION_LEVEL3 L"-O3"
+#define DXC_ARG_WARNINGS_ARE_ERRORS L"-WX"
+#define DXC_ARG_RESOURCES_MAY_ALIAS L"-res_may_alias"
+#define DXC_ARG_ALL_RESOURCES_BOUND L"-all_resources_bound"
+#define DXC_ARG_DEBUG_NAME_FOR_SOURCE L"-Zss"
+#define DXC_ARG_DEBUG_NAME_FOR_BINARY L"-Zsb"
+
+CROSS_PLATFORM_UUIDOF(IDxcBlob, "8BA5FB08-5195-40e2-AC58-0D989C3A0102")
+/// \brief A sized buffer that can be passed in and out of DXC APIs.
+///
+/// This is an alias of ID3D10Blob and ID3DBlob.
+struct IDxcBlob : public IUnknown {
+public:
+  /// \brief Retrieves a pointer to the blob's data.
+  virtual LPVOID STDMETHODCALLTYPE GetBufferPointer(void) = 0;
+
+  /// \brief Retrieves the size, in bytes, of the blob's data.
+  virtual SIZE_T STDMETHODCALLTYPE GetBufferSize(void) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcBlobEncoding, "7241d424-2646-4191-97c0-98e96e42fc68")
+/// \brief A blob that might have a known encoding.
+struct IDxcBlobEncoding : public IDxcBlob {
+public:
+  /// \brief Retrieve the encoding for this blob.
+  ///
+  /// \param pKnown Pointer to a variable that will be set to TRUE if the
+  /// encoding is known.
+  ///
+  /// \param pCodePage Pointer to variable that will be set to the encoding used
+  /// for this blog.
+  ///
+  /// If the encoding is not known then pCodePage will be set to CP_ACP.
+  virtual HRESULT STDMETHODCALLTYPE GetEncoding(_Out_ BOOL *pKnown,
+                                                _Out_ UINT32 *pCodePage) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcBlobWide, "A3F84EAB-0FAA-497E-A39C-EE6ED60B2D84")
+/// \brief A blob containing a null-terminated wide string.
+///
+/// This uses the native wide character encoding (utf16 on Windows, utf32 on
+/// Linux).
+///
+/// The value returned by GetBufferSize() is the size of the buffer, in bytes,
+/// including the null-terminator.
+///
+/// This interface is used to return output name strings DXC.  Other string
+/// output blobs, such as errors/warnings, preprocessed HLSL, or other text are
+/// returned using encodings based on the -encoding option passed to the
+/// compiler.
+struct IDxcBlobWide : public IDxcBlobEncoding {
+public:
+  /// \brief Retrieves a pointer to the string stored in this blob.
+  virtual LPCWSTR STDMETHODCALLTYPE GetStringPointer(void) = 0;
+
+  /// \brief Retrieves the length of the string stored in this blob, in
+  /// characters, excluding the null-terminator.
+  virtual SIZE_T STDMETHODCALLTYPE GetStringLength(void) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcBlobUtf8, "3DA636C9-BA71-4024-A301-30CBF125305B")
+/// \brief A blob containing a UTF-8 encoded string.
+///
+/// The value returned by GetBufferSize() is the size of the buffer, in bytes,
+/// including the null-terminator.
+///
+/// Depending on the -encoding option passed to the compiler, this interface is
+/// used to return string output blobs, such as errors/warnings, preprocessed
+/// HLSL, or other text. Output name strings always use IDxcBlobWide.
+struct IDxcBlobUtf8 : public IDxcBlobEncoding {
+public:
+  /// \brief Retrieves a pointer to the string stored in this blob.
+  virtual LPCSTR STDMETHODCALLTYPE GetStringPointer(void) = 0;
+
+  /// \brief Retrieves the length of the string stored in this blob, in
+  /// characters, excluding the null-terminator.
+  virtual SIZE_T STDMETHODCALLTYPE GetStringLength(void) = 0;
+};
+
+#ifdef _WIN32
+/// IDxcBlobUtf16 is a legacy alias for IDxcBlobWide on Win32.
+typedef IDxcBlobWide IDxcBlobUtf16;
+#endif
+
+CROSS_PLATFORM_UUIDOF(IDxcIncludeHandler,
+                      "7f61fc7d-950d-467f-b3e3-3c02fb49187c")
+/// \brief Interface for handling include directives.
+///
+/// This interface can be implemented to customize handling of include
+/// directives.
+///
+/// Use IDxcUtils::CreateDefaultIncludeHandler to create a default
+/// implementation that reads include files from the filesystem.
+///
+struct IDxcIncludeHandler : public IUnknown {
+  /// \brief Load a source file to be included by the compiler.
+  ///
+  /// \param pFilename Candidate filename.
+  ///
+  /// \param ppIncludeSource Resultant source object for included file, nullptr
+  /// if not found.
+  virtual HRESULT STDMETHODCALLTYPE
+  LoadSource(_In_z_ LPCWSTR pFilename,
+             _COM_Outptr_result_maybenull_ IDxcBlob **ppIncludeSource) = 0;
+};
+
+/// \brief Structure for supplying bytes or text input to Dxc APIs.
+typedef struct DxcBuffer {
+  /// \brief Pointer to the start of the buffer.
+  LPCVOID Ptr;
+
+  /// \brief Size of the buffer in bytes.
+  SIZE_T Size;
+
+  /// \brief Encoding of the buffer.
+  ///
+  /// Use Encoding = 0 for non-text bytes, ANSI text, or unknown with BOM.
+  UINT Encoding;
+} DxcText;
+
+/// \brief Structure for supplying defines to Dxc APIs.
+struct DxcDefine {
+  LPCWSTR Name;              ///< The define name.
+  _Maybenull_ LPCWSTR Value; ///< Optional value for the define.
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcCompilerArgs, "73EFFE2A-70DC-45F8-9690-EFF64C02429D")
+/// \brief Interface for managing arguments passed to DXC.
+///
+/// Use IDxcUtils::BuildArguments to create an instance of this interface.
+struct IDxcCompilerArgs : public IUnknown {
+  /// \brief Retrieve the array of arguments.
+  ///
+  /// This can be passed directly to the pArguments parameter of the Compile()
+  /// method.
+  virtual LPCWSTR *STDMETHODCALLTYPE GetArguments() = 0;
+
+  /// \brief Retrieve the number of arguments.
+  ///
+  /// This can be passed directly to the argCount parameter of the Compile()
+  /// method.
+  virtual UINT32 STDMETHODCALLTYPE GetCount() = 0;
+
+  /// \brief Add additional arguments to this list of compiler arguments.
+  virtual HRESULT STDMETHODCALLTYPE AddArguments(
+      _In_opt_count_(argCount)
+          LPCWSTR *pArguments, ///< Array of pointers to arguments to add.
+      _In_ UINT32 argCount     ///< Number of arguments to add.
+      ) = 0;
+
+  /// \brief Add additional UTF-8 encoded arguments to this list of compiler
+  /// arguments.
+  virtual HRESULT STDMETHODCALLTYPE AddArgumentsUTF8(
+      _In_opt_count_(argCount)
+          LPCSTR *pArguments, ///< Array of pointers to UTF-8 arguments to add.
+      _In_ UINT32 argCount    ///< Number of arguments to add.
+      ) = 0;
+
+  /// \brief Add additional defines to this list of compiler arguments.
+  virtual HRESULT STDMETHODCALLTYPE AddDefines(
+      _In_count_(defineCount) const DxcDefine *pDefines, ///< Array of defines.
+      _In_ UINT32 defineCount                            ///< Number of defines.
+      ) = 0;
+};
+
+//////////////////////////
+// Legacy Interfaces
+/////////////////////////
+
+CROSS_PLATFORM_UUIDOF(IDxcLibrary, "e5204dc7-d18c-4c3c-bdfb-851673980fe7")
+/// \deprecated IDxcUtils replaces IDxcLibrary; please use IDxcUtils insted.
+struct IDxcLibrary : public IUnknown {
+  /// \deprecated
+  virtual HRESULT STDMETHODCALLTYPE SetMalloc(_In_opt_ IMalloc *pMalloc) = 0;
+
+  /// \deprecated
+  virtual HRESULT STDMETHODCALLTYPE
+  CreateBlobFromBlob(_In_ IDxcBlob *pBlob, UINT32 offset, UINT32 length,
+                     _COM_Outptr_ IDxcBlob **ppResult) = 0;
+
+  /// \deprecated
+  virtual HRESULT STDMETHODCALLTYPE
+  CreateBlobFromFile(_In_z_ LPCWSTR pFileName, _In_opt_ UINT32 *codePage,
+                     _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;
+
+  /// \deprecated
+  virtual HRESULT STDMETHODCALLTYPE CreateBlobWithEncodingFromPinned(
+      _In_bytecount_(size) LPCVOID pText, UINT32 size, UINT32 codePage,
+      _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;
+
+  /// \deprecated
+  virtual HRESULT STDMETHODCALLTYPE CreateBlobWithEncodingOnHeapCopy(
+      _In_bytecount_(size) LPCVOID pText, UINT32 size, UINT32 codePage,
+      _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;
+
+  /// \deprecated
+  virtual HRESULT STDMETHODCALLTYPE CreateBlobWithEncodingOnMalloc(
+      _In_bytecount_(size) LPCVOID pText, IMalloc *pIMalloc, UINT32 size,
+      UINT32 codePage, _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;
+
+  /// \deprecated
+  virtual HRESULT STDMETHODCALLTYPE
+  CreateIncludeHandler(_COM_Outptr_ IDxcIncludeHandler **ppResult) = 0;
+
+  /// \deprecated
+  virtual HRESULT STDMETHODCALLTYPE CreateStreamFromBlobReadOnly(
+      _In_ IDxcBlob *pBlob, _COM_Outptr_ IStream **ppStream) = 0;
+
+  /// \deprecated
+  virtual HRESULT STDMETHODCALLTYPE GetBlobAsUtf8(
+      _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;
+
+  // Renamed from GetBlobAsUtf16 to GetBlobAsWide
+  /// \deprecated
+  virtual HRESULT STDMETHODCALLTYPE GetBlobAsWide(
+      _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;
+
+#ifdef _WIN32
+  // Alias to GetBlobAsWide on Win32
+  /// \deprecated
+  inline HRESULT GetBlobAsUtf16(_In_ IDxcBlob *pBlob,
+                                _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) {
+    return this->GetBlobAsWide(pBlob, pBlobEncoding);
+  }
+#endif
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcOperationResult,
+                      "CEDB484A-D4E9-445A-B991-CA21CA157DC2")
+/// \brief The results of a DXC operation.
+///
+/// Note: IDxcResult replaces IDxcOperationResult and should be used wherever
+/// possible.
+struct IDxcOperationResult : public IUnknown {
+  /// \brief Retrieve the overall status of the operation.
+  virtual HRESULT STDMETHODCALLTYPE GetStatus(_Out_ HRESULT *pStatus) = 0;
+
+  /// \brief Retrieve the primary output of the operation.
+  ///
+  /// This corresponds to:
+  /// * DXC_OUT_OBJECT - Compile() with shader or library target
+  /// * DXC_OUT_DISASSEMBLY - Disassemble()
+  /// * DXC_OUT_HLSL - Compile() with -P
+  /// * DXC_OUT_ROOT_SIGNATURE - Compile() with rootsig_* target
+  virtual HRESULT STDMETHODCALLTYPE
+  GetResult(_COM_Outptr_result_maybenull_ IDxcBlob **ppResult) = 0;
+
+  /// \brief Retrieves the error buffer from the operation, if there is one.
+  ///
+  // This corresponds to calling IDxcResult::GetOutput() with DXC_OUT_ERRORS.
+  virtual HRESULT STDMETHODCALLTYPE
+  GetErrorBuffer(_COM_Outptr_result_maybenull_ IDxcBlobEncoding **ppErrors) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcCompiler, "8c210bf3-011f-4422-8d70-6f9acb8db617")
+/// \deprecated Please use IDxcCompiler3 instead.
+struct IDxcCompiler : public IUnknown {
+  /// \brief Compile a single entry point to the target shader model.
+  ///
+  /// \deprecated Please use IDxcCompiler3::Compile() instead.
+  virtual HRESULT STDMETHODCALLTYPE Compile(
+      _In_ IDxcBlob *pSource,         // Source text to compile.
+      _In_opt_z_ LPCWSTR pSourceName, // Optional file name for pSource. Used in
+                                      // errors and include handlers.
+      _In_opt_z_ LPCWSTR pEntryPoint, // Entry point name.
+      _In_z_ LPCWSTR pTargetProfile,  // Shader profile to compile.
+      _In_opt_count_(argCount)
+          LPCWSTR *pArguments, // Array of pointers to arguments.
+      _In_ UINT32 argCount,    // Number of arguments.
+      _In_count_(defineCount) const DxcDefine *pDefines, // Array of defines.
+      _In_ UINT32 defineCount,                           // Number of defines.
+      _In_opt_ IDxcIncludeHandler
+          *pIncludeHandler, // User-provided interface to handle #include
+                            // directives (optional).
+      _COM_Outptr_ IDxcOperationResult *
+          *ppResult // Compiler output status, buffer, and errors.
+      ) = 0;
+
+  /// \brief Preprocess source text.
+  ///
+  /// \deprecated Please use IDxcCompiler3::Compile() with the "-P" argument
+  /// instead.
+  virtual HRESULT STDMETHODCALLTYPE Preprocess(
+      _In_ IDxcBlob *pSource,         // Source text to preprocess.
+      _In_opt_z_ LPCWSTR pSourceName, // Optional file name for pSource. Used in
+                                      // errors and include handlers.
+      _In_opt_count_(argCount)
+          LPCWSTR *pArguments, // Array of pointers to arguments.
+      _In_ UINT32 argCount,    // Number of arguments.
+      _In_count_(defineCount) const DxcDefine *pDefines, // Array of defines.
+      _In_ UINT32 defineCount,                           // Number of defines.
+      _In_opt_ IDxcIncludeHandler
+          *pIncludeHandler, // user-provided interface to handle #include
+                            // directives (optional).
+      _COM_Outptr_ IDxcOperationResult *
+          *ppResult // Preprocessor output status, buffer, and errors.
+      ) = 0;
+
+  /// \brief Disassemble a program.
+  ///
+  /// \deprecated Please use IDxcCompiler3::Disassemble() instead.
+  virtual HRESULT STDMETHODCALLTYPE Disassemble(
+      _In_ IDxcBlob *pSource,                       // Program to disassemble.
+      _COM_Outptr_ IDxcBlobEncoding **ppDisassembly // Disassembly text.
+      ) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcCompiler2, "A005A9D9-B8BB-4594-B5C9-0E633BEC4D37")
+/// \deprecated Please use IDxcCompiler3 instead.
+struct IDxcCompiler2 : public IDxcCompiler {
+  /// \brief Compile a single entry point to the target shader model with debug
+  /// information.
+  ///
+  /// \deprecated Please use IDxcCompiler3::Compile() instead.
+  virtual HRESULT STDMETHODCALLTYPE CompileWithDebug(
+      _In_ IDxcBlob *pSource,         // Source text to compile.
+      _In_opt_z_ LPCWSTR pSourceName, // Optional file name for pSource. Used in
+                                      // errors and include handlers.
+      _In_opt_z_ LPCWSTR pEntryPoint, // Entry point name.
+      _In_z_ LPCWSTR pTargetProfile,  // Shader profile to compile.
+      _In_opt_count_(argCount)
+          LPCWSTR *pArguments, // Array of pointers to arguments.
+      _In_ UINT32 argCount,    // Number of arguments.
+      _In_count_(defineCount) const DxcDefine *pDefines, // Array of defines.
+      _In_ UINT32 defineCount,                           // Number of defines.
+      _In_opt_ IDxcIncludeHandler
+          *pIncludeHandler, // user-provided interface to handle #include
+                            // directives (optional).
+      _COM_Outptr_ IDxcOperationResult *
+          *ppResult, // Compiler output status, buffer, and errors.
+      _Outptr_opt_result_z_ LPWSTR
+          *ppDebugBlobName, // Suggested file name for debug blob. Must be
+                            // CoTaskMemFree()'d.
+      _COM_Outptr_opt_ IDxcBlob **ppDebugBlob // Debug blob.
+      ) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcLinker, "F1B5BE2A-62DD-4327-A1C2-42AC1E1E78E6")
+/// \brief DXC linker interface.
+///
+/// Use DxcCreateInstance with CLSID_DxcLinker to obtain an instance of this
+/// interface.
+struct IDxcLinker : public IUnknown {
+public:
+  /// \brief Register a library with name to reference it later.
+  virtual HRESULT
+  RegisterLibrary(_In_opt_ LPCWSTR pLibName, ///< Name of the library.
+                  _In_ IDxcBlob *pLib        ///< Library blob.
+                  ) = 0;
+
+  /// \brief Links the shader and produces a shader blob that the Direct3D
+  /// runtime can use.
+  virtual HRESULT STDMETHODCALLTYPE Link(
+      _In_opt_ LPCWSTR pEntryName, ///< Entry point name.
+      _In_ LPCWSTR pTargetProfile, ///< shader profile to link.
+      _In_count_(libCount)
+          const LPCWSTR *pLibNames, ///< Array of library names to link.
+      _In_ UINT32 libCount,         ///< Number of libraries to link.
+      _In_opt_count_(argCount)
+          const LPCWSTR *pArguments, ///< Array of pointers to arguments.
+      _In_ UINT32 argCount,          ///< Number of arguments.
+      _COM_Outptr_ IDxcOperationResult *
+          *ppResult ///< Linker output status, buffer, and errors.
+      ) = 0;
+};
+
+/////////////////////////
+// Latest interfaces. Please use these.
+////////////////////////
+
+CROSS_PLATFORM_UUIDOF(IDxcUtils, "4605C4CB-2019-492A-ADA4-65F20BB7D67F")
+/// \brief Various utility functions for DXC.
+///
+/// Use DxcCreateInstance with CLSID_DxcUtils to obtain an instance of this
+/// interface.
+///
+/// IDxcUtils replaces IDxcLibrary.
+struct IDxcUtils : public IUnknown {
+  /// \brief Create a sub-blob that holds a reference to the outer blob and
+  /// points to its memory.
+  ///
+  /// \param pBlob The outer blob.
+  ///
+  /// \param offset The offset inside the outer blob.
+  ///
+  /// \param length The size, in bytes, of the buffer to reference from the
+  /// output blob.
+  ///
+  /// \param ppResult Address of the pointer that receives a pointer to the
+  /// newly created blob.
+  virtual HRESULT STDMETHODCALLTYPE
+  CreateBlobFromBlob(_In_ IDxcBlob *pBlob, UINT32 offset, UINT32 length,
+                     _COM_Outptr_ IDxcBlob **ppResult) = 0;
+
+  // For codePage, use 0 (or DXC_CP_ACP) for raw binary or ANSI code page.
+
+  /// \brief Create a blob referencing existing memory, with no copy.
+  ///
+  /// \param pData Pointer to buffer containing the contents of the new blob.
+  ///
+  /// \param size The size of the pData buffer, in bytes.
+  ///
+  /// \param codePage The code page to use if the blob contains text.  Use
+  /// DXC_CP_ACP for binary or ANSI code page.
+  ///
+  /// \param ppBlobEncoding Address of the pointer that receives a pointer to
+  /// the newly created blob.
+  ///
+  /// The user must manage the memory lifetime separately.
+  ///
+  /// This replaces IDxcLibrary::CreateBlobWithEncodingFromPinned.
+  virtual HRESULT STDMETHODCALLTYPE CreateBlobFromPinned(
+      _In_bytecount_(size) LPCVOID pData, UINT32 size, UINT32 codePage,
+      _COM_Outptr_ IDxcBlobEncoding **ppBlobEncoding) = 0;
+
+  /// \brief Create a blob, taking ownership of memory allocated with the
+  /// supplied allocator.
+  ///
+  /// \param pData Pointer to buffer containing the contents of the new blob.
+  ///
+  /// \param pIMalloc The memory allocator to use.
+  ///
+  /// \param size The size of thee pData buffer, in bytes.
+  ///
+  /// \param codePage The code page to use if the blob contains text. Use
+  /// DXC_CP_ACP for binary or ANSI code page.
+  ///
+  /// \param ppBlobEncoding Address of the pointer that receives a pointer to
+  /// the newly created blob.
+  ///
+  /// This replaces IDxcLibrary::CreateBlobWithEncodingOnMalloc.
+  virtual HRESULT STDMETHODCALLTYPE MoveToBlob(
+      _In_bytecount_(size) LPCVOID pData, IMalloc *pIMalloc, UINT32 size,
+      UINT32 codePage, _COM_Outptr_ IDxcBlobEncoding **ppBlobEncoding) = 0;
+
+  /// \brief Create a blob containing a copy of the existing data.
+  ///
+  /// \param pData Pointer to buffer containing the contents of the new blob.
+  ///
+  /// \param size The size of thee pData buffer, in bytes.
+  ///
+  /// \param codePage The code page to use if the blob contains text.  Use
+  /// DXC_CP_ACP for binary or ANSI code page.
+  ///
+  /// \param ppBlobEncoding Address of the pointer that receives a pointer to
+  /// the newly created blob.
+  ///
+  /// The new blob and its contents are allocated with the current allocator.
+  /// This replaces IDxcLibrary::CreateBlobWithEncodingOnHeapCopy.
+  virtual HRESULT STDMETHODCALLTYPE
+  CreateBlob(_In_bytecount_(size) LPCVOID pData, UINT32 size, UINT32 codePage,
+             _COM_Outptr_ IDxcBlobEncoding **ppBlobEncoding) = 0;
+
+  /// \brief Create a blob with data loaded from a file.
+  ///
+  /// \param pFileName The name of the file to load from.
+  ///
+  /// \param pCodePage Optional code page to use if the blob contains text. Pass
+  /// NULL for binary data.
+  ///
+  /// \param ppBlobEncoding Address of the pointer that receives a pointer to
+  /// the newly created blob.
+  ///
+  /// The new blob and its contents are allocated with the current allocator.
+  /// This replaces IDxcLibrary::CreateBlobFromFile.
+  virtual HRESULT STDMETHODCALLTYPE
+  LoadFile(_In_z_ LPCWSTR pFileName, _In_opt_ UINT32 *pCodePage,
+           _COM_Outptr_ IDxcBlobEncoding **ppBlobEncoding) = 0;
+
+  /// \brief Create a stream that reads data from a blob.
+  ///
+  /// \param pBlob The blob to read from.
+  ///
+  /// \param ppStream Address of the pointer that receives a pointer to the
+  /// newly created stream.
+  virtual HRESULT STDMETHODCALLTYPE CreateReadOnlyStreamFromBlob(
+      _In_ IDxcBlob *pBlob, _COM_Outptr_ IStream **ppStream) = 0;
+
+  /// \brief Create default file-based include handler.
+  ///
+  /// \param ppResult Address of the pointer that receives a pointer to the
+  /// newly created include handler.
+  virtual HRESULT STDMETHODCALLTYPE
+  CreateDefaultIncludeHandler(_COM_Outptr_ IDxcIncludeHandler **ppResult) = 0;
+
+  /// \brief Convert or return matching encoded text blob as UTF-8.
+  ///
+  /// \param pBlob The blob to convert.
+  ///
+  /// \param ppBlobEncoding Address of the pointer that receives a pointer to
+  /// the newly created blob.
+  virtual HRESULT STDMETHODCALLTYPE GetBlobAsUtf8(
+      _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobUtf8 **ppBlobEncoding) = 0;
+
+  /// \brief Convert or return matching encoded text blob as UTF-16.
+  ///
+  /// \param pBlob The blob to convert.
+  ///
+  /// \param ppBlobEncoding Address of the pointer that receives a pointer to
+  /// the newly created blob.
+  virtual HRESULT STDMETHODCALLTYPE GetBlobAsWide(
+      _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobWide **ppBlobEncoding) = 0;
+
+#ifdef _WIN32
+  /// \brief Convert or return matching encoded text blob as UTF-16.
+  ///
+  /// \param pBlob The blob to convert.
+  ///
+  /// \param ppBlobEncoding Address of the pointer that receives a pointer to
+  /// the newly created blob.
+  ///
+  /// Alias to GetBlobAsWide on Win32.
+  inline HRESULT GetBlobAsUtf16(_In_ IDxcBlob *pBlob,
+                                _COM_Outptr_ IDxcBlobWide **ppBlobEncoding) {
+    return this->GetBlobAsWide(pBlob, ppBlobEncoding);
+  }
+#endif
+
+  /// \brief Retrieve a single part from a DXIL container.
+  ///
+  /// \param pShader The shader to retrieve the part from.
+  ///
+  /// \param DxcPart The part to retrieve (eg DXC_PART_ROOT_SIGNATURE).
+  ///
+  /// \param ppPartData Address of the pointer that receives a pointer to the
+  /// part.
+  ///
+  /// \param pPartSizeInBytes Address of the pointer that receives the size of
+  /// the part.
+  ///
+  /// The returned pointer points inside the buffer passed in pShader.
+  virtual HRESULT STDMETHODCALLTYPE
+  GetDxilContainerPart(_In_ const DxcBuffer *pShader, _In_ UINT32 DxcPart,
+                       _Outptr_result_nullonfailure_ void **ppPartData,
+                       _Out_ UINT32 *pPartSizeInBytes) = 0;
+
+  /// \brief Create reflection interface from serialized DXIL container or the
+  /// DXC_OUT_REFLECTION blob contents.
+  ///
+  /// \param pData The source data.
+  ///
+  /// \param iid The interface ID of the reflection interface to create.
+  ///
+  /// \param ppvReflection Address of the pointer that receives a pointer to the
+  /// newly created reflection interface.
+  ///
+  /// Use this with interfaces such as ID3D12ShaderReflection.
+  virtual HRESULT STDMETHODCALLTYPE CreateReflection(
+      _In_ const DxcBuffer *pData, REFIID iid, void **ppvReflection) = 0;
+
+  /// \brief Build arguments that can be passed to the Compile method.
+  virtual HRESULT STDMETHODCALLTYPE BuildArguments(
+      _In_opt_z_ LPCWSTR pSourceName, ///< Optional file name for pSource. Used
+                                      ///< in errors and include handlers.
+      _In_opt_z_ LPCWSTR pEntryPoint, ///< Entry point name (-E).
+      _In_z_ LPCWSTR pTargetProfile,  ///< Shader profile to compile (-T).
+      _In_opt_count_(argCount)
+          LPCWSTR *pArguments, ///< Array of pointers to arguments.
+      _In_ UINT32 argCount,    ///< Number of arguments.
+      _In_count_(defineCount) const DxcDefine *pDefines, ///< Array of defines.
+      _In_ UINT32 defineCount,                           ///< Number of defines.
+      _COM_Outptr_ IDxcCompilerArgs *
+          *ppArgs ///< Arguments you can use with Compile() method.
+      ) = 0;
+
+  /// \brief Retrieve the hash and contents of a shader PDB.
+  ///
+  /// \param pPDBBlob The blob containing the PDB.
+  ///
+  /// \param ppHash Address of the pointer that receives a pointer to the hash
+  /// blob.
+  ///
+  /// \param ppContainer Address of the pointer that receives a pointer to the
+  /// bloc containing the contents of the PDB.
+  ///
+  virtual HRESULT STDMETHODCALLTYPE
+  GetPDBContents(_In_ IDxcBlob *pPDBBlob, _COM_Outptr_ IDxcBlob **ppHash,
+                 _COM_Outptr_ IDxcBlob **ppContainer) = 0;
+};
+
+/// \brief Specifies the kind of output to retrieve from a IDxcResult.
+///
+/// Note: text outputs returned from version 2 APIs are UTF-8 or UTF-16 based on
+/// the -encoding option passed to the compiler.
+typedef enum DXC_OUT_KIND {
+  DXC_OUT_NONE = 0,        ///< No output.
+  DXC_OUT_OBJECT = 1,      ///< IDxcBlob - Shader or library object.
+  DXC_OUT_ERRORS = 2,      ///< IDxcBlobUtf8 or IDxcBlobWide.
+  DXC_OUT_PDB = 3,         ///< IDxcBlob.
+  DXC_OUT_SHADER_HASH = 4, ///< IDxcBlob - DxcShaderHash of shader or shader
+                           ///< with source info (-Zsb/-Zss).
+  DXC_OUT_DISASSEMBLY = 5, ///< IDxcBlobUtf8 or IDxcBlobWide - from Disassemble.
+  DXC_OUT_HLSL =
+      6, ///< IDxcBlobUtf8 or IDxcBlobWide - from Preprocessor or Rewriter.
+  DXC_OUT_TEXT = 7, ///< IDxcBlobUtf8 or IDxcBlobWide - other text, such as
+                    ///< -ast-dump or -Odump.
+  DXC_OUT_REFLECTION = 8,     ///< IDxcBlob - RDAT part with reflection data.
+  DXC_OUT_ROOT_SIGNATURE = 9, ///< IDxcBlob - Serialized root signature output.
+  DXC_OUT_EXTRA_OUTPUTS = 10, ///< IDxcExtraOutputs - Extra outputs.
+  DXC_OUT_REMARKS =
+      11, ///< IDxcBlobUtf8 or IDxcBlobWide - text directed at stdout.
+  DXC_OUT_TIME_REPORT =
+      12, ///< IDxcBlobUtf8 or IDxcBlobWide - text directed at stdout.
+  DXC_OUT_TIME_TRACE =
+      13, ///< IDxcBlobUtf8 or IDxcBlobWide - text directed at stdout.
+
+  DXC_OUT_LAST = DXC_OUT_TIME_TRACE, ///< Last value for a counter.
+
+  DXC_OUT_NUM_ENUMS,
+  DXC_OUT_FORCE_DWORD = 0xFFFFFFFF
+} DXC_OUT_KIND;
+
+static_assert(DXC_OUT_NUM_ENUMS == DXC_OUT_LAST + 1,
+              "DXC_OUT_* Enum added and last value not updated.");
+
+CROSS_PLATFORM_UUIDOF(IDxcResult, "58346CDA-DDE7-4497-9461-6F87AF5E0659")
+/// \brief Result of a DXC operation.
+///
+/// DXC operations may have multiple outputs, such as a shader object and
+/// errors. This interface provides access to the outputs.
+struct IDxcResult : public IDxcOperationResult {
+  /// \brief Determines whether or not this result has the specified output.
+  ///
+  /// \param dxcOutKind The kind of output to check for.
+  virtual BOOL STDMETHODCALLTYPE HasOutput(_In_ DXC_OUT_KIND dxcOutKind) = 0;
+
+  /// \brief Retrieves the specified output.
+  ///
+  /// \param dxcOutKind The kind of output to retrieve.
+  ///
+  /// \param iid The interface ID of the output interface.
+  ///
+  /// \param ppvObject Address of the pointer that receives a pointer to the
+  /// output.
+  ///
+  /// \param ppOutputName Optional address of a pointer to receive the name
+  /// blob, if there is one.
+  virtual HRESULT STDMETHODCALLTYPE
+  GetOutput(_In_ DXC_OUT_KIND dxcOutKind, _In_ REFIID iid,
+            _COM_Outptr_opt_result_maybenull_ void **ppvObject,
+            _COM_Outptr_ IDxcBlobWide **ppOutputName) = 0;
+
+  /// \brief Retrieves the number of outputs available in this result.
+  virtual UINT32 GetNumOutputs() = 0;
+
+  /// \brief Retrieves the output kind at the specified index.
+  virtual DXC_OUT_KIND GetOutputByIndex(UINT32 Index) = 0;
+
+  /// \brief Retrieves the primary output kind for this result.
+  ///
+  /// See IDxcOperationResult::GetResult() for more information on the primary
+  /// output kinds.
+  virtual DXC_OUT_KIND PrimaryOutput() = 0;
+};
+
+// Special names for extra output that should get written to specific streams.
+#define DXC_EXTRA_OUTPUT_NAME_STDOUT L"*stdout*"
+#define DXC_EXTRA_OUTPUT_NAME_STDERR L"*stderr*"
+
+CROSS_PLATFORM_UUIDOF(IDxcExtraOutputs, "319b37a2-a5c2-494a-a5de-4801b2faf989")
+/// \brief Additional outputs from a DXC operation.
+///
+/// This can be used to obtain outputs that don't have an explicit DXC_OUT_KIND.
+/// Use DXC_OUT_EXTRA_OUTPUTS to obtain instances of this.
+struct IDxcExtraOutputs : public IUnknown {
+  /// \brief Retrieves the number of outputs available
+  virtual UINT32 STDMETHODCALLTYPE GetOutputCount() = 0;
+
+  /// \brief Retrieves the specified output.
+  ///
+  /// \param uIndex The index of the output to retrieve.
+  ///
+  /// \param iid The interface ID of the output interface.
+  ///
+  /// \param ppvObject Optional address of the pointer that receives a pointer
+  /// to the output if there is one.
+  ///
+  /// \param ppOutputType Optional address of the pointer that receives the
+  /// output type name blob if there is one.
+  ///
+  /// \param ppOutputName Optional address of the pointer that receives the
+  /// output name blob if there is one.
+  virtual HRESULT STDMETHODCALLTYPE
+  GetOutput(_In_ UINT32 uIndex, _In_ REFIID iid,
+            _COM_Outptr_opt_result_maybenull_ void **ppvObject,
+            _COM_Outptr_opt_result_maybenull_ IDxcBlobWide **ppOutputType,
+            _COM_Outptr_opt_result_maybenull_ IDxcBlobWide **ppOutputName) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcCompiler3, "228B4687-5A6A-4730-900C-9702B2203F54")
+/// \brief Interface to the DirectX Shader Compiler.
+///
+/// Use DxcCreateInstance with CLSID_DxcCompiler to obtain an instance of this
+/// interface.
+struct IDxcCompiler3 : public IUnknown {
+  /// \brief Compile a shader.
+  ///
+  /// IDxcUtils::BuildArguments can be used to assist building the pArguments
+  /// and argCount parameters.
+  ///
+  /// Depending on the arguments, this method can be used to:
+  ///
+  /// * Compile a single entry point to the target shader model,
+  /// * Compile a library to a library target (-T lib_*)
+  /// * Compile a root signature (-T rootsig_*),
+  /// * Preprocess HLSL source (-P).
+  virtual HRESULT STDMETHODCALLTYPE Compile(
+      _In_ const DxcBuffer *pSource, ///< Source text to compile.
+      _In_opt_count_(argCount)
+          LPCWSTR *pArguments, ///< Array of pointers to arguments.
+      _In_ UINT32 argCount,    ///< Number of arguments.
+      _In_opt_ IDxcIncludeHandler
+          *pIncludeHandler,  ///< user-provided interface to handle include
+                             ///< directives (optional).
+      _In_ REFIID riid,      ///< Interface ID for the result.
+      _Out_ LPVOID *ppResult ///< IDxcResult: status, buffer, and errors.
+      ) = 0;
+
+  /// \brief Disassemble a program.
+  virtual HRESULT STDMETHODCALLTYPE Disassemble(
+      _In_ const DxcBuffer
+          *pObject,     ///< Program to disassemble: dxil container or bitcode.
+      _In_ REFIID riid, ///< Interface ID for the result.
+      _Out_ LPVOID
+          *ppResult ///< IDxcResult: status, disassembly text, and errors.
+      ) = 0;
+};
+
+static const UINT32 DxcValidatorFlags_Default = 0;
+static const UINT32 DxcValidatorFlags_InPlaceEdit =
+    1; // Validator is allowed to update shader blob in-place.
+static const UINT32 DxcValidatorFlags_RootSignatureOnly = 2;
+static const UINT32 DxcValidatorFlags_ModuleOnly = 4;
+static const UINT32 DxcValidatorFlags_ValidMask = 0x7;
+
+CROSS_PLATFORM_UUIDOF(IDxcValidator, "A6E82BD2-1FD7-4826-9811-2857E797F49A")
+/// \brief Interface to DXC shader validator.
+///
+/// Use DxcCreateInstance with CLSID_DxcValidator to obtain an instance of this.
+struct IDxcValidator : public IUnknown {
+  /// \brief Validate a shader.
+  virtual HRESULT STDMETHODCALLTYPE Validate(
+      _In_ IDxcBlob *pShader, ///< Shader to validate.
+      _In_ UINT32 Flags,      ///< Validation flags.
+      _COM_Outptr_ IDxcOperationResult *
+          *ppResult ///< Validation output status, buffer, and errors.
+      ) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcValidator2, "458e1fd1-b1b2-4750-a6e1-9c10f03bed92")
+/// \brief Interface to DXC shader validator.
+///
+/// Use DxcCreateInstance with CLSID_DxcValidator to obtain an instance of this.
+struct IDxcValidator2 : public IDxcValidator {
+  /// \brief Validate a shader with optional debug bitcode.
+  virtual HRESULT STDMETHODCALLTYPE ValidateWithDebug(
+      _In_ IDxcBlob *pShader,               ///< Shader to validate.
+      _In_ UINT32 Flags,                    ///< Validation flags.
+      _In_opt_ DxcBuffer *pOptDebugBitcode, ///< Optional debug module bitcode
+                                            ///< to provide line numbers.
+      _COM_Outptr_ IDxcOperationResult *
+          *ppResult ///< Validation output status, buffer, and errors.
+      ) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcContainerBuilder,
+                      "334b1f50-2292-4b35-99a1-25588d8c17fe")
+/// \brief Interface to DXC container builder.
+///
+/// Use DxcCreateInstance with CLSID_DxcContainerBuilder to obtain an instance
+/// of this.
+struct IDxcContainerBuilder : public IUnknown {
+  /// \brief Load a DxilContainer to the builder.
+  virtual HRESULT STDMETHODCALLTYPE
+  Load(_In_ IDxcBlob *pDxilContainerHeader) = 0;
+
+  /// \brief Add a part to the container.
+  ///
+  /// \param fourCC The part identifier (eg DXC_PART_PDB).
+  ///
+  /// \param pSource The source blob.
+  virtual HRESULT STDMETHODCALLTYPE AddPart(_In_ UINT32 fourCC,
+                                            _In_ IDxcBlob *pSource) = 0;
+
+  /// \brief Remove a part from the container.
+  ///
+  /// \param fourCC The part identifier (eg DXC_PART_PDB).
+  ///
+  /// \return S_OK on success, DXC_E_MISSING_PART if the part was not found, or
+  /// other standard HRESULT error code.
+  virtual HRESULT STDMETHODCALLTYPE RemovePart(_In_ UINT32 fourCC) = 0;
+
+  /// \brief Build the container.
+  ///
+  /// \param ppResult Pointer to variable to receive the result.
+  virtual HRESULT STDMETHODCALLTYPE
+  SerializeContainer(_Out_ IDxcOperationResult **ppResult) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcAssembler, "091f7a26-1c1f-4948-904b-e6e3a8a771d5")
+/// \brief Interface to DxcAssembler.
+///
+/// Use DxcCreateInstance with CLSID_DxcAssembler to obtain an instance of this.
+struct IDxcAssembler : public IUnknown {
+  /// \brief Assemble DXIL in LL or LLVM bitcode to DXIL container.
+  virtual HRESULT STDMETHODCALLTYPE AssembleToContainer(
+      _In_ IDxcBlob *pShader, ///< Shader to assemble.
+      _COM_Outptr_ IDxcOperationResult *
+          *ppResult ///< Assembly output status, buffer, and errors.
+      ) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcContainerReflection,
+                      "d2c21b26-8350-4bdc-976a-331ce6f4c54c")
+/// \brief Interface to DxcContainerReflection.
+///
+/// Use DxcCreateInstance with CLSID_DxcContainerReflection to obtain an
+/// instance of this.
+struct IDxcContainerReflection : public IUnknown {
+  /// \brief Choose the container to perform reflection on
+  ///
+  /// \param pContainer The container to load.  If null is passed then this
+  /// instance will release any held resources.
+  virtual HRESULT STDMETHODCALLTYPE Load(_In_ IDxcBlob *pContainer) = 0;
+
+  /// \brief Retrieves the number of parts in the container.
+  ///
+  /// \param pResult Pointer to variable to receive the result.
+  ///
+  /// \return S_OK on success, E_NOT_VALID_STATE if a container has not been
+  /// loaded using Load(), or other standard HRESULT error codes.
+  virtual HRESULT STDMETHODCALLTYPE GetPartCount(_Out_ UINT32 *pResult) = 0;
+
+  /// \brief Retrieve the kind of a specified part.
+  ///
+  /// \param idx The index of the part to retrieve the kind of.
+  ///
+  /// \param pResult Pointer to variable to receive the result.
+  ///
+  /// \return S_OK on success, E_NOT_VALID_STATE if a container has not been
+  /// loaded using Load(), E_BOUND if idx is out of bounds, or other standard
+  /// HRESULT error codes.
+  virtual HRESULT STDMETHODCALLTYPE GetPartKind(UINT32 idx,
+                                                _Out_ UINT32 *pResult) = 0;
+
+  /// \brief Retrieve the content of a specified part.
+  ///
+  /// \param idx The index of the part to retrieve.
+  ///
+  /// \param ppResult Pointer to variable to receive the result.
+  ///
+  /// \return S_OK on success, E_NOT_VALID_STATE if a container has not been
+  /// loaded using Load(), E_BOUND if idx is out of bounds, or other standard
+  /// HRESULT error codes.
+  virtual HRESULT STDMETHODCALLTYPE
+  GetPartContent(UINT32 idx, _COM_Outptr_ IDxcBlob **ppResult) = 0;
+
+  /// \brief Retrieve the index of the first part with the specified kind.
+  ///
+  /// \param kind The kind to search for.
+  ///
+  /// \param pResult Pointer to variable to receive the index of the matching
+  /// part.
+  ///
+  /// \return S_OK on success, E_NOT_VALID_STATE if a container has not been
+  /// loaded using Load(), HRESULT_FROM_WIN32(ERROR_NOT_FOUND) if there is no
+  /// part with the specified kind, or other standard HRESULT error codes.
+  virtual HRESULT STDMETHODCALLTYPE
+  FindFirstPartKind(UINT32 kind, _Out_ UINT32 *pResult) = 0;
+
+  /// \brief Retrieve the reflection interface for a specified part.
+  ///
+  /// \param idx The index of the part to retrieve the reflection interface of.
+  ///
+  /// \param iid The IID of the interface to retrieve.
+  ///
+  /// \param ppvObject Pointer to variable to receive the result.
+  ///
+  /// Use this with interfaces such as ID3D12ShaderReflection.
+  ///
+  /// \return S_OK on success, E_NOT_VALID_STATE if a container has not been
+  /// loaded using Load(), E_BOUND if idx is out of bounds, or other standard
+  /// HRESULT error codes.
+  virtual HRESULT STDMETHODCALLTYPE GetPartReflection(UINT32 idx, REFIID iid,
+                                                      void **ppvObject) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcOptimizerPass, "AE2CD79F-CC22-453F-9B6B-B124E7A5204C")
+/// \brief An optimizer pass.
+///
+/// Instances of this can be obtained via IDxcOptimizer::GetAvailablePass.
+struct IDxcOptimizerPass : public IUnknown {
+  virtual HRESULT STDMETHODCALLTYPE
+  GetOptionName(_COM_Outptr_ LPWSTR *ppResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetDescription(_COM_Outptr_ LPWSTR *ppResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE GetOptionArgCount(_Out_ UINT32 *pCount) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetOptionArgName(UINT32 argIndex, _COM_Outptr_ LPWSTR *ppResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetOptionArgDescription(UINT32 argIndex, _COM_Outptr_ LPWSTR *ppResult) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcOptimizer, "25740E2E-9CBA-401B-9119-4FB42F39F270")
+/// \brief Interface to DxcOptimizer.
+///
+/// Use DxcCreateInstance with CLSID_DxcOptimizer to obtain an instance of this.
+struct IDxcOptimizer : public IUnknown {
+  virtual HRESULT STDMETHODCALLTYPE
+  GetAvailablePassCount(_Out_ UINT32 *pCount) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetAvailablePass(UINT32 index, _COM_Outptr_ IDxcOptimizerPass **ppResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  RunOptimizer(IDxcBlob *pBlob, _In_count_(optionCount) LPCWSTR *ppOptions,
+               UINT32 optionCount, _COM_Outptr_ IDxcBlob **pOutputModule,
+               _COM_Outptr_opt_ IDxcBlobEncoding **ppOutputText) = 0;
+};
+
+static const UINT32 DxcVersionInfoFlags_None = 0;
+static const UINT32 DxcVersionInfoFlags_Debug = 1; // Matches VS_FF_DEBUG
+static const UINT32 DxcVersionInfoFlags_Internal =
+    2; // Internal Validator (non-signing)
+
+CROSS_PLATFORM_UUIDOF(IDxcVersionInfo, "b04f5b50-2059-4f12-a8ff-a1e0cde1cc7e")
+/// \brief PDB Version information.
+///
+/// Use IDxcPdbUtils2::GetVersionInfo to obtain an instance of this.
+struct IDxcVersionInfo : public IUnknown {
+  virtual HRESULT STDMETHODCALLTYPE GetVersion(_Out_ UINT32 *pMajor,
+                                               _Out_ UINT32 *pMinor) = 0;
+  virtual HRESULT STDMETHODCALLTYPE GetFlags(_Out_ UINT32 *pFlags) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcVersionInfo2, "fb6904c4-42f0-4b62-9c46-983af7da7c83")
+/// \brief PDB Version Information.
+///
+/// Use IDxcPdbUtils2::GetVersionInfo to obtain a IDxcVersionInfo interface, and
+/// then use QueryInterface to obtain an instance of this interface from it.
+struct IDxcVersionInfo2 : public IDxcVersionInfo {
+  virtual HRESULT STDMETHODCALLTYPE GetCommitInfo(
+      _Out_ UINT32 *pCommitCount,          ///< The total number commits.
+      _Outptr_result_z_ char **pCommitHash ///< The SHA of the latest commit.
+                                           ///< Must be CoTaskMemFree()'d.
+      ) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcVersionInfo3, "5e13e843-9d25-473c-9ad2-03b2d0b44b1e")
+/// \brief PDB Version Information.
+///
+/// Use IDxcPdbUtils2::GetVersionInfo to obtain a IDxcVersionInfo interface, and
+/// then use QueryInterface to obtain an instance of this interface from it.
+struct IDxcVersionInfo3 : public IUnknown {
+  virtual HRESULT STDMETHODCALLTYPE GetCustomVersionString(
+      _Outptr_result_z_ char *
+          *pVersionString ///< Custom version string for compiler. Must be
+                          ///< CoTaskMemFree()'d.
+      ) = 0;
+};
+
+struct DxcArgPair {
+  const WCHAR *pName;
+  const WCHAR *pValue;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcPdbUtils, "E6C9647E-9D6A-4C3B-B94C-524B5A6C343D")
+/// \deprecated Please use IDxcPdbUtils2 instead.
+struct IDxcPdbUtils : public IUnknown {
+  virtual HRESULT STDMETHODCALLTYPE Load(_In_ IDxcBlob *pPdbOrDxil) = 0;
+
+  virtual HRESULT STDMETHODCALLTYPE GetSourceCount(_Out_ UINT32 *pCount) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetSource(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobEncoding **ppResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetSourceName(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pResult) = 0;
+
+  virtual HRESULT STDMETHODCALLTYPE GetFlagCount(_Out_ UINT32 *pCount) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetFlag(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pResult) = 0;
+
+  virtual HRESULT STDMETHODCALLTYPE GetArgCount(_Out_ UINT32 *pCount) = 0;
+  virtual HRESULT STDMETHODCALLTYPE GetArg(_In_ UINT32 uIndex,
+                                           _Outptr_result_z_ BSTR *pResult) = 0;
+
+  virtual HRESULT STDMETHODCALLTYPE GetArgPairCount(_Out_ UINT32 *pCount) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetArgPair(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pName,
+             _Outptr_result_z_ BSTR *pValue) = 0;
+
+  virtual HRESULT STDMETHODCALLTYPE GetDefineCount(_Out_ UINT32 *pCount) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetDefine(_In_ UINT32 uIndex, _Outptr_result_z_ BSTR *pResult) = 0;
+
+  virtual HRESULT STDMETHODCALLTYPE
+  GetTargetProfile(_Outptr_result_z_ BSTR *pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetEntryPoint(_Outptr_result_z_ BSTR *pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetMainFileName(_Outptr_result_z_ BSTR *pResult) = 0;
+
+  virtual HRESULT STDMETHODCALLTYPE
+  GetHash(_COM_Outptr_ IDxcBlob **ppResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetName(_Outptr_result_z_ BSTR *pResult) = 0;
+
+  virtual BOOL STDMETHODCALLTYPE IsFullPDB() = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetFullPDB(_COM_Outptr_ IDxcBlob **ppFullPDB) = 0;
+
+  virtual HRESULT STDMETHODCALLTYPE
+  GetVersionInfo(_COM_Outptr_ IDxcVersionInfo **ppVersionInfo) = 0;
+
+  virtual HRESULT STDMETHODCALLTYPE
+  SetCompiler(_In_ IDxcCompiler3 *pCompiler) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  CompileForFullPDB(_COM_Outptr_ IDxcResult **ppResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE OverrideArgs(_In_ DxcArgPair *pArgPairs,
+                                                 UINT32 uNumArgPairs) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  OverrideRootSignature(_In_ const WCHAR *pRootSignature) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcPdbUtils2, "4315D938-F369-4F93-95A2-252017CC3807")
+/// \brief DxcPdbUtils interface.
+///
+/// Use DxcCreateInstance with CLSID_DxcPdbUtils to create an instance of this.
+struct IDxcPdbUtils2 : public IUnknown {
+  virtual HRESULT STDMETHODCALLTYPE Load(_In_ IDxcBlob *pPdbOrDxil) = 0;
+
+  virtual HRESULT STDMETHODCALLTYPE GetSourceCount(_Out_ UINT32 *pCount) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetSource(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobEncoding **ppResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetSourceName(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobWide **ppResult) = 0;
+
+  virtual HRESULT STDMETHODCALLTYPE GetLibraryPDBCount(UINT32 *pCount) = 0;
+  virtual HRESULT STDMETHODCALLTYPE GetLibraryPDB(
+      _In_ UINT32 uIndex, _COM_Outptr_ IDxcPdbUtils2 **ppOutPdbUtils,
+      _COM_Outptr_opt_result_maybenull_ IDxcBlobWide **ppLibraryName) = 0;
+
+  virtual HRESULT STDMETHODCALLTYPE GetFlagCount(_Out_ UINT32 *pCount) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetFlag(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobWide **ppResult) = 0;
+
+  virtual HRESULT STDMETHODCALLTYPE GetArgCount(_Out_ UINT32 *pCount) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetArg(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobWide **ppResult) = 0;
+
+  virtual HRESULT STDMETHODCALLTYPE GetArgPairCount(_Out_ UINT32 *pCount) = 0;
+  virtual HRESULT STDMETHODCALLTYPE GetArgPair(
+      _In_ UINT32 uIndex, _COM_Outptr_result_maybenull_ IDxcBlobWide **ppName,
+      _COM_Outptr_result_maybenull_ IDxcBlobWide **ppValue) = 0;
+
+  virtual HRESULT STDMETHODCALLTYPE GetDefineCount(_Out_ UINT32 *pCount) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetDefine(_In_ UINT32 uIndex, _COM_Outptr_ IDxcBlobWide **ppResult) = 0;
+
+  virtual HRESULT STDMETHODCALLTYPE
+  GetTargetProfile(_COM_Outptr_result_maybenull_ IDxcBlobWide **ppResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetEntryPoint(_COM_Outptr_result_maybenull_ IDxcBlobWide **ppResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetMainFileName(_COM_Outptr_result_maybenull_ IDxcBlobWide **ppResult) = 0;
+
+  virtual HRESULT STDMETHODCALLTYPE
+  GetHash(_COM_Outptr_result_maybenull_ IDxcBlob **ppResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetName(_COM_Outptr_result_maybenull_ IDxcBlobWide **ppResult) = 0;
+
+  virtual HRESULT STDMETHODCALLTYPE GetVersionInfo(
+      _COM_Outptr_result_maybenull_ IDxcVersionInfo **ppVersionInfo) = 0;
+
+  virtual HRESULT STDMETHODCALLTYPE GetCustomToolchainID(_Out_ UINT32 *pID) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetCustomToolchainData(_COM_Outptr_result_maybenull_ IDxcBlob **ppBlob) = 0;
+
+  virtual HRESULT STDMETHODCALLTYPE
+  GetWholeDxil(_COM_Outptr_result_maybenull_ IDxcBlob **ppResult) = 0;
+
+  virtual BOOL STDMETHODCALLTYPE IsFullPDB() = 0;
+  virtual BOOL STDMETHODCALLTYPE IsPDBRef() = 0;
+};
+
+// Note: __declspec(selectany) requires 'extern'
+// On Linux __declspec(selectany) is removed and using 'extern' results in link
+// error.
+#ifdef _MSC_VER
+#define CLSID_SCOPE __declspec(selectany) extern
+#else
+#define CLSID_SCOPE
+#endif
+
+CLSID_SCOPE const CLSID CLSID_DxcCompiler = {
+    0x73e22d93,
+    0xe6ce,
+    0x47f3,
+    {0xb5, 0xbf, 0xf0, 0x66, 0x4f, 0x39, 0xc1, 0xb0}};
+
+// {EF6A8087-B0EA-4D56-9E45-D07E1A8B7806}
+CLSID_SCOPE const GUID CLSID_DxcLinker = {
+    0xef6a8087,
+    0xb0ea,
+    0x4d56,
+    {0x9e, 0x45, 0xd0, 0x7e, 0x1a, 0x8b, 0x78, 0x6}};
+
+// {CD1F6B73-2AB0-484D-8EDC-EBE7A43CA09F}
+CLSID_SCOPE const CLSID CLSID_DxcDiaDataSource = {
+    0xcd1f6b73,
+    0x2ab0,
+    0x484d,
+    {0x8e, 0xdc, 0xeb, 0xe7, 0xa4, 0x3c, 0xa0, 0x9f}};
+
+// {3E56AE82-224D-470F-A1A1-FE3016EE9F9D}
+CLSID_SCOPE const CLSID CLSID_DxcCompilerArgs = {
+    0x3e56ae82,
+    0x224d,
+    0x470f,
+    {0xa1, 0xa1, 0xfe, 0x30, 0x16, 0xee, 0x9f, 0x9d}};
+
+// {6245D6AF-66E0-48FD-80B4-4D271796748C}
+CLSID_SCOPE const GUID CLSID_DxcLibrary = {
+    0x6245d6af,
+    0x66e0,
+    0x48fd,
+    {0x80, 0xb4, 0x4d, 0x27, 0x17, 0x96, 0x74, 0x8c}};
+
+CLSID_SCOPE const GUID CLSID_DxcUtils = CLSID_DxcLibrary;
+
+// {8CA3E215-F728-4CF3-8CDD-88AF917587A1}
+CLSID_SCOPE const GUID CLSID_DxcValidator = {
+    0x8ca3e215,
+    0xf728,
+    0x4cf3,
+    {0x8c, 0xdd, 0x88, 0xaf, 0x91, 0x75, 0x87, 0xa1}};
+
+// {D728DB68-F903-4F80-94CD-DCCF76EC7151}
+CLSID_SCOPE const GUID CLSID_DxcAssembler = {
+    0xd728db68,
+    0xf903,
+    0x4f80,
+    {0x94, 0xcd, 0xdc, 0xcf, 0x76, 0xec, 0x71, 0x51}};
+
+// {b9f54489-55b8-400c-ba3a-1675e4728b91}
+CLSID_SCOPE const GUID CLSID_DxcContainerReflection = {
+    0xb9f54489,
+    0x55b8,
+    0x400c,
+    {0xba, 0x3a, 0x16, 0x75, 0xe4, 0x72, 0x8b, 0x91}};
+
+// {AE2CD79F-CC22-453F-9B6B-B124E7A5204C}
+CLSID_SCOPE const GUID CLSID_DxcOptimizer = {
+    0xae2cd79f,
+    0xcc22,
+    0x453f,
+    {0x9b, 0x6b, 0xb1, 0x24, 0xe7, 0xa5, 0x20, 0x4c}};
+
+// {94134294-411f-4574-b4d0-8741e25240d2}
+CLSID_SCOPE const GUID CLSID_DxcContainerBuilder = {
+    0x94134294,
+    0x411f,
+    0x4574,
+    {0xb4, 0xd0, 0x87, 0x41, 0xe2, 0x52, 0x40, 0xd2}};
+
+// {54621dfb-f2ce-457e-ae8c-ec355faeec7c}
+CLSID_SCOPE const GUID CLSID_DxcPdbUtils = {
+    0x54621dfb,
+    0xf2ce,
+    0x457e,
+    {0xae, 0x8c, 0xec, 0x35, 0x5f, 0xae, 0xec, 0x7c}};
+
+#endif

+ 30 - 0
ThirdParty/Dxc/dxcerrors.h

@@ -0,0 +1,30 @@
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// dxcerror.h                                                                //
+// Copyright (C) Microsoft Corporation. All rights reserved.                 //
+// This file is distributed under the University of Illinois Open Source     //
+// License. See LICENSE.TXT for details.                                     //
+//                                                                           //
+// Provides definition of error codes.                                        //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef __DXC_ERRORS__
+#define __DXC_ERRORS__
+
+#ifndef FACILITY_GRAPHICS
+#define FACILITY_GRAPHICS 36
+#endif
+
+#define DXC_EXCEPTION_CODE(name, status)                                       \
+  static constexpr DWORD EXCEPTION_##name =                                    \
+      (0xc0000000u | (FACILITY_GRAPHICS << 16) |                               \
+       (0xff00u | (status & 0xffu)));
+
+DXC_EXCEPTION_CODE(LOAD_LIBRARY_FAILED, 0x00u)
+DXC_EXCEPTION_CODE(NO_HMODULE, 0x01u)
+DXC_EXCEPTION_CODE(GET_PROC_FAILED, 0x02u)
+
+#undef DXC_EXCEPTION_CODE
+
+#endif

+ 959 - 0
ThirdParty/Dxc/dxcisense.h

@@ -0,0 +1,959 @@
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// dxcisense.h                                                               //
+// Copyright (C) Microsoft Corporation. All rights reserved.                 //
+// This file is distributed under the University of Illinois Open Source     //
+// License. See LICENSE.TXT for details.                                     //
+//                                                                           //
+// Provides declarations for the DirectX Compiler IntelliSense component.    //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef __DXC_ISENSE__
+#define __DXC_ISENSE__
+
+#include "dxcapi.h"
+#ifndef _WIN32
+#include "WinAdapter.h"
+#endif
+
+typedef enum DxcGlobalOptions {
+  DxcGlobalOpt_None = 0x0,
+  DxcGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
+  DxcGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
+  DxcGlobalOpt_ThreadBackgroundPriorityForAll =
+      DxcGlobalOpt_ThreadBackgroundPriorityForIndexing |
+      DxcGlobalOpt_ThreadBackgroundPriorityForEditing
+} DxcGlobalOptions;
+
+typedef enum DxcTokenKind {
+  DxcTokenKind_Punctuation =
+      0,                    // A token that contains some kind of punctuation.
+  DxcTokenKind_Keyword = 1, // A language keyword.
+  DxcTokenKind_Identifier = 2, // An identifier (that is not a keyword).
+  DxcTokenKind_Literal = 3,    // A numeric, string, or character literal.
+  DxcTokenKind_Comment = 4,    // A comment.
+  DxcTokenKind_Unknown =
+      5, // An unknown token (possibly known to a future version).
+  DxcTokenKind_BuiltInType = 6, // A built-in type like int, void or float3.
+} DxcTokenKind;
+
+typedef enum DxcTypeKind {
+  DxcTypeKind_Invalid =
+      0, // Reprents an invalid type (e.g., where no type is available).
+  DxcTypeKind_Unexposed =
+      1, // A type whose specific kind is not exposed via this interface.
+  // Builtin types
+  DxcTypeKind_Void = 2,
+  DxcTypeKind_Bool = 3,
+  DxcTypeKind_Char_U = 4,
+  DxcTypeKind_UChar = 5,
+  DxcTypeKind_Char16 = 6,
+  DxcTypeKind_Char32 = 7,
+  DxcTypeKind_UShort = 8,
+  DxcTypeKind_UInt = 9,
+  DxcTypeKind_ULong = 10,
+  DxcTypeKind_ULongLong = 11,
+  DxcTypeKind_UInt128 = 12,
+  DxcTypeKind_Char_S = 13,
+  DxcTypeKind_SChar = 14,
+  DxcTypeKind_WChar = 15,
+  DxcTypeKind_Short = 16,
+  DxcTypeKind_Int = 17,
+  DxcTypeKind_Long = 18,
+  DxcTypeKind_LongLong = 19,
+  DxcTypeKind_Int128 = 20,
+  DxcTypeKind_Float = 21,
+  DxcTypeKind_Double = 22,
+  DxcTypeKind_LongDouble = 23,
+  DxcTypeKind_NullPtr = 24,
+  DxcTypeKind_Overload = 25,
+  DxcTypeKind_Dependent = 26,
+  DxcTypeKind_ObjCId = 27,
+  DxcTypeKind_ObjCClass = 28,
+  DxcTypeKind_ObjCSel = 29,
+  DxcTypeKind_FirstBuiltin = DxcTypeKind_Void,
+  DxcTypeKind_LastBuiltin = DxcTypeKind_ObjCSel,
+
+  DxcTypeKind_Complex = 100,
+  DxcTypeKind_Pointer = 101,
+  DxcTypeKind_BlockPointer = 102,
+  DxcTypeKind_LValueReference = 103,
+  DxcTypeKind_RValueReference = 104,
+  DxcTypeKind_Record = 105,
+  DxcTypeKind_Enum = 106,
+  DxcTypeKind_Typedef = 107,
+  DxcTypeKind_ObjCInterface = 108,
+  DxcTypeKind_ObjCObjectPointer = 109,
+  DxcTypeKind_FunctionNoProto = 110,
+  DxcTypeKind_FunctionProto = 111,
+  DxcTypeKind_ConstantArray = 112,
+  DxcTypeKind_Vector = 113,
+  DxcTypeKind_IncompleteArray = 114,
+  DxcTypeKind_VariableArray = 115,
+  DxcTypeKind_DependentSizedArray = 116,
+  DxcTypeKind_MemberPointer = 117
+} DxcTypeKind;
+
+// Describes the severity of a particular diagnostic.
+typedef enum DxcDiagnosticSeverity {
+  // A diagnostic that has been suppressed, e.g., by a command-line option.
+  DxcDiagnostic_Ignored = 0,
+
+  // This diagnostic is a note that should be attached to the previous
+  // (non-note) diagnostic.
+  DxcDiagnostic_Note = 1,
+
+  // This diagnostic indicates suspicious code that may not be wrong.
+  DxcDiagnostic_Warning = 2,
+
+  // This diagnostic indicates that the code is ill-formed.
+  DxcDiagnostic_Error = 3,
+
+  // This diagnostic indicates that the code is ill-formed such that future
+  // parser rec unlikely to produce useful results.
+  DxcDiagnostic_Fatal = 4
+
+} DxcDiagnosticSeverity;
+
+// Options to control the display of diagnostics.
+typedef enum DxcDiagnosticDisplayOptions {
+  // Display the source-location information where the diagnostic was located.
+  DxcDiagnostic_DisplaySourceLocation = 0x01,
+
+  // If displaying the source-location information of the diagnostic,
+  // also include the column number.
+  DxcDiagnostic_DisplayColumn = 0x02,
+
+  // If displaying the source-location information of the diagnostic,
+  // also include information about source ranges in a machine-parsable format.
+  DxcDiagnostic_DisplaySourceRanges = 0x04,
+
+  // Display the option name associated with this diagnostic, if any.
+  DxcDiagnostic_DisplayOption = 0x08,
+
+  // Display the category number associated with this diagnostic, if any.
+  DxcDiagnostic_DisplayCategoryId = 0x10,
+
+  // Display the category name associated with this diagnostic, if any.
+  DxcDiagnostic_DisplayCategoryName = 0x20,
+
+  // Display the severity of the diagnostic message.
+  DxcDiagnostic_DisplaySeverity = 0x200
+} DxcDiagnosticDisplayOptions;
+
+typedef enum DxcTranslationUnitFlags {
+  // Used to indicate that no special translation-unit options are needed.
+  DxcTranslationUnitFlags_None = 0x0,
+
+  // Used to indicate that the parser should construct a "detailed"
+  // preprocessing record, including all macro definitions and instantiations.
+  DxcTranslationUnitFlags_DetailedPreprocessingRecord = 0x01,
+
+  // Used to indicate that the translation unit is incomplete.
+  DxcTranslationUnitFlags_Incomplete = 0x02,
+
+  // Used to indicate that the translation unit should be built with an
+  // implicit precompiled header for the preamble.
+  DxcTranslationUnitFlags_PrecompiledPreamble = 0x04,
+
+  // Used to indicate that the translation unit should cache some
+  // code-completion results with each reparse of the source file.
+  DxcTranslationUnitFlags_CacheCompletionResults = 0x08,
+
+  // Used to indicate that the translation unit will be serialized with
+  // SaveTranslationUnit.
+  DxcTranslationUnitFlags_ForSerialization = 0x10,
+
+  // DEPRECATED
+  DxcTranslationUnitFlags_CXXChainedPCH = 0x20,
+
+  // Used to indicate that function/method bodies should be skipped while
+  // parsing.
+  DxcTranslationUnitFlags_SkipFunctionBodies = 0x40,
+
+  // Used to indicate that brief documentation comments should be
+  // included into the set of code completions returned from this translation
+  // unit.
+  DxcTranslationUnitFlags_IncludeBriefCommentsInCodeCompletion = 0x80,
+
+  // Used to indicate that compilation should occur on the caller's thread.
+  DxcTranslationUnitFlags_UseCallerThread = 0x800
+} DxcTranslationUnitFlags;
+
+typedef enum DxcCursorFormatting {
+  DxcCursorFormatting_Default =
+      0x0, // Default rules, language-insensitive formatting.
+  DxcCursorFormatting_UseLanguageOptions =
+      0x1, // Language-sensitive formatting.
+  DxcCursorFormatting_SuppressSpecifiers = 0x2, // Supresses type specifiers.
+  DxcCursorFormatting_SuppressTagKeyword =
+      0x4, // Suppressed tag keyword (eg, 'class').
+  DxcCursorFormatting_IncludeNamespaceKeyword =
+      0x8, // Include namespace keyword.
+} DxcCursorFormatting;
+
+enum DxcCursorKind {
+  /* Declarations */
+  DxcCursor_UnexposedDecl =
+      1, // A declaration whose specific kind is not exposed via this interface.
+  DxcCursor_StructDecl = 2, // A C or C++ struct.
+  DxcCursor_UnionDecl = 3,  // A C or C++ union.
+  DxcCursor_ClassDecl = 4,  // A C++ class.
+  DxcCursor_EnumDecl = 5,   // An enumeration.
+  DxcCursor_FieldDecl = 6,  // A field (in C) or non-static data member (in C++)
+                            // in a struct, union, or C++ class.
+  DxcCursor_EnumConstantDecl = 7,   // An enumerator constant.
+  DxcCursor_FunctionDecl = 8,       // A function.
+  DxcCursor_VarDecl = 9,            // A variable.
+  DxcCursor_ParmDecl = 10,          // A function or method parameter.
+  DxcCursor_ObjCInterfaceDecl = 11, // An Objective-C interface.
+  DxcCursor_ObjCCategoryDecl = 12,  // An Objective-C interface for a category.
+  DxcCursor_ObjCProtocolDecl = 13,  // An Objective-C protocol declaration.
+  DxcCursor_ObjCPropertyDecl = 14,  // An Objective-C property declaration.
+  DxcCursor_ObjCIvarDecl = 15,      // An Objective-C instance variable.
+  DxcCursor_ObjCInstanceMethodDecl = 16, // An Objective-C instance method.
+  DxcCursor_ObjCClassMethodDecl = 17,    // An Objective-C class method.
+  DxcCursor_ObjCImplementationDecl = 18, // An Objective-C \@implementation.
+  DxcCursor_ObjCCategoryImplDecl =
+      19,                     // An Objective-C \@implementation for a category.
+  DxcCursor_TypedefDecl = 20, // A typedef
+  DxcCursor_CXXMethod = 21,   // A C++ class method.
+  DxcCursor_Namespace = 22,   // A C++ namespace.
+  DxcCursor_LinkageSpec = 23, // A linkage specification, e.g. 'extern "C"'.
+  DxcCursor_Constructor = 24, // A C++ constructor.
+  DxcCursor_Destructor = 25,  // A C++ destructor.
+  DxcCursor_ConversionFunction = 26,       // A C++ conversion function.
+  DxcCursor_TemplateTypeParameter = 27,    // A C++ template type parameter.
+  DxcCursor_NonTypeTemplateParameter = 28, // A C++ non-type template parameter.
+  DxcCursor_TemplateTemplateParameter =
+      29,                          // A C++ template template parameter.
+  DxcCursor_FunctionTemplate = 30, // A C++ function template.
+  DxcCursor_ClassTemplate = 31,    // A C++ class template.
+  DxcCursor_ClassTemplatePartialSpecialization =
+      32,                        // A C++ class template partial specialization.
+  DxcCursor_NamespaceAlias = 33, // A C++ namespace alias declaration.
+  DxcCursor_UsingDirective = 34, // A C++ using directive.
+  DxcCursor_UsingDeclaration = 35,   // A C++ using declaration.
+  DxcCursor_TypeAliasDecl = 36,      // A C++ alias declaration
+  DxcCursor_ObjCSynthesizeDecl = 37, // An Objective-C \@synthesize definition.
+  DxcCursor_ObjCDynamicDecl = 38,    // An Objective-C \@dynamic definition.
+  DxcCursor_CXXAccessSpecifier = 39, // An access specifier.
+
+  DxcCursor_FirstDecl = DxcCursor_UnexposedDecl,
+  DxcCursor_LastDecl = DxcCursor_CXXAccessSpecifier,
+
+  /* References */
+  DxcCursor_FirstRef = 40, /* Decl references */
+  DxcCursor_ObjCSuperClassRef = 40,
+  DxcCursor_ObjCProtocolRef = 41,
+  DxcCursor_ObjCClassRef = 42,
+  /**
+   * \brief A reference to a type declaration.
+   *
+   * A type reference occurs anywhere where a type is named but not
+   * declared. For example, given:
+   *
+   * \code
+   * typedef unsigned size_type;
+   * size_type size;
+   * \endcode
+   *
+   * The typedef is a declaration of size_type (DxcCursor_TypedefDecl),
+   * while the type of the variable "size" is referenced. The cursor
+   * referenced by the type of size is the typedef for size_type.
+   */
+  DxcCursor_TypeRef = 43, // A reference to a type declaration.
+  DxcCursor_CXXBaseSpecifier = 44,
+  DxcCursor_TemplateRef =
+      45, // A reference to a class template, function template, template
+          // template parameter, or class template partial specialization.
+  DxcCursor_NamespaceRef = 46, // A reference to a namespace or namespace alias.
+  DxcCursor_MemberRef =
+      47, // A reference to a member of a struct, union, or class that occurs in
+          // some non-expression context, e.g., a designated initializer.
+  /**
+   * \brief A reference to a labeled statement.
+   *
+   * This cursor kind is used to describe the jump to "start_over" in the
+   * goto statement in the following example:
+   *
+   * \code
+   *   start_over:
+   *     ++counter;
+   *
+   *     goto start_over;
+   * \endcode
+   *
+   * A label reference cursor refers to a label statement.
+   */
+  DxcCursor_LabelRef = 48, // A reference to a labeled statement.
+
+  // A reference to a set of overloaded functions or function templates
+  // that has not yet been resolved to a specific function or function template.
+  //
+  // An overloaded declaration reference cursor occurs in C++ templates where
+  // a dependent name refers to a function.
+  DxcCursor_OverloadedDeclRef = 49,
+  DxcCursor_VariableRef =
+      50, // A reference to a variable that occurs in some non-expression
+          // context, e.g., a C++ lambda capture list.
+
+  DxcCursor_LastRef = DxcCursor_VariableRef,
+
+  /* Error conditions */
+  DxcCursor_FirstInvalid = 70,
+  DxcCursor_InvalidFile = 70,
+  DxcCursor_NoDeclFound = 71,
+  DxcCursor_NotImplemented = 72,
+  DxcCursor_InvalidCode = 73,
+  DxcCursor_LastInvalid = DxcCursor_InvalidCode,
+
+  /* Expressions */
+  DxcCursor_FirstExpr = 100,
+
+  /**
+   * \brief An expression whose specific kind is not exposed via this
+   * interface.
+   *
+   * Unexposed expressions have the same operations as any other kind
+   * of expression; one can extract their location information,
+   * spelling, children, etc. However, the specific kind of the
+   * expression is not reported.
+   */
+  DxcCursor_UnexposedExpr = 100, // An expression whose specific kind is not
+                                 // exposed via this interface.
+  DxcCursor_DeclRefExpr =
+      101, // An expression that refers to some value declaration, such as a
+           // function, varible, or enumerator.
+  DxcCursor_MemberRefExpr =
+      102, // An expression that refers to a member of a struct, union, class,
+           // Objective-C class, etc.
+  DxcCursor_CallExpr = 103,        // An expression that calls a function.
+  DxcCursor_ObjCMessageExpr = 104, // An expression that sends a message to an
+                                   // Objective-C object or class.
+  DxcCursor_BlockExpr = 105, // An expression that represents a block literal.
+  DxcCursor_IntegerLiteral = 106,   // An integer literal.
+  DxcCursor_FloatingLiteral = 107,  // A floating point number literal.
+  DxcCursor_ImaginaryLiteral = 108, // An imaginary number literal.
+  DxcCursor_StringLiteral = 109,    // A string literal.
+  DxcCursor_CharacterLiteral = 110, // A character literal.
+  DxcCursor_ParenExpr =
+      111, // A parenthesized expression, e.g. "(1)". This AST node is only
+           // formed if full location information is requested.
+  DxcCursor_UnaryOperator = 112,      // This represents the unary-expression's
+                                      // (except sizeof and alignof).
+  DxcCursor_ArraySubscriptExpr = 113, // [C99 6.5.2.1] Array Subscripting.
+  DxcCursor_BinaryOperator =
+      114, // A builtin binary operation expression such as "x + y" or "x <= y".
+  DxcCursor_CompoundAssignOperator = 115, // Compound assignment such as "+=".
+  DxcCursor_ConditionalOperator = 116,    // The ?: ternary operator.
+  DxcCursor_CStyleCastExpr =
+      117, // An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++
+           // [expr.cast]), which uses the syntax (Type)expr, eg: (int)f.
+  DxcCursor_CompoundLiteralExpr = 118, // [C99 6.5.2.5]
+  DxcCursor_InitListExpr = 119, // Describes an C or C++ initializer list.
+  DxcCursor_AddrLabelExpr =
+      120, // The GNU address of label extension, representing &&label.
+  DxcCursor_StmtExpr =
+      121, // This is the GNU Statement Expression extension: ({int X=4; X;})
+  DxcCursor_GenericSelectionExpr = 122, // Represents a C11 generic selection.
+
+  /** \brief Implements the GNU __null extension, which is a name for a null
+   * pointer constant that has integral type (e.g., int or long) and is the same
+   * size and alignment as a pointer.
+   *
+   * The __null extension is typically only used by system headers, which define
+   * NULL as __null in C++ rather than using 0 (which is an integer that may not
+   * match the size of a pointer).
+   */
+  DxcCursor_GNUNullExpr = 123,
+  DxcCursor_CXXStaticCastExpr = 124,  // C++'s static_cast<> expression.
+  DxcCursor_CXXDynamicCastExpr = 125, // C++'s dynamic_cast<> expression.
+  DxcCursor_CXXReinterpretCastExpr =
+      126,                          // C++'s reinterpret_cast<> expression.
+  DxcCursor_CXXConstCastExpr = 127, // C++'s const_cast<> expression.
+
+  /** \brief Represents an explicit C++ type conversion that uses "functional"
+   * notion (C++ [expr.type.conv]).
+   *
+   * Example:
+   * \code
+   *   x = int(0.5);
+   * \endcode
+   */
+  DxcCursor_CXXFunctionalCastExpr = 128,
+  DxcCursor_CXXTypeidExpr = 129, // A C++ typeid expression (C++ [expr.typeid]).
+  DxcCursor_CXXBoolLiteralExpr = 130,    // [C++ 2.13.5] C++ Boolean Literal.
+  DxcCursor_CXXNullPtrLiteralExpr = 131, // [C++0x 2.14.7] C++ Pointer Literal.
+  DxcCursor_CXXThisExpr = 132,  // Represents the "this" expression in C++
+  DxcCursor_CXXThrowExpr = 133, // [C++ 15] C++ Throw Expression, both 'throw'
+                                // and 'throw' assignment-expression.
+  DxcCursor_CXXNewExpr = 134,   // A new expression for memory allocation and
+                              // constructor calls, e.g: "new CXXNewExpr(foo)".
+  DxcCursor_CXXDeleteExpr =
+      135, // A delete expression for memory deallocation and destructor calls,
+           // e.g. "delete[] pArray".
+  DxcCursor_UnaryExpr = 136, // A unary expression.
+  DxcCursor_ObjCStringLiteral =
+      137,                        // An Objective-C string literal i.e. @"foo".
+  DxcCursor_ObjCEncodeExpr = 138, // An Objective-C \@encode expression.
+  DxcCursor_ObjCSelectorExpr = 139, // An Objective-C \@selector expression.
+  DxcCursor_ObjCProtocolExpr = 140, // An Objective-C \@protocol expression.
+
+  /** \brief An Objective-C "bridged" cast expression, which casts between
+   * Objective-C pointers and C pointers, transferring ownership in the process.
+   *
+   * \code
+   *   NSString *str = (__bridge_transfer NSString *)CFCreateString();
+   * \endcode
+   */
+  DxcCursor_ObjCBridgedCastExpr = 141,
+
+  /** \brief Represents a C++0x pack expansion that produces a sequence of
+   * expressions.
+   *
+   * A pack expansion expression contains a pattern (which itself is an
+   * expression) followed by an ellipsis. For example:
+   *
+   * \code
+   * template<typename F, typename ...Types>
+   * void forward(F f, Types &&...args) {
+   *  f(static_cast<Types&&>(args)...);
+   * }
+   * \endcode
+   */
+  DxcCursor_PackExpansionExpr = 142,
+
+  /** \brief Represents an expression that computes the length of a parameter
+   * pack.
+   *
+   * \code
+   * template<typename ...Types>
+   * struct count {
+   *   static const unsigned value = sizeof...(Types);
+   * };
+   * \endcode
+   */
+  DxcCursor_SizeOfPackExpr = 143,
+
+  /* \brief Represents a C++ lambda expression that produces a local function
+   * object.
+   *
+   * \code
+   * void abssort(float *x, unsigned N) {
+   *   std::sort(x, x + N,
+   *             [](float a, float b) {
+   *               return std::abs(a) < std::abs(b);
+   *             });
+   * }
+   * \endcode
+   */
+  DxcCursor_LambdaExpr = 144,
+  DxcCursor_ObjCBoolLiteralExpr = 145, // Objective-c Boolean Literal.
+  DxcCursor_ObjCSelfExpr =
+      146, // Represents the "self" expression in a ObjC method.
+  DxcCursor_LastExpr = DxcCursor_ObjCSelfExpr,
+
+  /* Statements */
+  DxcCursor_FirstStmt = 200,
+  /**
+   * \brief A statement whose specific kind is not exposed via this
+   * interface.
+   *
+   * Unexposed statements have the same operations as any other kind of
+   * statement; one can extract their location information, spelling,
+   * children, etc. However, the specific kind of the statement is not
+   * reported.
+   */
+  DxcCursor_UnexposedStmt = 200,
+
+  /** \brief A labelled statement in a function.
+   *
+   * This cursor kind is used to describe the "start_over:" label statement in
+   * the following example:
+   *
+   * \code
+   *   start_over:
+   *     ++counter;
+   * \endcode
+   *
+   */
+  DxcCursor_LabelStmt = 201,
+  DxcCursor_CompoundStmt =
+      202, // A group of statements like { stmt stmt }. This cursor kind is used
+           // to describe compound statements, e.g. function bodies.
+  DxcCursor_CaseStmt = 203,         // A case statement.
+  DxcCursor_DefaultStmt = 204,      // A default statement.
+  DxcCursor_IfStmt = 205,           // An if statement
+  DxcCursor_SwitchStmt = 206,       // A switch statement.
+  DxcCursor_WhileStmt = 207,        // A while statement.
+  DxcCursor_DoStmt = 208,           // A do statement.
+  DxcCursor_ForStmt = 209,          // A for statement.
+  DxcCursor_GotoStmt = 210,         // A goto statement.
+  DxcCursor_IndirectGotoStmt = 211, // An indirect goto statement.
+  DxcCursor_ContinueStmt = 212,     // A continue statement.
+  DxcCursor_BreakStmt = 213,        // A break statement.
+  DxcCursor_ReturnStmt = 214,       // A return statement.
+  DxcCursor_GCCAsmStmt = 215, // A GCC inline assembly statement extension.
+  DxcCursor_AsmStmt = DxcCursor_GCCAsmStmt,
+
+  DxcCursor_ObjCAtTryStmt =
+      216, // Objective-C's overall \@try-\@catch-\@finally statement.
+  DxcCursor_ObjCAtCatchStmt = 217,   // Objective-C's \@catch statement.
+  DxcCursor_ObjCAtFinallyStmt = 218, // Objective-C's \@finally statement.
+  DxcCursor_ObjCAtThrowStmt = 219,   // Objective-C's \@throw statement.
+  DxcCursor_ObjCAtSynchronizedStmt =
+      220, // Objective-C's \@synchronized statement.
+  DxcCursor_ObjCAutoreleasePoolStmt =
+      221, // Objective-C's autorelease pool statement.
+  DxcCursor_ObjCForCollectionStmt = 222, // Objective-C's collection statement.
+
+  DxcCursor_CXXCatchStmt = 223,    // C++'s catch statement.
+  DxcCursor_CXXTryStmt = 224,      // C++'s try statement.
+  DxcCursor_CXXForRangeStmt = 225, // C++'s for (* : *) statement.
+
+  DxcCursor_SEHTryStmt =
+      226, // Windows Structured Exception Handling's try statement.
+  DxcCursor_SEHExceptStmt =
+      227, // Windows Structured Exception Handling's except statement.
+  DxcCursor_SEHFinallyStmt =
+      228, // Windows Structured Exception Handling's finally statement.
+
+  DxcCursor_MSAsmStmt = 229, // A MS inline assembly statement extension.
+  DxcCursor_NullStmt = 230,  // The null satement ";": C99 6.8.3p3.
+  DxcCursor_DeclStmt = 231,  // Adaptor class for mixing declarations with
+                             // statements and expressions.
+  DxcCursor_OMPParallelDirective = 232,    // OpenMP parallel directive.
+  DxcCursor_OMPSimdDirective = 233,        // OpenMP SIMD directive.
+  DxcCursor_OMPForDirective = 234,         // OpenMP for directive.
+  DxcCursor_OMPSectionsDirective = 235,    // OpenMP sections directive.
+  DxcCursor_OMPSectionDirective = 236,     // OpenMP section directive.
+  DxcCursor_OMPSingleDirective = 237,      // OpenMP single directive.
+  DxcCursor_OMPParallelForDirective = 238, // OpenMP parallel for directive.
+  DxcCursor_OMPParallelSectionsDirective =
+      239,                               // OpenMP parallel sections directive.
+  DxcCursor_OMPTaskDirective = 240,      // OpenMP task directive.
+  DxcCursor_OMPMasterDirective = 241,    // OpenMP master directive.
+  DxcCursor_OMPCriticalDirective = 242,  // OpenMP critical directive.
+  DxcCursor_OMPTaskyieldDirective = 243, // OpenMP taskyield directive.
+  DxcCursor_OMPBarrierDirective = 244,   // OpenMP barrier directive.
+  DxcCursor_OMPTaskwaitDirective = 245,  // OpenMP taskwait directive.
+  DxcCursor_OMPFlushDirective = 246,     // OpenMP flush directive.
+  DxcCursor_SEHLeaveStmt =
+      247, // Windows Structured Exception Handling's leave statement.
+  DxcCursor_OMPOrderedDirective = 248, // OpenMP ordered directive.
+  DxcCursor_OMPAtomicDirective = 249,  // OpenMP atomic directive.
+  DxcCursor_OMPForSimdDirective = 250, // OpenMP for SIMD directive.
+  DxcCursor_OMPParallelForSimdDirective =
+      251,                               // OpenMP parallel for SIMD directive.
+  DxcCursor_OMPTargetDirective = 252,    // OpenMP target directive.
+  DxcCursor_OMPTeamsDirective = 253,     // OpenMP teams directive.
+  DxcCursor_OMPTaskgroupDirective = 254, // OpenMP taskgroup directive.
+  DxcCursor_OMPCancellationPointDirective =
+      255,                            // OpenMP cancellation point directive.
+  DxcCursor_OMPCancelDirective = 256, // OpenMP cancel directive.
+  DxcCursor_LastStmt = DxcCursor_OMPCancelDirective,
+
+  DxcCursor_TranslationUnit =
+      300, // Cursor that represents the translation unit itself.
+
+  /* Attributes */
+  DxcCursor_FirstAttr = 400,
+  /**
+   * \brief An attribute whose specific kind is not exposed via this
+   * interface.
+   */
+  DxcCursor_UnexposedAttr = 400,
+
+  DxcCursor_IBActionAttr = 401,
+  DxcCursor_IBOutletAttr = 402,
+  DxcCursor_IBOutletCollectionAttr = 403,
+  DxcCursor_CXXFinalAttr = 404,
+  DxcCursor_CXXOverrideAttr = 405,
+  DxcCursor_AnnotateAttr = 406,
+  DxcCursor_AsmLabelAttr = 407,
+  DxcCursor_PackedAttr = 408,
+  DxcCursor_PureAttr = 409,
+  DxcCursor_ConstAttr = 410,
+  DxcCursor_NoDuplicateAttr = 411,
+  DxcCursor_CUDAConstantAttr = 412,
+  DxcCursor_CUDADeviceAttr = 413,
+  DxcCursor_CUDAGlobalAttr = 414,
+  DxcCursor_CUDAHostAttr = 415,
+  DxcCursor_CUDASharedAttr = 416,
+  DxcCursor_LastAttr = DxcCursor_CUDASharedAttr,
+
+  /* Preprocessing */
+  DxcCursor_PreprocessingDirective = 500,
+  DxcCursor_MacroDefinition = 501,
+  DxcCursor_MacroExpansion = 502,
+  DxcCursor_MacroInstantiation = DxcCursor_MacroExpansion,
+  DxcCursor_InclusionDirective = 503,
+  DxcCursor_FirstPreprocessing = DxcCursor_PreprocessingDirective,
+  DxcCursor_LastPreprocessing = DxcCursor_InclusionDirective,
+
+  /* Extra Declarations */
+  /**
+   * \brief A module import declaration.
+   */
+  DxcCursor_ModuleImportDecl = 600,
+  DxcCursor_FirstExtraDecl = DxcCursor_ModuleImportDecl,
+  DxcCursor_LastExtraDecl = DxcCursor_ModuleImportDecl
+};
+
+enum DxcCursorKindFlags {
+  DxcCursorKind_None = 0,
+  DxcCursorKind_Declaration = 0x1,
+  DxcCursorKind_Reference = 0x2,
+  DxcCursorKind_Expression = 0x4,
+  DxcCursorKind_Statement = 0x8,
+  DxcCursorKind_Attribute = 0x10,
+  DxcCursorKind_Invalid = 0x20,
+  DxcCursorKind_TranslationUnit = 0x40,
+  DxcCursorKind_Preprocessing = 0x80,
+  DxcCursorKind_Unexposed = 0x100,
+};
+
+enum DxcCodeCompleteFlags {
+  DxcCodeCompleteFlags_None = 0,
+  DxcCodeCompleteFlags_IncludeMacros = 0x1,
+  DxcCodeCompleteFlags_IncludeCodePatterns = 0x2,
+  DxcCodeCompleteFlags_IncludeBriefComments = 0x4,
+};
+
+enum DxcCompletionChunkKind {
+  DxcCompletionChunk_Optional = 0,
+  DxcCompletionChunk_TypedText = 1,
+  DxcCompletionChunk_Text = 2,
+  DxcCompletionChunk_Placeholder = 3,
+  DxcCompletionChunk_Informative = 4,
+  DxcCompletionChunk_CurrentParameter = 5,
+  DxcCompletionChunk_LeftParen = 6,
+  DxcCompletionChunk_RightParen = 7,
+  DxcCompletionChunk_LeftBracket = 8,
+  DxcCompletionChunk_RightBracket = 9,
+  DxcCompletionChunk_LeftBrace = 10,
+  DxcCompletionChunk_RightBrace = 11,
+  DxcCompletionChunk_LeftAngle = 12,
+  DxcCompletionChunk_RightAngle = 13,
+  DxcCompletionChunk_Comma = 14,
+  DxcCompletionChunk_ResultType = 15,
+  DxcCompletionChunk_Colon = 16,
+  DxcCompletionChunk_SemiColon = 17,
+  DxcCompletionChunk_Equal = 18,
+  DxcCompletionChunk_HorizontalSpace = 19,
+  DxcCompletionChunk_VerticalSpace = 20,
+};
+
+struct IDxcCursor;
+struct IDxcDiagnostic;
+struct IDxcFile;
+struct IDxcInclusion;
+struct IDxcIntelliSense;
+struct IDxcIndex;
+struct IDxcSourceLocation;
+struct IDxcSourceRange;
+struct IDxcToken;
+struct IDxcTranslationUnit;
+struct IDxcType;
+struct IDxcUnsavedFile;
+struct IDxcCodeCompleteResults;
+struct IDxcCompletionResult;
+struct IDxcCompletionString;
+
+CROSS_PLATFORM_UUIDOF(IDxcCursor, "1467b985-288d-4d2a-80c1-ef89c42c40bc")
+struct IDxcCursor : public IUnknown {
+  virtual HRESULT STDMETHODCALLTYPE
+  GetExtent(_Outptr_result_nullonfailure_ IDxcSourceRange **pRange) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetLocation(_Outptr_result_nullonfailure_ IDxcSourceLocation **pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE GetKind(_Out_ DxcCursorKind *pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetKindFlags(_Out_ DxcCursorKindFlags *pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetSemanticParent(_Outptr_result_nullonfailure_ IDxcCursor **pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetLexicalParent(_Outptr_result_nullonfailure_ IDxcCursor **pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetCursorType(_Outptr_result_nullonfailure_ IDxcType **pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE GetNumArguments(_Out_ int *pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE GetArgumentAt(
+      int index, _Outptr_result_nullonfailure_ IDxcCursor **pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetReferencedCursor(_Outptr_result_nullonfailure_ IDxcCursor **pResult) = 0;
+  /// <summary>For a cursor that is either a reference to or a declaration of
+  /// some entity, retrieve a cursor that describes the definition of that
+  /// entity.</summary> <remarks>Some entities can be declared multiple times
+  /// within a translation unit, but only one of those declarations can also be
+  /// a definition.</remarks> <returns>A cursor to the definition of this
+  /// entity; nullptr if there is no definition in this translation
+  /// unit.</returns>
+  virtual HRESULT STDMETHODCALLTYPE
+  GetDefinitionCursor(_Outptr_result_nullonfailure_ IDxcCursor **pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  FindReferencesInFile(_In_ IDxcFile *file, unsigned skip, unsigned top,
+                       _Out_ unsigned *pResultLength,
+                       _Outptr_result_buffer_maybenull_(*pResultLength)
+                           IDxcCursor ***pResult) = 0;
+  /// <summary>Gets the name for the entity references by the cursor, e.g. foo
+  /// for an 'int foo' variable.</summary>
+  virtual HRESULT STDMETHODCALLTYPE
+  GetSpelling(_Outptr_result_maybenull_ LPSTR *pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE IsEqualTo(_In_ IDxcCursor *other,
+                                              _Out_ BOOL *pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE IsNull(_Out_ BOOL *pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE IsDefinition(_Out_ BOOL *pResult) = 0;
+  /// <summary>Gets the display name for the cursor, including e.g. parameter
+  /// types for a function.</summary>
+  virtual HRESULT STDMETHODCALLTYPE GetDisplayName(_Out_ BSTR *pResult) = 0;
+  /// <summary>Gets the qualified name for the symbol the cursor refers
+  /// to.</summary>
+  virtual HRESULT STDMETHODCALLTYPE GetQualifiedName(
+      BOOL includeTemplateArgs, _Outptr_result_maybenull_ BSTR *pResult) = 0;
+  /// <summary>Gets a name for the cursor, applying the specified formatting
+  /// flags.</summary>
+  virtual HRESULT STDMETHODCALLTYPE
+  GetFormattedName(DxcCursorFormatting formatting,
+                   _Outptr_result_maybenull_ BSTR *pResult) = 0;
+  /// <summary>Gets children in pResult up to top elements.</summary>
+  virtual HRESULT STDMETHODCALLTYPE
+  GetChildren(unsigned skip, unsigned top, _Out_ unsigned *pResultLength,
+              _Outptr_result_buffer_maybenull_(*pResultLength)
+                  IDxcCursor ***pResult) = 0;
+  /// <summary>Gets the cursor following a location within a compound
+  /// cursor.</summary>
+  virtual HRESULT STDMETHODCALLTYPE
+  GetSnappedChild(_In_ IDxcSourceLocation *location,
+                  _Outptr_result_maybenull_ IDxcCursor **pResult) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcDiagnostic, "4f76b234-3659-4d33-99b0-3b0db994b564")
+struct IDxcDiagnostic : public IUnknown {
+  virtual HRESULT STDMETHODCALLTYPE
+  FormatDiagnostic(DxcDiagnosticDisplayOptions options,
+                   _Outptr_result_maybenull_ LPSTR *pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetSeverity(_Out_ DxcDiagnosticSeverity *pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetLocation(_Outptr_result_nullonfailure_ IDxcSourceLocation **pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetSpelling(_Outptr_result_maybenull_ LPSTR *pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetCategoryText(_Outptr_result_maybenull_ LPSTR *pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE GetNumRanges(_Out_ unsigned *pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetRangeAt(unsigned index,
+             _Outptr_result_nullonfailure_ IDxcSourceRange **pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE GetNumFixIts(_Out_ unsigned *pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetFixItAt(unsigned index,
+             _Outptr_result_nullonfailure_ IDxcSourceRange **pReplacementRange,
+             _Outptr_result_maybenull_ LPSTR *pText) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcFile, "bb2fca9e-1478-47ba-b08c-2c502ada4895")
+struct IDxcFile : public IUnknown {
+  /// <summary>Gets the file name for this file.</summary>
+  virtual HRESULT STDMETHODCALLTYPE
+  GetName(_Outptr_result_maybenull_ LPSTR *pResult) = 0;
+  /// <summary>Checks whether this file is equal to the other specified
+  /// file.</summary>
+  virtual HRESULT STDMETHODCALLTYPE IsEqualTo(_In_ IDxcFile *other,
+                                              _Out_ BOOL *pResult) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcInclusion, "0c364d65-df44-4412-888e-4e552fc5e3d6")
+struct IDxcInclusion : public IUnknown {
+  virtual HRESULT STDMETHODCALLTYPE
+  GetIncludedFile(_Outptr_result_nullonfailure_ IDxcFile **pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE GetStackLength(_Out_ unsigned *pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetStackItem(unsigned index,
+               _Outptr_result_nullonfailure_ IDxcSourceLocation **pResult) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcIntelliSense, "b1f99513-46d6-4112-8169-dd0d6053f17d")
+struct IDxcIntelliSense : public IUnknown {
+  virtual HRESULT STDMETHODCALLTYPE
+  CreateIndex(_Outptr_result_nullonfailure_ IDxcIndex **index) = 0;
+  virtual HRESULT STDMETHODCALLTYPE GetNullLocation(
+      _Outptr_result_nullonfailure_ IDxcSourceLocation **location) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetNullRange(_Outptr_result_nullonfailure_ IDxcSourceRange **location) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetRange(_In_ IDxcSourceLocation *start, _In_ IDxcSourceLocation *end,
+           _Outptr_result_nullonfailure_ IDxcSourceRange **location) = 0;
+  virtual HRESULT STDMETHODCALLTYPE GetDefaultDiagnosticDisplayOptions(
+      _Out_ DxcDiagnosticDisplayOptions *pValue) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetDefaultEditingTUOptions(_Out_ DxcTranslationUnitFlags *pValue) = 0;
+  virtual HRESULT STDMETHODCALLTYPE CreateUnsavedFile(
+      _In_ LPCSTR fileName, _In_ LPCSTR contents, unsigned contentLength,
+      _Outptr_result_nullonfailure_ IDxcUnsavedFile **pResult) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcIndex, "937824a0-7f5a-4815-9ba7-7fc0424f4173")
+struct IDxcIndex : public IUnknown {
+  virtual HRESULT STDMETHODCALLTYPE
+  SetGlobalOptions(DxcGlobalOptions options) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetGlobalOptions(_Out_ DxcGlobalOptions *options) = 0;
+  virtual HRESULT STDMETHODCALLTYPE ParseTranslationUnit(
+      _In_z_ const char *source_filename,
+      _In_count_(num_command_line_args) const char *const *command_line_args,
+      int num_command_line_args,
+      _In_count_(num_unsaved_files) IDxcUnsavedFile **unsaved_files,
+      unsigned num_unsaved_files, DxcTranslationUnitFlags options,
+      _Out_ IDxcTranslationUnit **pTranslationUnit) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcSourceLocation,
+                      "8e7ddf1c-d7d3-4d69-b286-85fccba1e0cf")
+struct IDxcSourceLocation : public IUnknown {
+  virtual HRESULT STDMETHODCALLTYPE IsEqualTo(_In_ IDxcSourceLocation *other,
+                                              _Out_ BOOL *pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE GetSpellingLocation(
+      _Outptr_opt_ IDxcFile **pFile, _Out_opt_ unsigned *pLine,
+      _Out_opt_ unsigned *pCol, _Out_opt_ unsigned *pOffset) = 0;
+  virtual HRESULT STDMETHODCALLTYPE IsNull(_Out_ BOOL *pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetPresumedLocation(_Outptr_opt_ LPSTR *pFilename, _Out_opt_ unsigned *pLine,
+                      _Out_opt_ unsigned *pCol) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcSourceRange, "f1359b36-a53f-4e81-b514-b6b84122a13f")
+struct IDxcSourceRange : public IUnknown {
+  virtual HRESULT STDMETHODCALLTYPE IsNull(_Out_ BOOL *pValue) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetStart(_Out_ IDxcSourceLocation **pValue) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetEnd(_Out_ IDxcSourceLocation **pValue) = 0;
+  virtual HRESULT STDMETHODCALLTYPE GetOffsets(_Out_ unsigned *startOffset,
+                                               _Out_ unsigned *endOffset) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcToken, "7f90b9ff-a275-4932-97d8-3cfd234482a2")
+struct IDxcToken : public IUnknown {
+  virtual HRESULT STDMETHODCALLTYPE GetKind(_Out_ DxcTokenKind *pValue) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetLocation(_Out_ IDxcSourceLocation **pValue) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetExtent(_Out_ IDxcSourceRange **pValue) = 0;
+  virtual HRESULT STDMETHODCALLTYPE GetSpelling(_Out_ LPSTR *pValue) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcTranslationUnit,
+                      "9677dee0-c0e5-46a1-8b40-3db3168be63d")
+struct IDxcTranslationUnit : public IUnknown {
+  virtual HRESULT STDMETHODCALLTYPE GetCursor(_Out_ IDxcCursor **pCursor) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  Tokenize(_In_ IDxcSourceRange *range,
+           _Outptr_result_buffer_maybenull_(*pTokenCount) IDxcToken ***pTokens,
+           _Out_ unsigned *pTokenCount) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetLocation(_In_ IDxcFile *file, unsigned line, unsigned column,
+              _Outptr_result_nullonfailure_ IDxcSourceLocation **pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetNumDiagnostics(_Out_ unsigned *pValue) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetDiagnostic(unsigned index,
+                _Outptr_result_nullonfailure_ IDxcDiagnostic **pValue) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetFile(_In_ const char *name,
+          _Outptr_result_nullonfailure_ IDxcFile **pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetFileName(_Outptr_result_maybenull_ LPSTR *pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE Reparse(_In_count_(num_unsaved_files)
+                                                IDxcUnsavedFile **unsaved_files,
+                                            unsigned num_unsaved_files) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetCursorForLocation(_In_ IDxcSourceLocation *location,
+                       _Outptr_result_nullonfailure_ IDxcCursor **pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE GetLocationForOffset(
+      _In_ IDxcFile *file, unsigned offset,
+      _Outptr_result_nullonfailure_ IDxcSourceLocation **pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE GetSkippedRanges(
+      _In_ IDxcFile *file, _Out_ unsigned *pResultCount,
+      _Outptr_result_buffer_(*pResultCount) IDxcSourceRange ***pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetDiagnosticDetails(unsigned index, DxcDiagnosticDisplayOptions options,
+                       _Out_ unsigned *errorCode, _Out_ unsigned *errorLine,
+                       _Out_ unsigned *errorColumn, _Out_ BSTR *errorFile,
+                       _Out_ unsigned *errorOffset, _Out_ unsigned *errorLength,
+                       _Out_ BSTR *errorMessage) = 0;
+  virtual HRESULT STDMETHODCALLTYPE GetInclusionList(
+      _Out_ unsigned *pResultCount,
+      _Outptr_result_buffer_(*pResultCount) IDxcInclusion ***pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE CodeCompleteAt(
+      _In_ const char *fileName, unsigned line, unsigned column,
+      _In_ IDxcUnsavedFile **pUnsavedFiles, unsigned numUnsavedFiles,
+      _In_ DxcCodeCompleteFlags options,
+      _Outptr_result_nullonfailure_ IDxcCodeCompleteResults **pResult) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcType, "2ec912fd-b144-4a15-ad0d-1c5439c81e46")
+struct IDxcType : public IUnknown {
+  virtual HRESULT STDMETHODCALLTYPE
+  GetSpelling(_Outptr_result_z_ LPSTR *pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE IsEqualTo(_In_ IDxcType *other,
+                                              _Out_ BOOL *pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE GetKind(_Out_ DxcTypeKind *pResult) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcUnsavedFile, "8ec00f98-07d0-4e60-9d7c-5a50b5b0017f")
+struct IDxcUnsavedFile : public IUnknown {
+  virtual HRESULT STDMETHODCALLTYPE
+  GetFileName(_Outptr_result_z_ LPSTR *pFileName) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetContents(_Outptr_result_z_ LPSTR *pContents) = 0;
+  virtual HRESULT STDMETHODCALLTYPE GetLength(_Out_ unsigned *pLength) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcCodeCompleteResults,
+                      "1E06466A-FD8B-45F3-A78F-8A3F76EBB552")
+struct IDxcCodeCompleteResults : public IUnknown {
+  virtual HRESULT STDMETHODCALLTYPE GetNumResults(_Out_ unsigned *pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetResultAt(unsigned index,
+              _Outptr_result_nullonfailure_ IDxcCompletionResult **pResult) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcCompletionResult,
+                      "943C0588-22D0-4784-86FC-701F802AC2B6")
+struct IDxcCompletionResult : public IUnknown {
+  virtual HRESULT STDMETHODCALLTYPE
+  GetCursorKind(_Out_ DxcCursorKind *pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE GetCompletionString(
+      _Outptr_result_nullonfailure_ IDxcCompletionString **pResult) = 0;
+};
+
+CROSS_PLATFORM_UUIDOF(IDxcCompletionString,
+                      "06B51E0F-A605-4C69-A110-CD6E14B58EEC")
+struct IDxcCompletionString : public IUnknown {
+  virtual HRESULT STDMETHODCALLTYPE
+  GetNumCompletionChunks(_Out_ unsigned *pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE GetCompletionChunkKind(
+      unsigned chunkNumber, _Out_ DxcCompletionChunkKind *pResult) = 0;
+  virtual HRESULT STDMETHODCALLTYPE
+  GetCompletionChunkText(unsigned chunkNumber, _Out_ LPSTR *pResult) = 0;
+};
+
+// Fun fact: 'extern' is required because const is by default static in C++, so
+// CLSID_DxcIntelliSense is not visible externally (this is OK in C, since const
+// is not by default static in C)
+
+#ifdef _MSC_VER
+#define CLSID_SCOPE __declspec(selectany) extern
+#else
+#define CLSID_SCOPE
+#endif
+
+CLSID_SCOPE const CLSID
+    CLSID_DxcIntelliSense = {/* 3047833c-d1c0-4b8e-9d40-102878605985 */
+                             0x3047833c,
+                             0xd1c0,
+                             0x4b8e,
+                             {0x9d, 0x40, 0x10, 0x28, 0x78, 0x60, 0x59, 0x85}};
+
+#endif

BIN
ThirdParty/Dxc/dxcompiler.lib


+ 20 - 1
Tools/Shader/ShaderProgramCompilerMain.cpp

@@ -14,6 +14,8 @@ Options:
 -j <thread count>    : Number of threads. Defaults to system's max
 -j <thread count>    : Number of threads. Defaults to system's max
 -I <include path>    : The path of the #include files
 -I <include path>    : The path of the #include files
 -D<define_name:val>  : Extra defines to pass to the compiler
 -D<define_name:val>  : Extra defines to pass to the compiler
+-spirv               : Compile SPIR-V
+-dxil                : Compile DXIL
 )";
 )";
 
 
 class CmdLineArgs
 class CmdLineArgs
@@ -25,6 +27,8 @@ public:
 	U32 m_threadCount = getCpuCoresCount();
 	U32 m_threadCount = getCpuCoresCount();
 	DynamicArray<String> m_defineNames;
 	DynamicArray<String> m_defineNames;
 	DynamicArray<ShaderCompilerDefine> m_defines;
 	DynamicArray<ShaderCompilerDefine> m_defines;
+	Bool m_spirv = false;
+	Bool m_dxil = false;
 };
 };
 
 
 static Error parseCommandLineArgs(int argc, char** argv, CmdLineArgs& info)
 static Error parseCommandLineArgs(int argc, char** argv, CmdLineArgs& info)
@@ -118,6 +122,14 @@ static Error parseCommandLineArgs(int argc, char** argv, CmdLineArgs& info)
 
 
 			info.m_defines.emplaceBack(ShaderCompilerDefine{info.m_defineNames.getBack().toCString(), val});
 			info.m_defines.emplaceBack(ShaderCompilerDefine{info.m_defineNames.getBack().toCString(), val});
 		}
 		}
+		else if(strcmp(argv[i], "-spirv") == 0)
+		{
+			info.m_spirv = true;
+		}
+		else if(strcmp(argv[i], "-dxil") == 0)
+		{
+			info.m_dxil = true;
+		}
 		else
 		else
 		{
 		{
 			return Error::kUserData;
 			return Error::kUserData;
@@ -198,7 +210,8 @@ static Error work(const CmdLineArgs& info)
 
 
 	// Compile
 	// Compile
 	ShaderProgramBinary* binary = nullptr;
 	ShaderProgramBinary* binary = nullptr;
-	ANKI_CHECK(compileShaderProgram(info.m_inputFname, fsystem, nullptr, (info.m_threadCount) ? &taskManager : nullptr, info.m_defines, binary));
+	ANKI_CHECK(compileShaderProgram(info.m_inputFname, info.m_spirv, fsystem, nullptr, (info.m_threadCount) ? &taskManager : nullptr, info.m_defines,
+									binary));
 
 
 	class Dummy
 	class Dummy
 	{
 	{
@@ -246,6 +259,12 @@ int myMain(int argc, char** argv)
 		return 1;
 		return 1;
 	}
 	}
 
 
+	if(info.m_spirv == info.m_dxil)
+	{
+		ANKI_LOGE(kUsage, argv[0]);
+		return 1;
+	}
+
 	if(info.m_outFname.isEmpty())
 	if(info.m_outFname.isEmpty())
 	{
 	{
 		getFilepathFilename(info.m_inputFname, info.m_outFname);
 		getFilepathFilename(info.m_inputFname, info.m_outFname);