Jump to content
  • Advertisement
Sign in to follow this  
Mumsfilibaba

Black screen after creating msaa Rendertarget

This topic is 835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I get only a black screen after trying to create a rendertarget with msaa. It worked perfectly before creating it. Here is the code:

 
bool D3DHandle::CreateRenderTarget()
{
	//retrive BackBuffer
	ID3D11Texture2D* backBuffer = nullptr;
	HRESULT result = this->swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&backBuffer);

	if (FAILED(result))
	{
		MessageBoxW(this->outputWindow->GetWindowHandle(), L"Could not retrive BackBuffer from SwapChain", L"ERROR", MB_OK | MB_ICONERROR);
		return false;
	}

	//get backbuffer description and set multisampling
	D3D11_TEXTURE2D_DESC backBufferDesc;
	RtlSecureZeroMemory(&backBufferDesc, sizeof(D3D11_TEXTURE2D_DESC));

	backBuffer->GetDesc(&backBufferDesc);
	this->sampleCount = backBufferDesc.SampleDesc.Count = 8;
	this->sampleQuality = backBufferDesc.SampleDesc.Quality = 32;
	this->renderHeight = backBufferDesc.Height;
	this->renderWidth = backBufferDesc.Width;

	backBuffer->Release();
	backBuffer = nullptr;

	//create the backbuffer with multisampling 
	result = this->device->CreateTexture2D(&backBufferDesc, nullptr, &backBuffer);
	if (FAILED(result))
	{
		MessageBoxW(this->outputWindow->GetWindowHandle(), L"Could not create Backbuffer", L"ERROR", MB_OK | MB_ICONERROR);
		return false;
	}

	//create RenderTarget
	result = this->device->CreateRenderTargetView(backBuffer, nullptr, &renderTarget);
	if (FAILED(result))
	{
		MessageBoxW(this->outputWindow->GetWindowHandle(), L"Could not create RenderTarget", L"ERROR", MB_OK | MB_ICONERROR);
		return false;
	}

	//release backbuffer
	backBuffer->Release();
	backBuffer = nullptr;

	return true;
}
 

I'm I not setting it correctly after creation?

 

Im calling this function after I created the depthbuffer:

void D3DHandle::SetBuffers()
{
	//set RenderTarget and DepthStencil
	this->immediateContext->OMSetRenderTargets(1, &this->renderTarget, this->depthStencil);
}
Edited by Mumsfilibaba

Share this post


Link to post
Share on other sites
Advertisement
Is the depth stencil multisampled as well? Do you resolve this multisampled render target into the backbuffer? Did you enable the debug layer? Edited by Mona2000

Share this post


Link to post
Share on other sites
The debuglayer is on, so I'm pretty sure it would have warned me if I tried to use a depthstencil that weren't multisampled.

I'm not resolving the rendertarget. Is that really necessary when I create the rendertargetview with the multisampled texture? And in that case, why is that needed?

Could it be that I only create one texture? I mean aren't there two, one front and back?

Share this post


Link to post
Share on other sites
You can't just create a new texture and name it backbuffer, the backbuffer is a special texture that D3D creates for you. You have two options:
1) draw to a multisampled texture like you already do and resolve it into the backbuffer
2) ask D3D for a multisampled backbuffer (in DXGI_SWAP_CHAIN_DESC) and draw to it directly

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!