From 5f6e0feacb2c056e0650df8bf49a43ffd44929c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 9 Jun 2017 14:50:39 +0200 Subject: [PATCH] D3D11: Fix Star Ocean again (wasn't clearing stencil properly) --- GPU/D3D11/StencilBufferD3D11.cpp | 18 ++++-------------- ext/native/thin3d/thin3d_d3d11.cpp | 29 ++++++++++++++++------------- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/GPU/D3D11/StencilBufferD3D11.cpp b/GPU/D3D11/StencilBufferD3D11.cpp index 9f18eff386..386edb3448 100644 --- a/GPU/D3D11/StencilBufferD3D11.cpp +++ b/GPU/D3D11/StencilBufferD3D11.cpp @@ -201,22 +201,12 @@ bool FramebufferManagerD3D11::NotifyStencilUpload(u32 addr, int size, bool skipZ D3D11_VIEWPORT vp{ 0.0f, 0.0f, (float)w, (float)h, 0.0f, 1.0f }; context_->RSSetViewports(1, &vp); - float fw = dstBuffer->width; - float fh = dstBuffer->height; - float coord[20] = { - 0.0f,0.0f,0.0f, 0.0f,0.0f, - fw,0.0f,0.0f, u1,0.0f, - 0.0f,fh,0.0f, 0.0f,v1, - fw,fh,0.0f, u1,v1, + -1.0f, 1.0f, 0.0f, 0.0f, 0.0f, + 1.0f, 1.0f, 0.0f, u1, 0.0f, + -1.0f, -1.0f, 0.0f, 0.0f, v1, + 1.0f, -1.0f, 0.0f, u1, v1, }; - // I think all these calculations pretty much cancel out? - float invDestW = 1.0f / (fw * 0.5f); - float invDestH = 1.0f / (fh * 0.5f); - for (int i = 0; i < 4; i++) { - coord[i * 5] = coord[i * 5] * invDestW - 1.0f; - coord[i * 5 + 1] = -(coord[i * 5 + 1] * invDestH - 1.0f); - } D3D11_MAPPED_SUBRESOURCE map; context_->Map(quadBuffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &map); diff --git a/ext/native/thin3d/thin3d_d3d11.cpp b/ext/native/thin3d/thin3d_d3d11.cpp index 85e44c9035..e5d26f6bb1 100644 --- a/ext/native/thin3d/thin3d_d3d11.cpp +++ b/ext/native/thin3d/thin3d_d3d11.cpp @@ -1291,21 +1291,24 @@ void D3D11DrawContext::BindFramebufferAsRenderTarget(Framebuffer *fbo, const Ren if (fbo) { D3D11Framebuffer *fb = (D3D11Framebuffer *)fbo; if (curRenderTargetView_ == fb->colorRTView && curDepthStencilView_ == fb->depthStencilRTView) { - return; + // No need to switch, but let's fallthrough to clear! + } else { + context_->OMSetRenderTargets(1, &fb->colorRTView, fb->depthStencilRTView); + curRenderTargetView_ = fb->colorRTView; + curDepthStencilView_ = fb->depthStencilRTView; + curRTWidth_ = fb->width; + curRTHeight_ = fb->height; } - context_->OMSetRenderTargets(1, &fb->colorRTView, fb->depthStencilRTView); - curRenderTargetView_ = fb->colorRTView; - curDepthStencilView_ = fb->depthStencilRTView; - curRTWidth_ = fb->width; - curRTHeight_ = fb->height; } else { - if (curRenderTargetView_ == bbRenderTargetView_ && curDepthStencilView_ == bbDepthStencilView_) - return; - context_->OMSetRenderTargets(1, &bbRenderTargetView_, bbDepthStencilView_); - curRenderTargetView_ = bbRenderTargetView_; - curDepthStencilView_ = bbDepthStencilView_; - curRTWidth_ = bbWidth_; - curRTHeight_ = bbHeight_; + if (curRenderTargetView_ == bbRenderTargetView_ && curDepthStencilView_ == bbDepthStencilView_) { + // No need to switch, but let's fallthrough to clear! + } else { + context_->OMSetRenderTargets(1, &bbRenderTargetView_, bbDepthStencilView_); + curRenderTargetView_ = bbRenderTargetView_; + curDepthStencilView_ = bbDepthStencilView_; + curRTWidth_ = bbWidth_; + curRTHeight_ = bbHeight_; + } } if (rp.color == RPAction::CLEAR && curRenderTargetView_) { float cv[4]{};