Skip to content

Commit

Permalink
Merge pull request #1 from microsoft/master
Browse files Browse the repository at this point in the history
Fix outputs -Fre, -Fsh, -Frs, and -Fc with -Fh (microsoft#2716)
  • Loading branch information
Darkstep79 authored Feb 25, 2020
2 parents eb33030 + 367dd44 commit 1a9c662
Show file tree
Hide file tree
Showing 5 changed files with 554 additions and 783 deletions.
2 changes: 1 addition & 1 deletion include/dxc/Support/dxcapi.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ struct DxcOutputObject {
}
HRESULT SetName(_In_opt_z_ llvm::StringRef Name) {
DXASSERT_NOMSG(!name);
if (!Name.empty())
if (Name.empty())
return S_OK;
CComPtr<IDxcBlobEncoding> pBlobEncoding;
IFR(TranslateUtf8StringForOutput(Name.data(), Name.size(), DXC_CP_UTF16, &pBlobEncoding));
Expand Down
11 changes: 9 additions & 2 deletions tools/clang/tools/dxclib/dxc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,22 @@ int DxcContext::ActOnBlob(IDxcBlob *pBlob, IDxcBlob *pDebugBlob, LPCWSTR pDebugB
#endif // ENABLE_SPIRV_CODEGEN
// SPIRV Change Ends

bool disassemblyWritten = false;
if (!m_Opts.OutputHeader.empty()) {
llvm::Twine varName = m_Opts.VariableName.empty()
? llvm::Twine("g_", m_Opts.EntryPoint)
: m_Opts.VariableName;
WriteHeader(pDisassembleResult, pBlob, varName,
StringRefUtf16(m_Opts.OutputHeader));
} else if (!m_Opts.AssemblyCode.empty()) {
disassemblyWritten = true;
}

if (!m_Opts.AssemblyCode.empty()) {
WriteBlobToFile(pDisassembleResult, m_Opts.AssemblyCode, m_Opts.DefaultTextCodePage);
} else {
disassemblyWritten = true;
}

if (!disassemblyWritten) {
WriteBlobToConsole(pDisassembleResult);
}
return retVal;
Expand Down
45 changes: 24 additions & 21 deletions tools/clang/tools/dxcompiler/dxcompilerobj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -787,11 +787,9 @@ class DxcCompiler : public IDxcCompiler3,
if (!opts.StripReflection) {
SerializeFlags |= SerializeDxilFlags::IncludeReflectionPart;
}
// StripRootSignature disabled on Xbox for now since
// API wrappers rely on embedded root signature instead of separate output.
//if (opts.StripRootSignature) {
// SerializeFlags |= SerializeDxilFlags::StripRootSignature;
//}
if (opts.StripRootSignature) {
SerializeFlags |= SerializeDxilFlags::StripRootSignature;
}

// Don't do work to put in a container if an error has occurred
// Do not create a container when there is only a a high-level representation in the module.
Expand All @@ -800,6 +798,7 @@ class DxcCompiler : public IDxcCompiler3,
CComPtr<AbstractMemoryStream> pReflectionStream;
CComPtr<AbstractMemoryStream> pRootSigStream;
IFT(CreateMemoryStream(DxcGetThreadMallocNoRef(), &pReflectionStream));
IFT(CreateMemoryStream(DxcGetThreadMallocNoRef(), &pRootSigStream));

dxcutil::AssembleInputs inputs(
action.takeModule(), pOutputBlob, m_pMalloc, SerializeFlags,
Expand All @@ -811,16 +810,6 @@ class DxcCompiler : public IDxcCompiler3,
} else {
dxcutil::AssembleToContainer(inputs);
}
if (pReflectionStream && pReflectionStream->GetPtrSize()) {
CComPtr<IDxcBlob> pReflection;
IFT(pReflectionStream->QueryInterface(&pReflection));
IFT(pResult->SetOutputObject(DXC_OUT_REFLECTION, pReflection));
}
if (pRootSigStream && pRootSigStream->GetPtrSize()) {
CComPtr<IDxcBlob> pRootSignature;
IFT(pRootSigStream->QueryInterface(&pRootSignature));
IFT(pResult->SetOutputObject(DXC_OUT_ROOT_SIGNATURE, pRootSignature));
}

// Callback after valid DXIL is produced
if (SUCCEEDED(valHR)) {
Expand All @@ -843,13 +832,27 @@ class DxcCompiler : public IDxcCompiler3,
}
}
}
}

// Always make hash blob for output
CComPtr<IDxcBlob> pHashBlob;
IFT(hlsl::DxcCreateBlobOnHeapCopy(&ShaderHashContent, (UINT32)sizeof(ShaderHashContent), &pHashBlob));
IFT(pResult->SetOutputObject(DXC_OUT_SHADER_HASH, pHashBlob));
}
if (pReflectionStream && pReflectionStream->GetPtrSize()) {
CComPtr<IDxcBlob> pReflection;
IFT(pReflectionStream->QueryInterface(&pReflection));
IFT(pResult->SetOutputObject(DXC_OUT_REFLECTION, pReflection));
}
if (pRootSigStream && pRootSigStream->GetPtrSize()) {
CComPtr<IDxcBlob> pRootSignature;
IFT(pRootSigStream->QueryInterface(&pRootSignature));
if (needsValidation) {
CComPtr<IDxcBlobEncoding> pValErrors;
// Validation failure communicated through diagnostic error
dxcutil::ValidateRootSignatureInContainer(pRootSignature, &compiler.getDiagnostics());
}
IFT(pResult->SetOutputObject(DXC_OUT_ROOT_SIGNATURE, pRootSignature));
}
CComPtr<IDxcBlob> pHashBlob;
IFT(hlsl::DxcCreateBlobOnHeapCopy(&ShaderHashContent, (UINT32)sizeof(ShaderHashContent), &pHashBlob));
IFT(pResult->SetOutputObject(DXC_OUT_SHADER_HASH, pHashBlob));
} // SUCCEEDED(valHR)
} // compileOK && !opts.CodeGenHighLevel
}

// Add std err to warnings.
Expand Down
2 changes: 2 additions & 0 deletions utils/hct/cmdtestfiles/smoke.hlsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
int g;
static int g_unused;

#ifndef semantic
#define semantic SV_Target
#endif
Expand Down
Loading

0 comments on commit 1a9c662

Please sign in to comment.