From b99d42c6889b27a609e31b8701a72b77c4f356ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Wed, 24 Apr 2024 14:02:18 +0200 Subject: [PATCH] [d3d11] Implement VideoProcessorSetStreamSourceRect scaling --- src/d3d11/d3d11_video.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/d3d11/d3d11_video.cpp b/src/d3d11/d3d11_video.cpp index 3851a498..5318be9e 100644 --- a/src/d3d11/d3d11_video.cpp +++ b/src/d3d11/d3d11_video.cpp @@ -1262,12 +1262,29 @@ namespace dxvk { viewport.height = float(cStreamState.dstRect.bottom) - viewport.y; } + VkExtent3D viewExtent = cViews[0]->mipLevelExtent(0); + VkViewport srcViewport; + + if (cStreamState.srcRectEnabled) { + srcViewport.x = float(cStreamState.srcRect.left); + srcViewport.y = float(cStreamState.srcRect.top); + srcViewport.width = float(cStreamState.srcRect.right) - srcViewport.x; + srcViewport.height = float(cStreamState.srcRect.bottom) - srcViewport.y; + } else { + srcViewport.x = 0.0f; + srcViewport.y = 0.0f; + srcViewport.width = float(viewExtent.width); + srcViewport.height = float(viewExtent.height); + } + UboData uboData = { }; uboData.colorMatrix[0][0] = 1.0f; uboData.colorMatrix[1][1] = 1.0f; uboData.colorMatrix[2][2] = 1.0f; - uboData.coordMatrix[0][0] = 1.0f; - uboData.coordMatrix[1][1] = 1.0f; + uboData.coordMatrix[0][0] = srcViewport.width / float(viewExtent.width); + uboData.coordMatrix[1][1] = srcViewport.height / float(viewExtent.height); + uboData.coordMatrix[2][0] = srcViewport.x / float(viewExtent.width); + uboData.coordMatrix[2][1] = srcViewport.y / float(viewExtent.height); uboData.yMin = 0.0f; uboData.yMax = 1.0f; uboData.isPlanar = cViews[1] != nullptr;