Add stencil buffer usage with object layer information

#3080 #967
This commit is contained in:
Wojtek Figat
2025-10-07 18:07:23 +02:00
parent 823ed247d2
commit 361fc3ecfb
36 changed files with 291 additions and 65 deletions

View File

@@ -227,6 +227,8 @@ void GPUTextureDX12::OnReleaseGPU()
_handlesPerSlice.Resize(0, false);
_handleArray.Release();
_handleVolume.Release();
_handleReadOnlyDepth.Release();
_handleStencil.Release();
_srv.Release();
_uav.Release();
releaseResource();
@@ -721,6 +723,45 @@ void GPUTextureDX12::initHandles()
_handleReadOnlyDepth.SetSRV(srDesc);
}
}
// Stencil view
if (useDSV && useSRV && PixelFormatExtensions::HasStencil(format))
{
PixelFormat stencilFormat;
switch (_dxgiFormatDSV)
{
case PixelFormat::D24_UNorm_S8_UInt:
srDesc.Format = DXGI_FORMAT_X24_TYPELESS_G8_UINT;
stencilFormat = PixelFormat::X24_Typeless_G8_UInt;
break;
case PixelFormat::D32_Float_S8X24_UInt:
srDesc.Format = DXGI_FORMAT_X32_TYPELESS_G8X24_UINT;
stencilFormat = PixelFormat::X32_Typeless_G8X24_UInt;
break;
}
if (isCubeMap)
{
srDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBE;
srDesc.TextureCube.MostDetailedMip = 0;
srDesc.TextureCube.MipLevels = mipLevels;
srDesc.TextureCube.ResourceMinLODClamp = 0;
}
else if (isMsaa)
{
srDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DMS;
}
else
{
srDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
srDesc.Texture2D.MostDetailedMip = 0;
srDesc.Texture2D.MipLevels = mipLevels;
srDesc.Texture2D.ResourceMinLODClamp = 0;
srDesc.Texture2D.PlaneSlice = 1;
}
_handleStencil.Init(this, _device, this, stencilFormat, msaa);
_handleStencil.ReadOnlyDepthView = true;
_handleStencil.SetSRV(srDesc);
}
}
#endif