Permalink
Browse files

D3D11: Fix Star Ocean again (wasn't clearing stencil properly)

  • Loading branch information...
hrydgard committed Jun 9, 2017
1 parent 3606111 commit 5f6e0feacb2c056e0650df8bf49a43ffd44929c3
Showing with 20 additions and 27 deletions.
  1. +4 −14 GPU/D3D11/StencilBufferD3D11.cpp
  2. +16 −13 ext/native/thin3d/thin3d_d3d11.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);
@@ -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]{};

0 comments on commit 5f6e0fe

Please sign in to comment.