| 57 | } |
| 58 | |
| 59 | HRESULT RenderTarget::Init(ID3D11Device* device, int width, int height, bool depthTest) |
| 60 | { |
| 61 | // set viewport |
| 62 | { |
| 63 | m_viewport.Width = float(width); |
| 64 | m_viewport.Height = float(height); |
| 65 | m_viewport.MinDepth = 0; |
| 66 | m_viewport.MaxDepth = 1; |
| 67 | m_viewport.TopLeftX = 0; |
| 68 | m_viewport.TopLeftY = 0; |
| 69 | } |
| 70 | |
| 71 | // create shadow render target |
| 72 | { |
| 73 | D3D11_TEXTURE2D_DESC texDesc = _getTextureDesc(DXGI_FORMAT_R32_FLOAT, UINT(width), UINT(height), |
| 74 | D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE); |
| 75 | |
| 76 | NV_RETURN_ON_FAIL(device->CreateTexture2D(&texDesc, NV_NULL, m_backTexture.ReleaseAndGetAddressOf())); |
| 77 | NV_RETURN_ON_FAIL(device->CreateShaderResourceView(m_backTexture.Get(), NV_NULL, m_backSrv.ReleaseAndGetAddressOf())); |
| 78 | NV_RETURN_ON_FAIL(device->CreateRenderTargetView(m_backTexture.Get(), NV_NULL, m_backRtv.ReleaseAndGetAddressOf())); |
| 79 | } |
| 80 | |
| 81 | // create shadow depth stencil |
| 82 | { |
| 83 | D3D11_TEXTURE2D_DESC texDesc = _getTextureDesc(DXGI_FORMAT_R32_TYPELESS, UINT(width), UINT(height), |
| 84 | D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE); |
| 85 | NV_RETURN_ON_FAIL(device->CreateTexture2D(&texDesc, NV_NULL, m_depthTexture.ReleaseAndGetAddressOf())); |
| 86 | |
| 87 | D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc = _getDsvDesc(DXGI_FORMAT_D32_FLOAT, D3D11_DSV_DIMENSION_TEXTURE2D); |
| 88 | NV_RETURN_ON_FAIL(device->CreateDepthStencilView(m_depthTexture.Get(), &dsvDesc, m_depthDsv.ReleaseAndGetAddressOf())); |
| 89 | |
| 90 | D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = _getSrvDesc(DXGI_FORMAT_R32_FLOAT); |
| 91 | NV_RETURN_ON_FAIL(device->CreateShaderResourceView(m_depthTexture.Get(), &srvDesc, m_depthSrv.ReleaseAndGetAddressOf())); |
| 92 | } |
| 93 | |
| 94 | { |
| 95 | D3D11_SAMPLER_DESC samplerDesc = |
| 96 | { |
| 97 | D3D11_FILTER_MIN_MAG_MIP_LINEAR, |
| 98 | D3D11_TEXTURE_ADDRESS_CLAMP, |
| 99 | D3D11_TEXTURE_ADDRESS_CLAMP, |
| 100 | D3D11_TEXTURE_ADDRESS_CLAMP, |
| 101 | 0.0, 0, D3D11_COMPARISON_NEVER, |
| 102 | 0.0f, 0.0f, 0.0f, 0.0f, |
| 103 | 0.0f, D3D11_FLOAT32_MAX, |
| 104 | }; |
| 105 | NV_RETURN_ON_FAIL(device->CreateSamplerState(&samplerDesc, m_linearSampler.ReleaseAndGetAddressOf())); |
| 106 | } |
| 107 | { |
| 108 | D3D11_SAMPLER_DESC samplerDesc = |
| 109 | { |
| 110 | D3D11_FILTER_MIN_MAG_MIP_POINT, |
| 111 | D3D11_TEXTURE_ADDRESS_CLAMP, |
| 112 | D3D11_TEXTURE_ADDRESS_CLAMP, |
| 113 | D3D11_TEXTURE_ADDRESS_CLAMP, |
| 114 | 0.0, 0, D3D11_COMPARISON_NEVER, |
| 115 | 0.0f, 0.0f, 0.0f, 0.0f, |
| 116 | 0.0f, D3D11_FLOAT32_MAX, |
nothing calls this directly
no test coverage detected