mirror of
https://github.com/microsoft/DirectXTex.git
synced 2025-07-13 21:50:13 +02:00
Cleaned up d3dx12
This commit is contained in:
parent
0d94e9469b
commit
7d838aa46a
@ -48,7 +48,6 @@ struct CD3DX12_RECT : public D3D12_RECT
|
||||
right = Right;
|
||||
bottom = Bottom;
|
||||
}
|
||||
~CD3DX12_RECT() {}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
@ -81,7 +80,7 @@ struct CD3DX12_VIEWPORT : public D3D12_VIEWPORT
|
||||
FLOAT minDepth = D3D12_MIN_DEPTH,
|
||||
FLOAT maxDepth = D3D12_MAX_DEPTH )
|
||||
{
|
||||
D3D12_RESOURCE_DESC Desc = pResource->GetDesc();
|
||||
auto Desc = pResource->GetDesc();
|
||||
const UINT64 SubresourceWidth = Desc.Width >> mipSlice;
|
||||
const UINT64 SubresourceHeight = Desc.Height >> mipSlice;
|
||||
switch (Desc.Dimension)
|
||||
@ -111,7 +110,6 @@ struct CD3DX12_VIEWPORT : public D3D12_VIEWPORT
|
||||
MinDepth = minDepth;
|
||||
MaxDepth = maxDepth;
|
||||
}
|
||||
~CD3DX12_VIEWPORT() {}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
@ -160,7 +158,6 @@ struct CD3DX12_BOX : public D3D12_BOX
|
||||
bottom = Bottom;
|
||||
back = Back;
|
||||
}
|
||||
~CD3DX12_BOX() {}
|
||||
};
|
||||
inline bool operator==( const D3D12_BOX& l, const D3D12_BOX& r )
|
||||
{
|
||||
@ -221,7 +218,6 @@ struct CD3DX12_DEPTH_STENCIL_DESC : public D3D12_DEPTH_STENCIL_DESC
|
||||
BackFace.StencilPassOp = backStencilPassOp;
|
||||
BackFace.StencilFunc = backStencilFunc;
|
||||
}
|
||||
~CD3DX12_DEPTH_STENCIL_DESC() {}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
@ -298,7 +294,6 @@ struct CD3DX12_DEPTH_STENCIL_DESC1 : public D3D12_DEPTH_STENCIL_DESC1
|
||||
BackFace.StencilFunc = backStencilFunc;
|
||||
DepthBoundsTestEnable = depthBoundsTestEnable;
|
||||
}
|
||||
~CD3DX12_DEPTH_STENCIL_DESC1() {}
|
||||
operator D3D12_DEPTH_STENCIL_DESC() const
|
||||
{
|
||||
D3D12_DEPTH_STENCIL_DESC D;
|
||||
@ -343,7 +338,6 @@ struct CD3DX12_BLEND_DESC : public D3D12_BLEND_DESC
|
||||
for (UINT i = 0; i < D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
|
||||
RenderTarget[ i ] = defaultRenderTargetBlendDesc;
|
||||
}
|
||||
~CD3DX12_BLEND_DESC() {}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
@ -392,7 +386,6 @@ struct CD3DX12_RASTERIZER_DESC : public D3D12_RASTERIZER_DESC
|
||||
ForcedSampleCount = forcedSampleCount;
|
||||
ConservativeRaster = conservativeRaster;
|
||||
}
|
||||
~CD3DX12_RASTERIZER_DESC() {}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
@ -744,8 +737,7 @@ struct CD3DX12_RESOURCE_BARRIER : public D3D12_RESOURCE_BARRIER
|
||||
UINT subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES,
|
||||
D3D12_RESOURCE_BARRIER_FLAGS flags = D3D12_RESOURCE_BARRIER_FLAG_NONE)
|
||||
{
|
||||
CD3DX12_RESOURCE_BARRIER result;
|
||||
ZeroMemory(&result, sizeof(result));
|
||||
CD3DX12_RESOURCE_BARRIER result = {};
|
||||
D3D12_RESOURCE_BARRIER &barrier = result;
|
||||
result.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
|
||||
result.Flags = flags;
|
||||
@ -759,8 +751,7 @@ struct CD3DX12_RESOURCE_BARRIER : public D3D12_RESOURCE_BARRIER
|
||||
_In_ ID3D12Resource* pResourceBefore,
|
||||
_In_ ID3D12Resource* pResourceAfter)
|
||||
{
|
||||
CD3DX12_RESOURCE_BARRIER result;
|
||||
ZeroMemory(&result, sizeof(result));
|
||||
CD3DX12_RESOURCE_BARRIER result = {};
|
||||
D3D12_RESOURCE_BARRIER &barrier = result;
|
||||
result.Type = D3D12_RESOURCE_BARRIER_TYPE_ALIASING;
|
||||
barrier.Aliasing.pResourceBefore = pResourceBefore;
|
||||
@ -770,8 +761,7 @@ struct CD3DX12_RESOURCE_BARRIER : public D3D12_RESOURCE_BARRIER
|
||||
static inline CD3DX12_RESOURCE_BARRIER UAV(
|
||||
_In_ ID3D12Resource* pResource)
|
||||
{
|
||||
CD3DX12_RESOURCE_BARRIER result;
|
||||
ZeroMemory(&result, sizeof(result));
|
||||
CD3DX12_RESOURCE_BARRIER result = {};
|
||||
D3D12_RESOURCE_BARRIER &barrier = result;
|
||||
result.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV;
|
||||
barrier.UAV.pResource = pResource;
|
||||
@ -838,14 +828,19 @@ struct CD3DX12_TEXTURE_COPY_LOCATION : public D3D12_TEXTURE_COPY_LOCATION
|
||||
explicit CD3DX12_TEXTURE_COPY_LOCATION(const D3D12_TEXTURE_COPY_LOCATION &o) :
|
||||
D3D12_TEXTURE_COPY_LOCATION(o)
|
||||
{}
|
||||
CD3DX12_TEXTURE_COPY_LOCATION(ID3D12Resource* pRes) { pResource = pRes; }
|
||||
CD3DX12_TEXTURE_COPY_LOCATION(ID3D12Resource* pRes, D3D12_PLACED_SUBRESOURCE_FOOTPRINT const& Footprint)
|
||||
CD3DX12_TEXTURE_COPY_LOCATION(_In_ ID3D12Resource* pRes)
|
||||
{
|
||||
pResource = pRes;
|
||||
Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
|
||||
PlacedFootprint = {};
|
||||
}
|
||||
CD3DX12_TEXTURE_COPY_LOCATION(_In_ ID3D12Resource* pRes, D3D12_PLACED_SUBRESOURCE_FOOTPRINT const& Footprint)
|
||||
{
|
||||
pResource = pRes;
|
||||
Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
|
||||
PlacedFootprint = Footprint;
|
||||
}
|
||||
CD3DX12_TEXTURE_COPY_LOCATION(ID3D12Resource* pRes, UINT Sub)
|
||||
CD3DX12_TEXTURE_COPY_LOCATION(_In_ ID3D12Resource* pRes, UINT Sub)
|
||||
{
|
||||
pResource = pRes;
|
||||
Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
|
||||
@ -1212,21 +1207,21 @@ struct CD3DX12_ROOT_SIGNATURE_DESC : public D3D12_ROOT_SIGNATURE_DESC
|
||||
UINT numParameters,
|
||||
_In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters,
|
||||
UINT numStaticSamplers = 0,
|
||||
_In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = NULL,
|
||||
_In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr,
|
||||
D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE)
|
||||
{
|
||||
Init(numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags);
|
||||
}
|
||||
CD3DX12_ROOT_SIGNATURE_DESC(CD3DX12_DEFAULT)
|
||||
{
|
||||
Init(0, NULL, 0, NULL, D3D12_ROOT_SIGNATURE_FLAG_NONE);
|
||||
Init(0, nullptr, 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_NONE);
|
||||
}
|
||||
|
||||
inline void Init(
|
||||
UINT numParameters,
|
||||
_In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters,
|
||||
UINT numStaticSamplers = 0,
|
||||
_In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = NULL,
|
||||
_In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr,
|
||||
D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE)
|
||||
{
|
||||
Init(*this, numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags);
|
||||
@ -1237,7 +1232,7 @@ struct CD3DX12_ROOT_SIGNATURE_DESC : public D3D12_ROOT_SIGNATURE_DESC
|
||||
UINT numParameters,
|
||||
_In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters,
|
||||
UINT numStaticSamplers = 0,
|
||||
_In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = NULL,
|
||||
_In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr,
|
||||
D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE)
|
||||
{
|
||||
desc.NumParameters = numParameters;
|
||||
@ -1497,7 +1492,7 @@ struct CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC : public D3D12_VERSIONED_ROOT_SIGNA
|
||||
UINT numParameters,
|
||||
_In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters,
|
||||
UINT numStaticSamplers = 0,
|
||||
_In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = NULL,
|
||||
_In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr,
|
||||
D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE)
|
||||
{
|
||||
Init_1_0(numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags);
|
||||
@ -1506,21 +1501,21 @@ struct CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC : public D3D12_VERSIONED_ROOT_SIGNA
|
||||
UINT numParameters,
|
||||
_In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER1* _pParameters,
|
||||
UINT numStaticSamplers = 0,
|
||||
_In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = NULL,
|
||||
_In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr,
|
||||
D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE)
|
||||
{
|
||||
Init_1_1(numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags);
|
||||
}
|
||||
CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC(CD3DX12_DEFAULT)
|
||||
{
|
||||
Init_1_1(0, NULL, 0, NULL, D3D12_ROOT_SIGNATURE_FLAG_NONE);
|
||||
Init_1_1(0, nullptr, 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_NONE);
|
||||
}
|
||||
|
||||
inline void Init_1_0(
|
||||
UINT numParameters,
|
||||
_In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters,
|
||||
UINT numStaticSamplers = 0,
|
||||
_In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = NULL,
|
||||
_In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr,
|
||||
D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE)
|
||||
{
|
||||
Init_1_0(*this, numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags);
|
||||
@ -1531,7 +1526,7 @@ struct CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC : public D3D12_VERSIONED_ROOT_SIGNA
|
||||
UINT numParameters,
|
||||
_In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters,
|
||||
UINT numStaticSamplers = 0,
|
||||
_In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = NULL,
|
||||
_In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr,
|
||||
D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE)
|
||||
{
|
||||
desc.Version = D3D_ROOT_SIGNATURE_VERSION_1_0;
|
||||
@ -1546,7 +1541,7 @@ struct CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC : public D3D12_VERSIONED_ROOT_SIGNA
|
||||
UINT numParameters,
|
||||
_In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER1* _pParameters,
|
||||
UINT numStaticSamplers = 0,
|
||||
_In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = NULL,
|
||||
_In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr,
|
||||
D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE)
|
||||
{
|
||||
Init_1_1(*this, numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags);
|
||||
@ -1557,7 +1552,7 @@ struct CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC : public D3D12_VERSIONED_ROOT_SIGNA
|
||||
UINT numParameters,
|
||||
_In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER1* _pParameters,
|
||||
UINT numStaticSamplers = 0,
|
||||
_In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = NULL,
|
||||
_In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr,
|
||||
D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE)
|
||||
{
|
||||
desc.Version = D3D_ROOT_SIGNATURE_VERSION_1_1;
|
||||
@ -1626,7 +1621,7 @@ struct CD3DX12_CPU_DESCRIPTOR_HANDLE : public D3D12_CPU_DESCRIPTOR_HANDLE
|
||||
|
||||
static inline void InitOffsetted(_Out_ D3D12_CPU_DESCRIPTOR_HANDLE &handle, _In_ const D3D12_CPU_DESCRIPTOR_HANDLE &base, INT offsetInDescriptors, UINT descriptorIncrementSize)
|
||||
{
|
||||
handle.ptr = base.ptr + INT64(offsetInDescriptors) * UINT64(descriptorIncrementSize);
|
||||
handle.ptr = static_cast<SIZE_T>(base.ptr + INT64(offsetInDescriptors) * UINT64(descriptorIncrementSize));
|
||||
}
|
||||
};
|
||||
|
||||
@ -1687,7 +1682,7 @@ struct CD3DX12_GPU_DESCRIPTOR_HANDLE : public D3D12_GPU_DESCRIPTOR_HANDLE
|
||||
|
||||
static inline void InitOffsetted(_Out_ D3D12_GPU_DESCRIPTOR_HANDLE &handle, _In_ const D3D12_GPU_DESCRIPTOR_HANDLE &base, INT offsetInDescriptors, UINT descriptorIncrementSize)
|
||||
{
|
||||
handle.ptr = base.ptr + INT64(offsetInDescriptors) * UINT64(descriptorIncrementSize);
|
||||
handle.ptr = static_cast<UINT64>(base.ptr + INT64(offsetInDescriptors) * UINT64(descriptorIncrementSize));
|
||||
}
|
||||
};
|
||||
|
||||
@ -1712,7 +1707,7 @@ inline UINT8 D3D12GetFormatPlaneCount(
|
||||
DXGI_FORMAT Format
|
||||
)
|
||||
{
|
||||
D3D12_FEATURE_DATA_FORMAT_INFO formatInfo = {Format};
|
||||
D3D12_FEATURE_DATA_FORMAT_INFO formatInfo = { Format, 0 };
|
||||
if (FAILED(pDevice->CheckFeatureSupport(D3D12_FEATURE_FORMAT_INFO, &formatInfo, sizeof(formatInfo))))
|
||||
{
|
||||
return 0;
|
||||
@ -1859,7 +1854,6 @@ struct CD3DX12_VIEW_INSTANCING_DESC : public D3D12_VIEW_INSTANCING_DESC
|
||||
pViewInstanceLocations = InViewInstanceLocations;
|
||||
Flags = InFlags;
|
||||
}
|
||||
~CD3DX12_VIEW_INSTANCING_DESC() {}
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -1892,10 +1886,10 @@ inline UINT64 GetRequiredIntermediateSize(
|
||||
_In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource,
|
||||
_In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources)
|
||||
{
|
||||
D3D12_RESOURCE_DESC Desc = pDestinationResource->GetDesc();
|
||||
auto Desc = pDestinationResource->GetDesc();
|
||||
UINT64 RequiredSize = 0;
|
||||
|
||||
ID3D12Device* pDevice;
|
||||
ID3D12Device* pDevice = nullptr;
|
||||
pDestinationResource->GetDevice(__uuidof(*pDevice), reinterpret_cast<void**>(&pDevice));
|
||||
pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, 0, nullptr, nullptr, nullptr, &RequiredSize);
|
||||
pDevice->Release();
|
||||
@ -1918,11 +1912,11 @@ inline UINT64 UpdateSubresources(
|
||||
_In_reads_(NumSubresources) const D3D12_SUBRESOURCE_DATA* pSrcData)
|
||||
{
|
||||
// Minor validation
|
||||
D3D12_RESOURCE_DESC IntermediateDesc = pIntermediate->GetDesc();
|
||||
D3D12_RESOURCE_DESC DestinationDesc = pDestinationResource->GetDesc();
|
||||
auto IntermediateDesc = pIntermediate->GetDesc();
|
||||
auto DestinationDesc = pDestinationResource->GetDesc();
|
||||
if (IntermediateDesc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER ||
|
||||
IntermediateDesc.Width < RequiredSize + pLayouts[0].Offset ||
|
||||
RequiredSize > (SIZE_T)-1 ||
|
||||
RequiredSize > SIZE_T(-1) ||
|
||||
(DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER &&
|
||||
(FirstSubresource != 0 || NumSubresources != 1)))
|
||||
{
|
||||
@ -1930,7 +1924,7 @@ inline UINT64 UpdateSubresources(
|
||||
}
|
||||
|
||||
BYTE* pData;
|
||||
HRESULT hr = pIntermediate->Map(0, NULL, reinterpret_cast<void**>(&pData));
|
||||
HRESULT hr = pIntermediate->Map(0, nullptr, reinterpret_cast<void**>(&pData));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
return 0;
|
||||
@ -1938,11 +1932,11 @@ inline UINT64 UpdateSubresources(
|
||||
|
||||
for (UINT i = 0; i < NumSubresources; ++i)
|
||||
{
|
||||
if (pRowSizesInBytes[i] > (SIZE_T)-1) return 0;
|
||||
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, &pSrcData[i], (SIZE_T)pRowSizesInBytes[i], pNumRows[i], pLayouts[i].Footprint.Depth);
|
||||
MemcpySubresource(&DestData, &pSrcData[i], static_cast<SIZE_T>(pRowSizesInBytes[i]), pNumRows[i], pLayouts[i].Footprint.Depth);
|
||||
}
|
||||
pIntermediate->Unmap(0, NULL);
|
||||
pIntermediate->Unmap(0, nullptr);
|
||||
|
||||
if (DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)
|
||||
{
|
||||
@ -1979,16 +1973,16 @@ inline UINT64 UpdateSubresources(
|
||||
return 0;
|
||||
}
|
||||
void* pMem = HeapAlloc(GetProcessHeap(), 0, static_cast<SIZE_T>(MemToAlloc));
|
||||
if (pMem == NULL)
|
||||
if (pMem == nullptr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts = reinterpret_cast<D3D12_PLACED_SUBRESOURCE_FOOTPRINT*>(pMem);
|
||||
auto pLayouts = reinterpret_cast<D3D12_PLACED_SUBRESOURCE_FOOTPRINT*>(pMem);
|
||||
UINT64* pRowSizesInBytes = reinterpret_cast<UINT64*>(pLayouts + NumSubresources);
|
||||
UINT* pNumRows = reinterpret_cast<UINT*>(pRowSizesInBytes + NumSubresources);
|
||||
|
||||
D3D12_RESOURCE_DESC Desc = pDestinationResource->GetDesc();
|
||||
ID3D12Device* pDevice;
|
||||
auto Desc = pDestinationResource->GetDesc();
|
||||
ID3D12Device* pDevice = nullptr;
|
||||
pDestinationResource->GetDevice(__uuidof(*pDevice), reinterpret_cast<void**>(&pDevice));
|
||||
pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, pLayouts, pNumRows, pRowSizesInBytes, &RequiredSize);
|
||||
pDevice->Release();
|
||||
@ -2015,8 +2009,8 @@ inline UINT64 UpdateSubresources(
|
||||
UINT NumRows[MaxSubresources];
|
||||
UINT64 RowSizesInBytes[MaxSubresources];
|
||||
|
||||
D3D12_RESOURCE_DESC Desc = pDestinationResource->GetDesc();
|
||||
ID3D12Device* pDevice;
|
||||
auto Desc = pDestinationResource->GetDesc();
|
||||
ID3D12Device* pDevice = nullptr;
|
||||
pDestinationResource->GetDevice(__uuidof(*pDevice), reinterpret_cast<void**>(&pDevice));
|
||||
pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, Layouts, NumRows, RowSizesInBytes, &RequiredSize);
|
||||
pDevice->Release();
|
||||
@ -2050,9 +2044,9 @@ inline HRESULT D3DX12SerializeVersionedRootSignature(
|
||||
_Outptr_ ID3DBlob** ppBlob,
|
||||
_Always_(_Outptr_opt_result_maybenull_) ID3DBlob** ppErrorBlob)
|
||||
{
|
||||
if (ppErrorBlob != NULL)
|
||||
if (ppErrorBlob != nullptr)
|
||||
{
|
||||
*ppErrorBlob = NULL;
|
||||
*ppErrorBlob = nullptr;
|
||||
}
|
||||
|
||||
switch (MaxVersion)
|
||||
@ -2069,12 +2063,12 @@ inline HRESULT D3DX12SerializeVersionedRootSignature(
|
||||
const D3D12_ROOT_SIGNATURE_DESC1& desc_1_1 = pRootSignatureDesc->Desc_1_1;
|
||||
|
||||
const SIZE_T ParametersSize = sizeof(D3D12_ROOT_PARAMETER) * desc_1_1.NumParameters;
|
||||
void* pParameters = (ParametersSize > 0) ? HeapAlloc(GetProcessHeap(), 0, ParametersSize) : NULL;
|
||||
if (ParametersSize > 0 && pParameters == NULL)
|
||||
void* pParameters = (ParametersSize > 0) ? HeapAlloc(GetProcessHeap(), 0, ParametersSize) : nullptr;
|
||||
if (ParametersSize > 0 && pParameters == nullptr)
|
||||
{
|
||||
hr = E_OUTOFMEMORY;
|
||||
}
|
||||
D3D12_ROOT_PARAMETER* pParameters_1_0 = reinterpret_cast<D3D12_ROOT_PARAMETER*>(pParameters);
|
||||
auto pParameters_1_0 = reinterpret_cast<D3D12_ROOT_PARAMETER*>(pParameters);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
@ -2103,12 +2097,12 @@ inline HRESULT D3DX12SerializeVersionedRootSignature(
|
||||
const D3D12_ROOT_DESCRIPTOR_TABLE1& table_1_1 = desc_1_1.pParameters[n].DescriptorTable;
|
||||
|
||||
const SIZE_T DescriptorRangesSize = sizeof(D3D12_DESCRIPTOR_RANGE) * table_1_1.NumDescriptorRanges;
|
||||
void* pDescriptorRanges = (DescriptorRangesSize > 0 && SUCCEEDED(hr)) ? HeapAlloc(GetProcessHeap(), 0, DescriptorRangesSize) : NULL;
|
||||
if (DescriptorRangesSize > 0 && pDescriptorRanges == NULL)
|
||||
void* pDescriptorRanges = (DescriptorRangesSize > 0 && SUCCEEDED(hr)) ? HeapAlloc(GetProcessHeap(), 0, DescriptorRangesSize) : nullptr;
|
||||
if (DescriptorRangesSize > 0 && pDescriptorRanges == nullptr)
|
||||
{
|
||||
hr = E_OUTOFMEMORY;
|
||||
}
|
||||
D3D12_DESCRIPTOR_RANGE* pDescriptorRanges_1_0 = reinterpret_cast<D3D12_DESCRIPTOR_RANGE*>(pDescriptorRanges);
|
||||
auto pDescriptorRanges_1_0 = reinterpret_cast<D3D12_DESCRIPTOR_RANGE*>(pDescriptorRanges);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
@ -2168,7 +2162,7 @@ struct CD3DX12_RT_FORMAT_ARRAY : public D3D12_RT_FORMAT_ARRAY
|
||||
explicit CD3DX12_RT_FORMAT_ARRAY(const D3D12_RT_FORMAT_ARRAY& o)
|
||||
: D3D12_RT_FORMAT_ARRAY(o)
|
||||
{}
|
||||
explicit CD3DX12_RT_FORMAT_ARRAY(const DXGI_FORMAT* pFormats, UINT NumFormats)
|
||||
explicit CD3DX12_RT_FORMAT_ARRAY(_In_reads_(NumFormats) const DXGI_FORMAT* pFormats, UINT NumFormats)
|
||||
{
|
||||
NumRenderTargets = NumFormats;
|
||||
memcpy(RTFormats, pFormats, sizeof(RTFormats));
|
||||
@ -2265,6 +2259,7 @@ struct ID3DX12PipelineParserCallbacks
|
||||
virtual void ErrorDuplicateSubobject(D3D12_PIPELINE_STATE_SUBOBJECT_TYPE /*DuplicateType*/) {}
|
||||
virtual void ErrorUnknownSubobject(UINT /*UnknownTypeValue*/) {}
|
||||
|
||||
virtual ~ID3DX12PipelineParserCallbacks() = default;
|
||||
};
|
||||
|
||||
// Requires the Windows 10 Fall Creators Update SDK (16299)
|
||||
@ -2476,34 +2471,33 @@ struct CD3DX12_PIPELINE_STATE_STREAM_PARSE_HELPER : public ID3DX12PipelineParser
|
||||
// Depth disabled if no DSV format specified.
|
||||
static_cast<D3D12_DEPTH_STENCIL_DESC1&>(PipelineStream.DepthStencilState).DepthEnable = false;
|
||||
}
|
||||
virtual ~CD3DX12_PIPELINE_STATE_STREAM_PARSE_HELPER() {}
|
||||
|
||||
// ID3DX12PipelineParserCallbacks
|
||||
void FlagsCb(D3D12_PIPELINE_STATE_FLAGS Flags) {PipelineStream.Flags = Flags;}
|
||||
void NodeMaskCb(UINT NodeMask) {PipelineStream.NodeMask = NodeMask;}
|
||||
void RootSignatureCb(ID3D12RootSignature* pRootSignature) {PipelineStream.pRootSignature = pRootSignature;}
|
||||
void InputLayoutCb(const D3D12_INPUT_LAYOUT_DESC& InputLayout) {PipelineStream.InputLayout = InputLayout;}
|
||||
void IBStripCutValueCb(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue) {PipelineStream.IBStripCutValue = IBStripCutValue;}
|
||||
void PrimitiveTopologyTypeCb(D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType) {PipelineStream.PrimitiveTopologyType = PrimitiveTopologyType;}
|
||||
void VSCb(const D3D12_SHADER_BYTECODE& VS) {PipelineStream.VS = VS;}
|
||||
void GSCb(const D3D12_SHADER_BYTECODE& GS) {PipelineStream.GS = GS;}
|
||||
void StreamOutputCb(const D3D12_STREAM_OUTPUT_DESC& StreamOutput) {PipelineStream.StreamOutput = StreamOutput;}
|
||||
void HSCb(const D3D12_SHADER_BYTECODE& HS) {PipelineStream.HS = HS;}
|
||||
void DSCb(const D3D12_SHADER_BYTECODE& DS) {PipelineStream.DS = DS;}
|
||||
void PSCb(const D3D12_SHADER_BYTECODE& PS) {PipelineStream.PS = PS;}
|
||||
void CSCb(const D3D12_SHADER_BYTECODE& CS) {PipelineStream.CS = CS;}
|
||||
void BlendStateCb(const D3D12_BLEND_DESC& BlendState) {PipelineStream.BlendState = CD3DX12_BLEND_DESC(BlendState);}
|
||||
void DepthStencilStateCb(const D3D12_DEPTH_STENCIL_DESC& DepthStencilState)
|
||||
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
|
||||
{
|
||||
PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(DepthStencilState);
|
||||
SeenDSS = true;
|
||||
}
|
||||
void DepthStencilState1Cb(const D3D12_DEPTH_STENCIL_DESC1& DepthStencilState)
|
||||
void DepthStencilState1Cb(const D3D12_DEPTH_STENCIL_DESC1& DepthStencilState) override
|
||||
{
|
||||
PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(DepthStencilState);
|
||||
SeenDSS = true;
|
||||
}
|
||||
void DSVFormatCb(DXGI_FORMAT DSVFormat)
|
||||
void DSVFormatCb(DXGI_FORMAT DSVFormat) override
|
||||
{
|
||||
PipelineStream.DSVFormat = DSVFormat;
|
||||
if (!SeenDSS && DSVFormat != DXGI_FORMAT_UNKNOWN)
|
||||
@ -2512,17 +2506,14 @@ struct CD3DX12_PIPELINE_STATE_STREAM_PARSE_HELPER : public ID3DX12PipelineParser
|
||||
static_cast<D3D12_DEPTH_STENCIL_DESC1&>(PipelineStream.DepthStencilState).DepthEnable = true;
|
||||
}
|
||||
}
|
||||
void RasterizerStateCb(const D3D12_RASTERIZER_DESC& RasterizerState) {PipelineStream.RasterizerState = CD3DX12_RASTERIZER_DESC(RasterizerState);}
|
||||
void RTVFormatsCb(const D3D12_RT_FORMAT_ARRAY& RTVFormats) {PipelineStream.RTVFormats = RTVFormats;}
|
||||
void SampleDescCb(const DXGI_SAMPLE_DESC& SampleDesc) {PipelineStream.SampleDesc = SampleDesc;}
|
||||
void SampleMaskCb(UINT SampleMask) {PipelineStream.SampleMask = SampleMask;}
|
||||
void 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;}
|
||||
#if defined(NTDDI_WIN10_RS3) && (NTDDI_VERSION >= NTDDI_WIN10_RS3)
|
||||
void ViewInstancingCb(const D3D12_VIEW_INSTANCING_DESC& ViewInstancingDesc) {PipelineStream.ViewInstancingDesc = CD3DX12_VIEW_INSTANCING_DESC(ViewInstancingDesc);}
|
||||
void ViewInstancingCb(const D3D12_VIEW_INSTANCING_DESC& ViewInstancingDesc) override {PipelineStream.ViewInstancingDesc = CD3DX12_VIEW_INSTANCING_DESC(ViewInstancingDesc);}
|
||||
#endif
|
||||
void CachedPSOCb(const D3D12_CACHED_PIPELINE_STATE& CachedPSO) {PipelineStream.CachedPSO = CachedPSO;}
|
||||
void ErrorBadInputParameter(UINT) {}
|
||||
void ErrorDuplicateSubobject(D3D12_PIPELINE_STATE_SUBOBJECT_TYPE) {}
|
||||
void ErrorUnknownSubobject(UINT) {}
|
||||
void CachedPSOCb(const D3D12_CACHED_PIPELINE_STATE& CachedPSO) override {PipelineStream.CachedPSO = CachedPSO;}
|
||||
|
||||
private:
|
||||
bool SeenDSS;
|
||||
|
Loading…
x
Reference in New Issue
Block a user