Hi Forum!
I am in half way of redesigning abstraction representations of 2D textures in my engine (CPU side) for:
RenderTarget, DepthStencil, and array versions of them.
And I would like to clarify some design decisions before starting to code.
============================================
RenderTarget2D abstraction
Consider this interface for render target 2D (not array version):
class RenderTarget2D
{
ComPtr<ID3D11Texture2D> m_texture;
ComPtr<ID3D11RenderTargetView> m_rtv;
ComPtr<ID3D11ShaderResourceView> m_srv;
ComPtr<ID3D11UnorderedAccessView> m_uav;
}
Questions1:
If I create UAV for any RenderTarget2D, can it degrade performance in runtime?
Can hardware treat texture with UAV as slower version than a texture, created without UAV?
============================================
DepthStencil abstraction
I haven’t found a good way of using Stencil part of it.
For deferred rendering and shadow generation I don’t use Stencil.
Question2:
Are there use cases in modern rendering when Stencil is useful?
============================================
DepthTexture2D abstraction
Question3:
Is it right way to say, that Depth texture without “Stencil” part can be treated as regular texture2D with next statements:
1. Format of Depth should start with D, but RenderTargets – from R?
2. CreateDepthStencilView() should be substituted with CreateRenderTargetView()
Are there other fundamental differences between them?
============================================
DepthArray2D abstraction (without stencil part)
In Shadow map generation, I need DepthStencilArray with 4 slices without stencil part.
class DepthArray2D
{
ComPtr<ID3D11Texture2D> m_texture;
ComPtr<ID3D11ShaderResourceView> m_srv; // As Texture2DArray in hlsl
std::vector<ComPtr<ID3D11ShaderResourceView>> m_srvSlices; // As Texture2D in hlsl
ComPtr<ID3D11DepthStencilView> m_dsv;
ComPtr<ID3D11DepthStencilView> m_dsvRO;
std::vector<ComPtr<ID3D11DepthStencilView>> m_dsvSlices;
}
Question4:
Is it right thing to say that DepthStencilArray is the same as Texture2DArray (I can create SRV slices as in Texture)?
Thanks in advance!