HLSL test infrastucture and other refactoring and helper classes (#2682)
* HLSL test infrastucture and other refactoring Refactor common test infrastructure code into HLSLTestLib Enable invocation of fxc and other executables via // RUN: commands in test files Add latest d3dx12.h to include/dxc/Support and remove two other outdated copies Improve DXIL container header validation on load New helper classes DxilContainerReader and FixedSizeMemoryStream Move LoadSubobjectsFromRDAT to DxilSubobjects.cpp Co-authored-by: Greg Roth <grroth@microsoft.com>
This commit is contained in:
Родитель
45deef90b0
Коммит
5d741a0279
|
@ -26,6 +26,9 @@
|
|||
.vscode
|
||||
# Visual Studio 2017
|
||||
.vs/
|
||||
# Test outputs
|
||||
*.dxbc
|
||||
*.ll.converted
|
||||
|
||||
#==============================================================================#
|
||||
# Explicit files to ignore (only matches one).
|
||||
|
@ -48,11 +51,11 @@ autoconf/autom4te.cache
|
|||
#==============================================================================#
|
||||
# Directories to ignore (do not add trailing '/'s, they skip symlinks).
|
||||
#==============================================================================#
|
||||
# Build directories
|
||||
build.x64
|
||||
build.x86
|
||||
# External projects that are tracked independently.
|
||||
external/*
|
||||
projects/*
|
||||
!projects/*.*
|
||||
!projects/Makefile
|
||||
# Clang, which is tracked independently.
|
||||
# HLSL Change - track clang together with llvm in this git repo
|
||||
# tools/clang
|
||||
|
|
|
@ -23,6 +23,10 @@ namespace hlsl {
|
|||
|
||||
class DxilSubobjects;
|
||||
|
||||
namespace RDAT {
|
||||
class SubobjectTableReader;
|
||||
}
|
||||
|
||||
class DxilSubobject {
|
||||
public:
|
||||
using Kind = DXIL::SubobjectKind;
|
||||
|
@ -171,4 +175,6 @@ private:
|
|||
SubobjectStorage m_Subobjects;
|
||||
};
|
||||
|
||||
bool LoadSubobjectsFromRDAT(DxilSubobjects &subobjects, RDAT::SubobjectTableReader *pSubobjectTableReader);
|
||||
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -257,8 +257,10 @@ GetDxilProgramHeader(const DxilContainerHeader *pHeader, DxilFourCC fourCC);
|
|||
void InitDxilContainer(_Out_ DxilContainerHeader *pHeader, uint32_t partCount,
|
||||
uint32_t containerSizeInBytes);
|
||||
|
||||
/// Checks whether pHeader claims by signature to be a DXIL container.
|
||||
/// Checks whether pHeader claims by signature to be a DXIL container
|
||||
/// and the length is at least sizeof(DxilContainerHeader).
|
||||
const DxilContainerHeader *IsDxilContainerLike(const void *ptr, size_t length);
|
||||
DxilContainerHeader *IsDxilContainerLike(void *ptr, size_t length);
|
||||
|
||||
/// Checks whether the DXIL container is valid and in-bounds.
|
||||
bool IsValidDxilContainer(const DxilContainerHeader *pHeader, size_t length);
|
||||
|
|
|
@ -5,20 +5,63 @@
|
|||
// This file is distributed under the University of Illinois Open Source //
|
||||
// License. See LICENSE.TXT for details. //
|
||||
// //
|
||||
// Helpers for reading from dxil container. //
|
||||
// Helper class for reading from dxil container. //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "dxc/Support/Global.h"
|
||||
#include "dxc/Support/WinIncludes.h"
|
||||
#include "dxc/DxilContainer/DxilContainer.h"
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
class DxilSubobjects;
|
||||
namespace RDAT {
|
||||
class SubobjectTableReader;
|
||||
}
|
||||
#define DXIL_CONTAINER_BLOB_NOT_FOUND -1
|
||||
|
||||
bool LoadSubobjectsFromRDAT(DxilSubobjects &subobjects,
|
||||
RDAT::SubobjectTableReader *pSubobjectTableReader);
|
||||
struct DxilContainerHeader;
|
||||
|
||||
//=================================================================================================================================
|
||||
// DxilContainerReader
|
||||
//
|
||||
// Parse a DXIL or DXBC Container that you provide as input.
|
||||
//
|
||||
// Basic usage:
|
||||
// (1) Call Load()
|
||||
// (2) Call various Get*() commands to retrieve information about the container such as
|
||||
// how many blobs are in it, the hash of the container, the version #, and most importantly
|
||||
// retrieve all of the Blobs. You can retrieve blobs by searching for the FourCC, or
|
||||
// enumerate through all of them. Multiple blobs can even have the same FourCC, if you choose to
|
||||
// create the DXBC that way, and this parser will let you discover all of them.
|
||||
// (3) You can parse a new container by calling Load() again, or just get rid of the class.
|
||||
//
|
||||
class DxilContainerReader
|
||||
{
|
||||
public:
|
||||
DxilContainerReader() {}
|
||||
|
||||
// Sets the container to be parsed, and does some
|
||||
// basic integrity checking, making sure the blob FourCCs
|
||||
// are all from the known list, and ensuring the version is:
|
||||
// Major = DXBC_MAJOR_VERSION
|
||||
// Minor = DXBC_MAJOR_VERSION
|
||||
//
|
||||
// Returns S_OK or E_FAIL
|
||||
HRESULT Load(_In_ const void* pContainer, _In_ uint32_t containerSizeInBytes);
|
||||
|
||||
HRESULT GetVersion(_Out_ DxilContainerVersion *pResult);
|
||||
HRESULT GetPartCount(_Out_ uint32_t *pResult);
|
||||
HRESULT GetPartContent(uint32_t idx, _Outptr_ const void **ppResult, _Out_ uint32_t *pResultSize = nullptr);
|
||||
HRESULT GetPartFourCC(uint32_t idx, _Out_ uint32_t *pResult);
|
||||
HRESULT FindFirstPartKind(uint32_t kind, _Out_ uint32_t *pResult);
|
||||
|
||||
private:
|
||||
const void* m_pContainer = nullptr;
|
||||
uint32_t m_uContainerSize = 0;
|
||||
const DxilContainerHeader *m_pHeader = nullptr;
|
||||
|
||||
bool IsLoaded() const { return m_pHeader != nullptr; }
|
||||
};
|
||||
|
||||
} // namespace hlsl
|
|
@ -233,6 +233,7 @@ public:
|
|||
};
|
||||
HRESULT CreateMemoryStream(_In_ IMalloc *pMalloc, _COM_Outptr_ AbstractMemoryStream** ppResult) throw();
|
||||
HRESULT CreateReadOnlyBlobStream(_In_ IDxcBlob *pSource, _COM_Outptr_ IStream** ppResult) throw();
|
||||
HRESULT CreateFixedSizeMemoryStream(_In_ LPBYTE pBuffer, size_t size, _COM_Outptr_ AbstractMemoryStream** ppResult) throw();
|
||||
|
||||
template <typename T>
|
||||
HRESULT WriteStreamValue(AbstractMemoryStream *pStream, const T& value) {
|
||||
|
|
|
@ -233,11 +233,13 @@
|
|||
|
||||
#define E_ABORT (HRESULT)0x80004004
|
||||
#define E_ACCESSDENIED (HRESULT)0x80070005
|
||||
#define E_BOUNDS (HRESULT)0x8000000B
|
||||
#define E_FAIL (HRESULT)0x80004005
|
||||
#define E_HANDLE (HRESULT)0x80070006
|
||||
#define E_INVALIDARG (HRESULT)0x80070057
|
||||
#define E_NOINTERFACE (HRESULT)0x80004002
|
||||
#define E_NOTIMPL (HRESULT)0x80004001
|
||||
#define E_NOT_VALID_STATE (HRESULT)0x8007139F
|
||||
#define E_OUTOFMEMORY (HRESULT)0x8007000E
|
||||
#define E_POINTER (HRESULT)0x80004003
|
||||
#define E_UNEXPECTED (HRESULT)0x8000FFFF
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include "dxc/dxcapi.h"
|
||||
#include "dxc/Support/dxcapi.use.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
|
@ -88,13 +89,15 @@ struct FileRunCommandResult {
|
|||
}
|
||||
};
|
||||
|
||||
typedef std::map<std::string, std::string> PluginToolsPaths;
|
||||
|
||||
class FileRunCommandPart {
|
||||
public:
|
||||
FileRunCommandPart(const std::string &command, const std::string &arguments, LPCWSTR commandFileName);
|
||||
FileRunCommandPart(const FileRunCommandPart&) = default;
|
||||
FileRunCommandPart(FileRunCommandPart&&) = default;
|
||||
|
||||
FileRunCommandResult Run(dxc::DxcDllSupport &DllSupport, const FileRunCommandResult *Prior);
|
||||
FileRunCommandResult Run(dxc::DxcDllSupport &DllSupport, const FileRunCommandResult *Prior, PluginToolsPaths *pPluginToolsPaths = nullptr );
|
||||
FileRunCommandResult RunHashTests(dxc::DxcDllSupport &DllSupport);
|
||||
|
||||
FileRunCommandResult ReadOptsForDxc(hlsl::options::MainArgs &argStrings, hlsl::options::DxcOpts &Opts);
|
||||
|
@ -113,6 +116,16 @@ private:
|
|||
FileRunCommandResult RunXFail(const FileRunCommandResult *Prior);
|
||||
FileRunCommandResult RunDxilVer(dxc::DxcDllSupport& DllSupport, const FileRunCommandResult* Prior);
|
||||
FileRunCommandResult RunDxcHashTest(dxc::DxcDllSupport &DllSupport);
|
||||
FileRunCommandResult RunFromPath(const std::string &path, const FileRunCommandResult *Prior);
|
||||
FileRunCommandResult RunFileCompareText(const FileRunCommandResult *Prior);
|
||||
#ifdef _WIN32
|
||||
FileRunCommandResult RunFxc(dxc::DxcDllSupport &DllSupport, const FileRunCommandResult* Prior);
|
||||
#endif
|
||||
|
||||
void SubstituteFilenameVars(std::string &args);
|
||||
#ifdef _WIN32
|
||||
bool ReadFileContentToString(HANDLE hFile, std::string &str);
|
||||
#endif
|
||||
};
|
||||
|
||||
void ParseCommandParts(LPCSTR commands, LPCWSTR fileName, std::vector<FileRunCommandPart> &parts);
|
||||
|
@ -123,8 +136,8 @@ public:
|
|||
std::string ErrorMessage;
|
||||
int RunResult;
|
||||
static FileRunTestResult RunHashTestFromFileCommands(LPCWSTR fileName);
|
||||
static FileRunTestResult RunFromFileCommands(LPCWSTR fileName);
|
||||
static FileRunTestResult RunFromFileCommands(LPCWSTR fileName, dxc::DxcDllSupport &dllSupport);
|
||||
static FileRunTestResult RunFromFileCommands(LPCWSTR fileName, PluginToolsPaths *pPluginToolsPaths = nullptr);
|
||||
static FileRunTestResult RunFromFileCommands(LPCWSTR fileName, dxc::DxcDllSupport &dllSupport, PluginToolsPaths *pPluginToolsPaths = nullptr);
|
||||
};
|
||||
|
||||
void AssembleToContainer(dxc::DxcDllSupport &dllSupport, IDxcBlob *pModule, IDxcBlob **pContainer);
|
|
@ -14,6 +14,10 @@
|
|||
#ifndef LLVM_TOOLS_OPT_PASSPRINTERS_H
|
||||
#define LLVM_TOOLS_OPT_PASSPRINTERS_H
|
||||
|
||||
#include "llvm/Analysis/CallGraphSCCPass.h"
|
||||
#include "llvm/Analysis/LoopPass.h"
|
||||
#include "llvm/Analysis/RegionPass.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class BasicBlockPass;
|
|
@ -18,7 +18,8 @@ add_subdirectory(AsmParser)
|
|||
# add_subdirectory(LineEditor) # HLSL Change
|
||||
add_subdirectory(ProfileData)
|
||||
# add_subdirectory(Fuzzer) # HLSL Change
|
||||
# add_subdirectory(Passes) # HLSL Change
|
||||
add_subdirectory(Passes) # HLSL Change
|
||||
add_subdirectory(PassPrinters) # HLSL Change
|
||||
# add_subdirectory(LibDriver) # HLSL Change
|
||||
add_subdirectory(DxcSupport) # HLSL Change
|
||||
add_subdirectory(HLSL) # HLSL Change
|
||||
|
|
|
@ -8,10 +8,12 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "dxc/Support/Global.h"
|
||||
#include "dxc/Support/Unicode.h"
|
||||
#include "dxc/Support/WinIncludes.h"
|
||||
#include "dxc/DXIL/DxilSubobject.h"
|
||||
#include "dxc/DxilContainer/DxilRuntimeReflection.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -341,6 +343,74 @@ DxilSubobject &DxilSubobjects::CreateSubobject(Kind kind, llvm::StringRef Name)
|
|||
return ref;
|
||||
}
|
||||
|
||||
bool LoadSubobjectsFromRDAT(DxilSubobjects &subobjects, RDAT::SubobjectTableReader *pSubobjectTableReader) {
|
||||
if (!pSubobjectTableReader)
|
||||
return false;
|
||||
bool result = true;
|
||||
for (unsigned i = 0; i < pSubobjectTableReader->GetCount(); ++i) {
|
||||
try {
|
||||
auto reader = pSubobjectTableReader->GetItem(i);
|
||||
DXIL::SubobjectKind kind = reader.GetKind();
|
||||
bool bLocalRS = false;
|
||||
switch (kind) {
|
||||
case DXIL::SubobjectKind::StateObjectConfig:
|
||||
subobjects.CreateStateObjectConfig(reader.GetName(),
|
||||
reader.GetStateObjectConfig_Flags());
|
||||
break;
|
||||
case DXIL::SubobjectKind::LocalRootSignature:
|
||||
bLocalRS = true;
|
||||
case DXIL::SubobjectKind::GlobalRootSignature: {
|
||||
const void *pOutBytes;
|
||||
uint32_t OutSizeInBytes;
|
||||
if (!reader.GetRootSignature(&pOutBytes, &OutSizeInBytes)) {
|
||||
result = false;
|
||||
continue;
|
||||
}
|
||||
subobjects.CreateRootSignature(reader.GetName(), bLocalRS, pOutBytes, OutSizeInBytes);
|
||||
break;
|
||||
}
|
||||
case DXIL::SubobjectKind::SubobjectToExportsAssociation: {
|
||||
uint32_t NumExports = reader.GetSubobjectToExportsAssociation_NumExports();
|
||||
std::vector<llvm::StringRef> Exports;
|
||||
Exports.resize(NumExports);
|
||||
for (unsigned i = 0; i < NumExports; ++i) {
|
||||
Exports[i] = reader.GetSubobjectToExportsAssociation_Export(i);
|
||||
}
|
||||
subobjects.CreateSubobjectToExportsAssociation(reader.GetName(),
|
||||
reader.GetSubobjectToExportsAssociation_Subobject(),
|
||||
Exports.data(), NumExports);
|
||||
break;
|
||||
}
|
||||
case DXIL::SubobjectKind::RaytracingShaderConfig:
|
||||
subobjects.CreateRaytracingShaderConfig(reader.GetName(),
|
||||
reader.GetRaytracingShaderConfig_MaxPayloadSizeInBytes(),
|
||||
reader.GetRaytracingShaderConfig_MaxAttributeSizeInBytes());
|
||||
break;
|
||||
case DXIL::SubobjectKind::RaytracingPipelineConfig:
|
||||
subobjects.CreateRaytracingPipelineConfig(reader.GetName(),
|
||||
reader.GetRaytracingPipelineConfig_MaxTraceRecursionDepth());
|
||||
break;
|
||||
case DXIL::SubobjectKind::HitGroup:
|
||||
subobjects.CreateHitGroup(reader.GetName(),
|
||||
reader.GetHitGroup_Type(),
|
||||
reader.GetHitGroup_AnyHit(),
|
||||
reader.GetHitGroup_ClosestHit(),
|
||||
reader.GetHitGroup_Intersection());
|
||||
break;
|
||||
case DXIL::SubobjectKind::RaytracingPipelineConfig1:
|
||||
subobjects.CreateRaytracingPipelineConfig1(
|
||||
reader.GetName(),
|
||||
reader.GetRaytracingPipelineConfig1_MaxTraceRecursionDepth(),
|
||||
reader.GetRaytracingPipelineConfig1_Flags());
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (hlsl::Exception &) {
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace hlsl
|
||||
|
||||
|
|
|
@ -1332,6 +1332,114 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class FixedSizeMemoryStream : public AbstractMemoryStream {
|
||||
private:
|
||||
DXC_MICROCOM_TM_REF_FIELDS()
|
||||
LPBYTE m_pBuffer;
|
||||
ULONG m_offset;
|
||||
ULONG m_size;
|
||||
public:
|
||||
DXC_MICROCOM_TM_ADDREF_RELEASE_IMPL()
|
||||
DXC_MICROCOM_TM_CTOR(FixedSizeMemoryStream)
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject) override {
|
||||
return DoBasicQueryInterface<IStream, ISequentialStream>(this, iid, ppvObject);
|
||||
}
|
||||
|
||||
void Init(LPBYTE pBuffer, size_t size) {
|
||||
m_pBuffer = pBuffer;
|
||||
m_offset = 0;
|
||||
m_size = size;
|
||||
}
|
||||
|
||||
// ISequentialStream implementation.
|
||||
HRESULT STDMETHODCALLTYPE Read(void *pv, ULONG cb, ULONG *pcbRead) override {
|
||||
if (!pv || !pcbRead)
|
||||
return E_POINTER;
|
||||
ULONG cbLeft = m_size - m_offset;
|
||||
*pcbRead = std::min(cb, cbLeft);
|
||||
memcpy(pv, m_pBuffer + m_offset, *pcbRead);
|
||||
m_offset += *pcbRead;
|
||||
return (*pcbRead == cb) ? S_OK : S_FALSE;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE Write(void const *pv, ULONG cb, ULONG *pcbWritten) override {
|
||||
if (!pv || !pcbWritten)
|
||||
return E_POINTER;
|
||||
ULONG cbLeft = m_size - m_offset;
|
||||
*pcbWritten = std::min(cb, cbLeft);
|
||||
memcpy(m_pBuffer + m_offset, pv, *pcbWritten);
|
||||
m_offset += *pcbWritten;
|
||||
return (*pcbWritten == cb) ? S_OK : S_FALSE;
|
||||
}
|
||||
|
||||
// IStream implementation.
|
||||
HRESULT STDMETHODCALLTYPE SetSize(ULARGE_INTEGER val) override {
|
||||
return STG_E_ACCESSDENIED;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CopyTo(IStream *, ULARGE_INTEGER,
|
||||
ULARGE_INTEGER *, ULARGE_INTEGER *) override {
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE Commit(DWORD) override { return E_NOTIMPL; }
|
||||
|
||||
HRESULT STDMETHODCALLTYPE Revert(void) override { return E_NOTIMPL; }
|
||||
|
||||
HRESULT STDMETHODCALLTYPE LockRegion(ULARGE_INTEGER,
|
||||
ULARGE_INTEGER, DWORD) override {
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE UnlockRegion(ULARGE_INTEGER,
|
||||
ULARGE_INTEGER, DWORD) override {
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE Clone(IStream **) override { return E_NOTIMPL; }
|
||||
|
||||
HRESULT STDMETHODCALLTYPE Seek(LARGE_INTEGER, DWORD, ULARGE_INTEGER *) override {
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE Stat(STATSTG *pStatstg,
|
||||
DWORD grfStatFlag) override {
|
||||
if (pStatstg == nullptr) {
|
||||
return E_POINTER;
|
||||
}
|
||||
ZeroMemory(pStatstg, sizeof(*pStatstg));
|
||||
pStatstg->type = STGTY_STREAM;
|
||||
pStatstg->cbSize.u.LowPart = m_size;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// AbstractMemoryStream implementation
|
||||
LPBYTE GetPtr() throw() override {
|
||||
return m_pBuffer;
|
||||
}
|
||||
|
||||
ULONG GetPtrSize() throw() override {
|
||||
return m_size;
|
||||
}
|
||||
|
||||
LPBYTE Detach() throw() override {
|
||||
LPBYTE result = m_pBuffer;
|
||||
m_pBuffer = nullptr;
|
||||
m_size = 0;
|
||||
m_offset = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
UINT64 GetPosition() throw() override {
|
||||
return m_offset;
|
||||
}
|
||||
|
||||
HRESULT Reserve(ULONG targetSize) throw() override {
|
||||
return targetSize <= m_size ? S_OK : E_BOUNDS;
|
||||
}
|
||||
};
|
||||
|
||||
HRESULT CreateMemoryStream(_In_ IMalloc *pMalloc, _COM_Outptr_ AbstractMemoryStream** ppResult) throw() {
|
||||
if (pMalloc == nullptr || ppResult == nullptr) {
|
||||
return E_POINTER;
|
||||
|
@ -1355,4 +1463,17 @@ HRESULT CreateReadOnlyBlobStream(_In_ IDxcBlob *pSource, _COM_Outptr_ IStream**
|
|||
return (*ppResult == nullptr) ? E_OUTOFMEMORY : S_OK;
|
||||
}
|
||||
|
||||
HRESULT CreateFixedSizeMemoryStream(_In_ LPBYTE pBuffer, size_t size, _COM_Outptr_ AbstractMemoryStream** ppResult) throw() {
|
||||
if (pBuffer == nullptr || ppResult == nullptr) {
|
||||
return E_POINTER;
|
||||
}
|
||||
|
||||
CComPtr<FixedSizeMemoryStream> stream = FixedSizeMemoryStream::Alloc(DxcGetThreadMallocNoRef());
|
||||
if (stream.p) {
|
||||
stream->Init(pBuffer, size);
|
||||
}
|
||||
*ppResult = stream.Detach();
|
||||
return (*ppResult == nullptr) ? E_OUTOFMEMORY : S_OK;
|
||||
}
|
||||
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -4,6 +4,7 @@ add_llvm_library(LLVMDxilContainer
|
|||
DxilContainer.cpp
|
||||
DxilContainerAssembler.cpp
|
||||
DxilContainerReader.cpp
|
||||
DxilRuntimeReflection.cpp
|
||||
|
||||
ADDITIONAL_HEADER_DIRS
|
||||
${LLVM_MAIN_INCLUDE_DIR}/llvm/IR
|
||||
|
|
|
@ -33,13 +33,18 @@ void InitDxilContainer(_Out_ DxilContainerHeader *pHeader, uint32_t partCount,
|
|||
}
|
||||
|
||||
const DxilContainerHeader *IsDxilContainerLike(const void *ptr, size_t length) {
|
||||
if (ptr == nullptr || length < 4)
|
||||
if (ptr == nullptr || length < sizeof(DxilContainerHeader))
|
||||
return nullptr;
|
||||
if (DFCC_Container != *reinterpret_cast<const uint32_t *>(ptr))
|
||||
return nullptr;
|
||||
return reinterpret_cast<const DxilContainerHeader *>(ptr);
|
||||
}
|
||||
|
||||
DxilContainerHeader *IsDxilContainerLike(void *ptr, size_t length) {
|
||||
return const_cast<DxilContainerHeader *>(IsDxilContainerLike(
|
||||
static_cast<const void *>(ptr), length));
|
||||
}
|
||||
|
||||
bool IsValidDxilContainer(const DxilContainerHeader *pHeader, size_t length) {
|
||||
// Validate that the header is where it's supposed to be.
|
||||
if (pHeader == nullptr) return false;
|
||||
|
|
|
@ -1,93 +1,86 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// DxilContainerReader.cpp //
|
||||
// DxilContainerReader.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 support for manipulating DXIL container structures. //
|
||||
// Helper class for reading from dxil container. //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "dxc/Support/Global.h"
|
||||
#include "dxc/Support/Unicode.h"
|
||||
#include "dxc/Support/WinIncludes.h"
|
||||
#include "dxc/DXIL/DxilSubobject.h"
|
||||
#include "dxc/Support/WinAdapter.h"
|
||||
#include "dxc/DxilContainer/DxilContainer.h"
|
||||
#include "dxc/DxilContainer/DxilContainerReader.h"
|
||||
#include "dxc/DxilContainer/DxilRuntimeReflection.h"
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
bool LoadSubobjectsFromRDAT(DxilSubobjects &subobjects, RDAT::SubobjectTableReader *pSubobjectTableReader) {
|
||||
if (!pSubobjectTableReader)
|
||||
return false;
|
||||
bool result = true;
|
||||
for (unsigned i = 0; i < pSubobjectTableReader->GetCount(); ++i) {
|
||||
try {
|
||||
auto reader = pSubobjectTableReader->GetItem(i);
|
||||
DXIL::SubobjectKind kind = reader.GetKind();
|
||||
bool bLocalRS = false;
|
||||
switch (kind) {
|
||||
case DXIL::SubobjectKind::StateObjectConfig:
|
||||
subobjects.CreateStateObjectConfig(reader.GetName(),
|
||||
reader.GetStateObjectConfig_Flags());
|
||||
break;
|
||||
case DXIL::SubobjectKind::LocalRootSignature:
|
||||
bLocalRS = true;
|
||||
case DXIL::SubobjectKind::GlobalRootSignature: {
|
||||
const void *pOutBytes;
|
||||
uint32_t OutSizeInBytes;
|
||||
if (!reader.GetRootSignature(&pOutBytes, &OutSizeInBytes)) {
|
||||
result = false;
|
||||
continue;
|
||||
}
|
||||
subobjects.CreateRootSignature(reader.GetName(), bLocalRS, pOutBytes, OutSizeInBytes);
|
||||
break;
|
||||
}
|
||||
case DXIL::SubobjectKind::SubobjectToExportsAssociation: {
|
||||
uint32_t NumExports = reader.GetSubobjectToExportsAssociation_NumExports();
|
||||
std::vector<llvm::StringRef> Exports;
|
||||
Exports.resize(NumExports);
|
||||
for (unsigned i = 0; i < NumExports; ++i) {
|
||||
Exports[i] = reader.GetSubobjectToExportsAssociation_Export(i);
|
||||
}
|
||||
subobjects.CreateSubobjectToExportsAssociation(reader.GetName(),
|
||||
reader.GetSubobjectToExportsAssociation_Subobject(),
|
||||
Exports.data(), NumExports);
|
||||
break;
|
||||
}
|
||||
case DXIL::SubobjectKind::RaytracingShaderConfig:
|
||||
subobjects.CreateRaytracingShaderConfig(reader.GetName(),
|
||||
reader.GetRaytracingShaderConfig_MaxPayloadSizeInBytes(),
|
||||
reader.GetRaytracingShaderConfig_MaxAttributeSizeInBytes());
|
||||
break;
|
||||
case DXIL::SubobjectKind::RaytracingPipelineConfig:
|
||||
subobjects.CreateRaytracingPipelineConfig(reader.GetName(),
|
||||
reader.GetRaytracingPipelineConfig_MaxTraceRecursionDepth());
|
||||
break;
|
||||
case DXIL::SubobjectKind::HitGroup:
|
||||
subobjects.CreateHitGroup(reader.GetName(),
|
||||
reader.GetHitGroup_Type(),
|
||||
reader.GetHitGroup_AnyHit(),
|
||||
reader.GetHitGroup_ClosestHit(),
|
||||
reader.GetHitGroup_Intersection());
|
||||
break;
|
||||
case DXIL::SubobjectKind::RaytracingPipelineConfig1:
|
||||
subobjects.CreateRaytracingPipelineConfig1(
|
||||
reader.GetName(),
|
||||
reader.GetRaytracingPipelineConfig1_MaxTraceRecursionDepth(),
|
||||
reader.GetRaytracingPipelineConfig1_Flags());
|
||||
break;
|
||||
}
|
||||
} catch (hlsl::Exception &) {
|
||||
result = false;
|
||||
}
|
||||
HRESULT DxilContainerReader::Load(_In_ const void* pContainer, _In_ uint32_t containerSizeInBytes) {
|
||||
if (pContainer == nullptr) {
|
||||
return E_FAIL;
|
||||
}
|
||||
return result;
|
||||
|
||||
const DxilContainerHeader *pHeader = IsDxilContainerLike(pContainer, containerSizeInBytes);
|
||||
if (pHeader == nullptr) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (!IsValidDxilContainer(pHeader, containerSizeInBytes)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
m_pContainer = pContainer;
|
||||
m_uContainerSize = containerSizeInBytes;
|
||||
m_pHeader = pHeader;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT DxilContainerReader::GetVersion(_Out_ DxilContainerVersion *pResult) {
|
||||
if (pResult == nullptr) return E_POINTER;
|
||||
if (!IsLoaded()) return E_NOT_VALID_STATE;
|
||||
*pResult = m_pHeader->Version;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT DxilContainerReader::GetPartCount(_Out_ uint32_t *pResult) {
|
||||
if (pResult == nullptr) return E_POINTER;
|
||||
if (!IsLoaded()) return E_NOT_VALID_STATE;
|
||||
*pResult = m_pHeader->PartCount;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT DxilContainerReader::GetPartContent(uint32_t idx, _Outptr_ const void **ppResult, _Out_ uint32_t *pResultSize) {
|
||||
if (ppResult == nullptr) return E_POINTER;
|
||||
*ppResult = nullptr;
|
||||
if (!IsLoaded()) return E_NOT_VALID_STATE;
|
||||
if (idx >= m_pHeader->PartCount) return E_BOUNDS;
|
||||
const DxilPartHeader *pPart = GetDxilContainerPart(m_pHeader, idx);
|
||||
*ppResult = GetDxilPartData(pPart);
|
||||
if (pResultSize != nullptr) {
|
||||
*pResultSize = pPart->PartSize;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT DxilContainerReader::GetPartFourCC(uint32_t idx, _Out_ uint32_t *pResult) {
|
||||
if (pResult == nullptr) return E_POINTER;
|
||||
if (!IsLoaded()) return E_NOT_VALID_STATE;
|
||||
if (idx >= m_pHeader->PartCount) return E_BOUNDS;
|
||||
const DxilPartHeader *pPart = GetDxilContainerPart(m_pHeader, idx);
|
||||
*pResult = pPart->PartFourCC;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT DxilContainerReader::FindFirstPartKind(uint32_t kind, _Out_ uint32_t *pResult) {
|
||||
if (pResult == nullptr) return E_POINTER;
|
||||
*pResult = 0;
|
||||
if (!IsLoaded()) return E_NOT_VALID_STATE;
|
||||
DxilPartIterator it = std::find_if(begin(m_pHeader), end(m_pHeader), DxilPartIsType(kind));
|
||||
*pResult = (it == end(m_pHeader)) ? DXIL_CONTAINER_BLOB_NOT_FOUND : it.index;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
} // namespace hlsl
|
||||
|
||||
// DxilRuntimeReflection implementation
|
||||
#include "dxc/DxilContainer/DxilRuntimeReflection.inl"
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// DxilRuntimeReflection.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. //
|
||||
// //
|
||||
// Provides support for manipulating DXIL container structures. //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "dxc/Support/Global.h"
|
||||
#include "dxc/Support/Unicode.h"
|
||||
#include "dxc/Support/WinIncludes.h"
|
||||
#include "dxc/DXIL/DxilSubobject.h"
|
||||
#include "dxc/DxilContainer/DxilContainer.h"
|
||||
#include "dxc/DxilContainer/DxilRuntimeReflection.h"
|
||||
|
||||
// DxilRuntimeReflection implementation
|
||||
#include "dxc/DxilContainer/DxilRuntimeReflection.inl"
|
|
@ -87,8 +87,12 @@ STDMETHODIMP dxil_dia::DataSource::loadDataFromIStream(_In_ IStream *pInputIStre
|
|||
CComPtr<IStream> pIStream = pInputIStream;
|
||||
CComPtr<IDxcBlob> pContainer;
|
||||
if (SUCCEEDED(hlsl::pdb::LoadDataFromStream(m_pMalloc, pInputIStream, &pContainer))) {
|
||||
hlsl::DxilPartHeader *PartHeader =
|
||||
hlsl::GetDxilPartByType((hlsl::DxilContainerHeader *)pContainer->GetBufferPointer(), hlsl::DFCC_ShaderDebugInfoDXIL);
|
||||
const hlsl::DxilContainerHeader *pContainerHeader =
|
||||
hlsl::IsDxilContainerLike(pContainer->GetBufferPointer(), pContainer->GetBufferSize());
|
||||
if (!hlsl::IsValidDxilContainer(pContainerHeader, pContainer->GetBufferSize()))
|
||||
return E_FAIL;
|
||||
const hlsl::DxilPartHeader *PartHeader =
|
||||
hlsl::GetDxilPartByType(pContainerHeader, hlsl::DFCC_ShaderDebugInfoDXIL);
|
||||
if (!PartHeader)
|
||||
return E_FAIL;
|
||||
CComPtr<IDxcBlobEncoding> pPinnedBlob;
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
# Copyright (C) Microsoft Corporation. All rights reserved.
|
||||
# This file is distributed under the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
set(LLVM_LINK_COMPONENTS
|
||||
${LLVM_TARGETS_TO_BUILD}
|
||||
passprinters
|
||||
)
|
||||
|
||||
add_llvm_library(LLVMHLSL
|
||||
ComputeViewIdState.cpp
|
||||
ComputeViewIdStateBuilder.cpp
|
||||
|
|
|
@ -42,8 +42,7 @@
|
|||
#include <list> // should change this for string_table
|
||||
#include <vector>
|
||||
|
||||
// This is pretty ugly; should be refactored to a proper library
|
||||
#include "../tools/opt/PassPrinters.cpp"
|
||||
#include "llvm/PassPrinters/PassPrinters.h"
|
||||
|
||||
using namespace llvm;
|
||||
using namespace hlsl;
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include "dxc/HLSL/DxilValidation.h"
|
||||
#include "dxc/DxilContainer/DxilContainerAssembler.h"
|
||||
#include "dxc/DxilContainer/DxilRuntimeReflection.h"
|
||||
#include "dxc/DxilContainer/DxilContainerReader.h"
|
||||
#include "dxc/HLSL/DxilGenerationPass.h"
|
||||
#include "dxc/DXIL/DxilOperations.h"
|
||||
#include "dxc/DXIL/DxilModule.h"
|
||||
|
|
|
@ -33,6 +33,7 @@ subdirectories =
|
|||
Object
|
||||
Option
|
||||
Passes
|
||||
PassPrinters
|
||||
ProfileData
|
||||
Support
|
||||
TableGen
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
add_llvm_library(LLVMPassPrinters
|
||||
PassPrinters.cpp
|
||||
ADDITIONAL_HEADER_DIRS
|
||||
)
|
||||
|
||||
add_dependencies(LLVMPassPrinters intrinsics_gen)
|
|
@ -0,0 +1,23 @@
|
|||
;===- ./lib/Passes/LLVMBuild.txt -------------------------------*- Conf -*--===;
|
||||
;
|
||||
; The LLVM Compiler Infrastructure
|
||||
;
|
||||
; This file is distributed under the University of Illinois Open Source
|
||||
; License. See LICENSE.TXT for details.
|
||||
;
|
||||
;===------------------------------------------------------------------------===;
|
||||
;
|
||||
; This is an LLVMBuild description file for the components in this subdirectory.
|
||||
;
|
||||
; For more information on the LLVMBuild system, please see:
|
||||
;
|
||||
; http://llvm.org/docs/LLVMBuild.html
|
||||
;
|
||||
;===------------------------------------------------------------------------===;
|
||||
|
||||
[component_0]
|
||||
type = Library
|
||||
name = PassPrinters
|
||||
parent = Libraries
|
||||
required_libraries = Passes Analysis Core IPA IPO InstCombine Scalar Support TransformUtils Vectorize
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
///
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "PassPrinters.h"
|
||||
#include "llvm/PassPrinters/PassPrinters.h"
|
||||
#include "llvm/Analysis/CallGraphSCCPass.h"
|
||||
#include "llvm/Analysis/LoopPass.h"
|
||||
#include "llvm/Analysis/RegionPass.h"
|
|
@ -413,8 +413,8 @@ HRESULT DxcContext::ReadFileIntoPartContent(hlsl::DxilFourCC fourCC, LPCWSTR fil
|
|||
DWORD dataSize;
|
||||
hlsl::ReadBinaryFile(fileName, (void**)&pData, &dataSize);
|
||||
DXASSERT(pData != nullptr, "otherwise ReadBinaryFile should throw an exception");
|
||||
hlsl::DxilContainerHeader *pHeader = (hlsl::DxilContainerHeader*) pData.m_pData;
|
||||
IFRBOOL(hlsl::IsDxilContainerLike(pHeader, pHeader->ContainerSizeInBytes), E_INVALIDARG);
|
||||
hlsl::DxilContainerHeader *pHeader = hlsl::IsDxilContainerLike(pData.m_pData, dataSize);
|
||||
IFRBOOL(hlsl::IsValidDxilContainer(pHeader, dataSize), E_INVALIDARG);
|
||||
hlsl::DxilPartHeader *pPartHeader = hlsl::GetDxilPartByType(pHeader, hlsl::DxilFourCC::DFCC_RootSignature);
|
||||
IFRBOOL(pPartHeader != nullptr, E_INVALIDARG);
|
||||
hlsl::DxcCreateBlobOnHeapCopy(hlsl::GetDxilPartData(pPartHeader), pPartHeader->PartSize, &pResult);
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include "dxc/DxilContainer/DxilPipelineStateValidation.h"
|
||||
#include "dxc/DxilContainer/DxilContainer.h"
|
||||
#include "dxc/DxilContainer/DxilRuntimeReflection.h"
|
||||
#include "dxc/DxilContainer/DxilContainerReader.h"
|
||||
#include "dxc/HLSL/ComputeViewIdState.h"
|
||||
#include "dxc/Support/FileIOHelper.h"
|
||||
#include "dxc/DXIL/DxilUtil.h"
|
||||
|
|
|
@ -37,6 +37,7 @@ endif (CLANG_INCLUDE_TESTS) # HLSL Change
|
|||
|
||||
if (HLSL_INCLUDE_TESTS)
|
||||
add_subdirectory(HLSL)
|
||||
add_subdirectory(HLSLTestLib)
|
||||
if (WIN32) # These tests require MS specific TAEF and DIA SDK
|
||||
add_subdirectory(HLSLHost)
|
||||
add_subdirectory(dxc_batch)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
find_package(D3D12 REQUIRED)
|
||||
|
||||
set(LLVM_LINK_COMPONENTS
|
||||
analysis
|
||||
asmparser
|
||||
|
@ -46,12 +48,15 @@ set_source_files_properties( ${TEST_FILES} PROPERTIES HEADER_FILE_ONLY ON)
|
|||
# create a file to include to provide a default path for test files
|
||||
set(DEFAULT_TEST_FILE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/testFiles/")
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/defaultTestFilePath.h.in ${CMAKE_CURRENT_BINARY_DIR}/defaultTestFilePath.h)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
include_directories(
|
||||
${D3D12_INCLUDE_DIRS}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
add_clang_executable(test_DxrFallback
|
||||
test_DxrFallback.cpp
|
||||
|
||||
d3dx12.h
|
||||
DXSampleHelper.h
|
||||
ShaderTester.h
|
||||
ShaderTesterImpl.cpp
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <dxgi1_4.h>
|
||||
#include <D3Dcompiler.h>
|
||||
#include <DirectXMath.h>
|
||||
#include "d3dx12.h"
|
||||
#include "dxc\Support\d3dx12.h"
|
||||
|
||||
#include <string>
|
||||
#include <wrl.h>
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -12,7 +12,7 @@
|
|||
#ifdef _WIN32
|
||||
#include "WexTestClass.h"
|
||||
#endif
|
||||
#include "HlslTestUtils.h"
|
||||
#include "dxc/Test/HlslTestUtils.h"
|
||||
|
||||
#include "dxc/HLSL/DxilSpanAllocator.h"
|
||||
#include <cstdlib>
|
||||
|
|
|
@ -30,20 +30,13 @@ set(HLSL_IGNORE_SOURCES
|
|||
)
|
||||
add_clang_library(clang-hlsl-tests SHARED
|
||||
AllocatorTest.cpp
|
||||
CompilationResult.h
|
||||
CompilerTest.cpp
|
||||
DxcTestUtils.cpp
|
||||
DxilContainerTest.cpp
|
||||
DxilModuleTest.cpp
|
||||
DXIsenseTest.cpp
|
||||
ExecutionTest.cpp
|
||||
ExtensionTest.cpp
|
||||
FileCheckerTest.cpp
|
||||
FileCheckForTest.cpp
|
||||
FunctionTest.cpp
|
||||
HLSLTestData.h
|
||||
HlslTestUtils.h
|
||||
D3DReflectionDumper.cpp
|
||||
LinkerTest.cpp
|
||||
MSFileSysTest.cpp
|
||||
Objects.cpp
|
||||
|
@ -63,20 +56,16 @@ set(HLSL_IGNORE_SOURCES
|
|||
MSFileSysTest.cpp
|
||||
RewriterTest.cpp
|
||||
ShaderOpTest.cpp
|
||||
D3DReflectionDumper.cpp
|
||||
DxilContainerTest.cpp
|
||||
FileCheckerTest.cpp
|
||||
ValidationTest.cpp
|
||||
CompilerTest.cpp
|
||||
)
|
||||
|
||||
add_clang_unittest(clang-hlsl-tests
|
||||
AllocatorTest.cpp
|
||||
DxcTestUtils.cpp
|
||||
DxilModuleTest.cpp
|
||||
DXIsenseTest.cpp
|
||||
ExtensionTest.cpp
|
||||
FileCheckForTest.cpp
|
||||
FunctionTest.cpp
|
||||
HLSLTestOptions.cpp
|
||||
Objects.cpp
|
||||
|
@ -94,6 +83,7 @@ set_target_properties(clang-hlsl-tests PROPERTIES FOLDER "Clang tests")
|
|||
if (WIN32)
|
||||
target_link_libraries(clang-hlsl-tests PRIVATE
|
||||
dxcompiler
|
||||
HLSLTestLib
|
||||
${TAEF_LIBRARIES}
|
||||
${DIASDK_LIBRARIES}
|
||||
${D3D12_LIBRARIES}
|
||||
|
@ -101,6 +91,7 @@ target_link_libraries(clang-hlsl-tests PRIVATE
|
|||
else(WIN32)
|
||||
target_link_libraries(clang-hlsl-tests
|
||||
dxcompiler
|
||||
HLSLTestLib
|
||||
)
|
||||
endif(WIN32)
|
||||
|
||||
|
@ -109,6 +100,7 @@ if(WIN32)
|
|||
include_directories(${TAEF_INCLUDE_DIRS})
|
||||
include_directories(${DIASDK_INCLUDE_DIRS})
|
||||
include_directories(${D3D12_INCLUDE_DIRS})
|
||||
|
||||
endif(WIN32)
|
||||
|
||||
# Add includes to directly reference intrinsic tables.
|
||||
|
|
|
@ -29,9 +29,9 @@
|
|||
#include "dia2.h"
|
||||
#endif
|
||||
|
||||
#include "HLSLTestData.h"
|
||||
#include "HlslTestUtils.h"
|
||||
#include "DxcTestUtils.h"
|
||||
#include "dxc/Test/HLSLTestData.h"
|
||||
#include "dxc/Test/HlslTestUtils.h"
|
||||
#include "dxc/Test/DxcTestUtils.h"
|
||||
|
||||
#include "llvm/Support/raw_os_ostream.h"
|
||||
#include "dxc/Support/Global.h"
|
||||
|
@ -1392,8 +1392,9 @@ TEST_F(CompilerTest, CompileWhenDebugWorksThenStripDebug) {
|
|||
0, nullptr, &pResult));
|
||||
VERIFY_SUCCEEDED(pResult->GetResult(&pProgram));
|
||||
// Check if it contains debug blob
|
||||
hlsl::DxilContainerHeader *pHeader =
|
||||
(hlsl::DxilContainerHeader *)(pProgram->GetBufferPointer());
|
||||
hlsl::DxilContainerHeader *pHeader =
|
||||
hlsl::IsDxilContainerLike(pProgram->GetBufferPointer(), pProgram->GetBufferSize());
|
||||
VERIFY_SUCCEEDED(hlsl::IsValidDxilContainer(pHeader, pProgram->GetBufferSize()));
|
||||
hlsl::DxilPartHeader *pPartHeader = hlsl::GetDxilPartByType(
|
||||
pHeader, hlsl::DxilFourCC::DFCC_ShaderDebugInfoDXIL);
|
||||
VERIFY_IS_NOT_NULL(pPartHeader);
|
||||
|
@ -1407,7 +1408,8 @@ TEST_F(CompilerTest, CompileWhenDebugWorksThenStripDebug) {
|
|||
pResult.Release();
|
||||
VERIFY_SUCCEEDED(pBuilder->SerializeContainer(&pResult));
|
||||
VERIFY_SUCCEEDED(pResult->GetResult(&pNewProgram));
|
||||
pHeader = (hlsl::DxilContainerHeader *)(pNewProgram->GetBufferPointer());
|
||||
pHeader = hlsl::IsDxilContainerLike(pNewProgram->GetBufferPointer(), pNewProgram->GetBufferSize());
|
||||
VERIFY_SUCCEEDED(hlsl::IsValidDxilContainer(pHeader, pNewProgram->GetBufferSize()));
|
||||
pPartHeader = hlsl::GetDxilPartByType(
|
||||
pHeader, hlsl::DxilFourCC::DFCC_ShaderDebugInfoDXIL);
|
||||
VERIFY_IS_NULL(pPartHeader);
|
||||
|
@ -1442,8 +1444,8 @@ TEST_F(CompilerTest, CompileWhenWorksThenAddRemovePrivate) {
|
|||
|
||||
CComPtr<IDxcBlob> pNewProgram;
|
||||
VERIFY_SUCCEEDED(pResult->GetResult(&pNewProgram));
|
||||
hlsl::DxilContainerHeader *pContainerHeader =
|
||||
(hlsl::DxilContainerHeader *)(pNewProgram->GetBufferPointer());
|
||||
hlsl::DxilContainerHeader *pContainerHeader = hlsl::IsDxilContainerLike(pNewProgram->GetBufferPointer(), pNewProgram->GetBufferSize());
|
||||
VERIFY_SUCCEEDED(hlsl::IsValidDxilContainer(pContainerHeader, pNewProgram->GetBufferSize()));
|
||||
hlsl::DxilPartHeader *pPartHeader = hlsl::GetDxilPartByType(
|
||||
pContainerHeader, hlsl::DxilFourCC::DFCC_PrivateData);
|
||||
VERIFY_IS_NOT_NULL(pPartHeader);
|
||||
|
@ -1461,8 +1463,8 @@ TEST_F(CompilerTest, CompileWhenWorksThenAddRemovePrivate) {
|
|||
|
||||
pNewProgram.Release();
|
||||
VERIFY_SUCCEEDED(pResult->GetResult(&pNewProgram));
|
||||
pContainerHeader =
|
||||
(hlsl::DxilContainerHeader *)(pNewProgram->GetBufferPointer());
|
||||
pContainerHeader = hlsl::IsDxilContainerLike(pNewProgram->GetBufferPointer(), pNewProgram->GetBufferSize());
|
||||
VERIFY_SUCCEEDED(hlsl::IsValidDxilContainer(pContainerHeader, pNewProgram->GetBufferSize()));
|
||||
pPartHeader = hlsl::GetDxilPartByType(
|
||||
pContainerHeader, hlsl::DxilFourCC::DFCC_PrivateData);
|
||||
VERIFY_IS_NULL(pPartHeader);
|
||||
|
@ -1518,8 +1520,8 @@ TEST_F(CompilerTest, CompileThenAddCustomDebugName) {
|
|||
|
||||
CComPtr<IDxcBlob> pNewProgram;
|
||||
VERIFY_SUCCEEDED(pResult->GetResult(&pNewProgram));
|
||||
hlsl::DxilContainerHeader *pContainerHeader =
|
||||
(hlsl::DxilContainerHeader *)(pNewProgram->GetBufferPointer());
|
||||
hlsl::DxilContainerHeader *pContainerHeader = hlsl::IsDxilContainerLike(pNewProgram->GetBufferPointer(), pNewProgram->GetBufferSize());
|
||||
VERIFY_SUCCEEDED(hlsl::IsValidDxilContainer(pContainerHeader, pNewProgram->GetBufferSize()));
|
||||
hlsl::DxilPartHeader *pPartHeader = hlsl::GetDxilPartByType(
|
||||
pContainerHeader, hlsl::DxilFourCC::DFCC_ShaderDebugName);
|
||||
VERIFY_IS_NOT_NULL(pPartHeader);
|
||||
|
@ -1538,8 +1540,8 @@ TEST_F(CompilerTest, CompileThenAddCustomDebugName) {
|
|||
|
||||
pNewProgram.Release();
|
||||
VERIFY_SUCCEEDED(pResult->GetResult(&pNewProgram));
|
||||
pContainerHeader =
|
||||
(hlsl::DxilContainerHeader *)(pNewProgram->GetBufferPointer());
|
||||
pContainerHeader = hlsl::IsDxilContainerLike(pNewProgram->GetBufferPointer(), pNewProgram->GetBufferSize());
|
||||
VERIFY_SUCCEEDED(hlsl::IsValidDxilContainer(pContainerHeader, pNewProgram->GetBufferSize()));
|
||||
pPartHeader = hlsl::GetDxilPartByType(
|
||||
pContainerHeader, hlsl::DxilFourCC::DFCC_ShaderDebugName);
|
||||
VERIFY_IS_NULL(pPartHeader);
|
||||
|
@ -1565,8 +1567,8 @@ TEST_F(CompilerTest, CompileWithRootSignatureThenStripRootSignature) {
|
|||
VERIFY_SUCCEEDED(status);
|
||||
VERIFY_SUCCEEDED(pResult->GetResult(&pProgram));
|
||||
VERIFY_IS_NOT_NULL(pProgram);
|
||||
hlsl::DxilContainerHeader *pContainerHeader =
|
||||
(hlsl::DxilContainerHeader *)(pProgram->GetBufferPointer());
|
||||
hlsl::DxilContainerHeader *pContainerHeader = hlsl::IsDxilContainerLike(pProgram->GetBufferPointer(), pProgram->GetBufferSize());
|
||||
VERIFY_SUCCEEDED(hlsl::IsValidDxilContainer(pContainerHeader, pProgram->GetBufferSize()));
|
||||
hlsl::DxilPartHeader *pPartHeader = hlsl::GetDxilPartByType(
|
||||
pContainerHeader, hlsl::DxilFourCC::DFCC_RootSignature);
|
||||
VERIFY_IS_NOT_NULL(pPartHeader);
|
||||
|
@ -1580,7 +1582,8 @@ TEST_F(CompilerTest, CompileWithRootSignatureThenStripRootSignature) {
|
|||
VERIFY_SUCCEEDED(pBuilder->RemovePart(hlsl::DxilFourCC::DFCC_RootSignature));
|
||||
VERIFY_SUCCEEDED(pBuilder->SerializeContainer(&pResult));
|
||||
VERIFY_SUCCEEDED(pResult->GetResult(&pProgramRootSigRemoved));
|
||||
pContainerHeader = (hlsl::DxilContainerHeader *)(pProgramRootSigRemoved->GetBufferPointer());
|
||||
pContainerHeader = hlsl::IsDxilContainerLike(pProgramRootSigRemoved->GetBufferPointer(), pProgramRootSigRemoved->GetBufferSize());
|
||||
VERIFY_SUCCEEDED(hlsl::IsValidDxilContainer(pContainerHeader, pProgramRootSigRemoved->GetBufferSize()));
|
||||
hlsl::DxilPartHeader *pPartHeaderShouldBeNull = hlsl::GetDxilPartByType(pContainerHeader,
|
||||
hlsl::DxilFourCC::DFCC_RootSignature);
|
||||
VERIFY_IS_NULL(pPartHeaderShouldBeNull);
|
||||
|
@ -1599,7 +1602,8 @@ TEST_F(CompilerTest, CompileWithRootSignatureThenStripRootSignature) {
|
|||
pBuilder->AddPart(hlsl::DxilFourCC::DFCC_RootSignature, pRootSignatureBlob);
|
||||
pBuilder->SerializeContainer(&pResult);
|
||||
VERIFY_SUCCEEDED(pResult->GetResult(&pProgramRootSigAdded));
|
||||
pContainerHeader = (hlsl::DxilContainerHeader *)(pProgramRootSigAdded->GetBufferPointer());
|
||||
pContainerHeader = hlsl::IsDxilContainerLike(pProgramRootSigAdded->GetBufferPointer(), pProgramRootSigAdded->GetBufferSize());
|
||||
VERIFY_SUCCEEDED(hlsl::IsValidDxilContainer(pContainerHeader, pProgramRootSigAdded->GetBufferSize()));
|
||||
pPartHeader = hlsl::GetDxilPartByType(pContainerHeader,
|
||||
hlsl::DxilFourCC::DFCC_RootSignature);
|
||||
VERIFY_IS_NOT_NULL(pPartHeader);
|
||||
|
|
|
@ -9,14 +9,14 @@
|
|||
// //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "CompilationResult.h"
|
||||
#include "HLSLTestData.h"
|
||||
#include "dxc/Test/CompilationResult.h"
|
||||
#include "dxc/Test/HLSLTestData.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "WexTestClass.h"
|
||||
#endif
|
||||
#include "HlslTestUtils.h"
|
||||
#include "dxc/Test/HlslTestUtils.h"
|
||||
#include "dxc/Support/microcom.h"
|
||||
|
||||
|
||||
|
|
|
@ -43,9 +43,9 @@
|
|||
#include "llvm/Support/Format.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
#include "HLSLTestData.h"
|
||||
#include "HlslTestUtils.h"
|
||||
#include "DxcTestUtils.h"
|
||||
#include "dxc/Test/HLSLTestData.h"
|
||||
#include "dxc/Test/HlslTestUtils.h"
|
||||
#include "dxc/Test/DxcTestUtils.h"
|
||||
|
||||
#include "dxc/Support/Global.h"
|
||||
#include "dxc/Support/dxcapi.use.h"
|
||||
|
@ -1851,7 +1851,7 @@ TEST_F(DxilContainerTest, DxilContainerUnitTest) {
|
|||
VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"hlsl.hlsl", L"main", L"ps_6_0", arguments.data(), arguments.size(), nullptr, 0, nullptr, &pResult));
|
||||
VERIFY_SUCCEEDED(pResult->GetResult(&pProgram));
|
||||
|
||||
const hlsl::DxilContainerHeader *pHeader = static_cast<const hlsl::DxilContainerHeader *> (pProgram->GetBufferPointer());
|
||||
const hlsl::DxilContainerHeader *pHeader = hlsl::IsDxilContainerLike(pProgram->GetBufferPointer(), pProgram->GetBufferSize());
|
||||
VERIFY_IS_TRUE(hlsl::IsValidDxilContainer(pHeader, pProgram->GetBufferSize()));
|
||||
VERIFY_IS_NOT_NULL(hlsl::IsDxilContainerLike(pHeader, pProgram->GetBufferSize()));
|
||||
VERIFY_IS_NOT_NULL(hlsl::GetDxilProgramHeader(pHeader, hlsl::DxilFourCC::DFCC_DXIL));
|
||||
|
@ -1866,7 +1866,7 @@ TEST_F(DxilContainerTest, DxilContainerUnitTest) {
|
|||
VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"hlsl.hlsl", L"main", L"ps_6_0", nullptr, 0, nullptr, 0, nullptr, &pResult));
|
||||
VERIFY_SUCCEEDED(pResult->GetResult(&pProgram));
|
||||
|
||||
pHeader = static_cast<const hlsl::DxilContainerHeader *> (pProgram->GetBufferPointer());
|
||||
pHeader = hlsl::IsDxilContainerLike(pProgram->GetBufferPointer(), pProgram->GetBufferSize());
|
||||
VERIFY_IS_TRUE(hlsl::IsValidDxilContainer(pHeader, pProgram->GetBufferSize()));
|
||||
VERIFY_IS_NOT_NULL(hlsl::IsDxilContainerLike(pHeader, pProgram->GetBufferSize()));
|
||||
VERIFY_IS_NOT_NULL(hlsl::GetDxilProgramHeader(pHeader, hlsl::DxilFourCC::DFCC_DXIL));
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
// //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "CompilationResult.h"
|
||||
#include "HlslTestUtils.h"
|
||||
#include "DxcTestUtils.h"
|
||||
#include "dxc/Test/CompilationResult.h"
|
||||
#include "dxc/Test/HlslTestUtils.h"
|
||||
#include "dxc/Test/DxcTestUtils.h"
|
||||
#include "dxc/Support/microcom.h"
|
||||
#include "dxc/dxcapi.internal.h"
|
||||
#include "dxc/HLSL/HLOperationLowerExtension.h"
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
#include <unordered_set>
|
||||
#include <strstream>
|
||||
#include <iomanip>
|
||||
#include "CompilationResult.h"
|
||||
#include "HLSLTestData.h"
|
||||
#include "dxc/Test/CompilationResult.h"
|
||||
#include "dxc/Test/HLSLTestData.h"
|
||||
#include <Shlwapi.h>
|
||||
#include <atlcoll.h>
|
||||
#include <locale>
|
||||
|
@ -27,8 +27,8 @@
|
|||
|
||||
#undef _read
|
||||
#include "WexTestClass.h"
|
||||
#include "HlslTestUtils.h"
|
||||
#include "DxcTestUtils.h"
|
||||
#include "dxc/Test/HlslTestUtils.h"
|
||||
#include "dxc/Test/DxcTestUtils.h"
|
||||
#include "dxc/Support/Global.h"
|
||||
#include "dxc/Support/WinIncludes.h"
|
||||
#include "dxc/Support/FileIOHelper.h"
|
||||
|
@ -42,7 +42,7 @@
|
|||
#include <d3d12.h>
|
||||
#include <dxgi1_4.h>
|
||||
#include <DXGIDebug.h>
|
||||
#include <D3dx12.h>
|
||||
#include "dxc/Support/d3dx12.h"
|
||||
#include <DirectXMath.h>
|
||||
#include <strsafe.h>
|
||||
#include <d3dcompiler.h>
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
// //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "CompilationResult.h"
|
||||
#include "HlslTestUtils.h"
|
||||
#include "DxcTestUtils.h"
|
||||
#include "dxc/Test/CompilationResult.h"
|
||||
#include "dxc/Test/HlslTestUtils.h"
|
||||
#include "dxc/Test/DxcTestUtils.h"
|
||||
#include "dxc/Support/microcom.h"
|
||||
#include "dxc/dxcapi.internal.h"
|
||||
#include "dxc/HLSL/HLOperationLowerExtension.h"
|
||||
|
|
|
@ -13,12 +13,12 @@
|
|||
#include <memory>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "CompilationResult.h"
|
||||
#include "HLSLTestData.h"
|
||||
#include "dxc/Test/CompilationResult.h"
|
||||
#include "dxc/Test/HLSLTestData.h"
|
||||
|
||||
#undef _read
|
||||
#include "HlslTestUtils.h"
|
||||
#include "DxcTestUtils.h"
|
||||
#include "dxc/Test/HlslTestUtils.h"
|
||||
#include "dxc/Test/DxcTestUtils.h"
|
||||
#include "dxc/Support/Global.h"
|
||||
#include "dxc/DxilContainer/DxilContainer.h"
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "HLSLTestOptions.h"
|
||||
#include "WEXAdapter.h"
|
||||
#include "dxc/Test/WEXAdapter.h"
|
||||
#include "dxc/Support/WinAdapter.h"
|
||||
|
||||
namespace clang {
|
||||
|
|
|
@ -12,16 +12,16 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "CompilationResult.h"
|
||||
#include "HLSLTestData.h"
|
||||
#include "dxc/Test/CompilationResult.h"
|
||||
#include "dxc/Test/HLSLTestData.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "WexTestClass.h"
|
||||
#include "HlslTestUtils.h"
|
||||
#include "dxc/Test/HlslTestUtils.h"
|
||||
#include "dxc/Test/DxcTestUtils.h"
|
||||
#include "dxc/dxcapi.h"
|
||||
#include "DxcTestUtils.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace hlsl;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <stdint.h>
|
||||
#include <dxc/Support/WinIncludes.h>
|
||||
#include "WexTestClass.h"
|
||||
#include "HlslTestUtils.h"
|
||||
#include "dxc/Test/HlslTestUtils.h"
|
||||
|
||||
#include "llvm/Support/MSFileSystem.h"
|
||||
#include "llvm/Support/Atomic.h"
|
||||
|
|
|
@ -8,14 +8,14 @@
|
|||
// //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "CompilationResult.h"
|
||||
#include "HLSLTestData.h"
|
||||
#include "dxc/Test/CompilationResult.h"
|
||||
#include "dxc/Test/HLSLTestData.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "WexTestClass.h"
|
||||
#endif
|
||||
#include "HlslTestUtils.h"
|
||||
#include "dxc/Test/HlslTestUtils.h"
|
||||
|
||||
#include <exception>
|
||||
#include <set>
|
||||
|
|
|
@ -24,9 +24,9 @@
|
|||
#include "dxc/Support/WinIncludes.h"
|
||||
#include "dxc/dxcapi.h"
|
||||
|
||||
#include "HLSLTestData.h"
|
||||
#include "HlslTestUtils.h"
|
||||
#include "DxcTestUtils.h"
|
||||
#include "dxc/Test/HLSLTestData.h"
|
||||
#include "dxc/Test/HlslTestUtils.h"
|
||||
#include "dxc/Test/DxcTestUtils.h"
|
||||
|
||||
#include "llvm/Support/raw_os_ostream.h"
|
||||
#include "dxc/Support/Global.h"
|
||||
|
|
|
@ -22,11 +22,11 @@
|
|||
#include "dxc/Support/WinIncludes.h"
|
||||
#include "dxc/dxcapi.h"
|
||||
|
||||
#include "HLSLTestData.h"
|
||||
#include "dxc/Test/HLSLTestData.h"
|
||||
#ifdef _WIN32
|
||||
#include "WexTestClass.h"
|
||||
#endif
|
||||
#include "HlslTestUtils.h"
|
||||
#include "dxc/Test/HlslTestUtils.h"
|
||||
|
||||
#include "llvm/Support/raw_os_ostream.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
|
|
|
@ -32,10 +32,10 @@
|
|||
#include <atlbase.h>
|
||||
#include <atlfile.h>
|
||||
|
||||
#include "HLSLTestData.h"
|
||||
#include "WexTestClass.h"
|
||||
#include "HlslTestUtils.h"
|
||||
#include "DxcTestUtils.h"
|
||||
#include "dxc/Test/HLSLTestData.h"
|
||||
#include "dxc/Test/HlslTestUtils.h"
|
||||
#include "dxc/Test/DxcTestUtils.h"
|
||||
|
||||
#include "dxc/Support/Global.h"
|
||||
#include "dxc/dxctools.h"
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <windows.h>
|
||||
#include <d3d12.h>
|
||||
#include <dxgi1_4.h>
|
||||
#include <D3dx12.h>
|
||||
#include "dxc/Support/d3dx12.h"
|
||||
#include <d3dcompiler.h>
|
||||
#include <atlbase.h>
|
||||
#include <atlenc.h>
|
||||
|
@ -25,7 +25,7 @@
|
|||
#include "dxc/Support/dxcapi.use.h" // DxcDllSupport
|
||||
#include "dxc/DXIL/DxilConstants.h" // ComponentType
|
||||
#include "WexTestClass.h" // TAEF
|
||||
#include "HLSLTestUtils.h" // LogCommentFmt
|
||||
#include "dxc/Test/HLSLTestUtils.h" // LogCommentFmt
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <DirectXMath.h>
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
#include "dxc/Support/WinIncludes.h"
|
||||
#include "dxc/dxcapi.h"
|
||||
|
||||
#include "HlslTestUtils.h"
|
||||
#include "DxcTestUtils.h"
|
||||
#include "dxc/Test/HlslTestUtils.h"
|
||||
#include "dxc/Test/DxcTestUtils.h"
|
||||
|
||||
#include "llvm/Support/raw_os_ostream.h"
|
||||
#include "dxc/Support/Global.h"
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "llvm/Support/Signals.h"
|
||||
|
||||
#include "HLSLTestOptions.h"
|
||||
#include "WEXAdapter.h"
|
||||
#include "dxc/Test/WEXAdapter.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
#include "dxc/Support/Global.h"
|
||||
#include "dxc/Support/FileIOHelper.h"
|
||||
|
||||
#include "DxcTestUtils.h"
|
||||
#include "HlslTestUtils.h"
|
||||
#include "dxc/Test/DxcTestUtils.h"
|
||||
#include "dxc/Test/HlslTestUtils.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace hlsl;
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
#include <memory>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "CompilationResult.h"
|
||||
#include "HLSLTestData.h"
|
||||
#include "dxc/Test/CompilationResult.h"
|
||||
#include "dxc/Test/HLSLTestData.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
|||
#else
|
||||
#define TEST_CLASS_DERIVATION : public ::testing::Test
|
||||
#endif
|
||||
#include "HlslTestUtils.h"
|
||||
#include "dxc/Test/HlslTestUtils.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,27 @@
|
|||
|
||||
if(WIN32)
|
||||
find_package(TAEF REQUIRED)
|
||||
include_directories(${TAEF_INCLUDE_DIRS})
|
||||
|
||||
add_clang_library(HLSLTestLib
|
||||
D3DReflectionDumper.cpp
|
||||
DxcTestUtils.cpp
|
||||
FileCheckerTest.cpp
|
||||
FileCheckForTest.cpp
|
||||
)
|
||||
else(WIN32)
|
||||
set(HLSL_IGNORE_SOURCES
|
||||
D3DReflectionDumper.cpp
|
||||
FileCheckerTest.cpp
|
||||
)
|
||||
add_clang_library(HLSLTestLib
|
||||
DxcTestUtils.cpp
|
||||
FileCheckForTest.cpp
|
||||
)
|
||||
include_directories(${DXC_GTEST_DIR}/googletest/include)
|
||||
include_directories(${DXC_GTEST_DIR}/googlemock/include)
|
||||
endif(WIN32)
|
||||
|
||||
add_dependencies(HLSLTestLib TablegenHLSLOptions)
|
||||
|
||||
set_target_properties(HLSLTestLib PROPERTIES FOLDER "Clang tests")
|
|
@ -10,7 +10,7 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "dxc/Support/Global.h"
|
||||
#include "D3DReflectionDumper.h"
|
||||
#include "dxc/test/D3DReflectionDumper.h"
|
||||
#include "dxc/DxilContainer/DxilContainer.h"
|
||||
#include <sstream>
|
||||
|
|
@ -9,9 +9,9 @@
|
|||
// //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "CompilationResult.h"
|
||||
#include "DxcTestUtils.h"
|
||||
#include "HlslTestUtils.h"
|
||||
#include "dxc/Test/CompilationResult.h"
|
||||
#include "dxc/Test/DxcTestUtils.h"
|
||||
#include "dxc/Test/HlslTestUtils.h"
|
||||
#include "dxc/Support/HLSLOptions.h"
|
||||
#include "dxc/Support/Global.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
|
@ -38,7 +38,7 @@
|
|||
// HLSL Change
|
||||
#include <dxc/Support/WinIncludes.h>
|
||||
#include "llvm/Support/MSFileSystem.h"
|
||||
#include "DxcTestUtils.h"
|
||||
#include "dxc/Test/DxcTestUtils.h"
|
||||
// End HLSL Change
|
||||
|
||||
using namespace llvm;
|
|
@ -25,9 +25,9 @@
|
|||
#include <atlfile.h>
|
||||
#endif
|
||||
|
||||
#include "HLSLTestData.h"
|
||||
#include "HlslTestUtils.h"
|
||||
#include "DxcTestUtils.h"
|
||||
#include "dxc/Test/HlslTestData.h"
|
||||
#include "dxc/Test/HlslTestUtils.h"
|
||||
#include "dxc/Test/DxcTestUtils.h"
|
||||
|
||||
#include "llvm/Support/raw_os_ostream.h"
|
||||
#include "llvm/Support/MD5.h"
|
||||
|
@ -36,7 +36,7 @@
|
|||
#include "dxc/Support/HLSLOptions.h"
|
||||
#include "dxc/Support/Unicode.h"
|
||||
#include "dxc/DxilContainer/DxilContainer.h"
|
||||
#include "D3DReflectionDumper.h"
|
||||
#include "dxc/Test/D3DReflectionDumper.h"
|
||||
|
||||
#include "d3d12shader.h"
|
||||
|
||||
|
@ -55,7 +55,8 @@ FileRunCommandResult FileRunCommandPart::RunHashTests(dxc::DxcDllSupport &DllSup
|
|||
}
|
||||
}
|
||||
|
||||
FileRunCommandResult FileRunCommandPart::Run(dxc::DxcDllSupport &DllSupport, const FileRunCommandResult *Prior) {
|
||||
FileRunCommandResult FileRunCommandPart::Run(dxc::DxcDllSupport &DllSupport, const FileRunCommandResult *Prior,
|
||||
PluginToolsPaths *pPluginToolsPaths /*=nullptr*/) {
|
||||
bool isFileCheck =
|
||||
0 == _stricmp(Command.c_str(), "FileCheck") ||
|
||||
0 == _stricmp(Command.c_str(), "%FileCheck");
|
||||
|
@ -79,6 +80,9 @@ FileRunCommandResult FileRunCommandPart::Run(dxc::DxcDllSupport &DllSupport, con
|
|||
else if (0 == _stricmp(Command.c_str(), "tee")) {
|
||||
return RunTee(Prior);
|
||||
}
|
||||
else if (0 == _stricmp(Command.c_str(), "fc")) {
|
||||
return RunFileCompareText(Prior);
|
||||
}
|
||||
else if (0 == _stricmp(Command.c_str(), "%dxilver")) {
|
||||
return RunDxilVer(DllSupport, Prior);
|
||||
}
|
||||
|
@ -94,13 +98,17 @@ FileRunCommandResult FileRunCommandPart::Run(dxc::DxcDllSupport &DllSupport, con
|
|||
else if (0 == _stricmp(Command.c_str(), "%D3DReflect")) {
|
||||
return RunD3DReflect(DllSupport, Prior);
|
||||
}
|
||||
else {
|
||||
FileRunCommandResult result {};
|
||||
result.ExitCode = 1;
|
||||
result.StdErr = "Unrecognized command ";
|
||||
result.StdErr += Command;
|
||||
return result;
|
||||
else if (pPluginToolsPaths != nullptr) {
|
||||
auto it = pPluginToolsPaths->find(Command.c_str());
|
||||
if (it != pPluginToolsPaths->end()) {
|
||||
return RunFromPath(it->second, Prior);
|
||||
}
|
||||
}
|
||||
FileRunCommandResult result {};
|
||||
result.ExitCode = 1;
|
||||
result.StdErr = "Unrecognized command ";
|
||||
result.StdErr += Command;
|
||||
return result;
|
||||
}
|
||||
|
||||
FileRunCommandResult FileRunCommandPart::RunFileChecker(const FileRunCommandResult *Prior) {
|
||||
|
@ -647,6 +655,92 @@ FileRunCommandResult FileRunCommandPart::RunTee(const FileRunCommandResult *Prio
|
|||
return *Prior;
|
||||
}
|
||||
|
||||
void FileRunCommandPart::SubstituteFilenameVars(std::string &args) {
|
||||
size_t pos;
|
||||
std::string baseFileName = CW2A(CommandFileName);
|
||||
if ((pos = baseFileName.find_last_of(".")) != std::string::npos) {
|
||||
baseFileName = baseFileName.substr(0, pos);
|
||||
}
|
||||
while ((pos = args.find("%t")) != std::string::npos) {
|
||||
args.replace(pos, 2, baseFileName.c_str());
|
||||
}
|
||||
while ((pos = args.find("%b")) != std::string::npos) {
|
||||
args.replace(pos, 2, baseFileName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
#if _WIN32
|
||||
bool FileRunCommandPart::ReadFileContentToString(HANDLE hFile, std::string &str) {
|
||||
char buffer[1024];
|
||||
DWORD len;
|
||||
|
||||
size_t size = ::GetFileSize(hFile, nullptr);
|
||||
if (size == INVALID_FILE_SIZE) {
|
||||
return false;
|
||||
}
|
||||
str.reserve(size);
|
||||
|
||||
if (::SetFilePointer(hFile, 0, nullptr, FILE_BEGIN) == INVALID_SET_FILE_POINTER) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (::ReadFile(hFile, buffer, sizeof(buffer), &len, nullptr) && len > 0) {
|
||||
str.append(buffer, len);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
FileRunCommandResult FileRunCommandPart::RunFileCompareText(const FileRunCommandResult *Prior) {
|
||||
if (Prior != nullptr) {
|
||||
return FileRunCommandResult::Error("prior command not supported");
|
||||
}
|
||||
|
||||
FileRunCommandResult result;
|
||||
result.ExitCode = 1;
|
||||
|
||||
// strip leading and trailing spaces and split
|
||||
std::string args(strtrim(Arguments));
|
||||
size_t pos;
|
||||
if ((pos = args.find_first_of(' ')) == std::string::npos) {
|
||||
return FileRunCommandResult::Error("RunFileCompareText expected 2 file arguments.");
|
||||
}
|
||||
std::string fileName1 = args.substr(0, pos);
|
||||
std::string fileName2 = strtrim(args.substr(pos + 1));
|
||||
|
||||
// replace %t and %b with the command file name without extension
|
||||
SubstituteFilenameVars(fileName1);
|
||||
SubstituteFilenameVars(fileName2);
|
||||
|
||||
// read file content and compare
|
||||
CA2W fileName1W(fileName1.c_str());
|
||||
CA2W fileName2W(fileName2.c_str());
|
||||
hlsl_test::LogCommentFmt(L"Comparing files %s and %s", fileName1W.m_psz, fileName2W.m_psz);
|
||||
|
||||
std::ifstream ifs1(fileName1, std::ifstream::in);
|
||||
if (ifs1.fail()) {
|
||||
hlsl_test::LogCommentFmt(L"Failed to open %s", fileName1W.m_psz);
|
||||
return result;
|
||||
}
|
||||
std::string file1Content((std::istreambuf_iterator<char>(ifs1)), (std::istreambuf_iterator<char>()));
|
||||
|
||||
std::ifstream ifs2(fileName2, std::ifstream::in);
|
||||
if (ifs2.fail()) {
|
||||
hlsl_test::LogCommentFmt(L"Failed to open %s", fileName2W.m_psz);
|
||||
return result;
|
||||
}
|
||||
std::string file2Content((std::istreambuf_iterator<char>(ifs2)), (std::istreambuf_iterator<char>()));
|
||||
|
||||
if (file1Content.compare(file2Content) == 0) {
|
||||
hlsl_test::LogCommentFmt(L"No differences found.");
|
||||
result.ExitCode = 0;
|
||||
}
|
||||
else {
|
||||
hlsl_test::LogCommentFmt(L"Files are different!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
FileRunCommandResult FileRunCommandPart::RunXFail(const FileRunCommandResult *Prior) {
|
||||
if (Prior == nullptr)
|
||||
return FileRunCommandResult::Error("XFail requires a prior command");
|
||||
|
@ -670,8 +764,90 @@ FileRunCommandResult FileRunCommandPart::RunDxilVer(dxc::DxcDllSupport& DllSuppo
|
|||
return CheckDxilVer(DllSupport, RequiredDxilMajor, RequiredDxilMinor);
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
FileRunCommandResult FileRunCommandPart::RunFromPath(const std::string &toolPath, const FileRunCommandResult *Prior) {
|
||||
return FileRunCommandResult::Error("RunFromPath not supported");
|
||||
}
|
||||
#else //_WIN32
|
||||
FileRunCommandResult FileRunCommandPart::RunFromPath(const std::string &toolPath, const FileRunCommandResult *Prior) {
|
||||
if (Prior != nullptr) {
|
||||
return FileRunCommandResult::Error("prior command not supported");
|
||||
}
|
||||
|
||||
std::string args = Arguments;
|
||||
|
||||
// replace %s with command file name
|
||||
size_t pos;
|
||||
while ((pos = args.find("%s")) != std::string::npos) {
|
||||
args.replace(pos, 2, CW2A(CommandFileName));
|
||||
}
|
||||
|
||||
// replace %t and %b with the command file name without extension
|
||||
SubstituteFilenameVars(args);
|
||||
|
||||
// Run the tool via CreateProcess, redirect stdout and strerr to temporary files
|
||||
std::wstring stdOutFileName = std::wstring(CommandFileName) + L".tmp_stdout";
|
||||
std::wstring stdErrFileName = std::wstring(CommandFileName) + L".tmp_stderr";
|
||||
|
||||
SECURITY_ATTRIBUTES sa;
|
||||
ZeroMemory(&sa, sizeof(sa));
|
||||
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||
sa.bInheritHandle = true;
|
||||
|
||||
HANDLE hStdOutFile = CreateFileW(stdOutFileName.c_str(), GENERIC_READ | GENERIC_WRITE, 0, &sa,
|
||||
CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, nullptr);
|
||||
IFT(hStdOutFile != INVALID_HANDLE_VALUE);
|
||||
HANDLE hStdErrFile = CreateFileW(stdErrFileName.c_str(), GENERIC_READ | GENERIC_WRITE, 0, &sa,
|
||||
CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, nullptr);
|
||||
IFT(hStdErrFile!= INVALID_HANDLE_VALUE);
|
||||
|
||||
STARTUPINFOA si;
|
||||
ZeroMemory(&si, sizeof(si));
|
||||
si.cb = sizeof(si);
|
||||
si.hStdOutput = hStdOutFile;
|
||||
si.hStdError = hStdErrFile;
|
||||
si.dwFlags |= STARTF_USESTDHANDLES;
|
||||
|
||||
PROCESS_INFORMATION pi;
|
||||
ZeroMemory(&pi, sizeof(pi));
|
||||
|
||||
std::vector<char> args2(args.c_str(), args.c_str() + args.size() + 1); // args to CreateProcess cannot be const char *
|
||||
if (!CreateProcessA(toolPath.c_str(), args2.data(), nullptr, nullptr, true, 0, nullptr, nullptr, &si, &pi)) {
|
||||
return FileRunCommandResult::Error("CreateProcess failed.");
|
||||
}
|
||||
::WaitForSingleObject(pi.hProcess, 10000); // 10s timeout
|
||||
|
||||
// Get exit code of the process
|
||||
FileRunCommandResult result;
|
||||
DWORD exitCode;
|
||||
if (!::GetExitCodeProcess(pi.hProcess, &exitCode)) {
|
||||
result = FileRunCommandResult::Error("GetExitCodeProcess failed.");
|
||||
}
|
||||
else {
|
||||
result.ExitCode = exitCode;
|
||||
}
|
||||
|
||||
// Close process and thread handles
|
||||
::CloseHandle(pi.hProcess);
|
||||
::CloseHandle(pi.hThread);
|
||||
|
||||
// Read stdout and strerr output from temporary files
|
||||
if (!ReadFileContentToString(hStdOutFile, result.StdOut) ||
|
||||
!ReadFileContentToString(hStdErrFile, result.StdErr)) {
|
||||
result = FileRunCommandResult::Error("RunFromPaths failed.");
|
||||
}
|
||||
|
||||
// Close temporary file handles - will delete the files
|
||||
IFT(::CloseHandle(hStdOutFile));
|
||||
IFT(::CloseHandle(hStdErrFile));
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif //_WIN32
|
||||
|
||||
class FileRunTestResultImpl : public FileRunTestResult {
|
||||
dxc::DxcDllSupport &m_support;
|
||||
PluginToolsPaths *m_pPluginToolsPaths;
|
||||
|
||||
void RunHashTestFromCommands(LPCSTR commands, LPCWSTR fileName) {
|
||||
std::vector<FileRunCommandPart> parts;
|
||||
|
@ -705,7 +881,7 @@ class FileRunTestResultImpl : public FileRunTestResult {
|
|||
FileRunCommandResult result;
|
||||
FileRunCommandResult* previousResult = nullptr;
|
||||
for (FileRunCommandPart & part : parts) {
|
||||
result = part.Run(m_support, previousResult);
|
||||
result = part.Run(m_support, previousResult, m_pPluginToolsPaths);
|
||||
previousResult = &result;
|
||||
if (result.AbortPipeline) break;
|
||||
}
|
||||
|
@ -715,7 +891,8 @@ class FileRunTestResultImpl : public FileRunTestResult {
|
|||
}
|
||||
|
||||
public:
|
||||
FileRunTestResultImpl(dxc::DxcDllSupport &support) : m_support(support) {}
|
||||
FileRunTestResultImpl(dxc::DxcDllSupport &support, PluginToolsPaths *pPluginToolsPaths = nullptr)
|
||||
: m_support(support), m_pPluginToolsPaths(pPluginToolsPaths) {}
|
||||
void RunFileCheckFromFileCommands(LPCWSTR fileName) {
|
||||
// Assume UTF-8 files.
|
||||
auto cmds = GetRunLines(fileName);
|
||||
|
@ -743,16 +920,18 @@ FileRunTestResult FileRunTestResult::RunHashTestFromFileCommands(LPCWSTR fileNam
|
|||
return result;
|
||||
}
|
||||
|
||||
FileRunTestResult FileRunTestResult::RunFromFileCommands(LPCWSTR fileName) {
|
||||
FileRunTestResult FileRunTestResult::RunFromFileCommands(LPCWSTR fileName,
|
||||
PluginToolsPaths *pPluginToolsPaths /*=nullptr*/) {
|
||||
dxc::DxcDllSupport dllSupport;
|
||||
IFT(dllSupport.Initialize());
|
||||
FileRunTestResultImpl result(dllSupport);
|
||||
FileRunTestResultImpl result(dllSupport, pPluginToolsPaths);
|
||||
result.RunFileCheckFromFileCommands(fileName);
|
||||
return result;
|
||||
}
|
||||
|
||||
FileRunTestResult FileRunTestResult::RunFromFileCommands(LPCWSTR fileName, dxc::DxcDllSupport &dllSupport) {
|
||||
FileRunTestResultImpl result(dllSupport);
|
||||
FileRunTestResult FileRunTestResult::RunFromFileCommands(LPCWSTR fileName, dxc::DxcDllSupport &dllSupport,
|
||||
PluginToolsPaths *pPluginToolsPaths /*=nullptr*/) {
|
||||
FileRunTestResultImpl result(dllSupport, pPluginToolsPaths);
|
||||
result.RunFileCheckFromFileCommands(fileName);
|
||||
return result;
|
||||
}
|
|
@ -408,10 +408,9 @@ HRESULT DxcContext::ReadFileIntoPartContent(hlsl::DxilFourCC fourCC,
|
|||
hlsl::ReadBinaryFile(fileName, (void **)&pData, &dataSize);
|
||||
DXASSERT(pData != nullptr,
|
||||
"otherwise ReadBinaryFile should throw an exception");
|
||||
hlsl::DxilContainerHeader *pHeader =
|
||||
(hlsl::DxilContainerHeader *)pData.m_pData;
|
||||
IFRBOOL(hlsl::IsDxilContainerLike(pHeader, pHeader->ContainerSizeInBytes),
|
||||
E_INVALIDARG);
|
||||
hlsl::DxilContainerHeader *pHeader =
|
||||
hlsl::IsDxilContainerLike(pData.m_pData, dataSize);
|
||||
IFRBOOL(IsValidDxilContainer(pHeader, dataSize), E_INVALIDARG);
|
||||
hlsl::DxilPartHeader *pPartHeader =
|
||||
hlsl::GetDxilPartByType(pHeader, hlsl::DxilFourCC::DFCC_RootSignature);
|
||||
IFRBOOL(pPartHeader != nullptr, E_INVALIDARG);
|
||||
|
|
|
@ -11,12 +11,13 @@ set(LLVM_LINK_COMPONENTS
|
|||
# Instrumentation # HLSL Change
|
||||
# MC # HLSL Change
|
||||
# ObjCARCOpts # HLSL Change
|
||||
Passes
|
||||
PassPrinters # HLSL Change
|
||||
ScalarOpts
|
||||
Support
|
||||
Target
|
||||
TransformUtils
|
||||
Vectorize
|
||||
Passes
|
||||
)
|
||||
|
||||
# Support plugins.
|
||||
|
@ -29,7 +30,6 @@ add_llvm_tool(opt
|
|||
BreakpointPrinter.cpp
|
||||
GraphPrinters.cpp
|
||||
NewPMDriver.cpp
|
||||
PassPrinters.cpp
|
||||
PrintSCC.cpp
|
||||
opt.cpp
|
||||
)
|
||||
|
|
|
@ -19,7 +19,7 @@ if errorlevel 1 (
|
|||
echo Failed to clean binaries, stopping hctcheckin.
|
||||
exit /b 1
|
||||
)
|
||||
call %HLSL_SRC_DIR%\utils\hct\hctbuild.cmd
|
||||
call %HLSL_SRC_DIR%\utils\hct\hctbuild.cmd -parallel
|
||||
if errorlevel 1 (
|
||||
echo Failed to build binaries, stopping hctcheckin.
|
||||
exit /b 1
|
||||
|
|
Загрузка…
Ссылка в новой задаче