| 273 | bool g_disableXSC_cache = true; |
| 274 | |
| 275 | HRESULT WINAPI Unmap_hook(ID3D11DeviceContext *context, _In_ ID3D11Resource *pResource, _In_ UINT Subresource) |
| 276 | { |
| 277 | ZoneScopedN(__FUNCTION__); |
| 278 | |
| 279 | CComPtr<ID3D11RenderTargetView> rtv; |
| 280 | context->OMGetRenderTargets(1, &rtv, nullptr); |
| 281 | |
| 282 | CComPtr<ID3D11Resource> rtRes = nullptr; |
| 283 | if (rtv) |
| 284 | rtv->GetResource(&rtRes); |
| 285 | |
| 286 | ID3D11Texture2D *const rtTex = (ID3D11Texture2D *)rtRes.p; |
| 287 | D3D11_TEXTURE2D_DESC rtTexDesc; |
| 288 | ZeroMemory(&rtTexDesc, sizeof(D3D11_TEXTURE2D_DESC)); |
| 289 | |
| 290 | if (rtTex) |
| 291 | rtTex->GetDesc(&rtTexDesc); |
| 292 | |
| 293 | UINT numViewports = 1; |
| 294 | D3D11_VIEWPORT viewport; |
| 295 | context->RSGetViewports(&numViewports, &viewport); |
| 296 | |
| 297 | CComPtr<ID3D11BlendState> blendState = nullptr; |
| 298 | context->OMGetBlendState(&blendState, nullptr, nullptr); |
| 299 | |
| 300 | D3D11_BLEND_DESC blendDesc; |
| 301 | ZeroMemory(&blendDesc, sizeof(D3D11_BLEND_DESC)); |
| 302 | if (blendState) |
| 303 | { |
| 304 | blendState->GetDesc(&blendDesc); |
| 305 | } |
| 306 | |
| 307 | const uint screenWidth = g_frameConstants.screenWidth; |
| 308 | const uint screenHeight = g_frameConstants.screenHeight; |
| 309 | |
| 310 | // Only want TAA jitter in full-screen render passes |
| 311 | if (rtTex && rtTexDesc.Width == screenWidth && rtTexDesc.Height == screenHeight && |
| 312 | viewport.Width == (float)screenWidth && viewport.Height == (float)screenHeight) |
| 313 | { |
| 314 | #ifndef ALIASISOLATION_NO_SMAA_JITTER_ADD |
| 315 | if (g_alienResources.cbDefaultXSC == pResource && g_alienResources.mappedCbDefaultXSC) |
| 316 | { |
| 317 | const glm::vec2 sampleOffset = getFrameJitter(); |
| 318 | |
| 319 | CbDefaultXSC *const xsc = g_alienResources.mappedCbDefaultXSC; |
| 320 | |
| 321 | if (glm::mat3(xsc->SecondaryProj) != glm::mat3()) // Planar reflections have identity SecondaryProj |
| 322 | { |
| 323 | g_frameConstants.gameTime = xsc->Time.x; |
| 324 | |
| 325 | // We cannot jitter shadow matrices, or we get terrible flickering due to moving acne. |
| 326 | // The way we detect shadow rendering is by comparing "CameraPosition" from the constant buffer |
| 327 | // with one reconstructed from the view matrix. They will only match for main viewport rendering, |
| 328 | // as "CameraPosition" is not updated for shadow views. |
| 329 | const glm::vec3 viewCameraPos = |
| 330 | glm::mat3(xsc->ViewMatrix) * |
| 331 | glm::vec3(-xsc->ViewMatrix[0][3], -xsc->ViewMatrix[1][3], -xsc->ViewMatrix[2][3]); |
| 332 |
nothing calls this directly
no test coverage detected