diff --git a/GPU/Common/GPUStateUtils.cpp b/GPU/Common/GPUStateUtils.cpp index 4ee8ba04a0..5244e4f83a 100644 --- a/GPU/Common/GPUStateUtils.cpp +++ b/GPU/Common/GPUStateUtils.cpp @@ -18,6 +18,8 @@ #include #include +#include "base/display.h" + #include "Common/StringUtils.h" #include "Core/Config.h" #include "Core/System.h" diff --git a/GPU/Common/ShaderUniforms.cpp b/GPU/Common/ShaderUniforms.cpp index 9c76b106db..a804be5023 100644 --- a/GPU/Common/ShaderUniforms.cpp +++ b/GPU/Common/ShaderUniforms.cpp @@ -1,6 +1,7 @@ #include #include "ShaderUniforms.h" +#include "base/display.h" #include "math/dataconv.h" #include "math/lin/matrix4x4.h" #include "math/math_util.h" @@ -8,6 +9,7 @@ #include "GPU/GPUState.h" #include "GPU/Math3D.h" #include "Core/Reporting.h" +#include "Core/Config.h" static void ConvertProjMatrixToVulkan(Matrix4x4 &in) { const Vec3 trans(0, 0, gstate_c.vpZOffset * 0.5f + 0.5f); @@ -78,6 +80,11 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipView } else { ConvertProjMatrixToVulkan(flippedMatrix); } + + if (g_Config.iRenderingMode == 0 && g_display_rotation != DisplayRotation::ROTATE_0) { + flippedMatrix = flippedMatrix * g_display_rot_matrix; + } + CopyMatrix4x4(ub->proj, flippedMatrix.getReadPtr()); } @@ -88,6 +95,9 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipView } else { proj_through.setOrthoVulkan(0.0f, gstate_c.curRTWidth, 0, gstate_c.curRTHeight, 0, 1); } + if (g_Config.iRenderingMode == 0 && g_display_rotation != DisplayRotation::ROTATE_0) { + proj_through = proj_through * g_display_rot_matrix; + } CopyMatrix4x4(ub->proj_through, proj_through.getReadPtr()); } diff --git a/GPU/D3D11/ShaderManagerD3D11.h b/GPU/D3D11/ShaderManagerD3D11.h index 5b891d8289..c66eda8153 100644 --- a/GPU/D3D11/ShaderManagerD3D11.h +++ b/GPU/D3D11/ShaderManagerD3D11.h @@ -25,9 +25,6 @@ #include "Globals.h" #include "GPU/Common/ShaderCommon.h" #include "GPU/Common/ShaderId.h" -// #include "GPU/DX9/VertexShaderGeneratorD3D11.h" -// #include "GPU/DX9/FragmentShaderGeneratorD3D11.h" -#include "math/lin/matrix4x4.h" #include "GPU/Common/ShaderUniforms.h" class D3D11Context; diff --git a/GPU/D3D11/StateMappingD3D11.cpp b/GPU/D3D11/StateMappingD3D11.cpp index 75e809c3f8..78a9b5e0ff 100644 --- a/GPU/D3D11/StateMappingD3D11.cpp +++ b/GPU/D3D11/StateMappingD3D11.cpp @@ -320,7 +320,7 @@ void DrawEngineD3D11::ApplyDrawState(int prim) { gstate_c.Dirty(DIRTY_DEPTHRANGE); } - D3D11_VIEWPORT &vp = dynState_.viewport; + Draw::Viewport &vp = dynState_.viewport; vp.TopLeftX = vpAndScissor.viewportX; vp.TopLeftY = vpAndScissor.viewportY; vp.Width = vpAndScissor.viewportW; @@ -443,19 +443,20 @@ void DrawEngineD3D11::ApplyDrawStateLate(bool applyStencilRef, uint8_t stencilRe if (!gstate.isModeClear()) { if (fboTexNeedBind_) { framebufferManager_->BindFramebufferAsColorTexture(1, framebufferManager_->GetCurrentRenderVFB(), BINDFBCOLOR_MAY_COPY); - // No sampler required, we do a Load in the pixel shader - // context_->PSSetSamplers(1, 1, &stockD3D11.samplerPoint2DClamp); + // No sampler required, we do a plain Load in the pixel shader. fboTexBound_ = true; fboTexNeedBind_ = false; } textureCache_->ApplyTexture(); } - // Need to do this AFTER ApplyTexture because the process of depalettization can ruin the blend state. + // Need to do this AFTER ApplyTexture because the process of depallettization can ruin the blend state. float blendColor[4]; Uint8x4ToFloat4(blendColor, dynState_.blendColor); - context_->RSSetViewports(1, &dynState_.viewport); - context_->RSSetScissorRects(1, &dynState_.scissor); + + // we go through Draw here because it automatically handles screen rotation, as needed in UWP on mobiles. + draw_->SetViewports(1, &dynState_.viewport); + draw_->SetScissorRect(dynState_.scissor.left, dynState_.scissor.top, dynState_.scissor.right - dynState_.scissor.left, dynState_.scissor.bottom - dynState_.scissor.top); context_->RSSetState(rasterState_); if (device1_) { context1_->OMSetBlendState(blendState1_, blendColor, 0xFFFFFFFF); diff --git a/GPU/D3D11/StateMappingD3D11.h b/GPU/D3D11/StateMappingD3D11.h index 33505d98dd..05f6b51c90 100644 --- a/GPU/D3D11/StateMappingD3D11.h +++ b/GPU/D3D11/StateMappingD3D11.h @@ -3,9 +3,9 @@ #include #include +#include "thin3d/thin3d.h" + // TODO: Do this more progressively. No need to compute the entire state if the entire state hasn't changed. -// In Vulkan, we simply collect all the state together into a "pipeline key" - we don't actually set any state here -// (the caller is responsible for setting the little dynamic state that is supported, dynState). struct D3D11BlendKey { union { @@ -67,6 +67,6 @@ struct D3D11DynamicState { uint32_t blendColor; bool useStencil; uint8_t stencilRef; - D3D11_VIEWPORT viewport; + Draw::Viewport viewport; D3D11_RECT scissor; };