Updated for latest d3dx12.h (10.0.15063)
This commit is contained in:
Родитель
fee69fe44b
Коммит
d63b144be2
516
Src/d3dx12.h
516
Src/d3dx12.h
|
@ -232,6 +232,105 @@ struct CD3DX12_DEPTH_STENCIL_DESC : public D3D12_DEPTH_STENCIL_DESC
|
|||
operator const D3D12_DEPTH_STENCIL_DESC&() const { return *this; }
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// Requires the Windows 10 Creators Update SDK (15063)
|
||||
#if defined(NTDDI_WIN10_RS2) && (NTDDI_VERSION >= NTDDI_WIN10_RS2)
|
||||
struct CD3DX12_DEPTH_STENCIL_DESC1 : public D3D12_DEPTH_STENCIL_DESC1
|
||||
{
|
||||
CD3DX12_DEPTH_STENCIL_DESC1()
|
||||
{}
|
||||
explicit CD3DX12_DEPTH_STENCIL_DESC1( const D3D12_DEPTH_STENCIL_DESC1& o ) :
|
||||
D3D12_DEPTH_STENCIL_DESC1( o )
|
||||
{}
|
||||
explicit CD3DX12_DEPTH_STENCIL_DESC1( const D3D12_DEPTH_STENCIL_DESC& o )
|
||||
{
|
||||
DepthEnable = o.DepthEnable;
|
||||
DepthWriteMask = o.DepthWriteMask;
|
||||
DepthFunc = o.DepthFunc;
|
||||
StencilEnable = o.StencilEnable;
|
||||
StencilReadMask = o.StencilReadMask;
|
||||
StencilWriteMask = o.StencilWriteMask;
|
||||
FrontFace.StencilFailOp = o.FrontFace.StencilFailOp;
|
||||
FrontFace.StencilDepthFailOp = o.FrontFace.StencilDepthFailOp;
|
||||
FrontFace.StencilPassOp = o.FrontFace.StencilPassOp;
|
||||
FrontFace.StencilFunc = o.FrontFace.StencilFunc;
|
||||
BackFace.StencilFailOp = o.BackFace.StencilFailOp;
|
||||
BackFace.StencilDepthFailOp = o.BackFace.StencilDepthFailOp;
|
||||
BackFace.StencilPassOp = o.BackFace.StencilPassOp;
|
||||
BackFace.StencilFunc = o.BackFace.StencilFunc;
|
||||
DepthBoundsTestEnable = FALSE;
|
||||
}
|
||||
explicit CD3DX12_DEPTH_STENCIL_DESC1( CD3DX12_DEFAULT )
|
||||
{
|
||||
DepthEnable = TRUE;
|
||||
DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL;
|
||||
DepthFunc = D3D12_COMPARISON_FUNC_LESS;
|
||||
StencilEnable = FALSE;
|
||||
StencilReadMask = D3D12_DEFAULT_STENCIL_READ_MASK;
|
||||
StencilWriteMask = D3D12_DEFAULT_STENCIL_WRITE_MASK;
|
||||
const D3D12_DEPTH_STENCILOP_DESC defaultStencilOp =
|
||||
{ D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_COMPARISON_FUNC_ALWAYS };
|
||||
FrontFace = defaultStencilOp;
|
||||
BackFace = defaultStencilOp;
|
||||
DepthBoundsTestEnable = FALSE;
|
||||
}
|
||||
explicit CD3DX12_DEPTH_STENCIL_DESC1(
|
||||
BOOL depthEnable,
|
||||
D3D12_DEPTH_WRITE_MASK depthWriteMask,
|
||||
D3D12_COMPARISON_FUNC depthFunc,
|
||||
BOOL stencilEnable,
|
||||
UINT8 stencilReadMask,
|
||||
UINT8 stencilWriteMask,
|
||||
D3D12_STENCIL_OP frontStencilFailOp,
|
||||
D3D12_STENCIL_OP frontStencilDepthFailOp,
|
||||
D3D12_STENCIL_OP frontStencilPassOp,
|
||||
D3D12_COMPARISON_FUNC frontStencilFunc,
|
||||
D3D12_STENCIL_OP backStencilFailOp,
|
||||
D3D12_STENCIL_OP backStencilDepthFailOp,
|
||||
D3D12_STENCIL_OP backStencilPassOp,
|
||||
D3D12_COMPARISON_FUNC backStencilFunc,
|
||||
BOOL depthBoundsTestEnable )
|
||||
{
|
||||
DepthEnable = depthEnable;
|
||||
DepthWriteMask = depthWriteMask;
|
||||
DepthFunc = depthFunc;
|
||||
StencilEnable = stencilEnable;
|
||||
StencilReadMask = stencilReadMask;
|
||||
StencilWriteMask = stencilWriteMask;
|
||||
FrontFace.StencilFailOp = frontStencilFailOp;
|
||||
FrontFace.StencilDepthFailOp = frontStencilDepthFailOp;
|
||||
FrontFace.StencilPassOp = frontStencilPassOp;
|
||||
FrontFace.StencilFunc = frontStencilFunc;
|
||||
BackFace.StencilFailOp = backStencilFailOp;
|
||||
BackFace.StencilDepthFailOp = backStencilDepthFailOp;
|
||||
BackFace.StencilPassOp = backStencilPassOp;
|
||||
BackFace.StencilFunc = backStencilFunc;
|
||||
DepthBoundsTestEnable = depthBoundsTestEnable;
|
||||
}
|
||||
~CD3DX12_DEPTH_STENCIL_DESC1() {}
|
||||
operator const D3D12_DEPTH_STENCIL_DESC1&() const { return *this; }
|
||||
operator const D3D12_DEPTH_STENCIL_DESC() const
|
||||
{
|
||||
D3D12_DEPTH_STENCIL_DESC D;
|
||||
D.DepthEnable = DepthEnable;
|
||||
D.DepthWriteMask = DepthWriteMask;
|
||||
D.DepthFunc = DepthFunc;
|
||||
D.StencilEnable = StencilEnable;
|
||||
D.StencilReadMask = StencilReadMask;
|
||||
D.StencilWriteMask = StencilWriteMask;
|
||||
D.FrontFace.StencilFailOp = FrontFace.StencilFailOp;
|
||||
D.FrontFace.StencilDepthFailOp = FrontFace.StencilDepthFailOp;
|
||||
D.FrontFace.StencilPassOp = FrontFace.StencilPassOp;
|
||||
D.FrontFace.StencilFunc = FrontFace.StencilFunc;
|
||||
D.BackFace.StencilFailOp = BackFace.StencilFailOp;
|
||||
D.BackFace.StencilDepthFailOp = BackFace.StencilDepthFailOp;
|
||||
D.BackFace.StencilPassOp = BackFace.StencilPassOp;
|
||||
D.BackFace.StencilFunc = BackFace.StencilFunc;
|
||||
return D;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
struct CD3DX12_BLEND_DESC : public D3D12_BLEND_DESC
|
||||
{
|
||||
|
@ -509,6 +608,54 @@ struct CD3DX12_RANGE : public D3D12_RANGE
|
|||
operator const D3D12_RANGE&() const { return *this; }
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// Requires the Windows 10 Creators Update SDK (15063)
|
||||
#if defined(NTDDI_WIN10_RS2) && (NTDDI_VERSION >= NTDDI_WIN10_RS2)
|
||||
struct CD3DX12_RANGE_UINT64 : public D3D12_RANGE_UINT64
|
||||
{
|
||||
CD3DX12_RANGE_UINT64()
|
||||
{}
|
||||
explicit CD3DX12_RANGE_UINT64(const D3D12_RANGE_UINT64 &o) :
|
||||
D3D12_RANGE_UINT64(o)
|
||||
{}
|
||||
CD3DX12_RANGE_UINT64(
|
||||
UINT64 begin,
|
||||
UINT64 end )
|
||||
{
|
||||
Begin = begin;
|
||||
End = end;
|
||||
}
|
||||
operator const D3D12_RANGE_UINT64&() const { return *this; }
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
struct CD3DX12_SUBRESOURCE_RANGE_UINT64 : public D3D12_SUBRESOURCE_RANGE_UINT64
|
||||
{
|
||||
CD3DX12_SUBRESOURCE_RANGE_UINT64()
|
||||
{}
|
||||
explicit CD3DX12_SUBRESOURCE_RANGE_UINT64(const D3D12_SUBRESOURCE_RANGE_UINT64 &o) :
|
||||
D3D12_SUBRESOURCE_RANGE_UINT64(o)
|
||||
{}
|
||||
CD3DX12_SUBRESOURCE_RANGE_UINT64(
|
||||
UINT subresource,
|
||||
const D3D12_RANGE_UINT64& range )
|
||||
{
|
||||
Subresource = subresource;
|
||||
Range = range;
|
||||
}
|
||||
CD3DX12_SUBRESOURCE_RANGE_UINT64(
|
||||
UINT subresource,
|
||||
UINT64 begin,
|
||||
UINT64 end )
|
||||
{
|
||||
Subresource = subresource;
|
||||
Range.Begin = begin;
|
||||
Range.End = end;
|
||||
}
|
||||
operator const D3D12_SUBRESOURCE_RANGE_UINT64&() const { return *this; }
|
||||
};
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
struct CD3DX12_SHADER_BYTECODE : public D3D12_SHADER_BYTECODE
|
||||
{
|
||||
|
@ -524,7 +671,7 @@ struct CD3DX12_SHADER_BYTECODE : public D3D12_SHADER_BYTECODE
|
|||
BytecodeLength = pShaderBlob->GetBufferSize();
|
||||
}
|
||||
CD3DX12_SHADER_BYTECODE(
|
||||
_In_reads_(bytecodeLength) const void* _pShaderBytecode,
|
||||
const void* _pShaderBytecode,
|
||||
SIZE_T bytecodeLength )
|
||||
{
|
||||
pShaderBytecode = _pShaderBytecode;
|
||||
|
@ -1902,7 +2049,8 @@ inline bool D3D12IsLayoutOpaque( D3D12_TEXTURE_LAYOUT Layout )
|
|||
{ return Layout == D3D12_TEXTURE_LAYOUT_UNKNOWN || Layout == D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE; }
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
inline ID3D12CommandList * const * CommandListCast(ID3D12GraphicsCommandList * const * pp)
|
||||
template <typename t_CommandListType>
|
||||
inline ID3D12CommandList * const * CommandListCast(t_CommandListType * const * pp)
|
||||
{
|
||||
// This cast is useful for passing strongly typed command list pointers into
|
||||
// ExecuteCommandLists.
|
||||
|
@ -2031,6 +2179,370 @@ inline HRESULT D3DX12SerializeVersionedRootSignature(
|
|||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// Requires the Windows 10 Creators Update SDK (15063)
|
||||
#if defined(NTDDI_WIN10_RS2) && (NTDDI_VERSION >= NTDDI_WIN10_RS2)
|
||||
struct CD3DX12_RT_FORMAT_ARRAY : public D3D12_RT_FORMAT_ARRAY
|
||||
{
|
||||
CD3DX12_RT_FORMAT_ARRAY() {}
|
||||
explicit CD3DX12_RT_FORMAT_ARRAY(const D3D12_RT_FORMAT_ARRAY& o)
|
||||
: D3D12_RT_FORMAT_ARRAY(o)
|
||||
{}
|
||||
explicit CD3DX12_RT_FORMAT_ARRAY(const DXGI_FORMAT* pFormats, UINT NumFormats)
|
||||
{
|
||||
NumRenderTargets = NumFormats;
|
||||
memcpy(RTFormats, pFormats, sizeof(RTFormats));
|
||||
// assumes ARRAY_SIZE(pFormats) == ARRAY_SIZE(RTFormats)
|
||||
}
|
||||
operator const D3D12_RT_FORMAT_ARRAY&() const { return *this; }
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// Pipeline State Stream Helpers
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// Stream Subobjects, i.e. elements of a stream
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4324)
|
||||
template <typename InnerStructType, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE Type, typename DefaultArg = InnerStructType>
|
||||
class alignas(void*) CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT
|
||||
{
|
||||
private:
|
||||
D3D12_PIPELINE_STATE_SUBOBJECT_TYPE _Type;
|
||||
InnerStructType _Inner;
|
||||
public:
|
||||
CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT() : _Type(Type), _Inner(DefaultArg()) {}
|
||||
CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT(InnerStructType const& i) : _Type(Type), _Inner(i) {}
|
||||
CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT& operator=(InnerStructType const& i) { _Inner = i; return *this; }
|
||||
operator InnerStructType() const { return _Inner; }
|
||||
};
|
||||
#pragma warning(pop)
|
||||
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_PIPELINE_STATE_FLAGS, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_FLAGS> CD3DX12_PIPELINE_STATE_STREAM_FLAGS;
|
||||
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< UINT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_NODE_MASK> CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK;
|
||||
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< ID3D12RootSignature*, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE> CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE;
|
||||
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_INPUT_LAYOUT_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_INPUT_LAYOUT> CD3DX12_PIPELINE_STATE_STREAM_INPUT_LAYOUT;
|
||||
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_INDEX_BUFFER_STRIP_CUT_VALUE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_IB_STRIP_CUT_VALUE> CD3DX12_PIPELINE_STATE_STREAM_IB_STRIP_CUT_VALUE;
|
||||
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_PRIMITIVE_TOPOLOGY_TYPE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PRIMITIVE_TOPOLOGY> CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY;
|
||||
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VS> CD3DX12_PIPELINE_STATE_STREAM_VS;
|
||||
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_GS> CD3DX12_PIPELINE_STATE_STREAM_GS;
|
||||
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_STREAM_OUTPUT_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_STREAM_OUTPUT> CD3DX12_PIPELINE_STATE_STREAM_STREAM_OUTPUT;
|
||||
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_HS> CD3DX12_PIPELINE_STATE_STREAM_HS;
|
||||
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DS> CD3DX12_PIPELINE_STATE_STREAM_DS;
|
||||
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PS> CD3DX12_PIPELINE_STATE_STREAM_PS;
|
||||
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CS> CD3DX12_PIPELINE_STATE_STREAM_CS;
|
||||
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_BLEND_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_BLEND, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC;
|
||||
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_DEPTH_STENCIL_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL;
|
||||
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_DEPTH_STENCIL_DESC1, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL1;
|
||||
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< DXGI_FORMAT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL_FORMAT> CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT;
|
||||
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_RASTERIZER_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER;
|
||||
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_RT_FORMAT_ARRAY, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RENDER_TARGET_FORMATS> CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS;
|
||||
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< DXGI_SAMPLE_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_DESC> CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC;
|
||||
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< UINT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_MASK> CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK;
|
||||
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_CACHED_PIPELINE_STATE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CACHED_PSO> CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO;
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// Stream Parser Helpers
|
||||
|
||||
struct ID3DX12PipelineParserCallbacks
|
||||
{
|
||||
// Subobject Callbacks
|
||||
virtual void FlagsCb(D3D12_PIPELINE_STATE_FLAGS) {}
|
||||
virtual void NodeMaskCb(UINT) {}
|
||||
virtual void RootSignatureCb(ID3D12RootSignature*) {}
|
||||
virtual void InputLayoutCb(const D3D12_INPUT_LAYOUT_DESC&) {}
|
||||
virtual void IBStripCutValueCb(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE) {}
|
||||
virtual void PrimitiveTopologyTypeCb(D3D12_PRIMITIVE_TOPOLOGY_TYPE) {}
|
||||
virtual void VSCb(const D3D12_SHADER_BYTECODE&) {}
|
||||
virtual void GSCb(const D3D12_SHADER_BYTECODE&) {}
|
||||
virtual void StreamOutputCb(const D3D12_STREAM_OUTPUT_DESC&) {}
|
||||
virtual void HSCb(const D3D12_SHADER_BYTECODE&) {}
|
||||
virtual void DSCb(const D3D12_SHADER_BYTECODE&) {}
|
||||
virtual void PSCb(const D3D12_SHADER_BYTECODE&) {}
|
||||
virtual void CSCb(const D3D12_SHADER_BYTECODE&) {}
|
||||
virtual void BlendStateCb(const D3D12_BLEND_DESC&) {}
|
||||
virtual void DepthStencilStateCb(const D3D12_DEPTH_STENCIL_DESC&) {}
|
||||
virtual void DepthStencilState1Cb(const D3D12_DEPTH_STENCIL_DESC1&) {}
|
||||
virtual void DSVFormatCb(DXGI_FORMAT) {}
|
||||
virtual void RasterizerStateCb(const D3D12_RASTERIZER_DESC&) {}
|
||||
virtual void RTVFormatsCb(const D3D12_RT_FORMAT_ARRAY&) {}
|
||||
virtual void SampleDescCb(const DXGI_SAMPLE_DESC&) {}
|
||||
virtual void SampleMaskCb(UINT) {}
|
||||
virtual void CachedPSOCb(const D3D12_CACHED_PIPELINE_STATE&) {}
|
||||
|
||||
// Error Callbacks
|
||||
virtual void ErrorBadInputParameter(UINT /*ParameterIndex*/) {}
|
||||
virtual void ErrorDuplicateSubobject(D3D12_PIPELINE_STATE_SUBOBJECT_TYPE /*DuplicateType*/) {}
|
||||
virtual void ErrorUnknownSubobject(UINT /*UnknownTypeValue*/) {}
|
||||
|
||||
};
|
||||
|
||||
struct CD3DX12_PIPELINE_STATE_STREAM
|
||||
{
|
||||
CD3DX12_PIPELINE_STATE_STREAM() {}
|
||||
CD3DX12_PIPELINE_STATE_STREAM(const D3D12_GRAPHICS_PIPELINE_STATE_DESC& Desc)
|
||||
: Flags(Desc.Flags)
|
||||
, NodeMask(Desc.NodeMask)
|
||||
, pRootSignature(Desc.pRootSignature)
|
||||
, InputLayout(Desc.InputLayout)
|
||||
, IBStripCutValue(Desc.IBStripCutValue)
|
||||
, PrimitiveTopologyType(Desc.PrimitiveTopologyType)
|
||||
, VS(Desc.VS)
|
||||
, GS(Desc.GS)
|
||||
, StreamOutput(Desc.StreamOutput)
|
||||
, HS(Desc.HS)
|
||||
, DS(Desc.DS)
|
||||
, PS(Desc.PS)
|
||||
, BlendState(CD3DX12_BLEND_DESC(Desc.BlendState))
|
||||
, DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC1(Desc.DepthStencilState))
|
||||
, DSVFormat(Desc.DSVFormat)
|
||||
, RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState))
|
||||
, RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets))
|
||||
, SampleDesc(Desc.SampleDesc)
|
||||
, SampleMask(Desc.SampleMask)
|
||||
, CachedPSO(Desc.CachedPSO)
|
||||
{}
|
||||
CD3DX12_PIPELINE_STATE_STREAM(const D3D12_COMPUTE_PIPELINE_STATE_DESC& Desc)
|
||||
: Flags(Desc.Flags)
|
||||
, NodeMask(Desc.NodeMask)
|
||||
, pRootSignature(Desc.pRootSignature)
|
||||
, CS(CD3DX12_SHADER_BYTECODE(Desc.CS))
|
||||
, CachedPSO(Desc.CachedPSO)
|
||||
{}
|
||||
CD3DX12_PIPELINE_STATE_STREAM_FLAGS Flags;
|
||||
CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK NodeMask;
|
||||
CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE pRootSignature;
|
||||
CD3DX12_PIPELINE_STATE_STREAM_INPUT_LAYOUT InputLayout;
|
||||
CD3DX12_PIPELINE_STATE_STREAM_IB_STRIP_CUT_VALUE IBStripCutValue;
|
||||
CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY PrimitiveTopologyType;
|
||||
CD3DX12_PIPELINE_STATE_STREAM_VS VS;
|
||||
CD3DX12_PIPELINE_STATE_STREAM_GS GS;
|
||||
CD3DX12_PIPELINE_STATE_STREAM_STREAM_OUTPUT StreamOutput;
|
||||
CD3DX12_PIPELINE_STATE_STREAM_HS HS;
|
||||
CD3DX12_PIPELINE_STATE_STREAM_DS DS;
|
||||
CD3DX12_PIPELINE_STATE_STREAM_PS PS;
|
||||
CD3DX12_PIPELINE_STATE_STREAM_CS CS;
|
||||
CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC BlendState;
|
||||
CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL1 DepthStencilState;
|
||||
CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT DSVFormat;
|
||||
CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER RasterizerState;
|
||||
CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS RTVFormats;
|
||||
CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC SampleDesc;
|
||||
CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK SampleMask;
|
||||
CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO CachedPSO;
|
||||
D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0() const
|
||||
{
|
||||
D3D12_GRAPHICS_PIPELINE_STATE_DESC D;
|
||||
D.Flags = this->Flags;
|
||||
D.NodeMask = this->NodeMask;
|
||||
D.pRootSignature = this->pRootSignature;
|
||||
D.InputLayout = this->InputLayout;
|
||||
D.IBStripCutValue = this->IBStripCutValue;
|
||||
D.PrimitiveTopologyType = this->PrimitiveTopologyType;
|
||||
D.VS = this->VS;
|
||||
D.GS = this->GS;
|
||||
D.StreamOutput = this->StreamOutput;
|
||||
D.HS = this->HS;
|
||||
D.DS = this->DS;
|
||||
D.PS = this->PS;
|
||||
D.BlendState = this->BlendState;
|
||||
D.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(D3D12_DEPTH_STENCIL_DESC1(this->DepthStencilState));
|
||||
D.DSVFormat = this->DSVFormat;
|
||||
D.RasterizerState = this->RasterizerState;
|
||||
D.NumRenderTargets = D3D12_RT_FORMAT_ARRAY(this->RTVFormats).NumRenderTargets;
|
||||
memcpy(D.RTVFormats, D3D12_RT_FORMAT_ARRAY(this->RTVFormats).RTFormats, sizeof(D.RTVFormats));
|
||||
D.SampleDesc = this->SampleDesc;
|
||||
D.SampleMask = this->SampleMask;
|
||||
D.CachedPSO = this->CachedPSO;
|
||||
return D;
|
||||
}
|
||||
D3D12_COMPUTE_PIPELINE_STATE_DESC ComputeDescV0() const
|
||||
{
|
||||
D3D12_COMPUTE_PIPELINE_STATE_DESC D;
|
||||
D.Flags = this->Flags;
|
||||
D.NodeMask = this->NodeMask;
|
||||
D.pRootSignature = this->pRootSignature;
|
||||
D.CS = this->CS;
|
||||
D.CachedPSO = this->CachedPSO;
|
||||
return D;
|
||||
}
|
||||
};
|
||||
|
||||
struct CD3DX12_PIPELINE_STATE_STREAM_PARSE_HELPER : public ID3DX12PipelineParserCallbacks
|
||||
{
|
||||
CD3DX12_PIPELINE_STATE_STREAM PipelineStream;
|
||||
|
||||
// ID3DX12PipelineParserCallbacks
|
||||
void FlagsCb(D3D12_PIPELINE_STATE_FLAGS Flags) {PipelineStream.Flags = Flags;}
|
||||
void NodeMaskCb(UINT NodeMask) {PipelineStream.NodeMask = NodeMask;}
|
||||
void RootSignatureCb(ID3D12RootSignature* pRootSignature) {PipelineStream.pRootSignature = pRootSignature;}
|
||||
void InputLayoutCb(const D3D12_INPUT_LAYOUT_DESC& InputLayout) {PipelineStream.InputLayout = InputLayout;}
|
||||
void IBStripCutValueCb(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue) {PipelineStream.IBStripCutValue = IBStripCutValue;}
|
||||
void PrimitiveTopologyTypeCb(D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType) {PipelineStream.PrimitiveTopologyType = PrimitiveTopologyType;}
|
||||
void VSCb(const D3D12_SHADER_BYTECODE& VS) {PipelineStream.VS = VS;}
|
||||
void GSCb(const D3D12_SHADER_BYTECODE& GS) {PipelineStream.GS = GS;}
|
||||
void StreamOutputCb(const D3D12_STREAM_OUTPUT_DESC& StreamOutput) {PipelineStream.StreamOutput = StreamOutput;}
|
||||
void HSCb(const D3D12_SHADER_BYTECODE& HS) {PipelineStream.HS = HS;}
|
||||
void DSCb(const D3D12_SHADER_BYTECODE& DS) {PipelineStream.DS = DS;}
|
||||
void PSCb(const D3D12_SHADER_BYTECODE& PS) {PipelineStream.PS = PS;}
|
||||
void CSCb(const D3D12_SHADER_BYTECODE& CS) {PipelineStream.CS = CS;}
|
||||
void BlendStateCb(const D3D12_BLEND_DESC& BlendState) {PipelineStream.BlendState = CD3DX12_BLEND_DESC(BlendState);}
|
||||
void DepthStencilStateCb(const D3D12_DEPTH_STENCIL_DESC& DepthStencilState) {PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(DepthStencilState);}
|
||||
void DepthStencilState1Cb(const D3D12_DEPTH_STENCIL_DESC1& DepthStencilState) {PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(DepthStencilState);}
|
||||
void DSVFormatCb(DXGI_FORMAT DSVFormat) {PipelineStream.DSVFormat = DSVFormat;}
|
||||
void RasterizerStateCb(const D3D12_RASTERIZER_DESC& RasterizerState) {PipelineStream.RasterizerState = CD3DX12_RASTERIZER_DESC(RasterizerState);}
|
||||
void RTVFormatsCb(const D3D12_RT_FORMAT_ARRAY& RTVFormats) {PipelineStream.RTVFormats = RTVFormats;}
|
||||
void SampleDescCb(const DXGI_SAMPLE_DESC& SampleDesc) {PipelineStream.SampleDesc = SampleDesc;}
|
||||
void SampleMaskCb(UINT SampleMask) {PipelineStream.SampleMask = SampleMask;}
|
||||
void CachedPSOCb(const D3D12_CACHED_PIPELINE_STATE& CachedPSO) {PipelineStream.CachedPSO = CachedPSO;}
|
||||
void ErrorBadInputParameter(UINT) {}
|
||||
void ErrorDuplicateSubobject(D3D12_PIPELINE_STATE_SUBOBJECT_TYPE) {}
|
||||
void ErrorUnknownSubobject(UINT) {}
|
||||
};
|
||||
|
||||
inline D3D12_PIPELINE_STATE_SUBOBJECT_TYPE D3DX12GetBaseSubobjectType(D3D12_PIPELINE_STATE_SUBOBJECT_TYPE SubobjectType)
|
||||
{
|
||||
switch (SubobjectType)
|
||||
{
|
||||
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1:
|
||||
return D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL;
|
||||
default:
|
||||
return SubobjectType;
|
||||
}
|
||||
}
|
||||
|
||||
inline HRESULT D3DX12ParsePipelineStream(const D3D12_PIPELINE_STATE_STREAM_DESC& Desc, ID3DX12PipelineParserCallbacks* pCallbacks)
|
||||
{
|
||||
if (Desc.SizeInBytes == 0 || Desc.pPipelineStateSubobjectStream == nullptr)
|
||||
{
|
||||
pCallbacks->ErrorBadInputParameter(1); // first parameter issue
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
if (pCallbacks == nullptr)
|
||||
{
|
||||
pCallbacks->ErrorBadInputParameter(2); // second parameter issue
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
bool SubobjectSeen[D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MAX_VALID] = {0};
|
||||
for (SIZE_T CurOffset = 0, SizeOfSubobject = 0; CurOffset < Desc.SizeInBytes; CurOffset += SizeOfSubobject)
|
||||
{
|
||||
BYTE* pStream = static_cast<BYTE*>(Desc.pPipelineStateSubobjectStream)+CurOffset;
|
||||
auto SubobjectType = *reinterpret_cast<D3D12_PIPELINE_STATE_SUBOBJECT_TYPE*>(pStream);
|
||||
if (SubobjectType >= D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MAX_VALID)
|
||||
{
|
||||
pCallbacks->ErrorUnknownSubobject(SubobjectType);
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
if (SubobjectSeen[D3DX12GetBaseSubobjectType(SubobjectType)])
|
||||
{
|
||||
pCallbacks->ErrorDuplicateSubobject(SubobjectType);
|
||||
return E_INVALIDARG; // disallow subobject duplicates in a stream
|
||||
}
|
||||
SubobjectSeen[SubobjectType] = true;
|
||||
switch (SubobjectType)
|
||||
{
|
||||
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE:
|
||||
pCallbacks->RootSignatureCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::pRootSignature)*>(pStream));
|
||||
SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::pRootSignature);
|
||||
break;
|
||||
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VS:
|
||||
pCallbacks->VSCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::VS)*>(pStream));
|
||||
SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::VS);
|
||||
break;
|
||||
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PS:
|
||||
pCallbacks->PSCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::PS)*>(pStream));
|
||||
SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::PS);
|
||||
break;
|
||||
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DS:
|
||||
pCallbacks->DSCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::DS)*>(pStream));
|
||||
SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::DS);
|
||||
break;
|
||||
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_HS:
|
||||
pCallbacks->HSCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::HS)*>(pStream));
|
||||
SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::HS);
|
||||
break;
|
||||
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_GS:
|
||||
pCallbacks->GSCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::GS)*>(pStream));
|
||||
SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::GS);
|
||||
break;
|
||||
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CS:
|
||||
pCallbacks->CSCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::CS)*>(pStream));
|
||||
SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::CS);
|
||||
break;
|
||||
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_STREAM_OUTPUT:
|
||||
pCallbacks->StreamOutputCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::StreamOutput)*>(pStream));
|
||||
SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::StreamOutput);
|
||||
break;
|
||||
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_BLEND:
|
||||
pCallbacks->BlendStateCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::BlendState)*>(pStream));
|
||||
SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::BlendState);
|
||||
break;
|
||||
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_MASK:
|
||||
pCallbacks->SampleMaskCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::SampleMask)*>(pStream));
|
||||
SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::SampleMask);
|
||||
break;
|
||||
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER:
|
||||
pCallbacks->RasterizerStateCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::RasterizerState)*>(pStream));
|
||||
SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::RasterizerState);
|
||||
break;
|
||||
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL:
|
||||
pCallbacks->DepthStencilStateCb(*reinterpret_cast<CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL*>(pStream));
|
||||
SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL);
|
||||
break;
|
||||
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1:
|
||||
pCallbacks->DepthStencilState1Cb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::DepthStencilState)*>(pStream));
|
||||
SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::DepthStencilState);
|
||||
break;
|
||||
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_INPUT_LAYOUT:
|
||||
pCallbacks->InputLayoutCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::InputLayout)*>(pStream));
|
||||
SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::InputLayout);
|
||||
break;
|
||||
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_IB_STRIP_CUT_VALUE:
|
||||
pCallbacks->IBStripCutValueCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::IBStripCutValue)*>(pStream));
|
||||
SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::IBStripCutValue);
|
||||
break;
|
||||
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PRIMITIVE_TOPOLOGY:
|
||||
pCallbacks->PrimitiveTopologyTypeCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::PrimitiveTopologyType)*>(pStream));
|
||||
SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::PrimitiveTopologyType);
|
||||
break;
|
||||
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RENDER_TARGET_FORMATS:
|
||||
pCallbacks->RTVFormatsCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::RTVFormats)*>(pStream));
|
||||
SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::RTVFormats);
|
||||
break;
|
||||
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL_FORMAT:
|
||||
pCallbacks->DSVFormatCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::DSVFormat)*>(pStream));
|
||||
SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::DSVFormat);
|
||||
break;
|
||||
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_DESC:
|
||||
pCallbacks->SampleDescCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::SampleDesc)*>(pStream));
|
||||
SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::SampleDesc);
|
||||
break;
|
||||
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_NODE_MASK:
|
||||
pCallbacks->NodeMaskCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::NodeMask)*>(pStream));
|
||||
SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::NodeMask);
|
||||
break;
|
||||
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CACHED_PSO:
|
||||
pCallbacks->CachedPSOCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::CachedPSO)*>(pStream));
|
||||
SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::CachedPSO);
|
||||
break;
|
||||
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_FLAGS:
|
||||
pCallbacks->FlagsCb(*reinterpret_cast<decltype(CD3DX12_PIPELINE_STATE_STREAM::Flags)*>(pStream));
|
||||
SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::Flags);
|
||||
break;
|
||||
default:
|
||||
pCallbacks->ErrorUnknownSubobject(SubobjectType);
|
||||
return E_INVALIDARG;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // defined( __cplusplus )
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче