Update to support new ABI for MinGW in DX Agility SDK v1.606.3 (#133)

This commit is contained in:
Chuck Walbourn 2022-07-25 14:18:35 -07:00 коммит произвёл GitHub
Родитель 6812ed10aa
Коммит 859ea65bf5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
13 изменённых файлов: 193 добавлений и 12 удалений

Просмотреть файл

@ -139,7 +139,12 @@ namespace DirectX
// Helper for obtaining texture size
inline XMUINT2 GetTextureSize(_In_ ID3D12Resource* tex) noexcept
{
#if defined(_MSC_VER) || !defined(_WIN32)
const auto desc = tex->GetDesc();
#else
D3D12_RESOURCE_DESC tmpDesc;
const auto& desc = *tex->GetDesc(&tmpDesc);
#endif
return XMUINT2(static_cast<uint32_t>(desc.Width), static_cast<uint32_t>(desc.Height));
}

Просмотреть файл

@ -67,6 +67,7 @@ namespace DirectX
const D3D12_SHADER_BYTECODE& pixelShader,
_Outptr_ ID3D12PipelineState** pPipelineState) const;
#if defined(_MSC_VER) || !defined(_WIN32)
D3D12_GRAPHICS_PIPELINE_STATE_DESC GetDesc() const noexcept
{
D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc = {};
@ -84,6 +85,28 @@ namespace DirectX
psoDesc.NodeMask = renderTargetState.nodeMask;
return psoDesc;
}
#else
D3D12_GRAPHICS_PIPELINE_STATE_DESC* GetDesc(_Out_ D3D12_GRAPHICS_PIPELINE_STATE_DESC* psoDesc) const noexcept
{
if (!psoDesc)
return nullptr;
*psoDesc = {};
psoDesc->BlendState = blendDesc;
psoDesc->SampleMask = renderTargetState.sampleMask;
psoDesc->RasterizerState = rasterizerDesc;
psoDesc->DepthStencilState = depthStencilDesc;
psoDesc->InputLayout = inputLayout;
psoDesc->IBStripCutValue = stripCutValue;
psoDesc->PrimitiveTopologyType = primitiveTopology;
psoDesc->NumRenderTargets = renderTargetState.numRenderTargets;
memcpy(psoDesc->RTVFormats, renderTargetState.rtvFormats, sizeof(DXGI_FORMAT) * D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT);
psoDesc->DSVFormat = renderTargetState.dsvFormat;
psoDesc->SampleDesc = renderTargetState.sampleDesc;
psoDesc->NodeMask = renderTargetState.nodeMask;
return psoDesc;
}
#endif
uint32_t ComputeHash() const noexcept;

Просмотреть файл

@ -538,7 +538,11 @@ namespace DirectX
if (textureIndex == -1)
return handle;
#if defined(_MSC_VER) || !defined(_WIN32)
handle = heap->GetGPUDescriptorHandleForHeapStart();
#else
std::ignore = heap->GetGPUDescriptorHandleForHeapStart(&handle);
#endif
handle.ptr += static_cast<UINT64>(descriptorSize * (UINT64(textureIndex) + UINT64(descriptorOffset)));
return handle;

Просмотреть файл

@ -572,7 +572,12 @@ void BasicPostProcess::SetSourceTexture(D3D12_GPU_DESCRIPTOR_HANDLE srvDescripto
if (resource)
{
#if defined(_MSC_VER) || !defined(_WIN32)
const auto desc = resource->GetDesc();
#else
D3D12_RESOURCE_DESC tmpDesc;
const auto& desc = *resource->GetDesc(&tmpDesc);
#endif
pImpl->texWidth = static_cast<unsigned>(desc.Width);
pImpl->texHeight = desc.Height;
}

Просмотреть файл

@ -871,7 +871,14 @@ HRESULT DirectX::CreateDDSTextureFromMemoryEx(
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
// If it's missing mips, let's generate them
if ((loadFlags & DDS_LOADER_MIP_AUTOGEN) && subresources.size() != (*texture)->GetDesc().MipLevels)
#if defined(_MSC_VER) || !defined(_WIN32)
const size_t mipLevels = (*texture)->GetDesc().MipLevels;
#else
D3D12_RESOURCE_DESC tmpDesc;
const size_t mipLevels = (*texture)->GetDesc(&tmpDesc)->MipLevels;
#endif
if ((loadFlags & DDS_LOADER_MIP_AUTOGEN) && subresources.size() != mipLevels)
{
resourceUpload.GenerateMips(*texture);
}
@ -986,7 +993,14 @@ HRESULT DirectX::CreateDDSTextureFromFileEx(
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
// If it's missing mips, let's generate them
if ((loadFlags & DDS_LOADER_MIP_AUTOGEN) && subresources.size() != (*texture)->GetDesc().MipLevels)
#if defined(_MSC_VER) || !defined(_WIN32)
const size_t mipLevels = (*texture)->GetDesc().MipLevels;
#else
D3D12_RESOURCE_DESC tmpDesc;
const size_t mipLevels = (*texture)->GetDesc(&tmpDesc)->MipLevels;
#endif
if ((loadFlags & DDS_LOADER_MIP_AUTOGEN) && subresources.size() != mipLevels)
{
resourceUpload.GenerateMips(*texture);
}

Просмотреть файл

@ -37,9 +37,15 @@ DescriptorHeap::DescriptorHeap(
ID3D12DescriptorHeap* pExistingHeap) noexcept
: m_pHeap(pExistingHeap)
{
#if defined(_MSC_VER) || !defined(_WIN32)
m_hCPU = pExistingHeap->GetCPUDescriptorHandleForHeapStart();
m_hGPU = pExistingHeap->GetGPUDescriptorHandleForHeapStart();
m_desc = pExistingHeap->GetDesc();
#else
std::ignore = pExistingHeap->GetCPUDescriptorHandleForHeapStart(&m_hCPU);
std::ignore = pExistingHeap->GetGPUDescriptorHandleForHeapStart(&m_hGPU);
std::ignore = pExistingHeap->GetDesc(&m_desc);
#endif
ComPtr<ID3D12Device> device;
pExistingHeap->GetDevice(IID_GRAPHICS_PPV_ARGS(device.GetAddressOf()));
@ -168,11 +174,19 @@ void DescriptorHeap::Create(
SetDebugObjectName(m_pHeap.Get(), L"DescriptorHeap");
#if defined(_MSC_VER) || !defined(_WIN32)
m_hCPU = m_pHeap->GetCPUDescriptorHandleForHeapStart();
if (pDesc->Flags & D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE)
{
m_hGPU = m_pHeap->GetGPUDescriptorHandleForHeapStart();
}
#else
std::ignore = m_pHeap->GetCPUDescriptorHandleForHeapStart(&m_hCPU);
if (pDesc->Flags & D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE)
{
std::ignore = m_pHeap->GetGPUDescriptorHandleForHeapStart(&m_hGPU);
}
#endif
}
}

Просмотреть файл

@ -21,7 +21,12 @@ void DirectX::CreateShaderResourceView(
D3D12_CPU_DESCRIPTOR_HANDLE srvDescriptor,
bool isCubeMap)
{
#if defined(_MSC_VER) || !defined(_WIN32)
const auto desc = tex->GetDesc();
#else
D3D12_RESOURCE_DESC tmpDesc;
const auto& desc = *tex->GetDesc(&tmpDesc);
#endif
D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
srvDesc.Format = desc.Format;

Просмотреть файл

@ -497,11 +497,20 @@ EffectFactory::EffectFactory(_In_ ID3D12DescriptorHeap* textureDescriptors, _In_
throw std::invalid_argument("Descriptor heap cannot be null if no device is provided. Use the alternative EffectFactory constructor instead.");
}
if (textureDescriptors->GetDesc().Type != D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV)
#if defined(_MSC_VER) || !defined(_WIN32)
const D3D12_DESCRIPTOR_HEAP_TYPE textureHeapType = textureDescriptors->GetDesc().Type;
const D3D12_DESCRIPTOR_HEAP_TYPE samplerHeapType = samplerDescriptors->GetDesc().Type;
#else
D3D12_DESCRIPTOR_HEAP_DESC tmpDesc1, tmpDesc2;
const D3D12_DESCRIPTOR_HEAP_TYPE textureHeapType = textureDescriptors->GetDesc(&tmpDesc1)->Type;
const D3D12_DESCRIPTOR_HEAP_TYPE samplerHeapType = samplerDescriptors->GetDesc(&tmpDesc2)->Type;
#endif
if (textureHeapType != D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV)
{
throw std::invalid_argument("EffectFactory::CreateEffect requires a CBV_SRV_UAV descriptor heap for textureDescriptors.");
}
if (samplerDescriptors->GetDesc().Type != D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER)
if (samplerHeapType != D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER)
{
throw std::invalid_argument("EffectFactory::CreateEffect requires a SAMPLER descriptor heap for samplerDescriptors.");
}

Просмотреть файл

@ -91,7 +91,13 @@ void EffectPipelineStateDescription::CreatePipelineState(
const D3D12_SHADER_BYTECODE& pixelShader,
_Outptr_ ID3D12PipelineState** pPipelineState) const
{
#if defined(_MSC_VER) || !defined(_WIN32)
auto psoDesc = GetDesc();
#else
D3D12_GRAPHICS_PIPELINE_STATE_DESC tmpPSODesc;
auto& psoDesc = *GetDesc(&tmpPSODesc);
#endif
psoDesc.pRootSignature = rootSignature;
psoDesc.VS = vertexShader;
psoDesc.PS = pixelShader;

Просмотреть файл

@ -257,11 +257,20 @@ PBREffectFactory::PBREffectFactory(_In_ ID3D12DescriptorHeap* textureDescriptors
throw std::invalid_argument("Descriptor heap cannot be null if no device is provided. Use the alternative PBREffectFactory constructor instead.");
}
if (textureDescriptors->GetDesc().Type != D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV)
#if defined(_MSC_VER) || !defined(_WIN32)
const D3D12_DESCRIPTOR_HEAP_TYPE textureHeapType = textureDescriptors->GetDesc().Type;
const D3D12_DESCRIPTOR_HEAP_TYPE samplerHeapType = samplerDescriptors->GetDesc().Type;
#else
D3D12_DESCRIPTOR_HEAP_DESC tmpDesc1, tmpDesc2;
const D3D12_DESCRIPTOR_HEAP_TYPE textureHeapType = textureDescriptors->GetDesc(&tmpDesc1)->Type;
const D3D12_DESCRIPTOR_HEAP_TYPE samplerHeapType = samplerDescriptors->GetDesc(&tmpDesc2)->Type;
#endif
if (textureHeapType != D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV)
{
throw std::invalid_argument("PBREffectFactory::CreateEffect requires a CBV_SRV_UAV descriptor heap for textureDescriptors.");
}
if (samplerDescriptors->GetDesc().Type != D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER)
if (samplerHeapType != D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER)
{
throw std::invalid_argument("PBREffectFactory::CreateEffect requires a SAMPLER descriptor heap for samplerDescriptors.");
}

Просмотреть файл

@ -418,7 +418,12 @@ public:
throw std::runtime_error("GenerateMips cannot operate on a copy queue");
}
#if defined(_MSC_VER) || !defined(_WIN32)
const auto desc = resource->GetDesc();
#else
D3D12_RESOURCE_DESC tmpDesc;
const auto& desc = *resource->GetDesc(&tmpDesc);
#endif
if (desc.MipLevels == 1)
{
@ -626,7 +631,12 @@ private:
void GenerateMips_UnorderedAccessPath(
_In_ ID3D12Resource* resource)
{
#if defined(_MSC_VER) || !defined(_WIN32)
const auto desc = resource->GetDesc();
#else
D3D12_RESOURCE_DESC tmpDesc;
const auto& desc = *resource->GetDesc(&tmpDesc);
#endif
assert(!FormatIsBGR(desc.Format) && !FormatIsSRGB(desc.Format));
const CD3DX12_HEAP_PROPERTIES defaultHeapProperties(D3D12_HEAP_TYPE_DEFAULT);
@ -683,7 +693,12 @@ private:
auto const descriptorSize = static_cast<int>(mDevice->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV));
// Create the top-level SRV
#if defined(_MSC_VER) || !defined(_WIN32)
CD3DX12_CPU_DESCRIPTOR_HANDLE handleIt(descriptorHeap->GetCPUDescriptorHandleForHeapStart());
#else
CD3DX12_CPU_DESCRIPTOR_HANDLE handleIt;
std::ignore = descriptorHeap->GetCPUDescriptorHandleForHeapStart(&handleIt);
#endif
D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
srvDesc.Format = desc.Format;
srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
@ -734,12 +749,17 @@ private:
mList->SetComputeRootSignature(mGenMipsResources->rootSignature.Get());
mList->SetPipelineState(pso.Get());
mList->SetDescriptorHeaps(1, descriptorHeap.GetAddressOf());
mList->SetComputeRootDescriptorTable(GenerateMipsResources::SourceTexture, descriptorHeap->GetGPUDescriptorHandleForHeapStart());
#if defined(_MSC_VER) || !defined(_WIN32)
D3D12_GPU_DESCRIPTOR_HANDLE handle(descriptorHeap->GetGPUDescriptorHandleForHeapStart());
#else
D3D12_GPU_DESCRIPTOR_HANDLE handle;
std::ignore = descriptorHeap->GetGPUDescriptorHandleForHeapStart(&handle);
#endif
mList->SetComputeRootDescriptorTable(GenerateMipsResources::SourceTexture, handle);
// Get the descriptor handle -- uavH will increment over each loop
CD3DX12_GPU_DESCRIPTOR_HANDLE uavH(
descriptorHeap->GetGPUDescriptorHandleForHeapStart(),
descriptorSize); // offset by 1 descriptor
CD3DX12_GPU_DESCRIPTOR_HANDLE uavH(handle, descriptorSize); // offset by 1 descriptor
// Process each mip
auto mipWidth = static_cast<uint32_t>(desc.Width);
@ -823,7 +843,12 @@ private:
void GenerateMips_TexturePath(
_In_ ID3D12Resource* resource)
{
#if defined(_MSC_VER) || !defined(_WIN32)
const auto resourceDesc = resource->GetDesc();
#else
D3D12_RESOURCE_DESC tmpDesc;
const auto& resourceDesc = *resource->GetDesc(&tmpDesc);
#endif
assert(!FormatIsBGR(resourceDesc.Format) || FormatIsSRGB(resourceDesc.Format));
auto copyDesc = resourceDesc;
@ -888,7 +913,12 @@ private:
void GenerateMips_TexturePathBGR(
_In_ ID3D12Resource* resource)
{
#if defined(_MSC_VER) || !defined(_WIN32)
const auto resourceDesc = resource->GetDesc();
#else
D3D12_RESOURCE_DESC tmpDesc;
const auto& resourceDesc = *resource->GetDesc(&tmpDesc);
#endif
assert(FormatIsBGR(resourceDesc.Format));
// Create a resource with the same description with RGB and with UAV flags
@ -900,7 +930,12 @@ private:
#endif
D3D12_HEAP_DESC heapDesc = {};
#if defined(_MSC_VER) || !defined(_WIN32)
auto const allocInfo = mDevice->GetResourceAllocationInfo(0, 1, &copyDesc);
#else
D3D12_RESOURCE_ALLOCATION_INFO allocInfo;
std::ignore = mDevice->GetResourceAllocationInfo(&allocInfo, 0, 1, &copyDesc);
#endif
heapDesc.SizeInBytes = allocInfo.SizeInBytes;
heapDesc.Flags = D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES;
heapDesc.Properties.Type = D3D12_HEAP_TYPE_DEFAULT;

Просмотреть файл

@ -234,7 +234,12 @@ HRESULT DirectX::SaveDDSTextureToFile(
pCommandQ->GetDevice(IID_GRAPHICS_PPV_ARGS(device.GetAddressOf()));
// Get the size of the image
#if defined(_MSC_VER) || !defined(_WIN32)
const auto desc = pSource->GetDesc();
#else
D3D12_RESOURCE_DESC tmpDesc;
const auto& desc = *pSource->GetDesc(&tmpDesc);
#endif
if (desc.Width > UINT32_MAX)
return E_INVALIDARG;
@ -457,7 +462,12 @@ HRESULT DirectX::SaveWICTextureToFile(
pCommandQ->GetDevice(IID_GRAPHICS_PPV_ARGS(device.GetAddressOf()));
// Get the size of the image
#if defined(_MSC_VER) || !defined(_WIN32)
const auto desc = pSource->GetDesc();
#else
D3D12_RESOURCE_DESC tmpDesc;
const auto& desc = *pSource->GetDesc(&tmpDesc);
#endif
if (desc.Width > UINT32_MAX)
return E_INVALIDARG;

Просмотреть файл

@ -76,7 +76,12 @@ struct CD3DX12_VIEWPORT : public D3D12_VIEWPORT
FLOAT minDepth = D3D12_MIN_DEPTH,
FLOAT maxDepth = D3D12_MAX_DEPTH ) noexcept
{
#if defined(_MSC_VER) || !defined(_WIN32)
const auto Desc = pResource->GetDesc();
#else
D3D12_RESOURCE_DESC tmpDesc;
const auto& Desc = *pResource->GetDesc(&tmpDesc);
#endif
const UINT64 SubresourceWidth = Desc.Width >> mipSlice;
const UINT64 SubresourceHeight = Desc.Height >> mipSlice;
switch (Desc.Dimension)
@ -2040,7 +2045,12 @@ inline UINT64 GetRequiredIntermediateSize(
_In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource,
_In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources) noexcept
{
#if defined(_MSC_VER) || !defined(_WIN32)
const auto Desc = pDestinationResource->GetDesc();
#else
D3D12_RESOURCE_DESC tmpDesc;
const auto& Desc = *pDestinationResource->GetDesc(&tmpDesc);
#endif
UINT64 RequiredSize = 0;
ID3D12Device* pDevice = nullptr;
@ -2066,8 +2076,14 @@ inline UINT64 UpdateSubresources(
_In_reads_(NumSubresources) const D3D12_SUBRESOURCE_DATA* pSrcData) noexcept
{
// Minor validation
#if defined(_MSC_VER) || !defined(_WIN32)
const auto IntermediateDesc = pIntermediate->GetDesc();
const auto DestinationDesc = pDestinationResource->GetDesc();
#else
D3D12_RESOURCE_DESC tmpDesc1, tmpDesc2;
const auto& IntermediateDesc = *pIntermediate->GetDesc(&tmpDesc1);
const auto& DestinationDesc = *pDestinationResource->GetDesc(&tmpDesc2);
#endif
if (IntermediateDesc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER ||
IntermediateDesc.Width < RequiredSize + pLayouts[0].Offset ||
RequiredSize > SIZE_T(-1) ||
@ -2125,8 +2141,14 @@ inline UINT64 UpdateSubresources(
_In_reads_(NumSubresources) const D3D12_SUBRESOURCE_INFO* pSrcData) noexcept
{
// Minor validation
#if defined(_MSC_VER) || !defined(_WIN32)
const auto IntermediateDesc = pIntermediate->GetDesc();
const auto DestinationDesc = pDestinationResource->GetDesc();
#else
D3D12_RESOURCE_DESC tmpDesc1, tmpDesc2;
const auto& IntermediateDesc = *pIntermediate->GetDesc(&tmpDesc1);
const auto& DestinationDesc = *pDestinationResource->GetDesc(&tmpDesc2);
#endif
if (IntermediateDesc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER ||
IntermediateDesc.Width < RequiredSize + pLayouts[0].Offset ||
RequiredSize > SIZE_T(-1) ||
@ -2194,7 +2216,12 @@ inline UINT64 UpdateSubresources(
auto pRowSizesInBytes = reinterpret_cast<UINT64*>(pLayouts + NumSubresources);
auto pNumRows = reinterpret_cast<UINT*>(pRowSizesInBytes + NumSubresources);
#if defined(_MSC_VER) || !defined(_WIN32)
const auto Desc = pDestinationResource->GetDesc();
#else
D3D12_RESOURCE_DESC tmpDesc;
const auto& Desc = *pDestinationResource->GetDesc(&tmpDesc);
#endif
ID3D12Device* pDevice = nullptr;
pDestinationResource->GetDevice(IID_ID3D12Device, reinterpret_cast<void**>(&pDevice));
pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, pLayouts, pNumRows, pRowSizesInBytes, &RequiredSize);
@ -2232,7 +2259,12 @@ inline UINT64 UpdateSubresources(
auto pRowSizesInBytes = reinterpret_cast<UINT64*>(pLayouts + NumSubresources);
auto pNumRows = reinterpret_cast<UINT*>(pRowSizesInBytes + NumSubresources);
#if defined(_MSC_VER) || !defined(_WIN32)
const auto Desc = pDestinationResource->GetDesc();
#else
D3D12_RESOURCE_DESC tmpDesc;
const auto& Desc = *pDestinationResource->GetDesc(&tmpDesc);
#endif
ID3D12Device* pDevice = nullptr;
pDestinationResource->GetDevice(IID_ID3D12Device, reinterpret_cast<void**>(&pDevice));
pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, pLayouts, pNumRows, pRowSizesInBytes, &RequiredSize);
@ -2260,7 +2292,12 @@ inline UINT64 UpdateSubresources(
UINT NumRows[MaxSubresources];
UINT64 RowSizesInBytes[MaxSubresources];
#if defined(_MSC_VER) || !defined(_WIN32)
const auto Desc = pDestinationResource->GetDesc();
#else
D3D12_RESOURCE_DESC tmpDesc;
const auto& Desc = *pDestinationResource->GetDesc(&tmpDesc);
#endif
ID3D12Device* pDevice = nullptr;
pDestinationResource->GetDevice(IID_ID3D12Device, reinterpret_cast<void**>(&pDevice));
pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, Layouts, NumRows, RowSizesInBytes, &RequiredSize);
@ -2287,7 +2324,12 @@ inline UINT64 UpdateSubresources(
UINT NumRows[MaxSubresources];
UINT64 RowSizesInBytes[MaxSubresources];
#if defined(_MSC_VER) || !defined(_WIN32)
const auto Desc = pDestinationResource->GetDesc();
#else
D3D12_RESOURCE_DESC tmpDesc;
const auto& Desc = *pDestinationResource->GetDesc(&tmpDesc);
#endif
ID3D12Device* pDevice = nullptr;
pDestinationResource->GetDevice(IID_ID3D12Device, reinterpret_cast<void**>(&pDevice));
pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, Layouts, NumRows, RowSizesInBytes, &RequiredSize);