[NFC] Clang-format DXC sources (#5602)
This change applies clang-format to all of the sources added in DXC that were not part of the original LLVM/Clang 3.7 release when DXC forked. This provides consistent code formatting across the codebase. Fixes #5591.
This commit is contained in:
Родитель
d949f78f69
Коммит
37ed613864
|
@ -11,14 +11,14 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "dxc/DXIL/DxilConstants.h"
|
||||
#include "dxc/DXIL/DxilShaderModel.h"
|
||||
#include "dxc/DXIL/DxilCompType.h"
|
||||
#include "dxc/DXIL/DxilInterpolationMode.h"
|
||||
#include "dxc/DXIL/DxilSemantic.h"
|
||||
#include "dxc/DXIL/DxilSignatureElement.h"
|
||||
#include "dxc/DXIL/DxilCBuffer.h"
|
||||
#include "dxc/DXIL/DxilCompType.h"
|
||||
#include "dxc/DXIL/DxilConstants.h"
|
||||
#include "dxc/DXIL/DxilInterpolationMode.h"
|
||||
#include "dxc/DXIL/DxilModule.h"
|
||||
#include "dxc/DXIL/DxilOperations.h"
|
||||
#include "dxc/DXIL/DxilResource.h"
|
||||
#include "dxc/DXIL/DxilSampler.h"
|
||||
#include "dxc/DXIL/DxilOperations.h"
|
||||
#include "dxc/DXIL/DxilModule.h"
|
||||
#include "dxc/DXIL/DxilSemantic.h"
|
||||
#include "dxc/DXIL/DxilShaderModel.h"
|
||||
#include "dxc/DXIL/DxilSignatureElement.h"
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
#include "dxc/DXIL/DxilResourceBase.h"
|
||||
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
/// Use this class to represent HLSL cbuffer.
|
||||
|
@ -27,7 +26,7 @@ public:
|
|||
void SetSize(unsigned InstanceSizeInBytes);
|
||||
|
||||
private:
|
||||
unsigned m_SizeInBytes; // Cbuffer instance size in bytes.
|
||||
unsigned m_SizeInBytes; // Cbuffer instance size in bytes.
|
||||
};
|
||||
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -17,8 +17,7 @@ namespace llvm {
|
|||
class Type;
|
||||
class PointerType;
|
||||
class LLVMContext;
|
||||
}
|
||||
|
||||
} // namespace llvm
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
|
@ -70,19 +69,20 @@ public:
|
|||
CompType GetBaseCompType() const;
|
||||
bool HasMinPrec() const;
|
||||
llvm::Type *GetLLVMType(llvm::LLVMContext &Ctx) const;
|
||||
llvm::PointerType *GetLLVMPtrType(llvm::LLVMContext &Ctx, const unsigned AddrSpace = 0) const;
|
||||
llvm::PointerType *GetLLVMPtrType(llvm::LLVMContext &Ctx,
|
||||
const unsigned AddrSpace = 0) const;
|
||||
llvm::Type *GetLLVMBaseType(llvm::LLVMContext &Ctx) const;
|
||||
|
||||
/// Get the component type for a given llvm type.
|
||||
///
|
||||
/// LLVM types do not hold sign information so there is no 1-1
|
||||
/// correspondence between llvm types and component types.
|
||||
/// correspondence between llvm types and component types.
|
||||
/// This method returns the signed version for all integer
|
||||
/// types.
|
||||
///
|
||||
///
|
||||
/// TODO: decide if we should distinguish between signed
|
||||
/// and unsigned types in this api.
|
||||
static CompType GetCompType(llvm::Type * type);
|
||||
static CompType GetCompType(llvm::Type *type);
|
||||
|
||||
const char *GetName() const;
|
||||
const char *GetHLSLName(bool MinPrecision) const;
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
#include "dxc/DXIL/DxilSignature.h"
|
||||
#include "dxc/DXIL/DxilFunctionProps.h"
|
||||
#include "dxc/DXIL/DxilSignature.h"
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
|
@ -21,7 +21,6 @@ public:
|
|||
DxilFunctionProps props;
|
||||
DxilEntryProps(DxilFunctionProps &p, bool bUseMinPrecision)
|
||||
: sig(p.shaderKind, bUseMinPrecision), props(p) {}
|
||||
DxilEntryProps(DxilEntryProps &p)
|
||||
: sig(p.sig), props(p.props) {}
|
||||
DxilEntryProps(DxilEntryProps &p) : sig(p.sig), props(p.props) {}
|
||||
};
|
||||
}
|
||||
} // namespace hlsl
|
|
@ -20,7 +20,7 @@
|
|||
namespace llvm {
|
||||
class Function;
|
||||
class Constant;
|
||||
}
|
||||
} // namespace llvm
|
||||
|
||||
namespace hlsl {
|
||||
struct DxilFunctionProps {
|
||||
|
@ -88,33 +88,43 @@ struct DxilFunctionProps {
|
|||
} AS;
|
||||
} ShaderProps;
|
||||
DXIL::ShaderKind shaderKind;
|
||||
// WaveSize is currently allowed only on compute shaders, but could be supported on other shader types in the future
|
||||
// WaveSize is currently allowed only on compute shaders, but could be
|
||||
// supported on other shader types in the future
|
||||
unsigned waveSize;
|
||||
// Save root signature for lib profile entry.
|
||||
std::vector<uint8_t> serializedRootSignature;
|
||||
void SetSerializedRootSignature(const uint8_t *pData, unsigned size) {
|
||||
serializedRootSignature.assign(pData, pData+size);
|
||||
serializedRootSignature.assign(pData, pData + size);
|
||||
}
|
||||
|
||||
// TODO: Should we have an unmangled name here for ray tracing shaders?
|
||||
bool IsPS() const { return shaderKind == DXIL::ShaderKind::Pixel; }
|
||||
bool IsVS() const { return shaderKind == DXIL::ShaderKind::Vertex; }
|
||||
bool IsGS() const { return shaderKind == DXIL::ShaderKind::Geometry; }
|
||||
bool IsHS() const { return shaderKind == DXIL::ShaderKind::Hull; }
|
||||
bool IsDS() const { return shaderKind == DXIL::ShaderKind::Domain; }
|
||||
bool IsCS() const { return shaderKind == DXIL::ShaderKind::Compute; }
|
||||
bool IsPS() const { return shaderKind == DXIL::ShaderKind::Pixel; }
|
||||
bool IsVS() const { return shaderKind == DXIL::ShaderKind::Vertex; }
|
||||
bool IsGS() const { return shaderKind == DXIL::ShaderKind::Geometry; }
|
||||
bool IsHS() const { return shaderKind == DXIL::ShaderKind::Hull; }
|
||||
bool IsDS() const { return shaderKind == DXIL::ShaderKind::Domain; }
|
||||
bool IsCS() const { return shaderKind == DXIL::ShaderKind::Compute; }
|
||||
bool IsGraphics() const {
|
||||
return (shaderKind >= DXIL::ShaderKind::Pixel && shaderKind <= DXIL::ShaderKind::Domain) ||
|
||||
shaderKind == DXIL::ShaderKind::Mesh || shaderKind == DXIL::ShaderKind::Amplification;
|
||||
return (shaderKind >= DXIL::ShaderKind::Pixel &&
|
||||
shaderKind <= DXIL::ShaderKind::Domain) ||
|
||||
shaderKind == DXIL::ShaderKind::Mesh ||
|
||||
shaderKind == DXIL::ShaderKind::Amplification;
|
||||
}
|
||||
bool IsRayGeneration() const {
|
||||
return shaderKind == DXIL::ShaderKind::RayGeneration;
|
||||
}
|
||||
bool IsIntersection() const {
|
||||
return shaderKind == DXIL::ShaderKind::Intersection;
|
||||
}
|
||||
bool IsRayGeneration() const { return shaderKind == DXIL::ShaderKind::RayGeneration; }
|
||||
bool IsIntersection() const { return shaderKind == DXIL::ShaderKind::Intersection; }
|
||||
bool IsAnyHit() const { return shaderKind == DXIL::ShaderKind::AnyHit; }
|
||||
bool IsClosestHit() const { return shaderKind == DXIL::ShaderKind::ClosestHit; }
|
||||
bool IsClosestHit() const {
|
||||
return shaderKind == DXIL::ShaderKind::ClosestHit;
|
||||
}
|
||||
bool IsMiss() const { return shaderKind == DXIL::ShaderKind::Miss; }
|
||||
bool IsCallable() const { return shaderKind == DXIL::ShaderKind::Callable; }
|
||||
bool IsRay() const {
|
||||
return (shaderKind >= DXIL::ShaderKind::RayGeneration && shaderKind <= DXIL::ShaderKind::Callable);
|
||||
return (shaderKind >= DXIL::ShaderKind::RayGeneration &&
|
||||
shaderKind <= DXIL::ShaderKind::Callable);
|
||||
}
|
||||
bool IsMS() const { return shaderKind == DXIL::ShaderKind::Mesh; }
|
||||
bool IsAS() const { return shaderKind == DXIL::ShaderKind::Amplification; }
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
namespace hlsl {
|
||||
|
||||
|
||||
/// Use this class to represent signature element interpolation mode.
|
||||
class InterpolationMode {
|
||||
public:
|
||||
|
@ -25,26 +24,35 @@ public:
|
|||
InterpolationMode(const InterpolationMode &Mode) = default;
|
||||
InterpolationMode(Kind Kind);
|
||||
InterpolationMode(unsigned long long Kind);
|
||||
InterpolationMode(bool bNoInterpolation, bool bLinear, bool bNoperspective, bool bCentroid, bool bSample);
|
||||
InterpolationMode(bool bNoInterpolation, bool bLinear, bool bNoperspective,
|
||||
bool bCentroid, bool bSample);
|
||||
InterpolationMode &operator=(const InterpolationMode &o);
|
||||
bool operator==(const InterpolationMode &o) const;
|
||||
|
||||
bool IsValid() const { return m_Kind >= Kind::Undefined && m_Kind < Kind::Invalid; }
|
||||
bool IsUndefined() const { return m_Kind == Kind::Undefined; }
|
||||
bool IsConstant() const { return m_Kind == Kind::Constant; }
|
||||
bool IsLinear() const { return m_Kind == Kind::Linear; }
|
||||
bool IsLinearCentroid() const { return m_Kind == Kind::LinearCentroid; }
|
||||
bool IsLinearNoperspective() const { return m_Kind == Kind::LinearNoperspective; }
|
||||
bool IsLinearNoperspectiveCentroid() const { return m_Kind == Kind::LinearNoperspectiveCentroid; }
|
||||
bool IsLinearSample() const { return m_Kind == Kind::LinearSample; }
|
||||
bool IsLinearNoperspectiveSample() const { return m_Kind == Kind::LinearNoperspectiveSample; }
|
||||
bool IsValid() const {
|
||||
return m_Kind >= Kind::Undefined && m_Kind < Kind::Invalid;
|
||||
}
|
||||
bool IsUndefined() const { return m_Kind == Kind::Undefined; }
|
||||
bool IsConstant() const { return m_Kind == Kind::Constant; }
|
||||
bool IsLinear() const { return m_Kind == Kind::Linear; }
|
||||
bool IsLinearCentroid() const { return m_Kind == Kind::LinearCentroid; }
|
||||
bool IsLinearNoperspective() const {
|
||||
return m_Kind == Kind::LinearNoperspective;
|
||||
}
|
||||
bool IsLinearNoperspectiveCentroid() const {
|
||||
return m_Kind == Kind::LinearNoperspectiveCentroid;
|
||||
}
|
||||
bool IsLinearSample() const { return m_Kind == Kind::LinearSample; }
|
||||
bool IsLinearNoperspectiveSample() const {
|
||||
return m_Kind == Kind::LinearNoperspectiveSample;
|
||||
}
|
||||
|
||||
bool IsAnyLinear() const;
|
||||
bool IsAnyNoPerspective() const;
|
||||
bool IsAnyCentroid() const;
|
||||
bool IsAnySample() const;
|
||||
|
||||
Kind GetKind() const { return m_Kind; }
|
||||
Kind GetKind() const { return m_Kind; }
|
||||
const char *GetName() const;
|
||||
|
||||
private:
|
||||
|
|
|
@ -33,7 +33,7 @@ class NamedMDNode;
|
|||
class GlobalVariable;
|
||||
class StringRef;
|
||||
class Type;
|
||||
}
|
||||
} // namespace llvm
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
|
@ -79,19 +79,20 @@ public:
|
|||
// Dxil version.
|
||||
static const char kDxilVersionMDName[];
|
||||
static const unsigned kDxilVersionNumFields = 2;
|
||||
static const unsigned kDxilVersionMajorIdx = 0; // DXIL version major.
|
||||
static const unsigned kDxilVersionMinorIdx = 1; // DXIL version minor.
|
||||
static const unsigned kDxilVersionMajorIdx = 0; // DXIL version major.
|
||||
static const unsigned kDxilVersionMinorIdx = 1; // DXIL version minor.
|
||||
|
||||
// Shader model.
|
||||
static const char kDxilShaderModelMDName[];
|
||||
static const unsigned kDxilShaderModelNumFields = 3;
|
||||
static const unsigned kDxilShaderModelTypeIdx = 0; // Shader type (vs,ps,cs,gs,ds,hs).
|
||||
static const unsigned kDxilShaderModelMajorIdx = 1; // Shader model major.
|
||||
static const unsigned kDxilShaderModelMinorIdx = 2; // Shader model minor.
|
||||
static const unsigned kDxilShaderModelTypeIdx =
|
||||
0; // Shader type (vs,ps,cs,gs,ds,hs).
|
||||
static const unsigned kDxilShaderModelMajorIdx = 1; // Shader model major.
|
||||
static const unsigned kDxilShaderModelMinorIdx = 2; // Shader model minor.
|
||||
|
||||
// Intermediate codegen/optimizer options, not valid in final DXIL module.
|
||||
static const char kDxilIntermediateOptionsMDName[];
|
||||
static const unsigned kDxilIntermediateOptionsFlags = 0; // Unique element ID.
|
||||
static const unsigned kDxilIntermediateOptionsFlags = 0; // Unique element ID.
|
||||
|
||||
// DxilCounters
|
||||
static const char kDxilCountersMDName[];
|
||||
|
@ -117,7 +118,7 @@ public:
|
|||
|
||||
// Resource binding data
|
||||
static const char kDxilDxcBindingTableMDName[];
|
||||
static const unsigned kDxilDxcBindingTableResourceName = 0;
|
||||
static const unsigned kDxilDxcBindingTableResourceName = 0;
|
||||
static const unsigned kDxilDxcBindingTableResourceClass = 1;
|
||||
static const unsigned kDxilDxcBindingTableResourceIndex = 2;
|
||||
static const unsigned kDxilDxcBindingTableResourceSpace = 3;
|
||||
|
@ -128,118 +129,143 @@ public:
|
|||
static const char kDxilSourceMainFileNameOldMDName[];
|
||||
static const char kDxilSourceArgsOldMDName[];
|
||||
|
||||
static const unsigned kDxilEntryPointNumFields = 5;
|
||||
static const unsigned kDxilEntryPointFunction = 0; // Entry point function symbol.
|
||||
static const unsigned kDxilEntryPointName = 1; // Entry point unmangled name.
|
||||
static const unsigned kDxilEntryPointSignatures = 2; // Entry point signature tuple.
|
||||
static const unsigned kDxilEntryPointResources = 3; // Entry point resource tuple.
|
||||
static const unsigned kDxilEntryPointProperties = 4; // Entry point properties tuple.
|
||||
static const unsigned kDxilEntryPointNumFields = 5;
|
||||
static const unsigned kDxilEntryPointFunction =
|
||||
0; // Entry point function symbol.
|
||||
static const unsigned kDxilEntryPointName = 1; // Entry point unmangled name.
|
||||
static const unsigned kDxilEntryPointSignatures =
|
||||
2; // Entry point signature tuple.
|
||||
static const unsigned kDxilEntryPointResources =
|
||||
3; // Entry point resource tuple.
|
||||
static const unsigned kDxilEntryPointProperties =
|
||||
4; // Entry point properties tuple.
|
||||
|
||||
// Signatures.
|
||||
static const unsigned kDxilNumSignatureFields = 3;
|
||||
static const unsigned kDxilInputSignature = 0; // Shader input signature.
|
||||
static const unsigned kDxilOutputSignature = 1; // Shader output signature.
|
||||
static const unsigned kDxilPatchConstantSignature = 2; // Shader patch constant (PC) signature.
|
||||
static const unsigned kDxilNumSignatureFields = 3;
|
||||
static const unsigned kDxilInputSignature = 0; // Shader input signature.
|
||||
static const unsigned kDxilOutputSignature = 1; // Shader output signature.
|
||||
static const unsigned kDxilPatchConstantSignature =
|
||||
2; // Shader patch constant (PC) signature.
|
||||
|
||||
// Signature Element.
|
||||
static const unsigned kDxilSignatureElementNumFields = 11;
|
||||
static const unsigned kDxilSignatureElementID = 0; // Unique element ID.
|
||||
static const unsigned kDxilSignatureElementName = 1; // Element name.
|
||||
static const unsigned kDxilSignatureElementType = 2; // Element type.
|
||||
static const unsigned kDxilSignatureElementSystemValue = 3; // Effective system value.
|
||||
static const unsigned kDxilSignatureElementIndexVector = 4; // Semantic index vector.
|
||||
static const unsigned kDxilSignatureElementInterpMode = 5; // Interpolation mode.
|
||||
static const unsigned kDxilSignatureElementRows = 6; // Number of rows.
|
||||
static const unsigned kDxilSignatureElementCols = 7; // Number of columns.
|
||||
static const unsigned kDxilSignatureElementStartRow = 8; // Element packing start row.
|
||||
static const unsigned kDxilSignatureElementStartCol = 9; // Element packing start column.
|
||||
static const unsigned kDxilSignatureElementNameValueList = 10; // Name-value list for extended properties.
|
||||
static const unsigned kDxilSignatureElementNumFields = 11;
|
||||
static const unsigned kDxilSignatureElementID = 0; // Unique element ID.
|
||||
static const unsigned kDxilSignatureElementName = 1; // Element name.
|
||||
static const unsigned kDxilSignatureElementType = 2; // Element type.
|
||||
static const unsigned kDxilSignatureElementSystemValue =
|
||||
3; // Effective system value.
|
||||
static const unsigned kDxilSignatureElementIndexVector =
|
||||
4; // Semantic index vector.
|
||||
static const unsigned kDxilSignatureElementInterpMode =
|
||||
5; // Interpolation mode.
|
||||
static const unsigned kDxilSignatureElementRows = 6; // Number of rows.
|
||||
static const unsigned kDxilSignatureElementCols = 7; // Number of columns.
|
||||
static const unsigned kDxilSignatureElementStartRow =
|
||||
8; // Element packing start row.
|
||||
static const unsigned kDxilSignatureElementStartCol =
|
||||
9; // Element packing start column.
|
||||
static const unsigned kDxilSignatureElementNameValueList =
|
||||
10; // Name-value list for extended properties.
|
||||
|
||||
// Signature Element Extended Properties.
|
||||
static const unsigned kDxilSignatureElementOutputStreamTag = 0;
|
||||
static const unsigned kHLSignatureElementGlobalSymbolTag = 1;
|
||||
static const unsigned kDxilSignatureElementDynIdxCompMaskTag = 2;
|
||||
static const unsigned kDxilSignatureElementUsageCompMaskTag = 3;
|
||||
static const unsigned kDxilSignatureElementOutputStreamTag = 0;
|
||||
static const unsigned kHLSignatureElementGlobalSymbolTag = 1;
|
||||
static const unsigned kDxilSignatureElementDynIdxCompMaskTag = 2;
|
||||
static const unsigned kDxilSignatureElementUsageCompMaskTag = 3;
|
||||
|
||||
// Resources.
|
||||
static const char kDxilResourcesMDName[];
|
||||
static const unsigned kDxilNumResourceFields = 4;
|
||||
static const unsigned kDxilResourceSRVs = 0;
|
||||
static const unsigned kDxilResourceUAVs = 1;
|
||||
static const unsigned kDxilResourceCBuffers = 2;
|
||||
static const unsigned kDxilResourceSamplers = 3;
|
||||
static const unsigned kDxilNumResourceFields = 4;
|
||||
static const unsigned kDxilResourceSRVs = 0;
|
||||
static const unsigned kDxilResourceUAVs = 1;
|
||||
static const unsigned kDxilResourceCBuffers = 2;
|
||||
static const unsigned kDxilResourceSamplers = 3;
|
||||
|
||||
// ResourceBase.
|
||||
static const unsigned kDxilResourceBaseNumFields = 6;
|
||||
static const unsigned kDxilResourceBaseID = 0; // Unique (per type) resource ID.
|
||||
static const unsigned kDxilResourceBaseVariable = 1; // Resource global variable.
|
||||
static const unsigned kDxilResourceBaseName = 2; // Original (HLSL) name of the resource.
|
||||
static const unsigned kDxilResourceBaseSpaceID = 3; // Resource range space ID.
|
||||
static const unsigned kDxilResourceBaseLowerBound = 4; // Resource range lower bound.
|
||||
static const unsigned kDxilResourceBaseRangeSize = 5; // Resource range size.
|
||||
static const unsigned kDxilResourceBaseNumFields = 6;
|
||||
static const unsigned kDxilResourceBaseID =
|
||||
0; // Unique (per type) resource ID.
|
||||
static const unsigned kDxilResourceBaseVariable =
|
||||
1; // Resource global variable.
|
||||
static const unsigned kDxilResourceBaseName =
|
||||
2; // Original (HLSL) name of the resource.
|
||||
static const unsigned kDxilResourceBaseSpaceID =
|
||||
3; // Resource range space ID.
|
||||
static const unsigned kDxilResourceBaseLowerBound =
|
||||
4; // Resource range lower bound.
|
||||
static const unsigned kDxilResourceBaseRangeSize = 5; // Resource range size.
|
||||
|
||||
// SRV-specific.
|
||||
static const unsigned kDxilSRVNumFields = 9;
|
||||
static const unsigned kDxilSRVShape = 6; // SRV shape.
|
||||
static const unsigned kDxilSRVSampleCount = 7; // SRV sample count.
|
||||
static const unsigned kDxilSRVNameValueList = 8; // Name-value list for extended properties.
|
||||
static const unsigned kDxilSRVNumFields = 9;
|
||||
static const unsigned kDxilSRVShape = 6; // SRV shape.
|
||||
static const unsigned kDxilSRVSampleCount = 7; // SRV sample count.
|
||||
static const unsigned kDxilSRVNameValueList =
|
||||
8; // Name-value list for extended properties.
|
||||
|
||||
// UAV-specific.
|
||||
static const unsigned kDxilUAVNumFields = 11;
|
||||
static const unsigned kDxilUAVShape = 6; // UAV shape.
|
||||
static const unsigned kDxilUAVGloballyCoherent = 7; // Globally-coherent UAV.
|
||||
static const unsigned kDxilUAVCounter = 8; // UAV with a counter.
|
||||
static const unsigned kDxilUAVRasterizerOrderedView = 9; // UAV that is a ROV.
|
||||
static const unsigned kDxilUAVNameValueList = 10; // Name-value list for extended properties.
|
||||
static const unsigned kDxilUAVNumFields = 11;
|
||||
static const unsigned kDxilUAVShape = 6; // UAV shape.
|
||||
static const unsigned kDxilUAVGloballyCoherent = 7; // Globally-coherent UAV.
|
||||
static const unsigned kDxilUAVCounter = 8; // UAV with a counter.
|
||||
static const unsigned kDxilUAVRasterizerOrderedView = 9; // UAV that is a ROV.
|
||||
static const unsigned kDxilUAVNameValueList =
|
||||
10; // Name-value list for extended properties.
|
||||
|
||||
// CBuffer-specific.
|
||||
static const unsigned kDxilCBufferNumFields = 8;
|
||||
static const unsigned kDxilCBufferSizeInBytes = 6; // CBuffer size in bytes.
|
||||
static const unsigned kDxilCBufferNameValueList = 7; // Name-value list for extended properties.
|
||||
static const unsigned kDxilCBufferNumFields = 8;
|
||||
static const unsigned kDxilCBufferSizeInBytes = 6; // CBuffer size in bytes.
|
||||
static const unsigned kDxilCBufferNameValueList =
|
||||
7; // Name-value list for extended properties.
|
||||
|
||||
// CBuffer extended properties
|
||||
static const unsigned kHLCBufferIsTBufferTag = 0; // CBuffer is actually TBuffer, not yet converted to SRV.
|
||||
static const unsigned kHLCBufferIsTBufferTag =
|
||||
0; // CBuffer is actually TBuffer, not yet converted to SRV.
|
||||
|
||||
// Sampler-specific.
|
||||
static const unsigned kDxilSamplerNumFields = 8;
|
||||
static const unsigned kDxilSamplerType = 6; // Sampler type.
|
||||
static const unsigned kDxilSamplerNameValueList = 7; // Name-value list for extended properties.
|
||||
static const unsigned kDxilSamplerNumFields = 8;
|
||||
static const unsigned kDxilSamplerType = 6; // Sampler type.
|
||||
static const unsigned kDxilSamplerNameValueList =
|
||||
7; // Name-value list for extended properties.
|
||||
|
||||
// Resource extended property tags.
|
||||
static const unsigned kDxilTypedBufferElementTypeTag = 0;
|
||||
static const unsigned kDxilStructuredBufferElementStrideTag = 1;
|
||||
static const unsigned kDxilSamplerFeedbackKindTag = 2;
|
||||
static const unsigned kDxilAtomic64UseTag = 3;
|
||||
static const unsigned kDxilTypedBufferElementTypeTag = 0;
|
||||
static const unsigned kDxilStructuredBufferElementStrideTag = 1;
|
||||
static const unsigned kDxilSamplerFeedbackKindTag = 2;
|
||||
static const unsigned kDxilAtomic64UseTag = 3;
|
||||
|
||||
// Type system.
|
||||
static const char kDxilTypeSystemMDName[];
|
||||
static const char kDxilTypeSystemHelperVariablePrefix[];
|
||||
static const unsigned kDxilTypeSystemStructTag = 0;
|
||||
static const unsigned kDxilTypeSystemFunctionTag = 1;
|
||||
static const unsigned kDxilFieldAnnotationSNormTag = 0;
|
||||
static const unsigned kDxilFieldAnnotationUNormTag = 1;
|
||||
static const unsigned kDxilFieldAnnotationMatrixTag = 2;
|
||||
static const unsigned kDxilFieldAnnotationCBufferOffsetTag = 3;
|
||||
static const unsigned kDxilFieldAnnotationSemanticStringTag = 4;
|
||||
static const unsigned kDxilFieldAnnotationInterpolationModeTag = 5;
|
||||
static const unsigned kDxilFieldAnnotationFieldNameTag = 6;
|
||||
static const unsigned kDxilFieldAnnotationCompTypeTag = 7;
|
||||
static const unsigned kDxilFieldAnnotationPreciseTag = 8;
|
||||
static const unsigned kDxilFieldAnnotationCBUsedTag = 9;
|
||||
static const unsigned kDxilFieldAnnotationResPropTag = 10;
|
||||
static const unsigned kDxilFieldAnnotationBitFieldsTag = 11;
|
||||
static const unsigned kDxilFieldAnnotationBitFieldWidthTag = 12;
|
||||
static const unsigned kDxilTypeSystemStructTag = 0;
|
||||
static const unsigned kDxilTypeSystemFunctionTag = 1;
|
||||
static const unsigned kDxilFieldAnnotationSNormTag = 0;
|
||||
static const unsigned kDxilFieldAnnotationUNormTag = 1;
|
||||
static const unsigned kDxilFieldAnnotationMatrixTag = 2;
|
||||
static const unsigned kDxilFieldAnnotationCBufferOffsetTag = 3;
|
||||
static const unsigned kDxilFieldAnnotationSemanticStringTag = 4;
|
||||
static const unsigned kDxilFieldAnnotationInterpolationModeTag = 5;
|
||||
static const unsigned kDxilFieldAnnotationFieldNameTag = 6;
|
||||
static const unsigned kDxilFieldAnnotationCompTypeTag = 7;
|
||||
static const unsigned kDxilFieldAnnotationPreciseTag = 8;
|
||||
static const unsigned kDxilFieldAnnotationCBUsedTag = 9;
|
||||
static const unsigned kDxilFieldAnnotationResPropTag = 10;
|
||||
static const unsigned kDxilFieldAnnotationBitFieldsTag = 11;
|
||||
static const unsigned kDxilFieldAnnotationBitFieldWidthTag = 12;
|
||||
|
||||
// DXR Payload Annotations
|
||||
static const unsigned kDxilPayloadAnnotationStructTag = 0;
|
||||
static const unsigned kDxilPayloadFieldAnnotationAccessTag = 0;
|
||||
static const unsigned kDxilPayloadAnnotationStructTag = 0;
|
||||
static const unsigned kDxilPayloadFieldAnnotationAccessTag = 0;
|
||||
|
||||
// StructAnnotation extended property tags (DXIL 1.5+ only, appended)
|
||||
static const unsigned kDxilTemplateArgumentsTag = 0; // Name for name-value list of extended struct properties
|
||||
static const unsigned kDxilTemplateArgumentsTag =
|
||||
0; // Name for name-value list of extended struct properties
|
||||
// TemplateArgument tags
|
||||
static const unsigned kDxilTemplateArgTypeTag = 0; // Type template argument, followed by undef of type
|
||||
static const unsigned kDxilTemplateArgIntegralTag = 1; // Integral template argument, followed by i64 value
|
||||
static const unsigned kDxilTemplateArgValue = 1; // Position of template arg value (type or int)
|
||||
static const unsigned kDxilTemplateArgTypeTag =
|
||||
0; // Type template argument, followed by undef of type
|
||||
static const unsigned kDxilTemplateArgIntegralTag =
|
||||
1; // Integral template argument, followed by i64 value
|
||||
static const unsigned kDxilTemplateArgValue =
|
||||
1; // Position of template arg value (type or int)
|
||||
|
||||
// Control flow hint.
|
||||
static const char kDxilControlFlowHintMDName[];
|
||||
|
@ -264,42 +290,42 @@ public:
|
|||
static const char kDxilDxrPayloadAnnotationsMDName[];
|
||||
|
||||
// Extended shader property tags.
|
||||
static const unsigned kDxilShaderFlagsTag = 0;
|
||||
static const unsigned kDxilGSStateTag = 1;
|
||||
static const unsigned kDxilDSStateTag = 2;
|
||||
static const unsigned kDxilHSStateTag = 3;
|
||||
static const unsigned kDxilNumThreadsTag = 4;
|
||||
static const unsigned kDxilAutoBindingSpaceTag = 5;
|
||||
static const unsigned kDxilRayPayloadSizeTag = 6;
|
||||
static const unsigned kDxilRayAttribSizeTag = 7;
|
||||
static const unsigned kDxilShaderKindTag = 8;
|
||||
static const unsigned kDxilMSStateTag = 9;
|
||||
static const unsigned kDxilASStateTag = 10;
|
||||
static const unsigned kDxilWaveSizeTag = 11;
|
||||
static const unsigned kDxilEntryRootSigTag = 12;
|
||||
static const unsigned kDxilShaderFlagsTag = 0;
|
||||
static const unsigned kDxilGSStateTag = 1;
|
||||
static const unsigned kDxilDSStateTag = 2;
|
||||
static const unsigned kDxilHSStateTag = 3;
|
||||
static const unsigned kDxilNumThreadsTag = 4;
|
||||
static const unsigned kDxilAutoBindingSpaceTag = 5;
|
||||
static const unsigned kDxilRayPayloadSizeTag = 6;
|
||||
static const unsigned kDxilRayAttribSizeTag = 7;
|
||||
static const unsigned kDxilShaderKindTag = 8;
|
||||
static const unsigned kDxilMSStateTag = 9;
|
||||
static const unsigned kDxilASStateTag = 10;
|
||||
static const unsigned kDxilWaveSizeTag = 11;
|
||||
static const unsigned kDxilEntryRootSigTag = 12;
|
||||
|
||||
// GSState.
|
||||
static const unsigned kDxilGSStateNumFields = 5;
|
||||
static const unsigned kDxilGSStateInputPrimitive = 0;
|
||||
static const unsigned kDxilGSStateMaxVertexCount = 1;
|
||||
static const unsigned kDxilGSStateActiveStreamMask = 2;
|
||||
static const unsigned kDxilGSStateOutputStreamTopology = 3;
|
||||
static const unsigned kDxilGSStateGSInstanceCount = 4;
|
||||
static const unsigned kDxilGSStateNumFields = 5;
|
||||
static const unsigned kDxilGSStateInputPrimitive = 0;
|
||||
static const unsigned kDxilGSStateMaxVertexCount = 1;
|
||||
static const unsigned kDxilGSStateActiveStreamMask = 2;
|
||||
static const unsigned kDxilGSStateOutputStreamTopology = 3;
|
||||
static const unsigned kDxilGSStateGSInstanceCount = 4;
|
||||
|
||||
// DSState.
|
||||
static const unsigned kDxilDSStateNumFields = 2;
|
||||
static const unsigned kDxilDSStateTessellatorDomain = 0;
|
||||
static const unsigned kDxilDSStateInputControlPointCount = 1;
|
||||
static const unsigned kDxilDSStateNumFields = 2;
|
||||
static const unsigned kDxilDSStateTessellatorDomain = 0;
|
||||
static const unsigned kDxilDSStateInputControlPointCount = 1;
|
||||
|
||||
// HSState.
|
||||
static const unsigned kDxilHSStateNumFields = 7;
|
||||
static const unsigned kDxilHSStatePatchConstantFunction = 0;
|
||||
static const unsigned kDxilHSStateInputControlPointCount = 1;
|
||||
static const unsigned kDxilHSStateOutputControlPointCount = 2;
|
||||
static const unsigned kDxilHSStateTessellatorDomain = 3;
|
||||
static const unsigned kDxilHSStateTessellatorPartitioning = 4;
|
||||
static const unsigned kDxilHSStateTessellatorOutputPrimitive= 5;
|
||||
static const unsigned kDxilHSStateMaxTessellationFactor = 6;
|
||||
static const unsigned kDxilHSStateNumFields = 7;
|
||||
static const unsigned kDxilHSStatePatchConstantFunction = 0;
|
||||
static const unsigned kDxilHSStateInputControlPointCount = 1;
|
||||
static const unsigned kDxilHSStateOutputControlPointCount = 2;
|
||||
static const unsigned kDxilHSStateTessellatorDomain = 3;
|
||||
static const unsigned kDxilHSStateTessellatorPartitioning = 4;
|
||||
static const unsigned kDxilHSStateTessellatorOutputPrimitive = 5;
|
||||
static const unsigned kDxilHSStateMaxTessellationFactor = 6;
|
||||
|
||||
// MSState.
|
||||
static const unsigned kDxilMSStateNumFields = 5;
|
||||
|
@ -315,34 +341,49 @@ public:
|
|||
static const unsigned kDxilASStatePayloadSizeInBytes = 1;
|
||||
|
||||
public:
|
||||
/// Use this class to manipulate metadata of DXIL or high-level DX IR specific fields in the record.
|
||||
/// Use this class to manipulate metadata of DXIL or high-level DX IR specific
|
||||
/// fields in the record.
|
||||
class ExtraPropertyHelper {
|
||||
public:
|
||||
ExtraPropertyHelper(llvm::Module *pModule);
|
||||
virtual ~ExtraPropertyHelper() {}
|
||||
|
||||
virtual void EmitSRVProperties(const DxilResource &SRV, std::vector<llvm::Metadata *> &MDVals) = 0;
|
||||
virtual void LoadSRVProperties(const llvm::MDOperand &MDO, DxilResource &SRV) = 0;
|
||||
virtual void EmitSRVProperties(const DxilResource &SRV,
|
||||
std::vector<llvm::Metadata *> &MDVals) = 0;
|
||||
virtual void LoadSRVProperties(const llvm::MDOperand &MDO,
|
||||
DxilResource &SRV) = 0;
|
||||
|
||||
virtual void EmitUAVProperties(const DxilResource &UAV, std::vector<llvm::Metadata *> &MDVals) = 0;
|
||||
virtual void LoadUAVProperties(const llvm::MDOperand &MDO, DxilResource &UAV) = 0;
|
||||
virtual void EmitUAVProperties(const DxilResource &UAV,
|
||||
std::vector<llvm::Metadata *> &MDVals) = 0;
|
||||
virtual void LoadUAVProperties(const llvm::MDOperand &MDO,
|
||||
DxilResource &UAV) = 0;
|
||||
|
||||
virtual void EmitCBufferProperties(const DxilCBuffer &CB, std::vector<llvm::Metadata *> &MDVals) = 0;
|
||||
virtual void LoadCBufferProperties(const llvm::MDOperand &MDO, DxilCBuffer &CB) = 0;
|
||||
virtual void
|
||||
EmitCBufferProperties(const DxilCBuffer &CB,
|
||||
std::vector<llvm::Metadata *> &MDVals) = 0;
|
||||
virtual void LoadCBufferProperties(const llvm::MDOperand &MDO,
|
||||
DxilCBuffer &CB) = 0;
|
||||
|
||||
virtual void EmitSamplerProperties(const DxilSampler &S, std::vector<llvm::Metadata *> &MDVals) = 0;
|
||||
virtual void LoadSamplerProperties(const llvm::MDOperand &MDO, DxilSampler &S) = 0;
|
||||
virtual void
|
||||
EmitSamplerProperties(const DxilSampler &S,
|
||||
std::vector<llvm::Metadata *> &MDVals) = 0;
|
||||
virtual void LoadSamplerProperties(const llvm::MDOperand &MDO,
|
||||
DxilSampler &S) = 0;
|
||||
|
||||
virtual void EmitSignatureElementProperties(const DxilSignatureElement &SE, std::vector<llvm::Metadata *> &MDVals) = 0;
|
||||
virtual void LoadSignatureElementProperties(const llvm::MDOperand &MDO, DxilSignatureElement &SE) = 0;
|
||||
virtual void
|
||||
EmitSignatureElementProperties(const DxilSignatureElement &SE,
|
||||
std::vector<llvm::Metadata *> &MDVals) = 0;
|
||||
virtual void LoadSignatureElementProperties(const llvm::MDOperand &MDO,
|
||||
DxilSignatureElement &SE) = 0;
|
||||
|
||||
protected:
|
||||
llvm::LLVMContext &m_Ctx;
|
||||
llvm::Module *m_pModule;
|
||||
|
||||
public:
|
||||
unsigned m_ValMajor, m_ValMinor; // Reported validation version in DXIL
|
||||
unsigned m_MinValMajor, m_MinValMinor; // Minimum validation version dictated by shader model
|
||||
unsigned m_ValMajor, m_ValMinor; // Reported validation version in DXIL
|
||||
unsigned m_MinValMajor,
|
||||
m_MinValMinor; // Minimum validation version dictated by shader model
|
||||
bool m_bExtraMetadata;
|
||||
};
|
||||
|
||||
|
@ -373,10 +414,14 @@ public:
|
|||
void EmitDxilEntryPoints(std::vector<llvm::MDNode *> &MDEntries);
|
||||
void UpdateDxilEntryPoints(std::vector<llvm::MDNode *> &MDEntries);
|
||||
const llvm::NamedMDNode *GetDxilEntryPoints();
|
||||
llvm::MDTuple *EmitDxilEntryPointTuple(llvm::Function *pFunc, const std::string &Name, llvm::MDTuple *pSignatures,
|
||||
llvm::MDTuple *pResources, llvm::MDTuple *pProperties);
|
||||
void GetDxilEntryPoint(const llvm::MDNode *MDO, llvm::Function *&pFunc, std::string &Name,
|
||||
const llvm::MDOperand *&pSignatures, const llvm::MDOperand *&pResources,
|
||||
llvm::MDTuple *EmitDxilEntryPointTuple(llvm::Function *pFunc,
|
||||
const std::string &Name,
|
||||
llvm::MDTuple *pSignatures,
|
||||
llvm::MDTuple *pResources,
|
||||
llvm::MDTuple *pProperties);
|
||||
void GetDxilEntryPoint(const llvm::MDNode *MDO, llvm::Function *&pFunc,
|
||||
std::string &Name, const llvm::MDOperand *&pSignatures,
|
||||
const llvm::MDOperand *&pResources,
|
||||
const llvm::MDOperand *&pProperties);
|
||||
|
||||
// Signatures.
|
||||
|
@ -387,17 +432,23 @@ public:
|
|||
void EmitRootSignature(std::vector<uint8_t> &SerializedRootSignature);
|
||||
void LoadSignatureMetadata(const llvm::MDOperand &MDO, DxilSignature &Sig);
|
||||
llvm::MDTuple *EmitSignatureElement(const DxilSignatureElement &SE);
|
||||
void LoadSignatureElement(const llvm::MDOperand &MDO, DxilSignatureElement &SE);
|
||||
void LoadSignatureElement(const llvm::MDOperand &MDO,
|
||||
DxilSignatureElement &SE);
|
||||
void LoadRootSignature(std::vector<uint8_t> &SerializedRootSignature);
|
||||
|
||||
// Resources.
|
||||
llvm::MDTuple *EmitDxilResourceTuple(llvm::MDTuple *pSRVs, llvm::MDTuple *pUAVs,
|
||||
llvm::MDTuple *pCBuffers, llvm::MDTuple *pSamplers);
|
||||
llvm::MDTuple *EmitDxilResourceTuple(llvm::MDTuple *pSRVs,
|
||||
llvm::MDTuple *pUAVs,
|
||||
llvm::MDTuple *pCBuffers,
|
||||
llvm::MDTuple *pSamplers);
|
||||
void EmitDxilResources(llvm::MDTuple *pDxilResourceTuple);
|
||||
void UpdateDxilResources(llvm::MDTuple *pDxilResourceTuple);
|
||||
void GetDxilResources(const llvm::MDOperand &MDO, const llvm::MDTuple *&pSRVs, const llvm::MDTuple *&pUAVs,
|
||||
const llvm::MDTuple *&pCBuffers, const llvm::MDTuple *&pSamplers);
|
||||
void EmitDxilResourceBase(const DxilResourceBase &R, llvm::Metadata *ppMDVals[]);
|
||||
void GetDxilResources(const llvm::MDOperand &MDO, const llvm::MDTuple *&pSRVs,
|
||||
const llvm::MDTuple *&pUAVs,
|
||||
const llvm::MDTuple *&pCBuffers,
|
||||
const llvm::MDTuple *&pSamplers);
|
||||
void EmitDxilResourceBase(const DxilResourceBase &R,
|
||||
llvm::Metadata *ppMDVals[]);
|
||||
void LoadDxilResourceBase(const llvm::MDOperand &MDO, DxilResourceBase &R);
|
||||
llvm::MDTuple *EmitDxilSRV(const DxilResource &SRV);
|
||||
void LoadDxilSRV(const llvm::MDOperand &MDO, DxilResource &SRV);
|
||||
|
@ -407,34 +458,51 @@ public:
|
|||
void LoadDxilCBuffer(const llvm::MDOperand &MDO, DxilCBuffer &CB);
|
||||
llvm::MDTuple *EmitDxilSampler(const DxilSampler &S);
|
||||
void LoadDxilSampler(const llvm::MDOperand &MDO, DxilSampler &S);
|
||||
const llvm::MDOperand &GetResourceClass(llvm::MDNode *MD, DXIL::ResourceClass &RC);
|
||||
const llvm::MDOperand &GetResourceClass(llvm::MDNode *MD,
|
||||
DXIL::ResourceClass &RC);
|
||||
|
||||
// Type system.
|
||||
void EmitDxilTypeSystem(DxilTypeSystem &TypeSystem, std::vector<llvm::GlobalVariable *> &LLVMUsed);
|
||||
void LoadDxilTypeSystemNode(const llvm::MDTuple &MDT, DxilTypeSystem &TypeSystem);
|
||||
void EmitDxilTypeSystem(DxilTypeSystem &TypeSystem,
|
||||
std::vector<llvm::GlobalVariable *> &LLVMUsed);
|
||||
void LoadDxilTypeSystemNode(const llvm::MDTuple &MDT,
|
||||
DxilTypeSystem &TypeSystem);
|
||||
void LoadDxilTypeSystem(DxilTypeSystem &TypeSystem);
|
||||
llvm::Metadata *EmitDxilStructAnnotation(const DxilStructAnnotation &SA);
|
||||
void LoadDxilStructAnnotation(const llvm::MDOperand &MDO, DxilStructAnnotation &SA);
|
||||
void LoadDxilStructAnnotation(const llvm::MDOperand &MDO,
|
||||
DxilStructAnnotation &SA);
|
||||
llvm::Metadata *EmitDxilFieldAnnotation(const DxilFieldAnnotation &FA);
|
||||
void LoadDxilFieldAnnotation(const llvm::MDOperand &MDO, DxilFieldAnnotation &FA);
|
||||
void LoadDxilFieldAnnotation(const llvm::MDOperand &MDO,
|
||||
DxilFieldAnnotation &FA);
|
||||
llvm::Metadata *EmitDxilFunctionAnnotation(const DxilFunctionAnnotation &FA);
|
||||
void LoadDxilFunctionAnnotation(const llvm::MDOperand &MDO, DxilFunctionAnnotation &FA);
|
||||
void LoadDxilFunctionAnnotation(const llvm::MDOperand &MDO,
|
||||
DxilFunctionAnnotation &FA);
|
||||
llvm::Metadata *EmitDxilParamAnnotation(const DxilParameterAnnotation &PA);
|
||||
void LoadDxilParamAnnotation(const llvm::MDOperand &MDO, DxilParameterAnnotation &PA);
|
||||
void LoadDxilParamAnnotation(const llvm::MDOperand &MDO,
|
||||
DxilParameterAnnotation &PA);
|
||||
llvm::Metadata *EmitDxilParamAnnotations(const DxilFunctionAnnotation &FA);
|
||||
void LoadDxilParamAnnotations(const llvm::MDOperand &MDO, DxilFunctionAnnotation &FA);
|
||||
llvm::Metadata *EmitDxilTemplateArgAnnotation(const DxilTemplateArgAnnotation &annotation);
|
||||
void LoadDxilTemplateArgAnnotation(const llvm::MDOperand &MDO, DxilTemplateArgAnnotation &annotation);
|
||||
void LoadDxilParamAnnotations(const llvm::MDOperand &MDO,
|
||||
DxilFunctionAnnotation &FA);
|
||||
llvm::Metadata *
|
||||
EmitDxilTemplateArgAnnotation(const DxilTemplateArgAnnotation &annotation);
|
||||
void LoadDxilTemplateArgAnnotation(const llvm::MDOperand &MDO,
|
||||
DxilTemplateArgAnnotation &annotation);
|
||||
|
||||
// DXR Payload Annotations
|
||||
// DXR Payload Annotations
|
||||
void EmitDxrPayloadAnnotations(DxilTypeSystem &TypeSystem);
|
||||
llvm::Metadata *EmitDxrPayloadStructAnnotation(const DxilPayloadAnnotation& SA);
|
||||
llvm::Metadata *EmitDxrPayloadFieldAnnotation(const DxilPayloadFieldAnnotation &FA, llvm::Type* fieldType);
|
||||
void LoadDxrPayloadAnnotationNode(const llvm::MDTuple &MDT, DxilTypeSystem &TypeSystem);
|
||||
llvm::Metadata *
|
||||
EmitDxrPayloadStructAnnotation(const DxilPayloadAnnotation &SA);
|
||||
llvm::Metadata *
|
||||
EmitDxrPayloadFieldAnnotation(const DxilPayloadFieldAnnotation &FA,
|
||||
llvm::Type *fieldType);
|
||||
void LoadDxrPayloadAnnotationNode(const llvm::MDTuple &MDT,
|
||||
DxilTypeSystem &TypeSystem);
|
||||
void LoadDxrPayloadAnnotations(DxilTypeSystem &TypeSystem);
|
||||
void LoadDxrPayloadFieldAnnoations(const llvm::MDOperand& MDO, DxilPayloadAnnotation& SA);
|
||||
void LoadDxrPayloadFieldAnnoation(const llvm::MDOperand &MDO, DxilPayloadFieldAnnotation &FA);
|
||||
void LoadDxrPayloadAccessQualifiers(const llvm::MDOperand &MDO, DxilPayloadFieldAnnotation &FA);
|
||||
void LoadDxrPayloadFieldAnnoations(const llvm::MDOperand &MDO,
|
||||
DxilPayloadAnnotation &SA);
|
||||
void LoadDxrPayloadFieldAnnoation(const llvm::MDOperand &MDO,
|
||||
DxilPayloadFieldAnnotation &FA);
|
||||
void LoadDxrPayloadAccessQualifiers(const llvm::MDOperand &MDO,
|
||||
DxilPayloadFieldAnnotation &FA);
|
||||
|
||||
// Function props.
|
||||
llvm::MDTuple *EmitDxilFunctionProps(const hlsl::DxilFunctionProps *props,
|
||||
|
@ -442,18 +510,20 @@ public:
|
|||
const llvm::Function *LoadDxilFunctionProps(const llvm::MDTuple *pProps,
|
||||
hlsl::DxilFunctionProps *props);
|
||||
llvm::MDTuple *EmitDxilEntryProperties(uint64_t rawShaderFlag,
|
||||
const hlsl::DxilFunctionProps &props,
|
||||
uint32_t autoBindingSpace);
|
||||
const hlsl::DxilFunctionProps &props,
|
||||
uint32_t autoBindingSpace);
|
||||
void LoadDxilEntryProperties(const llvm::MDOperand &MDO,
|
||||
uint64_t &rawShaderFlag,
|
||||
hlsl::DxilFunctionProps &props,
|
||||
uint32_t &autoBindingSpace);
|
||||
uint64_t &rawShaderFlag,
|
||||
hlsl::DxilFunctionProps &props,
|
||||
uint32_t &autoBindingSpace);
|
||||
|
||||
// ViewId state.
|
||||
void EmitDxilViewIdState(std::vector<unsigned> &SerializedState);
|
||||
void LoadDxilViewIdState(std::vector<unsigned> &SerializedState);
|
||||
// Control flow hints.
|
||||
static llvm::MDNode *EmitControlFlowHints(llvm::LLVMContext &Ctx, std::vector<DXIL::ControlFlowHint> &hints);
|
||||
static llvm::MDNode *
|
||||
EmitControlFlowHints(llvm::LLVMContext &Ctx,
|
||||
std::vector<DXIL::ControlFlowHint> &hints);
|
||||
static unsigned GetControlFlowHintMask(const llvm::Instruction *I);
|
||||
static bool HasControlFlowHintToPreventFlatten(const llvm::Instruction *I);
|
||||
|
||||
|
@ -472,23 +542,29 @@ public:
|
|||
|
||||
// Shader specific.
|
||||
private:
|
||||
llvm::MDTuple *EmitDxilGSState(DXIL::InputPrimitive Primitive, unsigned MaxVertexCount,
|
||||
unsigned ActiveStreamMask, DXIL::PrimitiveTopology StreamPrimitiveTopology,
|
||||
unsigned GSInstanceCount);
|
||||
void LoadDxilGSState(const llvm::MDOperand &MDO, DXIL::InputPrimitive &Primitive, unsigned &MaxVertexCount,
|
||||
unsigned &ActiveStreamMask, DXIL::PrimitiveTopology &StreamPrimitiveTopology,
|
||||
llvm::MDTuple *
|
||||
EmitDxilGSState(DXIL::InputPrimitive Primitive, unsigned MaxVertexCount,
|
||||
unsigned ActiveStreamMask,
|
||||
DXIL::PrimitiveTopology StreamPrimitiveTopology,
|
||||
unsigned GSInstanceCount);
|
||||
void LoadDxilGSState(const llvm::MDOperand &MDO,
|
||||
DXIL::InputPrimitive &Primitive,
|
||||
unsigned &MaxVertexCount, unsigned &ActiveStreamMask,
|
||||
DXIL::PrimitiveTopology &StreamPrimitiveTopology,
|
||||
unsigned &GSInstanceCount);
|
||||
|
||||
llvm::MDTuple *EmitDxilDSState(DXIL::TessellatorDomain Domain, unsigned InputControlPointCount);
|
||||
void LoadDxilDSState(const llvm::MDOperand &MDO, DXIL::TessellatorDomain &Domain, unsigned &InputControlPointCount);
|
||||
llvm::MDTuple *EmitDxilDSState(DXIL::TessellatorDomain Domain,
|
||||
unsigned InputControlPointCount);
|
||||
void LoadDxilDSState(const llvm::MDOperand &MDO,
|
||||
DXIL::TessellatorDomain &Domain,
|
||||
unsigned &InputControlPointCount);
|
||||
|
||||
llvm::MDTuple *EmitDxilHSState(llvm::Function *pPatchConstantFunction,
|
||||
unsigned InputControlPointCount,
|
||||
unsigned OutputControlPointCount,
|
||||
DXIL::TessellatorDomain TessDomain,
|
||||
DXIL::TessellatorPartitioning TessPartitioning,
|
||||
DXIL::TessellatorOutputPrimitive TessOutputPrimitive,
|
||||
float MaxTessFactor);
|
||||
llvm::MDTuple *EmitDxilHSState(
|
||||
llvm::Function *pPatchConstantFunction, unsigned InputControlPointCount,
|
||||
unsigned OutputControlPointCount, DXIL::TessellatorDomain TessDomain,
|
||||
DXIL::TessellatorPartitioning TessPartitioning,
|
||||
DXIL::TessellatorOutputPrimitive TessOutputPrimitive,
|
||||
float MaxTessFactor);
|
||||
void LoadDxilHSState(const llvm::MDOperand &MDO,
|
||||
llvm::Function *&pPatchConstantFunction,
|
||||
unsigned &InputControlPointCount,
|
||||
|
@ -503,33 +579,43 @@ private:
|
|||
unsigned MaxPrimitiveCount,
|
||||
DXIL::MeshOutputTopology OutputTopology,
|
||||
unsigned payloadSizeInBytes);
|
||||
void LoadDxilMSState(const llvm::MDOperand &MDO,
|
||||
unsigned *NumThreads,
|
||||
unsigned &MaxVertexCount,
|
||||
unsigned &MaxPrimitiveCount,
|
||||
void LoadDxilMSState(const llvm::MDOperand &MDO, unsigned *NumThreads,
|
||||
unsigned &MaxVertexCount, unsigned &MaxPrimitiveCount,
|
||||
DXIL::MeshOutputTopology &OutputTopology,
|
||||
unsigned &payloadSizeInBytes);
|
||||
|
||||
llvm::MDTuple *EmitDxilASState(const unsigned *NumThreads, unsigned payloadSizeInBytes);
|
||||
void LoadDxilASState(const llvm::MDOperand &MDO, unsigned *NumThreads, unsigned &payloadSizeInBytes);
|
||||
llvm::MDTuple *EmitDxilASState(const unsigned *NumThreads,
|
||||
unsigned payloadSizeInBytes);
|
||||
void LoadDxilASState(const llvm::MDOperand &MDO, unsigned *NumThreads,
|
||||
unsigned &payloadSizeInBytes);
|
||||
|
||||
void AddCounterIfNonZero(uint32_t value, llvm::StringRef name,
|
||||
std::vector<llvm::Metadata *> &MDVals);
|
||||
void LoadCounterMD(const llvm::MDOperand &MDName,
|
||||
const llvm::MDOperand &MDValue,
|
||||
DxilCounters &counters) const;
|
||||
|
||||
void AddCounterIfNonZero(uint32_t value, llvm::StringRef name, std::vector<llvm::Metadata*> &MDVals);
|
||||
void LoadCounterMD(const llvm::MDOperand &MDName, const llvm::MDOperand &MDValue, DxilCounters &counters) const;
|
||||
public:
|
||||
// Utility functions.
|
||||
static bool IsKnownNamedMetaData(const llvm::NamedMDNode &Node);
|
||||
static bool IsKnownMetadataID(llvm::LLVMContext &Ctx, unsigned ID);
|
||||
static void GetKnownMetadataIDs(llvm::LLVMContext &Ctx, llvm::SmallVectorImpl<unsigned> *pIDs);
|
||||
static void combineDxilMetadata(llvm::Instruction *K, const llvm::Instruction *J);
|
||||
static llvm::ConstantAsMetadata *Int32ToConstMD(int32_t v, llvm::LLVMContext &Ctx);
|
||||
static void GetKnownMetadataIDs(llvm::LLVMContext &Ctx,
|
||||
llvm::SmallVectorImpl<unsigned> *pIDs);
|
||||
static void combineDxilMetadata(llvm::Instruction *K,
|
||||
const llvm::Instruction *J);
|
||||
static llvm::ConstantAsMetadata *Int32ToConstMD(int32_t v,
|
||||
llvm::LLVMContext &Ctx);
|
||||
llvm::ConstantAsMetadata *Int32ToConstMD(int32_t v);
|
||||
static llvm::ConstantAsMetadata *Uint32ToConstMD(unsigned v, llvm::LLVMContext &Ctx);
|
||||
static llvm::ConstantAsMetadata *Uint32ToConstMD(unsigned v,
|
||||
llvm::LLVMContext &Ctx);
|
||||
llvm::ConstantAsMetadata *Uint32ToConstMD(unsigned v);
|
||||
static llvm::ConstantAsMetadata *Uint64ToConstMD(uint64_t v, llvm::LLVMContext &Ctx);
|
||||
static llvm::ConstantAsMetadata *Uint64ToConstMD(uint64_t v,
|
||||
llvm::LLVMContext &Ctx);
|
||||
llvm::ConstantAsMetadata *Uint64ToConstMD(uint64_t v);
|
||||
llvm::ConstantAsMetadata *Int8ToConstMD(int8_t v);
|
||||
llvm::ConstantAsMetadata *Uint8ToConstMD(uint8_t v);
|
||||
static llvm::ConstantAsMetadata *BoolToConstMD(bool v, llvm::LLVMContext &Ctx);
|
||||
static llvm::ConstantAsMetadata *BoolToConstMD(bool v,
|
||||
llvm::LLVMContext &Ctx);
|
||||
llvm::ConstantAsMetadata *BoolToConstMD(bool v);
|
||||
llvm::ConstantAsMetadata *FloatToConstMD(float v);
|
||||
static int32_t ConstMDToInt32(const llvm::MDOperand &MDO);
|
||||
|
@ -543,51 +629,66 @@ public:
|
|||
static llvm::StringRef StringMDToStringRef(const llvm::MDOperand &MDO);
|
||||
static llvm::Value *ValueMDToValue(const llvm::MDOperand &MDO);
|
||||
llvm::MDTuple *Uint32VectorToConstMDTuple(const std::vector<unsigned> &Vec);
|
||||
void ConstMDTupleToUint32Vector(llvm::MDTuple *pTupleMD, std::vector<unsigned> &Vec);
|
||||
void ConstMDTupleToUint32Vector(llvm::MDTuple *pTupleMD,
|
||||
std::vector<unsigned> &Vec);
|
||||
static bool IsMarkedPrecise(const llvm::Instruction *inst);
|
||||
static void MarkPrecise(llvm::Instruction *inst);
|
||||
static bool IsMarkedNonUniform(const llvm::Instruction *inst);
|
||||
static void MarkNonUniform(llvm::Instruction *inst);
|
||||
static bool GetVariableDebugLayout(llvm::DbgDeclareInst *inst,
|
||||
unsigned &StartOffsetInBits, std::vector<DxilDIArrayDim> &ArrayDims);
|
||||
static void SetVariableDebugLayout(llvm::DbgDeclareInst *inst,
|
||||
unsigned StartOffsetInBits, const std::vector<DxilDIArrayDim> &ArrayDims);
|
||||
static void CopyMetadata(llvm::Instruction &I, llvm::Instruction &SrcInst, llvm::ArrayRef<unsigned>WL = llvm::ArrayRef<unsigned>());
|
||||
unsigned &StartOffsetInBits,
|
||||
std::vector<DxilDIArrayDim> &ArrayDims);
|
||||
static void
|
||||
SetVariableDebugLayout(llvm::DbgDeclareInst *inst, unsigned StartOffsetInBits,
|
||||
const std::vector<DxilDIArrayDim> &ArrayDims);
|
||||
static void
|
||||
CopyMetadata(llvm::Instruction &I, llvm::Instruction &SrcInst,
|
||||
llvm::ArrayRef<unsigned> WL = llvm::ArrayRef<unsigned>());
|
||||
|
||||
private:
|
||||
llvm::LLVMContext &m_Ctx;
|
||||
llvm::Module *m_pModule;
|
||||
const ShaderModel *m_pSM;
|
||||
std::unique_ptr<ExtraPropertyHelper> m_ExtraPropertyHelper;
|
||||
unsigned m_ValMajor, m_ValMinor; // Reported validation version in DXIL
|
||||
unsigned m_MinValMajor, m_MinValMinor; // Minimum validation version dictated by shader model
|
||||
unsigned m_ValMajor, m_ValMinor; // Reported validation version in DXIL
|
||||
unsigned m_MinValMajor,
|
||||
m_MinValMinor; // Minimum validation version dictated by shader model
|
||||
|
||||
// Non-fatal if extra metadata is found, but will fail validation.
|
||||
// This is how metadata can be exteneded.
|
||||
bool m_bExtraMetadata;
|
||||
};
|
||||
|
||||
|
||||
/// Use this class to manipulate metadata of extra metadata record properties that are specific to DXIL.
|
||||
/// Use this class to manipulate metadata of extra metadata record properties
|
||||
/// that are specific to DXIL.
|
||||
class DxilExtraPropertyHelper : public DxilMDHelper::ExtraPropertyHelper {
|
||||
public:
|
||||
DxilExtraPropertyHelper(llvm::Module *pModule);
|
||||
virtual ~DxilExtraPropertyHelper() {}
|
||||
|
||||
virtual void EmitSRVProperties(const DxilResource &SRV, std::vector<llvm::Metadata *> &MDVals);
|
||||
virtual void EmitSRVProperties(const DxilResource &SRV,
|
||||
std::vector<llvm::Metadata *> &MDVals);
|
||||
virtual void LoadSRVProperties(const llvm::MDOperand &MDO, DxilResource &SRV);
|
||||
|
||||
virtual void EmitUAVProperties(const DxilResource &UAV, std::vector<llvm::Metadata *> &MDVals);
|
||||
virtual void EmitUAVProperties(const DxilResource &UAV,
|
||||
std::vector<llvm::Metadata *> &MDVals);
|
||||
virtual void LoadUAVProperties(const llvm::MDOperand &MDO, DxilResource &UAV);
|
||||
|
||||
virtual void EmitCBufferProperties(const DxilCBuffer &CB, std::vector<llvm::Metadata *> &MDVals);
|
||||
virtual void LoadCBufferProperties(const llvm::MDOperand &MDO, DxilCBuffer &CB);
|
||||
virtual void EmitCBufferProperties(const DxilCBuffer &CB,
|
||||
std::vector<llvm::Metadata *> &MDVals);
|
||||
virtual void LoadCBufferProperties(const llvm::MDOperand &MDO,
|
||||
DxilCBuffer &CB);
|
||||
|
||||
virtual void EmitSamplerProperties(const DxilSampler &S, std::vector<llvm::Metadata *> &MDVals);
|
||||
virtual void LoadSamplerProperties(const llvm::MDOperand &MDO, DxilSampler &S);
|
||||
virtual void EmitSamplerProperties(const DxilSampler &S,
|
||||
std::vector<llvm::Metadata *> &MDVals);
|
||||
virtual void LoadSamplerProperties(const llvm::MDOperand &MDO,
|
||||
DxilSampler &S);
|
||||
|
||||
virtual void EmitSignatureElementProperties(const DxilSignatureElement &SE, std::vector<llvm::Metadata *> &MDVals);
|
||||
virtual void LoadSignatureElementProperties(const llvm::MDOperand &MDO, DxilSignatureElement &SE);
|
||||
virtual void
|
||||
EmitSignatureElementProperties(const DxilSignatureElement &SE,
|
||||
std::vector<llvm::Metadata *> &MDVals);
|
||||
virtual void LoadSignatureElementProperties(const llvm::MDOperand &MDO,
|
||||
DxilSignatureElement &SE);
|
||||
};
|
||||
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "dxc/DXIL/DxilCBuffer.h"
|
||||
#include "dxc/DXIL/DxilConstants.h"
|
||||
#include "dxc/DXIL/DxilMetadataHelper.h"
|
||||
#include "dxc/DXIL/DxilCBuffer.h"
|
||||
#include "dxc/DXIL/DxilResource.h"
|
||||
#include "dxc/DXIL/DxilSampler.h"
|
||||
#include "dxc/DXIL/DxilShaderFlags.h"
|
||||
|
@ -23,9 +23,9 @@
|
|||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
class LLVMContext;
|
||||
|
@ -35,7 +35,7 @@ class Instruction;
|
|||
class MDTuple;
|
||||
class MDOperand;
|
||||
class DebugInfoFinder;
|
||||
}
|
||||
} // namespace llvm
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
|
@ -67,9 +67,11 @@ public:
|
|||
void SetForceZeroStoreLifetimes(bool ForceZeroStoreLifetimes);
|
||||
bool GetForceZeroStoreLifetimes() const;
|
||||
|
||||
// Return true on success, requires valid shader model and CollectShaderFlags to have been set
|
||||
// Return true on success, requires valid shader model and CollectShaderFlags
|
||||
// to have been set
|
||||
bool GetMinValidatorVersion(unsigned &ValMajor, unsigned &ValMinor) const;
|
||||
// Update validator version to minimum if higher than current (ex: after CollectShaderFlags)
|
||||
// Update validator version to minimum if higher than current (ex: after
|
||||
// CollectShaderFlags)
|
||||
bool UpgradeToMinValidatorVersion();
|
||||
|
||||
// Entry functions.
|
||||
|
@ -81,7 +83,7 @@ public:
|
|||
llvm::Function *GetPatchConstantFunction();
|
||||
const llvm::Function *GetPatchConstantFunction() const;
|
||||
void SetPatchConstantFunction(llvm::Function *pFunc);
|
||||
bool IsEntryOrPatchConstantFunction(const llvm::Function* pFunc) const;
|
||||
bool IsEntryOrPatchConstantFunction(const llvm::Function *pFunc) const;
|
||||
llvm::SmallVector<llvm::Function *, 64> GetExportedFunctions();
|
||||
|
||||
// Flags.
|
||||
|
@ -92,22 +94,22 @@ public:
|
|||
unsigned AddCBuffer(std::unique_ptr<DxilCBuffer> pCB);
|
||||
DxilCBuffer &GetCBuffer(unsigned idx);
|
||||
const DxilCBuffer &GetCBuffer(unsigned idx) const;
|
||||
const std::vector<std::unique_ptr<DxilCBuffer> > &GetCBuffers() const;
|
||||
const std::vector<std::unique_ptr<DxilCBuffer>> &GetCBuffers() const;
|
||||
|
||||
unsigned AddSampler(std::unique_ptr<DxilSampler> pSampler);
|
||||
DxilSampler &GetSampler(unsigned idx);
|
||||
const DxilSampler &GetSampler(unsigned idx) const;
|
||||
const std::vector<std::unique_ptr<DxilSampler> > &GetSamplers() const;
|
||||
const std::vector<std::unique_ptr<DxilSampler>> &GetSamplers() const;
|
||||
|
||||
unsigned AddSRV(std::unique_ptr<DxilResource> pSRV);
|
||||
DxilResource &GetSRV(unsigned idx);
|
||||
const DxilResource &GetSRV(unsigned idx) const;
|
||||
const std::vector<std::unique_ptr<DxilResource> > &GetSRVs() const;
|
||||
const std::vector<std::unique_ptr<DxilResource>> &GetSRVs() const;
|
||||
|
||||
unsigned AddUAV(std::unique_ptr<DxilResource> pUAV);
|
||||
DxilResource &GetUAV(unsigned idx);
|
||||
const DxilResource &GetUAV(unsigned idx) const;
|
||||
const std::vector<std::unique_ptr<DxilResource> > &GetUAVs() const;
|
||||
const std::vector<std::unique_ptr<DxilResource>> &GetUAVs() const;
|
||||
|
||||
void RemoveUnusedResources();
|
||||
void RemoveResourcesWithUnusedSymbols();
|
||||
|
@ -142,14 +144,15 @@ public:
|
|||
const DxilFunctionProps &GetDxilFunctionProps(const llvm::Function *F) const;
|
||||
|
||||
// Move DxilFunctionProps of F to NewF.
|
||||
void SetPatchConstantFunctionForHS(llvm::Function *hullShaderFunc, llvm::Function *patchConstantFunc);
|
||||
void SetPatchConstantFunctionForHS(llvm::Function *hullShaderFunc,
|
||||
llvm::Function *patchConstantFunc);
|
||||
bool IsGraphicsShader(const llvm::Function *F) const; // vs,hs,ds,gs,ps
|
||||
bool IsPatchConstantShader(const llvm::Function *F) const;
|
||||
bool IsComputeShader(const llvm::Function *F) const;
|
||||
|
||||
// Is an entry function that uses input/output signature conventions?
|
||||
// Includes: vs/hs/ds/gs/ps/cs as well as the patch constant function.
|
||||
bool IsEntryThatUsesSignatures(const llvm::Function *F) const ;
|
||||
bool IsEntryThatUsesSignatures(const llvm::Function *F) const;
|
||||
// Is F an entry?
|
||||
// Includes: IsEntryThatUsesSignatures and all ray tracing shaders.
|
||||
bool IsEntry(const llvm::Function *F) const;
|
||||
|
@ -165,9 +168,10 @@ public:
|
|||
DxilTypeSystem &GetTypeSystem();
|
||||
const DxilTypeSystem &GetTypeSystem() const;
|
||||
|
||||
/// Emit llvm.used array to make sure that optimizations do not remove unreferenced globals.
|
||||
/// Emit llvm.used array to make sure that optimizations do not remove
|
||||
/// unreferenced globals.
|
||||
void EmitLLVMUsed();
|
||||
std::vector<llvm::GlobalVariable* > &GetLLVMUsed();
|
||||
std::vector<llvm::GlobalVariable *> &GetLLVMUsed();
|
||||
void ClearLLVMUsed();
|
||||
|
||||
// ViewId state.
|
||||
|
@ -210,7 +214,7 @@ public:
|
|||
// Helper to remove dx.* metadata with source and compile options.
|
||||
// If the parameter `bReplaceWithDummyData` is true, the named metadata
|
||||
// are replaced with valid empty data that satisfy tools.
|
||||
void StripShaderSourcesAndCompileOptions(bool bReplaceWithDummyData=false);
|
||||
void StripShaderSourcesAndCompileOptions(bool bReplaceWithDummyData = false);
|
||||
llvm::DebugInfoFinder &GetOrCreateDebugInfoFinder();
|
||||
|
||||
static DxilModule *TryGetDxilModule(llvm::Module *pModule);
|
||||
|
@ -230,10 +234,10 @@ public:
|
|||
// Check if the instruction has fast math flags configured to indicate
|
||||
// the instruction is precise.
|
||||
static bool HasPreciseFastMathFlags(const llvm::Instruction *inst);
|
||||
|
||||
|
||||
// Set fast math flags configured to indicate the instruction is precise.
|
||||
static void SetPreciseFastMathFlags(llvm::Instruction *inst);
|
||||
|
||||
|
||||
// True if fast math flags are preserved across serialize/deserialize.
|
||||
static bool PreservesFastMathFlags(const llvm::Instruction *inst);
|
||||
|
||||
|
@ -242,7 +246,8 @@ public:
|
|||
void CollectShaderFlagsForModule(ShaderFlags &Flags);
|
||||
|
||||
// Check if DxilModule contains multi component UAV Loads.
|
||||
// This funciton must be called after unused resources are removed from DxilModule
|
||||
// This funciton must be called after unused resources are removed from
|
||||
// DxilModule
|
||||
bool ModuleHasMulticomponentUAVLoads();
|
||||
|
||||
// Compute/Mesh/Amplification shader.
|
||||
|
@ -294,9 +299,11 @@ public:
|
|||
unsigned GetOutputControlPointCount() const;
|
||||
void SetOutputControlPointCount(unsigned NumOCPs);
|
||||
DXIL::TessellatorPartitioning GetTessellatorPartitioning() const;
|
||||
void SetTessellatorPartitioning(DXIL::TessellatorPartitioning TessPartitioning);
|
||||
void
|
||||
SetTessellatorPartitioning(DXIL::TessellatorPartitioning TessPartitioning);
|
||||
DXIL::TessellatorOutputPrimitive GetTessellatorOutputPrimitive() const;
|
||||
void SetTessellatorOutputPrimitive(DXIL::TessellatorOutputPrimitive TessOutputPrimitive);
|
||||
void SetTessellatorOutputPrimitive(
|
||||
DXIL::TessellatorOutputPrimitive TessOutputPrimitive);
|
||||
float GetMaxTessellationFactor() const;
|
||||
void SetMaxTessellationFactor(float MaxTessellationFactor);
|
||||
|
||||
|
@ -327,13 +334,14 @@ private:
|
|||
std::vector<uint8_t> m_SerializedRootSignature;
|
||||
|
||||
// Shader resources.
|
||||
std::vector<std::unique_ptr<DxilResource> > m_SRVs;
|
||||
std::vector<std::unique_ptr<DxilResource> > m_UAVs;
|
||||
std::vector<std::unique_ptr<DxilCBuffer> > m_CBuffers;
|
||||
std::vector<std::unique_ptr<DxilSampler> > m_Samplers;
|
||||
std::vector<std::unique_ptr<DxilResource>> m_SRVs;
|
||||
std::vector<std::unique_ptr<DxilResource>> m_UAVs;
|
||||
std::vector<std::unique_ptr<DxilCBuffer>> m_CBuffers;
|
||||
std::vector<std::unique_ptr<DxilSampler>> m_Samplers;
|
||||
|
||||
// Geometry shader.
|
||||
DXIL::PrimitiveTopology m_StreamPrimitiveTopology = DXIL::PrimitiveTopology::Undefined;
|
||||
DXIL::PrimitiveTopology m_StreamPrimitiveTopology =
|
||||
DXIL::PrimitiveTopology::Undefined;
|
||||
unsigned m_ActiveStreamMask = 0;
|
||||
|
||||
enum IntermediateFlags : uint32_t {
|
||||
|
@ -356,16 +364,16 @@ private:
|
|||
std::unique_ptr<OP> m_pOP;
|
||||
|
||||
// LLVM used.
|
||||
std::vector<llvm::GlobalVariable*> m_LLVMUsed;
|
||||
std::vector<llvm::GlobalVariable *> m_LLVMUsed;
|
||||
|
||||
// Type annotations.
|
||||
std::unique_ptr<DxilTypeSystem> m_pTypeSystem;
|
||||
|
||||
// EntryProps for shader functions.
|
||||
DxilEntryPropsMap m_DxilEntryPropsMap;
|
||||
DxilEntryPropsMap m_DxilEntryPropsMap;
|
||||
|
||||
// Keeps track of patch constant functions used by hull shaders
|
||||
std::unordered_set<const llvm::Function *> m_PatchConstantFunctions;
|
||||
std::unordered_set<const llvm::Function *> m_PatchConstantFunctions;
|
||||
|
||||
// Serialized ViewId state.
|
||||
std::vector<unsigned> m_SerializedState;
|
||||
|
@ -391,9 +399,11 @@ private:
|
|||
void LoadDxilResources(const llvm::MDOperand &MDO);
|
||||
|
||||
// Helpers.
|
||||
template<typename T> unsigned AddResource(std::vector<std::unique_ptr<T> > &Vec, std::unique_ptr<T> pRes);
|
||||
void LoadDxilSignature(const llvm::MDTuple *pSigTuple, DxilSignature &Sig, bool bInput);
|
||||
|
||||
template <typename T>
|
||||
unsigned AddResource(std::vector<std::unique_ptr<T>> &Vec,
|
||||
std::unique_ptr<T> pRes);
|
||||
void LoadDxilSignature(const llvm::MDTuple *pSigTuple, DxilSignature &Sig,
|
||||
bool bInput);
|
||||
};
|
||||
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -21,10 +21,10 @@ class Constant;
|
|||
class Value;
|
||||
class Instruction;
|
||||
class CallInst;
|
||||
}
|
||||
#include "llvm/IR/Attributes.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
} // namespace llvm
|
||||
#include "llvm/ADT/MapVector.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/IR/Attributes.h"
|
||||
|
||||
#include "DxilConstants.h"
|
||||
#include <unordered_map>
|
||||
|
@ -45,7 +45,8 @@ public:
|
|||
void FixOverloadNames();
|
||||
|
||||
llvm::Function *GetOpFunc(OpCode OpCode, llvm::Type *pOverloadType);
|
||||
const llvm::SmallMapVector<llvm::Type *, llvm::Function *, 8> &GetOpFuncList(OpCode OpCode) const;
|
||||
const llvm::SmallMapVector<llvm::Type *, llvm::Function *, 8> &
|
||||
GetOpFuncList(OpCode OpCode) const;
|
||||
bool IsDxilOpUsed(OpCode opcode) const;
|
||||
void RemoveFunction(llvm::Function *F);
|
||||
llvm::LLVMContext &GetCtx() { return m_Ctx; }
|
||||
|
@ -114,10 +115,10 @@ public:
|
|||
static void GetMinShaderModelAndMask(OpCode C, bool bWithTranslation,
|
||||
unsigned &major, unsigned &minor,
|
||||
unsigned &mask);
|
||||
static void GetMinShaderModelAndMask(const llvm::CallInst *CI, bool bWithTranslation,
|
||||
unsigned valMajor, unsigned valMinor,
|
||||
unsigned &major, unsigned &minor,
|
||||
unsigned &mask);
|
||||
static void GetMinShaderModelAndMask(const llvm::CallInst *CI,
|
||||
bool bWithTranslation, unsigned valMajor,
|
||||
unsigned valMinor, unsigned &major,
|
||||
unsigned &minor, unsigned &mask);
|
||||
|
||||
private:
|
||||
// Per-module properties.
|
||||
|
@ -139,7 +140,8 @@ private:
|
|||
|
||||
static const unsigned kUserDefineTypeSlot = 9;
|
||||
static const unsigned kObjectTypeSlot = 10;
|
||||
static const unsigned kNumTypeOverloads = 11; // void, h,f,d, i1, i8,i16,i32,i64, udt, obj
|
||||
static const unsigned kNumTypeOverloads =
|
||||
11; // void, h,f,d, i1, i8,i16,i32,i64, udt, obj
|
||||
|
||||
llvm::Type *m_pResRetType[kNumTypeOverloads];
|
||||
llvm::Type *m_pCBufferRetType[kNumTypeOverloads];
|
||||
|
@ -149,7 +151,8 @@ private:
|
|||
};
|
||||
OpCodeCacheItem m_OpCodeClassCache[(unsigned)OpCodeClass::NumOpClasses];
|
||||
std::unordered_map<const llvm::Function *, OpCodeClass> m_FunctionToOpClass;
|
||||
void UpdateCache(OpCodeClass opClass, llvm::Type * Ty, llvm::Function *F);
|
||||
void UpdateCache(OpCodeClass opClass, llvm::Type *Ty, llvm::Function *F);
|
||||
|
||||
private:
|
||||
// Static properties.
|
||||
struct OpCodeProperty {
|
||||
|
@ -157,7 +160,8 @@ private:
|
|||
const char *pOpCodeName;
|
||||
OpCodeClass opCodeClass;
|
||||
const char *pOpCodeClassName;
|
||||
bool bAllowOverload[kNumTypeOverloads]; // void, h,f,d, i1, i8,i16,i32,i64, udt
|
||||
bool bAllowOverload[kNumTypeOverloads]; // void, h,f,d, i1, i8,i16,i32,i64,
|
||||
// udt
|
||||
llvm::Attribute::AttrKind FuncAttr;
|
||||
};
|
||||
static const OpCodeProperty m_OpCodeProps[(unsigned)OpCode::NumOpCodes];
|
||||
|
@ -169,7 +173,8 @@ private:
|
|||
static unsigned GetTypeSlot(llvm::Type *pType);
|
||||
static const char *GetOverloadTypeName(unsigned TypeSlot);
|
||||
static llvm::StringRef GetTypeName(llvm::Type *Ty, std::string &str);
|
||||
static llvm::StringRef ConstructOverloadName(llvm::Type *Ty, DXIL::OpCode opCode,
|
||||
static llvm::StringRef ConstructOverloadName(llvm::Type *Ty,
|
||||
DXIL::OpCode opCode,
|
||||
std::string &funcNameStorage);
|
||||
};
|
||||
|
||||
|
|
|
@ -19,9 +19,13 @@ struct IMalloc;
|
|||
namespace hlsl {
|
||||
namespace pdb {
|
||||
|
||||
HRESULT LoadDataFromStream(IMalloc *pMalloc, IStream *pIStream, IDxcBlob **ppHash, IDxcBlob **ppContainer);
|
||||
HRESULT LoadDataFromStream(IMalloc *pMalloc, IStream *pIStream, IDxcBlob **pOutContainer);
|
||||
HRESULT WriteDxilPDB(IMalloc *pMalloc, IDxcBlob *pContainer, llvm::ArrayRef<BYTE> HashData, IDxcBlob **ppOutBlob);
|
||||
HRESULT WriteDxilPDB(IMalloc *pMalloc, llvm::ArrayRef<BYTE> ContainerData, llvm::ArrayRef<BYTE> HashData, IDxcBlob **ppOutBlob);
|
||||
}
|
||||
}
|
||||
HRESULT LoadDataFromStream(IMalloc *pMalloc, IStream *pIStream,
|
||||
IDxcBlob **ppHash, IDxcBlob **ppContainer);
|
||||
HRESULT LoadDataFromStream(IMalloc *pMalloc, IStream *pIStream,
|
||||
IDxcBlob **pOutContainer);
|
||||
HRESULT WriteDxilPDB(IMalloc *pMalloc, IDxcBlob *pContainer,
|
||||
llvm::ArrayRef<BYTE> HashData, IDxcBlob **ppOutBlob);
|
||||
HRESULT WriteDxilPDB(IMalloc *pMalloc, llvm::ArrayRef<BYTE> ContainerData,
|
||||
llvm::ArrayRef<BYTE> HashData, IDxcBlob **ppOutBlob);
|
||||
} // namespace pdb
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -12,9 +12,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "DxilConstants.h"
|
||||
#include "dxc/DXIL/DxilResourceBase.h"
|
||||
#include "dxc/DXIL/DxilCompType.h"
|
||||
|
||||
#include "dxc/DXIL/DxilResourceBase.h"
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
|
@ -87,12 +86,13 @@ public:
|
|||
void SetHasAtomic64Use(bool b);
|
||||
|
||||
static bool classof(const DxilResourceBase *R) {
|
||||
return R->GetClass() == DXIL::ResourceClass::SRV || R->GetClass() == DXIL::ResourceClass::UAV;
|
||||
return R->GetClass() == DXIL::ResourceClass::SRV ||
|
||||
R->GetClass() == DXIL::ResourceClass::UAV;
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned m_SampleCount;
|
||||
unsigned m_ElementStride; // in bytes
|
||||
unsigned m_ElementStride; // in bytes
|
||||
unsigned m_baseAlignLog2 = 0; // worst-case alignment
|
||||
CompType m_CompType;
|
||||
DXIL::SamplerFeedbackType m_SamplerFeedbackType;
|
||||
|
|
|
@ -19,8 +19,7 @@ namespace llvm {
|
|||
class Value;
|
||||
class Constant;
|
||||
class Type;
|
||||
}
|
||||
|
||||
} // namespace llvm
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
|
@ -70,16 +69,17 @@ protected:
|
|||
void SetClass(Class C);
|
||||
|
||||
private:
|
||||
Class m_Class; // Resource class (SRV, UAV, CBuffer, Sampler).
|
||||
Kind m_Kind; // Detail resource kind( texture2D...).
|
||||
unsigned m_ID; // Unique ID within the class.
|
||||
unsigned m_SpaceID; // Root signature space.
|
||||
unsigned m_LowerBound; // Range lower bound.
|
||||
unsigned m_RangeSize; // Range size in entries.
|
||||
llvm::Constant *m_pSymbol; // Global variable.
|
||||
std::string m_Name; // Unmangled name of the global variable.
|
||||
llvm::Value *m_pHandle; // Cached resource handle for SM5.0- (and maybe SM5.1).
|
||||
llvm::Type *m_pHLSLTy; // The original hlsl type for reflection.
|
||||
Class m_Class; // Resource class (SRV, UAV, CBuffer, Sampler).
|
||||
Kind m_Kind; // Detail resource kind( texture2D...).
|
||||
unsigned m_ID; // Unique ID within the class.
|
||||
unsigned m_SpaceID; // Root signature space.
|
||||
unsigned m_LowerBound; // Range lower bound.
|
||||
unsigned m_RangeSize; // Range size in entries.
|
||||
llvm::Constant *m_pSymbol; // Global variable.
|
||||
std::string m_Name; // Unmangled name of the global variable.
|
||||
llvm::Value
|
||||
*m_pHandle; // Cached resource handle for SM5.0- (and maybe SM5.1).
|
||||
llvm::Type *m_pHLSLTy; // The original hlsl type for reflection.
|
||||
};
|
||||
|
||||
const char *GetResourceKindName(DXIL::ResourceKind K);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
namespace llvm {
|
||||
class Constant;
|
||||
class Type;
|
||||
}
|
||||
} // namespace llvm
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
|
@ -44,9 +44,9 @@ namespace resource_helper {
|
|||
llvm::Constant *getAsConstant(const DxilResourceBinding &, llvm::Type *Ty,
|
||||
const ShaderModel &);
|
||||
DxilResourceBinding loadBindingFromConstant(const llvm::Constant &C);
|
||||
DxilResourceBinding
|
||||
loadBindingFromCreateHandleFromBinding(const DxilInst_CreateHandleFromBinding &createHandle, llvm::Type *Ty,
|
||||
const ShaderModel &);
|
||||
DxilResourceBinding loadBindingFromCreateHandleFromBinding(
|
||||
const DxilInst_CreateHandleFromBinding &createHandle, llvm::Type *Ty,
|
||||
const ShaderModel &);
|
||||
DxilResourceBinding loadBindingFromResourceBase(DxilResourceBase *);
|
||||
|
||||
} // namespace resource_helper
|
||||
|
|
|
@ -16,15 +16,16 @@
|
|||
namespace llvm {
|
||||
class Constant;
|
||||
class Type;
|
||||
}
|
||||
} // namespace llvm
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
struct DxilResourceProperties {
|
||||
struct TypedProps {
|
||||
uint8_t CompType; // TypedBuffer/Image component type.
|
||||
uint8_t CompCount; // Number of components known to shader.
|
||||
uint8_t SampleCount; // Number of samples for multisample texture if defined in HLSL.
|
||||
uint8_t CompType; // TypedBuffer/Image component type.
|
||||
uint8_t CompCount; // Number of components known to shader.
|
||||
uint8_t SampleCount; // Number of samples for multisample texture if defined
|
||||
// in HLSL.
|
||||
uint8_t Reserved3;
|
||||
};
|
||||
|
||||
|
@ -53,7 +54,7 @@ struct DxilResourceProperties {
|
|||
};
|
||||
|
||||
union {
|
||||
BasicProps Basic;
|
||||
BasicProps Basic;
|
||||
uint32_t RawDword0;
|
||||
};
|
||||
// DWORD
|
||||
|
@ -66,7 +67,7 @@ struct DxilResourceProperties {
|
|||
};
|
||||
DxilResourceProperties();
|
||||
DXIL::ResourceClass getResourceClass() const;
|
||||
DXIL::ResourceKind getResourceKind() const;
|
||||
DXIL::ResourceKind getResourceKind() const;
|
||||
DXIL::ComponentType getCompType() const;
|
||||
unsigned getElementStride() const;
|
||||
void setResourceKind(DXIL::ResourceKind RK);
|
||||
|
@ -89,7 +90,8 @@ llvm::Constant *getAsConstant(const DxilResourceProperties &, llvm::Type *Ty,
|
|||
const ShaderModel &);
|
||||
DxilResourceProperties loadPropsFromConstant(const llvm::Constant &C);
|
||||
DxilResourceProperties
|
||||
loadPropsFromAnnotateHandle(DxilInst_AnnotateHandle &annotateHandle, const ShaderModel &);
|
||||
loadPropsFromAnnotateHandle(DxilInst_AnnotateHandle &annotateHandle,
|
||||
const ShaderModel &);
|
||||
DxilResourceProperties loadPropsFromResourceBase(const DxilResourceBase *);
|
||||
DxilResourceProperties tryMergeProps(DxilResourceProperties,
|
||||
DxilResourceProperties);
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
void SetSamplerKind(SamplerKind K);
|
||||
|
||||
private:
|
||||
SamplerKind m_SamplerKind; // Sampler mode.
|
||||
SamplerKind m_SamplerKind; // Sampler mode.
|
||||
};
|
||||
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -27,15 +27,20 @@ public:
|
|||
static const int kUndefinedCol = -1;
|
||||
|
||||
static const Semantic *GetByName(llvm::StringRef name);
|
||||
static const Semantic *GetByName(llvm::StringRef Name, DXIL::SigPointKind sigPointKind,
|
||||
unsigned MajorVersion = ShaderModel::kHighestMajor, unsigned MinorVersion = ShaderModel::kHighestMinor);
|
||||
static const Semantic *
|
||||
GetByName(llvm::StringRef Name, DXIL::SigPointKind sigPointKind,
|
||||
unsigned MajorVersion = ShaderModel::kHighestMajor,
|
||||
unsigned MinorVersion = ShaderModel::kHighestMinor);
|
||||
static const Semantic *Get(Kind kind);
|
||||
static const Semantic *Get(Kind kind, DXIL::SigPointKind sigPointKind,
|
||||
unsigned MajorVersion = ShaderModel::kHighestMajor, unsigned MinorVersion = ShaderModel::kHighestMinor);
|
||||
static const Semantic *
|
||||
Get(Kind kind, DXIL::SigPointKind sigPointKind,
|
||||
unsigned MajorVersion = ShaderModel::kHighestMajor,
|
||||
unsigned MinorVersion = ShaderModel::kHighestMinor);
|
||||
static const Semantic *GetInvalid();
|
||||
static const Semantic *GetArbitrary();
|
||||
static bool HasSVPrefix(llvm::StringRef Name);
|
||||
static void DecomposeNameAndIndex(llvm::StringRef FullName, llvm::StringRef *pName, unsigned *pIndex);
|
||||
static void DecomposeNameAndIndex(llvm::StringRef FullName,
|
||||
llvm::StringRef *pName, unsigned *pIndex);
|
||||
|
||||
Kind GetKind() const;
|
||||
const char *GetName() const;
|
||||
|
@ -43,8 +48,8 @@ public:
|
|||
bool IsInvalid() const;
|
||||
|
||||
private:
|
||||
Kind m_Kind; // Semantic kind.
|
||||
const char *m_pszName; // Canonical name (for system semantics).
|
||||
Kind m_Kind; // Semantic kind.
|
||||
const char *m_pszName; // Canonical name (for system semantics).
|
||||
|
||||
Semantic() = delete;
|
||||
Semantic(Kind Kind, const char *pszName);
|
||||
|
|
|
@ -14,195 +14,263 @@
|
|||
#include <stdint.h>
|
||||
|
||||
namespace hlsl {
|
||||
class DxilModule;
|
||||
class DxilModule;
|
||||
}
|
||||
|
||||
namespace llvm {
|
||||
class Function;
|
||||
class Function;
|
||||
}
|
||||
|
||||
namespace hlsl {
|
||||
// Shader properties.
|
||||
class ShaderFlags {
|
||||
public:
|
||||
ShaderFlags();
|
||||
// Shader properties.
|
||||
class ShaderFlags {
|
||||
public:
|
||||
ShaderFlags();
|
||||
|
||||
static ShaderFlags CollectShaderFlags(const llvm::Function *F, const hlsl::DxilModule *M);
|
||||
unsigned GetGlobalFlags() const;
|
||||
uint64_t GetFeatureInfo() const;
|
||||
static uint64_t GetShaderFlagsRawForCollection(); // some flags are collected (eg use 64-bit), some provided (eg allow refactoring)
|
||||
uint64_t GetShaderFlagsRaw() const;
|
||||
void SetShaderFlagsRaw(uint64_t data);
|
||||
void CombineShaderFlags(const ShaderFlags &other);
|
||||
static ShaderFlags CollectShaderFlags(const llvm::Function *F,
|
||||
const hlsl::DxilModule *M);
|
||||
unsigned GetGlobalFlags() const;
|
||||
uint64_t GetFeatureInfo() const;
|
||||
static uint64_t
|
||||
GetShaderFlagsRawForCollection(); // some flags are collected (eg use 64-bit),
|
||||
// some provided (eg allow refactoring)
|
||||
uint64_t GetShaderFlagsRaw() const;
|
||||
void SetShaderFlagsRaw(uint64_t data);
|
||||
void CombineShaderFlags(const ShaderFlags &other);
|
||||
|
||||
void SetDisableOptimizations(bool flag) { m_bDisableOptimizations = flag; }
|
||||
bool GetDisableOptimizations() const { return m_bDisableOptimizations; }
|
||||
void SetDisableOptimizations(bool flag) { m_bDisableOptimizations = flag; }
|
||||
bool GetDisableOptimizations() const { return m_bDisableOptimizations; }
|
||||
|
||||
void SetDisableMathRefactoring(bool flag) { m_bDisableMathRefactoring = flag; }
|
||||
bool GetDisableMathRefactoring() const { return m_bDisableMathRefactoring; }
|
||||
void SetDisableMathRefactoring(bool flag) {
|
||||
m_bDisableMathRefactoring = flag;
|
||||
}
|
||||
bool GetDisableMathRefactoring() const { return m_bDisableMathRefactoring; }
|
||||
|
||||
void SetEnableDoublePrecision(bool flag) { m_bEnableDoublePrecision = flag; }
|
||||
bool GetEnableDoublePrecision() const { return m_bEnableDoublePrecision; }
|
||||
void SetEnableDoublePrecision(bool flag) { m_bEnableDoublePrecision = flag; }
|
||||
bool GetEnableDoublePrecision() const { return m_bEnableDoublePrecision; }
|
||||
|
||||
void SetForceEarlyDepthStencil(bool flag) { m_bForceEarlyDepthStencil = flag; }
|
||||
bool GetForceEarlyDepthStencil() const { return m_bForceEarlyDepthStencil; }
|
||||
void SetForceEarlyDepthStencil(bool flag) {
|
||||
m_bForceEarlyDepthStencil = flag;
|
||||
}
|
||||
bool GetForceEarlyDepthStencil() const { return m_bForceEarlyDepthStencil; }
|
||||
|
||||
void SetEnableRawAndStructuredBuffers(bool flag) { m_bEnableRawAndStructuredBuffers = flag; }
|
||||
bool GetEnableRawAndStructuredBuffers() const { return m_bEnableRawAndStructuredBuffers; }
|
||||
void SetEnableRawAndStructuredBuffers(bool flag) {
|
||||
m_bEnableRawAndStructuredBuffers = flag;
|
||||
}
|
||||
bool GetEnableRawAndStructuredBuffers() const {
|
||||
return m_bEnableRawAndStructuredBuffers;
|
||||
}
|
||||
|
||||
void SetLowPrecisionPresent(bool flag) { m_bLowPrecisionPresent = flag; }
|
||||
bool GetLowPrecisionPresent() const { return m_bLowPrecisionPresent; }
|
||||
void SetLowPrecisionPresent(bool flag) { m_bLowPrecisionPresent = flag; }
|
||||
bool GetLowPrecisionPresent() const { return m_bLowPrecisionPresent; }
|
||||
|
||||
void SetEnableDoubleExtensions(bool flag) { m_bEnableDoubleExtensions = flag; }
|
||||
bool GetEnableDoubleExtensions() const { return m_bEnableDoubleExtensions; }
|
||||
void SetEnableDoubleExtensions(bool flag) {
|
||||
m_bEnableDoubleExtensions = flag;
|
||||
}
|
||||
bool GetEnableDoubleExtensions() const { return m_bEnableDoubleExtensions; }
|
||||
|
||||
void SetEnableMSAD(bool flag) { m_bEnableMSAD = flag; }
|
||||
bool GetEnableMSAD() const { return m_bEnableMSAD; }
|
||||
void SetEnableMSAD(bool flag) { m_bEnableMSAD = flag; }
|
||||
bool GetEnableMSAD() const { return m_bEnableMSAD; }
|
||||
|
||||
void SetAllResourcesBound(bool flag) { m_bAllResourcesBound = flag; }
|
||||
bool GetAllResourcesBound() const { return m_bAllResourcesBound; }
|
||||
void SetAllResourcesBound(bool flag) { m_bAllResourcesBound = flag; }
|
||||
bool GetAllResourcesBound() const { return m_bAllResourcesBound; }
|
||||
|
||||
void SetCSRawAndStructuredViaShader4X(bool flag) { m_bCSRawAndStructuredViaShader4X = flag; }
|
||||
bool GetCSRawAndStructuredViaShader4X() const { return m_bCSRawAndStructuredViaShader4X; }
|
||||
void SetCSRawAndStructuredViaShader4X(bool flag) {
|
||||
m_bCSRawAndStructuredViaShader4X = flag;
|
||||
}
|
||||
bool GetCSRawAndStructuredViaShader4X() const {
|
||||
return m_bCSRawAndStructuredViaShader4X;
|
||||
}
|
||||
|
||||
void SetROVs(bool flag) { m_bROVS = flag; }
|
||||
bool GetROVs() const { return m_bROVS; }
|
||||
void SetROVs(bool flag) { m_bROVS = flag; }
|
||||
bool GetROVs() const { return m_bROVS; }
|
||||
|
||||
void SetWaveOps(bool flag) { m_bWaveOps = flag; }
|
||||
bool GetWaveOps() const { return m_bWaveOps; }
|
||||
void SetWaveOps(bool flag) { m_bWaveOps = flag; }
|
||||
bool GetWaveOps() const { return m_bWaveOps; }
|
||||
|
||||
void SetInt64Ops(bool flag) { m_bInt64Ops = flag; }
|
||||
bool GetInt64Ops() const { return m_bInt64Ops; }
|
||||
void SetInt64Ops(bool flag) { m_bInt64Ops = flag; }
|
||||
bool GetInt64Ops() const { return m_bInt64Ops; }
|
||||
|
||||
void SetTiledResources(bool flag) { m_bTiledResources = flag; }
|
||||
bool GetTiledResources() const { return m_bTiledResources; }
|
||||
void SetTiledResources(bool flag) { m_bTiledResources = flag; }
|
||||
bool GetTiledResources() const { return m_bTiledResources; }
|
||||
|
||||
void SetStencilRef(bool flag) { m_bStencilRef = flag; }
|
||||
bool GetStencilRef() const { return m_bStencilRef; }
|
||||
void SetStencilRef(bool flag) { m_bStencilRef = flag; }
|
||||
bool GetStencilRef() const { return m_bStencilRef; }
|
||||
|
||||
void SetInnerCoverage(bool flag) { m_bInnerCoverage = flag; }
|
||||
bool GetInnerCoverage() const { return m_bInnerCoverage; }
|
||||
void SetInnerCoverage(bool flag) { m_bInnerCoverage = flag; }
|
||||
bool GetInnerCoverage() const { return m_bInnerCoverage; }
|
||||
|
||||
void SetViewportAndRTArrayIndex(bool flag) { m_bViewportAndRTArrayIndex = flag; }
|
||||
bool GetViewportAndRTArrayIndex() const { return m_bViewportAndRTArrayIndex; }
|
||||
void SetViewportAndRTArrayIndex(bool flag) {
|
||||
m_bViewportAndRTArrayIndex = flag;
|
||||
}
|
||||
bool GetViewportAndRTArrayIndex() const { return m_bViewportAndRTArrayIndex; }
|
||||
|
||||
void SetUAVLoadAdditionalFormats(bool flag) { m_bUAVLoadAdditionalFormats = flag; }
|
||||
bool GetUAVLoadAdditionalFormats() const { return m_bUAVLoadAdditionalFormats; }
|
||||
void SetUAVLoadAdditionalFormats(bool flag) {
|
||||
m_bUAVLoadAdditionalFormats = flag;
|
||||
}
|
||||
bool GetUAVLoadAdditionalFormats() const {
|
||||
return m_bUAVLoadAdditionalFormats;
|
||||
}
|
||||
|
||||
void SetLevel9ComparisonFiltering(bool flag) { m_bLevel9ComparisonFiltering = flag; }
|
||||
bool GetLevel9ComparisonFiltering() const { return m_bLevel9ComparisonFiltering; }
|
||||
void SetLevel9ComparisonFiltering(bool flag) {
|
||||
m_bLevel9ComparisonFiltering = flag;
|
||||
}
|
||||
bool GetLevel9ComparisonFiltering() const {
|
||||
return m_bLevel9ComparisonFiltering;
|
||||
}
|
||||
|
||||
void Set64UAVs(bool flag) { m_b64UAVs = flag; }
|
||||
bool Get64UAVs() const { return m_b64UAVs; }
|
||||
void Set64UAVs(bool flag) { m_b64UAVs = flag; }
|
||||
bool Get64UAVs() const { return m_b64UAVs; }
|
||||
|
||||
void SetUAVsAtEveryStage(bool flag) { m_UAVsAtEveryStage = flag; }
|
||||
bool GetUAVsAtEveryStage() const { return m_UAVsAtEveryStage; }
|
||||
void SetUAVsAtEveryStage(bool flag) { m_UAVsAtEveryStage = flag; }
|
||||
bool GetUAVsAtEveryStage() const { return m_UAVsAtEveryStage; }
|
||||
|
||||
void SetViewID(bool flag) { m_bViewID = flag; }
|
||||
bool GetViewID() const { return m_bViewID; }
|
||||
void SetViewID(bool flag) { m_bViewID = flag; }
|
||||
bool GetViewID() const { return m_bViewID; }
|
||||
|
||||
void SetBarycentrics(bool flag) { m_bBarycentrics = flag; }
|
||||
bool GetBarycentrics() const { return m_bBarycentrics; }
|
||||
void SetBarycentrics(bool flag) { m_bBarycentrics = flag; }
|
||||
bool GetBarycentrics() const { return m_bBarycentrics; }
|
||||
|
||||
void SetUseNativeLowPrecision(bool flag) { m_bUseNativeLowPrecision = flag; }
|
||||
bool GetUseNativeLowPrecision() const { return m_bUseNativeLowPrecision; }
|
||||
void SetUseNativeLowPrecision(bool flag) { m_bUseNativeLowPrecision = flag; }
|
||||
bool GetUseNativeLowPrecision() const { return m_bUseNativeLowPrecision; }
|
||||
|
||||
void SetShadingRate(bool flag) { m_bShadingRate = flag; }
|
||||
bool GetShadingRate() const { return m_bShadingRate; }
|
||||
void SetShadingRate(bool flag) { m_bShadingRate = flag; }
|
||||
bool GetShadingRate() const { return m_bShadingRate; }
|
||||
|
||||
void SetRaytracingTier1_1(bool flag) { m_bRaytracingTier1_1 = flag; }
|
||||
bool GetRaytracingTier1_1() const { return m_bRaytracingTier1_1; }
|
||||
void SetRaytracingTier1_1(bool flag) { m_bRaytracingTier1_1 = flag; }
|
||||
bool GetRaytracingTier1_1() const { return m_bRaytracingTier1_1; }
|
||||
|
||||
void SetSamplerFeedback(bool flag) { m_bSamplerFeedback = flag; }
|
||||
bool GetSamplerFeedback() const { return m_bSamplerFeedback; }
|
||||
void SetSamplerFeedback(bool flag) { m_bSamplerFeedback = flag; }
|
||||
bool GetSamplerFeedback() const { return m_bSamplerFeedback; }
|
||||
|
||||
void SetAtomicInt64OnTypedResource(bool flag) { m_bAtomicInt64OnTypedResource = flag; }
|
||||
bool GetAtomicInt64OnTypedResource() const { return m_bAtomicInt64OnTypedResource; }
|
||||
void SetAtomicInt64OnTypedResource(bool flag) {
|
||||
m_bAtomicInt64OnTypedResource = flag;
|
||||
}
|
||||
bool GetAtomicInt64OnTypedResource() const {
|
||||
return m_bAtomicInt64OnTypedResource;
|
||||
}
|
||||
|
||||
void SetAtomicInt64OnGroupShared(bool flag) { m_bAtomicInt64OnGroupShared = flag; }
|
||||
bool GetAtomicInt64OnGroupShared() const { return m_bAtomicInt64OnGroupShared; }
|
||||
void SetAtomicInt64OnGroupShared(bool flag) {
|
||||
m_bAtomicInt64OnGroupShared = flag;
|
||||
}
|
||||
bool GetAtomicInt64OnGroupShared() const {
|
||||
return m_bAtomicInt64OnGroupShared;
|
||||
}
|
||||
|
||||
void SetDerivativesInMeshAndAmpShaders(bool flag) { m_bDerivativesInMeshAndAmpShaders = flag; }
|
||||
bool GetDerivativesInMeshAndAmpShaders() { return m_bDerivativesInMeshAndAmpShaders; }
|
||||
void SetDerivativesInMeshAndAmpShaders(bool flag) {
|
||||
m_bDerivativesInMeshAndAmpShaders = flag;
|
||||
}
|
||||
bool GetDerivativesInMeshAndAmpShaders() {
|
||||
return m_bDerivativesInMeshAndAmpShaders;
|
||||
}
|
||||
|
||||
void SetAtomicInt64OnHeapResource(bool flag) { m_bAtomicInt64OnHeapResource = flag; }
|
||||
bool GetAtomicInt64OnHeapResource() const { return m_bAtomicInt64OnHeapResource; }
|
||||
void SetAtomicInt64OnHeapResource(bool flag) {
|
||||
m_bAtomicInt64OnHeapResource = flag;
|
||||
}
|
||||
bool GetAtomicInt64OnHeapResource() const {
|
||||
return m_bAtomicInt64OnHeapResource;
|
||||
}
|
||||
|
||||
void SetResourceDescriptorHeapIndexing(bool flag) { m_bResourceDescriptorHeapIndexing = flag; }
|
||||
bool GetResourceDescriptorHeapIndexing() const { return m_bResourceDescriptorHeapIndexing; }
|
||||
void SetResourceDescriptorHeapIndexing(bool flag) {
|
||||
m_bResourceDescriptorHeapIndexing = flag;
|
||||
}
|
||||
bool GetResourceDescriptorHeapIndexing() const {
|
||||
return m_bResourceDescriptorHeapIndexing;
|
||||
}
|
||||
|
||||
void SetSamplerDescriptorHeapIndexing(bool flag) { m_bSamplerDescriptorHeapIndexing = flag; }
|
||||
bool GetSamplerDescriptorHeapIndexing() const { return m_bSamplerDescriptorHeapIndexing; }
|
||||
void SetSamplerDescriptorHeapIndexing(bool flag) {
|
||||
m_bSamplerDescriptorHeapIndexing = flag;
|
||||
}
|
||||
bool GetSamplerDescriptorHeapIndexing() const {
|
||||
return m_bSamplerDescriptorHeapIndexing;
|
||||
}
|
||||
|
||||
void SetResMayNotAlias(bool flag) { m_bResMayNotAlias = flag; }
|
||||
bool GetResMayNotAlias() const { return m_bResMayNotAlias; }
|
||||
void SetResMayNotAlias(bool flag) { m_bResMayNotAlias = flag; }
|
||||
bool GetResMayNotAlias() const { return m_bResMayNotAlias; }
|
||||
|
||||
void SetAdvancedTextureOps(bool flag) { m_bAdvancedTextureOps = flag; }
|
||||
bool GetAdvancedTextureOps() const { return m_bAdvancedTextureOps; }
|
||||
void SetAdvancedTextureOps(bool flag) { m_bAdvancedTextureOps = flag; }
|
||||
bool GetAdvancedTextureOps() const { return m_bAdvancedTextureOps; }
|
||||
|
||||
void SetWriteableMSAATextures(bool flag) { m_bWriteableMSAATextures = flag; }
|
||||
bool GetWriteableMSAATextures() const { return m_bWriteableMSAATextures; }
|
||||
void SetWriteableMSAATextures(bool flag) { m_bWriteableMSAATextures = flag; }
|
||||
bool GetWriteableMSAATextures() const { return m_bWriteableMSAATextures; }
|
||||
|
||||
private:
|
||||
unsigned m_bDisableOptimizations :1; // D3D11_1_SB_GLOBAL_FLAG_SKIP_OPTIMIZATION
|
||||
unsigned m_bDisableMathRefactoring :1; //~D3D10_SB_GLOBAL_FLAG_REFACTORING_ALLOWED
|
||||
unsigned m_bEnableDoublePrecision :1; // D3D11_SB_GLOBAL_FLAG_ENABLE_DOUBLE_PRECISION_FLOAT_OPS
|
||||
unsigned m_bForceEarlyDepthStencil :1; // D3D11_SB_GLOBAL_FLAG_FORCE_EARLY_DEPTH_STENCIL
|
||||
unsigned m_bEnableRawAndStructuredBuffers :1; // D3D11_SB_GLOBAL_FLAG_ENABLE_RAW_AND_STRUCTURED_BUFFERS
|
||||
unsigned m_bLowPrecisionPresent :1; // D3D11_1_SB_GLOBAL_FLAG_ENABLE_MINIMUM_PRECISION
|
||||
unsigned m_bEnableDoubleExtensions :1; // D3D11_1_SB_GLOBAL_FLAG_ENABLE_DOUBLE_EXTENSIONS
|
||||
unsigned m_bEnableMSAD :1; // D3D11_1_SB_GLOBAL_FLAG_ENABLE_SHADER_EXTENSIONS
|
||||
unsigned m_bAllResourcesBound :1; // D3D12_SB_GLOBAL_FLAG_ALL_RESOURCES_BOUND
|
||||
private:
|
||||
unsigned
|
||||
m_bDisableOptimizations : 1; // D3D11_1_SB_GLOBAL_FLAG_SKIP_OPTIMIZATION
|
||||
unsigned
|
||||
m_bDisableMathRefactoring : 1; //~D3D10_SB_GLOBAL_FLAG_REFACTORING_ALLOWED
|
||||
unsigned
|
||||
m_bEnableDoublePrecision : 1; // D3D11_SB_GLOBAL_FLAG_ENABLE_DOUBLE_PRECISION_FLOAT_OPS
|
||||
unsigned
|
||||
m_bForceEarlyDepthStencil : 1; // D3D11_SB_GLOBAL_FLAG_FORCE_EARLY_DEPTH_STENCIL
|
||||
unsigned
|
||||
m_bEnableRawAndStructuredBuffers : 1; // D3D11_SB_GLOBAL_FLAG_ENABLE_RAW_AND_STRUCTURED_BUFFERS
|
||||
unsigned
|
||||
m_bLowPrecisionPresent : 1; // D3D11_1_SB_GLOBAL_FLAG_ENABLE_MINIMUM_PRECISION
|
||||
unsigned
|
||||
m_bEnableDoubleExtensions : 1; // D3D11_1_SB_GLOBAL_FLAG_ENABLE_DOUBLE_EXTENSIONS
|
||||
unsigned m_bEnableMSAD : 1; // D3D11_1_SB_GLOBAL_FLAG_ENABLE_SHADER_EXTENSIONS
|
||||
unsigned m_bAllResourcesBound : 1; // D3D12_SB_GLOBAL_FLAG_ALL_RESOURCES_BOUND
|
||||
|
||||
unsigned m_bViewportAndRTArrayIndex :1; // SHADER_FEATURE_VIEWPORT_AND_RT_ARRAY_INDEX_FROM_ANY_SHADER_FEEDING_RASTERIZER
|
||||
unsigned m_bInnerCoverage :1; // SHADER_FEATURE_INNER_COVERAGE
|
||||
unsigned m_bStencilRef :1; // SHADER_FEATURE_STENCIL_REF
|
||||
unsigned m_bTiledResources :1; // SHADER_FEATURE_TILED_RESOURCES
|
||||
unsigned m_bUAVLoadAdditionalFormats :1; // SHADER_FEATURE_TYPED_UAV_LOAD_ADDITIONAL_FORMATS
|
||||
unsigned m_bLevel9ComparisonFiltering :1; // SHADER_FEATURE_LEVEL_9_COMPARISON_FILTERING
|
||||
// SHADER_FEATURE_11_1_SHADER_EXTENSIONS shared with EnableMSAD
|
||||
unsigned m_b64UAVs :1; // SHADER_FEATURE_64_UAVS
|
||||
unsigned m_UAVsAtEveryStage :1; // SHADER_FEATURE_UAVS_AT_EVERY_STAGE
|
||||
unsigned m_bCSRawAndStructuredViaShader4X : 1; // SHADER_FEATURE_COMPUTE_SHADERS_PLUS_RAW_AND_STRUCTURED_BUFFERS_VIA_SHADER_4_X
|
||||
|
||||
// SHADER_FEATURE_COMPUTE_SHADERS_PLUS_RAW_AND_STRUCTURED_BUFFERS_VIA_SHADER_4_X is specifically
|
||||
// about shader model 4.x.
|
||||
unsigned
|
||||
m_bViewportAndRTArrayIndex : 1; // SHADER_FEATURE_VIEWPORT_AND_RT_ARRAY_INDEX_FROM_ANY_SHADER_FEEDING_RASTERIZER
|
||||
unsigned m_bInnerCoverage : 1; // SHADER_FEATURE_INNER_COVERAGE
|
||||
unsigned m_bStencilRef : 1; // SHADER_FEATURE_STENCIL_REF
|
||||
unsigned m_bTiledResources : 1; // SHADER_FEATURE_TILED_RESOURCES
|
||||
unsigned
|
||||
m_bUAVLoadAdditionalFormats : 1; // SHADER_FEATURE_TYPED_UAV_LOAD_ADDITIONAL_FORMATS
|
||||
unsigned
|
||||
m_bLevel9ComparisonFiltering : 1; // SHADER_FEATURE_LEVEL_9_COMPARISON_FILTERING
|
||||
// SHADER_FEATURE_11_1_SHADER_EXTENSIONS
|
||||
// shared with EnableMSAD
|
||||
unsigned m_b64UAVs : 1; // SHADER_FEATURE_64_UAVS
|
||||
unsigned m_UAVsAtEveryStage : 1; // SHADER_FEATURE_UAVS_AT_EVERY_STAGE
|
||||
unsigned
|
||||
m_bCSRawAndStructuredViaShader4X : 1; // SHADER_FEATURE_COMPUTE_SHADERS_PLUS_RAW_AND_STRUCTURED_BUFFERS_VIA_SHADER_4_X
|
||||
|
||||
unsigned m_bROVS :1; // SHADER_FEATURE_ROVS
|
||||
unsigned m_bWaveOps :1; // SHADER_FEATURE_WAVE_OPS
|
||||
unsigned m_bInt64Ops :1; // SHADER_FEATURE_INT64_OPS
|
||||
unsigned m_bViewID : 1; // SHADER_FEATURE_VIEWID
|
||||
unsigned m_bBarycentrics : 1; // SHADER_FEATURE_BARYCENTRICS
|
||||
// SHADER_FEATURE_COMPUTE_SHADERS_PLUS_RAW_AND_STRUCTURED_BUFFERS_VIA_SHADER_4_X
|
||||
// is specifically about shader model 4.x.
|
||||
|
||||
unsigned m_bUseNativeLowPrecision : 1;
|
||||
unsigned m_bROVS : 1; // SHADER_FEATURE_ROVS
|
||||
unsigned m_bWaveOps : 1; // SHADER_FEATURE_WAVE_OPS
|
||||
unsigned m_bInt64Ops : 1; // SHADER_FEATURE_INT64_OPS
|
||||
unsigned m_bViewID : 1; // SHADER_FEATURE_VIEWID
|
||||
unsigned m_bBarycentrics : 1; // SHADER_FEATURE_BARYCENTRICS
|
||||
|
||||
unsigned m_bShadingRate : 1; // SHADER_FEATURE_SHADINGRATE
|
||||
unsigned m_bUseNativeLowPrecision : 1;
|
||||
|
||||
unsigned m_bRaytracingTier1_1 : 1; // SHADER_FEATURE_RAYTRACING_TIER_1_1
|
||||
unsigned m_bSamplerFeedback : 1; // SHADER_FEATURE_SAMPLER_FEEDBACK
|
||||
unsigned m_bShadingRate : 1; // SHADER_FEATURE_SHADINGRATE
|
||||
|
||||
unsigned m_bAtomicInt64OnTypedResource : 1; // SHADER_FEATURE_ATOMIC_INT64_ON_TYPED_RESOURCE
|
||||
unsigned m_bAtomicInt64OnGroupShared : 1; // SHADER_FEATURE_ATOMIC_INT64_ON_GROUP_SHARED
|
||||
unsigned m_bRaytracingTier1_1 : 1; // SHADER_FEATURE_RAYTRACING_TIER_1_1
|
||||
unsigned m_bSamplerFeedback : 1; // SHADER_FEATURE_SAMPLER_FEEDBACK
|
||||
|
||||
unsigned m_bDerivativesInMeshAndAmpShaders : 1; //SHADER_FEATURE_DERIVATIVES_IN_MESH_AND_AMPLIFICATION_SHADERS
|
||||
unsigned
|
||||
m_bAtomicInt64OnTypedResource : 1; // SHADER_FEATURE_ATOMIC_INT64_ON_TYPED_RESOURCE
|
||||
unsigned
|
||||
m_bAtomicInt64OnGroupShared : 1; // SHADER_FEATURE_ATOMIC_INT64_ON_GROUP_SHARED
|
||||
|
||||
unsigned m_bResourceDescriptorHeapIndexing : 1; // SHADER_FEATURE_RESOURCE_DESCRIPTOR_HEAP_INDEXING
|
||||
unsigned m_bSamplerDescriptorHeapIndexing : 1; // SHADER_FEATURE_SAMPLER_DESCRIPTOR_HEAP_INDEXING
|
||||
unsigned
|
||||
m_bDerivativesInMeshAndAmpShaders : 1; // SHADER_FEATURE_DERIVATIVES_IN_MESH_AND_AMPLIFICATION_SHADERS
|
||||
|
||||
unsigned m_bAtomicInt64OnHeapResource : 1; // SHADER_FEATURE_ATOMIC_INT64_ON_DESCRIPTOR_HEAP_RESOURCE
|
||||
unsigned
|
||||
m_bResourceDescriptorHeapIndexing : 1; // SHADER_FEATURE_RESOURCE_DESCRIPTOR_HEAP_INDEXING
|
||||
unsigned
|
||||
m_bSamplerDescriptorHeapIndexing : 1; // SHADER_FEATURE_SAMPLER_DESCRIPTOR_HEAP_INDEXING
|
||||
|
||||
// Global flag indicating that any UAV may not alias any other UAV.
|
||||
// Set if UAVs are used, unless -res-may-alias was specified.
|
||||
// For modules compiled against validator version < 1.7, this flag will be
|
||||
// cleared, and it must be assumed that UAV resources may alias.
|
||||
unsigned m_bResMayNotAlias : 1;
|
||||
unsigned
|
||||
m_bAtomicInt64OnHeapResource : 1; // SHADER_FEATURE_ATOMIC_INT64_ON_DESCRIPTOR_HEAP_RESOURCE
|
||||
|
||||
unsigned m_bAdvancedTextureOps : 1; // SHADER_FEATURE_ADVANCED_TEXTURE_OPS
|
||||
unsigned m_bWriteableMSAATextures : 1; // SHADER_FEATURE_WRITEABLE_MSAA_TEXTURES
|
||||
// Global flag indicating that any UAV may not alias any other UAV.
|
||||
// Set if UAVs are used, unless -res-may-alias was specified.
|
||||
// For modules compiled against validator version < 1.7, this flag will be
|
||||
// cleared, and it must be assumed that UAV resources may alias.
|
||||
unsigned m_bResMayNotAlias : 1;
|
||||
|
||||
uint32_t m_align1 : 28; // align to 64 bit.
|
||||
};
|
||||
unsigned m_bAdvancedTextureOps : 1; // SHADER_FEATURE_ADVANCED_TEXTURE_OPS
|
||||
unsigned
|
||||
m_bWriteableMSAATextures : 1; // SHADER_FEATURE_WRITEABLE_MSAA_TEXTURES
|
||||
|
||||
uint32_t m_align1 : 28; // align to 64 bit.
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -16,25 +16,33 @@
|
|||
namespace hlsl {
|
||||
|
||||
struct VersionedSemanticInterpretation {
|
||||
VersionedSemanticInterpretation(DXIL::SemanticInterpretationKind k, unsigned MajorVersion=0, unsigned MinorVersion=0) :
|
||||
Kind(k), Major((unsigned short)MajorVersion), Minor((unsigned short)MinorVersion)
|
||||
{}
|
||||
VersionedSemanticInterpretation(DXIL::SemanticInterpretationKind k,
|
||||
unsigned MajorVersion = 0,
|
||||
unsigned MinorVersion = 0)
|
||||
: Kind(k), Major((unsigned short)MajorVersion),
|
||||
Minor((unsigned short)MinorVersion) {}
|
||||
DXIL::SemanticInterpretationKind Kind;
|
||||
unsigned short Major, Minor;
|
||||
};
|
||||
|
||||
/// Use this class to describe an HLSL signature point.
|
||||
/// A signature point is a set of signature parameters at a particular shader stage,
|
||||
/// grouped by input/output/patch constant and value frequency.
|
||||
/// A signature point is a set of signature parameters at a particular shader
|
||||
/// stage, grouped by input/output/patch constant and value frequency.
|
||||
class SigPoint {
|
||||
public:
|
||||
using Kind = DXIL::SigPointKind;
|
||||
|
||||
SigPoint(DXIL::SigPointKind spk, const char *name, DXIL::SigPointKind rspk, DXIL::ShaderKind shk, DXIL::SignatureKind sigk, DXIL::PackingKind pk);
|
||||
SigPoint(DXIL::SigPointKind spk, const char *name, DXIL::SigPointKind rspk,
|
||||
DXIL::ShaderKind shk, DXIL::SignatureKind sigk,
|
||||
DXIL::PackingKind pk);
|
||||
|
||||
bool IsInput() const { return m_SignatureKind == DXIL::SignatureKind::Input; }
|
||||
bool IsOutput() const { return m_SignatureKind == DXIL::SignatureKind::Output; }
|
||||
bool IsPatchConstOrPrim() const { return m_SignatureKind == DXIL::SignatureKind::PatchConstOrPrim; }
|
||||
bool IsOutput() const {
|
||||
return m_SignatureKind == DXIL::SignatureKind::Output;
|
||||
}
|
||||
bool IsPatchConstOrPrim() const {
|
||||
return m_SignatureKind == DXIL::SignatureKind::PatchConstOrPrim;
|
||||
}
|
||||
|
||||
Kind GetKind() const { return m_Kind; }
|
||||
const char *GetName() const { return m_pszName; }
|
||||
|
@ -43,18 +51,27 @@ public:
|
|||
DXIL::SignatureKind GetSignatureKind() const { return m_SignatureKind; }
|
||||
DXIL::SignatureKind GetSignatureKindWithFallback() const;
|
||||
DXIL::PackingKind GetPackingKind() const { return m_PackingKind; }
|
||||
bool NeedsInterpMode() const { return m_PackingKind == DXIL::PackingKind::Vertex; }
|
||||
bool NeedsInterpMode() const {
|
||||
return m_PackingKind == DXIL::PackingKind::Vertex;
|
||||
}
|
||||
|
||||
static const SigPoint* GetSigPoint(Kind K);
|
||||
static const SigPoint *GetSigPoint(Kind K);
|
||||
|
||||
// isSpecialInput selects a signature point outside the normal input/output/patch constant signatures.
|
||||
// These are used for a few system values that should not be included as part of the regular input
|
||||
// structure because they do not have the same dimensionality as other inputs, such as
|
||||
// isSpecialInput selects a signature point outside the normal
|
||||
// input/output/patch constant signatures. These are used for a few system
|
||||
// values that should not be included as part of the regular input structure
|
||||
// because they do not have the same dimensionality as other inputs, such as
|
||||
// SV_PrimitiveID for Geometry, Hull, and Patch Constant Functions.
|
||||
static DXIL::SigPointKind GetKind(DXIL::ShaderKind shaderKind, DXIL::SignatureKind sigKind, bool isPatchConstantFunction, bool isSpecialInput);
|
||||
static DXIL::SigPointKind GetKind(DXIL::ShaderKind shaderKind,
|
||||
DXIL::SignatureKind sigKind,
|
||||
bool isPatchConstantFunction,
|
||||
bool isSpecialInput);
|
||||
|
||||
// Interpretations are how system values are intrepeted at a particular signature point.
|
||||
static DXIL::SemanticInterpretationKind GetInterpretation(DXIL::SemanticKind SK, Kind K, unsigned MajorVersion, unsigned MinorVersion);
|
||||
// Interpretations are how system values are intrepeted at a particular
|
||||
// signature point.
|
||||
static DXIL::SemanticInterpretationKind
|
||||
GetInterpretation(DXIL::SemanticKind SK, Kind K, unsigned MajorVersion,
|
||||
unsigned MinorVersion);
|
||||
|
||||
// For Shadow elements, recover original SigPointKind
|
||||
static Kind RecoverKind(DXIL::SemanticKind SK, Kind K);
|
||||
|
@ -62,7 +79,8 @@ public:
|
|||
private:
|
||||
static const unsigned kNumSigPointRecords = (unsigned)Kind::Invalid + 1;
|
||||
static const SigPoint ms_SigPoints[kNumSigPointRecords];
|
||||
static const VersionedSemanticInterpretation ms_SemanticInterpretationTable[(unsigned)DXIL::SemanticKind::Invalid][(unsigned)Kind::Invalid];
|
||||
static const VersionedSemanticInterpretation ms_SemanticInterpretationTable[(
|
||||
unsigned)DXIL::SemanticKind::Invalid][(unsigned)Kind::Invalid];
|
||||
|
||||
Kind m_Kind;
|
||||
Kind m_RelatedKind;
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
/// Use this class to represent HLSL signature.
|
||||
|
@ -24,7 +23,8 @@ class DxilSignature {
|
|||
public:
|
||||
using Kind = DXIL::SignatureKind;
|
||||
|
||||
DxilSignature(DXIL::ShaderKind shaderKind, DXIL::SignatureKind sigKind, bool useMinPrecision);
|
||||
DxilSignature(DXIL::ShaderKind shaderKind, DXIL::SignatureKind sigKind,
|
||||
bool useMinPrecision);
|
||||
DxilSignature(DXIL::SigPointKind sigPointKind, bool useMinPrecision);
|
||||
DxilSignature(const DxilSignature &src);
|
||||
virtual ~DxilSignature();
|
||||
|
@ -34,17 +34,19 @@ public:
|
|||
|
||||
virtual std::unique_ptr<DxilSignatureElement> CreateElement();
|
||||
|
||||
unsigned AppendElement(std::unique_ptr<DxilSignatureElement> pSE, bool bSetID = true);
|
||||
unsigned AppendElement(std::unique_ptr<DxilSignatureElement> pSE,
|
||||
bool bSetID = true);
|
||||
|
||||
DxilSignatureElement &GetElement(unsigned idx);
|
||||
const DxilSignatureElement &GetElement(unsigned idx) const;
|
||||
const std::vector<std::unique_ptr<DxilSignatureElement> > &GetElements() const;
|
||||
const std::vector<std::unique_ptr<DxilSignatureElement>> &GetElements() const;
|
||||
|
||||
// Returns true if all signature elements that should be allocated are allocated
|
||||
// Returns true if all signature elements that should be allocated are
|
||||
// allocated
|
||||
bool IsFullyAllocated() const;
|
||||
|
||||
// Returns the number of allocated vectors used to contain signature
|
||||
unsigned NumVectorsUsed(unsigned streamIndex = 0) const;
|
||||
unsigned NumVectorsUsed(unsigned streamIndex = 0) const;
|
||||
|
||||
bool UseMinPrecision() const { return m_UseMinPrecision; }
|
||||
|
||||
|
@ -56,16 +58,18 @@ public:
|
|||
|
||||
private:
|
||||
DXIL::SigPointKind m_sigPointKind;
|
||||
std::vector<std::unique_ptr<DxilSignatureElement> > m_Elements;
|
||||
std::vector<std::unique_ptr<DxilSignatureElement>> m_Elements;
|
||||
bool m_UseMinPrecision;
|
||||
};
|
||||
|
||||
struct DxilEntrySignature {
|
||||
DxilEntrySignature(DXIL::ShaderKind shaderKind, bool useMinPrecision)
|
||||
: InputSignature(shaderKind, DxilSignature::Kind::Input, useMinPrecision),
|
||||
OutputSignature(shaderKind, DxilSignature::Kind::Output, useMinPrecision),
|
||||
PatchConstOrPrimSignature(shaderKind, DxilSignature::Kind::PatchConstOrPrim, useMinPrecision) {
|
||||
}
|
||||
OutputSignature(shaderKind, DxilSignature::Kind::Output,
|
||||
useMinPrecision),
|
||||
PatchConstOrPrimSignature(shaderKind,
|
||||
DxilSignature::Kind::PatchConstOrPrim,
|
||||
useMinPrecision) {}
|
||||
DxilEntrySignature(const DxilEntrySignature &src);
|
||||
DxilSignature InputSignature;
|
||||
DxilSignature OutputSignature;
|
||||
|
|
|
@ -11,13 +11,13 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "dxc/DXIL/DxilSemantic.h"
|
||||
#include "dxc/DXIL/DxilInterpolationMode.h"
|
||||
#include "dxc/DXIL/DxilCompType.h"
|
||||
#include "dxc/DXIL/DxilInterpolationMode.h"
|
||||
#include "dxc/DXIL/DxilSemantic.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include <limits.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <limits.h>
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
|
@ -35,10 +35,12 @@ public:
|
|||
DxilSignatureElement(Kind K);
|
||||
virtual ~DxilSignatureElement();
|
||||
|
||||
void Initialize(llvm::StringRef Name, const CompType &ElementType, const InterpolationMode &InterpMode,
|
||||
unsigned Rows, unsigned Cols,
|
||||
int StartRow = Semantic::kUndefinedRow, int StartCol = Semantic::kUndefinedCol,
|
||||
unsigned ID = kUndefinedID, const std::vector<unsigned> &IndexVector = std::vector<unsigned>());
|
||||
void Initialize(
|
||||
llvm::StringRef Name, const CompType &ElementType,
|
||||
const InterpolationMode &InterpMode, unsigned Rows, unsigned Cols,
|
||||
int StartRow = Semantic::kUndefinedRow,
|
||||
int StartCol = Semantic::kUndefinedCol, unsigned ID = kUndefinedID,
|
||||
const std::vector<unsigned> &IndexVector = std::vector<unsigned>());
|
||||
|
||||
unsigned GetID() const;
|
||||
void SetID(unsigned ID);
|
||||
|
|
|
@ -11,20 +11,20 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
#include "DxilConstants.h"
|
||||
#include "llvm/ADT/MapVector.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
class DxilSubobjects;
|
||||
|
||||
namespace RDAT {
|
||||
class DxilRuntimeData;
|
||||
class DxilRuntimeData;
|
||||
}
|
||||
|
||||
class DxilSubobject {
|
||||
|
@ -44,25 +44,25 @@ public:
|
|||
// Note: strings and root signature data is owned by DxilModule
|
||||
// When creating subobjects, use canonical strings from module
|
||||
|
||||
|
||||
bool GetStateObjectConfig(uint32_t &Flags) const;
|
||||
bool GetRootSignature(bool local, const void * &Data, uint32_t &Size,
|
||||
bool GetRootSignature(bool local, const void *&Data, uint32_t &Size,
|
||||
const char **pText = nullptr) const;
|
||||
bool GetSubobjectToExportsAssociation(llvm::StringRef &Subobject,
|
||||
const char * const * &Exports,
|
||||
const char *const *&Exports,
|
||||
uint32_t &NumExports) const;
|
||||
bool GetRaytracingShaderConfig(uint32_t &MaxPayloadSizeInBytes,
|
||||
uint32_t &MaxAttributeSizeInBytes) const;
|
||||
bool GetRaytracingPipelineConfig(uint32_t &MaxTraceRecursionDepth) const;
|
||||
bool GetRaytracingPipelineConfig1(uint32_t &MaxTraceRecursionDepth, uint32_t &Flags) const;
|
||||
bool GetHitGroup(DXIL::HitGroupType &hitGroupType,
|
||||
llvm::StringRef &AnyHit,
|
||||
bool GetRaytracingPipelineConfig1(uint32_t &MaxTraceRecursionDepth,
|
||||
uint32_t &Flags) const;
|
||||
bool GetHitGroup(DXIL::HitGroupType &hitGroupType, llvm::StringRef &AnyHit,
|
||||
llvm::StringRef &ClosestHit,
|
||||
llvm::StringRef &Intersection) const;
|
||||
|
||||
private:
|
||||
DxilSubobject(DxilSubobjects &owner, Kind kind, llvm::StringRef name);
|
||||
DxilSubobject(DxilSubobjects &owner, const DxilSubobject &other, llvm::StringRef name);
|
||||
DxilSubobject(DxilSubobjects &owner, const DxilSubobject &other,
|
||||
llvm::StringRef name);
|
||||
void CopyUnionedContents(const DxilSubobject &other);
|
||||
void InternStrings();
|
||||
|
||||
|
@ -70,10 +70,10 @@ private:
|
|||
Kind m_Kind;
|
||||
llvm::StringRef m_Name;
|
||||
|
||||
std::vector<const char*> m_Exports;
|
||||
std::vector<const char *> m_Exports;
|
||||
|
||||
struct StateObjectConfig_t {
|
||||
uint32_t Flags; // DXIL::StateObjectFlags
|
||||
uint32_t Flags; // DXIL::StateObjectFlags
|
||||
};
|
||||
struct RootSignature_t {
|
||||
uint32_t Size;
|
||||
|
@ -118,8 +118,9 @@ private:
|
|||
class DxilSubobjects {
|
||||
public:
|
||||
typedef std::pair<std::unique_ptr<char[]>, size_t> StoredBytes;
|
||||
typedef llvm::MapVector< llvm::StringRef, StoredBytes > BytesStorage;
|
||||
typedef llvm::MapVector< llvm::StringRef, std::unique_ptr<DxilSubobject> > SubobjectStorage;
|
||||
typedef llvm::MapVector<llvm::StringRef, StoredBytes> BytesStorage;
|
||||
typedef llvm::MapVector<llvm::StringRef, std::unique_ptr<DxilSubobject>>
|
||||
SubobjectStorage;
|
||||
using Kind = DXIL::SubobjectKind;
|
||||
|
||||
DxilSubobjects();
|
||||
|
@ -135,34 +136,30 @@ public:
|
|||
const void *InternRawBytes(const void *ptr, size_t size);
|
||||
DxilSubobject *FindSubobject(llvm::StringRef name);
|
||||
void RemoveSubobject(llvm::StringRef name);
|
||||
DxilSubobject &CloneSubobject(const DxilSubobject &Subobject, llvm::StringRef Name);
|
||||
const SubobjectStorage &GetSubobjects() const { return m_Subobjects; }
|
||||
DxilSubobject &CloneSubobject(const DxilSubobject &Subobject,
|
||||
llvm::StringRef Name);
|
||||
const SubobjectStorage &GetSubobjects() const { return m_Subobjects; }
|
||||
|
||||
// Create DxilSubobjects
|
||||
|
||||
DxilSubobject &CreateStateObjectConfig(llvm::StringRef Name,
|
||||
uint32_t Flags);
|
||||
DxilSubobject &CreateStateObjectConfig(llvm::StringRef Name, uint32_t Flags);
|
||||
// Local/Global RootSignature
|
||||
DxilSubobject &CreateRootSignature(llvm::StringRef Name,
|
||||
bool local,
|
||||
const void *Data,
|
||||
uint32_t Size,
|
||||
DxilSubobject &CreateRootSignature(llvm::StringRef Name, bool local,
|
||||
const void *Data, uint32_t Size,
|
||||
llvm::StringRef *pText = nullptr);
|
||||
DxilSubobject &CreateSubobjectToExportsAssociation(
|
||||
llvm::StringRef Name,
|
||||
llvm::StringRef Subobject, llvm::StringRef *Exports, uint32_t NumExports);
|
||||
DxilSubobject &CreateRaytracingShaderConfig(
|
||||
llvm::StringRef Name,
|
||||
uint32_t MaxPayloadSizeInBytes,
|
||||
uint32_t MaxAttributeSizeInBytes);
|
||||
DxilSubobject &CreateRaytracingPipelineConfig(
|
||||
llvm::StringRef Name,
|
||||
uint32_t MaxTraceRecursionDepth);
|
||||
DxilSubobject &CreateSubobjectToExportsAssociation(llvm::StringRef Name,
|
||||
llvm::StringRef Subobject,
|
||||
llvm::StringRef *Exports,
|
||||
uint32_t NumExports);
|
||||
DxilSubobject &CreateRaytracingShaderConfig(llvm::StringRef Name,
|
||||
uint32_t MaxPayloadSizeInBytes,
|
||||
uint32_t MaxAttributeSizeInBytes);
|
||||
DxilSubobject &
|
||||
CreateRaytracingPipelineConfig(llvm::StringRef Name,
|
||||
uint32_t MaxTraceRecursionDepth);
|
||||
DxilSubobject &CreateRaytracingPipelineConfig1(
|
||||
llvm::StringRef Name,
|
||||
uint32_t MaxTraceRecursionDepth,
|
||||
uint32_t Flags);
|
||||
DxilSubobject &CreateHitGroup(llvm::StringRef Name,
|
||||
llvm::StringRef Name, uint32_t MaxTraceRecursionDepth, uint32_t Flags);
|
||||
DxilSubobject &CreateHitGroup(llvm::StringRef Name,
|
||||
DXIL::HitGroupType hitGroupType,
|
||||
llvm::StringRef AnyHit,
|
||||
llvm::StringRef ClosestHit,
|
||||
|
@ -175,6 +172,7 @@ private:
|
|||
SubobjectStorage m_Subobjects;
|
||||
};
|
||||
|
||||
bool LoadSubobjectsFromRDAT(DxilSubobjects &subobjects, const RDAT::DxilRuntimeData &rdat);
|
||||
bool LoadSubobjectsFromRDAT(DxilSubobjects &subobjects,
|
||||
const RDAT::DxilRuntimeData &rdat);
|
||||
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -10,12 +10,12 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/MapVector.h"
|
||||
#include "dxc/DXIL/DxilConstants.h"
|
||||
#include "dxc/DXIL/DxilCompType.h"
|
||||
#include "dxc/DXIL/DxilConstants.h"
|
||||
#include "dxc/DXIL/DxilInterpolationMode.h"
|
||||
#include "dxc/DXIL/DxilResourceProperties.h"
|
||||
#include "llvm/ADT/MapVector.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
@ -28,12 +28,16 @@ class Function;
|
|||
class MDNode;
|
||||
class Type;
|
||||
class StructType;
|
||||
}
|
||||
|
||||
} // namespace llvm
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
enum class MatrixOrientation { Undefined = 0, RowMajor, ColumnMajor, LastEntry };
|
||||
enum class MatrixOrientation {
|
||||
Undefined = 0,
|
||||
RowMajor,
|
||||
ColumnMajor,
|
||||
LastEntry
|
||||
};
|
||||
|
||||
struct DxilMatrixAnnotation {
|
||||
unsigned Rows;
|
||||
|
@ -47,7 +51,7 @@ struct DxilMatrixAnnotation {
|
|||
class DxilFieldAnnotation {
|
||||
public:
|
||||
DxilFieldAnnotation();
|
||||
|
||||
|
||||
bool IsPrecise() const;
|
||||
void SetPrecise(bool b = true);
|
||||
|
||||
|
@ -103,7 +107,8 @@ private:
|
|||
std::string m_Semantic;
|
||||
InterpolationMode m_InterpMode;
|
||||
std::string m_FieldName;
|
||||
bool m_bCBufferVarUsed; // true if this field represents a top level variable in CB structure, and it is used.
|
||||
bool m_bCBufferVarUsed; // true if this field represents a top level variable
|
||||
// in CB structure, and it is used.
|
||||
std::vector<DxilFieldAnnotation> m_BitFields;
|
||||
unsigned m_BitFieldWidth; // For bit field. 0 means not bitfield.
|
||||
};
|
||||
|
@ -148,26 +153,30 @@ public:
|
|||
unsigned GetNumTemplateArgs() const;
|
||||
void SetNumTemplateArgs(unsigned count);
|
||||
DxilTemplateArgAnnotation &GetTemplateArgAnnotation(unsigned argIdx);
|
||||
const DxilTemplateArgAnnotation &GetTemplateArgAnnotation(unsigned argIdx) const;
|
||||
const DxilTemplateArgAnnotation &
|
||||
GetTemplateArgAnnotation(unsigned argIdx) const;
|
||||
|
||||
private:
|
||||
const llvm::StructType *m_pStructType = nullptr;
|
||||
std::vector<DxilFieldAnnotation> m_FieldAnnotations;
|
||||
unsigned m_CBufferSize = 0; // The size of struct if inside constant buffer.
|
||||
unsigned m_CBufferSize = 0; // The size of struct if inside constant buffer.
|
||||
std::vector<DxilTemplateArgAnnotation> m_TemplateAnnotations;
|
||||
|
||||
// m_ResourcesContained property not stored to metadata
|
||||
void SetContainsResources();
|
||||
// HasResources::Only will be set on MarkEmptyStruct() when HasResources::True
|
||||
enum class HasResources { True, False, Only } m_ResourcesContained = HasResources::False;
|
||||
enum class HasResources {
|
||||
True,
|
||||
False,
|
||||
Only
|
||||
} m_ResourcesContained = HasResources::False;
|
||||
};
|
||||
|
||||
|
||||
/// Use this class to represent type annotation for DXR payload field.
|
||||
class DxilPayloadFieldAnnotation {
|
||||
public:
|
||||
|
||||
static unsigned GetBitOffsetForShaderStage(DXIL::PayloadAccessShaderStage shaderStage);
|
||||
static unsigned
|
||||
GetBitOffsetForShaderStage(DXIL::PayloadAccessShaderStage shaderStage);
|
||||
|
||||
DxilPayloadFieldAnnotation() = default;
|
||||
|
||||
|
@ -177,8 +186,10 @@ public:
|
|||
|
||||
uint32_t GetPayloadFieldQualifierMask() const;
|
||||
void SetPayloadFieldQualifierMask(uint32_t fieldBitmask);
|
||||
void AddPayloadFieldQualifier(DXIL::PayloadAccessShaderStage shaderStage, DXIL::PayloadAccessQualifier qualifier);
|
||||
DXIL::PayloadAccessQualifier GetPayloadFieldQualifier(DXIL::PayloadAccessShaderStage shaderStage) const;
|
||||
void AddPayloadFieldQualifier(DXIL::PayloadAccessShaderStage shaderStage,
|
||||
DXIL::PayloadAccessQualifier qualifier);
|
||||
DXIL::PayloadAccessQualifier
|
||||
GetPayloadFieldQualifier(DXIL::PayloadAccessShaderStage shaderStage) const;
|
||||
bool HasAnnotations() const;
|
||||
|
||||
private:
|
||||
|
@ -202,7 +213,6 @@ private:
|
|||
std::vector<DxilPayloadFieldAnnotation> m_FieldAnnotations;
|
||||
};
|
||||
|
||||
|
||||
enum class DxilParamInputQual {
|
||||
In,
|
||||
Out,
|
||||
|
@ -229,6 +239,7 @@ public:
|
|||
const std::vector<unsigned> &GetSemanticIndexVec() const;
|
||||
void SetSemanticIndexVec(const std::vector<unsigned> &Vec);
|
||||
void AppendSemanticIndex(unsigned SemIdx);
|
||||
|
||||
private:
|
||||
DxilParamInputQual m_inputQual;
|
||||
std::vector<unsigned> m_semanticIndex;
|
||||
|
@ -241,7 +252,8 @@ class DxilFunctionAnnotation {
|
|||
public:
|
||||
unsigned GetNumParameters() const;
|
||||
DxilParameterAnnotation &GetParameterAnnotation(unsigned ParamIdx);
|
||||
const DxilParameterAnnotation &GetParameterAnnotation(unsigned ParamIdx) const;
|
||||
const DxilParameterAnnotation &
|
||||
GetParameterAnnotation(unsigned ParamIdx) const;
|
||||
const llvm::Function *GetFunction() const;
|
||||
DxilParameterAnnotation &GetRetTypeAnnotation();
|
||||
const DxilParameterAnnotation &GetRetTypeAnnotation() const;
|
||||
|
@ -261,34 +273,49 @@ private:
|
|||
/// Use this class to represent structure type annotations in HL and DXIL.
|
||||
class DxilTypeSystem {
|
||||
public:
|
||||
using StructAnnotationMap = llvm::MapVector<const llvm::StructType *, std::unique_ptr<DxilStructAnnotation> >;
|
||||
using PayloadAnnotationMap = llvm::MapVector<const llvm::StructType *, std::unique_ptr<DxilPayloadAnnotation> >;
|
||||
using FunctionAnnotationMap = llvm::MapVector<const llvm::Function *, std::unique_ptr<DxilFunctionAnnotation> >;
|
||||
using StructAnnotationMap =
|
||||
llvm::MapVector<const llvm::StructType *,
|
||||
std::unique_ptr<DxilStructAnnotation>>;
|
||||
using PayloadAnnotationMap =
|
||||
llvm::MapVector<const llvm::StructType *,
|
||||
std::unique_ptr<DxilPayloadAnnotation>>;
|
||||
using FunctionAnnotationMap =
|
||||
llvm::MapVector<const llvm::Function *,
|
||||
std::unique_ptr<DxilFunctionAnnotation>>;
|
||||
|
||||
DxilTypeSystem(llvm::Module *pModule);
|
||||
|
||||
DxilStructAnnotation *AddStructAnnotation(const llvm::StructType *pStructType, unsigned numTemplateArgs = 0);
|
||||
DxilStructAnnotation *AddStructAnnotation(const llvm::StructType *pStructType,
|
||||
unsigned numTemplateArgs = 0);
|
||||
void FinishStructAnnotation(DxilStructAnnotation &SA);
|
||||
DxilStructAnnotation *GetStructAnnotation(const llvm::StructType *pStructType);
|
||||
const DxilStructAnnotation *GetStructAnnotation(const llvm::StructType *pStructType) const;
|
||||
DxilStructAnnotation *
|
||||
GetStructAnnotation(const llvm::StructType *pStructType);
|
||||
const DxilStructAnnotation *
|
||||
GetStructAnnotation(const llvm::StructType *pStructType) const;
|
||||
void EraseStructAnnotation(const llvm::StructType *pStructType);
|
||||
void EraseUnusedStructAnnotations();
|
||||
|
||||
StructAnnotationMap &GetStructAnnotationMap();
|
||||
const StructAnnotationMap &GetStructAnnotationMap() const;
|
||||
|
||||
DxilPayloadAnnotation *AddPayloadAnnotation(const llvm::StructType *pStructType);
|
||||
DxilPayloadAnnotation *GetPayloadAnnotation(const llvm::StructType *pStructType);
|
||||
const DxilPayloadAnnotation *GetPayloadAnnotation(const llvm::StructType *pStructType) const;
|
||||
DxilPayloadAnnotation *
|
||||
AddPayloadAnnotation(const llvm::StructType *pStructType);
|
||||
DxilPayloadAnnotation *
|
||||
GetPayloadAnnotation(const llvm::StructType *pStructType);
|
||||
const DxilPayloadAnnotation *
|
||||
GetPayloadAnnotation(const llvm::StructType *pStructType) const;
|
||||
void ErasePayloadAnnotation(const llvm::StructType *pStructType);
|
||||
|
||||
PayloadAnnotationMap &GetPayloadAnnotationMap();
|
||||
const PayloadAnnotationMap &GetPayloadAnnotationMap() const;
|
||||
|
||||
DxilFunctionAnnotation *AddFunctionAnnotation(const llvm::Function *pFunction);
|
||||
DxilFunctionAnnotation *
|
||||
AddFunctionAnnotation(const llvm::Function *pFunction);
|
||||
void FinishFunctionAnnotation(DxilFunctionAnnotation &FA);
|
||||
DxilFunctionAnnotation *GetFunctionAnnotation(const llvm::Function *pFunction);
|
||||
const DxilFunctionAnnotation *GetFunctionAnnotation(const llvm::Function *pFunction) const;
|
||||
DxilFunctionAnnotation *
|
||||
GetFunctionAnnotation(const llvm::Function *pFunction);
|
||||
const DxilFunctionAnnotation *
|
||||
GetFunctionAnnotation(const llvm::Function *pFunction) const;
|
||||
void EraseFunctionAnnotation(const llvm::Function *pFunction);
|
||||
|
||||
FunctionAnnotationMap &GetFunctionAnnotationMap();
|
||||
|
@ -321,9 +348,12 @@ private:
|
|||
llvm::StructType *GetNormFloatType(CompType CT, unsigned NumComps);
|
||||
};
|
||||
|
||||
DXIL::SigPointKind SigPointFromInputQual(DxilParamInputQual Q, DXIL::ShaderKind SK, bool isPC);
|
||||
DXIL::SigPointKind SigPointFromInputQual(DxilParamInputQual Q,
|
||||
DXIL::ShaderKind SK, bool isPC);
|
||||
|
||||
void RemapObsoleteSemantic(DxilParameterAnnotation ¶mInfo, DXIL::SigPointKind sigPoint, llvm::LLVMContext &Context);
|
||||
void RemapObsoleteSemantic(DxilParameterAnnotation ¶mInfo,
|
||||
DXIL::SigPointKind sigPoint,
|
||||
llvm::LLVMContext &Context);
|
||||
|
||||
class DxilStructTypeIterator {
|
||||
private:
|
||||
|
|
|
@ -10,14 +10,14 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
#include <unordered_set>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include "dxc/DXIL/DxilConstants.h"
|
||||
#include "dxc/DXIL/DxilResourceProperties.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/Twine.h"
|
||||
#include "llvm/IR/Constants.h"
|
||||
#include "dxc/DXIL/DxilConstants.h"
|
||||
#include "dxc/DXIL/DxilResourceProperties.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace llvm {
|
||||
class Type;
|
||||
|
@ -41,8 +41,8 @@ class ConstantInt;
|
|||
class SwitchInst;
|
||||
|
||||
ModulePass *createDxilLoadMetadataPass();
|
||||
void initializeDxilLoadMetadataPass(llvm::PassRegistry&);
|
||||
}
|
||||
void initializeDxilLoadMetadataPass(llvm::PassRegistry &);
|
||||
} // namespace llvm
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
|
@ -52,133 +52,154 @@ class DxilTypeSystem;
|
|||
class OP;
|
||||
|
||||
namespace dxilutil {
|
||||
extern const char ManglingPrefix[];
|
||||
extern const char EntryPrefix[];
|
||||
extern const char *kResourceMapErrorMsg;
|
||||
extern const char ManglingPrefix[];
|
||||
extern const char EntryPrefix[];
|
||||
extern const char *kResourceMapErrorMsg;
|
||||
|
||||
unsigned
|
||||
GetLegacyCBufferFieldElementSize(DxilFieldAnnotation &fieldAnnotation,
|
||||
llvm::Type *Ty, DxilTypeSystem &typeSys);
|
||||
llvm::Type *GetArrayEltTy(llvm::Type *Ty);
|
||||
bool HasDynamicIndexing(llvm::Value *V);
|
||||
unsigned GetLegacyCBufferFieldElementSize(DxilFieldAnnotation &fieldAnnotation,
|
||||
llvm::Type *Ty,
|
||||
DxilTypeSystem &typeSys);
|
||||
llvm::Type *GetArrayEltTy(llvm::Type *Ty);
|
||||
bool HasDynamicIndexing(llvm::Value *V);
|
||||
|
||||
// Cleans up unnecessary chains of GEPs and bitcasts left over from certain
|
||||
// optimizations. This function is NOT safe to call while iterating
|
||||
// instructions either forward or backward. If V happens to be a GEP or
|
||||
// bitcast, the function may delete V, instructions preceding V it, and
|
||||
// instructions following V.
|
||||
bool MergeGepUse(llvm::Value *V);
|
||||
// Cleans up unnecessary chains of GEPs and bitcasts left over from certain
|
||||
// optimizations. This function is NOT safe to call while iterating
|
||||
// instructions either forward or backward. If V happens to be a GEP or
|
||||
// bitcast, the function may delete V, instructions preceding V it, and
|
||||
// instructions following V.
|
||||
bool MergeGepUse(llvm::Value *V);
|
||||
|
||||
// Find alloca insertion point, given instruction
|
||||
llvm::Instruction *FindAllocaInsertionPt(llvm::Instruction* I); // Considers entire parent function
|
||||
llvm::Instruction *FindAllocaInsertionPt(llvm::BasicBlock* BB); // Only considers provided block
|
||||
llvm::Instruction *FindAllocaInsertionPt(llvm::Function* F);
|
||||
llvm::Instruction *SkipAllocas(llvm::Instruction *I);
|
||||
// Get first non-alloca insertion point, to avoid inserting non-allocas before alloca
|
||||
llvm::Instruction *FirstNonAllocaInsertionPt(llvm::Instruction* I); // Considers entire parent function
|
||||
llvm::Instruction *FirstNonAllocaInsertionPt(llvm::BasicBlock* BB); // Only considers provided block
|
||||
llvm::Instruction *FirstNonAllocaInsertionPt(llvm::Function* F);
|
||||
// Find alloca insertion point, given instruction
|
||||
llvm::Instruction *
|
||||
FindAllocaInsertionPt(llvm::Instruction *I); // Considers entire parent function
|
||||
llvm::Instruction *
|
||||
FindAllocaInsertionPt(llvm::BasicBlock *BB); // Only considers provided block
|
||||
llvm::Instruction *FindAllocaInsertionPt(llvm::Function *F);
|
||||
llvm::Instruction *SkipAllocas(llvm::Instruction *I);
|
||||
// Get first non-alloca insertion point, to avoid inserting non-allocas before
|
||||
// alloca
|
||||
llvm::Instruction *FirstNonAllocaInsertionPt(
|
||||
llvm::Instruction *I); // Considers entire parent function
|
||||
llvm::Instruction *FirstNonAllocaInsertionPt(
|
||||
llvm::BasicBlock *BB); // Only considers provided block
|
||||
llvm::Instruction *FirstNonAllocaInsertionPt(llvm::Function *F);
|
||||
|
||||
bool IsStaticGlobal(llvm::GlobalVariable *GV);
|
||||
bool IsSharedMemoryGlobal(llvm::GlobalVariable *GV);
|
||||
bool RemoveUnusedFunctions(llvm::Module &M, llvm::Function *EntryFunc,
|
||||
llvm::Function *PatchConstantFunc, bool IsLib);
|
||||
bool IsStaticGlobal(llvm::GlobalVariable *GV);
|
||||
bool IsSharedMemoryGlobal(llvm::GlobalVariable *GV);
|
||||
bool RemoveUnusedFunctions(llvm::Module &M, llvm::Function *EntryFunc,
|
||||
llvm::Function *PatchConstantFunc, bool IsLib);
|
||||
|
||||
llvm::DIGlobalVariable *FindGlobalVariableDebugInfo(llvm::GlobalVariable *GV,
|
||||
llvm::DebugInfoFinder &DbgInfoFinder);
|
||||
llvm::DIGlobalVariable *
|
||||
FindGlobalVariableDebugInfo(llvm::GlobalVariable *GV,
|
||||
llvm::DebugInfoFinder &DbgInfoFinder);
|
||||
|
||||
void EmitErrorOnInstruction(llvm::Instruction *I, llvm::Twine Msg);
|
||||
void EmitWarningOnInstruction(llvm::Instruction *I, llvm::Twine Msg);
|
||||
void EmitErrorOnFunction(llvm::LLVMContext &Ctx, llvm::Function *F, llvm::Twine Msg);
|
||||
void EmitWarningOnFunction(llvm::LLVMContext &Ctx, llvm::Function *F, llvm::Twine Msg);
|
||||
void EmitErrorOnGlobalVariable(llvm::LLVMContext &Ctx, llvm::GlobalVariable *GV, llvm::Twine Msg);
|
||||
void EmitWarningOnGlobalVariable(llvm::LLVMContext &Ctx, llvm::GlobalVariable *GV, llvm::Twine Msg);
|
||||
void EmitErrorOnContext(llvm::LLVMContext &Ctx, llvm::Twine Msg);
|
||||
void EmitWarningOnContext(llvm::LLVMContext &Ctx, llvm::Twine Msg);
|
||||
void EmitNoteOnContext(llvm::LLVMContext &Ctx, llvm::Twine Msg);
|
||||
void EmitErrorOnInstruction(llvm::Instruction *I, llvm::Twine Msg);
|
||||
void EmitWarningOnInstruction(llvm::Instruction *I, llvm::Twine Msg);
|
||||
void EmitErrorOnFunction(llvm::LLVMContext &Ctx, llvm::Function *F,
|
||||
llvm::Twine Msg);
|
||||
void EmitWarningOnFunction(llvm::LLVMContext &Ctx, llvm::Function *F,
|
||||
llvm::Twine Msg);
|
||||
void EmitErrorOnGlobalVariable(llvm::LLVMContext &Ctx, llvm::GlobalVariable *GV,
|
||||
llvm::Twine Msg);
|
||||
void EmitWarningOnGlobalVariable(llvm::LLVMContext &Ctx,
|
||||
llvm::GlobalVariable *GV, llvm::Twine Msg);
|
||||
void EmitErrorOnContext(llvm::LLVMContext &Ctx, llvm::Twine Msg);
|
||||
void EmitWarningOnContext(llvm::LLVMContext &Ctx, llvm::Twine Msg);
|
||||
void EmitNoteOnContext(llvm::LLVMContext &Ctx, llvm::Twine Msg);
|
||||
|
||||
void EmitResMappingError(llvm::Instruction *Res);
|
||||
// Simple demangle just support case "\01?name@" pattern.
|
||||
llvm::StringRef DemangleFunctionName(llvm::StringRef name);
|
||||
// ReplaceFunctionName replaces the undecorated portion of originalName with undecorated newName
|
||||
std::string ReplaceFunctionName(llvm::StringRef originalName, llvm::StringRef newName);
|
||||
void PrintEscapedString(llvm::StringRef Name, llvm::raw_ostream &Out);
|
||||
void PrintUnescapedString(llvm::StringRef Name, llvm::raw_ostream &Out);
|
||||
// Change select/phi on operands into select/phi on operation.
|
||||
// phi0 = phi a0, b0, c0
|
||||
// phi1 = phi a1, b1, c1
|
||||
// Inst = Add(phi0, phi1);
|
||||
// into
|
||||
// A = Add(a0, a1);
|
||||
// B = Add(b0, b1);
|
||||
// C = Add(c0, c1);
|
||||
// NewInst = phi A, B, C
|
||||
// Only support 1 operand now, other oerands should be Constant.
|
||||
llvm::Value * SelectOnOperation(llvm::Instruction *Inst, unsigned operandIdx);
|
||||
// Collect all select operand used by Inst.
|
||||
void CollectSelect(llvm::Instruction *Inst,
|
||||
void EmitResMappingError(llvm::Instruction *Res);
|
||||
// Simple demangle just support case "\01?name@" pattern.
|
||||
llvm::StringRef DemangleFunctionName(llvm::StringRef name);
|
||||
// ReplaceFunctionName replaces the undecorated portion of originalName with
|
||||
// undecorated newName
|
||||
std::string ReplaceFunctionName(llvm::StringRef originalName,
|
||||
llvm::StringRef newName);
|
||||
void PrintEscapedString(llvm::StringRef Name, llvm::raw_ostream &Out);
|
||||
void PrintUnescapedString(llvm::StringRef Name, llvm::raw_ostream &Out);
|
||||
// Change select/phi on operands into select/phi on operation.
|
||||
// phi0 = phi a0, b0, c0
|
||||
// phi1 = phi a1, b1, c1
|
||||
// Inst = Add(phi0, phi1);
|
||||
// into
|
||||
// A = Add(a0, a1);
|
||||
// B = Add(b0, b1);
|
||||
// C = Add(c0, c1);
|
||||
// NewInst = phi A, B, C
|
||||
// Only support 1 operand now, other oerands should be Constant.
|
||||
llvm::Value *SelectOnOperation(llvm::Instruction *Inst, unsigned operandIdx);
|
||||
// Collect all select operand used by Inst.
|
||||
void CollectSelect(llvm::Instruction *Inst,
|
||||
std::unordered_set<llvm::Instruction *> &selectSet);
|
||||
// If all operands are the same for a select inst, replace it with the operand.
|
||||
// Returns replacement value if successful
|
||||
llvm::Value *MergeSelectOnSameValue(llvm::Instruction *SelInst,
|
||||
unsigned startOpIdx,
|
||||
unsigned numOperands);
|
||||
bool SimplifyTrivialPHIs(llvm::BasicBlock *BB);
|
||||
llvm::BasicBlock *GetSwitchSuccessorForCond(llvm::SwitchInst *Switch, llvm::ConstantInt *Cond);
|
||||
void MigrateDebugValue(llvm::Value *Old, llvm::Value *New);
|
||||
void TryScatterDebugValueToVectorElements(llvm::Value *Val);
|
||||
std::unique_ptr<llvm::Module> LoadModuleFromBitcode(llvm::StringRef BC,
|
||||
llvm::LLVMContext &Ctx, std::string &DiagStr);
|
||||
std::unique_ptr<llvm::Module> LoadModuleFromBitcode(llvm::MemoryBuffer *MB,
|
||||
llvm::LLVMContext &Ctx, std::string &DiagStr);
|
||||
std::unique_ptr<llvm::Module> LoadModuleFromBitcodeLazy(std::unique_ptr<llvm::MemoryBuffer> &&MB,
|
||||
llvm::LLVMContext &Ctx, std::string &DiagStr);
|
||||
void PrintDiagnosticHandler(const llvm::DiagnosticInfo &DI, void *Context);
|
||||
bool IsIntegerOrFloatingPointType(llvm::Type *Ty);
|
||||
// Returns true if type contains HLSL Object type (resource)
|
||||
bool ContainsHLSLObjectType(llvm::Type *Ty);
|
||||
std::pair<bool, DxilResourceProperties> GetHLSLResourceProperties(llvm::Type *Ty);
|
||||
bool IsHLSLResourceType(llvm::Type *Ty);
|
||||
bool IsHLSLObjectType(llvm::Type *Ty);
|
||||
bool IsHLSLRayQueryType(llvm::Type *Ty);
|
||||
bool IsHLSLResourceDescType(llvm::Type *Ty);
|
||||
bool IsResourceSingleComponent(llvm::Type *Ty);
|
||||
uint8_t GetResourceComponentCount(llvm::Type *Ty);
|
||||
bool IsSplat(llvm::ConstantDataVector *cdv);
|
||||
// If all operands are the same for a select inst, replace it with the operand.
|
||||
// Returns replacement value if successful
|
||||
llvm::Value *MergeSelectOnSameValue(llvm::Instruction *SelInst,
|
||||
unsigned startOpIdx, unsigned numOperands);
|
||||
bool SimplifyTrivialPHIs(llvm::BasicBlock *BB);
|
||||
llvm::BasicBlock *GetSwitchSuccessorForCond(llvm::SwitchInst *Switch,
|
||||
llvm::ConstantInt *Cond);
|
||||
void MigrateDebugValue(llvm::Value *Old, llvm::Value *New);
|
||||
void TryScatterDebugValueToVectorElements(llvm::Value *Val);
|
||||
std::unique_ptr<llvm::Module> LoadModuleFromBitcode(llvm::StringRef BC,
|
||||
llvm::LLVMContext &Ctx,
|
||||
std::string &DiagStr);
|
||||
std::unique_ptr<llvm::Module> LoadModuleFromBitcode(llvm::MemoryBuffer *MB,
|
||||
llvm::LLVMContext &Ctx,
|
||||
std::string &DiagStr);
|
||||
std::unique_ptr<llvm::Module>
|
||||
LoadModuleFromBitcodeLazy(std::unique_ptr<llvm::MemoryBuffer> &&MB,
|
||||
llvm::LLVMContext &Ctx, std::string &DiagStr);
|
||||
void PrintDiagnosticHandler(const llvm::DiagnosticInfo &DI, void *Context);
|
||||
bool IsIntegerOrFloatingPointType(llvm::Type *Ty);
|
||||
// Returns true if type contains HLSL Object type (resource)
|
||||
bool ContainsHLSLObjectType(llvm::Type *Ty);
|
||||
std::pair<bool, DxilResourceProperties>
|
||||
GetHLSLResourceProperties(llvm::Type *Ty);
|
||||
bool IsHLSLResourceType(llvm::Type *Ty);
|
||||
bool IsHLSLObjectType(llvm::Type *Ty);
|
||||
bool IsHLSLRayQueryType(llvm::Type *Ty);
|
||||
bool IsHLSLResourceDescType(llvm::Type *Ty);
|
||||
bool IsResourceSingleComponent(llvm::Type *Ty);
|
||||
uint8_t GetResourceComponentCount(llvm::Type *Ty);
|
||||
bool IsSplat(llvm::ConstantDataVector *cdv);
|
||||
|
||||
llvm::Type* StripArrayTypes(llvm::Type *Ty, llvm::SmallVectorImpl<unsigned> *OuterToInnerLengths = nullptr);
|
||||
llvm::Type* WrapInArrayTypes(llvm::Type *Ty, llvm::ArrayRef<unsigned> OuterToInnerLengths);
|
||||
llvm::Type *
|
||||
StripArrayTypes(llvm::Type *Ty,
|
||||
llvm::SmallVectorImpl<unsigned> *OuterToInnerLengths = nullptr);
|
||||
llvm::Type *WrapInArrayTypes(llvm::Type *Ty,
|
||||
llvm::ArrayRef<unsigned> OuterToInnerLengths);
|
||||
|
||||
llvm::CallInst *TranslateCallRawBufferLoadToBufferLoad(
|
||||
llvm::CallInst *TranslateCallRawBufferLoadToBufferLoad(
|
||||
llvm::CallInst *CI, llvm::Function *newFunction, hlsl::OP *op);
|
||||
void ReplaceRawBufferLoadWithBufferLoad(llvm::Function *F, hlsl::OP *op);
|
||||
void ReplaceRawBufferLoadWithBufferLoad(llvm::Function *F, hlsl::OP *op);
|
||||
|
||||
llvm::CallInst *TranslateCallRawBufferStoreToBufferStore(
|
||||
llvm::CallInst *TranslateCallRawBufferStoreToBufferStore(
|
||||
llvm::CallInst *CI, llvm::Function *newFunction, hlsl::OP *op);
|
||||
void ReplaceRawBufferStoreWithBufferStore(llvm::Function *F, hlsl::OP *op);
|
||||
void ReplaceRawBufferStoreWithBufferStore(llvm::Function *F, hlsl::OP *op);
|
||||
|
||||
void ReplaceRawBufferLoad64Bit(llvm::Function *F, llvm::Type *EltTy, hlsl::OP *hlslOP);
|
||||
void ReplaceRawBufferStore64Bit(llvm::Function *F, llvm::Type *ETy, hlsl::OP *hlslOP);
|
||||
void ReplaceRawBufferLoad64Bit(llvm::Function *F, llvm::Type *EltTy,
|
||||
hlsl::OP *hlslOP);
|
||||
void ReplaceRawBufferStore64Bit(llvm::Function *F, llvm::Type *ETy,
|
||||
hlsl::OP *hlslOP);
|
||||
|
||||
bool IsConvergentMarker(llvm::Value *V);
|
||||
llvm::Value *GetConvergentSource(llvm::Value *V);
|
||||
bool IsConvergentMarker(llvm::Value *V);
|
||||
llvm::Value *GetConvergentSource(llvm::Value *V);
|
||||
|
||||
/// If value is a bitcast to base class pattern, equivalent
|
||||
/// to a getelementptr X, 0, 0, 0... turn it into the appropriate gep.
|
||||
/// This can enhance SROA and other transforms that want type-safe pointers,
|
||||
/// and enables merging with other getelementptr's.
|
||||
llvm::Value *TryReplaceBaseCastWithGep(llvm::Value *V);
|
||||
/// If value is a bitcast to base class pattern, equivalent
|
||||
/// to a getelementptr X, 0, 0, 0... turn it into the appropriate gep.
|
||||
/// This can enhance SROA and other transforms that want type-safe pointers,
|
||||
/// and enables merging with other getelementptr's.
|
||||
llvm::Value *TryReplaceBaseCastWithGep(llvm::Value *V);
|
||||
|
||||
llvm::Value::user_iterator mdv_users_end(llvm::Value *V);
|
||||
llvm::Value::user_iterator mdv_users_begin(llvm::Value *V);
|
||||
inline bool mdv_user_empty(llvm::Value *V) {
|
||||
return mdv_users_begin(V) == mdv_users_end(V);
|
||||
}
|
||||
|
||||
/// Finds all allocas that only have stores and delete them.
|
||||
/// These allocas hold on to values that do not contribute to the
|
||||
/// shader's results.
|
||||
bool DeleteDeadAllocas(llvm::Function &F);
|
||||
llvm::Value::user_iterator mdv_users_end(llvm::Value *V);
|
||||
llvm::Value::user_iterator mdv_users_begin(llvm::Value *V);
|
||||
inline bool mdv_user_empty(llvm::Value *V) {
|
||||
return mdv_users_begin(V) == mdv_users_end(V);
|
||||
}
|
||||
|
||||
}
|
||||
/// Finds all allocas that only have stores and delete them.
|
||||
/// These allocas hold on to values that do not contribute to the
|
||||
/// shader's results.
|
||||
bool DeleteDeadAllocas(llvm::Function &F);
|
||||
} // namespace dxilutil
|
||||
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -9,19 +9,19 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "dxc/DXIL/DxilConstants.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace llvm {
|
||||
class raw_ostream;
|
||||
class Module;
|
||||
}
|
||||
class raw_ostream;
|
||||
class Module;
|
||||
} // namespace llvm
|
||||
|
||||
namespace hlsl {
|
||||
class DxilModule;
|
||||
class DxilModule;
|
||||
}
|
||||
|
||||
namespace hlsl {
|
||||
|
@ -34,8 +34,9 @@ struct DxcBindingTable {
|
|||
std::map<Key, Entry> entries;
|
||||
};
|
||||
|
||||
bool ParseBindingTable(llvm::StringRef fileName, llvm::StringRef content, llvm::raw_ostream &errors, DxcBindingTable *outTable);
|
||||
bool ParseBindingTable(llvm::StringRef fileName, llvm::StringRef content,
|
||||
llvm::raw_ostream &errors, DxcBindingTable *outTable);
|
||||
void WriteBindingTableToMetadata(llvm::Module &M, const DxcBindingTable &table);
|
||||
void ApplyBindingTableFromMetadata(hlsl::DxilModule &DM);
|
||||
|
||||
}
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -15,35 +15,29 @@
|
|||
#include <cstddef>
|
||||
struct IMalloc;
|
||||
namespace hlsl {
|
||||
enum class ZlibResult {
|
||||
Success = 0,
|
||||
InvalidData = 1,
|
||||
OutOfMemory = 2,
|
||||
};
|
||||
enum class ZlibResult {
|
||||
Success = 0,
|
||||
InvalidData = 1,
|
||||
OutOfMemory = 2,
|
||||
};
|
||||
|
||||
ZlibResult ZlibDecompress(
|
||||
IMalloc *pMalloc,
|
||||
const void *pCompressedBuffer,
|
||||
size_t BufferSizeInBytes,
|
||||
void *pUncompressedBuffer,
|
||||
size_t UncompressedBufferSize);
|
||||
ZlibResult ZlibDecompress(IMalloc *pMalloc, const void *pCompressedBuffer,
|
||||
size_t BufferSizeInBytes, void *pUncompressedBuffer,
|
||||
size_t UncompressedBufferSize);
|
||||
|
||||
//
|
||||
// This is a user-provided callback function. The compression routine does
|
||||
// not need to know how the destination data is being managed. For example:
|
||||
// appending to an std::vector.
|
||||
//
|
||||
// During compression, the routine will call this callback to request the
|
||||
// amount of memory required for the next segment, and then write to it.
|
||||
//
|
||||
// See DxilCompressionHelpers for example of usage.
|
||||
//
|
||||
typedef void *ZlibCallbackFn(void *pUserData, size_t RequiredSize);
|
||||
//
|
||||
// This is a user-provided callback function. The compression routine does
|
||||
// not need to know how the destination data is being managed. For example:
|
||||
// appending to an std::vector.
|
||||
//
|
||||
// During compression, the routine will call this callback to request the
|
||||
// amount of memory required for the next segment, and then write to it.
|
||||
//
|
||||
// See DxilCompressionHelpers for example of usage.
|
||||
//
|
||||
typedef void *ZlibCallbackFn(void *pUserData, size_t RequiredSize);
|
||||
|
||||
ZlibResult ZlibCompress(
|
||||
IMalloc *pMalloc,
|
||||
const void *pData, size_t pDataSize,
|
||||
void *pUserData,
|
||||
ZlibCallbackFn *Callback,
|
||||
size_t *pOutCompressedSize);
|
||||
}
|
||||
ZlibResult ZlibCompress(IMalloc *pMalloc, const void *pData, size_t pDataSize,
|
||||
void *pUserData, ZlibCallbackFn *Callback,
|
||||
size_t *pOutCompressedSize);
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -21,58 +21,66 @@
|
|||
|
||||
namespace hlsl {
|
||||
|
||||
template<typename Buffer>
|
||||
ZlibResult ZlibCompressAppend(IMalloc *pMalloc, const void *pData, size_t dataSize, Buffer &outBuffer)
|
||||
{
|
||||
static_assert(sizeof(typename Buffer::value_type) == sizeof(uint8_t), "Cannot append to a non-byte-sized buffer.");
|
||||
template <typename Buffer>
|
||||
ZlibResult ZlibCompressAppend(IMalloc *pMalloc, const void *pData,
|
||||
size_t dataSize, Buffer &outBuffer) {
|
||||
static_assert(sizeof(typename Buffer::value_type) == sizeof(uint8_t),
|
||||
"Cannot append to a non-byte-sized buffer.");
|
||||
|
||||
// This helper resets the buffer to its original size in case of failure or exception
|
||||
class RAIIResizer {
|
||||
Buffer &m_Buffer;
|
||||
size_t m_OriginalSize;
|
||||
bool m_Resize = true;
|
||||
public:
|
||||
RAIIResizer(Buffer &buffer) : m_Buffer(buffer), m_OriginalSize(buffer.size()) {}
|
||||
~RAIIResizer() {
|
||||
if (m_Resize) {
|
||||
m_Buffer.resize(m_OriginalSize);
|
||||
}
|
||||
// This helper resets the buffer to its original size in case of failure or
|
||||
// exception
|
||||
class RAIIResizer {
|
||||
Buffer &m_Buffer;
|
||||
size_t m_OriginalSize;
|
||||
bool m_Resize = true;
|
||||
|
||||
public:
|
||||
RAIIResizer(Buffer &buffer)
|
||||
: m_Buffer(buffer), m_OriginalSize(buffer.size()) {}
|
||||
~RAIIResizer() {
|
||||
if (m_Resize) {
|
||||
m_Buffer.resize(m_OriginalSize);
|
||||
}
|
||||
void DoNotResize() { m_Resize = false; }
|
||||
};
|
||||
RAIIResizer resizer(outBuffer);
|
||||
|
||||
const size_t sizeBeforeCompress = outBuffer.size();
|
||||
size_t compressedDataSize = 0;
|
||||
|
||||
ZlibResult ret =
|
||||
ZlibCompress(pMalloc, pData, dataSize,
|
||||
&outBuffer,
|
||||
[](void *pUserData, size_t requiredSize) -> void *{
|
||||
Buffer *pBuffer = (Buffer *)pUserData;
|
||||
const size_t lastSize = pBuffer->size();
|
||||
pBuffer->resize(pBuffer->size() + requiredSize);
|
||||
void *ptr = pBuffer->data() + lastSize;
|
||||
return ptr;
|
||||
}, &compressedDataSize);
|
||||
|
||||
if (ret == ZlibResult::Success) {
|
||||
// Resize the buffer to what was actually added to the end.
|
||||
outBuffer.resize(sizeBeforeCompress + compressedDataSize);
|
||||
resizer.DoNotResize();
|
||||
}
|
||||
void DoNotResize() { m_Resize = false; }
|
||||
};
|
||||
RAIIResizer resizer(outBuffer);
|
||||
|
||||
return ret;
|
||||
const size_t sizeBeforeCompress = outBuffer.size();
|
||||
size_t compressedDataSize = 0;
|
||||
|
||||
ZlibResult ret = ZlibCompress(
|
||||
pMalloc, pData, dataSize, &outBuffer,
|
||||
[](void *pUserData, size_t requiredSize) -> void * {
|
||||
Buffer *pBuffer = (Buffer *)pUserData;
|
||||
const size_t lastSize = pBuffer->size();
|
||||
pBuffer->resize(pBuffer->size() + requiredSize);
|
||||
void *ptr = pBuffer->data() + lastSize;
|
||||
return ptr;
|
||||
},
|
||||
&compressedDataSize);
|
||||
|
||||
if (ret == ZlibResult::Success) {
|
||||
// Resize the buffer to what was actually added to the end.
|
||||
outBuffer.resize(sizeBeforeCompress + compressedDataSize);
|
||||
resizer.DoNotResize();
|
||||
}
|
||||
|
||||
template
|
||||
ZlibResult ZlibCompressAppend<llvm::SmallVectorImpl<char> >(IMalloc *pMalloc, const void *pData, size_t dataSize, llvm::SmallVectorImpl<char> &outBuffer);
|
||||
template
|
||||
ZlibResult ZlibCompressAppend<llvm::SmallVectorImpl<uint8_t> >(IMalloc *pMalloc, const void *pData, size_t dataSize, llvm::SmallVectorImpl<uint8_t> &outBuffer);
|
||||
template
|
||||
ZlibResult ZlibCompressAppend<std::vector<char> >(IMalloc *pMalloc, const void *pData, size_t dataSize, std::vector<char> &outBuffer);
|
||||
template
|
||||
ZlibResult ZlibCompressAppend<std::vector<uint8_t> >(IMalloc *pMalloc, const void *pData, size_t dataSize, std::vector<uint8_t> &outBuffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
template ZlibResult ZlibCompressAppend<llvm::SmallVectorImpl<char>>(
|
||||
IMalloc *pMalloc, const void *pData, size_t dataSize,
|
||||
llvm::SmallVectorImpl<char> &outBuffer);
|
||||
template ZlibResult ZlibCompressAppend<llvm::SmallVectorImpl<uint8_t>>(
|
||||
IMalloc *pMalloc, const void *pData, size_t dataSize,
|
||||
llvm::SmallVectorImpl<uint8_t> &outBuffer);
|
||||
template ZlibResult
|
||||
ZlibCompressAppend<std::vector<char>>(IMalloc *pMalloc, const void *pData,
|
||||
size_t dataSize,
|
||||
std::vector<char> &outBuffer);
|
||||
template ZlibResult
|
||||
ZlibCompressAppend<std::vector<uint8_t>>(IMalloc *pMalloc, const void *pData,
|
||||
size_t dataSize,
|
||||
std::vector<uint8_t> &outBuffer);
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -11,16 +11,16 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "dxc/dxcapi.h"
|
||||
#include "dxc/DxilContainer/DxilContainer.h"
|
||||
#include "dxc/Support/Global.h"
|
||||
#include "dxc/Support/WinIncludes.h"
|
||||
#include "dxc/DxilContainer/DxilContainer.h"
|
||||
#include "dxc/Support/microcom.h"
|
||||
#include "dxc/dxcapi.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
|
||||
using namespace hlsl;
|
||||
namespace hlsl {
|
||||
class AbstractMemoryStream;
|
||||
class AbstractMemoryStream;
|
||||
}
|
||||
|
||||
class DxcContainerBuilder : public IDxcContainerBuilder {
|
||||
|
@ -37,7 +37,8 @@ public:
|
|||
|
||||
DXC_MICROCOM_TM_ADDREF_RELEASE_IMPL()
|
||||
DXC_MICROCOM_TM_CTOR(DxcContainerBuilder)
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject) override {
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid,
|
||||
void **ppvObject) override {
|
||||
return DoBasicQueryInterface<IDxcContainerBuilder>(this, riid, ppvObject);
|
||||
}
|
||||
|
||||
|
@ -55,19 +56,21 @@ private:
|
|||
public:
|
||||
UINT32 m_fourCC;
|
||||
CComPtr<IDxcBlob> m_Blob;
|
||||
DxilPart(UINT32 fourCC, IDxcBlob *pSource) : m_fourCC(fourCC), m_Blob(pSource) {}
|
||||
DxilPart(UINT32 fourCC, IDxcBlob *pSource)
|
||||
: m_fourCC(fourCC), m_Blob(pSource) {}
|
||||
};
|
||||
typedef llvm::SmallVector<DxilPart, 8> PartList;
|
||||
|
||||
PartList m_parts;
|
||||
CComPtr<IDxcBlob> m_pContainer;
|
||||
CComPtr<IDxcBlob> m_pContainer;
|
||||
const char *m_warning;
|
||||
bool m_RequireValidation;
|
||||
bool m_HasPrivateData;
|
||||
|
||||
UINT32 ComputeContainerSize();
|
||||
HRESULT UpdateContainerHeader(AbstractMemoryStream *pStream, uint32_t containerSize);
|
||||
HRESULT UpdateContainerHeader(AbstractMemoryStream *pStream,
|
||||
uint32_t containerSize);
|
||||
HRESULT UpdateOffsetTable(AbstractMemoryStream *pStream);
|
||||
HRESULT UpdateParts(AbstractMemoryStream *pStream);
|
||||
void AddPart(DxilPart&& part);
|
||||
void AddPart(DxilPart &&part);
|
||||
};
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
#ifndef __DXC_CONTAINER__
|
||||
#define __DXC_CONTAINER__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <iterator>
|
||||
#include "dxc/DXIL/DxilConstants.h"
|
||||
#include "dxc/WinAdapter.h"
|
||||
#include <iterator>
|
||||
#include <stdint.h>
|
||||
|
||||
struct IDxcContainerReflection;
|
||||
|
||||
|
@ -26,9 +26,10 @@ namespace hlsl {
|
|||
#pragma pack(push, 1)
|
||||
|
||||
static const size_t DxilContainerHashSize = 16;
|
||||
static const uint16_t DxilContainerVersionMajor = 1; // Current major version
|
||||
static const uint16_t DxilContainerVersionMinor = 0; // Current minor version
|
||||
static const uint32_t DxilContainerMaxSize = 0x80000000; // Max size for container.
|
||||
static const uint16_t DxilContainerVersionMajor = 1; // Current major version
|
||||
static const uint16_t DxilContainerVersionMinor = 0; // Current minor version
|
||||
static const uint32_t DxilContainerMaxSize =
|
||||
0x80000000; // Max size for container.
|
||||
|
||||
/// Use this type to represent the hash for the full container.
|
||||
struct DxilContainerHash {
|
||||
|
@ -53,46 +54,47 @@ struct DxilContainerVersion {
|
|||
|
||||
/// Use this type to describe a DXIL container of parts.
|
||||
struct DxilContainerHeader {
|
||||
uint32_t HeaderFourCC;
|
||||
DxilContainerHash Hash;
|
||||
DxilContainerVersion Version;
|
||||
uint32_t ContainerSizeInBytes; // From start of this header
|
||||
uint32_t PartCount;
|
||||
uint32_t HeaderFourCC;
|
||||
DxilContainerHash Hash;
|
||||
DxilContainerVersion Version;
|
||||
uint32_t ContainerSizeInBytes; // From start of this header
|
||||
uint32_t PartCount;
|
||||
// Structure is followed by uint32_t PartOffset[PartCount];
|
||||
// The offset is to a DxilPartHeader.
|
||||
};
|
||||
|
||||
/// Use this type to describe the size and type of a DXIL container part.
|
||||
struct DxilPartHeader {
|
||||
uint32_t PartFourCC; // Four char code for part type.
|
||||
uint32_t PartSize; // Byte count for PartData.
|
||||
uint32_t PartFourCC; // Four char code for part type.
|
||||
uint32_t PartSize; // Byte count for PartData.
|
||||
// Structure is followed by uint8_t PartData[PartSize].
|
||||
};
|
||||
|
||||
#define DXIL_FOURCC(ch0, ch1, ch2, ch3) ( \
|
||||
(uint32_t)(uint8_t)(ch0) | (uint32_t)(uint8_t)(ch1) << 8 | \
|
||||
(uint32_t)(uint8_t)(ch2) << 16 | (uint32_t)(uint8_t)(ch3) << 24 \
|
||||
)
|
||||
#define DXIL_FOURCC(ch0, ch1, ch2, ch3) \
|
||||
((uint32_t)(uint8_t)(ch0) | (uint32_t)(uint8_t)(ch1) << 8 | \
|
||||
(uint32_t)(uint8_t)(ch2) << 16 | (uint32_t)(uint8_t)(ch3) << 24)
|
||||
|
||||
enum DxilFourCC {
|
||||
DFCC_Container = DXIL_FOURCC('D', 'X', 'B', 'C'), // for back-compat with tools that look for DXBC containers
|
||||
DFCC_ResourceDef = DXIL_FOURCC('R', 'D', 'E', 'F'),
|
||||
DFCC_InputSignature = DXIL_FOURCC('I', 'S', 'G', '1'),
|
||||
DFCC_OutputSignature = DXIL_FOURCC('O', 'S', 'G', '1'),
|
||||
DFCC_PatchConstantSignature = DXIL_FOURCC('P', 'S', 'G', '1'),
|
||||
DFCC_ShaderStatistics = DXIL_FOURCC('S', 'T', 'A', 'T'),
|
||||
DFCC_ShaderDebugInfoDXIL = DXIL_FOURCC('I', 'L', 'D', 'B'),
|
||||
DFCC_ShaderDebugName = DXIL_FOURCC('I', 'L', 'D', 'N'),
|
||||
DFCC_FeatureInfo = DXIL_FOURCC('S', 'F', 'I', '0'),
|
||||
DFCC_PrivateData = DXIL_FOURCC('P', 'R', 'I', 'V'),
|
||||
DFCC_RootSignature = DXIL_FOURCC('R', 'T', 'S', '0'),
|
||||
DFCC_DXIL = DXIL_FOURCC('D', 'X', 'I', 'L'),
|
||||
DFCC_PipelineStateValidation = DXIL_FOURCC('P', 'S', 'V', '0'),
|
||||
DFCC_RuntimeData = DXIL_FOURCC('R', 'D', 'A', 'T'),
|
||||
DFCC_ShaderHash = DXIL_FOURCC('H', 'A', 'S', 'H'),
|
||||
DFCC_ShaderSourceInfo = DXIL_FOURCC('S', 'R', 'C', 'I'),
|
||||
DFCC_ShaderPDBInfo = DXIL_FOURCC('P', 'D', 'B', 'I'),
|
||||
DFCC_CompilerVersion = DXIL_FOURCC('V', 'E', 'R', 'S'),
|
||||
DFCC_Container = DXIL_FOURCC(
|
||||
'D', 'X', 'B',
|
||||
'C'), // for back-compat with tools that look for DXBC containers
|
||||
DFCC_ResourceDef = DXIL_FOURCC('R', 'D', 'E', 'F'),
|
||||
DFCC_InputSignature = DXIL_FOURCC('I', 'S', 'G', '1'),
|
||||
DFCC_OutputSignature = DXIL_FOURCC('O', 'S', 'G', '1'),
|
||||
DFCC_PatchConstantSignature = DXIL_FOURCC('P', 'S', 'G', '1'),
|
||||
DFCC_ShaderStatistics = DXIL_FOURCC('S', 'T', 'A', 'T'),
|
||||
DFCC_ShaderDebugInfoDXIL = DXIL_FOURCC('I', 'L', 'D', 'B'),
|
||||
DFCC_ShaderDebugName = DXIL_FOURCC('I', 'L', 'D', 'N'),
|
||||
DFCC_FeatureInfo = DXIL_FOURCC('S', 'F', 'I', '0'),
|
||||
DFCC_PrivateData = DXIL_FOURCC('P', 'R', 'I', 'V'),
|
||||
DFCC_RootSignature = DXIL_FOURCC('R', 'T', 'S', '0'),
|
||||
DFCC_DXIL = DXIL_FOURCC('D', 'X', 'I', 'L'),
|
||||
DFCC_PipelineStateValidation = DXIL_FOURCC('P', 'S', 'V', '0'),
|
||||
DFCC_RuntimeData = DXIL_FOURCC('R', 'D', 'A', 'T'),
|
||||
DFCC_ShaderHash = DXIL_FOURCC('H', 'A', 'S', 'H'),
|
||||
DFCC_ShaderSourceInfo = DXIL_FOURCC('S', 'R', 'C', 'I'),
|
||||
DFCC_ShaderPDBInfo = DXIL_FOURCC('P', 'D', 'B', 'I'),
|
||||
DFCC_CompilerVersion = DXIL_FOURCC('V', 'E', 'R', 'S'),
|
||||
};
|
||||
|
||||
#undef DXIL_FOURCC
|
||||
|
@ -103,17 +105,17 @@ struct DxilShaderFeatureInfo {
|
|||
|
||||
// DXIL program information.
|
||||
struct DxilBitcodeHeader {
|
||||
uint32_t DxilMagic; // ACSII "DXIL".
|
||||
uint32_t DxilVersion; // DXIL version.
|
||||
uint32_t BitcodeOffset; // Offset to LLVM bitcode (from start of header).
|
||||
uint32_t BitcodeSize; // Size of LLVM bitcode.
|
||||
uint32_t DxilMagic; // ACSII "DXIL".
|
||||
uint32_t DxilVersion; // DXIL version.
|
||||
uint32_t BitcodeOffset; // Offset to LLVM bitcode (from start of header).
|
||||
uint32_t BitcodeSize; // Size of LLVM bitcode.
|
||||
};
|
||||
static const uint32_t DxilMagicValue = 0x4C495844; // 'DXIL'
|
||||
|
||||
struct DxilProgramHeader {
|
||||
uint32_t ProgramVersion; /// Major and minor version, including type.
|
||||
uint32_t SizeInUint32; /// Size in uint32_t units including this header.
|
||||
DxilBitcodeHeader BitcodeHeader; /// Bitcode-specific header.
|
||||
uint32_t ProgramVersion; /// Major and minor version, including type.
|
||||
uint32_t SizeInUint32; /// Size in uint32_t units including this header.
|
||||
DxilBitcodeHeader BitcodeHeader; /// Bitcode-specific header.
|
||||
// Followed by uint8_t[BitcodeHeader.BitcodeOffset]
|
||||
};
|
||||
|
||||
|
@ -178,35 +180,43 @@ enum class DxilProgramSigCompType : uint32_t {
|
|||
};
|
||||
|
||||
struct DxilProgramSignatureElement {
|
||||
uint32_t Stream; // Stream index (parameters must appear in non-decreasing stream order)
|
||||
uint32_t SemanticName; // Offset to LPCSTR from start of DxilProgramSignature.
|
||||
uint32_t SemanticIndex; // Semantic Index
|
||||
DxilProgramSigSemantic SystemValue; // Semantic type. Similar to DxilSemantic::Kind, but a serialized rather than processing rep.
|
||||
DxilProgramSigCompType CompType; // Type of bits.
|
||||
uint32_t Register; // Register Index (row index)
|
||||
uint8_t Mask; // Mask (column allocation)
|
||||
union // Unconditional cases useful for validation of shader linkage.
|
||||
uint32_t Stream; // Stream index (parameters must appear in non-decreasing
|
||||
// stream order)
|
||||
uint32_t SemanticName; // Offset to LPCSTR from start of DxilProgramSignature.
|
||||
uint32_t SemanticIndex; // Semantic Index
|
||||
DxilProgramSigSemantic
|
||||
SystemValue; // Semantic type. Similar to DxilSemantic::Kind, but a
|
||||
// serialized rather than processing rep.
|
||||
DxilProgramSigCompType CompType; // Type of bits.
|
||||
uint32_t Register; // Register Index (row index)
|
||||
uint8_t Mask; // Mask (column allocation)
|
||||
union // Unconditional cases useful for validation of shader linkage.
|
||||
{
|
||||
uint8_t NeverWrites_Mask; // For an output signature, the shader the signature belongs to never
|
||||
// writes the masked components of the output register.
|
||||
uint8_t AlwaysReads_Mask; // For an input signature, the shader the signature belongs to always
|
||||
// reads the masked components of the input register.
|
||||
uint8_t NeverWrites_Mask; // For an output signature, the shader the
|
||||
// signature belongs to never writes the masked
|
||||
// components of the output register.
|
||||
uint8_t AlwaysReads_Mask; // For an input signature, the shader the
|
||||
// signature belongs to always reads the masked
|
||||
// components of the input register.
|
||||
};
|
||||
uint16_t Pad;
|
||||
DxilProgramSigMinPrecision MinPrecision; // Minimum precision of input/output data
|
||||
DxilProgramSigMinPrecision
|
||||
MinPrecision; // Minimum precision of input/output data
|
||||
};
|
||||
|
||||
// Easy to get this wrong. Earlier assertions can help determine
|
||||
static_assert(sizeof(DxilProgramSignatureElement) == 0x20, "else DxilProgramSignatureElement is misaligned");
|
||||
static_assert(sizeof(DxilProgramSignatureElement) == 0x20,
|
||||
"else DxilProgramSignatureElement is misaligned");
|
||||
|
||||
struct DxilShaderDebugName {
|
||||
uint16_t Flags; // Reserved, must be set to zero.
|
||||
uint16_t NameLength; // Length of the debug name, without null terminator.
|
||||
uint16_t Flags; // Reserved, must be set to zero.
|
||||
uint16_t NameLength; // Length of the debug name, without null terminator.
|
||||
// Followed by NameLength bytes of the UTF-8-encoded name.
|
||||
// Followed by a null terminator.
|
||||
// Followed by [0-3] zero bytes to align to a 4-byte boundary.
|
||||
};
|
||||
static const size_t MinDxilShaderDebugNameSize = sizeof(DxilShaderDebugName) + 4;
|
||||
static const size_t MinDxilShaderDebugNameSize =
|
||||
sizeof(DxilShaderDebugName) + 4;
|
||||
|
||||
struct DxilCompilerVersion {
|
||||
uint16_t Major;
|
||||
|
@ -214,7 +224,8 @@ struct DxilCompilerVersion {
|
|||
uint32_t VersionFlags;
|
||||
uint32_t CommitCount;
|
||||
uint32_t VersionStringListSizeInBytes;
|
||||
// Followed by VersionStringListSizeInBytes bytes, containing up to two null-terminated strings, sequentially:
|
||||
// Followed by VersionStringListSizeInBytes bytes, containing up to two
|
||||
// null-terminated strings, sequentially:
|
||||
// 1. CommitSha
|
||||
// 1. CustomVersionString
|
||||
// Followed by [0-3] zero bytes to align to a 4-byte boundary.
|
||||
|
@ -260,10 +271,10 @@ struct DxilCompilerVersion {
|
|||
// (0-3 zero bytes to align to a 4-byte boundary)
|
||||
//
|
||||
// ================ 2. Source Contents ==================================
|
||||
//
|
||||
//
|
||||
// DxilSourceInfo_SourceContents
|
||||
// char Entries[CompressedEntriesSizeInBytes]
|
||||
//
|
||||
//
|
||||
// `Entries` may be compressed. Here is the uncompressed structure:
|
||||
//
|
||||
// DxilSourceInfo_SourcesContentsEntry
|
||||
|
@ -297,26 +308,29 @@ struct DxilCompilerVersion {
|
|||
//
|
||||
|
||||
struct DxilSourceInfo {
|
||||
uint32_t AlignedSizeInBytes; // Total size of the contents including this header
|
||||
uint16_t Flags; // Reserved, must be set to zero.
|
||||
uint16_t SectionCount; // The number of sections in the source info.
|
||||
uint32_t
|
||||
AlignedSizeInBytes; // Total size of the contents including this header
|
||||
uint16_t Flags; // Reserved, must be set to zero.
|
||||
uint16_t SectionCount; // The number of sections in the source info.
|
||||
};
|
||||
|
||||
enum class DxilSourceInfoSectionType : uint16_t {
|
||||
SourceContents = 0,
|
||||
SourceNames = 1,
|
||||
Args = 2,
|
||||
SourceNames = 1,
|
||||
Args = 2,
|
||||
};
|
||||
|
||||
struct DxilSourceInfoSection {
|
||||
uint32_t AlignedSizeInBytes; // Size of the section, including this header, and the padding. Aligned to 4-byte boundary.
|
||||
uint16_t Flags; // Reserved, must be set to zero.
|
||||
DxilSourceInfoSectionType Type; // The type of data following this header.
|
||||
uint32_t AlignedSizeInBytes; // Size of the section, including this header,
|
||||
// and the padding. Aligned to 4-byte boundary.
|
||||
uint16_t Flags; // Reserved, must be set to zero.
|
||||
DxilSourceInfoSectionType Type; // The type of data following this header.
|
||||
};
|
||||
|
||||
struct DxilSourceInfo_Args {
|
||||
uint32_t Flags; // Reserved, must be set to zero.
|
||||
uint32_t SizeInBytes; // Length of all argument pairs, including their null terminators, not including this header.
|
||||
uint32_t SizeInBytes; // Length of all argument pairs, including their null
|
||||
// terminators, not including this header.
|
||||
uint32_t Count; // Number of arguments.
|
||||
|
||||
// Followed by `Count` argument pairs.
|
||||
|
@ -335,43 +349,54 @@ struct DxilSourceInfo_Args {
|
|||
};
|
||||
|
||||
struct DxilSourceInfo_SourceNames {
|
||||
uint32_t Flags; // Reserved, must be set to 0.
|
||||
uint32_t Count; // The number of data entries
|
||||
uint16_t EntriesSizeInBytes; // The total size of the data entries following this header.
|
||||
uint32_t Flags; // Reserved, must be set to 0.
|
||||
uint32_t Count; // The number of data entries
|
||||
uint16_t EntriesSizeInBytes; // The total size of the data entries following
|
||||
// this header.
|
||||
|
||||
// Followed by `Count` data entries with the header DxilSourceInfo_SourceNamesEntry
|
||||
// Followed by `Count` data entries with the header
|
||||
// DxilSourceInfo_SourceNamesEntry
|
||||
};
|
||||
|
||||
struct DxilSourceInfo_SourceNamesEntry {
|
||||
uint32_t AlignedSizeInBytes; // Size of the data including this header and padding. Aligned to 4-byte boundary.
|
||||
uint32_t Flags; // Reserved, must be set to 0.
|
||||
uint32_t NameSizeInBytes; // Size of the file name, *including* the null terminator.
|
||||
uint32_t ContentSizeInBytes; // Size of the file content, *including* the null terminator.
|
||||
// Followed by NameSizeInBytes bytes of the UTF-8-encoded file name (including null terminator).
|
||||
// Followed by [0-3] zero bytes to align to a 4-byte boundary.
|
||||
uint32_t AlignedSizeInBytes; // Size of the data including this header and
|
||||
// padding. Aligned to 4-byte boundary.
|
||||
uint32_t Flags; // Reserved, must be set to 0.
|
||||
uint32_t NameSizeInBytes; // Size of the file name, *including* the null
|
||||
// terminator.
|
||||
uint32_t ContentSizeInBytes; // Size of the file content, *including* the null
|
||||
// terminator.
|
||||
// Followed by NameSizeInBytes bytes of the UTF-8-encoded file name (including
|
||||
// null terminator). Followed by [0-3] zero bytes to align to a 4-byte
|
||||
// boundary.
|
||||
};
|
||||
|
||||
enum class DxilSourceInfo_SourceContentsCompressType : uint16_t {
|
||||
None,
|
||||
Zlib
|
||||
};
|
||||
enum class DxilSourceInfo_SourceContentsCompressType : uint16_t { None, Zlib };
|
||||
|
||||
struct DxilSourceInfo_SourceContents {
|
||||
uint32_t AlignedSizeInBytes; // Size of the entry including this header. Aligned to 4-byte boundary.
|
||||
uint16_t Flags; // Reserved, must be set to 0.
|
||||
DxilSourceInfo_SourceContentsCompressType CompressType; // The type of compression used to compress the data
|
||||
uint32_t EntriesSizeInBytes; // The size of the data entries following this header.
|
||||
uint32_t UncompressedEntriesSizeInBytes; // Total size of the data entries when uncompressed.
|
||||
uint32_t Count; // The number of data entries
|
||||
// Followed by (compressed) `Count` data entries with the header DxilSourceInfo_SourceContentsEntry
|
||||
uint32_t AlignedSizeInBytes; // Size of the entry including this header.
|
||||
// Aligned to 4-byte boundary.
|
||||
uint16_t Flags; // Reserved, must be set to 0.
|
||||
DxilSourceInfo_SourceContentsCompressType
|
||||
CompressType; // The type of compression used to compress the data
|
||||
uint32_t
|
||||
EntriesSizeInBytes; // The size of the data entries following this header.
|
||||
uint32_t UncompressedEntriesSizeInBytes; // Total size of the data entries
|
||||
// when uncompressed.
|
||||
uint32_t Count; // The number of data entries
|
||||
// Followed by (compressed) `Count` data entries with the header
|
||||
// DxilSourceInfo_SourceContentsEntry
|
||||
};
|
||||
|
||||
struct DxilSourceInfo_SourceContentsEntry {
|
||||
uint32_t AlignedSizeInBytes; // Size of the entry including this header and padding. Aligned to 4-byte boundary.
|
||||
uint32_t Flags; // Reserved, must be set to 0.
|
||||
uint32_t ContentSizeInBytes; // Size of the data following this header, *including* the null terminator
|
||||
// Followed by ContentSizeInBytes bytes of the UTF-8-encoded content (including null terminator).
|
||||
// Followed by [0-3] zero bytes to align to a 4-byte boundary.
|
||||
uint32_t AlignedSizeInBytes; // Size of the entry including this header and
|
||||
// padding. Aligned to 4-byte boundary.
|
||||
uint32_t Flags; // Reserved, must be set to 0.
|
||||
uint32_t ContentSizeInBytes; // Size of the data following this header,
|
||||
// *including* the null terminator
|
||||
// Followed by ContentSizeInBytes bytes of the UTF-8-encoded content
|
||||
// (including null terminator). Followed by [0-3] zero bytes to align to a
|
||||
// 4-byte boundary.
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
@ -379,7 +404,7 @@ struct DxilSourceInfo_SourceContentsEntry {
|
|||
enum class DxilShaderPDBInfoVersion : uint16_t {
|
||||
Version_0 = 0, // At this point, the data is still subject to change.
|
||||
LatestPlus1,
|
||||
Latest = LatestPlus1-1
|
||||
Latest = LatestPlus1 - 1
|
||||
};
|
||||
|
||||
enum class DxilShaderPDBInfoCompressionType : uint16_t {
|
||||
|
@ -397,7 +422,7 @@ enum class DxilShaderPDBInfoCompressionType : uint16_t {
|
|||
//
|
||||
struct DxilShaderPDBInfo {
|
||||
DxilShaderPDBInfoVersion Version;
|
||||
DxilShaderPDBInfoCompressionType CompressionType;
|
||||
DxilShaderPDBInfoCompressionType CompressionType;
|
||||
uint32_t SizeInBytes;
|
||||
uint32_t UncompressedSizeInBytes;
|
||||
};
|
||||
|
@ -408,8 +433,8 @@ GetDxilContainerPart(const DxilContainerHeader *pHeader, uint32_t index) {
|
|||
const uint8_t *pLinearContainer = reinterpret_cast<const uint8_t *>(pHeader);
|
||||
const uint32_t *pPartOffsetTable =
|
||||
reinterpret_cast<const uint32_t *>(pHeader + 1);
|
||||
return reinterpret_cast<const DxilPartHeader *>(
|
||||
pLinearContainer + pPartOffsetTable[index]);
|
||||
return reinterpret_cast<const DxilPartHeader *>(pLinearContainer +
|
||||
pPartOffsetTable[index]);
|
||||
}
|
||||
|
||||
/// Gets a part header by index.
|
||||
|
@ -430,14 +455,14 @@ inline char *GetDxilPartData(DxilPartHeader *pPart) {
|
|||
}
|
||||
/// Gets a part header by fourCC
|
||||
DxilPartHeader *GetDxilPartByType(DxilContainerHeader *pHeader,
|
||||
DxilFourCC fourCC);
|
||||
/// Gets a part header by fourCC
|
||||
const DxilPartHeader *
|
||||
GetDxilPartByType(const DxilContainerHeader *pHeader,
|
||||
DxilFourCC fourCC);
|
||||
DxilFourCC fourCC);
|
||||
/// Gets a part header by fourCC
|
||||
const DxilPartHeader *GetDxilPartByType(const DxilContainerHeader *pHeader,
|
||||
DxilFourCC fourCC);
|
||||
|
||||
/// Returns valid DxilProgramHeader. nullptr if does not exist.
|
||||
DxilProgramHeader *GetDxilProgramHeader(DxilContainerHeader *pHeader, DxilFourCC fourCC);
|
||||
DxilProgramHeader *GetDxilProgramHeader(DxilContainerHeader *pHeader,
|
||||
DxilFourCC fourCC);
|
||||
|
||||
/// Returns valid DxilProgramHeader. nullptr if does not exist.
|
||||
const DxilProgramHeader *
|
||||
|
@ -458,7 +483,7 @@ bool IsValidDxilContainer(const DxilContainerHeader *pHeader, size_t length);
|
|||
/// Use this type as a unary predicate functor.
|
||||
struct DxilPartIsType {
|
||||
uint32_t IsFourCC;
|
||||
DxilPartIsType(uint32_t FourCC) : IsFourCC(FourCC) { }
|
||||
DxilPartIsType(uint32_t FourCC) : IsFourCC(FourCC) {}
|
||||
bool operator()(const DxilPartHeader *pPart) const {
|
||||
return pPart->PartFourCC == IsFourCC;
|
||||
}
|
||||
|
@ -513,9 +538,8 @@ inline bool IsValidDxilBitcodeHeader(const DxilBitcodeHeader *pHeader,
|
|||
pHeader->DxilMagic == DxilMagicValue;
|
||||
}
|
||||
|
||||
inline void InitBitcodeHeader(DxilBitcodeHeader &header,
|
||||
uint32_t dxilVersion,
|
||||
uint32_t bitcodeSize) {
|
||||
inline void InitBitcodeHeader(DxilBitcodeHeader &header, uint32_t dxilVersion,
|
||||
uint32_t bitcodeSize) {
|
||||
header.DxilMagic = DxilMagicValue;
|
||||
header.DxilVersion = dxilVersion;
|
||||
header.BitcodeOffset = sizeof(DxilBitcodeHeader);
|
||||
|
@ -531,21 +555,20 @@ inline void GetDxilProgramBitcode(const DxilProgramHeader *pHeader,
|
|||
}
|
||||
|
||||
inline bool IsValidDxilProgramHeader(const DxilProgramHeader *pHeader,
|
||||
uint32_t length) {
|
||||
uint32_t length) {
|
||||
return length >= sizeof(DxilProgramHeader) &&
|
||||
length >= (pHeader->SizeInUint32 * sizeof(uint32_t)) &&
|
||||
IsValidDxilBitcodeHeader(
|
||||
&pHeader->BitcodeHeader,
|
||||
length - offsetof(DxilProgramHeader, BitcodeHeader));
|
||||
length >= (pHeader->SizeInUint32 * sizeof(uint32_t)) &&
|
||||
IsValidDxilBitcodeHeader(
|
||||
&pHeader->BitcodeHeader,
|
||||
length - offsetof(DxilProgramHeader, BitcodeHeader));
|
||||
}
|
||||
|
||||
inline void InitProgramHeader(DxilProgramHeader &header, uint32_t shaderVersion,
|
||||
uint32_t dxilVersion,
|
||||
uint32_t bitcodeSize) {
|
||||
uint32_t dxilVersion, uint32_t bitcodeSize) {
|
||||
header.ProgramVersion = shaderVersion;
|
||||
header.SizeInUint32 =
|
||||
sizeof(DxilProgramHeader) / sizeof(uint32_t) +
|
||||
bitcodeSize / sizeof(uint32_t) + ((bitcodeSize % 4) ? 1 : 0);
|
||||
header.SizeInUint32 = sizeof(DxilProgramHeader) / sizeof(uint32_t) +
|
||||
bitcodeSize / sizeof(uint32_t) +
|
||||
((bitcodeSize % 4) ? 1 : 0);
|
||||
InitBitcodeHeader(header.BitcodeHeader, dxilVersion, bitcodeSize);
|
||||
}
|
||||
|
||||
|
@ -569,20 +592,25 @@ inline uint32_t GetVersionMinor(uint32_t programVersion) {
|
|||
return (programVersion & 0xf);
|
||||
}
|
||||
inline uint32_t EncodeVersion(DXIL::ShaderKind shaderType, uint32_t major,
|
||||
uint32_t minor) {
|
||||
uint32_t minor) {
|
||||
return ((unsigned)shaderType << 16) | (major << 4) | minor;
|
||||
}
|
||||
|
||||
inline bool IsDxilShaderDebugNameValid(const DxilPartHeader *pPart) {
|
||||
if (pPart->PartFourCC != DFCC_ShaderDebugName) return false;
|
||||
if (pPart->PartSize < MinDxilShaderDebugNameSize) return false;
|
||||
const DxilShaderDebugName *pDebugNameContent = reinterpret_cast<const DxilShaderDebugName *>(GetDxilPartData(pPart));
|
||||
uint16_t ExpectedSize = sizeof(DxilShaderDebugName) + pDebugNameContent->NameLength + 1;
|
||||
if (pPart->PartFourCC != DFCC_ShaderDebugName)
|
||||
return false;
|
||||
if (pPart->PartSize < MinDxilShaderDebugNameSize)
|
||||
return false;
|
||||
const DxilShaderDebugName *pDebugNameContent =
|
||||
reinterpret_cast<const DxilShaderDebugName *>(GetDxilPartData(pPart));
|
||||
uint16_t ExpectedSize =
|
||||
sizeof(DxilShaderDebugName) + pDebugNameContent->NameLength + 1;
|
||||
if (ExpectedSize & 0x3) {
|
||||
ExpectedSize += 0x4;
|
||||
ExpectedSize &= ~(0x3);
|
||||
}
|
||||
if (pPart->PartSize != ExpectedSize) return false;
|
||||
if (pPart->PartSize != ExpectedSize)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -593,7 +621,9 @@ inline bool GetDxilShaderDebugName(const DxilPartHeader *pDebugNamePart,
|
|||
if (!IsDxilShaderDebugNameValid(pDebugNamePart)) {
|
||||
return false;
|
||||
}
|
||||
const DxilShaderDebugName *pDebugNameContent = reinterpret_cast<const DxilShaderDebugName *>(GetDxilPartData(pDebugNamePart));
|
||||
const DxilShaderDebugName *pDebugNameContent =
|
||||
reinterpret_cast<const DxilShaderDebugName *>(
|
||||
GetDxilPartData(pDebugNamePart));
|
||||
if (pUtf8NameLen) {
|
||||
*pUtf8NameLen = pDebugNameContent->NameLength;
|
||||
}
|
||||
|
@ -602,20 +632,29 @@ inline bool GetDxilShaderDebugName(const DxilPartHeader *pDebugNamePart,
|
|||
}
|
||||
|
||||
enum class SerializeDxilFlags : uint32_t {
|
||||
None = 0, // No flags defined.
|
||||
IncludeDebugInfoPart = 1 << 0, // Include the debug info part in the container.
|
||||
IncludeDebugNamePart = 1 << 1, // Include the debug name part in the container.
|
||||
DebugNameDependOnSource = 1 << 2, // Make the debug name depend on source (and not just final module).
|
||||
None = 0, // No flags defined.
|
||||
IncludeDebugInfoPart =
|
||||
1 << 0, // Include the debug info part in the container.
|
||||
IncludeDebugNamePart =
|
||||
1 << 1, // Include the debug name part in the container.
|
||||
DebugNameDependOnSource =
|
||||
1
|
||||
<< 2, // Make the debug name depend on source (and not just final module).
|
||||
StripReflectionFromDxilPart = 1 << 3, // Strip Reflection info from DXIL part.
|
||||
IncludeReflectionPart = 1 << 4, // Include reflection in STAT part.
|
||||
StripRootSignature = 1 << 5, // Strip Root Signature from main shader container.
|
||||
IncludeReflectionPart = 1 << 4, // Include reflection in STAT part.
|
||||
StripRootSignature =
|
||||
1 << 5, // Strip Root Signature from main shader container.
|
||||
};
|
||||
inline SerializeDxilFlags& operator |=(SerializeDxilFlags& l, const SerializeDxilFlags& r) {
|
||||
l = static_cast<SerializeDxilFlags>(static_cast<int>(l) | static_cast<int>(r));
|
||||
inline SerializeDxilFlags &operator|=(SerializeDxilFlags &l,
|
||||
const SerializeDxilFlags &r) {
|
||||
l = static_cast<SerializeDxilFlags>(static_cast<int>(l) |
|
||||
static_cast<int>(r));
|
||||
return l;
|
||||
}
|
||||
inline SerializeDxilFlags& operator &=(SerializeDxilFlags& l, const SerializeDxilFlags& r) {
|
||||
l = static_cast<SerializeDxilFlags>(static_cast<int>(l) & static_cast<int>(r));
|
||||
inline SerializeDxilFlags &operator&=(SerializeDxilFlags &l,
|
||||
const SerializeDxilFlags &r) {
|
||||
l = static_cast<SerializeDxilFlags>(static_cast<int>(l) &
|
||||
static_cast<int>(r));
|
||||
return l;
|
||||
}
|
||||
inline int operator&(SerializeDxilFlags l, SerializeDxilFlags r) {
|
||||
|
@ -641,7 +680,8 @@ inline size_t GetOffsetTableSize(uint32_t partCount) {
|
|||
return sizeof(uint32_t) * partCount;
|
||||
}
|
||||
// Compute total size of the dxil container from parts information
|
||||
inline size_t GetDxilContainerSizeFromParts(uint32_t partCount, uint32_t partsSize) {
|
||||
inline size_t GetDxilContainerSizeFromParts(uint32_t partCount,
|
||||
uint32_t partsSize) {
|
||||
return partsSize + (uint32_t)sizeof(DxilContainerHeader) +
|
||||
GetOffsetTableSize(partCount) +
|
||||
(uint32_t)sizeof(DxilPartHeader) * partCount;
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include "dxc/DxilContainer/DxilContainer.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include <functional>
|
||||
|
||||
struct IDxcVersionInfo;
|
||||
struct IStream;
|
||||
|
@ -40,17 +40,19 @@ public:
|
|||
virtual void write(AbstractMemoryStream *pStream) = 0;
|
||||
};
|
||||
|
||||
class DxilContainerWriter : public DxilPartWriter {
|
||||
class DxilContainerWriter : public DxilPartWriter {
|
||||
public:
|
||||
typedef std::function<void(AbstractMemoryStream*)> WriteFn;
|
||||
typedef std::function<void(AbstractMemoryStream *)> WriteFn;
|
||||
virtual ~DxilContainerWriter() {}
|
||||
virtual void AddPart(uint32_t FourCC, uint32_t Size, WriteFn Write) = 0;
|
||||
};
|
||||
|
||||
DxilPartWriter *NewProgramSignatureWriter(const DxilModule &M, DXIL::SignatureKind Kind);
|
||||
DxilPartWriter *NewProgramSignatureWriter(const DxilModule &M,
|
||||
DXIL::SignatureKind Kind);
|
||||
DxilPartWriter *NewRootSignatureWriter(const RootSignatureHandle &S);
|
||||
DxilPartWriter *NewFeatureInfoWriter(const DxilModule &M);
|
||||
DxilPartWriter *NewPSVWriter(const DxilModule &M, uint32_t PSVVersion = UINT_MAX);
|
||||
DxilPartWriter *NewPSVWriter(const DxilModule &M,
|
||||
uint32_t PSVVersion = UINT_MAX);
|
||||
DxilPartWriter *NewRDATWriter(const DxilModule &M);
|
||||
DxilPartWriter *NewVersionWriter(IDxcVersionInfo *pVersionInfo);
|
||||
|
||||
|
@ -67,26 +69,27 @@ unsigned LoadViewIDStateFromPSV(unsigned *pOutputData,
|
|||
// Unaligned is for matching container for validator version < 1.7.
|
||||
DxilContainerWriter *NewDxilContainerWriter(bool bUnaligned = false);
|
||||
|
||||
// Set validator version to 0,0 (not validated) then re-emit as much reflection metadata as possible.
|
||||
// Set validator version to 0,0 (not validated) then re-emit as much reflection
|
||||
// metadata as possible.
|
||||
void ReEmitLatestReflectionData(llvm::Module *pReflectionM);
|
||||
|
||||
// Strip functions and serialize module.
|
||||
void StripAndCreateReflectionStream(llvm::Module *pReflectionM, uint32_t *pReflectionPartSizeInBytes, AbstractMemoryStream **ppReflectionStreamOut);
|
||||
void StripAndCreateReflectionStream(
|
||||
llvm::Module *pReflectionM, uint32_t *pReflectionPartSizeInBytes,
|
||||
AbstractMemoryStream **ppReflectionStreamOut);
|
||||
|
||||
void WriteProgramPart(const hlsl::ShaderModel *pModel,
|
||||
AbstractMemoryStream *pModuleBitcode,
|
||||
IStream *pStream);
|
||||
AbstractMemoryStream *pModuleBitcode, IStream *pStream);
|
||||
|
||||
void SerializeDxilContainerForModule(
|
||||
hlsl::DxilModule *pModule, AbstractMemoryStream *pModuleBitcode,
|
||||
IDxcVersionInfo *DXCVersionInfo,
|
||||
AbstractMemoryStream *pStream, llvm::StringRef DebugName,
|
||||
SerializeDxilFlags Flags, DxilShaderHash *pShaderHashOut = nullptr,
|
||||
IDxcVersionInfo *DXCVersionInfo, AbstractMemoryStream *pStream,
|
||||
llvm::StringRef DebugName, SerializeDxilFlags Flags,
|
||||
DxilShaderHash *pShaderHashOut = nullptr,
|
||||
AbstractMemoryStream *pReflectionStreamOut = nullptr,
|
||||
AbstractMemoryStream *pRootSigStreamOut = nullptr,
|
||||
void *pPrivateData = nullptr,
|
||||
size_t PrivateDataSize = 0);
|
||||
void SerializeDxilContainerForRootSignature(hlsl::RootSignatureHandle *pRootSigHandle,
|
||||
AbstractMemoryStream *pStream);
|
||||
void *pPrivateData = nullptr, size_t PrivateDataSize = 0);
|
||||
void SerializeDxilContainerForRootSignature(
|
||||
hlsl::RootSignatureHandle *pRootSigHandle, AbstractMemoryStream *pStream);
|
||||
|
||||
} // namespace hlsl
|
|
@ -11,61 +11,60 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "dxc/DxilContainer/DxilContainer.h"
|
||||
#include "dxc/Support/Global.h"
|
||||
#include "dxc/Support/WinIncludes.h"
|
||||
#include "dxc/DxilContainer/DxilContainer.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
#define DXIL_CONTAINER_BLOB_NOT_FOUND -1
|
||||
|
||||
struct DxilContainerHeader;
|
||||
struct DxilContainerHeader;
|
||||
|
||||
//============================================================================
|
||||
// DxilContainerReader
|
||||
//============================================================================
|
||||
// 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
|
||||
//
|
||||
// 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() {}
|
||||
// Returns S_OK or E_FAIL
|
||||
HRESULT Load(const void *pContainer, uint32_t containerSizeInBytes);
|
||||
|
||||
// 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(const void *pContainer, uint32_t containerSizeInBytes);
|
||||
HRESULT GetVersion(DxilContainerVersion *pResult);
|
||||
HRESULT GetPartCount(uint32_t *pResult);
|
||||
HRESULT GetPartContent(uint32_t idx, const void **ppResult,
|
||||
uint32_t *pResultSize = nullptr);
|
||||
HRESULT GetPartFourCC(uint32_t idx, uint32_t *pResult);
|
||||
HRESULT FindFirstPartKind(uint32_t kind, uint32_t *pResult);
|
||||
|
||||
HRESULT GetVersion(DxilContainerVersion *pResult);
|
||||
HRESULT GetPartCount(uint32_t *pResult);
|
||||
HRESULT GetPartContent(uint32_t idx, const void **ppResult,
|
||||
uint32_t *pResultSize = nullptr);
|
||||
HRESULT GetPartFourCC(uint32_t idx, uint32_t *pResult);
|
||||
HRESULT FindFirstPartKind(uint32_t kind, uint32_t *pResult);
|
||||
private:
|
||||
const void *m_pContainer = nullptr;
|
||||
uint32_t m_uContainerSize = 0;
|
||||
const DxilContainerHeader *m_pHeader = nullptr;
|
||||
|
||||
private:
|
||||
const void* m_pContainer = nullptr;
|
||||
uint32_t m_uContainerSize = 0;
|
||||
const DxilContainerHeader *m_pHeader = nullptr;
|
||||
bool IsLoaded() const { return m_pHeader != nullptr; }
|
||||
};
|
||||
|
||||
bool IsLoaded() const { return m_pHeader != nullptr; }
|
||||
};
|
||||
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
#ifndef __DXIL_PIPELINE_STATE_VALIDATION__H__
|
||||
#define __DXIL_PIPELINE_STATE_VALIDATION__H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <cstring>
|
||||
#include "dxc/WinAdapter.h"
|
||||
#include <cstring>
|
||||
#include <stdint.h>
|
||||
|
||||
// Don't include assert.h here.
|
||||
// Since this header is included from multiple environments,
|
||||
|
@ -24,39 +24,59 @@
|
|||
#ifndef UINT_MAX
|
||||
#define UINT_MAX 0xffffffff
|
||||
#endif
|
||||
// How many dwords are required for mask with one bit per component, 4 components per vector
|
||||
inline uint32_t PSVComputeMaskDwordsFromVectors(uint32_t Vectors) { return (Vectors + 7) >> 3; }
|
||||
inline uint32_t PSVComputeInputOutputTableDwords(uint32_t InputVectors, uint32_t OutputVectors) {
|
||||
// How many dwords are required for mask with one bit per component, 4
|
||||
// components per vector
|
||||
inline uint32_t PSVComputeMaskDwordsFromVectors(uint32_t Vectors) {
|
||||
return (Vectors + 7) >> 3;
|
||||
}
|
||||
inline uint32_t PSVComputeInputOutputTableDwords(uint32_t InputVectors,
|
||||
uint32_t OutputVectors) {
|
||||
return PSVComputeMaskDwordsFromVectors(OutputVectors) * InputVectors * 4;
|
||||
}
|
||||
#define PSVALIGN(ptr, alignbits) (((ptr) + ((1 << (alignbits))-1)) & ~((1 << (alignbits))-1))
|
||||
#define PSVALIGN(ptr, alignbits) \
|
||||
(((ptr) + ((1 << (alignbits)) - 1)) & ~((1 << (alignbits)) - 1))
|
||||
#define PSVALIGN4(ptr) (((ptr) + 3) & ~3)
|
||||
#define PSV_GS_MAX_STREAMS 4
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define PSV_RETB(exp) do { if(!(exp)) { assert(false && #exp); return false; } } while(0)
|
||||
#else // NDEBUG
|
||||
#define PSV_RETB(exp) do { if(!(exp)) { return false; } } while(0)
|
||||
#endif // NDEBUG
|
||||
#define PSV_RETB(exp) \
|
||||
do { \
|
||||
if (!(exp)) { \
|
||||
assert(false && #exp); \
|
||||
return false; \
|
||||
} \
|
||||
} while (0)
|
||||
#else // NDEBUG
|
||||
#define PSV_RETB(exp) \
|
||||
do { \
|
||||
if (!(exp)) { \
|
||||
return false; \
|
||||
} \
|
||||
} while (0)
|
||||
#endif // NDEBUG
|
||||
|
||||
struct VSInfo {
|
||||
char OutputPositionPresent;
|
||||
};
|
||||
struct HSInfo {
|
||||
uint32_t InputControlPointCount; // max control points == 32
|
||||
uint32_t OutputControlPointCount; // max control points == 32
|
||||
uint32_t TessellatorDomain; // hlsl::DXIL::TessellatorDomain/D3D11_SB_TESSELLATOR_DOMAIN
|
||||
uint32_t TessellatorOutputPrimitive; // hlsl::DXIL::TessellatorOutputPrimitive/D3D11_SB_TESSELLATOR_OUTPUT_PRIMITIVE
|
||||
uint32_t InputControlPointCount; // max control points == 32
|
||||
uint32_t OutputControlPointCount; // max control points == 32
|
||||
uint32_t
|
||||
TessellatorDomain; // hlsl::DXIL::TessellatorDomain/D3D11_SB_TESSELLATOR_DOMAIN
|
||||
uint32_t
|
||||
TessellatorOutputPrimitive; // hlsl::DXIL::TessellatorOutputPrimitive/D3D11_SB_TESSELLATOR_OUTPUT_PRIMITIVE
|
||||
};
|
||||
struct DSInfo {
|
||||
uint32_t InputControlPointCount; // max control points == 32
|
||||
uint32_t InputControlPointCount; // max control points == 32
|
||||
char OutputPositionPresent;
|
||||
uint32_t TessellatorDomain; // hlsl::DXIL::TessellatorDomain/D3D11_SB_TESSELLATOR_DOMAIN
|
||||
uint32_t
|
||||
TessellatorDomain; // hlsl::DXIL::TessellatorDomain/D3D11_SB_TESSELLATOR_DOMAIN
|
||||
};
|
||||
struct GSInfo {
|
||||
uint32_t InputPrimitive; // hlsl::DXIL::InputPrimitive/D3D10_SB_PRIMITIVE
|
||||
uint32_t OutputTopology; // hlsl::DXIL::PrimitiveTopology/D3D10_SB_PRIMITIVE_TOPOLOGY
|
||||
uint32_t OutputStreamMask; // max streams == 4 (PSV_GS_MAX_STREAMS)
|
||||
uint32_t InputPrimitive; // hlsl::DXIL::InputPrimitive/D3D10_SB_PRIMITIVE
|
||||
uint32_t
|
||||
OutputTopology; // hlsl::DXIL::PrimitiveTopology/D3D10_SB_PRIMITIVE_TOPOLOGY
|
||||
uint32_t OutputStreamMask; // max streams == 4 (PSV_GS_MAX_STREAMS)
|
||||
char OutputPositionPresent;
|
||||
};
|
||||
struct PSInfo {
|
||||
|
@ -74,13 +94,12 @@ struct ASInfo {
|
|||
uint32_t PayloadSizeInBytes;
|
||||
};
|
||||
struct MSInfo1 {
|
||||
uint8_t SigPrimVectors; // Primitive output for MS
|
||||
uint8_t SigPrimVectors; // Primitive output for MS
|
||||
uint8_t MeshOutputTopology;
|
||||
};
|
||||
|
||||
// Versioning is additive and based on size
|
||||
struct PSVRuntimeInfo0
|
||||
{
|
||||
struct PSVRuntimeInfo0 {
|
||||
union {
|
||||
VSInfo VS;
|
||||
HSInfo HS;
|
||||
|
@ -90,11 +109,13 @@ struct PSVRuntimeInfo0
|
|||
MSInfo MS;
|
||||
ASInfo AS;
|
||||
};
|
||||
uint32_t MinimumExpectedWaveLaneCount; // minimum lane count required, 0 if unused
|
||||
uint32_t MaximumExpectedWaveLaneCount; // maximum lane count required, 0xffffffff if unused
|
||||
uint32_t
|
||||
MinimumExpectedWaveLaneCount; // minimum lane count required, 0 if unused
|
||||
uint32_t MaximumExpectedWaveLaneCount; // maximum lane count required,
|
||||
// 0xffffffff if unused
|
||||
};
|
||||
|
||||
enum class PSVShaderKind : uint8_t // DXIL::ShaderKind
|
||||
enum class PSVShaderKind : uint8_t // DXIL::ShaderKind
|
||||
{
|
||||
Pixel = 0,
|
||||
Vertex,
|
||||
|
@ -114,13 +135,14 @@ enum class PSVShaderKind : uint8_t // DXIL::ShaderKind
|
|||
Invalid,
|
||||
};
|
||||
|
||||
struct PSVRuntimeInfo1 : public PSVRuntimeInfo0
|
||||
{
|
||||
uint8_t ShaderStage; // PSVShaderKind
|
||||
struct PSVRuntimeInfo1 : public PSVRuntimeInfo0 {
|
||||
uint8_t ShaderStage; // PSVShaderKind
|
||||
uint8_t UsesViewID;
|
||||
union {
|
||||
uint16_t MaxVertexCount; // MaxVertexCount for GS only (max 1024)
|
||||
uint8_t SigPatchConstOrPrimVectors; // Output for HS; Input for DS; Primitive output for MS (overlaps MS1::SigPrimVectors)
|
||||
uint16_t MaxVertexCount; // MaxVertexCount for GS only (max 1024)
|
||||
uint8_t SigPatchConstOrPrimVectors; // Output for HS; Input for DS;
|
||||
// Primitive output for MS (overlaps
|
||||
// MS1::SigPrimVectors)
|
||||
struct MSInfo1 MS1;
|
||||
};
|
||||
|
||||
|
@ -131,18 +153,16 @@ struct PSVRuntimeInfo1 : public PSVRuntimeInfo0
|
|||
|
||||
// Number of packed vectors per signature
|
||||
uint8_t SigInputVectors;
|
||||
uint8_t SigOutputVectors[PSV_GS_MAX_STREAMS]; // Array for GS Stream Out Index
|
||||
uint8_t SigOutputVectors[PSV_GS_MAX_STREAMS]; // Array for GS Stream Out Index
|
||||
};
|
||||
|
||||
struct PSVRuntimeInfo2 : public PSVRuntimeInfo1
|
||||
{
|
||||
struct PSVRuntimeInfo2 : public PSVRuntimeInfo1 {
|
||||
uint32_t NumThreadsX;
|
||||
uint32_t NumThreadsY;
|
||||
uint32_t NumThreadsZ;
|
||||
};
|
||||
|
||||
enum class PSVResourceType
|
||||
{
|
||||
enum class PSVResourceType {
|
||||
Invalid = 0,
|
||||
|
||||
Sampler,
|
||||
|
@ -157,8 +177,7 @@ enum class PSVResourceType
|
|||
NumEntries
|
||||
};
|
||||
|
||||
enum class PSVResourceKind
|
||||
{
|
||||
enum class PSVResourceKind {
|
||||
Invalid = 0,
|
||||
Texture1D,
|
||||
Texture2D,
|
||||
|
@ -181,13 +200,13 @@ enum class PSVResourceKind
|
|||
NumEntries
|
||||
};
|
||||
|
||||
enum class PSVResourceFlag
|
||||
{
|
||||
None = 0x00000000,
|
||||
enum class PSVResourceFlag {
|
||||
None = 0x00000000,
|
||||
UsedByAtomic64 = 0x00000001,
|
||||
};
|
||||
|
||||
// Table of null-terminated strings, overall size aligned to dword boundary, last byte must be null
|
||||
// Table of null-terminated strings, overall size aligned to dword boundary,
|
||||
// last byte must be null
|
||||
struct PSVStringTable {
|
||||
const char *Table;
|
||||
uint32_t Size;
|
||||
|
@ -200,18 +219,16 @@ struct PSVStringTable {
|
|||
};
|
||||
|
||||
// Versioning is additive and based on size
|
||||
struct PSVResourceBindInfo0
|
||||
{
|
||||
uint32_t ResType; // PSVResourceType
|
||||
struct PSVResourceBindInfo0 {
|
||||
uint32_t ResType; // PSVResourceType
|
||||
uint32_t Space;
|
||||
uint32_t LowerBound;
|
||||
uint32_t UpperBound;
|
||||
};
|
||||
|
||||
struct PSVResourceBindInfo1 : public PSVResourceBindInfo0
|
||||
{
|
||||
uint32_t ResKind; // PSVResourceKind
|
||||
uint32_t ResFlags; // special characteristics of the resource
|
||||
struct PSVResourceBindInfo1 : public PSVResourceBindInfo0 {
|
||||
uint32_t ResKind; // PSVResourceKind
|
||||
uint32_t ResFlags; // special characteristics of the resource
|
||||
};
|
||||
|
||||
// Helpers for output dependencies (ViewID and Input-Output tables)
|
||||
|
@ -219,20 +236,20 @@ struct PSVComponentMask {
|
|||
uint32_t *Mask;
|
||||
uint32_t NumVectors;
|
||||
PSVComponentMask() : Mask(nullptr), NumVectors(0) {}
|
||||
PSVComponentMask(const PSVComponentMask &other) : Mask(other.Mask), NumVectors(other.NumVectors) {}
|
||||
PSVComponentMask(const PSVComponentMask &other)
|
||||
: Mask(other.Mask), NumVectors(other.NumVectors) {}
|
||||
PSVComponentMask(uint32_t *pMask, uint32_t outputVectors)
|
||||
: Mask(pMask),
|
||||
NumVectors(outputVectors)
|
||||
{}
|
||||
: Mask(pMask), NumVectors(outputVectors) {}
|
||||
const PSVComponentMask &operator|=(const PSVComponentMask &other) {
|
||||
uint32_t dwords = PSVComputeMaskDwordsFromVectors(NumVectors < other.NumVectors ? NumVectors : other.NumVectors);
|
||||
uint32_t dwords = PSVComputeMaskDwordsFromVectors(
|
||||
NumVectors < other.NumVectors ? NumVectors : other.NumVectors);
|
||||
for (uint32_t i = 0; i < dwords; ++i) {
|
||||
Mask[i] |= other.Mask[i];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
bool Get(uint32_t ComponentIndex) const {
|
||||
if(ComponentIndex < NumVectors * 4)
|
||||
if (ComponentIndex < NumVectors * 4)
|
||||
return (bool)(Mask[ComponentIndex >> 5] & (1 << (ComponentIndex & 0x1F)));
|
||||
return false;
|
||||
}
|
||||
|
@ -252,16 +269,20 @@ struct PSVDependencyTable {
|
|||
uint32_t InputVectors;
|
||||
uint32_t OutputVectors;
|
||||
PSVDependencyTable() : Table(nullptr), InputVectors(0), OutputVectors(0) {}
|
||||
PSVDependencyTable(const PSVDependencyTable &other) : Table(other.Table), InputVectors(other.InputVectors), OutputVectors(other.OutputVectors) {}
|
||||
PSVDependencyTable(uint32_t *pTable, uint32_t inputVectors, uint32_t outputVectors)
|
||||
: Table(pTable),
|
||||
InputVectors(inputVectors),
|
||||
OutputVectors(outputVectors)
|
||||
{}
|
||||
PSVDependencyTable(const PSVDependencyTable &other)
|
||||
: Table(other.Table), InputVectors(other.InputVectors),
|
||||
OutputVectors(other.OutputVectors) {}
|
||||
PSVDependencyTable(uint32_t *pTable, uint32_t inputVectors,
|
||||
uint32_t outputVectors)
|
||||
: Table(pTable), InputVectors(inputVectors),
|
||||
OutputVectors(outputVectors) {}
|
||||
PSVComponentMask GetMaskForInput(uint32_t inputComponentIndex) {
|
||||
if (!Table || !InputVectors || !OutputVectors)
|
||||
return PSVComponentMask();
|
||||
return PSVComponentMask(Table + (PSVComputeMaskDwordsFromVectors(OutputVectors) * inputComponentIndex), OutputVectors);
|
||||
return PSVComponentMask(
|
||||
Table + (PSVComputeMaskDwordsFromVectors(OutputVectors) *
|
||||
inputComponentIndex),
|
||||
OutputVectors);
|
||||
}
|
||||
bool IsValid() { return Table != nullptr; }
|
||||
};
|
||||
|
@ -270,14 +291,17 @@ struct PSVString {
|
|||
uint32_t Offset;
|
||||
PSVString() : Offset(0) {}
|
||||
PSVString(uint32_t offset) : Offset(offset) {}
|
||||
const char *Get(const PSVStringTable &table) const { return table.Get(Offset); }
|
||||
const char *Get(const PSVStringTable &table) const {
|
||||
return table.Get(Offset);
|
||||
}
|
||||
};
|
||||
|
||||
struct PSVSemanticIndexTable {
|
||||
const uint32_t *Table;
|
||||
uint32_t Entries;
|
||||
PSVSemanticIndexTable() : Table(nullptr), Entries(0) {}
|
||||
PSVSemanticIndexTable(const uint32_t *table, uint32_t entries) : Table(table), Entries(entries) {}
|
||||
PSVSemanticIndexTable(const uint32_t *table, uint32_t entries)
|
||||
: Table(table), Entries(entries) {}
|
||||
const uint32_t *Get(uint32_t offset) const {
|
||||
assert(offset < Entries && Table);
|
||||
return Table + offset;
|
||||
|
@ -288,10 +312,12 @@ struct PSVSemanticIndexes {
|
|||
uint32_t Offset;
|
||||
PSVSemanticIndexes() : Offset(0) {}
|
||||
PSVSemanticIndexes(uint32_t offset) : Offset(offset) {}
|
||||
const uint32_t *Get(const PSVSemanticIndexTable &table) const { return table.Get(Offset); }
|
||||
const uint32_t *Get(const PSVSemanticIndexTable &table) const {
|
||||
return table.Get(Offset);
|
||||
}
|
||||
};
|
||||
|
||||
enum class PSVSemanticKind : uint8_t // DXIL::SemanticKind
|
||||
enum class PSVSemanticKind : uint8_t // DXIL::SemanticKind
|
||||
{
|
||||
Arbitrary,
|
||||
VertexID,
|
||||
|
@ -327,51 +353,85 @@ enum class PSVSemanticKind : uint8_t // DXIL::SemanticKind
|
|||
Invalid,
|
||||
};
|
||||
|
||||
struct PSVSignatureElement0
|
||||
{
|
||||
uint32_t SemanticName; // Offset into StringTable
|
||||
uint32_t SemanticIndexes; // Offset into PSVSemanticIndexTable, count == Rows
|
||||
uint8_t Rows; // Number of rows this element occupies
|
||||
uint8_t StartRow; // Starting row of packing location if allocated
|
||||
uint8_t ColsAndStart; // 0:4 = Cols, 4:6 = StartCol, 6:7 == Allocated
|
||||
uint8_t SemanticKind; // PSVSemanticKind
|
||||
uint8_t ComponentType; // DxilProgramSigCompType
|
||||
uint8_t InterpolationMode; // DXIL::InterpolationMode or D3D10_SB_INTERPOLATION_MODE
|
||||
uint8_t DynamicMaskAndStream; // 0:4 = DynamicIndexMask, 4:6 = OutputStream (0-3)
|
||||
struct PSVSignatureElement0 {
|
||||
uint32_t SemanticName; // Offset into StringTable
|
||||
uint32_t SemanticIndexes; // Offset into PSVSemanticIndexTable, count == Rows
|
||||
uint8_t Rows; // Number of rows this element occupies
|
||||
uint8_t StartRow; // Starting row of packing location if allocated
|
||||
uint8_t ColsAndStart; // 0:4 = Cols, 4:6 = StartCol, 6:7 == Allocated
|
||||
uint8_t SemanticKind; // PSVSemanticKind
|
||||
uint8_t ComponentType; // DxilProgramSigCompType
|
||||
uint8_t InterpolationMode; // DXIL::InterpolationMode or
|
||||
// D3D10_SB_INTERPOLATION_MODE
|
||||
uint8_t
|
||||
DynamicMaskAndStream; // 0:4 = DynamicIndexMask, 4:6 = OutputStream (0-3)
|
||||
uint8_t Reserved;
|
||||
};
|
||||
|
||||
// Provides convenient access to packed PSVSignatureElementN structure
|
||||
class PSVSignatureElement
|
||||
{
|
||||
class PSVSignatureElement {
|
||||
private:
|
||||
const PSVStringTable &m_StringTable;
|
||||
const PSVSemanticIndexTable &m_SemanticIndexTable;
|
||||
const PSVSignatureElement0 *m_pElement0;
|
||||
|
||||
public:
|
||||
PSVSignatureElement(const PSVStringTable &stringTable, const PSVSemanticIndexTable &semanticIndexTable, const PSVSignatureElement0 *pElement0)
|
||||
: m_StringTable(stringTable), m_SemanticIndexTable(semanticIndexTable), m_pElement0(pElement0) {}
|
||||
const char *GetSemanticName() const { return !m_pElement0 ? "" : m_StringTable.Get(m_pElement0->SemanticName); }
|
||||
const uint32_t *GetSemanticIndexes() const { return !m_pElement0 ? nullptr: m_SemanticIndexTable.Get(m_pElement0->SemanticIndexes); }
|
||||
uint32_t GetRows() const { return !m_pElement0 ? 0 : ((uint32_t)m_pElement0->Rows); }
|
||||
uint32_t GetCols() const { return !m_pElement0 ? 0 : ((uint32_t)m_pElement0->ColsAndStart & 0xF); }
|
||||
bool IsAllocated() const { return !m_pElement0 ? false : !!(m_pElement0->ColsAndStart & 0x40); }
|
||||
int32_t GetStartRow() const { return !m_pElement0 ? 0 : !IsAllocated() ? -1 : (int32_t)m_pElement0->StartRow; }
|
||||
int32_t GetStartCol() const { return !m_pElement0 ? 0 : !IsAllocated() ? -1 : (int32_t)((m_pElement0->ColsAndStart >> 4) & 0x3); }
|
||||
PSVSemanticKind GetSemanticKind() const { return !m_pElement0 ? (PSVSemanticKind)0 : (PSVSemanticKind)m_pElement0->SemanticKind; }
|
||||
uint32_t GetComponentType() const { return !m_pElement0 ? 0 : (uint32_t)m_pElement0->ComponentType; }
|
||||
uint32_t GetInterpolationMode() const { return !m_pElement0 ? 0 : (uint32_t)m_pElement0->InterpolationMode; }
|
||||
uint32_t GetOutputStream() const { return !m_pElement0 ? 0 : (uint32_t)(m_pElement0->DynamicMaskAndStream >> 4) & 0x3; }
|
||||
uint32_t GetDynamicIndexMask() const { return !m_pElement0 ? 0 : (uint32_t)m_pElement0->DynamicMaskAndStream & 0xF; }
|
||||
PSVSignatureElement(const PSVStringTable &stringTable,
|
||||
const PSVSemanticIndexTable &semanticIndexTable,
|
||||
const PSVSignatureElement0 *pElement0)
|
||||
: m_StringTable(stringTable), m_SemanticIndexTable(semanticIndexTable),
|
||||
m_pElement0(pElement0) {}
|
||||
const char *GetSemanticName() const {
|
||||
return !m_pElement0 ? "" : m_StringTable.Get(m_pElement0->SemanticName);
|
||||
}
|
||||
const uint32_t *GetSemanticIndexes() const {
|
||||
return !m_pElement0
|
||||
? nullptr
|
||||
: m_SemanticIndexTable.Get(m_pElement0->SemanticIndexes);
|
||||
}
|
||||
uint32_t GetRows() const {
|
||||
return !m_pElement0 ? 0 : ((uint32_t)m_pElement0->Rows);
|
||||
}
|
||||
uint32_t GetCols() const {
|
||||
return !m_pElement0 ? 0 : ((uint32_t)m_pElement0->ColsAndStart & 0xF);
|
||||
}
|
||||
bool IsAllocated() const {
|
||||
return !m_pElement0 ? false : !!(m_pElement0->ColsAndStart & 0x40);
|
||||
}
|
||||
int32_t GetStartRow() const {
|
||||
return !m_pElement0 ? 0
|
||||
: !IsAllocated() ? -1
|
||||
: (int32_t)m_pElement0->StartRow;
|
||||
}
|
||||
int32_t GetStartCol() const {
|
||||
return !m_pElement0 ? 0
|
||||
: !IsAllocated() ? -1
|
||||
: (int32_t)((m_pElement0->ColsAndStart >> 4) & 0x3);
|
||||
}
|
||||
PSVSemanticKind GetSemanticKind() const {
|
||||
return !m_pElement0 ? (PSVSemanticKind)0
|
||||
: (PSVSemanticKind)m_pElement0->SemanticKind;
|
||||
}
|
||||
uint32_t GetComponentType() const {
|
||||
return !m_pElement0 ? 0 : (uint32_t)m_pElement0->ComponentType;
|
||||
}
|
||||
uint32_t GetInterpolationMode() const {
|
||||
return !m_pElement0 ? 0 : (uint32_t)m_pElement0->InterpolationMode;
|
||||
}
|
||||
uint32_t GetOutputStream() const {
|
||||
return !m_pElement0
|
||||
? 0
|
||||
: (uint32_t)(m_pElement0->DynamicMaskAndStream >> 4) & 0x3;
|
||||
}
|
||||
uint32_t GetDynamicIndexMask() const {
|
||||
return !m_pElement0 ? 0 : (uint32_t)m_pElement0->DynamicMaskAndStream & 0xF;
|
||||
}
|
||||
};
|
||||
|
||||
#define MAX_PSV_VERSION 2
|
||||
|
||||
struct PSVInitInfo
|
||||
{
|
||||
PSVInitInfo(uint32_t psvVersion)
|
||||
: PSVVersion(psvVersion)
|
||||
{}
|
||||
struct PSVInitInfo {
|
||||
PSVInitInfo(uint32_t psvVersion) : PSVVersion(psvVersion) {}
|
||||
uint32_t PSVVersion = 0;
|
||||
uint32_t ResourceCount = 0;
|
||||
PSVShaderKind ShaderStage = PSVShaderKind::Invalid;
|
||||
|
@ -388,26 +448,26 @@ struct PSVInitInfo
|
|||
static_assert(MAX_PSV_VERSION == 2, "otherwise this needs updating.");
|
||||
uint32_t RuntimeInfoSize() const {
|
||||
switch (PSVVersion) {
|
||||
case 0: return sizeof(PSVRuntimeInfo0);
|
||||
case 1: return sizeof(PSVRuntimeInfo1);
|
||||
default: break;
|
||||
case 0:
|
||||
return sizeof(PSVRuntimeInfo0);
|
||||
case 1:
|
||||
return sizeof(PSVRuntimeInfo1);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return sizeof(PSVRuntimeInfo2);
|
||||
return sizeof(PSVRuntimeInfo2);
|
||||
}
|
||||
uint32_t ResourceBindInfoSize() const {
|
||||
if (PSVVersion < 2)
|
||||
return sizeof(PSVResourceBindInfo0);
|
||||
return sizeof(PSVResourceBindInfo1);
|
||||
}
|
||||
uint32_t SignatureElementSize() const {
|
||||
return sizeof(PSVSignatureElement0);
|
||||
}
|
||||
uint32_t SignatureElementSize() const { return sizeof(PSVSignatureElement0); }
|
||||
};
|
||||
|
||||
class DxilPipelineStateValidation
|
||||
{
|
||||
class DxilPipelineStateValidation {
|
||||
uint32_t m_uPSVRuntimeInfoSize = 0;
|
||||
PSVRuntimeInfo0* m_pPSVRuntimeInfo0 = nullptr;
|
||||
PSVRuntimeInfo0 *m_pPSVRuntimeInfo0 = nullptr;
|
||||
PSVRuntimeInfo1 *m_pPSVRuntimeInfo1 = nullptr;
|
||||
PSVRuntimeInfo2 *m_pPSVRuntimeInfo2 = nullptr;
|
||||
uint32_t m_uResourceCount = 0;
|
||||
|
@ -419,9 +479,11 @@ class DxilPipelineStateValidation
|
|||
void *m_pSigInputElements = nullptr;
|
||||
void *m_pSigOutputElements = nullptr;
|
||||
void *m_pSigPatchConstOrPrimElements = nullptr;
|
||||
uint32_t *m_pViewIDOutputMask[PSV_GS_MAX_STREAMS] = {nullptr, nullptr, nullptr, nullptr};
|
||||
uint32_t *m_pViewIDOutputMask[PSV_GS_MAX_STREAMS] = {nullptr, nullptr,
|
||||
nullptr, nullptr};
|
||||
uint32_t *m_pViewIDPCOrPrimOutputMask = nullptr;
|
||||
uint32_t *m_pInputToOutputTable[PSV_GS_MAX_STREAMS] = {nullptr, nullptr, nullptr, nullptr};
|
||||
uint32_t *m_pInputToOutputTable[PSV_GS_MAX_STREAMS] = {nullptr, nullptr,
|
||||
nullptr, nullptr};
|
||||
uint32_t *m_pInputToPCOutputTable = nullptr;
|
||||
uint32_t *m_pPCInputToOutputTable = nullptr;
|
||||
|
||||
|
@ -443,8 +505,8 @@ public:
|
|||
|
||||
public:
|
||||
CheckedReaderWriter(const void *ptr, uint32_t size, RWMode mode)
|
||||
: Ptr(reinterpret_cast<char*>(const_cast<void*>(ptr))),
|
||||
Size(mode == RWMode::CalcSize ? 0 : size), Offset(0), Mode(mode) {}
|
||||
: Ptr(reinterpret_cast<char *>(const_cast<void *>(ptr))),
|
||||
Size(mode == RWMode::CalcSize ? 0 : size), Offset(0), Mode(mode) {}
|
||||
|
||||
uint32_t GetSize() { return Size; }
|
||||
RWMode GetMode() { return Mode; }
|
||||
|
@ -461,24 +523,25 @@ public:
|
|||
// Map* methods increment Offset.
|
||||
|
||||
// Assign pointer, increment Offset, and return true if size fits.
|
||||
template<typename _T> bool MapPtr(_T **ppPtr, size_t size = 0);
|
||||
template <typename _T> bool MapPtr(_T **ppPtr, size_t size = 0);
|
||||
// Read value, increment Offset, and return true if value fits.
|
||||
template <typename _T> bool MapValue(_T *pValue, const _T init = {});
|
||||
// Assign pointer, increment Offset, and return true if array fits.
|
||||
template <typename _T>
|
||||
bool MapArray(_T **ppPtr, size_t count, size_t eltSize);
|
||||
//template <> bool MapArray<void>(void **ppPtr, size_t count, size_t eltSize);
|
||||
// Assign pointer, increment Offset, and return true if array fits.
|
||||
// template <> bool MapArray<void>(void **ppPtr, size_t count, size_t
|
||||
// eltSize);
|
||||
// Assign pointer, increment Offset, and return true if array fits.
|
||||
template <typename _T> bool MapArray(_T **ppPtr, size_t count = 1);
|
||||
|
||||
void Clear();
|
||||
};
|
||||
|
||||
// Assigned derived ptr to base if size large enough.
|
||||
template<typename _Base, typename _T>
|
||||
bool AssignDerived(_T** ppDerived, _Base* pBase, uint32_t size) {
|
||||
template <typename _Base, typename _T>
|
||||
bool AssignDerived(_T **ppDerived, _Base *pBase, uint32_t size) {
|
||||
if ((size_t)size < sizeof(_T))
|
||||
return false; // size not large enough for type
|
||||
return false; // size not large enough for type
|
||||
*ppDerived = reinterpret_cast<_T *>(pBase);
|
||||
return true;
|
||||
}
|
||||
|
@ -488,7 +551,7 @@ private:
|
|||
const PSVInitInfo &initInfo = PSVInitInfo(MAX_PSV_VERSION));
|
||||
|
||||
public:
|
||||
bool InitFromPSV0(const void* pBits, uint32_t size) {
|
||||
bool InitFromPSV0(const void *pBits, uint32_t size) {
|
||||
return ReadOrWrite(pBits, &size, RWMode::Read);
|
||||
}
|
||||
|
||||
|
@ -506,21 +569,13 @@ public:
|
|||
return ReadOrWrite(pBuffer, pSize, Mode, initInfo);
|
||||
}
|
||||
|
||||
PSVRuntimeInfo0* GetPSVRuntimeInfo0() const {
|
||||
return m_pPSVRuntimeInfo0;
|
||||
}
|
||||
PSVRuntimeInfo0 *GetPSVRuntimeInfo0() const { return m_pPSVRuntimeInfo0; }
|
||||
|
||||
PSVRuntimeInfo1* GetPSVRuntimeInfo1() const {
|
||||
return m_pPSVRuntimeInfo1;
|
||||
}
|
||||
PSVRuntimeInfo1 *GetPSVRuntimeInfo1() const { return m_pPSVRuntimeInfo1; }
|
||||
|
||||
PSVRuntimeInfo2* GetPSVRuntimeInfo2() const {
|
||||
return m_pPSVRuntimeInfo2;
|
||||
}
|
||||
PSVRuntimeInfo2 *GetPSVRuntimeInfo2() const { return m_pPSVRuntimeInfo2; }
|
||||
|
||||
uint32_t GetBindCount() const {
|
||||
return m_uResourceCount;
|
||||
}
|
||||
uint32_t GetBindCount() const { return m_uResourceCount; }
|
||||
|
||||
template <typename _T>
|
||||
_T *GetRecord(void *pRecords, uint32_t recordSize, uint32_t numRecords,
|
||||
|
@ -533,20 +588,22 @@ public:
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
PSVResourceBindInfo0* GetPSVResourceBindInfo0(uint32_t index) const {
|
||||
PSVResourceBindInfo0 *GetPSVResourceBindInfo0(uint32_t index) const {
|
||||
return GetRecord<PSVResourceBindInfo0>(m_pPSVResourceBindInfo,
|
||||
m_uPSVResourceBindInfoSize,
|
||||
m_uResourceCount, index);
|
||||
}
|
||||
|
||||
PSVResourceBindInfo1* GetPSVResourceBindInfo1(uint32_t index) const {
|
||||
PSVResourceBindInfo1 *GetPSVResourceBindInfo1(uint32_t index) const {
|
||||
return GetRecord<PSVResourceBindInfo1>(m_pPSVResourceBindInfo,
|
||||
m_uPSVResourceBindInfoSize,
|
||||
m_uResourceCount, index);
|
||||
}
|
||||
|
||||
const PSVStringTable &GetStringTable() const { return m_StringTable; }
|
||||
const PSVSemanticIndexTable &GetSemanticIndexTable() const { return m_SemanticIndexTable; }
|
||||
const PSVSemanticIndexTable &GetSemanticIndexTable() const {
|
||||
return m_SemanticIndexTable;
|
||||
}
|
||||
|
||||
// Signature element access
|
||||
uint32_t GetSigInputElements() const {
|
||||
|
@ -564,28 +621,32 @@ public:
|
|||
return m_pPSVRuntimeInfo1->SigPatchConstOrPrimElements;
|
||||
return 0;
|
||||
}
|
||||
PSVSignatureElement0* GetInputElement0(uint32_t index) const {
|
||||
PSVSignatureElement0 *GetInputElement0(uint32_t index) const {
|
||||
return GetRecord<PSVSignatureElement0>(
|
||||
m_pSigInputElements, m_uPSVSignatureElementSize,
|
||||
m_pPSVRuntimeInfo1 ? m_pPSVRuntimeInfo1->SigInputElements : 0, index);
|
||||
}
|
||||
PSVSignatureElement0* GetOutputElement0(uint32_t index) const {
|
||||
PSVSignatureElement0 *GetOutputElement0(uint32_t index) const {
|
||||
return GetRecord<PSVSignatureElement0>(
|
||||
m_pSigOutputElements, m_uPSVSignatureElementSize,
|
||||
m_pPSVRuntimeInfo1 ? m_pPSVRuntimeInfo1->SigOutputElements : 0, index);
|
||||
}
|
||||
PSVSignatureElement0* GetPatchConstOrPrimElement0(uint32_t index) const {
|
||||
PSVSignatureElement0 *GetPatchConstOrPrimElement0(uint32_t index) const {
|
||||
return GetRecord<PSVSignatureElement0>(
|
||||
m_pSigPatchConstOrPrimElements, m_uPSVSignatureElementSize,
|
||||
m_pPSVRuntimeInfo1 ? m_pPSVRuntimeInfo1->SigPatchConstOrPrimElements : 0, index);
|
||||
m_pPSVRuntimeInfo1 ? m_pPSVRuntimeInfo1->SigPatchConstOrPrimElements
|
||||
: 0,
|
||||
index);
|
||||
}
|
||||
// More convenient wrapper:
|
||||
PSVSignatureElement GetSignatureElement(PSVSignatureElement0* pElement0) const {
|
||||
PSVSignatureElement
|
||||
GetSignatureElement(PSVSignatureElement0 *pElement0) const {
|
||||
return PSVSignatureElement(m_StringTable, m_SemanticIndexTable, pElement0);
|
||||
}
|
||||
|
||||
PSVShaderKind GetShaderKind() const {
|
||||
if (m_pPSVRuntimeInfo1 && m_pPSVRuntimeInfo1->ShaderStage < (uint8_t)PSVShaderKind::Invalid)
|
||||
if (m_pPSVRuntimeInfo1 &&
|
||||
m_pPSVRuntimeInfo1->ShaderStage < (uint8_t)PSVShaderKind::Invalid)
|
||||
return (PSVShaderKind)m_pPSVRuntimeInfo1->ShaderStage;
|
||||
return PSVShaderKind::Invalid;
|
||||
}
|
||||
|
@ -600,41 +661,58 @@ public:
|
|||
|
||||
// ViewID dependencies
|
||||
PSVComponentMask GetViewIDOutputMask(unsigned streamIndex = 0) const {
|
||||
if (streamIndex >= PSV_GS_MAX_STREAMS || !m_pViewIDOutputMask[streamIndex] || !m_pPSVRuntimeInfo1 || !m_pPSVRuntimeInfo1->SigOutputVectors[streamIndex])
|
||||
if (streamIndex >= PSV_GS_MAX_STREAMS ||
|
||||
!m_pViewIDOutputMask[streamIndex] || !m_pPSVRuntimeInfo1 ||
|
||||
!m_pPSVRuntimeInfo1->SigOutputVectors[streamIndex])
|
||||
return PSVComponentMask();
|
||||
return PSVComponentMask(m_pViewIDOutputMask[streamIndex], m_pPSVRuntimeInfo1->SigOutputVectors[streamIndex]);
|
||||
return PSVComponentMask(m_pViewIDOutputMask[streamIndex],
|
||||
m_pPSVRuntimeInfo1->SigOutputVectors[streamIndex]);
|
||||
}
|
||||
PSVComponentMask GetViewIDPCOutputMask() const {
|
||||
if ((!IsHS() && !IsMS()) || !m_pViewIDPCOrPrimOutputMask || !m_pPSVRuntimeInfo1 || !m_pPSVRuntimeInfo1->SigPatchConstOrPrimVectors)
|
||||
if ((!IsHS() && !IsMS()) || !m_pViewIDPCOrPrimOutputMask ||
|
||||
!m_pPSVRuntimeInfo1 || !m_pPSVRuntimeInfo1->SigPatchConstOrPrimVectors)
|
||||
return PSVComponentMask();
|
||||
return PSVComponentMask(m_pViewIDPCOrPrimOutputMask, m_pPSVRuntimeInfo1->SigPatchConstOrPrimVectors);
|
||||
return PSVComponentMask(m_pViewIDPCOrPrimOutputMask,
|
||||
m_pPSVRuntimeInfo1->SigPatchConstOrPrimVectors);
|
||||
}
|
||||
|
||||
// Input to Output dependencies
|
||||
PSVDependencyTable GetInputToOutputTable(unsigned streamIndex = 0) const {
|
||||
if (streamIndex < PSV_GS_MAX_STREAMS && m_pInputToOutputTable[streamIndex] && m_pPSVRuntimeInfo1) {
|
||||
return PSVDependencyTable(m_pInputToOutputTable[streamIndex], m_pPSVRuntimeInfo1->SigInputVectors, m_pPSVRuntimeInfo1->SigOutputVectors[streamIndex]);
|
||||
if (streamIndex < PSV_GS_MAX_STREAMS &&
|
||||
m_pInputToOutputTable[streamIndex] && m_pPSVRuntimeInfo1) {
|
||||
return PSVDependencyTable(
|
||||
m_pInputToOutputTable[streamIndex],
|
||||
m_pPSVRuntimeInfo1->SigInputVectors,
|
||||
m_pPSVRuntimeInfo1->SigOutputVectors[streamIndex]);
|
||||
}
|
||||
return PSVDependencyTable();
|
||||
}
|
||||
PSVDependencyTable GetInputToPCOutputTable() const {
|
||||
if (IsHS() && m_pInputToPCOutputTable && m_pPSVRuntimeInfo1) {
|
||||
return PSVDependencyTable(m_pInputToPCOutputTable, m_pPSVRuntimeInfo1->SigInputVectors, m_pPSVRuntimeInfo1->SigPatchConstOrPrimVectors);
|
||||
return PSVDependencyTable(m_pInputToPCOutputTable,
|
||||
m_pPSVRuntimeInfo1->SigInputVectors,
|
||||
m_pPSVRuntimeInfo1->SigPatchConstOrPrimVectors);
|
||||
}
|
||||
return PSVDependencyTable();
|
||||
}
|
||||
PSVDependencyTable GetPCInputToOutputTable() const {
|
||||
if (IsDS() && m_pPCInputToOutputTable && m_pPSVRuntimeInfo1) {
|
||||
return PSVDependencyTable(m_pPCInputToOutputTable, m_pPSVRuntimeInfo1->SigPatchConstOrPrimVectors, m_pPSVRuntimeInfo1->SigOutputVectors[0]);
|
||||
return PSVDependencyTable(m_pPCInputToOutputTable,
|
||||
m_pPSVRuntimeInfo1->SigPatchConstOrPrimVectors,
|
||||
m_pPSVRuntimeInfo1->SigOutputVectors[0]);
|
||||
}
|
||||
return PSVDependencyTable();
|
||||
}
|
||||
|
||||
bool GetNumThreads(uint32_t *pNumThreadsX, uint32_t *pNumThreadsY, uint32_t *pNumThreadsZ) {
|
||||
bool GetNumThreads(uint32_t *pNumThreadsX, uint32_t *pNumThreadsY,
|
||||
uint32_t *pNumThreadsZ) {
|
||||
if (m_pPSVRuntimeInfo2) {
|
||||
if (pNumThreadsX) *pNumThreadsX = m_pPSVRuntimeInfo2->NumThreadsX;
|
||||
if (pNumThreadsY) *pNumThreadsY = m_pPSVRuntimeInfo2->NumThreadsY;
|
||||
if (pNumThreadsZ) *pNumThreadsZ = m_pPSVRuntimeInfo2->NumThreadsZ;
|
||||
if (pNumThreadsX)
|
||||
*pNumThreadsX = m_pPSVRuntimeInfo2->NumThreadsX;
|
||||
if (pNumThreadsY)
|
||||
*pNumThreadsY = m_pPSVRuntimeInfo2->NumThreadsY;
|
||||
if (pNumThreadsZ)
|
||||
*pNumThreadsZ = m_pPSVRuntimeInfo2->NumThreadsZ;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -666,11 +744,13 @@ DxilPipelineStateValidation::CheckedReaderWriter::IncrementPos(size_t size) {
|
|||
}
|
||||
|
||||
// Cast and return true if it fits.
|
||||
template <typename _T> inline bool
|
||||
DxilPipelineStateValidation::CheckedReaderWriter::Cast(_T **ppPtr, size_t size) {
|
||||
template <typename _T>
|
||||
inline bool
|
||||
DxilPipelineStateValidation::CheckedReaderWriter::Cast(_T **ppPtr,
|
||||
size_t size) {
|
||||
PSV_RETB(CheckBounds(size));
|
||||
if (Mode != RWMode::CalcSize)
|
||||
*ppPtr = reinterpret_cast<_T*>(Ptr + Offset);
|
||||
*ppPtr = reinterpret_cast<_T *>(Ptr + Offset);
|
||||
return true;
|
||||
}
|
||||
template <typename _T>
|
||||
|
@ -681,9 +761,10 @@ inline bool DxilPipelineStateValidation::CheckedReaderWriter::Cast(_T **ppPtr) {
|
|||
// Map* methods increment Offset.
|
||||
|
||||
// Assign pointer, increment Offset, and return true if size fits.
|
||||
template<typename _T>
|
||||
template <typename _T>
|
||||
inline bool
|
||||
DxilPipelineStateValidation::CheckedReaderWriter::MapPtr(_T **ppPtr, size_t size) {
|
||||
DxilPipelineStateValidation::CheckedReaderWriter::MapPtr(_T **ppPtr,
|
||||
size_t size) {
|
||||
PSV_RETB(Cast(ppPtr, size));
|
||||
PSV_RETB(IncrementPos(size));
|
||||
return true;
|
||||
|
@ -691,13 +772,20 @@ DxilPipelineStateValidation::CheckedReaderWriter::MapPtr(_T **ppPtr, size_t size
|
|||
// Read value, increment Offset, and return true if value fits.
|
||||
template <typename _T>
|
||||
inline bool
|
||||
DxilPipelineStateValidation::CheckedReaderWriter::MapValue(_T *pValue, const _T init) {
|
||||
DxilPipelineStateValidation::CheckedReaderWriter::MapValue(_T *pValue,
|
||||
const _T init) {
|
||||
_T *pPtr = nullptr;
|
||||
PSV_RETB(MapPtr(&pPtr, sizeof(_T)));
|
||||
switch (Mode) {
|
||||
case RWMode::Read: *pValue = *pPtr; break;
|
||||
case RWMode::CalcSize: *pValue = init; break;
|
||||
case RWMode::Write: *pPtr = *pValue = init; break;
|
||||
case RWMode::Read:
|
||||
*pValue = *pPtr;
|
||||
break;
|
||||
case RWMode::CalcSize:
|
||||
*pValue = init;
|
||||
break;
|
||||
case RWMode::Write:
|
||||
*pPtr = *pValue = init;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -708,7 +796,7 @@ inline bool DxilPipelineStateValidation::CheckedReaderWriter::MapArray(
|
|||
PSV_RETB(count <= UINT_MAX && eltSize <= UINT_MAX && eltSize >= sizeof(_T));
|
||||
return count ? MapPtr(ppPtr, eltSize * count) : true;
|
||||
}
|
||||
//template <> bool MapArray<void>(void **ppPtr, size_t count, size_t eltSize);
|
||||
// template <> bool MapArray<void>(void **ppPtr, size_t count, size_t eltSize);
|
||||
template <>
|
||||
inline bool DxilPipelineStateValidation::CheckedReaderWriter::MapArray<void>(
|
||||
void **ppPtr, size_t count, size_t eltSize) {
|
||||
|
@ -719,7 +807,8 @@ inline bool DxilPipelineStateValidation::CheckedReaderWriter::MapArray<void>(
|
|||
// Assign pointer, increment Offset, and return true if array fits.
|
||||
template <typename _T>
|
||||
inline bool
|
||||
DxilPipelineStateValidation::CheckedReaderWriter::MapArray(_T **ppPtr, size_t count) {
|
||||
DxilPipelineStateValidation::CheckedReaderWriter::MapArray(_T **ppPtr,
|
||||
size_t count) {
|
||||
return count ? MapArray(ppPtr, count, sizeof(_T)) : true;
|
||||
}
|
||||
|
||||
|
@ -754,22 +843,28 @@ inline void DxilPipelineStateValidation::CheckedReaderWriter::Clear() {
|
|||
// { uint32_t * PSVComputeMaskDwordsFromVectors(SigOutputVectors[i]) }
|
||||
// - Outputs affected by ViewID as a bitmask
|
||||
// If (HS and SigPatchConstOrPrimVectors non-zero):
|
||||
// { uint32_t * PSVComputeMaskDwordsFromVectors(SigPatchConstOrPrimVectors) }
|
||||
// { uint32_t *
|
||||
// PSVComputeMaskDwordsFromVectors(SigPatchConstOrPrimVectors) }
|
||||
// - PCOutputs affected by ViewID as a bitmask
|
||||
// For (i : each stream index 0-3):
|
||||
// If (SigInputVectors and SigOutputVectors[i] non-zero):
|
||||
// { uint32_t * PSVComputeInputOutputTableDwords(SigInputVectors, SigOutputVectors[i]) }
|
||||
// { uint32_t * PSVComputeInputOutputTableDwords(SigInputVectors,
|
||||
// SigOutputVectors[i]) }
|
||||
// - Outputs affected by inputs as a table of bitmasks
|
||||
// If (HS and SigPatchConstOrPrimVectors and SigInputVectors non-zero):
|
||||
// { uint32_t * PSVComputeInputOutputTableDwords(SigInputVectors, SigPatchConstOrPrimVectors) }
|
||||
// { uint32_t * PSVComputeInputOutputTableDwords(SigInputVectors,
|
||||
// SigPatchConstOrPrimVectors) }
|
||||
// - Patch constant outputs affected by inputs as a table of bitmasks
|
||||
// If (DS and SigOutputVectors[0] and SigPatchConstOrPrimVectors non-zero):
|
||||
// { uint32_t * PSVComputeInputOutputTableDwords(SigPatchConstOrPrimVectors, SigOutputVectors[0]) }
|
||||
// { uint32_t *
|
||||
// PSVComputeInputOutputTableDwords(SigPatchConstOrPrimVectors,
|
||||
// SigOutputVectors[0]) }
|
||||
// - Outputs affected by patch constant inputs as a table of bitmasks
|
||||
// returns true if no errors occurred.
|
||||
inline bool DxilPipelineStateValidation::ReadOrWrite(
|
||||
const void *pBits, uint32_t *pSize, RWMode mode,
|
||||
const PSVInitInfo &initInfo) {
|
||||
inline bool
|
||||
DxilPipelineStateValidation::ReadOrWrite(const void *pBits, uint32_t *pSize,
|
||||
RWMode mode,
|
||||
const PSVInitInfo &initInfo) {
|
||||
PSV_RETB(pSize != nullptr);
|
||||
PSV_RETB(pBits != nullptr || mode == RWMode::CalcSize);
|
||||
PSV_RETB(initInfo.PSVVersion <= MAX_PSV_VERSION);
|
||||
|
@ -779,10 +874,13 @@ inline bool DxilPipelineStateValidation::ReadOrWrite(
|
|||
|
||||
PSV_RETB(rw.MapValue(&m_uPSVRuntimeInfoSize, initInfo.RuntimeInfoSize()));
|
||||
PSV_RETB(rw.MapArray(&m_pPSVRuntimeInfo0, 1, m_uPSVRuntimeInfoSize));
|
||||
AssignDerived(&m_pPSVRuntimeInfo1, m_pPSVRuntimeInfo0, m_uPSVRuntimeInfoSize); // failure ok
|
||||
AssignDerived(&m_pPSVRuntimeInfo2, m_pPSVRuntimeInfo0, m_uPSVRuntimeInfoSize); // failure ok
|
||||
AssignDerived(&m_pPSVRuntimeInfo1, m_pPSVRuntimeInfo0,
|
||||
m_uPSVRuntimeInfoSize); // failure ok
|
||||
AssignDerived(&m_pPSVRuntimeInfo2, m_pPSVRuntimeInfo0,
|
||||
m_uPSVRuntimeInfoSize); // failure ok
|
||||
|
||||
// In RWMode::CalcSize, use temp runtime info to hold needed values from initInfo
|
||||
// In RWMode::CalcSize, use temp runtime info to hold needed values from
|
||||
// initInfo
|
||||
PSVRuntimeInfo1 tempRuntimeInfo = {};
|
||||
if (mode == RWMode::CalcSize && initInfo.PSVVersion > 0) {
|
||||
m_pPSVRuntimeInfo1 = &tempRuntimeInfo;
|
||||
|
@ -791,9 +889,11 @@ inline bool DxilPipelineStateValidation::ReadOrWrite(
|
|||
PSV_RETB(rw.MapValue(&m_uResourceCount, initInfo.ResourceCount));
|
||||
|
||||
if (m_uResourceCount > 0) {
|
||||
PSV_RETB(rw.MapValue(&m_uPSVResourceBindInfoSize, initInfo.ResourceBindInfoSize()));
|
||||
PSV_RETB(rw.MapValue(&m_uPSVResourceBindInfoSize,
|
||||
initInfo.ResourceBindInfoSize()));
|
||||
PSV_RETB(sizeof(PSVResourceBindInfo0) <= m_uPSVResourceBindInfoSize);
|
||||
PSV_RETB(rw.MapArray(&m_pPSVResourceBindInfo, m_uResourceCount, m_uPSVResourceBindInfoSize));
|
||||
PSV_RETB(rw.MapArray(&m_pPSVResourceBindInfo, m_uResourceCount,
|
||||
m_uPSVResourceBindInfoSize));
|
||||
}
|
||||
|
||||
if (m_pPSVRuntimeInfo1) {
|
||||
|
@ -801,46 +901,63 @@ inline bool DxilPipelineStateValidation::ReadOrWrite(
|
|||
m_pPSVRuntimeInfo1->ShaderStage = (uint8_t)initInfo.ShaderStage;
|
||||
m_pPSVRuntimeInfo1->SigInputElements = initInfo.SigInputElements;
|
||||
m_pPSVRuntimeInfo1->SigOutputElements = initInfo.SigOutputElements;
|
||||
m_pPSVRuntimeInfo1->SigPatchConstOrPrimElements = initInfo.SigPatchConstOrPrimElements;
|
||||
m_pPSVRuntimeInfo1->SigPatchConstOrPrimElements =
|
||||
initInfo.SigPatchConstOrPrimElements;
|
||||
m_pPSVRuntimeInfo1->UsesViewID = initInfo.UsesViewID;
|
||||
for (unsigned i = 0; i < PSV_GS_MAX_STREAMS; i++) {
|
||||
m_pPSVRuntimeInfo1->SigOutputVectors[i] = initInfo.SigOutputVectors[i];
|
||||
}
|
||||
if (IsHS() || IsDS() || IsMS()) {
|
||||
m_pPSVRuntimeInfo1->SigPatchConstOrPrimVectors = initInfo.SigPatchConstOrPrimVectors;
|
||||
m_pPSVRuntimeInfo1->SigPatchConstOrPrimVectors =
|
||||
initInfo.SigPatchConstOrPrimVectors;
|
||||
}
|
||||
m_pPSVRuntimeInfo1->SigInputVectors = initInfo.SigInputVectors;
|
||||
}
|
||||
|
||||
PSV_RETB(rw.MapValue(&m_StringTable.Size, PSVALIGN4(initInfo.StringTable.Size)));
|
||||
PSV_RETB(
|
||||
rw.MapValue(&m_StringTable.Size, PSVALIGN4(initInfo.StringTable.Size)));
|
||||
PSV_RETB(PSVALIGN4(m_StringTable.Size) == m_StringTable.Size);
|
||||
if (m_StringTable.Size) {
|
||||
PSV_RETB(rw.MapArray(&m_StringTable.Table, m_StringTable.Size));
|
||||
if (mode == RWMode::Write) {
|
||||
memcpy(const_cast<char*>(m_StringTable.Table), initInfo.StringTable.Table, initInfo.StringTable.Size);
|
||||
memcpy(const_cast<char *>(m_StringTable.Table),
|
||||
initInfo.StringTable.Table, initInfo.StringTable.Size);
|
||||
}
|
||||
}
|
||||
|
||||
PSV_RETB(rw.MapValue(&m_SemanticIndexTable.Entries, initInfo.SemanticIndexTable.Entries));
|
||||
PSV_RETB(rw.MapValue(&m_SemanticIndexTable.Entries,
|
||||
initInfo.SemanticIndexTable.Entries));
|
||||
if (m_SemanticIndexTable.Entries) {
|
||||
PSV_RETB(rw.MapArray(&m_SemanticIndexTable.Table, m_SemanticIndexTable.Entries));
|
||||
PSV_RETB(rw.MapArray(&m_SemanticIndexTable.Table,
|
||||
m_SemanticIndexTable.Entries));
|
||||
if (mode == RWMode::Write) {
|
||||
memcpy(const_cast<uint32_t*>(m_SemanticIndexTable.Table), initInfo.SemanticIndexTable.Table, sizeof(uint32_t) * initInfo.SemanticIndexTable.Entries);
|
||||
memcpy(const_cast<uint32_t *>(m_SemanticIndexTable.Table),
|
||||
initInfo.SemanticIndexTable.Table,
|
||||
sizeof(uint32_t) * initInfo.SemanticIndexTable.Entries);
|
||||
}
|
||||
}
|
||||
|
||||
// Dxil Signature Elements
|
||||
if (m_pPSVRuntimeInfo1->SigInputElements || m_pPSVRuntimeInfo1->SigOutputElements || m_pPSVRuntimeInfo1->SigPatchConstOrPrimElements) {
|
||||
PSV_RETB(rw.MapValue(&m_uPSVSignatureElementSize, initInfo.SignatureElementSize()));
|
||||
if (m_pPSVRuntimeInfo1->SigInputElements ||
|
||||
m_pPSVRuntimeInfo1->SigOutputElements ||
|
||||
m_pPSVRuntimeInfo1->SigPatchConstOrPrimElements) {
|
||||
PSV_RETB(rw.MapValue(&m_uPSVSignatureElementSize,
|
||||
initInfo.SignatureElementSize()));
|
||||
PSV_RETB(sizeof(PSVSignatureElement0) <= m_uPSVSignatureElementSize);
|
||||
if (m_pPSVRuntimeInfo1->SigInputElements) {
|
||||
PSV_RETB(rw.MapArray(&m_pSigInputElements, m_pPSVRuntimeInfo1->SigInputElements, m_uPSVSignatureElementSize));
|
||||
PSV_RETB(rw.MapArray(&m_pSigInputElements,
|
||||
m_pPSVRuntimeInfo1->SigInputElements,
|
||||
m_uPSVSignatureElementSize));
|
||||
}
|
||||
if (m_pPSVRuntimeInfo1->SigOutputElements) {
|
||||
PSV_RETB(rw.MapArray(&m_pSigOutputElements, m_pPSVRuntimeInfo1->SigOutputElements, m_uPSVSignatureElementSize));
|
||||
PSV_RETB(rw.MapArray(&m_pSigOutputElements,
|
||||
m_pPSVRuntimeInfo1->SigOutputElements,
|
||||
m_uPSVSignatureElementSize));
|
||||
}
|
||||
if (m_pPSVRuntimeInfo1->SigPatchConstOrPrimElements) {
|
||||
PSV_RETB(rw.MapArray(&m_pSigPatchConstOrPrimElements, m_pPSVRuntimeInfo1->SigPatchConstOrPrimElements, m_uPSVSignatureElementSize));
|
||||
PSV_RETB(rw.MapArray(&m_pSigPatchConstOrPrimElements,
|
||||
m_pPSVRuntimeInfo1->SigPatchConstOrPrimElements,
|
||||
m_uPSVSignatureElementSize));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -849,33 +966,47 @@ inline bool DxilPipelineStateValidation::ReadOrWrite(
|
|||
for (unsigned i = 0; i < PSV_GS_MAX_STREAMS; i++) {
|
||||
if (m_pPSVRuntimeInfo1->SigOutputVectors[i]) {
|
||||
PSV_RETB(rw.MapArray(&m_pViewIDOutputMask[i],
|
||||
PSVComputeMaskDwordsFromVectors(m_pPSVRuntimeInfo1->SigOutputVectors[i])));
|
||||
PSVComputeMaskDwordsFromVectors(
|
||||
m_pPSVRuntimeInfo1->SigOutputVectors[i])));
|
||||
}
|
||||
if (!IsGS())
|
||||
break;
|
||||
}
|
||||
if ((IsHS() || IsMS()) && m_pPSVRuntimeInfo1->SigPatchConstOrPrimVectors) {
|
||||
PSV_RETB(rw.MapArray(&m_pViewIDPCOrPrimOutputMask,
|
||||
PSVComputeMaskDwordsFromVectors(m_pPSVRuntimeInfo1->SigPatchConstOrPrimVectors)));
|
||||
if ((IsHS() || IsMS()) &&
|
||||
m_pPSVRuntimeInfo1->SigPatchConstOrPrimVectors) {
|
||||
PSV_RETB(
|
||||
rw.MapArray(&m_pViewIDPCOrPrimOutputMask,
|
||||
PSVComputeMaskDwordsFromVectors(
|
||||
m_pPSVRuntimeInfo1->SigPatchConstOrPrimVectors)));
|
||||
}
|
||||
}
|
||||
|
||||
// Input to Output dependencies
|
||||
for (unsigned i = 0; i < PSV_GS_MAX_STREAMS; i++) {
|
||||
if (!IsMS() && m_pPSVRuntimeInfo1->SigOutputVectors[i] > 0 && m_pPSVRuntimeInfo1->SigInputVectors > 0) {
|
||||
if (!IsMS() && m_pPSVRuntimeInfo1->SigOutputVectors[i] > 0 &&
|
||||
m_pPSVRuntimeInfo1->SigInputVectors > 0) {
|
||||
PSV_RETB(rw.MapArray(&m_pInputToOutputTable[i],
|
||||
PSVComputeInputOutputTableDwords(m_pPSVRuntimeInfo1->SigInputVectors, m_pPSVRuntimeInfo1->SigOutputVectors[i])));
|
||||
PSVComputeInputOutputTableDwords(
|
||||
m_pPSVRuntimeInfo1->SigInputVectors,
|
||||
m_pPSVRuntimeInfo1->SigOutputVectors[i])));
|
||||
}
|
||||
if (!IsGS())
|
||||
break;
|
||||
}
|
||||
if (IsHS() && m_pPSVRuntimeInfo1->SigPatchConstOrPrimVectors > 0 && m_pPSVRuntimeInfo1->SigInputVectors > 0) {
|
||||
PSV_RETB(rw.MapArray(&m_pInputToPCOutputTable,
|
||||
PSVComputeInputOutputTableDwords(m_pPSVRuntimeInfo1->SigInputVectors, m_pPSVRuntimeInfo1->SigPatchConstOrPrimVectors)));
|
||||
if (IsHS() && m_pPSVRuntimeInfo1->SigPatchConstOrPrimVectors > 0 &&
|
||||
m_pPSVRuntimeInfo1->SigInputVectors > 0) {
|
||||
PSV_RETB(
|
||||
rw.MapArray(&m_pInputToPCOutputTable,
|
||||
PSVComputeInputOutputTableDwords(
|
||||
m_pPSVRuntimeInfo1->SigInputVectors,
|
||||
m_pPSVRuntimeInfo1->SigPatchConstOrPrimVectors)));
|
||||
}
|
||||
if (IsDS() && m_pPSVRuntimeInfo1->SigOutputVectors[0] > 0 && m_pPSVRuntimeInfo1->SigPatchConstOrPrimVectors > 0) {
|
||||
if (IsDS() && m_pPSVRuntimeInfo1->SigOutputVectors[0] > 0 &&
|
||||
m_pPSVRuntimeInfo1->SigPatchConstOrPrimVectors > 0) {
|
||||
PSV_RETB(rw.MapArray(&m_pPCInputToOutputTable,
|
||||
PSVComputeInputOutputTableDwords(m_pPSVRuntimeInfo1->SigPatchConstOrPrimVectors, m_pPSVRuntimeInfo1->SigOutputVectors[0])));
|
||||
PSVComputeInputOutputTableDwords(
|
||||
m_pPSVRuntimeInfo1->SigPatchConstOrPrimVectors,
|
||||
m_pPSVRuntimeInfo1->SigOutputVectors[0])));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -888,31 +1019,31 @@ inline bool DxilPipelineStateValidation::ReadOrWrite(
|
|||
|
||||
namespace hlsl {
|
||||
|
||||
class ViewIDValidator {
|
||||
public:
|
||||
enum class Result {
|
||||
Success = 0,
|
||||
SuccessWithViewIDDependentTessFactor,
|
||||
InsufficientInputSpace,
|
||||
InsufficientOutputSpace,
|
||||
InsufficientPCSpace,
|
||||
MismatchedSignatures,
|
||||
MismatchedPCSignatures,
|
||||
InvalidUsage,
|
||||
InvalidPSVVersion,
|
||||
InvalidPSV,
|
||||
};
|
||||
virtual ~ViewIDValidator() {}
|
||||
virtual Result ValidateStage(const DxilPipelineStateValidation &PSV,
|
||||
bool bFinalStage,
|
||||
bool bExpandInputOnly,
|
||||
unsigned &mismatchElementId) = 0;
|
||||
class ViewIDValidator {
|
||||
public:
|
||||
enum class Result {
|
||||
Success = 0,
|
||||
SuccessWithViewIDDependentTessFactor,
|
||||
InsufficientInputSpace,
|
||||
InsufficientOutputSpace,
|
||||
InsufficientPCSpace,
|
||||
MismatchedSignatures,
|
||||
MismatchedPCSignatures,
|
||||
InvalidUsage,
|
||||
InvalidPSVVersion,
|
||||
InvalidPSV,
|
||||
};
|
||||
virtual ~ViewIDValidator() {}
|
||||
virtual Result ValidateStage(const DxilPipelineStateValidation &PSV,
|
||||
bool bFinalStage, bool bExpandInputOnly,
|
||||
unsigned &mismatchElementId) = 0;
|
||||
};
|
||||
|
||||
ViewIDValidator* NewViewIDValidator(unsigned viewIDCount, unsigned gsRastStreamIndex);
|
||||
ViewIDValidator *NewViewIDValidator(unsigned viewIDCount,
|
||||
unsigned gsRastStreamIndex);
|
||||
|
||||
}
|
||||
} // namespace hlsl
|
||||
|
||||
#undef PSV_RETB
|
||||
|
||||
#endif // __DXIL_PIPELINE_STATE_VALIDATION__H__
|
||||
#endif // __DXIL_PIPELINE_STATE_VALIDATION__H__
|
||||
|
|
|
@ -17,20 +17,20 @@
|
|||
|
||||
namespace hlsl {
|
||||
|
||||
// Like DXIL container, RDAT itself is a mini container that contains multiple RDAT parts
|
||||
// Like DXIL container, RDAT itself is a mini container that contains multiple
|
||||
// RDAT parts
|
||||
class DxilRDATBuilder {
|
||||
llvm::SmallVector<char, 1024> m_RDATBuffer;
|
||||
std::vector<std::unique_ptr<RDATPart>> m_Parts;
|
||||
|
||||
StringBufferPart *m_pStringBufferPart = nullptr;
|
||||
IndexArraysPart *m_pIndexArraysPart = nullptr;
|
||||
RawBytesPart *m_pRawBytesPart = nullptr;
|
||||
IndexArraysPart *m_pIndexArraysPart = nullptr;
|
||||
RawBytesPart *m_pRawBytesPart = nullptr;
|
||||
RDATTable *m_pTables[(size_t)RDAT::RecordTableIndex::RecordTableCount] = {};
|
||||
|
||||
bool m_bRecordDeduplicationEnabled = true;
|
||||
|
||||
template<typename T>
|
||||
T *GetOrAddPart(T **ptrStorage) {
|
||||
template <typename T> T *GetOrAddPart(T **ptrStorage) {
|
||||
if (!*ptrStorage) {
|
||||
m_Parts.emplace_back(llvm::make_unique<T>());
|
||||
*ptrStorage = reinterpret_cast<T *>(m_Parts.back().get());
|
||||
|
@ -41,9 +41,9 @@ class DxilRDATBuilder {
|
|||
public:
|
||||
DxilRDATBuilder(bool allowRecordDuplication);
|
||||
|
||||
template<typename T>
|
||||
RDATTable *GetOrAddTable() {
|
||||
RDATTable **tablePtr = &m_pTables[ (size_t)RDAT::RecordTraits<T>::TableIndex() ];
|
||||
template <typename T> RDATTable *GetOrAddTable() {
|
||||
RDATTable **tablePtr =
|
||||
&m_pTables[(size_t)RDAT::RecordTraits<T>::TableIndex()];
|
||||
if (!*tablePtr) {
|
||||
m_Parts.emplace_back(llvm::make_unique<RDATTable>());
|
||||
*tablePtr = reinterpret_cast<RDATTable *>(m_Parts.back().get());
|
||||
|
@ -54,8 +54,7 @@ public:
|
|||
return *tablePtr;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
uint32_t InsertRecord(const T &record) {
|
||||
template <typename T> uint32_t InsertRecord(const T &record) {
|
||||
return GetOrAddTable<T>()->Insert(record);
|
||||
}
|
||||
uint32_t InsertString(llvm::StringRef str) {
|
||||
|
@ -67,12 +66,10 @@ public:
|
|||
hlsl::RDAT::BytesRef InsertBytesRef(llvm::StringRef data) {
|
||||
return GetRawBytesPart().InsertBytesRef(data.data(), data.size());
|
||||
}
|
||||
template<typename T>
|
||||
uint32_t InsertArray(T begin, T end) {
|
||||
template <typename T> uint32_t InsertArray(T begin, T end) {
|
||||
return GetIndexArraysPart().AddIndex(begin, end);
|
||||
}
|
||||
template<typename T>
|
||||
uint32_t InsertArray(T arr) {
|
||||
template <typename T> uint32_t InsertArray(T arr) {
|
||||
return InsertArray(arr.begin(), arr.end());
|
||||
}
|
||||
|
||||
|
@ -82,9 +79,7 @@ public:
|
|||
IndexArraysPart &GetIndexArraysPart() {
|
||||
return *GetOrAddPart(&m_pIndexArraysPart);
|
||||
}
|
||||
RawBytesPart &GetRawBytesPart() {
|
||||
return *GetOrAddPart(&m_pRawBytesPart);
|
||||
}
|
||||
RawBytesPart &GetRawBytesPart() { return *GetOrAddPart(&m_pRawBytesPart); }
|
||||
|
||||
struct SizeInfo {
|
||||
uint32_t sizeInBytes;
|
||||
|
@ -92,12 +87,9 @@ public:
|
|||
};
|
||||
SizeInfo ComputeSize() const;
|
||||
|
||||
uint32_t size() const {
|
||||
return ComputeSize().sizeInBytes;
|
||||
}
|
||||
uint32_t size() const { return ComputeSize().sizeInBytes; }
|
||||
|
||||
llvm::StringRef FinalizeAndGetData();
|
||||
};
|
||||
|
||||
} // namespace hlsl
|
||||
|
||||
|
|
|
@ -9,18 +9,18 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "dxc/Support/WinIncludes.h"
|
||||
#include "dxc/DxilContainer/DxilRuntimeReflection.h"
|
||||
#include "dxc/Support/WinIncludes.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
|
@ -28,7 +28,9 @@ class RDATPart {
|
|||
public:
|
||||
virtual uint32_t GetPartSize() const { return 0; }
|
||||
virtual void Write(void *ptr) {}
|
||||
virtual RDAT::RuntimeDataPartType GetType() const { return RDAT::RuntimeDataPartType::Invalid; }
|
||||
virtual RDAT::RuntimeDataPartType GetType() const {
|
||||
return RDAT::RuntimeDataPartType::Invalid;
|
||||
}
|
||||
virtual ~RDATPart() {}
|
||||
};
|
||||
|
||||
|
@ -40,17 +42,19 @@ private:
|
|||
|
||||
public:
|
||||
StringBufferPart() {
|
||||
// Always start string table with null so empty/null strings have offset of zero
|
||||
// Always start string table with null so empty/null strings have offset of
|
||||
// zero
|
||||
Insert("");
|
||||
}
|
||||
// returns the offset of the name inserted
|
||||
uint32_t Insert(llvm::StringRef str);
|
||||
RDAT::RuntimeDataPartType GetType() const { return RDAT::RuntimeDataPartType::StringBuffer; }
|
||||
RDAT::RuntimeDataPartType GetType() const {
|
||||
return RDAT::RuntimeDataPartType::StringBuffer;
|
||||
}
|
||||
uint32_t GetPartSize() const { return m_Size; }
|
||||
void Write(void *ptr);
|
||||
};
|
||||
|
||||
|
||||
class IndexArraysPart : public RDATPart {
|
||||
private:
|
||||
std::vector<uint32_t> m_IndexBuffer;
|
||||
|
@ -66,7 +70,8 @@ private:
|
|||
return (*pLeft < *pRight);
|
||||
uint32_t count = *pLeft;
|
||||
for (unsigned i = 0; i < count; i++) {
|
||||
++pLeft; ++pRight;
|
||||
++pLeft;
|
||||
++pRight;
|
||||
if (*pLeft != *pRight)
|
||||
return (*pLeft < *pRight);
|
||||
}
|
||||
|
@ -77,8 +82,7 @@ private:
|
|||
|
||||
public:
|
||||
IndexArraysPart() : m_IndexBuffer(), m_IndexSet(*this) {}
|
||||
template <class iterator>
|
||||
uint32_t AddIndex(iterator begin, iterator end) {
|
||||
template <class iterator> uint32_t AddIndex(iterator begin, iterator end) {
|
||||
uint32_t newOffset = m_IndexBuffer.size();
|
||||
m_IndexBuffer.push_back(0); // Size: update after insertion
|
||||
m_IndexBuffer.insert(m_IndexBuffer.end(), begin, end);
|
||||
|
@ -87,12 +91,15 @@ public:
|
|||
auto insertResult = m_IndexSet.insert(newOffset);
|
||||
if (insertResult.second)
|
||||
return newOffset;
|
||||
// Otherwise it was a duplicate, so chop off the size and return the original
|
||||
// Otherwise it was a duplicate, so chop off the size and return the
|
||||
// original
|
||||
m_IndexBuffer.resize(newOffset);
|
||||
return *insertResult.first;
|
||||
}
|
||||
|
||||
RDAT::RuntimeDataPartType GetType() const { return RDAT::RuntimeDataPartType::IndexArrays; }
|
||||
RDAT::RuntimeDataPartType GetType() const {
|
||||
return RDAT::RuntimeDataPartType::IndexArrays;
|
||||
}
|
||||
uint32_t GetPartSize() const {
|
||||
return sizeof(uint32_t) * m_IndexBuffer.size();
|
||||
}
|
||||
|
@ -107,6 +114,7 @@ private:
|
|||
std::unordered_map<std::string, uint32_t> m_Map;
|
||||
std::vector<llvm::StringRef> m_List;
|
||||
size_t m_Size = 0;
|
||||
|
||||
public:
|
||||
RawBytesPart() {}
|
||||
uint32_t Insert(const void *pData, size_t dataSize);
|
||||
|
@ -117,7 +125,9 @@ public:
|
|||
return ret;
|
||||
}
|
||||
|
||||
RDAT::RuntimeDataPartType GetType() const { return RDAT::RuntimeDataPartType::RawBytes; }
|
||||
RDAT::RuntimeDataPartType GetType() const {
|
||||
return RDAT::RuntimeDataPartType::RawBytes;
|
||||
}
|
||||
uint32_t GetPartSize() const { return m_Size; }
|
||||
void Write(void *ptr);
|
||||
};
|
||||
|
@ -132,6 +142,7 @@ protected:
|
|||
bool m_bDeduplicationEnabled = false;
|
||||
RDAT::RuntimeDataPartType m_Type = RDAT::RuntimeDataPartType::Invalid;
|
||||
uint32_t InsertImpl(const void *ptr, size_t size);
|
||||
|
||||
public:
|
||||
virtual ~RDATTable() {}
|
||||
|
||||
|
@ -139,15 +150,16 @@ public:
|
|||
RDAT::RuntimeDataPartType GetType() const { return m_Type; }
|
||||
void SetRecordStride(size_t RecordStride);
|
||||
size_t GetRecordStride() const { return m_RecordStride; }
|
||||
void SetDeduplication(bool bEnabled = true) { m_bDeduplicationEnabled = bEnabled; }
|
||||
void SetDeduplication(bool bEnabled = true) {
|
||||
m_bDeduplicationEnabled = bEnabled;
|
||||
}
|
||||
|
||||
uint32_t Count() {
|
||||
size_t count = m_rows.size();
|
||||
return (count < UINT32_MAX) ? count : 0;
|
||||
}
|
||||
|
||||
template<typename RecordType>
|
||||
uint32_t Insert(const RecordType &data) {
|
||||
template <typename RecordType> uint32_t Insert(const RecordType &data) {
|
||||
return InsertImpl(&data, sizeof(RecordType));
|
||||
}
|
||||
|
||||
|
@ -156,4 +168,3 @@ public:
|
|||
};
|
||||
|
||||
} // namespace hlsl
|
||||
|
||||
|
|
|
@ -41,35 +41,38 @@ enum RuntimeDataVersion {
|
|||
};
|
||||
|
||||
enum class RuntimeDataGroup : uint32_t {
|
||||
Core = 0,
|
||||
Core = 0,
|
||||
PdbInfo = 1,
|
||||
};
|
||||
|
||||
constexpr uint32_t RDAT_PART_ID_WITH_GROUP(RuntimeDataGroup group, uint32_t id) {
|
||||
return (((uint32_t)(group) << 16) | ((id) & 0xFFFF));
|
||||
constexpr uint32_t RDAT_PART_ID_WITH_GROUP(RuntimeDataGroup group,
|
||||
uint32_t id) {
|
||||
return (((uint32_t)(group) << 16) | ((id)&0xFFFF));
|
||||
}
|
||||
|
||||
enum class RuntimeDataPartType : uint32_t {
|
||||
Invalid = 0,
|
||||
StringBuffer = 1,
|
||||
IndexArrays = 2,
|
||||
ResourceTable = 3,
|
||||
FunctionTable = 4,
|
||||
Invalid = 0,
|
||||
StringBuffer = 1,
|
||||
IndexArrays = 2,
|
||||
ResourceTable = 3,
|
||||
FunctionTable = 4,
|
||||
Last_1_3 = FunctionTable,
|
||||
RawBytes = 5,
|
||||
SubobjectTable = 6,
|
||||
RawBytes = 5,
|
||||
SubobjectTable = 6,
|
||||
Last_1_4 = SubobjectTable,
|
||||
|
||||
LastPlus1,
|
||||
LastExperimental = LastPlus1 - 1,
|
||||
|
||||
DxilPdbInfoTable = RDAT_PART_ID_WITH_GROUP(RuntimeDataGroup::PdbInfo, 1),
|
||||
DxilPdbInfoSourceTable = RDAT_PART_ID_WITH_GROUP(RuntimeDataGroup::PdbInfo, 2),
|
||||
DxilPdbInfoLibraryTable = RDAT_PART_ID_WITH_GROUP(RuntimeDataGroup::PdbInfo, 3),
|
||||
DxilPdbInfoTable = RDAT_PART_ID_WITH_GROUP(RuntimeDataGroup::PdbInfo, 1),
|
||||
DxilPdbInfoSourceTable =
|
||||
RDAT_PART_ID_WITH_GROUP(RuntimeDataGroup::PdbInfo, 2),
|
||||
DxilPdbInfoLibraryTable =
|
||||
RDAT_PART_ID_WITH_GROUP(RuntimeDataGroup::PdbInfo, 3),
|
||||
};
|
||||
|
||||
inline
|
||||
RuntimeDataPartType MaxPartTypeForValVer(unsigned Major, unsigned Minor) {
|
||||
inline RuntimeDataPartType MaxPartTypeForValVer(unsigned Major,
|
||||
unsigned Minor) {
|
||||
return DXIL::CompareVersions(Major, Minor, 1, 3) < 0
|
||||
? RuntimeDataPartType::Invalid // No RDAT before 1.3
|
||||
: DXIL::CompareVersions(Major, Minor, 1, 4) < 0
|
||||
|
@ -104,7 +107,7 @@ struct RuntimeDataHeader {
|
|||
};
|
||||
struct RuntimeDataPartHeader {
|
||||
RuntimeDataPartType Type;
|
||||
uint32_t Size; // Not including this header. Must be 4-byte aligned.
|
||||
uint32_t Size; // Not including this header. Must be 4-byte aligned.
|
||||
// Followed by part data
|
||||
// byte Data[ALIGN4(Size)];
|
||||
};
|
||||
|
@ -113,7 +116,7 @@ struct RuntimeDataPartHeader {
|
|||
// Stride allows for extending records, with forward and backward compatibility
|
||||
struct RuntimeDataTableHeader {
|
||||
uint32_t RecordCount;
|
||||
uint32_t RecordStride; // Must be 4-byte aligned.
|
||||
uint32_t RecordStride; // Must be 4-byte aligned.
|
||||
// Followed by recordCount records of recordStride size
|
||||
// byte TableData[RecordCount * RecordStride];
|
||||
};
|
||||
|
@ -131,17 +134,19 @@ class TableReader {
|
|||
public:
|
||||
TableReader() : TableReader(nullptr, 0, 0) {}
|
||||
TableReader(const char *table, uint32_t count, uint32_t stride)
|
||||
: m_table(table), m_count(count), m_stride(stride) {}
|
||||
: m_table(table), m_count(count), m_stride(stride) {}
|
||||
void Init(const char *table, uint32_t count, uint32_t stride) {
|
||||
m_table = table; m_count = count; m_stride = stride;
|
||||
m_table = table;
|
||||
m_count = count;
|
||||
m_stride = stride;
|
||||
}
|
||||
const char *Data() const { return m_table; }
|
||||
uint32_t Count() const { return m_count; }
|
||||
uint32_t Stride() const { return m_stride; }
|
||||
|
||||
template<typename T> const T *Row(uint32_t index) const {
|
||||
template <typename T> const T *Row(uint32_t index) const {
|
||||
if (Valid() && index < m_count && sizeof(T) <= m_stride)
|
||||
return reinterpret_cast<const T*>(m_table + (m_stride * index));
|
||||
return reinterpret_cast<const T *>(m_table + (m_stride * index));
|
||||
return nullptr;
|
||||
}
|
||||
bool Valid() const { return m_table && m_count && m_stride; }
|
||||
|
@ -180,9 +185,10 @@ public:
|
|||
|
||||
IndexTableReader() : IndexTableReader(nullptr, 0) {}
|
||||
IndexTableReader(const uint32_t *table, uint32_t size)
|
||||
: m_table(table), m_size(size) {}
|
||||
: m_table(table), m_size(size) {}
|
||||
void Init(const uint32_t *table, uint32_t size) {
|
||||
m_table = table; m_size = size;
|
||||
m_table = table;
|
||||
m_size = size;
|
||||
}
|
||||
IndexRow getRow(uint32_t i) const {
|
||||
if (Valid() && i < m_size - 1 && m_table[i] + i < m_size) {
|
||||
|
@ -199,6 +205,7 @@ public:
|
|||
class StringTableReader {
|
||||
const char *m_table = nullptr;
|
||||
uint32_t m_size = 0;
|
||||
|
||||
public:
|
||||
void Init(const char *table, uint32_t size) {
|
||||
m_table = table;
|
||||
|
@ -215,24 +222,25 @@ public:
|
|||
class RawBytesReader {
|
||||
const void *m_table;
|
||||
uint32_t m_size;
|
||||
|
||||
public:
|
||||
RawBytesReader(const void *table, uint32_t size)
|
||||
: m_table(table), m_size(size) {}
|
||||
RawBytesReader() : RawBytesReader(nullptr, 0) {}
|
||||
void Init(const void *table, uint32_t size) {
|
||||
m_table = table; m_size = size;
|
||||
m_table = table;
|
||||
m_size = size;
|
||||
}
|
||||
uint32_t Size() const { return m_size; }
|
||||
const void *Get(uint32_t offset) const {
|
||||
return (const void*)(((const char*)m_table) + offset);
|
||||
return (const void *)(((const char *)m_table) + offset);
|
||||
}
|
||||
};
|
||||
|
||||
///////////////////////////////////////
|
||||
// Record Traits
|
||||
|
||||
template<typename _T>
|
||||
class RecordTraits {
|
||||
template <typename _T> class RecordTraits {
|
||||
public:
|
||||
static constexpr const char *TypeName();
|
||||
|
||||
|
@ -242,10 +250,13 @@ public:
|
|||
// RDAT_STRUCT is being used in ref type, which requires the struct to have
|
||||
// a table and be defined with RDAT_STRUCT_TABLE instead.
|
||||
static constexpr RecordTableIndex TableIndex();
|
||||
|
||||
// RecordSize() is defined in order to allow for use of forward decl type in RecordRef
|
||||
|
||||
// RecordSize() is defined in order to allow for use of forward decl type in
|
||||
// RecordRef
|
||||
static constexpr size_t RecordSize() { return sizeof(_T); }
|
||||
static constexpr size_t MaxRecordSize() { return RecordTraits<_T>::DerivedRecordSize(); }
|
||||
static constexpr size_t MaxRecordSize() {
|
||||
return RecordTraits<_T>::DerivedRecordSize();
|
||||
}
|
||||
static constexpr size_t DerivedRecordSize() { return sizeof(_T); }
|
||||
};
|
||||
|
||||
|
@ -265,14 +276,16 @@ struct RDATContext {
|
|||
TableReader &Table(RecordTableIndex idx) {
|
||||
return const_cast<TableReader &>(((const RDATContext *)this)->Table(idx));
|
||||
}
|
||||
template<typename RecordType>
|
||||
const TableReader &Table() const {
|
||||
static_assert(RecordTraits<RecordType>::TableIndex() < RecordTableIndex::RecordTableCount, "");
|
||||
template <typename RecordType> const TableReader &Table() const {
|
||||
static_assert(RecordTraits<RecordType>::TableIndex() <
|
||||
RecordTableIndex::RecordTableCount,
|
||||
"");
|
||||
return Table(RecordTraits<RecordType>::TableIndex());
|
||||
}
|
||||
template<typename RecordType>
|
||||
TableReader &Table() {
|
||||
return const_cast<TableReader &>(((const RDATContext *)this)->Table(RecordTraits<RecordType>::TableIndex()));
|
||||
template <typename RecordType> TableReader &Table() {
|
||||
return const_cast<TableReader &>(
|
||||
((const RDATContext *)this)
|
||||
->Table(RecordTraits<RecordType>::TableIndex()));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -285,15 +298,14 @@ protected:
|
|||
const void *m_pRecord = nullptr;
|
||||
uint32_t m_Size = 0;
|
||||
|
||||
template<typename _ReaderTy>
|
||||
const _ReaderTy asReader() const {
|
||||
if (*this && m_Size >= RecordTraits<typename _ReaderTy::RecordType>::RecordSize())
|
||||
template <typename _ReaderTy> const _ReaderTy asReader() const {
|
||||
if (*this &&
|
||||
m_Size >= RecordTraits<typename _ReaderTy::RecordType>::RecordSize())
|
||||
return _ReaderTy(*this);
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename _T>
|
||||
const _T *asRecord() const {
|
||||
template <typename _T> const _T *asRecord() const {
|
||||
return static_cast<const _T *>(
|
||||
(*this && m_Size >= RecordTraits<_T>::RecordSize()) ? m_pRecord
|
||||
: nullptr);
|
||||
|
@ -307,7 +319,7 @@ protected:
|
|||
|
||||
public:
|
||||
BaseRecordReader(const RDATContext *ctx, const void *record, uint32_t size)
|
||||
: m_pContext(ctx), m_pRecord(record), m_Size(size) {}
|
||||
: m_pContext(ctx), m_pRecord(record), m_Size(size) {}
|
||||
BaseRecordReader() : BaseRecordReader(nullptr, nullptr, 0) {}
|
||||
|
||||
// Is this a valid reader
|
||||
|
@ -317,10 +329,10 @@ public:
|
|||
const RDATContext *GetContext() const { return m_pContext; }
|
||||
};
|
||||
|
||||
template<typename _ReaderTy>
|
||||
class RecordArrayReader {
|
||||
template <typename _ReaderTy> class RecordArrayReader {
|
||||
const RDATContext *m_pContext;
|
||||
const uint32_t m_IndexOffset;
|
||||
|
||||
public:
|
||||
RecordArrayReader(const RDATContext *ctx, uint32_t indexOffset)
|
||||
: m_pContext(ctx), m_IndexOffset(indexOffset) {
|
||||
|
@ -358,9 +370,10 @@ public:
|
|||
class StringArrayReader {
|
||||
const RDATContext *m_pContext;
|
||||
const uint32_t m_IndexOffset;
|
||||
|
||||
public:
|
||||
StringArrayReader(const RDATContext *pContext, uint32_t indexOffset)
|
||||
: m_pContext(pContext), m_IndexOffset(indexOffset) {}
|
||||
: m_pContext(pContext), m_IndexOffset(indexOffset) {}
|
||||
uint32_t Count() const {
|
||||
return *this ? m_pContext->IndexTable.getRow(m_IndexOffset).Count() : 0;
|
||||
}
|
||||
|
@ -380,31 +393,35 @@ public:
|
|||
///////////////////////////////////////
|
||||
// Field Helpers
|
||||
|
||||
template<typename _T>
|
||||
struct RecordRef {
|
||||
template <typename _T> struct RecordRef {
|
||||
uint32_t Index;
|
||||
|
||||
template<typename RecordType = _T>
|
||||
template <typename RecordType = _T>
|
||||
const _T *Get(const RDATContext &ctx) const {
|
||||
return ctx.Table<_T>(). template Row<RecordType>(Index);
|
||||
return ctx.Table<_T>().template Row<RecordType>(Index);
|
||||
}
|
||||
RecordRef &operator =(uint32_t index) { Index = index; return *this; }
|
||||
operator uint32_t&() { return Index; }
|
||||
operator const uint32_t&() const { return Index; }
|
||||
uint32_t *operator &() { return &Index; }
|
||||
RecordRef &operator=(uint32_t index) {
|
||||
Index = index;
|
||||
return *this;
|
||||
}
|
||||
operator uint32_t &() { return Index; }
|
||||
operator const uint32_t &() const { return Index; }
|
||||
uint32_t *operator&() { return &Index; }
|
||||
};
|
||||
|
||||
template<typename _T>
|
||||
struct RecordArrayRef {
|
||||
template <typename _T> struct RecordArrayRef {
|
||||
uint32_t Index;
|
||||
|
||||
RecordArrayReader<_T> Get(const RDATContext &ctx) const {
|
||||
return RecordArrayReader<_T>(ctx.IndexTable, ctx.Table<_T>(), Index);
|
||||
}
|
||||
RecordArrayRef &operator =(uint32_t index) { Index = index; return *this; }
|
||||
operator uint32_t&() { return Index; }
|
||||
operator const uint32_t&() const { return Index; }
|
||||
uint32_t *operator &() { return &Index; }
|
||||
RecordArrayRef &operator=(uint32_t index) {
|
||||
Index = index;
|
||||
return *this;
|
||||
}
|
||||
operator uint32_t &() { return Index; }
|
||||
operator const uint32_t &() const { return Index; }
|
||||
uint32_t *operator&() { return &Index; }
|
||||
};
|
||||
|
||||
struct RDATString {
|
||||
|
@ -413,10 +430,13 @@ struct RDATString {
|
|||
const char *Get(const RDATContext &ctx) const {
|
||||
return ctx.StringBuffer.Get(Offset);
|
||||
}
|
||||
RDATString &operator =(uint32_t offset) { Offset = offset; return *this; }
|
||||
operator uint32_t&() { return Offset; }
|
||||
operator const uint32_t&() const { return Offset; }
|
||||
uint32_t *operator &() { return &Offset; }
|
||||
RDATString &operator=(uint32_t offset) {
|
||||
Offset = offset;
|
||||
return *this;
|
||||
}
|
||||
operator uint32_t &() { return Offset; }
|
||||
operator const uint32_t &() const { return Offset; }
|
||||
uint32_t *operator&() { return &Offset; }
|
||||
};
|
||||
|
||||
struct RDATStringArray {
|
||||
|
@ -426,10 +446,13 @@ struct RDATStringArray {
|
|||
return StringArrayReader(&ctx, Index);
|
||||
}
|
||||
operator bool() const { return Index == 0 ? false : true; }
|
||||
RDATStringArray &operator =(uint32_t index) { Index = index; return *this; }
|
||||
operator uint32_t&() { return Index; }
|
||||
operator const uint32_t&() const { return Index; }
|
||||
uint32_t *operator &() { return &Index; }
|
||||
RDATStringArray &operator=(uint32_t index) {
|
||||
Index = index;
|
||||
return *this;
|
||||
}
|
||||
operator uint32_t &() { return Index; }
|
||||
operator const uint32_t &() const { return Index; }
|
||||
uint32_t *operator&() { return &Index; }
|
||||
};
|
||||
|
||||
struct IndexArrayRef {
|
||||
|
@ -438,10 +461,13 @@ struct IndexArrayRef {
|
|||
IndexTableReader::IndexRow Get(const RDATContext &ctx) const {
|
||||
return ctx.IndexTable.getRow(Index);
|
||||
}
|
||||
IndexArrayRef &operator =(uint32_t index) { Index = index; return *this; }
|
||||
operator uint32_t&() { return Index; }
|
||||
operator const uint32_t&() const { return Index; }
|
||||
uint32_t *operator &() { return &Index; }
|
||||
IndexArrayRef &operator=(uint32_t index) {
|
||||
Index = index;
|
||||
return *this;
|
||||
}
|
||||
operator uint32_t &() { return Index; }
|
||||
operator const uint32_t &() const { return Index; }
|
||||
uint32_t *operator&() { return &Index; }
|
||||
};
|
||||
|
||||
struct BytesRef {
|
||||
|
@ -451,71 +477,73 @@ struct BytesRef {
|
|||
const void *GetBytes(const RDATContext &ctx) const {
|
||||
return ctx.RawBytes.Get(Offset);
|
||||
}
|
||||
template<typename _T>
|
||||
const _T *GetAs(const RDATContext &ctx) const {
|
||||
return (sizeof(_T) > Size) ? nullptr :
|
||||
reinterpret_cast<const _T*>(ctx.RawBytes.Get(Offset));
|
||||
template <typename _T> const _T *GetAs(const RDATContext &ctx) const {
|
||||
return (sizeof(_T) > Size)
|
||||
? nullptr
|
||||
: reinterpret_cast<const _T *>(ctx.RawBytes.Get(Offset));
|
||||
}
|
||||
uint32_t *operator &() { return &Offset; }
|
||||
uint32_t *operator&() { return &Offset; }
|
||||
};
|
||||
|
||||
struct BytesPtr {
|
||||
const void *Ptr = nullptr;
|
||||
uint32_t Size = 0;
|
||||
|
||||
BytesPtr(const void *ptr, uint32_t size) :
|
||||
Ptr(ptr), Size(size) {}
|
||||
BytesPtr(const void *ptr, uint32_t size) : Ptr(ptr), Size(size) {}
|
||||
BytesPtr() : BytesPtr(nullptr, 0) {}
|
||||
template<typename _T>
|
||||
const _T *GetAs() const {
|
||||
return (sizeof(_T) > Size) ? nullptr : reinterpret_cast<const _T*>(Ptr);
|
||||
template <typename _T> const _T *GetAs() const {
|
||||
return (sizeof(_T) > Size) ? nullptr : reinterpret_cast<const _T *>(Ptr);
|
||||
}
|
||||
};
|
||||
|
||||
///////////////////////////////////////
|
||||
// Record Helpers
|
||||
|
||||
template<typename _RecordReader>
|
||||
class RecordReader : public BaseRecordReader {
|
||||
template <typename _RecordReader> class RecordReader : public BaseRecordReader {
|
||||
public:
|
||||
typedef _RecordReader ThisReaderType;
|
||||
RecordReader(const BaseRecordReader &base) : BaseRecordReader(base) {
|
||||
typedef typename _RecordReader::RecordType RecordType;
|
||||
if ((m_pContext || m_pRecord) && m_Size < RecordTraits<RecordType>::RecordSize())
|
||||
if ((m_pContext || m_pRecord) &&
|
||||
m_Size < RecordTraits<RecordType>::RecordSize())
|
||||
InvalidateReader();
|
||||
}
|
||||
RecordReader() : BaseRecordReader() {}
|
||||
template<typename _ReaderType> _ReaderType as() { _ReaderType(*this); }
|
||||
template <typename _ReaderType> _ReaderType as() { _ReaderType(*this); }
|
||||
|
||||
protected:
|
||||
template<typename _FieldRecordReader>
|
||||
template <typename _FieldRecordReader>
|
||||
_FieldRecordReader GetField_RecordValue(const void *pField) const {
|
||||
if (*this) {
|
||||
return _FieldRecordReader(BaseRecordReader(
|
||||
m_pContext, pField, (uint32_t)RecordTraits<typename _FieldRecordReader::RecordType>::RecordSize()));
|
||||
m_pContext, pField,
|
||||
(uint32_t)RecordTraits<
|
||||
typename _FieldRecordReader::RecordType>::RecordSize()));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
template<typename _FieldRecordReader>
|
||||
template <typename _FieldRecordReader>
|
||||
_FieldRecordReader GetField_RecordRef(const void *pIndex) const {
|
||||
typedef typename _FieldRecordReader::RecordType RecordType;
|
||||
if (*this) {
|
||||
const TableReader &Table = m_pContext->Table<RecordType>();
|
||||
return _FieldRecordReader(BaseRecordReader(
|
||||
m_pContext, (const void *)Table.Row<RecordType>(*(const uint32_t*)pIndex),
|
||||
m_pContext,
|
||||
(const void *)Table.Row<RecordType>(*(const uint32_t *)pIndex),
|
||||
Table.Stride()));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
template<typename _FieldRecordReader>
|
||||
RecordArrayReader<_FieldRecordReader> GetField_RecordArrayRef(const void *pIndex) const {
|
||||
template <typename _FieldRecordReader>
|
||||
RecordArrayReader<_FieldRecordReader>
|
||||
GetField_RecordArrayRef(const void *pIndex) const {
|
||||
if (*this) {
|
||||
return RecordArrayReader<_FieldRecordReader>(m_pContext,
|
||||
*(const uint32_t *)pIndex);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
template<typename _T, typename _StorageTy>
|
||||
template <typename _T, typename _StorageTy>
|
||||
_T GetField_Value(const _StorageTy *value) const {
|
||||
_T result = {};
|
||||
if (*this)
|
||||
|
@ -530,34 +558,36 @@ protected:
|
|||
}
|
||||
// Would use std::array, but don't want this header dependent on that.
|
||||
// Array reference syntax is almost enough reason to abandon C++!!!
|
||||
template<typename _T, size_t _ArraySize>
|
||||
decltype(auto) GetField_ValueArray(_T const(&value)[_ArraySize])const {
|
||||
template <typename _T, size_t _ArraySize>
|
||||
decltype(auto) GetField_ValueArray(_T const (&value)[_ArraySize]) const {
|
||||
typedef _T ArrayType[_ArraySize];
|
||||
if (*this)
|
||||
return value;
|
||||
return *(const ArrayType*)nullptr;
|
||||
return *(const ArrayType *)nullptr;
|
||||
}
|
||||
const char *GetField_String(const void *pIndex) const {
|
||||
return *this ? m_pContext->StringBuffer.Get(*(const uint32_t*)pIndex) : nullptr;
|
||||
return *this ? m_pContext->StringBuffer.Get(*(const uint32_t *)pIndex)
|
||||
: nullptr;
|
||||
}
|
||||
StringArrayReader GetField_StringArray(const void *pIndex) const {
|
||||
return *this ? StringArrayReader(m_pContext, *(const uint32_t *)pIndex)
|
||||
: StringArrayReader(nullptr, 0);
|
||||
}
|
||||
const void *GetField_Bytes(const void *pIndex) const {
|
||||
return *this ? m_pContext->RawBytes.Get(*(const uint32_t*)pIndex) : nullptr;
|
||||
return *this ? m_pContext->RawBytes.Get(*(const uint32_t *)pIndex)
|
||||
: nullptr;
|
||||
}
|
||||
uint32_t GetField_BytesSize(const void *pIndex) const {
|
||||
return *this ? *(((const uint32_t*)pIndex) + 1) : 0;
|
||||
return *this ? *(((const uint32_t *)pIndex) + 1) : 0;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename _RecordReader>
|
||||
class RecordTableReader {
|
||||
template <typename _RecordReader> class RecordTableReader {
|
||||
const RDATContext *m_pContext;
|
||||
|
||||
public:
|
||||
RecordTableReader(const RDATContext *pContext) : m_pContext(pContext) {}
|
||||
template<typename RecordReaderType = _RecordReader>
|
||||
template <typename RecordReaderType = _RecordReader>
|
||||
RecordReaderType Row(uint32_t index) const {
|
||||
typedef typename _RecordReader::RecordType RecordType;
|
||||
const TableReader &Table = m_pContext->Table<RecordType>();
|
||||
|
@ -572,7 +602,6 @@ public:
|
|||
operator bool() { return m_pContext && Count(); }
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// All RDAT enums and types
|
||||
|
||||
|
@ -617,10 +646,8 @@ public:
|
|||
}
|
||||
#define DEF_RDAT_TYPES DEF_RDAT_DEFAULTS
|
||||
#include "dxc/DxilContainer/RDAT_Macros.inl"
|
||||
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////
|
||||
/// structures for library runtime
|
||||
|
||||
|
@ -645,8 +672,8 @@ struct DxilFunctionDesc {
|
|||
DxilResourceDescPtrArray Resources;
|
||||
const wchar_t *const *FunctionDependencies;
|
||||
DXIL::ShaderKind ShaderKind;
|
||||
uint32_t PayloadSizeInBytes; // 1) hit, miss, or closest shader: payload count
|
||||
// 2) call shader: parameter size
|
||||
uint32_t PayloadSizeInBytes; // 1) hit, miss, or closest shader: payload count
|
||||
// 2) call shader: parameter size
|
||||
uint32_t AttributeSizeInBytes; // attribute size for closest hit and any hit
|
||||
uint32_t FeatureInfo1; // first 32 bits of feature flag
|
||||
uint32_t FeatureInfo2; // second 32 bits of feature flag
|
||||
|
@ -656,15 +683,15 @@ struct DxilFunctionDesc {
|
|||
|
||||
struct DxilSubobjectDesc {
|
||||
const wchar_t *Name;
|
||||
DXIL::SubobjectKind Kind; // D3D12_STATE_SUBOBJECT_TYPE
|
||||
DXIL::SubobjectKind Kind; // D3D12_STATE_SUBOBJECT_TYPE
|
||||
|
||||
struct StateObjectConfig_t {
|
||||
uint32_t Flags; // DXIL::StateObjectFlags / D3D12_STATE_OBJECT_FLAGS
|
||||
uint32_t Flags; // DXIL::StateObjectFlags / D3D12_STATE_OBJECT_FLAGS
|
||||
};
|
||||
struct RootSignature_t {
|
||||
const void *pSerializedSignature;
|
||||
uint32_t SizeInBytes;
|
||||
}; // GlobalRootSignature or LocalRootSignature
|
||||
}; // GlobalRootSignature or LocalRootSignature
|
||||
struct SubobjectToExportsAssociation_t {
|
||||
const wchar_t *Subobject;
|
||||
uint32_t NumExports;
|
||||
|
@ -678,7 +705,7 @@ struct DxilSubobjectDesc {
|
|||
uint32_t MaxTraceRecursionDepth;
|
||||
};
|
||||
struct HitGroup_t {
|
||||
DXIL::HitGroupType Type; // D3D12_HIT_GROUP_TYPE
|
||||
DXIL::HitGroupType Type; // D3D12_HIT_GROUP_TYPE
|
||||
const wchar_t *AnyHit;
|
||||
const wchar_t *ClosestHit;
|
||||
const wchar_t *Intersection;
|
||||
|
@ -686,12 +713,13 @@ struct DxilSubobjectDesc {
|
|||
|
||||
struct RaytracingPipelineConfig1_t {
|
||||
uint32_t MaxTraceRecursionDepth;
|
||||
uint32_t Flags; // DXIL::RaytracingPipelineFlags / D3D12_RAYTRACING_PIPELINE_FLAGS
|
||||
uint32_t Flags; // DXIL::RaytracingPipelineFlags /
|
||||
// D3D12_RAYTRACING_PIPELINE_FLAGS
|
||||
};
|
||||
|
||||
union {
|
||||
StateObjectConfig_t StateObjectConfig;
|
||||
RootSignature_t RootSignature; // GlobalRootSignature or LocalRootSignature
|
||||
RootSignature_t RootSignature; // GlobalRootSignature or LocalRootSignature
|
||||
SubobjectToExportsAssociation_t SubobjectToExportsAssociation;
|
||||
RaytracingShaderConfig_t RaytracingShaderConfig;
|
||||
RaytracingPipelineConfig_t RaytracingPipelineConfig;
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "dxc/DxilContainer/DxilRuntimeReflection.h"
|
||||
#include <cwchar>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <cwchar>
|
||||
|
||||
namespace hlsl {
|
||||
namespace RDAT {
|
||||
|
@ -24,7 +24,7 @@ namespace RDAT {
|
|||
struct ResourceKey {
|
||||
uint32_t Class, ID;
|
||||
ResourceKey(uint32_t Class, uint32_t ID) : Class(Class), ID(ID) {}
|
||||
bool operator==(const ResourceKey& other) const {
|
||||
bool operator==(const ResourceKey &other) const {
|
||||
return other.Class == Class && other.ID == ID;
|
||||
}
|
||||
};
|
||||
|
@ -42,28 +42,31 @@ public:
|
|||
class buffer_overrun : public exception {
|
||||
public:
|
||||
buffer_overrun() noexcept {}
|
||||
virtual const char * what() const noexcept override {
|
||||
virtual const char *what() const noexcept override {
|
||||
return ("buffer_overrun");
|
||||
}
|
||||
};
|
||||
class buffer_overlap : public exception {
|
||||
public:
|
||||
buffer_overlap() noexcept {}
|
||||
virtual const char * what() const noexcept override {
|
||||
virtual const char *what() const noexcept override {
|
||||
return ("buffer_overlap");
|
||||
}
|
||||
};
|
||||
|
||||
CheckedReader(const void *ptr, size_t size) :
|
||||
Ptr(reinterpret_cast<const char*>(ptr)), Size(size), Offset(0) {}
|
||||
CheckedReader(const void *ptr, size_t size)
|
||||
: Ptr(reinterpret_cast<const char *>(ptr)), Size(size), Offset(0) {}
|
||||
void Reset(size_t offset = 0) {
|
||||
if (offset >= Size) throw buffer_overrun{};
|
||||
if (offset >= Size)
|
||||
throw buffer_overrun{};
|
||||
Offset = offset;
|
||||
}
|
||||
// offset is absolute, ensure offset is >= current offset
|
||||
void Advance(size_t offset = 0) {
|
||||
if (offset < Offset) throw buffer_overlap{};
|
||||
if (offset >= Size) throw buffer_overrun{};
|
||||
if (offset < Offset)
|
||||
throw buffer_overlap{};
|
||||
if (offset >= Size)
|
||||
throw buffer_overrun{};
|
||||
Offset = offset;
|
||||
}
|
||||
void CheckBounds(size_t size) const {
|
||||
|
@ -71,23 +74,21 @@ public:
|
|||
if (size > Size - Offset)
|
||||
throw buffer_overrun{};
|
||||
}
|
||||
template <typename T>
|
||||
const T *Cast(size_t size = 0) {
|
||||
if (0 == size) size = sizeof(T);
|
||||
template <typename T> const T *Cast(size_t size = 0) {
|
||||
if (0 == size)
|
||||
size = sizeof(T);
|
||||
CheckBounds(size);
|
||||
return reinterpret_cast<const T*>(Ptr + Offset);
|
||||
return reinterpret_cast<const T *>(Ptr + Offset);
|
||||
}
|
||||
template <typename T>
|
||||
const T &Read() {
|
||||
template <typename T> const T &Read() {
|
||||
const size_t size = sizeof(T);
|
||||
const T* p = Cast<T>(size);
|
||||
const T *p = Cast<T>(size);
|
||||
Offset += size;
|
||||
return *p;
|
||||
}
|
||||
template <typename T>
|
||||
const T *ReadArray(size_t count = 1) {
|
||||
template <typename T> const T *ReadArray(size_t count = 1) {
|
||||
const size_t size = sizeof(T) * count;
|
||||
const T* p = Cast<T>(size);
|
||||
const T *p = Cast<T>(size);
|
||||
Offset += size;
|
||||
return p;
|
||||
}
|
||||
|
@ -99,7 +100,8 @@ DxilRuntimeData::DxilRuntimeData(const void *ptr, size_t size) {
|
|||
InitFromRDAT(ptr, size);
|
||||
}
|
||||
|
||||
static void InitTable(RDATContext &ctx, CheckedReader &PR, RecordTableIndex tableIndex) {
|
||||
static void InitTable(RDATContext &ctx, CheckedReader &PR,
|
||||
RecordTableIndex tableIndex) {
|
||||
RuntimeDataTableHeader table = PR.Read<RuntimeDataTableHeader>();
|
||||
size_t tableSize = table.RecordCount * table.RecordStride;
|
||||
ctx.Table(tableIndex)
|
||||
|
@ -117,7 +119,8 @@ bool DxilRuntimeData::InitFromRDAT(const void *pRDAT, size_t size) {
|
|||
if (RDATHeader.Version < RDAT_Version_10) {
|
||||
return false;
|
||||
}
|
||||
const uint32_t *offsets = Reader.ReadArray<uint32_t>(RDATHeader.PartCount);
|
||||
const uint32_t *offsets =
|
||||
Reader.ReadArray<uint32_t>(RDATHeader.PartCount);
|
||||
for (uint32_t i = 0; i < RDATHeader.PartCount; ++i) {
|
||||
Reader.Advance(offsets[i]);
|
||||
RuntimeDataPartHeader part = Reader.Read<RuntimeDataPartHeader>();
|
||||
|
@ -138,7 +141,10 @@ bool DxilRuntimeData::InitFromRDAT(const void *pRDAT, size_t size) {
|
|||
}
|
||||
|
||||
// Once per table.
|
||||
#define RDAT_STRUCT_TABLE(type, table) case RuntimeDataPartType::table: InitTable(m_Context, PR, RecordTableIndex::table); break;
|
||||
#define RDAT_STRUCT_TABLE(type, table) \
|
||||
case RuntimeDataPartType::table: \
|
||||
InitTable(m_Context, PR, RecordTableIndex::table); \
|
||||
break;
|
||||
#define DEF_RDAT_TYPES DEF_RDAT_DEFAULTS
|
||||
#include "dxc/DxilContainer/RDAT_Macros.inl"
|
||||
|
||||
|
@ -151,9 +157,9 @@ bool DxilRuntimeData::InitFromRDAT(const void *pRDAT, size_t size) {
|
|||
#else // NDEBUG
|
||||
return true;
|
||||
#endif // NDEBUG
|
||||
} catch(CheckedReader::exception e) {
|
||||
} catch (CheckedReader::exception e) {
|
||||
// TODO: error handling
|
||||
//throw hlsl::Exception(DXC_E_MALFORMED_CONTAINER, e.what());
|
||||
// throw hlsl::Exception(DXC_E_MALFORMED_CONTAINER, e.what());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -166,7 +172,7 @@ bool DxilRuntimeData::InitFromRDAT(const void *pRDAT, size_t size) {
|
|||
// PRERELEASE-TODO: Low-pri: Check other things like that all the index, string,
|
||||
// and binary buffer space is actually used.
|
||||
|
||||
template<typename _RecordType>
|
||||
template <typename _RecordType>
|
||||
static bool ValidateRecordRef(const RDATContext &ctx, uint32_t id) {
|
||||
if (id == RDAT_NULL_REF)
|
||||
return true;
|
||||
|
@ -190,7 +196,7 @@ static bool ValidateIndexArrayRef(const RDATContext &ctx, uint32_t id) {
|
|||
return true;
|
||||
}
|
||||
|
||||
template<typename _RecordType>
|
||||
template <typename _RecordType>
|
||||
static bool ValidateRecordArrayRef(const RDATContext &ctx, uint32_t id) {
|
||||
// Make sure index array is well-formed
|
||||
if (!ValidateIndexArrayRef(ctx, id))
|
||||
|
@ -227,7 +233,7 @@ static bool ValidateStringArrayRef(const RDATContext &ctx, uint32_t id) {
|
|||
}
|
||||
|
||||
// Specialized for each record type
|
||||
template<typename _RecordType>
|
||||
template <typename _RecordType>
|
||||
bool ValidateRecord(const RDATContext &ctx, const _RecordType *pRecord) {
|
||||
return false;
|
||||
}
|
||||
|
@ -240,10 +246,12 @@ bool ValidateRecord(const RDATContext &ctx, const _RecordType *pRecord) {
|
|||
class RecursiveRecordValidator {
|
||||
const hlsl::RDAT::RDATContext &m_Context;
|
||||
uint32_t m_RecordStride;
|
||||
|
||||
public:
|
||||
RecursiveRecordValidator(const hlsl::RDAT::RDATContext &ctx, uint32_t recordStride)
|
||||
RecursiveRecordValidator(const hlsl::RDAT::RDATContext &ctx,
|
||||
uint32_t recordStride)
|
||||
: m_Context(ctx), m_RecordStride(recordStride) {}
|
||||
template<typename _RecordType>
|
||||
template <typename _RecordType>
|
||||
bool Validate(const _RecordType *pRecord) const {
|
||||
if (pRecord && sizeof(_RecordType) <= m_RecordStride) {
|
||||
if (!ValidateRecord(m_Context, pRecord))
|
||||
|
@ -253,11 +261,13 @@ public:
|
|||
return true;
|
||||
}
|
||||
// Specialized for base type to recurse into derived
|
||||
template<typename _RecordType>
|
||||
bool ValidateDerived(const _RecordType *) const { return true; }
|
||||
template <typename _RecordType>
|
||||
bool ValidateDerived(const _RecordType *) const {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename _RecordType>
|
||||
template <typename _RecordType>
|
||||
static bool ValidateRecordTable(RDATContext &ctx, RecordTableIndex tableIndex) {
|
||||
// iterate through records, bounds-checking all refs and index arrays
|
||||
auto &table = ctx.Table(tableIndex);
|
||||
|
@ -275,7 +285,8 @@ bool DxilRuntimeData::Validate() {
|
|||
}
|
||||
|
||||
// Once per table.
|
||||
#define RDAT_STRUCT_TABLE(type, table) ValidateRecordTable<type>(m_Context, RecordTableIndex::table);
|
||||
#define RDAT_STRUCT_TABLE(type, table) \
|
||||
ValidateRecordTable<type>(m_Context, RecordTableIndex::table);
|
||||
// As an assumption of the way record types are versioned, derived record
|
||||
// types must always be larger than base record types.
|
||||
#define RDAT_STRUCT_DERIVED(type, base) \
|
||||
|
@ -287,7 +298,8 @@ bool DxilRuntimeData::Validate() {
|
|||
return true;
|
||||
}
|
||||
|
||||
}} // hlsl::RDAT
|
||||
} // namespace RDAT
|
||||
} // namespace hlsl
|
||||
|
||||
using namespace hlsl;
|
||||
using namespace RDAT;
|
||||
|
@ -305,7 +317,8 @@ namespace {
|
|||
|
||||
class DxilRuntimeReflection_impl : public DxilRuntimeReflection {
|
||||
private:
|
||||
typedef std::unordered_map<const char *, std::unique_ptr<wchar_t[]>> StringMap;
|
||||
typedef std::unordered_map<const char *, std::unique_ptr<wchar_t[]>>
|
||||
StringMap;
|
||||
typedef std::unordered_map<const void *, std::unique_ptr<char[]>> BytesMap;
|
||||
typedef std::vector<const wchar_t *> WStringList;
|
||||
typedef std::vector<DxilResourceDesc> ResourceList;
|
||||
|
@ -330,12 +343,15 @@ private:
|
|||
void AddString(const char *ptr);
|
||||
const void *GetBytes(const void *ptr, size_t size);
|
||||
void InitializeReflection();
|
||||
const DxilResourceDesc * const*GetResourcesForFunction(DxilFunctionDesc &function,
|
||||
const RuntimeDataFunctionInfo_Reader &functionReader);
|
||||
const wchar_t **GetDependenciesForFunction(DxilFunctionDesc &function,
|
||||
const RuntimeDataFunctionInfo_Reader &functionReader);
|
||||
const wchar_t **GetExportsForAssociation(DxilSubobjectDesc &subobject,
|
||||
const RuntimeDataSubobjectInfo_Reader &reader);
|
||||
const DxilResourceDesc *const *
|
||||
GetResourcesForFunction(DxilFunctionDesc &function,
|
||||
const RuntimeDataFunctionInfo_Reader &functionReader);
|
||||
const wchar_t **GetDependenciesForFunction(
|
||||
DxilFunctionDesc &function,
|
||||
const RuntimeDataFunctionInfo_Reader &functionReader);
|
||||
const wchar_t **
|
||||
GetExportsForAssociation(DxilSubobjectDesc &subobject,
|
||||
const RuntimeDataSubobjectInfo_Reader &reader);
|
||||
void AddResources();
|
||||
void AddFunctions();
|
||||
void AddSubobjects();
|
||||
|
@ -344,9 +360,9 @@ public:
|
|||
// TODO: Implement pipeline state validation with runtime data
|
||||
// TODO: Update BlobContainer.h to recognize 'RDAT' blob
|
||||
DxilRuntimeReflection_impl()
|
||||
: m_RuntimeData(), m_StringMap(), m_BytesMap(), m_Resources(), m_Functions(),
|
||||
m_FuncToResMap(), m_FuncToDependenciesMap(), m_SubobjectToExportsMap(),
|
||||
m_initialized(false) {}
|
||||
: m_RuntimeData(), m_StringMap(), m_BytesMap(), m_Resources(),
|
||||
m_Functions(), m_FuncToResMap(), m_FuncToDependenciesMap(),
|
||||
m_SubobjectToExportsMap(), m_initialized(false) {}
|
||||
virtual ~DxilRuntimeReflection_impl() {}
|
||||
// This call will allocate memory for GetLibraryReflection call
|
||||
bool InitFromRDAT(const void *pRDAT, size_t size) override;
|
||||
|
@ -381,7 +397,8 @@ const void *DxilRuntimeReflection_impl::GetBytes(const void *ptr, size_t size) {
|
|||
if (it != m_BytesMap.end())
|
||||
return it->second.get();
|
||||
|
||||
auto inserted = m_BytesMap.insert(std::make_pair(ptr, std::unique_ptr<char[]>(new char[size])));
|
||||
auto inserted = m_BytesMap.insert(
|
||||
std::make_pair(ptr, std::unique_ptr<char[]>(new char[size])));
|
||||
void *newPtr = inserted.first->second.get();
|
||||
memcpy(newPtr, ptr, size);
|
||||
return newPtr;
|
||||
|
@ -440,8 +457,10 @@ void DxilRuntimeReflection_impl::AddResources() {
|
|||
}
|
||||
}
|
||||
|
||||
const DxilResourceDesc * const*DxilRuntimeReflection_impl::GetResourcesForFunction(
|
||||
DxilFunctionDesc &function, const RuntimeDataFunctionInfo_Reader &functionReader) {
|
||||
const DxilResourceDesc *const *
|
||||
DxilRuntimeReflection_impl::GetResourcesForFunction(
|
||||
DxilFunctionDesc &function,
|
||||
const RuntimeDataFunctionInfo_Reader &functionReader) {
|
||||
auto resources = functionReader.getResources();
|
||||
if (!resources.Count())
|
||||
return nullptr;
|
||||
|
@ -454,15 +473,18 @@ const DxilResourceDesc * const*DxilRuntimeReflection_impl::GetResourcesForFuncti
|
|||
ResourceKey key((uint32_t)resourceReader.getClass(),
|
||||
resourceReader.getID());
|
||||
auto it = m_ResourceMap.find(key);
|
||||
assert(it != m_ResourceMap.end() && it->second && "Otherwise, resource was not in map, or was null");
|
||||
assert(it != m_ResourceMap.end() && it->second &&
|
||||
"Otherwise, resource was not in map, or was null");
|
||||
resourceList.emplace_back(it->second);
|
||||
}
|
||||
return resourceList.data();
|
||||
}
|
||||
|
||||
const wchar_t **DxilRuntimeReflection_impl::GetDependenciesForFunction(
|
||||
DxilFunctionDesc &function, const RuntimeDataFunctionInfo_Reader &functionReader) {
|
||||
auto it = m_FuncToDependenciesMap.insert(std::make_pair(&function, WStringList()));
|
||||
DxilFunctionDesc &function,
|
||||
const RuntimeDataFunctionInfo_Reader &functionReader) {
|
||||
auto it =
|
||||
m_FuncToDependenciesMap.insert(std::make_pair(&function, WStringList()));
|
||||
assert(it.second && "otherwise, collision");
|
||||
WStringList &wStringList = it.first->second;
|
||||
auto dependencies = functionReader.getFunctionDependencies();
|
||||
|
@ -495,8 +517,10 @@ void DxilRuntimeReflection_impl::AddFunctions() {
|
|||
}
|
||||
|
||||
const wchar_t **DxilRuntimeReflection_impl::GetExportsForAssociation(
|
||||
DxilSubobjectDesc &subobject, const RuntimeDataSubobjectInfo_Reader &reader) {
|
||||
auto it = m_SubobjectToExportsMap.insert(std::make_pair(&subobject, WStringList()));
|
||||
DxilSubobjectDesc &subobject,
|
||||
const RuntimeDataSubobjectInfo_Reader &reader) {
|
||||
auto it =
|
||||
m_SubobjectToExportsMap.insert(std::make_pair(&subobject, WStringList()));
|
||||
assert(it.second && "otherwise, collision");
|
||||
auto exports = reader.getSubobjectToExportsAssociation().getExports();
|
||||
WStringList &wStringList = it.first->second;
|
||||
|
@ -521,30 +545,40 @@ void DxilRuntimeReflection_impl::AddSubobjects() {
|
|||
case DXIL::SubobjectKind::GlobalRootSignature:
|
||||
case DXIL::SubobjectKind::LocalRootSignature:
|
||||
desc.RootSignature.SizeInBytes = reader.getRootSignature().sizeData();
|
||||
desc.RootSignature.pSerializedSignature = GetBytes(reader.getRootSignature().getData(), desc.RootSignature.SizeInBytes);
|
||||
desc.RootSignature.pSerializedSignature = GetBytes(
|
||||
reader.getRootSignature().getData(), desc.RootSignature.SizeInBytes);
|
||||
break;
|
||||
case DXIL::SubobjectKind::SubobjectToExportsAssociation:
|
||||
desc.SubobjectToExportsAssociation.Subobject =
|
||||
GetWideString(reader.getSubobjectToExportsAssociation().getSubobject());
|
||||
desc.SubobjectToExportsAssociation.NumExports = reader.getSubobjectToExportsAssociation().getExports().Count();
|
||||
desc.SubobjectToExportsAssociation.Exports = GetExportsForAssociation(desc, reader);
|
||||
desc.SubobjectToExportsAssociation.Subobject = GetWideString(
|
||||
reader.getSubobjectToExportsAssociation().getSubobject());
|
||||
desc.SubobjectToExportsAssociation.NumExports =
|
||||
reader.getSubobjectToExportsAssociation().getExports().Count();
|
||||
desc.SubobjectToExportsAssociation.Exports =
|
||||
GetExportsForAssociation(desc, reader);
|
||||
break;
|
||||
case DXIL::SubobjectKind::RaytracingShaderConfig:
|
||||
desc.RaytracingShaderConfig.MaxPayloadSizeInBytes = reader.getRaytracingShaderConfig().getMaxPayloadSizeInBytes();
|
||||
desc.RaytracingShaderConfig.MaxAttributeSizeInBytes = reader.getRaytracingShaderConfig().getMaxAttributeSizeInBytes();
|
||||
desc.RaytracingShaderConfig.MaxPayloadSizeInBytes =
|
||||
reader.getRaytracingShaderConfig().getMaxPayloadSizeInBytes();
|
||||
desc.RaytracingShaderConfig.MaxAttributeSizeInBytes =
|
||||
reader.getRaytracingShaderConfig().getMaxAttributeSizeInBytes();
|
||||
break;
|
||||
case DXIL::SubobjectKind::RaytracingPipelineConfig:
|
||||
desc.RaytracingPipelineConfig.MaxTraceRecursionDepth = reader.getRaytracingPipelineConfig().getMaxTraceRecursionDepth();
|
||||
desc.RaytracingPipelineConfig.MaxTraceRecursionDepth =
|
||||
reader.getRaytracingPipelineConfig().getMaxTraceRecursionDepth();
|
||||
break;
|
||||
case DXIL::SubobjectKind::HitGroup:
|
||||
desc.HitGroup.Type = reader.getHitGroup().getType();
|
||||
desc.HitGroup.Intersection = GetWideString(reader.getHitGroup().getIntersection());
|
||||
desc.HitGroup.Intersection =
|
||||
GetWideString(reader.getHitGroup().getIntersection());
|
||||
desc.HitGroup.AnyHit = GetWideString(reader.getHitGroup().getAnyHit());
|
||||
desc.HitGroup.ClosestHit = GetWideString(reader.getHitGroup().getClosestHit());
|
||||
desc.HitGroup.ClosestHit =
|
||||
GetWideString(reader.getHitGroup().getClosestHit());
|
||||
break;
|
||||
case DXIL::SubobjectKind::RaytracingPipelineConfig1:
|
||||
desc.RaytracingPipelineConfig1.MaxTraceRecursionDepth = reader.getRaytracingPipelineConfig1().getMaxTraceRecursionDepth();
|
||||
desc.RaytracingPipelineConfig1.Flags = reader.getRaytracingPipelineConfig1().getFlags();
|
||||
desc.RaytracingPipelineConfig1.MaxTraceRecursionDepth =
|
||||
reader.getRaytracingPipelineConfig1().getMaxTraceRecursionDepth();
|
||||
desc.RaytracingPipelineConfig1.Flags =
|
||||
reader.getRaytracingPipelineConfig1().getFlags();
|
||||
break;
|
||||
default:
|
||||
// Ignore contents of unrecognized subobject type (forward-compat)
|
||||
|
@ -553,7 +587,7 @@ void DxilRuntimeReflection_impl::AddSubobjects() {
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
} // namespace
|
||||
|
||||
DxilRuntimeReflection *hlsl::RDAT::CreateDxilRuntimeReflection() {
|
||||
return new DxilRuntimeReflection_impl();
|
||||
|
|
|
@ -46,7 +46,8 @@
|
|||
// DEF_RDAT_TYPES and DEF_RDAT_ENUMS - define structural validation
|
||||
#define DEF_RDAT_STRUCT_VALIDATION 13
|
||||
|
||||
// PRERELEASE-TODO: deeper validation for DxilValidation (limiting enum values and other such things)
|
||||
// PRERELEASE-TODO: deeper validation for DxilValidation (limiting enum values
|
||||
// and other such things)
|
||||
|
||||
// clang-format off
|
||||
#define CLOSE_COMPOUND_DECL };
|
||||
|
@ -59,326 +60,432 @@
|
|||
|
||||
#if DEF_RDAT_TYPES == DEF_RDAT_TYPES_FORWARD_DECL
|
||||
|
||||
#define RDAT_STRUCT(type) struct type; class type##_Reader;
|
||||
#define RDAT_STRUCT_DERIVED(type, base) RDAT_STRUCT(type)
|
||||
#define RDAT_WRAP_ARRAY(type, count, type_name) struct type_name { type arr[count]; };
|
||||
#define RDAT_STRUCT(type) \
|
||||
struct type; \
|
||||
class type##_Reader;
|
||||
#define RDAT_STRUCT_DERIVED(type, base) RDAT_STRUCT(type)
|
||||
#define RDAT_WRAP_ARRAY(type, count, type_name) \
|
||||
struct type_name { \
|
||||
type arr[count]; \
|
||||
};
|
||||
|
||||
#elif DEF_RDAT_TYPES == DEF_RDAT_TYPES_BASIC_STRUCT
|
||||
|
||||
#define RDAT_STRUCT(type) struct type {
|
||||
#define RDAT_STRUCT_DERIVED(type, base) \
|
||||
struct type : public base {
|
||||
#define RDAT_STRUCT_END() CLOSE_COMPOUND_DECL
|
||||
#define RDAT_UNION() union {
|
||||
#define RDAT_UNION_END() CLOSE_COMPOUND_DECL
|
||||
#define RDAT_RECORD_REF(type, name) uint32_t name;
|
||||
#define RDAT_RECORD_ARRAY_REF(type, name) uint32_t name;
|
||||
#define RDAT_RECORD_VALUE(type, name) type name;
|
||||
#define RDAT_STRING(name) uint32_t name;
|
||||
#define RDAT_STRING_ARRAY_REF(name) uint32_t name;
|
||||
#define RDAT_VALUE(type, name) type name;
|
||||
#define RDAT_INDEX_ARRAY_REF(name) uint32_t name;
|
||||
#define RDAT_ENUM(sTy, eTy, name) sTy name;
|
||||
#define RDAT_FLAGS(sTy, eTy, name) sTy name;
|
||||
#define RDAT_BYTES(name) uint32_t name; uint32_t name##_Size; name;
|
||||
#define RDAT_ARRAY_VALUE(type, count, type_name, name) type_name name;
|
||||
#define RDAT_STRUCT(type) struct type {
|
||||
#define RDAT_STRUCT_DERIVED(type, base) struct type : public base {
|
||||
#define RDAT_STRUCT_END() CLOSE_COMPOUND_DECL
|
||||
#define RDAT_UNION() union {
|
||||
#define RDAT_UNION_END() CLOSE_COMPOUND_DECL
|
||||
#define RDAT_RECORD_REF(type, name) uint32_t name;
|
||||
#define RDAT_RECORD_ARRAY_REF(type, name) uint32_t name;
|
||||
#define RDAT_RECORD_VALUE(type, name) type name;
|
||||
#define RDAT_STRING(name) uint32_t name;
|
||||
#define RDAT_STRING_ARRAY_REF(name) uint32_t name;
|
||||
#define RDAT_VALUE(type, name) type name;
|
||||
#define RDAT_INDEX_ARRAY_REF(name) uint32_t name;
|
||||
#define RDAT_ENUM(sTy, eTy, name) sTy name;
|
||||
#define RDAT_FLAGS(sTy, eTy, name) sTy name;
|
||||
#define RDAT_BYTES(name) \
|
||||
uint32_t name; \
|
||||
uint32_t name##_Size; \
|
||||
name;
|
||||
#define RDAT_ARRAY_VALUE(type, count, type_name, name) type_name name;
|
||||
|
||||
#elif DEF_RDAT_TYPES == DEF_RDAT_TYPES_USE_HELPERS
|
||||
|
||||
#define RDAT_STRUCT(type) struct type {
|
||||
#define RDAT_STRUCT_DERIVED(type, base) struct type : public base {
|
||||
#define RDAT_STRUCT_END() CLOSE_COMPOUND_DECL
|
||||
#define RDAT_UNION() union {
|
||||
#define RDAT_UNION_END() CLOSE_COMPOUND_DECL
|
||||
#define RDAT_RECORD_REF(type, name) RecordRef<type> name;
|
||||
#define RDAT_RECORD_ARRAY_REF(type, name) RecordArrayRef<type> name;
|
||||
#define RDAT_RECORD_VALUE(type, name) type name;
|
||||
#define RDAT_STRING(name) RDATString name;
|
||||
#define RDAT_STRING_ARRAY_REF(name) RDATStringArray name;
|
||||
#define RDAT_VALUE(type, name) type name;
|
||||
#define RDAT_INDEX_ARRAY_REF(name) IndexArrayRef name;
|
||||
#define RDAT_ENUM(sTy, eTy, name) sTy name;
|
||||
#define RDAT_FLAGS(sTy, eTy, name) sTy name;
|
||||
#define RDAT_BYTES(name) hlsl::RDAT::BytesRef name;
|
||||
#define RDAT_ARRAY_VALUE(type, count, type_name, name) type_name name;
|
||||
#define RDAT_STRUCT(type) struct type {
|
||||
#define RDAT_STRUCT_DERIVED(type, base) struct type : public base {
|
||||
#define RDAT_STRUCT_END() CLOSE_COMPOUND_DECL
|
||||
#define RDAT_UNION() union {
|
||||
#define RDAT_UNION_END() CLOSE_COMPOUND_DECL
|
||||
#define RDAT_RECORD_REF(type, name) RecordRef<type> name;
|
||||
#define RDAT_RECORD_ARRAY_REF(type, name) RecordArrayRef<type> name;
|
||||
#define RDAT_RECORD_VALUE(type, name) type name;
|
||||
#define RDAT_STRING(name) RDATString name;
|
||||
#define RDAT_STRING_ARRAY_REF(name) RDATStringArray name;
|
||||
#define RDAT_VALUE(type, name) type name;
|
||||
#define RDAT_INDEX_ARRAY_REF(name) IndexArrayRef name;
|
||||
#define RDAT_ENUM(sTy, eTy, name) sTy name;
|
||||
#define RDAT_FLAGS(sTy, eTy, name) sTy name;
|
||||
#define RDAT_BYTES(name) hlsl::RDAT::BytesRef name;
|
||||
#define RDAT_ARRAY_VALUE(type, count, type_name, name) type_name name;
|
||||
|
||||
#elif DEF_RDAT_TYPES == DEF_RDAT_READER_DECL
|
||||
|
||||
#define RDAT_STRUCT(type) \
|
||||
class type##_Reader : public RecordReader<type##_Reader> { \
|
||||
public: \
|
||||
typedef type RecordType; \
|
||||
type##_Reader(const BaseRecordReader &reader); \
|
||||
type##_Reader() : RecordReader<type##_Reader>() {} \
|
||||
const RecordType *asRecord() const; \
|
||||
const RecordType *operator->() const { return asRecord(); }
|
||||
#define RDAT_STRUCT_DERIVED(type, base) \
|
||||
class type##_Reader : public base##_Reader { \
|
||||
public: \
|
||||
typedef type RecordType; \
|
||||
type##_Reader(const BaseRecordReader &reader); \
|
||||
type##_Reader(); \
|
||||
const RecordType *asRecord() const; \
|
||||
const RecordType *operator->() const { return asRecord(); }
|
||||
#define RDAT_STRUCT_END() CLOSE_COMPOUND_DECL
|
||||
#define RDAT_UNION_IF(name, expr) bool has##name() const;
|
||||
#define RDAT_UNION_ELIF(name, expr) RDAT_UNION_IF(name, expr)
|
||||
#define RDAT_RECORD_REF(type, name) type##_Reader get##name() const;
|
||||
#define RDAT_RECORD_ARRAY_REF(type, name) RecordArrayReader<type##_Reader> get##name() const;
|
||||
#define RDAT_RECORD_VALUE(type, name) type##_Reader get##name() const;
|
||||
#define RDAT_STRING(name) const char *get##name() const;
|
||||
#define RDAT_STRING_ARRAY_REF(name) StringArrayReader get##name() const;
|
||||
#define RDAT_VALUE(type, name) type get##name() const;
|
||||
#define RDAT_INDEX_ARRAY_REF(name) IndexTableReader::IndexRow get##name() const;
|
||||
#define RDAT_ENUM(sTy, eTy, name) eTy get##name() const;
|
||||
#define RDAT_FLAGS(sTy, eTy, name) sTy get##name() const;
|
||||
#define RDAT_BYTES(name) const void *get##name() const; \
|
||||
uint32_t size##name() const;
|
||||
#define RDAT_ARRAY_VALUE(type, count, type_name, name) type_name get##name() const;
|
||||
#define RDAT_STRUCT(type) \
|
||||
class type##_Reader : public RecordReader<type##_Reader> { \
|
||||
public: \
|
||||
typedef type RecordType; \
|
||||
type##_Reader(const BaseRecordReader &reader); \
|
||||
type##_Reader() : RecordReader<type##_Reader>() {} \
|
||||
const RecordType *asRecord() const; \
|
||||
const RecordType *operator->() const { return asRecord(); }
|
||||
#define RDAT_STRUCT_DERIVED(type, base) \
|
||||
class type##_Reader : public base##_Reader { \
|
||||
public: \
|
||||
typedef type RecordType; \
|
||||
type##_Reader(const BaseRecordReader &reader); \
|
||||
type##_Reader(); \
|
||||
const RecordType *asRecord() const; \
|
||||
const RecordType *operator->() const { return asRecord(); }
|
||||
#define RDAT_STRUCT_END() CLOSE_COMPOUND_DECL
|
||||
#define RDAT_UNION_IF(name, expr) bool has##name() const;
|
||||
#define RDAT_UNION_ELIF(name, expr) RDAT_UNION_IF(name, expr)
|
||||
#define RDAT_RECORD_REF(type, name) type##_Reader get##name() const;
|
||||
#define RDAT_RECORD_ARRAY_REF(type, name) \
|
||||
RecordArrayReader<type##_Reader> get##name() const;
|
||||
#define RDAT_RECORD_VALUE(type, name) type##_Reader get##name() const;
|
||||
#define RDAT_STRING(name) const char *get##name() const;
|
||||
#define RDAT_STRING_ARRAY_REF(name) StringArrayReader get##name() const;
|
||||
#define RDAT_VALUE(type, name) type get##name() const;
|
||||
#define RDAT_INDEX_ARRAY_REF(name) IndexTableReader::IndexRow get##name() const;
|
||||
#define RDAT_ENUM(sTy, eTy, name) eTy get##name() const;
|
||||
#define RDAT_FLAGS(sTy, eTy, name) sTy get##name() const;
|
||||
#define RDAT_BYTES(name) \
|
||||
const void *get##name() const; \
|
||||
uint32_t size##name() const;
|
||||
#define RDAT_ARRAY_VALUE(type, count, type_name, name) \
|
||||
type_name get##name() const;
|
||||
|
||||
#elif DEF_RDAT_TYPES == DEF_RDAT_READER_IMPL
|
||||
|
||||
#define RDAT_STRUCT(type) \
|
||||
type##_Reader::type##_Reader(const BaseRecordReader &reader) : RecordReader<type##_Reader>(reader) {} \
|
||||
const type *type##_Reader::asRecord() const { return BaseRecordReader::asRecord<type>(); }
|
||||
#define RDAT_STRUCT_DERIVED(type, base) \
|
||||
type##_Reader::type##_Reader(const BaseRecordReader &reader) : base##_Reader(reader) { \
|
||||
if ((m_pContext || m_pRecord) && m_Size < sizeof(type)) \
|
||||
InvalidateReader(); \
|
||||
} \
|
||||
type##_Reader::type##_Reader() : base##_Reader() {} \
|
||||
const type *type##_Reader::asRecord() const { return BaseRecordReader::asRecord<type>(); }
|
||||
#define RDAT_STRUCT_TABLE(type, table) RDAT_STRUCT(type)
|
||||
#define RDAT_STRUCT_TABLE_DERIVED(type, base, table) RDAT_STRUCT_DERIVED(type, base)
|
||||
#define RDAT_UNION_IF(name, expr) bool GLUE(RECORD_TYPE,_Reader)::has##name() const { if (auto *pRecord = asRecord()) return !!(expr); return false; }
|
||||
#define RDAT_UNION_ELIF(name, expr) RDAT_UNION_IF(name, expr)
|
||||
#define RDAT_RECORD_REF(type, name) type##_Reader GLUE(RECORD_TYPE,_Reader)::get##name() const { return GetField_RecordRef<type##_Reader> (&(asRecord()->name)); }
|
||||
#define RDAT_RECORD_ARRAY_REF(type, name) \
|
||||
RecordArrayReader<type##_Reader> GLUE(RECORD_TYPE,_Reader)::get##name() const { return GetField_RecordArrayRef<type##_Reader> (&(asRecord()->name)); }
|
||||
#define RDAT_RECORD_VALUE(type, name) type##_Reader GLUE(RECORD_TYPE,_Reader)::get##name() const { return GetField_RecordValue<type##_Reader> (&(asRecord()->name)); }
|
||||
#define RDAT_STRING(name) const char *GLUE(RECORD_TYPE,_Reader)::get##name() const { return GetField_String (&(asRecord()->name)); }
|
||||
#define RDAT_STRING_ARRAY_REF(name) StringArrayReader GLUE(RECORD_TYPE,_Reader)::get##name() const { return GetField_StringArray (&(asRecord()->name)); }
|
||||
#define RDAT_VALUE(type, name) type GLUE(RECORD_TYPE,_Reader)::get##name() const { return GetField_Value<type, type> (&(asRecord()->name)); }
|
||||
#define RDAT_INDEX_ARRAY_REF(name) IndexTableReader::IndexRow GLUE(RECORD_TYPE,_Reader)::get##name() const { return GetField_IndexArray (&(asRecord()->name)); }
|
||||
#define RDAT_ENUM(sTy, eTy, name) eTy GLUE(RECORD_TYPE,_Reader)::get##name() const { return GetField_Value<eTy, sTy> (&(asRecord()->name)); }
|
||||
#define RDAT_FLAGS(sTy, eTy, name) sTy GLUE(RECORD_TYPE,_Reader)::get##name() const { return GetField_Value<sTy, sTy> (&(asRecord()->name)); }
|
||||
#define RDAT_BYTES(name) const void *GLUE(RECORD_TYPE,_Reader)::get##name() const { return GetField_Bytes (&(asRecord()->name)); } \
|
||||
uint32_t GLUE(RECORD_TYPE,_Reader)::size##name() const { return GetField_BytesSize (&(asRecord()->name)); }
|
||||
#define RDAT_ARRAY_VALUE(type, count, type_name, name) \
|
||||
type_name GLUE(RECORD_TYPE,_Reader)::get##name() const { return GetField_Value<type_name, type_name> (&(asRecord()->name)); }
|
||||
#define RDAT_STRUCT(type) \
|
||||
type##_Reader::type##_Reader(const BaseRecordReader &reader) \
|
||||
: RecordReader<type##_Reader>(reader) {} \
|
||||
const type *type##_Reader::asRecord() const { \
|
||||
return BaseRecordReader::asRecord<type>(); \
|
||||
}
|
||||
#define RDAT_STRUCT_DERIVED(type, base) \
|
||||
type##_Reader::type##_Reader(const BaseRecordReader &reader) \
|
||||
: base##_Reader(reader) { \
|
||||
if ((m_pContext || m_pRecord) && m_Size < sizeof(type)) \
|
||||
InvalidateReader(); \
|
||||
} \
|
||||
type##_Reader::type##_Reader() : base##_Reader() {} \
|
||||
const type *type##_Reader::asRecord() const { \
|
||||
return BaseRecordReader::asRecord<type>(); \
|
||||
}
|
||||
#define RDAT_STRUCT_TABLE(type, table) RDAT_STRUCT(type)
|
||||
#define RDAT_STRUCT_TABLE_DERIVED(type, base, table) \
|
||||
RDAT_STRUCT_DERIVED(type, base)
|
||||
#define RDAT_UNION_IF(name, expr) \
|
||||
bool GLUE(RECORD_TYPE, _Reader)::has##name() const { \
|
||||
if (auto *pRecord = asRecord()) \
|
||||
return !!(expr); \
|
||||
return false; \
|
||||
}
|
||||
#define RDAT_UNION_ELIF(name, expr) RDAT_UNION_IF(name, expr)
|
||||
#define RDAT_RECORD_REF(type, name) \
|
||||
type##_Reader GLUE(RECORD_TYPE, _Reader)::get##name() const { \
|
||||
return GetField_RecordRef<type##_Reader>(&(asRecord()->name)); \
|
||||
}
|
||||
#define RDAT_RECORD_ARRAY_REF(type, name) \
|
||||
RecordArrayReader<type##_Reader> GLUE(RECORD_TYPE, _Reader)::get##name() \
|
||||
const { \
|
||||
return GetField_RecordArrayRef<type##_Reader>(&(asRecord()->name)); \
|
||||
}
|
||||
#define RDAT_RECORD_VALUE(type, name) \
|
||||
type##_Reader GLUE(RECORD_TYPE, _Reader)::get##name() const { \
|
||||
return GetField_RecordValue<type##_Reader>(&(asRecord()->name)); \
|
||||
}
|
||||
#define RDAT_STRING(name) \
|
||||
const char *GLUE(RECORD_TYPE, _Reader)::get##name() const { \
|
||||
return GetField_String(&(asRecord()->name)); \
|
||||
}
|
||||
#define RDAT_STRING_ARRAY_REF(name) \
|
||||
StringArrayReader GLUE(RECORD_TYPE, _Reader)::get##name() const { \
|
||||
return GetField_StringArray(&(asRecord()->name)); \
|
||||
}
|
||||
#define RDAT_VALUE(type, name) \
|
||||
type GLUE(RECORD_TYPE, _Reader)::get##name() const { \
|
||||
return GetField_Value<type, type>(&(asRecord()->name)); \
|
||||
}
|
||||
#define RDAT_INDEX_ARRAY_REF(name) \
|
||||
IndexTableReader::IndexRow GLUE(RECORD_TYPE, _Reader)::get##name() const { \
|
||||
return GetField_IndexArray(&(asRecord()->name)); \
|
||||
}
|
||||
#define RDAT_ENUM(sTy, eTy, name) \
|
||||
eTy GLUE(RECORD_TYPE, _Reader)::get##name() const { \
|
||||
return GetField_Value<eTy, sTy>(&(asRecord()->name)); \
|
||||
}
|
||||
#define RDAT_FLAGS(sTy, eTy, name) \
|
||||
sTy GLUE(RECORD_TYPE, _Reader)::get##name() const { \
|
||||
return GetField_Value<sTy, sTy>(&(asRecord()->name)); \
|
||||
}
|
||||
#define RDAT_BYTES(name) \
|
||||
const void *GLUE(RECORD_TYPE, _Reader)::get##name() const { \
|
||||
return GetField_Bytes(&(asRecord()->name)); \
|
||||
} \
|
||||
uint32_t GLUE(RECORD_TYPE, _Reader)::size##name() const { \
|
||||
return GetField_BytesSize(&(asRecord()->name)); \
|
||||
}
|
||||
#define RDAT_ARRAY_VALUE(type, count, type_name, name) \
|
||||
type_name GLUE(RECORD_TYPE, _Reader)::get##name() const { \
|
||||
return GetField_Value<type_name, type_name>(&(asRecord()->name)); \
|
||||
}
|
||||
|
||||
#elif DEF_RDAT_TYPES == DEF_RDAT_STRUCT_VALIDATION
|
||||
|
||||
#define RDAT_STRUCT(type) \
|
||||
template<> bool ValidateRecord<type>(const RDATContext &ctx, const type *pRecord) { \
|
||||
type##_Reader reader(BaseRecordReader(&ctx, (void*)pRecord, (uint32_t)RecordTraits<type>::RecordSize()));
|
||||
#define RDAT_STRUCT_DERIVED(type, base) RDAT_STRUCT(type)
|
||||
#define RDAT_STRUCT_END() return true; }
|
||||
#define RDAT_UNION_IF(name, expr) if (reader.has##name()) {
|
||||
#define RDAT_UNION_ELIF(name, expr) } else if (reader.has##name()) {
|
||||
#define RDAT_UNION_ENDIF() }
|
||||
#define RDAT_RECORD_REF(type, name) if (!ValidateRecordRef<type>(ctx, pRecord->name)) return false;
|
||||
#define RDAT_RECORD_ARRAY_REF(type, name) if (!ValidateRecordArrayRef<type>(ctx, pRecord->name)) return false;
|
||||
#define RDAT_RECORD_VALUE(type, name) if (!ValidateRecord<type>(ctx, &pRecord->name)) return false;
|
||||
#define RDAT_STRING(name) if (!ValidateStringRef(ctx, pRecord->name)) return false;
|
||||
#define RDAT_STRING_ARRAY_REF(name) if (!ValidateStringArrayRef(ctx, pRecord->name)) return false;
|
||||
#define RDAT_INDEX_ARRAY_REF(name) if (!ValidateIndexArrayRef(ctx, pRecord->name)) return false;
|
||||
#define RDAT_STRUCT(type) \
|
||||
template <> \
|
||||
bool ValidateRecord<type>(const RDATContext &ctx, const type *pRecord) { \
|
||||
type##_Reader reader(BaseRecordReader( \
|
||||
&ctx, (void *)pRecord, (uint32_t)RecordTraits<type>::RecordSize()));
|
||||
#define RDAT_STRUCT_DERIVED(type, base) RDAT_STRUCT(type)
|
||||
#define RDAT_STRUCT_END() \
|
||||
return true; \
|
||||
}
|
||||
#define RDAT_UNION_IF(name, expr) if (reader.has##name()) {
|
||||
#define RDAT_UNION_ELIF(name, expr) \
|
||||
} \
|
||||
else if (reader.has##name()) {
|
||||
#define RDAT_UNION_ENDIF() }
|
||||
#define RDAT_RECORD_REF(type, name) \
|
||||
if (!ValidateRecordRef<type>(ctx, pRecord->name)) \
|
||||
return false;
|
||||
#define RDAT_RECORD_ARRAY_REF(type, name) \
|
||||
if (!ValidateRecordArrayRef<type>(ctx, pRecord->name)) \
|
||||
return false;
|
||||
#define RDAT_RECORD_VALUE(type, name) \
|
||||
if (!ValidateRecord<type>(ctx, &pRecord->name)) \
|
||||
return false;
|
||||
#define RDAT_STRING(name) \
|
||||
if (!ValidateStringRef(ctx, pRecord->name)) \
|
||||
return false;
|
||||
#define RDAT_STRING_ARRAY_REF(name) \
|
||||
if (!ValidateStringArrayRef(ctx, pRecord->name)) \
|
||||
return false;
|
||||
#define RDAT_INDEX_ARRAY_REF(name) \
|
||||
if (!ValidateIndexArrayRef(ctx, pRecord->name)) \
|
||||
return false;
|
||||
|
||||
#elif DEF_RDAT_TYPES == DEF_RDAT_DUMP_IMPL
|
||||
|
||||
#define RDAT_STRUCT(type) \
|
||||
template <> \
|
||||
void RecordDumper<hlsl::RDAT::type>::Dump( \
|
||||
const hlsl::RDAT::RDATContext &ctx, DumpContext &d) const { \
|
||||
d.Indent(); \
|
||||
const hlsl::RDAT::type *pRecord = this; \
|
||||
type##_Reader reader(BaseRecordReader( \
|
||||
&ctx, (void *)pRecord, (uint32_t)RecordTraits<type>::RecordSize()));
|
||||
#define RDAT_STRUCT_DERIVED(type, base) \
|
||||
const char *RecordRefDumper<hlsl::RDAT::base>::TypeNameDerived( \
|
||||
const hlsl::RDAT::RDATContext &ctx) const { \
|
||||
return TypeName<hlsl::RDAT::type>(ctx); \
|
||||
} \
|
||||
void RecordRefDumper<hlsl::RDAT::base>::DumpDerived( \
|
||||
const hlsl::RDAT::RDATContext &ctx, DumpContext &d) const { \
|
||||
Dump<hlsl::RDAT::type>(ctx, d); \
|
||||
} \
|
||||
template <> \
|
||||
void DumpWithBase<hlsl::RDAT::type>(const hlsl::RDAT::RDATContext &ctx, \
|
||||
DumpContext &d, \
|
||||
const hlsl::RDAT::type *pRecord) { \
|
||||
DumpWithBase<hlsl::RDAT::base>(ctx, d, pRecord); \
|
||||
static_cast<const RecordDumper<hlsl::RDAT::type> *>(pRecord)->Dump(ctx, \
|
||||
d); \
|
||||
} \
|
||||
RDAT_STRUCT(type)
|
||||
#define RDAT_STRUCT_END() d.Dedent(); }
|
||||
#define RDAT_UNION_IF(name, expr) if (reader.has##name()) {
|
||||
#define RDAT_UNION_ELIF(name, expr) } else if (reader.has##name()) {
|
||||
#define RDAT_UNION_ENDIF() }
|
||||
#define RDAT_RECORD_REF(type, name) DumpRecordRef(ctx, d, #type, #name, name);
|
||||
#define RDAT_RECORD_ARRAY_REF(type, name) DumpRecordArrayRef(ctx, d, #type, #name, name);
|
||||
#define RDAT_RECORD_VALUE(type, name) DumpRecordValue(ctx, d, #type, #name, &name);
|
||||
#define RDAT_STRING(name) d.WriteLn(#name ": ", QuotedStringValue(name.Get(ctx)));
|
||||
#define RDAT_STRING_ARRAY_REF(name) DumpStringArray(ctx, d, #name, name);
|
||||
#define RDAT_VALUE(type, name) d.WriteLn(#name ": ", name);
|
||||
#define RDAT_INDEX_ARRAY_REF(name) DumpIndexArray(ctx, d, #name, name);
|
||||
#define RDAT_ENUM(sTy, eTy, name) d.DumpEnum<eTy>(#name, (eTy)name);
|
||||
#define RDAT_FLAGS(sTy, eTy, name) d.DumpFlags<eTy, sTy>(#name, name);
|
||||
#define RDAT_BYTES(name) DumpBytesRef(ctx, d, #name, name);
|
||||
#define RDAT_ARRAY_VALUE(type, count, type_name, name) DumpValueArray<type>(d, #name, #type, &name, count);
|
||||
#define RDAT_STRUCT(type) \
|
||||
template <> \
|
||||
void RecordDumper<hlsl::RDAT::type>::Dump( \
|
||||
const hlsl::RDAT::RDATContext &ctx, DumpContext &d) const { \
|
||||
d.Indent(); \
|
||||
const hlsl::RDAT::type *pRecord = this; \
|
||||
type##_Reader reader(BaseRecordReader( \
|
||||
&ctx, (void *)pRecord, (uint32_t)RecordTraits<type>::RecordSize()));
|
||||
#define RDAT_STRUCT_DERIVED(type, base) \
|
||||
const char *RecordRefDumper<hlsl::RDAT::base>::TypeNameDerived( \
|
||||
const hlsl::RDAT::RDATContext &ctx) const { \
|
||||
return TypeName<hlsl::RDAT::type>(ctx); \
|
||||
} \
|
||||
void RecordRefDumper<hlsl::RDAT::base>::DumpDerived( \
|
||||
const hlsl::RDAT::RDATContext &ctx, DumpContext &d) const { \
|
||||
Dump<hlsl::RDAT::type>(ctx, d); \
|
||||
} \
|
||||
template <> \
|
||||
void DumpWithBase<hlsl::RDAT::type>(const hlsl::RDAT::RDATContext &ctx, \
|
||||
DumpContext &d, \
|
||||
const hlsl::RDAT::type *pRecord) { \
|
||||
DumpWithBase<hlsl::RDAT::base>(ctx, d, pRecord); \
|
||||
static_cast<const RecordDumper<hlsl::RDAT::type> *>(pRecord)->Dump(ctx, \
|
||||
d); \
|
||||
} \
|
||||
RDAT_STRUCT(type)
|
||||
#define RDAT_STRUCT_END() \
|
||||
d.Dedent(); \
|
||||
}
|
||||
#define RDAT_UNION_IF(name, expr) if (reader.has##name()) {
|
||||
#define RDAT_UNION_ELIF(name, expr) \
|
||||
} \
|
||||
else if (reader.has##name()) {
|
||||
#define RDAT_UNION_ENDIF() }
|
||||
#define RDAT_RECORD_REF(type, name) DumpRecordRef(ctx, d, #type, #name, name);
|
||||
#define RDAT_RECORD_ARRAY_REF(type, name) \
|
||||
DumpRecordArrayRef(ctx, d, #type, #name, name);
|
||||
#define RDAT_RECORD_VALUE(type, name) \
|
||||
DumpRecordValue(ctx, d, #type, #name, &name);
|
||||
#define RDAT_STRING(name) \
|
||||
d.WriteLn(#name ": ", QuotedStringValue(name.Get(ctx)));
|
||||
#define RDAT_STRING_ARRAY_REF(name) DumpStringArray(ctx, d, #name, name);
|
||||
#define RDAT_VALUE(type, name) d.WriteLn(#name ": ", name);
|
||||
#define RDAT_INDEX_ARRAY_REF(name) DumpIndexArray(ctx, d, #name, name);
|
||||
#define RDAT_ENUM(sTy, eTy, name) d.DumpEnum<eTy>(#name, (eTy)name);
|
||||
#define RDAT_FLAGS(sTy, eTy, name) d.DumpFlags<eTy, sTy>(#name, name);
|
||||
#define RDAT_BYTES(name) DumpBytesRef(ctx, d, #name, name);
|
||||
#define RDAT_ARRAY_VALUE(type, count, type_name, name) \
|
||||
DumpValueArray<type>(d, #name, #type, &name, count);
|
||||
|
||||
#elif DEF_RDAT_TYPES == DEF_RDAT_TRAITS
|
||||
|
||||
#define RDAT_STRUCT(type) \
|
||||
template<> constexpr const char *RecordTraits<type>::TypeName() { return #type; }
|
||||
#define RDAT_STRUCT_DERIVED(type, base) RDAT_STRUCT(type)
|
||||
#define RDAT_STRUCT_TABLE(type, table) \
|
||||
RDAT_STRUCT(type) \
|
||||
template<> constexpr RecordTableIndex RecordTraits<type>::TableIndex() { return RecordTableIndex::table; } \
|
||||
template<> constexpr RuntimeDataPartType RecordTraits<type>::PartType() { return RuntimeDataPartType::table; }
|
||||
#define RDAT_STRUCT_TABLE_DERIVED(type, base, table) \
|
||||
RDAT_STRUCT_DERIVED(type, base) \
|
||||
template<> constexpr RecordTableIndex RecordTraits<type>::TableIndex() { return RecordTableIndex::table; } \
|
||||
template<> constexpr RuntimeDataPartType RecordTraits<type>::PartType() { return RuntimeDataPartType::table; } \
|
||||
template<> constexpr size_t RecordTraits<base>::DerivedRecordSize() { return RecordTraits<type>::MaxRecordSize(); }
|
||||
#define RDAT_STRUCT(type) \
|
||||
template <> constexpr const char *RecordTraits<type>::TypeName() { \
|
||||
return #type; \
|
||||
}
|
||||
#define RDAT_STRUCT_DERIVED(type, base) RDAT_STRUCT(type)
|
||||
#define RDAT_STRUCT_TABLE(type, table) \
|
||||
RDAT_STRUCT(type) \
|
||||
template <> constexpr RecordTableIndex RecordTraits<type>::TableIndex() { \
|
||||
return RecordTableIndex::table; \
|
||||
} \
|
||||
template <> constexpr RuntimeDataPartType RecordTraits<type>::PartType() { \
|
||||
return RuntimeDataPartType::table; \
|
||||
}
|
||||
#define RDAT_STRUCT_TABLE_DERIVED(type, base, table) \
|
||||
RDAT_STRUCT_DERIVED(type, base) \
|
||||
template <> constexpr RecordTableIndex RecordTraits<type>::TableIndex() { \
|
||||
return RecordTableIndex::table; \
|
||||
} \
|
||||
template <> constexpr RuntimeDataPartType RecordTraits<type>::PartType() { \
|
||||
return RuntimeDataPartType::table; \
|
||||
} \
|
||||
template <> constexpr size_t RecordTraits<base>::DerivedRecordSize() { \
|
||||
return RecordTraits<type>::MaxRecordSize(); \
|
||||
}
|
||||
#endif // DEF_RDAT_TYPES cases
|
||||
|
||||
// Define any undefined macros to defaults
|
||||
#ifndef RDAT_STRUCT
|
||||
#define RDAT_STRUCT(type)
|
||||
#define RDAT_STRUCT(type)
|
||||
#endif
|
||||
#ifndef RDAT_STRUCT_DERIVED
|
||||
#define RDAT_STRUCT_DERIVED(type, base)
|
||||
#define RDAT_STRUCT_DERIVED(type, base)
|
||||
#endif
|
||||
#ifndef RDAT_STRUCT_TABLE
|
||||
#define RDAT_STRUCT_TABLE(type, table) RDAT_STRUCT(type)
|
||||
#define RDAT_STRUCT_TABLE(type, table) RDAT_STRUCT(type)
|
||||
#endif
|
||||
#ifndef RDAT_STRUCT_TABLE_DERIVED
|
||||
#define RDAT_STRUCT_TABLE_DERIVED(type, base, table) RDAT_STRUCT_DERIVED(type, base)
|
||||
#define RDAT_STRUCT_TABLE_DERIVED(type, base, table) \
|
||||
RDAT_STRUCT_DERIVED(type, base)
|
||||
#endif
|
||||
#ifndef RDAT_STRUCT_END
|
||||
#define RDAT_STRUCT_END()
|
||||
#define RDAT_STRUCT_END()
|
||||
#endif
|
||||
#ifndef RDAT_UNION
|
||||
#define RDAT_UNION()
|
||||
#define RDAT_UNION()
|
||||
#endif
|
||||
#ifndef RDAT_UNION_IF
|
||||
#define RDAT_UNION_IF(name, expr) // In expr: 'this' is reader; pRecord is record struct
|
||||
#define RDAT_UNION_IF( \
|
||||
name, expr) // In expr: 'this' is reader; pRecord is record struct
|
||||
#endif
|
||||
#ifndef RDAT_UNION_ELIF
|
||||
#define RDAT_UNION_ELIF(name, expr) // In expr: 'this' is reader; pRecord is record struct
|
||||
#define RDAT_UNION_ELIF( \
|
||||
name, expr) // In expr: 'this' is reader; pRecord is record struct
|
||||
#endif
|
||||
#ifndef RDAT_UNION_ENDIF
|
||||
#define RDAT_UNION_ENDIF()
|
||||
#define RDAT_UNION_ENDIF()
|
||||
#endif
|
||||
#ifndef RDAT_UNION_END
|
||||
#define RDAT_UNION_END()
|
||||
#define RDAT_UNION_END()
|
||||
#endif
|
||||
#ifndef RDAT_RECORD_REF
|
||||
#define RDAT_RECORD_REF(type, name) // always use base record type in RDAT_RECORD_REF
|
||||
#define RDAT_RECORD_REF( \
|
||||
type, name) // always use base record type in RDAT_RECORD_REF
|
||||
#endif
|
||||
#ifndef RDAT_RECORD_ARRAY_REF
|
||||
#define RDAT_RECORD_ARRAY_REF(type, name) // always use base record type in RDAT_RECORD_ARRAY_REF
|
||||
#define RDAT_RECORD_ARRAY_REF( \
|
||||
type, name) // always use base record type in RDAT_RECORD_ARRAY_REF
|
||||
#endif
|
||||
#ifndef RDAT_RECORD_VALUE
|
||||
#define RDAT_RECORD_VALUE(type, name)
|
||||
#define RDAT_RECORD_VALUE(type, name)
|
||||
#endif
|
||||
#ifndef RDAT_STRING
|
||||
#define RDAT_STRING(name)
|
||||
#define RDAT_STRING(name)
|
||||
#endif
|
||||
#ifndef RDAT_STRING_ARRAY_REF
|
||||
#define RDAT_STRING_ARRAY_REF(name)
|
||||
#define RDAT_STRING_ARRAY_REF(name)
|
||||
#endif
|
||||
#ifndef RDAT_VALUE
|
||||
#define RDAT_VALUE(type, name)
|
||||
#define RDAT_VALUE(type, name)
|
||||
#endif
|
||||
#ifndef RDAT_INDEX_ARRAY_REF
|
||||
#define RDAT_INDEX_ARRAY_REF(name) // ref to array of uint32_t values
|
||||
#define RDAT_INDEX_ARRAY_REF(name) // ref to array of uint32_t values
|
||||
#endif
|
||||
#ifndef RDAT_ENUM
|
||||
#define RDAT_ENUM(sTy, eTy, name)
|
||||
#define RDAT_ENUM(sTy, eTy, name)
|
||||
#endif
|
||||
#ifndef RDAT_FLAGS
|
||||
#define RDAT_FLAGS(sTy, eTy, name)
|
||||
#define RDAT_FLAGS(sTy, eTy, name)
|
||||
#endif
|
||||
#ifndef RDAT_BYTES
|
||||
#define RDAT_BYTES(name)
|
||||
#define RDAT_BYTES(name)
|
||||
#endif
|
||||
#ifndef RDAT_WRAP_ARRAY
|
||||
#define RDAT_WRAP_ARRAY(type, count, type_name) // define struct-wrapped array type here
|
||||
#define RDAT_WRAP_ARRAY(type, count, \
|
||||
type_name) // define struct-wrapped array type here
|
||||
#endif
|
||||
#ifndef RDAT_ARRAY_VALUE
|
||||
#define RDAT_ARRAY_VALUE(type, count, type_name, name) // define struct-wrapped array member
|
||||
#define RDAT_ARRAY_VALUE(type, count, type_name, \
|
||||
name) // define struct-wrapped array member
|
||||
#endif
|
||||
|
||||
#endif // DEF_RDAT_TYPES defined
|
||||
|
||||
|
||||
#if defined(DEF_RDAT_ENUMS) || defined(DEF_DXIL_ENUMS)
|
||||
|
||||
#if DEF_RDAT_ENUMS == DEF_RDAT_ENUM_CLASS
|
||||
|
||||
#define RDAT_ENUM_START(eTy, sTy) enum class eTy : sTy {
|
||||
// No RDAT_DXIL_ENUM_START, DXIL enums are defined elsewhere
|
||||
#define RDAT_ENUM_VALUE(name, value) name = value,
|
||||
#define RDAT_ENUM_VALUE_ALIAS(name, value) name = value,
|
||||
#define RDAT_ENUM_VALUE_NODEF(name) name,
|
||||
#define RDAT_ENUM_END() CLOSE_COMPOUND_DECL
|
||||
#define RDAT_ENUM_START(eTy, sTy) enum class eTy : sTy {
|
||||
// No RDAT_DXIL_ENUM_START, DXIL enums are defined elsewhere
|
||||
#define RDAT_ENUM_VALUE(name, value) name = value,
|
||||
#define RDAT_ENUM_VALUE_ALIAS(name, value) name = value,
|
||||
#define RDAT_ENUM_VALUE_NODEF(name) name,
|
||||
#define RDAT_ENUM_END() CLOSE_COMPOUND_DECL
|
||||
|
||||
#elif DEF_RDAT_ENUMS == DEF_RDAT_DUMP_DECL
|
||||
|
||||
#define RDAT_ENUM_START(eTy, sTy) const char *ToString(eTy e);
|
||||
#define RDAT_DXIL_ENUM_START(eTy, sTy) const char *ToString(eTy e);
|
||||
#define RDAT_ENUM_START(eTy, sTy) const char *ToString(eTy e);
|
||||
#define RDAT_DXIL_ENUM_START(eTy, sTy) const char *ToString(eTy e);
|
||||
|
||||
#elif DEF_RDAT_ENUMS == DEF_RDAT_DUMP_IMPL
|
||||
|
||||
//#define RDAT_ENUM_START(eTy, sTy) \
|
||||
//#define RDAT_ENUM_START(eTy, sTy) \
|
||||
// const char *ToString(eTy e) { \
|
||||
// switch((sTy)e) {
|
||||
//#define RDAT_ENUM_VALUE(name, value) case value: return #name;
|
||||
#define RDAT_ENUM_START(eTy, sTy) \
|
||||
const char *ToString(eTy e) { \
|
||||
typedef eTy thisEnumTy; \
|
||||
switch(e) {
|
||||
#define RDAT_DXIL_ENUM_START(eTy, sTy) \
|
||||
const char *ToString(eTy e) { \
|
||||
typedef eTy thisEnumTy; \
|
||||
switch(e) {
|
||||
#define RDAT_ENUM_VALUE_NODEF(name) case thisEnumTy::name: return #name;
|
||||
#define RDAT_ENUM_VALUE(name, value) RDAT_ENUM_VALUE_NODEF(name)
|
||||
#define RDAT_ENUM_END() \
|
||||
default: return nullptr; \
|
||||
} \
|
||||
//#define RDAT_ENUM_VALUE(name, value) case value: return #name;
|
||||
#define RDAT_ENUM_START(eTy, sTy) \
|
||||
const char *ToString(eTy e) { \
|
||||
typedef eTy thisEnumTy; \
|
||||
switch (e) {
|
||||
#define RDAT_DXIL_ENUM_START(eTy, sTy) \
|
||||
const char *ToString(eTy e) { \
|
||||
typedef eTy thisEnumTy; \
|
||||
switch (e) {
|
||||
#define RDAT_ENUM_VALUE_NODEF(name) \
|
||||
case thisEnumTy::name: \
|
||||
return #name;
|
||||
#define RDAT_ENUM_VALUE(name, value) RDAT_ENUM_VALUE_NODEF(name)
|
||||
#define RDAT_ENUM_END() \
|
||||
default: \
|
||||
return nullptr; \
|
||||
} \
|
||||
}
|
||||
|
||||
#endif // DEF_RDAT_ENUMS cases
|
||||
|
||||
// Define any undefined macros to defaults
|
||||
#ifndef RDAT_ENUM_START
|
||||
#define RDAT_ENUM_START(eTy, sTy)
|
||||
#define RDAT_ENUM_START(eTy, sTy)
|
||||
#endif
|
||||
#ifndef RDAT_DXIL_ENUM_START
|
||||
#define RDAT_DXIL_ENUM_START(eTy, sTy)
|
||||
#define RDAT_DXIL_ENUM_START(eTy, sTy)
|
||||
#endif
|
||||
#ifndef RDAT_ENUM_VALUE
|
||||
#define RDAT_ENUM_VALUE(name, value) // value only used during declaration
|
||||
#define RDAT_ENUM_VALUE(name, value) // value only used during declaration
|
||||
#endif
|
||||
#ifndef RDAT_ENUM_VALUE_ALIAS
|
||||
#define RDAT_ENUM_VALUE_ALIAS(name, value) // secondary enum names that alias to the same value as another name in the enum
|
||||
#define RDAT_ENUM_VALUE_ALIAS(name, \
|
||||
value) // secondary enum names that alias to the
|
||||
// same value as another name in the enum
|
||||
#endif
|
||||
#ifndef RDAT_ENUM_VALUE_NODEF
|
||||
#define RDAT_ENUM_VALUE_NODEF(name) // enum names that have no explicitly defined value, or are defined elsewhere
|
||||
#define RDAT_ENUM_VALUE_NODEF(name) // enum names that have no explicitly
|
||||
// defined value, or are defined elsewhere
|
||||
#endif
|
||||
#ifndef RDAT_ENUM_END
|
||||
#define RDAT_ENUM_END()
|
||||
#define RDAT_ENUM_END()
|
||||
#endif
|
||||
|
||||
#endif // DEF_RDAT_ENUMS or DEF_DXIL_ENUMS defined
|
||||
|
||||
#include "RDAT_SubobjectTypes.inl"
|
||||
#include "RDAT_LibraryTypes.inl"
|
||||
#include "RDAT_PdbInfoTypes.inl"
|
||||
#include "RDAT_SubobjectTypes.inl"
|
||||
|
||||
#undef DEF_RDAT_TYPES
|
||||
#undef DEF_RDAT_ENUMS
|
||||
|
|
|
@ -13,31 +13,29 @@
|
|||
|
||||
#define RECORD_TYPE DxilPdbInfoLibrary
|
||||
RDAT_STRUCT_TABLE(DxilPdbInfoLibrary, DxilPdbInfoLibraryTable)
|
||||
RDAT_STRING(Name)
|
||||
RDAT_BYTES(Data)
|
||||
RDAT_STRING(Name)
|
||||
RDAT_BYTES(Data)
|
||||
RDAT_STRUCT_END()
|
||||
#undef RECORD_TYPE
|
||||
|
||||
#define RECORD_TYPE DxilPdbInfoSource
|
||||
RDAT_STRUCT_TABLE(DxilPdbInfoSource, DxilPdbInfoSourceTable)
|
||||
RDAT_STRING(Name)
|
||||
RDAT_STRING(Content)
|
||||
RDAT_STRING(Name)
|
||||
RDAT_STRING(Content)
|
||||
RDAT_STRUCT_END()
|
||||
#undef RECORD_TYPE
|
||||
|
||||
#define RECORD_TYPE DxilPdbInfo
|
||||
RDAT_STRUCT_TABLE(DxilPdbInfo, DxilPdbInfoTable)
|
||||
RDAT_RECORD_ARRAY_REF(DxilPdbInfoSource, Sources)
|
||||
RDAT_RECORD_ARRAY_REF(DxilPdbInfoLibrary, Libraries)
|
||||
RDAT_STRING_ARRAY_REF(ArgPairs)
|
||||
RDAT_BYTES(Hash)
|
||||
RDAT_STRING(PdbName)
|
||||
RDAT_VALUE(uint32_t, CustomToolchainId)
|
||||
RDAT_BYTES(CustomToolchainData)
|
||||
RDAT_BYTES(WholeDxil)
|
||||
RDAT_RECORD_ARRAY_REF(DxilPdbInfoSource, Sources)
|
||||
RDAT_RECORD_ARRAY_REF(DxilPdbInfoLibrary, Libraries)
|
||||
RDAT_STRING_ARRAY_REF(ArgPairs)
|
||||
RDAT_BYTES(Hash)
|
||||
RDAT_STRING(PdbName)
|
||||
RDAT_VALUE(uint32_t, CustomToolchainId)
|
||||
RDAT_BYTES(CustomToolchainData)
|
||||
RDAT_BYTES(WholeDxil)
|
||||
RDAT_STRUCT_END()
|
||||
#undef RECORD_TYPE
|
||||
|
||||
#endif // DEF_RDAT_TYPES
|
||||
|
||||
|
||||
|
|
|
@ -18,49 +18,53 @@
|
|||
#ifdef DEF_DXIL_ENUMS
|
||||
|
||||
RDAT_DXIL_ENUM_START(hlsl::DXIL::SubobjectKind, uint32_t)
|
||||
RDAT_ENUM_VALUE_NODEF(StateObjectConfig)
|
||||
RDAT_ENUM_VALUE_NODEF(GlobalRootSignature)
|
||||
RDAT_ENUM_VALUE_NODEF(LocalRootSignature)
|
||||
RDAT_ENUM_VALUE_NODEF(SubobjectToExportsAssociation)
|
||||
RDAT_ENUM_VALUE_NODEF(RaytracingShaderConfig)
|
||||
RDAT_ENUM_VALUE_NODEF(RaytracingPipelineConfig)
|
||||
RDAT_ENUM_VALUE_NODEF(HitGroup)
|
||||
RDAT_ENUM_VALUE_NODEF(RaytracingPipelineConfig1)
|
||||
// No need to define this here
|
||||
//RDAT_ENUM_VALUE_NODEF(NumKinds)
|
||||
RDAT_ENUM_VALUE_NODEF(StateObjectConfig)
|
||||
RDAT_ENUM_VALUE_NODEF(GlobalRootSignature)
|
||||
RDAT_ENUM_VALUE_NODEF(LocalRootSignature)
|
||||
RDAT_ENUM_VALUE_NODEF(SubobjectToExportsAssociation)
|
||||
RDAT_ENUM_VALUE_NODEF(RaytracingShaderConfig)
|
||||
RDAT_ENUM_VALUE_NODEF(RaytracingPipelineConfig)
|
||||
RDAT_ENUM_VALUE_NODEF(HitGroup)
|
||||
RDAT_ENUM_VALUE_NODEF(RaytracingPipelineConfig1)
|
||||
// No need to define this here
|
||||
// RDAT_ENUM_VALUE_NODEF(NumKinds)
|
||||
#if DEF_RDAT_ENUMS == DEF_RDAT_DUMP_IMPL
|
||||
static_assert((unsigned)hlsl::DXIL::SubobjectKind::NumKinds == 13, "otherwise, RDAT_DXIL_ENUM definition needs updating");
|
||||
static_assert((unsigned)hlsl::DXIL::SubobjectKind::NumKinds == 13,
|
||||
"otherwise, RDAT_DXIL_ENUM definition needs updating");
|
||||
#endif
|
||||
RDAT_ENUM_END()
|
||||
|
||||
RDAT_DXIL_ENUM_START(hlsl::DXIL::StateObjectFlags, uint32_t)
|
||||
RDAT_ENUM_VALUE_NODEF(AllowLocalDependenciesOnExternalDefinitions)
|
||||
RDAT_ENUM_VALUE_NODEF(AllowExternalDependenciesOnLocalDefinitions)
|
||||
RDAT_ENUM_VALUE_NODEF(AllowStateObjectAdditions)
|
||||
// No need to define these masks here
|
||||
//RDAT_ENUM_VALUE_NODEF(ValidMask_1_4)
|
||||
//RDAT_ENUM_VALUE_NODEF(ValidMask)
|
||||
RDAT_ENUM_VALUE_NODEF(AllowLocalDependenciesOnExternalDefinitions)
|
||||
RDAT_ENUM_VALUE_NODEF(AllowExternalDependenciesOnLocalDefinitions)
|
||||
RDAT_ENUM_VALUE_NODEF(AllowStateObjectAdditions)
|
||||
// No need to define these masks here
|
||||
// RDAT_ENUM_VALUE_NODEF(ValidMask_1_4)
|
||||
// RDAT_ENUM_VALUE_NODEF(ValidMask)
|
||||
#if DEF_RDAT_ENUMS == DEF_RDAT_DUMP_IMPL
|
||||
static_assert((unsigned)hlsl::DXIL::StateObjectFlags::ValidMask == 0x7, "otherwise, RDAT_DXIL_ENUM definition needs updating");
|
||||
static_assert((unsigned)hlsl::DXIL::StateObjectFlags::ValidMask == 0x7,
|
||||
"otherwise, RDAT_DXIL_ENUM definition needs updating");
|
||||
#endif
|
||||
RDAT_ENUM_END()
|
||||
|
||||
RDAT_DXIL_ENUM_START(hlsl::DXIL::HitGroupType, uint32_t)
|
||||
RDAT_ENUM_VALUE_NODEF(Triangle)
|
||||
RDAT_ENUM_VALUE_NODEF(ProceduralPrimitive)
|
||||
RDAT_ENUM_VALUE_NODEF(Triangle)
|
||||
RDAT_ENUM_VALUE_NODEF(ProceduralPrimitive)
|
||||
#if DEF_RDAT_ENUMS == DEF_RDAT_DUMP_IMPL
|
||||
static_assert((unsigned)hlsl::DXIL::HitGroupType::LastEntry == 2, "otherwise, RDAT_DXIL_ENUM definition needs updating");
|
||||
static_assert((unsigned)hlsl::DXIL::HitGroupType::LastEntry == 2,
|
||||
"otherwise, RDAT_DXIL_ENUM definition needs updating");
|
||||
#endif
|
||||
RDAT_ENUM_END()
|
||||
|
||||
RDAT_DXIL_ENUM_START(hlsl::DXIL::RaytracingPipelineFlags, uint32_t)
|
||||
RDAT_ENUM_VALUE_NODEF(None)
|
||||
RDAT_ENUM_VALUE_NODEF(SkipTriangles)
|
||||
RDAT_ENUM_VALUE_NODEF(SkipProceduralPrimitives)
|
||||
// No need to define mask here
|
||||
//RDAT_ENUM_VALUE_NODEF(ValidMask)
|
||||
RDAT_ENUM_VALUE_NODEF(None)
|
||||
RDAT_ENUM_VALUE_NODEF(SkipTriangles)
|
||||
RDAT_ENUM_VALUE_NODEF(SkipProceduralPrimitives)
|
||||
// No need to define mask here
|
||||
// RDAT_ENUM_VALUE_NODEF(ValidMask)
|
||||
#if DEF_RDAT_ENUMS == DEF_RDAT_DUMP_IMPL
|
||||
static_assert((unsigned)hlsl::DXIL::RaytracingPipelineFlags::ValidMask == 0x300, "otherwise, RDAT_DXIL_ENUM definition needs updating");
|
||||
static_assert((unsigned)hlsl::DXIL::RaytracingPipelineFlags::ValidMask == 0x300,
|
||||
"otherwise, RDAT_DXIL_ENUM definition needs updating");
|
||||
#endif
|
||||
RDAT_ENUM_END()
|
||||
|
||||
|
@ -70,79 +74,96 @@ RDAT_ENUM_END()
|
|||
|
||||
#define RECORD_TYPE StateObjectConfig_t
|
||||
RDAT_STRUCT(StateObjectConfig_t)
|
||||
RDAT_FLAGS(uint32_t, hlsl::DXIL::StateObjectFlags, Flags)
|
||||
RDAT_FLAGS(uint32_t, hlsl::DXIL::StateObjectFlags, Flags)
|
||||
RDAT_STRUCT_END()
|
||||
#undef RECORD_TYPE
|
||||
|
||||
#define RECORD_TYPE RootSignature_t
|
||||
RDAT_STRUCT(RootSignature_t)
|
||||
RDAT_BYTES(Data)
|
||||
RDAT_BYTES(Data)
|
||||
RDAT_STRUCT_END()
|
||||
#undef RECORD_TYPE
|
||||
|
||||
#define RECORD_TYPE SubobjectToExportsAssociation_t
|
||||
RDAT_STRUCT(SubobjectToExportsAssociation_t)
|
||||
RDAT_STRING(Subobject)
|
||||
RDAT_STRING_ARRAY_REF(Exports)
|
||||
RDAT_STRING(Subobject)
|
||||
RDAT_STRING_ARRAY_REF(Exports)
|
||||
RDAT_STRUCT_END()
|
||||
#undef RECORD_TYPE
|
||||
|
||||
#define RECORD_TYPE RaytracingShaderConfig_t
|
||||
RDAT_STRUCT(RaytracingShaderConfig_t)
|
||||
RDAT_VALUE(uint32_t, MaxPayloadSizeInBytes)
|
||||
RDAT_VALUE(uint32_t, MaxAttributeSizeInBytes)
|
||||
RDAT_VALUE(uint32_t, MaxPayloadSizeInBytes)
|
||||
RDAT_VALUE(uint32_t, MaxAttributeSizeInBytes)
|
||||
RDAT_STRUCT_END()
|
||||
#undef RECORD_TYPE
|
||||
|
||||
#define RECORD_TYPE RaytracingPipelineConfig_t
|
||||
RDAT_STRUCT(RaytracingPipelineConfig_t)
|
||||
RDAT_VALUE(uint32_t, MaxTraceRecursionDepth)
|
||||
RDAT_VALUE(uint32_t, MaxTraceRecursionDepth)
|
||||
RDAT_STRUCT_END()
|
||||
#undef RECORD_TYPE
|
||||
|
||||
#define RECORD_TYPE HitGroup_t
|
||||
RDAT_STRUCT(HitGroup_t)
|
||||
RDAT_ENUM(uint32_t, hlsl::DXIL::HitGroupType, Type)
|
||||
RDAT_STRING(AnyHit)
|
||||
RDAT_STRING(ClosestHit)
|
||||
RDAT_STRING(Intersection)
|
||||
RDAT_ENUM(uint32_t, hlsl::DXIL::HitGroupType, Type)
|
||||
RDAT_STRING(AnyHit)
|
||||
RDAT_STRING(ClosestHit)
|
||||
RDAT_STRING(Intersection)
|
||||
RDAT_STRUCT_END()
|
||||
#undef RECORD_TYPE
|
||||
|
||||
#define RECORD_TYPE RaytracingPipelineConfig1_t
|
||||
RDAT_STRUCT(RaytracingPipelineConfig1_t)
|
||||
RDAT_VALUE(uint32_t, MaxTraceRecursionDepth)
|
||||
RDAT_FLAGS(uint32_t, hlsl::DXIL::RaytracingPipelineFlags, Flags)
|
||||
RDAT_VALUE(uint32_t, MaxTraceRecursionDepth)
|
||||
RDAT_FLAGS(uint32_t, hlsl::DXIL::RaytracingPipelineFlags, Flags)
|
||||
RDAT_STRUCT_END()
|
||||
#undef RECORD_TYPE
|
||||
|
||||
#define RECORD_TYPE RuntimeDataSubobjectInfo
|
||||
RDAT_STRUCT_TABLE(RuntimeDataSubobjectInfo, SubobjectTable)
|
||||
RDAT_ENUM(uint32_t, hlsl::DXIL::SubobjectKind, Kind)
|
||||
RDAT_STRING(Name)
|
||||
RDAT_UNION()
|
||||
RDAT_UNION_IF(StateObjectConfig, ((uint32_t)pRecord->Kind == (uint32_t)hlsl::DXIL::SubobjectKind::StateObjectConfig))
|
||||
RDAT_RECORD_VALUE(StateObjectConfig_t, StateObjectConfig)
|
||||
RDAT_UNION_ELIF(RootSignature,
|
||||
((uint32_t)pRecord->Kind == (uint32_t)hlsl::DXIL::SubobjectKind::GlobalRootSignature) ||
|
||||
((uint32_t)pRecord->Kind == (uint32_t)hlsl::DXIL::SubobjectKind::LocalRootSignature))
|
||||
RDAT_RECORD_VALUE(RootSignature_t, RootSignature)
|
||||
RDAT_UNION_ELIF(SubobjectToExportsAssociation, ((uint32_t)pRecord->Kind == (uint32_t)hlsl::DXIL::SubobjectKind::SubobjectToExportsAssociation))
|
||||
RDAT_RECORD_VALUE(SubobjectToExportsAssociation_t, SubobjectToExportsAssociation)
|
||||
RDAT_UNION_ELIF(RaytracingShaderConfig, ((uint32_t)pRecord->Kind == (uint32_t)hlsl::DXIL::SubobjectKind::RaytracingShaderConfig))
|
||||
RDAT_RECORD_VALUE(RaytracingShaderConfig_t, RaytracingShaderConfig)
|
||||
RDAT_UNION_ELIF(RaytracingPipelineConfig, ((uint32_t)pRecord->Kind == (uint32_t)hlsl::DXIL::SubobjectKind::RaytracingPipelineConfig))
|
||||
RDAT_RECORD_VALUE(RaytracingPipelineConfig_t, RaytracingPipelineConfig)
|
||||
RDAT_UNION_ELIF(HitGroup, ((uint32_t)pRecord->Kind == (uint32_t)hlsl::DXIL::SubobjectKind::HitGroup))
|
||||
RDAT_RECORD_VALUE(HitGroup_t, HitGroup)
|
||||
RDAT_UNION_ELIF(RaytracingPipelineConfig1, ((uint32_t)pRecord->Kind == (uint32_t)hlsl::DXIL::SubobjectKind::RaytracingPipelineConfig1))
|
||||
RDAT_RECORD_VALUE(RaytracingPipelineConfig1_t, RaytracingPipelineConfig1)
|
||||
RDAT_UNION_ENDIF()
|
||||
RDAT_UNION_END()
|
||||
RDAT_ENUM(uint32_t, hlsl::DXIL::SubobjectKind, Kind)
|
||||
RDAT_STRING(Name)
|
||||
RDAT_UNION()
|
||||
RDAT_UNION_IF(StateObjectConfig,
|
||||
((uint32_t)pRecord->Kind ==
|
||||
(uint32_t)hlsl::DXIL::SubobjectKind::StateObjectConfig))
|
||||
RDAT_RECORD_VALUE(StateObjectConfig_t, StateObjectConfig)
|
||||
RDAT_UNION_ELIF(RootSignature,
|
||||
((uint32_t)pRecord->Kind ==
|
||||
(uint32_t)hlsl::DXIL::SubobjectKind::GlobalRootSignature) ||
|
||||
((uint32_t)pRecord->Kind ==
|
||||
(uint32_t)hlsl::DXIL::SubobjectKind::LocalRootSignature))
|
||||
RDAT_RECORD_VALUE(RootSignature_t, RootSignature)
|
||||
RDAT_UNION_ELIF(
|
||||
SubobjectToExportsAssociation,
|
||||
((uint32_t)pRecord->Kind ==
|
||||
(uint32_t)hlsl::DXIL::SubobjectKind::SubobjectToExportsAssociation))
|
||||
RDAT_RECORD_VALUE(SubobjectToExportsAssociation_t,
|
||||
SubobjectToExportsAssociation)
|
||||
RDAT_UNION_ELIF(RaytracingShaderConfig,
|
||||
((uint32_t)pRecord->Kind ==
|
||||
(uint32_t)hlsl::DXIL::SubobjectKind::RaytracingShaderConfig))
|
||||
RDAT_RECORD_VALUE(RaytracingShaderConfig_t, RaytracingShaderConfig)
|
||||
RDAT_UNION_ELIF(RaytracingPipelineConfig,
|
||||
((uint32_t)pRecord->Kind ==
|
||||
(uint32_t)hlsl::DXIL::SubobjectKind::RaytracingPipelineConfig))
|
||||
RDAT_RECORD_VALUE(RaytracingPipelineConfig_t, RaytracingPipelineConfig)
|
||||
RDAT_UNION_ELIF(HitGroup, ((uint32_t)pRecord->Kind ==
|
||||
(uint32_t)hlsl::DXIL::SubobjectKind::HitGroup))
|
||||
RDAT_RECORD_VALUE(HitGroup_t, HitGroup)
|
||||
RDAT_UNION_ELIF(
|
||||
RaytracingPipelineConfig1,
|
||||
((uint32_t)pRecord->Kind ==
|
||||
(uint32_t)hlsl::DXIL::SubobjectKind::RaytracingPipelineConfig1))
|
||||
RDAT_RECORD_VALUE(RaytracingPipelineConfig1_t, RaytracingPipelineConfig1)
|
||||
RDAT_UNION_ENDIF()
|
||||
RDAT_UNION_END()
|
||||
|
||||
// Note: this is how one could inject custom code into one of the definition modes:
|
||||
// Note: this is how one could inject custom code into one of the definition
|
||||
// modes:
|
||||
#if DEF_RDAT_TYPES == DEF_RDAT_READER
|
||||
// Add custom code here that only gets added to the reader class definition
|
||||
// Add custom code here that only gets added to the reader class definition
|
||||
#endif
|
||||
|
||||
RDAT_STRUCT_END()
|
||||
|
|
|
@ -28,17 +28,18 @@ ModulePass *createDxilShaderAccessTrackingPass();
|
|||
ModulePass *createDxilPIXAddTidToAmplificationShaderPayloadPass();
|
||||
ModulePass *createDxilPIXDXRInvocationsLogPass();
|
||||
|
||||
void initializeDxilAddPixelHitInstrumentationPass(llvm::PassRegistry&);
|
||||
void initializeDxilDbgValueToDbgDeclarePass(llvm::PassRegistry&);
|
||||
void initializeDxilAnnotateWithVirtualRegisterPass(llvm::PassRegistry&);
|
||||
void initializeDxilOutputColorBecomesConstantPass(llvm::PassRegistry&);
|
||||
void initializeDxilAddPixelHitInstrumentationPass(llvm::PassRegistry &);
|
||||
void initializeDxilDbgValueToDbgDeclarePass(llvm::PassRegistry &);
|
||||
void initializeDxilAnnotateWithVirtualRegisterPass(llvm::PassRegistry &);
|
||||
void initializeDxilOutputColorBecomesConstantPass(llvm::PassRegistry &);
|
||||
void initializeDxilPIXMeshShaderOutputInstrumentationPass(llvm::PassRegistry &);
|
||||
void initializeDxilRemoveDiscardsPass(llvm::PassRegistry&);
|
||||
void initializeDxilReduceMSAAToSingleSamplePass(llvm::PassRegistry&);
|
||||
void initializeDxilForceEarlyZPass(llvm::PassRegistry&);
|
||||
void initializeDxilDebugInstrumentationPass(llvm::PassRegistry&);
|
||||
void initializeDxilShaderAccessTrackingPass(llvm::PassRegistry&);
|
||||
void initializeDxilPIXAddTidToAmplificationShaderPayloadPass(llvm::PassRegistry&);
|
||||
void initializeDxilPIXDXRInvocationsLogPass(llvm::PassRegistry&);
|
||||
void initializeDxilRemoveDiscardsPass(llvm::PassRegistry &);
|
||||
void initializeDxilReduceMSAAToSingleSamplePass(llvm::PassRegistry &);
|
||||
void initializeDxilForceEarlyZPass(llvm::PassRegistry &);
|
||||
void initializeDxilDebugInstrumentationPass(llvm::PassRegistry &);
|
||||
void initializeDxilShaderAccessTrackingPass(llvm::PassRegistry &);
|
||||
void initializeDxilPIXAddTidToAmplificationShaderPayloadPass(
|
||||
llvm::PassRegistry &);
|
||||
void initializeDxilPIXDXRInvocationsLogPass(llvm::PassRegistry &);
|
||||
|
||||
}
|
||||
} // namespace llvm
|
||||
|
|
|
@ -19,16 +19,17 @@ class LLVMContext;
|
|||
class MDNode;
|
||||
class StoreInst;
|
||||
class Value;
|
||||
} // namespace llvm
|
||||
} // namespace llvm
|
||||
|
||||
namespace pix_dxil {
|
||||
namespace PixDxilInstNum {
|
||||
static constexpr char MDName[] = "pix-dxil-inst-num";
|
||||
static constexpr uint32_t ID = 3;
|
||||
|
||||
void AddMD(llvm::LLVMContext &Ctx, llvm::Instruction *pI, std::uint32_t InstNum);
|
||||
void AddMD(llvm::LLVMContext &Ctx, llvm::Instruction *pI,
|
||||
std::uint32_t InstNum);
|
||||
bool FromInst(llvm::Instruction *pI, std::uint32_t *pInstNum);
|
||||
} // namespace PixDxilInstNum
|
||||
} // namespace PixDxilInstNum
|
||||
|
||||
namespace PixDxilReg {
|
||||
static constexpr char MDName[] = "pix-dxil-reg";
|
||||
|
@ -36,20 +37,24 @@ static constexpr uint32_t ID = 0;
|
|||
|
||||
void AddMD(llvm::LLVMContext &Ctx, llvm::Instruction *pI, std::uint32_t RegNum);
|
||||
bool FromInst(llvm::Instruction *pI, std::uint32_t *pRegNum);
|
||||
} // namespace PixDxilReg
|
||||
} // namespace PixDxilReg
|
||||
|
||||
namespace PixAllocaReg {
|
||||
static constexpr char MDName[] = "pix-alloca-reg";
|
||||
static constexpr uint32_t ID = 1;
|
||||
|
||||
void AddMD(llvm::LLVMContext &Ctx, llvm::AllocaInst *pAlloca, std::uint32_t RegNum, std::uint32_t Count);
|
||||
bool FromInst(llvm::AllocaInst *pAlloca, std::uint32_t *pRegBase, std::uint32_t *pRegSize);
|
||||
} // namespace PixAllocaReg
|
||||
void AddMD(llvm::LLVMContext &Ctx, llvm::AllocaInst *pAlloca,
|
||||
std::uint32_t RegNum, std::uint32_t Count);
|
||||
bool FromInst(llvm::AllocaInst *pAlloca, std::uint32_t *pRegBase,
|
||||
std::uint32_t *pRegSize);
|
||||
} // namespace PixAllocaReg
|
||||
|
||||
namespace PixAllocaRegWrite {
|
||||
static constexpr char MDName[] = "pix-alloca-reg-write";
|
||||
static constexpr uint32_t ID = 2;
|
||||
void AddMD(llvm::LLVMContext &Ctx, llvm::StoreInst *pSt, llvm::MDNode *pAllocaReg, llvm::Value *Index);
|
||||
bool FromInst(llvm::StoreInst *pI, std::uint32_t *pRegBase, std::uint32_t *pRegSize, llvm::Value **pIndex);
|
||||
} // namespace PixAllocaRegWrite
|
||||
} // namespace pix_dxil
|
||||
void AddMD(llvm::LLVMContext &Ctx, llvm::StoreInst *pSt,
|
||||
llvm::MDNode *pAllocaReg, llvm::Value *Index);
|
||||
bool FromInst(llvm::StoreInst *pI, std::uint32_t *pRegBase,
|
||||
std::uint32_t *pRegSize, llvm::Value **pIndex);
|
||||
} // namespace PixAllocaRegWrite
|
||||
} // namespace pix_dxil
|
|
@ -18,7 +18,7 @@ struct IMalloc;
|
|||
|
||||
namespace hlsl {
|
||||
|
||||
HRESULT WritePdbInfoPart(IMalloc *pMalloc, const void *pUncompressedPdbInfoData, size_t size, std::vector<char> *outBuffer);
|
||||
HRESULT WritePdbInfoPart(IMalloc *pMalloc, const void *pUncompressedPdbInfoData,
|
||||
size_t size, std::vector<char> *outBuffer);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -16,14 +16,14 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "dxc/WinAdapter.h"
|
||||
#include "dxc/DXIL/DxilConstants.h"
|
||||
#include "dxc/WinAdapter.h"
|
||||
|
||||
struct IDxcBlob;
|
||||
struct IDxcBlobEncoding;
|
||||
|
||||
namespace llvm {
|
||||
class raw_ostream;
|
||||
class raw_ostream;
|
||||
}
|
||||
|
||||
namespace hlsl {
|
||||
|
@ -47,14 +47,14 @@ struct DxilVersionedRootSignatureDesc;
|
|||
static const uint32_t DxilDescriptorRangeOffsetAppend = 0xffffffff;
|
||||
static const uint32_t DxilSystemReservedRegisterSpaceValuesStart = 0xfffffff0;
|
||||
static const uint32_t DxilSystemReservedRegisterSpaceValuesEnd = 0xffffffff;
|
||||
#define DxilMipLodBiaxMax ( 15.99f )
|
||||
#define DxilMipLodBiaxMin ( -16.0f )
|
||||
#define DxilFloat32Max ( 3.402823466e+38f )
|
||||
#define DxilMipLodBiaxMax (15.99f)
|
||||
#define DxilMipLodBiaxMin (-16.0f)
|
||||
#define DxilFloat32Max (3.402823466e+38f)
|
||||
static const uint32_t DxilMipLodFractionalBitCount = 8;
|
||||
static const uint32_t DxilMapAnisotropy = 16;
|
||||
|
||||
// Enumerations and flags.
|
||||
enum class DxilComparisonFunc : unsigned{
|
||||
enum class DxilComparisonFunc : unsigned {
|
||||
Never = 1,
|
||||
Less = 2,
|
||||
Equal = 3,
|
||||
|
@ -190,22 +190,19 @@ enum class DxilTextureAddressMode {
|
|||
|
||||
// Structure definitions for serialized structures.
|
||||
#pragma pack(push, 1)
|
||||
struct DxilContainerRootDescriptor1
|
||||
{
|
||||
struct DxilContainerRootDescriptor1 {
|
||||
uint32_t ShaderRegister;
|
||||
uint32_t RegisterSpace;
|
||||
uint32_t Flags;
|
||||
};
|
||||
struct DxilContainerDescriptorRange
|
||||
{
|
||||
struct DxilContainerDescriptorRange {
|
||||
uint32_t RangeType;
|
||||
uint32_t NumDescriptors;
|
||||
uint32_t BaseShaderRegister;
|
||||
uint32_t RegisterSpace;
|
||||
uint32_t OffsetInDescriptorsFromTableStart;
|
||||
};
|
||||
struct DxilContainerDescriptorRange1
|
||||
{
|
||||
struct DxilContainerDescriptorRange1 {
|
||||
uint32_t RangeType;
|
||||
uint32_t NumDescriptors;
|
||||
uint32_t BaseShaderRegister;
|
||||
|
@ -213,19 +210,16 @@ struct DxilContainerDescriptorRange1
|
|||
uint32_t Flags;
|
||||
uint32_t OffsetInDescriptorsFromTableStart;
|
||||
};
|
||||
struct DxilContainerRootDescriptorTable
|
||||
{
|
||||
struct DxilContainerRootDescriptorTable {
|
||||
uint32_t NumDescriptorRanges;
|
||||
uint32_t DescriptorRangesOffset;
|
||||
};
|
||||
struct DxilContainerRootParameter
|
||||
{
|
||||
struct DxilContainerRootParameter {
|
||||
uint32_t ParameterType;
|
||||
uint32_t ShaderVisibility;
|
||||
uint32_t PayloadOffset;
|
||||
};
|
||||
struct DxilContainerRootSignatureDesc
|
||||
{
|
||||
struct DxilContainerRootSignatureDesc {
|
||||
uint32_t Version;
|
||||
uint32_t NumParameters;
|
||||
uint32_t RootParametersOffset;
|
||||
|
@ -328,14 +322,17 @@ struct DxilVersionedRootSignatureDesc {
|
|||
};
|
||||
};
|
||||
|
||||
void printRootSignature(const DxilVersionedRootSignatureDesc &RS, llvm::raw_ostream &os);
|
||||
void printRootSignature(const DxilVersionedRootSignatureDesc &RS,
|
||||
llvm::raw_ostream &os);
|
||||
|
||||
// Use this class to represent a root signature that may be in memory or serialized.
|
||||
// There is just enough API surface to help callers not take a dependency on Windows headers.
|
||||
// Use this class to represent a root signature that may be in memory or
|
||||
// serialized. There is just enough API surface to help callers not take a
|
||||
// dependency on Windows headers.
|
||||
class RootSignatureHandle {
|
||||
private:
|
||||
const DxilVersionedRootSignatureDesc *m_pDesc;
|
||||
IDxcBlob *m_pSerialized;
|
||||
|
||||
public:
|
||||
RootSignatureHandle() : m_pDesc(nullptr), m_pSerialized(nullptr) {}
|
||||
RootSignatureHandle(const RootSignatureHandle &) = delete;
|
||||
|
@ -349,7 +346,8 @@ public:
|
|||
const uint8_t *GetSerializedBytes() const;
|
||||
unsigned GetSerializedSize() const;
|
||||
|
||||
void Assign(const DxilVersionedRootSignatureDesc *pDesc, IDxcBlob *pSerialized);
|
||||
void Assign(const DxilVersionedRootSignatureDesc *pDesc,
|
||||
IDxcBlob *pSerialized);
|
||||
void Clear();
|
||||
void LoadSerialized(const uint8_t *pData, uint32_t length);
|
||||
void EnsureSerializedAvailable();
|
||||
|
@ -358,12 +356,14 @@ public:
|
|||
const DxilVersionedRootSignatureDesc *GetDesc() const { return m_pDesc; }
|
||||
};
|
||||
|
||||
void DeleteRootSignature(const DxilVersionedRootSignatureDesc *pRootSignature);
|
||||
void DeleteRootSignature(const DxilVersionedRootSignatureDesc *pRootSignature);
|
||||
|
||||
// Careful to delete: returns the original root signature, if conversion is not required.
|
||||
void ConvertRootSignature(const DxilVersionedRootSignatureDesc* pRootSignatureIn,
|
||||
DxilRootSignatureVersion RootSignatureVersionOut,
|
||||
const DxilVersionedRootSignatureDesc ** ppRootSignatureOut);
|
||||
// Careful to delete: returns the original root signature, if conversion is not
|
||||
// required.
|
||||
void ConvertRootSignature(
|
||||
const DxilVersionedRootSignatureDesc *pRootSignatureIn,
|
||||
DxilRootSignatureVersion RootSignatureVersionOut,
|
||||
const DxilVersionedRootSignatureDesc **ppRootSignatureOut);
|
||||
|
||||
void SerializeRootSignature(
|
||||
const DxilVersionedRootSignatureDesc *pRootSignature, IDxcBlob **ppBlob,
|
||||
|
@ -387,7 +387,7 @@ class DxilVersionedRootSignature {
|
|||
DxilVersionedRootSignatureDesc *m_pRootSignature;
|
||||
|
||||
public:
|
||||
// Non-copyable:
|
||||
// Non-copyable:
|
||||
DxilVersionedRootSignature(DxilVersionedRootSignature const &) = delete;
|
||||
DxilVersionedRootSignature const &
|
||||
operator=(DxilVersionedRootSignature const &) = delete;
|
||||
|
@ -401,23 +401,20 @@ public:
|
|||
explicit DxilVersionedRootSignature(
|
||||
const DxilVersionedRootSignatureDesc *pRootSignature)
|
||||
: m_pRootSignature(
|
||||
const_cast<DxilVersionedRootSignatureDesc *> (pRootSignature)) {}
|
||||
~DxilVersionedRootSignature() {
|
||||
DeleteRootSignature(m_pRootSignature);
|
||||
}
|
||||
const DxilVersionedRootSignatureDesc* operator -> () const {
|
||||
const_cast<DxilVersionedRootSignatureDesc *>(pRootSignature)) {}
|
||||
~DxilVersionedRootSignature() { DeleteRootSignature(m_pRootSignature); }
|
||||
const DxilVersionedRootSignatureDesc *operator->() const {
|
||||
return m_pRootSignature;
|
||||
}
|
||||
const DxilVersionedRootSignatureDesc ** get_address_of() {
|
||||
const DxilVersionedRootSignatureDesc **get_address_of() {
|
||||
if (m_pRootSignature != nullptr)
|
||||
return nullptr; // You're probably about to leak...
|
||||
return const_cast<const DxilVersionedRootSignatureDesc **> (&m_pRootSignature);
|
||||
return const_cast<const DxilVersionedRootSignatureDesc **>(
|
||||
&m_pRootSignature);
|
||||
}
|
||||
const DxilVersionedRootSignatureDesc* get() const {
|
||||
return m_pRootSignature;
|
||||
}
|
||||
DxilVersionedRootSignatureDesc* get_mutable() const {
|
||||
return m_pRootSignature;
|
||||
const DxilVersionedRootSignatureDesc *get() const { return m_pRootSignature; }
|
||||
DxilVersionedRootSignatureDesc *get_mutable() const {
|
||||
return m_pRootSignature;
|
||||
}
|
||||
};
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -5,52 +5,52 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace llvm
|
||||
{
|
||||
class CallInst;
|
||||
class Function;
|
||||
class Module;
|
||||
class Type;
|
||||
}
|
||||
namespace llvm {
|
||||
class CallInst;
|
||||
class Function;
|
||||
class Module;
|
||||
class Type;
|
||||
} // namespace llvm
|
||||
|
||||
// Combines DXIL raytracing shaders together into a compute shader.
|
||||
//
|
||||
// The incoming module should contain the following functions if the corresponding
|
||||
// intrinsic are called by the specified shaders,
|
||||
// if called:
|
||||
// Fallback_TraceRay()
|
||||
// The incoming module should contain the following functions if the
|
||||
// corresponding intrinsic are called by the specified shaders, if called:
|
||||
// Fallback_TraceRay()
|
||||
// Fallback_Ignore()
|
||||
// Fallback_AcceptHitAndEndSearch()
|
||||
// Fallback_ReportHit()
|
||||
//
|
||||
// Fallback_TraceRay() will be called with the original arguments, substituting
|
||||
// the offset of the payload on the stack for the actual payload.
|
||||
// the offset of the payload on the stack for the actual payload.
|
||||
// Fallback_TraceRay() will also be used to replace calls to TraceRayTest().
|
||||
//
|
||||
// ReportHit() returns a boolean. But to handle the abort of the intersection
|
||||
// shader when AcceptHitAndEndSearch() is called we need a third return value.
|
||||
// Fallback_ReportHit() should return an integer < 0 for end search, 0 for ignore,
|
||||
// and > 0 for accept.
|
||||
// Fallback_ReportHit() should return an integer < 0 for end search, 0 for
|
||||
// ignore, and > 0 for accept.
|
||||
//
|
||||
// The module should also contain a single call to Fallback_Scheduler() in the
|
||||
// entry shader for the raytracing compute shader.
|
||||
//
|
||||
// resizeStack() needs to be called after inlining everything in the compute
|
||||
// resizeStack() needs to be called after inlining everything in the compute
|
||||
// shader.
|
||||
//
|
||||
// Currently the main scheduling loop and the implementation for intrinsic
|
||||
// Currently the main scheduling loop and the implementation for intrinsic
|
||||
// functions come from an internal runtime module.
|
||||
class DxrFallbackCompiler
|
||||
{
|
||||
class DxrFallbackCompiler {
|
||||
public:
|
||||
typedef std::map<int, std::string> IntToFuncNameMap;
|
||||
|
||||
// If findCalledShaders is true, then the list of shaderNames is expanded to
|
||||
// include shader functions (functions with attribute "exp-shader") that are
|
||||
// If findCalledShaders is true, then the list of shaderNames is expanded to
|
||||
// include shader functions (functions with attribute "exp-shader") that are
|
||||
// called by functions in shaderNames. Shader entry state IDs are still
|
||||
// returned only for those originally in shaderNames. findCalledShaders used
|
||||
// returned only for those originally in shaderNames. findCalledShaders used
|
||||
// for testing.
|
||||
DxrFallbackCompiler(llvm::Module* mod, const std::vector<std::string>& shaderNames, unsigned maxAttributeSize, unsigned stackSizeInBytes, bool findCalledShaders = false);
|
||||
DxrFallbackCompiler(llvm::Module *mod,
|
||||
const std::vector<std::string> &shaderNames,
|
||||
unsigned maxAttributeSize, unsigned stackSizeInBytes,
|
||||
bool findCalledShaders = false);
|
||||
|
||||
// 0 - no debug output
|
||||
// 1 - dump initial combined module, compiled module, and final linked module
|
||||
|
@ -58,19 +58,25 @@ public:
|
|||
// 3 - dump intermediate stages of SFT to file
|
||||
void setDebugOutputLevel(int val);
|
||||
|
||||
// Returns the entry state id for each of shaderNames. The transformations
|
||||
// Returns the entry state id for each of shaderNames. The transformations
|
||||
// are performed in place on the module.
|
||||
void compile(std::vector<int>& shaderEntryStateIds, std::vector<unsigned int> &shaderStackSizes, IntToFuncNameMap *pCachedMap);
|
||||
void link(std::vector<int>& shaderEntryStateIds, std::vector<unsigned int> &shaderStackSizes, IntToFuncNameMap *pCachedMap);
|
||||
// TODO: Ideally we would run this after inlining everything at the end of compile.
|
||||
// Until we figure out to do this, we will call the function after the final link.
|
||||
static void resizeStack(llvm::Function* F, unsigned stackSizeInBytes);
|
||||
private:
|
||||
typedef std::map<int, llvm::Function*> IntToFuncMap;
|
||||
typedef std::map<std::string, llvm::Function*> StringToFuncMap;
|
||||
void compile(std::vector<int> &shaderEntryStateIds,
|
||||
std::vector<unsigned int> &shaderStackSizes,
|
||||
IntToFuncNameMap *pCachedMap);
|
||||
void link(std::vector<int> &shaderEntryStateIds,
|
||||
std::vector<unsigned int> &shaderStackSizes,
|
||||
IntToFuncNameMap *pCachedMap);
|
||||
// TODO: Ideally we would run this after inlining everything at the end of
|
||||
// compile. Until we figure out to do this, we will call the function after
|
||||
// the final link.
|
||||
static void resizeStack(llvm::Function *F, unsigned stackSizeInBytes);
|
||||
|
||||
llvm::Module* m_module = nullptr;
|
||||
const std::vector<std::string>& m_entryShaderNames;
|
||||
private:
|
||||
typedef std::map<int, llvm::Function *> IntToFuncMap;
|
||||
typedef std::map<std::string, llvm::Function *> StringToFuncMap;
|
||||
|
||||
llvm::Module *m_module = nullptr;
|
||||
const std::vector<std::string> &m_entryShaderNames;
|
||||
unsigned m_stackSizeInBytes = 0;
|
||||
unsigned m_maxAttributeSize = 0;
|
||||
bool m_findCalledShaders = false;
|
||||
|
@ -78,22 +84,31 @@ private:
|
|||
|
||||
StringToFuncMap m_shaderMap;
|
||||
|
||||
void initShaderMap(std::vector<std::string>& shaderNames);
|
||||
void initShaderMap(std::vector<std::string> &shaderNames);
|
||||
void linkRuntime();
|
||||
void lowerAnyHitControlFlowFuncs();
|
||||
void lowerReportHit();
|
||||
void lowerTraceRay(llvm::Type* runtimeDataArgTy);
|
||||
void createStateFunctions(IntToFuncMap& stateFunctionMap, std::vector<int>& shaderEntryStateIds, std::vector<unsigned int>& shaderStackSizes, int baseStateId, const std::vector<std::string>& shaderNames, llvm::Type* runtimeDataArgTy);
|
||||
void createLaunchParams(llvm::Function* func);
|
||||
void createStack(llvm::Function* func);
|
||||
void createStateDispatch(llvm::Function* func, const IntToFuncMap& stateFunctionMap, llvm::Type* runtimeDataArgTy);
|
||||
void lowerTraceRay(llvm::Type *runtimeDataArgTy);
|
||||
void createStateFunctions(IntToFuncMap &stateFunctionMap,
|
||||
std::vector<int> &shaderEntryStateIds,
|
||||
std::vector<unsigned int> &shaderStackSizes,
|
||||
int baseStateId,
|
||||
const std::vector<std::string> &shaderNames,
|
||||
llvm::Type *runtimeDataArgTy);
|
||||
void createLaunchParams(llvm::Function *func);
|
||||
void createStack(llvm::Function *func);
|
||||
void createStateDispatch(llvm::Function *func,
|
||||
const IntToFuncMap &stateFunctionMap,
|
||||
llvm::Type *runtimeDataArgTy);
|
||||
void lowerIntrinsics();
|
||||
|
||||
llvm::Type* getRuntimeDataArgType();
|
||||
llvm::Function* createDispatchFunction(const IntToFuncMap &stateFunctionMap, llvm::Type* runtimeDataArgTy);
|
||||
llvm::Type *getRuntimeDataArgType();
|
||||
llvm::Function *createDispatchFunction(const IntToFuncMap &stateFunctionMap,
|
||||
llvm::Type *runtimeDataArgTy);
|
||||
|
||||
// These functions return calls only in shaders in m_shaderMap.
|
||||
std::vector<llvm::CallInst*> getCallsInShadersToFunction(const std::string& funcName);
|
||||
std::vector<llvm::CallInst*> getCallsInShadersToFunctionWithPrefix(const std::string& funcNamePrefix);
|
||||
|
||||
std::vector<llvm::CallInst *>
|
||||
getCallsInShadersToFunction(const std::string &funcName);
|
||||
std::vector<llvm::CallInst *>
|
||||
getCallsInShadersToFunctionWithPrefix(const std::string &funcNamePrefix);
|
||||
};
|
||||
|
|
|
@ -12,31 +12,31 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
#include "llvm/Pass.h"
|
||||
#include "dxc/HLSL/ControlDependence.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Support/GenericDomTree.h"
|
||||
|
||||
#include <memory>
|
||||
#include <bitset>
|
||||
#include <unordered_set>
|
||||
#include <unordered_map>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace llvm {
|
||||
class Module;
|
||||
class Function;
|
||||
class BasicBlock;
|
||||
class Instruction;
|
||||
class ReturnInst;
|
||||
class Value;
|
||||
class PHINode;
|
||||
class AnalysisUsage;
|
||||
class CallGraph;
|
||||
class CallGraphNode;
|
||||
class ModulePass;
|
||||
class raw_ostream;
|
||||
}
|
||||
class Module;
|
||||
class Function;
|
||||
class BasicBlock;
|
||||
class Instruction;
|
||||
class ReturnInst;
|
||||
class Value;
|
||||
class PHINode;
|
||||
class AnalysisUsage;
|
||||
class CallGraph;
|
||||
class CallGraphNode;
|
||||
class ModulePass;
|
||||
class raw_ostream;
|
||||
} // namespace llvm
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
|
@ -46,16 +46,16 @@ class DxilSignatureElement;
|
|||
|
||||
struct DxilViewIdStateData {
|
||||
static const unsigned kNumComps = 4;
|
||||
static const unsigned kMaxSigScalars = 32*4;
|
||||
static const unsigned kMaxSigScalars = 32 * 4;
|
||||
|
||||
using OutputsDependentOnViewIdType = std::bitset<kMaxSigScalars>;
|
||||
using InputsContributingToOutputType = std::map<unsigned, std::set<unsigned>>;
|
||||
|
||||
static const unsigned kNumStreams = 4;
|
||||
|
||||
unsigned m_NumInputSigScalars = 0;
|
||||
unsigned m_NumOutputSigScalars[kNumStreams] = {0,0,0,0};
|
||||
unsigned m_NumPCOrPrimSigScalars = 0;
|
||||
unsigned m_NumInputSigScalars = 0;
|
||||
unsigned m_NumOutputSigScalars[kNumStreams] = {0, 0, 0, 0};
|
||||
unsigned m_NumPCOrPrimSigScalars = 0;
|
||||
|
||||
// Set of scalar outputs dependent on ViewID.
|
||||
OutputsDependentOnViewIdType m_OutputsDependentOnViewId[kNumStreams];
|
||||
|
@ -63,7 +63,8 @@ struct DxilViewIdStateData {
|
|||
|
||||
// Set of scalar inputs contributing to computation of scalar outputs.
|
||||
InputsContributingToOutputType m_InputsContributingToOutputs[kNumStreams];
|
||||
InputsContributingToOutputType m_InputsContributingToPCOrPrimOutputs; // HS PC and MS Prim only.
|
||||
InputsContributingToOutputType
|
||||
m_InputsContributingToPCOrPrimOutputs; // HS PC and MS Prim only.
|
||||
InputsContributingToOutputType m_PCInputsContributingToOutputs; // DS only.
|
||||
|
||||
bool m_bUsesViewId = false;
|
||||
|
@ -71,7 +72,8 @@ struct DxilViewIdStateData {
|
|||
|
||||
class DxilViewIdState : public DxilViewIdStateData {
|
||||
static const unsigned kNumComps = 4;
|
||||
static const unsigned kMaxSigScalars = 32*4;
|
||||
static const unsigned kMaxSigScalars = 32 * 4;
|
||||
|
||||
public:
|
||||
using OutputsDependentOnViewIdType = std::bitset<kMaxSigScalars>;
|
||||
using InputsContributingToOutputType = std::map<unsigned, std::set<unsigned>>;
|
||||
|
@ -81,11 +83,15 @@ public:
|
|||
unsigned getNumInputSigScalars() const;
|
||||
unsigned getNumOutputSigScalars(unsigned StreamId) const;
|
||||
unsigned getNumPCSigScalars() const;
|
||||
const OutputsDependentOnViewIdType &getOutputsDependentOnViewId(unsigned StreamId) const;
|
||||
const OutputsDependentOnViewIdType &
|
||||
getOutputsDependentOnViewId(unsigned StreamId) const;
|
||||
const OutputsDependentOnViewIdType &getPCOutputsDependentOnViewId() const;
|
||||
const InputsContributingToOutputType &getInputsContributingToOutputs(unsigned StreamId) const;
|
||||
const InputsContributingToOutputType &getInputsContributingToPCOutputs() const;
|
||||
const InputsContributingToOutputType &getPCInputsContributingToOutputs() const;
|
||||
const InputsContributingToOutputType &
|
||||
getInputsContributingToOutputs(unsigned StreamId) const;
|
||||
const InputsContributingToOutputType &
|
||||
getInputsContributingToPCOutputs() const;
|
||||
const InputsContributingToOutputType &
|
||||
getPCInputsContributingToOutputs() const;
|
||||
|
||||
void Serialize();
|
||||
const std::vector<unsigned> &GetSerialized();
|
||||
|
@ -101,12 +107,11 @@ private:
|
|||
void Clear();
|
||||
};
|
||||
|
||||
} // end of hlsl namespace
|
||||
|
||||
} // namespace hlsl
|
||||
|
||||
namespace llvm {
|
||||
|
||||
void initializeComputeViewIdStatePass(llvm::PassRegistry &);
|
||||
llvm::ModulePass *createComputeViewIdStatePass();
|
||||
|
||||
} // end of llvm namespace
|
||||
} // namespace llvm
|
||||
|
|
|
@ -13,14 +13,13 @@
|
|||
#include "llvm/IR/BasicBlock.h"
|
||||
#include "llvm/IR/Dominators.h"
|
||||
|
||||
#include <unordered_set>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace llvm {
|
||||
class Function;
|
||||
class raw_ostream;
|
||||
}
|
||||
|
||||
class Function;
|
||||
class raw_ostream;
|
||||
} // namespace llvm
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
|
@ -37,15 +36,19 @@ public:
|
|||
|
||||
private:
|
||||
using BasicBlockVector = std::vector<llvm::BasicBlock *>;
|
||||
using ControlDependenceType = std::unordered_map<llvm::BasicBlock *, BasicBlockSet>;
|
||||
using ControlDependenceType =
|
||||
std::unordered_map<llvm::BasicBlock *, BasicBlockSet>;
|
||||
|
||||
llvm::Function *m_pFunc;
|
||||
ControlDependenceType m_ControlDependence;
|
||||
BasicBlockSet m_EmptyBBSet;
|
||||
|
||||
llvm::BasicBlock *GetIPostDom(PostDomRelationType &PostDomRel, llvm::BasicBlock *pBB);
|
||||
void ComputeRevTopOrderRec(PostDomRelationType &PostDomRel, llvm::BasicBlock *pBB,
|
||||
BasicBlockVector &RevTopOrder, BasicBlockSet &VisitedBBs);
|
||||
llvm::BasicBlock *GetIPostDom(PostDomRelationType &PostDomRel,
|
||||
llvm::BasicBlock *pBB);
|
||||
void ComputeRevTopOrderRec(PostDomRelationType &PostDomRel,
|
||||
llvm::BasicBlock *pBB,
|
||||
BasicBlockVector &RevTopOrder,
|
||||
BasicBlockSet &VisitedBBs);
|
||||
};
|
||||
|
||||
} // end of hlsl namespace
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -11,5 +11,5 @@
|
|||
#pragma once
|
||||
|
||||
namespace hlsl {
|
||||
static const char *kConvergentFunctionPrefix = "dxil.convergent.marker.";
|
||||
static const char *kConvergentFunctionPrefix = "dxil.convergent.marker.";
|
||||
}
|
|
@ -14,99 +14,102 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "llvm/ADT/MapVector.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/StringSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/MapVector.h"
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <unordered_set>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
class Function;
|
||||
class raw_ostream;
|
||||
}
|
||||
} // namespace llvm
|
||||
|
||||
namespace hlsl {
|
||||
namespace dxilutil {
|
||||
class ExportMap {
|
||||
public:
|
||||
typedef std::unordered_set<std::string> StringStore;
|
||||
typedef std::set<llvm::StringRef> NameSet;
|
||||
typedef llvm::MapVector< llvm::Function*, NameSet > RenameMap;
|
||||
typedef llvm::StringMap< llvm::StringSet<> > ExportMapByString;
|
||||
typedef ExportMapByString::iterator iterator;
|
||||
typedef ExportMapByString::const_iterator const_iterator;
|
||||
class ExportMap {
|
||||
public:
|
||||
typedef std::unordered_set<std::string> StringStore;
|
||||
typedef std::set<llvm::StringRef> NameSet;
|
||||
typedef llvm::MapVector<llvm::Function *, NameSet> RenameMap;
|
||||
typedef llvm::StringMap<llvm::StringSet<>> ExportMapByString;
|
||||
typedef ExportMapByString::iterator iterator;
|
||||
typedef ExportMapByString::const_iterator const_iterator;
|
||||
|
||||
ExportMap():m_ExportShadersOnly(false) {}
|
||||
void clear();
|
||||
bool empty() const;
|
||||
ExportMap() : m_ExportShadersOnly(false) {}
|
||||
void clear();
|
||||
bool empty() const;
|
||||
|
||||
void setExportShadersOnly(bool v) { m_ExportShadersOnly = v; }
|
||||
bool isExportShadersOnly() const { return m_ExportShadersOnly; }
|
||||
void setExportShadersOnly(bool v) { m_ExportShadersOnly = v; }
|
||||
bool isExportShadersOnly() const { return m_ExportShadersOnly; }
|
||||
|
||||
// Iterate export map by string name
|
||||
iterator begin() { return m_ExportMap.begin(); }
|
||||
const_iterator begin() const { return m_ExportMap.begin(); }
|
||||
iterator end() { return m_ExportMap.end(); }
|
||||
const_iterator end() const { return m_ExportMap.end(); }
|
||||
// Iterate export map by string name
|
||||
iterator begin() { return m_ExportMap.begin(); }
|
||||
const_iterator begin() const { return m_ExportMap.begin(); }
|
||||
iterator end() { return m_ExportMap.end(); }
|
||||
const_iterator end() const { return m_ExportMap.end(); }
|
||||
|
||||
// Initialize export map from option strings
|
||||
bool ParseExports(const std::vector<std::string> &exportOpts, llvm::raw_ostream &errors);
|
||||
// Add one export to the export map
|
||||
void Add(llvm::StringRef exportName, llvm::StringRef internalName = llvm::StringRef());
|
||||
// Return true if export is present, or m_ExportMap is empty
|
||||
bool IsExported(llvm::StringRef original) const;
|
||||
// Initialize export map from option strings
|
||||
bool ParseExports(const std::vector<std::string> &exportOpts,
|
||||
llvm::raw_ostream &errors);
|
||||
// Add one export to the export map
|
||||
void Add(llvm::StringRef exportName,
|
||||
llvm::StringRef internalName = llvm::StringRef());
|
||||
// Return true if export is present, or m_ExportMap is empty
|
||||
bool IsExported(llvm::StringRef original) const;
|
||||
|
||||
// Retrieve export entry by name. If Name is mangled, it will fallback to
|
||||
// search for unmangled version if exact match fails.
|
||||
// If result == end(), no matching export was found.
|
||||
ExportMapByString::const_iterator GetExportsByName(llvm::StringRef Name) const;
|
||||
// Retrieve export entry by name. If Name is mangled, it will fallback to
|
||||
// search for unmangled version if exact match fails.
|
||||
// If result == end(), no matching export was found.
|
||||
ExportMapByString::const_iterator
|
||||
GetExportsByName(llvm::StringRef Name) const;
|
||||
|
||||
// Call before processing functions for renaming and cloning validation
|
||||
void BeginProcessing();
|
||||
// Call before processing functions for renaming and cloning validation
|
||||
void BeginProcessing();
|
||||
|
||||
// Called for each function to be processed
|
||||
// In order to avoid intermediate name collisions during renaming,
|
||||
// if collisionAvoidanceRenaming is true:
|
||||
// non-exported functions will be renamed internal.<name>
|
||||
// functions exported with a different name will be renamed temp.<name>
|
||||
// returns true if function is exported
|
||||
bool ProcessFunction(llvm::Function *F, bool collisionAvoidanceRenaming);
|
||||
// Called for each function to be processed
|
||||
// In order to avoid intermediate name collisions during renaming,
|
||||
// if collisionAvoidanceRenaming is true:
|
||||
// non-exported functions will be renamed internal.<name>
|
||||
// functions exported with a different name will be renamed temp.<name>
|
||||
// returns true if function is exported
|
||||
bool ProcessFunction(llvm::Function *F, bool collisionAvoidanceRenaming);
|
||||
|
||||
// Add function to exports without checking export map or renaming
|
||||
// (useful for patch constant functions used by exported HS)
|
||||
void RegisterExportedFunction(llvm::Function *F);
|
||||
// Add function to exports without checking export map or renaming
|
||||
// (useful for patch constant functions used by exported HS)
|
||||
void RegisterExportedFunction(llvm::Function *F);
|
||||
|
||||
// Called to mark an internal name as used (remove from unused set)
|
||||
void UseExport(llvm::StringRef internalName);
|
||||
// Called to add an exported (full) name (for collision detection)
|
||||
void ExportName(llvm::StringRef exportName);
|
||||
// Called to mark an internal name as used (remove from unused set)
|
||||
void UseExport(llvm::StringRef internalName);
|
||||
// Called to add an exported (full) name (for collision detection)
|
||||
void ExportName(llvm::StringRef exportName);
|
||||
|
||||
// Called after functions are processed.
|
||||
// Returns true if no name collisions or unused exports are present.
|
||||
bool EndProcessing() const;
|
||||
const NameSet& GetNameCollisions() const { return m_NameCollisions; }
|
||||
const NameSet& GetUnusedExports() const { return m_UnusedExports; }
|
||||
// Called after functions are processed.
|
||||
// Returns true if no name collisions or unused exports are present.
|
||||
bool EndProcessing() const;
|
||||
const NameSet &GetNameCollisions() const { return m_NameCollisions; }
|
||||
const NameSet &GetUnusedExports() const { return m_UnusedExports; }
|
||||
|
||||
// GetRenames gets the map of mangled renames by function pointer
|
||||
const RenameMap &GetFunctionRenames() const { return m_RenameMap; }
|
||||
// GetRenames gets the map of mangled renames by function pointer
|
||||
const RenameMap &GetFunctionRenames() const { return m_RenameMap; }
|
||||
|
||||
private:
|
||||
// {"internalname": ("export1", "export2", ...), ...}
|
||||
ExportMapByString m_ExportMap;
|
||||
StringStore m_StringStorage;
|
||||
llvm::StringRef StoreString(llvm::StringRef str);
|
||||
private:
|
||||
// {"internalname": ("export1", "export2", ...), ...}
|
||||
ExportMapByString m_ExportMap;
|
||||
StringStore m_StringStorage;
|
||||
llvm::StringRef StoreString(llvm::StringRef str);
|
||||
|
||||
// Renaming/Validation state
|
||||
RenameMap m_RenameMap;
|
||||
NameSet m_ExportNames;
|
||||
NameSet m_NameCollisions;
|
||||
NameSet m_UnusedExports;
|
||||
bool m_ExportShadersOnly;
|
||||
};
|
||||
}
|
||||
// Renaming/Validation state
|
||||
RenameMap m_RenameMap;
|
||||
NameSet m_ExportNames;
|
||||
NameSet m_NameCollisions;
|
||||
NameSet m_UnusedExports;
|
||||
bool m_ExportShadersOnly;
|
||||
};
|
||||
} // namespace dxilutil
|
||||
|
||||
}
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
#include "llvm/Pass.h"
|
||||
|
||||
namespace llvm {
|
||||
ModulePass *createDxilUpdateMetadataPass();
|
||||
ModulePass *createDxilPatchShaderRecordBindingsPass();
|
||||
ModulePass *createDxilUpdateMetadataPass();
|
||||
ModulePass *createDxilPatchShaderRecordBindingsPass();
|
||||
|
||||
void initializeDxilUpdateMetadataPass(llvm::PassRegistry&);
|
||||
void initializeDxilPatchShaderRecordBindingsPass(llvm::PassRegistry&);
|
||||
}
|
||||
void initializeDxilUpdateMetadataPass(llvm::PassRegistry &);
|
||||
void initializeDxilPatchShaderRecordBindingsPass(llvm::PassRegistry &);
|
||||
} // namespace llvm
|
||||
|
|
|
@ -20,14 +20,14 @@ class Instruction;
|
|||
class PassRegistry;
|
||||
class StringRef;
|
||||
struct PostDominatorTree;
|
||||
}
|
||||
} // namespace llvm
|
||||
|
||||
namespace hlsl {
|
||||
class DxilResourceBase;
|
||||
class WaveSensitivityAnalysis {
|
||||
public:
|
||||
static WaveSensitivityAnalysis* create(llvm::PostDominatorTree &PDT);
|
||||
virtual ~WaveSensitivityAnalysis() { }
|
||||
static WaveSensitivityAnalysis *create(llvm::PostDominatorTree &PDT);
|
||||
virtual ~WaveSensitivityAnalysis() {}
|
||||
virtual void Analyze(llvm::Function *F) = 0;
|
||||
virtual bool IsWaveSensitive(llvm::Instruction *op) = 0;
|
||||
};
|
||||
|
@ -35,10 +35,13 @@ public:
|
|||
class HLSLExtensionsCodegenHelper;
|
||||
|
||||
// Pause/resume support.
|
||||
bool ClearPauseResumePasses(llvm::Module &M); // true if modified; false if missing
|
||||
void GetPauseResumePasses(llvm::Module &M, llvm::StringRef &pause, llvm::StringRef &resume);
|
||||
void SetPauseResumePasses(llvm::Module &M, llvm::StringRef pause, llvm::StringRef resume);
|
||||
}
|
||||
bool ClearPauseResumePasses(
|
||||
llvm::Module &M); // true if modified; false if missing
|
||||
void GetPauseResumePasses(llvm::Module &M, llvm::StringRef &pause,
|
||||
llvm::StringRef &resume);
|
||||
void SetPauseResumePasses(llvm::Module &M, llvm::StringRef pause,
|
||||
llvm::StringRef resume);
|
||||
} // namespace hlsl
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -48,7 +51,9 @@ ModulePass *createDxilLowerCreateHandleForLibPass();
|
|||
ModulePass *createDxilAllocateResourcesForLibPass();
|
||||
ModulePass *createDxilCleanupDynamicResourceHandlePass();
|
||||
ModulePass *createDxilEliminateOutputDynamicIndexingPass();
|
||||
ModulePass *createDxilGenerationPass(bool NotOptimized, hlsl::HLSLExtensionsCodegenHelper *extensionsHelper);
|
||||
ModulePass *
|
||||
createDxilGenerationPass(bool NotOptimized,
|
||||
hlsl::HLSLExtensionsCodegenHelper *extensionsHelper);
|
||||
ModulePass *createHLEmitMetadataPass();
|
||||
ModulePass *createHLEnsureMetadataPass();
|
||||
ModulePass *createDxilFinalizeModulePass();
|
||||
|
@ -77,45 +82,45 @@ FunctionPass *createMatrixBitcastLowerPass();
|
|||
ModulePass *createDxilCleanupAddrSpaceCastPass();
|
||||
ModulePass *createDxilRenameResourcesPass();
|
||||
|
||||
void initializeDxilLowerCreateHandleForLibPass(llvm::PassRegistry&);
|
||||
void initializeDxilAllocateResourcesForLibPass(llvm::PassRegistry&);
|
||||
void initializeDxilLowerCreateHandleForLibPass(llvm::PassRegistry &);
|
||||
void initializeDxilAllocateResourcesForLibPass(llvm::PassRegistry &);
|
||||
void initializeDxilCleanupDynamicResourceHandlePass(llvm::PassRegistry &);
|
||||
void initializeDxilEliminateOutputDynamicIndexingPass(llvm::PassRegistry&);
|
||||
void initializeDxilGenerationPassPass(llvm::PassRegistry&);
|
||||
void initializeHLEnsureMetadataPass(llvm::PassRegistry&);
|
||||
void initializeHLEmitMetadataPass(llvm::PassRegistry&);
|
||||
void initializeDxilFinalizeModulePass(llvm::PassRegistry&);
|
||||
void initializeDxilEmitMetadataPass(llvm::PassRegistry&);
|
||||
void initializeDxilEraseDeadRegionPass(llvm::PassRegistry&);
|
||||
void initializeDxilExpandTrigIntrinsicsPass(llvm::PassRegistry&);
|
||||
void initializeDxilDeadFunctionEliminationPass(llvm::PassRegistry&);
|
||||
void initializeHLDeadFunctionEliminationPass(llvm::PassRegistry&);
|
||||
void initializeHLPreprocessPass(llvm::PassRegistry&);
|
||||
void initializeDxilConvergentMarkPass(llvm::PassRegistry&);
|
||||
void initializeDxilConvergentClearPass(llvm::PassRegistry&);
|
||||
void initializeDxilPrecisePropagatePassPass(llvm::PassRegistry&);
|
||||
void initializeDxilPreserveAllOutputsPass(llvm::PassRegistry&);
|
||||
void initializeDxilPromoteLocalResourcesPass(llvm::PassRegistry&);
|
||||
void initializeDxilPromoteStaticResourcesPass(llvm::PassRegistry&);
|
||||
void initializeDxilLegalizeResourcesPass(llvm::PassRegistry&);
|
||||
void initializeDxilLegalizeEvalOperationsPass(llvm::PassRegistry&);
|
||||
void initializeDxilLegalizeSampleOffsetPassPass(llvm::PassRegistry&);
|
||||
void initializeDxilSimpleGVNHoistPass(llvm::PassRegistry&);
|
||||
void initializeInvalidateUndefResourcesPass(llvm::PassRegistry&);
|
||||
void initializeSimplifyInstPass(llvm::PassRegistry&);
|
||||
void initializeDxilTranslateRawBufferPass(llvm::PassRegistry&);
|
||||
void initializeNoPausePassesPass(llvm::PassRegistry&);
|
||||
void initializePausePassesPass(llvm::PassRegistry&);
|
||||
void initializeResumePassesPass(llvm::PassRegistry&);
|
||||
void initializeMatrixBitcastLowerPassPass(llvm::PassRegistry&);
|
||||
void initializeDxilCleanupAddrSpaceCastPass(llvm::PassRegistry&);
|
||||
void initializeDxilRenameResourcesPass(llvm::PassRegistry&);
|
||||
void initializeDxilEliminateOutputDynamicIndexingPass(llvm::PassRegistry &);
|
||||
void initializeDxilGenerationPassPass(llvm::PassRegistry &);
|
||||
void initializeHLEnsureMetadataPass(llvm::PassRegistry &);
|
||||
void initializeHLEmitMetadataPass(llvm::PassRegistry &);
|
||||
void initializeDxilFinalizeModulePass(llvm::PassRegistry &);
|
||||
void initializeDxilEmitMetadataPass(llvm::PassRegistry &);
|
||||
void initializeDxilEraseDeadRegionPass(llvm::PassRegistry &);
|
||||
void initializeDxilExpandTrigIntrinsicsPass(llvm::PassRegistry &);
|
||||
void initializeDxilDeadFunctionEliminationPass(llvm::PassRegistry &);
|
||||
void initializeHLDeadFunctionEliminationPass(llvm::PassRegistry &);
|
||||
void initializeHLPreprocessPass(llvm::PassRegistry &);
|
||||
void initializeDxilConvergentMarkPass(llvm::PassRegistry &);
|
||||
void initializeDxilConvergentClearPass(llvm::PassRegistry &);
|
||||
void initializeDxilPrecisePropagatePassPass(llvm::PassRegistry &);
|
||||
void initializeDxilPreserveAllOutputsPass(llvm::PassRegistry &);
|
||||
void initializeDxilPromoteLocalResourcesPass(llvm::PassRegistry &);
|
||||
void initializeDxilPromoteStaticResourcesPass(llvm::PassRegistry &);
|
||||
void initializeDxilLegalizeResourcesPass(llvm::PassRegistry &);
|
||||
void initializeDxilLegalizeEvalOperationsPass(llvm::PassRegistry &);
|
||||
void initializeDxilLegalizeSampleOffsetPassPass(llvm::PassRegistry &);
|
||||
void initializeDxilSimpleGVNHoistPass(llvm::PassRegistry &);
|
||||
void initializeInvalidateUndefResourcesPass(llvm::PassRegistry &);
|
||||
void initializeSimplifyInstPass(llvm::PassRegistry &);
|
||||
void initializeDxilTranslateRawBufferPass(llvm::PassRegistry &);
|
||||
void initializeNoPausePassesPass(llvm::PassRegistry &);
|
||||
void initializePausePassesPass(llvm::PassRegistry &);
|
||||
void initializeResumePassesPass(llvm::PassRegistry &);
|
||||
void initializeMatrixBitcastLowerPassPass(llvm::PassRegistry &);
|
||||
void initializeDxilCleanupAddrSpaceCastPass(llvm::PassRegistry &);
|
||||
void initializeDxilRenameResourcesPass(llvm::PassRegistry &);
|
||||
|
||||
ModulePass *createDxilValidateWaveSensitivityPass();
|
||||
void initializeDxilValidateWaveSensitivityPass(llvm::PassRegistry&);
|
||||
void initializeDxilValidateWaveSensitivityPass(llvm::PassRegistry &);
|
||||
|
||||
FunctionPass *createCleanupDxBreakPass();
|
||||
void initializeCleanupDxBreakPass(llvm::PassRegistry&);
|
||||
void initializeCleanupDxBreakPass(llvm::PassRegistry &);
|
||||
|
||||
FunctionPass *createDxilLoopDeletionPass(bool NoSink);
|
||||
void initializeDxilLoopDeletionPass(llvm::PassRegistry &);
|
||||
|
@ -123,24 +128,25 @@ void initializeDxilLoopDeletionPass(llvm::PassRegistry &);
|
|||
ModulePass *createHLLegalizeParameter();
|
||||
void initializeHLLegalizeParameterPass(llvm::PassRegistry &);
|
||||
|
||||
bool AreDxilResourcesDense(llvm::Module *M, hlsl::DxilResourceBase **ppNonDense);
|
||||
bool AreDxilResourcesDense(llvm::Module *M,
|
||||
hlsl::DxilResourceBase **ppNonDense);
|
||||
|
||||
ModulePass *createDxilNoOptLegalizePass();
|
||||
void initializeDxilNoOptLegalizePass(llvm::PassRegistry&);
|
||||
void initializeDxilNoOptLegalizePass(llvm::PassRegistry &);
|
||||
|
||||
ModulePass *createDxilNoOptSimplifyInstructionsPass();
|
||||
void initializeDxilNoOptSimplifyInstructionsPass(llvm::PassRegistry&);
|
||||
void initializeDxilNoOptSimplifyInstructionsPass(llvm::PassRegistry &);
|
||||
|
||||
ModulePass *createDxilMutateResourceToHandlePass();
|
||||
void initializeDxilMutateResourceToHandlePass(llvm::PassRegistry&);
|
||||
void initializeDxilMutateResourceToHandlePass(llvm::PassRegistry &);
|
||||
|
||||
ModulePass *createDxilDeleteRedundantDebugValuesPass();
|
||||
void initializeDxilDeleteRedundantDebugValuesPass(llvm::PassRegistry&);
|
||||
void initializeDxilDeleteRedundantDebugValuesPass(llvm::PassRegistry &);
|
||||
|
||||
FunctionPass *createDxilSimpleGVNEliminateRegionPass();
|
||||
void initializeDxilSimpleGVNEliminateRegionPass(llvm::PassRegistry&);
|
||||
void initializeDxilSimpleGVNEliminateRegionPass(llvm::PassRegistry &);
|
||||
|
||||
ModulePass *createDxilModuleInitPass();
|
||||
void initializeDxilModuleInitPass(llvm::PassRegistry &);
|
||||
|
||||
}
|
||||
} // namespace llvm
|
||||
|
|
|
@ -36,9 +36,12 @@ class DxilResourceBase;
|
|||
class DxilLinker {
|
||||
public:
|
||||
virtual ~DxilLinker() {}
|
||||
static DxilLinker *CreateLinker(llvm::LLVMContext &Ctx, unsigned valMajor, unsigned valMinor);
|
||||
static DxilLinker *CreateLinker(llvm::LLVMContext &Ctx, unsigned valMajor,
|
||||
unsigned valMinor);
|
||||
|
||||
void SetValidatorVersion(unsigned valMajor, unsigned valMinor) { m_valMajor = valMajor, m_valMinor = valMinor; }
|
||||
void SetValidatorVersion(unsigned valMajor, unsigned valMinor) {
|
||||
m_valMajor = valMajor, m_valMinor = valMinor;
|
||||
}
|
||||
virtual bool HasLibNameRegistered(llvm::StringRef name) = 0;
|
||||
virtual bool RegisterLib(llvm::StringRef name,
|
||||
std::unique_ptr<llvm::Module> pModule,
|
||||
|
@ -48,10 +51,12 @@ public:
|
|||
virtual void DetachAll() = 0;
|
||||
|
||||
virtual std::unique_ptr<llvm::Module>
|
||||
Link(llvm::StringRef entry, llvm::StringRef profile, dxilutil::ExportMap &exportMap) = 0;
|
||||
Link(llvm::StringRef entry, llvm::StringRef profile,
|
||||
dxilutil::ExportMap &exportMap) = 0;
|
||||
|
||||
protected:
|
||||
DxilLinker(llvm::LLVMContext &Ctx, unsigned valMajor, unsigned valMinor) : m_ctx(Ctx), m_valMajor(valMajor), m_valMinor(valMinor) {}
|
||||
DxilLinker(llvm::LLVMContext &Ctx, unsigned valMajor, unsigned valMinor)
|
||||
: m_ctx(Ctx), m_valMajor(valMajor), m_valMinor(valMinor) {}
|
||||
llvm::LLVMContext &m_ctx;
|
||||
unsigned m_valMajor, m_valMinor;
|
||||
};
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "llvm/ADT/StringRef.h"
|
||||
|
||||
namespace llvm {
|
||||
class Instruction;
|
||||
class Instruction;
|
||||
}
|
||||
|
||||
namespace hlsl {
|
||||
|
@ -23,4 +23,4 @@ static const llvm::StringRef kPreserveName = "dx.preserve.value.a";
|
|||
bool IsPreserveRelatedValue(llvm::Instruction *I);
|
||||
bool IsPreserve(llvm::Instruction *S);
|
||||
bool IsNop(llvm::Instruction *I);
|
||||
}
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -31,19 +31,24 @@ class DxilPackElement : public DxilSignatureAllocator::PackElement {
|
|||
bool m_bUseMinPrecision;
|
||||
|
||||
public:
|
||||
DxilPackElement(DxilSignatureElement *pSE, bool useMinPrecision) : m_pSE(pSE), m_bUseMinPrecision(useMinPrecision) {}
|
||||
DxilPackElement(DxilSignatureElement *pSE, bool useMinPrecision)
|
||||
: m_pSE(pSE), m_bUseMinPrecision(useMinPrecision) {}
|
||||
~DxilPackElement() override {}
|
||||
uint32_t GetID() const override { return m_pSE->GetID(); }
|
||||
DXIL::SemanticKind GetKind() const override { return m_pSE->GetKind(); }
|
||||
DXIL::InterpolationMode GetInterpolationMode() const override { return m_pSE->GetInterpolationMode()->GetKind(); }
|
||||
DXIL::SemanticInterpretationKind GetInterpretation() const override { return m_pSE->GetInterpretation(); }
|
||||
DXIL::InterpolationMode GetInterpolationMode() const override {
|
||||
return m_pSE->GetInterpolationMode()->GetKind();
|
||||
}
|
||||
DXIL::SemanticInterpretationKind GetInterpretation() const override {
|
||||
return m_pSE->GetInterpretation();
|
||||
}
|
||||
DXIL::SignatureDataWidth GetDataBitWidth() const override {
|
||||
uint8_t size = m_pSE->GetCompType().GetSizeInBits();
|
||||
// bool, min precision, or 32 bit types map to 32 bit size.
|
||||
if (size == 16) {
|
||||
return m_bUseMinPrecision ? DXIL::SignatureDataWidth::Bits32 : DXIL::SignatureDataWidth::Bits16;
|
||||
}
|
||||
else if (size == 1 || size == 32) {
|
||||
return m_bUseMinPrecision ? DXIL::SignatureDataWidth::Bits32
|
||||
: DXIL::SignatureDataWidth::Bits16;
|
||||
} else if (size == 1 || size == 32) {
|
||||
return DXIL::SignatureDataWidth::Bits32;
|
||||
}
|
||||
return DXIL::SignatureDataWidth::Undefined;
|
||||
|
@ -67,7 +72,8 @@ public:
|
|||
};
|
||||
|
||||
class DxilSignature;
|
||||
// Packs the signature elements per DXIL constraints and returns the number of rows used for the signature.
|
||||
// Packs the signature elements per DXIL constraints and returns the number of
|
||||
// rows used for the signature.
|
||||
unsigned PackDxilSignature(DxilSignature &sig, DXIL::PackingStrategy packing);
|
||||
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -8,30 +8,32 @@
|
|||
// Allows insertion of poisoned values with error messages that get //
|
||||
// cleaned up late in the compiler. //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
|
||||
#include "llvm/IR/DebugLoc.h"
|
||||
|
||||
namespace llvm {
|
||||
class Instruction;
|
||||
class Type;
|
||||
class Value;
|
||||
class Module;
|
||||
}
|
||||
class Instruction;
|
||||
class Type;
|
||||
class Value;
|
||||
class Module;
|
||||
} // namespace llvm
|
||||
|
||||
namespace hlsl {
|
||||
// Create a special dx.poison.* instruction with debug location and an error message.
|
||||
// The reason for this is certain invalid code is allowed in the code as long as it is
|
||||
// removed by optimization at the end of compilation. We only want to emit the error
|
||||
// for real if we are sure the code with the problem is in the final DXIL.
|
||||
//
|
||||
// This "emits" an error message with the specified type. If by the end the compilation
|
||||
// it is still used, then FinalizePoisonValues will emit the correct error for real.
|
||||
llvm::Value *CreatePoisonValue(llvm::Type *ty, const llvm::Twine &errMsg, llvm::DebugLoc DL, llvm::Instruction *InsertPt);
|
||||
|
||||
// If there's any dx.poison.* values present in the module, emit them. Returns true
|
||||
// M was modified in any way.
|
||||
bool FinalizePoisonValues(llvm::Module &M);
|
||||
}
|
||||
// Create a special dx.poison.* instruction with debug location and an error
|
||||
// message. The reason for this is certain invalid code is allowed in the code
|
||||
// as long as it is removed by optimization at the end of compilation. We only
|
||||
// want to emit the error for real if we are sure the code with the problem is
|
||||
// in the final DXIL.
|
||||
//
|
||||
// This "emits" an error message with the specified type. If by the end the
|
||||
// compilation it is still used, then FinalizePoisonValues will emit the correct
|
||||
// error for real.
|
||||
llvm::Value *CreatePoisonValue(llvm::Type *ty, const llvm::Twine &errMsg,
|
||||
llvm::DebugLoc DL, llvm::Instruction *InsertPt);
|
||||
|
||||
// If there's any dx.poison.* values present in the module, emit them. Returns
|
||||
// true M was modified in any way.
|
||||
bool FinalizePoisonValues(llvm::Module &M);
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -48,19 +48,24 @@ public:
|
|||
uint32_t indexFlags;
|
||||
|
||||
public:
|
||||
DummyElement(uint32_t index = 0) : id(index), rows(1), cols(1), row((uint32_t)-1), col((uint32_t)-1),
|
||||
kind(DXIL::SemanticKind::Arbitrary),
|
||||
interpolation(DXIL::InterpolationMode::Undefined),
|
||||
interpretation(DXIL::SemanticInterpretationKind::Arb),
|
||||
dataBitWidth(DXIL::SignatureDataWidth::Undefined),
|
||||
indexFlags(0)
|
||||
{}
|
||||
DummyElement(uint32_t index = 0)
|
||||
: id(index), rows(1), cols(1), row((uint32_t)-1), col((uint32_t)-1),
|
||||
kind(DXIL::SemanticKind::Arbitrary),
|
||||
interpolation(DXIL::InterpolationMode::Undefined),
|
||||
interpretation(DXIL::SemanticInterpretationKind::Arb),
|
||||
dataBitWidth(DXIL::SignatureDataWidth::Undefined), indexFlags(0) {}
|
||||
~DummyElement() override {}
|
||||
uint32_t GetID() const override { return id; }
|
||||
DXIL::SemanticKind GetKind() const override { return kind; }
|
||||
DXIL::InterpolationMode GetInterpolationMode() const override { return interpolation; }
|
||||
DXIL::SemanticInterpretationKind GetInterpretation() const override { return interpretation; }
|
||||
DXIL::SignatureDataWidth GetDataBitWidth() const override { return dataBitWidth; }
|
||||
DXIL::InterpolationMode GetInterpolationMode() const override {
|
||||
return interpolation;
|
||||
}
|
||||
DXIL::SemanticInterpretationKind GetInterpretation() const override {
|
||||
return interpretation;
|
||||
}
|
||||
DXIL::SignatureDataWidth GetDataBitWidth() const override {
|
||||
return dataBitWidth;
|
||||
}
|
||||
uint32_t GetRows() const override { return rows; }
|
||||
uint32_t GetCols() const override { return cols; }
|
||||
bool IsAllocated() const override { return row != (uint32_t)-1; }
|
||||
|
@ -68,12 +73,15 @@ public:
|
|||
uint32_t GetStartCol() const override { return col; }
|
||||
|
||||
void ClearLocation() override { row = col = (uint32_t)-1; }
|
||||
void SetLocation(uint32_t Row, uint32_t Col) override { row = Row; col = Col; }
|
||||
void SetLocation(uint32_t Row, uint32_t Col) override {
|
||||
row = Row;
|
||||
col = Col;
|
||||
}
|
||||
};
|
||||
|
||||
// index flags
|
||||
static const uint8_t kIndexedUp = 1 << 0; // Indexing continues upwards
|
||||
static const uint8_t kIndexedDown = 1 << 1; // Indexing continues downwards
|
||||
static const uint8_t kIndexedUp = 1 << 0; // Indexing continues upwards
|
||||
static const uint8_t kIndexedDown = 1 << 1; // Indexing continues downwards
|
||||
static uint8_t GetIndexFlags(unsigned row, unsigned rows) {
|
||||
return ((row > 0) ? kIndexedUp : 0) | ((row < rows - 1) ? kIndexedDown : 0);
|
||||
}
|
||||
|
@ -87,12 +95,14 @@ public:
|
|||
static const uint8_t kEFConflictsWithIndexed = kEFSGV | kEFSV;
|
||||
static uint8_t GetElementFlags(const PackElement *SE);
|
||||
|
||||
// The following two functions enforce the rules of component ordering when packing different
|
||||
// kinds of elements into the same register.
|
||||
// The following two functions enforce the rules of component ordering when
|
||||
// packing different kinds of elements into the same register.
|
||||
|
||||
// given element flags, return element flags that conflict when placed to the left of the element
|
||||
// given element flags, return element flags that conflict when placed to the
|
||||
// left of the element
|
||||
static uint8_t GetConflictFlagsLeft(uint8_t flags);
|
||||
// given element flags, return element flags that conflict when placed to the right of the element
|
||||
// given element flags, return element flags that conflict when placed to the
|
||||
// right of the element
|
||||
static uint8_t GetConflictFlagsRight(uint8_t flags);
|
||||
|
||||
enum ConflictType {
|
||||
|
@ -115,37 +125,52 @@ public:
|
|||
DXIL::InterpolationMode Interp : 8;
|
||||
uint8_t IndexFlags : 2;
|
||||
uint8_t IndexingFixed : 1;
|
||||
DXIL::SignatureDataWidth DataWidth; // length of each scalar type in bytes. (2 or 4 for now)
|
||||
DXIL::SignatureDataWidth
|
||||
DataWidth; // length of each scalar type in bytes. (2 or 4 for now)
|
||||
|
||||
PackedRegister();
|
||||
ConflictType DetectRowConflict(uint8_t flags, uint8_t indexFlags, DXIL::InterpolationMode interp, unsigned width, DXIL::SignatureDataWidth dataWidth);
|
||||
ConflictType DetectRowConflict(uint8_t flags, uint8_t indexFlags,
|
||||
DXIL::InterpolationMode interp,
|
||||
unsigned width,
|
||||
DXIL::SignatureDataWidth dataWidth);
|
||||
ConflictType DetectColConflict(uint8_t flags, unsigned col, unsigned width);
|
||||
void PlaceElement(uint8_t flags, uint8_t indexFlags, DXIL::InterpolationMode interp, unsigned col, unsigned width, DXIL::SignatureDataWidth dataWidth);
|
||||
void PlaceElement(uint8_t flags, uint8_t indexFlags,
|
||||
DXIL::InterpolationMode interp, unsigned col,
|
||||
unsigned width, DXIL::SignatureDataWidth dataWidth);
|
||||
};
|
||||
|
||||
DxilSignatureAllocator(unsigned numRegisters, bool useMinPrecision);
|
||||
|
||||
bool GetIgnoreIndexing() const { return m_bIgnoreIndexing; }
|
||||
void SetIgnoreIndexing(bool ignoreIndexing) { m_bIgnoreIndexing = ignoreIndexing; }
|
||||
void SetIgnoreIndexing(bool ignoreIndexing) {
|
||||
m_bIgnoreIndexing = ignoreIndexing;
|
||||
}
|
||||
|
||||
ConflictType DetectRowConflict(const PackElement *SE, unsigned row);
|
||||
ConflictType DetectColConflict(const PackElement *SE, unsigned row, unsigned col);
|
||||
ConflictType DetectColConflict(const PackElement *SE, unsigned row,
|
||||
unsigned col);
|
||||
void PlaceElement(const PackElement *SE, unsigned row, unsigned col);
|
||||
|
||||
// FindNext/PackNext return found/packed location + element rows if found,
|
||||
// otherwise, they return 0.
|
||||
unsigned FindNext(unsigned &foundRow, unsigned &foundCol,
|
||||
PackElement* SE, unsigned startRow, unsigned numRows, unsigned startCol = 0);
|
||||
unsigned PackNext(PackElement* SE, unsigned startRow, unsigned numRows, unsigned startCol = 0);
|
||||
unsigned FindNext(unsigned &foundRow, unsigned &foundCol, PackElement *SE,
|
||||
unsigned startRow, unsigned numRows, unsigned startCol = 0);
|
||||
unsigned PackNext(PackElement *SE, unsigned startRow, unsigned numRows,
|
||||
unsigned startCol = 0);
|
||||
|
||||
// Simple greedy in-order packer used by PackOptimized
|
||||
unsigned PackGreedy(std::vector<PackElement*> elements, unsigned startRow, unsigned numRows, unsigned startCol = 0);
|
||||
unsigned PackGreedy(std::vector<PackElement *> elements, unsigned startRow,
|
||||
unsigned numRows, unsigned startCol = 0);
|
||||
|
||||
// Optimized packing algorithm - appended elements may affect positions of prior elements.
|
||||
unsigned PackOptimized(std::vector<PackElement*> elements, unsigned startRow, unsigned numRows);
|
||||
// Optimized packing algorithm - appended elements may affect positions of
|
||||
// prior elements.
|
||||
unsigned PackOptimized(std::vector<PackElement *> elements, unsigned startRow,
|
||||
unsigned numRows);
|
||||
|
||||
// Pack in a prefix-stable way - appended elements do not affect positions of prior elements.
|
||||
unsigned PackPrefixStable(std::vector<PackElement*> elements, unsigned startRow, unsigned numRows);
|
||||
// Pack in a prefix-stable way - appended elements do not affect positions of
|
||||
// prior elements.
|
||||
unsigned PackPrefixStable(std::vector<PackElement *> elements,
|
||||
unsigned startRow, unsigned numRows);
|
||||
|
||||
bool UseMinPrecision() const { return m_bUseMinPrecision; }
|
||||
|
||||
|
@ -155,5 +180,4 @@ protected:
|
|||
bool m_bUseMinPrecision;
|
||||
};
|
||||
|
||||
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
//#include "dxc/Support/Global.h" // for DXASSERT
|
||||
//#include "dxc/HLSL/DxilSignatureAllocator.h"
|
||||
|
||||
using std::vector; // #include <vector>
|
||||
using std::unique_ptr; // #include <memory>
|
||||
using std::sort; // #include <algorithm>
|
||||
using std::sort; // #include <algorithm>
|
||||
using std::unique_ptr; // #include <memory>
|
||||
using std::vector; // #include <vector>
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
|
@ -24,31 +24,33 @@ uint8_t DxilSignatureAllocator::GetElementFlags(const PackElement *SE) {
|
|||
uint8_t flags = 0;
|
||||
DXIL::SemanticInterpretationKind interpretation = SE->GetInterpretation();
|
||||
switch (interpretation) {
|
||||
case DXIL::SemanticInterpretationKind::Arb:
|
||||
flags |= kEFArbitrary;
|
||||
break;
|
||||
case DXIL::SemanticInterpretationKind::SV:
|
||||
flags |= kEFSV;
|
||||
break;
|
||||
case DXIL::SemanticInterpretationKind::SGV:
|
||||
flags |= kEFSGV;
|
||||
break;
|
||||
case DXIL::SemanticInterpretationKind::TessFactor:
|
||||
flags |= kEFTessFactor;
|
||||
break;
|
||||
case DXIL::SemanticInterpretationKind::ClipCull:
|
||||
flags |= kEFClipCull;
|
||||
break;
|
||||
default:
|
||||
DXASSERT(false, "otherwise, unexpected interpretation for allocated element");
|
||||
case DXIL::SemanticInterpretationKind::Arb:
|
||||
flags |= kEFArbitrary;
|
||||
break;
|
||||
case DXIL::SemanticInterpretationKind::SV:
|
||||
flags |= kEFSV;
|
||||
break;
|
||||
case DXIL::SemanticInterpretationKind::SGV:
|
||||
flags |= kEFSGV;
|
||||
break;
|
||||
case DXIL::SemanticInterpretationKind::TessFactor:
|
||||
flags |= kEFTessFactor;
|
||||
break;
|
||||
case DXIL::SemanticInterpretationKind::ClipCull:
|
||||
flags |= kEFClipCull;
|
||||
break;
|
||||
default:
|
||||
DXASSERT(false,
|
||||
"otherwise, unexpected interpretation for allocated element");
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
// The following two functions enforce the rules of component ordering when packing different
|
||||
// kinds of elements into the same register.
|
||||
// The following two functions enforce the rules of component ordering when
|
||||
// packing different kinds of elements into the same register.
|
||||
|
||||
// given element flags, return element flags that conflict when placed to the left of the element
|
||||
// given element flags, return element flags that conflict when placed to the
|
||||
// left of the element
|
||||
uint8_t DxilSignatureAllocator::GetConflictFlagsLeft(uint8_t flags) {
|
||||
uint8_t conflicts = 0;
|
||||
if (flags & kEFArbitrary)
|
||||
|
@ -62,7 +64,8 @@ uint8_t DxilSignatureAllocator::GetConflictFlagsLeft(uint8_t flags) {
|
|||
return conflicts;
|
||||
}
|
||||
|
||||
// given element flags, return element flags that conflict when placed to the right of the element
|
||||
// given element flags, return element flags that conflict when placed to the
|
||||
// right of the element
|
||||
uint8_t DxilSignatureAllocator::GetConflictFlagsRight(uint8_t flags) {
|
||||
uint8_t conflicts = 0;
|
||||
if (flags & kEFSGV)
|
||||
|
@ -83,18 +86,23 @@ DxilSignatureAllocator::PackedRegister::PackedRegister()
|
|||
Flags[i] = 0;
|
||||
}
|
||||
|
||||
DxilSignatureAllocator::ConflictType DxilSignatureAllocator::PackedRegister::DetectRowConflict(uint8_t flags, uint8_t indexFlags, DXIL::InterpolationMode interp, unsigned width, DXIL::SignatureDataWidth dataWidth) {
|
||||
DxilSignatureAllocator::ConflictType
|
||||
DxilSignatureAllocator::PackedRegister::DetectRowConflict(
|
||||
uint8_t flags, uint8_t indexFlags, DXIL::InterpolationMode interp,
|
||||
unsigned width, DXIL::SignatureDataWidth dataWidth) {
|
||||
// indexing already present, and element incompatible with indexing
|
||||
if (IndexFlags && (flags & kEFConflictsWithIndexed))
|
||||
return kConflictsWithIndexed;
|
||||
// indexing cannot be changed, and element indexing is incompatible when merged
|
||||
// indexing cannot be changed, and element indexing is incompatible when
|
||||
// merged
|
||||
if (IndexingFixed && (indexFlags | IndexFlags) != IndexFlags)
|
||||
return kConflictsWithIndexed;
|
||||
if ((flags & kEFTessFactor) && (indexFlags | IndexFlags) != indexFlags)
|
||||
return kConflictsWithIndexedTessFactor;
|
||||
if (Interp != DXIL::InterpolationMode::Undefined && Interp != interp)
|
||||
return kConflictsWithInterpolationMode;
|
||||
if (DataWidth != DXIL::SignatureDataWidth::Undefined && DataWidth != dataWidth)
|
||||
if (DataWidth != DXIL::SignatureDataWidth::Undefined &&
|
||||
DataWidth != dataWidth)
|
||||
return kConflictDataWidth;
|
||||
unsigned freeWidth = 0;
|
||||
for (unsigned i = 0; i < 4; ++i) {
|
||||
|
@ -110,7 +118,10 @@ DxilSignatureAllocator::ConflictType DxilSignatureAllocator::PackedRegister::Det
|
|||
return kNoConflict;
|
||||
}
|
||||
|
||||
DxilSignatureAllocator::ConflictType DxilSignatureAllocator::PackedRegister::DetectColConflict(uint8_t flags, unsigned col, unsigned width) {
|
||||
DxilSignatureAllocator::ConflictType
|
||||
DxilSignatureAllocator::PackedRegister::DetectColConflict(uint8_t flags,
|
||||
unsigned col,
|
||||
unsigned width) {
|
||||
if (col + width > 4)
|
||||
return kConflictFit;
|
||||
flags |= kEFOccupied;
|
||||
|
@ -128,12 +139,14 @@ DxilSignatureAllocator::ConflictType DxilSignatureAllocator::PackedRegister::Det
|
|||
void DxilSignatureAllocator::PackedRegister::PlaceElement(
|
||||
uint8_t flags, uint8_t indexFlags, DXIL::InterpolationMode interp,
|
||||
unsigned col, unsigned width, DXIL::SignatureDataWidth dataWidth) {
|
||||
// Assume no conflicts (DetectRowConflict and DetectColConflict both return 0).
|
||||
// Assume no conflicts (DetectRowConflict and DetectColConflict both return
|
||||
// 0).
|
||||
Interp = interp;
|
||||
IndexFlags |= indexFlags;
|
||||
DataWidth = dataWidth;
|
||||
if ((flags & kEFConflictsWithIndexed) || (flags & kEFTessFactor)) {
|
||||
DXASSERT(indexFlags == IndexFlags, "otherwise, bug in DetectRowConflict checking index flags");
|
||||
DXASSERT(indexFlags == IndexFlags,
|
||||
"otherwise, bug in DetectRowConflict checking index flags");
|
||||
IndexingFixed = 1;
|
||||
}
|
||||
uint8_t conflictLeft = GetConflictFlagsLeft(flags);
|
||||
|
@ -150,12 +163,14 @@ void DxilSignatureAllocator::PackedRegister::PlaceElement(
|
|||
}
|
||||
}
|
||||
|
||||
DxilSignatureAllocator::DxilSignatureAllocator(unsigned numRegisters, bool useMinPrecision)
|
||||
: m_bIgnoreIndexing(false), m_bUseMinPrecision(useMinPrecision) {
|
||||
DxilSignatureAllocator::DxilSignatureAllocator(unsigned numRegisters,
|
||||
bool useMinPrecision)
|
||||
: m_bIgnoreIndexing(false), m_bUseMinPrecision(useMinPrecision) {
|
||||
m_Registers.resize(numRegisters);
|
||||
}
|
||||
|
||||
DxilSignatureAllocator::ConflictType DxilSignatureAllocator::DetectRowConflict(const PackElement *SE, unsigned row) {
|
||||
DxilSignatureAllocator::ConflictType
|
||||
DxilSignatureAllocator::DetectRowConflict(const PackElement *SE, unsigned row) {
|
||||
unsigned rows = SE->GetRows();
|
||||
if (rows + row > m_Registers.size())
|
||||
return kConflictFit;
|
||||
|
@ -164,72 +179,85 @@ DxilSignatureAllocator::ConflictType DxilSignatureAllocator::DetectRowConflict(c
|
|||
uint8_t flags = GetElementFlags(SE);
|
||||
for (unsigned i = 0; i < rows; ++i) {
|
||||
uint8_t indexFlags = m_bIgnoreIndexing ? 0 : GetIndexFlags(i, rows);
|
||||
ConflictType conflict = m_Registers[row + i].DetectRowConflict(flags, indexFlags, interp, cols, SE->GetDataBitWidth());
|
||||
ConflictType conflict = m_Registers[row + i].DetectRowConflict(
|
||||
flags, indexFlags, interp, cols, SE->GetDataBitWidth());
|
||||
if (conflict)
|
||||
return conflict;
|
||||
}
|
||||
return kNoConflict;
|
||||
}
|
||||
|
||||
DxilSignatureAllocator::ConflictType DxilSignatureAllocator::DetectColConflict(const PackElement *SE, unsigned row, unsigned col) {
|
||||
DxilSignatureAllocator::ConflictType
|
||||
DxilSignatureAllocator::DetectColConflict(const PackElement *SE, unsigned row,
|
||||
unsigned col) {
|
||||
unsigned rows = SE->GetRows();
|
||||
unsigned cols = SE->GetCols();
|
||||
uint8_t flags = GetElementFlags(SE);
|
||||
for (unsigned i = 0; i < rows; ++i) {
|
||||
ConflictType conflict = m_Registers[row + i].DetectColConflict(flags, col, cols);
|
||||
ConflictType conflict =
|
||||
m_Registers[row + i].DetectColConflict(flags, col, cols);
|
||||
if (conflict)
|
||||
return conflict;
|
||||
}
|
||||
return kNoConflict;
|
||||
}
|
||||
|
||||
void DxilSignatureAllocator::PlaceElement(const PackElement *SE, unsigned row, unsigned col) {
|
||||
// Assume no conflicts (DetectRowConflict and DetectColConflict both return 0).
|
||||
void DxilSignatureAllocator::PlaceElement(const PackElement *SE, unsigned row,
|
||||
unsigned col) {
|
||||
// Assume no conflicts (DetectRowConflict and DetectColConflict both return
|
||||
// 0).
|
||||
unsigned rows = SE->GetRows();
|
||||
unsigned cols = SE->GetCols();
|
||||
DXIL::InterpolationMode interp = SE->GetInterpolationMode();
|
||||
uint8_t flags = GetElementFlags(SE);
|
||||
for (unsigned i = 0; i < rows; ++i) {
|
||||
uint8_t indexFlags = m_bIgnoreIndexing ? 0 : GetIndexFlags(i, rows);
|
||||
m_Registers[row + i].PlaceElement(flags, indexFlags, interp, col, cols, SE->GetDataBitWidth());
|
||||
m_Registers[row + i].PlaceElement(flags, indexFlags, interp, col, cols,
|
||||
SE->GetDataBitWidth());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
template <typename T>
|
||||
int cmp(T a, T b) {
|
||||
template <typename T> int cmp(T a, T b) {
|
||||
if (a < b)
|
||||
return -1;
|
||||
if (b < a)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
int CmpElements(const DxilSignatureAllocator::PackElement* left, const DxilSignatureAllocator::PackElement* right) {
|
||||
int CmpElements(const DxilSignatureAllocator::PackElement *left,
|
||||
const DxilSignatureAllocator::PackElement *right) {
|
||||
unsigned result;
|
||||
result = cmp((unsigned)left->GetInterpolationMode(), (unsigned)right->GetInterpolationMode());
|
||||
if (result) return result;
|
||||
result = cmp((unsigned)left->GetInterpolationMode(),
|
||||
(unsigned)right->GetInterpolationMode());
|
||||
if (result)
|
||||
return result;
|
||||
result = -cmp(left->GetRows(), right->GetRows());
|
||||
if (result) return result;
|
||||
if (result)
|
||||
return result;
|
||||
result = -cmp(left->GetCols(), right->GetCols());
|
||||
if (result) return result;
|
||||
if (result)
|
||||
return result;
|
||||
result = cmp(left->GetID(), right->GetID());
|
||||
if (result) return result;
|
||||
if (result)
|
||||
return result;
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct {
|
||||
bool operator()(const DxilSignatureAllocator::PackElement* left, const DxilSignatureAllocator::PackElement* right) {
|
||||
bool operator()(const DxilSignatureAllocator::PackElement *left,
|
||||
const DxilSignatureAllocator::PackElement *right) {
|
||||
return CmpElements(left, right) < 0;
|
||||
}
|
||||
} CmpElementsLess;
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
unsigned DxilSignatureAllocator::FindNext(
|
||||
unsigned &foundRow, unsigned &foundCol,
|
||||
PackElement* SE, unsigned startRow, unsigned numRows, unsigned startCol) {
|
||||
unsigned DxilSignatureAllocator::FindNext(unsigned &foundRow,
|
||||
unsigned &foundCol, PackElement *SE,
|
||||
unsigned startRow, unsigned numRows,
|
||||
unsigned startCol) {
|
||||
|
||||
unsigned rows = SE->GetRows();
|
||||
if (rows > numRows)
|
||||
|
@ -252,7 +280,8 @@ unsigned DxilSignatureAllocator::FindNext(
|
|||
return 0;
|
||||
}
|
||||
|
||||
unsigned DxilSignatureAllocator::PackNext(PackElement* SE, unsigned startRow, unsigned numRows, unsigned startCol) {
|
||||
unsigned DxilSignatureAllocator::PackNext(PackElement *SE, unsigned startRow,
|
||||
unsigned numRows, unsigned startCol) {
|
||||
unsigned row, col;
|
||||
unsigned rowsUsed = FindNext(row, col, SE, startRow, numRows, startCol);
|
||||
if (rowsUsed) {
|
||||
|
@ -262,7 +291,9 @@ unsigned DxilSignatureAllocator::PackNext(PackElement* SE, unsigned startRow, un
|
|||
return rowsUsed;
|
||||
}
|
||||
|
||||
unsigned DxilSignatureAllocator::PackGreedy(std::vector<PackElement*> elements, unsigned startRow, unsigned numRows, unsigned startCol) {
|
||||
unsigned DxilSignatureAllocator::PackGreedy(std::vector<PackElement *> elements,
|
||||
unsigned startRow, unsigned numRows,
|
||||
unsigned startCol) {
|
||||
// Allocation failures should be caught by IsFullyAllocated()
|
||||
unsigned rowsUsed = 0;
|
||||
|
||||
|
@ -276,7 +307,9 @@ unsigned DxilSignatureAllocator::PackGreedy(std::vector<PackElement*> elements,
|
|||
static_assert(DXIL::kMaxClipOrCullDistanceElementCount == 2,
|
||||
"code here assumes this is 2");
|
||||
|
||||
unsigned DxilSignatureAllocator::PackOptimized(std::vector<PackElement*> elements, unsigned startRow, unsigned numRows) {
|
||||
unsigned
|
||||
DxilSignatureAllocator::PackOptimized(std::vector<PackElement *> elements,
|
||||
unsigned startRow, unsigned numRows) {
|
||||
unsigned rowsUsed = 0;
|
||||
|
||||
// Clip/Cull needs special handling due to limitations unique to these.
|
||||
|
@ -317,13 +350,9 @@ unsigned DxilSignatureAllocator::PackOptimized(std::vector<PackElement*> element
|
|||
|
||||
// ==========
|
||||
// Group elements
|
||||
std::vector<PackElement*> clipcullElements,
|
||||
clipcullElementsByRow[DXIL::kMaxClipOrCullDistanceElementCount],
|
||||
vec4Elements,
|
||||
arbElements,
|
||||
svElements,
|
||||
sgvElements,
|
||||
indexedtessElements;
|
||||
std::vector<PackElement *> clipcullElements,
|
||||
clipcullElementsByRow[DXIL::kMaxClipOrCullDistanceElementCount],
|
||||
vec4Elements, arbElements, svElements, sgvElements, indexedtessElements;
|
||||
|
||||
for (auto &SE : elements) {
|
||||
// Clear any existing allocation
|
||||
|
@ -332,32 +361,33 @@ unsigned DxilSignatureAllocator::PackOptimized(std::vector<PackElement*> element
|
|||
}
|
||||
|
||||
switch (SE->GetInterpretation()) {
|
||||
case DXIL::SemanticInterpretationKind::Arb:
|
||||
if (SE->GetCols() == 4)
|
||||
vec4Elements.push_back(SE);
|
||||
else
|
||||
arbElements.push_back(SE);
|
||||
break;
|
||||
case DXIL::SemanticInterpretationKind::ClipCull:
|
||||
clipcullElements.push_back(SE);
|
||||
break;
|
||||
case DXIL::SemanticInterpretationKind::SV:
|
||||
if (SE->GetCols() == 4)
|
||||
vec4Elements.push_back(SE);
|
||||
else
|
||||
svElements.push_back(SE);
|
||||
break;
|
||||
case DXIL::SemanticInterpretationKind::SGV:
|
||||
sgvElements.push_back(SE);
|
||||
break;
|
||||
case DXIL::SemanticInterpretationKind::TessFactor:
|
||||
if (SE->GetRows() > 1)
|
||||
indexedtessElements.push_back(SE);
|
||||
else
|
||||
svElements.push_back(SE);
|
||||
break;
|
||||
default:
|
||||
DXASSERT(false, "otherwise, unexpected interpretation for allocated element");
|
||||
case DXIL::SemanticInterpretationKind::Arb:
|
||||
if (SE->GetCols() == 4)
|
||||
vec4Elements.push_back(SE);
|
||||
else
|
||||
arbElements.push_back(SE);
|
||||
break;
|
||||
case DXIL::SemanticInterpretationKind::ClipCull:
|
||||
clipcullElements.push_back(SE);
|
||||
break;
|
||||
case DXIL::SemanticInterpretationKind::SV:
|
||||
if (SE->GetCols() == 4)
|
||||
vec4Elements.push_back(SE);
|
||||
else
|
||||
svElements.push_back(SE);
|
||||
break;
|
||||
case DXIL::SemanticInterpretationKind::SGV:
|
||||
sgvElements.push_back(SE);
|
||||
break;
|
||||
case DXIL::SemanticInterpretationKind::TessFactor:
|
||||
if (SE->GetRows() > 1)
|
||||
indexedtessElements.push_back(SE);
|
||||
else
|
||||
svElements.push_back(SE);
|
||||
break;
|
||||
default:
|
||||
DXASSERT(false,
|
||||
"otherwise, unexpected interpretation for allocated element");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -372,8 +402,10 @@ unsigned DxilSignatureAllocator::PackOptimized(std::vector<PackElement*> element
|
|||
// ==========
|
||||
// Allocate indexed tessfactors in rightmost column
|
||||
if (!indexedtessElements.empty()) {
|
||||
std::sort(indexedtessElements.begin(), indexedtessElements.end(), CmpElementsLess);
|
||||
rowsUsed = std::max(rowsUsed, PackGreedy(indexedtessElements, startRow, numRows, 3));
|
||||
std::sort(indexedtessElements.begin(), indexedtessElements.end(),
|
||||
CmpElementsLess);
|
||||
rowsUsed = std::max(rowsUsed,
|
||||
PackGreedy(indexedtessElements, startRow, numRows, 3));
|
||||
}
|
||||
|
||||
// ==========
|
||||
|
@ -403,9 +435,12 @@ unsigned DxilSignatureAllocator::PackOptimized(std::vector<PackElement*> element
|
|||
}
|
||||
if (0 == clipCullMultiRowCols) {
|
||||
// Preallocate clip/cull elements into two rows and allocate independently
|
||||
DxilSignatureAllocator clipcullAllocator(DXIL::kMaxClipOrCullDistanceElementCount, m_bUseMinPrecision);
|
||||
unsigned clipcullRegUsed = clipcullAllocator.PackGreedy(clipcullElements, 0, DXIL::kMaxClipOrCullDistanceElementCount);
|
||||
unsigned clipcullComponentsByRow[DXIL::kMaxClipOrCullDistanceElementCount] = {0, 0};
|
||||
DxilSignatureAllocator clipcullAllocator(
|
||||
DXIL::kMaxClipOrCullDistanceElementCount, m_bUseMinPrecision);
|
||||
unsigned clipcullRegUsed = clipcullAllocator.PackGreedy(
|
||||
clipcullElements, 0, DXIL::kMaxClipOrCullDistanceElementCount);
|
||||
unsigned clipcullComponentsByRow[DXIL::kMaxClipOrCullDistanceElementCount] =
|
||||
{0, 0};
|
||||
for (auto &SE : clipcullElements) {
|
||||
if (!SE->IsAllocated()) {
|
||||
continue;
|
||||
|
@ -424,9 +459,12 @@ unsigned DxilSignatureAllocator::PackOptimized(std::vector<PackElement*> element
|
|||
for (unsigned row = 0; row < clipcullRegUsed; ++row) {
|
||||
DXASSERT_NOMSG(!clipcullElementsByRow[row].empty());
|
||||
clipcullTempElements[row].kind = clipcullElementsByRow[row][0]->GetKind();
|
||||
clipcullTempElements[row].interpolation = clipcullElementsByRow[row][0]->GetInterpolationMode();
|
||||
clipcullTempElements[row].interpretation = clipcullElementsByRow[row][0]->GetInterpretation();
|
||||
clipcullTempElements[row].dataBitWidth = clipcullElementsByRow[row][0]->GetDataBitWidth();
|
||||
clipcullTempElements[row].interpolation =
|
||||
clipcullElementsByRow[row][0]->GetInterpolationMode();
|
||||
clipcullTempElements[row].interpretation =
|
||||
clipcullElementsByRow[row][0]->GetInterpretation();
|
||||
clipcullTempElements[row].dataBitWidth =
|
||||
clipcullElementsByRow[row][0]->GetDataBitWidth();
|
||||
clipcullTempElements[row].rows = 1;
|
||||
clipcullTempElements[row].cols = clipcullComponentsByRow[row];
|
||||
}
|
||||
|
@ -459,10 +497,12 @@ unsigned DxilSignatureAllocator::PackOptimized(std::vector<PackElement*> element
|
|||
for (unsigned i = 0; i < numRows - 1; ++i) {
|
||||
unsigned row = startRow + i;
|
||||
// Use temp allocator with copy of rows to test locations
|
||||
DxilSignatureAllocator clipcullAllocator(DXIL::kMaxClipOrCullDistanceElementCount, m_bUseMinPrecision);
|
||||
DxilSignatureAllocator clipcullAllocator(
|
||||
DXIL::kMaxClipOrCullDistanceElementCount, m_bUseMinPrecision);
|
||||
clipcullAllocator.m_Registers[0] = m_Registers[row];
|
||||
clipcullAllocator.m_Registers[1] = m_Registers[row + 1];
|
||||
clipcullAllocator.PackGreedy(clipcullElements, 0, DXIL::kMaxClipOrCullDistanceElementCount, 0);
|
||||
clipcullAllocator.PackGreedy(clipcullElements, 0,
|
||||
DXIL::kMaxClipOrCullDistanceElementCount, 0);
|
||||
bool bFullyAllocated = true;
|
||||
for (auto &SE : clipcullElements) {
|
||||
bFullyAllocated &= SE->IsAllocated();
|
||||
|
@ -474,14 +514,16 @@ unsigned DxilSignatureAllocator::PackOptimized(std::vector<PackElement*> element
|
|||
SE->ClearLocation();
|
||||
if (bFullyAllocated) {
|
||||
// Found a spot, do real allocation
|
||||
PackGreedy(clipcullElements, row, DXIL::kMaxClipOrCullDistanceElementCount);
|
||||
PackGreedy(clipcullElements, row,
|
||||
DXIL::kMaxClipOrCullDistanceElementCount);
|
||||
#ifndef NDEBUG
|
||||
for (auto &SE : clipcullElements) {
|
||||
bFullyAllocated &= SE->IsAllocated();
|
||||
if (!bFullyAllocated)
|
||||
break;
|
||||
}
|
||||
DXASSERT(bFullyAllocated, "otherwise, clip/cull allocation failed when predicted to succeed.");
|
||||
DXASSERT(bFullyAllocated, "otherwise, clip/cull allocation failed when "
|
||||
"predicted to succeed.");
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
@ -498,16 +540,21 @@ unsigned DxilSignatureAllocator::PackOptimized(std::vector<PackElement*> element
|
|||
return rowsUsed;
|
||||
}
|
||||
|
||||
unsigned DxilSignatureAllocator::PackPrefixStable(std::vector<PackElement*> elements, unsigned startRow, unsigned numRows) {
|
||||
unsigned
|
||||
DxilSignatureAllocator::PackPrefixStable(std::vector<PackElement *> elements,
|
||||
unsigned startRow, unsigned numRows) {
|
||||
unsigned rowsUsed = 0;
|
||||
|
||||
// Special handling for prefix-stable clip/cull arguments
|
||||
// - basically, do not pack with anything else to maximize chance to pack into two register limit
|
||||
// - this is complicated by multi-row clip/cull elements, which force allocation adjacency,
|
||||
// - basically, do not pack with anything else to maximize chance to pack into
|
||||
// two register limit
|
||||
// - this is complicated by multi-row clip/cull elements, which force
|
||||
// allocation adjacency,
|
||||
// but PrefixStable does not know in advance if this will be the case.
|
||||
unsigned clipcullRegUsed = 0;
|
||||
bool clipcullIndexed = false;
|
||||
DxilSignatureAllocator clipcullAllocator(DXIL::kMaxClipOrCullDistanceElementCount, m_bUseMinPrecision);
|
||||
DxilSignatureAllocator clipcullAllocator(
|
||||
DXIL::kMaxClipOrCullDistanceElementCount, m_bUseMinPrecision);
|
||||
DummyElement clipcullTempElements[DXIL::kMaxClipOrCullDistanceElementCount];
|
||||
|
||||
for (auto &SE : elements) {
|
||||
|
@ -517,80 +564,84 @@ unsigned DxilSignatureAllocator::PackPrefixStable(std::vector<PackElement*> elem
|
|||
}
|
||||
|
||||
switch (SE->GetInterpretation()) {
|
||||
case DXIL::SemanticInterpretationKind::Arb:
|
||||
case DXIL::SemanticInterpretationKind::SGV:
|
||||
break;
|
||||
case DXIL::SemanticInterpretationKind::SV:
|
||||
break;
|
||||
case DXIL::SemanticInterpretationKind::ClipCull:
|
||||
{
|
||||
unsigned row, col;
|
||||
unsigned used = clipcullAllocator.FindNext(row, col, SE, 0, DXIL::kMaxClipOrCullDistanceElementCount);
|
||||
if (!used)
|
||||
continue;
|
||||
if (SE->GetRows() > 1 && !clipcullIndexed) {
|
||||
// If two rows already allocated, they must be adjacent to
|
||||
// pack indexed elements.
|
||||
if (clipcullRegUsed == DXIL::kMaxClipOrCullDistanceElementCount &&
|
||||
clipcullTempElements[0].row + 1 != clipcullTempElements[1].row)
|
||||
case DXIL::SemanticInterpretationKind::Arb:
|
||||
case DXIL::SemanticInterpretationKind::SGV:
|
||||
break;
|
||||
case DXIL::SemanticInterpretationKind::SV:
|
||||
break;
|
||||
case DXIL::SemanticInterpretationKind::ClipCull: {
|
||||
unsigned row, col;
|
||||
unsigned used = clipcullAllocator.FindNext(
|
||||
row, col, SE, 0, DXIL::kMaxClipOrCullDistanceElementCount);
|
||||
if (!used)
|
||||
continue;
|
||||
if (SE->GetRows() > 1 && !clipcullIndexed) {
|
||||
// If two rows already allocated, they must be adjacent to
|
||||
// pack indexed elements.
|
||||
if (clipcullRegUsed == DXIL::kMaxClipOrCullDistanceElementCount &&
|
||||
clipcullTempElements[0].row + 1 != clipcullTempElements[1].row)
|
||||
continue;
|
||||
clipcullIndexed = true;
|
||||
}
|
||||
// If necessary, allocate placeholder element to reserve space in
|
||||
// signature:
|
||||
if (used > clipcullRegUsed) {
|
||||
auto &DE = clipcullTempElements[clipcullRegUsed];
|
||||
DE.kind = SE->GetKind();
|
||||
DE.interpolation = SE->GetInterpolationMode();
|
||||
DE.interpretation = SE->GetInterpretation();
|
||||
DE.dataBitWidth = SE->GetDataBitWidth();
|
||||
DE.rows = 1;
|
||||
DE.cols = 4;
|
||||
if (clipcullIndexed) {
|
||||
// Either allocate one 2-row placeholder element, or allocate on
|
||||
// adjacent row.
|
||||
if (clipcullRegUsed < 1) {
|
||||
// Allocate one element with 2 rows
|
||||
DE.rows = DXIL::kMaxClipOrCullDistanceElementCount;
|
||||
rowsUsed = std::max(rowsUsed, PackNext(&DE, startRow, numRows));
|
||||
if (!DE.IsAllocated())
|
||||
continue;
|
||||
// Init second placeholder element to next row because it's used to
|
||||
// adjust element locations starting on that row.
|
||||
clipcullTempElements[1] = DE;
|
||||
clipcullTempElements[1].row = DE.row + 1;
|
||||
clipcullTempElements[1].rows = 1;
|
||||
} else {
|
||||
DXASSERT_NOMSG(clipcullRegUsed == 1);
|
||||
// Make sure additional element can be placed just after other
|
||||
// element, otherwise fail to allocate this element.
|
||||
rowsUsed = std::max(rowsUsed,
|
||||
PackNext(&DE, clipcullTempElements[0].row + 1,
|
||||
clipcullTempElements[0].row + 2));
|
||||
if (!DE.IsAllocated())
|
||||
continue;
|
||||
clipcullIndexed = true;
|
||||
}
|
||||
// If necessary, allocate placeholder element to reserve space in signature:
|
||||
if (used > clipcullRegUsed) {
|
||||
auto &DE = clipcullTempElements[clipcullRegUsed];
|
||||
DE.kind = SE->GetKind();
|
||||
DE.interpolation = SE->GetInterpolationMode();
|
||||
DE.interpretation = SE->GetInterpretation();
|
||||
DE.dataBitWidth = SE->GetDataBitWidth();
|
||||
DE.rows = 1;
|
||||
DE.cols = 4;
|
||||
if (clipcullIndexed) {
|
||||
// Either allocate one 2-row placeholder element, or allocate on adjacent row.
|
||||
if (clipcullRegUsed < 1) {
|
||||
// Allocate one element with 2 rows
|
||||
DE.rows = DXIL::kMaxClipOrCullDistanceElementCount;
|
||||
rowsUsed = std::max(rowsUsed, PackNext(&DE, startRow, numRows));
|
||||
if (!DE.IsAllocated())
|
||||
continue;
|
||||
// Init second placeholder element to next row because it's used to
|
||||
// adjust element locations starting on that row.
|
||||
clipcullTempElements[1] = DE;
|
||||
clipcullTempElements[1].row = DE.row + 1;
|
||||
clipcullTempElements[1].rows = 1;
|
||||
} else {
|
||||
DXASSERT_NOMSG(clipcullRegUsed == 1);
|
||||
// Make sure additional element can be placed just after other
|
||||
// element, otherwise fail to allocate this element.
|
||||
rowsUsed = std::max(rowsUsed, PackNext(&DE,
|
||||
clipcullTempElements[0].row + 1, clipcullTempElements[0].row + 2));
|
||||
if (!DE.IsAllocated())
|
||||
continue;
|
||||
}
|
||||
clipcullRegUsed = DXIL::kMaxClipOrCullDistanceElementCount;
|
||||
} else {
|
||||
// allocate placeholder element, reserving new row(s)
|
||||
rowsUsed = std::max(rowsUsed, PackNext(&DE, startRow, numRows));
|
||||
if (!DE.IsAllocated())
|
||||
continue;
|
||||
clipcullRegUsed = used;
|
||||
}
|
||||
}
|
||||
// Place element in temp allocator and adjust row for signature
|
||||
clipcullAllocator.PlaceElement(SE, row, col);
|
||||
SE->SetLocation(clipcullTempElements[row].GetStartRow(), col);
|
||||
continue;
|
||||
clipcullRegUsed = DXIL::kMaxClipOrCullDistanceElementCount;
|
||||
} else {
|
||||
// allocate placeholder element, reserving new row(s)
|
||||
rowsUsed = std::max(rowsUsed, PackNext(&DE, startRow, numRows));
|
||||
if (!DE.IsAllocated())
|
||||
continue;
|
||||
clipcullRegUsed = used;
|
||||
}
|
||||
break;
|
||||
case DXIL::SemanticInterpretationKind::TessFactor:
|
||||
if (SE->GetRows() > 1) {
|
||||
// Maximize opportunity for packing while preserving prefix-stable property
|
||||
rowsUsed = std::max(rowsUsed, PackNext(SE, startRow, numRows, 3));
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
DXASSERT(false, "otherwise, unexpected interpretation for allocated element");
|
||||
}
|
||||
// Place element in temp allocator and adjust row for signature
|
||||
clipcullAllocator.PlaceElement(SE, row, col);
|
||||
SE->SetLocation(clipcullTempElements[row].GetStartRow(), col);
|
||||
continue;
|
||||
} break;
|
||||
case DXIL::SemanticInterpretationKind::TessFactor:
|
||||
if (SE->GetRows() > 1) {
|
||||
// Maximize opportunity for packing while preserving prefix-stable
|
||||
// property
|
||||
rowsUsed = std::max(rowsUsed, PackNext(SE, startRow, numRows, 3));
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
DXASSERT(false,
|
||||
"otherwise, unexpected interpretation for allocated element");
|
||||
}
|
||||
rowsUsed = std::max(rowsUsed, PackNext(SE, startRow, numRows));
|
||||
}
|
||||
|
@ -598,5 +649,4 @@ unsigned DxilSignatureAllocator::PackPrefixStable(std::vector<PackElement*> elem
|
|||
return rowsUsed;
|
||||
}
|
||||
|
||||
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -12,29 +12,28 @@
|
|||
#pragma once
|
||||
|
||||
#include "dxc/Support/Global.h"
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
template<typename T_index, typename T_element>
|
||||
class SpanAllocator {
|
||||
template <typename T_index, typename T_element> class SpanAllocator {
|
||||
public:
|
||||
struct Span {
|
||||
Span(const T_element *element, T_index start, T_index end)
|
||||
: element(element), start(start), end(end) {
|
||||
: element(element), start(start), end(end) {
|
||||
DXASSERT_NOMSG(!(end < start));
|
||||
}
|
||||
const T_element *element;
|
||||
T_index start, end; // inclusive
|
||||
T_index start, end; // inclusive
|
||||
bool operator<(const Span &other) const { return end < other.start; }
|
||||
};
|
||||
typedef std::set<Span> SpanSet;
|
||||
|
||||
public:
|
||||
SpanAllocator(T_index Min, T_index Max)
|
||||
: m_Min(Min), m_Max(Max), m_FirstFree(Min),
|
||||
m_Unbounded(nullptr), m_AllocationFull(false) {
|
||||
: m_Min(Min), m_Max(Max), m_FirstFree(Min), m_Unbounded(nullptr),
|
||||
m_AllocationFull(false) {
|
||||
DXASSERT_NOMSG(Min <= Max);
|
||||
}
|
||||
T_index GetMin() { return m_Min; }
|
||||
|
@ -45,7 +44,8 @@ public:
|
|||
const T_element *GetUnbounded() const { return m_Unbounded; }
|
||||
const SpanSet &GetSpans() const { return m_Spans; }
|
||||
|
||||
// Find size gap starting at pos, updating pos, and returning true if successful
|
||||
// Find size gap starting at pos, updating pos, and returning true if
|
||||
// successful
|
||||
bool Find(T_index size, T_index &pos, T_index align = 1) {
|
||||
DXASSERT_NOMSG(size);
|
||||
if (size - 1 > m_Max - m_Min)
|
||||
|
@ -57,7 +57,7 @@ public:
|
|||
T_index end = pos + (size - 1);
|
||||
auto next = m_Spans.lower_bound(Span(nullptr, pos, end));
|
||||
if (next == m_Spans.end() || end < next->start)
|
||||
return true; // it fits here
|
||||
return true; // it fits here
|
||||
return Find(size, next, pos, align);
|
||||
}
|
||||
|
||||
|
@ -65,15 +65,16 @@ public:
|
|||
bool FindForUnbounded(T_index &pos, T_index align = 1) {
|
||||
if (m_Spans.empty()) {
|
||||
pos = m_Min;
|
||||
return UpdatePos(pos, /*size*/1, align);
|
||||
return UpdatePos(pos, /*size*/ 1, align);
|
||||
}
|
||||
|
||||
pos = m_Spans.crbegin()->end;
|
||||
return IncPos(pos, /*inc*/ 1, /*size*/1, align);
|
||||
return IncPos(pos, /*inc*/ 1, /*size*/ 1, align);
|
||||
}
|
||||
|
||||
// allocate element size in first available space, returns false on failure
|
||||
bool Allocate(const T_element *element, T_index size, T_index &pos, T_index align = 1) {
|
||||
bool Allocate(const T_element *element, T_index size, T_index &pos,
|
||||
T_index align = 1) {
|
||||
DXASSERT_NOMSG(size);
|
||||
if (size - 1 > m_Max - m_Min)
|
||||
return false;
|
||||
|
@ -94,19 +95,21 @@ public:
|
|||
return result.second;
|
||||
}
|
||||
|
||||
bool AllocateUnbounded(const T_element *element, T_index &pos, T_index align = 1) {
|
||||
bool AllocateUnbounded(const T_element *element, T_index &pos,
|
||||
T_index align = 1) {
|
||||
if (m_AllocationFull)
|
||||
return false;
|
||||
if (m_Spans.empty()) {
|
||||
pos = m_Min;
|
||||
if (!UpdatePos(pos, /*size*/1, align))
|
||||
if (!UpdatePos(pos, /*size*/ 1, align))
|
||||
return false;
|
||||
} else {
|
||||
// This will allocate after the last span
|
||||
auto it = m_Spans.end(); --it; // find last span
|
||||
auto it = m_Spans.end();
|
||||
--it; // find last span
|
||||
DXASSERT_NOMSG(it != m_Spans.end());
|
||||
pos = it->end;
|
||||
if (!IncPos(pos, /*inc*/1, /*size*/1, align))
|
||||
if (!IncPos(pos, /*inc*/ 1, /*size*/ 1, align))
|
||||
return false;
|
||||
}
|
||||
const T_element *conflict = Insert(element, pos, m_Max);
|
||||
|
@ -117,7 +120,8 @@ public:
|
|||
}
|
||||
|
||||
// Insert at specific location, returning conflicting element on collision
|
||||
const T_element *Insert(const T_element *element, T_index start, T_index end) {
|
||||
const T_element *Insert(const T_element *element, T_index start,
|
||||
T_index end) {
|
||||
DXASSERT_NOMSG(m_Min <= start && start <= end && end <= m_Max);
|
||||
auto result = m_Spans.emplace(element, start, end);
|
||||
if (!result.second)
|
||||
|
@ -128,13 +132,15 @@ public:
|
|||
|
||||
// Insert at specific location, overwriting anything previously there,
|
||||
// losing their element pointer, but conserving the spans they represented.
|
||||
void ForceInsertAndClobber(const T_element *element, T_index start, T_index end) {
|
||||
void ForceInsertAndClobber(const T_element *element, T_index start,
|
||||
T_index end) {
|
||||
DXASSERT_NOMSG(m_Min <= start && start <= end && end <= m_Max);
|
||||
for (;;) {
|
||||
auto result = m_Spans.emplace(element, start, end);
|
||||
if (result.second)
|
||||
break;
|
||||
// Delete the spans we overlap with, but make sure our new span covers what they covered.
|
||||
// Delete the spans we overlap with, but make sure our new span covers
|
||||
// what they covered.
|
||||
start = std::min(result.first->start, start);
|
||||
end = std::max(result.first->end, end);
|
||||
m_Spans.erase(result.first);
|
||||
|
@ -142,14 +148,18 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
// Find size gap starting at iterator, updating pos, and returning true if successful
|
||||
bool Find(T_index size, typename SpanSet::const_iterator it, T_index &pos, T_index align = 1) {
|
||||
// Find size gap starting at iterator, updating pos, and returning true if
|
||||
// successful
|
||||
bool Find(T_index size, typename SpanSet::const_iterator it, T_index &pos,
|
||||
T_index align = 1) {
|
||||
pos = it->end;
|
||||
if (!IncPos(pos, /*inc*/1, size, align))
|
||||
if (!IncPos(pos, /*inc*/ 1, size, align))
|
||||
return false;
|
||||
for (++it; it != m_Spans.end() && (it->start < pos || it->start - pos < size); ++it) {
|
||||
for (++it;
|
||||
it != m_Spans.end() && (it->start < pos || it->start - pos < size);
|
||||
++it) {
|
||||
pos = it->end;
|
||||
if (!IncPos(pos, /*inc*/1, size, align))
|
||||
if (!IncPos(pos, /*inc*/ 1, size, align))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -158,7 +168,7 @@ private:
|
|||
// Advance m_FirstFree if it's in span
|
||||
void AdvanceFirstFree(typename SpanSet::const_iterator it) {
|
||||
if (it->start <= m_FirstFree && m_FirstFree <= it->end) {
|
||||
for (; it != m_Spans.end(); ) {
|
||||
for (; it != m_Spans.end();) {
|
||||
if (it->end >= m_Max) {
|
||||
m_AllocationFull = true;
|
||||
break;
|
||||
|
@ -176,7 +186,8 @@ private:
|
|||
return rem ? pos + (align - rem) : pos;
|
||||
}
|
||||
|
||||
bool IncPos(T_index &pos, T_index inc = 1, T_index size = 1, T_index align = 1) {
|
||||
bool IncPos(T_index &pos, T_index inc = 1, T_index size = 1,
|
||||
T_index align = 1) {
|
||||
DXASSERT_NOMSG(inc > 0);
|
||||
if (pos + inc < pos)
|
||||
return false; // overflow
|
||||
|
@ -200,11 +211,10 @@ private:
|
|||
bool m_AllocationFull;
|
||||
};
|
||||
|
||||
template<typename T_index, typename T_element>
|
||||
class SpacesAllocator {
|
||||
template <typename T_index, typename T_element> class SpacesAllocator {
|
||||
public:
|
||||
typedef SpanAllocator<T_index, T_element> Allocator;
|
||||
typedef std::map<T_index, Allocator > AllocatorMap;
|
||||
typedef std::map<T_index, Allocator> AllocatorMap;
|
||||
|
||||
Allocator &Get(T_index SpaceID) {
|
||||
auto it = m_Allocators.find(SpaceID);
|
||||
|
@ -219,4 +229,4 @@ private:
|
|||
AllocatorMap m_Allocators;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "dxc/Support/Global.h"
|
||||
#include "dxc/DXIL/DxilConstants.h"
|
||||
#include "dxc/Support/Global.h"
|
||||
#include "dxc/WinAdapter.h"
|
||||
#include <memory>
|
||||
|
||||
|
@ -22,7 +22,7 @@ class LLVMContext;
|
|||
class raw_ostream;
|
||||
class DiagnosticPrinter;
|
||||
class DiagnosticInfo;
|
||||
}
|
||||
} // namespace llvm
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
|
@ -50,7 +50,8 @@ bool VerifyFeatureInfoMatches(llvm::Module *pModule,
|
|||
const void *pFeatureInfoData,
|
||||
uint32_t FeatureInfoSize);
|
||||
|
||||
// Validate the container parts, assuming supplied module is valid, loaded from the container provided
|
||||
// Validate the container parts, assuming supplied module is valid, loaded from
|
||||
// the container provided
|
||||
struct DxilContainerHeader;
|
||||
HRESULT ValidateDxilContainerParts(llvm::Module *pModule,
|
||||
llvm::Module *pDebugModule,
|
||||
|
@ -106,4 +107,4 @@ public:
|
|||
static void PrintDiagnosticHandler(const llvm::DiagnosticInfo &DI,
|
||||
void *Context);
|
||||
};
|
||||
}
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
#include "dxc/Support/Global.h"
|
||||
#include "dxc/DXIL/DxilConstants.h"
|
||||
#include "dxc/DXIL/DxilTypeSystem.h"
|
||||
#include "dxc/Support/Global.h"
|
||||
|
||||
namespace llvm {
|
||||
class Constant;
|
||||
|
@ -25,13 +25,14 @@ class Value;
|
|||
namespace hlsl {
|
||||
class DxilTypeSystem;
|
||||
|
||||
llvm::StructType *GetLoweredUDT(
|
||||
llvm::StructType *structTy, hlsl::DxilTypeSystem *pTypeSys = nullptr);
|
||||
llvm::Constant *TranslateInitForLoweredUDT(
|
||||
llvm::Constant *Init, llvm::Type *NewTy,
|
||||
// We need orientation for matrix fields
|
||||
hlsl::DxilTypeSystem *pTypeSys,
|
||||
hlsl::MatrixOrientation matOrientation = hlsl::MatrixOrientation::Undefined);
|
||||
llvm::StructType *GetLoweredUDT(llvm::StructType *structTy,
|
||||
hlsl::DxilTypeSystem *pTypeSys = nullptr);
|
||||
llvm::Constant *
|
||||
TranslateInitForLoweredUDT(llvm::Constant *Init, llvm::Type *NewTy,
|
||||
// We need orientation for matrix fields
|
||||
hlsl::DxilTypeSystem *pTypeSys,
|
||||
hlsl::MatrixOrientation matOrientation =
|
||||
hlsl::MatrixOrientation::Undefined);
|
||||
void ReplaceUsesForLoweredUDT(llvm::Value *V, llvm::Value *NewV);
|
||||
|
||||
} // namespace hlsl
|
|
@ -14,11 +14,10 @@
|
|||
#include "llvm/IR/IRBuilder.h"
|
||||
|
||||
namespace llvm {
|
||||
class Type;
|
||||
class Value;
|
||||
template<typename T>
|
||||
class ArrayRef;
|
||||
}
|
||||
class Type;
|
||||
class Value;
|
||||
template <typename T> class ArrayRef;
|
||||
} // namespace llvm
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
|
@ -27,8 +26,7 @@ class DxilTypeSystem;
|
|||
|
||||
namespace HLMatrixLower {
|
||||
|
||||
llvm::Value *BuildVector(llvm::Type *EltTy,
|
||||
llvm::ArrayRef<llvm::Value *> elts,
|
||||
llvm::Value *BuildVector(llvm::Type *EltTy, llvm::ArrayRef<llvm::Value *> elts,
|
||||
llvm::IRBuilder<> &Builder);
|
||||
|
||||
} // namespace HLMatrixLower
|
||||
|
|
|
@ -18,6 +18,6 @@ class PassRegistry;
|
|||
/// \brief Create and return a pass that lower high level matrix.
|
||||
/// Note that this pass is designed for use with the legacy pass manager.
|
||||
ModulePass *createHLMatrixLowerPass();
|
||||
void initializeHLMatrixLowerPassPass(llvm::PassRegistry&);
|
||||
void initializeHLMatrixLowerPassPass(llvm::PassRegistry &);
|
||||
|
||||
}
|
||||
} // namespace llvm
|
||||
|
|
|
@ -12,15 +12,14 @@
|
|||
#include "llvm/IR/IRBuilder.h"
|
||||
|
||||
namespace llvm {
|
||||
template<typename T>
|
||||
class ArrayRef;
|
||||
class Type;
|
||||
class Value;
|
||||
class Constant;
|
||||
class StructType;
|
||||
class VectorType;
|
||||
class StoreInst;
|
||||
}
|
||||
template <typename T> class ArrayRef;
|
||||
class Type;
|
||||
class Value;
|
||||
class Constant;
|
||||
class StructType;
|
||||
class VectorType;
|
||||
class StoreInst;
|
||||
} // namespace llvm
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
|
@ -31,27 +30,27 @@ class DxilTypeSystem;
|
|||
//
|
||||
// Matrices are represented by an llvm struct type of the following form:
|
||||
// { [RowCount x <ColCount x RegReprTy>] }
|
||||
// Note that the element type is always in its register representation (ie bools are i1s).
|
||||
// This allows preserving the original type and is okay since matrix types are only
|
||||
// manipulated in an opaque way, through intrinsics.
|
||||
// Note that the element type is always in its register representation (ie bools
|
||||
// are i1s). This allows preserving the original type and is okay since matrix
|
||||
// types are only manipulated in an opaque way, through intrinsics.
|
||||
//
|
||||
// During matrix lowering, matrices are converted to vectors of the following form:
|
||||
// <RowCount*ColCount x Ty>
|
||||
// At this point, register vs memory representation starts to matter and we have to
|
||||
// imitate the codegen for scalar and vector bools: i1s when in llvm registers,
|
||||
// and i32s when in memory (allocas, pointers, or in structs/lists, which are always in memory).
|
||||
// During matrix lowering, matrices are converted to vectors of the following
|
||||
// form: <RowCount*ColCount x Ty> At this point, register vs memory
|
||||
// representation starts to matter and we have to imitate the codegen for scalar
|
||||
// and vector bools: i1s when in llvm registers, and i32s when in memory
|
||||
// (allocas, pointers, or in structs/lists, which are always in memory).
|
||||
//
|
||||
// This class is designed to resemble a llvm::Type-derived class.
|
||||
class HLMatrixType
|
||||
{
|
||||
class HLMatrixType {
|
||||
public:
|
||||
static constexpr const char* StructNamePrefix = "class.matrix.";
|
||||
static constexpr const char *StructNamePrefix = "class.matrix.";
|
||||
|
||||
HLMatrixType() : RegReprElemTy(nullptr), NumRows(0), NumColumns(0) {}
|
||||
HLMatrixType(llvm::Type *RegReprElemTy, unsigned NumRows, unsigned NumColumns);
|
||||
HLMatrixType(llvm::Type *RegReprElemTy, unsigned NumRows,
|
||||
unsigned NumColumns);
|
||||
|
||||
// We allow default construction to an invalid state to support the dynCast pattern.
|
||||
// This tests whether we have a legit object.
|
||||
// We allow default construction to an invalid state to support the dynCast
|
||||
// pattern. This tests whether we have a legit object.
|
||||
operator bool() const { return RegReprElemTy != nullptr; }
|
||||
|
||||
llvm::Type *getElementType(bool MemRepr) const;
|
||||
|
@ -62,20 +61,32 @@ public:
|
|||
unsigned getNumElements() const { return NumRows * NumColumns; }
|
||||
unsigned getRowMajorIndex(unsigned RowIdx, unsigned ColIdx) const;
|
||||
unsigned getColumnMajorIndex(unsigned RowIdx, unsigned ColIdx) const;
|
||||
static unsigned getRowMajorIndex(unsigned RowIdx, unsigned ColIdx, unsigned NumRows, unsigned NumColumns);
|
||||
static unsigned getColumnMajorIndex(unsigned RowIdx, unsigned ColIdx, unsigned NumRows, unsigned NumColumns);
|
||||
static unsigned getRowMajorIndex(unsigned RowIdx, unsigned ColIdx,
|
||||
unsigned NumRows, unsigned NumColumns);
|
||||
static unsigned getColumnMajorIndex(unsigned RowIdx, unsigned ColIdx,
|
||||
unsigned NumRows, unsigned NumColumns);
|
||||
|
||||
llvm::VectorType *getLoweredVectorType(bool MemRepr) const;
|
||||
llvm::VectorType *getLoweredVectorTypeForReg() const { return getLoweredVectorType(false); }
|
||||
llvm::VectorType *getLoweredVectorTypeForMem() const { return getLoweredVectorType(true); }
|
||||
llvm::VectorType *getLoweredVectorTypeForReg() const {
|
||||
return getLoweredVectorType(false);
|
||||
}
|
||||
llvm::VectorType *getLoweredVectorTypeForMem() const {
|
||||
return getLoweredVectorType(true);
|
||||
}
|
||||
|
||||
llvm::Value *emitLoweredMemToReg(llvm::Value *Val, llvm::IRBuilder<> &Builder) const;
|
||||
llvm::Value *emitLoweredRegToMem(llvm::Value *Val, llvm::IRBuilder<> &Builder) const;
|
||||
llvm::Value *emitLoweredLoad(llvm::Value *Ptr, llvm::IRBuilder<> &Builder) const;
|
||||
llvm::StoreInst *emitLoweredStore(llvm::Value *Val, llvm::Value *Ptr, llvm::IRBuilder<> &Builder) const;
|
||||
llvm::Value *emitLoweredMemToReg(llvm::Value *Val,
|
||||
llvm::IRBuilder<> &Builder) const;
|
||||
llvm::Value *emitLoweredRegToMem(llvm::Value *Val,
|
||||
llvm::IRBuilder<> &Builder) const;
|
||||
llvm::Value *emitLoweredLoad(llvm::Value *Ptr,
|
||||
llvm::IRBuilder<> &Builder) const;
|
||||
llvm::StoreInst *emitLoweredStore(llvm::Value *Val, llvm::Value *Ptr,
|
||||
llvm::IRBuilder<> &Builder) const;
|
||||
|
||||
llvm::Value *emitLoweredVectorRowToCol(llvm::Value *VecVal, llvm::IRBuilder<> &Builder) const;
|
||||
llvm::Value *emitLoweredVectorColToRow(llvm::Value *VecVal, llvm::IRBuilder<> &Builder) const;
|
||||
llvm::Value *emitLoweredVectorRowToCol(llvm::Value *VecVal,
|
||||
llvm::IRBuilder<> &Builder) const;
|
||||
llvm::Value *emitLoweredVectorColToRow(llvm::Value *VecVal,
|
||||
llvm::IRBuilder<> &Builder) const;
|
||||
|
||||
static bool isa(llvm::Type *Ty);
|
||||
static bool isMatrixPtr(llvm::Type *Ty);
|
||||
|
|
|
@ -11,25 +11,25 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "dxc/Support/Global.h"
|
||||
#include "dxc/DXIL/DxilMetadataHelper.h"
|
||||
#include "dxc/DXIL/DxilConstants.h"
|
||||
#include "dxc/HLSL/HLResource.h"
|
||||
#include "dxc/HLSL/HLOperations.h"
|
||||
#include "dxc/DXIL/DxilFunctionProps.h"
|
||||
#include "dxc/DXIL/DxilMetadataHelper.h"
|
||||
#include "dxc/DXIL/DxilResourceProperties.h"
|
||||
#include "dxc/DXIL/DxilSampler.h"
|
||||
#include "dxc/DXIL/DxilShaderModel.h"
|
||||
#include "dxc/DXIL/DxilSignature.h"
|
||||
#include "dxc/DXIL/DxilFunctionProps.h"
|
||||
#include "dxc/DXIL/DxilSubobject.h"
|
||||
#include "dxc/DXIL/DxilResourceProperties.h"
|
||||
#include "dxc/HLSL/HLOperations.h"
|
||||
#include "dxc/HLSL/HLResource.h"
|
||||
#include "dxc/Support/Global.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
template<typename T> class ArrayRef;
|
||||
template <typename T> class ArrayRef;
|
||||
class LLVMContext;
|
||||
class Module;
|
||||
class Function;
|
||||
|
@ -41,8 +41,7 @@ class GlobalVariable;
|
|||
class DIGlobalVariable;
|
||||
class DebugInfoFinder;
|
||||
class GetElementPtrInst;
|
||||
}
|
||||
|
||||
} // namespace llvm
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
|
@ -51,29 +50,33 @@ class OP;
|
|||
|
||||
struct HLOptions {
|
||||
HLOptions()
|
||||
: bDefaultRowMajor(false), bIEEEStrict(false), bAllResourcesBound(false), bDisableOptimizations(false),
|
||||
bLegacyCBufferLoad(false), PackingStrategy(0), bUseMinPrecision(false), bDX9CompatMode(false),
|
||||
bFXCCompatMode(false), bLegacyResourceReservation(false), bForceZeroStoreLifetimes(false), unused(0) {
|
||||
}
|
||||
: bDefaultRowMajor(false), bIEEEStrict(false), bAllResourcesBound(false),
|
||||
bDisableOptimizations(false), bLegacyCBufferLoad(false),
|
||||
PackingStrategy(0), bUseMinPrecision(false), bDX9CompatMode(false),
|
||||
bFXCCompatMode(false), bLegacyResourceReservation(false),
|
||||
bForceZeroStoreLifetimes(false), unused(0) {}
|
||||
uint32_t GetHLOptionsRaw() const;
|
||||
void SetHLOptionsRaw(uint32_t data);
|
||||
unsigned bDefaultRowMajor : 1;
|
||||
unsigned bIEEEStrict : 1;
|
||||
unsigned bAllResourcesBound : 1;
|
||||
unsigned bDisableOptimizations : 1;
|
||||
unsigned bLegacyCBufferLoad : 1;
|
||||
unsigned PackingStrategy : 2;
|
||||
static_assert((unsigned)DXIL::PackingStrategy::Invalid < 4, "otherwise 2 bits is not enough to store PackingStrategy");
|
||||
unsigned bUseMinPrecision : 1;
|
||||
unsigned bDX9CompatMode : 1;
|
||||
unsigned bFXCCompatMode : 1;
|
||||
unsigned bDefaultRowMajor : 1;
|
||||
unsigned bIEEEStrict : 1;
|
||||
unsigned bAllResourcesBound : 1;
|
||||
unsigned bDisableOptimizations : 1;
|
||||
unsigned bLegacyCBufferLoad : 1;
|
||||
unsigned PackingStrategy : 2;
|
||||
static_assert((unsigned)DXIL::PackingStrategy::Invalid < 4,
|
||||
"otherwise 2 bits is not enough to store PackingStrategy");
|
||||
unsigned bUseMinPrecision : 1;
|
||||
unsigned bDX9CompatMode : 1;
|
||||
unsigned bFXCCompatMode : 1;
|
||||
unsigned bLegacyResourceReservation : 1;
|
||||
unsigned bForceZeroStoreLifetimes : 1;
|
||||
unsigned bResMayAlias : 1;
|
||||
unsigned unused : 19;
|
||||
unsigned bResMayAlias : 1;
|
||||
unsigned unused : 19;
|
||||
};
|
||||
|
||||
typedef std::unordered_map<const llvm::Function *, std::unique_ptr<DxilFunctionProps>> DxilFunctionPropsMap;
|
||||
typedef std::unordered_map<const llvm::Function *,
|
||||
std::unique_ptr<DxilFunctionProps>>
|
||||
DxilFunctionPropsMap;
|
||||
|
||||
/// Use this class to manipulate HLDXIR of a shader.
|
||||
class HLModule {
|
||||
|
@ -112,28 +115,28 @@ public:
|
|||
unsigned AddCBuffer(std::unique_ptr<DxilCBuffer> pCB);
|
||||
DxilCBuffer &GetCBuffer(unsigned idx);
|
||||
const DxilCBuffer &GetCBuffer(unsigned idx) const;
|
||||
const std::vector<std::unique_ptr<DxilCBuffer> > &GetCBuffers() const;
|
||||
const std::vector<std::unique_ptr<DxilCBuffer>> &GetCBuffers() const;
|
||||
|
||||
unsigned AddSampler(std::unique_ptr<DxilSampler> pSampler);
|
||||
DxilSampler &GetSampler(unsigned idx);
|
||||
const DxilSampler &GetSampler(unsigned idx) const;
|
||||
const std::vector<std::unique_ptr<DxilSampler> > &GetSamplers() const;
|
||||
const std::vector<std::unique_ptr<DxilSampler>> &GetSamplers() const;
|
||||
|
||||
unsigned AddSRV(std::unique_ptr<HLResource> pSRV);
|
||||
HLResource &GetSRV(unsigned idx);
|
||||
const HLResource &GetSRV(unsigned idx) const;
|
||||
const std::vector<std::unique_ptr<HLResource> > &GetSRVs() const;
|
||||
const std::vector<std::unique_ptr<HLResource>> &GetSRVs() const;
|
||||
|
||||
unsigned AddUAV(std::unique_ptr<HLResource> pUAV);
|
||||
HLResource &GetUAV(unsigned idx);
|
||||
const HLResource &GetUAV(unsigned idx) const;
|
||||
const std::vector<std::unique_ptr<HLResource> > &GetUAVs() const;
|
||||
const std::vector<std::unique_ptr<HLResource>> &GetUAVs() const;
|
||||
|
||||
void RemoveGlobal(llvm::GlobalVariable *GV);
|
||||
void RemoveFunction(llvm::Function *F);
|
||||
|
||||
// ThreadGroupSharedMemory.
|
||||
typedef std::vector<llvm::GlobalVariable*>::iterator tgsm_iterator;
|
||||
typedef std::vector<llvm::GlobalVariable *>::iterator tgsm_iterator;
|
||||
tgsm_iterator tgsm_begin();
|
||||
tgsm_iterator tgsm_end();
|
||||
void AddGroupSharedVariable(llvm::GlobalVariable *GV);
|
||||
|
@ -145,8 +148,10 @@ public:
|
|||
// DxilFunctionProps.
|
||||
bool HasDxilFunctionProps(llvm::Function *F);
|
||||
DxilFunctionProps &GetDxilFunctionProps(llvm::Function *F);
|
||||
void AddDxilFunctionProps(llvm::Function *F, std::unique_ptr<DxilFunctionProps> &info);
|
||||
void SetPatchConstantFunctionForHS(llvm::Function *hullShaderFunc, llvm::Function *patchConstantFunc);
|
||||
void AddDxilFunctionProps(llvm::Function *F,
|
||||
std::unique_ptr<DxilFunctionProps> &info);
|
||||
void SetPatchConstantFunctionForHS(llvm::Function *hullShaderFunc,
|
||||
llvm::Function *patchConstantFunc);
|
||||
bool IsGraphicsShader(llvm::Function *F); // vs,hs,ds,gs,ps
|
||||
bool IsPatchConstantShader(llvm::Function *F);
|
||||
bool IsComputeShader(llvm::Function *F);
|
||||
|
@ -187,23 +192,23 @@ public:
|
|||
// Type related methods.
|
||||
static bool IsStreamOutputPtrType(llvm::Type *Ty);
|
||||
static bool IsStreamOutputType(llvm::Type *Ty);
|
||||
static void GetParameterRowsAndCols(llvm::Type *Ty, unsigned &rows, unsigned &cols,
|
||||
static void GetParameterRowsAndCols(llvm::Type *Ty, unsigned &rows,
|
||||
unsigned &cols,
|
||||
DxilParameterAnnotation ¶mAnnotation);
|
||||
|
||||
// HL code gen.
|
||||
static llvm::Function *GetHLOperationFunction(
|
||||
HLOpcodeGroup group, unsigned opcode, llvm::Type *RetType,
|
||||
llvm::ArrayRef<llvm::Value *> paramList, llvm::Module &M);
|
||||
template<class BuilderTy>
|
||||
static llvm::CallInst *EmitHLOperationCall(BuilderTy &Builder,
|
||||
HLOpcodeGroup group, unsigned opcode,
|
||||
llvm::Type *RetType,
|
||||
llvm::ArrayRef<llvm::Value *> paramList,
|
||||
llvm::Module &M);
|
||||
template <class BuilderTy>
|
||||
static llvm::CallInst *
|
||||
EmitHLOperationCall(BuilderTy &Builder, HLOpcodeGroup group, unsigned opcode,
|
||||
llvm::Type *RetType,
|
||||
llvm::ArrayRef<llvm::Value *> paramList, llvm::Module &M);
|
||||
|
||||
// Caller must handle conversions to bool and no-ops
|
||||
static unsigned GetNumericCastOp(
|
||||
llvm::Type *SrcTy, bool SrcIsUnsigned, llvm::Type *DstTy, bool DstIsUnsigned);
|
||||
static unsigned GetNumericCastOp(llvm::Type *SrcTy, bool SrcIsUnsigned,
|
||||
llvm::Type *DstTy, bool DstIsUnsigned);
|
||||
|
||||
// Precise attribute.
|
||||
// Note: Precise will be marked on alloca inst with metadata in code gen.
|
||||
|
@ -212,9 +217,10 @@ public:
|
|||
static bool HasPreciseAttributeWithMetadata(llvm::Instruction *I);
|
||||
static void MarkPreciseAttributeWithMetadata(llvm::Instruction *I);
|
||||
static void ClearPreciseAttributeWithMetadata(llvm::Instruction *I);
|
||||
template<class BuilderTy>
|
||||
template <class BuilderTy>
|
||||
static void MarkPreciseAttributeOnValWithFunctionCall(llvm::Value *V,
|
||||
BuilderTy &Builder, llvm::Module &M);
|
||||
BuilderTy &Builder,
|
||||
llvm::Module &M);
|
||||
static void MarkPreciseAttributeOnPtrWithFunctionCall(llvm::Value *Ptr,
|
||||
llvm::Module &M);
|
||||
static bool HasPreciseAttribute(llvm::Function *F);
|
||||
|
@ -222,9 +228,10 @@ public:
|
|||
// DXIL type system.
|
||||
DxilTypeSystem &GetTypeSystem();
|
||||
|
||||
/// Emit llvm.used array to make sure that optimizations do not remove unreferenced globals.
|
||||
/// Emit llvm.used array to make sure that optimizations do not remove
|
||||
/// unreferenced globals.
|
||||
void EmitLLVMUsed();
|
||||
std::vector<llvm::GlobalVariable* > &GetLLVMUsed();
|
||||
std::vector<llvm::GlobalVariable *> &GetLLVMUsed();
|
||||
|
||||
// Release functions used to transfer ownership.
|
||||
DxilTypeSystem *ReleaseTypeSystem();
|
||||
|
@ -250,24 +257,26 @@ public:
|
|||
void ResetSubobjects(DxilSubobjects *subobjects);
|
||||
|
||||
// Reg binding for resource in cb.
|
||||
void AddRegBinding(unsigned CbID, unsigned ConstantIdx, unsigned Srv, unsigned Uav, unsigned Sampler);
|
||||
void AddRegBinding(unsigned CbID, unsigned ConstantIdx, unsigned Srv,
|
||||
unsigned Uav, unsigned Sampler);
|
||||
|
||||
private:
|
||||
// Signatures.
|
||||
std::vector<uint8_t> m_SerializedRootSignature;
|
||||
|
||||
// Shader resources.
|
||||
std::vector<std::unique_ptr<HLResource> > m_SRVs;
|
||||
std::vector<std::unique_ptr<HLResource> > m_UAVs;
|
||||
std::vector<std::unique_ptr<DxilCBuffer> > m_CBuffers;
|
||||
std::vector<std::unique_ptr<DxilSampler> > m_Samplers;
|
||||
std::vector<std::unique_ptr<HLResource>> m_SRVs;
|
||||
std::vector<std::unique_ptr<HLResource>> m_UAVs;
|
||||
std::vector<std::unique_ptr<DxilCBuffer>> m_CBuffers;
|
||||
std::vector<std::unique_ptr<DxilSampler>> m_Samplers;
|
||||
|
||||
// ThreadGroupSharedMemory.
|
||||
std::vector<llvm::GlobalVariable*> m_TGSMVariables;
|
||||
std::vector<llvm::GlobalVariable *> m_TGSMVariables;
|
||||
|
||||
// High level function info.
|
||||
std::unordered_map<const llvm::Function *, std::unique_ptr<DxilFunctionProps>> m_DxilFunctionPropsMap;
|
||||
std::unordered_set<llvm::Function *> m_PatchConstantFunctions;
|
||||
std::unordered_map<const llvm::Function *, std::unique_ptr<DxilFunctionProps>>
|
||||
m_DxilFunctionPropsMap;
|
||||
std::unordered_set<llvm::Function *> m_PatchConstantFunctions;
|
||||
|
||||
// Resource bindings for res in cb.
|
||||
// Key = CbID << 32 | ConstantIdx. Val is reg binding.
|
||||
|
@ -302,25 +311,29 @@ private:
|
|||
void LoadHLShaderProperties(const llvm::MDOperand &MDO);
|
||||
llvm::MDTuple *EmitDxilShaderProperties();
|
||||
// LLVM used.
|
||||
std::vector<llvm::GlobalVariable*> m_LLVMUsed;
|
||||
std::vector<llvm::GlobalVariable *> m_LLVMUsed;
|
||||
|
||||
// Type annotations.
|
||||
std::unique_ptr<DxilTypeSystem> m_pTypeSystem;
|
||||
|
||||
// Helpers.
|
||||
template<typename T> unsigned AddResource(std::vector<std::unique_ptr<T> > &Vec, std::unique_ptr<T> pRes);
|
||||
template <typename T>
|
||||
unsigned AddResource(std::vector<std::unique_ptr<T>> &Vec,
|
||||
std::unique_ptr<T> pRes);
|
||||
};
|
||||
|
||||
|
||||
/// Use this class to manipulate metadata of extra metadata record properties that are specific to high-level DX IR.
|
||||
/// Use this class to manipulate metadata of extra metadata record properties
|
||||
/// that are specific to high-level DX IR.
|
||||
class HLExtraPropertyHelper : public DxilExtraPropertyHelper {
|
||||
public:
|
||||
HLExtraPropertyHelper(llvm::Module *pModule);
|
||||
virtual ~HLExtraPropertyHelper() {}
|
||||
|
||||
virtual void EmitSignatureElementProperties(const DxilSignatureElement &SE, std::vector<llvm::Metadata *> &MDVals);
|
||||
virtual void LoadSignatureElementProperties(const llvm::MDOperand &MDO, DxilSignatureElement &SE);
|
||||
virtual void
|
||||
EmitSignatureElementProperties(const DxilSignatureElement &SE,
|
||||
std::vector<llvm::Metadata *> &MDVals);
|
||||
virtual void LoadSignatureElementProperties(const llvm::MDOperand &MDO,
|
||||
DxilSignatureElement &SE);
|
||||
};
|
||||
|
||||
} // namespace hlsl
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
namespace llvm {
|
||||
class Instruction;
|
||||
class Function;
|
||||
}
|
||||
} // namespace llvm
|
||||
|
||||
namespace hlsl {
|
||||
class HLModule;
|
||||
|
@ -25,4 +25,4 @@ class HLSLExtensionsCodegenHelper;
|
|||
void TranslateBuiltinOperations(
|
||||
HLModule &HLM, HLSLExtensionsCodegenHelper *extCodegenHelper,
|
||||
std::unordered_set<llvm::Instruction *> &UpdateCounterSet);
|
||||
}
|
||||
} // namespace hlsl
|
|
@ -17,76 +17,79 @@
|
|||
#include <unordered_map>
|
||||
|
||||
namespace llvm {
|
||||
class Value;
|
||||
class CallInst;
|
||||
class Function;
|
||||
class StringRef;
|
||||
class Instruction;
|
||||
}
|
||||
class Value;
|
||||
class CallInst;
|
||||
class Function;
|
||||
class StringRef;
|
||||
class Instruction;
|
||||
} // namespace llvm
|
||||
|
||||
namespace hlsl {
|
||||
class OP;
|
||||
class OP;
|
||||
|
||||
struct HLResourceLookup
|
||||
{
|
||||
// Lookup resource kind based on handle. Return true on success.
|
||||
virtual bool GetResourceKindName(llvm::Value *HLHandle, const char **ppName) = 0;
|
||||
virtual ~HLResourceLookup() {}
|
||||
struct HLResourceLookup {
|
||||
// Lookup resource kind based on handle. Return true on success.
|
||||
virtual bool GetResourceKindName(llvm::Value *HLHandle,
|
||||
const char **ppName) = 0;
|
||||
virtual ~HLResourceLookup() {}
|
||||
};
|
||||
|
||||
// Lowers HLSL extensions from HL operation to DXIL operation.
|
||||
class ExtensionLowering {
|
||||
public:
|
||||
// Strategy used for lowering extensions.
|
||||
enum class Strategy {
|
||||
Unknown, // Do not know how to lower. This is an error condition.
|
||||
NoTranslation, // Propagate the call arguments as is down to dxil.
|
||||
Replicate, // Scalarize the vector arguments and replicate the call.
|
||||
Pack, // Convert the vector arguments into structs.
|
||||
Resource, // Convert return value to resource return and explode vectors.
|
||||
Dxil, // Convert call to a dxil intrinsic.
|
||||
Custom, // Custom lowering based on flexible json string.
|
||||
};
|
||||
|
||||
// Lowers HLSL extensions from HL operation to DXIL operation.
|
||||
class ExtensionLowering {
|
||||
public:
|
||||
// Strategy used for lowering extensions.
|
||||
enum class Strategy {
|
||||
Unknown, // Do not know how to lower. This is an error condition.
|
||||
NoTranslation, // Propagate the call arguments as is down to dxil.
|
||||
Replicate, // Scalarize the vector arguments and replicate the call.
|
||||
Pack, // Convert the vector arguments into structs.
|
||||
Resource, // Convert return value to resource return and explode vectors.
|
||||
Dxil, // Convert call to a dxil intrinsic.
|
||||
Custom, // Custom lowering based on flexible json string.
|
||||
};
|
||||
// Create the lowering using the given strategy and custom codegen helper.
|
||||
ExtensionLowering(llvm::StringRef strategy,
|
||||
HLSLExtensionsCodegenHelper *helper, OP &hlslOp,
|
||||
HLResourceLookup &resourceHelper);
|
||||
ExtensionLowering(Strategy strategy, HLSLExtensionsCodegenHelper *helper,
|
||||
OP &hlslOp, HLResourceLookup &resourceHelper);
|
||||
|
||||
// Create the lowering using the given strategy and custom codegen helper.
|
||||
ExtensionLowering(llvm::StringRef strategy, HLSLExtensionsCodegenHelper *helper, OP& hlslOp, HLResourceLookup &resourceHelper);
|
||||
ExtensionLowering(Strategy strategy, HLSLExtensionsCodegenHelper *helper, OP& hlslOp, HLResourceLookup &resourceHelper);
|
||||
// Translate the HL op call to a DXIL op call.
|
||||
// Returns a new value if translation was successful.
|
||||
// Returns nullptr if translation failed or made no changes.
|
||||
llvm::Value *Translate(llvm::CallInst *CI);
|
||||
|
||||
// Translate the HL op call to a DXIL op call.
|
||||
// Returns a new value if translation was successful.
|
||||
// Returns nullptr if translation failed or made no changes.
|
||||
llvm::Value *Translate(llvm::CallInst *CI);
|
||||
|
||||
// Translate the strategy string to an enum. The strategy string is
|
||||
// added as a custom attribute on the high level extension function.
|
||||
// It is translated as follows:
|
||||
// "r" -> Replicate
|
||||
// "n" -> NoTranslation
|
||||
// "c" -> Custom
|
||||
static Strategy GetStrategy(llvm::StringRef strategy);
|
||||
// Translate the strategy string to an enum. The strategy string is
|
||||
// added as a custom attribute on the high level extension function.
|
||||
// It is translated as follows:
|
||||
// "r" -> Replicate
|
||||
// "n" -> NoTranslation
|
||||
// "c" -> Custom
|
||||
static Strategy GetStrategy(llvm::StringRef strategy);
|
||||
|
||||
// Translate the strategy enum into a name. This is the inverse of the
|
||||
// GetStrategy() function.
|
||||
static llvm::StringRef GetStrategyName(Strategy strategy);
|
||||
// Translate the strategy enum into a name. This is the inverse of the
|
||||
// GetStrategy() function.
|
||||
static llvm::StringRef GetStrategyName(Strategy strategy);
|
||||
|
||||
// Get the name that will be used for the extension function call after
|
||||
// lowering.
|
||||
std::string GetExtensionName(llvm::CallInst *CI);
|
||||
// Get the name that will be used for the extension function call after
|
||||
// lowering.
|
||||
std::string GetExtensionName(llvm::CallInst *CI);
|
||||
|
||||
private:
|
||||
Strategy m_strategy;
|
||||
HLSLExtensionsCodegenHelper *m_helper;
|
||||
OP &m_hlslOp;
|
||||
HLResourceLookup &m_hlResourceLookup;
|
||||
std::string m_extraStrategyInfo;
|
||||
private:
|
||||
Strategy m_strategy;
|
||||
HLSLExtensionsCodegenHelper *m_helper;
|
||||
OP &m_hlslOp;
|
||||
HLResourceLookup &m_hlResourceLookup;
|
||||
std::string m_extraStrategyInfo;
|
||||
|
||||
llvm::Value *Unknown(llvm::CallInst *CI);
|
||||
llvm::Value *NoTranslation(llvm::CallInst *CI);
|
||||
llvm::Value *Replicate(llvm::CallInst *CI);
|
||||
llvm::Value *Pack(llvm::CallInst *CI);
|
||||
llvm::Value *Resource(llvm::CallInst *CI);
|
||||
llvm::Value *Dxil(llvm::CallInst *CI);
|
||||
llvm::Value *CustomResource(llvm::CallInst *CI);
|
||||
llvm::Value *Custom(llvm::CallInst *CI);
|
||||
};
|
||||
}
|
||||
llvm::Value *Unknown(llvm::CallInst *CI);
|
||||
llvm::Value *NoTranslation(llvm::CallInst *CI);
|
||||
llvm::Value *Replicate(llvm::CallInst *CI);
|
||||
llvm::Value *Pack(llvm::CallInst *CI);
|
||||
llvm::Value *Resource(llvm::CallInst *CI);
|
||||
llvm::Value *Dxil(llvm::CallInst *CI);
|
||||
llvm::Value *CustomResource(llvm::CallInst *CI);
|
||||
llvm::Value *Custom(llvm::CallInst *CI);
|
||||
};
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
namespace llvm {
|
||||
class Argument;
|
||||
template<typename T> class ArrayRef;
|
||||
template <typename T> class ArrayRef;
|
||||
class AttributeSet;
|
||||
class CallInst;
|
||||
class Function;
|
||||
|
@ -25,7 +25,7 @@ class Module;
|
|||
class StringRef;
|
||||
class Type;
|
||||
class Value;
|
||||
}
|
||||
} // namespace llvm
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
|
@ -96,7 +96,8 @@ enum class HLSubscriptOpcode {
|
|||
RowMatElement,
|
||||
DoubleSubscript,
|
||||
CBufferSubscript,
|
||||
VectorSubscript, // Only for bool vector, other vector type will use GEP directly.
|
||||
VectorSubscript, // Only for bool vector, other vector type will use GEP
|
||||
// directly.
|
||||
};
|
||||
|
||||
enum class HLCastOpcode {
|
||||
|
@ -118,14 +119,14 @@ enum class HLMatLoadStoreOpcode {
|
|||
RowMatStore,
|
||||
};
|
||||
|
||||
extern const char * const HLPrefix;
|
||||
extern const char *const HLPrefix;
|
||||
|
||||
HLOpcodeGroup GetHLOpcodeGroup(llvm::Function *F);
|
||||
HLOpcodeGroup GetHLOpcodeGroupByName(const llvm::Function *F);
|
||||
llvm::StringRef GetHLOpcodeGroupNameByAttr(llvm::Function *F);
|
||||
llvm::StringRef GetHLLowerStrategy(llvm::Function *F);
|
||||
unsigned GetHLOpcode(const llvm::CallInst *CI);
|
||||
unsigned GetRowMajorOpcode(HLOpcodeGroup group, unsigned opcode);
|
||||
unsigned GetHLOpcode(const llvm::CallInst *CI);
|
||||
unsigned GetRowMajorOpcode(HLOpcodeGroup group, unsigned opcode);
|
||||
void SetHLLowerStrategy(llvm::Function *F, llvm::StringRef S);
|
||||
|
||||
void SetHLWaveSensitive(llvm::Function *F);
|
||||
|
@ -238,7 +239,6 @@ const unsigned kClampOpXIdx = 1;
|
|||
const unsigned kClampOpMinIdx = 2;
|
||||
const unsigned kClampOpMaxIdx = 3;
|
||||
|
||||
|
||||
// Object functions.
|
||||
const unsigned kHandleOpIdx = 1;
|
||||
// Store.
|
||||
|
@ -395,8 +395,7 @@ llvm::Function *GetOrCreateHLFunction(llvm::Module &M,
|
|||
llvm::FunctionType *funcTy,
|
||||
HLOpcodeGroup group,
|
||||
llvm::StringRef *groupName,
|
||||
llvm::StringRef *fnName,
|
||||
unsigned opcode);
|
||||
llvm::StringRef *fnName, unsigned opcode);
|
||||
|
||||
llvm::Function *GetOrCreateHLFunction(llvm::Module &M,
|
||||
llvm::FunctionType *funcTy,
|
||||
|
@ -406,8 +405,7 @@ llvm::Function *GetOrCreateHLFunction(llvm::Module &M,
|
|||
llvm::FunctionType *funcTy,
|
||||
HLOpcodeGroup group,
|
||||
llvm::StringRef *groupName,
|
||||
llvm::StringRef *fnName,
|
||||
unsigned opcode,
|
||||
llvm::StringRef *fnName, unsigned opcode,
|
||||
const llvm::AttributeSet &attribs);
|
||||
|
||||
llvm::Function *GetOrCreateHLFunctionWithBody(llvm::Module &M,
|
||||
|
@ -416,12 +414,15 @@ llvm::Function *GetOrCreateHLFunctionWithBody(llvm::Module &M,
|
|||
unsigned opcode,
|
||||
llvm::StringRef name);
|
||||
|
||||
llvm::Value *callHLFunction(llvm::Module &Module, HLOpcodeGroup OpcodeGroup, unsigned Opcode,
|
||||
llvm::Type *RetTy, llvm::ArrayRef<llvm::Value*> Args,
|
||||
const llvm::AttributeSet &attribs, llvm::IRBuilder<> &Builder);
|
||||
llvm::Value *callHLFunction(llvm::Module &Module, HLOpcodeGroup OpcodeGroup,
|
||||
unsigned Opcode, llvm::Type *RetTy,
|
||||
llvm::ArrayRef<llvm::Value *> Args,
|
||||
const llvm::AttributeSet &attribs,
|
||||
llvm::IRBuilder<> &Builder);
|
||||
|
||||
llvm::Value *callHLFunction(llvm::Module &Module, HLOpcodeGroup OpcodeGroup, unsigned Opcode,
|
||||
llvm::Type *RetTy, llvm::ArrayRef<llvm::Value*> Args,
|
||||
llvm::Value *callHLFunction(llvm::Module &Module, HLOpcodeGroup OpcodeGroup,
|
||||
unsigned Opcode, llvm::Type *RetTy,
|
||||
llvm::ArrayRef<llvm::Value *> Args,
|
||||
llvm::IRBuilder<> &Builder);
|
||||
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -13,15 +13,14 @@
|
|||
|
||||
#include "dxc/DXIL/DxilResource.h"
|
||||
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
/// Use this class to represent an HLSL resource (SRV/UAV) in HLDXIR.
|
||||
class HLResource : public DxilResource {
|
||||
public:
|
||||
//QQQ
|
||||
// TODO: this does not belong here. QQQ
|
||||
//static Kind KeywordToKind(const std::string &keyword);
|
||||
// QQQ
|
||||
// TODO: this does not belong here. QQQ
|
||||
// static Kind KeywordToKind(const std::string &keyword);
|
||||
|
||||
HLResource();
|
||||
};
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
#pragma once
|
||||
#include "dxc/DXIL/DxilOperations.h"
|
||||
#include "dxc/Support/DxcOptToggles.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace clang {
|
||||
class CodeGenOptions;
|
||||
|
@ -23,7 +23,7 @@ namespace llvm {
|
|||
class CallInst;
|
||||
class Value;
|
||||
class Module;
|
||||
}
|
||||
} // namespace llvm
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace hlsl {
|
|||
//
|
||||
// This class provides an interface for generating the DXIL bitcode
|
||||
// needed for the types of extensions above.
|
||||
//
|
||||
//
|
||||
class HLSLExtensionsCodegenHelper {
|
||||
public:
|
||||
// Used to indicate a semantic define was used incorrectly.
|
||||
|
@ -48,18 +48,17 @@ public:
|
|||
class SemanticDefineError {
|
||||
public:
|
||||
enum class Level { Warning, Error };
|
||||
SemanticDefineError(unsigned location, Level level, const std::string &message)
|
||||
: m_location(location)
|
||||
, m_level(level)
|
||||
, m_message(message)
|
||||
{ }
|
||||
SemanticDefineError(unsigned location, Level level,
|
||||
const std::string &message)
|
||||
: m_location(location), m_level(level), m_message(message) {}
|
||||
|
||||
unsigned Location() const { return m_location; }
|
||||
bool IsWarning() const { return m_level == Level::Warning; }
|
||||
const std::string &Message() const { return m_message; }
|
||||
|
||||
private:
|
||||
unsigned m_location; // Use an encoded clang::SourceLocation to avoid a clang include dependency.
|
||||
unsigned m_location; // Use an encoded clang::SourceLocation to avoid a
|
||||
// clang include dependency.
|
||||
Level m_level;
|
||||
std::string m_message;
|
||||
};
|
||||
|
@ -84,14 +83,15 @@ public:
|
|||
// Struct to hold a root signature that is read from a define.
|
||||
struct CustomRootSignature {
|
||||
std::string RootSignature;
|
||||
unsigned EncodedSourceLocation;
|
||||
unsigned EncodedSourceLocation;
|
||||
enum Status { NOT_FOUND = 0, FOUND };
|
||||
};
|
||||
|
||||
// Get custom defined root signature.
|
||||
virtual CustomRootSignature::Status GetCustomRootSignature(CustomRootSignature *out) = 0;
|
||||
virtual CustomRootSignature::Status
|
||||
GetCustomRootSignature(CustomRootSignature *out) = 0;
|
||||
|
||||
// Virtual destructor.
|
||||
virtual ~HLSLExtensionsCodegenHelper() {};
|
||||
virtual ~HLSLExtensionsCodegenHelper(){};
|
||||
};
|
||||
}
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
// //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
namespace {
|
||||
|
@ -18,21 +17,21 @@ typedef std::vector<DxilSignatureAllocator::DummyElement> ElementVec;
|
|||
|
||||
struct ComponentMask : public PSVComponentMask {
|
||||
uint32_t Data[4];
|
||||
ComponentMask() : PSVComponentMask(Data, 0) {
|
||||
memset(Data, 0, sizeof(Data));
|
||||
}
|
||||
ComponentMask(const ComponentMask &other) : PSVComponentMask(Data, other.NumVectors) {
|
||||
ComponentMask() : PSVComponentMask(Data, 0) { memset(Data, 0, sizeof(Data)); }
|
||||
ComponentMask(const ComponentMask &other)
|
||||
: PSVComponentMask(Data, other.NumVectors) {
|
||||
*this = other;
|
||||
}
|
||||
ComponentMask(const PSVComponentMask &other) : PSVComponentMask(Data, other.NumVectors) {
|
||||
ComponentMask(const PSVComponentMask &other)
|
||||
: PSVComponentMask(Data, other.NumVectors) {
|
||||
*this = other;
|
||||
}
|
||||
ComponentMask &operator=(const PSVComponentMask &other) {
|
||||
NumVectors = other.NumVectors;
|
||||
if (other.Mask && NumVectors) {
|
||||
memcpy(Data, other.Mask, sizeof(uint32_t) * PSVComputeMaskDwordsFromVectors(NumVectors));
|
||||
}
|
||||
else {
|
||||
memcpy(Data, other.Mask,
|
||||
sizeof(uint32_t) * PSVComputeMaskDwordsFromVectors(NumVectors));
|
||||
} else {
|
||||
memset(Data, 0, sizeof(Data));
|
||||
}
|
||||
return *this;
|
||||
|
@ -60,16 +59,16 @@ static void InitElement(DxilSignatureAllocator::DummyElement &eOut,
|
|||
eOut.interpretation = SigPoint::GetInterpretation(eOut.kind, sigPoint, 6, 1);
|
||||
eOut.indexFlags = eIn.GetDynamicIndexMask();
|
||||
|
||||
// Tessfactors must be treated as dynamically indexed to prevent breaking them up
|
||||
// Tessfactors must be treated as dynamically indexed to prevent breaking them
|
||||
// up
|
||||
if (eOut.interpretation == DXIL::SemanticInterpretationKind::TessFactor)
|
||||
eOut.indexFlags = (1 << eOut.cols) - 1;
|
||||
}
|
||||
|
||||
static void CopyElements( ElementVec &outElements,
|
||||
DXIL::SigPointKind sigPoint,
|
||||
unsigned numElements,
|
||||
unsigned streamIndex,
|
||||
std::function<PSVSignatureElement(unsigned)> getElement) {
|
||||
static void
|
||||
CopyElements(ElementVec &outElements, DXIL::SigPointKind sigPoint,
|
||||
unsigned numElements, unsigned streamIndex,
|
||||
std::function<PSVSignatureElement(unsigned)> getElement) {
|
||||
outElements.clear();
|
||||
outElements.reserve(numElements);
|
||||
for (unsigned i = 0; i < numElements; i++) {
|
||||
|
@ -82,10 +81,8 @@ static void CopyElements( ElementVec &outElements,
|
|||
}
|
||||
}
|
||||
|
||||
static void AddViewIDElements(ElementVec &outElements,
|
||||
ElementVec &inElements,
|
||||
PSVComponentMask &mask,
|
||||
unsigned viewIDCount) {
|
||||
static void AddViewIDElements(ElementVec &outElements, ElementVec &inElements,
|
||||
PSVComponentMask &mask, unsigned viewIDCount) {
|
||||
// Compute needed elements
|
||||
for (unsigned adding = 0; adding < 2; adding++) {
|
||||
uint32_t numElements = 0;
|
||||
|
@ -96,7 +93,8 @@ static void AddViewIDElements(ElementVec &outElements,
|
|||
if (row > 0 && bDynIndex)
|
||||
continue;
|
||||
if (adding) {
|
||||
uint32_t componentIndex = (E.GetStartRow() + row) * 4 + E.GetStartCol() + col;
|
||||
uint32_t componentIndex =
|
||||
(E.GetStartRow() + row) * 4 + E.GetStartCol() + col;
|
||||
DxilSignatureAllocator::DummyElement NE(E.id);
|
||||
NE.kind = E.kind;
|
||||
NE.interpolation = E.interpolation;
|
||||
|
@ -121,13 +119,14 @@ static void AddViewIDElements(ElementVec &outElements,
|
|||
}
|
||||
|
||||
static bool CheckFit(ElementVec &elements) {
|
||||
std::vector<DxilSignatureAllocator::PackElement*> packElements;
|
||||
std::vector<DxilSignatureAllocator::PackElement *> packElements;
|
||||
packElements.reserve(elements.size());
|
||||
for (auto &E : elements)
|
||||
packElements.push_back(&E);
|
||||
// Since we are putting an upper limit of 4x32 registers regardless of actual element size,
|
||||
// we can just have allocator to use the default behavior.
|
||||
// This should be fixed if we enforce loose upper limit on total number of signature registers based on element size.
|
||||
// Since we are putting an upper limit of 4x32 registers regardless of actual
|
||||
// element size, we can just have allocator to use the default behavior. This
|
||||
// should be fixed if we enforce loose upper limit on total number of
|
||||
// signature registers based on element size.
|
||||
DxilSignatureAllocator alloc(32, true);
|
||||
alloc.SetIgnoreIndexing(true);
|
||||
alloc.PackOptimized(packElements, 0, 32);
|
||||
|
@ -138,30 +137,31 @@ static bool CheckFit(ElementVec &elements) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool CheckMaxVertexCount(const ElementVec &elements, unsigned maxVertexCount) {
|
||||
static bool CheckMaxVertexCount(const ElementVec &elements,
|
||||
unsigned maxVertexCount) {
|
||||
unsigned numComponents = 0;
|
||||
for (auto &E : elements)
|
||||
numComponents += E.GetRows() * E.GetCols();
|
||||
return numComponents <= 1024 && maxVertexCount <= 1024 && numComponents * maxVertexCount <= 1024;
|
||||
return numComponents <= 1024 && maxVertexCount <= 1024 &&
|
||||
numComponents * maxVertexCount <= 1024;
|
||||
}
|
||||
|
||||
static bool MergeElements(const ElementVec &priorElements,
|
||||
ElementVec &inputElements,
|
||||
uint32_t &numVectors,
|
||||
ElementVec &inputElements, uint32_t &numVectors,
|
||||
unsigned &mismatchElementId) {
|
||||
inputElements.reserve(std::max(priorElements.size(), inputElements.size()));
|
||||
unsigned minElements = (unsigned)std::min(priorElements.size(), inputElements.size());
|
||||
unsigned minElements =
|
||||
(unsigned)std::min(priorElements.size(), inputElements.size());
|
||||
for (unsigned i = 0; i < minElements; i++) {
|
||||
const DxilSignatureAllocator::DummyElement &priorEl = priorElements[i];
|
||||
DxilSignatureAllocator::DummyElement &inputEl = inputElements[i];
|
||||
// Verify elements match
|
||||
if (priorEl.rows != inputEl.rows ||
|
||||
priorEl.cols != inputEl.cols ||
|
||||
priorEl.row != inputEl.row ||
|
||||
priorEl.col != inputEl.col ||
|
||||
priorEl.kind != inputEl.kind ||
|
||||
// don't care about interpolation since normal signature matching ignores it: priorEl.interpolation != inputEl.interpolation ||
|
||||
priorEl.interpretation != inputEl.interpretation) {
|
||||
if (priorEl.rows != inputEl.rows || priorEl.cols != inputEl.cols ||
|
||||
priorEl.row != inputEl.row || priorEl.col != inputEl.col ||
|
||||
priorEl.kind != inputEl.kind ||
|
||||
// don't care about interpolation since normal signature matching
|
||||
// ignores it: priorEl.interpolation != inputEl.interpolation ||
|
||||
priorEl.interpretation != inputEl.interpretation) {
|
||||
mismatchElementId = inputEl.id;
|
||||
return false;
|
||||
}
|
||||
|
@ -170,7 +170,8 @@ static bool MergeElements(const ElementVec &priorElements,
|
|||
}
|
||||
|
||||
// Add extra incoming elements if there are more
|
||||
for (unsigned i = (unsigned)inputElements.size(); i < (unsigned)priorElements.size(); i++) {
|
||||
for (unsigned i = (unsigned)inputElements.size();
|
||||
i < (unsigned)priorElements.size(); i++) {
|
||||
inputElements.push_back(priorElements[i]);
|
||||
}
|
||||
|
||||
|
@ -183,14 +184,14 @@ static bool MergeElements(const ElementVec &priorElements,
|
|||
}
|
||||
|
||||
static void PropagateMask(const ComponentMask &priorMask,
|
||||
ElementVec &inputElements,
|
||||
ComponentMask &outMask,
|
||||
ElementVec &inputElements, ComponentMask &outMask,
|
||||
std::function<PSVComponentMask(unsigned)> getMask) {
|
||||
// Iterate elements
|
||||
for (auto &E : inputElements) {
|
||||
for (unsigned row = 0; row < E.GetRows(); row++) {
|
||||
for (unsigned col = 0; col < E.GetCols(); col++) {
|
||||
uint32_t componentIndex = (E.GetStartRow() + row) * 4 + E.GetStartCol() + col;
|
||||
uint32_t componentIndex =
|
||||
(E.GetStartRow() + row) * 4 + E.GetStartCol() + col;
|
||||
// If bit set in priorMask
|
||||
if (priorMask.Get(componentIndex)) {
|
||||
// get mask of outputs affected by inputs and OR into outMask
|
||||
|
@ -201,12 +202,15 @@ static void PropagateMask(const ComponentMask &priorMask,
|
|||
}
|
||||
}
|
||||
|
||||
bool DetectViewIDDependentTessFactor(const ElementVec &pcElements, ComponentMask &mask) {
|
||||
bool DetectViewIDDependentTessFactor(const ElementVec &pcElements,
|
||||
ComponentMask &mask) {
|
||||
for (auto &E : pcElements) {
|
||||
if (E.GetKind() == DXIL::SemanticKind::TessFactor || E.GetKind() == DXIL::SemanticKind::InsideTessFactor) {
|
||||
if (E.GetKind() == DXIL::SemanticKind::TessFactor ||
|
||||
E.GetKind() == DXIL::SemanticKind::InsideTessFactor) {
|
||||
for (unsigned row = 0; row < E.GetRows(); row++) {
|
||||
for (unsigned col = 0; col < E.GetCols(); col++) {
|
||||
uint32_t componentIndex = (E.GetStartRow() + row) * 4 + E.GetStartCol() + col;
|
||||
uint32_t componentIndex =
|
||||
(E.GetStartRow() + row) * 4 + E.GetStartCol() + col;
|
||||
if (mask.Get(componentIndex))
|
||||
return true;
|
||||
}
|
||||
|
@ -233,13 +237,10 @@ class ViewIDValidator_impl : public hlsl::ViewIDValidator {
|
|||
|
||||
public:
|
||||
ViewIDValidator_impl(unsigned viewIDCount, unsigned gsRastStreamIndex)
|
||||
: m_PriorOutputMask(),
|
||||
m_ViewIDCount(viewIDCount),
|
||||
m_GSRastStreamIndex(gsRastStreamIndex)
|
||||
{}
|
||||
: m_PriorOutputMask(), m_ViewIDCount(viewIDCount),
|
||||
m_GSRastStreamIndex(gsRastStreamIndex) {}
|
||||
virtual ~ViewIDValidator_impl() {}
|
||||
Result ValidateStage(const DxilPipelineStateValidation &PSV,
|
||||
bool bFinalStage,
|
||||
Result ValidateStage(const DxilPipelineStateValidation &PSV, bool bFinalStage,
|
||||
bool bExpandInputOnly,
|
||||
unsigned &mismatchElementId) override {
|
||||
if (!PSV.GetPSVRuntimeInfo0())
|
||||
|
@ -257,10 +258,11 @@ public:
|
|||
|
||||
// capture output signature
|
||||
ElementVec outSig;
|
||||
CopyElements( outSig, DXIL::SigPointKind::VSOut, PSV.GetSigOutputElements(), 0,
|
||||
[&](unsigned i) -> PSVSignatureElement {
|
||||
return PSV.GetSignatureElement(PSV.GetOutputElement0(i));
|
||||
});
|
||||
CopyElements(outSig, DXIL::SigPointKind::VSOut,
|
||||
PSV.GetSigOutputElements(), 0,
|
||||
[&](unsigned i) -> PSVSignatureElement {
|
||||
return PSV.GetSignatureElement(PSV.GetOutputElement0(i));
|
||||
});
|
||||
|
||||
// Copy mask to prior mask
|
||||
m_PriorOutputMask = mask;
|
||||
|
@ -280,13 +282,14 @@ public:
|
|||
|
||||
// capture signatures
|
||||
ElementVec inSig, outSig, pcSig;
|
||||
CopyElements( inSig, DXIL::SigPointKind::HSCPIn, PSV.GetSigInputElements(), 0,
|
||||
[&](unsigned i) -> PSVSignatureElement {
|
||||
return PSV.GetSignatureElement(PSV.GetInputElement0(i));
|
||||
});
|
||||
CopyElements(inSig, DXIL::SigPointKind::HSCPIn, PSV.GetSigInputElements(),
|
||||
0, [&](unsigned i) -> PSVSignatureElement {
|
||||
return PSV.GetSignatureElement(PSV.GetInputElement0(i));
|
||||
});
|
||||
|
||||
// Merge prior and input signatures, update prior mask size if necessary
|
||||
if (!MergeElements(m_PriorOutputSignature, inSig, m_PriorOutputMask.NumVectors, mismatchElementId))
|
||||
if (!MergeElements(m_PriorOutputSignature, inSig,
|
||||
m_PriorOutputMask.NumVectors, mismatchElementId))
|
||||
return Result::MismatchedSignatures;
|
||||
|
||||
// Create new version with ViewID elements from merged signature
|
||||
|
@ -302,23 +305,30 @@ public:
|
|||
return Result::Success;
|
||||
}
|
||||
|
||||
CopyElements(outSig, DXIL::SigPointKind::HSCPOut, PSV.GetSigOutputElements(), 0,
|
||||
[&](unsigned i) -> PSVSignatureElement {
|
||||
return PSV.GetSignatureElement(PSV.GetOutputElement0(i));
|
||||
});
|
||||
CopyElements(pcSig, DXIL::SigPointKind::PCOut, PSV.GetSigPatchConstOrPrimElements(), 0,
|
||||
[&](unsigned i) -> PSVSignatureElement {
|
||||
return PSV.GetSignatureElement(PSV.GetPatchConstOrPrimElement0(i));
|
||||
});
|
||||
CopyElements(outSig, DXIL::SigPointKind::HSCPOut,
|
||||
PSV.GetSigOutputElements(), 0,
|
||||
[&](unsigned i) -> PSVSignatureElement {
|
||||
return PSV.GetSignatureElement(PSV.GetOutputElement0(i));
|
||||
});
|
||||
CopyElements(pcSig, DXIL::SigPointKind::PCOut,
|
||||
PSV.GetSigPatchConstOrPrimElements(), 0,
|
||||
[&](unsigned i) -> PSVSignatureElement {
|
||||
return PSV.GetSignatureElement(
|
||||
PSV.GetPatchConstOrPrimElement0(i));
|
||||
});
|
||||
|
||||
// Propagate prior mask through input-output dependencies
|
||||
if (PSV.GetInputToOutputTable(0).IsValid()) {
|
||||
PropagateMask(m_PriorOutputMask, inSig, outputMask,
|
||||
[&](unsigned i) -> PSVComponentMask { return PSV.GetInputToOutputTable(0).GetMaskForInput(i); });
|
||||
[&](unsigned i) -> PSVComponentMask {
|
||||
return PSV.GetInputToOutputTable(0).GetMaskForInput(i);
|
||||
});
|
||||
}
|
||||
if (PSV.GetInputToPCOutputTable().IsValid()) {
|
||||
PropagateMask(m_PriorOutputMask, inSig, pcMask,
|
||||
[&](unsigned i) -> PSVComponentMask { return PSV.GetInputToPCOutputTable().GetMaskForInput(i); });
|
||||
[&](unsigned i) -> PSVComponentMask {
|
||||
return PSV.GetInputToPCOutputTable().GetMaskForInput(i);
|
||||
});
|
||||
}
|
||||
|
||||
// Copy mask to prior mask
|
||||
|
@ -341,19 +351,22 @@ public:
|
|||
|
||||
// capture signatures
|
||||
ElementVec inSig, pcSig, outSig;
|
||||
CopyElements( inSig, DXIL::SigPointKind::DSCPIn, PSV.GetSigInputElements(), 0,
|
||||
[&](unsigned i) -> PSVSignatureElement {
|
||||
return PSV.GetSignatureElement(PSV.GetInputElement0(i));
|
||||
});
|
||||
CopyElements( pcSig, DXIL::SigPointKind::DSIn, PSV.GetSigPatchConstOrPrimElements(), 0,
|
||||
[&](unsigned i) -> PSVSignatureElement {
|
||||
return PSV.GetSignatureElement(PSV.GetPatchConstOrPrimElement0(i));
|
||||
});
|
||||
CopyElements(inSig, DXIL::SigPointKind::DSCPIn, PSV.GetSigInputElements(),
|
||||
0, [&](unsigned i) -> PSVSignatureElement {
|
||||
return PSV.GetSignatureElement(PSV.GetInputElement0(i));
|
||||
});
|
||||
CopyElements(
|
||||
pcSig, DXIL::SigPointKind::DSIn, PSV.GetSigPatchConstOrPrimElements(),
|
||||
0, [&](unsigned i) -> PSVSignatureElement {
|
||||
return PSV.GetSignatureElement(PSV.GetPatchConstOrPrimElement0(i));
|
||||
});
|
||||
|
||||
// Merge prior and input signatures, update prior mask size if necessary
|
||||
if (!MergeElements(m_PriorOutputSignature, inSig, m_PriorOutputMask.NumVectors, mismatchElementId))
|
||||
if (!MergeElements(m_PriorOutputSignature, inSig,
|
||||
m_PriorOutputMask.NumVectors, mismatchElementId))
|
||||
return Result::MismatchedSignatures;
|
||||
if (!MergeElements(m_PriorPCSignature, pcSig, m_PriorPCMask.NumVectors, mismatchElementId))
|
||||
if (!MergeElements(m_PriorPCSignature, pcSig, m_PriorPCMask.NumVectors,
|
||||
mismatchElementId))
|
||||
return Result::MismatchedPCSignatures;
|
||||
|
||||
{
|
||||
|
@ -381,19 +394,24 @@ public:
|
|||
return Result::Success;
|
||||
}
|
||||
|
||||
CopyElements(outSig, DXIL::SigPointKind::DSOut, PSV.GetSigOutputElements(), 0,
|
||||
[&](unsigned i) -> PSVSignatureElement {
|
||||
return PSV.GetSignatureElement(PSV.GetOutputElement0(i));
|
||||
});
|
||||
CopyElements(outSig, DXIL::SigPointKind::DSOut,
|
||||
PSV.GetSigOutputElements(), 0,
|
||||
[&](unsigned i) -> PSVSignatureElement {
|
||||
return PSV.GetSignatureElement(PSV.GetOutputElement0(i));
|
||||
});
|
||||
|
||||
// Propagate prior mask through input-output dependencies
|
||||
if (PSV.GetInputToOutputTable(0).IsValid()) {
|
||||
PropagateMask(m_PriorOutputMask, inSig, mask,
|
||||
[&](unsigned i) -> PSVComponentMask { return PSV.GetInputToOutputTable(0).GetMaskForInput(i); });
|
||||
[&](unsigned i) -> PSVComponentMask {
|
||||
return PSV.GetInputToOutputTable(0).GetMaskForInput(i);
|
||||
});
|
||||
}
|
||||
if (PSV.GetPCInputToOutputTable().IsValid()) {
|
||||
PropagateMask(m_PriorPCMask, pcSig, mask,
|
||||
[&](unsigned i) -> PSVComponentMask { return PSV.GetPCInputToOutputTable().GetMaskForInput(i); });
|
||||
[&](unsigned i) -> PSVComponentMask {
|
||||
return PSV.GetPCInputToOutputTable().GetMaskForInput(i);
|
||||
});
|
||||
}
|
||||
|
||||
// Copy mask to prior mask
|
||||
|
@ -409,13 +427,14 @@ public:
|
|||
case PSVShaderKind::Geometry: {
|
||||
// capture signatures
|
||||
ElementVec inSig, outSig[4];
|
||||
CopyElements( inSig, DXIL::SigPointKind::GSVIn, PSV.GetSigInputElements(), 0,
|
||||
[&](unsigned i) -> PSVSignatureElement {
|
||||
return PSV.GetSignatureElement(PSV.GetInputElement0(i));
|
||||
});
|
||||
CopyElements(inSig, DXIL::SigPointKind::GSVIn, PSV.GetSigInputElements(),
|
||||
0, [&](unsigned i) -> PSVSignatureElement {
|
||||
return PSV.GetSignatureElement(PSV.GetInputElement0(i));
|
||||
});
|
||||
|
||||
// Merge prior and input signatures, update prior mask size if necessary
|
||||
if (!MergeElements(m_PriorOutputSignature, inSig, m_PriorOutputMask.NumVectors, mismatchElementId))
|
||||
if (!MergeElements(m_PriorOutputSignature, inSig,
|
||||
m_PriorOutputMask.NumVectors, mismatchElementId))
|
||||
return Result::MismatchedSignatures;
|
||||
|
||||
// Create new version with ViewID elements from merged signature
|
||||
|
@ -435,24 +454,30 @@ public:
|
|||
// Initialize mask with direct ViewID dependent outputs
|
||||
ComponentMask mask(PSV.GetViewIDOutputMask(streamIndex));
|
||||
|
||||
CopyElements( outSig[streamIndex], DXIL::SigPointKind::GSOut, PSV.GetSigOutputElements(), streamIndex,
|
||||
[&](unsigned i) -> PSVSignatureElement {
|
||||
return PSV.GetSignatureElement(PSV.GetOutputElement0(i));
|
||||
});
|
||||
CopyElements(outSig[streamIndex], DXIL::SigPointKind::GSOut,
|
||||
PSV.GetSigOutputElements(), streamIndex,
|
||||
[&](unsigned i) -> PSVSignatureElement {
|
||||
return PSV.GetSignatureElement(PSV.GetOutputElement0(i));
|
||||
});
|
||||
|
||||
if (!outSig[streamIndex].empty()) {
|
||||
// Propagate prior mask through input-output dependencies
|
||||
if (PSV.GetInputToOutputTable(streamIndex).IsValid()) {
|
||||
PropagateMask(m_PriorOutputMask, inSig, mask,
|
||||
[&](unsigned i) -> PSVComponentMask { return PSV.GetInputToOutputTable(streamIndex).GetMaskForInput(i); });
|
||||
[&](unsigned i) -> PSVComponentMask {
|
||||
return PSV.GetInputToOutputTable(streamIndex)
|
||||
.GetMaskForInput(i);
|
||||
});
|
||||
}
|
||||
|
||||
// Create new version with ViewID elements from prior signature
|
||||
ElementVec viewIDSig;
|
||||
AddViewIDElements(viewIDSig, outSig[streamIndex], mask, m_ViewIDCount);
|
||||
AddViewIDElements(viewIDSig, outSig[streamIndex], mask,
|
||||
m_ViewIDCount);
|
||||
|
||||
// Verify fit
|
||||
if (!CheckMaxVertexCount(viewIDSig, PSV.GetPSVRuntimeInfo1()->MaxVertexCount))
|
||||
if (!CheckMaxVertexCount(viewIDSig,
|
||||
PSV.GetPSVRuntimeInfo1()->MaxVertexCount))
|
||||
return Result::InsufficientOutputSpace;
|
||||
if (!CheckFit(viewIDSig))
|
||||
return Result::InsufficientOutputSpace;
|
||||
|
@ -476,13 +501,14 @@ public:
|
|||
case PSVShaderKind::Pixel: {
|
||||
// capture signatures
|
||||
ElementVec inSig;
|
||||
CopyElements( inSig, DXIL::SigPointKind::PSIn, PSV.GetSigInputElements(), 0,
|
||||
[&](unsigned i) -> PSVSignatureElement {
|
||||
return PSV.GetSignatureElement(PSV.GetInputElement0(i));
|
||||
});
|
||||
CopyElements(inSig, DXIL::SigPointKind::PSIn, PSV.GetSigInputElements(),
|
||||
0, [&](unsigned i) -> PSVSignatureElement {
|
||||
return PSV.GetSignatureElement(PSV.GetInputElement0(i));
|
||||
});
|
||||
|
||||
// Merge prior and input signatures, update prior mask size if necessary
|
||||
if (!MergeElements(m_PriorOutputSignature, inSig, m_PriorOutputMask.NumVectors, mismatchElementId))
|
||||
if (!MergeElements(m_PriorOutputSignature, inSig,
|
||||
m_PriorOutputMask.NumVectors, mismatchElementId))
|
||||
return Result::MismatchedSignatures;
|
||||
|
||||
// Create new version with ViewID elements from merged signature
|
||||
|
@ -509,7 +535,8 @@ public:
|
|||
// Last stage was not pixel shader, so output has not yet been validated.
|
||||
// Create new version with ViewID elements from prior signature
|
||||
ElementVec viewIDSig;
|
||||
AddViewIDElements(viewIDSig, m_PriorOutputSignature, m_PriorOutputMask, m_ViewIDCount);
|
||||
AddViewIDElements(viewIDSig, m_PriorOutputSignature, m_PriorOutputMask,
|
||||
m_ViewIDCount);
|
||||
|
||||
// Verify fit
|
||||
if (!CheckFit(viewIDSig))
|
||||
|
@ -520,9 +547,10 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace anonymous
|
||||
} // namespace
|
||||
|
||||
ViewIDValidator* NewViewIDValidator(unsigned viewIDCount, unsigned gsRastStreamIndex) {
|
||||
ViewIDValidator *NewViewIDValidator(unsigned viewIDCount,
|
||||
unsigned gsRastStreamIndex) {
|
||||
return new ViewIDValidator_impl(viewIDCount, gsRastStreamIndex);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace llvm {
|
|||
class raw_string_ostream;
|
||||
class CallInst;
|
||||
class Value;
|
||||
}
|
||||
} // namespace llvm
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
|
@ -36,8 +36,8 @@ private:
|
|||
CComPtr<IDxcSemanticDefineValidator> m_semanticDefineValidator;
|
||||
std::string m_semanticDefineMetaDataName;
|
||||
std::string m_targetTriple;
|
||||
HRESULT STDMETHODCALLTYPE RegisterIntoVector(LPCWSTR name, llvm::SmallVector<std::string, 2>& here)
|
||||
{
|
||||
HRESULT STDMETHODCALLTYPE
|
||||
RegisterIntoVector(LPCWSTR name, llvm::SmallVector<std::string, 2> &here) {
|
||||
try {
|
||||
IFTPTR(name);
|
||||
std::string s;
|
||||
|
@ -50,8 +50,8 @@ private:
|
|||
CATCH_CPP_RETURN_HRESULT();
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE RegisterIntoSet(LPCWSTR name, llvm::SetVector<std::string>& here)
|
||||
{
|
||||
HRESULT STDMETHODCALLTYPE
|
||||
RegisterIntoSet(LPCWSTR name, llvm::SetVector<std::string> &here) {
|
||||
try {
|
||||
IFTPTR(name);
|
||||
std::string s;
|
||||
|
@ -65,31 +65,39 @@ private:
|
|||
}
|
||||
|
||||
public:
|
||||
const llvm::SmallVector<std::string, 2>& GetSemanticDefines() const { return m_semanticDefines; }
|
||||
const llvm::SmallVector<std::string, 2>& GetSemanticDefineExclusions() const { return m_semanticDefineExclusions; }
|
||||
const llvm::SetVector<std::string>& GetNonOptSemanticDefines() const { return m_nonOptSemanticDefines; }
|
||||
const llvm::SmallVector<std::string, 2>& GetDefines() const { return m_defines; }
|
||||
llvm::SmallVector<CComPtr<IDxcIntrinsicTable>, 2>& GetIntrinsicTables(){ return m_intrinsicTables; }
|
||||
const std::string &GetSemanticDefineMetadataName() { return m_semanticDefineMetaDataName; }
|
||||
const llvm::SmallVector<std::string, 2> &GetSemanticDefines() const {
|
||||
return m_semanticDefines;
|
||||
}
|
||||
const llvm::SmallVector<std::string, 2> &GetSemanticDefineExclusions() const {
|
||||
return m_semanticDefineExclusions;
|
||||
}
|
||||
const llvm::SetVector<std::string> &GetNonOptSemanticDefines() const {
|
||||
return m_nonOptSemanticDefines;
|
||||
}
|
||||
const llvm::SmallVector<std::string, 2> &GetDefines() const {
|
||||
return m_defines;
|
||||
}
|
||||
llvm::SmallVector<CComPtr<IDxcIntrinsicTable>, 2> &GetIntrinsicTables() {
|
||||
return m_intrinsicTables;
|
||||
}
|
||||
const std::string &GetSemanticDefineMetadataName() {
|
||||
return m_semanticDefineMetaDataName;
|
||||
}
|
||||
const std::string &GetTargetTriple() { return m_targetTriple; }
|
||||
|
||||
HRESULT STDMETHODCALLTYPE RegisterSemanticDefine(LPCWSTR name)
|
||||
{
|
||||
HRESULT STDMETHODCALLTYPE RegisterSemanticDefine(LPCWSTR name) {
|
||||
return RegisterIntoVector(name, m_semanticDefines);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE RegisterSemanticDefineExclusion(LPCWSTR name)
|
||||
{
|
||||
HRESULT STDMETHODCALLTYPE RegisterSemanticDefineExclusion(LPCWSTR name) {
|
||||
return RegisterIntoVector(name, m_semanticDefineExclusions);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE RegisterNonOptSemanticDefine(LPCWSTR name)
|
||||
{
|
||||
HRESULT STDMETHODCALLTYPE RegisterNonOptSemanticDefine(LPCWSTR name) {
|
||||
return RegisterIntoSet(name, m_nonOptSemanticDefines);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE RegisterDefine(LPCWSTR name)
|
||||
{
|
||||
HRESULT STDMETHODCALLTYPE RegisterDefine(LPCWSTR name) {
|
||||
return RegisterIntoVector(name, m_defines);
|
||||
}
|
||||
|
||||
|
@ -99,12 +107,14 @@ public:
|
|||
LPCSTR tableName = nullptr;
|
||||
IFT(pTable->GetTableName(&tableName));
|
||||
IFTPTR(tableName);
|
||||
IFTARG(strcmp(tableName, "op") != 0); // "op" is reserved for builtin intrinsics
|
||||
IFTARG(strcmp(tableName, "op") !=
|
||||
0); // "op" is reserved for builtin intrinsics
|
||||
for (auto &&table : m_intrinsicTables) {
|
||||
LPCSTR otherTableName = nullptr;
|
||||
IFT(table->GetTableName(&otherTableName));
|
||||
IFTPTR(otherTableName);
|
||||
IFTARG(strcmp(tableName, otherTableName) != 0); // Added a duplicate table name
|
||||
IFTARG(strcmp(tableName, otherTableName) !=
|
||||
0); // Added a duplicate table name
|
||||
}
|
||||
m_intrinsicTables.push_back(pTable);
|
||||
return S_OK;
|
||||
|
@ -148,7 +158,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
return "";
|
||||
}
|
||||
|
||||
// Get the dxil opcode for the extension opcode if one exists.
|
||||
|
@ -177,35 +187,44 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
// Use the contained semantice define validator to validate the given semantic define.
|
||||
SemanticDefineValidationResult ValidateSemanticDefine(const std::string &name, const std::string &value) {
|
||||
// Use the contained semantice define validator to validate the given semantic
|
||||
// define.
|
||||
SemanticDefineValidationResult
|
||||
ValidateSemanticDefine(const std::string &name, const std::string &value) {
|
||||
if (!m_semanticDefineValidator)
|
||||
return SemanticDefineValidationResult::Success();
|
||||
|
||||
// Blobs for getting restul from validator. Strings for returning results to caller.
|
||||
// Blobs for getting restul from validator. Strings for returning results to
|
||||
// caller.
|
||||
CComPtr<IDxcBlobEncoding> pError;
|
||||
CComPtr<IDxcBlobEncoding> pWarning;
|
||||
std::string error;
|
||||
std::string warning;
|
||||
|
||||
// Run semantic define validator.
|
||||
HRESULT result = m_semanticDefineValidator->GetSemanticDefineWarningsAndErrors(name.c_str(), value.c_str(), &pWarning, &pError);
|
||||
|
||||
HRESULT result =
|
||||
m_semanticDefineValidator->GetSemanticDefineWarningsAndErrors(
|
||||
name.c_str(), value.c_str(), &pWarning, &pError);
|
||||
|
||||
if (FAILED(result)) {
|
||||
// Failure indicates it was not able to even run validation so
|
||||
// we cannot say whether the define is invalid or not. Return a
|
||||
// generic error message about failure to run the valiadator.
|
||||
error = "failed to run semantic define validator for: ";
|
||||
error.append(name); error.append("="); error.append(value);
|
||||
return SemanticDefineValidationResult{ warning, error };
|
||||
error.append(name);
|
||||
error.append("=");
|
||||
error.append(value);
|
||||
return SemanticDefineValidationResult{warning, error};
|
||||
}
|
||||
|
||||
// Define a little function to convert encoded blob into a string.
|
||||
auto GetErrorAsString = [&name](const CComPtr<IDxcBlobEncoding> &pBlobString) -> std::string {
|
||||
auto GetErrorAsString =
|
||||
[&name](const CComPtr<IDxcBlobEncoding> &pBlobString) -> std::string {
|
||||
CComPtr<IDxcBlobUtf8> pUTF8BlobStr;
|
||||
if (SUCCEEDED(hlsl::DxcGetBlobAsUtf8(pBlobString, DxcGetThreadMallocNoRef(), &pUTF8BlobStr)))
|
||||
return std::string(pUTF8BlobStr->GetStringPointer(), pUTF8BlobStr->GetStringLength());
|
||||
if (SUCCEEDED(hlsl::DxcGetBlobAsUtf8(
|
||||
pBlobString, DxcGetThreadMallocNoRef(), &pUTF8BlobStr)))
|
||||
return std::string(pUTF8BlobStr->GetStringPointer(),
|
||||
pUTF8BlobStr->GetStringLength());
|
||||
else
|
||||
return std::string("invalid semantic define " + name);
|
||||
};
|
||||
|
@ -218,7 +237,7 @@ public:
|
|||
warning = GetErrorAsString(pWarning);
|
||||
}
|
||||
|
||||
return SemanticDefineValidationResult{ warning, error };
|
||||
return SemanticDefineValidationResult{warning, error};
|
||||
}
|
||||
|
||||
DxcLangExtensionsCommonHelper()
|
||||
|
|
|
@ -12,30 +12,30 @@
|
|||
#ifndef __DXCLANGEXTENSIONSHELPER_H__
|
||||
#define __DXCLANGEXTENSIONSHELPER_H__
|
||||
|
||||
#include "dxc/Support/DxcLangExtensionsCommonHelper.h"
|
||||
#include "dxc/Support/FileIOHelper.h"
|
||||
#include "dxc/Support/Unicode.h"
|
||||
#include "clang/AST/ASTContext.h"
|
||||
#include "clang/AST/Decl.h"
|
||||
#include "clang/Frontend/CompilerInstance.h"
|
||||
#include "clang/Sema/Sema.h"
|
||||
#include "clang/Sema/SemaHLSL.h"
|
||||
#include "dxc/Support/DxcLangExtensionsCommonHelper.h"
|
||||
#include "dxc/Support/FileIOHelper.h"
|
||||
#include "dxc/Support/Unicode.h"
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
class raw_string_ostream;
|
||||
class CallInst;
|
||||
class Value;
|
||||
}
|
||||
} // namespace llvm
|
||||
namespace clang {
|
||||
class CompilerInstance;
|
||||
}
|
||||
|
||||
namespace hlsl {
|
||||
|
||||
class DxcLangExtensionsHelper : public DxcLangExtensionsCommonHelper, public DxcLangExtensionsHelperApply {
|
||||
class DxcLangExtensionsHelper : public DxcLangExtensionsCommonHelper,
|
||||
public DxcLangExtensionsHelperApply {
|
||||
private:
|
||||
|
||||
public:
|
||||
void SetupSema(clang::Sema &S) override {
|
||||
clang::ExternalASTSource *astSource = S.getASTContext().getExternalSource();
|
||||
|
@ -64,7 +64,7 @@ public:
|
|||
// parsed by the compiler. It has a name (required), a value (could be
|
||||
// the empty string), and a location. We use an encoded clang::SourceLocation
|
||||
// for the location to avoid a clang include dependency.
|
||||
struct ParsedSemanticDefine{
|
||||
struct ParsedSemanticDefine {
|
||||
std::string Name;
|
||||
std::string Value;
|
||||
unsigned Location;
|
||||
|
|
|
@ -31,7 +31,7 @@ struct Toggle {
|
|||
};
|
||||
|
||||
enum {
|
||||
DEFAULT_ON = 1,
|
||||
DEFAULT_ON = 1,
|
||||
DEFAULT_OFF = 0,
|
||||
};
|
||||
|
||||
|
@ -44,16 +44,15 @@ static const Toggle TOGGLE_PARTIAL_LIFETIME_MARKERS = {
|
|||
static const Toggle TOGGLE_STRUCTURIZE_LOOP_EXITS_FOR_UNROLL = {
|
||||
"structurize-loop-exits-for-unroll", DEFAULT_ON};
|
||||
static const Toggle TOGGLE_DEBUG_NOPS = {"debug-nops", DEFAULT_ON};
|
||||
static const Toggle TOGGLE_STRUCTURIZE_RETURNS = {"structurize-returns", DEFAULT_OFF};
|
||||
static const Toggle TOGGLE_STRUCTURIZE_RETURNS = {"structurize-returns",
|
||||
DEFAULT_OFF};
|
||||
|
||||
struct OptimizationToggles {
|
||||
// Optimization pass enables, disables and selects
|
||||
std::map<std::string, bool> Toggles; // OPT_opt_enable & OPT_opt_disable
|
||||
std::map<std::string, bool> Toggles; // OPT_opt_enable & OPT_opt_disable
|
||||
std::map<std::string, std::string> Selects; // OPT_opt_select
|
||||
|
||||
void Set(Toggle Opt, bool Value) {
|
||||
Toggles[Opt.Name] = Value;
|
||||
}
|
||||
void Set(Toggle Opt, bool Value) { Toggles[Opt.Name] = Value; }
|
||||
bool IsSet(Toggle Opt) const {
|
||||
return Toggles.find(Opt.Name) != Toggles.end();
|
||||
}
|
||||
|
|
|
@ -11,108 +11,141 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
|
||||
// Redeclare some macros to not depend on winerror.h
|
||||
#define DXC_SEVERITY_ERROR 1
|
||||
#define DXC_MAKE_HRESULT(sev,fac,code) \
|
||||
((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) )
|
||||
#define DXC_SEVERITY_ERROR 1
|
||||
#define DXC_MAKE_HRESULT(sev, fac, code) \
|
||||
((HRESULT)(((unsigned long)(sev) << 31) | ((unsigned long)(fac) << 16) | \
|
||||
((unsigned long)(code))))
|
||||
|
||||
#define HRESULT_IS_WIN32ERR(hr) ((HRESULT)(hr & 0xFFFF0000) == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, 0))
|
||||
#define HRESULT_IS_WIN32ERR(hr) \
|
||||
((HRESULT)(hr & 0xFFFF0000) == \
|
||||
MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, 0))
|
||||
#define HRESULT_AS_WIN32ERR(hr) (HRESULT_CODE(hr))
|
||||
|
||||
// Error codes from C libraries (0n150) - 0x8096xxxx
|
||||
#define FACILITY_ERRNO (0x96)
|
||||
#define HRESULT_FROM_ERRNO(x) MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_ERRNO,(x))
|
||||
#define FACILITY_ERRNO (0x96)
|
||||
#define HRESULT_FROM_ERRNO(x) \
|
||||
MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_ERRNO, (x))
|
||||
|
||||
// Error codes from DXC libraries (0n170) - 0x8013xxxx
|
||||
#define FACILITY_DXC (0xAA)
|
||||
#define FACILITY_DXC (0xAA)
|
||||
|
||||
// 0x00000000 - The operation succeeded.
|
||||
#define DXC_S_OK 0 // _HRESULT_TYPEDEF_(0x00000000L)
|
||||
#define DXC_S_OK 0 // _HRESULT_TYPEDEF_(0x00000000L)
|
||||
|
||||
// 0x80AA0001 - The operation failed because overlapping semantics were found.
|
||||
#define DXC_E_OVERLAPPING_SEMANTICS DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0001))
|
||||
#define DXC_E_OVERLAPPING_SEMANTICS \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0001))
|
||||
|
||||
// 0x80AA0002 - The operation failed because multiple depth semantics were found.
|
||||
#define DXC_E_MULTIPLE_DEPTH_SEMANTICS DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0002))
|
||||
// 0x80AA0002 - The operation failed because multiple depth semantics were
|
||||
// found.
|
||||
#define DXC_E_MULTIPLE_DEPTH_SEMANTICS \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0002))
|
||||
|
||||
// 0x80AA0003 - Input file is too large.
|
||||
#define DXC_E_INPUT_FILE_TOO_LARGE DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0003))
|
||||
#define DXC_E_INPUT_FILE_TOO_LARGE \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0003))
|
||||
|
||||
// 0x80AA0004 - Error parsing DXBC container.
|
||||
#define DXC_E_INCORRECT_DXBC DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0004))
|
||||
#define DXC_E_INCORRECT_DXBC \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0004))
|
||||
|
||||
// 0x80AA0005 - Error parsing DXBC bytecode.
|
||||
#define DXC_E_ERROR_PARSING_DXBC_BYTECODE DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0005))
|
||||
#define DXC_E_ERROR_PARSING_DXBC_BYTECODE \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0005))
|
||||
|
||||
// 0x80AA0006 - Data is too large.
|
||||
#define DXC_E_DATA_TOO_LARGE DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0006))
|
||||
#define DXC_E_DATA_TOO_LARGE \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0006))
|
||||
|
||||
// 0x80AA0007 - Incompatible converter options.
|
||||
#define DXC_E_INCOMPATIBLE_CONVERTER_OPTIONS DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0007))
|
||||
#define DXC_E_INCOMPATIBLE_CONVERTER_OPTIONS \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0007))
|
||||
|
||||
// 0x80AA0008 - Irreducible control flow graph.
|
||||
#define DXC_E_IRREDUCIBLE_CFG DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0008))
|
||||
#define DXC_E_IRREDUCIBLE_CFG \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0008))
|
||||
|
||||
// 0x80AA0009 - IR verification error.
|
||||
#define DXC_E_IR_VERIFICATION_FAILED DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0009))
|
||||
#define DXC_E_IR_VERIFICATION_FAILED \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0009))
|
||||
|
||||
// 0x80AA000A - Scope-nested control flow recovery failed.
|
||||
#define DXC_E_SCOPE_NESTED_FAILED DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x000A))
|
||||
#define DXC_E_SCOPE_NESTED_FAILED \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x000A))
|
||||
|
||||
// 0x80AA000B - Operation is not supported.
|
||||
#define DXC_E_NOT_SUPPORTED DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x000B))
|
||||
#define DXC_E_NOT_SUPPORTED \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x000B))
|
||||
|
||||
// 0x80AA000C - Unable to encode string.
|
||||
#define DXC_E_STRING_ENCODING_FAILED DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x000C))
|
||||
#define DXC_E_STRING_ENCODING_FAILED \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x000C))
|
||||
|
||||
// 0x80AA000D - DXIL container is invalid.
|
||||
#define DXC_E_CONTAINER_INVALID DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x000D))
|
||||
#define DXC_E_CONTAINER_INVALID \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x000D))
|
||||
|
||||
// 0x80AA000E - DXIL container is missing the DXIL part.
|
||||
#define DXC_E_CONTAINER_MISSING_DXIL DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x000E))
|
||||
#define DXC_E_CONTAINER_MISSING_DXIL \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x000E))
|
||||
|
||||
// 0x80AA000F - Unable to parse DxilModule metadata.
|
||||
#define DXC_E_INCORRECT_DXIL_METADATA DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x000F))
|
||||
#define DXC_E_INCORRECT_DXIL_METADATA \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x000F))
|
||||
|
||||
// 0x80AA0010 - Error parsing DDI signature.
|
||||
#define DXC_E_INCORRECT_DDI_SIGNATURE DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0010))
|
||||
#define DXC_E_INCORRECT_DDI_SIGNATURE \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0010))
|
||||
|
||||
// 0x80AA0011 - Duplicate part exists in dxil container.
|
||||
#define DXC_E_DUPLICATE_PART DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0011))
|
||||
#define DXC_E_DUPLICATE_PART \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0011))
|
||||
|
||||
// 0x80AA0012 - Error finding part in dxil container.
|
||||
#define DXC_E_MISSING_PART DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0012))
|
||||
#define DXC_E_MISSING_PART \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0012))
|
||||
|
||||
// 0x80AA0013 - Malformed DXIL Container.
|
||||
#define DXC_E_MALFORMED_CONTAINER DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0013))
|
||||
#define DXC_E_MALFORMED_CONTAINER \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0013))
|
||||
|
||||
// 0x80AA0014 - Incorrect Root Signature for shader.
|
||||
#define DXC_E_INCORRECT_ROOT_SIGNATURE DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0014))
|
||||
#define DXC_E_INCORRECT_ROOT_SIGNATURE \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0014))
|
||||
|
||||
// 0X80AA0015 - DXIL container is missing DebugInfo part.
|
||||
#define DXC_E_CONTAINER_MISSING_DEBUG DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0015))
|
||||
#define DXC_E_CONTAINER_MISSING_DEBUG \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0015))
|
||||
|
||||
// 0X80AA0016 - Unexpected failure in macro expansion.
|
||||
#define DXC_E_MACRO_EXPANSION_FAILURE DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0016))
|
||||
#define DXC_E_MACRO_EXPANSION_FAILURE \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0016))
|
||||
|
||||
// 0X80AA0017 - DXIL optimization pass failed.
|
||||
#define DXC_E_OPTIMIZATION_FAILED DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0017))
|
||||
#define DXC_E_OPTIMIZATION_FAILED \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0017))
|
||||
|
||||
// 0X80AA0018 - General internal error.
|
||||
#define DXC_E_GENERAL_INTERNAL_ERROR DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0018))
|
||||
#define DXC_E_GENERAL_INTERNAL_ERROR \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0018))
|
||||
|
||||
// 0X80AA0019 - Abort compilation error.
|
||||
#define DXC_E_ABORT_COMPILATION_ERROR DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x0019))
|
||||
#define DXC_E_ABORT_COMPILATION_ERROR \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0019))
|
||||
|
||||
// 0X80AA001A - Error in extension mechanism.
|
||||
#define DXC_E_EXTENSION_ERROR DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x001A))
|
||||
#define DXC_E_EXTENSION_ERROR \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x001A))
|
||||
|
||||
// 0X80AA001B - LLVM Fatal Error
|
||||
#define DXC_E_LLVM_FATAL_ERROR DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x001B))
|
||||
#define DXC_E_LLVM_FATAL_ERROR \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x001B))
|
||||
|
||||
// 0X80AA001C - LLVM Unreachable code
|
||||
#define DXC_E_LLVM_UNREACHABLE DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x001C))
|
||||
#define DXC_E_LLVM_UNREACHABLE \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x001C))
|
||||
|
||||
// 0X80AA001D - LLVM Cast Failure
|
||||
#define DXC_E_LLVM_CAST_ERROR DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR,FACILITY_DXC,(0x001D))
|
||||
#define DXC_E_LLVM_CAST_ERROR \
|
||||
DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x001D))
|
||||
|
|
|
@ -47,24 +47,19 @@ public:
|
|||
|
||||
// Like CComHeapPtr, but with CDxcThreadMallocAllocator.
|
||||
template <typename T>
|
||||
class CDxcTMHeapPtr :
|
||||
public CHeapPtr<T, CDxcThreadMallocAllocator>
|
||||
{
|
||||
class CDxcTMHeapPtr : public CHeapPtr<T, CDxcThreadMallocAllocator> {
|
||||
public:
|
||||
CDxcTMHeapPtr() throw()
|
||||
{
|
||||
}
|
||||
CDxcTMHeapPtr() throw() {}
|
||||
|
||||
explicit CDxcTMHeapPtr(T *pData) throw()
|
||||
: CHeapPtr<T, CDxcThreadMallocAllocator>(pData) {}
|
||||
};
|
||||
|
||||
// Like CComHeapPtr, but with a stateful allocator.
|
||||
template <typename T>
|
||||
class CDxcMallocHeapPtr
|
||||
{
|
||||
template <typename T> class CDxcMallocHeapPtr {
|
||||
private:
|
||||
CComPtr<IMalloc> m_pMalloc;
|
||||
|
||||
public:
|
||||
T *m_pData;
|
||||
|
||||
|
@ -78,7 +73,7 @@ public:
|
|||
|
||||
operator T *() const throw() { return m_pData; }
|
||||
|
||||
IMalloc* GetMallocNoRef() const throw() { return m_pMalloc.p; }
|
||||
IMalloc *GetMallocNoRef() const throw() { return m_pMalloc.p; }
|
||||
|
||||
bool Allocate(SIZE_T ElementCount) throw() {
|
||||
ATLASSERT(m_pData == NULL);
|
||||
|
@ -135,16 +130,16 @@ UINT32 DxcCodePageFromBytes(const char *bytes, size_t byteLen) throw();
|
|||
// an IDxcBlobUtf8 or IDxcBlobWide will be constructed.
|
||||
// If text, it's best if size includes null terminator when not copying,
|
||||
// otherwise IDxcBlobUtf8 or IDxcBlobWide will not be constructed.
|
||||
HRESULT DxcCreateBlob(
|
||||
LPCVOID pPtr, SIZE_T size, bool bPinned, bool bCopy,
|
||||
bool encodingKnown, UINT32 codePage,
|
||||
IMalloc *pMalloc, IDxcBlobEncoding **ppBlobEncoding) throw();
|
||||
HRESULT DxcCreateBlob(LPCVOID pPtr, SIZE_T size, bool bPinned, bool bCopy,
|
||||
bool encodingKnown, UINT32 codePage, IMalloc *pMalloc,
|
||||
IDxcBlobEncoding **ppBlobEncoding) throw();
|
||||
// Create from blob references original blob.
|
||||
// Pass nonzero for offset or length for sub-blob reference.
|
||||
HRESULT DxcCreateBlobEncodingFromBlob(
|
||||
IDxcBlob *pFromBlob, UINT32 offset, UINT32 length,
|
||||
bool encodingKnown, UINT32 codePage,
|
||||
IMalloc *pMalloc, IDxcBlobEncoding **ppBlobEncoding) throw();
|
||||
HRESULT
|
||||
DxcCreateBlobEncodingFromBlob(IDxcBlob *pFromBlob, UINT32 offset, UINT32 length,
|
||||
bool encodingKnown, UINT32 codePage,
|
||||
IMalloc *pMalloc,
|
||||
IDxcBlobEncoding **ppBlobEncoding) throw();
|
||||
|
||||
// Load files
|
||||
HRESULT DxcCreateBlobFromFile(IMalloc *pMalloc, LPCWSTR pFileName,
|
||||
|
@ -200,7 +195,8 @@ DxcCreateBlobWithEncodingOnMalloc(LPCVOID pText, IMalloc *pIMalloc, UINT32 size,
|
|||
UINT32 codePage,
|
||||
IDxcBlobEncoding **pBlobEncoding) throw();
|
||||
|
||||
// Creates a blob with a copy of encoded text, allocated using the provided IMalloc
|
||||
// Creates a blob with a copy of encoded text, allocated using the provided
|
||||
// IMalloc
|
||||
HRESULT
|
||||
DxcCreateBlobWithEncodingOnMallocCopy(IMalloc *pIMalloc, LPCVOID pText,
|
||||
UINT32 size, UINT32 codePage,
|
||||
|
@ -232,7 +228,7 @@ HRESULT CreateFixedSizeMemoryStream(LPBYTE pBuffer, size_t size,
|
|||
AbstractMemoryStream **ppResult) throw();
|
||||
|
||||
template <typename T>
|
||||
HRESULT WriteStreamValue(IStream *pStream, const T& value) {
|
||||
HRESULT WriteStreamValue(IStream *pStream, const T &value) {
|
||||
ULONG cb;
|
||||
return pStream->Write(&value, sizeof(value), &cb);
|
||||
}
|
||||
|
|
|
@ -24,10 +24,10 @@ typedef _Return_type_success_(return >= 0) long HRESULT;
|
|||
#endif // !_HRESULT_DEFINED
|
||||
#endif // _WIN32
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <system_error>
|
||||
#include "dxc/Support/exception.h"
|
||||
#include "dxc/WinAdapter.h"
|
||||
#include <stdarg.h>
|
||||
#include <system_error>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Memory allocation support.
|
||||
|
@ -51,12 +51,13 @@ void DxcCleanupThreadMalloc() throw();
|
|||
void DxcSetThreadMallocToDefault() throw();
|
||||
void DxcClearThreadMalloc() throw();
|
||||
|
||||
// Used to retrieve the current invocation's allocator or perform an alloc/free/realloc.
|
||||
// Used to retrieve the current invocation's allocator or perform an
|
||||
// alloc/free/realloc.
|
||||
IMalloc *DxcGetThreadMallocNoRef() throw();
|
||||
|
||||
// Common implementation of operators new and delete
|
||||
void *DxcNew(std::size_t size) throw();
|
||||
void DxcDelete(void* ptr) throw();
|
||||
void DxcDelete(void *ptr) throw();
|
||||
|
||||
class DxcThreadMalloc {
|
||||
public:
|
||||
|
@ -69,10 +70,10 @@ private:
|
|||
// Copy constructor and assignment are dangerous and should always be
|
||||
// deleted...
|
||||
DxcThreadMalloc(const DxcThreadMalloc &) = delete;
|
||||
DxcThreadMalloc &operator =(const DxcThreadMalloc &) = delete;
|
||||
DxcThreadMalloc &operator=(const DxcThreadMalloc &) = delete;
|
||||
// Move constructor and assignment should be OK to be added if needed.
|
||||
DxcThreadMalloc(DxcThreadMalloc &&) = delete;
|
||||
DxcThreadMalloc &operator =(DxcThreadMalloc &&) = delete;
|
||||
DxcThreadMalloc &operator=(DxcThreadMalloc &&) = delete;
|
||||
|
||||
IMalloc *p;
|
||||
IMalloc *pPrior;
|
||||
|
@ -82,33 +83,122 @@ private:
|
|||
// Error handling support.
|
||||
void CheckLLVMErrorCode(const std::error_code &ec);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
Project-wide macros
|
||||
******************************************************************************/
|
||||
#define SAFE_RELEASE(p) { if (p) { (p)->Release(); (p) = nullptr; } }
|
||||
#define SAFE_ADDREF(p) { if (p) { (p)->AddRef(); } }
|
||||
#define SAFE_RELEASE(p) \
|
||||
{ \
|
||||
if (p) { \
|
||||
(p)->Release(); \
|
||||
(p) = nullptr; \
|
||||
} \
|
||||
}
|
||||
#define SAFE_ADDREF(p) \
|
||||
{ \
|
||||
if (p) { \
|
||||
(p)->AddRef(); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SAFE_DELETE_ARRAY(p) { delete [](p); p = nullptr; }
|
||||
#define SAFE_DELETE(p) { delete (p); p = nullptr; }
|
||||
#define SAFE_DELETE_ARRAY(p) \
|
||||
{ \
|
||||
delete[](p); \
|
||||
p = nullptr; \
|
||||
}
|
||||
#define SAFE_DELETE(p) \
|
||||
{ \
|
||||
delete (p); \
|
||||
p = nullptr; \
|
||||
}
|
||||
|
||||
// VH is used in other DXC projects, but it's also a typedef in llvm.
|
||||
// Use the IFC (IfFailedCleanup) set of conventions.
|
||||
#define IFC(x) { hr = (x); if (DXC_FAILED(hr)) goto Cleanup; }
|
||||
#define IFR(x) { HRESULT __hr = (x); if (DXC_FAILED(__hr)) return __hr; }
|
||||
#define IFRBOOL(x,y){ if (!(x)) return (y); }
|
||||
#define IFCBOOL(x,y){ if (!(x)) { hr = (y); goto Cleanup; } }
|
||||
#define IFCOOM(x) { if (nullptr == (x)) { hr = E_OUTOFMEMORY; goto Cleanup; } }
|
||||
#define IFROOM(x) { if (nullptr == (x)) { return E_OUTOFMEMORY; } }
|
||||
#define IFCPTR(x) { if (nullptr == (x)) { hr = E_POINTER; goto Cleanup; }}
|
||||
#define IFT(x) { HRESULT __hr = (x); if (DXC_FAILED(__hr)) throw ::hlsl::Exception(__hr); }
|
||||
#define IFTBOOL(x,y){ if (!(x)) throw ::hlsl::Exception(y); }
|
||||
#define IFTOOM(x) { if (nullptr == (x)) { throw ::hlsl::Exception(E_OUTOFMEMORY); }}
|
||||
#define IFTPTR(x) { if (nullptr == (x)) { throw ::hlsl::Exception(E_POINTER); }}
|
||||
#define IFTARG(x) { if (!(x)) { throw ::hlsl::Exception(E_INVALIDARG); }}
|
||||
#define IFTLLVM(x) { CheckLLVMErrorCode(x); }
|
||||
#define IFTMSG(x, msg) { HRESULT __hr = (x); if (DXC_FAILED(__hr)) throw ::hlsl::Exception(__hr, msg); }
|
||||
#define IFTBOOLMSG(x, y, msg) { if (!(x)) throw ::hlsl::Exception(y, msg); }
|
||||
#define IFC(x) \
|
||||
{ \
|
||||
hr = (x); \
|
||||
if (DXC_FAILED(hr)) \
|
||||
goto Cleanup; \
|
||||
}
|
||||
#define IFR(x) \
|
||||
{ \
|
||||
HRESULT __hr = (x); \
|
||||
if (DXC_FAILED(__hr)) \
|
||||
return __hr; \
|
||||
}
|
||||
#define IFRBOOL(x, y) \
|
||||
{ \
|
||||
if (!(x)) \
|
||||
return (y); \
|
||||
}
|
||||
#define IFCBOOL(x, y) \
|
||||
{ \
|
||||
if (!(x)) { \
|
||||
hr = (y); \
|
||||
goto Cleanup; \
|
||||
} \
|
||||
}
|
||||
#define IFCOOM(x) \
|
||||
{ \
|
||||
if (nullptr == (x)) { \
|
||||
hr = E_OUTOFMEMORY; \
|
||||
goto Cleanup; \
|
||||
} \
|
||||
}
|
||||
#define IFROOM(x) \
|
||||
{ \
|
||||
if (nullptr == (x)) { \
|
||||
return E_OUTOFMEMORY; \
|
||||
} \
|
||||
}
|
||||
#define IFCPTR(x) \
|
||||
{ \
|
||||
if (nullptr == (x)) { \
|
||||
hr = E_POINTER; \
|
||||
goto Cleanup; \
|
||||
} \
|
||||
}
|
||||
#define IFT(x) \
|
||||
{ \
|
||||
HRESULT __hr = (x); \
|
||||
if (DXC_FAILED(__hr)) \
|
||||
throw ::hlsl::Exception(__hr); \
|
||||
}
|
||||
#define IFTBOOL(x, y) \
|
||||
{ \
|
||||
if (!(x)) \
|
||||
throw ::hlsl::Exception(y); \
|
||||
}
|
||||
#define IFTOOM(x) \
|
||||
{ \
|
||||
if (nullptr == (x)) { \
|
||||
throw ::hlsl::Exception(E_OUTOFMEMORY); \
|
||||
} \
|
||||
}
|
||||
#define IFTPTR(x) \
|
||||
{ \
|
||||
if (nullptr == (x)) { \
|
||||
throw ::hlsl::Exception(E_POINTER); \
|
||||
} \
|
||||
}
|
||||
#define IFTARG(x) \
|
||||
{ \
|
||||
if (!(x)) { \
|
||||
throw ::hlsl::Exception(E_INVALIDARG); \
|
||||
} \
|
||||
}
|
||||
#define IFTLLVM(x) \
|
||||
{ CheckLLVMErrorCode(x); }
|
||||
#define IFTMSG(x, msg) \
|
||||
{ \
|
||||
HRESULT __hr = (x); \
|
||||
if (DXC_FAILED(__hr)) \
|
||||
throw ::hlsl::Exception(__hr, msg); \
|
||||
}
|
||||
#define IFTBOOLMSG(x, y, msg) \
|
||||
{ \
|
||||
if (!(x)) \
|
||||
throw ::hlsl::Exception(y, msg); \
|
||||
}
|
||||
|
||||
// Propagate an C++ exception into an HRESULT.
|
||||
#define CATCH_CPP_ASSIGN_HRESULT() \
|
||||
|
@ -132,7 +222,7 @@ void CheckLLVMErrorCode(const std::error_code &ec);
|
|||
return E_FAIL; \
|
||||
}
|
||||
|
||||
template<typename T> T *VerifyNullAndThrow(T *p) {
|
||||
template <typename T> T *VerifyNullAndThrow(T *p) {
|
||||
if (p == nullptr)
|
||||
throw std::bad_alloc();
|
||||
return p;
|
||||
|
@ -235,9 +325,21 @@ inline void OutputDebugFormatA(const char *pszFormat, ...) {
|
|||
|
||||
#define DXVERIFY_NOMSG assert
|
||||
|
||||
#define DXASSERT_ARGS(expr, fmt, ...) do { if (!(expr)) { fprintf(stderr, fmt, __VA_ARGS__); assert(false); } } while (0);
|
||||
#define DXASSERT_ARGS(expr, fmt, ...) \
|
||||
do { \
|
||||
if (!(expr)) { \
|
||||
fprintf(stderr, fmt, __VA_ARGS__); \
|
||||
assert(false); \
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
#define DXASSERT(expr, msg) do { if (!(expr)) { fprintf(stderr, msg); assert(false && msg); } } while (0);
|
||||
#define DXASSERT(expr, msg) \
|
||||
do { \
|
||||
if (!(expr)) { \
|
||||
fprintf(stderr, msg); \
|
||||
assert(false && msg); \
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
#endif // _WIN32
|
||||
|
||||
|
@ -249,7 +351,8 @@ inline void OutputDebugFormatA(const char *pszFormat, ...) {
|
|||
// DXASSERT is disabled in free builds.
|
||||
#define DXASSERT(exp, msg)
|
||||
|
||||
// DXASSERT_LOCALVAR is disabled in free builds, but we keep the local referenced to avoid a warning.
|
||||
// DXASSERT_LOCALVAR is disabled in free builds, but we keep the local
|
||||
// referenced to avoid a warning.
|
||||
#define DXASSERT_LOCALVAR(local, exp, msg) \
|
||||
do { \
|
||||
(void)(local); \
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
#ifndef LLVM_HLSL_OPTIONS_H
|
||||
#define LLVM_HLSL_OPTIONS_H
|
||||
|
||||
#include "dxc/Support/DxcOptToggles.h"
|
||||
#include "dxc/Support/HLSLVersion.h"
|
||||
#include "dxc/Support/SPIRVOptions.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Option/ArgList.h"
|
||||
#include "dxc/Support/HLSLVersion.h"
|
||||
#include "dxc/Support/SPIRVOptions.h"
|
||||
#include "dxc/Support/DxcOptToggles.h"
|
||||
|
||||
#include "dxc/Support/WinIncludes.h"
|
||||
|
||||
|
@ -32,8 +32,8 @@ namespace llvm {
|
|||
namespace opt {
|
||||
class OptTable;
|
||||
class raw_ostream;
|
||||
}
|
||||
}
|
||||
} // namespace opt
|
||||
} // namespace llvm
|
||||
|
||||
namespace dxc {
|
||||
class DxcDllSupport;
|
||||
|
@ -55,13 +55,14 @@ enum HlslFlags {
|
|||
};
|
||||
|
||||
enum ID {
|
||||
OPT_INVALID = 0, // This is not an option ID.
|
||||
#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
|
||||
HELPTEXT, METAVAR) OPT_##ID,
|
||||
OPT_INVALID = 0, // This is not an option ID.
|
||||
#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
|
||||
HELPTEXT, METAVAR) \
|
||||
OPT_##ID,
|
||||
#include "dxc/Support/HLSLOptions.inc"
|
||||
LastOption
|
||||
LastOption
|
||||
#undef OPTION
|
||||
};
|
||||
};
|
||||
|
||||
const llvm::opt::OptTable *getHlslOptTable();
|
||||
std::error_code initHlslOptTable();
|
||||
|
@ -73,13 +74,17 @@ void cleanupHlslOptTable();
|
|||
/// Flags for IDxcCompiler APIs.
|
||||
static const unsigned CompilerFlags = HlslFlags::CoreOption;
|
||||
/// Flags for dxc.exe command-line tool.
|
||||
static const unsigned DxcFlags = HlslFlags::CoreOption | HlslFlags::DriverOption;
|
||||
static const unsigned DxcFlags =
|
||||
HlslFlags::CoreOption | HlslFlags::DriverOption;
|
||||
/// Flags for dxr.exe command-line tool.
|
||||
static const unsigned DxrFlags = HlslFlags::RewriteOption | HlslFlags::DriverOption;
|
||||
static const unsigned DxrFlags =
|
||||
HlslFlags::RewriteOption | HlslFlags::DriverOption;
|
||||
/// Flags for IDxcIntelliSense APIs.
|
||||
static const unsigned ISenseFlags = HlslFlags::CoreOption | HlslFlags::ISenseOption;
|
||||
static const unsigned ISenseFlags =
|
||||
HlslFlags::CoreOption | HlslFlags::ISenseOption;
|
||||
|
||||
/// Use this class to capture preprocessor definitions and manage their lifetime.
|
||||
/// Use this class to capture preprocessor definitions and manage their
|
||||
/// lifetime.
|
||||
class DxcDefines {
|
||||
public:
|
||||
void push_back(llvm::StringRef value);
|
||||
|
@ -97,15 +102,15 @@ public:
|
|||
};
|
||||
|
||||
struct RewriterOpts {
|
||||
bool Unchanged = false; // OPT_rw_unchanged
|
||||
bool SkipFunctionBody = false; // OPT_rw_skip_function_body
|
||||
bool SkipStatic = false; // OPT_rw_skip_static
|
||||
bool GlobalExternByDefault = false; // OPT_rw_global_extern_by_default
|
||||
bool KeepUserMacro = false; // OPT_rw_keep_user_macro
|
||||
bool ExtractEntryUniforms = false; // OPT_rw_extract_entry_uniforms
|
||||
bool RemoveUnusedGlobals = false; // OPT_rw_remove_unused_globals
|
||||
bool RemoveUnusedFunctions = false; // OPT_rw_remove_unused_functions
|
||||
bool WithLineDirective = false; // OPT_rw_line_directive
|
||||
bool Unchanged = false; // OPT_rw_unchanged
|
||||
bool SkipFunctionBody = false; // OPT_rw_skip_function_body
|
||||
bool SkipStatic = false; // OPT_rw_skip_static
|
||||
bool GlobalExternByDefault = false; // OPT_rw_global_extern_by_default
|
||||
bool KeepUserMacro = false; // OPT_rw_keep_user_macro
|
||||
bool ExtractEntryUniforms = false; // OPT_rw_extract_entry_uniforms
|
||||
bool RemoveUnusedGlobals = false; // OPT_rw_remove_unused_globals
|
||||
bool RemoveUnusedFunctions = false; // OPT_rw_remove_unused_functions
|
||||
bool WithLineDirective = false; // OPT_rw_line_directive
|
||||
bool DeclGlobalCB = false; // OPT_rw_decl_global_cb
|
||||
};
|
||||
|
||||
|
@ -113,124 +118,128 @@ struct RewriterOpts {
|
|||
class DxcOpts {
|
||||
public:
|
||||
DxcDefines Defines;
|
||||
llvm::opt::InputArgList Args = llvm::opt::InputArgList(nullptr, nullptr); // Original arguments.
|
||||
llvm::opt::InputArgList Args =
|
||||
llvm::opt::InputArgList(nullptr, nullptr); // Original arguments.
|
||||
|
||||
llvm::StringRef AssemblyCode; // OPT_Fc
|
||||
llvm::StringRef DebugFile; // OPT_Fd
|
||||
llvm::StringRef EntryPoint; // OPT_entrypoint
|
||||
llvm::StringRef ExternalFn; // OPT_external_fn
|
||||
llvm::StringRef ExternalLib; // OPT_external_lib
|
||||
llvm::StringRef ExtractPrivateFile; // OPT_getprivate
|
||||
llvm::StringRef ForceRootSigVer; // OPT_force_rootsig_ver
|
||||
llvm::StringRef InputFile; // OPT_INPUT
|
||||
llvm::StringRef OutputHeader; // OPT_Fh
|
||||
llvm::StringRef OutputObject; // OPT_Fo
|
||||
llvm::StringRef OutputWarningsFile; // OPT_Fe
|
||||
llvm::StringRef OutputReflectionFile; // OPT_Fre
|
||||
llvm::StringRef OutputRootSigFile; // OPT_Frs
|
||||
llvm::StringRef OutputShaderHashFile; // OPT_Fsh
|
||||
llvm::StringRef OutputFileForDependencies; // OPT_write_dependencies_to
|
||||
std::string Preprocess; // OPT_P
|
||||
llvm::StringRef TargetProfile; // OPT_target_profile
|
||||
llvm::StringRef VariableName; // OPT_Vn
|
||||
llvm::StringRef PrivateSource; // OPT_setprivate
|
||||
llvm::StringRef RootSignatureSource; // OPT_setrootsignature
|
||||
llvm::StringRef VerifyRootSignatureSource; //OPT_verifyrootsignature
|
||||
llvm::StringRef RootSignatureDefine; // OPT_rootsig_define
|
||||
llvm::StringRef FloatDenormalMode; // OPT_denorm
|
||||
std::vector<std::string> Exports; // OPT_exports
|
||||
std::vector<std::string> PreciseOutputs; // OPT_precise_output
|
||||
llvm::StringRef DefaultLinkage; // OPT_default_linkage
|
||||
llvm::StringRef ImportBindingTable; // OPT_import_binding_table
|
||||
llvm::StringRef BindingTableDefine; // OPT_binding_table_define
|
||||
llvm::StringRef AssemblyCode; // OPT_Fc
|
||||
llvm::StringRef DebugFile; // OPT_Fd
|
||||
llvm::StringRef EntryPoint; // OPT_entrypoint
|
||||
llvm::StringRef ExternalFn; // OPT_external_fn
|
||||
llvm::StringRef ExternalLib; // OPT_external_lib
|
||||
llvm::StringRef ExtractPrivateFile; // OPT_getprivate
|
||||
llvm::StringRef ForceRootSigVer; // OPT_force_rootsig_ver
|
||||
llvm::StringRef InputFile; // OPT_INPUT
|
||||
llvm::StringRef OutputHeader; // OPT_Fh
|
||||
llvm::StringRef OutputObject; // OPT_Fo
|
||||
llvm::StringRef OutputWarningsFile; // OPT_Fe
|
||||
llvm::StringRef OutputReflectionFile; // OPT_Fre
|
||||
llvm::StringRef OutputRootSigFile; // OPT_Frs
|
||||
llvm::StringRef OutputShaderHashFile; // OPT_Fsh
|
||||
llvm::StringRef OutputFileForDependencies; // OPT_write_dependencies_to
|
||||
std::string Preprocess; // OPT_P
|
||||
llvm::StringRef TargetProfile; // OPT_target_profile
|
||||
llvm::StringRef VariableName; // OPT_Vn
|
||||
llvm::StringRef PrivateSource; // OPT_setprivate
|
||||
llvm::StringRef RootSignatureSource; // OPT_setrootsignature
|
||||
llvm::StringRef VerifyRootSignatureSource; // OPT_verifyrootsignature
|
||||
llvm::StringRef RootSignatureDefine; // OPT_rootsig_define
|
||||
llvm::StringRef FloatDenormalMode; // OPT_denorm
|
||||
std::vector<std::string> Exports; // OPT_exports
|
||||
std::vector<std::string> PreciseOutputs; // OPT_precise_output
|
||||
llvm::StringRef DefaultLinkage; // OPT_default_linkage
|
||||
llvm::StringRef ImportBindingTable; // OPT_import_binding_table
|
||||
llvm::StringRef BindingTableDefine; // OPT_binding_table_define
|
||||
unsigned DefaultTextCodePage = DXC_CP_UTF8; // OPT_encoding
|
||||
|
||||
bool AllResourcesBound = false; // OPT_all_resources_bound
|
||||
bool IgnoreOptSemDefs = false; // OPT_ignore_opt_semdefs
|
||||
bool AstDump = false; // OPT_ast_dump
|
||||
bool AstDumpImplicit = false; // OPT_ast_dump_implicit
|
||||
bool ColorCodeAssembly = false; // OPT_Cc
|
||||
bool CodeGenHighLevel = false; // OPT_fcgl
|
||||
bool AllowPreserveValues = false; // OPT_preserve_intermediate_values
|
||||
bool DebugInfo = false; // OPT__SLASH_Zi
|
||||
bool DebugNameForBinary = false; // OPT_Zsb
|
||||
bool DebugNameForSource = false; // OPT_Zss
|
||||
bool DumpBin = false; // OPT_dumpbin
|
||||
bool DumpDependencies = false; // OPT_dump_dependencies
|
||||
bool WriteDependencies = false; // OPT_write_dependencies
|
||||
bool Link = false; // OPT_link
|
||||
bool WarningAsError = false; // OPT__SLASH_WX
|
||||
bool IEEEStrict = false; // OPT_Gis
|
||||
bool IgnoreLineDirectives = false; // OPT_ignore_line_directives
|
||||
bool DefaultColMajor = false; // OPT_Zpc
|
||||
bool DefaultRowMajor = false; // OPT_Zpr
|
||||
bool DisableValidation = false; // OPT_VD
|
||||
unsigned OptLevel = 0; // OPT_O0/O1/O2/O3
|
||||
bool DisableOptimizations = false; // OPT_Od
|
||||
bool AvoidFlowControl = false; // OPT_Gfa
|
||||
bool PreferFlowControl = false; // OPT_Gfp
|
||||
bool EnableStrictMode = false; // OPT_Ges
|
||||
bool EnableDX9CompatMode = false; // OPT_Gec
|
||||
bool EnableFXCCompatMode = false; // internal flag
|
||||
LangStd HLSLVersion = LangStd::vUnset; // OPT_hlsl_version (2015-2021)
|
||||
bool Enable16BitTypes = false; // OPT_enable_16bit_types
|
||||
bool OptDump = false; // OPT_ODump - dump optimizer commands
|
||||
bool OutputWarnings = true; // OPT_no_warnings
|
||||
bool ShowHelp = false; // OPT_help
|
||||
bool ShowHelpHidden = false; // OPT__help_hidden
|
||||
bool ShowOptionNames = false; // OPT_fdiagnostics_show_option
|
||||
bool ShowVersion = false; // OPT_version
|
||||
bool UseColor = false; // OPT_Cc
|
||||
bool UseHexLiterals = false; // OPT_Lx
|
||||
bool AllResourcesBound = false; // OPT_all_resources_bound
|
||||
bool IgnoreOptSemDefs = false; // OPT_ignore_opt_semdefs
|
||||
bool AstDump = false; // OPT_ast_dump
|
||||
bool AstDumpImplicit = false; // OPT_ast_dump_implicit
|
||||
bool ColorCodeAssembly = false; // OPT_Cc
|
||||
bool CodeGenHighLevel = false; // OPT_fcgl
|
||||
bool AllowPreserveValues = false; // OPT_preserve_intermediate_values
|
||||
bool DebugInfo = false; // OPT__SLASH_Zi
|
||||
bool DebugNameForBinary = false; // OPT_Zsb
|
||||
bool DebugNameForSource = false; // OPT_Zss
|
||||
bool DumpBin = false; // OPT_dumpbin
|
||||
bool DumpDependencies = false; // OPT_dump_dependencies
|
||||
bool WriteDependencies = false; // OPT_write_dependencies
|
||||
bool Link = false; // OPT_link
|
||||
bool WarningAsError = false; // OPT__SLASH_WX
|
||||
bool IEEEStrict = false; // OPT_Gis
|
||||
bool IgnoreLineDirectives = false; // OPT_ignore_line_directives
|
||||
bool DefaultColMajor = false; // OPT_Zpc
|
||||
bool DefaultRowMajor = false; // OPT_Zpr
|
||||
bool DisableValidation = false; // OPT_VD
|
||||
unsigned OptLevel = 0; // OPT_O0/O1/O2/O3
|
||||
bool DisableOptimizations = false; // OPT_Od
|
||||
bool AvoidFlowControl = false; // OPT_Gfa
|
||||
bool PreferFlowControl = false; // OPT_Gfp
|
||||
bool EnableStrictMode = false; // OPT_Ges
|
||||
bool EnableDX9CompatMode = false; // OPT_Gec
|
||||
bool EnableFXCCompatMode = false; // internal flag
|
||||
LangStd HLSLVersion = LangStd::vUnset; // OPT_hlsl_version (2015-2021)
|
||||
bool Enable16BitTypes = false; // OPT_enable_16bit_types
|
||||
bool OptDump = false; // OPT_ODump - dump optimizer commands
|
||||
bool OutputWarnings = true; // OPT_no_warnings
|
||||
bool ShowHelp = false; // OPT_help
|
||||
bool ShowHelpHidden = false; // OPT__help_hidden
|
||||
bool ShowOptionNames = false; // OPT_fdiagnostics_show_option
|
||||
bool ShowVersion = false; // OPT_version
|
||||
bool UseColor = false; // OPT_Cc
|
||||
bool UseHexLiterals = false; // OPT_Lx
|
||||
bool UseInstructionByteOffsets = false; // OPT_No
|
||||
bool UseInstructionNumbers = false; // OPT_Ni
|
||||
bool NotUseLegacyCBufLoad = false; // OPT_no_legacy_cbuf_layout
|
||||
bool PackPrefixStable = false; // OPT_pack_prefix_stable
|
||||
bool PackOptimized = false; // OPT_pack_optimized
|
||||
bool DisplayIncludeProcess = false; // OPT__vi
|
||||
bool RecompileFromBinary = false; // OPT _Recompile (Recompiling the DXBC binary file not .hlsl file)
|
||||
bool StripDebug = false; // OPT Qstrip_debug
|
||||
bool EmbedDebug = false; // OPT Qembed_debug
|
||||
bool SourceInDebugModule = false; // OPT Zs
|
||||
bool SourceOnlyDebug = false; // OPT Qsource_only_debug
|
||||
bool PdbInPrivate = false; // OPT Qpdb_in_private
|
||||
bool StripRootSignature = false; // OPT_Qstrip_rootsignature
|
||||
bool StripPrivate = false; // OPT_Qstrip_priv
|
||||
bool StripReflection = false; // OPT_Qstrip_reflect
|
||||
bool KeepReflectionInDxil = false; // OPT_Qkeep_reflect_in_dxil
|
||||
bool StripReflectionFromDxil = false; // OPT_Qstrip_reflect_from_dxil
|
||||
bool ExtractRootSignature = false; // OPT_extractrootsignature
|
||||
bool DisassembleColorCoded = false; // OPT_Cc
|
||||
bool DisassembleInstNumbers = false; //OPT_Ni
|
||||
bool DisassembleByteOffset = false; //OPT_No
|
||||
bool DisaseembleHex = false; //OPT_Lx
|
||||
bool LegacyMacroExpansion = false; // OPT_flegacy_macro_expansion
|
||||
bool LegacyResourceReservation = false; // OPT_flegacy_resource_reservation
|
||||
bool UseInstructionNumbers = false; // OPT_Ni
|
||||
bool NotUseLegacyCBufLoad = false; // OPT_no_legacy_cbuf_layout
|
||||
bool PackPrefixStable = false; // OPT_pack_prefix_stable
|
||||
bool PackOptimized = false; // OPT_pack_optimized
|
||||
bool DisplayIncludeProcess = false; // OPT__vi
|
||||
bool RecompileFromBinary =
|
||||
false; // OPT _Recompile (Recompiling the DXBC binary file not .hlsl file)
|
||||
bool StripDebug = false; // OPT Qstrip_debug
|
||||
bool EmbedDebug = false; // OPT Qembed_debug
|
||||
bool SourceInDebugModule = false; // OPT Zs
|
||||
bool SourceOnlyDebug = false; // OPT Qsource_only_debug
|
||||
bool PdbInPrivate = false; // OPT Qpdb_in_private
|
||||
bool StripRootSignature = false; // OPT_Qstrip_rootsignature
|
||||
bool StripPrivate = false; // OPT_Qstrip_priv
|
||||
bool StripReflection = false; // OPT_Qstrip_reflect
|
||||
bool KeepReflectionInDxil = false; // OPT_Qkeep_reflect_in_dxil
|
||||
bool StripReflectionFromDxil = false; // OPT_Qstrip_reflect_from_dxil
|
||||
bool ExtractRootSignature = false; // OPT_extractrootsignature
|
||||
bool DisassembleColorCoded = false; // OPT_Cc
|
||||
bool DisassembleInstNumbers = false; // OPT_Ni
|
||||
bool DisassembleByteOffset = false; // OPT_No
|
||||
bool DisaseembleHex = false; // OPT_Lx
|
||||
bool LegacyMacroExpansion = false; // OPT_flegacy_macro_expansion
|
||||
bool LegacyResourceReservation = false; // OPT_flegacy_resource_reservation
|
||||
unsigned long AutoBindingSpace = UINT_MAX; // OPT_auto_binding_space
|
||||
bool ExportShadersOnly = false; // OPT_export_shaders_only
|
||||
bool ResMayAlias = false; // OPT_res_may_alias
|
||||
unsigned long ValVerMajor = UINT_MAX, ValVerMinor = UINT_MAX; // OPT_validator_version
|
||||
unsigned ScanLimit = 0; // OPT_memdep_block_scan_limit
|
||||
bool ExportShadersOnly = false; // OPT_export_shaders_only
|
||||
bool ResMayAlias = false; // OPT_res_may_alias
|
||||
unsigned long ValVerMajor = UINT_MAX,
|
||||
ValVerMinor = UINT_MAX; // OPT_validator_version
|
||||
unsigned ScanLimit = 0; // OPT_memdep_block_scan_limit
|
||||
bool ForceZeroStoreLifetimes = false; // OPT_force_zero_store_lifetimes
|
||||
bool EnableLifetimeMarkers = false; // OPT_enable_lifetime_markers
|
||||
bool EnableLifetimeMarkers = false; // OPT_enable_lifetime_markers
|
||||
bool ForceDisableLocTracking = false; // OPT_fdisable_loc_tracking
|
||||
bool NewInlining = false; // OPT_fnew_inlining_behavior
|
||||
bool TimeReport = false; // OPT_ftime_report
|
||||
std::string TimeTrace = ""; // OPT_ftime_trace[EQ]
|
||||
bool VerifyDiagnostics = false; // OPT_verify
|
||||
bool NewInlining = false; // OPT_fnew_inlining_behavior
|
||||
bool TimeReport = false; // OPT_ftime_report
|
||||
std::string TimeTrace = ""; // OPT_ftime_trace[EQ]
|
||||
bool VerifyDiagnostics = false; // OPT_verify
|
||||
|
||||
// Optimization pass enables, disables and selects
|
||||
OptimizationToggles OptToggles; // OPT_opt_enable, OPT_opt_disable, OPT_opt_select
|
||||
OptimizationToggles
|
||||
OptToggles; // OPT_opt_enable, OPT_opt_disable, OPT_opt_select
|
||||
|
||||
std::set<std::string> IgnoreSemDefs; // OPT_ignore_semdef
|
||||
std::set<std::string> IgnoreSemDefs; // OPT_ignore_semdef
|
||||
std::map<std::string, std::string> OverrideSemDefs; // OPT_override_semdef
|
||||
|
||||
bool PrintBeforeAll; // OPT_print_before_all
|
||||
std::set<std::string> PrintBefore; // OPT_print_before
|
||||
bool PrintAfterAll; // OPT_print_after_all
|
||||
std::set<std::string> PrintAfter; // OPT_print_after
|
||||
bool PrintBeforeAll; // OPT_print_before_all
|
||||
std::set<std::string> PrintBefore; // OPT_print_before
|
||||
bool PrintAfterAll; // OPT_print_after_all
|
||||
std::set<std::string> PrintAfter; // OPT_print_after
|
||||
bool EnablePayloadQualifiers = false; // OPT_enable_payload_qualifiers
|
||||
bool HandleExceptions = false; // OPT_disable_exception_handling
|
||||
bool HandleExceptions = false; // OPT_disable_exception_handling
|
||||
|
||||
// Rewriter Options
|
||||
RewriterOpts RWOpt;
|
||||
|
@ -250,8 +259,9 @@ public:
|
|||
|
||||
// SPIRV Change Starts
|
||||
#ifdef ENABLE_SPIRV_CODEGEN
|
||||
bool GenSPIRV; // OPT_spirv
|
||||
clang::spirv::SpirvCodeGenOptions SpirvOptions; // All SPIR-V CodeGen-related options
|
||||
bool GenSPIRV; // OPT_spirv
|
||||
clang::spirv::SpirvCodeGenOptions
|
||||
SpirvOptions; // All SPIR-V CodeGen-related options
|
||||
#endif
|
||||
// SPIRV Change Ends
|
||||
};
|
||||
|
@ -267,14 +277,15 @@ public:
|
|||
MainArgs(int argc, const wchar_t **argv, int skipArgCount = 1);
|
||||
MainArgs(int argc, const char **argv, int skipArgCount = 1);
|
||||
MainArgs(llvm::ArrayRef<llvm::StringRef> args);
|
||||
MainArgs& operator=(const MainArgs &other);
|
||||
MainArgs &operator=(const MainArgs &other);
|
||||
llvm::ArrayRef<const char *> getArrayRef() const {
|
||||
return llvm::ArrayRef<const char *>(Utf8CharPtrVector.data(),
|
||||
Utf8CharPtrVector.size());
|
||||
Utf8CharPtrVector.size());
|
||||
}
|
||||
};
|
||||
|
||||
/// Use this class to convert a StringRef into a wstring, handling empty values as nulls.
|
||||
/// Use this class to convert a StringRef into a wstring, handling empty values
|
||||
/// as nulls.
|
||||
class StringRefWide {
|
||||
private:
|
||||
std::wstring m_value;
|
||||
|
@ -300,7 +311,7 @@ void CopyArgsToWStrings(const llvm::opt::InputArgList &inArgs,
|
|||
|
||||
SerializeDxilFlags ComputeSerializeDxilFlags(const options::DxcOpts &opts);
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace options
|
||||
} // namespace hlsl
|
||||
|
||||
#endif
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
|
||||
namespace hlsl {
|
||||
|
||||
// This Updates to this enum must be reflected in HLSLOptions.td and Options.td
|
||||
// for the hlsl_version option.
|
||||
enum class LangStd : unsigned long {
|
||||
// This Updates to this enum must be reflected in HLSLOptions.td and Options.td
|
||||
// for the hlsl_version option.
|
||||
enum class LangStd : unsigned long {
|
||||
vUnset = 0,
|
||||
vError = 1,
|
||||
v2015 = 2015,
|
||||
|
|
|
@ -33,11 +33,19 @@ int WideCharToMultiByte(uint32_t CodePage, uint32_t dwFlags,
|
|||
bool *lpUsedDefaultChar = nullptr);
|
||||
#endif // _WIN32
|
||||
|
||||
namespace Unicode
|
||||
{
|
||||
namespace Unicode {
|
||||
|
||||
// Based on http://msdn.microsoft.com/en-us/library/windows/desktop/dd374101(v=vs.85).aspx.
|
||||
enum class Encoding { ASCII = 0, UTF8, UTF8_BOM, UTF16_LE, UTF16_BE, UTF32_LE, UTF32_BE };
|
||||
// Based on
|
||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/dd374101(v=vs.85).aspx.
|
||||
enum class Encoding {
|
||||
ASCII = 0,
|
||||
UTF8,
|
||||
UTF8_BOM,
|
||||
UTF16_LE,
|
||||
UTF16_BE,
|
||||
UTF32_LE,
|
||||
UTF32_BE
|
||||
};
|
||||
|
||||
// An acp_char is a character encoded in the current Windows ANSI code page.
|
||||
typedef char acp_char;
|
||||
|
@ -79,4 +87,4 @@ bool UTF8BufferToWideBuffer(const char *pUTF8, int cbUTF8, wchar_t **ppWide,
|
|||
bool WideBufferToUTF8Buffer(const wchar_t *pWide, int cchWide, char **ppUTF8,
|
||||
size_t *pcbUTF8) throw();
|
||||
|
||||
} // namespace Unicode
|
||||
} // namespace Unicode
|
||||
|
|
|
@ -30,7 +30,7 @@ int _stricmp(const char *str1, const char *str2);
|
|||
int _wcsicmp(const wchar_t *str1, const wchar_t *str2);
|
||||
int _wcsnicmp(const wchar_t *str1, const wchar_t *str2, size_t n);
|
||||
int wsprintf(wchar_t *wcs, const wchar_t *fmt, ...);
|
||||
unsigned char _BitScanForward(unsigned long * Index, unsigned long Mask);
|
||||
unsigned char _BitScanForward(unsigned long *Index, unsigned long Mask);
|
||||
|
||||
HANDLE CreateFile2(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
|
||||
DWORD dwCreationDisposition, void *pCreateExParams);
|
||||
|
@ -49,7 +49,7 @@ BOOL WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
|
|||
BOOL CloseHandle(HANDLE hObject);
|
||||
|
||||
// Windows-specific heap functions
|
||||
HANDLE HeapCreate(DWORD flOptions, SIZE_T dwInitialSize , SIZE_T dwMaximumSize);
|
||||
HANDLE HeapCreate(DWORD flOptions, SIZE_T dwInitialSize, SIZE_T dwMaximumSize);
|
||||
BOOL HeapDestroy(HANDLE heap);
|
||||
LPVOID HeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T nBytes);
|
||||
LPVOID HeapReAlloc(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem, SIZE_T dwBytes);
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
// Require at least Windows 7 (Updated from XP)
|
||||
#define _WIN32_WINNT 0x0601
|
||||
#define _WIN32_IE 0x0800 // MinGW at it again.
|
||||
#define _WIN32_IE 0x0800 // MinGW at it again.
|
||||
|
||||
#define NOATOM 1
|
||||
#define NOGDICAPMASKS 1
|
||||
|
@ -40,12 +40,12 @@
|
|||
#define VC_EXTRALEAN 1
|
||||
#define NONAMELESSSTRUCT 1
|
||||
|
||||
#include <windows.h>
|
||||
#include <unknwn.h>
|
||||
#include <atlbase.h> // atlbase.h needs to come before strsafe.h
|
||||
#include <strsafe.h>
|
||||
#include <intsafe.h>
|
||||
#include <ObjIdl.h>
|
||||
#include <atlbase.h> // atlbase.h needs to come before strsafe.h
|
||||
#include <intsafe.h>
|
||||
#include <strsafe.h>
|
||||
#include <unknwn.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "dxc/config.h"
|
||||
|
||||
|
@ -67,48 +67,52 @@ template <class T> void swap(CComHeapPtr<T> &a, CComHeapPtr<T> &b) {
|
|||
|
||||
#ifdef __cplusplus
|
||||
// Define operator overloads to enable bit operations on enum values that are
|
||||
// used to define flags. Use DEFINE_ENUM_FLAG_OPERATORS(YOUR_TYPE) to enable these
|
||||
// operators on YOUR_TYPE.
|
||||
// used to define flags. Use DEFINE_ENUM_FLAG_OPERATORS(YOUR_TYPE) to enable
|
||||
// these operators on YOUR_TYPE.
|
||||
extern "C++" {
|
||||
template <size_t S>
|
||||
struct _ENUM_FLAG_INTEGER_FOR_SIZE;
|
||||
template <size_t S> struct _ENUM_FLAG_INTEGER_FOR_SIZE;
|
||||
|
||||
template <>
|
||||
struct _ENUM_FLAG_INTEGER_FOR_SIZE<1>
|
||||
{
|
||||
typedef int8_t type;
|
||||
};
|
||||
template <> struct _ENUM_FLAG_INTEGER_FOR_SIZE<1> { typedef int8_t type; };
|
||||
|
||||
template <>
|
||||
struct _ENUM_FLAG_INTEGER_FOR_SIZE<2>
|
||||
{
|
||||
typedef int16_t type;
|
||||
};
|
||||
template <> struct _ENUM_FLAG_INTEGER_FOR_SIZE<2> { typedef int16_t type; };
|
||||
|
||||
template <>
|
||||
struct _ENUM_FLAG_INTEGER_FOR_SIZE<4>
|
||||
{
|
||||
typedef int32_t type;
|
||||
};
|
||||
|
||||
// used as an approximation of std::underlying_type<T>
|
||||
template <class T>
|
||||
struct _ENUM_FLAG_SIZED_INTEGER
|
||||
{
|
||||
typedef typename _ENUM_FLAG_INTEGER_FOR_SIZE<sizeof(T)>::type type;
|
||||
};
|
||||
template <> struct _ENUM_FLAG_INTEGER_FOR_SIZE<4> { typedef int32_t type; };
|
||||
|
||||
// used as an approximation of std::underlying_type<T>
|
||||
template <class T> struct _ENUM_FLAG_SIZED_INTEGER {
|
||||
typedef typename _ENUM_FLAG_INTEGER_FOR_SIZE<sizeof(T)>::type type;
|
||||
};
|
||||
}
|
||||
#define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) \
|
||||
extern "C++" { \
|
||||
inline ENUMTYPE operator | (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a) | ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \
|
||||
inline ENUMTYPE &operator |= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type &)a) |= ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \
|
||||
inline ENUMTYPE operator & (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a) & ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \
|
||||
inline ENUMTYPE &operator &= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type &)a) &= ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \
|
||||
inline ENUMTYPE operator ~ (ENUMTYPE a) { return ENUMTYPE(~((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a)); } \
|
||||
inline ENUMTYPE operator ^ (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a) ^ ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \
|
||||
inline ENUMTYPE &operator ^= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type &)a) ^= ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \
|
||||
}
|
||||
#define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) \
|
||||
extern "C++" { \
|
||||
inline ENUMTYPE operator|(ENUMTYPE a, ENUMTYPE b) { \
|
||||
return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a) | \
|
||||
((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); \
|
||||
} \
|
||||
inline ENUMTYPE &operator|=(ENUMTYPE &a, ENUMTYPE b) { \
|
||||
return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type &)a) |= \
|
||||
((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); \
|
||||
} \
|
||||
inline ENUMTYPE operator&(ENUMTYPE a, ENUMTYPE b) { \
|
||||
return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a) & \
|
||||
((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); \
|
||||
} \
|
||||
inline ENUMTYPE &operator&=(ENUMTYPE &a, ENUMTYPE b) { \
|
||||
return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type &)a) &= \
|
||||
((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); \
|
||||
} \
|
||||
inline ENUMTYPE operator~(ENUMTYPE a) { \
|
||||
return ENUMTYPE(~((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a)); \
|
||||
} \
|
||||
inline ENUMTYPE operator^(ENUMTYPE a, ENUMTYPE b) { \
|
||||
return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a) ^ \
|
||||
((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); \
|
||||
} \
|
||||
inline ENUMTYPE &operator^=(ENUMTYPE &a, ENUMTYPE b) { \
|
||||
return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type &)a) ^= \
|
||||
((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
#define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) // NOP, C allows these operators.
|
||||
#endif
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -12,10 +12,10 @@
|
|||
#ifndef __DXCAPI_IMPL__
|
||||
#define __DXCAPI_IMPL__
|
||||
|
||||
#include "dxc/dxcapi.h"
|
||||
#include "dxc/Support/microcom.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "dxc/dxcapi.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
// Simple adaptor for IStream. Can probably do better.
|
||||
class raw_stream_ostream : public llvm::raw_ostream {
|
||||
|
@ -26,22 +26,23 @@ private:
|
|||
IFT(m_pStream->Write(Ptr, Size, &cbWritten));
|
||||
}
|
||||
uint64_t current_pos() const override { return m_pStream->GetPosition(); }
|
||||
|
||||
public:
|
||||
raw_stream_ostream(hlsl::AbstractMemoryStream* pStream) : m_pStream(pStream) { }
|
||||
~raw_stream_ostream() override {
|
||||
flush();
|
||||
}
|
||||
raw_stream_ostream(hlsl::AbstractMemoryStream *pStream)
|
||||
: m_pStream(pStream) {}
|
||||
~raw_stream_ostream() override { flush(); }
|
||||
};
|
||||
|
||||
namespace {
|
||||
HRESULT TranslateUtf8StringForOutput(LPCSTR pStr, SIZE_T size, UINT32 codePage,
|
||||
IDxcBlobEncoding **ppBlobEncoding) {
|
||||
CComPtr<IDxcBlobEncoding> pBlobEncoding;
|
||||
IFR(hlsl::DxcCreateBlobWithEncodingOnHeapCopy(pStr, size, DXC_CP_UTF8, &pBlobEncoding));
|
||||
IFR(hlsl::DxcCreateBlobWithEncodingOnHeapCopy(pStr, size, DXC_CP_UTF8,
|
||||
&pBlobEncoding));
|
||||
if (codePage == DXC_CP_WIDE) {
|
||||
CComPtr<IDxcBlobWide> pBlobWide;
|
||||
IFT(hlsl::DxcGetBlobAsWide(pBlobEncoding, nullptr, &pBlobWide))
|
||||
pBlobEncoding = pBlobWide;
|
||||
pBlobEncoding = pBlobWide;
|
||||
}
|
||||
*ppBlobEncoding = pBlobEncoding.Detach();
|
||||
return S_OK;
|
||||
|
@ -50,17 +51,19 @@ HRESULT TranslateUtf8StringForOutput(LPCSTR pStr, SIZE_T size, UINT32 codePage,
|
|||
HRESULT TranslateWideStringForOutput(LPCWSTR pStr, SIZE_T size, UINT32 codePage,
|
||||
IDxcBlobEncoding **ppBlobEncoding) {
|
||||
CComPtr<IDxcBlobEncoding> pBlobEncoding;
|
||||
IFR(hlsl::DxcCreateBlobWithEncodingOnHeapCopy(pStr, size, DXC_CP_WIDE, &pBlobEncoding));
|
||||
IFR(hlsl::DxcCreateBlobWithEncodingOnHeapCopy(pStr, size, DXC_CP_WIDE,
|
||||
&pBlobEncoding));
|
||||
if (codePage == DXC_CP_UTF8) {
|
||||
CComPtr<IDxcBlobUtf8> pBlobUtf8;
|
||||
IFT(hlsl::DxcGetBlobAsUtf8(pBlobEncoding, nullptr, &pBlobUtf8))
|
||||
pBlobEncoding = pBlobUtf8;
|
||||
pBlobEncoding = pBlobUtf8;
|
||||
}
|
||||
*ppBlobEncoding = pBlobEncoding.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT TranslateStringBlobForOutput(IDxcBlob *pBlob, UINT32 codePage, IDxcBlobEncoding **ppBlobEncoding) {
|
||||
HRESULT TranslateStringBlobForOutput(IDxcBlob *pBlob, UINT32 codePage,
|
||||
IDxcBlobEncoding **ppBlobEncoding) {
|
||||
CComPtr<IDxcBlobEncoding> pEncoding;
|
||||
IFR(pBlob->QueryInterface(&pEncoding));
|
||||
BOOL known;
|
||||
|
@ -68,18 +71,22 @@ HRESULT TranslateStringBlobForOutput(IDxcBlob *pBlob, UINT32 codePage, IDxcBlobE
|
|||
IFR(pEncoding->GetEncoding(&known, &inputCP));
|
||||
IFRBOOL(known, E_INVALIDARG);
|
||||
if (inputCP == DXC_CP_UTF8) {
|
||||
return TranslateUtf8StringForOutput((LPCSTR)pBlob->GetBufferPointer(), pBlob->GetBufferSize(), codePage, ppBlobEncoding);
|
||||
return TranslateUtf8StringForOutput((LPCSTR)pBlob->GetBufferPointer(),
|
||||
pBlob->GetBufferSize(), codePage,
|
||||
ppBlobEncoding);
|
||||
} else if (inputCP == DXC_CP_WIDE) {
|
||||
return TranslateWideStringForOutput((LPCWSTR)pBlob->GetBufferPointer(), pBlob->GetBufferSize(), codePage, ppBlobEncoding);
|
||||
return TranslateWideStringForOutput((LPCWSTR)pBlob->GetBufferPointer(),
|
||||
pBlob->GetBufferSize(), codePage,
|
||||
ppBlobEncoding);
|
||||
}
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
typedef enum DxcOutputType {
|
||||
DxcOutputType_None = 0,
|
||||
DxcOutputType_Blob = 1,
|
||||
DxcOutputType_Text = 2,
|
||||
DxcOutputType_None = 0,
|
||||
DxcOutputType_Blob = 1,
|
||||
DxcOutputType_Text = 2,
|
||||
|
||||
DxcOutputTypeForceDword = 0xFFFFFFFF
|
||||
} DxcOutputType;
|
||||
|
@ -129,9 +136,9 @@ struct DxcOutputObject {
|
|||
CComPtr<IDxcBlobEncoding> pEncoding;
|
||||
// If not blob encoding, assume utf-8 text
|
||||
if (FAILED(TranslateStringBlobForOutput(pBlob, codePage, &pEncoding)))
|
||||
IFR(TranslateUtf8StringForOutput(
|
||||
(LPCSTR)pBlob->GetBufferPointer(), pBlob->GetBufferSize(),
|
||||
codePage, &pEncoding));
|
||||
IFR(TranslateUtf8StringForOutput((LPCSTR)pBlob->GetBufferPointer(),
|
||||
pBlob->GetBufferSize(), codePage,
|
||||
&pEncoding));
|
||||
object = pEncoding;
|
||||
} else {
|
||||
object = pUnknown;
|
||||
|
@ -180,7 +187,8 @@ struct DxcOutputObject {
|
|||
return S_OK;
|
||||
CComPtr<IDxcBlobEncoding> pBlobEncoding;
|
||||
IFR(hlsl::DxcCreateBlobWithEncodingOnHeapCopy(
|
||||
pName, (wcslen(pName) + 1) * sizeof(wchar_t), DXC_CP_WIDE, &pBlobEncoding));
|
||||
pName, (wcslen(pName) + 1) * sizeof(wchar_t), DXC_CP_WIDE,
|
||||
&pBlobEncoding));
|
||||
return pBlobEncoding->QueryInterface(&name);
|
||||
}
|
||||
HRESULT SetName(LPCSTR pName) {
|
||||
|
@ -188,7 +196,8 @@ struct DxcOutputObject {
|
|||
if (!pName)
|
||||
return S_OK;
|
||||
CComPtr<IDxcBlobEncoding> pBlobEncoding;
|
||||
IFR(TranslateUtf8StringForOutput(pName, strlen(pName) + 1, DXC_CP_WIDE, &pBlobEncoding));
|
||||
IFR(TranslateUtf8StringForOutput(pName, strlen(pName) + 1, DXC_CP_WIDE,
|
||||
&pBlobEncoding));
|
||||
return pBlobEncoding->QueryInterface(&name);
|
||||
}
|
||||
HRESULT SetName(llvm::StringRef Name) {
|
||||
|
@ -196,7 +205,8 @@ struct DxcOutputObject {
|
|||
if (Name.empty())
|
||||
return S_OK;
|
||||
CComPtr<IDxcBlobEncoding> pBlobEncoding;
|
||||
IFR(TranslateUtf8StringForOutput(Name.data(), Name.size(), DXC_CP_WIDE, &pBlobEncoding));
|
||||
IFR(TranslateUtf8StringForOutput(Name.data(), Name.size(), DXC_CP_WIDE,
|
||||
&pBlobEncoding));
|
||||
return pBlobEncoding->QueryInterface(&name);
|
||||
}
|
||||
|
||||
|
@ -261,16 +271,18 @@ struct DxcOutputObject {
|
|||
return output;
|
||||
}
|
||||
|
||||
template<typename DataTy>
|
||||
static DxcOutputObject ErrorOutput(UINT32 codePage, DataTy pText, SIZE_T size) {
|
||||
template <typename DataTy>
|
||||
static DxcOutputObject ErrorOutput(UINT32 codePage, DataTy pText,
|
||||
SIZE_T size) {
|
||||
return StringOutput(DXC_OUT_ERRORS, codePage, pText, size, DxcOutNoName);
|
||||
}
|
||||
template<typename DataTy>
|
||||
template <typename DataTy>
|
||||
static DxcOutputObject ErrorOutput(UINT32 codePage, DataTy pText) {
|
||||
return StringOutput(DXC_OUT_ERRORS, codePage, pText, DxcOutNoName);
|
||||
}
|
||||
template<typename NameTy>
|
||||
static DxcOutputObject ObjectOutput(LPCVOID pData, SIZE_T size, NameTy pName) {
|
||||
template <typename NameTy>
|
||||
static DxcOutputObject ObjectOutput(LPCVOID pData, SIZE_T size,
|
||||
NameTy pName) {
|
||||
return DataOutput(DXC_OUT_OBJECT, pData, size, pName);
|
||||
}
|
||||
static DxcOutputObject ObjectOutput(LPCVOID pData, SIZE_T size) {
|
||||
|
@ -281,7 +293,7 @@ struct DxcOutputObject {
|
|||
struct DxcExtraOutputObject {
|
||||
CComPtr<IDxcBlobWide> pType; // Custom name to identify the object
|
||||
CComPtr<IDxcBlobWide> pName; // The file path for the output
|
||||
CComPtr<IUnknown> pObject; // The object itself
|
||||
CComPtr<IUnknown> pObject; // The object itself
|
||||
};
|
||||
|
||||
class DxcExtraOutputs : public IDxcExtraOutputs {
|
||||
|
@ -291,15 +303,13 @@ class DxcExtraOutputs : public IDxcExtraOutputs {
|
|||
UINT32 m_uCount = 0;
|
||||
|
||||
public:
|
||||
|
||||
DXC_MICROCOM_TM_ADDREF_RELEASE_IMPL()
|
||||
DXC_MICROCOM_TM_CTOR(DxcExtraOutputs)
|
||||
|
||||
~DxcExtraOutputs() {
|
||||
Clear();
|
||||
}
|
||||
~DxcExtraOutputs() { Clear(); }
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject) override {
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid,
|
||||
void **ppvObject) override {
|
||||
return DoBasicQueryInterface<IDxcExtraOutputs>(this, iid, ppvObject);
|
||||
}
|
||||
|
||||
|
@ -307,9 +317,7 @@ public:
|
|||
// IDxcExtraOutputs
|
||||
/////////////////////
|
||||
|
||||
UINT32 STDMETHODCALLTYPE GetOutputCount() override {
|
||||
return m_uCount;
|
||||
}
|
||||
UINT32 STDMETHODCALLTYPE GetOutputCount() override { return m_uCount; }
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetOutput(UINT32 uIndex, REFIID iid,
|
||||
void **ppvObject,
|
||||
|
@ -367,16 +375,19 @@ class DxcResult : public IDxcResult {
|
|||
private:
|
||||
DXC_MICROCOM_TM_REF_FIELDS()
|
||||
HRESULT m_status = S_OK;
|
||||
DxcOutputObject m_outputs[kNumDxcOutputTypes]; // indexed by DXC_OUT_KIND enum - 1
|
||||
DXC_OUT_KIND m_resultType = DXC_OUT_NONE; // result type for GetResult()
|
||||
UINT32 m_textEncoding = DXC_CP_UTF8; // encoding for text outputs
|
||||
DxcOutputObject
|
||||
m_outputs[kNumDxcOutputTypes]; // indexed by DXC_OUT_KIND enum - 1
|
||||
DXC_OUT_KIND m_resultType = DXC_OUT_NONE; // result type for GetResult()
|
||||
UINT32 m_textEncoding = DXC_CP_UTF8; // encoding for text outputs
|
||||
|
||||
public:
|
||||
DXC_MICROCOM_TM_ADDREF_RELEASE_IMPL()
|
||||
DXC_MICROCOM_TM_CTOR(DxcResult)
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject) override {
|
||||
return DoBasicQueryInterface<IDxcResult, IDxcOperationResult>(this, iid, ppvObject);
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid,
|
||||
void **ppvObject) override {
|
||||
return DoBasicQueryInterface<IDxcResult, IDxcOperationResult>(this, iid,
|
||||
ppvObject);
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
|
@ -460,16 +471,15 @@ public:
|
|||
}
|
||||
return DXC_OUT_NONE;
|
||||
}
|
||||
DXC_OUT_KIND PrimaryOutput() override {
|
||||
return m_resultType;
|
||||
}
|
||||
DXC_OUT_KIND PrimaryOutput() override { return m_resultType; }
|
||||
|
||||
/////////////////////
|
||||
// Internal Interface
|
||||
/////////////////////
|
||||
|
||||
HRESULT SetEncoding(UINT32 textEncoding) {
|
||||
if (textEncoding != DXC_CP_ACP && textEncoding != DXC_CP_UTF8 && textEncoding != DXC_CP_WIDE)
|
||||
if (textEncoding != DXC_CP_ACP && textEncoding != DXC_CP_UTF8 &&
|
||||
textEncoding != DXC_CP_WIDE)
|
||||
return E_INVALIDARG;
|
||||
m_textEncoding = textEncoding;
|
||||
return S_OK;
|
||||
|
@ -496,7 +506,8 @@ public:
|
|||
ClearOutput((DXC_OUT_KIND)(i));
|
||||
}
|
||||
|
||||
HRESULT SetStatusAndPrimaryResult(HRESULT status, DXC_OUT_KIND resultType = DXC_OUT_NONE) {
|
||||
HRESULT SetStatusAndPrimaryResult(HRESULT status,
|
||||
DXC_OUT_KIND resultType = DXC_OUT_NONE) {
|
||||
if ((unsigned)resultType > kNumDxcOutputTypes)
|
||||
return E_INVALIDARG;
|
||||
m_status = status;
|
||||
|
@ -506,7 +517,8 @@ public:
|
|||
|
||||
// Set output object and name for previously uninitialized entry
|
||||
HRESULT SetOutput(const DxcOutputObject &output) {
|
||||
if (output.kind <= DXC_OUT_NONE || (unsigned)output.kind > kNumDxcOutputTypes)
|
||||
if (output.kind <= DXC_OUT_NONE ||
|
||||
(unsigned)output.kind > kNumDxcOutputTypes)
|
||||
return E_INVALIDARG;
|
||||
if (!output.object)
|
||||
return E_INVALIDARG;
|
||||
|
@ -530,8 +542,9 @@ public:
|
|||
return S_OK;
|
||||
}
|
||||
// Set or overwrite output string object and set the kind
|
||||
template<typename StringTy>
|
||||
HRESULT SetOutputString(DXC_OUT_KIND kind, StringTy pString, size_t size = kAutoSize) {
|
||||
template <typename StringTy>
|
||||
HRESULT SetOutputString(DXC_OUT_KIND kind, StringTy pString,
|
||||
size_t size = kAutoSize) {
|
||||
if (kind <= DXC_OUT_NONE || (unsigned)kind > kNumDxcOutputTypes)
|
||||
return E_INVALIDARG;
|
||||
DxcOutputObject &output = m_outputs[(unsigned)kind - 1];
|
||||
|
@ -543,7 +556,7 @@ public:
|
|||
}
|
||||
// Set or overwrite the output name. This does not set kind,
|
||||
// since that indicates an active output, which must have an object.
|
||||
template<typename NameTy>
|
||||
template <typename NameTy>
|
||||
HRESULT SetOutputName(DXC_OUT_KIND kind, NameTy Name) {
|
||||
if (kind <= DXC_OUT_NONE || (unsigned)kind > kNumDxcOutputTypes)
|
||||
return E_INVALIDARG;
|
||||
|
@ -569,7 +582,8 @@ public:
|
|||
DxcOutputObject &output = m_outputs[i];
|
||||
DXC_OUT_KIND kind = (DXC_OUT_KIND)(i + 1);
|
||||
if (pResult->HasOutput(kind)) {
|
||||
IFR(pResult->GetOutput(kind, IID_PPV_ARGS(&output.object), &output.name));
|
||||
IFR(pResult->GetOutput(kind, IID_PPV_ARGS(&output.object),
|
||||
&output.name));
|
||||
output.kind = kind;
|
||||
}
|
||||
}
|
||||
|
@ -590,10 +604,10 @@ public:
|
|||
const DxcOutputObject *pOutputs, unsigned numOutputs,
|
||||
IDxcResult **ppResult) {
|
||||
*ppResult = nullptr;
|
||||
CComPtr<DxcResult> result =
|
||||
DxcResult::Alloc(DxcGetThreadMallocNoRef());
|
||||
CComPtr<DxcResult> result = DxcResult::Alloc(DxcGetThreadMallocNoRef());
|
||||
IFROOM(result.p);
|
||||
IFR(result->Init(status, resultType, llvm::ArrayRef<DxcOutputObject>(pOutputs, numOutputs)));
|
||||
IFR(result->Init(status, resultType,
|
||||
llvm::ArrayRef<DxcOutputObject>(pOutputs, numOutputs)));
|
||||
*ppResult = result.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
|
||||
namespace dxc {
|
||||
|
||||
extern const char* kDxCompilerLib;
|
||||
extern const char* kDxilLib;
|
||||
extern const char *kDxCompilerLib;
|
||||
extern const char *kDxilLib;
|
||||
|
||||
// Helper class to dynamically load the dxcompiler or a compatible libraries.
|
||||
class DxcDllSupport {
|
||||
|
@ -27,13 +27,15 @@ protected:
|
|||
DxcCreateInstance2Proc m_createFn2;
|
||||
|
||||
HRESULT InitializeInternal(LPCSTR dllName, LPCSTR fnName) {
|
||||
if (m_dll != nullptr) return S_OK;
|
||||
if (m_dll != nullptr)
|
||||
return S_OK;
|
||||
|
||||
#ifdef _WIN32
|
||||
m_dll = LoadLibraryA(dllName);
|
||||
if (m_dll == nullptr) return HRESULT_FROM_WIN32(GetLastError());
|
||||
if (m_dll == nullptr)
|
||||
return HRESULT_FROM_WIN32(GetLastError());
|
||||
m_createFn = (DxcCreateInstanceProc)GetProcAddress(m_dll, fnName);
|
||||
|
||||
|
||||
if (m_createFn == nullptr) {
|
||||
HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
|
||||
FreeLibrary(m_dll);
|
||||
|
@ -42,9 +44,10 @@ protected:
|
|||
}
|
||||
#else
|
||||
m_dll = ::dlopen(dllName, RTLD_LAZY);
|
||||
if (m_dll == nullptr) return E_FAIL;
|
||||
if (m_dll == nullptr)
|
||||
return E_FAIL;
|
||||
m_createFn = (DxcCreateInstanceProc)::dlsym(m_dll, fnName);
|
||||
|
||||
|
||||
if (m_createFn == nullptr) {
|
||||
::dlclose(m_dll);
|
||||
m_dll = nullptr;
|
||||
|
@ -71,18 +74,18 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
DxcDllSupport() : m_dll(nullptr), m_createFn(nullptr), m_createFn2(nullptr) {
|
||||
DxcDllSupport() : m_dll(nullptr), m_createFn(nullptr), m_createFn2(nullptr) {}
|
||||
|
||||
DxcDllSupport(DxcDllSupport &&other) {
|
||||
m_dll = other.m_dll;
|
||||
other.m_dll = nullptr;
|
||||
m_createFn = other.m_createFn;
|
||||
other.m_createFn = nullptr;
|
||||
m_createFn2 = other.m_createFn2;
|
||||
other.m_createFn2 = nullptr;
|
||||
}
|
||||
|
||||
DxcDllSupport(DxcDllSupport&& other) {
|
||||
m_dll = other.m_dll; other.m_dll = nullptr;
|
||||
m_createFn = other.m_createFn; other.m_createFn = nullptr;
|
||||
m_createFn2 = other.m_createFn2; other.m_createFn2 = nullptr;
|
||||
}
|
||||
|
||||
~DxcDllSupport() {
|
||||
Cleanup();
|
||||
}
|
||||
~DxcDllSupport() { Cleanup(); }
|
||||
|
||||
HRESULT Initialize() {
|
||||
return InitializeInternal(kDxCompilerLib, "DxcCreateInstance");
|
||||
|
@ -94,38 +97,40 @@ public:
|
|||
|
||||
template <typename TInterface>
|
||||
HRESULT CreateInstance(REFCLSID clsid, TInterface **pResult) {
|
||||
return CreateInstance(clsid, __uuidof(TInterface), (IUnknown**)pResult);
|
||||
return CreateInstance(clsid, __uuidof(TInterface), (IUnknown **)pResult);
|
||||
}
|
||||
|
||||
HRESULT CreateInstance(REFCLSID clsid, REFIID riid, IUnknown **pResult) {
|
||||
if (pResult == nullptr) return E_POINTER;
|
||||
if (m_dll == nullptr) return E_FAIL;
|
||||
HRESULT hr = m_createFn(clsid, riid, (LPVOID*)pResult);
|
||||
if (pResult == nullptr)
|
||||
return E_POINTER;
|
||||
if (m_dll == nullptr)
|
||||
return E_FAIL;
|
||||
HRESULT hr = m_createFn(clsid, riid, (LPVOID *)pResult);
|
||||
return hr;
|
||||
}
|
||||
|
||||
template <typename TInterface>
|
||||
HRESULT CreateInstance2(IMalloc *pMalloc, REFCLSID clsid,
|
||||
TInterface **pResult) {
|
||||
return CreateInstance2(pMalloc, clsid, __uuidof(TInterface), (IUnknown**)pResult);
|
||||
return CreateInstance2(pMalloc, clsid, __uuidof(TInterface),
|
||||
(IUnknown **)pResult);
|
||||
}
|
||||
|
||||
HRESULT CreateInstance2(IMalloc *pMalloc, REFCLSID clsid, REFIID riid,
|
||||
IUnknown **pResult) {
|
||||
if (pResult == nullptr) return E_POINTER;
|
||||
if (m_dll == nullptr) return E_FAIL;
|
||||
if (m_createFn2 == nullptr) return E_FAIL;
|
||||
HRESULT hr = m_createFn2(pMalloc, clsid, riid, (LPVOID*)pResult);
|
||||
if (pResult == nullptr)
|
||||
return E_POINTER;
|
||||
if (m_dll == nullptr)
|
||||
return E_FAIL;
|
||||
if (m_createFn2 == nullptr)
|
||||
return E_FAIL;
|
||||
HRESULT hr = m_createFn2(pMalloc, clsid, riid, (LPVOID *)pResult);
|
||||
return hr;
|
||||
}
|
||||
|
||||
bool HasCreateWithMalloc() const {
|
||||
return m_createFn2 != nullptr;
|
||||
}
|
||||
bool HasCreateWithMalloc() const { return m_createFn2 != nullptr; }
|
||||
|
||||
bool IsEnabled() const {
|
||||
return m_dll != nullptr;
|
||||
}
|
||||
bool IsEnabled() const { return m_dll != nullptr; }
|
||||
|
||||
void Cleanup() {
|
||||
if (m_dll != nullptr) {
|
||||
|
|
|
@ -28,8 +28,6 @@ class MSFileSystem;
|
|||
} // namespace sys
|
||||
} // namespace llvm
|
||||
|
||||
|
||||
|
||||
namespace dxcutil {
|
||||
|
||||
class DxcArgsFileSystem : public ::llvm::sys::fs::MSFileSystem {
|
||||
|
|
|
@ -15,25 +15,24 @@
|
|||
#include <exception>
|
||||
#include <string>
|
||||
|
||||
namespace hlsl
|
||||
{
|
||||
namespace hlsl {
|
||||
|
||||
/// <summary>
|
||||
/// Exception stores off information about an error and its error message for
|
||||
/// later consumption by the hlsl compiler tools.
|
||||
/// </summary>
|
||||
struct Exception : public std::exception
|
||||
{
|
||||
struct Exception : public std::exception {
|
||||
/// <summary>HRESULT error code. Must be a failure.</summary>
|
||||
HRESULT hr;
|
||||
std::string msg;
|
||||
|
||||
Exception(HRESULT errCode) : hr(errCode) { }
|
||||
Exception(HRESULT errCode, const std::string &errMsg) : hr(errCode), msg(errMsg) { }
|
||||
Exception(HRESULT errCode) : hr(errCode) {}
|
||||
Exception(HRESULT errCode, const std::string &errMsg)
|
||||
: hr(errCode), msg(errMsg) {}
|
||||
|
||||
// what returns a formatted message with the error code and the message used
|
||||
// to create the message.
|
||||
virtual const char *what() const throw() { return msg.c_str(); }
|
||||
};
|
||||
|
||||
} // namespace hlsl
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -16,26 +16,20 @@
|
|||
#include "llvm/Support/Atomic.h"
|
||||
#include <atomic>
|
||||
|
||||
template <typename TIface>
|
||||
class CComInterfaceArray {
|
||||
template <typename TIface> class CComInterfaceArray {
|
||||
private:
|
||||
TIface **m_pData;
|
||||
unsigned m_length;
|
||||
|
||||
public:
|
||||
CComInterfaceArray() : m_pData(nullptr), m_length(0) { }
|
||||
~CComInterfaceArray() {
|
||||
clear();
|
||||
}
|
||||
CComInterfaceArray() : m_pData(nullptr), m_length(0) {}
|
||||
~CComInterfaceArray() { clear(); }
|
||||
bool empty() const { return m_length == 0; }
|
||||
unsigned size() const { return m_length; }
|
||||
TIface ***data_ref() { return &m_pData; }
|
||||
unsigned *size_ref() { return &m_length; }
|
||||
TIface **begin() {
|
||||
return m_pData;
|
||||
}
|
||||
TIface **end() {
|
||||
return m_pData + m_length;
|
||||
}
|
||||
TIface **begin() { return m_pData; }
|
||||
TIface **end() { return m_pData + m_length; }
|
||||
void clear() {
|
||||
if (m_length) {
|
||||
for (unsigned i = 0; i < m_length; ++i) {
|
||||
|
@ -53,16 +47,14 @@ public:
|
|||
}
|
||||
HRESULT alloc(unsigned count) {
|
||||
clear();
|
||||
m_pData = (TIface**)CoTaskMemAlloc(sizeof(TIface*) * count);
|
||||
m_pData = (TIface **)CoTaskMemAlloc(sizeof(TIface *) * count);
|
||||
if (m_pData == nullptr)
|
||||
return E_OUTOFMEMORY;
|
||||
m_length = count;
|
||||
ZeroMemory(m_pData, sizeof(TIface*) * count);
|
||||
ZeroMemory(m_pData, sizeof(TIface *) * count);
|
||||
return S_OK;
|
||||
}
|
||||
TIface **get_address_of(unsigned index) {
|
||||
return &(m_pData[index]);
|
||||
}
|
||||
TIface **get_address_of(unsigned index) { return &(m_pData[index]); }
|
||||
TIface **release() {
|
||||
TIface **result = m_pData;
|
||||
m_pData = nullptr;
|
||||
|
@ -77,17 +69,12 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
void DxcCallDestructor(T *obj) {
|
||||
obj->T::~T();
|
||||
}
|
||||
template <typename T> void DxcCallDestructor(T *obj) { obj->T::~T(); }
|
||||
|
||||
#define DXC_MICROCOM_REF_FIELD(m_dwRef) \
|
||||
volatile std::atomic<llvm::sys::cas_flag> m_dwRef = {0};
|
||||
#define DXC_MICROCOM_ADDREF_IMPL(m_dwRef) \
|
||||
ULONG STDMETHODCALLTYPE AddRef() override { \
|
||||
return (ULONG)++m_dwRef; \
|
||||
}
|
||||
ULONG STDMETHODCALLTYPE AddRef() override { return (ULONG)++m_dwRef; }
|
||||
#define DXC_MICROCOM_ADDREF_RELEASE_IMPL(m_dwRef) \
|
||||
DXC_MICROCOM_ADDREF_IMPL(m_dwRef) \
|
||||
ULONG STDMETHODCALLTYPE Release() override { \
|
||||
|
@ -100,10 +87,15 @@ void DxcCallDestructor(T *obj) {
|
|||
}
|
||||
|
||||
template <typename T, typename... Args>
|
||||
inline T *CreateOnMalloc(IMalloc * pMalloc, Args&&... args) {
|
||||
inline T *CreateOnMalloc(IMalloc *pMalloc, Args &&...args) {
|
||||
void *P = pMalloc->Alloc(sizeof(T));
|
||||
try { if (P) new (P)T(pMalloc, std::forward<Args>(args)...); }
|
||||
catch (...) { pMalloc->Free(P); throw; }
|
||||
try {
|
||||
if (P)
|
||||
new (P) T(pMalloc, std::forward<Args>(args)...);
|
||||
} catch (...) {
|
||||
pMalloc->Free(P);
|
||||
throw;
|
||||
}
|
||||
return (T *)P;
|
||||
}
|
||||
|
||||
|
@ -133,7 +125,7 @@ inline T *CreateOnMalloc(IMalloc * pMalloc, Args&&... args) {
|
|||
T(IMalloc *pMalloc) : m_dwRef(0), m_pMalloc(pMalloc) {}
|
||||
#define DXC_MICROCOM_TM_ALLOC(T) \
|
||||
template <typename... Args> \
|
||||
static T *Alloc(IMalloc *pMalloc, Args &&... args) { \
|
||||
static T *Alloc(IMalloc *pMalloc, Args &&...args) { \
|
||||
void *P = pMalloc->Alloc(sizeof(T)); \
|
||||
try { \
|
||||
if (P) \
|
||||
|
@ -154,29 +146,33 @@ inline T *CreateOnMalloc(IMalloc * pMalloc, Args&&... args) {
|
|||
/// marshaling. This will help catch marshaling problems early or avoid
|
||||
/// them altogether.
|
||||
/// </remarks>
|
||||
template<typename TObject>
|
||||
HRESULT DoBasicQueryInterface_recurse(TObject* self, REFIID iid, void** ppvObject) {
|
||||
template <typename TObject>
|
||||
HRESULT DoBasicQueryInterface_recurse(TObject *self, REFIID iid,
|
||||
void **ppvObject) {
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
template<typename TObject, typename TInterface, typename... Ts>
|
||||
HRESULT DoBasicQueryInterface_recurse(TObject* self, REFIID iid, void** ppvObject) {
|
||||
if (ppvObject == nullptr) return E_POINTER;
|
||||
template <typename TObject, typename TInterface, typename... Ts>
|
||||
HRESULT DoBasicQueryInterface_recurse(TObject *self, REFIID iid,
|
||||
void **ppvObject) {
|
||||
if (ppvObject == nullptr)
|
||||
return E_POINTER;
|
||||
if (IsEqualIID(iid, __uuidof(TInterface))) {
|
||||
*(TInterface**)ppvObject = self;
|
||||
*(TInterface **)ppvObject = self;
|
||||
self->AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
return DoBasicQueryInterface_recurse<TObject, Ts...>(self, iid, ppvObject);
|
||||
}
|
||||
template<typename... Ts, typename TObject>
|
||||
HRESULT DoBasicQueryInterface(TObject* self, REFIID iid, void** ppvObject) {
|
||||
if (ppvObject == nullptr) return E_POINTER;
|
||||
template <typename... Ts, typename TObject>
|
||||
HRESULT DoBasicQueryInterface(TObject *self, REFIID iid, void **ppvObject) {
|
||||
if (ppvObject == nullptr)
|
||||
return E_POINTER;
|
||||
|
||||
// Support INoMarshal to void GIT shenanigans.
|
||||
if (IsEqualIID(iid, __uuidof(IUnknown)) ||
|
||||
IsEqualIID(iid, __uuidof(INoMarshal))) {
|
||||
*ppvObject = reinterpret_cast<IUnknown*>(self);
|
||||
reinterpret_cast<IUnknown*>(self)->AddRef();
|
||||
IsEqualIID(iid, __uuidof(INoMarshal))) {
|
||||
*ppvObject = reinterpret_cast<IUnknown *>(self);
|
||||
reinterpret_cast<IUnknown *>(self)->AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,21 +10,21 @@
|
|||
// //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "dxc/Support/WinIncludes.h"
|
||||
#include "dxc/Support/microcom.h"
|
||||
|
||||
#include "dxc/Support/dxcapi.use.h"
|
||||
#include "dxc/dxcapi.h"
|
||||
#include "dxc/dxcisense.h"
|
||||
#include "dxc/Support/dxcapi.use.h"
|
||||
#include "llvm/Support/Atomic.h"
|
||||
|
||||
inline HRESULT IFE(HRESULT hr) {
|
||||
|
@ -50,55 +50,52 @@ inline HRESULT GetFirstChildFromCursor(IDxcCursor *cursor,
|
|||
return hr;
|
||||
}
|
||||
|
||||
class TrivialDxcUnsavedFile : public IDxcUnsavedFile
|
||||
{
|
||||
class TrivialDxcUnsavedFile : public IDxcUnsavedFile {
|
||||
private:
|
||||
DXC_MICROCOM_REF_FIELD(m_dwRef)
|
||||
LPCSTR m_fileName;
|
||||
LPCSTR m_contents;
|
||||
unsigned m_length;
|
||||
|
||||
public:
|
||||
DXC_MICROCOM_ADDREF_RELEASE_IMPL(m_dwRef)
|
||||
TrivialDxcUnsavedFile(LPCSTR fileName, LPCSTR contents)
|
||||
: m_dwRef(0), m_fileName(fileName), m_contents(contents)
|
||||
{
|
||||
: m_dwRef(0), m_fileName(fileName), m_contents(contents) {
|
||||
m_length = (unsigned)strlen(m_contents);
|
||||
}
|
||||
|
||||
static HRESULT Create(LPCSTR fileName, LPCSTR contents, IDxcUnsavedFile** pResult)
|
||||
{
|
||||
CComPtr<TrivialDxcUnsavedFile> pNewValue = new TrivialDxcUnsavedFile(fileName, contents);
|
||||
static HRESULT Create(LPCSTR fileName, LPCSTR contents,
|
||||
IDxcUnsavedFile **pResult) {
|
||||
CComPtr<TrivialDxcUnsavedFile> pNewValue =
|
||||
new TrivialDxcUnsavedFile(fileName, contents);
|
||||
return pNewValue.QueryInterface(pResult);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void** ppvObject) override
|
||||
{
|
||||
if (ppvObject == nullptr) return E_POINTER;
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid,
|
||||
void **ppvObject) override {
|
||||
if (ppvObject == nullptr)
|
||||
return E_POINTER;
|
||||
if (IsEqualIID(iid, __uuidof(IUnknown)) ||
|
||||
IsEqualIID(iid, __uuidof(INoMarshal)) ||
|
||||
IsEqualIID(iid, __uuidof(IDxcUnsavedFile)))
|
||||
{
|
||||
*ppvObject = reinterpret_cast<IDxcUnsavedFile*>(this);
|
||||
reinterpret_cast<IDxcUnsavedFile*>(this)->AddRef();
|
||||
IsEqualIID(iid, __uuidof(IDxcUnsavedFile))) {
|
||||
*ppvObject = reinterpret_cast<IDxcUnsavedFile *>(this);
|
||||
reinterpret_cast<IDxcUnsavedFile *>(this)->AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
HRESULT STDMETHODCALLTYPE GetFileName(LPSTR* pFileName) override
|
||||
{
|
||||
HRESULT STDMETHODCALLTYPE GetFileName(LPSTR *pFileName) override {
|
||||
*pFileName = (LPSTR)CoTaskMemAlloc(1 + strlen(m_fileName));
|
||||
strcpy(*pFileName, m_fileName);
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT STDMETHODCALLTYPE GetContents(LPSTR* pContents) override
|
||||
{
|
||||
HRESULT STDMETHODCALLTYPE GetContents(LPSTR *pContents) override {
|
||||
*pContents = (LPSTR)CoTaskMemAlloc(m_length + 1);
|
||||
memcpy(*pContents, m_contents, m_length + 1);
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT STDMETHODCALLTYPE GetLength(unsigned* pLength) override
|
||||
{
|
||||
HRESULT STDMETHODCALLTYPE GetLength(unsigned *pLength) override {
|
||||
*pLength = m_length;
|
||||
return S_OK;
|
||||
}
|
||||
|
@ -116,8 +113,7 @@ public:
|
|||
};
|
||||
|
||||
/// Summary of the results of a clang compilation operation.
|
||||
class CompilationResult
|
||||
{
|
||||
class CompilationResult {
|
||||
private:
|
||||
// Keep Intellisense alive.
|
||||
std::shared_ptr<HlslIntellisenseSupport> IsenseSupport;
|
||||
|
@ -140,16 +136,14 @@ private:
|
|||
std::vector<DxcDiagnosticSeverity> DiagnosticSeverities;
|
||||
|
||||
// Hide the copy constructor.
|
||||
CompilationResult(const CompilationResult&);
|
||||
CompilationResult(const CompilationResult &);
|
||||
|
||||
public:
|
||||
CompilationResult(std::shared_ptr<HlslIntellisenseSupport> support, IDxcIntelliSense* isense, IDxcIndex* index, IDxcTranslationUnit* tu) :
|
||||
IsenseSupport(support),
|
||||
Intellisense(isense),
|
||||
Index(index),
|
||||
NumErrorDiagnostics(0),
|
||||
TU(tu)
|
||||
{
|
||||
CompilationResult(std::shared_ptr<HlslIntellisenseSupport> support,
|
||||
IDxcIntelliSense *isense, IDxcIndex *index,
|
||||
IDxcTranslationUnit *tu)
|
||||
: IsenseSupport(support), Intellisense(isense), Index(index),
|
||||
NumErrorDiagnostics(0), TU(tu) {
|
||||
if (tu) {
|
||||
IFE(tu->GetNumDiagnostics(&NumDiagnostics));
|
||||
} else {
|
||||
|
@ -175,17 +169,23 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
assert(NumErrorDiagnostics <= NumDiagnostics && "else counting code in loop is incorrect");
|
||||
assert(DiagnosticMessages.size() == NumDiagnostics && "else some diagnostics have no message");
|
||||
assert(DiagnosticSeverities.size() == NumDiagnostics && "else some diagnostics have no severity");
|
||||
assert(NumErrorDiagnostics <= NumDiagnostics &&
|
||||
"else counting code in loop is incorrect");
|
||||
assert(DiagnosticMessages.size() == NumDiagnostics &&
|
||||
"else some diagnostics have no message");
|
||||
assert(DiagnosticSeverities.size() == NumDiagnostics &&
|
||||
"else some diagnostics have no severity");
|
||||
}
|
||||
|
||||
CompilationResult(CompilationResult&& other) :
|
||||
IsenseSupport(std::move(other.IsenseSupport)) {
|
||||
|
||||
CompilationResult(CompilationResult &&other)
|
||||
: IsenseSupport(std::move(other.IsenseSupport)) {
|
||||
// Allow move constructor.
|
||||
Intellisense = other.Intellisense; other.Intellisense = nullptr;
|
||||
Index = other.Index; other.Index = nullptr;
|
||||
TU = other.TU; other.TU = nullptr;
|
||||
Intellisense = other.Intellisense;
|
||||
other.Intellisense = nullptr;
|
||||
Index = other.Index;
|
||||
other.Index = nullptr;
|
||||
TU = other.TU;
|
||||
other.TU = nullptr;
|
||||
NumDiagnostics = other.NumDiagnostics;
|
||||
NumErrorDiagnostics = other.NumErrorDiagnostics;
|
||||
DiagnosticMessages = std::move(other.DiagnosticMessages);
|
||||
|
@ -205,7 +205,8 @@ public:
|
|||
if (DefaultHlslSupport.get() != nullptr) {
|
||||
return DefaultHlslSupport;
|
||||
}
|
||||
std::shared_ptr<HlslIntellisenseSupport> result = std::make_shared<HlslIntellisenseSupport>();
|
||||
std::shared_ptr<HlslIntellisenseSupport> result =
|
||||
std::make_shared<HlslIntellisenseSupport>();
|
||||
IFE(result->Initialize());
|
||||
return result;
|
||||
}
|
||||
|
@ -222,7 +223,8 @@ public:
|
|||
CComPtr<IDxcIndex> tuIndex;
|
||||
CComPtr<IDxcTranslationUnit> tu;
|
||||
const char *fileName = getDefaultFileName();
|
||||
if (textLen == 0) textLen = strlen(text);
|
||||
if (textLen == 0)
|
||||
textLen = strlen(text);
|
||||
|
||||
IFE(isense->CreateIndex(&tuIndex));
|
||||
|
||||
|
@ -230,18 +232,15 @@ public:
|
|||
IFE(TrivialDxcUnsavedFile::Create(fileName, text, &unsavedFile));
|
||||
|
||||
DxcTranslationUnitFlags localOptions;
|
||||
if (options == nullptr)
|
||||
{
|
||||
if (options == nullptr) {
|
||||
IFE(isense->GetDefaultEditingTUOptions(&localOptions));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
localOptions = *options;
|
||||
}
|
||||
IFE(tuIndex->ParseTranslationUnit(fileName,
|
||||
commandLineArgs, commandLineArgsCount,
|
||||
&(unsavedFile.p), 1, localOptions, &tu));
|
||||
|
||||
IFE(tuIndex->ParseTranslationUnit(fileName, commandLineArgs,
|
||||
commandLineArgsCount, &(unsavedFile.p), 1,
|
||||
localOptions, &tu));
|
||||
|
||||
return CompilationResult(support, isense.p, tuIndex.p, tu.p);
|
||||
}
|
||||
|
||||
|
@ -254,19 +253,22 @@ public:
|
|||
commandLineArgsCount, options);
|
||||
}
|
||||
|
||||
static CompilationResult CreateForCommandLine(char* arguments, const char* fileName) {
|
||||
static CompilationResult CreateForCommandLine(char *arguments,
|
||||
const char *fileName) {
|
||||
std::shared_ptr<HlslIntellisenseSupport> support(GetHlslSupport());
|
||||
return CreateForCommandLine(arguments, fileName, support);
|
||||
}
|
||||
|
||||
static CompilationResult CreateForCommandLine(char* arguments, const char* fileName, std::shared_ptr<HlslIntellisenseSupport> support) {
|
||||
static CompilationResult
|
||||
CreateForCommandLine(char *arguments, const char *fileName,
|
||||
std::shared_ptr<HlslIntellisenseSupport> support) {
|
||||
CComPtr<IDxcIntelliSense> isense;
|
||||
IFE(support->CreateIntellisense(&isense));
|
||||
CComPtr<IDxcIndex> tuIndex;
|
||||
CComPtr<IDxcTranslationUnit> tu;
|
||||
const char* commandLineArgs[32];
|
||||
const char *commandLineArgs[32];
|
||||
unsigned commandLineArgsCount = 0;
|
||||
char* nextArg = arguments;
|
||||
char *nextArg = arguments;
|
||||
|
||||
// Set a very high number of errors to avoid giving up too early.
|
||||
commandLineArgs[commandLineArgsCount++] = "-ferror-limit=2000";
|
||||
|
@ -306,17 +308,20 @@ public:
|
|||
}
|
||||
|
||||
bool IsTUAvailable() const { return TU != nullptr; }
|
||||
bool ParseSucceeded() const { return TU != nullptr && NumErrorDiagnostics == 0; }
|
||||
bool ParseSucceeded() const {
|
||||
return TU != nullptr && NumErrorDiagnostics == 0;
|
||||
}
|
||||
|
||||
static bool IsErrorSeverity(DxcDiagnosticSeverity severity)
|
||||
{
|
||||
static bool IsErrorSeverity(DxcDiagnosticSeverity severity) {
|
||||
return (severity == DxcDiagnostic_Error || severity == DxcDiagnostic_Fatal);
|
||||
}
|
||||
|
||||
/// Gets a string with all error messages concatenated, one per line.
|
||||
std::string GetTextForErrors() const {
|
||||
assert(DiagnosticMessages.size() == NumDiagnostics && "otherwise some diagnostics have no message");
|
||||
assert(DiagnosticSeverities.size() == NumDiagnostics && "otherwise some diagnostics have no severity");
|
||||
assert(DiagnosticMessages.size() == NumDiagnostics &&
|
||||
"otherwise some diagnostics have no message");
|
||||
assert(DiagnosticSeverities.size() == NumDiagnostics &&
|
||||
"otherwise some diagnostics have no severity");
|
||||
|
||||
std::stringstream ostr;
|
||||
for (size_t i = 0; i < DiagnosticMessages.size(); i++) {
|
||||
|
@ -329,8 +334,7 @@ public:
|
|||
}
|
||||
|
||||
/// Releases resources, including the translation unit AST.
|
||||
void Dispose()
|
||||
{
|
||||
void Dispose() {
|
||||
TU = nullptr;
|
||||
Index = nullptr;
|
||||
Intellisense = nullptr;
|
||||
|
@ -345,24 +349,23 @@ private:
|
|||
CursorStringData(std::stringstream &the_ostr) : ostr(the_ostr) {}
|
||||
};
|
||||
|
||||
static
|
||||
CXChildVisitResult AppendCursorStringCallback(
|
||||
CXCursor cursor, CXCursor parent, CXClientData client_data)
|
||||
{
|
||||
CursorStringData* d = (CursorStringData*)client_data;
|
||||
static CXChildVisitResult
|
||||
AppendCursorStringCallback(CXCursor cursor, CXCursor parent,
|
||||
CXClientData client_data) {
|
||||
CursorStringData *d = (CursorStringData *)client_data;
|
||||
auto cursorsStart = std::begin(d->cursors);
|
||||
auto cursorsEnd = std::end(d->cursors);
|
||||
auto parentLocation = std::find(cursorsStart, cursorsEnd, parent);
|
||||
assert(parentLocation != cursorsEnd && "otherwise the parent was not visited previously");
|
||||
assert(parentLocation != cursorsEnd &&
|
||||
"otherwise the parent was not visited previously");
|
||||
AppendCursorString(cursor, parentLocation - cursorsStart, d->ostr);
|
||||
d->cursors.resize(1 + (parentLocation - cursorsStart));
|
||||
d->cursors.push_back(cursor);
|
||||
return CXChildVisit_Recurse;
|
||||
}
|
||||
#endif
|
||||
static
|
||||
void AppendCursorString(IDxcCursor* cursor, size_t indent, std::stringstream& ostr)
|
||||
{
|
||||
static void AppendCursorString(IDxcCursor *cursor, size_t indent,
|
||||
std::stringstream &ostr) {
|
||||
if (indent > 0) {
|
||||
std::streamsize prior = ostr.width();
|
||||
ostr.width(indent);
|
||||
|
@ -374,144 +377,415 @@ private:
|
|||
DxcCursorKind kind;
|
||||
cursor->GetKind(&kind);
|
||||
cursor->GetCursorType(&type);
|
||||
switch (kind)
|
||||
{
|
||||
case DxcCursor_UnexposedDecl: ostr << "UnexposedDecl"; break;
|
||||
case DxcCursor_StructDecl: ostr << "StructDecl"; break;
|
||||
case DxcCursor_UnionDecl: ostr << "UnionDecl"; break;
|
||||
case DxcCursor_ClassDecl: ostr << "ClassDecl"; break;
|
||||
case DxcCursor_EnumDecl: ostr << "EnumDecl"; break;
|
||||
case DxcCursor_FieldDecl: ostr << "FieldDecl"; break;
|
||||
case DxcCursor_EnumConstantDecl: ostr << "EnumConstantDecl"; break;
|
||||
case DxcCursor_FunctionDecl: ostr << "FunctionDecl"; break;
|
||||
case DxcCursor_VarDecl: ostr << "VarDecl"; break;
|
||||
case DxcCursor_ParmDecl: ostr << "ParmDecl"; break;
|
||||
case DxcCursor_ObjCInterfaceDecl: ostr << "ObjCInterfaceDecl"; break;
|
||||
case DxcCursor_ObjCCategoryDecl: ostr << "ObjCCategoryDecl"; break;
|
||||
case DxcCursor_ObjCProtocolDecl: ostr << "ObjCProtocolDecl"; break;
|
||||
case DxcCursor_ObjCPropertyDecl: ostr << "ObjCPropertyDecl"; break;
|
||||
case DxcCursor_ObjCIvarDecl: ostr << "ObjCIvarDecl"; break;
|
||||
case DxcCursor_ObjCInstanceMethodDecl: ostr << "ObjCInstanceMethodDecl"; break;
|
||||
case DxcCursor_ObjCClassMethodDecl: ostr << "ObjCClassMethodDecl"; break;
|
||||
case DxcCursor_ObjCImplementationDecl: ostr << "ObjCImplementationDecl"; break;
|
||||
case DxcCursor_ObjCCategoryImplDecl: ostr << "ObjCCategoryImplDecl"; break;
|
||||
case DxcCursor_TypedefDecl: ostr << "TypedefDecl"; break;
|
||||
case DxcCursor_CXXMethod: ostr << "CXXMethod"; break;
|
||||
case DxcCursor_Namespace: ostr << "Namespace"; break;
|
||||
case DxcCursor_LinkageSpec: ostr << "LinkageSpec"; break;
|
||||
case DxcCursor_Constructor: ostr << "Constructor"; break;
|
||||
case DxcCursor_Destructor: ostr << "Destructor"; break;
|
||||
case DxcCursor_ConversionFunction: ostr << "ConversionFunction"; break;
|
||||
case DxcCursor_TemplateTypeParameter: ostr << "TemplateTypeParameter"; break;
|
||||
case DxcCursor_NonTypeTemplateParameter: ostr << "NonTypeTemplateParameter"; break;
|
||||
case DxcCursor_TemplateTemplateParameter: ostr << "TemplateTemplateParameter"; break;
|
||||
case DxcCursor_FunctionTemplate: ostr << "FunctionTemplate"; break;
|
||||
case DxcCursor_ClassTemplate: ostr << "ClassTemplate"; break;
|
||||
case DxcCursor_ClassTemplatePartialSpecialization: ostr << "ClassTemplatePartialSpecialization"; break;
|
||||
case DxcCursor_NamespaceAlias: ostr << "NamespaceAlias"; break;
|
||||
case DxcCursor_UsingDirective: ostr << "UsingDirective"; break;
|
||||
case DxcCursor_UsingDeclaration: ostr << "UsingDeclaration"; break;
|
||||
case DxcCursor_TypeAliasDecl: ostr << "TypeAliasDecl"; break;
|
||||
case DxcCursor_ObjCSynthesizeDecl: ostr << "ObjCSynthesizeDecl"; break;
|
||||
case DxcCursor_ObjCDynamicDecl: ostr << "ObjCDynamicDecl"; break;
|
||||
case DxcCursor_CXXAccessSpecifier: ostr << "CXXAccessSpecifier"; break;
|
||||
case DxcCursor_ObjCSuperClassRef: ostr << "ObjCSuperClassRef"; break;
|
||||
case DxcCursor_ObjCProtocolRef: ostr << "ObjCProtocolRef"; break;
|
||||
case DxcCursor_ObjCClassRef: ostr << "ObjCClassRef"; break;
|
||||
case DxcCursor_TypeRef: ostr << "TypeRef"; break;
|
||||
case DxcCursor_CXXBaseSpecifier: ostr << "CXXBaseSpecifier"; break;
|
||||
case DxcCursor_TemplateRef: ostr << "TemplateRef"; break;
|
||||
case DxcCursor_NamespaceRef: ostr << "NamespaceRef"; break;
|
||||
case DxcCursor_MemberRef: ostr << "MemberRef"; break;
|
||||
case DxcCursor_LabelRef: ostr << "LabelRef"; break;
|
||||
case DxcCursor_OverloadedDeclRef: ostr << "OverloadedDeclRef"; break;
|
||||
case DxcCursor_VariableRef: ostr << "VariableRef"; break;
|
||||
case DxcCursor_InvalidFile: ostr << "InvalidFile"; break;
|
||||
case DxcCursor_NoDeclFound: ostr << "NoDeclFound"; break;
|
||||
case DxcCursor_NotImplemented: ostr << "NotImplemented"; break;
|
||||
case DxcCursor_InvalidCode: ostr << "InvalidCode"; break;
|
||||
case DxcCursor_UnexposedExpr: ostr << "UnexposedExpr"; break;
|
||||
case DxcCursor_DeclRefExpr: ostr << "DeclRefExpr"; break;
|
||||
case DxcCursor_MemberRefExpr: ostr << "MemberRefExpr"; break;
|
||||
case DxcCursor_CallExpr: ostr << "CallExpr"; break;
|
||||
case DxcCursor_ObjCMessageExpr: ostr << "ObjCMessageExpr"; break;
|
||||
case DxcCursor_BlockExpr: ostr << "BlockExpr"; break;
|
||||
case DxcCursor_IntegerLiteral: ostr << "IntegerLiteral"; break;
|
||||
case DxcCursor_FloatingLiteral: ostr << "FloatingLiteral"; break;
|
||||
case DxcCursor_ImaginaryLiteral: ostr << "ImaginaryLiteral"; break;
|
||||
case DxcCursor_StringLiteral: ostr << "StringLiteral"; break;
|
||||
case DxcCursor_CharacterLiteral: ostr << "CharacterLiteral"; break;
|
||||
case DxcCursor_ParenExpr: ostr << "ParenExpr"; break;
|
||||
case DxcCursor_UnaryOperator: ostr << "UnaryOperator"; break;
|
||||
case DxcCursor_ArraySubscriptExpr: ostr << "ArraySubscriptExpr"; break;
|
||||
case DxcCursor_BinaryOperator: ostr << "BinaryOperator"; break;
|
||||
case DxcCursor_CompoundAssignOperator: ostr << "CompoundAssignOperator"; break;
|
||||
case DxcCursor_ConditionalOperator: ostr << "ConditionalOperator"; break;
|
||||
case DxcCursor_CStyleCastExpr: ostr << "CStyleCastExpr"; break;
|
||||
case DxcCursor_CompoundLiteralExpr: ostr << "CompoundLiteralExpr"; break;
|
||||
case DxcCursor_InitListExpr: ostr << "InitListExpr"; break;
|
||||
case DxcCursor_AddrLabelExpr: ostr << "AddrLabelExpr"; break;
|
||||
case DxcCursor_StmtExpr: ostr << "StmtExpr"; break;
|
||||
case DxcCursor_GenericSelectionExpr: ostr << "GenericSelectionExpr"; break;
|
||||
case DxcCursor_GNUNullExpr: ostr << "GNUNullExpr"; break;
|
||||
case DxcCursor_CXXStaticCastExpr: ostr << "CXXStaticCastExpr"; break;
|
||||
case DxcCursor_CXXDynamicCastExpr: ostr << "CXXDynamicCastExpr"; break;
|
||||
case DxcCursor_CXXReinterpretCastExpr: ostr << "CXXReinterpretCastExpr"; break;
|
||||
case DxcCursor_CXXConstCastExpr: ostr << "CXXConstCastExpr"; break;
|
||||
case DxcCursor_CXXFunctionalCastExpr: ostr << "CXXFunctionalCastExpr"; break;
|
||||
case DxcCursor_CXXTypeidExpr: ostr << "CXXTypeidExpr"; break;
|
||||
case DxcCursor_CXXBoolLiteralExpr: ostr << "CXXBoolLiteralExpr"; break;
|
||||
case DxcCursor_CXXNullPtrLiteralExpr: ostr << "CXXNullPtrLiteralExpr"; break;
|
||||
case DxcCursor_CXXThisExpr: ostr << "CXXThisExpr"; break;
|
||||
case DxcCursor_CXXThrowExpr: ostr << "CXXThrowExpr"; break;
|
||||
case DxcCursor_CXXNewExpr: ostr << "CXXNewExpr"; break;
|
||||
case DxcCursor_CXXDeleteExpr: ostr << "CXXDeleteExpr"; break;
|
||||
case DxcCursor_UnaryExpr: ostr << "UnaryExpr"; break;
|
||||
case DxcCursor_ObjCStringLiteral: ostr << "ObjCStringLiteral"; break;
|
||||
case DxcCursor_ObjCEncodeExpr: ostr << "ObjCEncodeExpr"; break;
|
||||
case DxcCursor_ObjCSelectorExpr: ostr << "ObjCSelectorExpr"; break;
|
||||
case DxcCursor_ObjCProtocolExpr: ostr << "ObjCProtocolExpr"; break;
|
||||
case DxcCursor_ObjCBridgedCastExpr: ostr << "ObjCBridgedCastExpr"; break;
|
||||
case DxcCursor_PackExpansionExpr: ostr << "PackExpansionExpr"; break;
|
||||
case DxcCursor_SizeOfPackExpr: ostr << "SizeOfPackExpr"; break;
|
||||
case DxcCursor_LambdaExpr: ostr << "LambdaExpr"; break;
|
||||
case DxcCursor_ObjCBoolLiteralExpr: ostr << "ObjCBoolLiteralExpr"; break;
|
||||
case DxcCursor_ObjCSelfExpr: ostr << "ObjCSelfExpr"; break;
|
||||
case DxcCursor_UnexposedStmt: ostr << "UnexposedStmt"; break;
|
||||
case DxcCursor_LabelStmt: ostr << "LabelStmt"; break;
|
||||
case DxcCursor_CompoundStmt: ostr << "CompoundStmt"; break;
|
||||
case DxcCursor_CaseStmt: ostr << "CaseStmt"; break;
|
||||
case DxcCursor_DefaultStmt: ostr << "DefaultStmt"; break;
|
||||
case DxcCursor_IfStmt: ostr << "IfStmt"; break;
|
||||
case DxcCursor_SwitchStmt: ostr << "SwitchStmt"; break;
|
||||
case DxcCursor_WhileStmt: ostr << "WhileStmt"; break;
|
||||
case DxcCursor_DoStmt: ostr << "DoStmt"; break;
|
||||
case DxcCursor_ForStmt: ostr << "ForStmt"; break;
|
||||
case DxcCursor_GotoStmt: ostr << "GotoStmt"; break;
|
||||
case DxcCursor_IndirectGotoStmt: ostr << "IndirectGotoStmt"; break;
|
||||
case DxcCursor_ContinueStmt: ostr << "ContinueStmt"; break;
|
||||
case DxcCursor_BreakStmt: ostr << "BreakStmt"; break;
|
||||
case DxcCursor_ReturnStmt: ostr << "ReturnStmt"; break;
|
||||
case DxcCursor_GCCAsmStmt: ostr << "GCCAsmStmt"; break;
|
||||
case DxcCursor_ObjCAtTryStmt: ostr << "ObjCAtTryStmt"; break;
|
||||
case DxcCursor_ObjCAtCatchStmt: ostr << "ObjCAtCatchStmt"; break;
|
||||
case DxcCursor_ObjCAtFinallyStmt: ostr << "ObjCAtFinallyStmt"; break;
|
||||
case DxcCursor_ObjCAtThrowStmt: ostr << "ObjCAtThrowStmt"; break;
|
||||
case DxcCursor_ObjCAtSynchronizedStmt: ostr << "ObjCAtSynchronizedStmt"; break;
|
||||
case DxcCursor_ObjCAutoreleasePoolStmt: ostr << "ObjCAutoreleasePoolStmt"; break;
|
||||
case DxcCursor_ObjCForCollectionStmt: ostr << "ObjCForCollectionStmt"; break;
|
||||
case DxcCursor_CXXCatchStmt: ostr << "CXXCatchStmt"; break;
|
||||
case DxcCursor_CXXTryStmt: ostr << "CXXTryStmt"; break;
|
||||
case DxcCursor_CXXForRangeStmt: ostr << "CXXForRangeStmt"; break;
|
||||
case DxcCursor_SEHTryStmt: ostr << "SEHTryStmt"; break;
|
||||
case DxcCursor_SEHExceptStmt: ostr << "SEHExceptStmt"; break;
|
||||
case DxcCursor_SEHFinallyStmt: ostr << "SEHFinallyStmt"; break;
|
||||
case DxcCursor_MSAsmStmt: ostr << "MSAsmStmt"; break;
|
||||
case DxcCursor_NullStmt: ostr << "NullStmt"; break;
|
||||
case DxcCursor_DeclStmt: ostr << "DeclStmt"; break;
|
||||
case DxcCursor_OMPParallelDirective: ostr << "OMPParallelDirective"; break;
|
||||
case DxcCursor_TranslationUnit: ostr << "TranslationUnit"; break;
|
||||
case DxcCursor_UnexposedAttr: ostr << "UnexposedAttr"; break;
|
||||
switch (kind) {
|
||||
case DxcCursor_UnexposedDecl:
|
||||
ostr << "UnexposedDecl";
|
||||
break;
|
||||
case DxcCursor_StructDecl:
|
||||
ostr << "StructDecl";
|
||||
break;
|
||||
case DxcCursor_UnionDecl:
|
||||
ostr << "UnionDecl";
|
||||
break;
|
||||
case DxcCursor_ClassDecl:
|
||||
ostr << "ClassDecl";
|
||||
break;
|
||||
case DxcCursor_EnumDecl:
|
||||
ostr << "EnumDecl";
|
||||
break;
|
||||
case DxcCursor_FieldDecl:
|
||||
ostr << "FieldDecl";
|
||||
break;
|
||||
case DxcCursor_EnumConstantDecl:
|
||||
ostr << "EnumConstantDecl";
|
||||
break;
|
||||
case DxcCursor_FunctionDecl:
|
||||
ostr << "FunctionDecl";
|
||||
break;
|
||||
case DxcCursor_VarDecl:
|
||||
ostr << "VarDecl";
|
||||
break;
|
||||
case DxcCursor_ParmDecl:
|
||||
ostr << "ParmDecl";
|
||||
break;
|
||||
case DxcCursor_ObjCInterfaceDecl:
|
||||
ostr << "ObjCInterfaceDecl";
|
||||
break;
|
||||
case DxcCursor_ObjCCategoryDecl:
|
||||
ostr << "ObjCCategoryDecl";
|
||||
break;
|
||||
case DxcCursor_ObjCProtocolDecl:
|
||||
ostr << "ObjCProtocolDecl";
|
||||
break;
|
||||
case DxcCursor_ObjCPropertyDecl:
|
||||
ostr << "ObjCPropertyDecl";
|
||||
break;
|
||||
case DxcCursor_ObjCIvarDecl:
|
||||
ostr << "ObjCIvarDecl";
|
||||
break;
|
||||
case DxcCursor_ObjCInstanceMethodDecl:
|
||||
ostr << "ObjCInstanceMethodDecl";
|
||||
break;
|
||||
case DxcCursor_ObjCClassMethodDecl:
|
||||
ostr << "ObjCClassMethodDecl";
|
||||
break;
|
||||
case DxcCursor_ObjCImplementationDecl:
|
||||
ostr << "ObjCImplementationDecl";
|
||||
break;
|
||||
case DxcCursor_ObjCCategoryImplDecl:
|
||||
ostr << "ObjCCategoryImplDecl";
|
||||
break;
|
||||
case DxcCursor_TypedefDecl:
|
||||
ostr << "TypedefDecl";
|
||||
break;
|
||||
case DxcCursor_CXXMethod:
|
||||
ostr << "CXXMethod";
|
||||
break;
|
||||
case DxcCursor_Namespace:
|
||||
ostr << "Namespace";
|
||||
break;
|
||||
case DxcCursor_LinkageSpec:
|
||||
ostr << "LinkageSpec";
|
||||
break;
|
||||
case DxcCursor_Constructor:
|
||||
ostr << "Constructor";
|
||||
break;
|
||||
case DxcCursor_Destructor:
|
||||
ostr << "Destructor";
|
||||
break;
|
||||
case DxcCursor_ConversionFunction:
|
||||
ostr << "ConversionFunction";
|
||||
break;
|
||||
case DxcCursor_TemplateTypeParameter:
|
||||
ostr << "TemplateTypeParameter";
|
||||
break;
|
||||
case DxcCursor_NonTypeTemplateParameter:
|
||||
ostr << "NonTypeTemplateParameter";
|
||||
break;
|
||||
case DxcCursor_TemplateTemplateParameter:
|
||||
ostr << "TemplateTemplateParameter";
|
||||
break;
|
||||
case DxcCursor_FunctionTemplate:
|
||||
ostr << "FunctionTemplate";
|
||||
break;
|
||||
case DxcCursor_ClassTemplate:
|
||||
ostr << "ClassTemplate";
|
||||
break;
|
||||
case DxcCursor_ClassTemplatePartialSpecialization:
|
||||
ostr << "ClassTemplatePartialSpecialization";
|
||||
break;
|
||||
case DxcCursor_NamespaceAlias:
|
||||
ostr << "NamespaceAlias";
|
||||
break;
|
||||
case DxcCursor_UsingDirective:
|
||||
ostr << "UsingDirective";
|
||||
break;
|
||||
case DxcCursor_UsingDeclaration:
|
||||
ostr << "UsingDeclaration";
|
||||
break;
|
||||
case DxcCursor_TypeAliasDecl:
|
||||
ostr << "TypeAliasDecl";
|
||||
break;
|
||||
case DxcCursor_ObjCSynthesizeDecl:
|
||||
ostr << "ObjCSynthesizeDecl";
|
||||
break;
|
||||
case DxcCursor_ObjCDynamicDecl:
|
||||
ostr << "ObjCDynamicDecl";
|
||||
break;
|
||||
case DxcCursor_CXXAccessSpecifier:
|
||||
ostr << "CXXAccessSpecifier";
|
||||
break;
|
||||
case DxcCursor_ObjCSuperClassRef:
|
||||
ostr << "ObjCSuperClassRef";
|
||||
break;
|
||||
case DxcCursor_ObjCProtocolRef:
|
||||
ostr << "ObjCProtocolRef";
|
||||
break;
|
||||
case DxcCursor_ObjCClassRef:
|
||||
ostr << "ObjCClassRef";
|
||||
break;
|
||||
case DxcCursor_TypeRef:
|
||||
ostr << "TypeRef";
|
||||
break;
|
||||
case DxcCursor_CXXBaseSpecifier:
|
||||
ostr << "CXXBaseSpecifier";
|
||||
break;
|
||||
case DxcCursor_TemplateRef:
|
||||
ostr << "TemplateRef";
|
||||
break;
|
||||
case DxcCursor_NamespaceRef:
|
||||
ostr << "NamespaceRef";
|
||||
break;
|
||||
case DxcCursor_MemberRef:
|
||||
ostr << "MemberRef";
|
||||
break;
|
||||
case DxcCursor_LabelRef:
|
||||
ostr << "LabelRef";
|
||||
break;
|
||||
case DxcCursor_OverloadedDeclRef:
|
||||
ostr << "OverloadedDeclRef";
|
||||
break;
|
||||
case DxcCursor_VariableRef:
|
||||
ostr << "VariableRef";
|
||||
break;
|
||||
case DxcCursor_InvalidFile:
|
||||
ostr << "InvalidFile";
|
||||
break;
|
||||
case DxcCursor_NoDeclFound:
|
||||
ostr << "NoDeclFound";
|
||||
break;
|
||||
case DxcCursor_NotImplemented:
|
||||
ostr << "NotImplemented";
|
||||
break;
|
||||
case DxcCursor_InvalidCode:
|
||||
ostr << "InvalidCode";
|
||||
break;
|
||||
case DxcCursor_UnexposedExpr:
|
||||
ostr << "UnexposedExpr";
|
||||
break;
|
||||
case DxcCursor_DeclRefExpr:
|
||||
ostr << "DeclRefExpr";
|
||||
break;
|
||||
case DxcCursor_MemberRefExpr:
|
||||
ostr << "MemberRefExpr";
|
||||
break;
|
||||
case DxcCursor_CallExpr:
|
||||
ostr << "CallExpr";
|
||||
break;
|
||||
case DxcCursor_ObjCMessageExpr:
|
||||
ostr << "ObjCMessageExpr";
|
||||
break;
|
||||
case DxcCursor_BlockExpr:
|
||||
ostr << "BlockExpr";
|
||||
break;
|
||||
case DxcCursor_IntegerLiteral:
|
||||
ostr << "IntegerLiteral";
|
||||
break;
|
||||
case DxcCursor_FloatingLiteral:
|
||||
ostr << "FloatingLiteral";
|
||||
break;
|
||||
case DxcCursor_ImaginaryLiteral:
|
||||
ostr << "ImaginaryLiteral";
|
||||
break;
|
||||
case DxcCursor_StringLiteral:
|
||||
ostr << "StringLiteral";
|
||||
break;
|
||||
case DxcCursor_CharacterLiteral:
|
||||
ostr << "CharacterLiteral";
|
||||
break;
|
||||
case DxcCursor_ParenExpr:
|
||||
ostr << "ParenExpr";
|
||||
break;
|
||||
case DxcCursor_UnaryOperator:
|
||||
ostr << "UnaryOperator";
|
||||
break;
|
||||
case DxcCursor_ArraySubscriptExpr:
|
||||
ostr << "ArraySubscriptExpr";
|
||||
break;
|
||||
case DxcCursor_BinaryOperator:
|
||||
ostr << "BinaryOperator";
|
||||
break;
|
||||
case DxcCursor_CompoundAssignOperator:
|
||||
ostr << "CompoundAssignOperator";
|
||||
break;
|
||||
case DxcCursor_ConditionalOperator:
|
||||
ostr << "ConditionalOperator";
|
||||
break;
|
||||
case DxcCursor_CStyleCastExpr:
|
||||
ostr << "CStyleCastExpr";
|
||||
break;
|
||||
case DxcCursor_CompoundLiteralExpr:
|
||||
ostr << "CompoundLiteralExpr";
|
||||
break;
|
||||
case DxcCursor_InitListExpr:
|
||||
ostr << "InitListExpr";
|
||||
break;
|
||||
case DxcCursor_AddrLabelExpr:
|
||||
ostr << "AddrLabelExpr";
|
||||
break;
|
||||
case DxcCursor_StmtExpr:
|
||||
ostr << "StmtExpr";
|
||||
break;
|
||||
case DxcCursor_GenericSelectionExpr:
|
||||
ostr << "GenericSelectionExpr";
|
||||
break;
|
||||
case DxcCursor_GNUNullExpr:
|
||||
ostr << "GNUNullExpr";
|
||||
break;
|
||||
case DxcCursor_CXXStaticCastExpr:
|
||||
ostr << "CXXStaticCastExpr";
|
||||
break;
|
||||
case DxcCursor_CXXDynamicCastExpr:
|
||||
ostr << "CXXDynamicCastExpr";
|
||||
break;
|
||||
case DxcCursor_CXXReinterpretCastExpr:
|
||||
ostr << "CXXReinterpretCastExpr";
|
||||
break;
|
||||
case DxcCursor_CXXConstCastExpr:
|
||||
ostr << "CXXConstCastExpr";
|
||||
break;
|
||||
case DxcCursor_CXXFunctionalCastExpr:
|
||||
ostr << "CXXFunctionalCastExpr";
|
||||
break;
|
||||
case DxcCursor_CXXTypeidExpr:
|
||||
ostr << "CXXTypeidExpr";
|
||||
break;
|
||||
case DxcCursor_CXXBoolLiteralExpr:
|
||||
ostr << "CXXBoolLiteralExpr";
|
||||
break;
|
||||
case DxcCursor_CXXNullPtrLiteralExpr:
|
||||
ostr << "CXXNullPtrLiteralExpr";
|
||||
break;
|
||||
case DxcCursor_CXXThisExpr:
|
||||
ostr << "CXXThisExpr";
|
||||
break;
|
||||
case DxcCursor_CXXThrowExpr:
|
||||
ostr << "CXXThrowExpr";
|
||||
break;
|
||||
case DxcCursor_CXXNewExpr:
|
||||
ostr << "CXXNewExpr";
|
||||
break;
|
||||
case DxcCursor_CXXDeleteExpr:
|
||||
ostr << "CXXDeleteExpr";
|
||||
break;
|
||||
case DxcCursor_UnaryExpr:
|
||||
ostr << "UnaryExpr";
|
||||
break;
|
||||
case DxcCursor_ObjCStringLiteral:
|
||||
ostr << "ObjCStringLiteral";
|
||||
break;
|
||||
case DxcCursor_ObjCEncodeExpr:
|
||||
ostr << "ObjCEncodeExpr";
|
||||
break;
|
||||
case DxcCursor_ObjCSelectorExpr:
|
||||
ostr << "ObjCSelectorExpr";
|
||||
break;
|
||||
case DxcCursor_ObjCProtocolExpr:
|
||||
ostr << "ObjCProtocolExpr";
|
||||
break;
|
||||
case DxcCursor_ObjCBridgedCastExpr:
|
||||
ostr << "ObjCBridgedCastExpr";
|
||||
break;
|
||||
case DxcCursor_PackExpansionExpr:
|
||||
ostr << "PackExpansionExpr";
|
||||
break;
|
||||
case DxcCursor_SizeOfPackExpr:
|
||||
ostr << "SizeOfPackExpr";
|
||||
break;
|
||||
case DxcCursor_LambdaExpr:
|
||||
ostr << "LambdaExpr";
|
||||
break;
|
||||
case DxcCursor_ObjCBoolLiteralExpr:
|
||||
ostr << "ObjCBoolLiteralExpr";
|
||||
break;
|
||||
case DxcCursor_ObjCSelfExpr:
|
||||
ostr << "ObjCSelfExpr";
|
||||
break;
|
||||
case DxcCursor_UnexposedStmt:
|
||||
ostr << "UnexposedStmt";
|
||||
break;
|
||||
case DxcCursor_LabelStmt:
|
||||
ostr << "LabelStmt";
|
||||
break;
|
||||
case DxcCursor_CompoundStmt:
|
||||
ostr << "CompoundStmt";
|
||||
break;
|
||||
case DxcCursor_CaseStmt:
|
||||
ostr << "CaseStmt";
|
||||
break;
|
||||
case DxcCursor_DefaultStmt:
|
||||
ostr << "DefaultStmt";
|
||||
break;
|
||||
case DxcCursor_IfStmt:
|
||||
ostr << "IfStmt";
|
||||
break;
|
||||
case DxcCursor_SwitchStmt:
|
||||
ostr << "SwitchStmt";
|
||||
break;
|
||||
case DxcCursor_WhileStmt:
|
||||
ostr << "WhileStmt";
|
||||
break;
|
||||
case DxcCursor_DoStmt:
|
||||
ostr << "DoStmt";
|
||||
break;
|
||||
case DxcCursor_ForStmt:
|
||||
ostr << "ForStmt";
|
||||
break;
|
||||
case DxcCursor_GotoStmt:
|
||||
ostr << "GotoStmt";
|
||||
break;
|
||||
case DxcCursor_IndirectGotoStmt:
|
||||
ostr << "IndirectGotoStmt";
|
||||
break;
|
||||
case DxcCursor_ContinueStmt:
|
||||
ostr << "ContinueStmt";
|
||||
break;
|
||||
case DxcCursor_BreakStmt:
|
||||
ostr << "BreakStmt";
|
||||
break;
|
||||
case DxcCursor_ReturnStmt:
|
||||
ostr << "ReturnStmt";
|
||||
break;
|
||||
case DxcCursor_GCCAsmStmt:
|
||||
ostr << "GCCAsmStmt";
|
||||
break;
|
||||
case DxcCursor_ObjCAtTryStmt:
|
||||
ostr << "ObjCAtTryStmt";
|
||||
break;
|
||||
case DxcCursor_ObjCAtCatchStmt:
|
||||
ostr << "ObjCAtCatchStmt";
|
||||
break;
|
||||
case DxcCursor_ObjCAtFinallyStmt:
|
||||
ostr << "ObjCAtFinallyStmt";
|
||||
break;
|
||||
case DxcCursor_ObjCAtThrowStmt:
|
||||
ostr << "ObjCAtThrowStmt";
|
||||
break;
|
||||
case DxcCursor_ObjCAtSynchronizedStmt:
|
||||
ostr << "ObjCAtSynchronizedStmt";
|
||||
break;
|
||||
case DxcCursor_ObjCAutoreleasePoolStmt:
|
||||
ostr << "ObjCAutoreleasePoolStmt";
|
||||
break;
|
||||
case DxcCursor_ObjCForCollectionStmt:
|
||||
ostr << "ObjCForCollectionStmt";
|
||||
break;
|
||||
case DxcCursor_CXXCatchStmt:
|
||||
ostr << "CXXCatchStmt";
|
||||
break;
|
||||
case DxcCursor_CXXTryStmt:
|
||||
ostr << "CXXTryStmt";
|
||||
break;
|
||||
case DxcCursor_CXXForRangeStmt:
|
||||
ostr << "CXXForRangeStmt";
|
||||
break;
|
||||
case DxcCursor_SEHTryStmt:
|
||||
ostr << "SEHTryStmt";
|
||||
break;
|
||||
case DxcCursor_SEHExceptStmt:
|
||||
ostr << "SEHExceptStmt";
|
||||
break;
|
||||
case DxcCursor_SEHFinallyStmt:
|
||||
ostr << "SEHFinallyStmt";
|
||||
break;
|
||||
case DxcCursor_MSAsmStmt:
|
||||
ostr << "MSAsmStmt";
|
||||
break;
|
||||
case DxcCursor_NullStmt:
|
||||
ostr << "NullStmt";
|
||||
break;
|
||||
case DxcCursor_DeclStmt:
|
||||
ostr << "DeclStmt";
|
||||
break;
|
||||
case DxcCursor_OMPParallelDirective:
|
||||
ostr << "OMPParallelDirective";
|
||||
break;
|
||||
case DxcCursor_TranslationUnit:
|
||||
ostr << "TranslationUnit";
|
||||
break;
|
||||
case DxcCursor_UnexposedAttr:
|
||||
ostr << "UnexposedAttr";
|
||||
break;
|
||||
#if 0
|
||||
CXCursor_IBActionAttr = 401,
|
||||
CXCursor_IBOutletAttr = 402,
|
||||
|
@ -535,7 +809,7 @@ private:
|
|||
case CXCursor_TranslationUnit:
|
||||
ostr << "translation unit";
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
default:
|
||||
ostr << "unknown/unhandled cursor kind " << kind;
|
||||
break;
|
||||
|
@ -553,7 +827,7 @@ private:
|
|||
ostr << '\n';
|
||||
|
||||
// Recurse.
|
||||
IDxcCursor** children = nullptr;
|
||||
IDxcCursor **children = nullptr;
|
||||
unsigned childrenCount;
|
||||
cursor->GetChildren(0, 64, &childrenCount, &children);
|
||||
for (unsigned i = 0; i < childrenCount; i++) {
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "dxc/Support/Global.h"
|
||||
#include "DumpContext.h"
|
||||
#include "dxc/Support/Global.h"
|
||||
#include "dxc/Support/WinIncludes.h"
|
||||
|
||||
namespace hlsl {
|
||||
|
@ -22,7 +22,9 @@ class D3DReflectionDumper : public DumpContext {
|
|||
private:
|
||||
bool m_bCheckByName = false;
|
||||
const char *m_LastName = nullptr;
|
||||
void SetLastName(const char *Name = nullptr) { m_LastName = Name ? Name : "<nullptr>"; }
|
||||
void SetLastName(const char *Name = nullptr) {
|
||||
m_LastName = Name ? Name : "<nullptr>";
|
||||
}
|
||||
|
||||
public:
|
||||
D3DReflectionDumper(std::ostream &outStream) : DumpContext(outStream) {}
|
||||
|
@ -48,7 +50,6 @@ public:
|
|||
void Dump(ID3D12ShaderReflection *pShaderReflection);
|
||||
void Dump(ID3D12FunctionReflection *pFunctionReflection);
|
||||
void Dump(ID3D12LibraryReflection *pLibraryReflection);
|
||||
|
||||
};
|
||||
|
||||
} // namespace dump
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
|
||||
#include "dxc/WinAdapter.h"
|
||||
|
||||
#include "dxc/Support/D3DReflection.h"
|
||||
#include "dxc/DxilContainer/DxilRuntimeReflection.h"
|
||||
#include "dxc/Support/D3DReflection.h"
|
||||
|
||||
namespace hlsl {
|
||||
using namespace RDAT;
|
||||
|
|
|
@ -13,25 +13,23 @@
|
|||
|
||||
#include "dxc/Support/Global.h"
|
||||
#include "dxc/Test/D3DReflectionStrings.h"
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace hlsl {
|
||||
using namespace RDAT;
|
||||
namespace dump {
|
||||
|
||||
template<typename _T>
|
||||
struct EnumValue {
|
||||
template <typename _T> struct EnumValue {
|
||||
public:
|
||||
EnumValue(const _T &e) : eValue(e) {}
|
||||
_T eValue;
|
||||
};
|
||||
|
||||
template<typename _T, typename _StoreT = uint32_t>
|
||||
struct FlagsValue {
|
||||
template <typename _T, typename _StoreT = uint32_t> struct FlagsValue {
|
||||
public:
|
||||
FlagsValue(const _StoreT &f) : Flags(f) {}
|
||||
_StoreT Flags;
|
||||
|
@ -51,46 +49,48 @@ private:
|
|||
|
||||
std::ostream &DoIndent() {
|
||||
return m_out << std::setfill(' ')
|
||||
<< std::setw((m_indent > 16) ? 32 : m_indent * 2)
|
||||
<< "";
|
||||
<< std::setw((m_indent > 16) ? 32 : m_indent * 2) << "";
|
||||
}
|
||||
|
||||
public:
|
||||
DumpContext(std::ostream &outStream) : m_out(outStream) {}
|
||||
|
||||
void Indent() { if (m_indent < (1 << 30)) m_indent++; }
|
||||
void Dedent() { if (m_indent > 0) m_indent--; }
|
||||
|
||||
template<typename _T>
|
||||
std::ostream &Write(_T t) {
|
||||
return Write(m_out, t);
|
||||
void Indent() {
|
||||
if (m_indent < (1 << 30))
|
||||
m_indent++;
|
||||
}
|
||||
template<typename _T, typename... Args>
|
||||
void Dedent() {
|
||||
if (m_indent > 0)
|
||||
m_indent--;
|
||||
}
|
||||
|
||||
template <typename _T> std::ostream &Write(_T t) { return Write(m_out, t); }
|
||||
template <typename _T, typename... Args>
|
||||
std::ostream &Write(_T t, Args... args) {
|
||||
return Write(Write(m_out, t), args...);
|
||||
}
|
||||
template<typename _T>
|
||||
std::ostream &Write(std::ostream &out, _T t) {
|
||||
template <typename _T> std::ostream &Write(std::ostream &out, _T t) {
|
||||
return out << t;
|
||||
}
|
||||
template<typename _T, typename... Args>
|
||||
template <typename _T, typename... Args>
|
||||
std::ostream &Write(std::ostream &out, _T t, Args... args) {
|
||||
return Write(Write(out, t), args...);
|
||||
}
|
||||
|
||||
template<typename _T>
|
||||
std::ostream &WriteLn(_T t) {
|
||||
template <typename _T> std::ostream &WriteLn(_T t) {
|
||||
return Write(DoIndent(), t) << std::endl
|
||||
<< std::resetiosflags(std::ios_base::basefield | std::ios_base::showbase);
|
||||
<< std::resetiosflags(std::ios_base::basefield |
|
||||
std::ios_base::showbase);
|
||||
}
|
||||
template<typename _T, typename... Args>
|
||||
template <typename _T, typename... Args>
|
||||
std::ostream &WriteLn(_T t, Args... args) {
|
||||
return Write(Write(DoIndent(), t), args...) << std::endl
|
||||
<< std::resetiosflags(std::ios_base::basefield | std::ios_base::showbase);
|
||||
return Write(Write(DoIndent(), t), args...)
|
||||
<< std::endl
|
||||
<< std::resetiosflags(std::ios_base::basefield |
|
||||
std::ios_base::showbase);
|
||||
}
|
||||
|
||||
template <typename _T>
|
||||
std::ostream &WriteEnumValue(_T eValue) {
|
||||
template <typename _T> std::ostream &WriteEnumValue(_T eValue) {
|
||||
const char *szValue = ToString(eValue);
|
||||
if (szValue)
|
||||
return Write(szValue);
|
||||
|
@ -98,17 +98,15 @@ public:
|
|||
return Write("<unknown: ", std::hex, std::showbase, (UINT)eValue, ">");
|
||||
}
|
||||
|
||||
template<typename _T>
|
||||
void DumpEnum(const char *Name, _T eValue) {
|
||||
template <typename _T> void DumpEnum(const char *Name, _T eValue) {
|
||||
WriteLn(Name, ": ", EnumValue<_T>(eValue));
|
||||
}
|
||||
template<typename _T, typename _StoreT = uint32_t>
|
||||
template <typename _T, typename _StoreT = uint32_t>
|
||||
void DumpFlags(const char *Name, _StoreT Flags) {
|
||||
WriteLn(Name, ": ", FlagsValue<_T, _StoreT>(Flags));
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void Failure(Args... args) {
|
||||
template <typename... Args> void Failure(Args... args) {
|
||||
WriteLn("Failed: ", args...);
|
||||
}
|
||||
|
||||
|
@ -118,7 +116,7 @@ public:
|
|||
void VisitReset() { m_visited.clear(); }
|
||||
};
|
||||
|
||||
template<>
|
||||
template <>
|
||||
inline std::ostream &DumpContext::Write<uint8_t>(std::ostream &out, uint8_t t) {
|
||||
return out << (unsigned)t;
|
||||
}
|
||||
|
@ -144,16 +142,18 @@ inline std::string EscapedString(const char *text) {
|
|||
return ss.str();
|
||||
}
|
||||
|
||||
template<typename _T>
|
||||
std::ostream& operator<<(std::ostream& out, const EnumValue<_T> &obj) {
|
||||
template <typename _T>
|
||||
std::ostream &operator<<(std::ostream &out, const EnumValue<_T> &obj) {
|
||||
if (const char *szValue = ToString(obj.eValue))
|
||||
return out << szValue;
|
||||
else
|
||||
return out << "<unknown: " << std::hex << std::showbase << (UINT)obj.eValue << ">";
|
||||
return out << "<unknown: " << std::hex << std::showbase << (UINT)obj.eValue
|
||||
<< ">";
|
||||
}
|
||||
|
||||
template<typename _T, typename _StoreT>
|
||||
std::ostream& operator<<(std::ostream& out, const FlagsValue<_T, _StoreT> &obj) {
|
||||
template <typename _T, typename _StoreT>
|
||||
std::ostream &operator<<(std::ostream &out,
|
||||
const FlagsValue<_T, _StoreT> &obj) {
|
||||
_StoreT Flags = obj.Flags;
|
||||
if (!Flags) {
|
||||
const char *szValue = ToString((_T)0);
|
||||
|
@ -175,7 +175,8 @@ std::ostream& operator<<(std::ostream& out, const FlagsValue<_T, _StoreT> &obj)
|
|||
return out;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& out, const QuotedStringValue &obj) {
|
||||
inline std::ostream &operator<<(std::ostream &out,
|
||||
const QuotedStringValue &obj) {
|
||||
if (!obj.Str)
|
||||
return out << "<null string pointer>";
|
||||
return out << "\"" << EscapedString(obj.Str) << "\"";
|
||||
|
|
|
@ -11,25 +11,24 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "dxc/Support/WinIncludes.h"
|
||||
|
||||
#include "dxc/dxcapi.h"
|
||||
#include "dxc/Support/dxcapi.use.h"
|
||||
#include "dxc/dxcapi.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
namespace hlsl {
|
||||
namespace options {
|
||||
class DxcOpts;
|
||||
class MainArgs;
|
||||
}
|
||||
}
|
||||
} // namespace options
|
||||
} // namespace hlsl
|
||||
|
||||
/// Use this class to run a FileCheck invocation in memory.
|
||||
class FileCheckForTest {
|
||||
|
@ -64,7 +63,8 @@ public:
|
|||
int Run();
|
||||
};
|
||||
|
||||
// wstring because most uses need UTF-16: IDxcResult output names, include handler
|
||||
// wstring because most uses need UTF-16: IDxcResult output names, include
|
||||
// handler
|
||||
typedef std::map<std::wstring, CComPtr<IDxcBlob>> FileMap;
|
||||
|
||||
// The result of running a single command in a run pipeline
|
||||
|
@ -104,37 +104,54 @@ 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, PluginToolsPaths *pPluginToolsPaths = nullptr, LPCWSTR dumpName = nullptr);
|
||||
FileRunCommandResult RunHashTests(dxc::DxcDllSupport &DllSupport);
|
||||
|
||||
FileRunCommandResult ReadOptsForDxc(hlsl::options::MainArgs &argStrings, hlsl::options::DxcOpts &Opts, unsigned flagsToInclude = 0);
|
||||
FileRunCommandPart(const std::string &command, const std::string &arguments,
|
||||
LPCWSTR commandFileName);
|
||||
FileRunCommandPart(const FileRunCommandPart &) = default;
|
||||
FileRunCommandPart(FileRunCommandPart &&) = default;
|
||||
|
||||
std::string Command; // Command to run, eg %dxc
|
||||
std::string Arguments; // Arguments to command
|
||||
LPCWSTR CommandFileName; // File name replacement for %s
|
||||
FileMap *pVFS = nullptr; // Files in virtual file system
|
||||
FileRunCommandResult Run(dxc::DxcDllSupport &DllSupport,
|
||||
const FileRunCommandResult *Prior,
|
||||
PluginToolsPaths *pPluginToolsPaths = nullptr,
|
||||
LPCWSTR dumpName = nullptr);
|
||||
FileRunCommandResult RunHashTests(dxc::DxcDllSupport &DllSupport);
|
||||
|
||||
FileRunCommandResult ReadOptsForDxc(hlsl::options::MainArgs &argStrings,
|
||||
hlsl::options::DxcOpts &Opts,
|
||||
unsigned flagsToInclude = 0);
|
||||
|
||||
std::string Command; // Command to run, eg %dxc
|
||||
std::string Arguments; // Arguments to command
|
||||
LPCWSTR CommandFileName; // File name replacement for %s
|
||||
FileMap *pVFS = nullptr; // Files in virtual file system
|
||||
|
||||
private:
|
||||
FileRunCommandResult RunFileChecker(const FileRunCommandResult *Prior, LPCWSTR dumpName = nullptr);
|
||||
FileRunCommandResult RunDxc(dxc::DxcDllSupport &DllSupport, const FileRunCommandResult *Prior);
|
||||
FileRunCommandResult RunDxv(dxc::DxcDllSupport &DllSupport, const FileRunCommandResult *Prior);
|
||||
FileRunCommandResult RunOpt(dxc::DxcDllSupport &DllSupport, const FileRunCommandResult *Prior);
|
||||
FileRunCommandResult RunListParts(dxc::DxcDllSupport &DllSupport, const FileRunCommandResult *Prior);
|
||||
FileRunCommandResult RunD3DReflect(dxc::DxcDllSupport &DllSupport, const FileRunCommandResult *Prior);
|
||||
FileRunCommandResult RunDxr(dxc::DxcDllSupport &DllSupport, const FileRunCommandResult *Prior);
|
||||
FileRunCommandResult RunLink(dxc::DxcDllSupport &DllSupport, const FileRunCommandResult *Prior);
|
||||
FileRunCommandResult RunFileChecker(const FileRunCommandResult *Prior,
|
||||
LPCWSTR dumpName = nullptr);
|
||||
FileRunCommandResult RunDxc(dxc::DxcDllSupport &DllSupport,
|
||||
const FileRunCommandResult *Prior);
|
||||
FileRunCommandResult RunDxv(dxc::DxcDllSupport &DllSupport,
|
||||
const FileRunCommandResult *Prior);
|
||||
FileRunCommandResult RunOpt(dxc::DxcDllSupport &DllSupport,
|
||||
const FileRunCommandResult *Prior);
|
||||
FileRunCommandResult RunListParts(dxc::DxcDllSupport &DllSupport,
|
||||
const FileRunCommandResult *Prior);
|
||||
FileRunCommandResult RunD3DReflect(dxc::DxcDllSupport &DllSupport,
|
||||
const FileRunCommandResult *Prior);
|
||||
FileRunCommandResult RunDxr(dxc::DxcDllSupport &DllSupport,
|
||||
const FileRunCommandResult *Prior);
|
||||
FileRunCommandResult RunLink(dxc::DxcDllSupport &DllSupport,
|
||||
const FileRunCommandResult *Prior);
|
||||
FileRunCommandResult RunTee(const FileRunCommandResult *Prior);
|
||||
FileRunCommandResult RunXFail(const FileRunCommandResult *Prior);
|
||||
FileRunCommandResult RunDxilVer(dxc::DxcDllSupport& DllSupport, 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 RunFromPath(const std::string &path,
|
||||
const FileRunCommandResult *Prior);
|
||||
FileRunCommandResult RunFileCompareText(const FileRunCommandResult *Prior);
|
||||
#ifdef _WIN32
|
||||
FileRunCommandResult RunFxc(dxc::DxcDllSupport &DllSupport, const FileRunCommandResult* Prior);
|
||||
FileRunCommandResult RunFxc(dxc::DxcDllSupport &DllSupport,
|
||||
const FileRunCommandResult *Prior);
|
||||
#endif
|
||||
|
||||
void SubstituteFilenameVars(std::string &args);
|
||||
|
@ -143,24 +160,28 @@ private:
|
|||
#endif
|
||||
};
|
||||
|
||||
void ParseCommandParts(LPCSTR commands, LPCWSTR fileName, std::vector<FileRunCommandPart> &parts);
|
||||
void ParseCommandPartsFromFile(LPCWSTR fileName, std::vector<FileRunCommandPart> &parts);
|
||||
void ParseCommandParts(LPCSTR commands, LPCWSTR fileName,
|
||||
std::vector<FileRunCommandPart> &parts);
|
||||
void ParseCommandPartsFromFile(LPCWSTR fileName,
|
||||
std::vector<FileRunCommandPart> &parts);
|
||||
|
||||
class FileRunTestResult {
|
||||
public:
|
||||
std::string ErrorMessage;
|
||||
int RunResult = -1;
|
||||
static FileRunTestResult RunHashTestFromFileCommands(LPCWSTR fileName);
|
||||
static FileRunTestResult RunFromFileCommands(LPCWSTR fileName,
|
||||
PluginToolsPaths *pPluginToolsPaths = nullptr,
|
||||
LPCWSTR dumpName = nullptr);
|
||||
static FileRunTestResult RunFromFileCommands(LPCWSTR fileName,
|
||||
dxc::DxcDllSupport &dllSupport,
|
||||
PluginToolsPaths *pPluginToolsPaths = nullptr,
|
||||
LPCWSTR dumpName = nullptr);
|
||||
static FileRunTestResult
|
||||
RunFromFileCommands(LPCWSTR fileName,
|
||||
PluginToolsPaths *pPluginToolsPaths = nullptr,
|
||||
LPCWSTR dumpName = nullptr);
|
||||
static FileRunTestResult
|
||||
RunFromFileCommands(LPCWSTR fileName, dxc::DxcDllSupport &dllSupport,
|
||||
PluginToolsPaths *pPluginToolsPaths = nullptr,
|
||||
LPCWSTR dumpName = nullptr);
|
||||
};
|
||||
|
||||
void AssembleToContainer(dxc::DxcDllSupport &dllSupport, IDxcBlob *pModule, IDxcBlob **pContainer);
|
||||
void AssembleToContainer(dxc::DxcDllSupport &dllSupport, IDxcBlob *pModule,
|
||||
IDxcBlob **pContainer);
|
||||
std::string BlobToUtf8(IDxcBlob *pBlob);
|
||||
std::wstring BlobToWide(IDxcBlob *pBlob);
|
||||
void CheckOperationSucceeded(IDxcOperationResult *pResult, IDxcBlob **ppBlob);
|
||||
|
@ -172,10 +193,12 @@ bool CheckOperationResultMsgs(IDxcOperationResult *pResult,
|
|||
bool maySucceedAnyway, bool bRegex);
|
||||
bool CheckMsgs(const LPCSTR pText, size_t TextCount, const LPCSTR *pErrorMsgs,
|
||||
size_t errorMsgCount, bool bRegex);
|
||||
bool CheckNotMsgs(const LPCSTR pText, size_t TextCount, const LPCSTR *pErrorMsgs,
|
||||
size_t errorMsgCount, bool bRegex);
|
||||
void GetDxilPart(dxc::DxcDllSupport &dllSupport, IDxcBlob *pProgram, IDxcBlob **pDxilPart);
|
||||
std::string DisassembleProgram(dxc::DxcDllSupport &dllSupport, IDxcBlob *pProgram);
|
||||
bool CheckNotMsgs(const LPCSTR pText, size_t TextCount,
|
||||
const LPCSTR *pErrorMsgs, size_t errorMsgCount, bool bRegex);
|
||||
void GetDxilPart(dxc::DxcDllSupport &dllSupport, IDxcBlob *pProgram,
|
||||
IDxcBlob **pDxilPart);
|
||||
std::string DisassembleProgram(dxc::DxcDllSupport &dllSupport,
|
||||
IDxcBlob *pProgram);
|
||||
void SplitPassList(LPWSTR pPassesBuffer, std::vector<LPCWSTR> &passes);
|
||||
void MultiByteStringToBlob(dxc::DxcDllSupport &dllSupport,
|
||||
const std::string &val, UINT32 codePoint,
|
||||
|
@ -199,12 +222,16 @@ void VerifyCompileOK(dxc::DxcDllSupport &dllSupport, LPCSTR pText,
|
|||
LPWSTR pTargetProfile, std::vector<LPCWSTR> &args,
|
||||
IDxcBlob **ppResult);
|
||||
|
||||
HRESULT GetVersion(dxc::DxcDllSupport& DllSupport, REFCLSID clsid, unsigned &Major, unsigned &Minor);
|
||||
bool ParseTargetProfile(llvm::StringRef targetProfile, llvm::StringRef &outStage, unsigned &outMajor, unsigned &outMinor);
|
||||
HRESULT GetVersion(dxc::DxcDllSupport &DllSupport, REFCLSID clsid,
|
||||
unsigned &Major, unsigned &Minor);
|
||||
bool ParseTargetProfile(llvm::StringRef targetProfile,
|
||||
llvm::StringRef &outStage, unsigned &outMajor,
|
||||
unsigned &outMinor);
|
||||
|
||||
class VersionSupportInfo {
|
||||
private:
|
||||
bool m_CompilerIsDebugBuild;
|
||||
|
||||
public:
|
||||
bool m_InternalValidator;
|
||||
unsigned m_DxilMajor, m_DxilMinor;
|
||||
|
@ -215,7 +242,8 @@ public:
|
|||
void Initialize(dxc::DxcDllSupport &dllSupport);
|
||||
// Return true if IR sensitive test should be skipped, and log comment
|
||||
bool SkipIRSensitiveTest();
|
||||
// Return true if test requiring DXIL of given version should be skipped, and log comment
|
||||
// Return true if test requiring DXIL of given version should be skipped, and
|
||||
// log comment
|
||||
bool SkipDxilVersion(unsigned major, unsigned minor);
|
||||
// Return true if out-of-memory test should be skipped, and log comment
|
||||
bool SkipOutOfMemoryTest();
|
||||
|
|
|
@ -11,30 +11,18 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
struct StorageClassDataItem
|
||||
{
|
||||
const char* Keyword;
|
||||
struct StorageClassDataItem {
|
||||
const char *Keyword;
|
||||
bool IsValid;
|
||||
};
|
||||
|
||||
const StorageClassDataItem StorageClassData[] =
|
||||
{
|
||||
{ "inline", true },
|
||||
{ "extern", false },
|
||||
{ "", true }
|
||||
};
|
||||
const StorageClassDataItem StorageClassData[] = {
|
||||
{"inline", true}, {"extern", false}, {"", true}};
|
||||
|
||||
struct InOutParameterModifierDataItem
|
||||
{
|
||||
const char* Keyword;
|
||||
struct InOutParameterModifierDataItem {
|
||||
const char *Keyword;
|
||||
bool ActsAsReference;
|
||||
};
|
||||
|
||||
const InOutParameterModifierDataItem InOutParameterModifierData[] =
|
||||
{
|
||||
{ "", false },
|
||||
{ "in", false },
|
||||
{ "inout", true },
|
||||
{ "out", true }
|
||||
};
|
||||
|
||||
const InOutParameterModifierDataItem InOutParameterModifierData[] = {
|
||||
{"", false}, {"in", false}, {"inout", true}, {"out", true}};
|
||||
|
|
|
@ -11,19 +11,19 @@
|
|||
|
||||
// *** THIS FILE CANNOT TAKE ANY LLVM DEPENDENCIES *** //
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#ifdef _WIN32
|
||||
#include <dxgiformat.h>
|
||||
#include "WexTestClass.h"
|
||||
#include <dxgiformat.h>
|
||||
#else
|
||||
#include "dxc/Support/Global.h" // DXASSERT_LOCALVAR
|
||||
#include "WEXAdapter.h"
|
||||
#include "dxc/Support/Global.h" // DXASSERT_LOCALVAR
|
||||
#endif
|
||||
#include "dxc/DXIL/DxilConstants.h" // DenormMode
|
||||
|
||||
|
@ -61,22 +61,33 @@ using namespace std;
|
|||
#endif
|
||||
#define EXPECT_STREQW(a, b) VERIFY_ARE_EQUAL(0, wcscmp(a, b))
|
||||
#define VERIFY_ARE_EQUAL_CMP(a, b, ...) VERIFY_IS_TRUE(a == b, __VA_ARGS__)
|
||||
#define VERIFY_ARE_EQUAL_STR(a, b) { \
|
||||
const char *pTmpA = (a);\
|
||||
const char *pTmpB = (b);\
|
||||
if (0 != strcmp(pTmpA, pTmpB)) {\
|
||||
CA2W conv(pTmpB, CP_UTF8); WEX::Logging::Log::Comment(conv);\
|
||||
const char *pA = pTmpA; const char *pB = pTmpB; \
|
||||
while(*pA == *pB) { pA++; pB++; } \
|
||||
wchar_t diffMsg[32]; swprintf_s(diffMsg, _countof(diffMsg), L"diff at %u", (unsigned)(pA-pTmpA)); \
|
||||
WEX::Logging::Log::Comment(diffMsg); \
|
||||
} \
|
||||
VERIFY_ARE_EQUAL(0, strcmp(pTmpA, pTmpB)); \
|
||||
}
|
||||
#define VERIFY_ARE_EQUAL_WSTR(a, b) { \
|
||||
if (0 != wcscmp(a, b)) { WEX::Logging::Log::Comment(b);} \
|
||||
VERIFY_ARE_EQUAL(0, wcscmp(a, b)); \
|
||||
}
|
||||
#define VERIFY_ARE_EQUAL_STR(a, b) \
|
||||
{ \
|
||||
const char *pTmpA = (a); \
|
||||
const char *pTmpB = (b); \
|
||||
if (0 != strcmp(pTmpA, pTmpB)) { \
|
||||
CA2W conv(pTmpB, CP_UTF8); \
|
||||
WEX::Logging::Log::Comment(conv); \
|
||||
const char *pA = pTmpA; \
|
||||
const char *pB = pTmpB; \
|
||||
while (*pA == *pB) { \
|
||||
pA++; \
|
||||
pB++; \
|
||||
} \
|
||||
wchar_t diffMsg[32]; \
|
||||
swprintf_s(diffMsg, _countof(diffMsg), L"diff at %u", \
|
||||
(unsigned)(pA - pTmpA)); \
|
||||
WEX::Logging::Log::Comment(diffMsg); \
|
||||
} \
|
||||
VERIFY_ARE_EQUAL(0, strcmp(pTmpA, pTmpB)); \
|
||||
}
|
||||
#define VERIFY_ARE_EQUAL_WSTR(a, b) \
|
||||
{ \
|
||||
if (0 != wcscmp(a, b)) { \
|
||||
WEX::Logging::Log::Comment(b); \
|
||||
} \
|
||||
VERIFY_ARE_EQUAL(0, wcscmp(a, b)); \
|
||||
}
|
||||
#ifndef ASSERT_EQ
|
||||
#define ASSERT_EQ(expected, actual) VERIFY_ARE_EQUAL(expected, actual)
|
||||
#endif
|
||||
|
@ -89,7 +100,7 @@ using namespace std;
|
|||
#define ASSERT_HRESULT_SUCCEEDED VERIFY_SUCCEEDED
|
||||
#ifndef EXPECT_EQ
|
||||
#define EXPECT_EQ(expected, actual) VERIFY_ARE_EQUAL(expected, actual)
|
||||
#endif
|
||||
#endif
|
||||
#endif // VERIFY_ARE_EQUAL
|
||||
|
||||
static constexpr char whitespaceChars[] = " \t\r\n";
|
||||
|
@ -108,31 +119,39 @@ inline std::string strtrim(const std::string &value) {
|
|||
return strltrim(strrtrim(value));
|
||||
}
|
||||
|
||||
inline bool strstartswith(const std::string& value, const char* pattern) {
|
||||
for (size_t i = 0; ; ++i) {
|
||||
if (pattern[i] == '\0') return true;
|
||||
if (i == value.size() || value[i] != pattern[i]) return false;
|
||||
inline bool strstartswith(const std::string &value, const char *pattern) {
|
||||
for (size_t i = 0;; ++i) {
|
||||
if (pattern[i] == '\0')
|
||||
return true;
|
||||
if (i == value.size() || value[i] != pattern[i])
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
inline std::vector<std::string> strtok(const std::string &value, const char *delimiters = whitespaceChars) {
|
||||
inline std::vector<std::string>
|
||||
strtok(const std::string &value, const char *delimiters = whitespaceChars) {
|
||||
size_t searchOffset = 0;
|
||||
std::vector<std::string> tokens;
|
||||
while (searchOffset != value.size()) {
|
||||
size_t tokenStartIndex = value.find_first_not_of(delimiters, searchOffset);
|
||||
if (tokenStartIndex == std::string::npos) break;
|
||||
if (tokenStartIndex == std::string::npos)
|
||||
break;
|
||||
size_t tokenEndIndex = value.find_first_of(delimiters, tokenStartIndex);
|
||||
if (tokenEndIndex == std::string::npos) tokenEndIndex = value.size();
|
||||
tokens.emplace_back(value.substr(tokenStartIndex, tokenEndIndex - tokenStartIndex));
|
||||
if (tokenEndIndex == std::string::npos)
|
||||
tokenEndIndex = value.size();
|
||||
tokens.emplace_back(
|
||||
value.substr(tokenStartIndex, tokenEndIndex - tokenStartIndex));
|
||||
searchOffset = tokenEndIndex;
|
||||
}
|
||||
return tokens;
|
||||
}
|
||||
|
||||
// strreplace will replace all instances of lookFors with replacements at the same index.
|
||||
// Will log an error if the string is not found, unless the first character is ? marking it optional.
|
||||
inline void strreplace(const std::vector<std::string>& lookFors, const std::vector<std::string>& replacements,
|
||||
std::string& str) {
|
||||
// strreplace will replace all instances of lookFors with replacements at the
|
||||
// same index. Will log an error if the string is not found, unless the first
|
||||
// character is ? marking it optional.
|
||||
inline void strreplace(const std::vector<std::string> &lookFors,
|
||||
const std::vector<std::string> &replacements,
|
||||
std::string &str) {
|
||||
for (unsigned i = 0; i < lookFors.size(); ++i) {
|
||||
bool bOptional = false;
|
||||
bool found = false;
|
||||
|
@ -158,8 +177,8 @@ inline void strreplace(const std::vector<std::string>& lookFors, const std::vect
|
|||
if (!bOptional) {
|
||||
if (!found) {
|
||||
WEX::Logging::Log::Comment(WEX::Common::String().Format(
|
||||
L"String not found: '%S' in text:\r\n%.*S", pLookFor,
|
||||
(unsigned)str.size(), str.data()));
|
||||
L"String not found: '%S' in text:\r\n%.*S", pLookFor,
|
||||
(unsigned)str.size(), str.data()));
|
||||
}
|
||||
VERIFY_IS_TRUE(found);
|
||||
}
|
||||
|
@ -208,22 +227,32 @@ inline void LogErrorFmt(const wchar_t *fmt, ...) {
|
|||
WEX::Logging::Log::Error(buf.data());
|
||||
}
|
||||
|
||||
inline std::wstring GetPathToHlslDataFile(const wchar_t* relative, LPCWSTR paramName = HLSLDATAFILEPARAM, LPCWSTR defaultDataDir = DEFAULT_TEST_DIR) {
|
||||
WEX::TestExecution::SetVerifyOutput verifySettings(WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
|
||||
inline std::wstring
|
||||
GetPathToHlslDataFile(const wchar_t *relative,
|
||||
LPCWSTR paramName = HLSLDATAFILEPARAM,
|
||||
LPCWSTR defaultDataDir = DEFAULT_TEST_DIR) {
|
||||
WEX::TestExecution::SetVerifyOutput verifySettings(
|
||||
WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
|
||||
WEX::Common::String HlslDataDirValue;
|
||||
if (std::wstring(paramName).compare(HLSLDATAFILEPARAM) != 0) {
|
||||
// Not fatal, for instance, FILECHECKDUMPDIRPARAM will dump files before running FileCheck, so they can be compared run to run
|
||||
if (FAILED(WEX::TestExecution::RuntimeParameters::TryGetValue(paramName, HlslDataDirValue)))
|
||||
// Not fatal, for instance, FILECHECKDUMPDIRPARAM will dump files before
|
||||
// running FileCheck, so they can be compared run to run
|
||||
if (FAILED(WEX::TestExecution::RuntimeParameters::TryGetValue(
|
||||
paramName, HlslDataDirValue)))
|
||||
return std::wstring();
|
||||
} else {
|
||||
if (FAILED(WEX::TestExecution::RuntimeParameters::TryGetValue(HLSLDATAFILEPARAM, HlslDataDirValue)))
|
||||
if (FAILED(WEX::TestExecution::RuntimeParameters::TryGetValue(
|
||||
HLSLDATAFILEPARAM, HlslDataDirValue)))
|
||||
HlslDataDirValue = defaultDataDir;
|
||||
}
|
||||
|
||||
wchar_t envPath[MAX_PATH];
|
||||
wchar_t expanded[MAX_PATH];
|
||||
swprintf_s(envPath, _countof(envPath), L"%ls\\%ls", reinterpret_cast<const wchar_t*>(HlslDataDirValue.GetBuffer()), relative);
|
||||
VERIFY_WIN32_BOOL_SUCCEEDED(ExpandEnvironmentStringsW(envPath, expanded, _countof(expanded)));
|
||||
swprintf_s(envPath, _countof(envPath), L"%ls\\%ls",
|
||||
reinterpret_cast<const wchar_t *>(HlslDataDirValue.GetBuffer()),
|
||||
relative);
|
||||
VERIFY_WIN32_BOOL_SUCCEEDED(
|
||||
ExpandEnvironmentStringsW(envPath, expanded, _countof(expanded)));
|
||||
return std::wstring(expanded);
|
||||
}
|
||||
|
||||
|
@ -239,14 +268,13 @@ inline bool PathLooksAbsolute(LPCWSTR name) {
|
|||
static bool HasRunLine(std::string &line) {
|
||||
const char *delimiters = " ;/";
|
||||
auto lineelems = strtok(line, delimiters);
|
||||
return !lineelems.empty() &&
|
||||
lineelems.front().compare("RUN:") == 0;
|
||||
return !lineelems.empty() && lineelems.front().compare("RUN:") == 0;
|
||||
}
|
||||
|
||||
inline std::vector<std::string> GetRunLines(const LPCWSTR name) {
|
||||
const std::wstring path = PathLooksAbsolute(name)
|
||||
? std::wstring(name)
|
||||
: hlsl_test::GetPathToHlslDataFile(name);
|
||||
? std::wstring(name)
|
||||
: hlsl_test::GetPathToHlslDataFile(name);
|
||||
#ifdef _WIN32
|
||||
std::ifstream infile(path);
|
||||
#else
|
||||
|
@ -297,30 +325,37 @@ inline std::string GetFirstLine(LPCWSTR name) {
|
|||
}
|
||||
|
||||
inline HANDLE CreateFileForReading(LPCWSTR path) {
|
||||
HANDLE sourceHandle = CreateFileW(path, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
|
||||
HANDLE sourceHandle =
|
||||
CreateFileW(path, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
|
||||
if (sourceHandle == INVALID_HANDLE_VALUE) {
|
||||
DWORD err = GetLastError();
|
||||
std::wstring errorMessage(FormatToWString(L"Unable to open file '%s', err=%u", path, err).c_str());
|
||||
std::wstring errorMessage(
|
||||
FormatToWString(L"Unable to open file '%s', err=%u", path, err)
|
||||
.c_str());
|
||||
VERIFY_SUCCEEDED(HRESULT_FROM_WIN32(err), errorMessage.c_str());
|
||||
}
|
||||
return sourceHandle;
|
||||
}
|
||||
|
||||
inline HANDLE CreateNewFileForReadWrite(LPCWSTR path) {
|
||||
HANDLE sourceHandle = CreateFileW(path, GENERIC_READ | GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
|
||||
HANDLE sourceHandle = CreateFileW(path, GENERIC_READ | GENERIC_WRITE, 0, 0,
|
||||
CREATE_ALWAYS, 0, 0);
|
||||
if (sourceHandle == INVALID_HANDLE_VALUE) {
|
||||
DWORD err = GetLastError();
|
||||
std::wstring errorMessage(FormatToWString(L"Unable to create file '%s', err=%u", path, err).c_str());
|
||||
std::wstring errorMessage(
|
||||
FormatToWString(L"Unable to create file '%s', err=%u", path, err)
|
||||
.c_str());
|
||||
VERIFY_SUCCEEDED(HRESULT_FROM_WIN32(err), errorMessage.c_str());
|
||||
}
|
||||
return sourceHandle;
|
||||
}
|
||||
|
||||
// Copy of Unicode::IsStarMatchT/IsStarMatchWide is included here to avoid the dependency on
|
||||
// DXC support libraries.
|
||||
template<typename TChar>
|
||||
inline static
|
||||
bool IsStarMatchT(const TChar *pMask, size_t maskLen, const TChar *pName, size_t nameLen, TChar star) {
|
||||
// Copy of Unicode::IsStarMatchT/IsStarMatchWide is included here to avoid the
|
||||
// dependency on DXC support libraries.
|
||||
template <typename TChar>
|
||||
inline static bool IsStarMatchT(const TChar *pMask, size_t maskLen,
|
||||
const TChar *pName, size_t nameLen,
|
||||
TChar star) {
|
||||
if (maskLen == 0 && nameLen == 0) {
|
||||
return true;
|
||||
}
|
||||
|
@ -338,8 +373,7 @@ bool IsStarMatchT(const TChar *pMask, size_t maskLen, const TChar *pName, size_t
|
|||
return false;
|
||||
}
|
||||
return 0 == memcmp(pMask, pName, sizeof(TChar) * maskLen);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Exact match.
|
||||
if (nameLen != maskLen) {
|
||||
return false;
|
||||
|
@ -348,7 +382,8 @@ bool IsStarMatchT(const TChar *pMask, size_t maskLen, const TChar *pName, size_t
|
|||
}
|
||||
}
|
||||
|
||||
inline bool IsStarMatchWide(const wchar_t *pMask, size_t maskLen, const wchar_t *pName, size_t nameLen) {
|
||||
inline bool IsStarMatchWide(const wchar_t *pMask, size_t maskLen,
|
||||
const wchar_t *pName, size_t nameLen) {
|
||||
return IsStarMatchT<wchar_t>(pMask, maskLen, pName, nameLen, L'*');
|
||||
}
|
||||
|
||||
|
@ -378,7 +413,7 @@ inline bool GetTestParamBool(LPCWSTR name) {
|
|||
inline bool GetTestParamUseWARP(bool defaultVal) {
|
||||
WEX::Common::String AdapterValue;
|
||||
if (FAILED(WEX::TestExecution::RuntimeParameters::TryGetValue(
|
||||
L"Adapter", AdapterValue))) {
|
||||
L"Adapter", AdapterValue))) {
|
||||
return defaultVal;
|
||||
}
|
||||
if ((defaultVal && AdapterValue.IsEmpty()) ||
|
||||
|
@ -388,19 +423,19 @@ inline bool GetTestParamUseWARP(bool defaultVal) {
|
|||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace hlsl_test
|
||||
|
||||
#ifdef FP_SUBNORMAL
|
||||
|
||||
inline bool isdenorm(float f) {
|
||||
return FP_SUBNORMAL == std::fpclassify(f);
|
||||
}
|
||||
inline bool isdenorm(float f) { return FP_SUBNORMAL == std::fpclassify(f); }
|
||||
|
||||
#else
|
||||
|
||||
inline bool isdenorm(float f) {
|
||||
return (std::numeric_limits<float>::denorm_min() <= f && f < std::numeric_limits<float>::min()) ||
|
||||
(-std::numeric_limits<float>::min() < f && f <= -std::numeric_limits<float>::denorm_min());
|
||||
return (std::numeric_limits<float>::denorm_min() <= f &&
|
||||
f < std::numeric_limits<float>::min()) ||
|
||||
(-std::numeric_limits<float>::min() < f &&
|
||||
f <= -std::numeric_limits<float>::denorm_min());
|
||||
}
|
||||
|
||||
#endif // FP_SUBNORMAL
|
||||
|
@ -421,9 +456,7 @@ static const uint16_t Float16NegDenorm = 0x8008;
|
|||
static const uint16_t Float16PosZero = 0x0000;
|
||||
static const uint16_t Float16NegZero = 0x8000;
|
||||
|
||||
inline bool GetSign(float x) {
|
||||
return std::signbit(x);
|
||||
}
|
||||
inline bool GetSign(float x) { return std::signbit(x); }
|
||||
|
||||
inline int GetMantissa(float x) {
|
||||
int bits = reinterpret_cast<int &>(x);
|
||||
|
@ -450,8 +483,9 @@ inline bool isnanFloat16(uint16_t val) {
|
|||
uint16_t ConvertFloat32ToFloat16(float val) throw();
|
||||
float ConvertFloat16ToFloat32(uint16_t val) throw();
|
||||
|
||||
inline bool CompareFloatULP(const float &fsrc, const float &fref, int ULPTolerance,
|
||||
hlsl::DXIL::Float32DenormMode mode = hlsl::DXIL::Float32DenormMode::Any) {
|
||||
inline bool CompareFloatULP(
|
||||
const float &fsrc, const float &fref, int ULPTolerance,
|
||||
hlsl::DXIL::Float32DenormMode mode = hlsl::DXIL::Float32DenormMode::Any) {
|
||||
if (fsrc == fref) {
|
||||
return true;
|
||||
}
|
||||
|
@ -471,8 +505,9 @@ inline bool CompareFloatULP(const float &fsrc, const float &fref, int ULPToleran
|
|||
return uDiff <= (unsigned int)ULPTolerance;
|
||||
}
|
||||
|
||||
inline bool CompareFloatEpsilon(const float &fsrc, const float &fref, float epsilon,
|
||||
hlsl::DXIL::Float32DenormMode mode = hlsl::DXIL::Float32DenormMode::Any) {
|
||||
inline bool CompareFloatEpsilon(
|
||||
const float &fsrc, const float &fref, float epsilon,
|
||||
hlsl::DXIL::Float32DenormMode mode = hlsl::DXIL::Float32DenormMode::Any) {
|
||||
if (fsrc == fref) {
|
||||
return true;
|
||||
}
|
||||
|
@ -491,12 +526,14 @@ inline bool CompareFloatEpsilon(const float &fsrc, const float &fref, float epsi
|
|||
}
|
||||
|
||||
// Compare using relative error (relative error < 2^{nRelativeExp})
|
||||
inline bool CompareFloatRelativeEpsilon(const float &fsrc, const float &fref, int nRelativeExp,
|
||||
hlsl::DXIL::Float32DenormMode mode = hlsl::DXIL::Float32DenormMode::Any) {
|
||||
inline bool CompareFloatRelativeEpsilon(
|
||||
const float &fsrc, const float &fref, int nRelativeExp,
|
||||
hlsl::DXIL::Float32DenormMode mode = hlsl::DXIL::Float32DenormMode::Any) {
|
||||
return CompareFloatULP(fsrc, fref, 23 - nRelativeExp, mode);
|
||||
}
|
||||
|
||||
inline bool CompareHalfULP(const uint16_t &fsrc, const uint16_t &fref, float ULPTolerance) {
|
||||
inline bool CompareHalfULP(const uint16_t &fsrc, const uint16_t &fref,
|
||||
float ULPTolerance) {
|
||||
if (fsrc == fref)
|
||||
return true;
|
||||
if (isnanFloat16(fsrc))
|
||||
|
@ -507,17 +544,19 @@ inline bool CompareHalfULP(const uint16_t &fsrc, const uint16_t &fref, float ULP
|
|||
return uDiff <= (unsigned int)ULPTolerance;
|
||||
}
|
||||
|
||||
inline bool CompareHalfEpsilon(const uint16_t &fsrc, const uint16_t &fref, float epsilon) {
|
||||
inline bool CompareHalfEpsilon(const uint16_t &fsrc, const uint16_t &fref,
|
||||
float epsilon) {
|
||||
if (fsrc == fref)
|
||||
return true;
|
||||
if (isnanFloat16(fsrc))
|
||||
return isnanFloat16(fref);
|
||||
float src_f32 = ConvertFloat16ToFloat32(fsrc);
|
||||
float ref_f32 = ConvertFloat16ToFloat32(fref);
|
||||
return std::abs(src_f32-ref_f32) < epsilon;
|
||||
return std::abs(src_f32 - ref_f32) < epsilon;
|
||||
}
|
||||
|
||||
inline bool CompareHalfRelativeEpsilon(const uint16_t &fsrc, const uint16_t &fref, int nRelativeExp) {
|
||||
inline bool CompareHalfRelativeEpsilon(const uint16_t &fsrc,
|
||||
const uint16_t &fref, int nRelativeExp) {
|
||||
return CompareHalfULP(fsrc, fref, (float)(10 - nRelativeExp));
|
||||
}
|
||||
|
||||
|
@ -525,76 +564,142 @@ inline bool CompareHalfRelativeEpsilon(const uint16_t &fsrc, const uint16_t &fre
|
|||
// returns the number of bytes per pixel for a given dxgi format
|
||||
// add more cases if different format needed to copy back resources
|
||||
inline UINT GetByteSizeForFormat(DXGI_FORMAT value) {
|
||||
switch (value) {
|
||||
case DXGI_FORMAT_R32G32B32A32_TYPELESS: return 16;
|
||||
case DXGI_FORMAT_R32G32B32A32_FLOAT: return 16;
|
||||
case DXGI_FORMAT_R32G32B32A32_UINT: return 16;
|
||||
case DXGI_FORMAT_R32G32B32A32_SINT: return 16;
|
||||
case DXGI_FORMAT_R32G32B32_TYPELESS: return 12;
|
||||
case DXGI_FORMAT_R32G32B32_FLOAT: return 12;
|
||||
case DXGI_FORMAT_R32G32B32_UINT: return 12;
|
||||
case DXGI_FORMAT_R32G32B32_SINT: return 12;
|
||||
case DXGI_FORMAT_R16G16B16A16_TYPELESS: return 8;
|
||||
case DXGI_FORMAT_R16G16B16A16_FLOAT: return 8;
|
||||
case DXGI_FORMAT_R16G16B16A16_UNORM: return 8;
|
||||
case DXGI_FORMAT_R16G16B16A16_UINT: return 8;
|
||||
case DXGI_FORMAT_R16G16B16A16_SNORM: return 8;
|
||||
case DXGI_FORMAT_R16G16B16A16_SINT: return 8;
|
||||
case DXGI_FORMAT_R32G32_TYPELESS: return 8;
|
||||
case DXGI_FORMAT_R32G32_FLOAT: return 8;
|
||||
case DXGI_FORMAT_R32G32_UINT: return 8;
|
||||
case DXGI_FORMAT_R32G32_SINT: return 8;
|
||||
case DXGI_FORMAT_R32G8X24_TYPELESS: return 8;
|
||||
case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: return 4;
|
||||
case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: return 4;
|
||||
case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: return 4;
|
||||
case DXGI_FORMAT_R10G10B10A2_TYPELESS: return 4;
|
||||
case DXGI_FORMAT_R10G10B10A2_UNORM: return 4;
|
||||
case DXGI_FORMAT_R10G10B10A2_UINT: return 4;
|
||||
case DXGI_FORMAT_R11G11B10_FLOAT: return 4;
|
||||
case DXGI_FORMAT_R8G8B8A8_TYPELESS: return 4;
|
||||
case DXGI_FORMAT_R8G8B8A8_UNORM: return 4;
|
||||
case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: return 4;
|
||||
case DXGI_FORMAT_R8G8B8A8_UINT: return 4;
|
||||
case DXGI_FORMAT_R8G8B8A8_SNORM: return 4;
|
||||
case DXGI_FORMAT_R8G8B8A8_SINT: return 4;
|
||||
case DXGI_FORMAT_R16G16_TYPELESS: return 4;
|
||||
case DXGI_FORMAT_R16G16_FLOAT: return 4;
|
||||
case DXGI_FORMAT_R16G16_UNORM: return 4;
|
||||
case DXGI_FORMAT_R16G16_UINT: return 4;
|
||||
case DXGI_FORMAT_R16G16_SNORM: return 4;
|
||||
case DXGI_FORMAT_R16G16_SINT: return 4;
|
||||
case DXGI_FORMAT_R32_TYPELESS: return 4;
|
||||
case DXGI_FORMAT_D32_FLOAT: return 4;
|
||||
case DXGI_FORMAT_R32_FLOAT: return 4;
|
||||
case DXGI_FORMAT_R32_UINT: return 4;
|
||||
case DXGI_FORMAT_R32_SINT: return 4;
|
||||
case DXGI_FORMAT_R24G8_TYPELESS: return 4;
|
||||
case DXGI_FORMAT_D24_UNORM_S8_UINT: return 4;
|
||||
case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: return 4;
|
||||
case DXGI_FORMAT_X24_TYPELESS_G8_UINT: return 4;
|
||||
case DXGI_FORMAT_R8G8_TYPELESS: return 2;
|
||||
case DXGI_FORMAT_R8G8_UNORM: return 2;
|
||||
case DXGI_FORMAT_R8G8_UINT: return 2;
|
||||
case DXGI_FORMAT_R8G8_SNORM: return 2;
|
||||
case DXGI_FORMAT_R8G8_SINT: return 2;
|
||||
case DXGI_FORMAT_R16_TYPELESS: return 2;
|
||||
case DXGI_FORMAT_R16_FLOAT: return 2;
|
||||
case DXGI_FORMAT_D16_UNORM: return 2;
|
||||
case DXGI_FORMAT_R16_UNORM: return 2;
|
||||
case DXGI_FORMAT_R16_UINT: return 2;
|
||||
case DXGI_FORMAT_R16_SNORM: return 2;
|
||||
case DXGI_FORMAT_R16_SINT: return 2;
|
||||
case DXGI_FORMAT_R8_TYPELESS: return 1;
|
||||
case DXGI_FORMAT_R8_UNORM: return 1;
|
||||
case DXGI_FORMAT_R8_UINT: return 1;
|
||||
case DXGI_FORMAT_R8_SNORM: return 1;
|
||||
case DXGI_FORMAT_R8_SINT: return 1;
|
||||
case DXGI_FORMAT_A8_UNORM: return 1;
|
||||
case DXGI_FORMAT_R1_UNORM: return 1;
|
||||
default:
|
||||
VERIFY_FAILED(E_INVALIDARG);
|
||||
return 0;
|
||||
}
|
||||
switch (value) {
|
||||
case DXGI_FORMAT_R32G32B32A32_TYPELESS:
|
||||
return 16;
|
||||
case DXGI_FORMAT_R32G32B32A32_FLOAT:
|
||||
return 16;
|
||||
case DXGI_FORMAT_R32G32B32A32_UINT:
|
||||
return 16;
|
||||
case DXGI_FORMAT_R32G32B32A32_SINT:
|
||||
return 16;
|
||||
case DXGI_FORMAT_R32G32B32_TYPELESS:
|
||||
return 12;
|
||||
case DXGI_FORMAT_R32G32B32_FLOAT:
|
||||
return 12;
|
||||
case DXGI_FORMAT_R32G32B32_UINT:
|
||||
return 12;
|
||||
case DXGI_FORMAT_R32G32B32_SINT:
|
||||
return 12;
|
||||
case DXGI_FORMAT_R16G16B16A16_TYPELESS:
|
||||
return 8;
|
||||
case DXGI_FORMAT_R16G16B16A16_FLOAT:
|
||||
return 8;
|
||||
case DXGI_FORMAT_R16G16B16A16_UNORM:
|
||||
return 8;
|
||||
case DXGI_FORMAT_R16G16B16A16_UINT:
|
||||
return 8;
|
||||
case DXGI_FORMAT_R16G16B16A16_SNORM:
|
||||
return 8;
|
||||
case DXGI_FORMAT_R16G16B16A16_SINT:
|
||||
return 8;
|
||||
case DXGI_FORMAT_R32G32_TYPELESS:
|
||||
return 8;
|
||||
case DXGI_FORMAT_R32G32_FLOAT:
|
||||
return 8;
|
||||
case DXGI_FORMAT_R32G32_UINT:
|
||||
return 8;
|
||||
case DXGI_FORMAT_R32G32_SINT:
|
||||
return 8;
|
||||
case DXGI_FORMAT_R32G8X24_TYPELESS:
|
||||
return 8;
|
||||
case DXGI_FORMAT_D32_FLOAT_S8X24_UINT:
|
||||
return 4;
|
||||
case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS:
|
||||
return 4;
|
||||
case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT:
|
||||
return 4;
|
||||
case DXGI_FORMAT_R10G10B10A2_TYPELESS:
|
||||
return 4;
|
||||
case DXGI_FORMAT_R10G10B10A2_UNORM:
|
||||
return 4;
|
||||
case DXGI_FORMAT_R10G10B10A2_UINT:
|
||||
return 4;
|
||||
case DXGI_FORMAT_R11G11B10_FLOAT:
|
||||
return 4;
|
||||
case DXGI_FORMAT_R8G8B8A8_TYPELESS:
|
||||
return 4;
|
||||
case DXGI_FORMAT_R8G8B8A8_UNORM:
|
||||
return 4;
|
||||
case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
|
||||
return 4;
|
||||
case DXGI_FORMAT_R8G8B8A8_UINT:
|
||||
return 4;
|
||||
case DXGI_FORMAT_R8G8B8A8_SNORM:
|
||||
return 4;
|
||||
case DXGI_FORMAT_R8G8B8A8_SINT:
|
||||
return 4;
|
||||
case DXGI_FORMAT_R16G16_TYPELESS:
|
||||
return 4;
|
||||
case DXGI_FORMAT_R16G16_FLOAT:
|
||||
return 4;
|
||||
case DXGI_FORMAT_R16G16_UNORM:
|
||||
return 4;
|
||||
case DXGI_FORMAT_R16G16_UINT:
|
||||
return 4;
|
||||
case DXGI_FORMAT_R16G16_SNORM:
|
||||
return 4;
|
||||
case DXGI_FORMAT_R16G16_SINT:
|
||||
return 4;
|
||||
case DXGI_FORMAT_R32_TYPELESS:
|
||||
return 4;
|
||||
case DXGI_FORMAT_D32_FLOAT:
|
||||
return 4;
|
||||
case DXGI_FORMAT_R32_FLOAT:
|
||||
return 4;
|
||||
case DXGI_FORMAT_R32_UINT:
|
||||
return 4;
|
||||
case DXGI_FORMAT_R32_SINT:
|
||||
return 4;
|
||||
case DXGI_FORMAT_R24G8_TYPELESS:
|
||||
return 4;
|
||||
case DXGI_FORMAT_D24_UNORM_S8_UINT:
|
||||
return 4;
|
||||
case DXGI_FORMAT_R24_UNORM_X8_TYPELESS:
|
||||
return 4;
|
||||
case DXGI_FORMAT_X24_TYPELESS_G8_UINT:
|
||||
return 4;
|
||||
case DXGI_FORMAT_R8G8_TYPELESS:
|
||||
return 2;
|
||||
case DXGI_FORMAT_R8G8_UNORM:
|
||||
return 2;
|
||||
case DXGI_FORMAT_R8G8_UINT:
|
||||
return 2;
|
||||
case DXGI_FORMAT_R8G8_SNORM:
|
||||
return 2;
|
||||
case DXGI_FORMAT_R8G8_SINT:
|
||||
return 2;
|
||||
case DXGI_FORMAT_R16_TYPELESS:
|
||||
return 2;
|
||||
case DXGI_FORMAT_R16_FLOAT:
|
||||
return 2;
|
||||
case DXGI_FORMAT_D16_UNORM:
|
||||
return 2;
|
||||
case DXGI_FORMAT_R16_UNORM:
|
||||
return 2;
|
||||
case DXGI_FORMAT_R16_UINT:
|
||||
return 2;
|
||||
case DXGI_FORMAT_R16_SNORM:
|
||||
return 2;
|
||||
case DXGI_FORMAT_R16_SINT:
|
||||
return 2;
|
||||
case DXGI_FORMAT_R8_TYPELESS:
|
||||
return 1;
|
||||
case DXGI_FORMAT_R8_UNORM:
|
||||
return 1;
|
||||
case DXGI_FORMAT_R8_UINT:
|
||||
return 1;
|
||||
case DXGI_FORMAT_R8_SNORM:
|
||||
return 1;
|
||||
case DXGI_FORMAT_R8_SINT:
|
||||
return 1;
|
||||
case DXGI_FORMAT_A8_UNORM:
|
||||
return 1;
|
||||
case DXGI_FORMAT_R1_UNORM:
|
||||
return 1;
|
||||
default:
|
||||
VERIFY_FAILED(E_INVALIDARG);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -20,79 +20,80 @@ using namespace RDAT;
|
|||
namespace dump {
|
||||
|
||||
void DumpRuntimeData(const RDAT::DxilRuntimeData &RDAT, DumpContext &d);
|
||||
template<typename RecordType>
|
||||
template <typename RecordType>
|
||||
void DumpRecordTable(const RDAT::RDATContext &ctx, DumpContext &d,
|
||||
const char *tableName, const RDAT::TableReader &table);
|
||||
template<typename RecordType>
|
||||
template <typename RecordType>
|
||||
void DumpRecordTableEntry(const RDAT::RDATContext &ctx, DumpContext &d,
|
||||
uint32_t i);
|
||||
|
||||
template<typename _RecordType>
|
||||
class RecordDumper : public _RecordType {
|
||||
template <typename _RecordType> class RecordDumper : public _RecordType {
|
||||
public:
|
||||
void Dump(const hlsl::RDAT::RDATContext &ctx, DumpContext &d) const;
|
||||
};
|
||||
|
||||
// Dump record starting at base fields, ending at the type specified.
|
||||
// Specialized for derived records
|
||||
template<typename _RecordType>
|
||||
void DumpWithBase(const hlsl::RDAT::RDATContext &ctx, DumpContext &d, const _RecordType *pRecord) {
|
||||
static_cast< const RecordDumper<_RecordType>* >(pRecord)->Dump(ctx, d);
|
||||
template <typename _RecordType>
|
||||
void DumpWithBase(const hlsl::RDAT::RDATContext &ctx, DumpContext &d,
|
||||
const _RecordType *pRecord) {
|
||||
static_cast<const RecordDumper<_RecordType> *>(pRecord)->Dump(ctx, d);
|
||||
}
|
||||
|
||||
template<typename _RecordType>
|
||||
template <typename _RecordType>
|
||||
class RecordRefDumper : public hlsl::RDAT::RecordRef<_RecordType> {
|
||||
public:
|
||||
RecordRefDumper(uint32_t index) { this->Index = index; }
|
||||
template<typename _DumpTy = _RecordType>
|
||||
template <typename _DumpTy = _RecordType>
|
||||
const char *TypeName(const hlsl::RDAT::RDATContext &ctx) const {
|
||||
if (const char *name = RecordRefDumper<_DumpTy>(this->Index).TypeNameDerived(ctx))
|
||||
if (const char *name =
|
||||
RecordRefDumper<_DumpTy>(this->Index).TypeNameDerived(ctx))
|
||||
return name;
|
||||
RecordRef<_DumpTy> rr = { this->Index };
|
||||
RecordRef<_DumpTy> rr = {this->Index};
|
||||
if (rr.Get(ctx))
|
||||
return RecordTraits<_DumpTy>::TypeName();
|
||||
return nullptr;
|
||||
}
|
||||
template<typename _DumpTy = _RecordType>
|
||||
template <typename _DumpTy = _RecordType>
|
||||
void Dump(const hlsl::RDAT::RDATContext &ctx, DumpContext &d) const {
|
||||
RecordRefDumper<_DumpTy> rrDumper(this->Index);
|
||||
if (const _DumpTy *ptr = rrDumper.Get(ctx)) {
|
||||
static_cast< const RecordDumper<_DumpTy>* >(ptr)->Dump(ctx, d);
|
||||
static_cast<const RecordDumper<_DumpTy> *>(ptr)->Dump(ctx, d);
|
||||
rrDumper.DumpDerived(ctx, d);
|
||||
}
|
||||
}
|
||||
// Specialized for base type to recurse into derived
|
||||
const char *TypeNameDerived(const hlsl::RDAT::RDATContext &ctx) const { return nullptr; }
|
||||
const char *TypeNameDerived(const hlsl::RDAT::RDATContext &ctx) const {
|
||||
return nullptr;
|
||||
}
|
||||
void DumpDerived(const hlsl::RDAT::RDATContext &ctx, DumpContext &d) const {}
|
||||
};
|
||||
|
||||
template<typename _T>
|
||||
template <typename _T>
|
||||
void DumpRecordValue(const hlsl::RDAT::RDATContext &ctx, DumpContext &d,
|
||||
const char *tyName, const char *memberName,
|
||||
const _T *memberPtr);
|
||||
|
||||
template<typename _T>
|
||||
template <typename _T>
|
||||
void DumpRecordRef(const hlsl::RDAT::RDATContext &ctx, DumpContext &d,
|
||||
const char *tyName, const char *memberName,
|
||||
hlsl::RDAT::RecordRef<_T> rr);
|
||||
|
||||
template<typename _T>
|
||||
template <typename _T>
|
||||
void DumpRecordArrayRef(const hlsl::RDAT::RDATContext &ctx, DumpContext &d,
|
||||
const char *tyName, const char *memberName,
|
||||
hlsl::RDAT::RecordArrayRef<_T> rar);
|
||||
|
||||
void DumpStringArray(const hlsl::RDAT::RDATContext &ctx, DumpContext &d,
|
||||
const char *memberName,
|
||||
hlsl::RDAT::RDATStringArray sa);
|
||||
const char *memberName, hlsl::RDAT::RDATStringArray sa);
|
||||
|
||||
void DumpIndexArray(const hlsl::RDAT::RDATContext &ctx, DumpContext &d,
|
||||
const char *memberName, uint32_t index);
|
||||
|
||||
void DumpBytesRef(const hlsl::RDAT::RDATContext &ctx, DumpContext &d,
|
||||
const char *memberName,
|
||||
hlsl::RDAT::BytesRef bytesRef);
|
||||
const char *memberName, hlsl::RDAT::BytesRef bytesRef);
|
||||
|
||||
template<typename _T>
|
||||
template <typename _T>
|
||||
void DumpValueArray(DumpContext &d, const char *memberName,
|
||||
const char *typeName, const void *valueArray,
|
||||
unsigned arraySize);
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
#include <unistd.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include "dxc/WinAdapter.h"
|
||||
#include "dxc/Support/WinFunctions.h"
|
||||
#include "dxc/WinAdapter.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#define MAX_PATH 260
|
||||
|
@ -62,16 +62,20 @@
|
|||
#define VERIFY_IS_GREATER_THAN_OR_EQUAL(greater, less) EXPECT_GE(greater, less)
|
||||
|
||||
#define VERIFY_IS_GREATER_THAN_2(greater, less) EXPECT_GT(greater, less)
|
||||
#define VERIFY_IS_GREATER_THAN_3(greater, less, msg) EXPECT_GT(greater, less) << msg
|
||||
#define VERIFY_IS_GREATER_THAN(...) MACRO_N(VERIFY_IS_GREATER_THAN_, __VA_ARGS__)
|
||||
#define VERIFY_IS_GREATER_THAN_3(greater, less, msg) \
|
||||
EXPECT_GT(greater, less) << msg
|
||||
#define VERIFY_IS_GREATER_THAN(...) \
|
||||
MACRO_N(VERIFY_IS_GREATER_THAN_, __VA_ARGS__)
|
||||
|
||||
#define VERIFY_IS_LESS_THAN_2(greater, less) EXPECT_LT(greater, less)
|
||||
#define VERIFY_IS_LESS_THAN_3(greater, less, msg) EXPECT_LT(greater, less) << msg
|
||||
#define VERIFY_IS_LESS_THAN_3(greater, less, msg) \
|
||||
EXPECT_LT(greater, less) << msg
|
||||
#define VERIFY_IS_LESS_THAN(...) MACRO_N(VERIFY_IS_LESS_THAN_, __VA_ARGS__)
|
||||
|
||||
#define VERIFY_WIN32_BOOL_SUCCEEDED_1(expr) EXPECT_TRUE(expr)
|
||||
#define VERIFY_WIN32_BOOL_SUCCEEDED_2(expr, msg) EXPECT_TRUE(expr) << msg
|
||||
#define VERIFY_WIN32_BOOL_SUCCEEDED(...) MACRO_N(VERIFY_WIN32_BOOL_SUCCEEDED_, __VA_ARGS__)
|
||||
#define VERIFY_WIN32_BOOL_SUCCEEDED(...) \
|
||||
MACRO_N(VERIFY_WIN32_BOOL_SUCCEEDED_, __VA_ARGS__)
|
||||
|
||||
#define VERIFY_FAIL(...) ADD_FAILURE() << __VA_ARGS__ ""
|
||||
|
||||
|
@ -167,8 +171,12 @@ HRESULT TryGetValue(const wchar_t *param, Common::String &retStr);
|
|||
} // namespace TestExecution
|
||||
namespace Logging {
|
||||
namespace Log {
|
||||
inline void StartGroup(const wchar_t *name) { wprintf(L"BEGIN TEST(S): <%ls>\n", name); }
|
||||
inline void EndGroup(const wchar_t *name) { wprintf(L"END TEST(S): <%ls>\n", name); }
|
||||
inline void StartGroup(const wchar_t *name) {
|
||||
wprintf(L"BEGIN TEST(S): <%ls>\n", name);
|
||||
}
|
||||
inline void EndGroup(const wchar_t *name) {
|
||||
wprintf(L"END TEST(S): <%ls>\n", name);
|
||||
}
|
||||
inline void Comment(const wchar_t *msg) {
|
||||
fputws(msg, stdout);
|
||||
fputwc(L'\n', stdout);
|
||||
|
|
|
@ -68,11 +68,10 @@
|
|||
#define STDMETHODCALLTYPE
|
||||
#define STDMETHODIMP_(type) type STDMETHODCALLTYPE
|
||||
#define STDMETHODIMP STDMETHODIMP_(HRESULT)
|
||||
#define STDMETHOD_(type,name) virtual STDMETHODIMP_(type) name
|
||||
#define STDMETHOD_(type, name) virtual STDMETHODIMP_(type) name
|
||||
#define STDMETHOD(name) STDMETHOD_(HRESULT, name)
|
||||
#define EXTERN_C extern "C"
|
||||
|
||||
|
||||
#define UNREFERENCED_PARAMETER(P) (void)(P)
|
||||
|
||||
#define RtlEqualMemory(Destination, Source, Length) \
|
||||
|
@ -561,17 +560,18 @@ template <typename T> inline void **IID_PPV_ARGS_Helper(T **pp) {
|
|||
#endif // __EMULATE_UUID
|
||||
|
||||
// Needed for d3d headers, but fail to create actual interfaces
|
||||
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) const GUID name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
|
||||
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
|
||||
const GUID name = {l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}}
|
||||
#define DECLSPEC_UUID(x)
|
||||
#define MIDL_INTERFACE(x) struct DECLSPEC_UUID(x)
|
||||
#define DECLARE_INTERFACE(iface) struct iface
|
||||
#define DECLARE_INTERFACE_(iface, parent) DECLARE_INTERFACE(iface) : parent
|
||||
#define DECLARE_INTERFACE(iface) struct iface
|
||||
#define DECLARE_INTERFACE_(iface, parent) DECLARE_INTERFACE(iface) : parent
|
||||
|
||||
//===--------------------- COM Interfaces ---------------------------------===//
|
||||
|
||||
CROSS_PLATFORM_UUIDOF(IUnknown, "00000000-0000-0000-C000-000000000046")
|
||||
struct IUnknown {
|
||||
IUnknown() {};
|
||||
IUnknown(){};
|
||||
virtual HRESULT QueryInterface(REFIID riid, void **ppvObject) = 0;
|
||||
virtual ULONG AddRef() = 0;
|
||||
virtual ULONG Release() = 0;
|
||||
|
@ -615,8 +615,10 @@ struct IStream : public ISequentialStream {
|
|||
|
||||
// These don't need stub implementations as they come from the DirectX Headers
|
||||
// They still need the __uuidof() though
|
||||
CROSS_PLATFORM_UUIDOF(ID3D12LibraryReflection, "8E349D19-54DB-4A56-9DC9-119D87BDB804")
|
||||
CROSS_PLATFORM_UUIDOF(ID3D12ShaderReflection, "5A58797D-A72C-478D-8BA2-EFC6B0EFE88E")
|
||||
CROSS_PLATFORM_UUIDOF(ID3D12LibraryReflection,
|
||||
"8E349D19-54DB-4A56-9DC9-119D87BDB804")
|
||||
CROSS_PLATFORM_UUIDOF(ID3D12ShaderReflection,
|
||||
"5A58797D-A72C-478D-8BA2-EFC6B0EFE88E")
|
||||
|
||||
//===--------------------- COM Pointer Types ------------------------------===//
|
||||
|
||||
|
@ -749,9 +751,10 @@ public:
|
|||
}
|
||||
|
||||
// NOTE: This conversion constructor is not part of the official CComPtr spec;
|
||||
// however, it is needed to convert CComPtr<Q> to CComPtr<T> where T derives from Q on Clang.
|
||||
// MSVC compiles this conversion as first a call to CComPtr<Q>::operator T*, followed by CComPtr<T>(T*),
|
||||
// but Clang fails to compile with error: no viable conversion from 'CComPtr<Q>' to 'CComPtr<T>'.
|
||||
// however, it is needed to convert CComPtr<Q> to CComPtr<T> where T derives
|
||||
// from Q on Clang. MSVC compiles this conversion as first a call to
|
||||
// CComPtr<Q>::operator T*, followed by CComPtr<T>(T*), but Clang fails to
|
||||
// compile with error: no viable conversion from 'CComPtr<Q>' to 'CComPtr<T>'.
|
||||
template <typename Q>
|
||||
CComPtr(const CComPtr<Q> &lp) throw() : CComPtrBase<T>(lp.p) {}
|
||||
|
||||
|
@ -978,39 +981,27 @@ private:
|
|||
HANDLE m_h;
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CComBSTR
|
||||
|
||||
class CComBSTR
|
||||
{
|
||||
class CComBSTR {
|
||||
public:
|
||||
BSTR m_str;
|
||||
CComBSTR() : m_str(nullptr) {};
|
||||
CComBSTR(int nSize, LPCWSTR sz);
|
||||
~CComBSTR() throw() {
|
||||
SysFreeString(m_str);
|
||||
}
|
||||
BSTR m_str;
|
||||
CComBSTR() : m_str(nullptr){};
|
||||
CComBSTR(int nSize, LPCWSTR sz);
|
||||
~CComBSTR() throw() { SysFreeString(m_str); }
|
||||
|
||||
operator BSTR() const throw()
|
||||
{
|
||||
return m_str;
|
||||
}
|
||||
operator BSTR() const throw() { return m_str; }
|
||||
|
||||
bool operator==(const CComBSTR &bstrSrc) const throw();
|
||||
bool operator==(const CComBSTR &bstrSrc) const throw();
|
||||
|
||||
BSTR* operator&() throw()
|
||||
{
|
||||
return &m_str;
|
||||
}
|
||||
|
||||
BSTR Detach() throw()
|
||||
{
|
||||
BSTR s = m_str;
|
||||
m_str = NULL;
|
||||
return s;
|
||||
}
|
||||
BSTR *operator&() throw() { return &m_str; }
|
||||
|
||||
BSTR Detach() throw() {
|
||||
BSTR s = m_str;
|
||||
m_str = NULL;
|
||||
return s;
|
||||
}
|
||||
};
|
||||
|
||||
//===--------- Convert argv to wchar ----------------===//
|
||||
|
@ -1020,7 +1011,7 @@ class WArgV {
|
|||
|
||||
public:
|
||||
WArgV(int argc, const char **argv);
|
||||
const wchar_t **argv() { return WCharPtrVector.data();}
|
||||
const wchar_t **argv() { return WCharPtrVector.data(); }
|
||||
};
|
||||
|
||||
#endif // __cplusplus
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -22,12 +22,12 @@ typedef struct ID3D10Blob ID3D10Blob;
|
|||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Intrinsic definitions.
|
||||
#define AR_QUAL_IN 0x0000000000000010ULL
|
||||
#define AR_QUAL_OUT 0x0000000000000020ULL
|
||||
#define AR_QUAL_REF 0x0000000000000040ULL
|
||||
#define AR_QUAL_CONST 0x0000000000000200ULL
|
||||
#define AR_QUAL_ROWMAJOR 0x0000000000000400ULL
|
||||
#define AR_QUAL_COLMAJOR 0x0000000000000800ULL
|
||||
#define AR_QUAL_IN 0x0000000000000010ULL
|
||||
#define AR_QUAL_OUT 0x0000000000000020ULL
|
||||
#define AR_QUAL_REF 0x0000000000000040ULL
|
||||
#define AR_QUAL_CONST 0x0000000000000200ULL
|
||||
#define AR_QUAL_ROWMAJOR 0x0000000000000400ULL
|
||||
#define AR_QUAL_COLMAJOR 0x0000000000000800ULL
|
||||
|
||||
#define AR_QUAL_IN_OUT (AR_QUAL_IN | AR_QUAL_OUT)
|
||||
|
||||
|
@ -37,12 +37,13 @@ static const BYTE INTRIN_TEMPLATE_FROM_FUNCTION = 0xfd;
|
|||
|
||||
// Use this enumeration to describe allowed templates (layouts) in intrinsics.
|
||||
enum LEGAL_INTRINSIC_TEMPLATES {
|
||||
LITEMPLATE_VOID = 0, // No return type.
|
||||
LITEMPLATE_SCALAR = 1, // Scalar types.
|
||||
LITEMPLATE_VECTOR = 2, // Vector types (eg. float3).
|
||||
LITEMPLATE_MATRIX = 3, // Matrix types (eg. float3x3).
|
||||
LITEMPLATE_ANY = 4, // Any one of scalar, vector or matrix types (but not object).
|
||||
LITEMPLATE_OBJECT = 5, // Object types.
|
||||
LITEMPLATE_VOID = 0, // No return type.
|
||||
LITEMPLATE_SCALAR = 1, // Scalar types.
|
||||
LITEMPLATE_VECTOR = 2, // Vector types (eg. float3).
|
||||
LITEMPLATE_MATRIX = 3, // Matrix types (eg. float3x3).
|
||||
LITEMPLATE_ANY =
|
||||
4, // Any one of scalar, vector or matrix types (but not object).
|
||||
LITEMPLATE_OBJECT = 5, // Object types.
|
||||
|
||||
LITEMPLATE_COUNT = 6
|
||||
};
|
||||
|
@ -120,33 +121,45 @@ static const BYTE IA_C2 = 0xf3;
|
|||
static const BYTE IA_SPECIAL_SLOTS = 4;
|
||||
|
||||
struct HLSL_INTRINSIC_ARGUMENT {
|
||||
LPCSTR pName; // Name of the argument; the first argument has the function name.
|
||||
UINT64 qwUsage; // A combination of AR_QUAL_IN|AR_QUAL_OUT|AR_QUAL_COLMAJOR|AR_QUAL_ROWMAJOR in parameter tables; other values possible elsewhere.
|
||||
LPCSTR
|
||||
pName; // Name of the argument; the first argument has the function name.
|
||||
UINT64 qwUsage; // A combination of
|
||||
// AR_QUAL_IN|AR_QUAL_OUT|AR_QUAL_COLMAJOR|AR_QUAL_ROWMAJOR in
|
||||
// parameter tables; other values possible elsewhere.
|
||||
|
||||
BYTE uTemplateId; // One of INTRIN_TEMPLATE_FROM_TYPE, INTRIN_TEMPLATE_VARARGS or the argument # the template (layout) must match (trivially itself).
|
||||
BYTE uLegalTemplates; // A LEGAL_INTRINSIC_TEMPLATES value for allowed templates.
|
||||
BYTE uComponentTypeId; // INTRIN_COMPTYPE_FROM_TYPE_ELT0, or the argument # the component (element type) must match (trivially itself).
|
||||
BYTE uLegalComponentTypes; // A LEGAL_INTRINSIC_COMPTYPES value for allowed components.
|
||||
BYTE uTemplateId; // One of INTRIN_TEMPLATE_FROM_TYPE, INTRIN_TEMPLATE_VARARGS
|
||||
// or the argument # the template (layout) must match
|
||||
// (trivially itself).
|
||||
BYTE uLegalTemplates; // A LEGAL_INTRINSIC_TEMPLATES value for allowed
|
||||
// templates.
|
||||
BYTE uComponentTypeId; // INTRIN_COMPTYPE_FROM_TYPE_ELT0, or the argument #
|
||||
// the component (element type) must match (trivially
|
||||
// itself).
|
||||
BYTE uLegalComponentTypes; // A LEGAL_INTRINSIC_COMPTYPES value for allowed
|
||||
// components.
|
||||
|
||||
BYTE uRows; // Required number of rows, or one of IA_R/IA_C/IA_R2/IA_C2 for matching input constraints.
|
||||
BYTE uCols; // Required number of cols, or one of IA_R/IA_C/IA_R2/IA_C2 for matching input constraints.
|
||||
BYTE uRows; // Required number of rows, or one of IA_R/IA_C/IA_R2/IA_C2 for
|
||||
// matching input constraints.
|
||||
BYTE uCols; // Required number of cols, or one of IA_R/IA_C/IA_R2/IA_C2 for
|
||||
// matching input constraints.
|
||||
};
|
||||
|
||||
struct HLSL_INTRINSIC {
|
||||
UINT Op; // Intrinsic Op ID
|
||||
BOOL bReadOnly; // Only read memory
|
||||
BOOL bReadNone; // Not read memory
|
||||
BOOL bIsWave; // Is a wave-sensitive op
|
||||
INT iOverloadParamIndex; // Parameter decide the overload type, -1 means ret type
|
||||
UINT uNumArgs; // Count of arguments in pArgs.
|
||||
const HLSL_INTRINSIC_ARGUMENT* pArgs; // Pointer to first argument.
|
||||
UINT Op; // Intrinsic Op ID
|
||||
BOOL bReadOnly; // Only read memory
|
||||
BOOL bReadNone; // Not read memory
|
||||
BOOL bIsWave; // Is a wave-sensitive op
|
||||
INT iOverloadParamIndex; // Parameter decide the overload type, -1 means ret
|
||||
// type
|
||||
UINT uNumArgs; // Count of arguments in pArgs.
|
||||
const HLSL_INTRINSIC_ARGUMENT *pArgs; // Pointer to first argument.
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Interfaces.
|
||||
CROSS_PLATFORM_UUIDOF(IDxcIntrinsicTable, "f0d4da3f-f863-4660-b8b4-dfd94ded6215")
|
||||
struct IDxcIntrinsicTable : public IUnknown
|
||||
{
|
||||
CROSS_PLATFORM_UUIDOF(IDxcIntrinsicTable,
|
||||
"f0d4da3f-f863-4660-b8b4-dfd94ded6215")
|
||||
struct IDxcIntrinsicTable : public IUnknown {
|
||||
public:
|
||||
virtual HRESULT STDMETHODCALLTYPE GetTableName(LPCSTR *pTableName) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE
|
||||
|
@ -154,32 +167,37 @@ public:
|
|||
const HLSL_INTRINSIC **pIntrinsic, UINT64 *pLookupCookie) = 0;
|
||||
|
||||
// Get the lowering strategy for an hlsl extension intrinsic.
|
||||
virtual HRESULT STDMETHODCALLTYPE GetLoweringStrategy(UINT opcode, LPCSTR *pStrategy) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE GetLoweringStrategy(UINT opcode,
|
||||
LPCSTR *pStrategy) = 0;
|
||||
|
||||
// Callback to support custom naming of hlsl extension intrinsic functions in dxil.
|
||||
// Return the empty string to get the default intrinsic name, which is the mangled
|
||||
// name of the high level intrinsic function.
|
||||
// Callback to support custom naming of hlsl extension intrinsic functions in
|
||||
// dxil. Return the empty string to get the default intrinsic name, which is
|
||||
// the mangled name of the high level intrinsic function.
|
||||
//
|
||||
// Overloaded intrinsics are supported by use of an overload place holder in the
|
||||
// name. The string "$o" in the name will be replaced by the return type of the
|
||||
// intrinsic.
|
||||
virtual HRESULT STDMETHODCALLTYPE GetIntrinsicName(UINT opcode, LPCSTR *pName) = 0;
|
||||
// Overloaded intrinsics are supported by use of an overload place holder in
|
||||
// the name. The string "$o" in the name will be replaced by the return type
|
||||
// of the intrinsic.
|
||||
virtual HRESULT STDMETHODCALLTYPE GetIntrinsicName(UINT opcode,
|
||||
LPCSTR *pName) = 0;
|
||||
|
||||
// Callback to support the 'dxil' lowering strategy.
|
||||
// Returns the dxil opcode that the intrinsic should use for lowering.
|
||||
virtual HRESULT STDMETHODCALLTYPE GetDxilOpCode(UINT opcode, UINT *pDxilOpcode) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE GetDxilOpCode(UINT opcode,
|
||||
UINT *pDxilOpcode) = 0;
|
||||
};
|
||||
|
||||
CROSS_PLATFORM_UUIDOF(IDxcSemanticDefineValidator, "1d063e4f-515a-4d57-a12a-431f6a44cfb9")
|
||||
struct IDxcSemanticDefineValidator : public IUnknown
|
||||
{
|
||||
CROSS_PLATFORM_UUIDOF(IDxcSemanticDefineValidator,
|
||||
"1d063e4f-515a-4d57-a12a-431f6a44cfb9")
|
||||
struct IDxcSemanticDefineValidator : public IUnknown {
|
||||
public:
|
||||
virtual HRESULT STDMETHODCALLTYPE GetSemanticDefineWarningsAndErrors(LPCSTR pName, LPCSTR pValue, IDxcBlobEncoding **ppWarningBlob, IDxcBlobEncoding **ppErrorBlob) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE GetSemanticDefineWarningsAndErrors(
|
||||
LPCSTR pName, LPCSTR pValue, IDxcBlobEncoding **ppWarningBlob,
|
||||
IDxcBlobEncoding **ppErrorBlob) = 0;
|
||||
};
|
||||
|
||||
CROSS_PLATFORM_UUIDOF(IDxcLangExtensions, "282a56b4-3f56-4360-98c7-9ea04a752272")
|
||||
struct IDxcLangExtensions : public IUnknown
|
||||
{
|
||||
CROSS_PLATFORM_UUIDOF(IDxcLangExtensions,
|
||||
"282a56b4-3f56-4360-98c7-9ea04a752272")
|
||||
struct IDxcLangExtensions : public IUnknown {
|
||||
public:
|
||||
/// <summary>
|
||||
/// Registers the name of a preprocessor define that has semantic meaning
|
||||
|
@ -187,39 +205,47 @@ public:
|
|||
/// </summary>
|
||||
virtual HRESULT STDMETHODCALLTYPE RegisterSemanticDefine(LPCWSTR name) = 0;
|
||||
/// <summary>Registers a name to exclude from semantic defines.</summary>
|
||||
virtual HRESULT STDMETHODCALLTYPE RegisterSemanticDefineExclusion(LPCWSTR name) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE
|
||||
RegisterSemanticDefineExclusion(LPCWSTR name) = 0;
|
||||
/// <summary>Registers a definition for compilation.</summary>
|
||||
virtual HRESULT STDMETHODCALLTYPE RegisterDefine(LPCWSTR name) = 0;
|
||||
/// <summary>Registers a table of built-in intrinsics.</summary>
|
||||
virtual HRESULT STDMETHODCALLTYPE
|
||||
RegisterIntrinsicTable(IDxcIntrinsicTable *pTable) = 0;
|
||||
/// <summary>Sets an (optional) validator for parsed semantic defines.<summary>
|
||||
/// This provides a hook to check that the semantic defines present in the source
|
||||
/// contain valid data. One validator is used to validate all parsed semantic defines.
|
||||
/// <summary>Sets an (optional) validator for parsed semantic
|
||||
/// defines.<summary> This provides a hook to check that the semantic defines
|
||||
/// present in the source contain valid data. One validator is used to
|
||||
/// validate all parsed semantic defines.
|
||||
virtual HRESULT STDMETHODCALLTYPE
|
||||
SetSemanticDefineValidator(IDxcSemanticDefineValidator *pValidator) = 0;
|
||||
/// <summary>Sets the name for the root metadata node used in DXIL to hold the semantic defines.</summary>
|
||||
virtual HRESULT STDMETHODCALLTYPE SetSemanticDefineMetaDataName(LPCSTR name) = 0;
|
||||
/// <summary>Sets the name for the root metadata node used in DXIL to hold the
|
||||
/// semantic defines.</summary>
|
||||
virtual HRESULT STDMETHODCALLTYPE
|
||||
SetSemanticDefineMetaDataName(LPCSTR name) = 0;
|
||||
};
|
||||
|
||||
CROSS_PLATFORM_UUIDOF(IDxcLangExtensions2, "2490C368-89EE-4491-A4B2-C6547B6C9381")
|
||||
CROSS_PLATFORM_UUIDOF(IDxcLangExtensions2,
|
||||
"2490C368-89EE-4491-A4B2-C6547B6C9381")
|
||||
struct IDxcLangExtensions2 : public IDxcLangExtensions {
|
||||
public:
|
||||
virtual HRESULT STDMETHODCALLTYPE SetTargetTriple(LPCSTR name) = 0;
|
||||
};
|
||||
|
||||
CROSS_PLATFORM_UUIDOF(IDxcLangExtensions3, "A1B19880-FB1F-4920-9BC5-50356483BAC1")
|
||||
CROSS_PLATFORM_UUIDOF(IDxcLangExtensions3,
|
||||
"A1B19880-FB1F-4920-9BC5-50356483BAC1")
|
||||
struct IDxcLangExtensions3 : public IDxcLangExtensions2 {
|
||||
public:
|
||||
/// Registers a semantic define which cannot be overriden using the flag -override-opt-semdefs
|
||||
virtual HRESULT STDMETHODCALLTYPE RegisterNonOptSemanticDefine(LPCWSTR name) = 0;
|
||||
/// Registers a semantic define which cannot be overriden using the flag
|
||||
/// -override-opt-semdefs
|
||||
virtual HRESULT STDMETHODCALLTYPE
|
||||
RegisterNonOptSemanticDefine(LPCWSTR name) = 0;
|
||||
};
|
||||
|
||||
CROSS_PLATFORM_UUIDOF(IDxcSystemAccess, "454b764f-3549-475b-958c-a7a6fcd05fbc")
|
||||
struct IDxcSystemAccess : public IUnknown
|
||||
{
|
||||
struct IDxcSystemAccess : public IUnknown {
|
||||
public:
|
||||
virtual HRESULT STDMETHODCALLTYPE EnumFiles(LPCWSTR fileName, IEnumSTATSTG** pResult) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE EnumFiles(LPCWSTR fileName,
|
||||
IEnumSTATSTG **pResult) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE OpenStorage(LPCWSTR lpFileName,
|
||||
DWORD dwDesiredAccess,
|
||||
DWORD dwShareMode,
|
||||
|
@ -241,7 +267,8 @@ public:
|
|||
virtual HRESULT STDMETHODCALLTYPE
|
||||
GetFileAttributesForStorage(LPCWSTR lpFileName, DWORD *pResult) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE DeleteStorage(LPCWSTR lpFileName) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE RemoveDirectoryStorage(LPCWSTR lpFileName) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE
|
||||
RemoveDirectoryStorage(LPCWSTR lpFileName) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE
|
||||
CreateDirectoryStorage(LPCWSTR lpPathName) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE GetCurrentDirectoryForStorage(
|
||||
|
@ -270,19 +297,21 @@ public:
|
|||
unsigned *columnCount) = 0;
|
||||
};
|
||||
|
||||
CROSS_PLATFORM_UUIDOF(IDxcContainerEventsHandler, "e991ca8d-2045-413c-a8b8-788b2c06e14d")
|
||||
struct IDxcContainerEventsHandler : public IUnknown
|
||||
{
|
||||
CROSS_PLATFORM_UUIDOF(IDxcContainerEventsHandler,
|
||||
"e991ca8d-2045-413c-a8b8-788b2c06e14d")
|
||||
struct IDxcContainerEventsHandler : public IUnknown {
|
||||
public:
|
||||
virtual HRESULT STDMETHODCALLTYPE
|
||||
OnDxilContainerBuilt(IDxcBlob *pSource, IDxcBlob **ppTarget) = 0;
|
||||
};
|
||||
|
||||
CROSS_PLATFORM_UUIDOF(IDxcContainerEvent, "0cfc5058-342b-4ff2-83f7-04c12aad3d01")
|
||||
struct IDxcContainerEvent : public IUnknown
|
||||
{
|
||||
CROSS_PLATFORM_UUIDOF(IDxcContainerEvent,
|
||||
"0cfc5058-342b-4ff2-83f7-04c12aad3d01")
|
||||
struct IDxcContainerEvent : public IUnknown {
|
||||
public:
|
||||
virtual HRESULT STDMETHODCALLTYPE RegisterDxilContainerEventHandler(IDxcContainerEventsHandler *pHandler, UINT64 *pCookie) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE UnRegisterDxilContainerEventHandler(UINT64 cookie) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE RegisterDxilContainerEventHandler(
|
||||
IDxcContainerEventsHandler *pHandler, UINT64 *pCookie) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE
|
||||
UnRegisterDxilContainerEventHandler(UINT64 cookie) = 0;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -14,42 +14,39 @@
|
|||
#define __DXC_DXR_FALLBACK_COMPILER_API__
|
||||
#include "dxcapi.h"
|
||||
|
||||
enum class ShaderType : unsigned int
|
||||
{
|
||||
Raygen,
|
||||
AnyHit,
|
||||
ClosestHit,
|
||||
Intersection,
|
||||
Miss,
|
||||
Callable,
|
||||
Lib,
|
||||
enum class ShaderType : unsigned int {
|
||||
Raygen,
|
||||
AnyHit,
|
||||
ClosestHit,
|
||||
Intersection,
|
||||
Miss,
|
||||
Callable,
|
||||
Lib,
|
||||
};
|
||||
|
||||
struct DxcShaderInfo
|
||||
{
|
||||
UINT32 Identifier;
|
||||
UINT32 StackSize;
|
||||
ShaderType Type;
|
||||
struct DxcShaderInfo {
|
||||
UINT32 Identifier;
|
||||
UINT32 StackSize;
|
||||
ShaderType Type;
|
||||
};
|
||||
|
||||
struct DxcShaderBytecode
|
||||
{
|
||||
LPBYTE pData;
|
||||
UINT32 Size;
|
||||
struct DxcShaderBytecode {
|
||||
LPBYTE pData;
|
||||
UINT32 Size;
|
||||
};
|
||||
|
||||
struct DxcExportDesc
|
||||
{
|
||||
LPCWSTR ExportToRename;
|
||||
LPCWSTR ExportName;
|
||||
struct DxcExportDesc {
|
||||
LPCWSTR ExportToRename;
|
||||
LPCWSTR ExportName;
|
||||
};
|
||||
|
||||
struct __declspec(uuid("76bb3c85-006d-4b72-9e10-63cd97df57f0"))
|
||||
IDxcDxrFallbackCompiler : public IUnknown {
|
||||
IDxcDxrFallbackCompiler : public IUnknown {
|
||||
|
||||
// If set to true then shaders not listed in pShaderNames in Compile() but
|
||||
// called by shaders in pShaderNames are added to the final computer shader.
|
||||
// Otherwise these are considered errors. This is intended for testing purposes.
|
||||
// If set to true then shaders not listed in pShaderNames in Compile() but
|
||||
// called by shaders in pShaderNames are added to the final computer shader.
|
||||
// Otherwise these are considered errors. This is intended for testing
|
||||
// purposes.
|
||||
virtual HRESULT STDMETHODCALLTYPE SetFindCalledShaders(bool val) = 0;
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SetDebugOutput(int val) = 0;
|
||||
|
@ -62,9 +59,9 @@ struct __declspec(uuid("76bb3c85-006d-4b72-9e10-63cd97df57f0"))
|
|||
const LPCWSTR pEntryName, DxcShaderBytecode *pShaderBytecode,
|
||||
void *pShaderInfo, IDxcOperationResult **ppResult) = 0;
|
||||
|
||||
// Compiles libs together to create a raytracing compute shader. One of the libs
|
||||
// should be the fallback implementation lib that defines functions like
|
||||
// Fallback_TraceRay(), Fallback_ReportHit(), etc. Fallback_TraceRay() should
|
||||
// Compiles libs together to create a raytracing compute shader. One of the
|
||||
// libs should be the fallback implementation lib that defines functions like
|
||||
// Fallback_TraceRay(), Fallback_ReportHit(), etc. Fallback_TraceRay() should
|
||||
// be one of the shader names so that it gets included in the compile.
|
||||
virtual HRESULT STDMETHODCALLTYPE Compile(
|
||||
DxcShaderBytecode *pLibs, // Array of libraries containing shaders
|
||||
|
@ -95,7 +92,8 @@ struct __declspec(uuid("76bb3c85-006d-4b72-9e10-63cd97df57f0"))
|
|||
};
|
||||
|
||||
// Note: __declspec(selectany) requires 'extern'
|
||||
// On Linux __declspec(selectany) is removed and using 'extern' results in link error.
|
||||
// On Linux __declspec(selectany) is removed and using 'extern' results in link
|
||||
// error.
|
||||
#ifdef _MSC_VER
|
||||
#define CLSID_SCOPE __declspec(selectany) extern
|
||||
#else
|
||||
|
@ -104,11 +102,10 @@ struct __declspec(uuid("76bb3c85-006d-4b72-9e10-63cd97df57f0"))
|
|||
|
||||
// {76bb3c85-006d-4b72-9e10-63cd97df57f0}
|
||||
CLSID_SCOPE const GUID CLSID_DxcDxrFallbackCompiler = {
|
||||
0x76bb3c85,
|
||||
0x006d,
|
||||
0x4b72,
|
||||
{ 0x9e, 0x10, 0x63, 0xcd, 0x97, 0xdf, 0x57, 0xf0 }
|
||||
};
|
||||
0x76bb3c85,
|
||||
0x006d,
|
||||
0x4b72,
|
||||
{0x9e, 0x10, 0x63, 0xcd, 0x97, 0xdf, 0x57, 0xf0}};
|
||||
|
||||
typedef HRESULT(__stdcall *DxcCreateDxrFallbackCompilerProc)(REFCLSID rclsid,
|
||||
REFIID riid,
|
||||
|
|
|
@ -16,13 +16,14 @@
|
|||
#define FACILITY_GRAPHICS 36
|
||||
#endif
|
||||
|
||||
#define DXC_EXCEPTION_CODE(name, status) \
|
||||
static constexpr DWORD EXCEPTION_##name = \
|
||||
(0xc0000000u | (FACILITY_GRAPHICS << 16) | (0xff00u | (status & 0xffu)));
|
||||
#define DXC_EXCEPTION_CODE(name, status) \
|
||||
static constexpr DWORD EXCEPTION_##name = \
|
||||
(0xc0000000u | (FACILITY_GRAPHICS << 16) | \
|
||||
(0xff00u | (status & 0xffu)));
|
||||
|
||||
DXC_EXCEPTION_CODE(LOAD_LIBRARY_FAILED, 0x00u)
|
||||
DXC_EXCEPTION_CODE(NO_HMODULE, 0x01u)
|
||||
DXC_EXCEPTION_CODE(GET_PROC_FAILED, 0x02u)
|
||||
DXC_EXCEPTION_CODE(NO_HMODULE, 0x01u)
|
||||
DXC_EXCEPTION_CODE(GET_PROC_FAILED, 0x02u)
|
||||
|
||||
#undef DXC_EXCEPTION_CODE
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче