From c852b6de349793944ee193d85825c63132723b86 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Fri, 13 Sep 2019 14:38:51 +0200 Subject: [PATCH] [d3d11] Optimize viewport updates if there is only one single viewport --- src/d3d11/d3d11_context.cpp | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index e5d94802..210fee95 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -3219,16 +3219,27 @@ namespace dxvk { } } - EmitCs([ - cViewportCount = viewportCount, - cViewports = viewports, - cScissors = scissors - ] (DxvkContext* ctx) { - ctx->setViewports( - cViewportCount, - cViewports.data(), - cScissors.data()); - }); + if (likely(viewportCount == 1)) { + EmitCs([ + cViewport = viewports[0], + cScissor = scissors[0] + ] (DxvkContext* ctx) { + ctx->setViewports(1, + &cViewport, + &cScissor); + }); + } else { + EmitCs([ + cViewportCount = viewportCount, + cViewports = viewports, + cScissors = scissors + ] (DxvkContext* ctx) { + ctx->setViewports( + cViewportCount, + cViewports.data(), + cScissors.data()); + }); + } }