diff --git a/tools/clang/test/DXC/metal.test b/tools/clang/test/DXC/metal.test index 3d00850abc..10f8eec384 100644 --- a/tools/clang/test/DXC/metal.test +++ b/tools/clang/test/DXC/metal.test @@ -2,6 +2,9 @@ // Metal libraries are LLVM bitcode. This check inspects the magic number from // the metal library output. -// RUN: %dxc %S/Inputs/smoke.hlsl /T ps_6_0 -metal -Fo Tmp.metal +// RUN: %dxc %S/Inputs/smoke.hlsl /T ps_6_0 -metal -Fo Tmp.metal -Fre Tmp.json // RUN: head -c 4 Tmp.metal | FileCheck -check-prefix=MTL %s // MTL: {{^MTLB}} + +// RUN: cat Tmp.json | FileCheck --check-prefix=FRE %s +// FRE: "EntryPoint":"main" diff --git a/tools/clang/tools/dxcompiler/dxcompilerobj.cpp b/tools/clang/tools/dxcompiler/dxcompilerobj.cpp index 230047b4a8..261ff85249 100644 --- a/tools/clang/tools/dxcompiler/dxcompilerobj.cpp +++ b/tools/clang/tools/dxcompiler/dxcompilerobj.cpp @@ -1173,6 +1173,16 @@ class DxcCompiler : public IDxcCompiler3, std::unique_ptr(new uint8_t[MetalLibSize]); IRMetalLibGetBytecode(MetalLib, MetalLibBytes.get()); + if (!opts.OutputReflectionFile.empty()) { + IRShaderReflection *Reflection = IRShaderReflectionCreate(); + IRObjectGetReflection(AIR, Stage, Reflection); + const char *RawJSON = + IRShaderReflectionCopyJSONString(Reflection); + IFT(pResult->SetOutputString(DXC_OUT_REFLECTION, RawJSON, + strlen(RawJSON))); + IRShaderReflectionDestroy(Reflection); + } + // Store the metallib to custom format or disk, or use to create a // MTLLibrary.