Creates all required render targets
| 788 | |
| 789 | // Creates all required render targets |
| 790 | void BindlessDeferred::CreateRenderTargets() |
| 791 | { |
| 792 | uint32 width = swapChain.Width(); |
| 793 | uint32 height = swapChain.Height(); |
| 794 | const uint32 NumSamples = AppSettings::NumMSAASamples(); |
| 795 | |
| 796 | mainTarget.Initialize(width, height, DXGI_FORMAT_R16G16B16A16_FLOAT, NumSamples, 1, NumSamples == 1); |
| 797 | |
| 798 | tangentFrameTarget.Initialize(width, height, DXGI_FORMAT_R10G10B10A2_UNORM, NumSamples, 1, false, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); |
| 799 | uvTarget.Initialize(width, height, DXGI_FORMAT_R16G16B16A16_SNORM, NumSamples, 1, false, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); |
| 800 | uvGradientsTarget.Initialize(width, height, DXGI_FORMAT_R16G16B16A16_SNORM, NumSamples, 1, false, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); |
| 801 | materialIDTarget.Initialize(width, height, DXGI_FORMAT_R8_UINT, NumSamples, 1, false, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); |
| 802 | |
| 803 | if(NumSamples > 1) |
| 804 | { |
| 805 | resolveTarget.Initialize(width, height, DXGI_FORMAT_R16G16B16A16_FLOAT, 1, 1, false); |
| 806 | |
| 807 | uint32 deferredWidth = width * 2; |
| 808 | uint32 deferredHeight = NumSamples == 4 ? height * 2 : height; |
| 809 | deferredMSAATarget.Initialize(deferredWidth, deferredHeight, DXGI_FORMAT_R16G16B16A16_FLOAT, 1, 1, true); |
| 810 | } |
| 811 | |
| 812 | depthBuffer.Initialize(width, height, DXGI_FORMAT_D24_UNORM_S8_UINT, NumSamples, 1, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); |
| 813 | |
| 814 | AppSettings::NumXTiles = (width + (AppSettings::ClusterTileSize - 1)) / AppSettings::ClusterTileSize; |
| 815 | AppSettings::NumYTiles = (height + (AppSettings::ClusterTileSize - 1)) / AppSettings::ClusterTileSize; |
| 816 | const uint64 numXYZTiles = AppSettings::NumXTiles * AppSettings::NumYTiles * AppSettings::NumZTiles; |
| 817 | |
| 818 | // Render target for forcing MSAA during cluster rasterization. Ideally we would use ForcedSampleCount for this, |
| 819 | // but it's currently causing the Nvidia driver to crash. :( |
| 820 | ClusterRasterizationModes rastMode = AppSettings::ClusterRasterizationMode; |
| 821 | if(rastMode == ClusterRasterizationModes::MSAA4x) |
| 822 | clusterMSAATarget.Initialize(AppSettings::NumXTiles, AppSettings::NumYTiles, DXGI_FORMAT_R8_UNORM, 4, 1, false); |
| 823 | else if(rastMode == ClusterRasterizationModes::MSAA8x) |
| 824 | clusterMSAATarget.Initialize(AppSettings::NumXTiles, AppSettings::NumYTiles, DXGI_FORMAT_R8_UNORM, 8, 1, false); |
| 825 | else |
| 826 | clusterMSAATarget.Shutdown(); |
| 827 | |
| 828 | { |
| 829 | // Decal cluster bitmask buffer |
| 830 | RawBufferInit rbInit; |
| 831 | rbInit.NumElements = numXYZTiles * AppSettings::DecalElementsPerCluster; |
| 832 | rbInit.CreateUAV = true; |
| 833 | decalClusterBuffer.Initialize(rbInit); |
| 834 | decalClusterBuffer.InternalBuffer.Resource->SetName(L"Decal Cluster Buffer"); |
| 835 | } |
| 836 | |
| 837 | { |
| 838 | // Spotlight cluster bitmask buffer |
| 839 | RawBufferInit rbInit; |
| 840 | rbInit.NumElements = numXYZTiles * AppSettings::SpotLightElementsPerCluster; |
| 841 | rbInit.CreateUAV = true; |
| 842 | spotLightClusterBuffer.Initialize(rbInit); |
| 843 | spotLightClusterBuffer.InternalBuffer.Resource->SetName(L"Spot Light Cluster Buffer"); |
| 844 | } |
| 845 | |
| 846 | { |
| 847 | const uint64 numComputeTilesX = AlignTo(mainTarget.Width(), AppSettings::DeferredTileSize) / AppSettings::DeferredTileSize; |
nothing calls this directly
no test coverage detected