我有一个 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中,您可以找到该类,也可以在此处查看