File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33// Metal libraries are LLVM bitcode. This check inspects the magic number from
44// the metal library output.
5- // RUN: %dxc %S/Inputs/smoke.hlsl /T ps_6_0 -metal -Fo Tmp.metal
5+ // RUN: %dxc %S/Inputs/smoke.hlsl /T ps_6_0 -metal -Fo Tmp.metal -Fre Tmp.json
66// RUN: head -c 4 Tmp.metal | FileCheck -check-prefix=MTL %s
77// MTL: {{^MTLB}}
8+
9+ // RUN: cat Tmp.json | FileCheck --check-prefix=FRE %s
10+ // FRE: "EntryPoint":"main"
Original file line number Diff line number Diff line change @@ -1085,7 +1085,10 @@ class DxcCompiler : public IDxcCompiler3,
10851085 }
10861086 }
10871087
1088- if (pReflectionStream && pReflectionStream->GetPtrSize ()) {
1088+ // Skip reflection generation here when targeting metal, this is
1089+ // handled below.
1090+ if (!opts.GenMetal && pReflectionStream &&
1091+ pReflectionStream->GetPtrSize ()) {
10891092 CComPtr<IDxcBlob> pReflection;
10901093 IFT (pReflectionStream->QueryInterface (&pReflection));
10911094 IFT (pResult->SetOutputObject (DXC_OUT_REFLECTION, pReflection));
@@ -1173,6 +1176,16 @@ class DxcCompiler : public IDxcCompiler3,
11731176 std::unique_ptr<uint8_t []>(new uint8_t [MetalLibSize]);
11741177 IRMetalLibGetBytecode (MetalLib, MetalLibBytes.get ());
11751178
1179+ if (!opts.OutputReflectionFile .empty ()) {
1180+ IRShaderReflection *Reflection = IRShaderReflectionCreate ();
1181+ IRObjectGetReflection (AIR, Stage, Reflection);
1182+ const char *RawJSON =
1183+ IRShaderReflectionCopyJSONString (Reflection);
1184+ IFT (pResult->SetOutputString (DXC_OUT_REFLECTION, RawJSON,
1185+ strlen (RawJSON)));
1186+ IRShaderReflectionDestroy (Reflection);
1187+ }
1188+
11761189 // Store the metallib to custom format or disk, or use to create a
11771190 // MTLLibrary.
11781191
You can’t perform that action at this time.
0 commit comments