From 7b76f7ae60c028ce695941e22fbbe0ec4f69c4b8 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 18 Sep 2014 08:00:41 -0700 Subject: [PATCH] d3d: Fix depal flipping and negative z. --- GPU/Directx9/TextureCacheDX9.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/GPU/Directx9/TextureCacheDX9.cpp b/GPU/Directx9/TextureCacheDX9.cpp index 9f020d297d..14ccd4be50 100644 --- a/GPU/Directx9/TextureCacheDX9.cpp +++ b/GPU/Directx9/TextureCacheDX9.cpp @@ -911,10 +911,10 @@ void TextureCacheDX9::SetTextureFramebuffer(TexCacheEntry *entry, VirtualFramebu fbo_bind_as_render_target(depalFBO); static const float pos[12 + 8] = { - -1, -1, -1, 0, 0, - 1, -1, -1, 1, 0, - 1, 1, -1, 1, 1, - -1, 1, -1, 0, 1, + -1, 1, 0, 0, 0, + 1, 1, 0, 1, 0, + 1, -1, 0, 1, 1, + -1, -1, 0, 0, 1, }; static const u16 indices[4] = { 0, 1, 3, 2 }; @@ -922,6 +922,7 @@ void TextureCacheDX9::SetTextureFramebuffer(TexCacheEntry *entry, VirtualFramebu pD3Ddevice->SetPixelShader(pshader); pD3Ddevice->SetVertexShader(depalShaderCache_->GetDepalettizeVertexShader()); + pD3Ddevice->SetVertexDeclaration(pFramebufferVertexDecl); pD3Ddevice->SetTexture(1, clutTexture); framebufferManager_->BindFramebufferColor(0, framebuffer, true); @@ -930,7 +931,6 @@ void TextureCacheDX9::SetTextureFramebuffer(TexCacheEntry *entry, VirtualFramebu pD3Ddevice->SetRenderState(D3DRS_STENCILENABLE, FALSE); pD3Ddevice->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE); pD3Ddevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); - pD3Ddevice->SetFVF(D3DFVF_XYZ | D3DFVF_TEX0); D3DVIEWPORT9 vp; vp.MinZ = 0; @@ -941,7 +941,10 @@ void TextureCacheDX9::SetTextureFramebuffer(TexCacheEntry *entry, VirtualFramebu vp.Height = framebuffer->renderHeight; pD3Ddevice->SetViewport(&vp); - pD3Ddevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLEFAN, 0, 4, 2, indices, D3DFMT_INDEX16, pos, (3 + 2) * sizeof(float)); + HRESULT hr = pD3Ddevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, pos, (3 + 2) * sizeof(float)); + if (FAILED(hr)) { + ERROR_LOG_REPORT(G3D, "Depal render failed: %08x", hr); + } fbo_bind_color_as_texture(depalFBO, 0); dxstate.Restore();