Support -T rootsig_1_0/rootsig_1_1. (#112)
This commit is contained in:
Родитель
cc4387b7ae
Коммит
38586597b9
|
@ -395,6 +395,9 @@ DxilContainerWriter *NewDxilContainerWriter();
|
|||
void SerializeDxilContainerForModule(hlsl::DxilModule *pModule,
|
||||
AbstractMemoryStream *pModuleBitcode,
|
||||
AbstractMemoryStream *pStream);
|
||||
void SerializeDxilContainerForRootSignature(hlsl::RootSignatureHandle *pRootSigHandle,
|
||||
AbstractMemoryStream *pStream);
|
||||
|
||||
void CreateDxcContainerReflection(IDxcContainerReflection **ppResult);
|
||||
|
||||
// Converts uint32_t partKind to char array object.
|
||||
|
|
|
@ -145,6 +145,7 @@ public:
|
|||
bool DisassembleInstNumbers; //OPT_Ni
|
||||
bool DisassembleByteOffset; //OPT_No
|
||||
bool DisaseembleHex; //OPT_Lx
|
||||
bool IsRootSignatureProfile();
|
||||
};
|
||||
|
||||
/// Use this class to capture, convert and handle the lifetime for the
|
||||
|
|
|
@ -113,6 +113,11 @@ void DxcDefines::BuildDefines() {
|
|||
}
|
||||
}
|
||||
|
||||
bool DxcOpts::IsRootSignatureProfile() {
|
||||
return TargetProfile == "rootsig_1_0" ||
|
||||
TargetProfile == "rootsig_1_1";
|
||||
}
|
||||
|
||||
MainArgs::MainArgs(int argc, const wchar_t **argv, int skipArgCount) {
|
||||
if (argc > skipArgCount) {
|
||||
Utf8StringVector.reserve(argc - skipArgCount);
|
||||
|
|
|
@ -703,3 +703,18 @@ void hlsl::SerializeDxilContainerForModule(DxilModule *pModule,
|
|||
|
||||
writer.write(pFinalStream);
|
||||
}
|
||||
|
||||
void hlsl::SerializeDxilContainerForRootSignature(hlsl::RootSignatureHandle *pRootSigHandle,
|
||||
AbstractMemoryStream *pFinalStream) {
|
||||
DXASSERT_NOMSG(pRootSigHandle != nullptr);
|
||||
DXASSERT_NOMSG(pFinalStream != nullptr);
|
||||
DxilContainerWriter_impl writer;
|
||||
// Write the root signature (RTS0) part.
|
||||
DxilProgramRootSignatureWriter rootSigWriter(*pRootSigHandle);
|
||||
if (!pRootSigHandle->IsEmpty()) {
|
||||
writer.AddPart(
|
||||
DFCC_RootSignature, rootSigWriter.size(),
|
||||
[&](AbstractMemoryStream *pStream) { rootSigWriter.write(pStream); });
|
||||
}
|
||||
writer.write(pFinalStream);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,12 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// HLSL Change Begin.
|
||||
namespace hlsl {
|
||||
class RootSignatureHandle;
|
||||
}
|
||||
// HLSL Change End.
|
||||
|
||||
namespace clang {
|
||||
|
||||
class Module;
|
||||
|
@ -235,6 +241,26 @@ protected:
|
|||
|
||||
bool hasPCHSupport() const override { return true; }
|
||||
};
|
||||
|
||||
// HLSL Change Begin.
|
||||
class HLSLRootSignatureAction : public PreprocessorFrontendAction {
|
||||
private:
|
||||
std::string HLSLRootSignatureMacro;
|
||||
unsigned rootSigMajor;
|
||||
unsigned rootSigMinor;
|
||||
std::unique_ptr<hlsl::RootSignatureHandle> rootSigHandle;
|
||||
|
||||
protected:
|
||||
void ExecuteAction() override;
|
||||
|
||||
public:
|
||||
HLSLRootSignatureAction(StringRef rootSigMacro, unsigned major,
|
||||
unsigned minor);
|
||||
/// Take the generated LLVM module, for use after the action has been run.
|
||||
/// The result may be null on failure.
|
||||
std::unique_ptr<hlsl::RootSignatureHandle> takeRootSigHandle();
|
||||
};
|
||||
// HLSL Change End.
|
||||
|
||||
} // end namespace clang
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ class raw_ostream;
|
|||
namespace hlsl {
|
||||
enum class DxilRootSignatureVersion;
|
||||
struct DxilVersionedRootSignatureDesc;
|
||||
class RootSignatureHandle;
|
||||
}
|
||||
|
||||
namespace clang {
|
||||
|
@ -33,6 +34,10 @@ bool ParseHLSLRootSignature(_In_count_(Len) const char *pData, unsigned Len,
|
|||
void ReportHLSLRootSigError(clang::DiagnosticsEngine &Diags,
|
||||
clang::SourceLocation Loc,
|
||||
_In_count_(Len) const char *pData, unsigned Len);
|
||||
void CompileRootSignature(StringRef rootSigStr, DiagnosticsEngine &Diags,
|
||||
SourceLocation SLoc,
|
||||
hlsl::DxilRootSignatureVersion rootSigVer,
|
||||
hlsl::RootSignatureHandle *pRootSigHandle);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -261,6 +261,30 @@ public:
|
|||
};
|
||||
}
|
||||
|
||||
void clang::CompileRootSignature(
|
||||
StringRef rootSigStr, DiagnosticsEngine &Diags, SourceLocation SLoc,
|
||||
hlsl::DxilRootSignatureVersion rootSigVer,
|
||||
hlsl::RootSignatureHandle *pRootSigHandle) {
|
||||
std::string OSStr;
|
||||
llvm::raw_string_ostream OS(OSStr);
|
||||
hlsl::DxilVersionedRootSignatureDesc *D = nullptr;
|
||||
|
||||
if (ParseHLSLRootSignature(rootSigStr.data(), rootSigStr.size(), rootSigVer,
|
||||
&D, SLoc, Diags)) {
|
||||
CComPtr<IDxcBlob> pSignature;
|
||||
CComPtr<IDxcBlobEncoding> pErrors;
|
||||
hlsl::SerializeRootSignature(D, &pSignature, &pErrors, false);
|
||||
if (pSignature == nullptr) {
|
||||
assert(pErrors != nullptr && "else serialize failed with no msg");
|
||||
ReportHLSLRootSigError(Diags, SLoc, (char *)pErrors->GetBufferPointer(),
|
||||
pErrors->GetBufferSize());
|
||||
hlsl::DeleteRootSignature(D);
|
||||
} else {
|
||||
pRootSigHandle->Assign(D, pSignature);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// CGMSHLSLRuntime methods.
|
||||
|
@ -5206,24 +5230,8 @@ void CGMSHLSLRuntime::EmitHLSLRootSignature(CodeGenFunction &CGF,
|
|||
StringRef StrRef = RSA->getSignatureName();
|
||||
DiagnosticsEngine &Diags = CGF.getContext().getDiagnostics();
|
||||
SourceLocation SLoc = RSA->getLocation();
|
||||
std::string OSStr;
|
||||
raw_string_ostream OS(OSStr);
|
||||
hlsl::DxilVersionedRootSignatureDesc *D = nullptr;
|
||||
|
||||
if (ParseHLSLRootSignature(StrRef.data(), StrRef.size(), rootSigVer, &D, SLoc,
|
||||
Diags)) {
|
||||
CComPtr<IDxcBlob> pSignature;
|
||||
CComPtr<IDxcBlobEncoding> pErrors;
|
||||
hlsl::SerializeRootSignature(D, &pSignature, &pErrors, false);
|
||||
if (pSignature == nullptr) {
|
||||
DXASSERT(pErrors != nullptr, "else serialize failed with no msg");
|
||||
ReportHLSLRootSigError(Diags, SLoc,
|
||||
(char *)pErrors->GetBufferPointer(), pErrors->GetBufferSize());
|
||||
hlsl::DeleteRootSignature(D);
|
||||
} else {
|
||||
m_pHLModule->GetRootSignature().Assign(D, pSignature);
|
||||
}
|
||||
}
|
||||
clang::CompileRootSignature(StrRef, Diags, SLoc, rootSigVer, &m_pHLModule->GetRootSignature());
|
||||
}
|
||||
|
||||
void CGMSHLSLRuntime::EmitHLSLOutParamConversionInit(
|
||||
|
|
|
@ -27,7 +27,10 @@
|
|||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <memory>
|
||||
#include <system_error>
|
||||
|
||||
// HLSL Change Begin.
|
||||
#include "dxc/HLSL/DxilRootSignature.h"
|
||||
#include "clang/Parse/ParseHLSL.h"
|
||||
// HLSL Change End.
|
||||
using namespace clang;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -697,6 +700,94 @@ void PrintPreprocessedAction::ExecuteAction() {
|
|||
CI.getPreprocessorOutputOpts());
|
||||
}
|
||||
|
||||
// HLSL Change Begin.
|
||||
HLSLRootSignatureAction::HLSLRootSignatureAction(StringRef rootSigMacro,
|
||||
unsigned major, unsigned minor)
|
||||
: HLSLRootSignatureMacro(rootSigMacro), rootSigMajor(major),
|
||||
rootSigMinor(minor) {
|
||||
rootSigHandle = std::make_unique<hlsl::RootSignatureHandle>();
|
||||
}
|
||||
|
||||
void HLSLRootSignatureAction::ExecuteAction() {
|
||||
CompilerInstance &CI = getCompilerInstance();
|
||||
Preprocessor &PP = CI.getPreprocessor();
|
||||
// Ignore unknown pragmas.
|
||||
PP.IgnorePragmas();
|
||||
|
||||
// Scans and ignores all tokens in the files.
|
||||
PP.EnterMainSourceFile();
|
||||
|
||||
Token Tok;
|
||||
do PP.Lex(Tok);
|
||||
while (Tok.isNot(tok::eof));
|
||||
|
||||
hlsl::DxilRootSignatureVersion rootSigVer;
|
||||
if (rootSigMinor == 0) {
|
||||
rootSigVer = hlsl::DxilRootSignatureVersion::Version_1_0;
|
||||
}
|
||||
else {
|
||||
assert(rootSigMinor == 1 &&
|
||||
"else CGMSHLSLRuntime Constructor needs to be updated");
|
||||
rootSigVer = hlsl::DxilRootSignatureVersion::Version_1_1;
|
||||
}
|
||||
|
||||
assert(rootSigMajor == 1 &&
|
||||
"else CGMSHLSLRuntime Constructor needs to be updated");
|
||||
// Try to find HLSLRootSignatureMacro in macros.
|
||||
MacroInfo *rootSigMI = nullptr;
|
||||
for (Preprocessor::macro_iterator I = PP.macro_begin(), E = PP.macro_end();
|
||||
I != E; ++I) {
|
||||
auto *MD = I->second.getLatest();
|
||||
if (MD && MD->isDefined()) {
|
||||
if (I->first->getName() == HLSLRootSignatureMacro) {
|
||||
rootSigMI = MD->getMacroInfo();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DiagnosticsEngine &Diags = CI.getDiagnostics();
|
||||
if (!rootSigMI) {
|
||||
std::string cannotFindMacro =
|
||||
"undeclared identifier " + HLSLRootSignatureMacro;
|
||||
SourceLocation SLoc = Tok.getLocation();
|
||||
ReportHLSLRootSigError(Diags, SLoc, cannotFindMacro.c_str(),
|
||||
cannotFindMacro.size());
|
||||
return;
|
||||
}
|
||||
|
||||
SourceLocation SLoc = rootSigMI->getDefinitionLoc();
|
||||
|
||||
std::string rootSigStr;
|
||||
llvm::raw_string_ostream rootSigOS(rootSigStr);
|
||||
|
||||
SmallString<128> SpellingBuffer;
|
||||
for (const auto &T : rootSigMI->tokens()) {
|
||||
if (T.hasLeadingSpace())
|
||||
rootSigOS << ' ';
|
||||
|
||||
rootSigOS << PP.getSpelling(T, SpellingBuffer);
|
||||
}
|
||||
rootSigOS.flush();
|
||||
StringRef StrRef = rootSigStr;
|
||||
|
||||
// Remove the "" on rootsig macro.
|
||||
if (StrRef.size() >= 2) {
|
||||
if (rootSigStr.front() == '"') {
|
||||
if (rootSigStr.back() == '"') {
|
||||
StrRef = StrRef.substr(1, StrRef.size()-2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
clang::CompileRootSignature(StrRef, Diags, SLoc, rootSigVer, rootSigHandle.get());
|
||||
}
|
||||
|
||||
std::unique_ptr<hlsl::RootSignatureHandle> HLSLRootSignatureAction::takeRootSigHandle() {
|
||||
return std::move(rootSigHandle);
|
||||
}
|
||||
// HLSL Change End.
|
||||
|
||||
void PrintPreambleAction::ExecuteAction() {
|
||||
switch (getCurrentFileKind()) {
|
||||
case IK_C:
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
// RUN: %dxc -E main -T rootsig_1_0 %s
|
||||
|
||||
#define main "RootFlags(ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT), DescriptorTable( visibility=SHADER_VISIBILITY_PIXEL, SRV(t0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_PIXEL, CBV(b0, numDescriptors=8) ), DescriptorTable( visibility=SHADER_VISIBILITY_PIXEL, Sampler(s0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_VERTEX, SRV(t0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_VERTEX, CBV(b0, numDescriptors=8) ), DescriptorTable( visibility=SHADER_VISIBILITY_VERTEX, Sampler(s0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_GEOMETRY, SRV(t0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_GEOMETRY, CBV(b0, numDescriptors=8) ), DescriptorTable( visibility=SHADER_VISIBILITY_GEOMETRY, Sampler(s0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_HULL, SRV(t0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_HULL, CBV(b0, numDescriptors=8) ), DescriptorTable( visibility=SHADER_VISIBILITY_HULL, Sampler(s0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_DOMAIN, SRV(t0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_DOMAIN, CBV(b0, numDescriptors=8) ), DescriptorTable( visibility=SHADER_VISIBILITY_DOMAIN, Sampler(s0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_ALL, UAV(u0, numDescriptors=8) )"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
// RUN: %dxc -E main -T rootsig_1_0 /Dmain="SRV(t0)" %s
|
||||
|
||||
#define MyRS2 RootFlags(ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT), DescriptorTable( visibility=SHADER_VISIBILITY_PIXEL, SRV(t0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_PIXEL, CBV(b0, numDescriptors=8) ), DescriptorTable( visibility=SHADER_VISIBILITY_PIXEL, Sampler(s0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_VERTEX, SRV(t0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_VERTEX, CBV(b0, numDescriptors=8) ), DescriptorTable( visibility=SHADER_VISIBILITY_VERTEX, Sampler(s0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_GEOMETRY, SRV(t0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_GEOMETRY, CBV(b0, numDescriptors=8) ), DescriptorTable( visibility=SHADER_VISIBILITY_GEOMETRY, Sampler(s0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_HULL, SRV(t0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_HULL, CBV(b0, numDescriptors=8) ), DescriptorTable( visibility=SHADER_VISIBILITY_HULL, Sampler(s0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_DOMAIN, SRV(t0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_DOMAIN, CBV(b0, numDescriptors=8) ), DescriptorTable( visibility=SHADER_VISIBILITY_DOMAIN, Sampler(s0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_ALL, UAV(u0, numDescriptors=8) )
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
// RUN: %dxc -E main -T rootsig_1_0 %s | FileCheck %s
|
||||
|
||||
// CHECK: root signature error - undeclared identifier main
|
||||
|
||||
#define MyRS2 RootFlags(ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT), DescriptorTable( visibility=SHADER_VISIBILITY_PIXEL, SRV(t0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_PIXEL, CBV(b0, numDescriptors=8) ), DescriptorTable( visibility=SHADER_VISIBILITY_PIXEL, Sampler(s0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_VERTEX, SRV(t0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_VERTEX, CBV(b0, numDescriptors=8) ), DescriptorTable( visibility=SHADER_VISIBILITY_VERTEX, Sampler(s0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_GEOMETRY, SRV(t0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_GEOMETRY, CBV(b0, numDescriptors=8) ), DescriptorTable( visibility=SHADER_VISIBILITY_GEOMETRY, Sampler(s0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_HULL, SRV(t0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_HULL, CBV(b0, numDescriptors=8) ), DescriptorTable( visibility=SHADER_VISIBILITY_HULL, Sampler(s0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_DOMAIN, SRV(t0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_DOMAIN, CBV(b0, numDescriptors=8) ), DescriptorTable( visibility=SHADER_VISIBILITY_DOMAIN, Sampler(s0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_ALL, UAV(u0, numDescriptors=8) )
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
// RUN: %dxc -E main -T rootsig_1_0 /Dmain="SSRV(t0)" %s | FileCheck %s
|
||||
|
||||
// CHECK: root signature error - Unexpected token 'SSRV' when parsing root signature
|
||||
|
||||
#define MyRS2 RootFlags(ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT), DescriptorTable( visibility=SHADER_VISIBILITY_PIXEL, SRV(t0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_PIXEL, CBV(b0, numDescriptors=8) ), DescriptorTable( visibility=SHADER_VISIBILITY_PIXEL, Sampler(s0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_VERTEX, SRV(t0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_VERTEX, CBV(b0, numDescriptors=8) ), DescriptorTable( visibility=SHADER_VISIBILITY_VERTEX, Sampler(s0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_GEOMETRY, SRV(t0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_GEOMETRY, CBV(b0, numDescriptors=8) ), DescriptorTable( visibility=SHADER_VISIBILITY_GEOMETRY, Sampler(s0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_HULL, SRV(t0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_HULL, CBV(b0, numDescriptors=8) ), DescriptorTable( visibility=SHADER_VISIBILITY_HULL, Sampler(s0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_DOMAIN, SRV(t0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_DOMAIN, CBV(b0, numDescriptors=8) ), DescriptorTable( visibility=SHADER_VISIBILITY_DOMAIN, Sampler(s0, numDescriptors=16) ), DescriptorTable( visibility=SHADER_VISIBILITY_ALL, UAV(u0, numDescriptors=8) )
|
||||
|
|
@ -186,8 +186,10 @@ int DxcContext::ActOnBlob(IDxcBlob *pBlob) {
|
|||
m_Opts.ExtractPrivateFile.empty() &&
|
||||
m_Opts.VerifyRootSignatureSource.empty() && !m_Opts.ExtractRootSignature);
|
||||
|
||||
if (!needDisassembly)
|
||||
return retVal;
|
||||
bool isRootSigProfile = m_Opts.IsRootSignatureProfile();
|
||||
|
||||
if (!needDisassembly || isRootSigProfile)
|
||||
return retVal;
|
||||
|
||||
CComPtr<IDxcCompiler> pCompiler;
|
||||
IFT(m_dxcSupport.CreateInstance(CLSID_DxcCompiler, &pCompiler));
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "dxc/Support/WinIncludes.h" // For DxilPipelineStateValidation.h
|
||||
#include "dxc/HLSL/DxilPipelineStateValidation.h"
|
||||
#include "dxc/HLSL/HLSLExtensionsCodegenHelper.h"
|
||||
#include "dxc/HLSL/DxilRootSignature.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#if defined(_MSC_VER)
|
||||
|
@ -2037,6 +2038,16 @@ public:
|
|||
compiler.getCodeGenOpts().HLSLEntryFunction = pUtf8EntryPoint.m_psz;
|
||||
compiler.getCodeGenOpts().HLSLProfile = pUtf8TargetProfile.m_psz;
|
||||
|
||||
unsigned rootSigMajor = 0;
|
||||
unsigned rootSigMinor = 0;
|
||||
if (compiler.getCodeGenOpts().HLSLProfile == "rootsig_1_1") {
|
||||
rootSigMajor = 1;
|
||||
rootSigMinor = 1;
|
||||
} else if (compiler.getCodeGenOpts().HLSLProfile == "rootsig_1_0") {
|
||||
rootSigMajor = 1;
|
||||
rootSigMinor = 0;
|
||||
}
|
||||
|
||||
// NOTE: this calls the validation component from dxil.dll; the built-in
|
||||
// validator can be used as a fallback.
|
||||
bool needsValidation = !opts.CodeGenHighLevel && !opts.DisableValidation;
|
||||
|
@ -2081,6 +2092,29 @@ public:
|
|||
action.EndSourceFile();
|
||||
outStream.flush();
|
||||
}
|
||||
else if (rootSigMajor) {
|
||||
HLSLRootSignatureAction action(
|
||||
compiler.getCodeGenOpts().HLSLEntryFunction, rootSigMajor,
|
||||
rootSigMinor);
|
||||
FrontendInputFile file(utf8SourceName.m_psz, IK_HLSL);
|
||||
action.BeginSourceFile(compiler, file);
|
||||
action.Execute();
|
||||
action.EndSourceFile();
|
||||
outStream.flush();
|
||||
// Don't do work to put in a container if an error has occurred
|
||||
bool compileOK = !compiler.getDiagnostics().hasErrorOccurred();
|
||||
if (compileOK) {
|
||||
auto rootSigHandle = action.takeRootSigHandle();
|
||||
|
||||
CComPtr<AbstractMemoryStream> pContainerStream;
|
||||
IFT(CreateMemoryStream(pMalloc, &pContainerStream));
|
||||
SerializeDxilContainerForRootSignature(rootSigHandle.get(),
|
||||
pContainerStream);
|
||||
|
||||
pOutputBlob.Release();
|
||||
IFT(pContainerStream.QueryInterface(&pOutputBlob));
|
||||
}
|
||||
}
|
||||
else {
|
||||
llvm::LLVMContext llvmContext;
|
||||
EmitBCAction action(&llvmContext);
|
||||
|
|
|
@ -593,6 +593,10 @@ public:
|
|||
TEST_METHOD(CodeGenResPhi)
|
||||
TEST_METHOD(CodeGenResPhi2)
|
||||
TEST_METHOD(CodeGenRootSigEntry)
|
||||
TEST_METHOD(CodeGenRootSigProfile)
|
||||
TEST_METHOD(CodeGenRootSigProfile2)
|
||||
TEST_METHOD(CodeGenRootSigProfile3)
|
||||
TEST_METHOD(CodeGenRootSigProfile4)
|
||||
TEST_METHOD(CodeGenCBufferStructArray)
|
||||
TEST_METHOD(PreprocessWhenValidThenOK)
|
||||
TEST_METHOD(WhenSigMismatchPCFunctionThenFail)
|
||||
|
@ -1040,9 +1044,9 @@ public:
|
|||
std::wstring profile =
|
||||
Unicode::UTF8ToUTF16StringOrThrow(opts.TargetProfile.str().c_str());
|
||||
|
||||
VERIFY_SUCCEEDED(pCompiler->Compile(pSource, name, entry.c_str(),
|
||||
profile.c_str(), nullptr, 0, nullptr, 0,
|
||||
nullptr, &pResult));
|
||||
VERIFY_SUCCEEDED(pCompiler->Compile(
|
||||
pSource, name, entry.c_str(), profile.c_str(), nullptr, 0,
|
||||
opts.Defines.data(), opts.Defines.size(), nullptr, &pResult));
|
||||
HRESULT result;
|
||||
VERIFY_SUCCEEDED(pResult->GetStatus(&result));
|
||||
if (FAILED(result)) {
|
||||
|
@ -1057,6 +1061,8 @@ public:
|
|||
|
||||
CComPtr<IDxcBlob> pProgram;
|
||||
VERIFY_SUCCEEDED(pResult->GetResult(&pProgram));
|
||||
if (opts.IsRootSignatureProfile())
|
||||
return;
|
||||
|
||||
CComPtr<IDxcBlobEncoding> pDisassembleBlob;
|
||||
VERIFY_SUCCEEDED(pCompiler->Disassemble(pProgram, &pDisassembleBlob));
|
||||
|
@ -3031,6 +3037,23 @@ TEST_F(CompilerTest, CodeGenRootSigEntry) {
|
|||
CodeGenTest(L"..\\CodeGenHLSL\\rootSigEntry.hlsl");
|
||||
}
|
||||
|
||||
TEST_F(CompilerTest, CodeGenRootSigProfile) {
|
||||
CodeGenTest(L"..\\CodeGenHLSL\\rootSigProfile.hlsl");
|
||||
}
|
||||
|
||||
TEST_F(CompilerTest, CodeGenRootSigProfile2) {
|
||||
// TODO: Verify the result when reflect the structures.
|
||||
CodeGenTest(L"..\\CodeGenHLSL\\rootSigProfile2.hlsl");
|
||||
}
|
||||
|
||||
TEST_F(CompilerTest, CodeGenRootSigProfile3) {
|
||||
CodeGenTestCheck(L"..\\CodeGenHLSL\\rootSigProfile3.hlsl");
|
||||
}
|
||||
|
||||
TEST_F(CompilerTest, CodeGenRootSigProfile4) {
|
||||
CodeGenTestCheck(L"..\\CodeGenHLSL\\rootSigProfile4.hlsl");
|
||||
}
|
||||
|
||||
TEST_F(CompilerTest, CodeGenCBufferStructArray) {
|
||||
CodeGenTestCheck(L"..\\CodeGenHLSL\\cbuffer-structarray.hlsl");
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче