Sign in to follow this  

Render to Texture Array, seeing nothing

This topic is 1465 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

As per the title, I am having trouble rendering to a texture array.  I have successfully rendered to one using MRT.  I called CreateTexture2D with a D3D11_TEXTURE2D_DESC that specified an ArraySize of 4, called CreateShaderResourceView with a D3D11_SHADER_RESOURCE_VIEW_DESC that had 4 for its Texture2DArray.ArraySize parameter, and made a call to CreateRenderTargetView for each render target (i created an array of them) with a D3D11_RENDER_TARGET_VIEW_DESC specifying 1 for its Texture2DArray.ArraySize and an index offset for its Texture2DArray.FirstArraySlice.  In the pixel shader I then wrote to SV_TARGET0, SV_TARGET1 etc.  When I call OMSetRenderTargets, I set it to render 4 render targets and pass my array.

 

That works fine.

 

Now I want to render to a texture array, but use the geometry shader to specify which slice to render to via SV_RenderTargetArrayIndex.  So I set up the same as above; 4 layers specified to CreateTexture2D, 4 layers specified to CreateShaderResourceView.  But this time I set up the D3D11_RENDER_TARGET_VIEW_DESC to have 4 layers in its Texture2DArray.ArraySize, and called CreateRenderTargetView only once.  I draw 4 instanced copies, and my geometry shader sets SV_RenderTargetArrayIndex and the associated pixel shader outputs to SV_TARGET. I call OMSetRenderTargets for 1 render target,  I see nothing.

 

If I change the D3D11_RENDER_TARGET_VIEW_DESC to have 1 layer, I see all my instanced renderings output to the first slice of the texture.  But setting it to 4 means I see nothing.  The device clears each layer of the array properly, but I can't seem to render to them.

 

What could I be missing?

Share this post


Link to post
Share on other sites

Ah, I solved it.  For an MRT set up, I was only using a single depth buffer.  For an array of render targets, I need an array of depth buffers.

Share this post


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