2017-01-26 18:23:36 +00:00
//*********************************************************
//
2021-02-27 06:59:42 +00:00
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License (MIT).
2017-01-26 18:23:36 +00:00
//
//*********************************************************
# ifndef __D3DX12_H__
# define __D3DX12_H__
# include "d3d12.h"
# if defined( __cplusplus )
2023-04-28 00:03:18 +00:00
# ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wfloat-equal"
# pragma clang diagnostic ignored "-Wunknown-warning-option"
# pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
# endif
2017-01-26 18:23:36 +00:00
struct CD3DX12_DEFAULT { } ;
extern const DECLSPEC_SELECTANY CD3DX12_DEFAULT D3D12_DEFAULT ;
//------------------------------------------------------------------------------------------------
2020-03-16 09:16:44 +00:00
inline bool operator = = ( const D3D12_VIEWPORT & l , const D3D12_VIEWPORT & r ) noexcept
2017-01-26 18:23:36 +00:00
{
return l . TopLeftX = = r . TopLeftX & & l . TopLeftY = = r . TopLeftY & & l . Width = = r . Width & &
l . Height = = r . Height & & l . MinDepth = = r . MinDepth & & l . MaxDepth = = r . MaxDepth ;
}
//------------------------------------------------------------------------------------------------
2020-03-16 09:16:44 +00:00
inline bool operator ! = ( const D3D12_VIEWPORT & l , const D3D12_VIEWPORT & r ) noexcept
2017-01-26 18:23:36 +00:00
{ return ! ( l = = r ) ; }
//------------------------------------------------------------------------------------------------
struct CD3DX12_RECT : public D3D12_RECT
{
2018-04-12 01:06:24 +00:00
CD3DX12_RECT ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_RECT ( const D3D12_RECT & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_RECT ( o )
{ }
explicit CD3DX12_RECT (
LONG Left ,
LONG Top ,
LONG Right ,
2020-03-16 09:16:44 +00:00
LONG Bottom ) noexcept
2017-01-26 18:23:36 +00:00
{
left = Left ;
top = Top ;
right = Right ;
bottom = Bottom ;
}
} ;
//------------------------------------------------------------------------------------------------
struct CD3DX12_VIEWPORT : public D3D12_VIEWPORT
{
2018-04-12 01:06:24 +00:00
CD3DX12_VIEWPORT ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_VIEWPORT ( const D3D12_VIEWPORT & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_VIEWPORT ( o )
{ }
explicit CD3DX12_VIEWPORT (
FLOAT topLeftX ,
FLOAT topLeftY ,
FLOAT width ,
FLOAT height ,
FLOAT minDepth = D3D12_MIN_DEPTH ,
2020-03-16 09:16:44 +00:00
FLOAT maxDepth = D3D12_MAX_DEPTH ) noexcept
2017-01-26 18:23:36 +00:00
{
TopLeftX = topLeftX ;
TopLeftY = topLeftY ;
Width = width ;
Height = height ;
MinDepth = minDepth ;
MaxDepth = maxDepth ;
}
explicit CD3DX12_VIEWPORT (
_In_ ID3D12Resource * pResource ,
UINT mipSlice = 0 ,
FLOAT topLeftX = 0.0f ,
FLOAT topLeftY = 0.0f ,
FLOAT minDepth = D3D12_MIN_DEPTH ,
2020-03-16 09:16:44 +00:00
FLOAT maxDepth = D3D12_MAX_DEPTH ) noexcept
2017-01-26 18:23:36 +00:00
{
2022-07-25 21:48:46 +00:00
# if defined(_MSC_VER) || !defined(_WIN32)
2021-10-22 23:43:43 +00:00
const auto Desc = pResource - > GetDesc ( ) ;
2022-07-25 21:48:46 +00:00
# else
D3D12_RESOURCE_DESC tmpDesc ;
const auto & Desc = * pResource - > GetDesc ( & tmpDesc ) ;
# endif
2017-01-26 18:23:36 +00:00
const UINT64 SubresourceWidth = Desc . Width > > mipSlice ;
const UINT64 SubresourceHeight = Desc . Height > > mipSlice ;
switch ( Desc . Dimension )
{
case D3D12_RESOURCE_DIMENSION_BUFFER :
TopLeftX = topLeftX ;
TopLeftY = 0.0f ;
2020-04-30 08:06:28 +00:00
Width = float ( Desc . Width ) - topLeftX ;
2017-01-26 18:23:36 +00:00
Height = 1.0f ;
break ;
case D3D12_RESOURCE_DIMENSION_TEXTURE1D :
TopLeftX = topLeftX ;
TopLeftY = 0.0f ;
2020-04-30 08:06:28 +00:00
Width = ( SubresourceWidth ? float ( SubresourceWidth ) : 1.0f ) - topLeftX ;
2017-01-26 18:23:36 +00:00
Height = 1.0f ;
break ;
case D3D12_RESOURCE_DIMENSION_TEXTURE2D :
case D3D12_RESOURCE_DIMENSION_TEXTURE3D :
TopLeftX = topLeftX ;
TopLeftY = topLeftY ;
2020-04-30 08:06:28 +00:00
Width = ( SubresourceWidth ? float ( SubresourceWidth ) : 1.0f ) - topLeftX ;
Height = ( SubresourceHeight ? float ( SubresourceHeight ) : 1.0f ) - topLeftY ;
2017-01-26 18:23:36 +00:00
break ;
default : break ;
}
MinDepth = minDepth ;
MaxDepth = maxDepth ;
}
} ;
//------------------------------------------------------------------------------------------------
struct CD3DX12_BOX : public D3D12_BOX
{
2018-04-12 01:06:24 +00:00
CD3DX12_BOX ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_BOX ( const D3D12_BOX & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_BOX ( o )
{ }
explicit CD3DX12_BOX (
LONG Left ,
2020-03-16 09:16:44 +00:00
LONG Right ) noexcept
2017-01-26 18:23:36 +00:00
{
2019-07-05 06:26:40 +00:00
left = static_cast < UINT > ( Left ) ;
2017-01-26 18:23:36 +00:00
top = 0 ;
front = 0 ;
2019-07-05 06:26:40 +00:00
right = static_cast < UINT > ( Right ) ;
2017-01-26 18:23:36 +00:00
bottom = 1 ;
back = 1 ;
}
explicit CD3DX12_BOX (
LONG Left ,
LONG Top ,
LONG Right ,
2020-03-16 09:16:44 +00:00
LONG Bottom ) noexcept
2017-01-26 18:23:36 +00:00
{
2019-07-05 06:26:40 +00:00
left = static_cast < UINT > ( Left ) ;
top = static_cast < UINT > ( Top ) ;
2017-01-26 18:23:36 +00:00
front = 0 ;
2019-07-05 06:26:40 +00:00
right = static_cast < UINT > ( Right ) ;
bottom = static_cast < UINT > ( Bottom ) ;
2017-01-26 18:23:36 +00:00
back = 1 ;
}
explicit CD3DX12_BOX (
LONG Left ,
LONG Top ,
LONG Front ,
LONG Right ,
LONG Bottom ,
2020-03-16 09:16:44 +00:00
LONG Back ) noexcept
2017-01-26 18:23:36 +00:00
{
2019-07-05 06:26:40 +00:00
left = static_cast < UINT > ( Left ) ;
top = static_cast < UINT > ( Top ) ;
front = static_cast < UINT > ( Front ) ;
right = static_cast < UINT > ( Right ) ;
bottom = static_cast < UINT > ( Bottom ) ;
back = static_cast < UINT > ( Back ) ;
2017-01-26 18:23:36 +00:00
}
} ;
2020-03-16 09:16:44 +00:00
inline bool operator = = ( const D3D12_BOX & l , const D3D12_BOX & r ) noexcept
2017-01-26 18:23:36 +00:00
{
return l . left = = r . left & & l . top = = r . top & & l . front = = r . front & &
l . right = = r . right & & l . bottom = = r . bottom & & l . back = = r . back ;
}
2020-03-16 09:16:44 +00:00
inline bool operator ! = ( const D3D12_BOX & l , const D3D12_BOX & r ) noexcept
2017-01-26 18:23:36 +00:00
{ return ! ( l = = r ) ; }
//------------------------------------------------------------------------------------------------
struct CD3DX12_DEPTH_STENCIL_DESC : public D3D12_DEPTH_STENCIL_DESC
{
2018-04-12 01:06:24 +00:00
CD3DX12_DEPTH_STENCIL_DESC ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_DEPTH_STENCIL_DESC ( const D3D12_DEPTH_STENCIL_DESC & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_DEPTH_STENCIL_DESC ( o )
{ }
2020-03-16 09:16:44 +00:00
explicit CD3DX12_DEPTH_STENCIL_DESC ( CD3DX12_DEFAULT ) noexcept
2017-01-26 18:23:36 +00:00
{
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 ;
}
explicit CD3DX12_DEPTH_STENCIL_DESC (
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 ,
2020-03-16 09:16:44 +00:00
D3D12_COMPARISON_FUNC backStencilFunc ) noexcept
2017-01-26 18:23:36 +00:00
{
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 ;
}
} ;
2017-04-20 01:13:34 +00:00
//------------------------------------------------------------------------------------------------
struct CD3DX12_DEPTH_STENCIL_DESC1 : public D3D12_DEPTH_STENCIL_DESC1
{
2018-04-12 01:06:24 +00:00
CD3DX12_DEPTH_STENCIL_DESC1 ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_DEPTH_STENCIL_DESC1 ( const D3D12_DEPTH_STENCIL_DESC1 & o ) noexcept :
2017-04-20 01:13:34 +00:00
D3D12_DEPTH_STENCIL_DESC1 ( o )
{ }
2020-03-16 09:16:44 +00:00
explicit CD3DX12_DEPTH_STENCIL_DESC1 ( const D3D12_DEPTH_STENCIL_DESC & o ) noexcept
2017-04-20 01:13:34 +00:00
{
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 ;
}
2020-03-16 09:16:44 +00:00
explicit CD3DX12_DEPTH_STENCIL_DESC1 ( CD3DX12_DEFAULT ) noexcept
2017-04-20 01:13:34 +00:00
{
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 ,
2020-03-16 09:16:44 +00:00
BOOL depthBoundsTestEnable ) noexcept
2017-04-20 01:13:34 +00:00
{
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 ;
}
2020-03-16 09:16:44 +00:00
operator D3D12_DEPTH_STENCIL_DESC ( ) const noexcept
2017-04-20 01:13:34 +00:00
{
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 ;
}
} ;
2022-11-19 21:03:20 +00:00
//------------------------------------------------------------------------------------------------
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606)
2022-11-19 21:03:20 +00:00
struct CD3DX12_DEPTH_STENCIL_DESC2 : public D3D12_DEPTH_STENCIL_DESC2
{
CD3DX12_DEPTH_STENCIL_DESC2 ( ) = default ;
explicit CD3DX12_DEPTH_STENCIL_DESC2 ( const D3D12_DEPTH_STENCIL_DESC2 & o ) noexcept :
D3D12_DEPTH_STENCIL_DESC2 ( o )
{ }
explicit CD3DX12_DEPTH_STENCIL_DESC2 ( const D3D12_DEPTH_STENCIL_DESC1 & o ) noexcept
{
DepthEnable = o . DepthEnable ;
DepthWriteMask = o . DepthWriteMask ;
DepthFunc = o . DepthFunc ;
StencilEnable = o . StencilEnable ;
FrontFace . StencilFailOp = o . FrontFace . StencilFailOp ;
FrontFace . StencilDepthFailOp = o . FrontFace . StencilDepthFailOp ;
FrontFace . StencilPassOp = o . FrontFace . StencilPassOp ;
FrontFace . StencilFunc = o . FrontFace . StencilFunc ;
FrontFace . StencilReadMask = o . StencilReadMask ;
FrontFace . StencilWriteMask = o . StencilWriteMask ;
BackFace . StencilFailOp = o . BackFace . StencilFailOp ;
BackFace . StencilDepthFailOp = o . BackFace . StencilDepthFailOp ;
BackFace . StencilPassOp = o . BackFace . StencilPassOp ;
BackFace . StencilFunc = o . BackFace . StencilFunc ;
BackFace . StencilReadMask = o . StencilReadMask ;
BackFace . StencilWriteMask = o . StencilWriteMask ;
DepthBoundsTestEnable = o . DepthBoundsTestEnable ;
}
explicit CD3DX12_DEPTH_STENCIL_DESC2 ( const D3D12_DEPTH_STENCIL_DESC & o ) noexcept
{
DepthEnable = o . DepthEnable ;
DepthWriteMask = o . DepthWriteMask ;
DepthFunc = o . DepthFunc ;
StencilEnable = o . StencilEnable ;
FrontFace . StencilFailOp = o . FrontFace . StencilFailOp ;
FrontFace . StencilDepthFailOp = o . FrontFace . StencilDepthFailOp ;
FrontFace . StencilPassOp = o . FrontFace . StencilPassOp ;
FrontFace . StencilFunc = o . FrontFace . StencilFunc ;
FrontFace . StencilReadMask = o . StencilReadMask ;
FrontFace . StencilWriteMask = o . StencilWriteMask ;
BackFace . StencilFailOp = o . BackFace . StencilFailOp ;
BackFace . StencilDepthFailOp = o . BackFace . StencilDepthFailOp ;
BackFace . StencilPassOp = o . BackFace . StencilPassOp ;
BackFace . StencilFunc = o . BackFace . StencilFunc ;
BackFace . StencilReadMask = o . StencilReadMask ;
BackFace . StencilWriteMask = o . StencilWriteMask ;
DepthBoundsTestEnable = FALSE ;
}
explicit CD3DX12_DEPTH_STENCIL_DESC2 ( CD3DX12_DEFAULT ) noexcept
{
DepthEnable = TRUE ;
DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL ;
DepthFunc = D3D12_COMPARISON_FUNC_LESS ;
StencilEnable = FALSE ;
const D3D12_DEPTH_STENCILOP_DESC1 defaultStencilOp =
{ D3D12_STENCIL_OP_KEEP , D3D12_STENCIL_OP_KEEP , D3D12_STENCIL_OP_KEEP , D3D12_COMPARISON_FUNC_ALWAYS , D3D12_DEFAULT_STENCIL_READ_MASK , D3D12_DEFAULT_STENCIL_WRITE_MASK } ;
FrontFace = defaultStencilOp ;
BackFace = defaultStencilOp ;
DepthBoundsTestEnable = FALSE ;
}
explicit CD3DX12_DEPTH_STENCIL_DESC2 (
BOOL depthEnable ,
D3D12_DEPTH_WRITE_MASK depthWriteMask ,
D3D12_COMPARISON_FUNC depthFunc ,
BOOL stencilEnable ,
D3D12_STENCIL_OP frontStencilFailOp ,
D3D12_STENCIL_OP frontStencilDepthFailOp ,
D3D12_STENCIL_OP frontStencilPassOp ,
D3D12_COMPARISON_FUNC frontStencilFunc ,
UINT8 frontStencilReadMask ,
UINT8 frontStencilWriteMask ,
D3D12_STENCIL_OP backStencilFailOp ,
D3D12_STENCIL_OP backStencilDepthFailOp ,
D3D12_STENCIL_OP backStencilPassOp ,
D3D12_COMPARISON_FUNC backStencilFunc ,
UINT8 backStencilReadMask ,
UINT8 backStencilWriteMask ,
BOOL depthBoundsTestEnable ) noexcept
{
DepthEnable = depthEnable ;
DepthWriteMask = depthWriteMask ;
DepthFunc = depthFunc ;
StencilEnable = stencilEnable ;
FrontFace . StencilFailOp = frontStencilFailOp ;
FrontFace . StencilDepthFailOp = frontStencilDepthFailOp ;
FrontFace . StencilPassOp = frontStencilPassOp ;
FrontFace . StencilFunc = frontStencilFunc ;
FrontFace . StencilReadMask = frontStencilReadMask ;
FrontFace . StencilWriteMask = frontStencilWriteMask ;
BackFace . StencilFailOp = backStencilFailOp ;
BackFace . StencilDepthFailOp = backStencilDepthFailOp ;
BackFace . StencilPassOp = backStencilPassOp ;
BackFace . StencilFunc = backStencilFunc ;
BackFace . StencilReadMask = backStencilReadMask ;
BackFace . StencilWriteMask = backStencilWriteMask ;
DepthBoundsTestEnable = depthBoundsTestEnable ;
}
operator D3D12_DEPTH_STENCIL_DESC ( ) const noexcept
{
D3D12_DEPTH_STENCIL_DESC D ;
D . DepthEnable = DepthEnable ;
D . DepthWriteMask = DepthWriteMask ;
D . DepthFunc = DepthFunc ;
D . StencilEnable = StencilEnable ;
D . StencilReadMask = FrontFace . StencilReadMask ;
D . StencilWriteMask = FrontFace . 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 ;
}
} ;
2023-04-24 20:52:49 +00:00
# endif // D3D12_SDK_VERSION >= 606
2022-11-19 21:03:20 +00:00
2017-01-26 18:23:36 +00:00
//------------------------------------------------------------------------------------------------
struct CD3DX12_BLEND_DESC : public D3D12_BLEND_DESC
{
2018-04-12 01:06:24 +00:00
CD3DX12_BLEND_DESC ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_BLEND_DESC ( const D3D12_BLEND_DESC & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_BLEND_DESC ( o )
{ }
2020-03-16 09:16:44 +00:00
explicit CD3DX12_BLEND_DESC ( CD3DX12_DEFAULT ) noexcept
2017-01-26 18:23:36 +00:00
{
AlphaToCoverageEnable = FALSE ;
IndependentBlendEnable = FALSE ;
const D3D12_RENDER_TARGET_BLEND_DESC defaultRenderTargetBlendDesc =
{
FALSE , FALSE ,
D3D12_BLEND_ONE , D3D12_BLEND_ZERO , D3D12_BLEND_OP_ADD ,
D3D12_BLEND_ONE , D3D12_BLEND_ZERO , D3D12_BLEND_OP_ADD ,
D3D12_LOGIC_OP_NOOP ,
D3D12_COLOR_WRITE_ENABLE_ALL ,
} ;
for ( UINT i = 0 ; i < D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT ; + + i )
RenderTarget [ i ] = defaultRenderTargetBlendDesc ;
}
} ;
//------------------------------------------------------------------------------------------------
struct CD3DX12_RASTERIZER_DESC : public D3D12_RASTERIZER_DESC
{
2018-04-12 01:06:24 +00:00
CD3DX12_RASTERIZER_DESC ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_RASTERIZER_DESC ( const D3D12_RASTERIZER_DESC & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_RASTERIZER_DESC ( o )
{ }
2020-03-16 09:16:44 +00:00
explicit CD3DX12_RASTERIZER_DESC ( CD3DX12_DEFAULT ) noexcept
2017-01-26 18:23:36 +00:00
{
FillMode = D3D12_FILL_MODE_SOLID ;
CullMode = D3D12_CULL_MODE_BACK ;
FrontCounterClockwise = FALSE ;
DepthBias = D3D12_DEFAULT_DEPTH_BIAS ;
DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP ;
SlopeScaledDepthBias = D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS ;
DepthClipEnable = TRUE ;
MultisampleEnable = FALSE ;
AntialiasedLineEnable = FALSE ;
ForcedSampleCount = 0 ;
ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF ;
}
explicit CD3DX12_RASTERIZER_DESC (
D3D12_FILL_MODE fillMode ,
D3D12_CULL_MODE cullMode ,
BOOL frontCounterClockwise ,
INT depthBias ,
FLOAT depthBiasClamp ,
FLOAT slopeScaledDepthBias ,
BOOL depthClipEnable ,
BOOL multisampleEnable ,
2020-03-18 04:45:33 +00:00
BOOL antialiasedLineEnable ,
UINT forcedSampleCount ,
2020-03-16 09:16:44 +00:00
D3D12_CONSERVATIVE_RASTERIZATION_MODE conservativeRaster ) noexcept
2017-01-26 18:23:36 +00:00
{
FillMode = fillMode ;
CullMode = cullMode ;
FrontCounterClockwise = frontCounterClockwise ;
DepthBias = depthBias ;
DepthBiasClamp = depthBiasClamp ;
SlopeScaledDepthBias = slopeScaledDepthBias ;
DepthClipEnable = depthClipEnable ;
MultisampleEnable = multisampleEnable ;
AntialiasedLineEnable = antialiasedLineEnable ;
ForcedSampleCount = forcedSampleCount ;
ConservativeRaster = conservativeRaster ;
}
} ;
2022-11-19 21:03:20 +00:00
//------------------------------------------------------------------------------------------------
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608)
2022-11-19 21:03:20 +00:00
struct CD3DX12_RASTERIZER_DESC1 : public D3D12_RASTERIZER_DESC1
{
CD3DX12_RASTERIZER_DESC1 ( ) = default ;
explicit CD3DX12_RASTERIZER_DESC1 ( const D3D12_RASTERIZER_DESC1 & o ) noexcept :
D3D12_RASTERIZER_DESC1 ( o )
{
}
explicit CD3DX12_RASTERIZER_DESC1 ( const D3D12_RASTERIZER_DESC & o ) noexcept
{
FillMode = o . FillMode ;
CullMode = o . CullMode ;
FrontCounterClockwise = o . FrontCounterClockwise ;
2022-11-19 21:49:10 +00:00
DepthBias = static_cast < FLOAT > ( o . DepthBias ) ;
2022-11-19 21:03:20 +00:00
DepthBiasClamp = o . DepthBiasClamp ;
SlopeScaledDepthBias = o . SlopeScaledDepthBias ;
DepthClipEnable = o . DepthClipEnable ;
MultisampleEnable = o . MultisampleEnable ;
AntialiasedLineEnable = o . AntialiasedLineEnable ;
ForcedSampleCount = o . ForcedSampleCount ;
ConservativeRaster = o . ConservativeRaster ;
}
explicit CD3DX12_RASTERIZER_DESC1 ( CD3DX12_DEFAULT ) noexcept
{
FillMode = D3D12_FILL_MODE_SOLID ;
CullMode = D3D12_CULL_MODE_BACK ;
FrontCounterClockwise = FALSE ;
DepthBias = D3D12_DEFAULT_DEPTH_BIAS ;
DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP ;
SlopeScaledDepthBias = D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS ;
DepthClipEnable = TRUE ;
MultisampleEnable = FALSE ;
AntialiasedLineEnable = FALSE ;
ForcedSampleCount = 0 ;
ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF ;
}
explicit CD3DX12_RASTERIZER_DESC1 (
D3D12_FILL_MODE fillMode ,
D3D12_CULL_MODE cullMode ,
BOOL frontCounterClockwise ,
FLOAT depthBias ,
FLOAT depthBiasClamp ,
FLOAT slopeScaledDepthBias ,
BOOL depthClipEnable ,
BOOL multisampleEnable ,
BOOL antialiasedLineEnable ,
UINT forcedSampleCount ,
D3D12_CONSERVATIVE_RASTERIZATION_MODE conservativeRaster ) noexcept
{
FillMode = fillMode ;
CullMode = cullMode ;
FrontCounterClockwise = frontCounterClockwise ;
DepthBias = depthBias ;
DepthBiasClamp = depthBiasClamp ;
SlopeScaledDepthBias = slopeScaledDepthBias ;
DepthClipEnable = depthClipEnable ;
MultisampleEnable = multisampleEnable ;
AntialiasedLineEnable = antialiasedLineEnable ;
ForcedSampleCount = forcedSampleCount ;
ConservativeRaster = conservativeRaster ;
}
operator D3D12_RASTERIZER_DESC ( ) const noexcept
{
D3D12_RASTERIZER_DESC o ;
o . FillMode = FillMode ;
o . CullMode = CullMode ;
o . FrontCounterClockwise = FrontCounterClockwise ;
2022-11-19 21:49:10 +00:00
o . DepthBias = static_cast < INT > ( DepthBias ) ;
2022-11-19 21:03:20 +00:00
o . DepthBiasClamp = DepthBiasClamp ;
o . SlopeScaledDepthBias = SlopeScaledDepthBias ;
o . DepthClipEnable = DepthClipEnable ;
o . MultisampleEnable = MultisampleEnable ;
o . AntialiasedLineEnable = AntialiasedLineEnable ;
o . ForcedSampleCount = ForcedSampleCount ;
o . ConservativeRaster = ConservativeRaster ;
return o ;
}
} ;
2023-04-24 20:52:49 +00:00
# endif // D3D12_SDK_VERSION >= 608
//------------------------------------------------------------------------------------------------
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610)
struct CD3DX12_RASTERIZER_DESC2 : public D3D12_RASTERIZER_DESC2
{
CD3DX12_RASTERIZER_DESC2 ( ) = default ;
explicit CD3DX12_RASTERIZER_DESC2 ( const D3D12_RASTERIZER_DESC2 & o ) noexcept :
D3D12_RASTERIZER_DESC2 ( o )
{
}
explicit CD3DX12_RASTERIZER_DESC2 ( const D3D12_RASTERIZER_DESC1 & o ) noexcept
{
FillMode = o . FillMode ;
CullMode = o . CullMode ;
FrontCounterClockwise = o . FrontCounterClockwise ;
DepthBias = o . DepthBias ;
DepthBiasClamp = o . DepthBiasClamp ;
SlopeScaledDepthBias = o . SlopeScaledDepthBias ;
DepthClipEnable = o . DepthClipEnable ;
LineRasterizationMode = D3D12_LINE_RASTERIZATION_MODE_ALIASED ;
if ( o . MultisampleEnable )
{
LineRasterizationMode = D3D12_LINE_RASTERIZATION_MODE_QUADRILATERAL_WIDE ;
}
else if ( o . AntialiasedLineEnable )
{
LineRasterizationMode = D3D12_LINE_RASTERIZATION_MODE_ALPHA_ANTIALIASED ;
}
ForcedSampleCount = o . ForcedSampleCount ;
ConservativeRaster = o . ConservativeRaster ;
}
explicit CD3DX12_RASTERIZER_DESC2 ( const D3D12_RASTERIZER_DESC & o ) noexcept
: CD3DX12_RASTERIZER_DESC2 ( CD3DX12_RASTERIZER_DESC1 ( o ) )
{
}
explicit CD3DX12_RASTERIZER_DESC2 ( CD3DX12_DEFAULT ) noexcept
{
FillMode = D3D12_FILL_MODE_SOLID ;
CullMode = D3D12_CULL_MODE_BACK ;
FrontCounterClockwise = FALSE ;
DepthBias = D3D12_DEFAULT_DEPTH_BIAS ;
DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP ;
SlopeScaledDepthBias = D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS ;
DepthClipEnable = TRUE ;
LineRasterizationMode = D3D12_LINE_RASTERIZATION_MODE_ALIASED ;
ForcedSampleCount = 0 ;
ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF ;
}
explicit CD3DX12_RASTERIZER_DESC2 (
D3D12_FILL_MODE fillMode ,
D3D12_CULL_MODE cullMode ,
BOOL frontCounterClockwise ,
FLOAT depthBias ,
FLOAT depthBiasClamp ,
FLOAT slopeScaledDepthBias ,
BOOL depthClipEnable ,
D3D12_LINE_RASTERIZATION_MODE lineRasterizationMode ,
UINT forcedSampleCount ,
D3D12_CONSERVATIVE_RASTERIZATION_MODE conservativeRaster ) noexcept
{
FillMode = fillMode ;
CullMode = cullMode ;
FrontCounterClockwise = frontCounterClockwise ;
DepthBias = depthBias ;
DepthBiasClamp = depthBiasClamp ;
SlopeScaledDepthBias = slopeScaledDepthBias ;
DepthClipEnable = depthClipEnable ;
LineRasterizationMode = lineRasterizationMode ;
ForcedSampleCount = forcedSampleCount ;
ConservativeRaster = conservativeRaster ;
}
operator D3D12_RASTERIZER_DESC1 ( ) const noexcept
{
D3D12_RASTERIZER_DESC1 o ;
o . FillMode = FillMode ;
o . CullMode = CullMode ;
o . FrontCounterClockwise = FrontCounterClockwise ;
o . DepthBias = DepthBias ;
o . DepthBiasClamp = DepthBiasClamp ;
o . SlopeScaledDepthBias = SlopeScaledDepthBias ;
o . DepthClipEnable = DepthClipEnable ;
o . MultisampleEnable = FALSE ;
o . AntialiasedLineEnable = FALSE ;
if ( LineRasterizationMode = = D3D12_LINE_RASTERIZATION_MODE_ALPHA_ANTIALIASED )
{
o . AntialiasedLineEnable = TRUE ;
}
else if ( LineRasterizationMode ! = D3D12_LINE_RASTERIZATION_MODE_ALIASED )
{
o . MultisampleEnable = TRUE ;
}
o . ForcedSampleCount = ForcedSampleCount ;
o . ConservativeRaster = ConservativeRaster ;
return o ;
}
operator D3D12_RASTERIZER_DESC ( ) const noexcept
{
2023-07-03 22:29:35 +00:00
return static_cast < D3D12_RASTERIZER_DESC > ( CD3DX12_RASTERIZER_DESC1 ( static_cast < D3D12_RASTERIZER_DESC1 > ( * this ) ) ) ;
2023-04-24 20:52:49 +00:00
}
} ;
# endif // D3D12_SDK_VERSION >= 610
2022-11-19 21:03:20 +00:00
2017-01-26 18:23:36 +00:00
//------------------------------------------------------------------------------------------------
struct CD3DX12_RESOURCE_ALLOCATION_INFO : public D3D12_RESOURCE_ALLOCATION_INFO
{
2018-04-12 01:06:24 +00:00
CD3DX12_RESOURCE_ALLOCATION_INFO ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_RESOURCE_ALLOCATION_INFO ( const D3D12_RESOURCE_ALLOCATION_INFO & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_RESOURCE_ALLOCATION_INFO ( o )
{ }
CD3DX12_RESOURCE_ALLOCATION_INFO (
UINT64 size ,
2020-03-16 09:16:44 +00:00
UINT64 alignment ) noexcept
2017-01-26 18:23:36 +00:00
{
SizeInBytes = size ;
Alignment = alignment ;
}
} ;
//------------------------------------------------------------------------------------------------
struct CD3DX12_HEAP_PROPERTIES : public D3D12_HEAP_PROPERTIES
{
2018-04-12 01:06:24 +00:00
CD3DX12_HEAP_PROPERTIES ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_HEAP_PROPERTIES ( const D3D12_HEAP_PROPERTIES & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_HEAP_PROPERTIES ( o )
{ }
2020-03-18 04:45:33 +00:00
CD3DX12_HEAP_PROPERTIES (
D3D12_CPU_PAGE_PROPERTY cpuPageProperty ,
2017-01-26 18:23:36 +00:00
D3D12_MEMORY_POOL memoryPoolPreference ,
2020-03-18 04:45:33 +00:00
UINT creationNodeMask = 1 ,
2020-03-16 09:16:44 +00:00
UINT nodeMask = 1 ) noexcept
2017-01-26 18:23:36 +00:00
{
Type = D3D12_HEAP_TYPE_CUSTOM ;
CPUPageProperty = cpuPageProperty ;
MemoryPoolPreference = memoryPoolPreference ;
CreationNodeMask = creationNodeMask ;
VisibleNodeMask = nodeMask ;
}
2020-03-18 04:45:33 +00:00
explicit CD3DX12_HEAP_PROPERTIES (
D3D12_HEAP_TYPE type ,
UINT creationNodeMask = 1 ,
2020-03-16 09:16:44 +00:00
UINT nodeMask = 1 ) noexcept
2017-01-26 18:23:36 +00:00
{
Type = type ;
CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN ;
MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN ;
CreationNodeMask = creationNodeMask ;
VisibleNodeMask = nodeMask ;
}
2020-03-16 09:16:44 +00:00
bool IsCPUAccessible ( ) const noexcept
2017-01-26 18:23:36 +00:00
{
2022-11-19 21:03:20 +00:00
return Type = = D3D12_HEAP_TYPE_UPLOAD | | Type = = D3D12_HEAP_TYPE_READBACK
2024-02-05 18:08:59 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
2023-04-24 20:52:49 +00:00
| | Type = = D3D12_HEAP_TYPE_GPU_UPLOAD
# endif
2022-11-19 21:03:20 +00:00
| | ( Type = = D3D12_HEAP_TYPE_CUSTOM & &
( CPUPageProperty = = D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE | | CPUPageProperty = = D3D12_CPU_PAGE_PROPERTY_WRITE_BACK ) ) ;
2017-01-26 18:23:36 +00:00
}
} ;
2020-03-16 09:16:44 +00:00
inline bool operator = = ( const D3D12_HEAP_PROPERTIES & l , const D3D12_HEAP_PROPERTIES & r ) noexcept
2017-01-26 18:23:36 +00:00
{
2020-03-18 04:45:33 +00:00
return l . Type = = r . Type & & l . CPUPageProperty = = r . CPUPageProperty & &
2017-01-26 18:23:36 +00:00
l . MemoryPoolPreference = = r . MemoryPoolPreference & &
l . CreationNodeMask = = r . CreationNodeMask & &
l . VisibleNodeMask = = r . VisibleNodeMask ;
}
2020-03-16 09:16:44 +00:00
inline bool operator ! = ( const D3D12_HEAP_PROPERTIES & l , const D3D12_HEAP_PROPERTIES & r ) noexcept
2017-01-26 18:23:36 +00:00
{ return ! ( l = = r ) ; }
//------------------------------------------------------------------------------------------------
struct CD3DX12_HEAP_DESC : public D3D12_HEAP_DESC
{
2018-04-12 01:06:24 +00:00
CD3DX12_HEAP_DESC ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_HEAP_DESC ( const D3D12_HEAP_DESC & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_HEAP_DESC ( o )
{ }
2020-03-18 04:45:33 +00:00
CD3DX12_HEAP_DESC (
UINT64 size ,
D3D12_HEAP_PROPERTIES properties ,
UINT64 alignment = 0 ,
2020-03-16 09:16:44 +00:00
D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept
2017-01-26 18:23:36 +00:00
{
SizeInBytes = size ;
Properties = properties ;
Alignment = alignment ;
Flags = flags ;
}
2020-03-18 04:45:33 +00:00
CD3DX12_HEAP_DESC (
UINT64 size ,
D3D12_HEAP_TYPE type ,
UINT64 alignment = 0 ,
2020-03-16 09:16:44 +00:00
D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept
2017-01-26 18:23:36 +00:00
{
SizeInBytes = size ;
Properties = CD3DX12_HEAP_PROPERTIES ( type ) ;
Alignment = alignment ;
Flags = flags ;
}
2020-03-18 04:45:33 +00:00
CD3DX12_HEAP_DESC (
UINT64 size ,
D3D12_CPU_PAGE_PROPERTY cpuPageProperty ,
D3D12_MEMORY_POOL memoryPoolPreference ,
UINT64 alignment = 0 ,
2020-03-16 09:16:44 +00:00
D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept
2017-01-26 18:23:36 +00:00
{
SizeInBytes = size ;
Properties = CD3DX12_HEAP_PROPERTIES ( cpuPageProperty , memoryPoolPreference ) ;
Alignment = alignment ;
Flags = flags ;
}
2020-03-18 04:45:33 +00:00
CD3DX12_HEAP_DESC (
2017-01-26 18:23:36 +00:00
const D3D12_RESOURCE_ALLOCATION_INFO & resAllocInfo ,
2020-03-18 04:45:33 +00:00
D3D12_HEAP_PROPERTIES properties ,
2020-03-16 09:16:44 +00:00
D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept
2017-01-26 18:23:36 +00:00
{
SizeInBytes = resAllocInfo . SizeInBytes ;
Properties = properties ;
Alignment = resAllocInfo . Alignment ;
Flags = flags ;
}
2020-03-18 04:45:33 +00:00
CD3DX12_HEAP_DESC (
2017-01-26 18:23:36 +00:00
const D3D12_RESOURCE_ALLOCATION_INFO & resAllocInfo ,
2020-03-18 04:45:33 +00:00
D3D12_HEAP_TYPE type ,
2020-03-16 09:16:44 +00:00
D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept
2017-01-26 18:23:36 +00:00
{
SizeInBytes = resAllocInfo . SizeInBytes ;
Properties = CD3DX12_HEAP_PROPERTIES ( type ) ;
Alignment = resAllocInfo . Alignment ;
Flags = flags ;
}
2020-03-18 04:45:33 +00:00
CD3DX12_HEAP_DESC (
2017-01-26 18:23:36 +00:00
const D3D12_RESOURCE_ALLOCATION_INFO & resAllocInfo ,
2020-03-18 04:45:33 +00:00
D3D12_CPU_PAGE_PROPERTY cpuPageProperty ,
D3D12_MEMORY_POOL memoryPoolPreference ,
2020-03-16 09:16:44 +00:00
D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept
2017-01-26 18:23:36 +00:00
{
SizeInBytes = resAllocInfo . SizeInBytes ;
Properties = CD3DX12_HEAP_PROPERTIES ( cpuPageProperty , memoryPoolPreference ) ;
Alignment = resAllocInfo . Alignment ;
Flags = flags ;
}
2020-03-16 09:16:44 +00:00
bool IsCPUAccessible ( ) const noexcept
2017-01-26 18:23:36 +00:00
{ return static_cast < const CD3DX12_HEAP_PROPERTIES * > ( & Properties ) - > IsCPUAccessible ( ) ; }
} ;
2020-03-16 09:16:44 +00:00
inline bool operator = = ( const D3D12_HEAP_DESC & l , const D3D12_HEAP_DESC & r ) noexcept
2017-01-26 18:23:36 +00:00
{
return l . SizeInBytes = = r . SizeInBytes & &
2020-03-18 04:45:33 +00:00
l . Properties = = r . Properties & &
2017-01-26 18:23:36 +00:00
l . Alignment = = r . Alignment & &
l . Flags = = r . Flags ;
}
2020-03-16 09:16:44 +00:00
inline bool operator ! = ( const D3D12_HEAP_DESC & l , const D3D12_HEAP_DESC & r ) noexcept
2017-01-26 18:23:36 +00:00
{ return ! ( l = = r ) ; }
//------------------------------------------------------------------------------------------------
struct CD3DX12_CLEAR_VALUE : public D3D12_CLEAR_VALUE
{
2018-04-12 01:06:24 +00:00
CD3DX12_CLEAR_VALUE ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_CLEAR_VALUE ( const D3D12_CLEAR_VALUE & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_CLEAR_VALUE ( o )
{ }
2020-03-18 04:45:33 +00:00
CD3DX12_CLEAR_VALUE (
DXGI_FORMAT format ,
2020-03-16 09:16:44 +00:00
const FLOAT color [ 4 ] ) noexcept
2017-01-26 18:23:36 +00:00
{
Format = format ;
memcpy ( Color , color , sizeof ( Color ) ) ;
}
2020-03-18 04:45:33 +00:00
CD3DX12_CLEAR_VALUE (
DXGI_FORMAT format ,
2017-01-26 18:23:36 +00:00
FLOAT depth ,
2020-03-16 09:16:44 +00:00
UINT8 stencil ) noexcept
2017-01-26 18:23:36 +00:00
{
Format = format ;
2019-08-23 20:26:03 +00:00
memset ( & Color , 0 , sizeof ( Color ) ) ;
2017-01-26 18:23:36 +00:00
/* Use memcpy to preserve NAN values */
memcpy ( & DepthStencil . Depth , & depth , sizeof ( depth ) ) ;
DepthStencil . Stencil = stencil ;
}
} ;
2022-11-19 21:03:20 +00:00
//------------------------------------------------------------------------------------------------
inline bool operator = = ( const D3D12_CLEAR_VALUE & a , const D3D12_CLEAR_VALUE & b ) noexcept
{
if ( a . Format ! = b . Format ) return false ;
if ( a . Format = = DXGI_FORMAT_D24_UNORM_S8_UINT
| | a . Format = = DXGI_FORMAT_D16_UNORM
| | a . Format = = DXGI_FORMAT_D32_FLOAT
| | a . Format = = DXGI_FORMAT_D32_FLOAT_S8X24_UINT )
{
return ( a . DepthStencil . Depth = = b . DepthStencil . Depth ) & &
( a . DepthStencil . Stencil = = b . DepthStencil . Stencil ) ;
} else {
return ( a . Color [ 0 ] = = b . Color [ 0 ] ) & &
( a . Color [ 1 ] = = b . Color [ 1 ] ) & &
( a . Color [ 2 ] = = b . Color [ 2 ] ) & &
( a . Color [ 3 ] = = b . Color [ 3 ] ) ;
}
}
2017-01-26 18:23:36 +00:00
//------------------------------------------------------------------------------------------------
struct CD3DX12_RANGE : public D3D12_RANGE
{
2018-04-12 01:06:24 +00:00
CD3DX12_RANGE ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_RANGE ( const D3D12_RANGE & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_RANGE ( o )
{ }
2020-03-18 04:45:33 +00:00
CD3DX12_RANGE (
SIZE_T begin ,
2020-03-16 09:16:44 +00:00
SIZE_T end ) noexcept
2017-01-26 18:23:36 +00:00
{
Begin = begin ;
End = end ;
}
} ;
2017-04-20 01:13:34 +00:00
//------------------------------------------------------------------------------------------------
struct CD3DX12_RANGE_UINT64 : public D3D12_RANGE_UINT64
{
2018-04-12 01:06:24 +00:00
CD3DX12_RANGE_UINT64 ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_RANGE_UINT64 ( const D3D12_RANGE_UINT64 & o ) noexcept :
2017-04-20 01:13:34 +00:00
D3D12_RANGE_UINT64 ( o )
{ }
2020-03-18 04:45:33 +00:00
CD3DX12_RANGE_UINT64 (
UINT64 begin ,
2020-03-16 09:16:44 +00:00
UINT64 end ) noexcept
2017-04-20 01:13:34 +00:00
{
Begin = begin ;
End = end ;
}
} ;
//------------------------------------------------------------------------------------------------
struct CD3DX12_SUBRESOURCE_RANGE_UINT64 : public D3D12_SUBRESOURCE_RANGE_UINT64
{
2018-04-12 01:06:24 +00:00
CD3DX12_SUBRESOURCE_RANGE_UINT64 ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_SUBRESOURCE_RANGE_UINT64 ( const D3D12_SUBRESOURCE_RANGE_UINT64 & o ) noexcept :
2017-04-20 01:13:34 +00:00
D3D12_SUBRESOURCE_RANGE_UINT64 ( o )
{ }
2020-03-18 04:45:33 +00:00
CD3DX12_SUBRESOURCE_RANGE_UINT64 (
2017-04-20 01:13:34 +00:00
UINT subresource ,
2020-03-16 09:16:44 +00:00
const D3D12_RANGE_UINT64 & range ) noexcept
2017-04-20 01:13:34 +00:00
{
Subresource = subresource ;
Range = range ;
}
2020-03-18 04:45:33 +00:00
CD3DX12_SUBRESOURCE_RANGE_UINT64 (
2017-04-20 01:13:34 +00:00
UINT subresource ,
2020-03-18 04:45:33 +00:00
UINT64 begin ,
2020-03-16 09:16:44 +00:00
UINT64 end ) noexcept
2017-04-20 01:13:34 +00:00
{
Subresource = subresource ;
Range . Begin = begin ;
Range . End = end ;
}
} ;
2017-01-26 18:23:36 +00:00
//------------------------------------------------------------------------------------------------
struct CD3DX12_SHADER_BYTECODE : public D3D12_SHADER_BYTECODE
{
2018-04-12 01:06:24 +00:00
CD3DX12_SHADER_BYTECODE ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_SHADER_BYTECODE ( const D3D12_SHADER_BYTECODE & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_SHADER_BYTECODE ( o )
{ }
CD3DX12_SHADER_BYTECODE (
2020-03-16 09:16:44 +00:00
_In_ ID3DBlob * pShaderBlob ) noexcept
2017-01-26 18:23:36 +00:00
{
pShaderBytecode = pShaderBlob - > GetBufferPointer ( ) ;
BytecodeLength = pShaderBlob - > GetBufferSize ( ) ;
}
CD3DX12_SHADER_BYTECODE (
2017-04-20 01:13:34 +00:00
const void * _pShaderBytecode ,
2020-03-16 09:16:44 +00:00
SIZE_T bytecodeLength ) noexcept
2017-01-26 18:23:36 +00:00
{
pShaderBytecode = _pShaderBytecode ;
BytecodeLength = bytecodeLength ;
}
} ;
//------------------------------------------------------------------------------------------------
struct CD3DX12_TILED_RESOURCE_COORDINATE : public D3D12_TILED_RESOURCE_COORDINATE
{
2018-04-12 01:06:24 +00:00
CD3DX12_TILED_RESOURCE_COORDINATE ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_TILED_RESOURCE_COORDINATE ( const D3D12_TILED_RESOURCE_COORDINATE & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_TILED_RESOURCE_COORDINATE ( o )
{ }
2020-03-18 04:45:33 +00:00
CD3DX12_TILED_RESOURCE_COORDINATE (
UINT x ,
UINT y ,
UINT z ,
2020-03-16 09:16:44 +00:00
UINT subresource ) noexcept
2017-01-26 18:23:36 +00:00
{
X = x ;
Y = y ;
Z = z ;
Subresource = subresource ;
}
} ;
//------------------------------------------------------------------------------------------------
struct CD3DX12_TILE_REGION_SIZE : public D3D12_TILE_REGION_SIZE
{
2018-04-12 01:06:24 +00:00
CD3DX12_TILE_REGION_SIZE ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_TILE_REGION_SIZE ( const D3D12_TILE_REGION_SIZE & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_TILE_REGION_SIZE ( o )
{ }
2020-03-18 04:45:33 +00:00
CD3DX12_TILE_REGION_SIZE (
UINT numTiles ,
BOOL useBox ,
UINT width ,
UINT16 height ,
2020-03-16 09:16:44 +00:00
UINT16 depth ) noexcept
2017-01-26 18:23:36 +00:00
{
NumTiles = numTiles ;
UseBox = useBox ;
Width = width ;
Height = height ;
Depth = depth ;
}
} ;
//------------------------------------------------------------------------------------------------
struct CD3DX12_SUBRESOURCE_TILING : public D3D12_SUBRESOURCE_TILING
{
2018-04-12 01:06:24 +00:00
CD3DX12_SUBRESOURCE_TILING ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_SUBRESOURCE_TILING ( const D3D12_SUBRESOURCE_TILING & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_SUBRESOURCE_TILING ( o )
{ }
2020-03-18 04:45:33 +00:00
CD3DX12_SUBRESOURCE_TILING (
UINT widthInTiles ,
UINT16 heightInTiles ,
UINT16 depthInTiles ,
2020-03-16 09:16:44 +00:00
UINT startTileIndexInOverallResource ) noexcept
2017-01-26 18:23:36 +00:00
{
WidthInTiles = widthInTiles ;
HeightInTiles = heightInTiles ;
DepthInTiles = depthInTiles ;
StartTileIndexInOverallResource = startTileIndexInOverallResource ;
}
} ;
//------------------------------------------------------------------------------------------------
struct CD3DX12_TILE_SHAPE : public D3D12_TILE_SHAPE
{
2018-04-12 01:06:24 +00:00
CD3DX12_TILE_SHAPE ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_TILE_SHAPE ( const D3D12_TILE_SHAPE & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_TILE_SHAPE ( o )
{ }
2020-03-18 04:45:33 +00:00
CD3DX12_TILE_SHAPE (
UINT widthInTexels ,
UINT heightInTexels ,
2020-03-16 09:16:44 +00:00
UINT depthInTexels ) noexcept
2017-01-26 18:23:36 +00:00
{
WidthInTexels = widthInTexels ;
HeightInTexels = heightInTexels ;
DepthInTexels = depthInTexels ;
}
} ;
//------------------------------------------------------------------------------------------------
struct CD3DX12_RESOURCE_BARRIER : public D3D12_RESOURCE_BARRIER
{
2018-04-12 01:06:24 +00:00
CD3DX12_RESOURCE_BARRIER ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_RESOURCE_BARRIER ( const D3D12_RESOURCE_BARRIER & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_RESOURCE_BARRIER ( o )
{ }
static inline CD3DX12_RESOURCE_BARRIER Transition (
_In_ ID3D12Resource * pResource ,
D3D12_RESOURCE_STATES stateBefore ,
D3D12_RESOURCE_STATES stateAfter ,
UINT subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES ,
2020-03-16 09:16:44 +00:00
D3D12_RESOURCE_BARRIER_FLAGS flags = D3D12_RESOURCE_BARRIER_FLAG_NONE ) noexcept
2017-01-26 18:23:36 +00:00
{
2018-06-22 23:55:00 +00:00
CD3DX12_RESOURCE_BARRIER result = { } ;
2017-01-26 18:23:36 +00:00
D3D12_RESOURCE_BARRIER & barrier = result ;
result . Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION ;
result . Flags = flags ;
barrier . Transition . pResource = pResource ;
barrier . Transition . StateBefore = stateBefore ;
barrier . Transition . StateAfter = stateAfter ;
barrier . Transition . Subresource = subresource ;
return result ;
}
static inline CD3DX12_RESOURCE_BARRIER Aliasing (
2023-04-24 20:52:49 +00:00
_In_opt_ ID3D12Resource * pResourceBefore ,
_In_opt_ ID3D12Resource * pResourceAfter ) noexcept
2017-01-26 18:23:36 +00:00
{
2018-06-22 23:55:00 +00:00
CD3DX12_RESOURCE_BARRIER result = { } ;
2017-01-26 18:23:36 +00:00
D3D12_RESOURCE_BARRIER & barrier = result ;
result . Type = D3D12_RESOURCE_BARRIER_TYPE_ALIASING ;
barrier . Aliasing . pResourceBefore = pResourceBefore ;
barrier . Aliasing . pResourceAfter = pResourceAfter ;
return result ;
}
static inline CD3DX12_RESOURCE_BARRIER UAV (
2023-04-24 20:52:49 +00:00
_In_opt_ ID3D12Resource * pResource ) noexcept
2017-01-26 18:23:36 +00:00
{
2018-06-22 23:55:00 +00:00
CD3DX12_RESOURCE_BARRIER result = { } ;
2017-01-26 18:23:36 +00:00
D3D12_RESOURCE_BARRIER & barrier = result ;
result . Type = D3D12_RESOURCE_BARRIER_TYPE_UAV ;
barrier . UAV . pResource = pResource ;
return result ;
}
} ;
//------------------------------------------------------------------------------------------------
struct CD3DX12_PACKED_MIP_INFO : public D3D12_PACKED_MIP_INFO
{
2018-04-12 01:06:24 +00:00
CD3DX12_PACKED_MIP_INFO ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_PACKED_MIP_INFO ( const D3D12_PACKED_MIP_INFO & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_PACKED_MIP_INFO ( o )
{ }
2020-03-18 04:45:33 +00:00
CD3DX12_PACKED_MIP_INFO (
UINT8 numStandardMips ,
UINT8 numPackedMips ,
UINT numTilesForPackedMips ,
2020-03-16 09:16:44 +00:00
UINT startTileIndexInOverallResource ) noexcept
2017-01-26 18:23:36 +00:00
{
NumStandardMips = numStandardMips ;
NumPackedMips = numPackedMips ;
NumTilesForPackedMips = numTilesForPackedMips ;
StartTileIndexInOverallResource = startTileIndexInOverallResource ;
}
} ;
//------------------------------------------------------------------------------------------------
struct CD3DX12_SUBRESOURCE_FOOTPRINT : public D3D12_SUBRESOURCE_FOOTPRINT
{
2018-04-12 01:06:24 +00:00
CD3DX12_SUBRESOURCE_FOOTPRINT ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_SUBRESOURCE_FOOTPRINT ( const D3D12_SUBRESOURCE_FOOTPRINT & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_SUBRESOURCE_FOOTPRINT ( o )
{ }
2020-03-18 04:45:33 +00:00
CD3DX12_SUBRESOURCE_FOOTPRINT (
DXGI_FORMAT format ,
UINT width ,
UINT height ,
UINT depth ,
2020-03-16 09:16:44 +00:00
UINT rowPitch ) noexcept
2017-01-26 18:23:36 +00:00
{
Format = format ;
Width = width ;
Height = height ;
Depth = depth ;
RowPitch = rowPitch ;
}
2020-03-18 04:45:33 +00:00
explicit CD3DX12_SUBRESOURCE_FOOTPRINT (
const D3D12_RESOURCE_DESC & resDesc ,
2020-03-16 09:16:44 +00:00
UINT rowPitch ) noexcept
2017-01-26 18:23:36 +00:00
{
Format = resDesc . Format ;
Width = UINT ( resDesc . Width ) ;
Height = resDesc . Height ;
2021-10-22 23:43:43 +00:00
Depth = ( resDesc . Dimension = = D3D12_RESOURCE_DIMENSION_TEXTURE3D ? resDesc . DepthOrArraySize : 1u ) ;
2017-01-26 18:23:36 +00:00
RowPitch = rowPitch ;
}
} ;
//------------------------------------------------------------------------------------------------
struct CD3DX12_TEXTURE_COPY_LOCATION : public D3D12_TEXTURE_COPY_LOCATION
2020-03-18 04:45:33 +00:00
{
2018-04-12 01:06:24 +00:00
CD3DX12_TEXTURE_COPY_LOCATION ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_TEXTURE_COPY_LOCATION ( const D3D12_TEXTURE_COPY_LOCATION & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_TEXTURE_COPY_LOCATION ( o )
{ }
2020-03-16 09:16:44 +00:00
CD3DX12_TEXTURE_COPY_LOCATION ( _In_ ID3D12Resource * pRes ) noexcept
2018-06-22 23:55:00 +00:00
{
pResource = pRes ;
Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX ;
PlacedFootprint = { } ;
}
2020-03-16 09:16:44 +00:00
CD3DX12_TEXTURE_COPY_LOCATION ( _In_ ID3D12Resource * pRes , D3D12_PLACED_SUBRESOURCE_FOOTPRINT const & Footprint ) noexcept
2017-01-26 18:23:36 +00:00
{
pResource = pRes ;
Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT ;
PlacedFootprint = Footprint ;
}
2020-03-16 09:16:44 +00:00
CD3DX12_TEXTURE_COPY_LOCATION ( _In_ ID3D12Resource * pRes , UINT Sub ) noexcept
2017-01-26 18:23:36 +00:00
{
pResource = pRes ;
Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX ;
2019-08-23 20:26:03 +00:00
PlacedFootprint = { } ;
2017-01-26 18:23:36 +00:00
SubresourceIndex = Sub ;
}
2020-03-18 04:45:33 +00:00
} ;
2017-01-26 18:23:36 +00:00
//------------------------------------------------------------------------------------------------
struct CD3DX12_DESCRIPTOR_RANGE : public D3D12_DESCRIPTOR_RANGE
{
2018-04-12 01:06:24 +00:00
CD3DX12_DESCRIPTOR_RANGE ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_DESCRIPTOR_RANGE ( const D3D12_DESCRIPTOR_RANGE & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_DESCRIPTOR_RANGE ( o )
{ }
CD3DX12_DESCRIPTOR_RANGE (
D3D12_DESCRIPTOR_RANGE_TYPE rangeType ,
UINT numDescriptors ,
UINT baseShaderRegister ,
UINT registerSpace = 0 ,
UINT offsetInDescriptorsFromTableStart =
2020-03-16 09:16:44 +00:00
D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND ) noexcept
2017-01-26 18:23:36 +00:00
{
Init ( rangeType , numDescriptors , baseShaderRegister , registerSpace , offsetInDescriptorsFromTableStart ) ;
}
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
inline void Init (
D3D12_DESCRIPTOR_RANGE_TYPE rangeType ,
UINT numDescriptors ,
UINT baseShaderRegister ,
UINT registerSpace = 0 ,
UINT offsetInDescriptorsFromTableStart =
2020-03-16 09:16:44 +00:00
D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND ) noexcept
2017-01-26 18:23:36 +00:00
{
Init ( * this , rangeType , numDescriptors , baseShaderRegister , registerSpace , offsetInDescriptorsFromTableStart ) ;
}
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
static inline void Init (
_Out_ D3D12_DESCRIPTOR_RANGE & range ,
D3D12_DESCRIPTOR_RANGE_TYPE rangeType ,
UINT numDescriptors ,
UINT baseShaderRegister ,
UINT registerSpace = 0 ,
UINT offsetInDescriptorsFromTableStart =
2020-03-16 09:16:44 +00:00
D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND ) noexcept
2017-01-26 18:23:36 +00:00
{
range . RangeType = rangeType ;
range . NumDescriptors = numDescriptors ;
range . BaseShaderRegister = baseShaderRegister ;
range . RegisterSpace = registerSpace ;
range . OffsetInDescriptorsFromTableStart = offsetInDescriptorsFromTableStart ;
}
} ;
//------------------------------------------------------------------------------------------------
struct CD3DX12_ROOT_DESCRIPTOR_TABLE : public D3D12_ROOT_DESCRIPTOR_TABLE
{
2018-04-12 01:06:24 +00:00
CD3DX12_ROOT_DESCRIPTOR_TABLE ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_ROOT_DESCRIPTOR_TABLE ( const D3D12_ROOT_DESCRIPTOR_TABLE & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_ROOT_DESCRIPTOR_TABLE ( o )
{ }
CD3DX12_ROOT_DESCRIPTOR_TABLE (
UINT numDescriptorRanges ,
2020-03-16 09:16:44 +00:00
_In_reads_opt_ ( numDescriptorRanges ) const D3D12_DESCRIPTOR_RANGE * _pDescriptorRanges ) noexcept
2017-01-26 18:23:36 +00:00
{
Init ( numDescriptorRanges , _pDescriptorRanges ) ;
}
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
inline void Init (
UINT numDescriptorRanges ,
2020-03-16 09:16:44 +00:00
_In_reads_opt_ ( numDescriptorRanges ) const D3D12_DESCRIPTOR_RANGE * _pDescriptorRanges ) noexcept
2017-01-26 18:23:36 +00:00
{
Init ( * this , numDescriptorRanges , _pDescriptorRanges ) ;
}
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
static inline void Init (
_Out_ D3D12_ROOT_DESCRIPTOR_TABLE & rootDescriptorTable ,
UINT numDescriptorRanges ,
2020-03-16 09:16:44 +00:00
_In_reads_opt_ ( numDescriptorRanges ) const D3D12_DESCRIPTOR_RANGE * _pDescriptorRanges ) noexcept
2017-01-26 18:23:36 +00:00
{
rootDescriptorTable . NumDescriptorRanges = numDescriptorRanges ;
rootDescriptorTable . pDescriptorRanges = _pDescriptorRanges ;
}
} ;
//------------------------------------------------------------------------------------------------
struct CD3DX12_ROOT_CONSTANTS : public D3D12_ROOT_CONSTANTS
{
2018-04-12 01:06:24 +00:00
CD3DX12_ROOT_CONSTANTS ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_ROOT_CONSTANTS ( const D3D12_ROOT_CONSTANTS & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_ROOT_CONSTANTS ( o )
{ }
CD3DX12_ROOT_CONSTANTS (
UINT num32BitValues ,
UINT shaderRegister ,
2020-03-16 09:16:44 +00:00
UINT registerSpace = 0 ) noexcept
2017-01-26 18:23:36 +00:00
{
Init ( num32BitValues , shaderRegister , registerSpace ) ;
}
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
inline void Init (
UINT num32BitValues ,
UINT shaderRegister ,
2020-03-16 09:16:44 +00:00
UINT registerSpace = 0 ) noexcept
2017-01-26 18:23:36 +00:00
{
Init ( * this , num32BitValues , shaderRegister , registerSpace ) ;
}
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
static inline void Init (
_Out_ D3D12_ROOT_CONSTANTS & rootConstants ,
UINT num32BitValues ,
UINT shaderRegister ,
2020-03-16 09:16:44 +00:00
UINT registerSpace = 0 ) noexcept
2017-01-26 18:23:36 +00:00
{
rootConstants . Num32BitValues = num32BitValues ;
rootConstants . ShaderRegister = shaderRegister ;
rootConstants . RegisterSpace = registerSpace ;
}
} ;
//------------------------------------------------------------------------------------------------
struct CD3DX12_ROOT_DESCRIPTOR : public D3D12_ROOT_DESCRIPTOR
{
2018-04-12 01:06:24 +00:00
CD3DX12_ROOT_DESCRIPTOR ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_ROOT_DESCRIPTOR ( const D3D12_ROOT_DESCRIPTOR & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_ROOT_DESCRIPTOR ( o )
{ }
CD3DX12_ROOT_DESCRIPTOR (
UINT shaderRegister ,
2020-03-16 09:16:44 +00:00
UINT registerSpace = 0 ) noexcept
2017-01-26 18:23:36 +00:00
{
Init ( shaderRegister , registerSpace ) ;
}
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
inline void Init (
UINT shaderRegister ,
2020-03-16 09:16:44 +00:00
UINT registerSpace = 0 ) noexcept
2017-01-26 18:23:36 +00:00
{
Init ( * this , shaderRegister , registerSpace ) ;
}
2020-03-18 04:45:33 +00:00
2020-03-16 09:16:44 +00:00
static inline void Init ( _Out_ D3D12_ROOT_DESCRIPTOR & table , UINT shaderRegister , UINT registerSpace = 0 ) noexcept
2017-01-26 18:23:36 +00:00
{
table . ShaderRegister = shaderRegister ;
table . RegisterSpace = registerSpace ;
}
} ;
//------------------------------------------------------------------------------------------------
struct CD3DX12_ROOT_PARAMETER : public D3D12_ROOT_PARAMETER
{
2018-04-12 01:06:24 +00:00
CD3DX12_ROOT_PARAMETER ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_ROOT_PARAMETER ( const D3D12_ROOT_PARAMETER & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_ROOT_PARAMETER ( o )
{ }
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
static inline void InitAsDescriptorTable (
_Out_ D3D12_ROOT_PARAMETER & rootParam ,
UINT numDescriptorRanges ,
_In_reads_ ( numDescriptorRanges ) const D3D12_DESCRIPTOR_RANGE * pDescriptorRanges ,
2020-03-16 09:16:44 +00:00
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL ) noexcept
2017-01-26 18:23:36 +00:00
{
rootParam . ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE ;
rootParam . ShaderVisibility = visibility ;
CD3DX12_ROOT_DESCRIPTOR_TABLE : : Init ( rootParam . DescriptorTable , numDescriptorRanges , pDescriptorRanges ) ;
}
static inline void InitAsConstants (
_Out_ D3D12_ROOT_PARAMETER & rootParam ,
UINT num32BitValues ,
UINT shaderRegister ,
UINT registerSpace = 0 ,
2020-03-16 09:16:44 +00:00
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL ) noexcept
2017-01-26 18:23:36 +00:00
{
rootParam . ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS ;
rootParam . ShaderVisibility = visibility ;
CD3DX12_ROOT_CONSTANTS : : Init ( rootParam . Constants , num32BitValues , shaderRegister , registerSpace ) ;
}
static inline void InitAsConstantBufferView (
_Out_ D3D12_ROOT_PARAMETER & rootParam ,
UINT shaderRegister ,
UINT registerSpace = 0 ,
2020-03-16 09:16:44 +00:00
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL ) noexcept
2017-01-26 18:23:36 +00:00
{
rootParam . ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV ;
rootParam . ShaderVisibility = visibility ;
CD3DX12_ROOT_DESCRIPTOR : : Init ( rootParam . Descriptor , shaderRegister , registerSpace ) ;
}
static inline void InitAsShaderResourceView (
_Out_ D3D12_ROOT_PARAMETER & rootParam ,
UINT shaderRegister ,
UINT registerSpace = 0 ,
2020-03-16 09:16:44 +00:00
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL ) noexcept
2017-01-26 18:23:36 +00:00
{
rootParam . ParameterType = D3D12_ROOT_PARAMETER_TYPE_SRV ;
rootParam . ShaderVisibility = visibility ;
CD3DX12_ROOT_DESCRIPTOR : : Init ( rootParam . Descriptor , shaderRegister , registerSpace ) ;
}
static inline void InitAsUnorderedAccessView (
_Out_ D3D12_ROOT_PARAMETER & rootParam ,
UINT shaderRegister ,
UINT registerSpace = 0 ,
2020-03-16 09:16:44 +00:00
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL ) noexcept
2017-01-26 18:23:36 +00:00
{
rootParam . ParameterType = D3D12_ROOT_PARAMETER_TYPE_UAV ;
rootParam . ShaderVisibility = visibility ;
CD3DX12_ROOT_DESCRIPTOR : : Init ( rootParam . Descriptor , shaderRegister , registerSpace ) ;
}
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
inline void InitAsDescriptorTable (
UINT numDescriptorRanges ,
_In_reads_ ( numDescriptorRanges ) const D3D12_DESCRIPTOR_RANGE * pDescriptorRanges ,
2020-03-16 09:16:44 +00:00
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL ) noexcept
2017-01-26 18:23:36 +00:00
{
InitAsDescriptorTable ( * this , numDescriptorRanges , pDescriptorRanges , visibility ) ;
}
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
inline void InitAsConstants (
UINT num32BitValues ,
UINT shaderRegister ,
UINT registerSpace = 0 ,
2020-03-16 09:16:44 +00:00
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL ) noexcept
2017-01-26 18:23:36 +00:00
{
InitAsConstants ( * this , num32BitValues , shaderRegister , registerSpace , visibility ) ;
}
inline void InitAsConstantBufferView (
UINT shaderRegister ,
UINT registerSpace = 0 ,
2020-03-16 09:16:44 +00:00
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL ) noexcept
2017-01-26 18:23:36 +00:00
{
InitAsConstantBufferView ( * this , shaderRegister , registerSpace , visibility ) ;
}
inline void InitAsShaderResourceView (
UINT shaderRegister ,
UINT registerSpace = 0 ,
2020-03-16 09:16:44 +00:00
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL ) noexcept
2017-01-26 18:23:36 +00:00
{
InitAsShaderResourceView ( * this , shaderRegister , registerSpace , visibility ) ;
}
inline void InitAsUnorderedAccessView (
UINT shaderRegister ,
UINT registerSpace = 0 ,
2020-03-16 09:16:44 +00:00
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL ) noexcept
2017-01-26 18:23:36 +00:00
{
InitAsUnorderedAccessView ( * this , shaderRegister , registerSpace , visibility ) ;
}
} ;
//------------------------------------------------------------------------------------------------
struct CD3DX12_STATIC_SAMPLER_DESC : public D3D12_STATIC_SAMPLER_DESC
{
2018-04-12 01:06:24 +00:00
CD3DX12_STATIC_SAMPLER_DESC ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_STATIC_SAMPLER_DESC ( const D3D12_STATIC_SAMPLER_DESC & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_STATIC_SAMPLER_DESC ( o )
{ }
CD3DX12_STATIC_SAMPLER_DESC (
UINT shaderRegister ,
D3D12_FILTER filter = D3D12_FILTER_ANISOTROPIC ,
D3D12_TEXTURE_ADDRESS_MODE addressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP ,
D3D12_TEXTURE_ADDRESS_MODE addressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP ,
D3D12_TEXTURE_ADDRESS_MODE addressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP ,
FLOAT mipLODBias = 0 ,
UINT maxAnisotropy = 16 ,
D3D12_COMPARISON_FUNC comparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL ,
D3D12_STATIC_BORDER_COLOR borderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE ,
FLOAT minLOD = 0.f ,
FLOAT maxLOD = D3D12_FLOAT32_MAX ,
2020-03-18 04:45:33 +00:00
D3D12_SHADER_VISIBILITY shaderVisibility = D3D12_SHADER_VISIBILITY_ALL ,
2020-03-16 09:16:44 +00:00
UINT registerSpace = 0 ) noexcept
2017-01-26 18:23:36 +00:00
{
Init (
shaderRegister ,
filter ,
addressU ,
addressV ,
addressW ,
mipLODBias ,
maxAnisotropy ,
comparisonFunc ,
borderColor ,
minLOD ,
maxLOD ,
shaderVisibility ,
registerSpace ) ;
}
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
static inline void Init (
_Out_ D3D12_STATIC_SAMPLER_DESC & samplerDesc ,
UINT shaderRegister ,
D3D12_FILTER filter = D3D12_FILTER_ANISOTROPIC ,
D3D12_TEXTURE_ADDRESS_MODE addressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP ,
D3D12_TEXTURE_ADDRESS_MODE addressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP ,
D3D12_TEXTURE_ADDRESS_MODE addressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP ,
FLOAT mipLODBias = 0 ,
UINT maxAnisotropy = 16 ,
D3D12_COMPARISON_FUNC comparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL ,
D3D12_STATIC_BORDER_COLOR borderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE ,
FLOAT minLOD = 0.f ,
FLOAT maxLOD = D3D12_FLOAT32_MAX ,
2020-03-18 04:45:33 +00:00
D3D12_SHADER_VISIBILITY shaderVisibility = D3D12_SHADER_VISIBILITY_ALL ,
2020-03-16 09:16:44 +00:00
UINT registerSpace = 0 ) noexcept
2017-01-26 18:23:36 +00:00
{
samplerDesc . ShaderRegister = shaderRegister ;
samplerDesc . Filter = filter ;
samplerDesc . AddressU = addressU ;
samplerDesc . AddressV = addressV ;
samplerDesc . AddressW = addressW ;
samplerDesc . MipLODBias = mipLODBias ;
samplerDesc . MaxAnisotropy = maxAnisotropy ;
samplerDesc . ComparisonFunc = comparisonFunc ;
samplerDesc . BorderColor = borderColor ;
samplerDesc . MinLOD = minLOD ;
samplerDesc . MaxLOD = maxLOD ;
samplerDesc . ShaderVisibility = shaderVisibility ;
samplerDesc . RegisterSpace = registerSpace ;
}
inline void Init (
UINT shaderRegister ,
D3D12_FILTER filter = D3D12_FILTER_ANISOTROPIC ,
D3D12_TEXTURE_ADDRESS_MODE addressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP ,
D3D12_TEXTURE_ADDRESS_MODE addressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP ,
D3D12_TEXTURE_ADDRESS_MODE addressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP ,
FLOAT mipLODBias = 0 ,
UINT maxAnisotropy = 16 ,
D3D12_COMPARISON_FUNC comparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL ,
D3D12_STATIC_BORDER_COLOR borderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE ,
FLOAT minLOD = 0.f ,
FLOAT maxLOD = D3D12_FLOAT32_MAX ,
2020-03-18 04:45:33 +00:00
D3D12_SHADER_VISIBILITY shaderVisibility = D3D12_SHADER_VISIBILITY_ALL ,
2020-03-16 09:16:44 +00:00
UINT registerSpace = 0 ) noexcept
2017-01-26 18:23:36 +00:00
{
Init (
* this ,
shaderRegister ,
filter ,
addressU ,
addressV ,
addressW ,
mipLODBias ,
maxAnisotropy ,
comparisonFunc ,
borderColor ,
minLOD ,
maxLOD ,
shaderVisibility ,
registerSpace ) ;
}
} ;
2023-04-24 20:52:49 +00:00
//------------------------------------------------------------------------------------------------
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
struct CD3DX12_STATIC_SAMPLER_DESC1 : public D3D12_STATIC_SAMPLER_DESC1
{
CD3DX12_STATIC_SAMPLER_DESC1 ( ) = default ;
explicit CD3DX12_STATIC_SAMPLER_DESC1 ( const D3D12_STATIC_SAMPLER_DESC & o ) noexcept
{
memcpy ( this , & o , sizeof ( D3D12_STATIC_SAMPLER_DESC ) ) ;
Flags = D3D12_SAMPLER_FLAGS : : D3D12_SAMPLER_FLAG_NONE ;
}
explicit CD3DX12_STATIC_SAMPLER_DESC1 ( const D3D12_STATIC_SAMPLER_DESC1 & o ) noexcept :
D3D12_STATIC_SAMPLER_DESC1 ( o )
{ }
CD3DX12_STATIC_SAMPLER_DESC1 (
UINT shaderRegister ,
D3D12_FILTER filter = D3D12_FILTER_ANISOTROPIC ,
D3D12_TEXTURE_ADDRESS_MODE addressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP ,
D3D12_TEXTURE_ADDRESS_MODE addressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP ,
D3D12_TEXTURE_ADDRESS_MODE addressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP ,
FLOAT mipLODBias = 0 ,
UINT maxAnisotropy = 16 ,
D3D12_COMPARISON_FUNC comparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL ,
D3D12_STATIC_BORDER_COLOR borderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE ,
FLOAT minLOD = 0.f ,
FLOAT maxLOD = D3D12_FLOAT32_MAX ,
D3D12_SHADER_VISIBILITY shaderVisibility = D3D12_SHADER_VISIBILITY_ALL ,
UINT registerSpace = 0 ,
D3D12_SAMPLER_FLAGS flags = D3D12_SAMPLER_FLAGS : : D3D12_SAMPLER_FLAG_NONE ) noexcept
{
Init (
shaderRegister ,
filter ,
addressU ,
addressV ,
addressW ,
mipLODBias ,
maxAnisotropy ,
comparisonFunc ,
borderColor ,
minLOD ,
maxLOD ,
shaderVisibility ,
registerSpace ,
flags ) ;
}
static inline void Init (
_Out_ D3D12_STATIC_SAMPLER_DESC1 & samplerDesc ,
UINT shaderRegister ,
D3D12_FILTER filter = D3D12_FILTER_ANISOTROPIC ,
D3D12_TEXTURE_ADDRESS_MODE addressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP ,
D3D12_TEXTURE_ADDRESS_MODE addressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP ,
D3D12_TEXTURE_ADDRESS_MODE addressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP ,
FLOAT mipLODBias = 0 ,
UINT maxAnisotropy = 16 ,
D3D12_COMPARISON_FUNC comparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL ,
D3D12_STATIC_BORDER_COLOR borderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE ,
FLOAT minLOD = 0.f ,
FLOAT maxLOD = D3D12_FLOAT32_MAX ,
D3D12_SHADER_VISIBILITY shaderVisibility = D3D12_SHADER_VISIBILITY_ALL ,
UINT registerSpace = 0 ,
D3D12_SAMPLER_FLAGS flags = D3D12_SAMPLER_FLAGS : : D3D12_SAMPLER_FLAG_NONE ) noexcept
{
samplerDesc . ShaderRegister = shaderRegister ;
samplerDesc . Filter = filter ;
samplerDesc . AddressU = addressU ;
samplerDesc . AddressV = addressV ;
samplerDesc . AddressW = addressW ;
samplerDesc . MipLODBias = mipLODBias ;
samplerDesc . MaxAnisotropy = maxAnisotropy ;
samplerDesc . ComparisonFunc = comparisonFunc ;
samplerDesc . BorderColor = borderColor ;
samplerDesc . MinLOD = minLOD ;
samplerDesc . MaxLOD = maxLOD ;
samplerDesc . ShaderVisibility = shaderVisibility ;
samplerDesc . RegisterSpace = registerSpace ;
samplerDesc . Flags = flags ;
}
inline void Init (
UINT shaderRegister ,
D3D12_FILTER filter = D3D12_FILTER_ANISOTROPIC ,
D3D12_TEXTURE_ADDRESS_MODE addressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP ,
D3D12_TEXTURE_ADDRESS_MODE addressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP ,
D3D12_TEXTURE_ADDRESS_MODE addressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP ,
FLOAT mipLODBias = 0 ,
UINT maxAnisotropy = 16 ,
D3D12_COMPARISON_FUNC comparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL ,
D3D12_STATIC_BORDER_COLOR borderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE ,
FLOAT minLOD = 0.f ,
FLOAT maxLOD = D3D12_FLOAT32_MAX ,
D3D12_SHADER_VISIBILITY shaderVisibility = D3D12_SHADER_VISIBILITY_ALL ,
UINT registerSpace = 0 ,
D3D12_SAMPLER_FLAGS flags = D3D12_SAMPLER_FLAGS : : D3D12_SAMPLER_FLAG_NONE ) noexcept
{
Init (
* this ,
shaderRegister ,
filter ,
addressU ,
addressV ,
addressW ,
mipLODBias ,
maxAnisotropy ,
comparisonFunc ,
borderColor ,
minLOD ,
maxLOD ,
shaderVisibility ,
registerSpace ,
flags ) ;
}
} ;
# endif // D3D12_SDK_VERSION >= 609
2017-01-26 18:23:36 +00:00
//------------------------------------------------------------------------------------------------
struct CD3DX12_ROOT_SIGNATURE_DESC : public D3D12_ROOT_SIGNATURE_DESC
{
2018-04-12 01:06:24 +00:00
CD3DX12_ROOT_SIGNATURE_DESC ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_ROOT_SIGNATURE_DESC ( const D3D12_ROOT_SIGNATURE_DESC & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_ROOT_SIGNATURE_DESC ( o )
{ }
CD3DX12_ROOT_SIGNATURE_DESC (
UINT numParameters ,
_In_reads_opt_ ( numParameters ) const D3D12_ROOT_PARAMETER * _pParameters ,
UINT numStaticSamplers = 0 ,
2018-06-22 23:55:00 +00:00
_In_reads_opt_ ( numStaticSamplers ) const D3D12_STATIC_SAMPLER_DESC * _pStaticSamplers = nullptr ,
2020-03-16 09:16:44 +00:00
D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE ) noexcept
2017-01-26 18:23:36 +00:00
{
Init ( numParameters , _pParameters , numStaticSamplers , _pStaticSamplers , flags ) ;
}
2020-03-16 09:16:44 +00:00
CD3DX12_ROOT_SIGNATURE_DESC ( CD3DX12_DEFAULT ) noexcept
2017-01-26 18:23:36 +00:00
{
2018-06-22 23:55:00 +00:00
Init ( 0 , nullptr , 0 , nullptr , D3D12_ROOT_SIGNATURE_FLAG_NONE ) ;
2017-01-26 18:23:36 +00:00
}
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
inline void Init (
UINT numParameters ,
_In_reads_opt_ ( numParameters ) const D3D12_ROOT_PARAMETER * _pParameters ,
UINT numStaticSamplers = 0 ,
2018-06-22 23:55:00 +00:00
_In_reads_opt_ ( numStaticSamplers ) const D3D12_STATIC_SAMPLER_DESC * _pStaticSamplers = nullptr ,
2020-03-16 09:16:44 +00:00
D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE ) noexcept
2017-01-26 18:23:36 +00:00
{
Init ( * this , numParameters , _pParameters , numStaticSamplers , _pStaticSamplers , flags ) ;
}
static inline void Init (
_Out_ D3D12_ROOT_SIGNATURE_DESC & desc ,
UINT numParameters ,
_In_reads_opt_ ( numParameters ) const D3D12_ROOT_PARAMETER * _pParameters ,
UINT numStaticSamplers = 0 ,
2018-06-22 23:55:00 +00:00
_In_reads_opt_ ( numStaticSamplers ) const D3D12_STATIC_SAMPLER_DESC * _pStaticSamplers = nullptr ,
2020-03-16 09:16:44 +00:00
D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE ) noexcept
2017-01-26 18:23:36 +00:00
{
desc . NumParameters = numParameters ;
desc . pParameters = _pParameters ;
desc . NumStaticSamplers = numStaticSamplers ;
desc . pStaticSamplers = _pStaticSamplers ;
desc . Flags = flags ;
}
} ;
//------------------------------------------------------------------------------------------------
struct CD3DX12_DESCRIPTOR_RANGE1 : public D3D12_DESCRIPTOR_RANGE1
{
2018-04-12 01:06:24 +00:00
CD3DX12_DESCRIPTOR_RANGE1 ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_DESCRIPTOR_RANGE1 ( const D3D12_DESCRIPTOR_RANGE1 & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_DESCRIPTOR_RANGE1 ( o )
{ }
CD3DX12_DESCRIPTOR_RANGE1 (
D3D12_DESCRIPTOR_RANGE_TYPE rangeType ,
UINT numDescriptors ,
UINT baseShaderRegister ,
UINT registerSpace = 0 ,
D3D12_DESCRIPTOR_RANGE_FLAGS flags = D3D12_DESCRIPTOR_RANGE_FLAG_NONE ,
UINT offsetInDescriptorsFromTableStart =
2020-03-16 09:16:44 +00:00
D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND ) noexcept
2017-01-26 18:23:36 +00:00
{
Init ( rangeType , numDescriptors , baseShaderRegister , registerSpace , flags , offsetInDescriptorsFromTableStart ) ;
}
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
inline void Init (
D3D12_DESCRIPTOR_RANGE_TYPE rangeType ,
UINT numDescriptors ,
UINT baseShaderRegister ,
UINT registerSpace = 0 ,
D3D12_DESCRIPTOR_RANGE_FLAGS flags = D3D12_DESCRIPTOR_RANGE_FLAG_NONE ,
UINT offsetInDescriptorsFromTableStart =
2020-03-16 09:16:44 +00:00
D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND ) noexcept
2017-01-26 18:23:36 +00:00
{
Init ( * this , rangeType , numDescriptors , baseShaderRegister , registerSpace , flags , offsetInDescriptorsFromTableStart ) ;
}
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
static inline void Init (
_Out_ D3D12_DESCRIPTOR_RANGE1 & range ,
D3D12_DESCRIPTOR_RANGE_TYPE rangeType ,
UINT numDescriptors ,
UINT baseShaderRegister ,
UINT registerSpace = 0 ,
D3D12_DESCRIPTOR_RANGE_FLAGS flags = D3D12_DESCRIPTOR_RANGE_FLAG_NONE ,
UINT offsetInDescriptorsFromTableStart =
2020-03-16 09:16:44 +00:00
D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND ) noexcept
2017-01-26 18:23:36 +00:00
{
range . RangeType = rangeType ;
range . NumDescriptors = numDescriptors ;
range . BaseShaderRegister = baseShaderRegister ;
range . RegisterSpace = registerSpace ;
range . Flags = flags ;
range . OffsetInDescriptorsFromTableStart = offsetInDescriptorsFromTableStart ;
}
} ;
//------------------------------------------------------------------------------------------------
struct CD3DX12_ROOT_DESCRIPTOR_TABLE1 : public D3D12_ROOT_DESCRIPTOR_TABLE1
{
2018-04-12 01:06:24 +00:00
CD3DX12_ROOT_DESCRIPTOR_TABLE1 ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_ROOT_DESCRIPTOR_TABLE1 ( const D3D12_ROOT_DESCRIPTOR_TABLE1 & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_ROOT_DESCRIPTOR_TABLE1 ( o )
{ }
CD3DX12_ROOT_DESCRIPTOR_TABLE1 (
UINT numDescriptorRanges ,
2020-03-16 09:16:44 +00:00
_In_reads_opt_ ( numDescriptorRanges ) const D3D12_DESCRIPTOR_RANGE1 * _pDescriptorRanges ) noexcept
2017-01-26 18:23:36 +00:00
{
Init ( numDescriptorRanges , _pDescriptorRanges ) ;
}
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
inline void Init (
UINT numDescriptorRanges ,
2020-03-16 09:16:44 +00:00
_In_reads_opt_ ( numDescriptorRanges ) const D3D12_DESCRIPTOR_RANGE1 * _pDescriptorRanges ) noexcept
2017-01-26 18:23:36 +00:00
{
Init ( * this , numDescriptorRanges , _pDescriptorRanges ) ;
}
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
static inline void Init (
_Out_ D3D12_ROOT_DESCRIPTOR_TABLE1 & rootDescriptorTable ,
UINT numDescriptorRanges ,
2020-03-16 09:16:44 +00:00
_In_reads_opt_ ( numDescriptorRanges ) const D3D12_DESCRIPTOR_RANGE1 * _pDescriptorRanges ) noexcept
2017-01-26 18:23:36 +00:00
{
rootDescriptorTable . NumDescriptorRanges = numDescriptorRanges ;
rootDescriptorTable . pDescriptorRanges = _pDescriptorRanges ;
}
} ;
//------------------------------------------------------------------------------------------------
struct CD3DX12_ROOT_DESCRIPTOR1 : public D3D12_ROOT_DESCRIPTOR1
{
2018-04-12 01:06:24 +00:00
CD3DX12_ROOT_DESCRIPTOR1 ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_ROOT_DESCRIPTOR1 ( const D3D12_ROOT_DESCRIPTOR1 & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_ROOT_DESCRIPTOR1 ( o )
{ }
CD3DX12_ROOT_DESCRIPTOR1 (
UINT shaderRegister ,
UINT registerSpace = 0 ,
2020-03-16 09:16:44 +00:00
D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE ) noexcept
2017-01-26 18:23:36 +00:00
{
Init ( shaderRegister , registerSpace , flags ) ;
}
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
inline void Init (
UINT shaderRegister ,
UINT registerSpace = 0 ,
2020-03-16 09:16:44 +00:00
D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE ) noexcept
2017-01-26 18:23:36 +00:00
{
Init ( * this , shaderRegister , registerSpace , flags ) ;
}
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
static inline void Init (
2020-03-18 04:45:33 +00:00
_Out_ D3D12_ROOT_DESCRIPTOR1 & table ,
UINT shaderRegister ,
UINT registerSpace = 0 ,
2020-03-16 09:16:44 +00:00
D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE ) noexcept
2017-01-26 18:23:36 +00:00
{
table . ShaderRegister = shaderRegister ;
table . RegisterSpace = registerSpace ;
table . Flags = flags ;
}
} ;
//------------------------------------------------------------------------------------------------
struct CD3DX12_ROOT_PARAMETER1 : public D3D12_ROOT_PARAMETER1
{
2018-04-12 01:06:24 +00:00
CD3DX12_ROOT_PARAMETER1 ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_ROOT_PARAMETER1 ( const D3D12_ROOT_PARAMETER1 & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_ROOT_PARAMETER1 ( o )
{ }
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
static inline void InitAsDescriptorTable (
_Out_ D3D12_ROOT_PARAMETER1 & rootParam ,
UINT numDescriptorRanges ,
_In_reads_ ( numDescriptorRanges ) const D3D12_DESCRIPTOR_RANGE1 * pDescriptorRanges ,
2020-03-16 09:16:44 +00:00
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL ) noexcept
2017-01-26 18:23:36 +00:00
{
rootParam . ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE ;
rootParam . ShaderVisibility = visibility ;
CD3DX12_ROOT_DESCRIPTOR_TABLE1 : : Init ( rootParam . DescriptorTable , numDescriptorRanges , pDescriptorRanges ) ;
}
static inline void InitAsConstants (
_Out_ D3D12_ROOT_PARAMETER1 & rootParam ,
UINT num32BitValues ,
UINT shaderRegister ,
UINT registerSpace = 0 ,
2020-03-16 09:16:44 +00:00
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL ) noexcept
2017-01-26 18:23:36 +00:00
{
rootParam . ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS ;
rootParam . ShaderVisibility = visibility ;
CD3DX12_ROOT_CONSTANTS : : Init ( rootParam . Constants , num32BitValues , shaderRegister , registerSpace ) ;
}
static inline void InitAsConstantBufferView (
_Out_ D3D12_ROOT_PARAMETER1 & rootParam ,
UINT shaderRegister ,
UINT registerSpace = 0 ,
D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE ,
2020-03-16 09:16:44 +00:00
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL ) noexcept
2017-01-26 18:23:36 +00:00
{
rootParam . ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV ;
rootParam . ShaderVisibility = visibility ;
CD3DX12_ROOT_DESCRIPTOR1 : : Init ( rootParam . Descriptor , shaderRegister , registerSpace , flags ) ;
}
static inline void InitAsShaderResourceView (
_Out_ D3D12_ROOT_PARAMETER1 & rootParam ,
UINT shaderRegister ,
UINT registerSpace = 0 ,
D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE ,
2020-03-16 09:16:44 +00:00
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL ) noexcept
2017-01-26 18:23:36 +00:00
{
rootParam . ParameterType = D3D12_ROOT_PARAMETER_TYPE_SRV ;
rootParam . ShaderVisibility = visibility ;
CD3DX12_ROOT_DESCRIPTOR1 : : Init ( rootParam . Descriptor , shaderRegister , registerSpace , flags ) ;
}
static inline void InitAsUnorderedAccessView (
_Out_ D3D12_ROOT_PARAMETER1 & rootParam ,
UINT shaderRegister ,
UINT registerSpace = 0 ,
D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE ,
2020-03-16 09:16:44 +00:00
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL ) noexcept
2017-01-26 18:23:36 +00:00
{
rootParam . ParameterType = D3D12_ROOT_PARAMETER_TYPE_UAV ;
rootParam . ShaderVisibility = visibility ;
CD3DX12_ROOT_DESCRIPTOR1 : : Init ( rootParam . Descriptor , shaderRegister , registerSpace , flags ) ;
}
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
inline void InitAsDescriptorTable (
UINT numDescriptorRanges ,
_In_reads_ ( numDescriptorRanges ) const D3D12_DESCRIPTOR_RANGE1 * pDescriptorRanges ,
2020-03-16 09:16:44 +00:00
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL ) noexcept
2017-01-26 18:23:36 +00:00
{
InitAsDescriptorTable ( * this , numDescriptorRanges , pDescriptorRanges , visibility ) ;
}
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
inline void InitAsConstants (
UINT num32BitValues ,
UINT shaderRegister ,
UINT registerSpace = 0 ,
2020-03-16 09:16:44 +00:00
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL ) noexcept
2017-01-26 18:23:36 +00:00
{
InitAsConstants ( * this , num32BitValues , shaderRegister , registerSpace , visibility ) ;
}
inline void InitAsConstantBufferView (
UINT shaderRegister ,
UINT registerSpace = 0 ,
D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE ,
2020-03-16 09:16:44 +00:00
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL ) noexcept
2017-01-26 18:23:36 +00:00
{
InitAsConstantBufferView ( * this , shaderRegister , registerSpace , flags , visibility ) ;
}
inline void InitAsShaderResourceView (
UINT shaderRegister ,
UINT registerSpace = 0 ,
D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE ,
2020-03-16 09:16:44 +00:00
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL ) noexcept
2017-01-26 18:23:36 +00:00
{
InitAsShaderResourceView ( * this , shaderRegister , registerSpace , flags , visibility ) ;
}
inline void InitAsUnorderedAccessView (
UINT shaderRegister ,
UINT registerSpace = 0 ,
D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE ,
2020-03-16 09:16:44 +00:00
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL ) noexcept
2017-01-26 18:23:36 +00:00
{
InitAsUnorderedAccessView ( * this , shaderRegister , registerSpace , flags , visibility ) ;
}
} ;
//------------------------------------------------------------------------------------------------
struct CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC : public D3D12_VERSIONED_ROOT_SIGNATURE_DESC
{
2018-04-12 01:06:24 +00:00
CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC ( const D3D12_VERSIONED_ROOT_SIGNATURE_DESC & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_VERSIONED_ROOT_SIGNATURE_DESC ( o )
{ }
2020-03-16 09:16:44 +00:00
explicit CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC ( const D3D12_ROOT_SIGNATURE_DESC & o ) noexcept
2017-01-26 18:23:36 +00:00
{
Version = D3D_ROOT_SIGNATURE_VERSION_1_0 ;
Desc_1_0 = o ;
}
2020-03-16 09:16:44 +00:00
explicit CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC ( const D3D12_ROOT_SIGNATURE_DESC1 & o ) noexcept
2017-01-26 18:23:36 +00:00
{
Version = D3D_ROOT_SIGNATURE_VERSION_1_1 ;
Desc_1_1 = o ;
}
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
explicit CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC ( const D3D12_ROOT_SIGNATURE_DESC2 & o ) noexcept
{
Version = D3D_ROOT_SIGNATURE_VERSION_1_2 ;
Desc_1_2 = o ;
}
# endif
2017-01-26 18:23:36 +00:00
CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC (
UINT numParameters ,
_In_reads_opt_ ( numParameters ) const D3D12_ROOT_PARAMETER * _pParameters ,
UINT numStaticSamplers = 0 ,
2018-06-22 23:55:00 +00:00
_In_reads_opt_ ( numStaticSamplers ) const D3D12_STATIC_SAMPLER_DESC * _pStaticSamplers = nullptr ,
2020-03-16 09:16:44 +00:00
D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE ) noexcept
2017-01-26 18:23:36 +00:00
{
Init_1_0 ( numParameters , _pParameters , numStaticSamplers , _pStaticSamplers , flags ) ;
}
CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC (
UINT numParameters ,
_In_reads_opt_ ( numParameters ) const D3D12_ROOT_PARAMETER1 * _pParameters ,
UINT numStaticSamplers = 0 ,
2018-06-22 23:55:00 +00:00
_In_reads_opt_ ( numStaticSamplers ) const D3D12_STATIC_SAMPLER_DESC * _pStaticSamplers = nullptr ,
2020-03-16 09:16:44 +00:00
D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE ) noexcept
2017-01-26 18:23:36 +00:00
{
Init_1_1 ( numParameters , _pParameters , numStaticSamplers , _pStaticSamplers , flags ) ;
}
2020-03-16 09:16:44 +00:00
CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC ( CD3DX12_DEFAULT ) noexcept
2017-01-26 18:23:36 +00:00
{
2018-06-22 23:55:00 +00:00
Init_1_1 ( 0 , nullptr , 0 , nullptr , D3D12_ROOT_SIGNATURE_FLAG_NONE ) ;
2017-01-26 18:23:36 +00:00
}
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
inline void Init_1_0 (
UINT numParameters ,
_In_reads_opt_ ( numParameters ) const D3D12_ROOT_PARAMETER * _pParameters ,
UINT numStaticSamplers = 0 ,
2018-06-22 23:55:00 +00:00
_In_reads_opt_ ( numStaticSamplers ) const D3D12_STATIC_SAMPLER_DESC * _pStaticSamplers = nullptr ,
2020-03-16 09:16:44 +00:00
D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE ) noexcept
2017-01-26 18:23:36 +00:00
{
Init_1_0 ( * this , numParameters , _pParameters , numStaticSamplers , _pStaticSamplers , flags ) ;
}
static inline void Init_1_0 (
_Out_ D3D12_VERSIONED_ROOT_SIGNATURE_DESC & desc ,
UINT numParameters ,
_In_reads_opt_ ( numParameters ) const D3D12_ROOT_PARAMETER * _pParameters ,
UINT numStaticSamplers = 0 ,
2018-06-22 23:55:00 +00:00
_In_reads_opt_ ( numStaticSamplers ) const D3D12_STATIC_SAMPLER_DESC * _pStaticSamplers = nullptr ,
2020-03-16 09:16:44 +00:00
D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE ) noexcept
2017-01-26 18:23:36 +00:00
{
desc . Version = D3D_ROOT_SIGNATURE_VERSION_1_0 ;
desc . Desc_1_0 . NumParameters = numParameters ;
desc . Desc_1_0 . pParameters = _pParameters ;
desc . Desc_1_0 . NumStaticSamplers = numStaticSamplers ;
desc . Desc_1_0 . pStaticSamplers = _pStaticSamplers ;
desc . Desc_1_0 . Flags = flags ;
}
inline void Init_1_1 (
UINT numParameters ,
_In_reads_opt_ ( numParameters ) const D3D12_ROOT_PARAMETER1 * _pParameters ,
UINT numStaticSamplers = 0 ,
2018-06-22 23:55:00 +00:00
_In_reads_opt_ ( numStaticSamplers ) const D3D12_STATIC_SAMPLER_DESC * _pStaticSamplers = nullptr ,
2020-03-16 09:16:44 +00:00
D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE ) noexcept
2017-01-26 18:23:36 +00:00
{
Init_1_1 ( * this , numParameters , _pParameters , numStaticSamplers , _pStaticSamplers , flags ) ;
}
static inline void Init_1_1 (
_Out_ D3D12_VERSIONED_ROOT_SIGNATURE_DESC & desc ,
UINT numParameters ,
_In_reads_opt_ ( numParameters ) const D3D12_ROOT_PARAMETER1 * _pParameters ,
UINT numStaticSamplers = 0 ,
2018-06-22 23:55:00 +00:00
_In_reads_opt_ ( numStaticSamplers ) const D3D12_STATIC_SAMPLER_DESC * _pStaticSamplers = nullptr ,
2020-03-16 09:16:44 +00:00
D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE ) noexcept
2017-01-26 18:23:36 +00:00
{
desc . Version = D3D_ROOT_SIGNATURE_VERSION_1_1 ;
desc . Desc_1_1 . NumParameters = numParameters ;
desc . Desc_1_1 . pParameters = _pParameters ;
desc . Desc_1_1 . NumStaticSamplers = numStaticSamplers ;
desc . Desc_1_1 . pStaticSamplers = _pStaticSamplers ;
desc . Desc_1_1 . Flags = flags ;
}
2024-02-05 18:08:59 +00:00
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
static inline void Init_1_2 (
_Out_ D3D12_VERSIONED_ROOT_SIGNATURE_DESC & desc ,
UINT numParameters ,
_In_reads_opt_ ( numParameters ) const D3D12_ROOT_PARAMETER1 * _pParameters ,
UINT numStaticSamplers = 0 ,
_In_reads_opt_ ( numStaticSamplers ) const D3D12_STATIC_SAMPLER_DESC1 * _pStaticSamplers = nullptr ,
D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE ) noexcept
{
desc . Version = D3D_ROOT_SIGNATURE_VERSION_1_2 ;
desc . Desc_1_2 . NumParameters = numParameters ;
desc . Desc_1_2 . pParameters = _pParameters ;
desc . Desc_1_2 . NumStaticSamplers = numStaticSamplers ;
desc . Desc_1_2 . pStaticSamplers = _pStaticSamplers ;
desc . Desc_1_2 . Flags = flags ;
}
# endif
2017-01-26 18:23:36 +00:00
} ;
//------------------------------------------------------------------------------------------------
struct CD3DX12_CPU_DESCRIPTOR_HANDLE : public D3D12_CPU_DESCRIPTOR_HANDLE
{
2018-04-12 01:06:24 +00:00
CD3DX12_CPU_DESCRIPTOR_HANDLE ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_CPU_DESCRIPTOR_HANDLE ( const D3D12_CPU_DESCRIPTOR_HANDLE & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_CPU_DESCRIPTOR_HANDLE ( o )
{ }
2020-03-16 09:16:44 +00:00
CD3DX12_CPU_DESCRIPTOR_HANDLE ( CD3DX12_DEFAULT ) noexcept { ptr = 0 ; }
CD3DX12_CPU_DESCRIPTOR_HANDLE ( _In_ const D3D12_CPU_DESCRIPTOR_HANDLE & other , INT offsetScaledByIncrementSize ) noexcept
2017-01-26 18:23:36 +00:00
{
InitOffsetted ( other , offsetScaledByIncrementSize ) ;
}
2020-03-16 09:16:44 +00:00
CD3DX12_CPU_DESCRIPTOR_HANDLE ( _In_ const D3D12_CPU_DESCRIPTOR_HANDLE & other , INT offsetInDescriptors , UINT descriptorIncrementSize ) noexcept
2017-01-26 18:23:36 +00:00
{
InitOffsetted ( other , offsetInDescriptors , descriptorIncrementSize ) ;
}
2020-03-16 09:16:44 +00:00
CD3DX12_CPU_DESCRIPTOR_HANDLE & Offset ( INT offsetInDescriptors , UINT descriptorIncrementSize ) noexcept
2020-03-18 04:45:33 +00:00
{
2019-07-08 18:57:07 +00:00
ptr = SIZE_T ( INT64 ( ptr ) + INT64 ( offsetInDescriptors ) * INT64 ( descriptorIncrementSize ) ) ;
2017-01-26 18:23:36 +00:00
return * this ;
}
2020-03-16 09:16:44 +00:00
CD3DX12_CPU_DESCRIPTOR_HANDLE & Offset ( INT offsetScaledByIncrementSize ) noexcept
2020-03-18 04:45:33 +00:00
{
2019-07-08 18:57:07 +00:00
ptr = SIZE_T ( INT64 ( ptr ) + INT64 ( offsetScaledByIncrementSize ) ) ;
2017-01-26 18:23:36 +00:00
return * this ;
}
2020-03-16 09:16:44 +00:00
bool operator = = ( _In_ const D3D12_CPU_DESCRIPTOR_HANDLE & other ) const noexcept
2017-01-26 18:23:36 +00:00
{
return ( ptr = = other . ptr ) ;
}
2020-03-16 09:16:44 +00:00
bool operator ! = ( _In_ const D3D12_CPU_DESCRIPTOR_HANDLE & other ) const noexcept
2017-01-26 18:23:36 +00:00
{
return ( ptr ! = other . ptr ) ;
}
2020-03-16 09:16:44 +00:00
CD3DX12_CPU_DESCRIPTOR_HANDLE & operator = ( const D3D12_CPU_DESCRIPTOR_HANDLE & other ) noexcept
2017-01-26 18:23:36 +00:00
{
ptr = other . ptr ;
return * this ;
}
2018-04-12 01:06:24 +00:00
2020-03-16 09:16:44 +00:00
inline void InitOffsetted ( _In_ const D3D12_CPU_DESCRIPTOR_HANDLE & base , INT offsetScaledByIncrementSize ) noexcept
2017-01-26 18:23:36 +00:00
{
InitOffsetted ( * this , base , offsetScaledByIncrementSize ) ;
}
2020-03-18 04:45:33 +00:00
2020-03-16 09:16:44 +00:00
inline void InitOffsetted ( _In_ const D3D12_CPU_DESCRIPTOR_HANDLE & base , INT offsetInDescriptors , UINT descriptorIncrementSize ) noexcept
2017-01-26 18:23:36 +00:00
{
InitOffsetted ( * this , base , offsetInDescriptors , descriptorIncrementSize ) ;
}
2020-03-18 04:45:33 +00:00
2020-03-16 09:16:44 +00:00
static inline void InitOffsetted ( _Out_ D3D12_CPU_DESCRIPTOR_HANDLE & handle , _In_ const D3D12_CPU_DESCRIPTOR_HANDLE & base , INT offsetScaledByIncrementSize ) noexcept
2017-01-26 18:23:36 +00:00
{
2019-07-08 18:57:07 +00:00
handle . ptr = SIZE_T ( INT64 ( base . ptr ) + INT64 ( offsetScaledByIncrementSize ) ) ;
2017-01-26 18:23:36 +00:00
}
2020-03-18 04:45:33 +00:00
2020-03-16 09:16:44 +00:00
static inline void InitOffsetted ( _Out_ D3D12_CPU_DESCRIPTOR_HANDLE & handle , _In_ const D3D12_CPU_DESCRIPTOR_HANDLE & base , INT offsetInDescriptors , UINT descriptorIncrementSize ) noexcept
2017-01-26 18:23:36 +00:00
{
2019-07-08 18:57:07 +00:00
handle . ptr = SIZE_T ( INT64 ( base . ptr ) + INT64 ( offsetInDescriptors ) * INT64 ( descriptorIncrementSize ) ) ;
2017-01-26 18:23:36 +00:00
}
} ;
//------------------------------------------------------------------------------------------------
struct CD3DX12_GPU_DESCRIPTOR_HANDLE : public D3D12_GPU_DESCRIPTOR_HANDLE
{
2018-04-12 01:06:24 +00:00
CD3DX12_GPU_DESCRIPTOR_HANDLE ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_GPU_DESCRIPTOR_HANDLE ( const D3D12_GPU_DESCRIPTOR_HANDLE & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_GPU_DESCRIPTOR_HANDLE ( o )
{ }
2020-03-16 09:16:44 +00:00
CD3DX12_GPU_DESCRIPTOR_HANDLE ( CD3DX12_DEFAULT ) noexcept { ptr = 0 ; }
CD3DX12_GPU_DESCRIPTOR_HANDLE ( _In_ const D3D12_GPU_DESCRIPTOR_HANDLE & other , INT offsetScaledByIncrementSize ) noexcept
2017-01-26 18:23:36 +00:00
{
InitOffsetted ( other , offsetScaledByIncrementSize ) ;
}
2020-03-16 09:16:44 +00:00
CD3DX12_GPU_DESCRIPTOR_HANDLE ( _In_ const D3D12_GPU_DESCRIPTOR_HANDLE & other , INT offsetInDescriptors , UINT descriptorIncrementSize ) noexcept
2017-01-26 18:23:36 +00:00
{
InitOffsetted ( other , offsetInDescriptors , descriptorIncrementSize ) ;
}
2020-03-16 09:16:44 +00:00
CD3DX12_GPU_DESCRIPTOR_HANDLE & Offset ( INT offsetInDescriptors , UINT descriptorIncrementSize ) noexcept
{
2019-07-08 18:57:07 +00:00
ptr = UINT64 ( INT64 ( ptr ) + INT64 ( offsetInDescriptors ) * INT64 ( descriptorIncrementSize ) ) ;
2017-01-26 18:23:36 +00:00
return * this ;
}
2020-03-16 09:16:44 +00:00
CD3DX12_GPU_DESCRIPTOR_HANDLE & Offset ( INT offsetScaledByIncrementSize ) noexcept
{
2019-07-08 18:57:07 +00:00
ptr = UINT64 ( INT64 ( ptr ) + INT64 ( offsetScaledByIncrementSize ) ) ;
2017-01-26 18:23:36 +00:00
return * this ;
}
2020-03-16 09:16:44 +00:00
inline bool operator = = ( _In_ const D3D12_GPU_DESCRIPTOR_HANDLE & other ) const noexcept
2017-01-26 18:23:36 +00:00
{
return ( ptr = = other . ptr ) ;
}
2020-03-16 09:16:44 +00:00
inline bool operator ! = ( _In_ const D3D12_GPU_DESCRIPTOR_HANDLE & other ) const noexcept
2017-01-26 18:23:36 +00:00
{
return ( ptr ! = other . ptr ) ;
}
2020-03-16 09:16:44 +00:00
CD3DX12_GPU_DESCRIPTOR_HANDLE & operator = ( const D3D12_GPU_DESCRIPTOR_HANDLE & other ) noexcept
2017-01-26 18:23:36 +00:00
{
ptr = other . ptr ;
return * this ;
}
2018-04-12 01:06:24 +00:00
2020-03-16 09:16:44 +00:00
inline void InitOffsetted ( _In_ const D3D12_GPU_DESCRIPTOR_HANDLE & base , INT offsetScaledByIncrementSize ) noexcept
2017-01-26 18:23:36 +00:00
{
InitOffsetted ( * this , base , offsetScaledByIncrementSize ) ;
}
2020-03-18 04:45:33 +00:00
2020-03-16 09:16:44 +00:00
inline void InitOffsetted ( _In_ const D3D12_GPU_DESCRIPTOR_HANDLE & base , INT offsetInDescriptors , UINT descriptorIncrementSize ) noexcept
2017-01-26 18:23:36 +00:00
{
InitOffsetted ( * this , base , offsetInDescriptors , descriptorIncrementSize ) ;
}
2020-03-18 04:45:33 +00:00
2020-03-16 09:16:44 +00:00
static inline void InitOffsetted ( _Out_ D3D12_GPU_DESCRIPTOR_HANDLE & handle , _In_ const D3D12_GPU_DESCRIPTOR_HANDLE & base , INT offsetScaledByIncrementSize ) noexcept
2017-01-26 18:23:36 +00:00
{
2019-07-08 18:57:07 +00:00
handle . ptr = UINT64 ( INT64 ( base . ptr ) + INT64 ( offsetScaledByIncrementSize ) ) ;
2017-01-26 18:23:36 +00:00
}
2020-03-18 04:45:33 +00:00
2020-03-16 09:16:44 +00:00
static inline void InitOffsetted ( _Out_ D3D12_GPU_DESCRIPTOR_HANDLE & handle , _In_ const D3D12_GPU_DESCRIPTOR_HANDLE & base , INT offsetInDescriptors , UINT descriptorIncrementSize ) noexcept
2017-01-26 18:23:36 +00:00
{
2019-07-08 18:57:07 +00:00
handle . ptr = UINT64 ( INT64 ( base . ptr ) + INT64 ( offsetInDescriptors ) * INT64 ( descriptorIncrementSize ) ) ;
2017-01-26 18:23:36 +00:00
}
} ;
//------------------------------------------------------------------------------------------------
2021-10-22 23:43:43 +00:00
constexpr UINT D3D12CalcSubresource ( UINT MipSlice , UINT ArraySlice , UINT PlaneSlice , UINT MipLevels , UINT ArraySize ) noexcept
2020-03-18 04:45:33 +00:00
{
return MipSlice + ArraySlice * MipLevels + PlaneSlice * MipLevels * ArraySize ;
2017-01-26 18:23:36 +00:00
}
//------------------------------------------------------------------------------------------------
inline UINT8 D3D12GetFormatPlaneCount (
_In_ ID3D12Device * pDevice ,
DXGI_FORMAT Format
2020-03-16 09:16:44 +00:00
) noexcept
2017-01-26 18:23:36 +00:00
{
2018-06-22 23:55:00 +00:00
D3D12_FEATURE_DATA_FORMAT_INFO formatInfo = { Format , 0 } ;
2017-01-26 18:23:36 +00:00
if ( FAILED ( pDevice - > CheckFeatureSupport ( D3D12_FEATURE_FORMAT_INFO , & formatInfo , sizeof ( formatInfo ) ) ) )
{
return 0 ;
}
return formatInfo . PlaneCount ;
}
//------------------------------------------------------------------------------------------------
struct CD3DX12_RESOURCE_DESC : public D3D12_RESOURCE_DESC
{
2018-04-12 01:06:24 +00:00
CD3DX12_RESOURCE_DESC ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_RESOURCE_DESC ( const D3D12_RESOURCE_DESC & o ) noexcept :
2017-01-26 18:23:36 +00:00
D3D12_RESOURCE_DESC ( o )
{ }
2020-03-18 04:45:33 +00:00
CD3DX12_RESOURCE_DESC (
2017-01-26 18:23:36 +00:00
D3D12_RESOURCE_DIMENSION dimension ,
UINT64 alignment ,
UINT64 width ,
UINT height ,
UINT16 depthOrArraySize ,
UINT16 mipLevels ,
DXGI_FORMAT format ,
UINT sampleCount ,
UINT sampleQuality ,
D3D12_TEXTURE_LAYOUT layout ,
2020-03-16 09:16:44 +00:00
D3D12_RESOURCE_FLAGS flags ) noexcept
2017-01-26 18:23:36 +00:00
{
Dimension = dimension ;
Alignment = alignment ;
Width = width ;
Height = height ;
DepthOrArraySize = depthOrArraySize ;
MipLevels = mipLevels ;
Format = format ;
SampleDesc . Count = sampleCount ;
SampleDesc . Quality = sampleQuality ;
Layout = layout ;
Flags = flags ;
}
2020-03-18 04:45:33 +00:00
static inline CD3DX12_RESOURCE_DESC Buffer (
2017-01-26 18:23:36 +00:00
const D3D12_RESOURCE_ALLOCATION_INFO & resAllocInfo ,
2020-03-16 09:16:44 +00:00
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE ) noexcept
2017-01-26 18:23:36 +00:00
{
2020-03-18 04:45:33 +00:00
return CD3DX12_RESOURCE_DESC ( D3D12_RESOURCE_DIMENSION_BUFFER , resAllocInfo . Alignment , resAllocInfo . SizeInBytes ,
2017-01-26 18:23:36 +00:00
1 , 1 , 1 , DXGI_FORMAT_UNKNOWN , 1 , 0 , D3D12_TEXTURE_LAYOUT_ROW_MAJOR , flags ) ;
}
2020-03-18 04:45:33 +00:00
static inline CD3DX12_RESOURCE_DESC Buffer (
2017-01-26 18:23:36 +00:00
UINT64 width ,
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE ,
2020-03-16 09:16:44 +00:00
UINT64 alignment = 0 ) noexcept
2017-01-26 18:23:36 +00:00
{
2020-03-18 04:45:33 +00:00
return CD3DX12_RESOURCE_DESC ( D3D12_RESOURCE_DIMENSION_BUFFER , alignment , width , 1 , 1 , 1 ,
2017-01-26 18:23:36 +00:00
DXGI_FORMAT_UNKNOWN , 1 , 0 , D3D12_TEXTURE_LAYOUT_ROW_MAJOR , flags ) ;
}
2020-03-18 04:45:33 +00:00
static inline CD3DX12_RESOURCE_DESC Tex1D (
2017-01-26 18:23:36 +00:00
DXGI_FORMAT format ,
UINT64 width ,
UINT16 arraySize = 1 ,
UINT16 mipLevels = 0 ,
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE ,
D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN ,
2020-03-16 09:16:44 +00:00
UINT64 alignment = 0 ) noexcept
2017-01-26 18:23:36 +00:00
{
2020-03-18 04:45:33 +00:00
return CD3DX12_RESOURCE_DESC ( D3D12_RESOURCE_DIMENSION_TEXTURE1D , alignment , width , 1 , arraySize ,
2017-01-26 18:23:36 +00:00
mipLevels , format , 1 , 0 , layout , flags ) ;
}
2020-03-18 04:45:33 +00:00
static inline CD3DX12_RESOURCE_DESC Tex2D (
2017-01-26 18:23:36 +00:00
DXGI_FORMAT format ,
UINT64 width ,
UINT height ,
UINT16 arraySize = 1 ,
UINT16 mipLevels = 0 ,
UINT sampleCount = 1 ,
UINT sampleQuality = 0 ,
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE ,
D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN ,
2020-03-16 09:16:44 +00:00
UINT64 alignment = 0 ) noexcept
2017-01-26 18:23:36 +00:00
{
2020-03-18 04:45:33 +00:00
return CD3DX12_RESOURCE_DESC ( D3D12_RESOURCE_DIMENSION_TEXTURE2D , alignment , width , height , arraySize ,
2017-01-26 18:23:36 +00:00
mipLevels , format , sampleCount , sampleQuality , layout , flags ) ;
}
2020-03-18 04:45:33 +00:00
static inline CD3DX12_RESOURCE_DESC Tex3D (
2017-01-26 18:23:36 +00:00
DXGI_FORMAT format ,
UINT64 width ,
UINT height ,
UINT16 depth ,
UINT16 mipLevels = 0 ,
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE ,
D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN ,
2020-03-16 09:16:44 +00:00
UINT64 alignment = 0 ) noexcept
2017-01-26 18:23:36 +00:00
{
2020-03-18 04:45:33 +00:00
return CD3DX12_RESOURCE_DESC ( D3D12_RESOURCE_DIMENSION_TEXTURE3D , alignment , width , height , depth ,
2017-01-26 18:23:36 +00:00
mipLevels , format , 1 , 0 , layout , flags ) ;
}
2020-03-16 09:16:44 +00:00
inline UINT16 Depth ( ) const noexcept
2021-10-22 23:43:43 +00:00
{ return ( Dimension = = D3D12_RESOURCE_DIMENSION_TEXTURE3D ? DepthOrArraySize : 1u ) ; }
2020-03-16 09:16:44 +00:00
inline UINT16 ArraySize ( ) const noexcept
2021-10-22 23:43:43 +00:00
{ return ( Dimension ! = D3D12_RESOURCE_DIMENSION_TEXTURE3D ? DepthOrArraySize : 1u ) ; }
2020-03-16 09:16:44 +00:00
inline UINT8 PlaneCount ( _In_ ID3D12Device * pDevice ) const noexcept
2017-01-26 18:23:36 +00:00
{ return D3D12GetFormatPlaneCount ( pDevice , Format ) ; }
2020-03-16 09:16:44 +00:00
inline UINT Subresources ( _In_ ID3D12Device * pDevice ) const noexcept
2021-10-22 23:43:43 +00:00
{ return static_cast < UINT > ( MipLevels ) * ArraySize ( ) * PlaneCount ( pDevice ) ; }
2020-03-16 09:16:44 +00:00
inline UINT CalcSubresource ( UINT MipSlice , UINT ArraySlice , UINT PlaneSlice ) noexcept
2017-01-26 18:23:36 +00:00
{ return D3D12CalcSubresource ( MipSlice , ArraySlice , PlaneSlice , MipLevels , ArraySize ( ) ) ; }
} ;
2020-03-16 09:16:44 +00:00
inline bool operator = = ( const D3D12_RESOURCE_DESC & l , const D3D12_RESOURCE_DESC & r ) noexcept
2017-01-26 18:23:36 +00:00
{
return l . Dimension = = r . Dimension & &
l . Alignment = = r . Alignment & &
l . Width = = r . Width & &
l . Height = = r . Height & &
l . DepthOrArraySize = = r . DepthOrArraySize & &
l . MipLevels = = r . MipLevels & &
l . Format = = r . Format & &
l . SampleDesc . Count = = r . SampleDesc . Count & &
l . SampleDesc . Quality = = r . SampleDesc . Quality & &
l . Layout = = r . Layout & &
l . Flags = = r . Flags ;
}
2020-03-16 09:16:44 +00:00
inline bool operator ! = ( const D3D12_RESOURCE_DESC & l , const D3D12_RESOURCE_DESC & r ) noexcept
2017-01-26 18:23:36 +00:00
{ return ! ( l = = r ) ; }
2020-03-18 04:45:33 +00:00
//------------------------------------------------------------------------------------------------
struct CD3DX12_RESOURCE_DESC1 : public D3D12_RESOURCE_DESC1
{
CD3DX12_RESOURCE_DESC1 ( ) = default ;
explicit CD3DX12_RESOURCE_DESC1 ( const D3D12_RESOURCE_DESC1 & o ) noexcept :
D3D12_RESOURCE_DESC1 ( o )
{ }
2022-02-07 21:18:10 +00:00
explicit CD3DX12_RESOURCE_DESC1 ( const D3D12_RESOURCE_DESC & o ) noexcept
{
Dimension = o . Dimension ;
Alignment = o . Alignment ;
Width = o . Width ;
Height = o . Height ;
DepthOrArraySize = o . DepthOrArraySize ;
MipLevels = o . MipLevels ;
Format = o . Format ;
SampleDesc = o . SampleDesc ;
Layout = o . Layout ;
Flags = o . Flags ;
SamplerFeedbackMipRegion = { } ;
}
2020-03-18 04:45:33 +00:00
CD3DX12_RESOURCE_DESC1 (
D3D12_RESOURCE_DIMENSION dimension ,
UINT64 alignment ,
UINT64 width ,
UINT height ,
UINT16 depthOrArraySize ,
UINT16 mipLevels ,
DXGI_FORMAT format ,
UINT sampleCount ,
UINT sampleQuality ,
D3D12_TEXTURE_LAYOUT layout ,
D3D12_RESOURCE_FLAGS flags ,
UINT samplerFeedbackMipRegionWidth = 0 ,
UINT samplerFeedbackMipRegionHeight = 0 ,
UINT samplerFeedbackMipRegionDepth = 0 ) noexcept
{
Dimension = dimension ;
Alignment = alignment ;
Width = width ;
Height = height ;
DepthOrArraySize = depthOrArraySize ;
MipLevels = mipLevels ;
Format = format ;
SampleDesc . Count = sampleCount ;
SampleDesc . Quality = sampleQuality ;
Layout = layout ;
Flags = flags ;
SamplerFeedbackMipRegion . Width = samplerFeedbackMipRegionWidth ;
SamplerFeedbackMipRegion . Height = samplerFeedbackMipRegionHeight ;
SamplerFeedbackMipRegion . Depth = samplerFeedbackMipRegionDepth ;
}
static inline CD3DX12_RESOURCE_DESC1 Buffer (
const D3D12_RESOURCE_ALLOCATION_INFO & resAllocInfo ,
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE ) noexcept
{
return CD3DX12_RESOURCE_DESC1 ( D3D12_RESOURCE_DIMENSION_BUFFER , resAllocInfo . Alignment , resAllocInfo . SizeInBytes ,
1 , 1 , 1 , DXGI_FORMAT_UNKNOWN , 1 , 0 , D3D12_TEXTURE_LAYOUT_ROW_MAJOR , flags , 0 , 0 , 0 ) ;
}
static inline CD3DX12_RESOURCE_DESC1 Buffer (
UINT64 width ,
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE ,
UINT64 alignment = 0 ) noexcept
{
return CD3DX12_RESOURCE_DESC1 ( D3D12_RESOURCE_DIMENSION_BUFFER , alignment , width , 1 , 1 , 1 ,
DXGI_FORMAT_UNKNOWN , 1 , 0 , D3D12_TEXTURE_LAYOUT_ROW_MAJOR , flags , 0 , 0 , 0 ) ;
}
static inline CD3DX12_RESOURCE_DESC1 Tex1D (
DXGI_FORMAT format ,
UINT64 width ,
UINT16 arraySize = 1 ,
UINT16 mipLevels = 0 ,
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE ,
D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN ,
UINT64 alignment = 0 ) noexcept
{
return CD3DX12_RESOURCE_DESC1 ( D3D12_RESOURCE_DIMENSION_TEXTURE1D , alignment , width , 1 , arraySize ,
mipLevels , format , 1 , 0 , layout , flags , 0 , 0 , 0 ) ;
}
static inline CD3DX12_RESOURCE_DESC1 Tex2D (
DXGI_FORMAT format ,
UINT64 width ,
UINT height ,
UINT16 arraySize = 1 ,
UINT16 mipLevels = 0 ,
UINT sampleCount = 1 ,
UINT sampleQuality = 0 ,
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE ,
D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN ,
UINT64 alignment = 0 ,
UINT samplerFeedbackMipRegionWidth = 0 ,
UINT samplerFeedbackMipRegionHeight = 0 ,
UINT samplerFeedbackMipRegionDepth = 0 ) noexcept
{
return CD3DX12_RESOURCE_DESC1 ( D3D12_RESOURCE_DIMENSION_TEXTURE2D , alignment , width , height , arraySize ,
mipLevels , format , sampleCount , sampleQuality , layout , flags , samplerFeedbackMipRegionWidth ,
samplerFeedbackMipRegionHeight , samplerFeedbackMipRegionDepth ) ;
}
static inline CD3DX12_RESOURCE_DESC1 Tex3D (
DXGI_FORMAT format ,
UINT64 width ,
UINT height ,
UINT16 depth ,
UINT16 mipLevels = 0 ,
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE ,
D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN ,
UINT64 alignment = 0 ) noexcept
{
return CD3DX12_RESOURCE_DESC1 ( D3D12_RESOURCE_DIMENSION_TEXTURE3D , alignment , width , height , depth ,
mipLevels , format , 1 , 0 , layout , flags , 0 , 0 , 0 ) ;
}
inline UINT16 Depth ( ) const noexcept
2021-10-22 23:43:43 +00:00
{ return ( Dimension = = D3D12_RESOURCE_DIMENSION_TEXTURE3D ? DepthOrArraySize : 1u ) ; }
2020-03-18 04:45:33 +00:00
inline UINT16 ArraySize ( ) const noexcept
2021-10-22 23:43:43 +00:00
{ return ( Dimension ! = D3D12_RESOURCE_DIMENSION_TEXTURE3D ? DepthOrArraySize : 1u ) ; }
2020-03-18 04:45:33 +00:00
inline UINT8 PlaneCount ( _In_ ID3D12Device * pDevice ) const noexcept
{ return D3D12GetFormatPlaneCount ( pDevice , Format ) ; }
inline UINT Subresources ( _In_ ID3D12Device * pDevice ) const noexcept
2021-10-22 23:43:43 +00:00
{ return static_cast < UINT > ( MipLevels ) * ArraySize ( ) * PlaneCount ( pDevice ) ; }
2020-03-18 04:45:33 +00:00
inline UINT CalcSubresource ( UINT MipSlice , UINT ArraySlice , UINT PlaneSlice ) noexcept
{ return D3D12CalcSubresource ( MipSlice , ArraySlice , PlaneSlice , MipLevels , ArraySize ( ) ) ; }
} ;
inline bool operator = = ( const D3D12_RESOURCE_DESC1 & l , const D3D12_RESOURCE_DESC1 & r ) noexcept
{
return l . Dimension = = r . Dimension & &
l . Alignment = = r . Alignment & &
l . Width = = r . Width & &
l . Height = = r . Height & &
l . DepthOrArraySize = = r . DepthOrArraySize & &
l . MipLevels = = r . MipLevels & &
l . Format = = r . Format & &
l . SampleDesc . Count = = r . SampleDesc . Count & &
l . SampleDesc . Quality = = r . SampleDesc . Quality & &
l . Layout = = r . Layout & &
l . Flags = = r . Flags & &
l . SamplerFeedbackMipRegion . Width = = r . SamplerFeedbackMipRegion . Width & &
l . SamplerFeedbackMipRegion . Height = = r . SamplerFeedbackMipRegion . Height & &
l . SamplerFeedbackMipRegion . Depth = = r . SamplerFeedbackMipRegion . Depth ;
}
inline bool operator ! = ( const D3D12_RESOURCE_DESC1 & l , const D3D12_RESOURCE_DESC1 & r ) noexcept
{ return ! ( l = = r ) ; }
2017-10-24 22:00:28 +00:00
//------------------------------------------------------------------------------------------------
struct CD3DX12_VIEW_INSTANCING_DESC : public D3D12_VIEW_INSTANCING_DESC
{
2018-04-12 01:06:24 +00:00
CD3DX12_VIEW_INSTANCING_DESC ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_VIEW_INSTANCING_DESC ( const D3D12_VIEW_INSTANCING_DESC & o ) noexcept :
2017-10-24 22:00:28 +00:00
D3D12_VIEW_INSTANCING_DESC ( o )
{ }
2020-03-16 09:16:44 +00:00
explicit CD3DX12_VIEW_INSTANCING_DESC ( CD3DX12_DEFAULT ) noexcept
2017-10-24 22:00:28 +00:00
{
ViewInstanceCount = 0 ;
pViewInstanceLocations = nullptr ;
Flags = D3D12_VIEW_INSTANCING_FLAG_NONE ;
}
2020-03-18 04:45:33 +00:00
explicit CD3DX12_VIEW_INSTANCING_DESC (
2017-10-24 22:00:28 +00:00
UINT InViewInstanceCount ,
const D3D12_VIEW_INSTANCE_LOCATION * InViewInstanceLocations ,
2020-03-16 09:16:44 +00:00
D3D12_VIEW_INSTANCING_FLAGS InFlags ) noexcept
2017-10-24 22:00:28 +00:00
{
ViewInstanceCount = InViewInstanceCount ;
pViewInstanceLocations = InViewInstanceLocations ;
Flags = InFlags ;
}
} ;
2024-05-17 23:56:19 +00:00
//------------------------------------------------------------------------------------------------
template < typename T , typename U , typename V >
inline void D3D12DecomposeSubresource ( UINT Subresource , UINT MipLevels , UINT ArraySize , _Out_ T & MipSlice , _Out_ U & ArraySlice , _Out_ V & PlaneSlice ) noexcept
{
MipSlice = static_cast < T > ( Subresource % MipLevels ) ;
ArraySlice = static_cast < U > ( ( Subresource / MipLevels ) % ArraySize ) ;
PlaneSlice = static_cast < V > ( Subresource / ( MipLevels * ArraySize ) ) ;
}
2017-01-26 18:23:36 +00:00
//------------------------------------------------------------------------------------------------
// Row-by-row memcpy
inline void MemcpySubresource (
_In_ const D3D12_MEMCPY_DEST * pDest ,
_In_ const D3D12_SUBRESOURCE_DATA * pSrc ,
SIZE_T RowSizeInBytes ,
UINT NumRows ,
2020-03-16 09:16:44 +00:00
UINT NumSlices ) noexcept
2017-01-26 18:23:36 +00:00
{
for ( UINT z = 0 ; z < NumSlices ; + + z )
{
2020-03-16 09:16:44 +00:00
auto pDestSlice = static_cast < BYTE * > ( pDest - > pData ) + pDest - > SlicePitch * z ;
auto pSrcSlice = static_cast < const BYTE * > ( pSrc - > pData ) + pSrc - > SlicePitch * LONG_PTR ( z ) ;
2017-01-26 18:23:36 +00:00
for ( UINT y = 0 ; y < NumRows ; + + y )
{
memcpy ( pDestSlice + pDest - > RowPitch * y ,
2019-07-11 22:21:03 +00:00
pSrcSlice + pSrc - > RowPitch * LONG_PTR ( y ) ,
2017-01-26 18:23:36 +00:00
RowSizeInBytes ) ;
}
}
}
2020-11-02 21:00:21 +00:00
//------------------------------------------------------------------------------------------------
// Row-by-row memcpy
inline void MemcpySubresource (
_In_ const D3D12_MEMCPY_DEST * pDest ,
_In_ const void * pResourceData ,
_In_ const D3D12_SUBRESOURCE_INFO * pSrc ,
SIZE_T RowSizeInBytes ,
UINT NumRows ,
UINT NumSlices ) noexcept
{
for ( UINT z = 0 ; z < NumSlices ; + + z )
{
auto pDestSlice = static_cast < BYTE * > ( pDest - > pData ) + pDest - > SlicePitch * z ;
2021-02-10 21:53:09 +00:00
auto pSrcSlice = ( static_cast < const BYTE * > ( pResourceData ) + pSrc - > Offset ) + pSrc - > DepthPitch * ULONG_PTR ( z ) ;
2020-11-02 21:00:21 +00:00
for ( UINT y = 0 ; y < NumRows ; + + y )
{
memcpy ( pDestSlice + pDest - > RowPitch * y ,
2021-02-10 21:53:09 +00:00
pSrcSlice + pSrc - > RowPitch * ULONG_PTR ( y ) ,
2020-11-02 21:00:21 +00:00
RowSizeInBytes ) ;
}
}
}
2017-01-26 18:23:36 +00:00
//------------------------------------------------------------------------------------------------
// Returns required size of a buffer to be used for data upload
inline UINT64 GetRequiredIntermediateSize (
_In_ ID3D12Resource * pDestinationResource ,
_In_range_ ( 0 , D3D12_REQ_SUBRESOURCES ) UINT FirstSubresource ,
2020-03-16 09:16:44 +00:00
_In_range_ ( 0 , D3D12_REQ_SUBRESOURCES - FirstSubresource ) UINT NumSubresources ) noexcept
2017-01-26 18:23:36 +00:00
{
2022-07-25 21:48:46 +00:00
# if defined(_MSC_VER) || !defined(_WIN32)
2021-10-22 23:43:43 +00:00
const auto Desc = pDestinationResource - > GetDesc ( ) ;
2022-07-25 21:48:46 +00:00
# else
D3D12_RESOURCE_DESC tmpDesc ;
const auto & Desc = * pDestinationResource - > GetDesc ( & tmpDesc ) ;
# endif
2017-01-26 18:23:36 +00:00
UINT64 RequiredSize = 0 ;
2020-03-18 04:45:33 +00:00
2018-06-22 23:55:00 +00:00
ID3D12Device * pDevice = nullptr ;
2019-07-05 06:26:40 +00:00
pDestinationResource - > GetDevice ( IID_ID3D12Device , reinterpret_cast < void * * > ( & pDevice ) ) ;
2017-01-26 18:23:36 +00:00
pDevice - > GetCopyableFootprints ( & Desc , FirstSubresource , NumSubresources , 0 , nullptr , nullptr , nullptr , & RequiredSize ) ;
pDevice - > Release ( ) ;
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
return RequiredSize ;
}
//------------------------------------------------------------------------------------------------
// All arrays must be populated (e.g. by calling GetCopyableFootprints)
inline UINT64 UpdateSubresources (
_In_ ID3D12GraphicsCommandList * pCmdList ,
_In_ ID3D12Resource * pDestinationResource ,
_In_ ID3D12Resource * pIntermediate ,
_In_range_ ( 0 , D3D12_REQ_SUBRESOURCES ) UINT FirstSubresource ,
_In_range_ ( 0 , D3D12_REQ_SUBRESOURCES - FirstSubresource ) UINT NumSubresources ,
UINT64 RequiredSize ,
_In_reads_ ( NumSubresources ) const D3D12_PLACED_SUBRESOURCE_FOOTPRINT * pLayouts ,
_In_reads_ ( NumSubresources ) const UINT * pNumRows ,
_In_reads_ ( NumSubresources ) const UINT64 * pRowSizesInBytes ,
2020-03-16 09:16:44 +00:00
_In_reads_ ( NumSubresources ) const D3D12_SUBRESOURCE_DATA * pSrcData ) noexcept
2017-01-26 18:23:36 +00:00
{
// Minor validation
2022-07-25 21:48:46 +00:00
# if defined(_MSC_VER) || !defined(_WIN32)
2021-10-22 23:43:43 +00:00
const auto IntermediateDesc = pIntermediate - > GetDesc ( ) ;
const auto DestinationDesc = pDestinationResource - > GetDesc ( ) ;
2022-07-25 21:48:46 +00:00
# else
D3D12_RESOURCE_DESC tmpDesc1 , tmpDesc2 ;
const auto & IntermediateDesc = * pIntermediate - > GetDesc ( & tmpDesc1 ) ;
const auto & DestinationDesc = * pDestinationResource - > GetDesc ( & tmpDesc2 ) ;
# endif
2020-03-18 04:45:33 +00:00
if ( IntermediateDesc . Dimension ! = D3D12_RESOURCE_DIMENSION_BUFFER | |
IntermediateDesc . Width < RequiredSize + pLayouts [ 0 ] . Offset | |
RequiredSize > SIZE_T ( - 1 ) | |
( DestinationDesc . Dimension = = D3D12_RESOURCE_DIMENSION_BUFFER & &
2017-01-26 18:23:36 +00:00
( FirstSubresource ! = 0 | | NumSubresources ! = 1 ) ) )
{
return 0 ;
}
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
BYTE * pData ;
2018-06-22 23:55:00 +00:00
HRESULT hr = pIntermediate - > Map ( 0 , nullptr , reinterpret_cast < void * * > ( & pData ) ) ;
2017-01-26 18:23:36 +00:00
if ( FAILED ( hr ) )
{
return 0 ;
}
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
for ( UINT i = 0 ; i < NumSubresources ; + + i )
{
2018-06-22 23:55:00 +00:00
if ( pRowSizesInBytes [ i ] > SIZE_T ( - 1 ) ) return 0 ;
2018-04-12 01:06:24 +00:00
D3D12_MEMCPY_DEST DestData = { pData + pLayouts [ i ] . Offset , pLayouts [ i ] . Footprint . RowPitch , SIZE_T ( pLayouts [ i ] . Footprint . RowPitch ) * SIZE_T ( pNumRows [ i ] ) } ;
2018-06-22 23:55:00 +00:00
MemcpySubresource ( & DestData , & pSrcData [ i ] , static_cast < SIZE_T > ( pRowSizesInBytes [ i ] ) , pNumRows [ i ] , pLayouts [ i ] . Footprint . Depth ) ;
2017-01-26 18:23:36 +00:00
}
2018-06-22 23:55:00 +00:00
pIntermediate - > Unmap ( 0 , nullptr ) ;
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
if ( DestinationDesc . Dimension = = D3D12_RESOURCE_DIMENSION_BUFFER )
{
pCmdList - > CopyBufferRegion (
pDestinationResource , 0 , pIntermediate , pLayouts [ 0 ] . Offset , pLayouts [ 0 ] . Footprint . Width ) ;
}
else
{
for ( UINT i = 0 ; i < NumSubresources ; + + i )
{
2022-02-21 09:10:19 +00:00
const CD3DX12_TEXTURE_COPY_LOCATION Dst ( pDestinationResource , i + FirstSubresource ) ;
const CD3DX12_TEXTURE_COPY_LOCATION Src ( pIntermediate , pLayouts [ i ] ) ;
2017-01-26 18:23:36 +00:00
pCmdList - > CopyTextureRegion ( & Dst , 0 , 0 , 0 , & Src , nullptr ) ;
}
}
return RequiredSize ;
}
2020-11-02 21:00:21 +00:00
//------------------------------------------------------------------------------------------------
// All arrays must be populated (e.g. by calling GetCopyableFootprints)
inline UINT64 UpdateSubresources (
_In_ ID3D12GraphicsCommandList * pCmdList ,
_In_ ID3D12Resource * pDestinationResource ,
_In_ ID3D12Resource * pIntermediate ,
_In_range_ ( 0 , D3D12_REQ_SUBRESOURCES ) UINT FirstSubresource ,
_In_range_ ( 0 , D3D12_REQ_SUBRESOURCES - FirstSubresource ) UINT NumSubresources ,
UINT64 RequiredSize ,
_In_reads_ ( NumSubresources ) const D3D12_PLACED_SUBRESOURCE_FOOTPRINT * pLayouts ,
_In_reads_ ( NumSubresources ) const UINT * pNumRows ,
_In_reads_ ( NumSubresources ) const UINT64 * pRowSizesInBytes ,
_In_ const void * pResourceData ,
_In_reads_ ( NumSubresources ) const D3D12_SUBRESOURCE_INFO * pSrcData ) noexcept
{
// Minor validation
2022-07-25 21:48:46 +00:00
# if defined(_MSC_VER) || !defined(_WIN32)
2021-10-22 23:43:43 +00:00
const auto IntermediateDesc = pIntermediate - > GetDesc ( ) ;
const auto DestinationDesc = pDestinationResource - > GetDesc ( ) ;
2022-07-25 21:48:46 +00:00
# else
D3D12_RESOURCE_DESC tmpDesc1 , tmpDesc2 ;
const auto & IntermediateDesc = * pIntermediate - > GetDesc ( & tmpDesc1 ) ;
const auto & DestinationDesc = * pDestinationResource - > GetDesc ( & tmpDesc2 ) ;
# endif
2020-11-02 21:00:21 +00:00
if ( IntermediateDesc . Dimension ! = D3D12_RESOURCE_DIMENSION_BUFFER | |
IntermediateDesc . Width < RequiredSize + pLayouts [ 0 ] . Offset | |
RequiredSize > SIZE_T ( - 1 ) | |
( DestinationDesc . Dimension = = D3D12_RESOURCE_DIMENSION_BUFFER & &
( FirstSubresource ! = 0 | | NumSubresources ! = 1 ) ) )
{
return 0 ;
}
BYTE * pData ;
HRESULT hr = pIntermediate - > Map ( 0 , nullptr , reinterpret_cast < void * * > ( & pData ) ) ;
if ( FAILED ( hr ) )
{
return 0 ;
}
for ( UINT i = 0 ; i < NumSubresources ; + + i )
{
if ( pRowSizesInBytes [ i ] > SIZE_T ( - 1 ) ) return 0 ;
D3D12_MEMCPY_DEST DestData = { pData + pLayouts [ i ] . Offset , pLayouts [ i ] . Footprint . RowPitch , SIZE_T ( pLayouts [ i ] . Footprint . RowPitch ) * SIZE_T ( pNumRows [ i ] ) } ;
MemcpySubresource ( & DestData , pResourceData , & pSrcData [ i ] , static_cast < SIZE_T > ( pRowSizesInBytes [ i ] ) , pNumRows [ i ] , pLayouts [ i ] . Footprint . Depth ) ;
}
pIntermediate - > Unmap ( 0 , nullptr ) ;
if ( DestinationDesc . Dimension = = D3D12_RESOURCE_DIMENSION_BUFFER )
{
pCmdList - > CopyBufferRegion (
pDestinationResource , 0 , pIntermediate , pLayouts [ 0 ] . Offset , pLayouts [ 0 ] . Footprint . Width ) ;
}
else
{
for ( UINT i = 0 ; i < NumSubresources ; + + i )
{
2022-02-21 09:10:19 +00:00
const CD3DX12_TEXTURE_COPY_LOCATION Dst ( pDestinationResource , i + FirstSubresource ) ;
const CD3DX12_TEXTURE_COPY_LOCATION Src ( pIntermediate , pLayouts [ i ] ) ;
2020-11-02 21:00:21 +00:00
pCmdList - > CopyTextureRegion ( & Dst , 0 , 0 , 0 , & Src , nullptr ) ;
}
}
return RequiredSize ;
}
2017-01-26 18:23:36 +00:00
//------------------------------------------------------------------------------------------------
// Heap-allocating UpdateSubresources implementation
2020-03-18 04:45:33 +00:00
inline UINT64 UpdateSubresources (
2017-01-26 18:23:36 +00:00
_In_ ID3D12GraphicsCommandList * pCmdList ,
_In_ ID3D12Resource * pDestinationResource ,
_In_ ID3D12Resource * pIntermediate ,
UINT64 IntermediateOffset ,
_In_range_ ( 0 , D3D12_REQ_SUBRESOURCES ) UINT FirstSubresource ,
_In_range_ ( 0 , D3D12_REQ_SUBRESOURCES - FirstSubresource ) UINT NumSubresources ,
2020-03-16 09:16:44 +00:00
_In_reads_ ( NumSubresources ) const D3D12_SUBRESOURCE_DATA * pSrcData ) noexcept
2017-01-26 18:23:36 +00:00
{
UINT64 RequiredSize = 0 ;
2021-10-22 23:43:43 +00:00
const auto MemToAlloc = static_cast < UINT64 > ( sizeof ( D3D12_PLACED_SUBRESOURCE_FOOTPRINT ) + sizeof ( UINT ) + sizeof ( UINT64 ) ) * NumSubresources ;
2017-01-26 18:23:36 +00:00
if ( MemToAlloc > SIZE_MAX )
{
return 0 ;
}
void * pMem = HeapAlloc ( GetProcessHeap ( ) , 0 , static_cast < SIZE_T > ( MemToAlloc ) ) ;
2018-06-22 23:55:00 +00:00
if ( pMem = = nullptr )
2017-01-26 18:23:36 +00:00
{
return 0 ;
}
2020-03-16 09:16:44 +00:00
auto pLayouts = static_cast < D3D12_PLACED_SUBRESOURCE_FOOTPRINT * > ( pMem ) ;
2020-11-02 21:00:21 +00:00
auto pRowSizesInBytes = reinterpret_cast < UINT64 * > ( pLayouts + NumSubresources ) ;
auto pNumRows = reinterpret_cast < UINT * > ( pRowSizesInBytes + NumSubresources ) ;
2020-03-18 04:45:33 +00:00
2022-07-25 21:48:46 +00:00
# if defined(_MSC_VER) || !defined(_WIN32)
2021-10-22 23:43:43 +00:00
const auto Desc = pDestinationResource - > GetDesc ( ) ;
2022-07-25 21:48:46 +00:00
# else
D3D12_RESOURCE_DESC tmpDesc ;
const auto & Desc = * pDestinationResource - > GetDesc ( & tmpDesc ) ;
# endif
2018-06-22 23:55:00 +00:00
ID3D12Device * pDevice = nullptr ;
2019-07-05 06:26:40 +00:00
pDestinationResource - > GetDevice ( IID_ID3D12Device , reinterpret_cast < void * * > ( & pDevice ) ) ;
2017-01-26 18:23:36 +00:00
pDevice - > GetCopyableFootprints ( & Desc , FirstSubresource , NumSubresources , IntermediateOffset , pLayouts , pNumRows , pRowSizesInBytes , & RequiredSize ) ;
pDevice - > Release ( ) ;
2020-03-18 04:45:33 +00:00
2021-10-22 23:43:43 +00:00
const UINT64 Result = UpdateSubresources ( pCmdList , pDestinationResource , pIntermediate , FirstSubresource , NumSubresources , RequiredSize , pLayouts , pNumRows , pRowSizesInBytes , pSrcData ) ;
2017-01-26 18:23:36 +00:00
HeapFree ( GetProcessHeap ( ) , 0 , pMem ) ;
return Result ;
}
2020-11-02 21:00:21 +00:00
//------------------------------------------------------------------------------------------------
// Heap-allocating UpdateSubresources implementation
inline UINT64 UpdateSubresources (
_In_ ID3D12GraphicsCommandList * pCmdList ,
_In_ ID3D12Resource * pDestinationResource ,
_In_ ID3D12Resource * pIntermediate ,
UINT64 IntermediateOffset ,
_In_range_ ( 0 , D3D12_REQ_SUBRESOURCES ) UINT FirstSubresource ,
_In_range_ ( 0 , D3D12_REQ_SUBRESOURCES - FirstSubresource ) UINT NumSubresources ,
_In_ const void * pResourceData ,
2021-10-22 23:43:43 +00:00
_In_reads_ ( NumSubresources ) const D3D12_SUBRESOURCE_INFO * pSrcData ) noexcept
2020-11-02 21:00:21 +00:00
{
UINT64 RequiredSize = 0 ;
2021-10-22 23:43:43 +00:00
const auto MemToAlloc = static_cast < UINT64 > ( sizeof ( D3D12_PLACED_SUBRESOURCE_FOOTPRINT ) + sizeof ( UINT ) + sizeof ( UINT64 ) ) * NumSubresources ;
2020-11-02 21:00:21 +00:00
if ( MemToAlloc > SIZE_MAX )
{
return 0 ;
}
void * pMem = HeapAlloc ( GetProcessHeap ( ) , 0 , static_cast < SIZE_T > ( MemToAlloc ) ) ;
if ( pMem = = nullptr )
{
return 0 ;
}
2021-10-22 23:43:43 +00:00
auto pLayouts = static_cast < D3D12_PLACED_SUBRESOURCE_FOOTPRINT * > ( pMem ) ;
2020-11-02 21:00:21 +00:00
auto pRowSizesInBytes = reinterpret_cast < UINT64 * > ( pLayouts + NumSubresources ) ;
auto pNumRows = reinterpret_cast < UINT * > ( pRowSizesInBytes + NumSubresources ) ;
2022-07-25 21:48:46 +00:00
# if defined(_MSC_VER) || !defined(_WIN32)
2021-10-22 23:43:43 +00:00
const auto Desc = pDestinationResource - > GetDesc ( ) ;
2022-07-25 21:48:46 +00:00
# else
D3D12_RESOURCE_DESC tmpDesc ;
const auto & Desc = * pDestinationResource - > GetDesc ( & tmpDesc ) ;
# endif
2020-11-02 21:00:21 +00:00
ID3D12Device * pDevice = nullptr ;
pDestinationResource - > GetDevice ( IID_ID3D12Device , reinterpret_cast < void * * > ( & pDevice ) ) ;
pDevice - > GetCopyableFootprints ( & Desc , FirstSubresource , NumSubresources , IntermediateOffset , pLayouts , pNumRows , pRowSizesInBytes , & RequiredSize ) ;
pDevice - > Release ( ) ;
2021-10-22 23:43:43 +00:00
const UINT64 Result = UpdateSubresources ( pCmdList , pDestinationResource , pIntermediate , FirstSubresource , NumSubresources , RequiredSize , pLayouts , pNumRows , pRowSizesInBytes , pResourceData , pSrcData ) ;
2020-11-02 21:00:21 +00:00
HeapFree ( GetProcessHeap ( ) , 0 , pMem ) ;
return Result ;
}
2017-01-26 18:23:36 +00:00
//------------------------------------------------------------------------------------------------
// Stack-allocating UpdateSubresources implementation
template < UINT MaxSubresources >
2020-03-18 04:45:33 +00:00
inline UINT64 UpdateSubresources (
2017-01-26 18:23:36 +00:00
_In_ ID3D12GraphicsCommandList * pCmdList ,
_In_ ID3D12Resource * pDestinationResource ,
_In_ ID3D12Resource * pIntermediate ,
UINT64 IntermediateOffset ,
2020-11-02 21:00:21 +00:00
_In_range_ ( 0 , MaxSubresources ) UINT FirstSubresource ,
_In_range_ ( 1 , MaxSubresources - FirstSubresource ) UINT NumSubresources ,
2020-03-16 09:16:44 +00:00
_In_reads_ ( NumSubresources ) const D3D12_SUBRESOURCE_DATA * pSrcData ) noexcept
2017-01-26 18:23:36 +00:00
{
UINT64 RequiredSize = 0 ;
D3D12_PLACED_SUBRESOURCE_FOOTPRINT Layouts [ MaxSubresources ] ;
UINT NumRows [ MaxSubresources ] ;
UINT64 RowSizesInBytes [ MaxSubresources ] ;
2020-03-18 04:45:33 +00:00
2022-07-25 21:48:46 +00:00
# if defined(_MSC_VER) || !defined(_WIN32)
2021-10-22 23:43:43 +00:00
const auto Desc = pDestinationResource - > GetDesc ( ) ;
2022-07-25 21:48:46 +00:00
# else
D3D12_RESOURCE_DESC tmpDesc ;
const auto & Desc = * pDestinationResource - > GetDesc ( & tmpDesc ) ;
# endif
2018-06-22 23:55:00 +00:00
ID3D12Device * pDevice = nullptr ;
2019-07-05 06:26:40 +00:00
pDestinationResource - > GetDevice ( IID_ID3D12Device , reinterpret_cast < void * * > ( & pDevice ) ) ;
2017-01-26 18:23:36 +00:00
pDevice - > GetCopyableFootprints ( & Desc , FirstSubresource , NumSubresources , IntermediateOffset , Layouts , NumRows , RowSizesInBytes , & RequiredSize ) ;
pDevice - > Release ( ) ;
2020-03-18 04:45:33 +00:00
2017-01-26 18:23:36 +00:00
return UpdateSubresources ( pCmdList , pDestinationResource , pIntermediate , FirstSubresource , NumSubresources , RequiredSize , Layouts , NumRows , RowSizesInBytes , pSrcData ) ;
}
2020-11-02 21:00:21 +00:00
//------------------------------------------------------------------------------------------------
// Stack-allocating UpdateSubresources implementation
template < UINT MaxSubresources >
inline UINT64 UpdateSubresources (
_In_ ID3D12GraphicsCommandList * pCmdList ,
_In_ ID3D12Resource * pDestinationResource ,
_In_ ID3D12Resource * pIntermediate ,
UINT64 IntermediateOffset ,
_In_range_ ( 0 , MaxSubresources ) UINT FirstSubresource ,
_In_range_ ( 1 , MaxSubresources - FirstSubresource ) UINT NumSubresources ,
_In_ const void * pResourceData ,
2021-10-22 23:43:43 +00:00
_In_reads_ ( NumSubresources ) const D3D12_SUBRESOURCE_INFO * pSrcData ) noexcept
2020-11-02 21:00:21 +00:00
{
UINT64 RequiredSize = 0 ;
D3D12_PLACED_SUBRESOURCE_FOOTPRINT Layouts [ MaxSubresources ] ;
UINT NumRows [ MaxSubresources ] ;
UINT64 RowSizesInBytes [ MaxSubresources ] ;
2022-07-25 21:48:46 +00:00
# if defined(_MSC_VER) || !defined(_WIN32)
2021-10-22 23:43:43 +00:00
const auto Desc = pDestinationResource - > GetDesc ( ) ;
2022-07-25 21:48:46 +00:00
# else
D3D12_RESOURCE_DESC tmpDesc ;
const auto & Desc = * pDestinationResource - > GetDesc ( & tmpDesc ) ;
# endif
2020-11-02 21:00:21 +00:00
ID3D12Device * pDevice = nullptr ;
pDestinationResource - > GetDevice ( IID_ID3D12Device , reinterpret_cast < void * * > ( & pDevice ) ) ;
pDevice - > GetCopyableFootprints ( & Desc , FirstSubresource , NumSubresources , IntermediateOffset , Layouts , NumRows , RowSizesInBytes , & RequiredSize ) ;
pDevice - > Release ( ) ;
return UpdateSubresources ( pCmdList , pDestinationResource , pIntermediate , FirstSubresource , NumSubresources , RequiredSize , Layouts , NumRows , RowSizesInBytes , pResourceData , pSrcData ) ;
}
2017-01-26 18:23:36 +00:00
//------------------------------------------------------------------------------------------------
2021-10-22 23:43:43 +00:00
constexpr bool D3D12IsLayoutOpaque ( D3D12_TEXTURE_LAYOUT Layout ) noexcept
2017-01-26 18:23:36 +00:00
{ return Layout = = D3D12_TEXTURE_LAYOUT_UNKNOWN | | Layout = = D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE ; }
2024-05-17 23:56:19 +00:00
//------------------------------------------------------------------------------------------------
2024-05-30 19:39:25 +00:00
# ifndef D3DX12_ASSERT
# ifdef assert
# define D3DX12_ASSERT(x) assert(x)
# else
# define D3DX12_ASSERT(x)
# endif
# endif
2024-05-17 23:56:19 +00:00
template < typename T >
inline T D3DX12Align ( T uValue , T uAlign )
{
// Assert power of 2 alignment
D3DX12_ASSERT ( 0 = = ( uAlign & ( uAlign - 1 ) ) ) ;
T uMask = uAlign - 1 ;
T uResult = ( uValue + uMask ) & ~ uMask ;
D3DX12_ASSERT ( uResult > = uValue ) ;
D3DX12_ASSERT ( 0 = = ( uResult % uAlign ) ) ;
return uResult ;
}
//------------------------------------------------------------------------------------------------
template < typename T >
inline T D3DX12AlignAtLeast ( T uValue , T uAlign )
{
T aligned = D3DX12Align ( uValue , uAlign ) ;
return aligned > uAlign ? aligned : uAlign ;
}
// D3DX12GetCopyableFootprints is not included as it relies on D3D12_PROPERTY_LAYOUT_FORMAT_TABLE
2017-01-26 18:23:36 +00:00
//------------------------------------------------------------------------------------------------
2017-04-20 01:13:34 +00:00
template < typename t_CommandListType >
2020-03-16 09:16:44 +00:00
inline ID3D12CommandList * const * CommandListCast ( t_CommandListType * const * pp ) noexcept
2017-01-26 18:23:36 +00:00
{
// This cast is useful for passing strongly typed command list pointers into
// ExecuteCommandLists.
// This cast is valid as long as the const-ness is respected. D3D12 APIs do
// respect the const-ness of their arguments.
return reinterpret_cast < ID3D12CommandList * const * > ( pp ) ;
}
//------------------------------------------------------------------------------------------------
// D3D12 exports a new method for serializing root signatures in the Windows 10 Anniversary Update.
// To help enable root signature 1.1 features when they are available and not require maintaining
// two code paths for building root signatures, this helper method reconstructs a 1.0 signature when
// 1.1 is not supported.
2024-02-05 18:08:59 +00:00
# ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wcovered-switch-default"
# endif
2017-01-26 18:23:36 +00:00
inline HRESULT D3DX12SerializeVersionedRootSignature (
_In_ const D3D12_VERSIONED_ROOT_SIGNATURE_DESC * pRootSignatureDesc ,
D3D_ROOT_SIGNATURE_VERSION MaxVersion ,
_Outptr_ ID3DBlob * * ppBlob ,
2020-03-16 09:16:44 +00:00
_Always_ ( _Outptr_opt_result_maybenull_ ) ID3DBlob * * ppErrorBlob ) noexcept
2017-01-26 18:23:36 +00:00
{
2018-06-22 23:55:00 +00:00
if ( ppErrorBlob ! = nullptr )
2017-01-26 18:23:36 +00:00
{
2018-06-22 23:55:00 +00:00
* ppErrorBlob = nullptr ;
2017-01-26 18:23:36 +00:00
}
switch ( MaxVersion )
{
case D3D_ROOT_SIGNATURE_VERSION_1_0 :
switch ( pRootSignatureDesc - > Version )
{
case D3D_ROOT_SIGNATURE_VERSION_1_0 :
return D3D12SerializeRootSignature ( & pRootSignatureDesc - > Desc_1_0 , D3D_ROOT_SIGNATURE_VERSION_1 , ppBlob , ppErrorBlob ) ;
case D3D_ROOT_SIGNATURE_VERSION_1_1 :
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
2022-11-30 22:18:40 +00:00
case D3D_ROOT_SIGNATURE_VERSION_1_2 :
# endif
2017-01-26 18:23:36 +00:00
{
HRESULT hr = S_OK ;
const D3D12_ROOT_SIGNATURE_DESC1 & desc_1_1 = pRootSignatureDesc - > Desc_1_1 ;
const SIZE_T ParametersSize = sizeof ( D3D12_ROOT_PARAMETER ) * desc_1_1 . NumParameters ;
2018-06-22 23:55:00 +00:00
void * pParameters = ( ParametersSize > 0 ) ? HeapAlloc ( GetProcessHeap ( ) , 0 , ParametersSize ) : nullptr ;
if ( ParametersSize > 0 & & pParameters = = nullptr )
2017-01-26 18:23:36 +00:00
{
hr = E_OUTOFMEMORY ;
}
2020-03-16 09:16:44 +00:00
auto pParameters_1_0 = static_cast < D3D12_ROOT_PARAMETER * > ( pParameters ) ;
2017-01-26 18:23:36 +00:00
if ( SUCCEEDED ( hr ) )
{
for ( UINT n = 0 ; n < desc_1_1 . NumParameters ; n + + )
{
__analysis_assume ( ParametersSize = = sizeof ( D3D12_ROOT_PARAMETER ) * desc_1_1 . NumParameters ) ;
pParameters_1_0 [ n ] . ParameterType = desc_1_1 . pParameters [ n ] . ParameterType ;
pParameters_1_0 [ n ] . ShaderVisibility = desc_1_1 . pParameters [ n ] . ShaderVisibility ;
switch ( desc_1_1 . pParameters [ n ] . ParameterType )
{
case D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS :
pParameters_1_0 [ n ] . Constants . Num32BitValues = desc_1_1 . pParameters [ n ] . Constants . Num32BitValues ;
pParameters_1_0 [ n ] . Constants . RegisterSpace = desc_1_1 . pParameters [ n ] . Constants . RegisterSpace ;
pParameters_1_0 [ n ] . Constants . ShaderRegister = desc_1_1 . pParameters [ n ] . Constants . ShaderRegister ;
break ;
case D3D12_ROOT_PARAMETER_TYPE_CBV :
case D3D12_ROOT_PARAMETER_TYPE_SRV :
case D3D12_ROOT_PARAMETER_TYPE_UAV :
pParameters_1_0 [ n ] . Descriptor . RegisterSpace = desc_1_1 . pParameters [ n ] . Descriptor . RegisterSpace ;
pParameters_1_0 [ n ] . Descriptor . ShaderRegister = desc_1_1 . pParameters [ n ] . Descriptor . ShaderRegister ;
break ;
case D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE :
{
2024-02-05 18:08:59 +00:00
const D3D12_ROOT_DESCRIPTOR_TABLE1 & table_1_1 = desc_1_1 . pParameters [ n ] . DescriptorTable ;
2017-01-26 18:23:36 +00:00
2024-02-05 18:08:59 +00:00
const SIZE_T DescriptorRangesSize = sizeof ( D3D12_DESCRIPTOR_RANGE ) * table_1_1 . NumDescriptorRanges ;
void * pDescriptorRanges = ( DescriptorRangesSize > 0 & & SUCCEEDED ( hr ) ) ? HeapAlloc ( GetProcessHeap ( ) , 0 , DescriptorRangesSize ) : nullptr ;
if ( DescriptorRangesSize > 0 & & pDescriptorRanges = = nullptr )
2017-01-26 18:23:36 +00:00
{
2024-02-05 18:08:59 +00:00
hr = E_OUTOFMEMORY ;
2017-01-26 18:23:36 +00:00
}
2024-02-05 18:08:59 +00:00
auto pDescriptorRanges_1_0 = static_cast < D3D12_DESCRIPTOR_RANGE * > ( pDescriptorRanges ) ;
if ( SUCCEEDED ( hr ) )
{
for ( UINT x = 0 ; x < table_1_1 . NumDescriptorRanges ; x + + )
{
__analysis_assume ( DescriptorRangesSize = = sizeof ( D3D12_DESCRIPTOR_RANGE ) * table_1_1 . NumDescriptorRanges ) ;
pDescriptorRanges_1_0 [ x ] . BaseShaderRegister = table_1_1 . pDescriptorRanges [ x ] . BaseShaderRegister ;
pDescriptorRanges_1_0 [ x ] . NumDescriptors = table_1_1 . pDescriptorRanges [ x ] . NumDescriptors ;
pDescriptorRanges_1_0 [ x ] . OffsetInDescriptorsFromTableStart = table_1_1 . pDescriptorRanges [ x ] . OffsetInDescriptorsFromTableStart ;
pDescriptorRanges_1_0 [ x ] . RangeType = table_1_1 . pDescriptorRanges [ x ] . RangeType ;
pDescriptorRanges_1_0 [ x ] . RegisterSpace = table_1_1 . pDescriptorRanges [ x ] . RegisterSpace ;
}
}
D3D12_ROOT_DESCRIPTOR_TABLE & table_1_0 = pParameters_1_0 [ n ] . DescriptorTable ;
table_1_0 . NumDescriptorRanges = table_1_1 . NumDescriptorRanges ;
table_1_0 . pDescriptorRanges = pDescriptorRanges_1_0 ;
2017-01-26 18:23:36 +00:00
}
2024-02-05 18:08:59 +00:00
break ;
2017-01-26 18:23:36 +00:00
2024-02-05 18:08:59 +00:00
default :
break ;
2017-01-26 18:23:36 +00:00
}
}
}
2024-02-05 18:08:59 +00:00
D3D12_STATIC_SAMPLER_DESC * pStaticSamplers = nullptr ;
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
if ( desc_1_1 . NumStaticSamplers > 0 & & pRootSignatureDesc - > Version = = D3D_ROOT_SIGNATURE_VERSION_1_2 )
{
const SIZE_T SamplersSize = sizeof ( D3D12_STATIC_SAMPLER_DESC ) * desc_1_1 . NumStaticSamplers ;
pStaticSamplers = static_cast < D3D12_STATIC_SAMPLER_DESC * > ( HeapAlloc ( GetProcessHeap ( ) , 0 , SamplersSize ) ) ;
if ( pStaticSamplers = = nullptr )
{
hr = E_OUTOFMEMORY ;
}
else
{
const D3D12_ROOT_SIGNATURE_DESC2 & desc_1_2 = pRootSignatureDesc - > Desc_1_2 ;
for ( UINT n = 0 ; n < desc_1_1 . NumStaticSamplers ; + + n )
{
if ( ( desc_1_2 . pStaticSamplers [ n ] . Flags & ~ D3D12_SAMPLER_FLAG_UINT_BORDER_COLOR ) ! = 0 )
{
hr = E_INVALIDARG ;
break ;
}
memcpy ( pStaticSamplers + n , desc_1_2 . pStaticSamplers + n , sizeof ( D3D12_STATIC_SAMPLER_DESC ) ) ;
}
}
}
# endif
2017-01-26 18:23:36 +00:00
if ( SUCCEEDED ( hr ) )
{
2024-02-05 18:08:59 +00:00
const CD3DX12_ROOT_SIGNATURE_DESC desc_1_0 ( desc_1_1 . NumParameters , pParameters_1_0 , desc_1_1 . NumStaticSamplers , pStaticSamplers = = nullptr ? desc_1_1 . pStaticSamplers : pStaticSamplers , desc_1_1 . Flags ) ;
2017-01-26 18:23:36 +00:00
hr = D3D12SerializeRootSignature ( & desc_1_0 , D3D_ROOT_SIGNATURE_VERSION_1 , ppBlob , ppErrorBlob ) ;
}
if ( pParameters )
{
for ( UINT n = 0 ; n < desc_1_1 . NumParameters ; n + + )
{
if ( desc_1_1 . pParameters [ n ] . ParameterType = = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE )
{
2021-04-21 00:07:33 +00:00
auto pDescriptorRanges_1_0 = pParameters_1_0 [ n ] . DescriptorTable . pDescriptorRanges ;
HeapFree ( GetProcessHeap ( ) , 0 , reinterpret_cast < void * > ( const_cast < D3D12_DESCRIPTOR_RANGE * > ( pDescriptorRanges_1_0 ) ) ) ;
2017-01-26 18:23:36 +00:00
}
}
HeapFree ( GetProcessHeap ( ) , 0 , pParameters ) ;
}
2024-02-05 18:08:59 +00:00
if ( pStaticSamplers )
{
HeapFree ( GetProcessHeap ( ) , 0 , pStaticSamplers ) ;
}
2017-01-26 18:23:36 +00:00
return hr ;
}
2024-02-05 18:08:59 +00:00
default :
break ;
2017-01-26 18:23:36 +00:00
}
break ;
case D3D_ROOT_SIGNATURE_VERSION_1_1 :
2024-02-05 18:08:59 +00:00
switch ( pRootSignatureDesc - > Version )
{
case D3D_ROOT_SIGNATURE_VERSION_1_0 :
case D3D_ROOT_SIGNATURE_VERSION_1_1 :
return D3D12SerializeVersionedRootSignature ( pRootSignatureDesc , ppBlob , ppErrorBlob ) ;
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
case D3D_ROOT_SIGNATURE_VERSION_1_2 :
{
HRESULT hr = S_OK ;
const D3D12_ROOT_SIGNATURE_DESC1 & desc_1_1 = pRootSignatureDesc - > Desc_1_1 ;
D3D12_STATIC_SAMPLER_DESC * pStaticSamplers = nullptr ;
if ( desc_1_1 . NumStaticSamplers > 0 )
{
const SIZE_T SamplersSize = sizeof ( D3D12_STATIC_SAMPLER_DESC ) * desc_1_1 . NumStaticSamplers ;
pStaticSamplers = static_cast < D3D12_STATIC_SAMPLER_DESC * > ( HeapAlloc ( GetProcessHeap ( ) , 0 , SamplersSize ) ) ;
if ( pStaticSamplers = = nullptr )
{
hr = E_OUTOFMEMORY ;
}
else
{
const D3D12_ROOT_SIGNATURE_DESC2 & desc_1_2 = pRootSignatureDesc - > Desc_1_2 ;
for ( UINT n = 0 ; n < desc_1_1 . NumStaticSamplers ; + + n )
{
if ( ( desc_1_2 . pStaticSamplers [ n ] . Flags & ~ D3D12_SAMPLER_FLAG_UINT_BORDER_COLOR ) ! = 0 )
{
hr = E_INVALIDARG ;
break ;
}
memcpy ( pStaticSamplers + n , desc_1_2 . pStaticSamplers + n , sizeof ( D3D12_STATIC_SAMPLER_DESC ) ) ;
}
}
}
if ( SUCCEEDED ( hr ) )
{
const CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC desc ( desc_1_1 . NumParameters , desc_1_1 . pParameters , desc_1_1 . NumStaticSamplers , pStaticSamplers = = nullptr ? desc_1_1 . pStaticSamplers : pStaticSamplers , desc_1_1 . Flags ) ;
hr = D3D12SerializeVersionedRootSignature ( & desc , ppBlob , ppErrorBlob ) ;
}
if ( pStaticSamplers )
{
HeapFree ( GetProcessHeap ( ) , 0 , pStaticSamplers ) ;
}
return hr ;
}
# endif
default :
break ;
}
break ;
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
2022-11-30 22:18:40 +00:00
case D3D_ROOT_SIGNATURE_VERSION_1_2 :
# endif
2024-02-05 18:08:59 +00:00
default :
2017-01-26 18:23:36 +00:00
return D3D12SerializeVersionedRootSignature ( pRootSignatureDesc , ppBlob , ppErrorBlob ) ;
}
return E_INVALIDARG ;
}
2024-02-05 18:08:59 +00:00
# ifdef __clang__
# pragma clang diagnostic pop
# endif
2017-04-20 01:13:34 +00:00
//------------------------------------------------------------------------------------------------
struct CD3DX12_RT_FORMAT_ARRAY : public D3D12_RT_FORMAT_ARRAY
{
2018-04-12 01:06:24 +00:00
CD3DX12_RT_FORMAT_ARRAY ( ) = default ;
2020-03-16 09:16:44 +00:00
explicit CD3DX12_RT_FORMAT_ARRAY ( const D3D12_RT_FORMAT_ARRAY & o ) noexcept
2017-04-20 01:13:34 +00:00
: D3D12_RT_FORMAT_ARRAY ( o )
{ }
2020-03-16 09:16:44 +00:00
explicit CD3DX12_RT_FORMAT_ARRAY ( _In_reads_ ( NumFormats ) const DXGI_FORMAT * pFormats , UINT NumFormats ) noexcept
2017-04-20 01:13:34 +00:00
{
NumRenderTargets = NumFormats ;
memcpy ( RTFormats , pFormats , sizeof ( RTFormats ) ) ;
// assumes ARRAY_SIZE(pFormats) == ARRAY_SIZE(RTFormats)
}
} ;
//------------------------------------------------------------------------------------------------
// Pipeline State Stream Helpers
//------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------
// Stream Subobjects, i.e. elements of a stream
2020-03-16 09:16:44 +00:00
struct DefaultSampleMask { operator UINT ( ) noexcept { return UINT_MAX ; } } ;
struct DefaultSampleDesc { operator DXGI_SAMPLE_DESC ( ) noexcept { return DXGI_SAMPLE_DESC { 1 , 0 } ; } } ;
2017-10-24 22:00:28 +00:00
2024-02-05 18:08:59 +00:00
# ifdef _MSC_VER
2017-04-20 01:13:34 +00:00
# pragma warning(push)
# pragma warning(disable : 4324)
2024-02-05 18:08:59 +00:00
# endif
2017-04-20 01:13:34 +00:00
template < typename InnerStructType , D3D12_PIPELINE_STATE_SUBOBJECT_TYPE Type , typename DefaultArg = InnerStructType >
class alignas ( void * ) CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT
{
private :
2022-02-20 22:47:07 +00:00
D3D12_PIPELINE_STATE_SUBOBJECT_TYPE pssType ;
InnerStructType pssInner ;
2017-04-20 01:13:34 +00:00
public :
2022-02-20 22:47:07 +00:00
CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT ( ) noexcept : pssType ( Type ) , pssInner ( DefaultArg ( ) ) { }
CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT ( InnerStructType const & i ) noexcept : pssType ( Type ) , pssInner ( i ) { }
CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT & operator = ( InnerStructType const & i ) noexcept { pssType = Type ; pssInner = i ; return * this ; }
operator InnerStructType const & ( ) const noexcept { return pssInner ; }
operator InnerStructType & ( ) noexcept { return pssInner ; }
InnerStructType * operator & ( ) noexcept { return & pssInner ; }
InnerStructType const * operator & ( ) const noexcept { return & pssInner ; }
2017-04-20 01:13:34 +00:00
} ;
2024-02-05 18:08:59 +00:00
# ifdef _MSC_VER
2017-04-20 01:13:34 +00:00
# pragma warning(pop)
2024-02-05 18:08:59 +00:00
# endif
2017-10-24 22:00:28 +00:00
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 ;
2020-03-18 04:45:33 +00:00
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT < D3D12_SHADER_BYTECODE , D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_AS > CD3DX12_PIPELINE_STATE_STREAM_AS ;
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT < D3D12_SHADER_BYTECODE , D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MS > CD3DX12_PIPELINE_STATE_STREAM_MS ;
2017-10-24 22:00:28 +00:00
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 ;
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606)
2022-11-19 21:03:20 +00:00
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT < CD3DX12_DEPTH_STENCIL_DESC2 , D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL2 , CD3DX12_DEFAULT > CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL2 ;
# endif
2017-10-24 22:00:28 +00:00
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 ;
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608)
2022-11-19 21:03:20 +00:00
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT < CD3DX12_RASTERIZER_DESC1 , D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER1 , CD3DX12_DEFAULT > CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER1 ;
# endif
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610)
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT < CD3DX12_RASTERIZER_DESC2 , D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER2 , CD3DX12_DEFAULT > CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER2 ;
# endif
2017-10-24 22:00:28 +00:00
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 , DefaultSampleDesc > CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC ;
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT < UINT , D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_MASK , DefaultSampleMask > 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 ;
typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT < CD3DX12_VIEW_INSTANCING_DESC , D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING , CD3DX12_DEFAULT > CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING ;
2017-04-20 01:13:34 +00:00
//------------------------------------------------------------------------------------------------
// 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 & ) { }
2020-03-18 04:45:33 +00:00
virtual void ASCb ( const D3D12_SHADER_BYTECODE & ) { }
virtual void MSCb ( const D3D12_SHADER_BYTECODE & ) { }
2017-04-20 01:13:34 +00:00
virtual void BlendStateCb ( const D3D12_BLEND_DESC & ) { }
virtual void DepthStencilStateCb ( const D3D12_DEPTH_STENCIL_DESC & ) { }
virtual void DepthStencilState1Cb ( const D3D12_DEPTH_STENCIL_DESC1 & ) { }
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606)
2022-11-19 21:03:20 +00:00
virtual void DepthStencilState2Cb ( const D3D12_DEPTH_STENCIL_DESC2 & ) { }
# endif
2017-04-20 01:13:34 +00:00
virtual void DSVFormatCb ( DXGI_FORMAT ) { }
virtual void RasterizerStateCb ( const D3D12_RASTERIZER_DESC & ) { }
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608)
virtual void RasterizerState1Cb ( const D3D12_RASTERIZER_DESC1 & ) { }
# endif
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610)
virtual void RasterizerState2Cb ( const D3D12_RASTERIZER_DESC2 & ) { }
2022-11-19 21:03:20 +00:00
# endif
2017-04-20 01:13:34 +00:00
virtual void RTVFormatsCb ( const D3D12_RT_FORMAT_ARRAY & ) { }
virtual void SampleDescCb ( const DXGI_SAMPLE_DESC & ) { }
virtual void SampleMaskCb ( UINT ) { }
2017-10-24 22:00:28 +00:00
virtual void ViewInstancingCb ( const D3D12_VIEW_INSTANCING_DESC & ) { }
2017-04-20 01:13:34 +00:00
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*/ ) { }
2024-05-17 23:56:19 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 613)
virtual void FinalizeCb ( ) { }
# endif
2017-04-20 01:13:34 +00:00
2018-06-22 23:55:00 +00:00
virtual ~ ID3DX12PipelineParserCallbacks ( ) = default ;
2017-04-20 01:13:34 +00:00
} ;
2022-11-19 21:03:20 +00:00
struct D3DX12_MESH_SHADER_PIPELINE_STATE_DESC
{
ID3D12RootSignature * pRootSignature ;
D3D12_SHADER_BYTECODE AS ;
D3D12_SHADER_BYTECODE MS ;
D3D12_SHADER_BYTECODE PS ;
D3D12_BLEND_DESC BlendState ;
UINT SampleMask ;
D3D12_RASTERIZER_DESC RasterizerState ;
D3D12_DEPTH_STENCIL_DESC DepthStencilState ;
D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType ;
UINT NumRenderTargets ;
DXGI_FORMAT RTVFormats [ D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT ] ;
DXGI_FORMAT DSVFormat ;
DXGI_SAMPLE_DESC SampleDesc ;
UINT NodeMask ;
D3D12_CACHED_PIPELINE_STATE CachedPSO ;
D3D12_PIPELINE_STATE_FLAGS Flags ;
} ;
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610)
// Use CD3DX12_PIPELINE_STATE_STREAM5 for D3D12_RASTERIZER_DESC2 when CheckFeatureSupport returns true for Options19::RasterizerDesc2Supported is true
// Use CD3DX12_PIPELINE_STATE_STREAM4 for D3D12_RASTERIZER_DESC1 when CheckFeatureSupport returns true for Options16::DynamicDepthBiasSupported is true
// Use CD3DX12_PIPELINE_STATE_STREAM3 for D3D12_DEPTH_STENCIL_DESC2 when CheckFeatureSupport returns true for Options14::IndependentFrontAndBackStencilSupported is true
// Use CD3DX12_PIPELINE_STATE_STREAM2 for OS Build 19041+ (where there is a new mesh shader pipeline).
// Use CD3DX12_PIPELINE_STATE_STREAM1 for OS Build 16299+ (where there is a new view instancing subobject).
// Use CD3DX12_PIPELINE_STATE_STREAM for OS Build 15063+ support.
struct CD3DX12_PIPELINE_STATE_STREAM5
{
CD3DX12_PIPELINE_STATE_STREAM5 ( ) = default ;
// Mesh and amplification shaders must be set manually, since they do not have representation in D3D12_GRAPHICS_PIPELINE_STATE_DESC
CD3DX12_PIPELINE_STATE_STREAM5 ( const D3D12_GRAPHICS_PIPELINE_STATE_DESC & Desc ) noexcept
: 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_DESC2 ( Desc . DepthStencilState ) )
, DSVFormat ( Desc . DSVFormat )
, RasterizerState ( CD3DX12_RASTERIZER_DESC2 ( Desc . RasterizerState ) )
, RTVFormats ( CD3DX12_RT_FORMAT_ARRAY ( Desc . RTVFormats , Desc . NumRenderTargets ) )
, SampleDesc ( Desc . SampleDesc )
, SampleMask ( Desc . SampleMask )
, CachedPSO ( Desc . CachedPSO )
, ViewInstancingDesc ( CD3DX12_VIEW_INSTANCING_DESC ( CD3DX12_DEFAULT ( ) ) )
{ }
CD3DX12_PIPELINE_STATE_STREAM5 ( const D3DX12_MESH_SHADER_PIPELINE_STATE_DESC & Desc ) noexcept
: Flags ( Desc . Flags )
, NodeMask ( Desc . NodeMask )
, pRootSignature ( Desc . pRootSignature )
, PrimitiveTopologyType ( Desc . PrimitiveTopologyType )
, PS ( Desc . PS )
, AS ( Desc . AS )
, MS ( Desc . MS )
, BlendState ( CD3DX12_BLEND_DESC ( Desc . BlendState ) )
, DepthStencilState ( CD3DX12_DEPTH_STENCIL_DESC2 ( Desc . DepthStencilState ) )
, DSVFormat ( Desc . DSVFormat )
, RasterizerState ( CD3DX12_RASTERIZER_DESC2 ( Desc . RasterizerState ) )
, RTVFormats ( CD3DX12_RT_FORMAT_ARRAY ( Desc . RTVFormats , Desc . NumRenderTargets ) )
, SampleDesc ( Desc . SampleDesc )
, SampleMask ( Desc . SampleMask )
, CachedPSO ( Desc . CachedPSO )
, ViewInstancingDesc ( CD3DX12_VIEW_INSTANCING_DESC ( CD3DX12_DEFAULT ( ) ) )
{ }
CD3DX12_PIPELINE_STATE_STREAM5 ( const D3D12_COMPUTE_PIPELINE_STATE_DESC & Desc ) noexcept
: Flags ( Desc . Flags )
, NodeMask ( Desc . NodeMask )
, pRootSignature ( Desc . pRootSignature )
, CS ( CD3DX12_SHADER_BYTECODE ( Desc . CS ) )
, CachedPSO ( Desc . CachedPSO )
{
static_cast < D3D12_DEPTH_STENCIL_DESC2 & > ( DepthStencilState ) . DepthEnable = false ;
}
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_AS AS ;
CD3DX12_PIPELINE_STATE_STREAM_MS MS ;
CD3DX12_PIPELINE_STATE_STREAM_CS CS ;
CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC BlendState ;
CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL2 DepthStencilState ;
CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT DSVFormat ;
CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER2 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 ;
CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING ViewInstancingDesc ;
D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0 ( ) const noexcept
{
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_DESC2 ( D3D12_DEPTH_STENCIL_DESC2 ( this - > DepthStencilState ) ) ;
D . DSVFormat = this - > DSVFormat ;
D . RasterizerState = CD3DX12_RASTERIZER_DESC2 ( D3D12_RASTERIZER_DESC2 ( 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 noexcept
{
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 ;
}
} ;
# endif // D3D12_SDK_VERSION >= 610
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608)
2022-11-19 21:03:20 +00:00
// Use CD3DX12_PIPELINE_STATE_STREAM4 for D3D12_RASTERIZER_DESC1 when CheckFeatureSupport returns true for Options16::DynamicDepthBiasSupported is true
// Use CD3DX12_PIPELINE_STATE_STREAM3 for D3D12_DEPTH_STENCIL_DESC2 when CheckFeatureSupport returns true for Options14::IndependentFrontAndBackStencilSupported is true
// Use CD3DX12_PIPELINE_STATE_STREAM2 for OS Build 19041+ (where there is a new mesh shader pipeline).
// Use CD3DX12_PIPELINE_STATE_STREAM1 for OS Build 16299+ (where there is a new view instancing subobject).
// Use CD3DX12_PIPELINE_STATE_STREAM for OS Build 15063+ support.
struct CD3DX12_PIPELINE_STATE_STREAM4
{
CD3DX12_PIPELINE_STATE_STREAM4 ( ) = default ;
// Mesh and amplification shaders must be set manually, since they do not have representation in D3D12_GRAPHICS_PIPELINE_STATE_DESC
CD3DX12_PIPELINE_STATE_STREAM4 ( const D3D12_GRAPHICS_PIPELINE_STATE_DESC & Desc ) noexcept
: 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_DESC2 ( Desc . DepthStencilState ) )
, DSVFormat ( Desc . DSVFormat )
, RasterizerState ( CD3DX12_RASTERIZER_DESC1 ( Desc . RasterizerState ) )
, RTVFormats ( CD3DX12_RT_FORMAT_ARRAY ( Desc . RTVFormats , Desc . NumRenderTargets ) )
, SampleDesc ( Desc . SampleDesc )
, SampleMask ( Desc . SampleMask )
, CachedPSO ( Desc . CachedPSO )
, ViewInstancingDesc ( CD3DX12_VIEW_INSTANCING_DESC ( CD3DX12_DEFAULT ( ) ) )
{ }
CD3DX12_PIPELINE_STATE_STREAM4 ( const D3DX12_MESH_SHADER_PIPELINE_STATE_DESC & Desc ) noexcept
: Flags ( Desc . Flags )
, NodeMask ( Desc . NodeMask )
, pRootSignature ( Desc . pRootSignature )
, PrimitiveTopologyType ( Desc . PrimitiveTopologyType )
, PS ( Desc . PS )
, AS ( Desc . AS )
, MS ( Desc . MS )
, BlendState ( CD3DX12_BLEND_DESC ( Desc . BlendState ) )
, DepthStencilState ( CD3DX12_DEPTH_STENCIL_DESC2 ( Desc . DepthStencilState ) )
, DSVFormat ( Desc . DSVFormat )
, RasterizerState ( CD3DX12_RASTERIZER_DESC1 ( Desc . RasterizerState ) )
, RTVFormats ( CD3DX12_RT_FORMAT_ARRAY ( Desc . RTVFormats , Desc . NumRenderTargets ) )
, SampleDesc ( Desc . SampleDesc )
, SampleMask ( Desc . SampleMask )
, CachedPSO ( Desc . CachedPSO )
, ViewInstancingDesc ( CD3DX12_VIEW_INSTANCING_DESC ( CD3DX12_DEFAULT ( ) ) )
{ }
CD3DX12_PIPELINE_STATE_STREAM4 ( const D3D12_COMPUTE_PIPELINE_STATE_DESC & Desc ) noexcept
: Flags ( Desc . Flags )
, NodeMask ( Desc . NodeMask )
, pRootSignature ( Desc . pRootSignature )
, CS ( CD3DX12_SHADER_BYTECODE ( Desc . CS ) )
, CachedPSO ( Desc . CachedPSO )
{
static_cast < D3D12_DEPTH_STENCIL_DESC2 & > ( DepthStencilState ) . DepthEnable = false ;
}
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_AS AS ;
CD3DX12_PIPELINE_STATE_STREAM_MS MS ;
CD3DX12_PIPELINE_STATE_STREAM_CS CS ;
CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC BlendState ;
CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL2 DepthStencilState ;
CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT DSVFormat ;
CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER1 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 ;
CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING ViewInstancingDesc ;
D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0 ( ) const noexcept
{
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_DESC2 ( D3D12_DEPTH_STENCIL_DESC2 ( this - > DepthStencilState ) ) ;
D . DSVFormat = this - > DSVFormat ;
D . RasterizerState = CD3DX12_RASTERIZER_DESC1 ( D3D12_RASTERIZER_DESC1 ( 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 noexcept
{
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 ;
}
} ;
2023-04-24 20:52:49 +00:00
# endif // D3D12_SDK_VERSION >= 608
2022-11-19 21:03:20 +00:00
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606)
2022-11-19 21:03:20 +00:00
// Use CD3DX12_PIPELINE_STATE_STREAM3 for D3D12_DEPTH_STENCIL_DESC2 when CheckFeatureSupport returns true for Options14::IndependentFrontAndBackStencilSupported is true
// Use CD3DX12_PIPELINE_STATE_STREAM2 for OS Build 19041+ (where there is a new mesh shader pipeline).
// Use CD3DX12_PIPELINE_STATE_STREAM1 for OS Build 16299+ (where there is a new view instancing subobject).
// Use CD3DX12_PIPELINE_STATE_STREAM for OS Build 15063+ support.
struct CD3DX12_PIPELINE_STATE_STREAM3
2020-03-18 04:45:33 +00:00
{
2022-11-19 21:03:20 +00:00
CD3DX12_PIPELINE_STATE_STREAM3 ( ) = default ;
// Mesh and amplification shaders must be set manually, since they do not have representation in D3D12_GRAPHICS_PIPELINE_STATE_DESC
CD3DX12_PIPELINE_STATE_STREAM3 ( const D3D12_GRAPHICS_PIPELINE_STATE_DESC & Desc ) noexcept
: 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_DESC2 ( 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 )
, ViewInstancingDesc ( CD3DX12_VIEW_INSTANCING_DESC ( CD3DX12_DEFAULT ( ) ) )
{ }
CD3DX12_PIPELINE_STATE_STREAM3 ( const D3DX12_MESH_SHADER_PIPELINE_STATE_DESC & Desc ) noexcept
: Flags ( Desc . Flags )
, NodeMask ( Desc . NodeMask )
, pRootSignature ( Desc . pRootSignature )
, PrimitiveTopologyType ( Desc . PrimitiveTopologyType )
, PS ( Desc . PS )
, AS ( Desc . AS )
, MS ( Desc . MS )
, BlendState ( CD3DX12_BLEND_DESC ( Desc . BlendState ) )
, DepthStencilState ( CD3DX12_DEPTH_STENCIL_DESC2 ( 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 )
, ViewInstancingDesc ( CD3DX12_VIEW_INSTANCING_DESC ( CD3DX12_DEFAULT ( ) ) )
{ }
CD3DX12_PIPELINE_STATE_STREAM3 ( const D3D12_COMPUTE_PIPELINE_STATE_DESC & Desc ) noexcept
: Flags ( Desc . Flags )
, NodeMask ( Desc . NodeMask )
, pRootSignature ( Desc . pRootSignature )
, CS ( CD3DX12_SHADER_BYTECODE ( Desc . CS ) )
, CachedPSO ( Desc . CachedPSO )
{
static_cast < D3D12_DEPTH_STENCIL_DESC2 & > ( DepthStencilState ) . DepthEnable = false ;
}
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_AS AS ;
CD3DX12_PIPELINE_STATE_STREAM_MS MS ;
CD3DX12_PIPELINE_STATE_STREAM_CS CS ;
CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC BlendState ;
CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL2 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 ;
CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING ViewInstancingDesc ;
D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0 ( ) const noexcept
{
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_DESC2 ( D3D12_DEPTH_STENCIL_DESC2 ( 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 noexcept
{
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 ;
}
2020-03-18 04:45:33 +00:00
} ;
2023-04-24 20:52:49 +00:00
# endif // D3D12_SDK_VERSION >= 606
2020-03-18 04:45:33 +00:00
2020-07-16 00:41:45 +00:00
// CD3DX12_PIPELINE_STATE_STREAM2 Works on OS Build 19041+ (where there is a new mesh shader pipeline).
// Use CD3DX12_PIPELINE_STATE_STREAM1 for OS Build 16299+ (where there is a new view instancing subobject).
// Use CD3DX12_PIPELINE_STATE_STREAM for OS Build 15063+ support.
2020-03-18 04:45:33 +00:00
struct CD3DX12_PIPELINE_STATE_STREAM2
{
CD3DX12_PIPELINE_STATE_STREAM2 ( ) = default ;
// Mesh and amplification shaders must be set manually, since they do not have representation in D3D12_GRAPHICS_PIPELINE_STATE_DESC
CD3DX12_PIPELINE_STATE_STREAM2 ( const D3D12_GRAPHICS_PIPELINE_STATE_DESC & Desc ) noexcept
: 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 )
, ViewInstancingDesc ( CD3DX12_VIEW_INSTANCING_DESC ( CD3DX12_DEFAULT ( ) ) )
{ }
CD3DX12_PIPELINE_STATE_STREAM2 ( const D3DX12_MESH_SHADER_PIPELINE_STATE_DESC & Desc ) noexcept
: Flags ( Desc . Flags )
, NodeMask ( Desc . NodeMask )
, pRootSignature ( Desc . pRootSignature )
, PrimitiveTopologyType ( Desc . PrimitiveTopologyType )
, PS ( Desc . PS )
2020-04-22 22:51:14 +00:00
, AS ( Desc . AS )
, MS ( Desc . MS )
2020-03-18 04:45:33 +00:00
, 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 )
, ViewInstancingDesc ( CD3DX12_VIEW_INSTANCING_DESC ( CD3DX12_DEFAULT ( ) ) )
{ }
CD3DX12_PIPELINE_STATE_STREAM2 ( const D3D12_COMPUTE_PIPELINE_STATE_DESC & Desc ) noexcept
: Flags ( Desc . Flags )
, NodeMask ( Desc . NodeMask )
, pRootSignature ( Desc . pRootSignature )
, CS ( CD3DX12_SHADER_BYTECODE ( Desc . CS ) )
, CachedPSO ( Desc . CachedPSO )
{
static_cast < D3D12_DEPTH_STENCIL_DESC1 & > ( DepthStencilState ) . DepthEnable = false ;
}
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_AS AS ;
CD3DX12_PIPELINE_STATE_STREAM_MS MS ;
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 ;
CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING ViewInstancingDesc ;
D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0 ( ) const noexcept
{
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 noexcept
{
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 ;
}
} ;
2020-07-16 00:41:45 +00:00
// CD3DX12_PIPELINE_STATE_STREAM1 Works on OS Build 16299+ (where there is a new view instancing subobject).
// Use CD3DX12_PIPELINE_STATE_STREAM for OS Build 15063+ support.
2017-10-24 22:00:28 +00:00
struct CD3DX12_PIPELINE_STATE_STREAM1
{
2018-04-12 01:06:24 +00:00
CD3DX12_PIPELINE_STATE_STREAM1 ( ) = default ;
2020-03-18 04:45:33 +00:00
// Mesh and amplification shaders must be set manually, since they do not have representation in D3D12_GRAPHICS_PIPELINE_STATE_DESC
2020-03-16 09:16:44 +00:00
CD3DX12_PIPELINE_STATE_STREAM1 ( const D3D12_GRAPHICS_PIPELINE_STATE_DESC & Desc ) noexcept
2017-10-24 22:00:28 +00:00
: 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 )
, ViewInstancingDesc ( CD3DX12_VIEW_INSTANCING_DESC ( CD3DX12_DEFAULT ( ) ) )
{ }
2020-03-18 04:45:33 +00:00
CD3DX12_PIPELINE_STATE_STREAM1 ( const D3DX12_MESH_SHADER_PIPELINE_STATE_DESC & Desc ) noexcept
: Flags ( Desc . Flags )
, NodeMask ( Desc . NodeMask )
, pRootSignature ( Desc . pRootSignature )
, PrimitiveTopologyType ( Desc . PrimitiveTopologyType )
, 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 )
, ViewInstancingDesc ( CD3DX12_VIEW_INSTANCING_DESC ( CD3DX12_DEFAULT ( ) ) )
{ }
2020-03-16 09:16:44 +00:00
CD3DX12_PIPELINE_STATE_STREAM1 ( const D3D12_COMPUTE_PIPELINE_STATE_DESC & Desc ) noexcept
2017-10-24 22:00:28 +00:00
: Flags ( Desc . Flags )
, NodeMask ( Desc . NodeMask )
, pRootSignature ( Desc . pRootSignature )
, CS ( CD3DX12_SHADER_BYTECODE ( Desc . CS ) )
, CachedPSO ( Desc . CachedPSO )
2018-04-12 01:06:24 +00:00
{
static_cast < D3D12_DEPTH_STENCIL_DESC1 & > ( DepthStencilState ) . DepthEnable = false ;
}
2017-10-24 22:00:28 +00:00
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 ;
CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING ViewInstancingDesc ;
2020-03-16 09:16:44 +00:00
D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0 ( ) const noexcept
2017-10-24 22:00:28 +00:00
{
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 ;
}
2020-03-16 09:16:44 +00:00
D3D12_COMPUTE_PIPELINE_STATE_DESC ComputeDescV0 ( ) const noexcept
2017-10-24 22:00:28 +00:00
{
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 ;
}
} ;
2021-10-05 19:52:45 +00:00
2020-03-18 04:45:33 +00:00
struct CD3DX12_PIPELINE_MESH_STATE_STREAM
{
CD3DX12_PIPELINE_MESH_STATE_STREAM ( ) = default ;
CD3DX12_PIPELINE_MESH_STATE_STREAM ( const D3DX12_MESH_SHADER_PIPELINE_STATE_DESC & Desc ) noexcept
: Flags ( Desc . Flags )
, NodeMask ( Desc . NodeMask )
, pRootSignature ( Desc . pRootSignature )
2024-05-17 23:56:19 +00:00
, PrimitiveTopologyType ( Desc . PrimitiveTopologyType )
2020-03-18 04:45:33 +00:00
, PS ( Desc . PS )
2020-04-22 22:51:14 +00:00
, AS ( Desc . AS )
, MS ( Desc . MS )
2020-03-18 04:45:33 +00:00
, 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 )
, ViewInstancingDesc ( CD3DX12_VIEW_INSTANCING_DESC ( CD3DX12_DEFAULT ( ) ) )
{ }
CD3DX12_PIPELINE_STATE_STREAM_FLAGS Flags ;
CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK NodeMask ;
CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE pRootSignature ;
2024-05-17 23:56:19 +00:00
CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY PrimitiveTopologyType ;
2020-03-18 04:45:33 +00:00
CD3DX12_PIPELINE_STATE_STREAM_PS PS ;
CD3DX12_PIPELINE_STATE_STREAM_AS AS ;
CD3DX12_PIPELINE_STATE_STREAM_MS MS ;
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 ;
CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING ViewInstancingDesc ;
D3DX12_MESH_SHADER_PIPELINE_STATE_DESC MeshShaderDescV0 ( ) const noexcept
{
D3DX12_MESH_SHADER_PIPELINE_STATE_DESC D ;
2024-05-17 23:56:19 +00:00
D . Flags = this - > Flags ;
D . NodeMask = this - > NodeMask ;
D . pRootSignature = this - > pRootSignature ;
D . PrimitiveTopologyType = this - > PrimitiveTopologyType ;
D . PS = this - > PS ;
D . AS = this - > AS ;
D . MS = this - > MS ;
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 ;
2020-03-18 04:45:33 +00:00
memcpy ( D . RTVFormats , D3D12_RT_FORMAT_ARRAY ( this - > RTVFormats ) . RTFormats , sizeof ( D . RTVFormats ) ) ;
2024-05-17 23:56:19 +00:00
D . SampleDesc = this - > SampleDesc ;
D . SampleMask = this - > SampleMask ;
D . CachedPSO = this - > CachedPSO ;
2020-03-18 04:45:33 +00:00
return D ;
}
} ;
2020-07-16 00:41:45 +00:00
// CD3DX12_PIPELINE_STATE_STREAM works on OS Build 15063+ but does not support new subobject(s) added in OS Build 16299+.
2017-10-24 22:00:28 +00:00
// See CD3DX12_PIPELINE_STATE_STREAM1 for instance.
2017-04-20 01:13:34 +00:00
struct CD3DX12_PIPELINE_STATE_STREAM
{
2018-04-12 01:06:24 +00:00
CD3DX12_PIPELINE_STATE_STREAM ( ) = default ;
2020-03-16 09:16:44 +00:00
CD3DX12_PIPELINE_STATE_STREAM ( const D3D12_GRAPHICS_PIPELINE_STATE_DESC & Desc ) noexcept
2017-04-20 01:13:34 +00:00
: 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 )
{ }
2020-03-16 09:16:44 +00:00
CD3DX12_PIPELINE_STATE_STREAM ( const D3D12_COMPUTE_PIPELINE_STATE_DESC & Desc ) noexcept
2017-04-20 01:13:34 +00:00
: 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 ;
2020-03-16 09:16:44 +00:00
D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0 ( ) const noexcept
2017-04-20 01:13:34 +00:00
{
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 ;
}
2020-03-16 09:16:44 +00:00
D3D12_COMPUTE_PIPELINE_STATE_DESC ComputeDescV0 ( ) const noexcept
2017-04-20 01:13:34 +00:00
{
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 ;
}
} ;
2020-03-18 04:45:33 +00:00
struct CD3DX12_PIPELINE_STATE_STREAM2_PARSE_HELPER : public ID3DX12PipelineParserCallbacks
{
CD3DX12_PIPELINE_STATE_STREAM2 PipelineStream ;
CD3DX12_PIPELINE_STATE_STREAM2_PARSE_HELPER ( ) noexcept
: SeenDSS ( false )
{
// Adjust defaults to account for absent members.
PipelineStream . PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE ;
// Depth disabled if no DSV format specified.
static_cast < D3D12_DEPTH_STENCIL_DESC1 & > ( PipelineStream . DepthStencilState ) . DepthEnable = false ;
}
// ID3DX12PipelineParserCallbacks
void FlagsCb ( D3D12_PIPELINE_STATE_FLAGS Flags ) override { PipelineStream . Flags = Flags ; }
void NodeMaskCb ( UINT NodeMask ) override { PipelineStream . NodeMask = NodeMask ; }
void RootSignatureCb ( ID3D12RootSignature * pRootSignature ) override { PipelineStream . pRootSignature = pRootSignature ; }
void InputLayoutCb ( const D3D12_INPUT_LAYOUT_DESC & InputLayout ) override { PipelineStream . InputLayout = InputLayout ; }
void IBStripCutValueCb ( D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue ) override { PipelineStream . IBStripCutValue = IBStripCutValue ; }
void PrimitiveTopologyTypeCb ( D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType ) override { PipelineStream . PrimitiveTopologyType = PrimitiveTopologyType ; }
void VSCb ( const D3D12_SHADER_BYTECODE & VS ) override { PipelineStream . VS = VS ; }
void GSCb ( const D3D12_SHADER_BYTECODE & GS ) override { PipelineStream . GS = GS ; }
void StreamOutputCb ( const D3D12_STREAM_OUTPUT_DESC & StreamOutput ) override { PipelineStream . StreamOutput = StreamOutput ; }
void HSCb ( const D3D12_SHADER_BYTECODE & HS ) override { PipelineStream . HS = HS ; }
void DSCb ( const D3D12_SHADER_BYTECODE & DS ) override { PipelineStream . DS = DS ; }
void PSCb ( const D3D12_SHADER_BYTECODE & PS ) override { PipelineStream . PS = PS ; }
void CSCb ( const D3D12_SHADER_BYTECODE & CS ) override { PipelineStream . CS = CS ; }
void ASCb ( const D3D12_SHADER_BYTECODE & AS ) override { PipelineStream . AS = AS ; }
void MSCb ( const D3D12_SHADER_BYTECODE & MS ) override { PipelineStream . MS = MS ; }
void BlendStateCb ( const D3D12_BLEND_DESC & BlendState ) override { PipelineStream . BlendState = CD3DX12_BLEND_DESC ( BlendState ) ; }
void DepthStencilStateCb ( const D3D12_DEPTH_STENCIL_DESC & DepthStencilState ) override
{
PipelineStream . DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1 ( DepthStencilState ) ;
SeenDSS = true ;
}
void DepthStencilState1Cb ( const D3D12_DEPTH_STENCIL_DESC1 & DepthStencilState ) override
{
PipelineStream . DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1 ( DepthStencilState ) ;
SeenDSS = true ;
}
void DSVFormatCb ( DXGI_FORMAT DSVFormat ) override
{
PipelineStream . DSVFormat = DSVFormat ;
if ( ! SeenDSS & & DSVFormat ! = DXGI_FORMAT_UNKNOWN )
{
// Re-enable depth for the default state.
static_cast < D3D12_DEPTH_STENCIL_DESC1 & > ( PipelineStream . DepthStencilState ) . DepthEnable = true ;
}
}
void RasterizerStateCb ( const D3D12_RASTERIZER_DESC & RasterizerState ) override { PipelineStream . RasterizerState = CD3DX12_RASTERIZER_DESC ( RasterizerState ) ; }
void RTVFormatsCb ( const D3D12_RT_FORMAT_ARRAY & RTVFormats ) override { PipelineStream . RTVFormats = RTVFormats ; }
void SampleDescCb ( const DXGI_SAMPLE_DESC & SampleDesc ) override { PipelineStream . SampleDesc = SampleDesc ; }
void SampleMaskCb ( UINT SampleMask ) override { PipelineStream . SampleMask = SampleMask ; }
void ViewInstancingCb ( const D3D12_VIEW_INSTANCING_DESC & ViewInstancingDesc ) override { PipelineStream . ViewInstancingDesc = CD3DX12_VIEW_INSTANCING_DESC ( ViewInstancingDesc ) ; }
void CachedPSOCb ( const D3D12_CACHED_PIPELINE_STATE & CachedPSO ) override { PipelineStream . CachedPSO = CachedPSO ; }
private :
bool SeenDSS ;
} ;
2021-10-05 19:52:45 +00:00
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606)
2022-11-19 21:03:20 +00:00
struct CD3DX12_PIPELINE_STATE_STREAM3_PARSE_HELPER : public ID3DX12PipelineParserCallbacks
{
CD3DX12_PIPELINE_STATE_STREAM3 PipelineStream ;
CD3DX12_PIPELINE_STATE_STREAM3_PARSE_HELPER ( ) noexcept
: SeenDSS ( false )
{
// Adjust defaults to account for absent members.
PipelineStream . PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE ;
// Depth disabled if no DSV format specified.
static_cast < D3D12_DEPTH_STENCIL_DESC2 & > ( PipelineStream . DepthStencilState ) . DepthEnable = false ;
}
// ID3DX12PipelineParserCallbacks
void FlagsCb ( D3D12_PIPELINE_STATE_FLAGS Flags ) override { PipelineStream . Flags = Flags ; }
void NodeMaskCb ( UINT NodeMask ) override { PipelineStream . NodeMask = NodeMask ; }
void RootSignatureCb ( ID3D12RootSignature * pRootSignature ) override { PipelineStream . pRootSignature = pRootSignature ; }
void InputLayoutCb ( const D3D12_INPUT_LAYOUT_DESC & InputLayout ) override { PipelineStream . InputLayout = InputLayout ; }
void IBStripCutValueCb ( D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue ) override { PipelineStream . IBStripCutValue = IBStripCutValue ; }
void PrimitiveTopologyTypeCb ( D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType ) override { PipelineStream . PrimitiveTopologyType = PrimitiveTopologyType ; }
void VSCb ( const D3D12_SHADER_BYTECODE & VS ) override { PipelineStream . VS = VS ; }
void GSCb ( const D3D12_SHADER_BYTECODE & GS ) override { PipelineStream . GS = GS ; }
void StreamOutputCb ( const D3D12_STREAM_OUTPUT_DESC & StreamOutput ) override { PipelineStream . StreamOutput = StreamOutput ; }
void HSCb ( const D3D12_SHADER_BYTECODE & HS ) override { PipelineStream . HS = HS ; }
void DSCb ( const D3D12_SHADER_BYTECODE & DS ) override { PipelineStream . DS = DS ; }
void PSCb ( const D3D12_SHADER_BYTECODE & PS ) override { PipelineStream . PS = PS ; }
void CSCb ( const D3D12_SHADER_BYTECODE & CS ) override { PipelineStream . CS = CS ; }
void ASCb ( const D3D12_SHADER_BYTECODE & AS ) override { PipelineStream . AS = AS ; }
void MSCb ( const D3D12_SHADER_BYTECODE & MS ) override { PipelineStream . MS = MS ; }
void BlendStateCb ( const D3D12_BLEND_DESC & BlendState ) override { PipelineStream . BlendState = CD3DX12_BLEND_DESC ( BlendState ) ; }
void DepthStencilStateCb ( const D3D12_DEPTH_STENCIL_DESC & DepthStencilState ) override
{
PipelineStream . DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2 ( DepthStencilState ) ;
SeenDSS = true ;
}
void DepthStencilState1Cb ( const D3D12_DEPTH_STENCIL_DESC1 & DepthStencilState ) override
{
PipelineStream . DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2 ( DepthStencilState ) ;
SeenDSS = true ;
}
void DepthStencilState2Cb ( const D3D12_DEPTH_STENCIL_DESC2 & DepthStencilState ) override
{
PipelineStream . DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2 ( DepthStencilState ) ;
SeenDSS = true ;
}
void DSVFormatCb ( DXGI_FORMAT DSVFormat ) override
{
PipelineStream . DSVFormat = DSVFormat ;
if ( ! SeenDSS & & DSVFormat ! = DXGI_FORMAT_UNKNOWN )
{
// Re-enable depth for the default state.
static_cast < D3D12_DEPTH_STENCIL_DESC2 & > ( PipelineStream . DepthStencilState ) . DepthEnable = true ;
}
}
void RasterizerStateCb ( const D3D12_RASTERIZER_DESC & RasterizerState ) override { PipelineStream . RasterizerState = CD3DX12_RASTERIZER_DESC ( RasterizerState ) ; }
void RTVFormatsCb ( const D3D12_RT_FORMAT_ARRAY & RTVFormats ) override { PipelineStream . RTVFormats = RTVFormats ; }
void SampleDescCb ( const DXGI_SAMPLE_DESC & SampleDesc ) override { PipelineStream . SampleDesc = SampleDesc ; }
void SampleMaskCb ( UINT SampleMask ) override { PipelineStream . SampleMask = SampleMask ; }
void ViewInstancingCb ( const D3D12_VIEW_INSTANCING_DESC & ViewInstancingDesc ) override { PipelineStream . ViewInstancingDesc = CD3DX12_VIEW_INSTANCING_DESC ( ViewInstancingDesc ) ; }
void CachedPSOCb ( const D3D12_CACHED_PIPELINE_STATE & CachedPSO ) override { PipelineStream . CachedPSO = CachedPSO ; }
private :
bool SeenDSS ;
} ;
2023-04-24 20:52:49 +00:00
# endif // D3D12_SDK_VERSION >= 606
2022-11-19 21:03:20 +00:00
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608)
2022-11-19 21:03:20 +00:00
struct CD3DX12_PIPELINE_STATE_STREAM4_PARSE_HELPER : public ID3DX12PipelineParserCallbacks
{
CD3DX12_PIPELINE_STATE_STREAM4 PipelineStream ;
CD3DX12_PIPELINE_STATE_STREAM4_PARSE_HELPER ( ) noexcept
: SeenDSS ( false )
{
// Adjust defaults to account for absent members.
PipelineStream . PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE ;
// Depth disabled if no DSV format specified.
static_cast < D3D12_DEPTH_STENCIL_DESC2 & > ( PipelineStream . DepthStencilState ) . DepthEnable = false ;
}
// ID3DX12PipelineParserCallbacks
void FlagsCb ( D3D12_PIPELINE_STATE_FLAGS Flags ) override { PipelineStream . Flags = Flags ; }
void NodeMaskCb ( UINT NodeMask ) override { PipelineStream . NodeMask = NodeMask ; }
void RootSignatureCb ( ID3D12RootSignature * pRootSignature ) override { PipelineStream . pRootSignature = pRootSignature ; }
void InputLayoutCb ( const D3D12_INPUT_LAYOUT_DESC & InputLayout ) override { PipelineStream . InputLayout = InputLayout ; }
void IBStripCutValueCb ( D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue ) override { PipelineStream . IBStripCutValue = IBStripCutValue ; }
void PrimitiveTopologyTypeCb ( D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType ) override { PipelineStream . PrimitiveTopologyType = PrimitiveTopologyType ; }
void VSCb ( const D3D12_SHADER_BYTECODE & VS ) override { PipelineStream . VS = VS ; }
void GSCb ( const D3D12_SHADER_BYTECODE & GS ) override { PipelineStream . GS = GS ; }
void StreamOutputCb ( const D3D12_STREAM_OUTPUT_DESC & StreamOutput ) override { PipelineStream . StreamOutput = StreamOutput ; }
void HSCb ( const D3D12_SHADER_BYTECODE & HS ) override { PipelineStream . HS = HS ; }
void DSCb ( const D3D12_SHADER_BYTECODE & DS ) override { PipelineStream . DS = DS ; }
void PSCb ( const D3D12_SHADER_BYTECODE & PS ) override { PipelineStream . PS = PS ; }
void CSCb ( const D3D12_SHADER_BYTECODE & CS ) override { PipelineStream . CS = CS ; }
void ASCb ( const D3D12_SHADER_BYTECODE & AS ) override { PipelineStream . AS = AS ; }
void MSCb ( const D3D12_SHADER_BYTECODE & MS ) override { PipelineStream . MS = MS ; }
void BlendStateCb ( const D3D12_BLEND_DESC & BlendState ) override { PipelineStream . BlendState = CD3DX12_BLEND_DESC ( BlendState ) ; }
void DepthStencilStateCb ( const D3D12_DEPTH_STENCIL_DESC & DepthStencilState ) override
{
PipelineStream . DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2 ( DepthStencilState ) ;
SeenDSS = true ;
}
void DepthStencilState1Cb ( const D3D12_DEPTH_STENCIL_DESC1 & DepthStencilState ) override
{
PipelineStream . DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2 ( DepthStencilState ) ;
SeenDSS = true ;
}
void DepthStencilState2Cb ( const D3D12_DEPTH_STENCIL_DESC2 & DepthStencilState ) override
{
PipelineStream . DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2 ( DepthStencilState ) ;
SeenDSS = true ;
}
void DSVFormatCb ( DXGI_FORMAT DSVFormat ) override
{
PipelineStream . DSVFormat = DSVFormat ;
if ( ! SeenDSS & & DSVFormat ! = DXGI_FORMAT_UNKNOWN )
{
// Re-enable depth for the default state.
static_cast < D3D12_DEPTH_STENCIL_DESC2 & > ( PipelineStream . DepthStencilState ) . DepthEnable = true ;
}
}
void RasterizerStateCb ( const D3D12_RASTERIZER_DESC & RasterizerState ) override { PipelineStream . RasterizerState = CD3DX12_RASTERIZER_DESC1 ( RasterizerState ) ; }
2023-04-24 20:52:49 +00:00
void RasterizerState1Cb ( const D3D12_RASTERIZER_DESC1 & RasterizerState ) override { PipelineStream . RasterizerState = CD3DX12_RASTERIZER_DESC1 ( RasterizerState ) ; }
void RTVFormatsCb ( const D3D12_RT_FORMAT_ARRAY & RTVFormats ) override { PipelineStream . RTVFormats = RTVFormats ; }
void SampleDescCb ( const DXGI_SAMPLE_DESC & SampleDesc ) override { PipelineStream . SampleDesc = SampleDesc ; }
void SampleMaskCb ( UINT SampleMask ) override { PipelineStream . SampleMask = SampleMask ; }
void ViewInstancingCb ( const D3D12_VIEW_INSTANCING_DESC & ViewInstancingDesc ) override { PipelineStream . ViewInstancingDesc = CD3DX12_VIEW_INSTANCING_DESC ( ViewInstancingDesc ) ; }
void CachedPSOCb ( const D3D12_CACHED_PIPELINE_STATE & CachedPSO ) override { PipelineStream . CachedPSO = CachedPSO ; }
private :
bool SeenDSS ;
} ;
# endif // D3D12_SDK_VERSION >= 608
2024-05-17 23:56:19 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 613)
// This SDK 613 version has better primitive topology default handling than the v610 equivalent below.
struct CD3DX12_PIPELINE_STATE_STREAM5_PARSE_HELPER : public ID3DX12PipelineParserCallbacks
{
CD3DX12_PIPELINE_STATE_STREAM5 PipelineStream ;
CD3DX12_PIPELINE_STATE_STREAM5_PARSE_HELPER ( ) noexcept
: SeenDSS ( false ) ,
SeenMS ( false ) ,
SeenTopology ( false )
{
// Adjust defaults to account for absent members.
PipelineStream . PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE ;
// Depth disabled if no DSV format specified.
static_cast < D3D12_DEPTH_STENCIL_DESC2 & > ( PipelineStream . DepthStencilState ) . DepthEnable = false ;
}
// ID3DX12PipelineParserCallbacks
void FlagsCb ( D3D12_PIPELINE_STATE_FLAGS Flags ) override { PipelineStream . Flags = Flags ; }
void NodeMaskCb ( UINT NodeMask ) override { PipelineStream . NodeMask = NodeMask ; }
void RootSignatureCb ( ID3D12RootSignature * pRootSignature ) override { PipelineStream . pRootSignature = pRootSignature ; }
void InputLayoutCb ( const D3D12_INPUT_LAYOUT_DESC & InputLayout ) override { PipelineStream . InputLayout = InputLayout ; }
void IBStripCutValueCb ( D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue ) override { PipelineStream . IBStripCutValue = IBStripCutValue ; }
void PrimitiveTopologyTypeCb ( D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType ) override
{
PipelineStream . PrimitiveTopologyType = PrimitiveTopologyType ;
SeenTopology = true ;
}
void VSCb ( const D3D12_SHADER_BYTECODE & VS ) override { PipelineStream . VS = VS ; }
void GSCb ( const D3D12_SHADER_BYTECODE & GS ) override { PipelineStream . GS = GS ; }
void StreamOutputCb ( const D3D12_STREAM_OUTPUT_DESC & StreamOutput ) override { PipelineStream . StreamOutput = StreamOutput ; }
void HSCb ( const D3D12_SHADER_BYTECODE & HS ) override { PipelineStream . HS = HS ; }
void DSCb ( const D3D12_SHADER_BYTECODE & DS ) override { PipelineStream . DS = DS ; }
void PSCb ( const D3D12_SHADER_BYTECODE & PS ) override { PipelineStream . PS = PS ; }
void CSCb ( const D3D12_SHADER_BYTECODE & CS ) override { PipelineStream . CS = CS ; }
void ASCb ( const D3D12_SHADER_BYTECODE & AS ) override { PipelineStream . AS = AS ; }
void MSCb ( const D3D12_SHADER_BYTECODE & MS ) override { PipelineStream . MS = MS ; SeenMS = true ; }
void BlendStateCb ( const D3D12_BLEND_DESC & BlendState ) override { PipelineStream . BlendState = CD3DX12_BLEND_DESC ( BlendState ) ; }
void DepthStencilStateCb ( const D3D12_DEPTH_STENCIL_DESC & DepthStencilState ) override
{
PipelineStream . DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2 ( DepthStencilState ) ;
SeenDSS = true ;
}
void DepthStencilState1Cb ( const D3D12_DEPTH_STENCIL_DESC1 & DepthStencilState ) override
{
PipelineStream . DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2 ( DepthStencilState ) ;
SeenDSS = true ;
}
void DepthStencilState2Cb ( const D3D12_DEPTH_STENCIL_DESC2 & DepthStencilState ) override
{
PipelineStream . DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2 ( DepthStencilState ) ;
SeenDSS = true ;
}
void DSVFormatCb ( DXGI_FORMAT DSVFormat ) override { PipelineStream . DSVFormat = DSVFormat ; }
void RasterizerStateCb ( const D3D12_RASTERIZER_DESC & RasterizerState ) override { PipelineStream . RasterizerState = CD3DX12_RASTERIZER_DESC2 ( RasterizerState ) ; }
void RasterizerState1Cb ( const D3D12_RASTERIZER_DESC1 & RasterizerState ) override { PipelineStream . RasterizerState = CD3DX12_RASTERIZER_DESC2 ( RasterizerState ) ; }
void RasterizerState2Cb ( const D3D12_RASTERIZER_DESC2 & RasterizerState ) override { PipelineStream . RasterizerState = CD3DX12_RASTERIZER_DESC2 ( RasterizerState ) ; }
void RTVFormatsCb ( const D3D12_RT_FORMAT_ARRAY & RTVFormats ) override { PipelineStream . RTVFormats = RTVFormats ; }
void SampleDescCb ( const DXGI_SAMPLE_DESC & SampleDesc ) override { PipelineStream . SampleDesc = SampleDesc ; }
void SampleMaskCb ( UINT SampleMask ) override { PipelineStream . SampleMask = SampleMask ; }
void ViewInstancingCb ( const D3D12_VIEW_INSTANCING_DESC & ViewInstancingDesc ) override { PipelineStream . ViewInstancingDesc = CD3DX12_VIEW_INSTANCING_DESC ( ViewInstancingDesc ) ; }
void CachedPSOCb ( const D3D12_CACHED_PIPELINE_STATE & CachedPSO ) override { PipelineStream . CachedPSO = CachedPSO ; }
void FinalizeCb ( ) override
{
if ( ! SeenDSS & & PipelineStream . DSVFormat ! = DXGI_FORMAT_UNKNOWN )
{
// Re-enable depth for the default state.
static_cast < D3D12_DEPTH_STENCIL_DESC2 & > ( PipelineStream . DepthStencilState ) . DepthEnable = true ;
}
if ( ! SeenTopology & & SeenMS )
{
PipelineStream . PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_UNDEFINED ;
}
}
private :
bool SeenDSS ;
bool SeenMS ;
bool SeenTopology ;
} ;
# elif defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610)
2023-04-24 20:52:49 +00:00
struct CD3DX12_PIPELINE_STATE_STREAM5_PARSE_HELPER : public ID3DX12PipelineParserCallbacks
{
CD3DX12_PIPELINE_STATE_STREAM5 PipelineStream ;
CD3DX12_PIPELINE_STATE_STREAM5_PARSE_HELPER ( ) noexcept
: SeenDSS ( false )
{
// Adjust defaults to account for absent members.
PipelineStream . PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE ;
// Depth disabled if no DSV format specified.
static_cast < D3D12_DEPTH_STENCIL_DESC2 & > ( PipelineStream . DepthStencilState ) . DepthEnable = false ;
}
// ID3DX12PipelineParserCallbacks
void FlagsCb ( D3D12_PIPELINE_STATE_FLAGS Flags ) override { PipelineStream . Flags = Flags ; }
void NodeMaskCb ( UINT NodeMask ) override { PipelineStream . NodeMask = NodeMask ; }
void RootSignatureCb ( ID3D12RootSignature * pRootSignature ) override { PipelineStream . pRootSignature = pRootSignature ; }
void InputLayoutCb ( const D3D12_INPUT_LAYOUT_DESC & InputLayout ) override { PipelineStream . InputLayout = InputLayout ; }
void IBStripCutValueCb ( D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue ) override { PipelineStream . IBStripCutValue = IBStripCutValue ; }
void PrimitiveTopologyTypeCb ( D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType ) override { PipelineStream . PrimitiveTopologyType = PrimitiveTopologyType ; }
void VSCb ( const D3D12_SHADER_BYTECODE & VS ) override { PipelineStream . VS = VS ; }
void GSCb ( const D3D12_SHADER_BYTECODE & GS ) override { PipelineStream . GS = GS ; }
void StreamOutputCb ( const D3D12_STREAM_OUTPUT_DESC & StreamOutput ) override { PipelineStream . StreamOutput = StreamOutput ; }
void HSCb ( const D3D12_SHADER_BYTECODE & HS ) override { PipelineStream . HS = HS ; }
void DSCb ( const D3D12_SHADER_BYTECODE & DS ) override { PipelineStream . DS = DS ; }
void PSCb ( const D3D12_SHADER_BYTECODE & PS ) override { PipelineStream . PS = PS ; }
void CSCb ( const D3D12_SHADER_BYTECODE & CS ) override { PipelineStream . CS = CS ; }
void ASCb ( const D3D12_SHADER_BYTECODE & AS ) override { PipelineStream . AS = AS ; }
void MSCb ( const D3D12_SHADER_BYTECODE & MS ) override { PipelineStream . MS = MS ; }
void BlendStateCb ( const D3D12_BLEND_DESC & BlendState ) override { PipelineStream . BlendState = CD3DX12_BLEND_DESC ( BlendState ) ; }
void DepthStencilStateCb ( const D3D12_DEPTH_STENCIL_DESC & DepthStencilState ) override
{
PipelineStream . DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2 ( DepthStencilState ) ;
SeenDSS = true ;
}
void DepthStencilState1Cb ( const D3D12_DEPTH_STENCIL_DESC1 & DepthStencilState ) override
{
PipelineStream . DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2 ( DepthStencilState ) ;
SeenDSS = true ;
}
void DepthStencilState2Cb ( const D3D12_DEPTH_STENCIL_DESC2 & DepthStencilState ) override
{
PipelineStream . DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC2 ( DepthStencilState ) ;
SeenDSS = true ;
}
void DSVFormatCb ( DXGI_FORMAT DSVFormat ) override
{
PipelineStream . DSVFormat = DSVFormat ;
if ( ! SeenDSS & & DSVFormat ! = DXGI_FORMAT_UNKNOWN )
{
// Re-enable depth for the default state.
static_cast < D3D12_DEPTH_STENCIL_DESC2 & > ( PipelineStream . DepthStencilState ) . DepthEnable = true ;
}
}
void RasterizerStateCb ( const D3D12_RASTERIZER_DESC & RasterizerState ) override { PipelineStream . RasterizerState = CD3DX12_RASTERIZER_DESC2 ( RasterizerState ) ; }
void RasterizerState1Cb ( const D3D12_RASTERIZER_DESC1 & RasterizerState ) override { PipelineStream . RasterizerState = CD3DX12_RASTERIZER_DESC2 ( RasterizerState ) ; }
void RasterizerState2Cb ( const D3D12_RASTERIZER_DESC2 & RasterizerState ) override { PipelineStream . RasterizerState = CD3DX12_RASTERIZER_DESC2 ( RasterizerState ) ; }
2022-11-19 21:03:20 +00:00
void RTVFormatsCb ( const D3D12_RT_FORMAT_ARRAY & RTVFormats ) override { PipelineStream . RTVFormats = RTVFormats ; }
void SampleDescCb ( const DXGI_SAMPLE_DESC & SampleDesc ) override { PipelineStream . SampleDesc = SampleDesc ; }
void SampleMaskCb ( UINT SampleMask ) override { PipelineStream . SampleMask = SampleMask ; }
void ViewInstancingCb ( const D3D12_VIEW_INSTANCING_DESC & ViewInstancingDesc ) override { PipelineStream . ViewInstancingDesc = CD3DX12_VIEW_INSTANCING_DESC ( ViewInstancingDesc ) ; }
void CachedPSOCb ( const D3D12_CACHED_PIPELINE_STATE & CachedPSO ) override { PipelineStream . CachedPSO = CachedPSO ; }
private :
bool SeenDSS ;
} ;
2023-04-24 20:52:49 +00:00
# endif // D3D12_SDK_VERSION >= 610
2020-03-18 04:45:33 +00:00
2017-04-20 01:13:34 +00:00
struct CD3DX12_PIPELINE_STATE_STREAM_PARSE_HELPER : public ID3DX12PipelineParserCallbacks
{
2017-10-24 22:00:28 +00:00
CD3DX12_PIPELINE_STATE_STREAM1 PipelineStream ;
2018-04-12 01:06:24 +00:00
CD3DX12_PIPELINE_STATE_STREAM_PARSE_HELPER ( ) noexcept
2017-10-24 22:00:28 +00:00
: SeenDSS ( false )
{
// Adjust defaults to account for absent members.
PipelineStream . PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE ;
// Depth disabled if no DSV format specified.
static_cast < D3D12_DEPTH_STENCIL_DESC1 & > ( PipelineStream . DepthStencilState ) . DepthEnable = false ;
}
2017-04-20 01:13:34 +00:00
// ID3DX12PipelineParserCallbacks
2018-06-22 23:55:00 +00:00
void FlagsCb ( D3D12_PIPELINE_STATE_FLAGS Flags ) override { PipelineStream . Flags = Flags ; }
void NodeMaskCb ( UINT NodeMask ) override { PipelineStream . NodeMask = NodeMask ; }
void RootSignatureCb ( ID3D12RootSignature * pRootSignature ) override { PipelineStream . pRootSignature = pRootSignature ; }
void InputLayoutCb ( const D3D12_INPUT_LAYOUT_DESC & InputLayout ) override { PipelineStream . InputLayout = InputLayout ; }
void IBStripCutValueCb ( D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue ) override { PipelineStream . IBStripCutValue = IBStripCutValue ; }
void PrimitiveTopologyTypeCb ( D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType ) override { PipelineStream . PrimitiveTopologyType = PrimitiveTopologyType ; }
void VSCb ( const D3D12_SHADER_BYTECODE & VS ) override { PipelineStream . VS = VS ; }
void GSCb ( const D3D12_SHADER_BYTECODE & GS ) override { PipelineStream . GS = GS ; }
void StreamOutputCb ( const D3D12_STREAM_OUTPUT_DESC & StreamOutput ) override { PipelineStream . StreamOutput = StreamOutput ; }
void HSCb ( const D3D12_SHADER_BYTECODE & HS ) override { PipelineStream . HS = HS ; }
void DSCb ( const D3D12_SHADER_BYTECODE & DS ) override { PipelineStream . DS = DS ; }
void PSCb ( const D3D12_SHADER_BYTECODE & PS ) override { PipelineStream . PS = PS ; }
void CSCb ( const D3D12_SHADER_BYTECODE & CS ) override { PipelineStream . CS = CS ; }
void BlendStateCb ( const D3D12_BLEND_DESC & BlendState ) override { PipelineStream . BlendState = CD3DX12_BLEND_DESC ( BlendState ) ; }
void DepthStencilStateCb ( const D3D12_DEPTH_STENCIL_DESC & DepthStencilState ) override
2017-10-24 22:00:28 +00:00
{
PipelineStream . DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1 ( DepthStencilState ) ;
SeenDSS = true ;
}
2018-06-22 23:55:00 +00:00
void DepthStencilState1Cb ( const D3D12_DEPTH_STENCIL_DESC1 & DepthStencilState ) override
2017-10-24 22:00:28 +00:00
{
PipelineStream . DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1 ( DepthStencilState ) ;
SeenDSS = true ;
}
2018-06-22 23:55:00 +00:00
void DSVFormatCb ( DXGI_FORMAT DSVFormat ) override
2017-10-24 22:00:28 +00:00
{
PipelineStream . DSVFormat = DSVFormat ;
if ( ! SeenDSS & & DSVFormat ! = DXGI_FORMAT_UNKNOWN )
{
// Re-enable depth for the default state.
static_cast < D3D12_DEPTH_STENCIL_DESC1 & > ( PipelineStream . DepthStencilState ) . DepthEnable = true ;
}
}
2018-06-22 23:55:00 +00:00
void RasterizerStateCb ( const D3D12_RASTERIZER_DESC & RasterizerState ) override { PipelineStream . RasterizerState = CD3DX12_RASTERIZER_DESC ( RasterizerState ) ; }
void RTVFormatsCb ( const D3D12_RT_FORMAT_ARRAY & RTVFormats ) override { PipelineStream . RTVFormats = RTVFormats ; }
void SampleDescCb ( const DXGI_SAMPLE_DESC & SampleDesc ) override { PipelineStream . SampleDesc = SampleDesc ; }
void SampleMaskCb ( UINT SampleMask ) override { PipelineStream . SampleMask = SampleMask ; }
void ViewInstancingCb ( const D3D12_VIEW_INSTANCING_DESC & ViewInstancingDesc ) override { PipelineStream . ViewInstancingDesc = CD3DX12_VIEW_INSTANCING_DESC ( ViewInstancingDesc ) ; }
void CachedPSOCb ( const D3D12_CACHED_PIPELINE_STATE & CachedPSO ) override { PipelineStream . CachedPSO = CachedPSO ; }
2017-10-24 22:00:28 +00:00
private :
bool SeenDSS ;
2017-04-20 01:13:34 +00:00
} ;
2020-03-16 09:16:44 +00:00
inline D3D12_PIPELINE_STATE_SUBOBJECT_TYPE D3DX12GetBaseSubobjectType ( D3D12_PIPELINE_STATE_SUBOBJECT_TYPE SubobjectType ) noexcept
2017-04-20 01:13:34 +00:00
{
switch ( SubobjectType )
{
2020-03-18 04:45:33 +00:00
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1 :
2017-04-20 01:13:34 +00:00
return D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL ;
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606)
2022-11-19 21:03:20 +00:00
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL2 :
return D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL ;
2023-04-24 20:52:49 +00:00
# endif
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608)
2022-11-19 21:03:20 +00:00
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER1 :
return D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER ;
# endif
2017-04-20 01:13:34 +00:00
default :
return SubobjectType ;
}
}
inline HRESULT D3DX12ParsePipelineStream ( const D3D12_PIPELINE_STATE_STREAM_DESC & Desc , ID3DX12PipelineParserCallbacks * pCallbacks )
{
2018-04-12 01:06:24 +00:00
if ( pCallbacks = = nullptr )
2017-04-20 01:13:34 +00:00
{
return E_INVALIDARG ;
}
2018-04-12 01:06:24 +00:00
if ( Desc . SizeInBytes = = 0 | | Desc . pPipelineStateSubobjectStream = = nullptr )
2017-04-20 01:13:34 +00:00
{
2018-04-12 01:06:24 +00:00
pCallbacks - > ErrorBadInputParameter ( 1 ) ; // first parameter issue
2017-04-20 01:13:34 +00:00
return E_INVALIDARG ;
}
2018-01-18 23:02:05 +00:00
bool SubobjectSeen [ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MAX_VALID ] = { } ;
2017-04-20 01:13:34 +00:00
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 ) ;
2018-07-06 18:57:14 +00:00
if ( SubobjectType < 0 | | SubobjectType > = D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MAX_VALID )
2017-04-20 01:13:34 +00:00
{
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 )
{
2020-03-18 04:45:33 +00:00
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE :
2017-04-20 01:13:34 +00:00
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 ;
2020-03-18 04:45:33 +00:00
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PS :
2017-04-20 01:13:34 +00:00
pCallbacks - > PSCb ( * reinterpret_cast < decltype ( CD3DX12_PIPELINE_STATE_STREAM : : PS ) * > ( pStream ) ) ;
SizeOfSubobject = sizeof ( CD3DX12_PIPELINE_STATE_STREAM : : PS ) ;
break ;
2020-03-18 04:45:33 +00:00
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DS :
2017-04-20 01:13:34 +00:00
pCallbacks - > DSCb ( * reinterpret_cast < decltype ( CD3DX12_PIPELINE_STATE_STREAM : : DS ) * > ( pStream ) ) ;
SizeOfSubobject = sizeof ( CD3DX12_PIPELINE_STATE_STREAM : : DS ) ;
break ;
2020-03-18 04:45:33 +00:00
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_HS :
2017-04-20 01:13:34 +00:00
pCallbacks - > HSCb ( * reinterpret_cast < decltype ( CD3DX12_PIPELINE_STATE_STREAM : : HS ) * > ( pStream ) ) ;
SizeOfSubobject = sizeof ( CD3DX12_PIPELINE_STATE_STREAM : : HS ) ;
break ;
2020-03-18 04:45:33 +00:00
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_GS :
2017-04-20 01:13:34 +00:00
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 ;
2020-03-18 04:45:33 +00:00
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_AS :
pCallbacks - > ASCb ( * reinterpret_cast < decltype ( CD3DX12_PIPELINE_STATE_STREAM2 : : AS ) * > ( pStream ) ) ;
SizeOfSubobject = sizeof ( CD3DX12_PIPELINE_STATE_STREAM2 : : AS ) ;
break ;
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MS :
pCallbacks - > MSCb ( * reinterpret_cast < decltype ( CD3DX12_PIPELINE_STATE_STREAM2 : : MS ) * > ( pStream ) ) ;
SizeOfSubobject = sizeof ( CD3DX12_PIPELINE_STATE_STREAM2 : : MS ) ;
break ;
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_STREAM_OUTPUT :
2017-04-20 01:13:34 +00:00
pCallbacks - > StreamOutputCb ( * reinterpret_cast < decltype ( CD3DX12_PIPELINE_STATE_STREAM : : StreamOutput ) * > ( pStream ) ) ;
SizeOfSubobject = sizeof ( CD3DX12_PIPELINE_STATE_STREAM : : StreamOutput ) ;
break ;
2020-03-18 04:45:33 +00:00
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_BLEND :
2017-04-20 01:13:34 +00:00
pCallbacks - > BlendStateCb ( * reinterpret_cast < decltype ( CD3DX12_PIPELINE_STATE_STREAM : : BlendState ) * > ( pStream ) ) ;
SizeOfSubobject = sizeof ( CD3DX12_PIPELINE_STATE_STREAM : : BlendState ) ;
break ;
2020-03-18 04:45:33 +00:00
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_MASK :
2017-04-20 01:13:34 +00:00
pCallbacks - > SampleMaskCb ( * reinterpret_cast < decltype ( CD3DX12_PIPELINE_STATE_STREAM : : SampleMask ) * > ( pStream ) ) ;
SizeOfSubobject = sizeof ( CD3DX12_PIPELINE_STATE_STREAM : : SampleMask ) ;
break ;
2020-03-18 04:45:33 +00:00
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER :
2017-04-20 01:13:34 +00:00
pCallbacks - > RasterizerStateCb ( * reinterpret_cast < decltype ( CD3DX12_PIPELINE_STATE_STREAM : : RasterizerState ) * > ( pStream ) ) ;
SizeOfSubobject = sizeof ( CD3DX12_PIPELINE_STATE_STREAM : : RasterizerState ) ;
break ;
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608)
2022-11-19 21:03:20 +00:00
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER1 :
2023-04-24 20:52:49 +00:00
pCallbacks - > RasterizerState1Cb ( * reinterpret_cast < decltype ( CD3DX12_PIPELINE_STATE_STREAM4 : : RasterizerState ) * > ( pStream ) ) ;
2022-11-19 21:03:20 +00:00
SizeOfSubobject = sizeof ( CD3DX12_PIPELINE_STATE_STREAM4 : : RasterizerState ) ;
break ;
2023-04-24 20:52:49 +00:00
# endif
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610)
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER2 :
pCallbacks - > RasterizerState2Cb ( * reinterpret_cast < decltype ( CD3DX12_PIPELINE_STATE_STREAM5 : : RasterizerState ) * > ( pStream ) ) ;
SizeOfSubobject = sizeof ( CD3DX12_PIPELINE_STATE_STREAM5 : : RasterizerState ) ;
break ;
2022-11-19 21:03:20 +00:00
# endif
2020-03-18 04:45:33 +00:00
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL :
2017-04-20 01:13:34 +00:00
pCallbacks - > DepthStencilStateCb ( * reinterpret_cast < CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL * > ( pStream ) ) ;
SizeOfSubobject = sizeof ( CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL ) ;
break ;
2020-03-18 04:45:33 +00:00
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1 :
2017-04-20 01:13:34 +00:00
pCallbacks - > DepthStencilState1Cb ( * reinterpret_cast < decltype ( CD3DX12_PIPELINE_STATE_STREAM : : DepthStencilState ) * > ( pStream ) ) ;
SizeOfSubobject = sizeof ( CD3DX12_PIPELINE_STATE_STREAM : : DepthStencilState ) ;
break ;
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606)
2022-11-19 21:03:20 +00:00
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL2 :
pCallbacks - > DepthStencilState2Cb ( * reinterpret_cast < decltype ( CD3DX12_PIPELINE_STATE_STREAM3 : : DepthStencilState ) * > ( pStream ) ) ;
SizeOfSubobject = sizeof ( CD3DX12_PIPELINE_STATE_STREAM3 : : DepthStencilState ) ;
break ;
# endif
2020-03-18 04:45:33 +00:00
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_INPUT_LAYOUT :
2017-04-20 01:13:34 +00:00
pCallbacks - > InputLayoutCb ( * reinterpret_cast < decltype ( CD3DX12_PIPELINE_STATE_STREAM : : InputLayout ) * > ( pStream ) ) ;
SizeOfSubobject = sizeof ( CD3DX12_PIPELINE_STATE_STREAM : : InputLayout ) ;
break ;
2020-03-18 04:45:33 +00:00
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_IB_STRIP_CUT_VALUE :
2017-04-20 01:13:34 +00:00
pCallbacks - > IBStripCutValueCb ( * reinterpret_cast < decltype ( CD3DX12_PIPELINE_STATE_STREAM : : IBStripCutValue ) * > ( pStream ) ) ;
SizeOfSubobject = sizeof ( CD3DX12_PIPELINE_STATE_STREAM : : IBStripCutValue ) ;
break ;
2020-03-18 04:45:33 +00:00
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PRIMITIVE_TOPOLOGY :
2017-04-20 01:13:34 +00:00
pCallbacks - > PrimitiveTopologyTypeCb ( * reinterpret_cast < decltype ( CD3DX12_PIPELINE_STATE_STREAM : : PrimitiveTopologyType ) * > ( pStream ) ) ;
SizeOfSubobject = sizeof ( CD3DX12_PIPELINE_STATE_STREAM : : PrimitiveTopologyType ) ;
break ;
2020-03-18 04:45:33 +00:00
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RENDER_TARGET_FORMATS :
2017-04-20 01:13:34 +00:00
pCallbacks - > RTVFormatsCb ( * reinterpret_cast < decltype ( CD3DX12_PIPELINE_STATE_STREAM : : RTVFormats ) * > ( pStream ) ) ;
SizeOfSubobject = sizeof ( CD3DX12_PIPELINE_STATE_STREAM : : RTVFormats ) ;
break ;
2020-03-18 04:45:33 +00:00
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL_FORMAT :
2017-04-20 01:13:34 +00:00
pCallbacks - > DSVFormatCb ( * reinterpret_cast < decltype ( CD3DX12_PIPELINE_STATE_STREAM : : DSVFormat ) * > ( pStream ) ) ;
SizeOfSubobject = sizeof ( CD3DX12_PIPELINE_STATE_STREAM : : DSVFormat ) ;
break ;
2020-03-18 04:45:33 +00:00
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_DESC :
2017-04-20 01:13:34 +00:00
pCallbacks - > SampleDescCb ( * reinterpret_cast < decltype ( CD3DX12_PIPELINE_STATE_STREAM : : SampleDesc ) * > ( pStream ) ) ;
SizeOfSubobject = sizeof ( CD3DX12_PIPELINE_STATE_STREAM : : SampleDesc ) ;
break ;
2020-03-18 04:45:33 +00:00
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_NODE_MASK :
2017-04-20 01:13:34 +00:00
pCallbacks - > NodeMaskCb ( * reinterpret_cast < decltype ( CD3DX12_PIPELINE_STATE_STREAM : : NodeMask ) * > ( pStream ) ) ;
SizeOfSubobject = sizeof ( CD3DX12_PIPELINE_STATE_STREAM : : NodeMask ) ;
break ;
2020-03-18 04:45:33 +00:00
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CACHED_PSO :
2017-04-20 01:13:34 +00:00
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 ;
2017-10-24 22:00:28 +00:00
case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING :
pCallbacks - > ViewInstancingCb ( * reinterpret_cast < decltype ( CD3DX12_PIPELINE_STATE_STREAM1 : : ViewInstancingDesc ) * > ( pStream ) ) ;
SizeOfSubobject = sizeof ( CD3DX12_PIPELINE_STATE_STREAM1 : : ViewInstancingDesc ) ;
break ;
2017-04-20 01:13:34 +00:00
default :
pCallbacks - > ErrorUnknownSubobject ( SubobjectType ) ;
return E_INVALIDARG ;
}
}
2024-05-17 23:56:19 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 613)
pCallbacks - > FinalizeCb ( ) ;
# endif
2017-04-20 01:13:34 +00:00
return S_OK ;
}
2018-10-03 22:46:26 +00:00
//------------------------------------------------------------------------------------------------
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
inline bool operator = = ( const D3D12_RENDER_PASS_BEGINNING_ACCESS_PRESERVE_LOCAL_PARAMETERS & a , const D3D12_RENDER_PASS_ENDING_ACCESS_PRESERVE_LOCAL_PARAMETERS & b ) noexcept
{
return ( ( a . AdditionalWidth = = b . AdditionalWidth ) & & ( a . AdditionalHeight = = b . AdditionalHeight ) ) ;
}
inline bool operator = = ( const D3D12_RENDER_PASS_BEGINNING_ACCESS_PRESERVE_LOCAL_PARAMETERS & a , const D3D12_RENDER_PASS_BEGINNING_ACCESS_PRESERVE_LOCAL_PARAMETERS & b ) noexcept
{
return ( ( a . AdditionalWidth = = b . AdditionalWidth ) & & ( a . AdditionalHeight = = b . AdditionalHeight ) ) ;
}
inline bool operator = = ( const D3D12_RENDER_PASS_ENDING_ACCESS_PRESERVE_LOCAL_PARAMETERS & a , const D3D12_RENDER_PASS_ENDING_ACCESS_PRESERVE_LOCAL_PARAMETERS & b ) noexcept
{
return ( ( a . AdditionalWidth = = b . AdditionalWidth ) & & ( a . AdditionalHeight = = b . AdditionalHeight ) ) ;
}
# endif
2020-03-16 09:16:44 +00:00
inline bool operator = = ( const D3D12_RENDER_PASS_BEGINNING_ACCESS_CLEAR_PARAMETERS & a , const D3D12_RENDER_PASS_BEGINNING_ACCESS_CLEAR_PARAMETERS & b ) noexcept
2018-10-03 22:46:26 +00:00
{
return a . ClearValue = = b . ClearValue ;
}
2023-04-24 20:52:49 +00:00
2020-03-16 09:16:44 +00:00
inline bool operator = = ( const D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_PARAMETERS & a , const D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_PARAMETERS & b ) noexcept
2018-10-03 22:46:26 +00:00
{
if ( a . pSrcResource ! = b . pSrcResource ) return false ;
if ( a . pDstResource ! = b . pDstResource ) return false ;
if ( a . SubresourceCount ! = b . SubresourceCount ) return false ;
if ( a . Format ! = b . Format ) return false ;
2020-03-18 04:45:33 +00:00
if ( a . ResolveMode ! = b . ResolveMode ) return false ;
if ( a . PreserveResolveSource ! = b . PreserveResolveSource ) return false ;
2018-10-03 22:46:26 +00:00
return true ;
}
2023-04-24 20:52:49 +00:00
2020-03-16 09:16:44 +00:00
inline bool operator = = ( const D3D12_RENDER_PASS_BEGINNING_ACCESS & a , const D3D12_RENDER_PASS_BEGINNING_ACCESS & b ) noexcept
2018-10-03 22:46:26 +00:00
{
if ( a . Type ! = b . Type ) return false ;
2023-04-24 20:52:49 +00:00
switch ( a . Type )
{
case D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_CLEAR :
if ( ! ( a . Clear = = b . Clear ) ) return false ;
break ;
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
case D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_PRESERVE_LOCAL_RENDER :
case D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_PRESERVE_LOCAL_SRV :
case D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_PRESERVE_LOCAL_UAV :
if ( ! ( a . PreserveLocal = = b . PreserveLocal ) ) return false ;
break ;
# endif
2024-05-17 23:56:19 +00:00
default :
break ;
2023-04-24 20:52:49 +00:00
}
2018-10-03 22:46:26 +00:00
return true ;
}
2023-04-24 20:52:49 +00:00
inline bool operator = = ( const D3D12_RENDER_PASS_ENDING_ACCESS & a , const D3D12_RENDER_PASS_ENDING_ACCESS & b ) noexcept
2018-10-03 22:46:26 +00:00
{
if ( a . Type ! = b . Type ) return false ;
2023-04-24 20:52:49 +00:00
switch ( a . Type )
{
case D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_RESOLVE :
if ( ! ( a . Resolve = = b . Resolve ) ) return false ;
break ;
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
case D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE_LOCAL_RENDER :
case D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE_LOCAL_SRV :
case D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE_LOCAL_UAV :
if ( ! ( a . PreserveLocal = = b . PreserveLocal ) ) return false ;
break ;
# endif
2024-05-17 23:56:19 +00:00
default :
break ;
2023-04-24 20:52:49 +00:00
}
2018-10-03 22:46:26 +00:00
return true ;
}
2023-04-24 20:52:49 +00:00
2020-03-16 09:16:44 +00:00
inline bool operator = = ( const D3D12_RENDER_PASS_RENDER_TARGET_DESC & a , const D3D12_RENDER_PASS_RENDER_TARGET_DESC & b ) noexcept
2018-10-03 22:46:26 +00:00
{
if ( a . cpuDescriptor . ptr ! = b . cpuDescriptor . ptr ) return false ;
if ( ! ( a . BeginningAccess = = b . BeginningAccess ) ) return false ;
if ( ! ( a . EndingAccess = = b . EndingAccess ) ) return false ;
return true ;
}
2020-03-16 09:16:44 +00:00
inline bool operator = = ( const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC & a , const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC & b ) noexcept
2018-10-03 22:46:26 +00:00
{
if ( a . cpuDescriptor . ptr ! = b . cpuDescriptor . ptr ) return false ;
if ( ! ( a . DepthBeginningAccess = = b . DepthBeginningAccess ) ) return false ;
2019-04-01 17:32:47 +00:00
if ( ! ( a . StencilBeginningAccess = = b . StencilBeginningAccess ) ) return false ;
2018-10-03 22:46:26 +00:00
if ( ! ( a . DepthEndingAccess = = b . DepthEndingAccess ) ) return false ;
if ( ! ( a . StencilEndingAccess = = b . StencilEndingAccess ) ) return false ;
return true ;
}
# ifndef D3DX12_NO_STATE_OBJECT_HELPERS
//================================================================================================
// D3DX12 State Object Creation Helpers
2020-03-18 04:45:33 +00:00
//
2018-10-03 22:46:26 +00:00
// Helper classes for creating new style state objects out of an arbitrary set of subobjects.
// Uses STL
//
2021-10-05 06:51:02 +00:00
// Start by instantiating CD3DX12_STATE_OBJECT_DESC (see its public methods).
2018-10-03 22:46:26 +00:00
// One of its methods is CreateSubobject(), which has a comment showing a couple of options for
2020-03-18 04:45:33 +00:00
// defining subobjects using the helper classes for each subobject (CD3DX12_DXIL_LIBRARY_SUBOBJECT
2021-10-05 06:51:02 +00:00
// etc.). The subobject helpers each have methods specific to the subobject for configuring its
2018-10-03 22:46:26 +00:00
// contents.
2020-03-18 04:45:33 +00:00
//
2018-10-03 22:46:26 +00:00
//================================================================================================
# include <list>
2024-05-17 23:56:19 +00:00
# include <forward_list>
# include <vector>
2022-05-08 21:25:55 +00:00
# include <memory>
2018-10-03 22:46:26 +00:00
# include <string>
2021-10-05 06:51:02 +00:00
# include <vector>
2021-10-06 00:41:32 +00:00
# ifndef D3DX12_USE_ATL
2018-10-03 22:46:26 +00:00
# include <wrl/client.h>
2021-10-06 00:41:32 +00:00
# define D3DX12_COM_PTR Microsoft::WRL::ComPtr
# define D3DX12_COM_PTR_GET(x) x.Get()
# define D3DX12_COM_PTR_ADDRESSOF(x) x.GetAddressOf()
# else
# include <atlbase.h>
# define D3DX12_COM_PTR ATL::CComPtr
# define D3DX12_COM_PTR_GET(x) x.p
# define D3DX12_COM_PTR_ADDRESSOF(x) &x.p
# endif
2018-10-03 22:46:26 +00:00
//------------------------------------------------------------------------------------------------
class CD3DX12_STATE_OBJECT_DESC
{
public :
2020-03-16 09:16:44 +00:00
CD3DX12_STATE_OBJECT_DESC ( ) noexcept
2018-10-03 22:46:26 +00:00
{
Init ( D3D12_STATE_OBJECT_TYPE_COLLECTION ) ;
}
2020-03-16 09:16:44 +00:00
CD3DX12_STATE_OBJECT_DESC ( D3D12_STATE_OBJECT_TYPE Type ) noexcept
2018-10-03 22:46:26 +00:00
{
Init ( Type ) ;
}
2020-03-16 09:16:44 +00:00
void SetStateObjectType ( D3D12_STATE_OBJECT_TYPE Type ) noexcept { m_Desc . Type = Type ; }
2024-05-17 23:56:19 +00:00
CD3DX12_STATE_OBJECT_DESC ( const CD3DX12_STATE_OBJECT_DESC & other ) = delete ;
CD3DX12_STATE_OBJECT_DESC & operator = ( const CD3DX12_STATE_OBJECT_DESC & other ) = delete ;
CD3DX12_STATE_OBJECT_DESC ( CD3DX12_STATE_OBJECT_DESC & & other ) = default ;
CD3DX12_STATE_OBJECT_DESC & operator = ( CD3DX12_STATE_OBJECT_DESC & & other ) = default ;
operator const D3D12_STATE_OBJECT_DESC & ( )
2018-10-03 22:46:26 +00:00
{
// Do final preparation work
2024-05-17 23:56:19 +00:00
for ( auto & ownedSubobject : m_OwnedSubobjectHelpers )
{
ownedSubobject - > Finalize ( ) ;
}
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612)
m_RepointedSubobjectVectors . clear ( ) ;
m_RepointedPrograms . clear ( ) ;
# endif
2018-10-03 22:46:26 +00:00
m_RepointedAssociations . clear ( ) ;
m_SubobjectArray . clear ( ) ;
m_SubobjectArray . reserve ( m_Desc . NumSubobjects ) ;
2020-03-18 04:45:33 +00:00
// Flatten subobjects into an array (each flattened subobject still has a
2021-10-05 06:51:02 +00:00
// member that's a pointer to its desc that's not flattened)
2018-10-03 22:46:26 +00:00
for ( auto Iter = m_SubobjectList . begin ( ) ;
Iter ! = m_SubobjectList . end ( ) ; Iter + + )
{
m_SubobjectArray . push_back ( * Iter ) ;
2020-03-18 04:45:33 +00:00
// Store new location in array so we can redirect pointers contained in subobjects
Iter - > pSubobjectArrayLocation = & m_SubobjectArray . back ( ) ;
2018-10-03 22:46:26 +00:00
}
// For subobjects with pointer fields, create a new copy of those subobject definitions
// with fixed pointers
for ( UINT i = 0 ; i < m_Desc . NumSubobjects ; i + + )
{
if ( m_SubobjectArray [ i ] . Type = = D3D12_STATE_SUBOBJECT_TYPE_SUBOBJECT_TO_EXPORTS_ASSOCIATION )
{
2020-03-18 04:45:33 +00:00
auto pOriginalSubobjectAssociation =
2020-03-16 09:16:44 +00:00
static_cast < const D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION * > ( m_SubobjectArray [ i ] . pDesc ) ;
2018-10-03 22:46:26 +00:00
D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION Repointed = * pOriginalSubobjectAssociation ;
2020-03-18 04:45:33 +00:00
auto pWrapper =
2018-10-03 22:46:26 +00:00
static_cast < const SUBOBJECT_WRAPPER * > ( pOriginalSubobjectAssociation - > pSubobjectToAssociate ) ;
Repointed . pSubobjectToAssociate = pWrapper - > pSubobjectArrayLocation ;
m_RepointedAssociations . push_back ( Repointed ) ;
m_SubobjectArray [ i ] . pDesc = & m_RepointedAssociations . back ( ) ;
}
2024-05-17 23:56:19 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612)
else if ( m_SubobjectArray [ i ] . Type = = D3D12_STATE_SUBOBJECT_TYPE_GENERIC_PROGRAM )
{
auto originalGenericProgramDesc =
static_cast < const D3D12_GENERIC_PROGRAM_DESC * > ( m_SubobjectArray [ i ] . pDesc ) ;
D3D12_GENERIC_PROGRAM_DESC Repointed = * originalGenericProgramDesc ;
if ( originalGenericProgramDesc - > NumSubobjects > 0 )
{
m_RepointedSubobjectVectors . emplace_back ( std : : vector < const D3D12_STATE_SUBOBJECT * > ( ) ) ;
std : : vector < D3D12_STATE_SUBOBJECT const * > & repointedGenericProgramSubobjects = m_RepointedSubobjectVectors . back ( ) ;
repointedGenericProgramSubobjects . resize ( originalGenericProgramDesc - > NumSubobjects ) ;
for ( UINT s = 0 ; s < originalGenericProgramDesc - > NumSubobjects ; s + + )
{
auto pWrapper =
static_cast < const SUBOBJECT_WRAPPER * > ( originalGenericProgramDesc - > ppSubobjects [ s ] ) ;
repointedGenericProgramSubobjects [ s ] = pWrapper - > pSubobjectArrayLocation ;
}
// Below: using ugly way to get pointer in case .data() is not defined
Repointed . ppSubobjects = & repointedGenericProgramSubobjects [ 0 ] ;
}
m_RepointedPrograms . push_back ( Repointed ) ;
m_SubobjectArray [ i ] . pDesc = & m_RepointedPrograms . back ( ) ;
}
# endif
2018-10-03 22:46:26 +00:00
}
// Below: using ugly way to get pointer in case .data() is not defined
2020-03-18 04:45:33 +00:00
m_Desc . pSubobjects = m_Desc . NumSubobjects ? & m_SubobjectArray [ 0 ] : nullptr ;
2018-10-03 22:46:26 +00:00
return m_Desc ;
}
2024-05-17 23:56:19 +00:00
operator const D3D12_STATE_OBJECT_DESC * ( )
2018-10-03 22:46:26 +00:00
{
// Cast calls the above final preparation work
return & static_cast < const D3D12_STATE_OBJECT_DESC & > ( * this ) ;
}
2020-03-18 04:45:33 +00:00
// CreateSubobject creates a sububject helper (e.g. CD3DX12_HIT_GROUP_SUBOBJECT)
2018-10-03 22:46:26 +00:00
// whose lifetime is owned by this class.
2020-03-18 04:45:33 +00:00
// e.g.
//
2018-10-03 22:46:26 +00:00
// CD3DX12_STATE_OBJECT_DESC Collection1(D3D12_STATE_OBJECT_TYPE_COLLECTION);
// auto Lib0 = Collection1.CreateSubobject<CD3DX12_DXIL_LIBRARY_SUBOBJECT>();
// Lib0->SetDXILLibrary(&pMyAppDxilLibs[0]);
2020-03-18 04:45:33 +00:00
// Lib0->DefineExport(L"rayGenShader0"); // in practice these export listings might be
2018-10-03 22:46:26 +00:00
// // data/engine driven
// etc.
//
2020-03-18 04:45:33 +00:00
// Alternatively, users can instantiate sububject helpers explicitly, such as via local
// variables instead, passing the state object desc that should point to it into the helper
// constructor (or call mySubobjectHelper.AddToStateObject(Collection1)).
// In this alternative scenario, the user must keep the subobject alive as long as the state
2021-10-05 06:51:02 +00:00
// object it is associated with is alive, else its pointer references will be stale.
2018-10-03 22:46:26 +00:00
// e.g.
//
// CD3DX12_STATE_OBJECT_DESC RaytracingState2(D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE);
// CD3DX12_DXIL_LIBRARY_SUBOBJECT LibA(RaytracingState2);
2020-03-18 04:45:33 +00:00
// LibA.SetDXILLibrary(&pMyAppDxilLibs[4]); // not manually specifying exports
// // - meaning all exports in the libraries
2018-10-03 22:46:26 +00:00
// // are exported
// etc.
template < typename T >
T * CreateSubobject ( )
{
T * pSubobject = new T ( * this ) ;
m_OwnedSubobjectHelpers . emplace_back ( pSubobject ) ;
return pSubobject ;
}
private :
D3D12_STATE_SUBOBJECT * TrackSubobject ( D3D12_STATE_SUBOBJECT_TYPE Type , void * pDesc )
{
SUBOBJECT_WRAPPER Subobject ;
Subobject . pSubobjectArrayLocation = nullptr ;
Subobject . Type = Type ;
Subobject . pDesc = pDesc ;
m_SubobjectList . push_back ( Subobject ) ;
m_Desc . NumSubobjects + + ;
return & m_SubobjectList . back ( ) ;
}
2020-03-16 09:16:44 +00:00
void Init ( D3D12_STATE_OBJECT_TYPE Type ) noexcept
2018-10-03 22:46:26 +00:00
{
SetStateObjectType ( Type ) ;
m_Desc . pSubobjects = nullptr ;
m_Desc . NumSubobjects = 0 ;
m_SubobjectList . clear ( ) ;
m_SubobjectArray . clear ( ) ;
m_RepointedAssociations . clear ( ) ;
2024-05-17 23:56:19 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612)
m_RepointedSubobjectVectors . clear ( ) ;
m_RepointedPrograms . clear ( ) ;
# endif
2018-10-03 22:46:26 +00:00
}
typedef struct SUBOBJECT_WRAPPER : public D3D12_STATE_SUBOBJECT
{
2020-03-18 04:45:33 +00:00
D3D12_STATE_SUBOBJECT * pSubobjectArrayLocation ; // new location when flattened into array
2018-10-03 22:46:26 +00:00
// for repointing pointers in subobjects
} SUBOBJECT_WRAPPER ;
D3D12_STATE_OBJECT_DESC m_Desc ;
2020-03-18 04:45:33 +00:00
std : : list < SUBOBJECT_WRAPPER > m_SubobjectList ; // Pointers to list nodes handed out so
2018-10-03 22:46:26 +00:00
// these can be edited live
std : : vector < D3D12_STATE_SUBOBJECT > m_SubobjectArray ; // Built at the end, copying list contents
2020-03-18 04:45:33 +00:00
std : : list < D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION >
2024-05-17 23:56:19 +00:00
m_RepointedAssociations ; // subobject type that contains pointers to other subobjects,
// repointed to flattened array
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612)
std : : list < std : : vector < D3D12_STATE_SUBOBJECT const * > >
m_RepointedSubobjectVectors ;
std : : list < D3D12_GENERIC_PROGRAM_DESC >
m_RepointedPrograms ;
# endif
2018-10-03 22:46:26 +00:00
2024-05-17 23:56:19 +00:00
template < typename CStr , typename StdStr >
2018-10-03 22:46:26 +00:00
class StringContainer
{
public :
2024-05-17 23:56:19 +00:00
CStr LocalCopy ( CStr string , bool bSingleString = false )
2018-10-03 22:46:26 +00:00
{
if ( string )
{
if ( bSingleString )
{
m_Strings . clear ( ) ;
m_Strings . push_back ( string ) ;
}
else
{
m_Strings . push_back ( string ) ;
}
return m_Strings . back ( ) . c_str ( ) ;
}
else
{
return nullptr ;
}
}
2020-03-16 09:16:44 +00:00
void clear ( ) noexcept { m_Strings . clear ( ) ; }
2018-10-03 22:46:26 +00:00
private :
2024-05-17 23:56:19 +00:00
std : : list < StdStr > m_Strings ;
2018-10-03 22:46:26 +00:00
} ;
2024-05-17 23:56:19 +00:00
public :
2018-10-03 22:46:26 +00:00
class SUBOBJECT_HELPER_BASE
{
public :
2020-03-16 09:16:44 +00:00
SUBOBJECT_HELPER_BASE ( ) noexcept { Init ( ) ; }
virtual ~ SUBOBJECT_HELPER_BASE ( ) = default ;
virtual D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept = 0 ;
2024-05-17 23:56:19 +00:00
SUBOBJECT_HELPER_BASE ( const SUBOBJECT_HELPER_BASE & other ) = delete ;
SUBOBJECT_HELPER_BASE & operator = ( const SUBOBJECT_HELPER_BASE & other ) = delete ;
SUBOBJECT_HELPER_BASE ( SUBOBJECT_HELPER_BASE & & other ) = default ;
SUBOBJECT_HELPER_BASE & operator = ( SUBOBJECT_HELPER_BASE & & other ) = default ;
2018-10-03 22:46:26 +00:00
void AddToStateObject ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
m_pSubobject = ContainingStateObject . TrackSubobject ( Type ( ) , Data ( ) ) ;
}
2024-05-17 23:56:19 +00:00
virtual void Finalize ( ) { } ;
operator const D3D12_STATE_SUBOBJECT & ( ) const noexcept { return * m_pSubobject ; }
2018-10-03 22:46:26 +00:00
protected :
2020-03-16 09:16:44 +00:00
virtual void * Data ( ) noexcept = 0 ;
void Init ( ) noexcept { m_pSubobject = nullptr ; }
2018-10-03 22:46:26 +00:00
D3D12_STATE_SUBOBJECT * m_pSubobject ;
} ;
2024-05-17 23:56:19 +00:00
private :
std : : list < std : : unique_ptr < SUBOBJECT_HELPER_BASE > > m_OwnedSubobjectHelpers ;
2017-04-20 01:13:34 +00:00
2018-10-03 22:46:26 +00:00
friend class CD3DX12_DXIL_LIBRARY_SUBOBJECT ;
friend class CD3DX12_EXISTING_COLLECTION_SUBOBJECT ;
friend class CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT ;
friend class CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION ;
friend class CD3DX12_HIT_GROUP_SUBOBJECT ;
friend class CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT ;
friend class CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT ;
2020-03-18 04:45:33 +00:00
friend class CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT ;
2018-10-03 22:46:26 +00:00
friend class CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT ;
friend class CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT ;
friend class CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT ;
friend class CD3DX12_NODE_MASK_SUBOBJECT ;
2024-05-17 23:56:19 +00:00
//TODO: SDK Version check should include all the newly added subobject type for the public release.
// The SDK version check will be changed based on when we release state objects.
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612)
friend class CD3DX12_GENERIC_PROGRAM_SUBOBJECT ;
friend class CD3DX12_WORK_GRAPH_SUBOBJECT ;
friend class CD3DX12_STREAM_OUTPUT_SUBOBJECT ;
friend class CD3DX12_BLEND_SUBOBJECT ;
friend class CD3DX12_RASTERIZER_SUBOBJECT ;
friend class CD3DX12_DEPTH_STENCIL2_SUBOBJECT ;
friend class CD3DX12_INPUT_LAYOUT_SUBOBJECT ;
friend class CD3DX12_IB_STRIP_CUT_VALUE_SUBOBJECT ;
friend class CD3DX12_PRIMITIVE_TOPOLOGY_SUBOBJECT ;
friend class CD3DX12_RENDER_TARGET_FORMATS_SUBOBJECT ;
friend class CD3DX12_DEPTH_STENCIL_FORMAT_SUBOBJECT ;
friend class CD3DX12_SAMPLE_DESC_SUBOBJECT ;
friend class CD3DX12_FLAGS_SUBOBJECT ;
friend class CD3DX12_VIEW_INSTANCING_SUBOBJECT ;
friend class CD3DX12_DEPTH_STENCIL_SUBOBJECT ;
friend class CD3DX12_DEPTH_STENCIL1_SUBOBJECT ;
friend class CD3DX12_SAMPLE_MASK_SUBOBJECT ;
friend class CD3DX12_NODE_OUTPUT_OVERRIDES ;
friend class CD3DX12_SHADER_NODE ;
friend class CD3DX12_BROADCASTING_LAUNCH_NODE_OVERRIDES ;
friend class CD3DX12_COALESCING_LAUNCH_NODE_OVERRIDES ;
friend class CD3DX12_THREAD_LAUNCH_NODE_OVERRIDES ;
friend class CD3DX12_COMMON_COMPUTE_NODE_OVERRIDES ;
# endif // D3D12_SDK_VERSION >= 612
2018-10-03 22:46:26 +00:00
} ;
//------------------------------------------------------------------------------------------------
2020-03-18 04:45:33 +00:00
class CD3DX12_DXIL_LIBRARY_SUBOBJECT
2018-10-03 22:46:26 +00:00
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
2020-03-16 09:16:44 +00:00
CD3DX12_DXIL_LIBRARY_SUBOBJECT ( ) noexcept
2018-10-03 22:46:26 +00:00
{
Init ( ) ;
}
CD3DX12_DXIL_LIBRARY_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
2024-05-30 19:39:25 +00:00
CD3DX12_DXIL_LIBRARY_SUBOBJECT ( const CD3DX12_DXIL_LIBRARY_SUBOBJECT & other ) = delete ;
CD3DX12_DXIL_LIBRARY_SUBOBJECT & operator = ( const CD3DX12_DXIL_LIBRARY_SUBOBJECT & other ) = delete ;
CD3DX12_DXIL_LIBRARY_SUBOBJECT ( CD3DX12_DXIL_LIBRARY_SUBOBJECT & & other ) = default ;
CD3DX12_DXIL_LIBRARY_SUBOBJECT & operator = ( CD3DX12_DXIL_LIBRARY_SUBOBJECT & & other ) = default ;
2020-03-16 09:16:44 +00:00
void SetDXILLibrary ( const D3D12_SHADER_BYTECODE * pCode ) noexcept
2020-03-18 04:45:33 +00:00
{
static const D3D12_SHADER_BYTECODE Default = { } ;
m_Desc . DXILLibrary = pCode ? * pCode : Default ;
2018-10-03 22:46:26 +00:00
}
void DefineExport (
2020-03-18 04:45:33 +00:00
LPCWSTR Name ,
LPCWSTR ExportToRename = nullptr ,
2018-10-03 22:46:26 +00:00
D3D12_EXPORT_FLAGS Flags = D3D12_EXPORT_FLAG_NONE )
{
D3D12_EXPORT_DESC Export ;
Export . Name = m_Strings . LocalCopy ( Name ) ;
Export . ExportToRename = m_Strings . LocalCopy ( ExportToRename ) ;
Export . Flags = Flags ;
m_Exports . push_back ( Export ) ;
m_Desc . pExports = & m_Exports [ 0 ] ; // using ugly way to get pointer in case .data() is not defined
m_Desc . NumExports = static_cast < UINT > ( m_Exports . size ( ) ) ;
}
template < size_t N >
void DefineExports ( LPCWSTR ( & Exports ) [ N ] )
{
for ( UINT i = 0 ; i < N ; i + + )
{
DefineExport ( Exports [ i ] ) ;
}
}
2020-03-16 09:16:44 +00:00
void DefineExports ( const LPCWSTR * Exports , UINT N )
2018-10-03 22:46:26 +00:00
{
for ( UINT i = 0 ; i < N ; i + + )
{
DefineExport ( Exports [ i ] ) ;
}
2020-03-18 04:45:33 +00:00
}
2020-03-16 09:16:44 +00:00
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
2020-03-18 04:45:33 +00:00
{
return D3D12_STATE_SUBOBJECT_TYPE_DXIL_LIBRARY ;
2018-10-03 22:46:26 +00:00
}
2020-03-16 09:16:44 +00:00
operator const D3D12_DXIL_LIBRARY_DESC & ( ) const noexcept { return m_Desc ; }
2018-10-03 22:46:26 +00:00
private :
2020-03-16 09:16:44 +00:00
void Init ( ) noexcept
2018-10-03 22:46:26 +00:00
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
m_Desc = { } ;
m_Strings . clear ( ) ;
m_Exports . clear ( ) ;
}
2020-03-16 09:16:44 +00:00
void * Data ( ) noexcept override { return & m_Desc ; }
2018-10-03 22:46:26 +00:00
D3D12_DXIL_LIBRARY_DESC m_Desc ;
2024-05-17 23:56:19 +00:00
CD3DX12_STATE_OBJECT_DESC : : StringContainer < LPCWSTR , std : : wstring > m_Strings ;
2018-10-03 22:46:26 +00:00
std : : vector < D3D12_EXPORT_DESC > m_Exports ;
} ;
//------------------------------------------------------------------------------------------------
2020-03-18 04:45:33 +00:00
class CD3DX12_EXISTING_COLLECTION_SUBOBJECT
2018-10-03 22:46:26 +00:00
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
2020-03-16 09:16:44 +00:00
CD3DX12_EXISTING_COLLECTION_SUBOBJECT ( ) noexcept
2018-10-03 22:46:26 +00:00
{
Init ( ) ;
}
CD3DX12_EXISTING_COLLECTION_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
2024-05-30 19:39:25 +00:00
CD3DX12_EXISTING_COLLECTION_SUBOBJECT ( const CD3DX12_EXISTING_COLLECTION_SUBOBJECT & other ) = delete ;
CD3DX12_EXISTING_COLLECTION_SUBOBJECT & operator = ( const CD3DX12_EXISTING_COLLECTION_SUBOBJECT & other ) = delete ;
CD3DX12_EXISTING_COLLECTION_SUBOBJECT ( CD3DX12_EXISTING_COLLECTION_SUBOBJECT & & other ) = default ;
CD3DX12_EXISTING_COLLECTION_SUBOBJECT & operator = ( CD3DX12_EXISTING_COLLECTION_SUBOBJECT & & other ) = default ;
2020-03-16 09:16:44 +00:00
void SetExistingCollection ( ID3D12StateObject * pExistingCollection ) noexcept
2020-03-18 04:45:33 +00:00
{
m_Desc . pExistingCollection = pExistingCollection ;
m_CollectionRef = pExistingCollection ;
2018-10-03 22:46:26 +00:00
}
void DefineExport (
2020-03-18 04:45:33 +00:00
LPCWSTR Name ,
LPCWSTR ExportToRename = nullptr ,
2018-10-03 22:46:26 +00:00
D3D12_EXPORT_FLAGS Flags = D3D12_EXPORT_FLAG_NONE )
{
D3D12_EXPORT_DESC Export ;
Export . Name = m_Strings . LocalCopy ( Name ) ;
Export . ExportToRename = m_Strings . LocalCopy ( ExportToRename ) ;
Export . Flags = Flags ;
m_Exports . push_back ( Export ) ;
m_Desc . pExports = & m_Exports [ 0 ] ; // using ugly way to get pointer in case .data() is not defined
m_Desc . NumExports = static_cast < UINT > ( m_Exports . size ( ) ) ;
}
template < size_t N >
void DefineExports ( LPCWSTR ( & Exports ) [ N ] )
{
for ( UINT i = 0 ; i < N ; i + + )
{
DefineExport ( Exports [ i ] ) ;
}
}
2020-03-16 09:16:44 +00:00
void DefineExports ( const LPCWSTR * Exports , UINT N )
2018-10-03 22:46:26 +00:00
{
for ( UINT i = 0 ; i < N ; i + + )
{
DefineExport ( Exports [ i ] ) ;
}
2020-03-18 04:45:33 +00:00
}
2020-03-16 09:16:44 +00:00
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
2020-03-18 04:45:33 +00:00
{
return D3D12_STATE_SUBOBJECT_TYPE_EXISTING_COLLECTION ;
2018-10-03 22:46:26 +00:00
}
2020-03-16 09:16:44 +00:00
operator const D3D12_EXISTING_COLLECTION_DESC & ( ) const noexcept { return m_Desc ; }
2018-10-03 22:46:26 +00:00
private :
2020-03-16 09:16:44 +00:00
void Init ( ) noexcept
2018-10-03 22:46:26 +00:00
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
m_Desc = { } ;
m_CollectionRef = nullptr ;
m_Strings . clear ( ) ;
m_Exports . clear ( ) ;
}
2020-03-16 09:16:44 +00:00
void * Data ( ) noexcept override { return & m_Desc ; }
2018-10-03 22:46:26 +00:00
D3D12_EXISTING_COLLECTION_DESC m_Desc ;
2021-10-06 00:41:32 +00:00
D3DX12_COM_PTR < ID3D12StateObject > m_CollectionRef ;
2024-05-17 23:56:19 +00:00
CD3DX12_STATE_OBJECT_DESC : : StringContainer < LPCWSTR , std : : wstring > m_Strings ;
2018-10-03 22:46:26 +00:00
std : : vector < D3D12_EXPORT_DESC > m_Exports ;
} ;
//------------------------------------------------------------------------------------------------
2020-03-18 04:45:33 +00:00
class CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT
2018-10-03 22:46:26 +00:00
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
2020-03-16 09:16:44 +00:00
CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT ( ) noexcept
2018-10-03 22:46:26 +00:00
{
Init ( ) ;
}
CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
2024-05-30 19:39:25 +00:00
CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT ( const CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT & other ) = delete ;
CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT & operator = ( const CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT & other ) = delete ;
CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT ( CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT & & other ) = default ;
CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT & operator = ( CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT & & other ) = default ;
2020-03-16 09:16:44 +00:00
void SetSubobjectToAssociate ( const D3D12_STATE_SUBOBJECT & SubobjectToAssociate ) noexcept
2020-03-18 04:45:33 +00:00
{
m_Desc . pSubobjectToAssociate = & SubobjectToAssociate ;
2018-10-03 22:46:26 +00:00
}
void AddExport ( LPCWSTR Export )
{
m_Desc . NumExports + + ;
m_Exports . push_back ( m_Strings . LocalCopy ( Export ) ) ;
m_Desc . pExports = & m_Exports [ 0 ] ; // using ugly way to get pointer in case .data() is not defined
}
template < size_t N >
void AddExports ( LPCWSTR ( & Exports ) [ N ] )
{
for ( UINT i = 0 ; i < N ; i + + )
{
AddExport ( Exports [ i ] ) ;
}
}
2020-03-16 09:16:44 +00:00
void AddExports ( const LPCWSTR * Exports , UINT N )
2018-10-03 22:46:26 +00:00
{
for ( UINT i = 0 ; i < N ; i + + )
{
AddExport ( Exports [ i ] ) ;
}
2020-03-18 04:45:33 +00:00
}
2020-03-16 09:16:44 +00:00
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
2020-03-18 04:45:33 +00:00
{
return D3D12_STATE_SUBOBJECT_TYPE_SUBOBJECT_TO_EXPORTS_ASSOCIATION ;
2018-10-03 22:46:26 +00:00
}
2020-03-16 09:16:44 +00:00
operator const D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION & ( ) const noexcept { return m_Desc ; }
2018-10-03 22:46:26 +00:00
private :
2020-03-16 09:16:44 +00:00
void Init ( ) noexcept
2018-10-03 22:46:26 +00:00
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
m_Desc = { } ;
m_Strings . clear ( ) ;
m_Exports . clear ( ) ;
}
2020-03-16 09:16:44 +00:00
void * Data ( ) noexcept override { return & m_Desc ; }
2018-10-03 22:46:26 +00:00
D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION m_Desc ;
2024-05-17 23:56:19 +00:00
CD3DX12_STATE_OBJECT_DESC : : StringContainer < LPCWSTR , std : : wstring > m_Strings ;
2018-10-03 22:46:26 +00:00
std : : vector < LPCWSTR > m_Exports ;
} ;
//------------------------------------------------------------------------------------------------
2020-03-18 04:45:33 +00:00
class CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION
2018-10-03 22:46:26 +00:00
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
2020-03-16 09:16:44 +00:00
CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION ( ) noexcept
2018-10-03 22:46:26 +00:00
{
Init ( ) ;
}
CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
2024-05-30 19:39:25 +00:00
CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION ( const CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION & other ) = delete ;
CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION & operator = ( const CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION & other ) = delete ;
CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION ( CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION & & other ) = default ;
CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION & operator = ( CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION & & other ) = default ;
2020-03-18 04:45:33 +00:00
void SetSubobjectNameToAssociate ( LPCWSTR SubobjectToAssociate )
2018-10-03 22:46:26 +00:00
{
2020-03-18 04:45:33 +00:00
m_Desc . SubobjectToAssociate = m_SubobjectName . LocalCopy ( SubobjectToAssociate , true ) ;
2018-10-03 22:46:26 +00:00
}
void AddExport ( LPCWSTR Export )
{
m_Desc . NumExports + + ;
m_Exports . push_back ( m_Strings . LocalCopy ( Export ) ) ;
m_Desc . pExports = & m_Exports [ 0 ] ; // using ugly way to get pointer in case .data() is not defined
}
template < size_t N >
void AddExports ( LPCWSTR ( & Exports ) [ N ] )
{
for ( UINT i = 0 ; i < N ; i + + )
{
AddExport ( Exports [ i ] ) ;
}
}
2020-03-16 09:16:44 +00:00
void AddExports ( const LPCWSTR * Exports , UINT N )
2018-10-03 22:46:26 +00:00
{
for ( UINT i = 0 ; i < N ; i + + )
{
AddExport ( Exports [ i ] ) ;
}
2020-03-18 04:45:33 +00:00
}
2020-03-16 09:16:44 +00:00
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
2020-03-18 04:45:33 +00:00
{
return D3D12_STATE_SUBOBJECT_TYPE_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION ;
2018-10-03 22:46:26 +00:00
}
2020-03-16 09:16:44 +00:00
operator const D3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION & ( ) const noexcept { return m_Desc ; }
2018-10-03 22:46:26 +00:00
private :
2020-03-16 09:16:44 +00:00
void Init ( ) noexcept
2018-10-03 22:46:26 +00:00
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
m_Desc = { } ;
m_Strings . clear ( ) ;
m_SubobjectName . clear ( ) ;
m_Exports . clear ( ) ;
}
2020-03-16 09:16:44 +00:00
void * Data ( ) noexcept override { return & m_Desc ; }
2018-10-03 22:46:26 +00:00
D3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION m_Desc ;
2024-05-17 23:56:19 +00:00
CD3DX12_STATE_OBJECT_DESC : : StringContainer < LPCWSTR , std : : wstring > m_Strings ;
CD3DX12_STATE_OBJECT_DESC : : StringContainer < LPCWSTR , std : : wstring > m_SubobjectName ;
2018-10-03 22:46:26 +00:00
std : : vector < LPCWSTR > m_Exports ;
} ;
//------------------------------------------------------------------------------------------------
2020-03-18 04:45:33 +00:00
class CD3DX12_HIT_GROUP_SUBOBJECT
2018-10-03 22:46:26 +00:00
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
2020-03-16 09:16:44 +00:00
CD3DX12_HIT_GROUP_SUBOBJECT ( ) noexcept
2018-10-03 22:46:26 +00:00
{
Init ( ) ;
}
CD3DX12_HIT_GROUP_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
2024-05-30 19:39:25 +00:00
CD3DX12_HIT_GROUP_SUBOBJECT ( const CD3DX12_HIT_GROUP_SUBOBJECT & other ) = delete ;
CD3DX12_HIT_GROUP_SUBOBJECT & operator = ( const CD3DX12_HIT_GROUP_SUBOBJECT & other ) = delete ;
CD3DX12_HIT_GROUP_SUBOBJECT ( CD3DX12_HIT_GROUP_SUBOBJECT & & other ) = default ;
CD3DX12_HIT_GROUP_SUBOBJECT & operator = ( CD3DX12_HIT_GROUP_SUBOBJECT & & other ) = default ;
2018-10-03 22:46:26 +00:00
void SetHitGroupExport ( LPCWSTR exportName )
2020-03-18 04:45:33 +00:00
{
m_Desc . HitGroupExport = m_Strings [ 0 ] . LocalCopy ( exportName , true ) ;
2018-10-03 22:46:26 +00:00
}
2020-03-16 09:16:44 +00:00
void SetHitGroupType ( D3D12_HIT_GROUP_TYPE Type ) noexcept { m_Desc . Type = Type ; }
2018-10-03 22:46:26 +00:00
void SetAnyHitShaderImport ( LPCWSTR importName )
2020-03-18 04:45:33 +00:00
{
m_Desc . AnyHitShaderImport = m_Strings [ 1 ] . LocalCopy ( importName , true ) ;
2018-10-03 22:46:26 +00:00
}
void SetClosestHitShaderImport ( LPCWSTR importName )
2020-03-18 04:45:33 +00:00
{
m_Desc . ClosestHitShaderImport = m_Strings [ 2 ] . LocalCopy ( importName , true ) ;
2018-10-03 22:46:26 +00:00
}
void SetIntersectionShaderImport ( LPCWSTR importName )
{
2020-03-18 04:45:33 +00:00
m_Desc . IntersectionShaderImport = m_Strings [ 3 ] . LocalCopy ( importName , true ) ;
2018-10-03 22:46:26 +00:00
}
2020-03-16 09:16:44 +00:00
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
2018-10-03 22:46:26 +00:00
{
2020-03-18 04:45:33 +00:00
return D3D12_STATE_SUBOBJECT_TYPE_HIT_GROUP ;
2018-10-03 22:46:26 +00:00
}
2020-03-16 09:16:44 +00:00
operator const D3D12_HIT_GROUP_DESC & ( ) const noexcept { return m_Desc ; }
2018-10-03 22:46:26 +00:00
private :
2020-03-16 09:16:44 +00:00
void Init ( ) noexcept
2018-10-03 22:46:26 +00:00
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
m_Desc = { } ;
for ( UINT i = 0 ; i < m_NumStrings ; i + + )
{
m_Strings [ i ] . clear ( ) ;
}
}
2020-03-16 09:16:44 +00:00
void * Data ( ) noexcept override { return & m_Desc ; }
2018-10-03 22:46:26 +00:00
D3D12_HIT_GROUP_DESC m_Desc ;
2021-10-22 23:43:43 +00:00
static constexpr UINT m_NumStrings = 4 ;
2024-05-17 23:56:19 +00:00
CD3DX12_STATE_OBJECT_DESC : : StringContainer < LPCWSTR , std : : wstring >
2018-10-03 22:46:26 +00:00
m_Strings [ m_NumStrings ] ; // one string for every entrypoint name
} ;
//------------------------------------------------------------------------------------------------
2020-03-18 04:45:33 +00:00
class CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT
2018-10-03 22:46:26 +00:00
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
2020-03-16 09:16:44 +00:00
CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT ( ) noexcept
2018-10-03 22:46:26 +00:00
{
Init ( ) ;
}
CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
2024-05-30 19:39:25 +00:00
CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT ( const CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT & other ) = delete ;
CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT & operator = ( const CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT & other ) = delete ;
CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT ( CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT & & other ) = default ;
CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT & operator = ( CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT & & other ) = default ;
2020-03-16 09:16:44 +00:00
void Config ( UINT MaxPayloadSizeInBytes , UINT MaxAttributeSizeInBytes ) noexcept
2018-10-03 22:46:26 +00:00
{
m_Desc . MaxPayloadSizeInBytes = MaxPayloadSizeInBytes ;
m_Desc . MaxAttributeSizeInBytes = MaxAttributeSizeInBytes ;
}
2020-03-16 09:16:44 +00:00
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
2020-03-18 04:45:33 +00:00
{
return D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_SHADER_CONFIG ;
2018-10-03 22:46:26 +00:00
}
2020-03-16 09:16:44 +00:00
operator const D3D12_RAYTRACING_SHADER_CONFIG & ( ) const noexcept { return m_Desc ; }
2018-10-03 22:46:26 +00:00
private :
2020-03-16 09:16:44 +00:00
void Init ( ) noexcept
2018-10-03 22:46:26 +00:00
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
m_Desc = { } ;
}
2020-03-16 09:16:44 +00:00
void * Data ( ) noexcept override { return & m_Desc ; }
2018-10-03 22:46:26 +00:00
D3D12_RAYTRACING_SHADER_CONFIG m_Desc ;
} ;
//------------------------------------------------------------------------------------------------
2020-03-18 04:45:33 +00:00
class CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT
2018-10-03 22:46:26 +00:00
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
2020-03-16 09:16:44 +00:00
CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT ( ) noexcept
2018-10-03 22:46:26 +00:00
{
Init ( ) ;
}
CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
2024-05-30 19:39:25 +00:00
CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT ( const CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT & other ) = delete ;
CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT & operator = ( const CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT & other ) = delete ;
CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT ( CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT & & other ) = default ;
CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT & operator = ( CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT & & other ) = default ;
2020-03-16 09:16:44 +00:00
void Config ( UINT MaxTraceRecursionDepth ) noexcept
2018-10-03 22:46:26 +00:00
{
m_Desc . MaxTraceRecursionDepth = MaxTraceRecursionDepth ;
}
2020-03-16 09:16:44 +00:00
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
2020-03-18 04:45:33 +00:00
{
return D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_PIPELINE_CONFIG ;
2018-10-03 22:46:26 +00:00
}
2020-03-16 09:16:44 +00:00
operator const D3D12_RAYTRACING_PIPELINE_CONFIG & ( ) const noexcept { return m_Desc ; }
2018-10-03 22:46:26 +00:00
private :
2020-03-16 09:16:44 +00:00
void Init ( ) noexcept
2018-10-03 22:46:26 +00:00
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
m_Desc = { } ;
}
2020-03-16 09:16:44 +00:00
void * Data ( ) noexcept override { return & m_Desc ; }
2018-10-03 22:46:26 +00:00
D3D12_RAYTRACING_PIPELINE_CONFIG m_Desc ;
} ;
//------------------------------------------------------------------------------------------------
2020-03-18 04:45:33 +00:00
class CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT ( ) noexcept
{
Init ( ) ;
}
CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
2024-05-30 19:39:25 +00:00
CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT ( const CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT & other ) = delete ;
CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT & operator = ( const CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT & other ) = delete ;
CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT ( CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT & & other ) = default ;
CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT & operator = ( CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT & & other ) = default ;
2020-03-18 04:45:33 +00:00
void Config ( UINT MaxTraceRecursionDepth , D3D12_RAYTRACING_PIPELINE_FLAGS Flags ) noexcept
{
m_Desc . MaxTraceRecursionDepth = MaxTraceRecursionDepth ;
m_Desc . Flags = Flags ;
}
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
{
return D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_PIPELINE_CONFIG1 ;
}
operator const D3D12_RAYTRACING_PIPELINE_CONFIG1 & ( ) const noexcept { return m_Desc ; }
private :
void Init ( ) noexcept
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
m_Desc = { } ;
}
void * Data ( ) noexcept override { return & m_Desc ; }
D3D12_RAYTRACING_PIPELINE_CONFIG1 m_Desc ;
} ;
//------------------------------------------------------------------------------------------------
class CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT
2018-10-03 22:46:26 +00:00
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
2020-03-16 09:16:44 +00:00
CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT ( ) noexcept
2018-10-03 22:46:26 +00:00
{
Init ( ) ;
}
CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
2024-05-30 19:39:25 +00:00
CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT ( const CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT & other ) = delete ;
CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT & operator = ( const CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT & other ) = delete ;
CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT ( CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT & & other ) = default ;
CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT & operator = ( CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT & & other ) = default ;
2020-03-16 09:16:44 +00:00
void SetRootSignature ( ID3D12RootSignature * pRootSig ) noexcept
2018-10-03 22:46:26 +00:00
{
m_pRootSig = pRootSig ;
}
2020-03-16 09:16:44 +00:00
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
2020-03-18 04:45:33 +00:00
{
return D3D12_STATE_SUBOBJECT_TYPE_GLOBAL_ROOT_SIGNATURE ;
2018-10-03 22:46:26 +00:00
}
2021-10-06 00:41:32 +00:00
operator ID3D12RootSignature * ( ) const noexcept { return D3DX12_COM_PTR_GET ( m_pRootSig ) ; }
2018-10-03 22:46:26 +00:00
private :
2020-03-16 09:16:44 +00:00
void Init ( ) noexcept
2018-10-03 22:46:26 +00:00
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
m_pRootSig = nullptr ;
}
2021-10-06 00:41:32 +00:00
void * Data ( ) noexcept override { return D3DX12_COM_PTR_ADDRESSOF ( m_pRootSig ) ; }
D3DX12_COM_PTR < ID3D12RootSignature > m_pRootSig ;
2018-10-03 22:46:26 +00:00
} ;
//------------------------------------------------------------------------------------------------
2020-03-18 04:45:33 +00:00
class CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT
2018-10-03 22:46:26 +00:00
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
2020-03-16 09:16:44 +00:00
CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT ( ) noexcept
2018-10-03 22:46:26 +00:00
{
Init ( ) ;
}
CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
2024-05-30 19:39:25 +00:00
CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT ( const CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT & other ) = delete ;
CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT & operator = ( const CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT & other ) = delete ;
CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT ( CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT & & other ) = default ;
CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT & operator = ( CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT & & other ) = default ;
2020-03-16 09:16:44 +00:00
void SetRootSignature ( ID3D12RootSignature * pRootSig ) noexcept
2018-10-03 22:46:26 +00:00
{
m_pRootSig = pRootSig ;
}
2020-03-16 09:16:44 +00:00
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
2020-03-18 04:45:33 +00:00
{
return D3D12_STATE_SUBOBJECT_TYPE_LOCAL_ROOT_SIGNATURE ;
2018-10-03 22:46:26 +00:00
}
2021-10-06 00:41:32 +00:00
operator ID3D12RootSignature * ( ) const noexcept { return D3DX12_COM_PTR_GET ( m_pRootSig ) ; }
2018-10-03 22:46:26 +00:00
private :
2020-03-16 09:16:44 +00:00
void Init ( ) noexcept
2018-10-03 22:46:26 +00:00
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
m_pRootSig = nullptr ;
}
2021-10-06 00:41:32 +00:00
void * Data ( ) noexcept override { return D3DX12_COM_PTR_ADDRESSOF ( m_pRootSig ) ; }
D3DX12_COM_PTR < ID3D12RootSignature > m_pRootSig ;
2018-10-03 22:46:26 +00:00
} ;
//------------------------------------------------------------------------------------------------
2020-03-18 04:45:33 +00:00
class CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT
2018-10-03 22:46:26 +00:00
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
2020-03-16 09:16:44 +00:00
CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT ( ) noexcept
2018-10-03 22:46:26 +00:00
{
Init ( ) ;
}
CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
2024-05-30 19:39:25 +00:00
CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT ( const CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT & other ) = delete ;
CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT & operator = ( const CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT & other ) = delete ;
CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT ( CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT & & other ) = default ;
CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT & operator = ( CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT & & other ) = default ;
2020-03-16 09:16:44 +00:00
void SetFlags ( D3D12_STATE_OBJECT_FLAGS Flags ) noexcept
2018-10-03 22:46:26 +00:00
{
m_Desc . Flags = Flags ;
}
2020-03-16 09:16:44 +00:00
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
2020-03-18 04:45:33 +00:00
{
return D3D12_STATE_SUBOBJECT_TYPE_STATE_OBJECT_CONFIG ;
2018-10-03 22:46:26 +00:00
}
2020-03-16 09:16:44 +00:00
operator const D3D12_STATE_OBJECT_CONFIG & ( ) const noexcept { return m_Desc ; }
2018-10-03 22:46:26 +00:00
private :
2020-03-16 09:16:44 +00:00
void Init ( ) noexcept
2018-10-03 22:46:26 +00:00
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
m_Desc = { } ;
}
2020-03-16 09:16:44 +00:00
void * Data ( ) noexcept override { return & m_Desc ; }
2018-10-03 22:46:26 +00:00
D3D12_STATE_OBJECT_CONFIG m_Desc ;
} ;
//------------------------------------------------------------------------------------------------
2020-03-18 04:45:33 +00:00
class CD3DX12_NODE_MASK_SUBOBJECT
2018-10-03 22:46:26 +00:00
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
2020-03-16 09:16:44 +00:00
CD3DX12_NODE_MASK_SUBOBJECT ( ) noexcept
2018-10-03 22:46:26 +00:00
{
Init ( ) ;
}
CD3DX12_NODE_MASK_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
2024-05-30 19:39:25 +00:00
CD3DX12_NODE_MASK_SUBOBJECT ( const CD3DX12_NODE_MASK_SUBOBJECT & other ) = delete ;
CD3DX12_NODE_MASK_SUBOBJECT & operator = ( const CD3DX12_NODE_MASK_SUBOBJECT & other ) = delete ;
CD3DX12_NODE_MASK_SUBOBJECT ( CD3DX12_NODE_MASK_SUBOBJECT & & other ) = default ;
CD3DX12_NODE_MASK_SUBOBJECT & operator = ( CD3DX12_NODE_MASK_SUBOBJECT & & other ) = default ;
2020-03-16 09:16:44 +00:00
void SetNodeMask ( UINT NodeMask ) noexcept
2018-10-03 22:46:26 +00:00
{
m_Desc . NodeMask = NodeMask ;
}
2020-03-16 09:16:44 +00:00
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
2020-03-18 04:45:33 +00:00
{
return D3D12_STATE_SUBOBJECT_TYPE_NODE_MASK ;
2018-10-03 22:46:26 +00:00
}
2020-03-16 09:16:44 +00:00
operator const D3D12_NODE_MASK & ( ) const noexcept { return m_Desc ; }
2018-10-03 22:46:26 +00:00
private :
2020-03-16 09:16:44 +00:00
void Init ( ) noexcept
2018-10-03 22:46:26 +00:00
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
m_Desc = { } ;
}
2020-03-16 09:16:44 +00:00
void * Data ( ) noexcept override { return & m_Desc ; }
2018-10-03 22:46:26 +00:00
D3D12_NODE_MASK m_Desc ;
} ;
2024-05-17 23:56:19 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612)
//------------------------------------------------------------------------------------------------
class CD3DX12_STREAM_OUTPUT_SUBOBJECT
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
2022-05-08 21:25:55 +00:00
{
public :
2024-05-17 23:56:19 +00:00
CD3DX12_STREAM_OUTPUT_SUBOBJECT ( )
{
Init ( ) ;
}
CD3DX12_STREAM_OUTPUT_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
void SetSODeclEntries ( const D3D12_SO_DECLARATION_ENTRY * soDeclEntries , UINT numEntries )
{
m_soDecalEntries . resize ( numEntries ) ;
for ( UINT i = 0 ; i < numEntries ; i + + )
2022-05-08 21:25:55 +00:00
{
2024-05-17 23:56:19 +00:00
m_soDecalEntries [ i ] = D3D12_SO_DECLARATION_ENTRY {
soDeclEntries [ i ] . Stream ,
m_Strings . LocalCopy ( soDeclEntries [ i ] . SemanticName ) ,
soDeclEntries [ i ] . SemanticIndex ,
soDeclEntries [ i ] . StartComponent ,
soDeclEntries [ i ] . ComponentCount ,
soDeclEntries [ i ] . OutputSlot
} ;
2022-05-08 21:25:55 +00:00
}
2024-05-17 23:56:19 +00:00
// Below: using ugly way to get pointer in case .data() is not defined
m_Desc . pSODeclaration = & m_soDecalEntries [ 0 ] ;
m_Desc . NumEntries = numEntries ;
}
void SetBufferStrides ( const UINT * bufferStrides , UINT numStrides )
{
m_Desc . pBufferStrides = bufferStrides ;
m_Desc . NumStrides = numStrides ;
}
void SetRasterizedStream ( UINT rasterizedStream )
{
m_Desc . RasterizedStream = rasterizedStream ;
}
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
{
return D3D12_STATE_SUBOBJECT_TYPE_STREAM_OUTPUT ;
}
operator const D3D12_STREAM_OUTPUT_DESC & ( ) const noexcept { return m_Desc ; }
private :
void Init ( )
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
m_Desc = { } ;
}
void * Data ( ) noexcept override { return & m_Desc ; }
D3D12_STREAM_OUTPUT_DESC m_Desc ;
CD3DX12_STATE_OBJECT_DESC : : StringContainer < LPCSTR , std : : string > m_Strings ;
std : : vector < D3D12_SO_DECLARATION_ENTRY > m_soDecalEntries ;
2022-05-08 21:25:55 +00:00
} ;
2024-05-17 23:56:19 +00:00
//------------------------------------------------------------------------------------------------
class CD3DX12_BLEND_SUBOBJECT
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
2022-05-08 21:25:55 +00:00
{
public :
2024-05-17 23:56:19 +00:00
CD3DX12_BLEND_SUBOBJECT ( )
{
Init ( ) ;
}
CD3DX12_BLEND_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
void SetAlphaToCoverageEnable ( bool alphaToCoverageEnable )
{
m_Desc . AlphaToCoverageEnable = alphaToCoverageEnable ;
}
void SetIndependentBlendEnable ( bool independentBlendEnable )
{
m_Desc . IndependentBlendEnable = independentBlendEnable ;
}
void SetRenderTarget ( UINT renderTargetIndex , const D3D12_RENDER_TARGET_BLEND_DESC & renderTargetBlendDesc )
{
m_Desc . RenderTarget [ renderTargetIndex ] . BlendEnable = renderTargetBlendDesc . BlendEnable ;
m_Desc . RenderTarget [ renderTargetIndex ] . BlendOp = renderTargetBlendDesc . BlendOp ;
m_Desc . RenderTarget [ renderTargetIndex ] . BlendOpAlpha = renderTargetBlendDesc . BlendOpAlpha ;
m_Desc . RenderTarget [ renderTargetIndex ] . DestBlend = renderTargetBlendDesc . DestBlend ;
m_Desc . RenderTarget [ renderTargetIndex ] . DestBlendAlpha = renderTargetBlendDesc . DestBlendAlpha ;
m_Desc . RenderTarget [ renderTargetIndex ] . LogicOp = renderTargetBlendDesc . LogicOp ;
m_Desc . RenderTarget [ renderTargetIndex ] . LogicOpEnable = renderTargetBlendDesc . LogicOpEnable ;
m_Desc . RenderTarget [ renderTargetIndex ] . RenderTargetWriteMask = renderTargetBlendDesc . RenderTargetWriteMask ;
m_Desc . RenderTarget [ renderTargetIndex ] . SrcBlend = renderTargetBlendDesc . SrcBlend ;
m_Desc . RenderTarget [ renderTargetIndex ] . SrcBlendAlpha = renderTargetBlendDesc . SrcBlendAlpha ;
}
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
{
return D3D12_STATE_SUBOBJECT_TYPE_BLEND ;
}
operator const D3D12_BLEND_DESC & ( ) const noexcept { return m_Desc ; }
private :
void Init ( ) noexcept
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
m_Desc = CD3DX12_BLEND_DESC ( D3D12_DEFAULT ) ;
}
void * Data ( ) noexcept override { return & m_Desc ; }
CD3DX12_BLEND_DESC m_Desc ;
2022-05-08 21:25:55 +00:00
} ;
2024-05-17 23:56:19 +00:00
//------------------------------------------------------------------------------------------------
class CD3DX12_RASTERIZER_SUBOBJECT
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
2022-05-08 21:25:55 +00:00
{
public :
2024-05-17 23:56:19 +00:00
CD3DX12_RASTERIZER_SUBOBJECT ( )
{
Init ( ) ;
}
CD3DX12_RASTERIZER_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
void SetFillMode ( D3D12_FILL_MODE fillMode )
{
m_Desc . FillMode = fillMode ;
}
void SetCullMode ( D3D12_CULL_MODE cullMode )
{
m_Desc . CullMode = cullMode ;
}
void SetFrontCounterClockwise ( BOOL frontCounterClockwise )
{
m_Desc . FrontCounterClockwise = frontCounterClockwise ;
}
void SetDepthBias ( FLOAT depthBias )
{
m_Desc . DepthBias = depthBias ;
}
void SetDepthBiasClamp ( FLOAT depthBiasClamp )
{
m_Desc . DepthBiasClamp = depthBiasClamp ;
}
void SetSlopeScaledDepthBias ( FLOAT slopeScaledDepthBias )
{
m_Desc . SlopeScaledDepthBias = slopeScaledDepthBias ;
}
void SetDepthClipEnable ( BOOL depthClipEnable )
{
m_Desc . DepthClipEnable = depthClipEnable ;
}
void SetLineRasterizationMode ( D3D12_LINE_RASTERIZATION_MODE lineRasterizationMode )
{
m_Desc . LineRasterizationMode = lineRasterizationMode ;
}
void SetForcedSampleCount ( UINT forcedSampleCount )
{
m_Desc . ForcedSampleCount = forcedSampleCount ;
}
void SetConservativeRaster ( D3D12_CONSERVATIVE_RASTERIZATION_MODE conservativeRaster )
{
m_Desc . ConservativeRaster = conservativeRaster ;
}
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
{
return D3D12_STATE_SUBOBJECT_TYPE_RASTERIZER ;
}
operator const D3D12_RASTERIZER_DESC2 & ( ) const noexcept { return m_Desc ; }
private :
void Init ( ) noexcept
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
m_Desc = CD3DX12_RASTERIZER_DESC2 ( D3D12_DEFAULT ) ;
}
void * Data ( ) noexcept override { return & m_Desc ; }
CD3DX12_RASTERIZER_DESC2 m_Desc ;
} ;
//------------------------------------------------------------------------------------------------
class CD3DX12_DEPTH_STENCIL2_SUBOBJECT
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
CD3DX12_DEPTH_STENCIL2_SUBOBJECT ( )
{
Init ( ) ;
}
CD3DX12_DEPTH_STENCIL2_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
void SetDepthEnable ( BOOL depthEnable )
{
m_Desc . DepthEnable = depthEnable ;
}
void SetDepthWriteMask ( D3D12_DEPTH_WRITE_MASK depthWriteMask )
{
m_Desc . DepthWriteMask = depthWriteMask ;
}
void SetDepthFunc ( D3D12_COMPARISON_FUNC depthFunc )
{
m_Desc . DepthFunc = depthFunc ;
}
void SetStencilEnable ( BOOL stencilEnable )
{
m_Desc . StencilEnable = stencilEnable ;
}
void SetFrontFace ( D3D12_DEPTH_STENCILOP_DESC1 frontFace )
{
m_Desc . FrontFace = {
frontFace . StencilFailOp ,
frontFace . StencilDepthFailOp ,
frontFace . StencilPassOp ,
frontFace . StencilFunc ,
frontFace . StencilReadMask ,
frontFace . StencilWriteMask
} ;
}
void SetBackFace ( D3D12_DEPTH_STENCILOP_DESC1 backFace )
{
m_Desc . BackFace = {
backFace . StencilFailOp ,
backFace . StencilDepthFailOp ,
backFace . StencilPassOp ,
backFace . StencilFunc ,
backFace . StencilReadMask ,
backFace . StencilWriteMask
} ;
}
void SetDepthBoundsTestEnable ( BOOL depthBoundsTestEnable )
{
m_Desc . DepthBoundsTestEnable = depthBoundsTestEnable ;
}
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
{
return D3D12_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL2 ;
}
operator const D3D12_DEPTH_STENCIL_DESC2 & ( ) const noexcept { return m_Desc ; }
private :
void Init ( ) noexcept
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
m_Desc = CD3DX12_DEPTH_STENCIL_DESC2 ( D3D12_DEFAULT ) ;
}
void * Data ( ) noexcept override { return & m_Desc ; }
CD3DX12_DEPTH_STENCIL_DESC2 m_Desc ;
} ;
//------------------------------------------------------------------------------------------------
class CD3DX12_INPUT_LAYOUT_SUBOBJECT
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
CD3DX12_INPUT_LAYOUT_SUBOBJECT ( )
{
Init ( ) ;
}
CD3DX12_INPUT_LAYOUT_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
void AddInputLayoutElementDesc ( D3D12_INPUT_ELEMENT_DESC inputLayoutElementDesc )
{
m_inputLayoutElements . emplace_back (
D3D12_INPUT_ELEMENT_DESC {
m_Strings . LocalCopy ( inputLayoutElementDesc . SemanticName ) ,
inputLayoutElementDesc . SemanticIndex ,
inputLayoutElementDesc . Format ,
inputLayoutElementDesc . InputSlot ,
inputLayoutElementDesc . AlignedByteOffset ,
inputLayoutElementDesc . InputSlotClass ,
inputLayoutElementDesc . InstanceDataStepRate
} ) ;
+ + m_numElements ;
}
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
{
return D3D12_STATE_SUBOBJECT_TYPE_INPUT_LAYOUT ;
}
operator const D3D12_INPUT_LAYOUT_DESC & ( ) const noexcept { return m_Desc ; }
virtual void Finalize ( ) override
{
if ( m_numElements > 0 )
{
std : : list < D3D12_INPUT_ELEMENT_DESC > : : iterator inputLayoutIt = m_inputLayoutElements . begin ( ) ;
m_inputLayoutElementsVector . resize ( m_numElements ) ;
for ( UINT i = 0 ; inputLayoutIt ! = m_inputLayoutElements . end ( ) ; i + + , inputLayoutIt + + )
{
m_inputLayoutElementsVector [ i ] = * inputLayoutIt ;
}
// Below: using ugly way to get pointer in case .data() is not defined
m_Desc . pInputElementDescs = & m_inputLayoutElementsVector [ 0 ] ;
}
m_Desc . NumElements = m_numElements ;
}
private :
void Init ( ) noexcept
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
m_Desc = { } ;
m_Desc . pInputElementDescs = nullptr ;
m_numElements = 0 ;
m_inputLayoutElements . clear ( ) ;
m_inputLayoutElementsVector . clear ( ) ;
}
void * Data ( ) noexcept override { return & m_Desc ; }
D3D12_INPUT_LAYOUT_DESC m_Desc ;
std : : list < D3D12_INPUT_ELEMENT_DESC > m_inputLayoutElements ;
std : : vector < D3D12_INPUT_ELEMENT_DESC > m_inputLayoutElementsVector ;
UINT m_numElements ;
CD3DX12_STATE_OBJECT_DESC : : StringContainer < LPCSTR , std : : string > m_Strings ;
} ;
//------------------------------------------------------------------------------------------------
class CD3DX12_IB_STRIP_CUT_VALUE_SUBOBJECT
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
CD3DX12_IB_STRIP_CUT_VALUE_SUBOBJECT ( )
{
Init ( ) ;
}
CD3DX12_IB_STRIP_CUT_VALUE_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
void SetIBStripCutValue ( D3D12_INDEX_BUFFER_STRIP_CUT_VALUE ibStripCutValue )
{
m_Desc = ibStripCutValue ;
}
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
{
return D3D12_STATE_SUBOBJECT_TYPE_IB_STRIP_CUT_VALUE ;
}
operator const D3D12_INDEX_BUFFER_STRIP_CUT_VALUE & ( ) const noexcept { return m_Desc ; }
private :
void Init ( ) noexcept
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
}
void * Data ( ) noexcept override { return & m_Desc ; }
D3D12_INDEX_BUFFER_STRIP_CUT_VALUE m_Desc ;
} ;
//------------------------------------------------------------------------------------------------
class CD3DX12_PRIMITIVE_TOPOLOGY_SUBOBJECT
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
CD3DX12_PRIMITIVE_TOPOLOGY_SUBOBJECT ( )
{
Init ( ) ;
}
CD3DX12_PRIMITIVE_TOPOLOGY_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
void SetPrimitiveTopologyType ( D3D12_PRIMITIVE_TOPOLOGY_TYPE primitiveTopologytype )
{
m_Desc = primitiveTopologytype ;
}
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
{
return D3D12_STATE_SUBOBJECT_TYPE_PRIMITIVE_TOPOLOGY ;
}
operator const D3D12_PRIMITIVE_TOPOLOGY_TYPE & ( ) const noexcept { return m_Desc ; }
private :
void Init ( ) noexcept
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
}
void * Data ( ) noexcept override { return & m_Desc ; }
D3D12_PRIMITIVE_TOPOLOGY_TYPE m_Desc ;
} ;
//------------------------------------------------------------------------------------------------
class CD3DX12_RENDER_TARGET_FORMATS_SUBOBJECT
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
CD3DX12_RENDER_TARGET_FORMATS_SUBOBJECT ( )
{
Init ( ) ;
}
CD3DX12_RENDER_TARGET_FORMATS_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
void SetNumRenderTargets ( UINT numRenderTargets )
{
m_Desc . NumRenderTargets = numRenderTargets ;
}
void SetRenderTargetFormat ( UINT renderTarget , DXGI_FORMAT renderTargetFormat )
{
m_Desc . RTFormats [ renderTarget ] = renderTargetFormat ;
}
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
{
return D3D12_STATE_SUBOBJECT_TYPE_RENDER_TARGET_FORMATS ;
}
operator const D3D12_RT_FORMAT_ARRAY & ( ) const noexcept { return m_Desc ; }
private :
void Init ( ) noexcept
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
m_Desc = { } ;
}
void * Data ( ) noexcept override { return & m_Desc ; }
D3D12_RT_FORMAT_ARRAY m_Desc ;
} ;
//------------------------------------------------------------------------------------------------
class CD3DX12_DEPTH_STENCIL_FORMAT_SUBOBJECT
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
CD3DX12_DEPTH_STENCIL_FORMAT_SUBOBJECT ( )
{
Init ( ) ;
}
CD3DX12_DEPTH_STENCIL_FORMAT_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
void SetDepthStencilFormat ( DXGI_FORMAT depthStencilFormat )
{
m_Desc = depthStencilFormat ;
}
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
{
return D3D12_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL_FORMAT ;
}
operator const DXGI_FORMAT & ( ) const noexcept { return m_Desc ; }
private :
void Init ( ) noexcept
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
}
void * Data ( ) noexcept override { return & m_Desc ; }
DXGI_FORMAT m_Desc ;
} ;
//------------------------------------------------------------------------------------------------
class CD3DX12_SAMPLE_DESC_SUBOBJECT
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
CD3DX12_SAMPLE_DESC_SUBOBJECT ( )
{
Init ( ) ;
}
CD3DX12_SAMPLE_DESC_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
void SetCount ( UINT count )
{
m_Desc . Count = count ;
}
void SetQuality ( UINT quality )
{
m_Desc . Quality = quality ;
}
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
{
return D3D12_STATE_SUBOBJECT_TYPE_SAMPLE_DESC ;
}
operator const DXGI_SAMPLE_DESC & ( ) const noexcept { return m_Desc ; }
private :
void Init ( ) noexcept
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
m_Desc = { } ;
}
void * Data ( ) noexcept override { return & m_Desc ; }
DXGI_SAMPLE_DESC m_Desc ;
} ;
//------------------------------------------------------------------------------------------------
class CD3DX12_FLAGS_SUBOBJECT
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
CD3DX12_FLAGS_SUBOBJECT ( )
{
Init ( ) ;
}
CD3DX12_FLAGS_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
void SetFlags ( D3D12_PIPELINE_STATE_FLAGS flags )
{
m_Desc = flags ;
}
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
{
return D3D12_STATE_SUBOBJECT_TYPE_FLAGS ;
}
operator const D3D12_PIPELINE_STATE_FLAGS & ( ) const noexcept { return m_Desc ; }
private :
void Init ( ) noexcept
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
m_Desc = { } ;
}
void * Data ( ) noexcept override { return & m_Desc ; }
D3D12_PIPELINE_STATE_FLAGS m_Desc ;
} ;
//------------------------------------------------------------------------------------------------
class CD3DX12_VIEW_INSTANCING_SUBOBJECT
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
CD3DX12_VIEW_INSTANCING_SUBOBJECT ( )
{
Init ( ) ;
}
CD3DX12_VIEW_INSTANCING_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
void AddViewInstanceLocation ( D3D12_VIEW_INSTANCE_LOCATION viewInstanceLocation )
{
m_viewInstanceCount + + ;
m_viewInstanceLocations . emplace_back (
D3D12_VIEW_INSTANCE_LOCATION
{
viewInstanceLocation . ViewportArrayIndex ,
viewInstanceLocation . RenderTargetArrayIndex
}
) ;
}
void SetFlags ( D3D12_VIEW_INSTANCING_FLAGS flags )
{
m_Desc . Flags = flags ;
}
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
{
return D3D12_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING ;
}
operator const D3D12_VIEW_INSTANCING_DESC & ( ) const noexcept { return m_Desc ; }
virtual void Finalize ( ) override
{
if ( m_viewInstanceCount > 0 )
{
m_viewInstanceLocationsVector . resize ( m_viewInstanceCount ) ;
std : : list < D3D12_VIEW_INSTANCE_LOCATION > : : iterator viewInstancingLocationIt = m_viewInstanceLocations . begin ( ) ;
for ( UINT i = 0 ; viewInstancingLocationIt ! = m_viewInstanceLocations . end ( ) ; i + + , viewInstancingLocationIt + + )
{
m_viewInstanceLocationsVector [ i ] = * viewInstancingLocationIt ;
}
// Below: using ugly way to get pointer in case .data() is not defined
m_Desc . pViewInstanceLocations = & m_viewInstanceLocationsVector [ 0 ] ;
}
m_Desc . ViewInstanceCount = m_viewInstanceCount ;
}
private :
void Init ( ) noexcept
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
m_Desc = CD3DX12_VIEW_INSTANCING_DESC ( D3D12_DEFAULT ) ;
m_viewInstanceCount = 0 ;
m_viewInstanceLocations . clear ( ) ;
m_viewInstanceLocationsVector . clear ( ) ;
}
void * Data ( ) noexcept override { return & m_Desc ; }
CD3DX12_VIEW_INSTANCING_DESC m_Desc ;
UINT m_viewInstanceCount ;
std : : list < D3D12_VIEW_INSTANCE_LOCATION > m_viewInstanceLocations ;
std : : vector < D3D12_VIEW_INSTANCE_LOCATION > m_viewInstanceLocationsVector ;
} ;
//------------------------------------------------------------------------------------------------
class CD3DX12_DEPTH_STENCIL_SUBOBJECT
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
CD3DX12_DEPTH_STENCIL_SUBOBJECT ( )
{
Init ( ) ;
}
CD3DX12_DEPTH_STENCIL_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
void SetDepthEnable ( BOOL depthEnable )
{
m_Desc . DepthEnable = depthEnable ;
}
void SetDepthWriteMask ( D3D12_DEPTH_WRITE_MASK depthWriteMask )
{
m_Desc . DepthWriteMask = depthWriteMask ;
}
void SetDepthFunc ( D3D12_COMPARISON_FUNC depthFunc )
{
m_Desc . DepthFunc = depthFunc ;
}
void SetStencilEnable ( BOOL stencilEnable )
{
m_Desc . StencilEnable = stencilEnable ;
}
void SetStencilReadMask ( UINT8 stencilReadMask )
{
m_Desc . StencilReadMask = stencilReadMask ;
}
void SetStencilWriteMask ( UINT8 stencilWriteMask )
{
m_Desc . StencilWriteMask = stencilWriteMask ;
}
void SetFrontFace ( D3D12_DEPTH_STENCILOP_DESC frontFace )
{
m_Desc . FrontFace = {
frontFace . StencilFailOp ,
frontFace . StencilDepthFailOp ,
frontFace . StencilPassOp ,
frontFace . StencilFunc
} ;
}
void SetBackFace ( D3D12_DEPTH_STENCILOP_DESC backFace )
{
m_Desc . BackFace = {
backFace . StencilFailOp ,
backFace . StencilDepthFailOp ,
backFace . StencilPassOp ,
backFace . StencilFunc
} ;
}
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
{
return D3D12_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL ;
}
operator const D3D12_DEPTH_STENCIL_DESC & ( ) const noexcept { return m_Desc ; }
private :
void Init ( ) noexcept
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
m_Desc = CD3DX12_DEPTH_STENCIL_DESC ( D3D12_DEFAULT ) ;
}
void * Data ( ) noexcept override { return & m_Desc ; }
CD3DX12_DEPTH_STENCIL_DESC m_Desc ;
} ;
//------------------------------------------------------------------------------------------------
class CD3DX12_DEPTH_STENCIL1_SUBOBJECT
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
CD3DX12_DEPTH_STENCIL1_SUBOBJECT ( )
{
Init ( ) ;
}
CD3DX12_DEPTH_STENCIL1_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
void SetDepthEnable ( BOOL depthEnable )
{
m_Desc . DepthEnable = depthEnable ;
}
void SetDepthWriteMask ( D3D12_DEPTH_WRITE_MASK depthWriteMask )
{
m_Desc . DepthWriteMask = depthWriteMask ;
}
void SetDepthFunc ( D3D12_COMPARISON_FUNC depthFunc )
{
m_Desc . DepthFunc = depthFunc ;
}
void SetStencilEnable ( BOOL stencilEnable )
{
m_Desc . StencilEnable = stencilEnable ;
}
void SetStencilReadMask ( UINT8 stencilReadMask )
{
m_Desc . StencilReadMask = stencilReadMask ;
}
void SetStencilWriteMask ( UINT8 stencilWriteMask )
{
m_Desc . StencilWriteMask = stencilWriteMask ;
}
void SetFrontFace ( D3D12_DEPTH_STENCILOP_DESC frontFace )
{
m_Desc . FrontFace = {
frontFace . StencilFailOp ,
frontFace . StencilDepthFailOp ,
frontFace . StencilPassOp ,
frontFace . StencilFunc
} ;
}
void SetBackFace ( D3D12_DEPTH_STENCILOP_DESC backFace )
{
m_Desc . BackFace = {
backFace . StencilFailOp ,
backFace . StencilDepthFailOp ,
backFace . StencilPassOp ,
backFace . StencilFunc
} ;
}
void SetDepthBoundsTestEnable ( BOOL depthBoundsTestEnable )
{
m_Desc . DepthBoundsTestEnable = depthBoundsTestEnable ;
}
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
{
return D3D12_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1 ;
}
operator const D3D12_DEPTH_STENCIL_DESC1 & ( ) const noexcept { return m_Desc ; }
private :
void Init ( ) noexcept
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
m_Desc = CD3DX12_DEPTH_STENCIL_DESC1 ( D3D12_DEFAULT ) ;
}
void * Data ( ) noexcept override { return & m_Desc ; }
CD3DX12_DEPTH_STENCIL_DESC1 m_Desc ;
} ;
//------------------------------------------------------------------------------------------------
class CD3DX12_SAMPLE_MASK_SUBOBJECT
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
CD3DX12_SAMPLE_MASK_SUBOBJECT ( )
{
Init ( ) ;
}
CD3DX12_SAMPLE_MASK_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
void SetSampleMask ( UINT sampleMask )
{
m_Desc = sampleMask ;
}
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
{
return D3D12_STATE_SUBOBJECT_TYPE_SAMPLE_MASK ;
}
operator const UINT & ( ) const noexcept { return m_Desc ; }
private :
void Init ( ) noexcept
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
}
void * Data ( ) noexcept override { return & m_Desc ; }
UINT m_Desc ;
} ;
//------------------------------------------------------------------------------------------------
class CD3DX12_GENERIC_PROGRAM_SUBOBJECT
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
CD3DX12_GENERIC_PROGRAM_SUBOBJECT ( )
{
Init ( ) ;
}
CD3DX12_GENERIC_PROGRAM_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
void SetProgramName ( LPCWSTR ProgramName )
{
m_Desc . ProgramName = m_Strings . LocalCopy ( ProgramName ) ;
}
void AddExport ( LPCWSTR exportName )
{
m_Exports . emplace_back ( m_Strings . LocalCopy ( exportName ) ) ;
m_numExports + + ;
}
void AddSubobject ( const D3D12_STATE_SUBOBJECT & subobject )
{
m_Subobjects . emplace_back ( & subobject ) ;
m_numSubobjects + + ;
}
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
{
return D3D12_STATE_SUBOBJECT_TYPE_GENERIC_PROGRAM ;
}
operator const D3D12_GENERIC_PROGRAM_DESC & ( ) const noexcept { return m_Desc ; }
virtual void Finalize ( ) override
{
// Set exports
if ( m_numExports > 0 )
{
m_ExportsVector . resize ( m_numExports ) ;
std : : list < LPCWSTR > : : iterator exportIt = m_Exports . begin ( ) ;
for ( UINT i = 0 ; exportIt ! = m_Exports . end ( ) ; i + + , exportIt + + )
{
m_ExportsVector [ i ] = * exportIt ;
}
// Below: using ugly way to get pointer in case .data() is not defined
m_Desc . pExports = & m_ExportsVector [ 0 ] ;
}
else
{
m_Desc . pExports = nullptr ;
}
m_Desc . NumExports = m_numExports ;
// Set subobjects
if ( m_numSubobjects > 0 )
{
m_SubobjectsVector . resize ( m_numSubobjects ) ;
std : : list < D3D12_STATE_SUBOBJECT const * > : : iterator subobjectIt = m_Subobjects . begin ( ) ;
for ( UINT i = 0 ; subobjectIt ! = m_Subobjects . end ( ) ; i + + , subobjectIt + + )
{
m_SubobjectsVector [ i ] = * subobjectIt ;
}
// Below: using ugly way to get pointer in case .data() is not defined
m_Desc . ppSubobjects = & m_SubobjectsVector [ 0 ] ;
}
else
{
m_Desc . ppSubobjects = nullptr ;
}
m_Desc . NumSubobjects = m_numSubobjects ;
}
private :
void Init ( ) noexcept
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
m_Desc = { } ;
m_numExports = 0 ;
m_numSubobjects = 0 ;
}
void * Data ( ) noexcept override { return & m_Desc ; }
D3D12_GENERIC_PROGRAM_DESC m_Desc ;
std : : list < LPCWSTR > m_Exports ;
std : : vector < LPCWSTR > m_ExportsVector ;
UINT m_numExports ;
std : : list < D3D12_STATE_SUBOBJECT const * > m_Subobjects ;
std : : vector < D3D12_STATE_SUBOBJECT const * > m_SubobjectsVector ;
UINT m_numSubobjects ;
CD3DX12_STATE_OBJECT_DESC : : StringContainer < LPCWSTR , std : : wstring > m_Strings ;
} ;
//------------------------------------------------------------------------------------------------
class CD3DX12_NODE_OUTPUT_OVERRIDES
{
public :
CD3DX12_NODE_OUTPUT_OVERRIDES ( const D3D12_NODE_OUTPUT_OVERRIDES * * ppOwner , UINT * pNumOutputOverrides ) noexcept
{
m_Desc . clear ( ) ;
m_ppOwner = ppOwner ;
* m_ppOwner = nullptr ;
m_pNumOutputOverrides = pNumOutputOverrides ;
* m_pNumOutputOverrides = 0 ;
}
void NewOutputOverride ( )
{
m_Desc . emplace_back ( D3D12_NODE_OUTPUT_OVERRIDES { } ) ;
* m_ppOwner = m_Desc . data ( ) ;
( * m_pNumOutputOverrides ) + + ;
}
void OutputIndex ( UINT index )
{
m_Desc . back ( ) . OutputIndex = index ;
}
void NewName ( LPCWSTR Name , UINT ArrayIndex = 0 )
{
m_NodeIDs . emplace_front ( D3D12_NODE_ID { m_Strings . LocalCopy ( Name ) , ArrayIndex } ) ;
m_Desc . back ( ) . pNewName = & m_NodeIDs . front ( ) ;
}
void AllowSparseNodes ( BOOL bAllow )
{
m_UINTs . emplace_front ( ( UINT ) bAllow ) ;
m_Desc . back ( ) . pAllowSparseNodes = ( BOOL * ) & m_UINTs . front ( ) ;
}
void MaxOutputRecords ( UINT maxOutputRecords ) noexcept
{
m_UINTs . emplace_front ( maxOutputRecords ) ;
m_Desc . back ( ) . pMaxRecords = & m_UINTs . front ( ) ;
}
void MaxOutputRecordsSharedWith ( UINT outputIndex ) noexcept
{
m_UINTs . emplace_front ( outputIndex ) ;
m_Desc . back ( ) . pMaxRecordsSharedWithOutputIndex = & m_UINTs . front ( ) ;
}
private :
std : : vector < D3D12_NODE_OUTPUT_OVERRIDES > m_Desc ;
// Cached parameters
CD3DX12_STATE_OBJECT_DESC : : StringContainer < LPCWSTR , std : : wstring > m_Strings ;
std : : forward_list < UINT > m_UINTs ;
std : : forward_list < D3D12_NODE_ID > m_NodeIDs ;
const D3D12_NODE_OUTPUT_OVERRIDES * * m_ppOwner ;
UINT * m_pNumOutputOverrides ;
} ;
//------------------------------------------------------------------------------------------------
class CD3DX12_NODE_HELPER_BASE
{
public :
virtual ~ CD3DX12_NODE_HELPER_BASE ( ) = default ;
} ;
//------------------------------------------------------------------------------------------------
class CD3DX12_SHADER_NODE // Not specifying launch mode.
// Don't need to distinguish if no parameter overriding is happening
: public CD3DX12_NODE_HELPER_BASE
{
public :
CD3DX12_SHADER_NODE (
D3D12_NODE * pNode ,
LPCWSTR _Shader = nullptr )
{
m_pDesc = pNode ;
m_pDesc - > NodeType = D3D12_NODE_TYPE_SHADER ;
Shader ( _Shader ) ;
}
void Shader ( LPCWSTR _Shader )
{
m_pDesc - > Shader . Shader = m_Strings . LocalCopy ( _Shader ) ;
}
D3D12_NODE * m_pDesc ;
private :
CD3DX12_STATE_OBJECT_DESC : : StringContainer < LPCWSTR , std : : wstring > m_Strings ;
} ;
//------------------------------------------------------------------------------------------------
// Use this class when defining a broadcasting launch node where configuration parameters
// need to be overridden. If overrides are not needed, just use CD3DX12_COMPUTE_SHADER_NODE
class CD3DX12_BROADCASTING_LAUNCH_NODE_OVERRIDES
: public CD3DX12_NODE_HELPER_BASE
{
public :
CD3DX12_BROADCASTING_LAUNCH_NODE_OVERRIDES (
D3D12_NODE * pNode ,
LPCWSTR _Shader = nullptr ) :
m_NodeOutputOverrides ( & Overrides . pOutputOverrides , & Overrides . NumOutputOverrides )
{
Overrides = { } ;
m_pDesc = pNode ;
m_pDesc - > NodeType = D3D12_NODE_TYPE_SHADER ;
m_pDesc - > Shader . OverridesType = D3D12_NODE_OVERRIDES_TYPE_BROADCASTING_LAUNCH ;
m_pDesc - > Shader . pBroadcastingLaunchOverrides = & Overrides ;
Shader ( _Shader ) ;
}
void Shader ( LPCWSTR _Shader )
{
m_pDesc - > Shader . Shader = m_Strings . LocalCopy ( _Shader ) ;
}
void LocalRootArgumentsTableIndex ( UINT index )
{
m_UINTs . emplace_front ( index ) ;
Overrides . pLocalRootArgumentsTableIndex = & m_UINTs . front ( ) ;
}
void ProgramEntry ( BOOL bIsProgramEntry )
{
m_UINTs . emplace_front ( bIsProgramEntry ) ;
Overrides . pProgramEntry = ( BOOL * ) & m_UINTs . front ( ) ;
}
void NewName ( D3D12_NODE_ID NodeID )
{
m_NodeIDs . emplace_front ( D3D12_NODE_ID { m_Strings . LocalCopy ( NodeID . Name ) , NodeID . ArrayIndex } ) ;
Overrides . pNewName = & m_NodeIDs . front ( ) ;
}
void ShareInputOf ( D3D12_NODE_ID NodeID )
{
m_NodeIDs . emplace_front ( D3D12_NODE_ID { m_Strings . LocalCopy ( NodeID . Name ) , NodeID . ArrayIndex } ) ;
Overrides . pShareInputOf = & m_NodeIDs . front ( ) ;
}
void DispatchGrid ( UINT x , UINT y , UINT z )
{
m_UINT3s . emplace_front ( UINT3 { x , y , z } ) ;
Overrides . pDispatchGrid = ( UINT * ) & m_UINT3s . front ( ) ;
}
void MaxDispatchGrid ( UINT x , UINT y , UINT z )
{
m_UINT3s . emplace_front ( UINT3 { x , y , z } ) ;
Overrides . pMaxDispatchGrid = ( UINT * ) & m_UINT3s . front ( ) ;
}
CD3DX12_NODE_OUTPUT_OVERRIDES & NodeOutputOverrides ( )
{
return m_NodeOutputOverrides ;
}
D3D12_BROADCASTING_LAUNCH_OVERRIDES Overrides ;
D3D12_NODE * m_pDesc ;
private :
// Cached parameters
CD3DX12_STATE_OBJECT_DESC : : StringContainer < LPCWSTR , std : : wstring > m_Strings ;
std : : forward_list < UINT > m_UINTs ;
struct UINT3
{
UINT x ;
UINT y ;
UINT z ;
} ;
std : : forward_list < UINT3 > m_UINT3s ;
std : : forward_list < D3D12_NODE_ID > m_NodeIDs ;
CD3DX12_NODE_OUTPUT_OVERRIDES m_NodeOutputOverrides ;
} ;
//------------------------------------------------------------------------------------------------
// Use this class when defining a coalescing launch node where configuration parameters
// need to be overridden. If overrides are not needed, just use CD3DX12_COMPUTE_SHADER_NODE
class CD3DX12_COALESCING_LAUNCH_NODE_OVERRIDES
: public CD3DX12_NODE_HELPER_BASE
{
public :
CD3DX12_COALESCING_LAUNCH_NODE_OVERRIDES (
D3D12_NODE * pNode ,
LPCWSTR _Shader = nullptr ) :
m_NodeOutputOverrides ( & Overrides . pOutputOverrides , & Overrides . NumOutputOverrides )
{
Overrides = { } ;
m_pDesc = pNode ;
m_pDesc - > NodeType = D3D12_NODE_TYPE_SHADER ;
m_pDesc - > Shader . OverridesType = D3D12_NODE_OVERRIDES_TYPE_COALESCING_LAUNCH ;
m_pDesc - > Shader . pCoalescingLaunchOverrides = & Overrides ;
Shader ( _Shader ) ;
}
void Shader ( LPCWSTR _Shader )
{
m_pDesc - > Shader . Shader = m_Strings . LocalCopy ( _Shader ) ;
}
void LocalRootArgumentsTableIndex ( UINT index )
{
m_UINTs . emplace_front ( index ) ;
Overrides . pLocalRootArgumentsTableIndex = & m_UINTs . front ( ) ;
}
void ProgramEntry ( BOOL bIsProgramEntry )
{
m_UINTs . emplace_front ( bIsProgramEntry ) ;
Overrides . pProgramEntry = ( BOOL * ) & m_UINTs . front ( ) ;
}
void NewName ( D3D12_NODE_ID NodeID )
{
m_NodeIDs . emplace_front ( D3D12_NODE_ID { m_Strings . LocalCopy ( NodeID . Name ) , NodeID . ArrayIndex } ) ;
Overrides . pNewName = & m_NodeIDs . front ( ) ;
}
void ShareInputOf ( D3D12_NODE_ID NodeID )
{
m_NodeIDs . emplace_front ( D3D12_NODE_ID { m_Strings . LocalCopy ( NodeID . Name ) , NodeID . ArrayIndex } ) ;
Overrides . pShareInputOf = & m_NodeIDs . front ( ) ;
}
CD3DX12_NODE_OUTPUT_OVERRIDES & NodeOutputOverrides ( )
{
return m_NodeOutputOverrides ;
}
D3D12_COALESCING_LAUNCH_OVERRIDES Overrides ;
D3D12_NODE * m_pDesc ;
private :
// Cached parameters
CD3DX12_STATE_OBJECT_DESC : : StringContainer < LPCWSTR , std : : wstring > m_Strings ;
std : : forward_list < UINT > m_UINTs ;
struct UINT3
{
UINT x ;
UINT y ;
UINT z ;
} ;
std : : forward_list < UINT3 > m_UINT3s ;
std : : forward_list < D3D12_NODE_ID > m_NodeIDs ;
CD3DX12_NODE_OUTPUT_OVERRIDES m_NodeOutputOverrides ;
} ;
//------------------------------------------------------------------------------------------------
// Use this class when defining a thread launch node where configuration parameters
// need to be overridden. If overrides are not needed, just use CD3DX12_COMPUTE_SHADER_NODE
class CD3DX12_THREAD_LAUNCH_NODE_OVERRIDES
: public CD3DX12_NODE_HELPER_BASE
{
public :
CD3DX12_THREAD_LAUNCH_NODE_OVERRIDES (
D3D12_NODE * pNode ,
LPCWSTR _Shader = nullptr ) :
m_NodeOutputOverrides ( & Overrides . pOutputOverrides , & Overrides . NumOutputOverrides )
{
Overrides = { } ;
m_pDesc = pNode ;
m_pDesc - > NodeType = D3D12_NODE_TYPE_SHADER ;
m_pDesc - > Shader . OverridesType = D3D12_NODE_OVERRIDES_TYPE_THREAD_LAUNCH ;
m_pDesc - > Shader . pThreadLaunchOverrides = & Overrides ;
Shader ( _Shader ) ;
}
void Shader ( LPCWSTR _Shader )
{
m_pDesc - > Shader . Shader = m_Strings . LocalCopy ( _Shader ) ;
}
void LocalRootArgumentsTableIndex ( UINT index )
{
m_UINTs . emplace_front ( index ) ;
Overrides . pLocalRootArgumentsTableIndex = & m_UINTs . front ( ) ;
}
void ProgramEntry ( BOOL bIsProgramEntry )
{
m_UINTs . emplace_front ( bIsProgramEntry ) ;
Overrides . pProgramEntry = ( BOOL * ) & m_UINTs . front ( ) ;
}
void NewName ( D3D12_NODE_ID NodeID )
{
m_NodeIDs . emplace_front ( D3D12_NODE_ID { m_Strings . LocalCopy ( NodeID . Name ) , NodeID . ArrayIndex } ) ;
Overrides . pNewName = & m_NodeIDs . front ( ) ;
}
void ShareInputOf ( D3D12_NODE_ID NodeID )
{
m_NodeIDs . emplace_front ( D3D12_NODE_ID { m_Strings . LocalCopy ( NodeID . Name ) , NodeID . ArrayIndex } ) ;
Overrides . pShareInputOf = & m_NodeIDs . front ( ) ;
}
CD3DX12_NODE_OUTPUT_OVERRIDES & NodeOutputOverrides ( )
{
return m_NodeOutputOverrides ;
}
D3D12_THREAD_LAUNCH_OVERRIDES Overrides ;
D3D12_NODE * m_pDesc ;
private :
// Cached parameters
CD3DX12_STATE_OBJECT_DESC : : StringContainer < LPCWSTR , std : : wstring > m_Strings ;
std : : forward_list < UINT > m_UINTs ;
std : : forward_list < D3D12_NODE_ID > m_NodeIDs ;
CD3DX12_NODE_OUTPUT_OVERRIDES m_NodeOutputOverrides ;
} ;
//------------------------------------------------------------------------------------------------
// Use this class when defining a node where configuration parameters
// need to be overridden for parameters that are common to all launch node types.
// This option is a convenience if you don't want to determine what the launch mode is
// and just want to override a setting that isn't specific to launch mode.
// If overrides are not needed, just use CD3DX12_COMPUTE_SHADER_NODE
class CD3DX12_COMMON_COMPUTE_NODE_OVERRIDES
: public CD3DX12_NODE_HELPER_BASE
{
public :
CD3DX12_COMMON_COMPUTE_NODE_OVERRIDES (
D3D12_NODE * pNode ,
LPCWSTR _Shader = nullptr ) :
m_NodeOutputOverrides ( & Overrides . pOutputOverrides , & Overrides . NumOutputOverrides )
{
Overrides = { } ;
m_pDesc = pNode ;
m_pDesc - > NodeType = D3D12_NODE_TYPE_SHADER ;
m_pDesc - > Shader . OverridesType = D3D12_NODE_OVERRIDES_TYPE_COMMON_COMPUTE ;
m_pDesc - > Shader . pThreadLaunchOverrides = & Overrides ;
Shader ( _Shader ) ;
}
void Shader ( LPCWSTR _Shader )
{
m_pDesc - > Shader . Shader = m_Strings . LocalCopy ( _Shader ) ;
}
void LocalRootArgumentsTableIndex ( UINT index )
{
m_UINTs . emplace_front ( index ) ;
Overrides . pLocalRootArgumentsTableIndex = & m_UINTs . front ( ) ;
}
void ProgramEntry ( BOOL bIsProgramEntry )
{
m_UINTs . emplace_front ( bIsProgramEntry ) ;
Overrides . pProgramEntry = ( BOOL * ) & m_UINTs . front ( ) ;
}
void NewName ( D3D12_NODE_ID NodeID )
{
m_NodeIDs . emplace_front ( D3D12_NODE_ID { m_Strings . LocalCopy ( NodeID . Name ) , NodeID . ArrayIndex } ) ;
Overrides . pNewName = & m_NodeIDs . front ( ) ;
}
void ShareInputOf ( D3D12_NODE_ID NodeID )
{
m_NodeIDs . emplace_front ( D3D12_NODE_ID { m_Strings . LocalCopy ( NodeID . Name ) , NodeID . ArrayIndex } ) ;
Overrides . pShareInputOf = & m_NodeIDs . front ( ) ;
}
CD3DX12_NODE_OUTPUT_OVERRIDES & NodeOutputOverrides ( )
{
return m_NodeOutputOverrides ;
}
D3D12_THREAD_LAUNCH_OVERRIDES Overrides ;
D3D12_NODE * m_pDesc ;
private :
// Cached parameters
CD3DX12_STATE_OBJECT_DESC : : StringContainer < LPCWSTR , std : : wstring > m_Strings ;
std : : forward_list < UINT > m_UINTs ;
std : : forward_list < D3D12_NODE_ID > m_NodeIDs ;
CD3DX12_NODE_OUTPUT_OVERRIDES m_NodeOutputOverrides ;
} ;
//------------------------------------------------------------------------------------------------
class CD3DX12_WORK_GRAPH_SUBOBJECT
: public CD3DX12_STATE_OBJECT_DESC : : SUBOBJECT_HELPER_BASE
{
public :
CD3DX12_WORK_GRAPH_SUBOBJECT ( ) noexcept
{
Init ( ) ;
}
CD3DX12_WORK_GRAPH_SUBOBJECT ( CD3DX12_STATE_OBJECT_DESC & ContainingStateObject )
{
Init ( ) ;
AddToStateObject ( ContainingStateObject ) ;
}
D3D12_STATE_SUBOBJECT_TYPE Type ( ) const noexcept override
{
return D3D12_STATE_SUBOBJECT_TYPE_WORK_GRAPH ;
}
void IncludeAllAvailableNodes ( )
{
m_Desc . Flags | = D3D12_WORK_GRAPH_FLAG_INCLUDE_ALL_AVAILABLE_NODES ;
}
void SetProgramName ( LPCWSTR ProgramName )
{
m_Desc . ProgramName = m_Strings . LocalCopy ( ProgramName ) ;
}
void AddEntrypoint ( D3D12_NODE_ID Entrypoint )
{
m_Entrypoints . emplace_back ( D3D12_NODE_ID { m_Strings . LocalCopy ( Entrypoint . Name ) , Entrypoint . ArrayIndex } ) ;
m_NumEntrypoints + + ;
}
template < typename T >
T * CreateNode ( )
{
m_NodeDescs . push_back ( { } ) ;
m_NumNodes + + ;
T * pNodeHelper = new T ( & m_NodeDescs . back ( ) ) ;
m_OwnedNodeHelpers . emplace_back ( pNodeHelper ) ;
return pNodeHelper ;
}
CD3DX12_SHADER_NODE * CreateShaderNode ( LPCWSTR Shader = nullptr )
{
auto pNode = CreateNode < CD3DX12_SHADER_NODE > ( ) ;
pNode - > Shader ( Shader ) ;
return pNode ;
}
CD3DX12_BROADCASTING_LAUNCH_NODE_OVERRIDES * CreateBroadcastingLaunchNodeOverrides ( LPCWSTR Shader = nullptr )
{
auto pNode = CreateNode < CD3DX12_BROADCASTING_LAUNCH_NODE_OVERRIDES > ( ) ;
pNode - > Shader ( Shader ) ;
return pNode ;
}
CD3DX12_COALESCING_LAUNCH_NODE_OVERRIDES * CreateCoalescingLaunchNodeOverrides ( LPCWSTR Shader = nullptr )
{
auto pNode = CreateNode < CD3DX12_COALESCING_LAUNCH_NODE_OVERRIDES > ( ) ;
pNode - > Shader ( Shader ) ;
return pNode ;
}
CD3DX12_THREAD_LAUNCH_NODE_OVERRIDES * CreateThreadLaunchNodeOverrides ( LPCWSTR Shader = nullptr )
{
auto pNode = CreateNode < CD3DX12_THREAD_LAUNCH_NODE_OVERRIDES > ( ) ;
pNode - > Shader ( Shader ) ;
return pNode ;
}
CD3DX12_COMMON_COMPUTE_NODE_OVERRIDES * CreateCommonComputeNodeOverrides ( LPCWSTR Shader = nullptr )
{
auto pNode = CreateNode < CD3DX12_COMMON_COMPUTE_NODE_OVERRIDES > ( ) ;
pNode - > Shader ( Shader ) ;
return pNode ;
}
operator const D3D12_WORK_GRAPH_DESC & ( ) noexcept
{
return m_Desc ;
}
virtual void Finalize ( ) override
{
m_EntrypointsVector . resize ( m_NumEntrypoints ) ;
std : : list < D3D12_NODE_ID > : : iterator entryIt = m_Entrypoints . begin ( ) ;
for ( UINT n = 0 ; n < m_NumEntrypoints ; n + + , entryIt + + )
{
m_EntrypointsVector [ n ] = * entryIt ;
}
m_Desc . NumEntrypoints = m_NumEntrypoints ;
m_Desc . pEntrypoints = m_EntrypointsVector . data ( ) ;
m_NodeDescsVector . resize ( m_NumNodes ) ;
std : : list < D3D12_NODE > : : iterator nodeIt = m_NodeDescs . begin ( ) ;
for ( UINT n = 0 ; n < m_NumNodes ; n + + , nodeIt + + )
{
m_NodeDescsVector [ n ] = * nodeIt ;
}
m_Desc . NumExplicitlyDefinedNodes = m_NumNodes ;
m_Desc . pExplicitlyDefinedNodes = m_NodeDescsVector . data ( ) ;
}
private :
void Init ( ) noexcept
{
SUBOBJECT_HELPER_BASE : : Init ( ) ;
m_Desc = { } ;
m_NodeDescs . clear ( ) ;
m_NodeDescsVector . clear ( ) ;
m_NumNodes = 0 ;
m_NumEntrypoints = 0 ;
}
void * Data ( ) noexcept override { return & m_Desc ; }
D3D12_WORK_GRAPH_DESC m_Desc ;
std : : list < D3D12_NODE_ID > m_Entrypoints ;
UINT m_NumEntrypoints ;
std : : vector < D3D12_NODE_ID > m_EntrypointsVector ;
std : : list < D3D12_NODE > m_NodeDescs ;
UINT m_NumNodes ;
std : : vector < D3D12_NODE > m_NodeDescsVector ;
CD3DX12_STATE_OBJECT_DESC : : StringContainer < LPCWSTR , std : : wstring > m_Strings ;
std : : list < std : : unique_ptr < const CD3DX12_NODE_HELPER_BASE > > m_OwnedNodeHelpers ;
} ;
# endif // D3D12_SDK_VERSION >= 612
# undef D3DX12_COM_PTR
# undef D3DX12_COM_PTR_GET
# undef D3DX12_COM_PTR_ADDRESSOF
# endif // !D3DX12_NO_STATE_OBJECT_HELPERS
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608)
//================================================================================================
// D3DX12 Enhanced Barrier Helpers
//================================================================================================
class CD3DX12_BARRIER_SUBRESOURCE_RANGE : public D3D12_BARRIER_SUBRESOURCE_RANGE
{
public :
CD3DX12_BARRIER_SUBRESOURCE_RANGE ( ) = default ;
CD3DX12_BARRIER_SUBRESOURCE_RANGE ( const D3D12_BARRIER_SUBRESOURCE_RANGE & o ) noexcept :
D3D12_BARRIER_SUBRESOURCE_RANGE ( o )
{ }
explicit CD3DX12_BARRIER_SUBRESOURCE_RANGE ( UINT Subresource ) noexcept :
D3D12_BARRIER_SUBRESOURCE_RANGE { Subresource , 0 , 0 , 0 , 0 , 0 }
{ }
CD3DX12_BARRIER_SUBRESOURCE_RANGE (
UINT firstMipLevel ,
UINT numMips ,
UINT firstArraySlice ,
UINT numArraySlices ,
UINT firstPlane = 0 ,
UINT numPlanes = 1 ) noexcept :
D3D12_BARRIER_SUBRESOURCE_RANGE
{
firstMipLevel ,
numMips ,
firstArraySlice ,
numArraySlices ,
firstPlane ,
numPlanes
}
{ }
} ;
class CD3DX12_GLOBAL_BARRIER : public D3D12_GLOBAL_BARRIER
{
public :
CD3DX12_GLOBAL_BARRIER ( ) = default ;
CD3DX12_GLOBAL_BARRIER ( const D3D12_GLOBAL_BARRIER & o ) noexcept : D3D12_GLOBAL_BARRIER ( o ) { }
CD3DX12_GLOBAL_BARRIER (
D3D12_BARRIER_SYNC syncBefore ,
D3D12_BARRIER_SYNC syncAfter ,
D3D12_BARRIER_ACCESS accessBefore ,
D3D12_BARRIER_ACCESS accessAfter ) noexcept : D3D12_GLOBAL_BARRIER {
syncBefore ,
syncAfter ,
accessBefore ,
accessAfter
}
{ }
} ;
class CD3DX12_BUFFER_BARRIER : public D3D12_BUFFER_BARRIER
{
public :
CD3DX12_BUFFER_BARRIER ( ) = default ;
CD3DX12_BUFFER_BARRIER ( const D3D12_BUFFER_BARRIER & o ) noexcept : D3D12_BUFFER_BARRIER ( o ) { }
CD3DX12_BUFFER_BARRIER (
D3D12_BARRIER_SYNC syncBefore ,
D3D12_BARRIER_SYNC syncAfter ,
D3D12_BARRIER_ACCESS accessBefore ,
D3D12_BARRIER_ACCESS accessAfter ,
ID3D12Resource * pRes ) noexcept : D3D12_BUFFER_BARRIER {
syncBefore ,
2022-05-08 21:25:55 +00:00
syncAfter ,
accessBefore ,
accessAfter ,
pRes ,
0 , ULLONG_MAX
}
{ }
} ;
class CD3DX12_TEXTURE_BARRIER : public D3D12_TEXTURE_BARRIER
{
public :
CD3DX12_TEXTURE_BARRIER ( ) = default ;
CD3DX12_TEXTURE_BARRIER ( const D3D12_TEXTURE_BARRIER & o ) noexcept : D3D12_TEXTURE_BARRIER ( o ) { }
CD3DX12_TEXTURE_BARRIER (
D3D12_BARRIER_SYNC syncBefore ,
D3D12_BARRIER_SYNC syncAfter ,
D3D12_BARRIER_ACCESS accessBefore ,
D3D12_BARRIER_ACCESS accessAfter ,
D3D12_BARRIER_LAYOUT layoutBefore ,
D3D12_BARRIER_LAYOUT layoutAfter ,
ID3D12Resource * pRes ,
const D3D12_BARRIER_SUBRESOURCE_RANGE & subresources ,
D3D12_TEXTURE_BARRIER_FLAGS flag = D3D12_TEXTURE_BARRIER_FLAG_NONE ) noexcept : D3D12_TEXTURE_BARRIER {
syncBefore ,
syncAfter ,
accessBefore ,
accessAfter ,
layoutBefore ,
layoutAfter ,
pRes ,
subresources ,
flag
}
{ }
} ;
class CD3DX12_BARRIER_GROUP : public D3D12_BARRIER_GROUP
{
public :
CD3DX12_BARRIER_GROUP ( ) = default ;
CD3DX12_BARRIER_GROUP ( const D3D12_BARRIER_GROUP & o ) noexcept : D3D12_BARRIER_GROUP ( o ) { }
CD3DX12_BARRIER_GROUP ( UINT32 numBarriers , const D3D12_BUFFER_BARRIER * pBarriers ) noexcept
{
Type = D3D12_BARRIER_TYPE_BUFFER ;
NumBarriers = numBarriers ;
pBufferBarriers = pBarriers ;
}
CD3DX12_BARRIER_GROUP ( UINT32 numBarriers , const D3D12_TEXTURE_BARRIER * pBarriers ) noexcept
{
Type = D3D12_BARRIER_TYPE_TEXTURE ;
NumBarriers = numBarriers ;
pTextureBarriers = pBarriers ;
}
CD3DX12_BARRIER_GROUP ( UINT32 numBarriers , const D3D12_GLOBAL_BARRIER * pBarriers ) noexcept
{
Type = D3D12_BARRIER_TYPE_GLOBAL ;
NumBarriers = numBarriers ;
pGlobalBarriers = pBarriers ;
}
} ;
2023-04-24 20:52:49 +00:00
# endif // D3D12_SDK_VERSION >= 608
2017-01-26 18:23:36 +00:00
2021-10-06 00:41:32 +00:00
2022-11-19 21:03:20 +00:00
# ifndef D3DX12_NO_CHECK_FEATURE_SUPPORT_CLASS
2021-10-06 00:41:32 +00:00
2022-05-08 21:25:55 +00:00
//================================================================================================
// D3DX12 Check Feature Support
//================================================================================================
2021-10-06 00:41:32 +00:00
# include <vector>
class CD3DX12FeatureSupport
{
public : // Function declaration
// Default constructor that creates an empty object
2021-10-22 23:43:43 +00:00
CD3DX12FeatureSupport ( ) noexcept ;
2021-10-06 00:41:32 +00:00
// Initialize data from the given device
HRESULT Init ( ID3D12Device * pDevice ) ;
// Retreives the status of the object. If an error occurred in the initialization process, the function returns the error code.
2021-10-22 23:43:43 +00:00
HRESULT GetStatus ( ) const noexcept { return m_hStatus ; }
2021-10-06 00:41:32 +00:00
// Getter functions for each feature class
// D3D12_OPTIONS
2021-10-22 23:43:43 +00:00
BOOL DoublePrecisionFloatShaderOps ( ) const noexcept ;
BOOL OutputMergerLogicOp ( ) const noexcept ;
D3D12_SHADER_MIN_PRECISION_SUPPORT MinPrecisionSupport ( ) const noexcept ;
D3D12_TILED_RESOURCES_TIER TiledResourcesTier ( ) const noexcept ;
D3D12_RESOURCE_BINDING_TIER ResourceBindingTier ( ) const noexcept ;
BOOL PSSpecifiedStencilRefSupported ( ) const noexcept ;
BOOL TypedUAVLoadAdditionalFormats ( ) const noexcept ;
BOOL ROVsSupported ( ) const noexcept ;
D3D12_CONSERVATIVE_RASTERIZATION_TIER ConservativeRasterizationTier ( ) const noexcept ;
BOOL StandardSwizzle64KBSupported ( ) const noexcept ;
BOOL CrossAdapterRowMajorTextureSupported ( ) const noexcept ;
BOOL VPAndRTArrayIndexFromAnyShaderFeedingRasterizerSupportedWithoutGSEmulation ( ) const noexcept ;
D3D12_RESOURCE_HEAP_TIER ResourceHeapTier ( ) const noexcept ;
D3D12_CROSS_NODE_SHARING_TIER CrossNodeSharingTier ( ) const noexcept ;
UINT MaxGPUVirtualAddressBitsPerResource ( ) const noexcept ;
2021-10-06 00:41:32 +00:00
// FEATURE_LEVELS
2021-10-22 23:43:43 +00:00
D3D_FEATURE_LEVEL MaxSupportedFeatureLevel ( ) const noexcept ;
2021-10-06 00:41:32 +00:00
// FORMAT_SUPPORT
2021-10-22 23:43:43 +00:00
HRESULT FormatSupport ( DXGI_FORMAT Format , D3D12_FORMAT_SUPPORT1 & Support1 , D3D12_FORMAT_SUPPORT2 & Support2 ) const ;
2021-10-06 00:41:32 +00:00
// MUTLTISAMPLE_QUALITY_LEVELS
2021-10-22 23:43:43 +00:00
HRESULT MultisampleQualityLevels ( DXGI_FORMAT Format , UINT SampleCount , D3D12_MULTISAMPLE_QUALITY_LEVEL_FLAGS Flags , UINT & NumQualityLevels ) const ;
2021-10-06 00:41:32 +00:00
// FORMAT_INFO
2021-10-22 23:43:43 +00:00
HRESULT FormatInfo ( DXGI_FORMAT Format , UINT8 & PlaneCount ) const ;
2021-10-06 00:41:32 +00:00
// GPU_VIRTUAL_ADDRESS_SUPPORT
2021-10-22 23:43:43 +00:00
UINT MaxGPUVirtualAddressBitsPerProcess ( ) const noexcept ;
2021-10-06 00:41:32 +00:00
// SHADER_MODEL
2021-10-22 23:43:43 +00:00
D3D_SHADER_MODEL HighestShaderModel ( ) const noexcept ;
2021-10-06 00:41:32 +00:00
// D3D12_OPTIONS1
2021-10-22 23:43:43 +00:00
BOOL WaveOps ( ) const noexcept ;
UINT WaveLaneCountMin ( ) const noexcept ;
UINT WaveLaneCountMax ( ) const noexcept ;
UINT TotalLaneCount ( ) const noexcept ;
BOOL ExpandedComputeResourceStates ( ) const noexcept ;
BOOL Int64ShaderOps ( ) const noexcept ;
2021-10-06 00:41:32 +00:00
// PROTECTED_RESOURCE_SESSION_SUPPORT
D3D12_PROTECTED_RESOURCE_SESSION_SUPPORT_FLAGS ProtectedResourceSessionSupport ( UINT NodeIndex = 0 ) const ;
// ROOT_SIGNATURE
2021-10-22 23:43:43 +00:00
D3D_ROOT_SIGNATURE_VERSION HighestRootSignatureVersion ( ) const noexcept ;
2021-10-06 00:41:32 +00:00
// ARCHITECTURE1
BOOL TileBasedRenderer ( UINT NodeIndex = 0 ) const ;
BOOL UMA ( UINT NodeIndex = 0 ) const ;
BOOL CacheCoherentUMA ( UINT NodeIndex = 0 ) const ;
BOOL IsolatedMMU ( UINT NodeIndex = 0 ) const ;
// D3D12_OPTIONS2
2021-10-22 23:43:43 +00:00
BOOL DepthBoundsTestSupported ( ) const noexcept ;
D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER ProgrammableSamplePositionsTier ( ) const noexcept ;
2021-10-06 00:41:32 +00:00
// SHADER_CACHE
2021-10-22 23:43:43 +00:00
D3D12_SHADER_CACHE_SUPPORT_FLAGS ShaderCacheSupportFlags ( ) const noexcept ;
2021-10-06 00:41:32 +00:00
// COMMAND_QUEUE_PRIORITY
BOOL CommandQueuePrioritySupported ( D3D12_COMMAND_LIST_TYPE CommandListType , UINT Priority ) ;
// D3D12_OPTIONS3
2021-10-22 23:43:43 +00:00
BOOL CopyQueueTimestampQueriesSupported ( ) const noexcept ;
BOOL CastingFullyTypedFormatSupported ( ) const noexcept ;
D3D12_COMMAND_LIST_SUPPORT_FLAGS WriteBufferImmediateSupportFlags ( ) const noexcept ;
D3D12_VIEW_INSTANCING_TIER ViewInstancingTier ( ) const noexcept ;
BOOL BarycentricsSupported ( ) const noexcept ;
2021-10-06 00:41:32 +00:00
// EXISTING_HEAPS
2021-10-22 23:43:43 +00:00
BOOL ExistingHeapsSupported ( ) const noexcept ;
2021-10-06 00:41:32 +00:00
// D3D12_OPTIONS4
2021-10-22 23:43:43 +00:00
BOOL MSAA64KBAlignedTextureSupported ( ) const noexcept ;
D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER SharedResourceCompatibilityTier ( ) const noexcept ;
BOOL Native16BitShaderOpsSupported ( ) const noexcept ;
2021-10-06 00:41:32 +00:00
// SERIALIZATION
D3D12_HEAP_SERIALIZATION_TIER HeapSerializationTier ( UINT NodeIndex = 0 ) const ;
// CROSS_NODE
// CrossNodeSharingTier handled in D3D12Options
2021-10-22 23:43:43 +00:00
BOOL CrossNodeAtomicShaderInstructions ( ) const noexcept ;
2021-10-06 00:41:32 +00:00
// D3D12_OPTIONS5
2021-10-22 23:43:43 +00:00
BOOL SRVOnlyTiledResourceTier3 ( ) const noexcept ;
D3D12_RENDER_PASS_TIER RenderPassesTier ( ) const noexcept ;
D3D12_RAYTRACING_TIER RaytracingTier ( ) const noexcept ;
2021-10-06 00:41:32 +00:00
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4)
2021-10-06 00:41:32 +00:00
// DISPLAYABLE
2021-10-22 23:43:43 +00:00
BOOL DisplayableTexture ( ) const noexcept ;
2021-10-06 00:41:32 +00:00
// SharedResourceCompatibilityTier handled in D3D12Options4
2022-11-19 21:03:20 +00:00
# endif
2021-10-06 00:41:32 +00:00
// D3D12_OPTIONS6
2021-10-22 23:43:43 +00:00
BOOL AdditionalShadingRatesSupported ( ) const noexcept ;
BOOL PerPrimitiveShadingRateSupportedWithViewportIndexing ( ) const noexcept ;
D3D12_VARIABLE_SHADING_RATE_TIER VariableShadingRateTier ( ) const noexcept ;
UINT ShadingRateImageTileSize ( ) const noexcept ;
BOOL BackgroundProcessingSupported ( ) const noexcept ;
2021-10-06 00:41:32 +00:00
// QUERY_META_COMMAND
2021-10-22 23:43:43 +00:00
HRESULT QueryMetaCommand ( D3D12_FEATURE_DATA_QUERY_META_COMMAND & dQueryMetaCommand ) const ;
2021-10-06 00:41:32 +00:00
// D3D12_OPTIONS7
2021-10-22 23:43:43 +00:00
D3D12_MESH_SHADER_TIER MeshShaderTier ( ) const noexcept ;
D3D12_SAMPLER_FEEDBACK_TIER SamplerFeedbackTier ( ) const noexcept ;
2021-10-06 00:41:32 +00:00
// PROTECTED_RESOURCE_SESSION_TYPE_COUNT
UINT ProtectedResourceSessionTypeCount ( UINT NodeIndex = 0 ) const ;
2021-10-22 23:43:43 +00:00
2021-10-06 00:41:32 +00:00
// PROTECTED_RESOURCE_SESSION_TYPES
std : : vector < GUID > ProtectedResourceSessionTypes ( UINT NodeIndex = 0 ) const ;
2021-10-22 23:43:43 +00:00
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 3)
2021-10-06 00:41:32 +00:00
// D3D12_OPTIONS8
2021-10-22 23:43:43 +00:00
BOOL UnalignedBlockTexturesSupported ( ) const noexcept ;
2021-10-06 00:41:32 +00:00
// D3D12_OPTIONS9
2021-10-22 23:43:43 +00:00
BOOL MeshShaderPipelineStatsSupported ( ) const noexcept ;
BOOL MeshShaderSupportsFullRangeRenderTargetArrayIndex ( ) const noexcept ;
BOOL AtomicInt64OnTypedResourceSupported ( ) const noexcept ;
BOOL AtomicInt64OnGroupSharedSupported ( ) const noexcept ;
BOOL DerivativesInMeshAndAmplificationShadersSupported ( ) const noexcept ;
D3D12_WAVE_MMA_TIER WaveMMATier ( ) const noexcept ;
2022-11-19 21:03:20 +00:00
# endif
2021-10-06 00:41:32 +00:00
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4)
2021-10-06 00:41:32 +00:00
// D3D12_OPTIONS10
2021-10-22 23:43:43 +00:00
BOOL VariableRateShadingSumCombinerSupported ( ) const noexcept ;
BOOL MeshShaderPerPrimitiveShadingRateSupported ( ) const noexcept ;
2021-10-06 00:41:32 +00:00
// D3D12_OPTIONS11
2021-10-22 23:43:43 +00:00
BOOL AtomicInt64OnDescriptorHeapResourceSupported ( ) const noexcept ;
2022-11-19 21:03:20 +00:00
# endif
2022-05-08 21:25:55 +00:00
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 600)
2022-05-08 21:25:55 +00:00
// D3D12_OPTIONS12
D3D12_TRI_STATE MSPrimitivesPipelineStatisticIncludesCulledPrimitives ( ) const noexcept ;
BOOL EnhancedBarriersSupported ( ) const noexcept ;
BOOL RelaxedFormatCastingSupported ( ) const noexcept ;
2023-04-24 20:52:49 +00:00
# endif
2022-05-08 21:25:55 +00:00
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 602)
2022-05-08 21:25:55 +00:00
// D3D12_OPTIONS13
BOOL UnrestrictedBufferTextureCopyPitchSupported ( ) const noexcept ;
BOOL UnrestrictedVertexElementAlignmentSupported ( ) const noexcept ;
BOOL InvertedViewportHeightFlipsYSupported ( ) const noexcept ;
BOOL InvertedViewportDepthFlipsZSupported ( ) const noexcept ;
BOOL TextureCopyBetweenDimensionsSupported ( ) const noexcept ;
BOOL AlphaBlendFactorSupported ( ) const noexcept ;
# endif
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606)
2022-11-19 21:03:20 +00:00
// D3D12_OPTIONS14
BOOL AdvancedTextureOpsSupported ( ) const noexcept ;
BOOL WriteableMSAATexturesSupported ( ) const noexcept ;
BOOL IndependentFrontAndBackStencilRefMaskSupported ( ) const noexcept ;
// D3D12_OPTIONS15
BOOL TriangleFanSupported ( ) const noexcept ;
BOOL DynamicIndexBufferStripCutSupported ( ) const noexcept ;
2023-04-24 20:52:49 +00:00
# endif
2022-11-19 21:03:20 +00:00
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608)
2022-11-19 21:03:20 +00:00
// D3D12_OPTIONS16
BOOL DynamicDepthBiasSupported ( ) const noexcept ;
# endif
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
BOOL GPUUploadHeapSupported ( ) const noexcept ;
// D3D12_OPTIONS17
BOOL NonNormalizedCoordinateSamplersSupported ( ) const noexcept ;
BOOL ManualWriteTrackingResourceSupported ( ) const noexcept ;
// D3D12_OPTIONS18
BOOL RenderPassesValid ( ) const noexcept ;
# endif
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610)
BOOL MismatchingOutputDimensionsSupported ( ) const noexcept ;
UINT SupportedSampleCountsWithNoOutputs ( ) const noexcept ;
BOOL PointSamplingAddressesNeverRoundUp ( ) const noexcept ;
BOOL RasterizerDesc2Supported ( ) const noexcept ;
BOOL NarrowQuadrilateralLinesSupported ( ) const noexcept ;
BOOL AnisoFilterWithPointMipSupported ( ) const noexcept ;
UINT MaxSamplerDescriptorHeapSize ( ) const noexcept ;
UINT MaxSamplerDescriptorHeapSizeWithStaticSamplers ( ) const noexcept ;
UINT MaxViewDescriptorHeapSize ( ) const noexcept ;
# endif
2024-02-05 18:08:59 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 611)
BOOL ComputeOnlyWriteWatchSupported ( ) const noexcept ;
# endif
2024-05-17 23:56:19 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612)
D3D12_EXECUTE_INDIRECT_TIER ExecuteIndirectTier ( ) const noexcept ;
D3D12_WORK_GRAPHS_TIER WorkGraphsTier ( ) const noexcept ;
# endif
2021-10-06 00:41:32 +00:00
private : // Private structs and helpers declaration
struct ProtectedResourceSessionTypesLocal : D3D12_FEATURE_DATA_PROTECTED_RESOURCE_SESSION_TYPES
{
std : : vector < GUID > TypeVec ;
} ;
// Helper function to decide the highest shader model supported by the system
// Stores the result in m_dShaderModel
// Must be updated whenever a new shader model is added to the d3d12.h header
HRESULT QueryHighestShaderModel ( ) ;
// Helper function to decide the highest root signature supported
// Must be updated whenever a new root signature version is added to the d3d12.h header
HRESULT QueryHighestRootSignatureVersion ( ) ;
// Helper funcion to decide the highest feature level
HRESULT QueryHighestFeatureLevel ( ) ;
2021-10-22 23:43:43 +00:00
2021-10-06 00:41:32 +00:00
// Helper function to initialize local protected resource session types structs
2021-10-22 23:43:43 +00:00
HRESULT QueryProtectedResourceSessionTypes ( UINT NodeIndex , UINT Count ) ;
2021-10-06 00:41:32 +00:00
private : // Member data
// Pointer to the underlying device
ID3D12Device * m_pDevice ;
// Stores the error code from initialization
HRESULT m_hStatus ;
// Feature support data structs
D3D12_FEATURE_DATA_D3D12_OPTIONS m_dOptions ;
D3D_FEATURE_LEVEL m_eMaxFeatureLevel ;
D3D12_FEATURE_DATA_GPU_VIRTUAL_ADDRESS_SUPPORT m_dGPUVASupport ;
D3D12_FEATURE_DATA_SHADER_MODEL m_dShaderModel ;
D3D12_FEATURE_DATA_D3D12_OPTIONS1 m_dOptions1 ;
std : : vector < D3D12_FEATURE_DATA_PROTECTED_RESOURCE_SESSION_SUPPORT > m_dProtectedResourceSessionSupport ;
D3D12_FEATURE_DATA_ROOT_SIGNATURE m_dRootSignature ;
std : : vector < D3D12_FEATURE_DATA_ARCHITECTURE1 > m_dArchitecture1 ;
D3D12_FEATURE_DATA_D3D12_OPTIONS2 m_dOptions2 ;
D3D12_FEATURE_DATA_SHADER_CACHE m_dShaderCache ;
D3D12_FEATURE_DATA_COMMAND_QUEUE_PRIORITY m_dCommandQueuePriority ;
D3D12_FEATURE_DATA_D3D12_OPTIONS3 m_dOptions3 ;
D3D12_FEATURE_DATA_EXISTING_HEAPS m_dExistingHeaps ;
D3D12_FEATURE_DATA_D3D12_OPTIONS4 m_dOptions4 ;
std : : vector < D3D12_FEATURE_DATA_SERIALIZATION > m_dSerialization ; // Cat2 NodeIndex
D3D12_FEATURE_DATA_CROSS_NODE m_dCrossNode ;
D3D12_FEATURE_DATA_D3D12_OPTIONS5 m_dOptions5 ;
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4)
2021-10-06 00:41:32 +00:00
D3D12_FEATURE_DATA_DISPLAYABLE m_dDisplayable ;
2022-11-19 21:03:20 +00:00
# endif
2021-10-06 00:41:32 +00:00
D3D12_FEATURE_DATA_D3D12_OPTIONS6 m_dOptions6 ;
D3D12_FEATURE_DATA_D3D12_OPTIONS7 m_dOptions7 ;
std : : vector < D3D12_FEATURE_DATA_PROTECTED_RESOURCE_SESSION_TYPE_COUNT > m_dProtectedResourceSessionTypeCount ; // Cat2 NodeIndex
std : : vector < ProtectedResourceSessionTypesLocal > m_dProtectedResourceSessionTypes ; // Cat3
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 3)
2021-10-06 00:41:32 +00:00
D3D12_FEATURE_DATA_D3D12_OPTIONS8 m_dOptions8 ;
D3D12_FEATURE_DATA_D3D12_OPTIONS9 m_dOptions9 ;
2022-11-19 21:03:20 +00:00
# endif
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4)
2021-10-06 00:41:32 +00:00
D3D12_FEATURE_DATA_D3D12_OPTIONS10 m_dOptions10 ;
2021-10-22 23:43:43 +00:00
D3D12_FEATURE_DATA_D3D12_OPTIONS11 m_dOptions11 ;
2022-11-19 21:03:20 +00:00
# endif
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 600)
2022-05-08 21:25:55 +00:00
D3D12_FEATURE_DATA_D3D12_OPTIONS12 m_dOptions12 ;
2023-04-24 20:52:49 +00:00
# endif
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 602)
2022-05-08 21:25:55 +00:00
D3D12_FEATURE_DATA_D3D12_OPTIONS13 m_dOptions13 ;
# endif
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606)
2022-11-19 21:03:20 +00:00
D3D12_FEATURE_DATA_D3D12_OPTIONS14 m_dOptions14 ;
D3D12_FEATURE_DATA_D3D12_OPTIONS15 m_dOptions15 ;
2023-04-24 20:52:49 +00:00
# endif
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608)
2022-11-19 21:03:20 +00:00
D3D12_FEATURE_DATA_D3D12_OPTIONS16 m_dOptions16 ;
# endif
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
D3D12_FEATURE_DATA_D3D12_OPTIONS17 m_dOptions17 ;
# endif
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
D3D12_FEATURE_DATA_D3D12_OPTIONS18 m_dOptions18 ;
# endif
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610)
D3D12_FEATURE_DATA_D3D12_OPTIONS19 m_dOptions19 ;
# endif
2024-02-05 18:08:59 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 611)
D3D12_FEATURE_DATA_D3D12_OPTIONS20 m_dOptions20 ;
# endif
2024-05-17 23:56:19 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612)
D3D12_FEATURE_DATA_D3D12_OPTIONS21 m_dOptions21 ;
# endif
2021-10-06 00:41:32 +00:00
} ;
// Implementations for CD3DX12FeatureSupport functions
// Macro to set up a getter function for each entry in feature support data
// The getter function will have the same name as the feature option name
# define FEATURE_SUPPORT_GET(RETTYPE,FEATURE,OPTION) \
2021-10-22 23:43:43 +00:00
inline RETTYPE CD3DX12FeatureSupport : : OPTION ( ) const noexcept \
2021-10-06 00:41:32 +00:00
{ \
return FEATURE . OPTION ; \
}
// Macro to set up a getter function for each entry in feature support data
// Also specifies the name for the function which can be different from the feature name
# define FEATURE_SUPPORT_GET_NAME(RETTYPE,FEATURE,OPTION,NAME) \
2021-10-22 23:43:43 +00:00
inline RETTYPE CD3DX12FeatureSupport : : NAME ( ) const noexcept \
2021-10-06 00:41:32 +00:00
{ \
return FEATURE . OPTION ; \
}
// Macro to set up a getter function for feature data indexed by the graphics node ID
// The default parameter is 0, or the first availabe graphics device node
# define FEATURE_SUPPORT_GET_NODE_INDEXED(RETTYPE,FEATURE,OPTION) \
inline RETTYPE CD3DX12FeatureSupport : : OPTION ( UINT NodeIndex ) const \
{ \
return FEATURE [ NodeIndex ] . OPTION ; \
}
// Macro to set up a getter function for feature data indexed by NodeIndex
// Allows a custom name for the getter function
# define FEATURE_SUPPORT_GET_NODE_INDEXED_NAME(RETTYPE,FEATURE,OPTION,NAME) \
inline RETTYPE CD3DX12FeatureSupport : : NAME ( UINT NodeIndex ) const \
{ \
return FEATURE [ NodeIndex ] . OPTION ; \
}
2021-10-22 23:43:43 +00:00
inline CD3DX12FeatureSupport : : CD3DX12FeatureSupport ( ) noexcept
2021-10-06 00:41:32 +00:00
: m_pDevice ( nullptr )
, m_hStatus ( E_INVALIDARG )
2021-10-22 23:43:43 +00:00
, m_dOptions { }
, m_eMaxFeatureLevel { }
, m_dGPUVASupport { }
, m_dShaderModel { }
, m_dOptions1 { }
, m_dRootSignature { }
, m_dOptions2 { }
, m_dShaderCache { }
, m_dCommandQueuePriority { }
, m_dOptions3 { }
, m_dExistingHeaps { }
, m_dOptions4 { }
, m_dCrossNode { }
, m_dOptions5 { }
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4)
2021-10-22 23:43:43 +00:00
, m_dDisplayable { }
2022-11-19 21:03:20 +00:00
# endif
2021-10-22 23:43:43 +00:00
, m_dOptions6 { }
, m_dOptions7 { }
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 3)
2021-10-22 23:43:43 +00:00
, m_dOptions8 { }
, m_dOptions9 { }
2022-11-19 21:03:20 +00:00
# endif
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4)
2021-10-22 23:43:43 +00:00
, m_dOptions10 { }
, m_dOptions11 { }
2022-11-19 21:03:20 +00:00
# endif
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 600)
2022-05-08 21:25:55 +00:00
, m_dOptions12 { }
2023-04-24 20:52:49 +00:00
# endif
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 602)
2022-05-08 21:25:55 +00:00
, m_dOptions13 { }
# endif
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606)
2022-11-19 21:03:20 +00:00
, m_dOptions14 { }
, m_dOptions15 { }
2023-04-24 20:52:49 +00:00
# endif
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608)
2022-11-19 21:03:20 +00:00
, m_dOptions16 { }
# endif
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
, m_dOptions17 { }
# endif
# if defined (D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
, m_dOptions18 { }
# endif
# if defined (D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610)
, m_dOptions19 { }
# endif
2024-02-05 18:08:59 +00:00
# if defined (D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 611)
, m_dOptions20 { }
# endif
2024-05-17 23:56:19 +00:00
# if defined (D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612)
, m_dOptions21 { }
# endif
2021-10-06 00:41:32 +00:00
{ }
inline HRESULT CD3DX12FeatureSupport : : Init ( ID3D12Device * pDevice )
{
2021-10-22 23:43:43 +00:00
if ( ! pDevice )
2021-10-06 00:41:32 +00:00
{
m_hStatus = E_INVALIDARG ;
return m_hStatus ;
}
m_pDevice = pDevice ;
// Initialize static feature support data structures
2021-10-22 23:43:43 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_D3D12_OPTIONS , & m_dOptions , sizeof ( m_dOptions ) ) ) )
2021-10-06 00:41:32 +00:00
{
2022-11-19 21:03:20 +00:00
m_dOptions = { } ;
2021-10-06 00:41:32 +00:00
}
2021-10-22 23:43:43 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_GPU_VIRTUAL_ADDRESS_SUPPORT , & m_dGPUVASupport , sizeof ( m_dGPUVASupport ) ) ) )
2021-10-06 00:41:32 +00:00
{
2022-11-19 21:03:20 +00:00
m_dGPUVASupport = { } ;
2021-10-06 00:41:32 +00:00
}
2021-10-22 23:43:43 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_D3D12_OPTIONS1 , & m_dOptions1 , sizeof ( m_dOptions1 ) ) ) )
2021-10-06 00:41:32 +00:00
{
2022-11-19 21:03:20 +00:00
m_dOptions1 = { } ;
2021-10-06 00:41:32 +00:00
}
2021-10-22 23:43:43 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_D3D12_OPTIONS2 , & m_dOptions2 , sizeof ( m_dOptions2 ) ) ) )
2021-10-06 00:41:32 +00:00
{
2022-11-19 21:03:20 +00:00
m_dOptions2 = { } ;
2021-10-06 00:41:32 +00:00
}
2021-10-22 23:43:43 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_SHADER_CACHE , & m_dShaderCache , sizeof ( m_dShaderCache ) ) ) )
2021-10-06 00:41:32 +00:00
{
2022-11-19 21:03:20 +00:00
m_dShaderCache = { } ;
2021-10-06 00:41:32 +00:00
}
2021-10-22 23:43:43 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_D3D12_OPTIONS3 , & m_dOptions3 , sizeof ( m_dOptions3 ) ) ) )
2021-10-06 00:41:32 +00:00
{
2022-11-19 21:03:20 +00:00
m_dOptions3 = { } ;
2021-10-06 00:41:32 +00:00
}
2021-10-22 23:43:43 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_EXISTING_HEAPS , & m_dExistingHeaps , sizeof ( m_dExistingHeaps ) ) ) )
2021-10-06 00:41:32 +00:00
{
2022-11-19 21:03:20 +00:00
m_dExistingHeaps = { } ;
2021-10-06 00:41:32 +00:00
}
2021-10-22 23:43:43 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_D3D12_OPTIONS4 , & m_dOptions4 , sizeof ( m_dOptions4 ) ) ) )
2021-10-06 00:41:32 +00:00
{
2022-11-19 21:03:20 +00:00
m_dOptions4 = { } ;
2021-10-06 00:41:32 +00:00
}
2021-10-22 23:43:43 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_CROSS_NODE , & m_dCrossNode , sizeof ( m_dCrossNode ) ) ) )
2021-10-06 00:41:32 +00:00
{
2022-11-19 21:03:20 +00:00
m_dCrossNode = { } ;
2021-10-06 00:41:32 +00:00
}
2021-10-22 23:43:43 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_D3D12_OPTIONS5 , & m_dOptions5 , sizeof ( m_dOptions5 ) ) ) )
2021-10-06 00:41:32 +00:00
{
2022-11-19 21:03:20 +00:00
m_dOptions5 = { } ;
2021-10-06 00:41:32 +00:00
}
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4)
2021-10-22 23:43:43 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_DISPLAYABLE , & m_dDisplayable , sizeof ( m_dDisplayable ) ) ) )
2021-10-06 00:41:32 +00:00
{
2022-11-19 21:03:20 +00:00
m_dDisplayable = { } ;
2021-10-06 00:41:32 +00:00
}
2022-11-19 21:03:20 +00:00
# endif
2021-10-06 00:41:32 +00:00
2021-10-22 23:43:43 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_D3D12_OPTIONS6 , & m_dOptions6 , sizeof ( m_dOptions6 ) ) ) )
2021-10-06 00:41:32 +00:00
{
2022-11-19 21:03:20 +00:00
m_dOptions6 = { } ;
2021-10-06 00:41:32 +00:00
}
2021-10-22 23:43:43 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_D3D12_OPTIONS7 , & m_dOptions7 , sizeof ( m_dOptions7 ) ) ) )
2021-10-06 00:41:32 +00:00
{
2022-11-19 21:03:20 +00:00
m_dOptions7 = { } ;
2021-10-06 00:41:32 +00:00
}
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 3)
2021-10-22 23:43:43 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_D3D12_OPTIONS8 , & m_dOptions8 , sizeof ( m_dOptions8 ) ) ) )
2021-10-06 00:41:32 +00:00
{
2022-11-19 21:03:20 +00:00
m_dOptions8 = { } ;
2021-10-06 00:41:32 +00:00
}
2021-10-22 23:43:43 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_D3D12_OPTIONS9 , & m_dOptions9 , sizeof ( m_dOptions9 ) ) ) )
2021-10-06 00:41:32 +00:00
{
2022-11-19 21:03:20 +00:00
m_dOptions9 = { } ;
2021-10-06 00:41:32 +00:00
}
2022-11-19 21:03:20 +00:00
# endif
2021-10-06 00:41:32 +00:00
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4)
2021-10-22 23:43:43 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_D3D12_OPTIONS10 , & m_dOptions10 , sizeof ( m_dOptions10 ) ) ) )
2021-10-06 00:41:32 +00:00
{
2022-11-19 21:03:20 +00:00
m_dOptions10 = { } ;
2021-10-06 00:41:32 +00:00
}
2021-10-22 23:43:43 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_D3D12_OPTIONS11 , & m_dOptions11 , sizeof ( m_dOptions11 ) ) ) )
2021-10-06 00:41:32 +00:00
{
2022-11-19 21:03:20 +00:00
m_dOptions11 = { } ;
2021-10-06 00:41:32 +00:00
}
2022-11-19 21:03:20 +00:00
# endif
2021-10-06 00:41:32 +00:00
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 600)
2022-05-08 21:25:55 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_D3D12_OPTIONS12 , & m_dOptions12 , sizeof ( m_dOptions12 ) ) ) )
{
2022-11-19 21:03:20 +00:00
m_dOptions12 = { } ;
2022-05-08 21:25:55 +00:00
m_dOptions12 . MSPrimitivesPipelineStatisticIncludesCulledPrimitives = D3D12_TRI_STATE : : D3D12_TRI_STATE_UNKNOWN ;
}
2023-04-24 20:52:49 +00:00
# endif
2022-05-08 21:25:55 +00:00
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 602)
2022-05-08 21:25:55 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_D3D12_OPTIONS13 , & m_dOptions13 , sizeof ( m_dOptions13 ) ) ) )
{
2022-11-19 21:03:20 +00:00
m_dOptions13 = { } ;
2022-05-08 21:25:55 +00:00
}
# endif
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606)
2022-11-19 21:03:20 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_D3D12_OPTIONS14 , & m_dOptions14 , sizeof ( m_dOptions14 ) ) ) )
{
m_dOptions14 = { } ;
}
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_D3D12_OPTIONS15 , & m_dOptions15 , sizeof ( m_dOptions15 ) ) ) )
{
m_dOptions15 = { } ;
}
2023-04-24 20:52:49 +00:00
# endif
2022-11-19 21:03:20 +00:00
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608)
2022-11-19 21:03:20 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_D3D12_OPTIONS16 , & m_dOptions16 , sizeof ( m_dOptions16 ) ) ) )
{
m_dOptions16 = { } ;
}
2023-04-24 20:52:49 +00:00
# endif
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_D3D12_OPTIONS17 , & m_dOptions17 , sizeof ( m_dOptions17 ) ) ) )
{
m_dOptions17 = { } ;
}
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_D3D12_OPTIONS18 , & m_dOptions18 , sizeof ( m_dOptions18 ) ) ) )
{
m_dOptions18 . RenderPassesValid = false ;
}
# endif
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610)
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_D3D12_OPTIONS19 , & m_dOptions19 , sizeof ( m_dOptions19 ) ) ) )
{
m_dOptions19 = { } ;
m_dOptions19 . SupportedSampleCountsWithNoOutputs = 1 ;
m_dOptions19 . MaxSamplerDescriptorHeapSize = D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE ;
m_dOptions19 . MaxSamplerDescriptorHeapSizeWithStaticSamplers = D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE ;
m_dOptions19 . MaxViewDescriptorHeapSize = D3D12_MAX_SHADER_VISIBLE_DESCRIPTOR_HEAP_SIZE_TIER_1 ;
}
# endif
2022-11-19 21:03:20 +00:00
2024-02-05 18:08:59 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 611)
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_D3D12_OPTIONS20 , & m_dOptions20 , sizeof ( m_dOptions20 ) ) ) )
{
m_dOptions20 = { } ;
}
# endif
2024-05-17 23:56:19 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612)
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_D3D12_OPTIONS21 , & m_dOptions21 , sizeof ( m_dOptions21 ) ) ) )
{
m_dOptions21 = { } ;
}
# endif
2021-10-06 00:41:32 +00:00
// Initialize per-node feature support data structures
const UINT uNodeCount = m_pDevice - > GetNodeCount ( ) ;
m_dProtectedResourceSessionSupport . resize ( uNodeCount ) ;
m_dArchitecture1 . resize ( uNodeCount ) ;
m_dSerialization . resize ( uNodeCount ) ;
m_dProtectedResourceSessionTypeCount . resize ( uNodeCount ) ;
m_dProtectedResourceSessionTypes . resize ( uNodeCount ) ;
2021-10-22 23:43:43 +00:00
for ( UINT NodeIndex = 0 ; NodeIndex < uNodeCount ; NodeIndex + + )
2021-10-06 00:41:32 +00:00
{
m_dProtectedResourceSessionSupport [ NodeIndex ] . NodeIndex = NodeIndex ;
2021-10-22 23:43:43 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_PROTECTED_RESOURCE_SESSION_SUPPORT , & m_dProtectedResourceSessionSupport [ NodeIndex ] , sizeof ( m_dProtectedResourceSessionSupport [ NodeIndex ] ) ) ) )
2021-10-06 00:41:32 +00:00
{
m_dProtectedResourceSessionSupport [ NodeIndex ] . Support = D3D12_PROTECTED_RESOURCE_SESSION_SUPPORT_FLAG_NONE ;
}
m_dArchitecture1 [ NodeIndex ] . NodeIndex = NodeIndex ;
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_ARCHITECTURE1 , & m_dArchitecture1 [ NodeIndex ] , sizeof ( m_dArchitecture1 [ NodeIndex ] ) ) ) )
{
D3D12_FEATURE_DATA_ARCHITECTURE dArchLocal = { } ;
dArchLocal . NodeIndex = NodeIndex ;
2021-10-22 23:43:43 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_ARCHITECTURE , & dArchLocal , sizeof ( dArchLocal ) ) ) )
2021-10-06 00:41:32 +00:00
{
dArchLocal . TileBasedRenderer = false ;
dArchLocal . UMA = false ;
dArchLocal . CacheCoherentUMA = false ;
}
2021-10-22 23:43:43 +00:00
2021-10-06 00:41:32 +00:00
m_dArchitecture1 [ NodeIndex ] . TileBasedRenderer = dArchLocal . TileBasedRenderer ;
m_dArchitecture1 [ NodeIndex ] . UMA = dArchLocal . UMA ;
m_dArchitecture1 [ NodeIndex ] . CacheCoherentUMA = dArchLocal . CacheCoherentUMA ;
m_dArchitecture1 [ NodeIndex ] . IsolatedMMU = false ;
}
m_dSerialization [ NodeIndex ] . NodeIndex = NodeIndex ;
2021-10-22 23:43:43 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_SERIALIZATION , & m_dSerialization [ NodeIndex ] , sizeof ( m_dSerialization [ NodeIndex ] ) ) ) )
2021-10-06 00:41:32 +00:00
{
m_dSerialization [ NodeIndex ] . HeapSerializationTier = D3D12_HEAP_SERIALIZATION_TIER_0 ;
}
m_dProtectedResourceSessionTypeCount [ NodeIndex ] . NodeIndex = NodeIndex ;
2021-10-22 23:43:43 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_PROTECTED_RESOURCE_SESSION_TYPE_COUNT , & m_dProtectedResourceSessionTypeCount [ NodeIndex ] , sizeof ( m_dProtectedResourceSessionTypeCount [ NodeIndex ] ) ) ) )
2021-10-06 00:41:32 +00:00
{
m_dProtectedResourceSessionTypeCount [ NodeIndex ] . Count = 0 ;
}
// Special procedure to initialize local protected resource session types structs
// Must wait until session type count initialized
QueryProtectedResourceSessionTypes ( NodeIndex , m_dProtectedResourceSessionTypeCount [ NodeIndex ] . Count ) ;
}
// Initialize features that requires highest version check
2021-10-22 23:43:43 +00:00
if ( FAILED ( m_hStatus = QueryHighestShaderModel ( ) ) )
2021-10-06 00:41:32 +00:00
{
return m_hStatus ;
}
2021-10-22 23:43:43 +00:00
if ( FAILED ( m_hStatus = QueryHighestRootSignatureVersion ( ) ) )
2021-10-06 00:41:32 +00:00
{
return m_hStatus ;
}
// Initialize Feature Levels data
2021-10-22 23:43:43 +00:00
if ( FAILED ( m_hStatus = QueryHighestFeatureLevel ( ) ) )
2021-10-06 00:41:32 +00:00
{
return m_hStatus ;
}
2021-10-22 23:43:43 +00:00
2021-10-06 00:41:32 +00:00
return m_hStatus ;
}
// 0: D3D12_OPTIONS
FEATURE_SUPPORT_GET ( BOOL , m_dOptions , DoublePrecisionFloatShaderOps ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions , OutputMergerLogicOp ) ;
FEATURE_SUPPORT_GET ( D3D12_SHADER_MIN_PRECISION_SUPPORT , m_dOptions , MinPrecisionSupport ) ;
FEATURE_SUPPORT_GET ( D3D12_TILED_RESOURCES_TIER , m_dOptions , TiledResourcesTier ) ;
FEATURE_SUPPORT_GET ( D3D12_RESOURCE_BINDING_TIER , m_dOptions , ResourceBindingTier ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions , PSSpecifiedStencilRefSupported ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions , TypedUAVLoadAdditionalFormats ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions , ROVsSupported ) ;
FEATURE_SUPPORT_GET ( D3D12_CONSERVATIVE_RASTERIZATION_TIER , m_dOptions , ConservativeRasterizationTier ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions , StandardSwizzle64KBSupported ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions , CrossAdapterRowMajorTextureSupported ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions , VPAndRTArrayIndexFromAnyShaderFeedingRasterizerSupportedWithoutGSEmulation ) ;
FEATURE_SUPPORT_GET ( D3D12_RESOURCE_HEAP_TIER , m_dOptions , ResourceHeapTier ) ;
// Special procedure for handling caps that is also part of other features
2021-10-22 23:43:43 +00:00
inline D3D12_CROSS_NODE_SHARING_TIER CD3DX12FeatureSupport : : CrossNodeSharingTier ( ) const noexcept
2021-10-06 00:41:32 +00:00
{
if ( m_dCrossNode . SharingTier > D3D12_CROSS_NODE_SHARING_TIER_NOT_SUPPORTED )
{
return m_dCrossNode . SharingTier ;
}
else
{
return m_dOptions . CrossNodeSharingTier ;
}
}
2021-10-22 23:43:43 +00:00
inline UINT CD3DX12FeatureSupport : : MaxGPUVirtualAddressBitsPerResource ( ) const noexcept
2021-10-06 00:41:32 +00:00
{
2021-10-22 23:43:43 +00:00
if ( m_dOptions . MaxGPUVirtualAddressBitsPerResource > 0 )
2021-10-06 00:41:32 +00:00
{
return m_dOptions . MaxGPUVirtualAddressBitsPerResource ;
}
2021-10-22 23:43:43 +00:00
else
2021-10-06 00:41:32 +00:00
{
return m_dGPUVASupport . MaxGPUVirtualAddressBitsPerResource ;
}
}
// 1: Architecture
// Combined with Architecture1
// 2: Feature Levels
// Simply returns the highest supported feature level
2021-10-22 23:43:43 +00:00
inline D3D_FEATURE_LEVEL CD3DX12FeatureSupport : : MaxSupportedFeatureLevel ( ) const noexcept
2021-10-06 00:41:32 +00:00
{
return m_eMaxFeatureLevel ;
}
// 3: Feature Format Support
2021-10-22 23:43:43 +00:00
inline HRESULT CD3DX12FeatureSupport : : FormatSupport ( DXGI_FORMAT Format , D3D12_FORMAT_SUPPORT1 & Support1 , D3D12_FORMAT_SUPPORT2 & Support2 ) const
2021-10-06 00:41:32 +00:00
{
D3D12_FEATURE_DATA_FORMAT_SUPPORT dFormatSupport ;
dFormatSupport . Format = Format ;
// It is possible that the function call returns an error
HRESULT result = m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_FORMAT_SUPPORT , & dFormatSupport , sizeof ( D3D12_FEATURE_DATA_FORMAT_SUPPORT ) ) ;
Support1 = dFormatSupport . Support1 ;
Support2 = dFormatSupport . Support2 ; // Two outputs. Probably better just to take in the struct as an argument?
2021-10-22 23:43:43 +00:00
2021-10-06 00:41:32 +00:00
return result ;
}
// 4: Multisample Quality Levels
2021-10-22 23:43:43 +00:00
inline HRESULT CD3DX12FeatureSupport : : MultisampleQualityLevels ( DXGI_FORMAT Format , UINT SampleCount , D3D12_MULTISAMPLE_QUALITY_LEVEL_FLAGS Flags , UINT & NumQualityLevels ) const
2021-10-06 00:41:32 +00:00
{
D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS dMultisampleQualityLevels ;
dMultisampleQualityLevels . Format = Format ;
dMultisampleQualityLevels . SampleCount = SampleCount ;
dMultisampleQualityLevels . Flags = Flags ;
HRESULT result = m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS , & dMultisampleQualityLevels , sizeof ( D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS ) ) ;
2021-10-22 23:43:43 +00:00
if ( SUCCEEDED ( result ) )
2021-10-06 00:41:32 +00:00
{
NumQualityLevels = dMultisampleQualityLevels . NumQualityLevels ;
2021-10-22 23:43:43 +00:00
}
else
2021-10-06 00:41:32 +00:00
{
NumQualityLevels = 0 ;
}
return result ;
}
// 5: Format Info
2021-10-22 23:43:43 +00:00
inline HRESULT CD3DX12FeatureSupport : : FormatInfo ( DXGI_FORMAT Format , UINT8 & PlaneCount ) const
2021-10-06 00:41:32 +00:00
{
D3D12_FEATURE_DATA_FORMAT_INFO dFormatInfo ;
dFormatInfo . Format = Format ;
HRESULT result = m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_FORMAT_INFO , & dFormatInfo , sizeof ( D3D12_FEATURE_DATA_FORMAT_INFO ) ) ;
if ( FAILED ( result ) )
{
PlaneCount = 0 ;
}
2021-10-22 23:43:43 +00:00
else
2021-10-06 00:41:32 +00:00
{
PlaneCount = dFormatInfo . PlaneCount ;
}
return result ;
}
// 6: GPU Virtual Address Support
// MaxGPUVirtualAddressBitsPerResource handled in D3D12Options
FEATURE_SUPPORT_GET ( UINT , m_dGPUVASupport , MaxGPUVirtualAddressBitsPerProcess ) ;
// 7: Shader Model
2021-10-22 23:43:43 +00:00
inline D3D_SHADER_MODEL CD3DX12FeatureSupport : : HighestShaderModel ( ) const noexcept
2021-10-06 00:41:32 +00:00
{
return m_dShaderModel . HighestShaderModel ;
}
// 8: D3D12 Options1
FEATURE_SUPPORT_GET ( BOOL , m_dOptions1 , WaveOps ) ;
FEATURE_SUPPORT_GET ( UINT , m_dOptions1 , WaveLaneCountMin ) ;
FEATURE_SUPPORT_GET ( UINT , m_dOptions1 , WaveLaneCountMax ) ;
FEATURE_SUPPORT_GET ( UINT , m_dOptions1 , TotalLaneCount ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions1 , ExpandedComputeResourceStates ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions1 , Int64ShaderOps ) ;
// 10: Protected Resource Session Support
inline D3D12_PROTECTED_RESOURCE_SESSION_SUPPORT_FLAGS CD3DX12FeatureSupport : : ProtectedResourceSessionSupport ( UINT NodeIndex ) const
{
return m_dProtectedResourceSessionSupport [ NodeIndex ] . Support ;
}
// 12: Root Signature
2021-10-22 23:43:43 +00:00
inline D3D_ROOT_SIGNATURE_VERSION CD3DX12FeatureSupport : : HighestRootSignatureVersion ( ) const noexcept
2021-10-06 00:41:32 +00:00
{
return m_dRootSignature . HighestVersion ;
}
// 16: Architecture1
// Same data fields can be queried from m_dArchitecture
FEATURE_SUPPORT_GET_NODE_INDEXED ( BOOL , m_dArchitecture1 , TileBasedRenderer ) ;
FEATURE_SUPPORT_GET_NODE_INDEXED ( BOOL , m_dArchitecture1 , UMA ) ;
FEATURE_SUPPORT_GET_NODE_INDEXED ( BOOL , m_dArchitecture1 , CacheCoherentUMA ) ;
FEATURE_SUPPORT_GET_NODE_INDEXED ( BOOL , m_dArchitecture1 , IsolatedMMU ) ;
// 18: D3D12 Options2
FEATURE_SUPPORT_GET ( BOOL , m_dOptions2 , DepthBoundsTestSupported ) ;
FEATURE_SUPPORT_GET ( D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER , m_dOptions2 , ProgrammableSamplePositionsTier ) ;
// 19: Shader Cache
FEATURE_SUPPORT_GET_NAME ( D3D12_SHADER_CACHE_SUPPORT_FLAGS , m_dShaderCache , SupportFlags , ShaderCacheSupportFlags ) ;
// 20: Command Queue Priority
inline BOOL CD3DX12FeatureSupport : : CommandQueuePrioritySupported ( D3D12_COMMAND_LIST_TYPE CommandListType , UINT Priority )
{
m_dCommandQueuePriority . CommandListType = CommandListType ;
m_dCommandQueuePriority . Priority = Priority ;
2021-10-22 23:43:43 +00:00
if ( FAILED ( m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_COMMAND_QUEUE_PRIORITY , & m_dCommandQueuePriority , sizeof ( D3D12_FEATURE_DATA_COMMAND_QUEUE_PRIORITY ) ) ) )
2021-10-06 00:41:32 +00:00
{
return false ;
}
return m_dCommandQueuePriority . PriorityForTypeIsSupported ;
}
// 21: D3D12 Options3
FEATURE_SUPPORT_GET ( BOOL , m_dOptions3 , CopyQueueTimestampQueriesSupported ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions3 , CastingFullyTypedFormatSupported ) ;
FEATURE_SUPPORT_GET ( D3D12_COMMAND_LIST_SUPPORT_FLAGS , m_dOptions3 , WriteBufferImmediateSupportFlags ) ;
FEATURE_SUPPORT_GET ( D3D12_VIEW_INSTANCING_TIER , m_dOptions3 , ViewInstancingTier ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions3 , BarycentricsSupported ) ;
// 22: Existing Heaps
FEATURE_SUPPORT_GET_NAME ( BOOL , m_dExistingHeaps , Supported , ExistingHeapsSupported ) ;
// 23: D3D12 Options4
FEATURE_SUPPORT_GET ( BOOL , m_dOptions4 , MSAA64KBAlignedTextureSupported ) ;
FEATURE_SUPPORT_GET ( D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER , m_dOptions4 , SharedResourceCompatibilityTier ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions4 , Native16BitShaderOpsSupported ) ;
// 24: Serialization
FEATURE_SUPPORT_GET_NODE_INDEXED ( D3D12_HEAP_SERIALIZATION_TIER , m_dSerialization , HeapSerializationTier ) ;
// 25: Cross Node
// CrossNodeSharingTier handled in D3D12Options
FEATURE_SUPPORT_GET_NAME ( BOOL , m_dCrossNode , AtomicShaderInstructions , CrossNodeAtomicShaderInstructions ) ;
// 27: D3D12 Options5
FEATURE_SUPPORT_GET ( BOOL , m_dOptions5 , SRVOnlyTiledResourceTier3 ) ;
FEATURE_SUPPORT_GET ( D3D12_RENDER_PASS_TIER , m_dOptions5 , RenderPassesTier ) ;
FEATURE_SUPPORT_GET ( D3D12_RAYTRACING_TIER , m_dOptions5 , RaytracingTier ) ;
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4)
2021-10-06 00:41:32 +00:00
// 28: Displayable
FEATURE_SUPPORT_GET ( BOOL , m_dDisplayable , DisplayableTexture ) ;
// SharedResourceCompatibilityTier handled in D3D12Options4
2022-11-19 21:03:20 +00:00
# endif
2021-10-06 00:41:32 +00:00
// 30: D3D12 Options6
FEATURE_SUPPORT_GET ( BOOL , m_dOptions6 , AdditionalShadingRatesSupported ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions6 , PerPrimitiveShadingRateSupportedWithViewportIndexing ) ;
FEATURE_SUPPORT_GET ( D3D12_VARIABLE_SHADING_RATE_TIER , m_dOptions6 , VariableShadingRateTier ) ;
FEATURE_SUPPORT_GET ( UINT , m_dOptions6 , ShadingRateImageTileSize ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions6 , BackgroundProcessingSupported ) ;
// 31: Query Meta Command
// Keep the original call routine
2021-10-22 23:43:43 +00:00
inline HRESULT CD3DX12FeatureSupport : : QueryMetaCommand ( D3D12_FEATURE_DATA_QUERY_META_COMMAND & dQueryMetaCommand ) const
2021-10-06 00:41:32 +00:00
{
return m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_QUERY_META_COMMAND , & dQueryMetaCommand , sizeof ( D3D12_FEATURE_DATA_QUERY_META_COMMAND ) ) ;
}
// 32: D3D12 Options7
FEATURE_SUPPORT_GET ( D3D12_MESH_SHADER_TIER , m_dOptions7 , MeshShaderTier ) ;
FEATURE_SUPPORT_GET ( D3D12_SAMPLER_FEEDBACK_TIER , m_dOptions7 , SamplerFeedbackTier ) ;
// 33: Protected Resource Session Type Count
FEATURE_SUPPORT_GET_NODE_INDEXED_NAME ( UINT , m_dProtectedResourceSessionTypeCount , Count , ProtectedResourceSessionTypeCount ) ;
// 34: Protected Resource Session Types
FEATURE_SUPPORT_GET_NODE_INDEXED_NAME ( std : : vector < GUID > , m_dProtectedResourceSessionTypes , TypeVec , ProtectedResourceSessionTypes ) ;
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 3)
2021-10-06 00:41:32 +00:00
// 36: Options8
FEATURE_SUPPORT_GET ( BOOL , m_dOptions8 , UnalignedBlockTexturesSupported ) ;
// 37: Options9
FEATURE_SUPPORT_GET ( BOOL , m_dOptions9 , MeshShaderPipelineStatsSupported ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions9 , MeshShaderSupportsFullRangeRenderTargetArrayIndex ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions9 , AtomicInt64OnTypedResourceSupported ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions9 , AtomicInt64OnGroupSharedSupported ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions9 , DerivativesInMeshAndAmplificationShadersSupported ) ;
FEATURE_SUPPORT_GET ( D3D12_WAVE_MMA_TIER , m_dOptions9 , WaveMMATier ) ;
2022-11-19 21:03:20 +00:00
# endif
2021-10-06 00:41:32 +00:00
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 4)
2021-10-06 00:41:32 +00:00
// 39: Options10
FEATURE_SUPPORT_GET ( BOOL , m_dOptions10 , VariableRateShadingSumCombinerSupported ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions10 , MeshShaderPerPrimitiveShadingRateSupported ) ;
// 40: Options11
FEATURE_SUPPORT_GET ( BOOL , m_dOptions11 , AtomicInt64OnDescriptorHeapResourceSupported ) ;
2022-11-19 21:03:20 +00:00
# endif
2021-10-06 00:41:32 +00:00
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 600)
2022-05-08 21:25:55 +00:00
// 41: Options12
FEATURE_SUPPORT_GET ( D3D12_TRI_STATE , m_dOptions12 , MSPrimitivesPipelineStatisticIncludesCulledPrimitives ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions12 , EnhancedBarriersSupported ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions12 , RelaxedFormatCastingSupported ) ;
2023-04-24 20:52:49 +00:00
# endif
2022-05-08 21:25:55 +00:00
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 602)
2022-05-08 21:25:55 +00:00
// 42: Options13
FEATURE_SUPPORT_GET ( BOOL , m_dOptions13 , UnrestrictedBufferTextureCopyPitchSupported ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions13 , UnrestrictedVertexElementAlignmentSupported ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions13 , InvertedViewportHeightFlipsYSupported ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions13 , InvertedViewportDepthFlipsZSupported ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions13 , TextureCopyBetweenDimensionsSupported ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions13 , AlphaBlendFactorSupported ) ;
# endif
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606)
2022-11-19 21:03:20 +00:00
// 43: Options14
FEATURE_SUPPORT_GET ( BOOL , m_dOptions14 , AdvancedTextureOpsSupported ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions14 , WriteableMSAATexturesSupported ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions14 , IndependentFrontAndBackStencilRefMaskSupported ) ;
// 44: Options15
FEATURE_SUPPORT_GET ( BOOL , m_dOptions15 , TriangleFanSupported ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions15 , DynamicIndexBufferStripCutSupported ) ;
2023-04-24 20:52:49 +00:00
# endif
2022-11-19 21:03:20 +00:00
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 608)
2022-11-19 21:03:20 +00:00
// 45: Options16
FEATURE_SUPPORT_GET ( BOOL , m_dOptions16 , DynamicDepthBiasSupported ) ;
2023-04-24 20:52:49 +00:00
# endif
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
FEATURE_SUPPORT_GET ( BOOL , m_dOptions16 , GPUUploadHeapSupported ) ;
// 46: Options17
FEATURE_SUPPORT_GET ( BOOL , m_dOptions17 , NonNormalizedCoordinateSamplersSupported ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions17 , ManualWriteTrackingResourceSupported ) ;
// 47: Option18
FEATURE_SUPPORT_GET ( BOOL , m_dOptions18 , RenderPassesValid ) ;
# endif
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 610)
FEATURE_SUPPORT_GET ( BOOL , m_dOptions19 , MismatchingOutputDimensionsSupported ) ;
FEATURE_SUPPORT_GET ( UINT , m_dOptions19 , SupportedSampleCountsWithNoOutputs ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions19 , PointSamplingAddressesNeverRoundUp ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions19 , RasterizerDesc2Supported ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions19 , NarrowQuadrilateralLinesSupported ) ;
FEATURE_SUPPORT_GET ( BOOL , m_dOptions19 , AnisoFilterWithPointMipSupported ) ;
FEATURE_SUPPORT_GET ( UINT , m_dOptions19 , MaxSamplerDescriptorHeapSize ) ;
FEATURE_SUPPORT_GET ( UINT , m_dOptions19 , MaxSamplerDescriptorHeapSizeWithStaticSamplers ) ;
FEATURE_SUPPORT_GET ( UINT , m_dOptions19 , MaxViewDescriptorHeapSize ) ;
# endif
2022-11-19 21:03:20 +00:00
2024-02-05 18:08:59 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 611)
// 49: Options20
FEATURE_SUPPORT_GET ( BOOL , m_dOptions20 , ComputeOnlyWriteWatchSupported ) ;
# endif
2024-05-17 23:56:19 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612)
// 50: Options21
FEATURE_SUPPORT_GET ( D3D12_EXECUTE_INDIRECT_TIER , m_dOptions21 , ExecuteIndirectTier ) ;
FEATURE_SUPPORT_GET ( D3D12_WORK_GRAPHS_TIER , m_dOptions21 , WorkGraphsTier ) ;
# endif
2021-10-06 00:41:32 +00:00
// Helper function to decide the highest shader model supported by the system
// Stores the result in m_dShaderModel
// Must be updated whenever a new shader model is added to the d3d12.h header
inline HRESULT CD3DX12FeatureSupport : : QueryHighestShaderModel ( )
{
// Check support in descending order
HRESULT result ;
2021-10-22 23:43:43 +00:00
const D3D_SHADER_MODEL allModelVersions [ ] =
2021-10-06 00:41:32 +00:00
{
2024-05-17 23:56:19 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 612)
D3D_SHADER_MODEL_6_9 ,
# endif
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 606)
2022-11-19 21:03:20 +00:00
D3D_SHADER_MODEL_6_8 ,
# endif
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 3)
2021-10-06 00:41:32 +00:00
D3D_SHADER_MODEL_6_7 ,
2022-11-19 21:03:20 +00:00
# endif
2021-10-06 00:41:32 +00:00
D3D_SHADER_MODEL_6_6 ,
D3D_SHADER_MODEL_6_5 ,
D3D_SHADER_MODEL_6_4 ,
D3D_SHADER_MODEL_6_3 ,
D3D_SHADER_MODEL_6_2 ,
D3D_SHADER_MODEL_6_1 ,
D3D_SHADER_MODEL_6_0 ,
D3D_SHADER_MODEL_5_1
} ;
2021-10-22 23:43:43 +00:00
constexpr size_t numModelVersions = sizeof ( allModelVersions ) / sizeof ( D3D_SHADER_MODEL ) ;
2021-10-06 00:41:32 +00:00
2021-10-22 23:43:43 +00:00
for ( size_t i = 0 ; i < numModelVersions ; i + + )
2021-10-06 00:41:32 +00:00
{
m_dShaderModel . HighestShaderModel = allModelVersions [ i ] ;
result = m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_SHADER_MODEL , & m_dShaderModel , sizeof ( D3D12_FEATURE_DATA_SHADER_MODEL ) ) ;
2021-10-22 23:43:43 +00:00
if ( result ! = E_INVALIDARG )
2021-10-06 00:41:32 +00:00
{
// Indicates that the version is recognizable by the runtime and stored in the struct
// Also terminate on unexpected error code
2021-10-22 23:43:43 +00:00
if ( FAILED ( result ) )
2021-10-06 00:41:32 +00:00
{
2021-10-22 23:43:43 +00:00
m_dShaderModel . HighestShaderModel = static_cast < D3D_SHADER_MODEL > ( 0 ) ;
2021-10-06 00:41:32 +00:00
}
return result ;
}
}
// Shader model may not be supported. Continue the rest initializations
2021-10-22 23:43:43 +00:00
m_dShaderModel . HighestShaderModel = static_cast < D3D_SHADER_MODEL > ( 0 ) ;
2021-10-06 00:41:32 +00:00
return S_OK ;
}
// Helper function to decide the highest root signature supported
// Must be updated whenever a new root signature version is added to the d3d12.h header
inline HRESULT CD3DX12FeatureSupport : : QueryHighestRootSignatureVersion ( )
{
HRESULT result ;
2021-10-22 23:43:43 +00:00
const D3D_ROOT_SIGNATURE_VERSION allRootSignatureVersions [ ] =
2021-10-06 00:41:32 +00:00
{
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 609)
2022-11-30 22:18:40 +00:00
D3D_ROOT_SIGNATURE_VERSION_1_2 ,
# endif
2021-10-06 00:41:32 +00:00
D3D_ROOT_SIGNATURE_VERSION_1_1 ,
D3D_ROOT_SIGNATURE_VERSION_1_0 ,
D3D_ROOT_SIGNATURE_VERSION_1 ,
} ;
2021-10-22 23:43:43 +00:00
constexpr size_t numRootSignatureVersions = sizeof ( allRootSignatureVersions ) / sizeof ( D3D_ROOT_SIGNATURE_VERSION ) ;
2021-10-06 00:41:32 +00:00
2021-10-22 23:43:43 +00:00
for ( size_t i = 0 ; i < numRootSignatureVersions ; i + + )
2021-10-06 00:41:32 +00:00
{
m_dRootSignature . HighestVersion = allRootSignatureVersions [ i ] ;
result = m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_ROOT_SIGNATURE , & m_dRootSignature , sizeof ( D3D12_FEATURE_DATA_ROOT_SIGNATURE ) ) ;
2021-10-22 23:43:43 +00:00
if ( result ! = E_INVALIDARG )
2021-10-06 00:41:32 +00:00
{
2021-10-22 23:43:43 +00:00
if ( FAILED ( result ) )
2021-10-06 00:41:32 +00:00
{
2021-10-22 23:43:43 +00:00
m_dRootSignature . HighestVersion = static_cast < D3D_ROOT_SIGNATURE_VERSION > ( 0 ) ;
2021-10-06 00:41:32 +00:00
}
// If succeeded, the highest version is already written into the member struct
return result ;
}
}
// No version left. Set to invalid value and continue.
2021-10-22 23:43:43 +00:00
m_dRootSignature . HighestVersion = static_cast < D3D_ROOT_SIGNATURE_VERSION > ( 0 ) ;
2021-10-06 00:41:32 +00:00
return S_OK ;
}
// Helper funcion to decide the highest feature level
inline HRESULT CD3DX12FeatureSupport : : QueryHighestFeatureLevel ( )
{
HRESULT result ;
// Check against a list of all feature levels present in d3dcommon.h
// Needs to be updated for future feature levels
2021-10-22 23:43:43 +00:00
const D3D_FEATURE_LEVEL allLevels [ ] =
2021-10-06 00:41:32 +00:00
{
2023-04-24 20:52:49 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 3)
2021-10-06 00:41:32 +00:00
D3D_FEATURE_LEVEL_12_2 ,
2022-11-19 21:03:20 +00:00
# endif
2021-10-06 00:41:32 +00:00
D3D_FEATURE_LEVEL_12_1 ,
D3D_FEATURE_LEVEL_12_0 ,
D3D_FEATURE_LEVEL_11_1 ,
D3D_FEATURE_LEVEL_11_0 ,
D3D_FEATURE_LEVEL_10_1 ,
D3D_FEATURE_LEVEL_10_0 ,
D3D_FEATURE_LEVEL_9_3 ,
D3D_FEATURE_LEVEL_9_2 ,
D3D_FEATURE_LEVEL_9_1 ,
2024-02-05 18:08:59 +00:00
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 5)
D3D_FEATURE_LEVEL_1_0_CORE ,
# endif
# if defined(D3D12_SDK_VERSION) && (D3D12_SDK_VERSION >= 611)
D3D_FEATURE_LEVEL_1_0_GENERIC
# endif
2021-10-06 00:41:32 +00:00
} ;
D3D12_FEATURE_DATA_FEATURE_LEVELS dFeatureLevel ;
2021-10-22 23:43:43 +00:00
dFeatureLevel . NumFeatureLevels = static_cast < UINT > ( sizeof ( allLevels ) / sizeof ( D3D_FEATURE_LEVEL ) ) ;
2021-10-06 00:41:32 +00:00
dFeatureLevel . pFeatureLevelsRequested = allLevels ;
result = m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_FEATURE_LEVELS , & dFeatureLevel , sizeof ( D3D12_FEATURE_DATA_FEATURE_LEVELS ) ) ;
2021-10-22 23:43:43 +00:00
if ( SUCCEEDED ( result ) )
2021-10-06 00:41:32 +00:00
{
m_eMaxFeatureLevel = dFeatureLevel . MaxSupportedFeatureLevel ;
2021-10-22 23:43:43 +00:00
}
else
2021-10-06 00:41:32 +00:00
{
2021-10-22 23:43:43 +00:00
m_eMaxFeatureLevel = static_cast < D3D_FEATURE_LEVEL > ( 0 ) ;
2021-10-06 00:41:32 +00:00
2021-10-22 23:43:43 +00:00
if ( result = = DXGI_ERROR_UNSUPPORTED )
{
2021-10-06 00:41:32 +00:00
// Indicates that none supported. Continue initialization
result = S_OK ;
}
}
return result ;
}
// Helper function to initialize local protected resource session types structs
inline HRESULT CD3DX12FeatureSupport : : QueryProtectedResourceSessionTypes ( UINT NodeIndex , UINT Count )
{
auto & CurrentPRSTypes = m_dProtectedResourceSessionTypes [ NodeIndex ] ;
CurrentPRSTypes . NodeIndex = NodeIndex ;
CurrentPRSTypes . Count = Count ;
CurrentPRSTypes . TypeVec . resize ( CurrentPRSTypes . Count ) ;
CurrentPRSTypes . pTypes = CurrentPRSTypes . TypeVec . data ( ) ;
HRESULT result = m_pDevice - > CheckFeatureSupport ( D3D12_FEATURE_PROTECTED_RESOURCE_SESSION_TYPES , & m_dProtectedResourceSessionTypes [ NodeIndex ] , sizeof ( D3D12_FEATURE_DATA_PROTECTED_RESOURCE_SESSION_TYPES ) ) ;
if ( FAILED ( result ) )
{
// Resize TypeVec to empty
CurrentPRSTypes . TypeVec . clear ( ) ;
}
return result ;
}
# undef FEATURE_SUPPORT_GET
# undef FEATURE_SUPPORT_GET_NAME
# undef FEATURE_SUPPORT_GET_NODE_INDEXED
# undef FEATURE_SUPPORT_GET_NODE_INDEXED_NAME
// end CD3DX12FeatureSupport
2022-05-08 21:25:55 +00:00
# endif // !D3DX12_NO_CHECK_FEATURE_SUPPORT_CLASS
2021-10-06 00:41:32 +00:00
# undef D3DX12_COM_PTR
# undef D3DX12_COM_PTR_GET
# undef D3DX12_COM_PTR_ADDRESSOF
2023-04-28 00:03:18 +00:00
# ifdef __clang__
# pragma clang diagnostic pop
# endif
2017-01-26 18:23:36 +00:00
# endif // defined( __cplusplus )
# endif //__D3DX12_H__