Graphics Reference
In-Depth Information
// SRV description for render targets
var srvDesc = new ShaderResourceViewDescription();
srvDesc.Format = SharpDX.DXGI.Format.R8G8B8A8_UNorm;
srvDesc.Dimension = isMSAA ? SharpDX.Direct3D.
ShaderResourceViewDimension.Texture2DMultisampled :
SharpDX.Direct3D.ShaderResourceViewDimension.Texture2D;
srvDesc.Texture2D.MipLevels = -1; // auto
srvDesc.Texture2D.MostDetailedMip = 0;
All render targets and the depth stencil buffer used simultaneously
for Multiple Render Targets (MRTs) must use the same underlying
dimension (for example, Texture2D and Texture3D ) and have
the same value for SampleDescription .
5.
We now need to create the corresponding texture, RTV and SRV, for each of the
specified render target formats of the G-Buffer using the description objects we
created previously:
// Create Render Target's texture (with SRV and RTV)
foreach (var format in RTFormats)
{
texDesc.Format = format;
srvDesc.Format = format;
rtvDesc.Format = format;
RTs.Add(ToDispose( new Texture2D(device, texDesc) ));
SRVs.Add(ToDispose( new ShaderResourceView(device,
RTs.Last(), srvDesc) ));
RTVs.Add(ToDispose( new RenderTargetView(device,
RTs.Last(), rtvDesc) ));
}
6.
To complete the CreateDeviceDependentResources method, we will create
the depth stencil texture and Depth Stencil View (DSV), along with an SRV in order
to access the depth buffer from our shaders:
// Create Depth/Stencil
texDesc.BindFlags = BindFlags.ShaderResource |
BindFlags.DepthStencil;
// typeless so we can use as shader resource
texDesc.Format = SharpDX.DXGI.Format.R32G8X24_Typeless;
DS0 = ToDispose( new Texture2D(device, texDesc) );
 
Search WWH ::




Custom Search