I'm having some trouble copying a subregion from a source texture (2D) to a destination texture.
Both textures are mipmapped 2D textures, with dimensions (at mip 0) of 512 x 32.
Rather than tell you about each parameter, it's easier to show you, according to the Visual Studio debugger, at the call site:
So, question 1: Is there anything wrong here that would cause CopySubresourceRegion to fail? There is nothing in the Debug window (the debug layer is enabled). The destination texture is a Staging resource with the CPU Read access flag.
If that seems okay to you, here's the rest of the question:
I'm making this call as part of a unit test, and attempting to read the data right out of the destination texture immediately after. If I replace the CopySubresourceRegion call with a CopyResource instead, the answer is wrong, but there is definitely data copied across. However, after making the call to CopySubresourceRegion and then using a Map/Read/Unmap chain, the data that comes back is all zeroes. The texel type is R32G32B32A32_FLOAT (or whatever it is).
I realise that the call is made asynchronously, so I added the following code between the copy and the read:
for (UINT i = 0U; i < numDeferredContexts; ++i) {
CHECK_CALL(deferredContextPtrArr[i]->FinishCommandList(FALSE, &outCommandList));
immediateContextPtr->ExecuteCommandList(outCommandList, FALSE);
}
And still, all zeroes. So I went one further, and changed it to the following (desperate) code:
for (UINT i = 0U; i < numDeferredContexts; ++i) {
deferredContextPtrArr[i]->Flush();
CHECK_CALL(deferredContextPtrArr[i]->FinishCommandList(FALSE, &outCommandList));
immediateContextPtr->ExecuteCommandList(outCommandList, FALSE);
}
immediateContextPtr->Flush();
Sleep(10000);
But still nothing. Finally, I turned off the multithreaded rendering so it all executes on the immediate context, but even then, still zeroes.
So I'm totally stuck, and any ideas are appreciated: How can I make CopySubresourceRegion actually copy the data?