| 328 | } |
| 329 | |
| 330 | bool NGXWrapper::evaluateDLSS( |
| 331 | RenderContext* pRenderContext, |
| 332 | Texture* pUnresolvedColor, |
| 333 | Texture* pResolvedColor, |
| 334 | Texture* pMotionVectors, |
| 335 | Texture* pDepth, |
| 336 | Texture* pExposure, |
| 337 | bool resetAccumulation, |
| 338 | float sharpness, |
| 339 | float2 jitterOffset, |
| 340 | float2 motionVectorScale |
| 341 | ) const |
| 342 | { |
| 343 | if (!mpFeature) |
| 344 | return false; |
| 345 | |
| 346 | // In DLSS v2, the target is already upsampled (while in v1, the upsampling is handled in a later pass) |
| 347 | FALCOR_ASSERT(pResolvedColor->getWidth() > pUnresolvedColor->getWidth() && pResolvedColor->getHeight() > pUnresolvedColor->getHeight()); |
| 348 | |
| 349 | bool success = true; |
| 350 | |
| 351 | switch (mpDevice->getType()) |
| 352 | { |
| 353 | case Device::Type::D3D12: |
| 354 | { |
| 355 | #if FALCOR_HAS_D3D12 |
| 356 | pRenderContext->resourceBarrier(pUnresolvedColor, Resource::State::ShaderResource); |
| 357 | pRenderContext->resourceBarrier(pMotionVectors, Resource::State::ShaderResource); |
| 358 | pRenderContext->resourceBarrier(pDepth, Resource::State::ShaderResource); |
| 359 | pRenderContext->resourceBarrier(pResolvedColor, Resource::State::UnorderedAccess); |
| 360 | |
| 361 | ID3D12Resource* unresolvedColorBuffer = pUnresolvedColor->getNativeHandle().as<ID3D12Resource*>(); |
| 362 | ID3D12Resource* motionVectorsBuffer = pMotionVectors->getNativeHandle().as<ID3D12Resource*>(); |
| 363 | ID3D12Resource* resolvedColorBuffer = pResolvedColor->getNativeHandle().as<ID3D12Resource*>(); |
| 364 | ID3D12Resource* depthBuffer = pDepth->getNativeHandle().as<ID3D12Resource*>(); |
| 365 | ID3D12Resource* exposureBuffer = pExposure ? pExposure->getNativeHandle().as<ID3D12Resource*>() : nullptr; |
| 366 | |
| 367 | NVSDK_NGX_D3D12_DLSS_Eval_Params evalParams = {}; |
| 368 | |
| 369 | evalParams.Feature.pInColor = unresolvedColorBuffer; |
| 370 | evalParams.Feature.pInOutput = resolvedColorBuffer; |
| 371 | evalParams.Feature.InSharpness = sharpness; |
| 372 | evalParams.pInDepth = depthBuffer; |
| 373 | evalParams.pInMotionVectors = motionVectorsBuffer; |
| 374 | evalParams.InJitterOffsetX = jitterOffset.x; |
| 375 | evalParams.InJitterOffsetY = jitterOffset.y; |
| 376 | evalParams.InReset = resetAccumulation ? 1 : 0; |
| 377 | evalParams.InRenderSubrectDimensions.Width = pUnresolvedColor->getWidth(); |
| 378 | evalParams.InRenderSubrectDimensions.Height = pUnresolvedColor->getHeight(); |
| 379 | evalParams.InMVScaleX = motionVectorScale.x; |
| 380 | evalParams.InMVScaleY = motionVectorScale.y; |
| 381 | evalParams.pInExposureTexture = exposureBuffer; |
| 382 | |
| 383 | ID3D12GraphicsCommandList* pCommandList = |
| 384 | pRenderContext->getLowLevelData()->getCommandBufferNativeHandle().as<ID3D12GraphicsCommandList*>(); |
| 385 | NVSDK_NGX_Result result = NGX_D3D12_EVALUATE_DLSS_EXT(pCommandList, mpFeature, mpParameters, &evalParams); |
| 386 | if (NVSDK_NGX_FAILED(result)) |
| 387 | { |
no test coverage detected