diff options
| author | Jules Blok <jules.blok@gmail.com> | 2015-05-26 15:39:50 +0200 |
|---|---|---|
| committer | Jules Blok <jules.blok@gmail.com> | 2015-05-26 15:39:50 +0200 |
| commit | 0b61a0dfc591cbbac7a450bb8b5a7166c9504e51 (patch) | |
| tree | a3c9f5d568cc50e44dd0234d3d69221415c249f5 /Source/Core/VideoBackends/D3D/Render.cpp | |
| parent | d7900b442367c4481b66a35fbcb1d30dd5c25176 (diff) | |
| parent | ca7801da449d214bebdfd2573aeae16cd492bc72 (diff) | |
Merge pull request #2448 from Armada651/depth-inversion
D3D: Depth range inversion.
Diffstat (limited to 'Source/Core/VideoBackends/D3D/Render.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/D3D/Render.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index 6bda211de6..230cb11ec4 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -259,7 +259,7 @@ Renderer::Renderer(void *&window_handle) // Clear EFB textures float ClearColor[4] = { 0.f, 0.f, 0.f, 1.f }; D3D::context->ClearRenderTargetView(FramebufferManager::GetEFBColorTexture()->GetRTV(), ClearColor); - D3D::context->ClearDepthStencilView(FramebufferManager::GetEFBDepthTexture()->GetDSV(), D3D11_CLEAR_DEPTH, 1.f, 0); + D3D::context->ClearDepthStencilView(FramebufferManager::GetEFBDepthTexture()->GetDSV(), D3D11_CLEAR_DEPTH, 0.f, 0); D3D11_VIEWPORT vp = CD3D11_VIEWPORT(0.f, 0.f, (float)s_target_width, (float)s_target_height); D3D::context->RSSetViewports(1, &vp); @@ -415,7 +415,8 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data) // read the data from system memory D3D::context->Map(read_tex, 0, D3D11_MAP_READ, 0, &map); - float val = *(float*)map.pData; + // depth buffer is inverted in the d3d backend + float val = 1.0f - *(float*)map.pData; u32 ret = 0; if (bpmem.zcontrol.pixel_format == PEControl::RGB565_Z16) { @@ -522,8 +523,8 @@ void Renderer::SetViewport() Ht = (Y + Ht <= GetTargetHeight()) ? Ht : (GetTargetHeight() - Y); D3D11_VIEWPORT vp = CD3D11_VIEWPORT(X, Y, Wd, Ht, - MathUtil::Clamp<float>(xfmem.viewport.farZ - xfmem.viewport.zRange, 0.0f, 16777215.0f) / 16777216.0f, - MathUtil::Clamp<float>(xfmem.viewport.farZ, 0.0f, 16777215.0f) / 16777216.0f); + 1.0f - MathUtil::Clamp<float>(xfmem.viewport.farZ, 0.0f, 16777215.0f) / 16777216.0f, + 1.0f - MathUtil::Clamp<float>(xfmem.viewport.farZ - xfmem.viewport.zRange, 0.0f, 16777215.0f) / 16777216.0f); D3D::context->RSSetViewports(1, &vp); } @@ -548,7 +549,7 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaE // Color is passed in bgra mode so we need to convert it to rgba u32 rgbaColor = (color & 0xFF00FF00) | ((color >> 16) & 0xFF) | ((color << 16) & 0xFF0000); - D3D::drawClearQuad(rgbaColor, (z & 0xFFFFFF) / 16777216.0f); + D3D::drawClearQuad(rgbaColor, 1.0f - (z & 0xFFFFFF) / 16777216.0f); D3D::stateman->PopDepthState(); D3D::stateman->PopBlendState(); @@ -956,7 +957,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co g_framebuffer_manager = new FramebufferManager; float clear_col[4] = { 0.f, 0.f, 0.f, 1.f }; D3D::context->ClearRenderTargetView(FramebufferManager::GetEFBColorTexture()->GetRTV(), clear_col); - D3D::context->ClearDepthStencilView(FramebufferManager::GetEFBDepthTexture()->GetDSV(), D3D11_CLEAR_DEPTH, 1.f, 0); + D3D::context->ClearDepthStencilView(FramebufferManager::GetEFBDepthTexture()->GetDSV(), D3D11_CLEAR_DEPTH, 0.f, 0); } // begin next frame |
