Jump to content

  • Log In with Google      Sign In   
  • Create Account

DX11 - Multiple Render Targets


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
23 replies to this topic

#21 Migi0027   Crossbones+   -  Reputation: 2119

Like
0Likes
Like

Posted 01 July 2013 - 04:26 AM

This is how I initialize each single render target:

D3D11_TEXTURE2D_DESC textureDesc;
	HRESULT result;
	D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewDesc;
	D3D11_SHADER_RESOURCE_VIEW_DESC shaderResourceViewDesc;


	// Initialize the render target texture description.
	ZeroMemory(&textureDesc, sizeof(textureDesc));

	// Setup the render target texture description.
	textureDesc.Width = textureWidth;
	textureDesc.Height = textureHeight;
	textureDesc.MipLevels = 1;
	textureDesc.ArraySize = 1;
	textureDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
	textureDesc.SampleDesc.Count = 1;
	textureDesc.SampleDesc.Quality = 0;
	textureDesc.Usage = D3D11_USAGE_DEFAULT;
	textureDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
	textureDesc.CPUAccessFlags = 0;
	textureDesc.MiscFlags = 0;

	// Create the render target texture.
	result = device->CreateTexture2D(&textureDesc, NULL, &m_renderTargetTexture);
	if(FAILED(result))
	{
		return false;
	}

	// Setup the description of the render target view.
	renderTargetViewDesc.Format = textureDesc.Format;
	renderTargetViewDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
	renderTargetViewDesc.Texture2D.MipSlice = 0;

	// Create the render target view.
	result = device->CreateRenderTargetView(m_renderTargetTexture, &renderTargetViewDesc, &m_renderTargetView);
	if(FAILED(result))
	{
		return false;
	}

	// Setup the description of the shader resource view.
	shaderResourceViewDesc.Format = textureDesc.Format;
	shaderResourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
	shaderResourceViewDesc.Texture2D.MostDetailedMip = 0;
	shaderResourceViewDesc.Texture2D.MipLevels = 1;

	// Create the shader resource view.
	result = device->CreateShaderResourceView(m_renderTargetTexture, &shaderResourceViewDesc, &m_shaderResourceView);
	if(FAILED(result))
	{
		return false;
	}

	return true;

Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to steal all their shaders!

Sponsor:

#22 Auskennfuchs   Members   -  Reputation: 592

Like
1Likes
Like

Posted 01 July 2013 - 07:53 AM

Are you using the second and third Rendertarget after rendering to them as InputTexture for e.g. final combining the image? If so you have to unset the textures from your shaderresources. You can't read and write from and to the same resource at same time. In the first resourceslot you propably using another texture as input.



#23 Juliean   GDNet+   -  Reputation: 2731

Like
1Likes
Like

Posted 01 July 2013 - 09:36 AM


Are you using the second and third Rendertarget after rendering to them as InputTexture for e.g. final combining the image? If so you have to unset the textures from your shaderresources. You can't read and write from and to the same resource at same time. In the first resourceslot you propably using another texture as input.

 

Theoretically true, DX11 will unbind any such resource itself. Try it, set a texture as render target that is still bound to the shader, you should get a warning in debug mode telling you that the shader resource view has been unbound.

 

Some more ideas:

 

- check your blend states. You eigther have to set the blend state manually for each render target, or set independant blend mode to false.

- Check your depth states and / or depth stencil view, I think there is the need to configure it for different render targets explicitely (or at least tell him to only use the setting of the first one) too.


Edited by Juliean, 01 July 2013 - 09:36 AM.


#24 Migi0027   Crossbones+   -  Reputation: 2119

Like
0Likes
Like

Posted 01 July 2013 - 09:52 AM

Right now, I'm only testing the second, and yes, I unset the resource them after using it.

 

Juliean:

 

The first step fixed it!

 

YAS! laugh.png

 

Thanks!


Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to steal all their shaders!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS