I am trying to render an image to my window using Direct X but I don't really want a "3D" world as such, and I don't really want to set up all the vertex/index buffers as I won't need them. I am performing all of my calculations and operations using compute shaders which returns me an image. As the file io is quite a bottleneck, I am looking to just render the image directly to the screen to increase performance. My question is, how would I go about this using Direct X 11? I have looked at some examples already such as rastertek and other questions on SO but they are either over-complicating the matter, or they want a solution to font drawing etc.
At the moment I am able to produce a blank screen using the following code and the screen size is the size of the image retrieved from the GPU. I am looking to draw this entire image to my back buffer or some render target, and then display it.
void Application::Draw()
{
float ClearColor[4] = { 0.5f, 0.125f, 0.3f, 1.0f };
context->ClearRenderTargetView(_pRenderTargetView, ClearColor);
// compute shader operations, retrieve image data from gpu
// draw image to back buffer/render target then present
swapChain->Present(0, 0);
}
From Why can't I write to my render targets?, I have tried the solution using
ID3D11Resource * backBufferResource;
_pRenderTargetView->GetResource(&backBufferResource);//backbuffer render target
context->CopyResource(backBufferResource, gpuResource);
This doesn't seem to throw any errors, but it doesn't change the output on the screen. It is mentioned that the back buffer must be the exact same format as the image we're trying to copy to it so this may be the issue. My swap chain desc is as follows
DXGI_SWAP_CHAIN_DESC sd;
ZeroMemory(&sd, sizeof(sd));
sd.BufferCount = 1;
sd.BufferDesc.Width = _WindowWidth;
sd.BufferDesc.Height = _WindowHeight;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;//FORMAT DIFFERENT
sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.OutputWindow = _hWnd;
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;
sd.Windowed = TRUE;
and my image format is
DXGI_FORMAT_R32G32B32A32_FLOAT
If I try to change the swap chain format it throws a memory access violation.