Graphics Reference
In-Depth Information
srvDesc.Format =
SharpDX.DXGI.Format.R32_Float_X8X24_Typeless;
DSSRV = ToDispose( new ShaderResourceView(device, DS0,
srvDesc) );
// Depth Stencil View
var dsvDesc = new DepthStencilViewDescription();
dsvDesc.Flags = DepthStencilViewFlags.None;
dsvDesc.Dimension = isMSAA ?
DepthStencilViewDimension.Texture2DMultisampled :
DepthStencilViewDimension.Texture2D;
dsvDesc.Format = SharpDX.DXGI.Format.D32_Float_S8X24_UInt;
DSV = ToDispose( new DepthStencilView(device, DS0,
dsvDesc) );
7.
Next, we create methods to bind and unbind the render targets to the pipeline and
finally to clear the G-Buffer:
// Bind the render targets to the OutputMerger
public void Bind(DeviceContext1 context)
{
context.OutputMerger.SetTargets(DSV, 0,
new UnorderedAccessView [0], RTVs.ToArray());
}
// Unbind the render targets
public void Unbind(DeviceContext1 context)
{
context.OutputMerger.ResetTargets();
}
// Clear the render targets and depth stencil
public void Clear(DeviceContext1 context, Color background)
{
context.ClearDepthStencilView(DSV,
DepthStencilClearFlags.Depth |
DepthStencilClearFlags.Stencil, 1.0f, 0);
foreach (var rtv in RTVs)
context.ClearRenderTargetView(rtv, background);
}
This completes our generic GBuffer class. With this we can easily create new
G-Buffer layouts depending on the specific rendering requirements.
 
Search WWH ::




Custom Search