延迟上下文不会填充D3D11_MAPPED_SUBRESOURCE大小

问题描述 投票:0回答:1

我有一个3D应用程序,它使用4个线程,每个都有一个延迟上下文。问题是,当我使用延迟上下文来映射(ID3D11DeviceContext::Map)资源时,变量RowPitch和DepthPitch等于0.我得到指向映射资源的指针,并且使用内存检查器,我看到它有预留内存(如一个calloc)。

我只有ATI显卡有这个问题。

以下代码显示问题所在(hieroglyph3引擎的一部分):

D3D11_MAPPED_SUBRESOURCE Data;
Data.pData = NULL;
Data.DepthPitch = Data.RowPitch = 0;

if ( nullptr == pGlyphResource ) {
    Log::Get().Write( L"Trying to map a subresource that doesn't exist!!!" );
    return( Data );
}
// TODO: Update this to use a ComPtr!
// Acquire the native resource pointer.
ID3D11Resource* pResource = 0;
pResource = pGlyphResource->GetResource();

if ( nullptr == pResource ) {
    Log::Get().Write( L"Trying to map a subresource that has no native resource in it!!!" );
    return( Data );
}

// Perform the mapping of the resource.
// This function must fill Data but it only fill the pointer to the mapped resource
HRESULT hr = m_pContext->Map( pResource, subresource, actions, flags, &Data );

if ( FAILED( hr ) ) {
    Log::Get().Write( L"Failed to map resource!" );
}

return( Data );

hieroglyph3,您可以下载并测试它。代码在第688行的PipeLineManagerDX11.cpp中,你可以找到类也检查它here

c++ multithreading directx directx-11 deferred-rendering
1个回答
0
投票

问题是在ATI GPU中,功能不能填充变量。这在NVIDIA GPU中不会发生。

解决方案是使用填充变量的NVIDIA GPU。

© www.soinside.com 2019 - 2024. All rights reserved.