I would like to set a slice of a Texture2DArray
as a render target in D3D/DirectX11. It's not clear how to do this.
What I'm looking for is the DirectX equivalent of glFramebufferTextureLayer()
, which sets a slice of a GL_TEXTURE_2D_ARRAY_EXT
as a texture resource of a Framebuffer Object.
In D3D11, you set a render target using ID3D11DeviceContext::OMSetRenderTargets
, and you can set a Texture2DArray
resource view as a render target. However, the only way I see to select which slice of the texture is painted is to use the SV_RenderTargetArrayIndex
semantic in an HLSL geometry shader. (The semantic is only available in a geometry shader).
My pipeline doesn't have a geometry shader, and I don't know at compile time which primitive type I will be rendering - I'm reading models out of input files. It seems like, to add a passthrough geometry shader I would need one shader program for every possible primitive type (terrible).
The desired output slice will not change between rendering passes. Is there no way to set a slice of a Texture2DArray
as a render target without using a geometry shader?