Tuesday, February 28, 2012 8:15 PM
Hi. I am writing a D3D 11 application, and I have a problem related to resource copying. I have a resource which only has the RENDERTARGET binding flag, so I can only set it as a Render Target and its format is DXGI_FORMAT_B8G8R8A8_UNORM. After rendering, I am trying to entirely copy it to the back buffer using resource copying functions, since I can't set it as a shader resource view to use a shader for copying. But the problem is that the format of the render target [DXGI_FORMAT_B8G8R8A8_UNORM] and the back buffer [DXGI_FORMAT_R8G8B8A8_UNORM] are different, so ID3D11DeviceContext::CopyResource() can't perform the copy operation. And I didn't find any other way to copy! In D3D9 there was a StretchRect function which could convert the formats. But in D3D11 I didn't find such function. The problem is that for some reason I can't change type of the render target, for example change its format or bind it as SHADERRESOURCE view. Anyway it is weird that you can have a render target that you can write to, but you can't read it anymore. Not lockable, not able to be bound to shader, not able to be copied on a render target, ... What should I do?
Tuesday, February 28, 2012 8:37 PMI forgot to say that I found this function: ResolveSubresource(). But I am not sure this is what I want because it says that the source must be multisampled
Friday, March 02, 2012 2:28 AMModerator
How are you creating the resource? Can you create it as DXGI_FORMAT_R8G8B8A8_UNORM so it doesn't need to be converted and can be copied via GPU?
As you point out, StretchRect was removed in D3D10 and there is no direct analogue. CopySubResourceRegion or ResolveSubresource are the closest, but they require compatible formats.