延迟上下文不填充 D3D11_MAPPED_SUBRESOURCE 大小

Deferred context do not fill D3D11_MAPPED_SUBRESOURCE size

我有一个 3D 应用程序,它使用 4 个线程,每个线程有一个延迟上下文。问题是,当我使用延迟上下文映射 (ID3D11DeviceContext::Map) 资源时,变量 RowPitchDepthPitch 等于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 you can download and test it. The code is in PipeLineManagerDX11.cpp in line 688, you can find the class also check it here

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

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