فهرست منبع

[linux] Enable Reflection on *nix platforms (#4810)


Needed for the impending enabling on *nix platforms

* Remove circular dependency from RDAT Dumper

A file included by the source that implemented various ToString
converters of reflection data to strings itself depended on those
declarations, which it only found because of the unique way MSVC
processes templates. By moving the definitions and declarations into
their own header and source files, everyone gets what they need
without ouroborosing.

* Create DirectX-Headers submodule

Creates the DirectX-Headers submodule and adds the needed defines to
allow them to be used. As yet makes no use of these headers

* Improve src dir finding error

The check for the file stream that is meant to represent the filechecked
source file wasn't sufficient to detect a non-existent file. By expanding
the error check, it can produce a helpful message.

Also initialize the failure code so it isn't random

* Enable reflection functionality and testing

This flips the switch, removing or repositioning many ifdefs and
including previously excluded files in the build.

* Actually add the DirectX-Headers submodule

* fix *nix build breaks caused while fixing win breaks :P

* Respond to feedback -- some of it anyway ;)

* simplify cmake file to exclude unneeded src dir

* fix cmake (again)

* Fix GCC template specialization finickiness

What compiler is overly permissive now huh? huh? (or just quick to adopt
new language features?)

* LPCBYTE isn't a thing

Loathe as I am to push one more commit onto this. I don't want to
propagate a misconception. I meant to remove this earlier and caught it
from one final self-review >:(
Greg Roth 2 سال پیش
والد
کامیت
14a55b7738

+ 3 - 0
.gitmodules

@@ -13,3 +13,6 @@
 [submodule "external/effcee"]
 	path = external/effcee
 	url = https://github.com/google/effcee
+[submodule "external/DirectX-Headers"]
+	path = external/DirectX-Headers
+	url = https://github.com/microsoft/DirectX-Headers.git

+ 6 - 4
CMakeLists.txt

@@ -662,6 +662,12 @@ add_subdirectory(include/dxc)
 # This over-specifies the dependency graph, but since generating these doesn't
 # really depend on anything else in the build it is safe.
 list(APPEND LLVM_COMMON_DEPENDS HCTGen) 
+
+if(EXISTS "${LLVM_MAIN_SRC_DIR}/external")
+  add_subdirectory(external) # SPIRV change
+endif()
+include_directories(AFTER ${DIRECTX_HEADER_INCLUDE_DIR}/directx ${DIRECTX_HEADER_INCLUDE_DIR}/wsl/stubs)
+
 # HLSL - Change End
 
 add_subdirectory(lib)
@@ -702,10 +708,6 @@ if(WITH_POLLY)
   endif()
 endif(WITH_POLLY)
 
-if(EXISTS "${LLVM_MAIN_SRC_DIR}/external")
-  add_subdirectory(external) # SPIRV change
-endif()
-
 if( LLVM_INCLUDE_TOOLS )
   add_subdirectory(tools)
 endif()

+ 9 - 0
external/CMakeLists.txt

@@ -7,6 +7,15 @@ if (NOT HLSL_ENABLE_DEBUG_ITERATORS)
   add_definitions(/D_ITERATOR_DEBUG_LEVEL=0)
 endif (NOT HLSL_ENABLE_DEBUG_ITERATORS)
 
+# Need DirectX-Headers module if not on windows
+if (NOT WIN32)
+  if (IS_DIRECTORY "${DXC_EXTERNAL_ROOT_DIR}/DirectX-Headers")
+    set(DIRECTX_HEADER_INCLUDE_DIR ${DXC_EXTERNAL_ROOT_DIR}/DirectX-Headers/include PARENT_SCOPE)
+  else()
+    message(FATAL_ERROR "DirectX-Headers was not found - required for reflection support on *nix see https://github.com/microsoft/DirectX-Headers")
+  endif()
+endif (NOT WIN32)
+
 # Enabling SPIR-V codegen requires SPIRV-Headers for spirv.hpp and
 # SPIRV-Tools for SPIR-V disassembling functionality.
 if (${ENABLE_SPIRV_CODEGEN})

+ 1 - 0
external/DirectX-Headers

@@ -0,0 +1 @@
+Subproject commit 980971e835876dc0cde415e8f9bc646e64667bf7

+ 25 - 0
include/dxc/Support/D3DReflection.h

@@ -0,0 +1,25 @@
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// DxReflection.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 the needed headers and defines for D3D reflection.               //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#pragma once
+
+#ifndef _WIN32
+// need to disable this as it is voilated by this header
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
+// Need to instruct non-windows compilers on what an interface is
+#define interface struct
+#include "d3d12shader.h"
+#undef interface
+#pragma GCC diagnostic pop
+#else
+#include <d3d12shader.h>
+#endif

+ 24 - 3
include/dxc/Support/WinAdapter.h

@@ -33,6 +33,8 @@
 #include <vector>
 #endif // __cplusplus
 
+#define COM_NO_WINDOWS_H // needed to inform d3d headers that this isn't windows
+
 //===----------------------------------------------------------------------===//
 //
 //                             Begin: Macro Definitions
@@ -64,10 +66,12 @@
 #endif // __EMULATE_UUID
 
 #define STDMETHODCALLTYPE
-#define STDAPI extern "C" HRESULT STDAPICALLTYPE
-#define STDAPI_(type) extern "C" type STDAPICALLTYPE
-#define STDMETHODIMP HRESULT STDMETHODCALLTYPE
 #define STDMETHODIMP_(type) type STDMETHODCALLTYPE
+#define STDMETHODIMP STDMETHODIMP_(HRESULT)
+#define STDMETHOD_(type,name) virtual STDMETHODIMP_(type) name
+#define STDMETHOD(name) STDMETHOD_(HRESULT, name)
+#define EXTERN_C extern "C"
+
 
 #define UNREFERENCED_PARAMETER(P) (void)(P)
 
@@ -325,6 +329,9 @@
 #define _Null_
 #define _Notnull_
 #define _Maybenull_
+#define THIS_
+#define THIS
+#define PURE = 0
 
 #define _Outptr_result_bytebuffer_(size)
 
@@ -364,6 +371,7 @@ typedef unsigned int UINT;
 typedef unsigned long ULONG;
 typedef long long LONGLONG;
 typedef long long LONG_PTR;
+typedef unsigned long long ULONG_PTR;
 typedef unsigned long long ULONGLONG;
 
 typedef uint16_t WORD;
@@ -403,6 +411,7 @@ typedef signed int HRESULT;
 //===--------------------- Handle Types -----------------------------------===//
 
 typedef void *HANDLE;
+typedef void *RPC_IF_HANDLE;
 
 #define DECLARE_HANDLE(name)                                                   \
   struct name##__ {                                                            \
@@ -610,6 +619,13 @@ template <typename T> inline void **IID_PPV_ARGS_Helper(T **pp) {
 
 #endif // __EMULATE_UUID
 
+// Needed for d3d headers, but fail to create actual interfaces
+#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) const GUID name = { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }
+#define DECLSPEC_UUID(x)
+#define MIDL_INTERFACE(x) struct DECLSPEC_UUID(x)
+#define DECLARE_INTERFACE(iface)                struct iface
+#define DECLARE_INTERFACE_(iface, parent)       DECLARE_INTERFACE(iface) : parent
+
 //===--------------------- COM Interfaces ---------------------------------===//
 
 CROSS_PLATFORM_UUIDOF(IUnknown, "00000000-0000-0000-C000-000000000046")
@@ -666,6 +682,11 @@ struct IStream : public ISequentialStream {
   virtual HRESULT Clone(IStream **ppstm) = 0;
 };
 
+// These don't need stub implementations as they come from the DirectX Headers
+// They still need the __uuidof() though
+CROSS_PLATFORM_UUIDOF(ID3D12LibraryReflection, "8E349D19-54DB-4A56-9DC9-119D87BDB804")
+CROSS_PLATFORM_UUIDOF(ID3D12ShaderReflection, "5A58797D-A72C-478D-8BA2-EFC6B0EFE88E")
+
 //===--------------------- COM Pointer Types ------------------------------===//
 
 class CAllocator {

+ 0 - 21
include/dxc/Test/D3DReflectionDumper.h

@@ -14,31 +14,10 @@
 #include "dxc/Support/Global.h"
 #include "DumpContext.h"
 #include "dxc/Support/WinIncludes.h"
-#include <d3d12shader.h>
 
 namespace hlsl {
 namespace dump {
 
-LPCSTR ToString(D3D_CBUFFER_TYPE CBType);
-LPCSTR ToString(D3D_SHADER_INPUT_TYPE Type);
-LPCSTR ToString(D3D_RESOURCE_RETURN_TYPE ReturnType);
-LPCSTR ToString(D3D_SRV_DIMENSION Dimension);
-LPCSTR ToString(D3D_PRIMITIVE_TOPOLOGY GSOutputTopology);
-LPCSTR ToString(D3D_PRIMITIVE InputPrimitive);
-LPCSTR ToString(D3D_TESSELLATOR_OUTPUT_PRIMITIVE HSOutputPrimitive);
-LPCSTR ToString(D3D_TESSELLATOR_PARTITIONING HSPartitioning);
-LPCSTR ToString(D3D_TESSELLATOR_DOMAIN TessellatorDomain);
-LPCSTR ToString(D3D_SHADER_VARIABLE_CLASS Class);
-LPCSTR ToString(D3D_SHADER_VARIABLE_TYPE Type);
-LPCSTR ToString(D3D_SHADER_VARIABLE_FLAGS Flag);
-LPCSTR ToString(D3D_SHADER_INPUT_FLAGS Flag);
-LPCSTR ToString(D3D_SHADER_CBUFFER_FLAGS Flag);
-LPCSTR ToString(D3D_PARAMETER_FLAGS Flag);
-LPCSTR ToString(D3D_NAME Name);
-LPCSTR ToString(D3D_REGISTER_COMPONENT_TYPE CompTy);
-LPCSTR ToString(D3D_MIN_PRECISION MinPrec);
-LPCSTR CompMaskToString(unsigned CompMask);
-
 class D3DReflectionDumper : public DumpContext {
 private:
   bool m_bCheckByName = false;

+ 48 - 0
include/dxc/Test/D3DReflectionStrings.h

@@ -0,0 +1,48 @@
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// D3DReflectionStrings.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.                                     //
+//                                                                           //
+// Used to convert reflection data types into strings.                       //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#pragma once
+
+#include "dxc/Support/D3DReflection.h"
+#include "dxc/DxilContainer/DxilRuntimeReflection.h"
+
+namespace hlsl {
+using namespace RDAT;
+namespace dump {
+
+// ToString functions for D3D types
+LPCSTR ToString(D3D_CBUFFER_TYPE CBType);
+LPCSTR ToString(D3D_SHADER_INPUT_TYPE Type);
+LPCSTR ToString(D3D_RESOURCE_RETURN_TYPE ReturnType);
+LPCSTR ToString(D3D_SRV_DIMENSION Dimension);
+LPCSTR ToString(D3D_PRIMITIVE_TOPOLOGY GSOutputTopology);
+LPCSTR ToString(D3D_PRIMITIVE InputPrimitive);
+LPCSTR ToString(D3D_TESSELLATOR_OUTPUT_PRIMITIVE HSOutputPrimitive);
+LPCSTR ToString(D3D_TESSELLATOR_PARTITIONING HSPartitioning);
+LPCSTR ToString(D3D_TESSELLATOR_DOMAIN TessellatorDomain);
+LPCSTR ToString(D3D_SHADER_VARIABLE_CLASS Class);
+LPCSTR ToString(D3D_SHADER_VARIABLE_TYPE Type);
+LPCSTR ToString(D3D_SHADER_VARIABLE_FLAGS Flag);
+LPCSTR ToString(D3D_SHADER_INPUT_FLAGS Flag);
+LPCSTR ToString(D3D_SHADER_CBUFFER_FLAGS Flag);
+LPCSTR ToString(D3D_PARAMETER_FLAGS Flag);
+LPCSTR ToString(D3D_NAME Name);
+LPCSTR ToString(D3D_REGISTER_COMPONENT_TYPE CompTy);
+LPCSTR ToString(D3D_MIN_PRECISION MinPrec);
+LPCSTR CompMaskToString(unsigned CompMask);
+
+// These macros declare the ToString functions for DXC types
+#define DEF_RDAT_ENUMS DEF_RDAT_DUMP_DECL
+#define DEF_DXIL_ENUMS DEF_RDAT_DUMP_DECL
+#include "dxc/DxilContainer/RDAT_Macros.inl"
+
+} // namespace dump
+} // namespace hlsl

+ 7 - 5
include/dxc/Test/DumpContext.h

@@ -12,6 +12,7 @@
 #pragma once
 
 #include "dxc/Support/Global.h"
+#include "dxc/Test/D3DReflectionStrings.h"
 #include <string>
 #include <ostream>
 #include <sstream>
@@ -19,6 +20,7 @@
 #include <unordered_set>
 
 namespace hlsl {
+using namespace RDAT;
 namespace dump {
 
 template<typename _T>
@@ -45,7 +47,6 @@ class DumpContext {
 private:
   std::ostream &m_out;
   unsigned m_indent = 0;
-  bool m_bCheckByName = false;
   std::unordered_set<size_t> m_visited;
 
   std::ostream &DoIndent() {
@@ -72,10 +73,6 @@ public:
   std::ostream &Write(std::ostream &out, _T t) {
     return out << t;
   }
-  template<>
-  std::ostream &Write<uint8_t>(std::ostream &out, uint8_t t) {
-    return out << (unsigned)t;
-  }
   template<typename _T, typename... Args>
   std::ostream &Write(std::ostream &out, _T t, Args... args) {
     return Write(Write(out, t), args...);
@@ -121,6 +118,11 @@ public:
   void VisitReset() { m_visited.clear(); }
 };
 
+template<>
+inline std::ostream &DumpContext::Write<uint8_t>(std::ostream &out, uint8_t t) {
+  return out << (unsigned)t;
+}
+
 // Copied from llvm/ADT/StringExtras.h
 inline char hexdigit(unsigned X, bool LowerCase = false) {
   const char HexChar = LowerCase ? 'a' : 'A';

+ 1 - 1
include/dxc/Test/DxcTestUtils.h

@@ -145,7 +145,7 @@ void ParseCommandPartsFromFile(LPCWSTR fileName, std::vector<FileRunCommandPart>
 class FileRunTestResult {
 public:
   std::string ErrorMessage;
-  int RunResult;
+  int RunResult = -1;
   static FileRunTestResult RunHashTestFromFileCommands(LPCWSTR fileName);
   static FileRunTestResult RunFromFileCommands(LPCWSTR fileName,
                                                PluginToolsPaths *pPluginToolsPaths = nullptr,

+ 1 - 1
include/dxc/Test/HlslTestUtils.h

@@ -249,7 +249,7 @@ inline std::vector<std::string> GetRunLines(const LPCWSTR name) {
 #else
   std::ifstream infile((CW2A(path.c_str())));
 #endif
-  if (infile.bad()) {
+  if (infile.fail() || infile.bad()) {
     std::wstring errMsg(L"Unable to read file ");
     errMsg += path;
     WEX::Logging::Log::Error(errMsg.c_str());

+ 0 - 6
include/dxc/Test/RDATDumper.h

@@ -13,7 +13,6 @@
 
 #include "DumpContext.h"
 #include "dxc/Support/WinIncludes.h"
-#include "dxc/DxilContainer/DxilRuntimeReflection.h"
 
 namespace hlsl {
 using namespace RDAT;
@@ -97,10 +96,5 @@ template<typename _T>
 void DumpValueArray(DumpContext &d, const char *memberName,
                     const char *typeName, const void *valueArray,
                     unsigned arraySize);
-
-#define DEF_RDAT_ENUMS DEF_RDAT_DUMP_DECL
-#define DEF_DXIL_ENUMS DEF_RDAT_DUMP_DECL
-#include "dxc/DxilContainer/RDAT_Macros.inl"
-
 } // namespace dump
 } // namespace hlsl

+ 1 - 1
include/dxc/Test/WEXAdapter.h

@@ -73,7 +73,7 @@
 #define VERIFY_WIN32_BOOL_SUCCEEDED_2(expr, msg) EXPECT_TRUE(expr) << msg
 #define VERIFY_WIN32_BOOL_SUCCEEDED(...) MACRO_N(VERIFY_WIN32_BOOL_SUCCEEDED_, __VA_ARGS__)
 
-#define VERIFY_FAIL ADD_FAILURE
+#define VERIFY_FAIL(...) ADD_FAILURE() << __VA_ARGS__ ""
 
 #define TEST_CLASS_SETUP(method)                                               \
   bool method();                                                               \

+ 42 - 76
lib/HLSL/DxilContainerReflection.cpp

@@ -36,9 +36,14 @@
 
 #include "dxc/dxcapi.h"
 
-#ifdef LLVM_ON_WIN32
-#include "d3d12shader.h" // for compatibility
+#include "dxc/Support/D3DReflection.h"
+#ifdef _WIN32
 #include "d3d11shader.h" // for compatibility
+#else
+// Dummy D3D11 struct to allow nix-dead code to compile
+struct D3D11_SHADER_INPUT_BIND_DESC {int dummy;};
+#include "dxc/Support/WinAdapter.h"
+#endif
 
 #include "dxc/DxilContainer/DxilRuntimeReflection.h"
 
@@ -70,7 +75,7 @@ private:
 public:
   DXC_MICROCOM_TM_ADDREF_RELEASE_IMPL()
   DXC_MICROCOM_TM_CTOR(DxilContainerReflection)
-  HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject) {
+  HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject) override {
     return DoBasicQueryInterface<IDxcContainerReflection>(this, iid, ppvObject);
   }
 
@@ -165,7 +170,7 @@ public:
   }
   DXC_MICROCOM_TM_ADDREF_RELEASE_IMPL()
   DXC_MICROCOM_TM_CTOR(DxilShaderReflection)
-  HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject) {
+  HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject) override {
     HRESULT hr = DoBasicQueryInterface<ID3D12ShaderReflection>(this, iid, ppvObject);
     if (hr == E_NOINTERFACE) {
       // ID3D11ShaderReflection is identical to ID3D12ShaderReflection, except
@@ -183,43 +188,43 @@ public:
   HRESULT Load(const DxilProgramHeader *pProgramHeader, const DxilPartHeader *pRDATPart);
 
   // ID3D12ShaderReflection
-  STDMETHODIMP GetDesc(THIS_ _Out_ D3D12_SHADER_DESC *pDesc);
+  STDMETHODIMP GetDesc(THIS_ _Out_ D3D12_SHADER_DESC *pDesc) override;
 
-  STDMETHODIMP_(ID3D12ShaderReflectionConstantBuffer*) GetConstantBufferByIndex(THIS_ _In_ UINT Index);
-  STDMETHODIMP_(ID3D12ShaderReflectionConstantBuffer*) GetConstantBufferByName(THIS_ _In_ LPCSTR Name);
+  STDMETHODIMP_(ID3D12ShaderReflectionConstantBuffer*) GetConstantBufferByIndex(THIS_ _In_ UINT Index) override;
+  STDMETHODIMP_(ID3D12ShaderReflectionConstantBuffer*) GetConstantBufferByName(THIS_ _In_ LPCSTR Name) override;
 
   STDMETHODIMP GetResourceBindingDesc(THIS_ _In_ UINT ResourceIndex,
-    _Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc);
+    _Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc) override;
 
   STDMETHODIMP GetInputParameterDesc(THIS_ _In_ UINT ParameterIndex,
-    _Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc);
+    _Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc) override;
   STDMETHODIMP GetOutputParameterDesc(THIS_ _In_ UINT ParameterIndex,
-    _Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc);
+    _Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc) override;
   STDMETHODIMP GetPatchConstantParameterDesc(THIS_ _In_ UINT ParameterIndex,
-    _Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc);
+    _Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc) override;
 
-  STDMETHODIMP_(ID3D12ShaderReflectionVariable*) GetVariableByName(THIS_ _In_ LPCSTR Name);
+  STDMETHODIMP_(ID3D12ShaderReflectionVariable*) GetVariableByName(THIS_ _In_ LPCSTR Name) override;
 
   STDMETHODIMP GetResourceBindingDescByName(THIS_ _In_ LPCSTR Name,
-    _Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc);
+    _Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc) override;
 
-  STDMETHODIMP_(UINT) GetMovInstructionCount(THIS);
-  STDMETHODIMP_(UINT) GetMovcInstructionCount(THIS);
-  STDMETHODIMP_(UINT) GetConversionInstructionCount(THIS);
-  STDMETHODIMP_(UINT) GetBitwiseInstructionCount(THIS);
+  STDMETHODIMP_(UINT) GetMovInstructionCount(THIS) override;
+  STDMETHODIMP_(UINT) GetMovcInstructionCount(THIS) override;
+  STDMETHODIMP_(UINT) GetConversionInstructionCount(THIS) override;
+  STDMETHODIMP_(UINT) GetBitwiseInstructionCount(THIS) override;
 
-  STDMETHODIMP_(D3D_PRIMITIVE) GetGSInputPrimitive(THIS);
-  STDMETHODIMP_(BOOL) IsSampleFrequencyShader(THIS);
+  STDMETHODIMP_(D3D_PRIMITIVE) GetGSInputPrimitive(THIS) override;
+  STDMETHODIMP_(BOOL) IsSampleFrequencyShader(THIS) override;
 
-  STDMETHODIMP_(UINT) GetNumInterfaceSlots(THIS);
-  STDMETHODIMP GetMinFeatureLevel(THIS_ _Out_ enum D3D_FEATURE_LEVEL* pLevel);
+  STDMETHODIMP_(UINT) GetNumInterfaceSlots(THIS) override;
+  STDMETHODIMP GetMinFeatureLevel(THIS_ _Out_ enum D3D_FEATURE_LEVEL* pLevel) override;
 
   STDMETHODIMP_(UINT) GetThreadGroupSize(THIS_
     _Out_opt_ UINT* pSizeX,
     _Out_opt_ UINT* pSizeY,
-    _Out_opt_ UINT* pSizeZ);
+    _Out_opt_ UINT* pSizeZ) override;
 
-  STDMETHODIMP_(UINT64) GetRequiresFlags(THIS);
+  STDMETHODIMP_(UINT64) GetRequiresFlags(THIS) override;
 };
 
 class CFunctionReflection;
@@ -241,16 +246,16 @@ private:
 public:
   DXC_MICROCOM_TM_ADDREF_RELEASE_IMPL()
   DXC_MICROCOM_TM_CTOR(DxilLibraryReflection)
-  HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject) {
+  HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject) override {
     return DoBasicQueryInterface<ID3D12LibraryReflection>(this, iid, ppvObject);
   }
 
   HRESULT Load(const DxilProgramHeader *pProgramHeader, const DxilPartHeader *pRDATPart);
 
   // ID3D12LibraryReflection
-  STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_LIBRARY_DESC * pDesc);
+  STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_LIBRARY_DESC * pDesc) override;
 
-  STDMETHOD_(ID3D12FunctionReflection *, GetFunctionByIndex)(THIS_ _In_ INT FunctionIndex);
+  STDMETHOD_(ID3D12FunctionReflection *, GetFunctionByIndex)(THIS_ _In_ INT FunctionIndex) override;
 };
 
 namespace hlsl {
@@ -453,7 +458,7 @@ class CShaderReflectionVariable;
 class CShaderReflectionConstantBuffer;
 class CShaderReflection;
 struct D3D11_INTERNALSHADER_RESOURCE_DEF;
-class CShaderReflectionType : public ID3D12ShaderReflectionType
+class CShaderReflectionType final : public ID3D12ShaderReflectionType
 {
   friend class CShaderReflectionConstantBuffer;
 protected:
@@ -500,7 +505,7 @@ public:
   UINT GetCBufferSize() { return m_SizeInCBuffer; }
 };
 
-class CShaderReflectionVariable : public ID3D12ShaderReflectionVariable
+class CShaderReflectionVariable final : public ID3D12ShaderReflectionVariable
 {
 protected:
   D3D12_SHADER_VARIABLE_DESC          m_Desc;
@@ -524,7 +529,7 @@ public:
   STDMETHOD_(UINT, GetInterfaceSlot)(THIS_ UINT uArrayIndex);
 };
 
-class CShaderReflectionConstantBuffer : public ID3D12ShaderReflectionConstantBuffer
+class CShaderReflectionConstantBuffer final : public ID3D12ShaderReflectionConstantBuffer
 {
 protected:
   D3D12_SHADER_BUFFER_DESC                m_Desc;
@@ -566,7 +571,7 @@ class CInvalidSRConstantBuffer;
 class CInvalidSRLibraryFunction;
 class CInvalidSRFunctionParameter;
 
-class CInvalidSRType : public ID3D12ShaderReflectionType {
+class CInvalidSRType final : public ID3D12ShaderReflectionType {
   STDMETHOD(GetDesc)(D3D12_SHADER_TYPE_DESC *pDesc) { return E_FAIL; }
 
   STDMETHOD_(ID3D12ShaderReflectionType*, GetMemberTypeByIndex)(UINT Index);
@@ -589,7 +594,7 @@ ID3D12ShaderReflectionType* CInvalidSRType::GetSubType() { return &g_InvalidSRTy
 ID3D12ShaderReflectionType* CInvalidSRType::GetBaseClass() { return &g_InvalidSRType; }
 ID3D12ShaderReflectionType* CInvalidSRType::GetInterfaceByIndex(UINT) { return &g_InvalidSRType; }
 
-class CInvalidSRVariable : public ID3D12ShaderReflectionVariable {
+class CInvalidSRVariable final : public ID3D12ShaderReflectionVariable {
   STDMETHOD(GetDesc)(D3D12_SHADER_VARIABLE_DESC *pDesc) { return E_FAIL; }
 
   STDMETHOD_(ID3D12ShaderReflectionType*, GetType)() { return &g_InvalidSRType; }
@@ -599,7 +604,7 @@ class CInvalidSRVariable : public ID3D12ShaderReflectionVariable {
 };
 static CInvalidSRVariable g_InvalidSRVariable;
 
-class CInvalidSRConstantBuffer : public ID3D12ShaderReflectionConstantBuffer {
+class CInvalidSRConstantBuffer final : public ID3D12ShaderReflectionConstantBuffer {
   STDMETHOD(GetDesc)(D3D12_SHADER_BUFFER_DESC *pDesc) { return E_FAIL; }
 
   STDMETHOD_(ID3D12ShaderReflectionVariable*, GetVariableByIndex)(UINT Index) { return &g_InvalidSRVariable; }
@@ -607,12 +612,12 @@ class CInvalidSRConstantBuffer : public ID3D12ShaderReflectionConstantBuffer {
 };
 static CInvalidSRConstantBuffer g_InvalidSRConstantBuffer;
 
-class CInvalidFunctionParameter : public ID3D12FunctionParameterReflection {
+class CInvalidFunctionParameter final : public ID3D12FunctionParameterReflection {
   STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_PARAMETER_DESC * pDesc) { return E_FAIL; }
 };
 CInvalidFunctionParameter g_InvalidFunctionParameter;
 
-class CInvalidFunction : public ID3D12FunctionReflection {
+class CInvalidFunction final : public ID3D12FunctionReflection {
   STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_FUNCTION_DESC * pDesc) { return E_FAIL; }
 
   STDMETHOD_(ID3D12ShaderReflectionConstantBuffer *, GetConstantBufferByIndex)(THIS_ _In_ UINT BufferIndex) { return &g_InvalidSRConstantBuffer; }
@@ -1319,34 +1324,6 @@ void CShaderReflectionConstantBuffer::Initialize(
   }
 }
 
-
-static unsigned CalcTypeSize(Type *Ty, unsigned &alignment) {
-  // Assume aligned values.
-  if (Ty->isArrayTy()) {
-    ArrayType *AT = dyn_cast<ArrayType>(Ty);
-    return AT->getNumElements() * CalcTypeSize(AT->getArrayElementType(), alignment);
-  }
-  else if (Ty->isStructTy()) {
-    StructType *ST = dyn_cast<StructType>(Ty);
-    unsigned i = 0, c = ST->getStructNumElements();
-    unsigned result = 0;
-    for (; i < c; ++i) {
-      unsigned memberalign = 0;
-      result += CalcTypeSize(ST->getStructElementType(i), memberalign);
-      alignment = std::max(alignment, memberalign);
-      result = (unsigned)RoundUpToAlignment(result, memberalign);
-    }
-    result = (unsigned)RoundUpToAlignment(result, alignment);
-    return result;
-  }
-  else if (FixedVectorType *VT = dyn_cast<FixedVectorType>(Ty)) {
-    return VT->getNumElements() * CalcTypeSize(VT->getElementType(), alignment);
-  }
-  else {
-    return alignment = Ty->getPrimitiveSizeInBits() / 8;
-  }
-}
-
 static unsigned CalcResTypeSize(DxilModule &M, DxilResource &R) {
   UNREFERENCED_PARAMETER(M);
   Type *Ty = R.GetHLSLType()->getPointerElementType();
@@ -1354,10 +1331,6 @@ static unsigned CalcResTypeSize(DxilModule &M, DxilResource &R) {
     Ty = dxilutil::StripArrayTypes(Ty);
   }
   return M.GetModule()->getDataLayout().getTypeAllocSize(Ty);
-
-  // Don't think we need this one if we can just use the data layout:
-  //unsigned alignment = 0;
-  //return CalcTypeSize(Ty, alignment);
 }
 
 void CShaderReflectionConstantBuffer::InitializeStructuredBuffer(
@@ -2093,7 +2066,7 @@ HRESULT DxilModuleReflection::LoadProgramHeader(const DxilProgramHeader *pProgra
   try {
     const char *pBitcode;
     uint32_t bitcodeLength;
-    GetDxilProgramBitcode((DxilProgramHeader *)pProgramHeader, &pBitcode, &bitcodeLength);
+    GetDxilProgramBitcode((const DxilProgramHeader *)pProgramHeader, &pBitcode, &bitcodeLength);
     std::unique_ptr<MemoryBuffer> pMemBuffer =
         MemoryBuffer::getMemBufferCopy(StringRef(pBitcode, bitcodeLength));
     bool bBitcodeLoadError = false;
@@ -2180,7 +2153,7 @@ void DxilShaderReflection::MarkUsedSignatureElements() {
     DxilInst_StorePatchConstant SPC(&*I);
     DxilInst_StoreVertexOutput SVO(&*I);
     DxilInst_StorePrimitiveOutput SPO(&*I);
-    std::vector<D3D12_SIGNATURE_PARAMETER_DESC> *pDescs;
+    std::vector<D3D12_SIGNATURE_PARAMETER_DESC> *pDescs = nullptr;
     const DxilSignature *pSig;
     uint32_t col, row, sigId;
     if (LI) {
@@ -2544,7 +2517,7 @@ UINT64 DxilShaderReflection::GetRequiresFlags() {
 
 // ID3D12FunctionReflection
 
-class CFunctionReflection : public ID3D12FunctionReflection {
+class CFunctionReflection final : public ID3D12FunctionReflection {
 protected:
   DxilLibraryReflection * m_pLibraryReflection = nullptr;
   const Function *m_pFunction;
@@ -2823,10 +2796,3 @@ ID3D12FunctionReflection *DxilLibraryReflection::GetFunctionByIndex(INT Function
   return m_FunctionVector[FunctionIndex];
 }
 
-#else // LLVM_ON_WIN32
-
-void hlsl::CreateDxcContainerReflection(IDxcContainerReflection **ppResult) {
-  *ppResult = nullptr;
-}
-
-#endif // LLVM_ON_WIN32

+ 3 - 3
tools/clang/tools/dxcompiler/dxcapi.cpp

@@ -108,6 +108,9 @@ static HRESULT ThreadMallocDxcCreateInstance(
   else if (IsEqualCLSID(rclsid, CLSID_DxcContainerBuilder)) {
     hr = CreateDxcContainerBuilder(riid, ppv);
   }
+  else if (IsEqualCLSID(rclsid, CLSID_DxcContainerReflection)) {
+    hr = CreateDxcContainerReflection(riid, ppv);
+  }
 // Note: The following targets are not yet enabled for non-Windows platforms.
 #ifdef _WIN32
   else if (IsEqualCLSID(rclsid, CLSID_DxcRewriter)) {
@@ -116,9 +119,6 @@ static HRESULT ThreadMallocDxcCreateInstance(
   else if (IsEqualCLSID(rclsid, CLSID_DxcDiaDataSource)) {
     hr = CreateDxcDiaDataSource(riid, ppv);
   }
-  else if (IsEqualCLSID(rclsid, CLSID_DxcContainerReflection)) {
-    hr = CreateDxcContainerReflection(riid, ppv);
-  }
   else if (IsEqualCLSID(rclsid, CLSID_DxcLinker)) {
     hr = CreateDxcLinker(riid, ppv);
   }

+ 1 - 7
tools/clang/tools/dxcompiler/dxclibrary.cpp

@@ -28,13 +28,11 @@
 using namespace llvm;
 using namespace hlsl;
 
-#ifdef _WIN32
 // Temporary: Define these here until a better header location is found.
 namespace hlsl {
 HRESULT CreateDxilShaderOrLibraryReflectionFromProgramHeader(const DxilProgramHeader *pProgramHeader, const DxilPartHeader *pRDATPart, REFIID iid, void **ppvObject);
 HRESULT CreateDxilShaderOrLibraryReflectionFromModulePart(const DxilPartHeader *pModulePart, const DxilPartHeader *pRDATPart, REFIID iid, void **ppvObject);
 }
-#endif
 
 class DxcIncludeHandlerForFS : public IDxcIncludeHandler {
 private:
@@ -345,7 +343,6 @@ public:
 
   virtual HRESULT STDMETHODCALLTYPE CreateReflection(
     _In_ const DxcBuffer *pData, REFIID iid, void **ppvReflection) override {
-#ifdef _WIN32
     if (!pData || !pData->Ptr || pData->Size < 8 || pData->Encoding != DXC_CP_ACP ||
         !ppvReflection)
       return E_INVALIDARG;
@@ -419,7 +416,7 @@ public:
         UINT32 SizeRemaining = pData->Size - (sizeof(DxilPartHeader) + pPart->PartSize);
         if (SizeRemaining > sizeof(DxilPartHeader)) {
           // Looks like we also have an RDAT part
-          pPart = (DxilPartHeader*)(GetDxilPartData(pPart) + pPart->PartSize);
+          pPart = (const DxilPartHeader*)(GetDxilPartData(pPart) + pPart->PartSize);
           if (pPart->PartSize < /*sizeof(RuntimeDataHeader)*/8 ||
               pPart->PartSize + sizeof(DxilPartHeader) > SizeRemaining)
             return E_INVALIDARG;
@@ -432,9 +429,6 @@ public:
       return hlsl::CreateDxilShaderOrLibraryReflectionFromModulePart(pModulePart, pRDATPart, iid, ppvReflection);
     }
     CATCH_CPP_RETURN_HRESULT();
-#else
-    return E_NOTIMPL;
-#endif
   }
 
   virtual HRESULT STDMETHODCALLTYPE BuildArguments(

+ 148 - 146
tools/clang/unittests/HLSL/CompilerTest.cpp

@@ -24,6 +24,7 @@
 #include <cfloat>
 #include "dxc/DxilContainer/DxilContainer.h"
 #include "dxc/Support/WinIncludes.h"
+#include "dxc/Support/D3DReflection.h"
 #include "dxc/dxcapi.h"
 #ifdef _WIN32
 #include "dxc/dxcpix.h"
@@ -1033,6 +1034,149 @@ TEST_F(CompilerTest, CompileThenAddCustomDebugName) {
   VERIFY_IS_NULL(pPartHeader);
 }
 
+
+TEST_F(CompilerTest, CompileThenTestReflectionWithProgramHeader) {
+  CComPtr<IDxcCompiler> pCompiler;
+  CComPtr<IDxcBlobEncoding> pSource;
+  CComPtr<IDxcOperationResult> pOperationResult;
+
+  const char* source = R"x(
+      cbuffer cb : register(b1) {
+        float foo;
+      };
+      [RootSignature("CBV(b1)")]
+      float4 main(float a : A) : SV_Target {
+        return a + foo;
+      }
+  )x";
+  std::string included_File = "#define ZERO 0";
+
+  VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
+  CreateBlobFromText(source, &pSource);
+
+  const WCHAR * args[] = {
+    L"-Zi",
+  };
+
+  VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
+    L"ps_6_0", args, _countof(args), nullptr, 0, nullptr, &pOperationResult));
+
+  HRESULT CompileStatus = S_OK;
+  VERIFY_SUCCEEDED(pOperationResult->GetStatus(&CompileStatus));
+  VERIFY_SUCCEEDED(CompileStatus);
+
+  CComPtr<IDxcResult> pResult;
+  VERIFY_SUCCEEDED(pOperationResult.QueryInterface(&pResult));
+
+  CComPtr<IDxcBlob> pPdbBlob;
+  VERIFY_SUCCEEDED(pResult->GetOutput(DXC_OUT_PDB, IID_PPV_ARGS(&pPdbBlob), nullptr));
+
+  CComPtr<IDxcContainerReflection> pContainerReflection;
+  VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcContainerReflection, &pContainerReflection));
+
+  VERIFY_SUCCEEDED(pContainerReflection->Load(pPdbBlob));
+  UINT32 index = 0;
+  VERIFY_SUCCEEDED(pContainerReflection->FindFirstPartKind(hlsl::DFCC_ShaderDebugInfoDXIL, &index));
+
+  CComPtr<IDxcBlob> pDebugDxilBlob;
+  VERIFY_SUCCEEDED(pContainerReflection->GetPartContent(index, &pDebugDxilBlob));
+
+  CComPtr<IDxcUtils> pUtils;
+  VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcUtils, &pUtils));
+
+  DxcBuffer buf = {};
+  buf.Ptr = pDebugDxilBlob->GetBufferPointer();
+  buf.Size = pDebugDxilBlob->GetBufferSize();
+
+  CComPtr<ID3D12ShaderReflection> pReflection;
+  VERIFY_SUCCEEDED(pUtils->CreateReflection(&buf, IID_PPV_ARGS(&pReflection)));
+
+  ID3D12ShaderReflectionConstantBuffer *cb = pReflection->GetConstantBufferByName("cb");
+  VERIFY_IS_TRUE(cb != nullptr);
+}
+
+void CompilerTest::CompileThenTestReflectionThreadSize(const char *source, const WCHAR *target, UINT expectedX, UINT expectedY, UINT expectedZ) {
+  CComPtr<IDxcCompiler> pCompiler;
+  CComPtr<IDxcBlobEncoding> pSource;
+  CComPtr<IDxcOperationResult> pOperationResult;
+
+  VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
+  CreateBlobFromText(source, &pSource);
+
+  const WCHAR * args[] = { L"-Zs", };
+
+  VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main", target,
+    args, _countof(args), nullptr, 0, nullptr, &pOperationResult));
+
+  HRESULT CompileStatus = S_OK;
+  VERIFY_SUCCEEDED(pOperationResult->GetStatus(&CompileStatus));
+  VERIFY_SUCCEEDED(CompileStatus);
+
+  CComPtr<IDxcBlob> pBlob;
+  VERIFY_SUCCEEDED(pOperationResult->GetResult(&pBlob));
+
+  CComPtr<IDxcUtils> pUtils;
+  VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcUtils, &pUtils));
+
+  DxcBuffer buf = {};
+  buf.Ptr  = pBlob->GetBufferPointer();
+  buf.Size = pBlob->GetBufferSize();
+
+  CComPtr<ID3D12ShaderReflection> pReflection;
+  VERIFY_SUCCEEDED(pUtils->CreateReflection(&buf, IID_PPV_ARGS(&pReflection)));
+
+  UINT x = 0, y = 0, z = 0;
+  VERIFY_SUCCEEDED(pReflection->GetThreadGroupSize(&x, &y, &z));
+  VERIFY_ARE_EQUAL(x, expectedX);
+  VERIFY_ARE_EQUAL(y, expectedY);
+  VERIFY_ARE_EQUAL(z, expectedZ);
+}
+
+TEST_F(CompilerTest, CompileThenTestReflectionThreadSizeCS) {
+  const char* source = R"x(
+    [numthreads(2, 3, 1)]
+    void main()
+    {
+    }
+  )x";
+
+  CompileThenTestReflectionThreadSize(source, L"cs_6_5", 2, 3, 1);
+}
+
+TEST_F(CompilerTest, CompileThenTestReflectionThreadSizeAS) {
+  const char* source = R"x(
+    struct Payload {
+        float2 dummy;
+        float4 pos;
+        float color[2];
+    };
+
+    [numthreads(2, 3, 1)]
+    void main()
+    {
+        Payload pld;
+        pld.dummy = float2(1.0,2.0);
+        pld.pos = float4(3.0,4.0,5.0,6.0);
+        pld.color[0] = 7.0;
+        pld.color[1] = 8.0;
+        DispatchMesh(2, 3, 1, pld);
+    }
+  )x";
+
+  CompileThenTestReflectionThreadSize(source, L"as_6_5", 2, 3, 1);
+}
+
+TEST_F(CompilerTest, CompileThenTestReflectionThreadSizeMS) {
+  const char* source = R"x(
+    [NumThreads(2,3,1)]
+    [OutputTopology("triangle")]
+    void main() {
+      int x = 2;
+    }
+  )x";
+  CompileThenTestReflectionThreadSize(source, L"ms_6_5", 2, 3, 1);
+}
+
 #ifdef _WIN32 // No PDBUtil support
 static void VerifyPdbUtil(dxc::DxcDllSupport &dllSupport,
     IDxcBlob *pBlob, IDxcPdbUtils *pPdbUtils,
@@ -1609,148 +1753,6 @@ void CompilerTest::TestPdbUtils(bool bSlim, bool bSourceInDebugModule, bool bStr
   VERIFY_ARE_EQUAL(pPdbUtils.p->Release(), 1);
 }
 
-TEST_F(CompilerTest, CompileThenTestReflectionWithProgramHeader) {
-  CComPtr<IDxcCompiler> pCompiler;
-  CComPtr<IDxcBlobEncoding> pSource;
-  CComPtr<IDxcOperationResult> pOperationResult;
-
-  const char* source = R"x(
-      cbuffer cb : register(b1) {
-        float foo;
-      };
-      [RootSignature("CBV(b1)")]
-      float4 main(float a : A) : SV_Target {
-        return a + foo;
-      }
-  )x";
-  std::string included_File = "#define ZERO 0";
-
-  VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
-  CreateBlobFromText(source, &pSource);
-
-  const WCHAR * args[] = {
-    L"-Zi",
-  };
-
-  VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
-    L"ps_6_0", args, _countof(args), nullptr, 0, nullptr, &pOperationResult));
-
-  HRESULT CompileStatus = S_OK;
-  VERIFY_SUCCEEDED(pOperationResult->GetStatus(&CompileStatus));
-  VERIFY_SUCCEEDED(CompileStatus);
-
-  CComPtr<IDxcResult> pResult;
-  VERIFY_SUCCEEDED(pOperationResult.QueryInterface(&pResult));
-
-  CComPtr<IDxcBlob> pPdbBlob;
-  VERIFY_SUCCEEDED(pResult->GetOutput(DXC_OUT_PDB, IID_PPV_ARGS(&pPdbBlob), nullptr));
-
-  CComPtr<IDxcContainerReflection> pContainerReflection;
-  VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcContainerReflection, &pContainerReflection));
-
-  VERIFY_SUCCEEDED(pContainerReflection->Load(pPdbBlob));
-  UINT32 index = 0;
-  VERIFY_SUCCEEDED(pContainerReflection->FindFirstPartKind(hlsl::DFCC_ShaderDebugInfoDXIL, &index));
-
-  CComPtr<IDxcBlob> pDebugDxilBlob;
-  VERIFY_SUCCEEDED(pContainerReflection->GetPartContent(index, &pDebugDxilBlob));
-
-  CComPtr<IDxcUtils> pUtils;
-  VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcUtils, &pUtils));
-
-  DxcBuffer buf = {};
-  buf.Ptr = pDebugDxilBlob->GetBufferPointer();
-  buf.Size = pDebugDxilBlob->GetBufferSize();
-
-  CComPtr<ID3D12ShaderReflection> pReflection;
-  VERIFY_SUCCEEDED(pUtils->CreateReflection(&buf, IID_PPV_ARGS(&pReflection)));
-
-  ID3D12ShaderReflectionConstantBuffer *cb = pReflection->GetConstantBufferByName("cb");
-  VERIFY_IS_TRUE(cb != nullptr);
-}
-
-void CompilerTest::CompileThenTestReflectionThreadSize(const char *source, const WCHAR *target, UINT expectedX, UINT expectedY, UINT expectedZ) {
-  CComPtr<IDxcCompiler> pCompiler;
-  CComPtr<IDxcBlobEncoding> pSource;
-  CComPtr<IDxcOperationResult> pOperationResult;
-
-  VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
-  CreateBlobFromText(source, &pSource);
-
-  const WCHAR * args[] = { L"-Zs", };
-
-  VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main", target,
-    args, _countof(args), nullptr, 0, nullptr, &pOperationResult));
-
-  HRESULT CompileStatus = S_OK;
-  VERIFY_SUCCEEDED(pOperationResult->GetStatus(&CompileStatus));
-  VERIFY_SUCCEEDED(CompileStatus);
-
-  CComPtr<IDxcBlob> pBlob;
-  VERIFY_SUCCEEDED(pOperationResult->GetResult(&pBlob));
-
-  CComPtr<IDxcUtils> pUtils;
-  VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcUtils, &pUtils));
-
-  DxcBuffer buf = {};
-  buf.Ptr  = pBlob->GetBufferPointer();
-  buf.Size = pBlob->GetBufferSize();
-
-  CComPtr<ID3D12ShaderReflection> pReflection;
-  VERIFY_SUCCEEDED(pUtils->CreateReflection(&buf, IID_PPV_ARGS(&pReflection)));
-
-  UINT x = 0, y = 0, z = 0;
-  VERIFY_SUCCEEDED(pReflection->GetThreadGroupSize(&x, &y, &z));
-  VERIFY_ARE_EQUAL(x, expectedX);
-  VERIFY_ARE_EQUAL(y, expectedY);
-  VERIFY_ARE_EQUAL(z, expectedZ);
-}
-
-TEST_F(CompilerTest, CompileThenTestReflectionThreadSizeCS) {
-  const char* source = R"x(
-    [numthreads(2, 3, 1)]
-    void main()
-    {
-    }
-  )x";
-
-  CompileThenTestReflectionThreadSize(source, L"cs_6_5", 2, 3, 1);
-}
-
-TEST_F(CompilerTest, CompileThenTestReflectionThreadSizeAS) {
-  const char* source = R"x(
-    struct Payload {
-        float2 dummy;
-        float4 pos;
-        float color[2];
-    };
-
-    [numthreads(2, 3, 1)]
-    void main()
-    {
-        Payload pld;
-        pld.dummy = float2(1.0,2.0);
-        pld.pos = float4(3.0,4.0,5.0,6.0);
-        pld.color[0] = 7.0;
-        pld.color[1] = 8.0;
-        DispatchMesh(2, 3, 1, pld);
-    }
-  )x";
-
-  CompileThenTestReflectionThreadSize(source, L"as_6_5", 2, 3, 1);
-}
-
-TEST_F(CompilerTest, CompileThenTestReflectionThreadSizeMS) {
-  const char* source = R"x(
-    [NumThreads(2,3,1)]
-    [OutputTopology("triangle")]
-    void main() {
-      int x = 2;
-    }
-  )x";
-  CompileThenTestReflectionThreadSize(source, L"ms_6_5", 2, 3, 1);
-}
-
 TEST_F(CompilerTest, CompileThenTestPdbUtils) {
   if (m_ver.SkipDxilVersion(1, 5)) return;
   TestPdbUtils(/*bSlim*/true,  /*bSourceInDebugModule*/false, /*strip*/true, /*bTestEntryPoint*/ false);  // Slim PDB, where source info is stored in its own part, and debug module is NOT present
@@ -3712,7 +3714,6 @@ TEST_F(CompilerTest, CodeGenVectorAtan2) {
   CodeGenTestCheck(L"atan2_vector_argument.hlsl");
 }
 
-#ifdef _WIN32 // Reflection unsupported
 TEST_F(CompilerTest, LibGVStore) {
   CComPtr<IDxcCompiler> pCompiler;
   CComPtr<IDxcOperationResult> pResult;
@@ -3788,7 +3789,6 @@ TEST_F(CompilerTest, LibGVStore) {
   std::wstring Text = BlobToWide(pTextBlob);
   VERIFY_ARE_NOT_EQUAL(std::wstring::npos, Text.find(L"store"));
 }
-#endif // WIN32 - Reflection unsupported
 
 TEST_F(CompilerTest, PreprocessWhenValidThenOK) {
   CComPtr<IDxcCompiler> pCompiler;
@@ -4062,15 +4062,17 @@ TEST_F(CompilerTest, DISABLED_ManualFileCheckTest) {
 }
 
 
-#ifdef _WIN32 // Reflection unsupported
+#ifdef _WIN32
 TEST_F(CompilerTest, CodeGenHashStability) {
+#else
+TEST_F(CompilerTest, DISABLED_CodeGenHashStability) {
+#endif
   CodeGenTestCheckBatchHash(L"");
 }
 
 TEST_F(CompilerTest, BatchD3DReflect) {
   CodeGenTestCheckBatchDir(L"d3dreflect");
 }
-#endif // WIN32 - Reflection unsupported
 
 TEST_F(CompilerTest, BatchDxil) {
   CodeGenTestCheckBatchDir(L"dxil");

+ 65 - 66
tools/clang/unittests/HLSL/DxilContainerTest.cpp

@@ -27,6 +27,7 @@
 #include <algorithm>
 #include <unordered_set>
 #include "dxc/Support/WinIncludes.h"
+#include "dxc/Support/D3DReflection.h"
 #include "dxc/dxcapi.h"
 #ifdef _WIN32
 #include <atlfile.h>
@@ -139,7 +140,7 @@ public:
     return m_dllSupport.CreateInstance(CLSID_DxcCompiler, ppResult);
   }
 
-#ifdef _WIN32 // - Reflection Unsupported
+#ifdef _WIN32 // DXBC Unsupported
   void CompareShaderInputBindDesc(D3D12_SHADER_INPUT_BIND_DESC *pTestDesc,
     D3D12_SHADER_INPUT_BIND_DESC *pBaseDesc) {
     VERIFY_ARE_EQUAL(pTestDesc->BindCount, pBaseDesc->BindCount);
@@ -410,7 +411,7 @@ public:
         D3DReflect(pBlob->GetBufferPointer(), pBlob->GetBufferSize(),
                    __uuidof(ID3D12ShaderReflection), (void **)ppReflection));
   }
-#endif // _WIN32 - Reflection unsupported
+#endif // _WIN32 - DXBC Unsupported
 
   void CompileToProgram(LPCSTR program, LPCWSTR entryPoint, LPCWSTR target,
                         LPCWSTR *pArguments, UINT32 argCount,
@@ -546,7 +547,7 @@ public:
     }
   }
 
-#ifdef _WIN32 // Reflection unsupported
+#ifdef _WIN32  // DXBC Unsupported
   WEX::Common::String WStrFmt(const wchar_t* msg, ...) {
     va_list args;
     va_start(args, msg);
@@ -590,7 +591,7 @@ public:
 
     CompareReflection(pProgramReflection, pProgramReflectionDXBC);
   }
-#endif // _WIN32 - Reflection unsupported
+#endif // _WIN32 - DXBC Unsupported
 };
 
 bool DxilContainerTest::InitSupport() {
@@ -888,7 +889,6 @@ TEST_F(DxilContainerTest, CompileWhenSigSquareThenIncludeSplit) {
 #endif
 }
 
-#ifdef _WIN32 // - Reflection unsupported
 TEST_F(DxilContainerTest, CompileAS_CheckPSV0) {
   if (m_ver.SkipDxilVersion(1, 5)) return;
   const char asSource[] =
@@ -933,7 +933,7 @@ TEST_F(DxilContainerTest, CompileAS_CheckPSV0) {
       VERIFY_ARE_EQUAL(PSVShaderKind::Amplification, kind);
       PSVRuntimeInfo0* pInfo = PSV.GetPSVRuntimeInfo0();
       VERIFY_IS_NOT_NULL(pInfo);
-      VERIFY_ARE_EQUAL(12, pInfo->AS.PayloadSizeInBytes);
+      VERIFY_ARE_EQUAL(12U, pInfo->AS.PayloadSizeInBytes);
       break;
     }
   }
@@ -1007,7 +1007,7 @@ TEST_F(DxilContainerTest, CompileWhenOkThenCheckRDAT) {
       context.InitFromRDAT((char *)pBlob->GetBufferPointer(), pBlob->GetBufferSize());
       auto funcTable = context.GetFunctionTable();
       auto resTable = context.GetResourceTable();
-      VERIFY_ARE_EQUAL(funcTable.Count(), 4);
+      VERIFY_ARE_EQUAL(funcTable.Count(), 4U);
       std::string str("function");
       for (uint32_t j = 0; j < funcTable.Count(); ++j) {
         auto funcReader = funcTable[j];
@@ -1016,7 +1016,7 @@ TEST_F(DxilContainerTest, CompileWhenOkThenCheckRDAT) {
         std::string cur_str = str;
         cur_str.push_back('0' + j);
         if (cur_str.compare("function0") == 0) {
-          VERIFY_ARE_EQUAL(funcReader.getResources().Count(), 1);
+          VERIFY_ARE_EQUAL(funcReader.getResources().Count(), 1U);
           hlsl::ShaderFlags flag;
           flag.SetUAVLoadAdditionalFormats(true);
           flag.SetLowPrecisionPresent(true);
@@ -1031,16 +1031,16 @@ TEST_F(DxilContainerTest, CompileWhenOkThenCheckRDAT) {
           flag.SetLowPrecisionPresent(true);
           uint64_t rawFlag = flag.GetFeatureInfo();
           VERIFY_ARE_EQUAL(funcReader.GetFeatureFlags(), rawFlag);
-          VERIFY_ARE_EQUAL(funcReader.getResources().Count(), 3);
+          VERIFY_ARE_EQUAL(funcReader.getResources().Count(), 3U);
         }
         else if (cur_str.compare("function2") == 0) {
-          VERIFY_ARE_EQUAL(funcReader.GetFeatureFlags() & 0xffffffffffffffff, 0);
-          VERIFY_ARE_EQUAL(funcReader.getResources().Count(), 0);
+          VERIFY_ARE_EQUAL(funcReader.GetFeatureFlags() & 0xffffffffffffffff, 0U);
+          VERIFY_ARE_EQUAL(funcReader.getResources().Count(), 0U);
           std::string dependency = funcReader.getFunctionDependencies()[0];
           VERIFY_IS_TRUE(dependency.find("function_import") != std::string::npos);
         }
         else if (cur_str.compare("function3") == 0) {
-          VERIFY_ARE_EQUAL(funcReader.GetFeatureFlags() & 0xffffffffffffffff, 0);
+          VERIFY_ARE_EQUAL(funcReader.GetFeatureFlags() & 0xffffffffffffffff, 0U);
           VERIFY_ARE_EQUAL(funcReader.getResources().Count(), numResFlagCheck);
           for (unsigned i = 0; i < funcReader.getResources().Count(); ++i) {
             auto resReader = funcReader.getResources()[0];
@@ -1059,12 +1059,12 @@ TEST_F(DxilContainerTest, CompileWhenOkThenCheckRDAT) {
           IFTBOOLMSG(false, E_FAIL, "unknown function name");
         }
       }
-      VERIFY_ARE_EQUAL(resTable.Count(), 8);
+      VERIFY_ARE_EQUAL(resTable.Count(), 8U);
       // This is validation test for DxilRuntimeReflection implemented on DxilRuntimeReflection.inl
       unique_ptr<DxilRuntimeReflection> pReflection(CreateDxilRuntimeReflection());
       VERIFY_IS_TRUE(pReflection->InitFromRDAT(pBlob->GetBufferPointer(), pBlob->GetBufferSize()));
       DxilLibraryDesc lib_reflection = pReflection->GetLibraryReflection();
-      VERIFY_ARE_EQUAL(lib_reflection.NumFunctions, 4);
+      VERIFY_ARE_EQUAL(lib_reflection.NumFunctions, 4U);
       for (uint32_t j = 0; j < 3; ++j) {
         DxilFunctionDesc function = lib_reflection.pFunction[j];
         std::string cur_str = str;
@@ -1077,8 +1077,8 @@ TEST_F(DxilContainerTest, CompileWhenOkThenCheckRDAT) {
           uint64_t featureFlag = static_cast<uint64_t>(function.FeatureInfo2) << 32;
           featureFlag |= static_cast<uint64_t>(function.FeatureInfo1);
           VERIFY_ARE_EQUAL(featureFlag, rawFlag);
-          VERIFY_ARE_EQUAL(function.NumResources, 1);
-          VERIFY_ARE_EQUAL(function.NumFunctionDependencies, 0);
+          VERIFY_ARE_EQUAL(function.NumResources, 1U);
+          VERIFY_ARE_EQUAL(function.NumFunctionDependencies, 0U);
           const DxilResourceDesc &resource = *function.Resources[0];
           VERIFY_ARE_EQUAL(resource.Class, (uint32_t)hlsl::DXIL::ResourceClass::UAV);
           VERIFY_ARE_EQUAL(resource.Kind, (uint32_t)hlsl::DXIL::ResourceKind::Texture1D);
@@ -1092,8 +1092,8 @@ TEST_F(DxilContainerTest, CompileWhenOkThenCheckRDAT) {
           uint64_t featureFlag = static_cast<uint64_t>(function.FeatureInfo2) << 32;
           featureFlag |= static_cast<uint64_t>(function.FeatureInfo1);
           VERIFY_ARE_EQUAL(featureFlag, rawFlag);
-          VERIFY_ARE_EQUAL(function.NumResources, 3);
-          VERIFY_ARE_EQUAL(function.NumFunctionDependencies, 0);
+          VERIFY_ARE_EQUAL(function.NumResources, 3U);
+          VERIFY_ARE_EQUAL(function.NumFunctionDependencies, 0U);
           std::unordered_set<std::wstring> stringSet = { L"$Globals", L"b_buf", L"tex2" };
           for (uint32_t j = 0; j < 3; ++j) {
             const DxilResourceDesc &resource = *function.Resources[j];
@@ -1102,18 +1102,18 @@ TEST_F(DxilContainerTest, CompileWhenOkThenCheckRDAT) {
           }
         }
         else if (cur_str.compare("function2") == 0) {
-          VERIFY_ARE_EQUAL(function.FeatureInfo1, 0);
-          VERIFY_ARE_EQUAL(function.FeatureInfo2, 0);
-          VERIFY_ARE_EQUAL(function.NumResources, 0);
-          VERIFY_ARE_EQUAL(function.NumFunctionDependencies, 1);
+          VERIFY_ARE_EQUAL(function.FeatureInfo1, 0U);
+          VERIFY_ARE_EQUAL(function.FeatureInfo2, 0U);
+          VERIFY_ARE_EQUAL(function.NumResources, 0U);
+          VERIFY_ARE_EQUAL(function.NumFunctionDependencies, 1U);
           std::wstring dependency = function.FunctionDependencies[0];
           VERIFY_IS_TRUE(dependency.find(L"function_import") != std::wstring::npos);
         }
         else if (cur_str.compare("function3") == 0) {
-          VERIFY_ARE_EQUAL(function.FeatureInfo1, 0);
-          VERIFY_ARE_EQUAL(function.FeatureInfo2, 0);
+          VERIFY_ARE_EQUAL(function.FeatureInfo1, 0U);
+          VERIFY_ARE_EQUAL(function.FeatureInfo2, 0U);
           VERIFY_ARE_EQUAL(function.NumResources, numResFlagCheck);
-          VERIFY_ARE_EQUAL(function.NumFunctionDependencies, 0);
+          VERIFY_ARE_EQUAL(function.NumFunctionDependencies, 0U);
           for (unsigned i = 0; i < function.NumResources; ++i) {
             const DxilResourceDesc *res = function.Resources[i];
             VERIFY_ARE_EQUAL(res->Class, static_cast<uint32_t>(hlsl::DXIL::ResourceClass::UAV));
@@ -1209,17 +1209,17 @@ static uint32_t EncodedVersion_vs_6_3 = hlsl::EncodeVersion(hlsl::DXIL::ShaderKi
 static void Ref1_CheckCBuffer_Globals(ID3D12ShaderReflectionConstantBuffer *pCBReflection, D3D12_SHADER_BUFFER_DESC &cbDesc) {
   std::string cbName = cbDesc.Name;
   VERIFY_IS_TRUE(cbName.compare("$Globals") == 0);
-  VERIFY_ARE_EQUAL(cbDesc.Size, 16);
+  VERIFY_ARE_EQUAL(cbDesc.Size, 16U);
   VERIFY_ARE_EQUAL(cbDesc.Type, D3D_CT_CBUFFER);
-  VERIFY_ARE_EQUAL(cbDesc.Variables, 1);
+  VERIFY_ARE_EQUAL(cbDesc.Variables, 1U);
 
   // cbval1
   ID3D12ShaderReflectionVariable *pVar = pCBReflection->GetVariableByIndex(0);
   D3D12_SHADER_VARIABLE_DESC varDesc;
   VERIFY_SUCCEEDED(pVar->GetDesc(&varDesc));
   VERIFY_ARE_EQUAL_STR(varDesc.Name, "cbval1");
-  VERIFY_ARE_EQUAL(varDesc.StartOffset, 0);
-  VERIFY_ARE_EQUAL(varDesc.Size, 4);
+  VERIFY_ARE_EQUAL(varDesc.StartOffset, 0U);
+  VERIFY_ARE_EQUAL(varDesc.Size, 4U);
   // TODO: verify rest of variable
   ID3D12ShaderReflectionType *pType = pVar->GetType();
   D3D12_SHADER_TYPE_DESC tyDesc;
@@ -1232,9 +1232,9 @@ static void Ref1_CheckCBuffer_Globals(ID3D12ShaderReflectionConstantBuffer *pCBR
 static void Ref1_CheckCBuffer_MyCB(ID3D12ShaderReflectionConstantBuffer *pCBReflection, D3D12_SHADER_BUFFER_DESC &cbDesc) {
   std::string cbName = cbDesc.Name;
   VERIFY_IS_TRUE(cbName.compare("MyCB") == 0);
-  VERIFY_ARE_EQUAL(cbDesc.Size, 32);
+  VERIFY_ARE_EQUAL(cbDesc.Size, 32U);
   VERIFY_ARE_EQUAL(cbDesc.Type, D3D_CT_CBUFFER);
-  VERIFY_ARE_EQUAL(cbDesc.Variables, 2);
+  VERIFY_ARE_EQUAL(cbDesc.Variables, 2U);
 
   // cbval2
   {
@@ -1242,8 +1242,8 @@ static void Ref1_CheckCBuffer_MyCB(ID3D12ShaderReflectionConstantBuffer *pCBRefl
     D3D12_SHADER_VARIABLE_DESC varDesc;
     VERIFY_SUCCEEDED(pVar->GetDesc(&varDesc));
     VERIFY_ARE_EQUAL_STR(varDesc.Name, "cbval2");
-    VERIFY_ARE_EQUAL(varDesc.StartOffset, 0);
-    VERIFY_ARE_EQUAL(varDesc.Size, 16);
+    VERIFY_ARE_EQUAL(varDesc.StartOffset, 0U);
+    VERIFY_ARE_EQUAL(varDesc.Size, 16U);
     // TODO: verify rest of variable
     ID3D12ShaderReflectionType *pType = pVar->GetType();
     D3D12_SHADER_TYPE_DESC tyDesc;
@@ -1259,8 +1259,8 @@ static void Ref1_CheckCBuffer_MyCB(ID3D12ShaderReflectionConstantBuffer *pCBRefl
     D3D12_SHADER_VARIABLE_DESC varDesc;
     VERIFY_SUCCEEDED(pVar->GetDesc(&varDesc));
     VERIFY_ARE_EQUAL_STR(varDesc.Name, "cbval3");
-    VERIFY_ARE_EQUAL(varDesc.StartOffset, 16);
-    VERIFY_ARE_EQUAL(varDesc.Size, 16);
+    VERIFY_ARE_EQUAL(varDesc.StartOffset, 16U);
+    VERIFY_ARE_EQUAL(varDesc.Size, 16U);
     // TODO: verify rest of variable
     ID3D12ShaderReflectionType *pType = pVar->GetType();
     D3D12_SHADER_TYPE_DESC tyDesc;
@@ -1276,45 +1276,45 @@ static void Ref1_CheckBinding_Globals(D3D12_SHADER_INPUT_BIND_DESC &resDesc) {
   VERIFY_IS_TRUE(resName.compare("$Globals") == 0);
   VERIFY_ARE_EQUAL(resDesc.Type, D3D_SIT_CBUFFER);
   // not explicitly bound:
-  VERIFY_ARE_EQUAL(resDesc.BindPoint, 4294967295);
-  VERIFY_ARE_EQUAL(resDesc.Space, 0);
-  VERIFY_ARE_EQUAL(resDesc.BindCount, 1);
+  VERIFY_ARE_EQUAL(resDesc.BindPoint, 4294967295U);
+  VERIFY_ARE_EQUAL(resDesc.Space, 0U);
+  VERIFY_ARE_EQUAL(resDesc.BindCount, 1U);
 }
 
 static void Ref1_CheckBinding_MyCB(D3D12_SHADER_INPUT_BIND_DESC &resDesc) {
   std::string resName = resDesc.Name;
   VERIFY_IS_TRUE(resName.compare("MyCB") == 0);
   VERIFY_ARE_EQUAL(resDesc.Type, D3D_SIT_CBUFFER);
-  VERIFY_ARE_EQUAL(resDesc.BindPoint, 11);
-  VERIFY_ARE_EQUAL(resDesc.Space, 2);
-  VERIFY_ARE_EQUAL(resDesc.BindCount, 1);
+  VERIFY_ARE_EQUAL(resDesc.BindPoint, 11U);
+  VERIFY_ARE_EQUAL(resDesc.Space, 2U);
+  VERIFY_ARE_EQUAL(resDesc.BindCount, 1U);
 }
 
 static void Ref1_CheckBinding_tex(D3D12_SHADER_INPUT_BIND_DESC &resDesc) {
   std::string resName = resDesc.Name;
   VERIFY_IS_TRUE(resName.compare("tex") == 0);
   VERIFY_ARE_EQUAL(resDesc.Type, D3D_SIT_UAV_RWTYPED);
-  VERIFY_ARE_EQUAL(resDesc.BindPoint, 5);
-  VERIFY_ARE_EQUAL(resDesc.Space, 0);
-  VERIFY_ARE_EQUAL(resDesc.BindCount, 1);
+  VERIFY_ARE_EQUAL(resDesc.BindPoint, 5U);
+  VERIFY_ARE_EQUAL(resDesc.Space, 0U);
+  VERIFY_ARE_EQUAL(resDesc.BindCount, 1U);
 }
 
 static void Ref1_CheckBinding_tex2(D3D12_SHADER_INPUT_BIND_DESC &resDesc) {
   std::string resName = resDesc.Name;
   VERIFY_IS_TRUE(resName.compare("tex2") == 0);
   VERIFY_ARE_EQUAL(resDesc.Type, D3D_SIT_TEXTURE);
-  VERIFY_ARE_EQUAL(resDesc.BindPoint, 0);
-  VERIFY_ARE_EQUAL(resDesc.Space, 0);
-  VERIFY_ARE_EQUAL(resDesc.BindCount, 1);
+  VERIFY_ARE_EQUAL(resDesc.BindPoint, 0U);
+  VERIFY_ARE_EQUAL(resDesc.Space, 0U);
+  VERIFY_ARE_EQUAL(resDesc.BindCount, 1U);
 }
 
 static void Ref1_CheckBinding_samp(D3D12_SHADER_INPUT_BIND_DESC &resDesc) {
   std::string resName = resDesc.Name;
   VERIFY_IS_TRUE(resName.compare("samp") == 0);
   VERIFY_ARE_EQUAL(resDesc.Type, D3D_SIT_SAMPLER);
-  VERIFY_ARE_EQUAL(resDesc.BindPoint, 7);
-  VERIFY_ARE_EQUAL(resDesc.Space, 0);
-  VERIFY_ARE_EQUAL(resDesc.BindCount, 1);
+  VERIFY_ARE_EQUAL(resDesc.BindPoint, 7U);
+  VERIFY_ARE_EQUAL(resDesc.Space, 0U);
+  VERIFY_ARE_EQUAL(resDesc.BindCount, 1U);
 }
 
 static void Ref1_CheckBinding_b_buf(D3D12_SHADER_INPUT_BIND_DESC &resDesc) {
@@ -1322,9 +1322,9 @@ static void Ref1_CheckBinding_b_buf(D3D12_SHADER_INPUT_BIND_DESC &resDesc) {
   VERIFY_IS_TRUE(resName.compare("b_buf") == 0);
   VERIFY_ARE_EQUAL(resDesc.Type, D3D_SIT_UAV_RWBYTEADDRESS);
   // not explicitly bound:
-  VERIFY_ARE_EQUAL(resDesc.BindPoint, 4294967295);
-  VERIFY_ARE_EQUAL(resDesc.Space, 4294967295);
-  VERIFY_ARE_EQUAL(resDesc.BindCount, 1);
+  VERIFY_ARE_EQUAL(resDesc.BindPoint, 4294967295U);
+  VERIFY_ARE_EQUAL(resDesc.Space, 4294967295U);
+  VERIFY_ARE_EQUAL(resDesc.BindCount, 1U);
 }
 
 
@@ -1373,7 +1373,7 @@ TEST_F(DxilContainerTest, CompileWhenOkThenCheckReflection1) {
       VERIFY_SUCCEEDED(containerReflection->GetPartReflection(i, IID_PPV_ARGS(&pLibraryReflection)));
       D3D12_LIBRARY_DESC LibDesc;
       VERIFY_SUCCEEDED(pLibraryReflection->GetDesc(&LibDesc));
-      VERIFY_ARE_EQUAL(LibDesc.FunctionCount, 3);
+      VERIFY_ARE_EQUAL(LibDesc.FunctionCount, 3U);
       for (INT iFn = 0; iFn < (INT)LibDesc.FunctionCount; iFn++) {
         ID3D12FunctionReflection *pFunctionReflection = pLibraryReflection->GetFunctionByIndex(iFn);
         D3D12_FUNCTION_DESC FnDesc;
@@ -1381,8 +1381,8 @@ TEST_F(DxilContainerTest, CompileWhenOkThenCheckReflection1) {
         std::string Name = FnDesc.Name;
         if (Name.compare("\01?function0@@YAM$min16f@@Z") == 0) {
           VERIFY_ARE_EQUAL(FnDesc.Version, EncodedVersion_lib_6_3);
-          VERIFY_ARE_EQUAL(FnDesc.ConstantBuffers, 1);
-          VERIFY_ARE_EQUAL(FnDesc.BoundResources, 2);
+          VERIFY_ARE_EQUAL(FnDesc.ConstantBuffers, 1U);
+          VERIFY_ARE_EQUAL(FnDesc.BoundResources, 2U);
           D3D12_SHADER_BUFFER_DESC cbDesc;
           ID3D12ShaderReflectionConstantBuffer *pCBReflection = pFunctionReflection->GetConstantBufferByIndex(0);
           VERIFY_SUCCEEDED(pCBReflection->GetDesc(&cbDesc));
@@ -1412,8 +1412,8 @@ TEST_F(DxilContainerTest, CompileWhenOkThenCheckReflection1) {
           }
         } else if (Name.compare("\01?function1@@YAMM$min12i@@Z") == 0) {
           VERIFY_ARE_EQUAL(FnDesc.Version, EncodedVersion_lib_6_3);
-          VERIFY_ARE_EQUAL(FnDesc.ConstantBuffers, 1);
-          VERIFY_ARE_EQUAL(FnDesc.BoundResources, 4);
+          VERIFY_ARE_EQUAL(FnDesc.ConstantBuffers, 1U);
+          VERIFY_ARE_EQUAL(FnDesc.BoundResources, 4U);
           D3D12_SHADER_BUFFER_DESC cbDesc;
           ID3D12ShaderReflectionConstantBuffer *pCBReflection = pFunctionReflection->GetConstantBufferByIndex(0);
           VERIFY_SUCCEEDED(pCBReflection->GetDesc(&cbDesc));
@@ -1444,8 +1444,8 @@ TEST_F(DxilContainerTest, CompileWhenOkThenCheckReflection1) {
         } else if (Name.compare("function2") == 0) {
           // shader function with unmangled name
           VERIFY_ARE_EQUAL(FnDesc.Version, EncodedVersion_vs_6_3);
-          VERIFY_ARE_EQUAL(FnDesc.ConstantBuffers, 2);
-          VERIFY_ARE_EQUAL(FnDesc.BoundResources, 2);
+          VERIFY_ARE_EQUAL(FnDesc.ConstantBuffers, 2U);
+          VERIFY_ARE_EQUAL(FnDesc.BoundResources, 2U);
           for (INT iCB = 0; iCB < (INT)FnDesc.BoundResources; iCB++) {
             D3D12_SHADER_BUFFER_DESC cbDesc;
             ID3D12ShaderReflectionConstantBuffer *pCBReflection = pFunctionReflection->GetConstantBufferByIndex(0);
@@ -1541,8 +1541,8 @@ TEST_F(DxilContainerTest, DxcUtils_CreateReflection) {
       VERIFY_SUCCEEDED(pShaderReflection->GetDesc(&desc));
       VERIFY_ARE_EQUAL(desc.Version, EncodedVersion_vs_6_3);
       if (bValid) {
-        VERIFY_ARE_EQUAL(desc.ConstantBuffers, 2);
-        VERIFY_ARE_EQUAL(desc.BoundResources, 2);
+        VERIFY_ARE_EQUAL(desc.ConstantBuffers, 2U);
+        VERIFY_ARE_EQUAL(desc.BoundResources, 2U);
         // That should be good enough to check that IDxcUtils::CreateReflection worked
       }
     };
@@ -1600,7 +1600,7 @@ TEST_F(DxilContainerTest, DxcUtils_CreateReflection) {
       D3D12_LIBRARY_DESC desc;
       VERIFY_SUCCEEDED(pLibraryReflection->GetDesc(&desc));
       if (bValid) {
-        VERIFY_ARE_EQUAL(desc.FunctionCount, 3);
+        VERIFY_ARE_EQUAL(desc.FunctionCount, 3U);
       // That should be good enough to check that IDxcUtils::CreateReflection worked
       }
     };
@@ -1649,7 +1649,6 @@ TEST_F(DxilContainerTest, DxcUtils_CreateReflection) {
     }
   }
 }
-#endif // _WIN32 - Reflection unsupported
 
 TEST_F(DxilContainerTest, CompileWhenOKThenIncludesFeatureInfo) {
   CComPtr<IDxcCompiler> pCompiler;
@@ -1897,7 +1896,7 @@ HRESULT HlslFileVariables::SetFromText(_In_count_(len) const char *pText, size_t
   return S_OK;
 }
 
-#ifdef _WIN32 // Reflection unsupported
+#ifdef _WIN32 // DXBC unsupported
 TEST_F(DxilContainerTest, ReflectionMatchesDXBC_CheckIn) {
   WEX::TestExecution::SetVerifyOutput verifySettings(WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
   ReflectionTest(hlsl_test::GetPathToHlslDataFile(L"..\\CodeGenHLSL\\container\\SimpleBezier11DS.hlsl").c_str(), false);
@@ -1968,7 +1967,7 @@ TEST_F(DxilContainerTest, ReflectionMatchesDXBC_Full) {
     }
   }
 }
-#endif // _WIN32 - Reflection unsupported
+#endif // _WIN32 - DXBC unsupported
 
 TEST_F(DxilContainerTest, ValidateFromLL_Abs2) {
   CodeGenTestCheck(L"..\\CodeGenHLSL\\container\\abs2_m.ll");

+ 5 - 14
tools/clang/unittests/HLSLTestLib/CMakeLists.txt

@@ -2,28 +2,19 @@
 if(WIN32)
 find_package(TAEF REQUIRED)
 include_directories(${TAEF_INCLUDE_DIRS})
+else(WIN32)
+include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
+include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googlemock/include)
+endif(WIN32)
 
 add_clang_library(HLSLTestLib
   D3DReflectionDumper.cpp
+  D3DReflectionStrings.cpp
   DxcTestUtils.cpp
   FileCheckerTest.cpp
   FileCheckForTest.cpp
   RDATDumper.cpp
 )
-else(WIN32)
-set(HLSL_IGNORE_SOURCES
-  D3DReflectionDumper.cpp
-  RDATDumper.cpp
-)
-add_clang_library(HLSLTestLib
-  DxcTestUtils.cpp
-  FileCheckerTest.cpp
-  FileCheckForTest.cpp
-)
-include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
-include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googlemock/include)
-
-endif(WIN32)
 
 add_dependencies(HLSLTestLib TablegenHLSLOptions)
 

+ 2 - 400
tools/clang/unittests/HLSLTestLib/D3DReflectionDumper.cpp

@@ -11,414 +11,16 @@
 
 #include "dxc/Support/Global.h"
 #include "dxc/DXIL/DxilConstants.h"
-#include "dxc/test/D3DReflectionDumper.h"
+#include "dxc/Test/D3DReflectionDumper.h"
+#include "dxc/Test/D3DReflectionStrings.h"
 #include "dxc/DxilContainer/DxilContainer.h"
 #include "dxc/dxcapi.h"
 #include <sstream>
 
-// Remove this workaround once newer version of d3dcommon.h can be compiled against
-#define ADD_16_64_BIT_TYPES
 
 namespace hlsl {
 namespace dump {
 
-LPCSTR ToString(D3D_CBUFFER_TYPE CBType) {
-  switch (CBType) {
-  case D3D_CT_CBUFFER: return "D3D_CT_CBUFFER";
-  case D3D_CT_TBUFFER: return "D3D_CT_TBUFFER";
-  case D3D_CT_INTERFACE_POINTERS: return "D3D_CT_INTERFACE_POINTERS";
-  case D3D_CT_RESOURCE_BIND_INFO: return "D3D_CT_RESOURCE_BIND_INFO";
-  default: return nullptr;
-  }
-}
-LPCSTR ToString(D3D_SHADER_INPUT_TYPE Type) {
-  switch ((UINT32)Type) {
-  case D3D_SIT_CBUFFER: return "D3D_SIT_CBUFFER";
-  case D3D_SIT_TBUFFER: return "D3D_SIT_TBUFFER";
-  case D3D_SIT_TEXTURE: return "D3D_SIT_TEXTURE";
-  case D3D_SIT_SAMPLER: return "D3D_SIT_SAMPLER";
-  case D3D_SIT_UAV_RWTYPED: return "D3D_SIT_UAV_RWTYPED";
-  case D3D_SIT_STRUCTURED: return "D3D_SIT_STRUCTURED";
-  case D3D_SIT_UAV_RWSTRUCTURED: return "D3D_SIT_UAV_RWSTRUCTURED";
-  case D3D_SIT_BYTEADDRESS: return "D3D_SIT_BYTEADDRESS";
-  case D3D_SIT_UAV_RWBYTEADDRESS: return "D3D_SIT_UAV_RWBYTEADDRESS";
-  case D3D_SIT_UAV_APPEND_STRUCTURED: return "D3D_SIT_UAV_APPEND_STRUCTURED";
-  case D3D_SIT_UAV_CONSUME_STRUCTURED: return "D3D_SIT_UAV_CONSUME_STRUCTURED";
-  case D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER: return "D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER";
-  case (D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER + 1): return "D3D_SIT_RTACCELERATIONSTRUCTURE";
-  case (D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER + 2): return "D3D_SIT_UAV_FEEDBACKTEXTURE";
-  default: return nullptr;
-  }
-}
-LPCSTR ToString(D3D_RESOURCE_RETURN_TYPE ReturnType) {
-  switch (ReturnType) {
-  case D3D_RETURN_TYPE_UNORM: return "D3D_RETURN_TYPE_UNORM";
-  case D3D_RETURN_TYPE_SNORM: return "D3D_RETURN_TYPE_SNORM";
-  case D3D_RETURN_TYPE_SINT: return "D3D_RETURN_TYPE_SINT";
-  case D3D_RETURN_TYPE_UINT: return "D3D_RETURN_TYPE_UINT";
-  case D3D_RETURN_TYPE_FLOAT: return "D3D_RETURN_TYPE_FLOAT";
-  case D3D_RETURN_TYPE_MIXED: return "D3D_RETURN_TYPE_MIXED";
-  case D3D_RETURN_TYPE_DOUBLE: return "D3D_RETURN_TYPE_DOUBLE";
-  case D3D_RETURN_TYPE_CONTINUED: return "D3D_RETURN_TYPE_CONTINUED";
-  default: return nullptr;
-  }
-}
-LPCSTR ToString(D3D_SRV_DIMENSION Dimension) {
-  switch (Dimension) {
-  case D3D_SRV_DIMENSION_UNKNOWN: return "D3D_SRV_DIMENSION_UNKNOWN";
-  case D3D_SRV_DIMENSION_BUFFER: return "D3D_SRV_DIMENSION_BUFFER";
-  case D3D_SRV_DIMENSION_TEXTURE1D: return "D3D_SRV_DIMENSION_TEXTURE1D";
-  case D3D_SRV_DIMENSION_TEXTURE1DARRAY: return "D3D_SRV_DIMENSION_TEXTURE1DARRAY";
-  case D3D_SRV_DIMENSION_TEXTURE2D: return "D3D_SRV_DIMENSION_TEXTURE2D";
-  case D3D_SRV_DIMENSION_TEXTURE2DARRAY: return "D3D_SRV_DIMENSION_TEXTURE2DARRAY";
-  case D3D_SRV_DIMENSION_TEXTURE2DMS: return "D3D_SRV_DIMENSION_TEXTURE2DMS";
-  case D3D_SRV_DIMENSION_TEXTURE2DMSARRAY: return "D3D_SRV_DIMENSION_TEXTURE2DMSARRAY";
-  case D3D_SRV_DIMENSION_TEXTURE3D: return "D3D_SRV_DIMENSION_TEXTURE3D";
-  case D3D_SRV_DIMENSION_TEXTURECUBE: return "D3D_SRV_DIMENSION_TEXTURECUBE";
-  case D3D_SRV_DIMENSION_TEXTURECUBEARRAY: return "D3D_SRV_DIMENSION_TEXTURECUBEARRAY";
-  case D3D_SRV_DIMENSION_BUFFEREX: return "D3D_SRV_DIMENSION_BUFFEREX";
-  default: return nullptr;
-  }
-}
-LPCSTR ToString(D3D_PRIMITIVE_TOPOLOGY GSOutputTopology) {
-  switch (GSOutputTopology) {
-  case D3D_PRIMITIVE_TOPOLOGY_UNDEFINED: return "D3D_PRIMITIVE_TOPOLOGY_UNDEFINED";
-  case D3D_PRIMITIVE_TOPOLOGY_POINTLIST: return "D3D_PRIMITIVE_TOPOLOGY_POINTLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_LINELIST: return "D3D_PRIMITIVE_TOPOLOGY_LINELIST";
-  case D3D_PRIMITIVE_TOPOLOGY_LINESTRIP: return "D3D_PRIMITIVE_TOPOLOGY_LINESTRIP";
-  case D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST: return "D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST";
-  case D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP: return "D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP";
-  case D3D_PRIMITIVE_TOPOLOGY_LINELIST_ADJ: return "D3D_PRIMITIVE_TOPOLOGY_LINELIST_ADJ";
-  case D3D_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ: return "D3D_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ";
-  case D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ: return "D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ";
-  case D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ: return "D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ";
-  case D3D_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_2_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_2_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_5_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_5_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_6_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_6_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_7_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_7_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_8_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_8_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_9_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_9_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_10_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_10_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_11_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_11_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_13_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_13_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_14_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_14_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_15_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_15_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_17_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_17_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_18_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_18_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_19_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_19_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_20_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_20_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_21_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_21_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_22_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_22_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_23_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_23_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_24_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_24_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_25_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_25_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_26_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_26_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_27_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_27_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_28_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_28_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_29_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_29_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_30_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_30_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_31_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_31_CONTROL_POINT_PATCHLIST";
-  case D3D_PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST";
-  default: return nullptr;
-  }
-}
-LPCSTR ToString(D3D_PRIMITIVE InputPrimitive) {
-  switch (InputPrimitive) {
-  case D3D_PRIMITIVE_UNDEFINED: return "D3D_PRIMITIVE_UNDEFINED";
-  case D3D_PRIMITIVE_POINT: return "D3D_PRIMITIVE_POINT";
-  case D3D_PRIMITIVE_LINE: return "D3D_PRIMITIVE_LINE";
-  case D3D_PRIMITIVE_TRIANGLE: return "D3D_PRIMITIVE_TRIANGLE";
-  case D3D_PRIMITIVE_LINE_ADJ: return "D3D_PRIMITIVE_LINE_ADJ";
-  case D3D_PRIMITIVE_TRIANGLE_ADJ: return "D3D_PRIMITIVE_TRIANGLE_ADJ";
-  case D3D_PRIMITIVE_1_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_1_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_2_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_2_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_3_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_3_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_4_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_4_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_5_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_5_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_6_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_6_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_7_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_7_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_8_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_8_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_9_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_9_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_10_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_10_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_11_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_11_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_12_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_12_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_13_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_13_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_14_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_14_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_15_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_15_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_16_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_16_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_17_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_17_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_18_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_18_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_19_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_19_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_20_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_20_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_21_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_21_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_22_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_22_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_23_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_23_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_24_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_24_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_25_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_25_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_26_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_26_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_27_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_27_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_28_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_28_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_29_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_29_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_30_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_30_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_31_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_31_CONTROL_POINT_PATCH";
-  case D3D_PRIMITIVE_32_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_32_CONTROL_POINT_PATCH";
-  default: return nullptr;
-  }
-}
-LPCSTR ToString(D3D_TESSELLATOR_OUTPUT_PRIMITIVE HSOutputPrimitive) {
-  switch (HSOutputPrimitive) {
-  case D3D_TESSELLATOR_OUTPUT_UNDEFINED: return "D3D_TESSELLATOR_OUTPUT_UNDEFINED";
-  case D3D_TESSELLATOR_OUTPUT_POINT: return "D3D_TESSELLATOR_OUTPUT_POINT";
-  case D3D_TESSELLATOR_OUTPUT_LINE: return "D3D_TESSELLATOR_OUTPUT_LINE";
-  case D3D_TESSELLATOR_OUTPUT_TRIANGLE_CW: return "D3D_TESSELLATOR_OUTPUT_TRIANGLE_CW";
-  case D3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW: return "D3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW";
-  default: return nullptr;
-  }
-}
-LPCSTR ToString(D3D_TESSELLATOR_PARTITIONING HSPartitioning) {
-  switch (HSPartitioning) {
-  case D3D_TESSELLATOR_PARTITIONING_UNDEFINED: return "D3D_TESSELLATOR_PARTITIONING_UNDEFINED";
-  case D3D_TESSELLATOR_PARTITIONING_INTEGER: return "D3D_TESSELLATOR_PARTITIONING_INTEGER";
-  case D3D_TESSELLATOR_PARTITIONING_POW2: return "D3D_TESSELLATOR_PARTITIONING_POW2";
-  case D3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD: return "D3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD";
-  case D3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN: return "D3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN";
-  default: return nullptr;
-  }
-}
-LPCSTR ToString(D3D_TESSELLATOR_DOMAIN TessellatorDomain) {
-  switch (TessellatorDomain) {
-  case D3D_TESSELLATOR_DOMAIN_UNDEFINED: return "D3D_TESSELLATOR_DOMAIN_UNDEFINED";
-  case D3D_TESSELLATOR_DOMAIN_ISOLINE: return "D3D_TESSELLATOR_DOMAIN_ISOLINE";
-  case D3D_TESSELLATOR_DOMAIN_TRI: return "D3D_TESSELLATOR_DOMAIN_TRI";
-  case D3D_TESSELLATOR_DOMAIN_QUAD: return "D3D_TESSELLATOR_DOMAIN_QUAD";
-  default: return nullptr;
-  }
-}
-LPCSTR ToString(D3D_SHADER_VARIABLE_CLASS Class) {
-  switch (Class) {
-  case D3D_SVC_SCALAR: return "D3D_SVC_SCALAR";
-  case D3D_SVC_VECTOR: return "D3D_SVC_VECTOR";
-  case D3D_SVC_MATRIX_ROWS: return "D3D_SVC_MATRIX_ROWS";
-  case D3D_SVC_MATRIX_COLUMNS: return "D3D_SVC_MATRIX_COLUMNS";
-  case D3D_SVC_OBJECT: return "D3D_SVC_OBJECT";
-  case D3D_SVC_STRUCT: return "D3D_SVC_STRUCT";
-  case D3D_SVC_INTERFACE_CLASS: return "D3D_SVC_INTERFACE_CLASS";
-  case D3D_SVC_INTERFACE_POINTER: return "D3D_SVC_INTERFACE_POINTER";
-  default: return nullptr;
-  }
-}
-
-#ifdef ADD_16_64_BIT_TYPES
-// Disable warning about value not being valid in enum
-#pragma warning( disable : 4063 )
-#define D3D_SVT_INT16   ((D3D_SHADER_VARIABLE_TYPE)58)
-#define D3D_SVT_UINT16  ((D3D_SHADER_VARIABLE_TYPE)59)
-#define D3D_SVT_FLOAT16 ((D3D_SHADER_VARIABLE_TYPE)60)
-#define D3D_SVT_INT64   ((D3D_SHADER_VARIABLE_TYPE)61)
-#define D3D_SVT_UINT64  ((D3D_SHADER_VARIABLE_TYPE)62)
-#endif // ADD_16_64_BIT_TYPES
-
-LPCSTR ToString(D3D_SHADER_VARIABLE_TYPE Type) {
-  switch (Type) {
-  case D3D_SVT_VOID: return "D3D_SVT_VOID";
-  case D3D_SVT_BOOL: return "D3D_SVT_BOOL";
-  case D3D_SVT_INT: return "D3D_SVT_INT";
-  case D3D_SVT_FLOAT: return "D3D_SVT_FLOAT";
-  case D3D_SVT_STRING: return "D3D_SVT_STRING";
-  case D3D_SVT_TEXTURE: return "D3D_SVT_TEXTURE";
-  case D3D_SVT_TEXTURE1D: return "D3D_SVT_TEXTURE1D";
-  case D3D_SVT_TEXTURE2D: return "D3D_SVT_TEXTURE2D";
-  case D3D_SVT_TEXTURE3D: return "D3D_SVT_TEXTURE3D";
-  case D3D_SVT_TEXTURECUBE: return "D3D_SVT_TEXTURECUBE";
-  case D3D_SVT_SAMPLER: return "D3D_SVT_SAMPLER";
-  case D3D_SVT_SAMPLER1D: return "D3D_SVT_SAMPLER1D";
-  case D3D_SVT_SAMPLER2D: return "D3D_SVT_SAMPLER2D";
-  case D3D_SVT_SAMPLER3D: return "D3D_SVT_SAMPLER3D";
-  case D3D_SVT_SAMPLERCUBE: return "D3D_SVT_SAMPLERCUBE";
-  case D3D_SVT_PIXELSHADER: return "D3D_SVT_PIXELSHADER";
-  case D3D_SVT_VERTEXSHADER: return "D3D_SVT_VERTEXSHADER";
-  case D3D_SVT_PIXELFRAGMENT: return "D3D_SVT_PIXELFRAGMENT";
-  case D3D_SVT_VERTEXFRAGMENT: return "D3D_SVT_VERTEXFRAGMENT";
-  case D3D_SVT_UINT: return "D3D_SVT_UINT";
-  case D3D_SVT_UINT8: return "D3D_SVT_UINT8";
-  case D3D_SVT_GEOMETRYSHADER: return "D3D_SVT_GEOMETRYSHADER";
-  case D3D_SVT_RASTERIZER: return "D3D_SVT_RASTERIZER";
-  case D3D_SVT_DEPTHSTENCIL: return "D3D_SVT_DEPTHSTENCIL";
-  case D3D_SVT_BLEND: return "D3D_SVT_BLEND";
-  case D3D_SVT_BUFFER: return "D3D_SVT_BUFFER";
-  case D3D_SVT_CBUFFER: return "D3D_SVT_CBUFFER";
-  case D3D_SVT_TBUFFER: return "D3D_SVT_TBUFFER";
-  case D3D_SVT_TEXTURE1DARRAY: return "D3D_SVT_TEXTURE1DARRAY";
-  case D3D_SVT_TEXTURE2DARRAY: return "D3D_SVT_TEXTURE2DARRAY";
-  case D3D_SVT_RENDERTARGETVIEW: return "D3D_SVT_RENDERTARGETVIEW";
-  case D3D_SVT_DEPTHSTENCILVIEW: return "D3D_SVT_DEPTHSTENCILVIEW";
-  case D3D_SVT_TEXTURE2DMS: return "D3D_SVT_TEXTURE2DMS";
-  case D3D_SVT_TEXTURE2DMSARRAY: return "D3D_SVT_TEXTURE2DMSARRAY";
-  case D3D_SVT_TEXTURECUBEARRAY: return "D3D_SVT_TEXTURECUBEARRAY";
-  case D3D_SVT_HULLSHADER: return "D3D_SVT_HULLSHADER";
-  case D3D_SVT_DOMAINSHADER: return "D3D_SVT_DOMAINSHADER";
-  case D3D_SVT_INTERFACE_POINTER: return "D3D_SVT_INTERFACE_POINTER";
-  case D3D_SVT_COMPUTESHADER: return "D3D_SVT_COMPUTESHADER";
-  case D3D_SVT_DOUBLE: return "D3D_SVT_DOUBLE";
-  case D3D_SVT_RWTEXTURE1D: return "D3D_SVT_RWTEXTURE1D";
-  case D3D_SVT_RWTEXTURE1DARRAY: return "D3D_SVT_RWTEXTURE1DARRAY";
-  case D3D_SVT_RWTEXTURE2D: return "D3D_SVT_RWTEXTURE2D";
-  case D3D_SVT_RWTEXTURE2DARRAY: return "D3D_SVT_RWTEXTURE2DARRAY";
-  case D3D_SVT_RWTEXTURE3D: return "D3D_SVT_RWTEXTURE3D";
-  case D3D_SVT_RWBUFFER: return "D3D_SVT_RWBUFFER";
-  case D3D_SVT_BYTEADDRESS_BUFFER: return "D3D_SVT_BYTEADDRESS_BUFFER";
-  case D3D_SVT_RWBYTEADDRESS_BUFFER: return "D3D_SVT_RWBYTEADDRESS_BUFFER";
-  case D3D_SVT_STRUCTURED_BUFFER: return "D3D_SVT_STRUCTURED_BUFFER";
-  case D3D_SVT_RWSTRUCTURED_BUFFER: return "D3D_SVT_RWSTRUCTURED_BUFFER";
-  case D3D_SVT_APPEND_STRUCTURED_BUFFER: return "D3D_SVT_APPEND_STRUCTURED_BUFFER";
-  case D3D_SVT_CONSUME_STRUCTURED_BUFFER: return "D3D_SVT_CONSUME_STRUCTURED_BUFFER";
-  case D3D_SVT_MIN8FLOAT: return "D3D_SVT_MIN8FLOAT";
-  case D3D_SVT_MIN10FLOAT: return "D3D_SVT_MIN10FLOAT";
-  case D3D_SVT_MIN16FLOAT: return "D3D_SVT_MIN16FLOAT";
-  case D3D_SVT_MIN12INT: return "D3D_SVT_MIN12INT";
-  case D3D_SVT_MIN16INT: return "D3D_SVT_MIN16INT";
-  case D3D_SVT_MIN16UINT: return "D3D_SVT_MIN16UINT";
-  case D3D_SVT_INT16: return "D3D_SVT_INT16";
-  case D3D_SVT_UINT16: return "D3D_SVT_UINT16";
-  case D3D_SVT_FLOAT16: return "D3D_SVT_FLOAT16";
-  case D3D_SVT_INT64: return "D3D_SVT_INT64";
-  case D3D_SVT_UINT64: return "D3D_SVT_UINT64";
-  default: return nullptr;
-  }
-}
-
-LPCSTR ToString(D3D_SHADER_VARIABLE_FLAGS Flag) {
-  switch (Flag) {
-  case D3D_SVF_USERPACKED: return "D3D_SVF_USERPACKED";
-  case D3D_SVF_USED: return "D3D_SVF_USED";
-  case D3D_SVF_INTERFACE_POINTER: return "D3D_SVF_INTERFACE_POINTER";
-  case D3D_SVF_INTERFACE_PARAMETER: return "D3D_SVF_INTERFACE_PARAMETER";
-  }
-  return nullptr;
-}
-
-LPCSTR ToString(D3D_SHADER_INPUT_FLAGS Flag) {
-  switch (Flag) {
-  case D3D_SIF_USERPACKED: return "D3D_SIF_USERPACKED";
-  case D3D_SIF_COMPARISON_SAMPLER: return "D3D_SIF_COMPARISON_SAMPLER";
-  case D3D_SIF_TEXTURE_COMPONENT_0: return "D3D_SIF_TEXTURE_COMPONENT_0";
-  case D3D_SIF_TEXTURE_COMPONENT_1: return "D3D_SIF_TEXTURE_COMPONENT_1";
-  case D3D_SIF_TEXTURE_COMPONENTS: return "D3D_SIF_TEXTURE_COMPONENTS";
-  case D3D_SIF_UNUSED: return "D3D_SIF_UNUSED";
-  }
-  return nullptr;
-}
-
-LPCSTR ToString(D3D_SHADER_CBUFFER_FLAGS Flag) {
-  switch (Flag) {
-  case D3D_CBF_USERPACKED: return "D3D_CBF_USERPACKED";
-  }
-  return nullptr;
-}
-
-LPCSTR ToString(D3D_PARAMETER_FLAGS Flag) {
-  switch (Flag) {
-  case D3D_PF_IN: return "D3D_PF_IN";
-  case D3D_PF_OUT: return "D3D_PF_OUT";
-  }
-  return nullptr;
-}
-
-#ifndef D3D_NAME_SHADINGRATE
-#define D3D_NAME_SHADINGRATE ((D3D_NAME)hlsl::DxilProgramSigSemantic::ShadingRate)
-#endif
-#ifndef D3D_NAME_CULLPRIMITIVE
-#define D3D_NAME_CULLPRIMITIVE ((D3D_NAME)hlsl::DxilProgramSigSemantic::CullPrimitive)
-#endif
-
-LPCSTR ToString(D3D_NAME Name) {
-  switch (Name) {
-  case D3D_NAME_UNDEFINED: return "D3D_NAME_UNDEFINED";
-  case D3D_NAME_POSITION: return "D3D_NAME_POSITION";
-  case D3D_NAME_CLIP_DISTANCE: return "D3D_NAME_CLIP_DISTANCE";
-  case D3D_NAME_CULL_DISTANCE: return "D3D_NAME_CULL_DISTANCE";
-  case D3D_NAME_RENDER_TARGET_ARRAY_INDEX: return "D3D_NAME_RENDER_TARGET_ARRAY_INDEX";
-  case D3D_NAME_VIEWPORT_ARRAY_INDEX: return "D3D_NAME_VIEWPORT_ARRAY_INDEX";
-  case D3D_NAME_VERTEX_ID: return "D3D_NAME_VERTEX_ID";
-  case D3D_NAME_PRIMITIVE_ID: return "D3D_NAME_PRIMITIVE_ID";
-  case D3D_NAME_INSTANCE_ID: return "D3D_NAME_INSTANCE_ID";
-  case D3D_NAME_IS_FRONT_FACE: return "D3D_NAME_IS_FRONT_FACE";
-  case D3D_NAME_SAMPLE_INDEX: return "D3D_NAME_SAMPLE_INDEX";
-  case D3D_NAME_FINAL_QUAD_EDGE_TESSFACTOR: return "D3D_NAME_FINAL_QUAD_EDGE_TESSFACTOR";
-  case D3D_NAME_FINAL_QUAD_INSIDE_TESSFACTOR: return "D3D_NAME_FINAL_QUAD_INSIDE_TESSFACTOR";
-  case D3D_NAME_FINAL_TRI_EDGE_TESSFACTOR: return "D3D_NAME_FINAL_TRI_EDGE_TESSFACTOR";
-  case D3D_NAME_FINAL_TRI_INSIDE_TESSFACTOR: return "D3D_NAME_FINAL_TRI_INSIDE_TESSFACTOR";
-  case D3D_NAME_FINAL_LINE_DETAIL_TESSFACTOR: return "D3D_NAME_FINAL_LINE_DETAIL_TESSFACTOR";
-  case D3D_NAME_FINAL_LINE_DENSITY_TESSFACTOR: return "D3D_NAME_FINAL_LINE_DENSITY_TESSFACTOR";
-  case D3D_NAME_BARYCENTRICS: return "D3D_NAME_BARYCENTRICS";
-  case D3D_NAME_TARGET: return "D3D_NAME_TARGET";
-  case D3D_NAME_DEPTH: return "D3D_NAME_DEPTH";
-  case D3D_NAME_COVERAGE: return "D3D_NAME_COVERAGE";
-  case D3D_NAME_DEPTH_GREATER_EQUAL: return "D3D_NAME_DEPTH_GREATER_EQUAL";
-  case D3D_NAME_DEPTH_LESS_EQUAL: return "D3D_NAME_DEPTH_LESS_EQUAL";
-  case D3D_NAME_STENCIL_REF: return "D3D_NAME_STENCIL_REF";
-  case D3D_NAME_INNER_COVERAGE: return "D3D_NAME_INNER_COVERAGE";
-  case D3D_NAME_SHADINGRATE: return "D3D_NAME_SHADINGRATE";
-  case D3D_NAME_CULLPRIMITIVE: return "D3D_NAME_CULLPRIMITIVE";
-  }
-  return nullptr;
-}
-
-LPCSTR ToString(D3D_REGISTER_COMPONENT_TYPE CompTy) {
-  switch (CompTy) {
-  case D3D_REGISTER_COMPONENT_UNKNOWN: return "D3D_REGISTER_COMPONENT_UNKNOWN";
-  case D3D_REGISTER_COMPONENT_UINT32: return "D3D_REGISTER_COMPONENT_UINT32";
-  case D3D_REGISTER_COMPONENT_SINT32: return "D3D_REGISTER_COMPONENT_SINT32";
-  case D3D_REGISTER_COMPONENT_FLOAT32: return "D3D_REGISTER_COMPONENT_FLOAT32";
-  }
-  return nullptr;
-}
-
-LPCSTR ToString(D3D_MIN_PRECISION MinPrec) {
-  switch (MinPrec) {
-  case D3D_MIN_PRECISION_DEFAULT: return "D3D_MIN_PRECISION_DEFAULT";
-  case D3D_MIN_PRECISION_FLOAT_16: return "D3D_MIN_PRECISION_FLOAT_16";
-  case D3D_MIN_PRECISION_FLOAT_2_8: return "D3D_MIN_PRECISION_FLOAT_2_8";
-  case D3D_MIN_PRECISION_RESERVED: return "D3D_MIN_PRECISION_RESERVED";
-  case D3D_MIN_PRECISION_SINT_16: return "D3D_MIN_PRECISION_SINT_16";
-  case D3D_MIN_PRECISION_UINT_16: return "D3D_MIN_PRECISION_UINT_16";
-  case D3D_MIN_PRECISION_ANY_16: return "D3D_MIN_PRECISION_ANY_16";
-  case D3D_MIN_PRECISION_ANY_10: return "D3D_MIN_PRECISION_ANY_10";
-  }
-  return nullptr;
-}
-
-LPCSTR CompMaskToString(unsigned CompMask) {
-  static const LPCSTR masks[16] = {
-    "----",
-    "x---",
-    "-y--",
-    "xy--",
-    "--z-",
-    "x-z-",
-    "-yz-",
-    "xyz-",
-    "---w",
-    "x--w",
-    "-y-w",
-    "xy-w",
-    "--zw",
-    "x-zw",
-    "-yzw",
-    "xyzw"
-  };
-  if (CompMask < 16) {
-    return masks[CompMask];
-  }
-  return "<invalid mask>";
-}
-
-
 void D3DReflectionDumper::DumpDefaultValue(LPCVOID pDefaultValue, UINT Size) {
   WriteLn("DefaultValue: ", pDefaultValue ? "<present>" : "<nullptr>");    // TODO: Dump DefaultValue
 }

+ 428 - 0
tools/clang/unittests/HLSLTestLib/D3DReflectionStrings.cpp

@@ -0,0 +1,428 @@
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// D3DReflectionStrings.cpp                                                  //
+// Copyright (C) Microsoft Corporation. All rights reserved.                 //
+// This file is distributed under the University of Illinois Open Source     //
+// License. See LICENSE.TXT for details.                                     //
+//                                                                           //
+// Used to convert reflection data types into strings.                       //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#include "dxc/Support/Global.h"
+#include "dxc/Test/D3DReflectionStrings.h"
+#include "dxc/DxilContainer/DxilContainer.h"
+
+// Remove this workaround once newer version of d3dcommon.h can be compiled against
+#define ADD_16_64_BIT_TYPES
+
+namespace hlsl {
+namespace dump {
+
+// ToString functions for D3D types
+
+LPCSTR ToString(D3D_CBUFFER_TYPE CBType) {
+  switch (CBType) {
+  case D3D_CT_CBUFFER: return "D3D_CT_CBUFFER";
+  case D3D_CT_TBUFFER: return "D3D_CT_TBUFFER";
+  case D3D_CT_INTERFACE_POINTERS: return "D3D_CT_INTERFACE_POINTERS";
+  case D3D_CT_RESOURCE_BIND_INFO: return "D3D_CT_RESOURCE_BIND_INFO";
+  default: return nullptr;
+  }
+}
+LPCSTR ToString(D3D_SHADER_INPUT_TYPE Type) {
+  switch ((UINT32)Type) {
+  case D3D_SIT_CBUFFER: return "D3D_SIT_CBUFFER";
+  case D3D_SIT_TBUFFER: return "D3D_SIT_TBUFFER";
+  case D3D_SIT_TEXTURE: return "D3D_SIT_TEXTURE";
+  case D3D_SIT_SAMPLER: return "D3D_SIT_SAMPLER";
+  case D3D_SIT_UAV_RWTYPED: return "D3D_SIT_UAV_RWTYPED";
+  case D3D_SIT_STRUCTURED: return "D3D_SIT_STRUCTURED";
+  case D3D_SIT_UAV_RWSTRUCTURED: return "D3D_SIT_UAV_RWSTRUCTURED";
+  case D3D_SIT_BYTEADDRESS: return "D3D_SIT_BYTEADDRESS";
+  case D3D_SIT_UAV_RWBYTEADDRESS: return "D3D_SIT_UAV_RWBYTEADDRESS";
+  case D3D_SIT_UAV_APPEND_STRUCTURED: return "D3D_SIT_UAV_APPEND_STRUCTURED";
+  case D3D_SIT_UAV_CONSUME_STRUCTURED: return "D3D_SIT_UAV_CONSUME_STRUCTURED";
+  case D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER: return "D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER";
+  case (D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER + 1): return "D3D_SIT_RTACCELERATIONSTRUCTURE";
+  case (D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER + 2): return "D3D_SIT_UAV_FEEDBACKTEXTURE";
+  default: return nullptr;
+  }
+}
+LPCSTR ToString(D3D_RESOURCE_RETURN_TYPE ReturnType) {
+  switch (ReturnType) {
+  case D3D_RETURN_TYPE_UNORM: return "D3D_RETURN_TYPE_UNORM";
+  case D3D_RETURN_TYPE_SNORM: return "D3D_RETURN_TYPE_SNORM";
+  case D3D_RETURN_TYPE_SINT: return "D3D_RETURN_TYPE_SINT";
+  case D3D_RETURN_TYPE_UINT: return "D3D_RETURN_TYPE_UINT";
+  case D3D_RETURN_TYPE_FLOAT: return "D3D_RETURN_TYPE_FLOAT";
+  case D3D_RETURN_TYPE_MIXED: return "D3D_RETURN_TYPE_MIXED";
+  case D3D_RETURN_TYPE_DOUBLE: return "D3D_RETURN_TYPE_DOUBLE";
+  case D3D_RETURN_TYPE_CONTINUED: return "D3D_RETURN_TYPE_CONTINUED";
+  default: return nullptr;
+  }
+}
+LPCSTR ToString(D3D_SRV_DIMENSION Dimension) {
+  switch (Dimension) {
+  case D3D_SRV_DIMENSION_UNKNOWN: return "D3D_SRV_DIMENSION_UNKNOWN";
+  case D3D_SRV_DIMENSION_BUFFER: return "D3D_SRV_DIMENSION_BUFFER";
+  case D3D_SRV_DIMENSION_TEXTURE1D: return "D3D_SRV_DIMENSION_TEXTURE1D";
+  case D3D_SRV_DIMENSION_TEXTURE1DARRAY: return "D3D_SRV_DIMENSION_TEXTURE1DARRAY";
+  case D3D_SRV_DIMENSION_TEXTURE2D: return "D3D_SRV_DIMENSION_TEXTURE2D";
+  case D3D_SRV_DIMENSION_TEXTURE2DARRAY: return "D3D_SRV_DIMENSION_TEXTURE2DARRAY";
+  case D3D_SRV_DIMENSION_TEXTURE2DMS: return "D3D_SRV_DIMENSION_TEXTURE2DMS";
+  case D3D_SRV_DIMENSION_TEXTURE2DMSARRAY: return "D3D_SRV_DIMENSION_TEXTURE2DMSARRAY";
+  case D3D_SRV_DIMENSION_TEXTURE3D: return "D3D_SRV_DIMENSION_TEXTURE3D";
+  case D3D_SRV_DIMENSION_TEXTURECUBE: return "D3D_SRV_DIMENSION_TEXTURECUBE";
+  case D3D_SRV_DIMENSION_TEXTURECUBEARRAY: return "D3D_SRV_DIMENSION_TEXTURECUBEARRAY";
+  case D3D_SRV_DIMENSION_BUFFEREX: return "D3D_SRV_DIMENSION_BUFFEREX";
+  default: return nullptr;
+  }
+}
+LPCSTR ToString(D3D_PRIMITIVE_TOPOLOGY GSOutputTopology) {
+  switch (GSOutputTopology) {
+  case D3D_PRIMITIVE_TOPOLOGY_UNDEFINED: return "D3D_PRIMITIVE_TOPOLOGY_UNDEFINED";
+  case D3D_PRIMITIVE_TOPOLOGY_POINTLIST: return "D3D_PRIMITIVE_TOPOLOGY_POINTLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_LINELIST: return "D3D_PRIMITIVE_TOPOLOGY_LINELIST";
+  case D3D_PRIMITIVE_TOPOLOGY_LINESTRIP: return "D3D_PRIMITIVE_TOPOLOGY_LINESTRIP";
+  case D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST: return "D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST";
+  case D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP: return "D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP";
+  case D3D_PRIMITIVE_TOPOLOGY_LINELIST_ADJ: return "D3D_PRIMITIVE_TOPOLOGY_LINELIST_ADJ";
+  case D3D_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ: return "D3D_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ";
+  case D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ: return "D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ";
+  case D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ: return "D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ";
+  case D3D_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_2_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_2_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_5_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_5_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_6_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_6_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_7_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_7_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_8_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_8_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_9_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_9_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_10_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_10_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_11_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_11_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_13_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_13_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_14_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_14_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_15_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_15_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_17_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_17_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_18_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_18_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_19_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_19_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_20_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_20_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_21_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_21_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_22_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_22_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_23_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_23_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_24_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_24_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_25_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_25_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_26_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_26_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_27_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_27_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_28_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_28_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_29_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_29_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_30_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_30_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_31_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_31_CONTROL_POINT_PATCHLIST";
+  case D3D_PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST: return "D3D_PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST";
+  default: return nullptr;
+  }
+}
+LPCSTR ToString(D3D_PRIMITIVE InputPrimitive) {
+  switch (InputPrimitive) {
+  case D3D_PRIMITIVE_UNDEFINED: return "D3D_PRIMITIVE_UNDEFINED";
+  case D3D_PRIMITIVE_POINT: return "D3D_PRIMITIVE_POINT";
+  case D3D_PRIMITIVE_LINE: return "D3D_PRIMITIVE_LINE";
+  case D3D_PRIMITIVE_TRIANGLE: return "D3D_PRIMITIVE_TRIANGLE";
+  case D3D_PRIMITIVE_LINE_ADJ: return "D3D_PRIMITIVE_LINE_ADJ";
+  case D3D_PRIMITIVE_TRIANGLE_ADJ: return "D3D_PRIMITIVE_TRIANGLE_ADJ";
+  case D3D_PRIMITIVE_1_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_1_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_2_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_2_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_3_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_3_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_4_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_4_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_5_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_5_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_6_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_6_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_7_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_7_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_8_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_8_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_9_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_9_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_10_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_10_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_11_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_11_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_12_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_12_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_13_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_13_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_14_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_14_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_15_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_15_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_16_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_16_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_17_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_17_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_18_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_18_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_19_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_19_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_20_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_20_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_21_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_21_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_22_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_22_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_23_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_23_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_24_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_24_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_25_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_25_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_26_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_26_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_27_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_27_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_28_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_28_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_29_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_29_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_30_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_30_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_31_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_31_CONTROL_POINT_PATCH";
+  case D3D_PRIMITIVE_32_CONTROL_POINT_PATCH: return "D3D_PRIMITIVE_32_CONTROL_POINT_PATCH";
+  default: return nullptr;
+  }
+}
+LPCSTR ToString(D3D_TESSELLATOR_OUTPUT_PRIMITIVE HSOutputPrimitive) {
+  switch (HSOutputPrimitive) {
+  case D3D_TESSELLATOR_OUTPUT_UNDEFINED: return "D3D_TESSELLATOR_OUTPUT_UNDEFINED";
+  case D3D_TESSELLATOR_OUTPUT_POINT: return "D3D_TESSELLATOR_OUTPUT_POINT";
+  case D3D_TESSELLATOR_OUTPUT_LINE: return "D3D_TESSELLATOR_OUTPUT_LINE";
+  case D3D_TESSELLATOR_OUTPUT_TRIANGLE_CW: return "D3D_TESSELLATOR_OUTPUT_TRIANGLE_CW";
+  case D3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW: return "D3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW";
+  default: return nullptr;
+  }
+}
+LPCSTR ToString(D3D_TESSELLATOR_PARTITIONING HSPartitioning) {
+  switch (HSPartitioning) {
+  case D3D_TESSELLATOR_PARTITIONING_UNDEFINED: return "D3D_TESSELLATOR_PARTITIONING_UNDEFINED";
+  case D3D_TESSELLATOR_PARTITIONING_INTEGER: return "D3D_TESSELLATOR_PARTITIONING_INTEGER";
+  case D3D_TESSELLATOR_PARTITIONING_POW2: return "D3D_TESSELLATOR_PARTITIONING_POW2";
+  case D3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD: return "D3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD";
+  case D3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN: return "D3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN";
+  default: return nullptr;
+  }
+}
+LPCSTR ToString(D3D_TESSELLATOR_DOMAIN TessellatorDomain) {
+  switch (TessellatorDomain) {
+  case D3D_TESSELLATOR_DOMAIN_UNDEFINED: return "D3D_TESSELLATOR_DOMAIN_UNDEFINED";
+  case D3D_TESSELLATOR_DOMAIN_ISOLINE: return "D3D_TESSELLATOR_DOMAIN_ISOLINE";
+  case D3D_TESSELLATOR_DOMAIN_TRI: return "D3D_TESSELLATOR_DOMAIN_TRI";
+  case D3D_TESSELLATOR_DOMAIN_QUAD: return "D3D_TESSELLATOR_DOMAIN_QUAD";
+  default: return nullptr;
+  }
+}
+LPCSTR ToString(D3D_SHADER_VARIABLE_CLASS Class) {
+  switch (Class) {
+  case D3D_SVC_SCALAR: return "D3D_SVC_SCALAR";
+  case D3D_SVC_VECTOR: return "D3D_SVC_VECTOR";
+  case D3D_SVC_MATRIX_ROWS: return "D3D_SVC_MATRIX_ROWS";
+  case D3D_SVC_MATRIX_COLUMNS: return "D3D_SVC_MATRIX_COLUMNS";
+  case D3D_SVC_OBJECT: return "D3D_SVC_OBJECT";
+  case D3D_SVC_STRUCT: return "D3D_SVC_STRUCT";
+  case D3D_SVC_INTERFACE_CLASS: return "D3D_SVC_INTERFACE_CLASS";
+  case D3D_SVC_INTERFACE_POINTER: return "D3D_SVC_INTERFACE_POINTER";
+  default: return nullptr;
+  }
+}
+
+#ifdef ADD_16_64_BIT_TYPES
+// Disable warning about value not being valid in enum
+#pragma warning( disable : 4063 )
+#define D3D_SVT_INT16   ((D3D_SHADER_VARIABLE_TYPE)58)
+#define D3D_SVT_UINT16  ((D3D_SHADER_VARIABLE_TYPE)59)
+#define D3D_SVT_FLOAT16 ((D3D_SHADER_VARIABLE_TYPE)60)
+#define D3D_SVT_INT64   ((D3D_SHADER_VARIABLE_TYPE)61)
+#define D3D_SVT_UINT64  ((D3D_SHADER_VARIABLE_TYPE)62)
+#endif // ADD_16_64_BIT_TYPES
+
+LPCSTR ToString(D3D_SHADER_VARIABLE_TYPE Type) {
+  switch (Type) {
+  case D3D_SVT_VOID: return "D3D_SVT_VOID";
+  case D3D_SVT_BOOL: return "D3D_SVT_BOOL";
+  case D3D_SVT_INT: return "D3D_SVT_INT";
+  case D3D_SVT_FLOAT: return "D3D_SVT_FLOAT";
+  case D3D_SVT_STRING: return "D3D_SVT_STRING";
+  case D3D_SVT_TEXTURE: return "D3D_SVT_TEXTURE";
+  case D3D_SVT_TEXTURE1D: return "D3D_SVT_TEXTURE1D";
+  case D3D_SVT_TEXTURE2D: return "D3D_SVT_TEXTURE2D";
+  case D3D_SVT_TEXTURE3D: return "D3D_SVT_TEXTURE3D";
+  case D3D_SVT_TEXTURECUBE: return "D3D_SVT_TEXTURECUBE";
+  case D3D_SVT_SAMPLER: return "D3D_SVT_SAMPLER";
+  case D3D_SVT_SAMPLER1D: return "D3D_SVT_SAMPLER1D";
+  case D3D_SVT_SAMPLER2D: return "D3D_SVT_SAMPLER2D";
+  case D3D_SVT_SAMPLER3D: return "D3D_SVT_SAMPLER3D";
+  case D3D_SVT_SAMPLERCUBE: return "D3D_SVT_SAMPLERCUBE";
+  case D3D_SVT_PIXELSHADER: return "D3D_SVT_PIXELSHADER";
+  case D3D_SVT_VERTEXSHADER: return "D3D_SVT_VERTEXSHADER";
+  case D3D_SVT_PIXELFRAGMENT: return "D3D_SVT_PIXELFRAGMENT";
+  case D3D_SVT_VERTEXFRAGMENT: return "D3D_SVT_VERTEXFRAGMENT";
+  case D3D_SVT_UINT: return "D3D_SVT_UINT";
+  case D3D_SVT_UINT8: return "D3D_SVT_UINT8";
+  case D3D_SVT_GEOMETRYSHADER: return "D3D_SVT_GEOMETRYSHADER";
+  case D3D_SVT_RASTERIZER: return "D3D_SVT_RASTERIZER";
+  case D3D_SVT_DEPTHSTENCIL: return "D3D_SVT_DEPTHSTENCIL";
+  case D3D_SVT_BLEND: return "D3D_SVT_BLEND";
+  case D3D_SVT_BUFFER: return "D3D_SVT_BUFFER";
+  case D3D_SVT_CBUFFER: return "D3D_SVT_CBUFFER";
+  case D3D_SVT_TBUFFER: return "D3D_SVT_TBUFFER";
+  case D3D_SVT_TEXTURE1DARRAY: return "D3D_SVT_TEXTURE1DARRAY";
+  case D3D_SVT_TEXTURE2DARRAY: return "D3D_SVT_TEXTURE2DARRAY";
+  case D3D_SVT_RENDERTARGETVIEW: return "D3D_SVT_RENDERTARGETVIEW";
+  case D3D_SVT_DEPTHSTENCILVIEW: return "D3D_SVT_DEPTHSTENCILVIEW";
+  case D3D_SVT_TEXTURE2DMS: return "D3D_SVT_TEXTURE2DMS";
+  case D3D_SVT_TEXTURE2DMSARRAY: return "D3D_SVT_TEXTURE2DMSARRAY";
+  case D3D_SVT_TEXTURECUBEARRAY: return "D3D_SVT_TEXTURECUBEARRAY";
+  case D3D_SVT_HULLSHADER: return "D3D_SVT_HULLSHADER";
+  case D3D_SVT_DOMAINSHADER: return "D3D_SVT_DOMAINSHADER";
+  case D3D_SVT_INTERFACE_POINTER: return "D3D_SVT_INTERFACE_POINTER";
+  case D3D_SVT_COMPUTESHADER: return "D3D_SVT_COMPUTESHADER";
+  case D3D_SVT_DOUBLE: return "D3D_SVT_DOUBLE";
+  case D3D_SVT_RWTEXTURE1D: return "D3D_SVT_RWTEXTURE1D";
+  case D3D_SVT_RWTEXTURE1DARRAY: return "D3D_SVT_RWTEXTURE1DARRAY";
+  case D3D_SVT_RWTEXTURE2D: return "D3D_SVT_RWTEXTURE2D";
+  case D3D_SVT_RWTEXTURE2DARRAY: return "D3D_SVT_RWTEXTURE2DARRAY";
+  case D3D_SVT_RWTEXTURE3D: return "D3D_SVT_RWTEXTURE3D";
+  case D3D_SVT_RWBUFFER: return "D3D_SVT_RWBUFFER";
+  case D3D_SVT_BYTEADDRESS_BUFFER: return "D3D_SVT_BYTEADDRESS_BUFFER";
+  case D3D_SVT_RWBYTEADDRESS_BUFFER: return "D3D_SVT_RWBYTEADDRESS_BUFFER";
+  case D3D_SVT_STRUCTURED_BUFFER: return "D3D_SVT_STRUCTURED_BUFFER";
+  case D3D_SVT_RWSTRUCTURED_BUFFER: return "D3D_SVT_RWSTRUCTURED_BUFFER";
+  case D3D_SVT_APPEND_STRUCTURED_BUFFER: return "D3D_SVT_APPEND_STRUCTURED_BUFFER";
+  case D3D_SVT_CONSUME_STRUCTURED_BUFFER: return "D3D_SVT_CONSUME_STRUCTURED_BUFFER";
+  case D3D_SVT_MIN8FLOAT: return "D3D_SVT_MIN8FLOAT";
+  case D3D_SVT_MIN10FLOAT: return "D3D_SVT_MIN10FLOAT";
+  case D3D_SVT_MIN16FLOAT: return "D3D_SVT_MIN16FLOAT";
+  case D3D_SVT_MIN12INT: return "D3D_SVT_MIN12INT";
+  case D3D_SVT_MIN16INT: return "D3D_SVT_MIN16INT";
+  case D3D_SVT_MIN16UINT: return "D3D_SVT_MIN16UINT";
+  case D3D_SVT_INT16: return "D3D_SVT_INT16";
+  case D3D_SVT_UINT16: return "D3D_SVT_UINT16";
+  case D3D_SVT_FLOAT16: return "D3D_SVT_FLOAT16";
+  case D3D_SVT_INT64: return "D3D_SVT_INT64";
+  case D3D_SVT_UINT64: return "D3D_SVT_UINT64";
+  default: return nullptr;
+  }
+}
+
+LPCSTR ToString(D3D_SHADER_VARIABLE_FLAGS Flag) {
+  switch (Flag) {
+  case D3D_SVF_USERPACKED: return "D3D_SVF_USERPACKED";
+  case D3D_SVF_USED: return "D3D_SVF_USED";
+  case D3D_SVF_INTERFACE_POINTER: return "D3D_SVF_INTERFACE_POINTER";
+  case D3D_SVF_INTERFACE_PARAMETER: return "D3D_SVF_INTERFACE_PARAMETER";
+  }
+  return nullptr;
+}
+
+LPCSTR ToString(D3D_SHADER_INPUT_FLAGS Flag) {
+  switch (Flag) {
+  case D3D_SIF_USERPACKED: return "D3D_SIF_USERPACKED";
+  case D3D_SIF_COMPARISON_SAMPLER: return "D3D_SIF_COMPARISON_SAMPLER";
+  case D3D_SIF_TEXTURE_COMPONENT_0: return "D3D_SIF_TEXTURE_COMPONENT_0";
+  case D3D_SIF_TEXTURE_COMPONENT_1: return "D3D_SIF_TEXTURE_COMPONENT_1";
+  case D3D_SIF_TEXTURE_COMPONENTS: return "D3D_SIF_TEXTURE_COMPONENTS";
+  case D3D_SIF_UNUSED: return "D3D_SIF_UNUSED";
+  }
+  return nullptr;
+}
+
+LPCSTR ToString(D3D_SHADER_CBUFFER_FLAGS Flag) {
+  switch (Flag) {
+  case D3D_CBF_USERPACKED: return "D3D_CBF_USERPACKED";
+  }
+  return nullptr;
+}
+
+LPCSTR ToString(D3D_PARAMETER_FLAGS Flag) {
+  switch (Flag) {
+  case D3D_PF_IN: return "D3D_PF_IN";
+  case D3D_PF_OUT: return "D3D_PF_OUT";
+  }
+  return nullptr;
+}
+
+#ifndef D3D_NAME_SHADINGRATE
+#define D3D_NAME_SHADINGRATE ((D3D_NAME)hlsl::DxilProgramSigSemantic::ShadingRate)
+#endif
+#ifndef D3D_NAME_CULLPRIMITIVE
+#define D3D_NAME_CULLPRIMITIVE ((D3D_NAME)hlsl::DxilProgramSigSemantic::CullPrimitive)
+#endif
+
+LPCSTR ToString(D3D_NAME Name) {
+  switch (Name) {
+  case D3D_NAME_UNDEFINED: return "D3D_NAME_UNDEFINED";
+  case D3D_NAME_POSITION: return "D3D_NAME_POSITION";
+  case D3D_NAME_CLIP_DISTANCE: return "D3D_NAME_CLIP_DISTANCE";
+  case D3D_NAME_CULL_DISTANCE: return "D3D_NAME_CULL_DISTANCE";
+  case D3D_NAME_RENDER_TARGET_ARRAY_INDEX: return "D3D_NAME_RENDER_TARGET_ARRAY_INDEX";
+  case D3D_NAME_VIEWPORT_ARRAY_INDEX: return "D3D_NAME_VIEWPORT_ARRAY_INDEX";
+  case D3D_NAME_VERTEX_ID: return "D3D_NAME_VERTEX_ID";
+  case D3D_NAME_PRIMITIVE_ID: return "D3D_NAME_PRIMITIVE_ID";
+  case D3D_NAME_INSTANCE_ID: return "D3D_NAME_INSTANCE_ID";
+  case D3D_NAME_IS_FRONT_FACE: return "D3D_NAME_IS_FRONT_FACE";
+  case D3D_NAME_SAMPLE_INDEX: return "D3D_NAME_SAMPLE_INDEX";
+  case D3D_NAME_FINAL_QUAD_EDGE_TESSFACTOR: return "D3D_NAME_FINAL_QUAD_EDGE_TESSFACTOR";
+  case D3D_NAME_FINAL_QUAD_INSIDE_TESSFACTOR: return "D3D_NAME_FINAL_QUAD_INSIDE_TESSFACTOR";
+  case D3D_NAME_FINAL_TRI_EDGE_TESSFACTOR: return "D3D_NAME_FINAL_TRI_EDGE_TESSFACTOR";
+  case D3D_NAME_FINAL_TRI_INSIDE_TESSFACTOR: return "D3D_NAME_FINAL_TRI_INSIDE_TESSFACTOR";
+  case D3D_NAME_FINAL_LINE_DETAIL_TESSFACTOR: return "D3D_NAME_FINAL_LINE_DETAIL_TESSFACTOR";
+  case D3D_NAME_FINAL_LINE_DENSITY_TESSFACTOR: return "D3D_NAME_FINAL_LINE_DENSITY_TESSFACTOR";
+  case D3D_NAME_BARYCENTRICS: return "D3D_NAME_BARYCENTRICS";
+  case D3D_NAME_TARGET: return "D3D_NAME_TARGET";
+  case D3D_NAME_DEPTH: return "D3D_NAME_DEPTH";
+  case D3D_NAME_COVERAGE: return "D3D_NAME_COVERAGE";
+  case D3D_NAME_DEPTH_GREATER_EQUAL: return "D3D_NAME_DEPTH_GREATER_EQUAL";
+  case D3D_NAME_DEPTH_LESS_EQUAL: return "D3D_NAME_DEPTH_LESS_EQUAL";
+  case D3D_NAME_STENCIL_REF: return "D3D_NAME_STENCIL_REF";
+  case D3D_NAME_INNER_COVERAGE: return "D3D_NAME_INNER_COVERAGE";
+  case D3D_NAME_SHADINGRATE: return "D3D_NAME_SHADINGRATE";
+  case D3D_NAME_CULLPRIMITIVE: return "D3D_NAME_CULLPRIMITIVE";
+  }
+  return nullptr;
+}
+
+LPCSTR ToString(D3D_REGISTER_COMPONENT_TYPE CompTy) {
+  switch (CompTy) {
+  case D3D_REGISTER_COMPONENT_UNKNOWN: return "D3D_REGISTER_COMPONENT_UNKNOWN";
+  case D3D_REGISTER_COMPONENT_UINT32: return "D3D_REGISTER_COMPONENT_UINT32";
+  case D3D_REGISTER_COMPONENT_SINT32: return "D3D_REGISTER_COMPONENT_SINT32";
+  case D3D_REGISTER_COMPONENT_FLOAT32: return "D3D_REGISTER_COMPONENT_FLOAT32";
+  }
+  return nullptr;
+}
+
+LPCSTR ToString(D3D_MIN_PRECISION MinPrec) {
+  switch (MinPrec) {
+  case D3D_MIN_PRECISION_DEFAULT: return "D3D_MIN_PRECISION_DEFAULT";
+  case D3D_MIN_PRECISION_FLOAT_16: return "D3D_MIN_PRECISION_FLOAT_16";
+  case D3D_MIN_PRECISION_FLOAT_2_8: return "D3D_MIN_PRECISION_FLOAT_2_8";
+  case D3D_MIN_PRECISION_RESERVED: return "D3D_MIN_PRECISION_RESERVED";
+  case D3D_MIN_PRECISION_SINT_16: return "D3D_MIN_PRECISION_SINT_16";
+  case D3D_MIN_PRECISION_UINT_16: return "D3D_MIN_PRECISION_UINT_16";
+  case D3D_MIN_PRECISION_ANY_16: return "D3D_MIN_PRECISION_ANY_16";
+  case D3D_MIN_PRECISION_ANY_10: return "D3D_MIN_PRECISION_ANY_10";
+  }
+  return nullptr;
+}
+
+
+LPCSTR CompMaskToString(unsigned CompMask) {
+  static const LPCSTR masks[16] = {
+    "----",
+    "x---",
+    "-y--",
+    "xy--",
+    "--z-",
+    "x-z-",
+    "-yz-",
+    "xyz-",
+    "---w",
+    "x--w",
+    "-y-w",
+    "xy-w",
+    "--zw",
+    "x-zw",
+    "-yzw",
+    "xyzw"
+  };
+  if (CompMask < 16) {
+    return masks[CompMask];
+  }
+  return "<invalid mask>";
+}
+
+// These macros define the implementation of the DXC ToString functions
+#define DEF_RDAT_ENUMS DEF_RDAT_DUMP_IMPL
+#define DEF_DXIL_ENUMS DEF_RDAT_DUMP_IMPL
+#include "dxc/DxilContainer/RDAT_Macros.inl"
+
+
+} // namespace dump
+} // namespace hlsl

+ 2 - 18
tools/clang/unittests/HLSLTestLib/FileCheckerTest.cpp

@@ -37,19 +37,17 @@
 #include "dxc/Support/Global.h"
 #include "dxc/Support/dxcapi.use.h"
 #include "dxc/dxctools.h"
+#include "dxc/Support/D3DReflection.h"
 #include "dxc/Support/HLSLOptions.h"
 #include "dxc/Support/Unicode.h"
 #include "dxc/Support/microcom.h"
 #include "dxc/DxilContainer/DxilContainer.h"
 
-#ifdef _WIN32 // Reflection unsupported
 #include "dxc/Test/D3DReflectionDumper.h"
 #include "dxc/DxilContainer/DxilRuntimeReflection.h"
 #include "dxc/Test/RDATDumper.h"
 
-#include "d3d12shader.h"
 using namespace hlsl::dump;
-#endif // WIN32 - Reflection unsupported
 
 using namespace std;
 using namespace hlsl_test;
@@ -108,22 +106,10 @@ FileRunCommandResult FileRunCommandPart::Run(dxc::DxcDllSupport &DllSupport, con
     return RunOpt(DllSupport, Prior);
   }
   else if (0 == _stricmp(Command.c_str(), "%listparts")) {
-#ifdef _WIN32 // Reflection unsupported
     return RunListParts(DllSupport, Prior);
-#else
-    FileRunCommandResult result = FileRunCommandResult::Success("Can't run listparts on non-windows, so just assuming success");
-    result.AbortPipeline = true;
-    return result;
-#endif // WIN32 - Reflection unsupported
   }
   else if (0 == _stricmp(Command.c_str(), "%D3DReflect")) {
-#ifdef _WIN32 // Reflection unsupported
     return RunD3DReflect(DllSupport, Prior);
-#else
-    FileRunCommandResult result = FileRunCommandResult::Success("Can't run D3DReflect on non-windows, so just assuming success");
-    result.AbortPipeline = true;
-    return result;
-#endif // WIN32 - Reflection unsupported
   }
   else if (0 == _stricmp(Command.c_str(), "%dxr")) {
     return RunDxr(DllSupport, Prior);
@@ -666,7 +652,6 @@ FileRunCommandResult FileRunCommandPart::RunOpt(dxc::DxcDllSupport &DllSupport,
   return FileRunCommandResult::Success(BlobToUtf8(pOutputText));
 }
 
-#ifdef _WIN32 // Reflection unsupported
 FileRunCommandResult FileRunCommandPart::RunListParts(dxc::DxcDllSupport &DllSupport, const FileRunCommandResult *Prior) {
   std::string args(strtrim(Arguments));
   const char *inputPos = strstr(args.c_str(), "%s");
@@ -757,7 +742,7 @@ FileRunCommandResult FileRunCommandPart::RunD3DReflect(dxc::DxcDllSupport &DllSu
   IFT(DllSupport.CreateInstance(CLSID_DxcAssembler, &pAssembler));
 
   IFT(pLibrary->CreateBlobWithEncodingFromPinned(
-      (LPBYTE)Prior->StdOut.c_str(), Prior->StdOut.size(), CP_UTF8,
+      (LPCVOID)Prior->StdOut.c_str(), Prior->StdOut.size(), CP_UTF8,
       &pSource));
 
   IFT(pAssembler->AssembleToContainer(pSource, &pResult));
@@ -811,7 +796,6 @@ FileRunCommandResult FileRunCommandPart::RunD3DReflect(dxc::DxcDllSupport &DllSu
 
   return FileRunCommandResult::Success(ss.str());
 }
-#endif // _WIN32 - Reflection unsupported
 
 FileRunCommandResult FileRunCommandPart::RunDxr(dxc::DxcDllSupport &DllSupport, const FileRunCommandResult *Prior) {
   // Support piping stdin from prior if needed.

+ 0 - 2
tools/clang/unittests/HLSLTestLib/RDATDumper.cpp

@@ -179,8 +179,6 @@ void DumpValueArray(DumpContext &d, const char *memberName,
 }
 
 #define DEF_RDAT_TYPES DEF_RDAT_DUMP_IMPL
-#define DEF_RDAT_ENUMS DEF_RDAT_DUMP_IMPL
-#define DEF_DXIL_ENUMS DEF_RDAT_DUMP_IMPL
 #include "dxc/DxilContainer/RDAT_Macros.inl"
 
 } // namespace dump