Hey,
To begin with - I was successful with creating MSAA using MSAA swap chain, but I am not satisfied with it, especially because it doesn't support changing MSAA settings on the fly.
I've already read many thread on this forum regarding MSAA and I learnt here about ResolveSubresource and how we deal with converting MSAA texture to non-MSAA to present it on screen with non-MSAA buffer.
A little background: I have forward rendering engine, I have also already used render targets. I am creating render target for scene, render models to it. Then I am creating G-buffers for SSAO which I render to another texture and then I apply another post-processes. For sake of testing MSAA, I am using no post-processes.
m_renderTextureMainScene is my MSAA buffer. Then I am trying to resolve it to non-MSAA render target but only black screen appears. When m_renderTextureMainScene is non-MSAA, rendering works fine:
XMMATRIX worldMatrix, viewMatrix, projectionMatrix, lightViewMatrix, lightProjectionMatrix;
m_renderTextureMainScene->SetRenderTarget(m_D3D->GetDeviceContext(), m_D3D->GetDepthStencilView());
m_renderTextureMainScene->ClearRenderTarget(m_D3D->GetDeviceContext(), m_D3D->GetDepthStencilView(), 0.0f, 0.0f, 0.0f, 1.0f);
for (ModelClass* const& model : m_sceneModels)
{
// ...
model->Render(m_D3D->GetDeviceContext());
// ...
}
if (DRAW_SKYBOX)
{
if (RenderSkybox() == false)
return false;
}
m_D3D->SetBackBufferRenderTarget();
static RenderTextureClass *renderTexture;
if (renderTexture == nullptr)
{
renderTexture = new RenderTextureClass;
renderTexture->Initialize(m_D3D->GetDevice(), m_screenWidth, m_screenHeight, 1);
}
m_D3D->GetDeviceContext()->ResolveSubresource(renderTexture->GetShaderResource(), 0, m_renderTextureMainScene->GetShaderResource(), 0, DXGI_FORMAT_R16G16B16A16_FLOAT);
m_renderTexturePreview->BindTexture(renderTexture->GetShaderResourceView());
if (!m_renderTexturePreview->Render(m_D3D->GetDeviceContext(), 0, worldMatrix, viewMatrix, projectionMatrix))
return false;