c++multithreadingdirectxdirectx-11deferred-rendering

Deferred context do not fill D3D11_MAPPED_SUBRESOURCE size


I have a 3D application that use 4 thread with one deferred context each one. The problem is that when I use the deferred context to map (ID3D11DeviceContext::Map) the resource, the variables RowPitch and DepthPitch are equal to 0. I get the pointer to the mapped resource and with the memory inspector I see that it have reserve memory (like a calloc).

I have this problem only with ATI graphic cards.

The following code show where is the problem (part of hieroglyph3 engine):

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 );

In 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


Solution

  • The problem was that in ATI GPUs that function don't fill that variables. This don't happen in NVIDIA GPUs.

    The solution is to use NVIDIA GPUs that fill the variables.