| 24 | extern ID3D11DeviceContext *g_deferred_context; |
| 25 | |
| 26 | static void renderTaa(ID3D11DeviceContext *const context, ID3D11ShaderResourceView *mainTexView) |
| 27 | { |
| 28 | ZoneScopedN(__FUNCTION__); |
| 29 | |
| 30 | static ID3D11Texture2D *accumTex[2]; |
| 31 | static ID3D11SamplerState *pointSampler; |
| 32 | static ID3D11SamplerState *linearSampler; |
| 33 | static ID3D11Buffer *cb = NULL; |
| 34 | static ShaderHandle taaCsHandle; |
| 35 | |
| 36 | static bool resourcesCreated = false; |
| 37 | static glm::uvec2 resourcesResolution; |
| 38 | |
| 39 | struct Constants |
| 40 | { |
| 41 | unsigned screenWidth; |
| 42 | unsigned screenHeight; |
| 43 | float invScreenWidth; |
| 44 | float invScreenHeight; |
| 45 | } constants; |
| 46 | ZeroMemory(&constants, sizeof(constants)); |
| 47 | |
| 48 | const uint screenWidth = g_frameConstants.screenWidth; |
| 49 | const uint screenHeight = g_frameConstants.screenHeight; |
| 50 | |
| 51 | // Fade off the logo with time |
| 52 | constants.screenWidth = screenWidth; |
| 53 | constants.screenHeight = screenHeight; |
| 54 | constants.invScreenWidth = 1.f / screenWidth; |
| 55 | constants.invScreenHeight = 1.f / screenHeight; |
| 56 | |
| 57 | if (!resourcesCreated || resourcesResolution != glm::uvec2(screenWidth, screenHeight)) |
| 58 | { |
| 59 | resourcesCreated = true; |
| 60 | resourcesResolution = glm::uvec2(screenWidth, screenHeight); |
| 61 | |
| 62 | taaCsHandle = ShaderRegistry::addComputeShader("taa_cs.cso"); |
| 63 | |
| 64 | { |
| 65 | D3D11_TEXTURE2D_DESC texDesc; |
| 66 | ZeroMemory(&texDesc, sizeof(texDesc)); |
| 67 | texDesc.Width = screenWidth; |
| 68 | texDesc.Height = screenHeight; |
| 69 | texDesc.MipLevels = 1; |
| 70 | texDesc.ArraySize = 1; |
| 71 | texDesc.Format = DXGI_FORMAT_R11G11B10_FLOAT; |
| 72 | texDesc.SampleDesc.Count = 1; |
| 73 | texDesc.SampleDesc.Quality = 0; |
| 74 | texDesc.Usage = D3D11_USAGE_DEFAULT; |
| 75 | texDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET | D3D11_BIND_UNORDERED_ACCESS; |
| 76 | |
| 77 | DX_CHECK(g_device->CreateTexture2D(&texDesc, nullptr, &accumTex[0])); |
| 78 | DX_CHECK(g_device->CreateTexture2D(&texDesc, nullptr, &accumTex[1])); |
| 79 | } |
| 80 | |
| 81 | { |
| 82 | D3D11_SAMPLER_DESC samplerDesc; |
| 83 | ZeroMemory(&samplerDesc, sizeof(samplerDesc)); |
no test coverage detected