From 1dfecbf2b8cbb7eb99a5e357cb41ec2306fadbef Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 17 Sep 2014 23:49:50 -0700 Subject: [PATCH] d3d: Actually upload the clut texture. --- CMakeLists.txt | 3 +-- GPU/Common/DepalettizeShaderCommon.cpp | 2 -- GPU/Directx9/DepalettizeShaderDX9.cpp | 17 ++++++++++++++++- GPU/Directx9/FramebufferDX9.h | 2 +- GPU/Directx9/TextureCacheDX9.cpp | 10 +++++----- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 457414f538..51453db4fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1378,9 +1378,8 @@ if(ARMV7) set(GPU_NEON GPU/Common/TextureDecoderNEON.cpp) endif() add_library(GPU OBJECT - GPU/Common/DepalettizeShaderCommon.h GPU/Common/DepalettizeShaderCommon.cpp - GPU/Common/FramebufferCommon.h + GPU/Common/DepalettizeShaderCommon.h GPU/Common/FramebufferCommon.cpp GPU/Common/FramebufferCommon.h GPU/Common/GPUDebugInterface.h diff --git a/GPU/Common/DepalettizeShaderCommon.cpp b/GPU/Common/DepalettizeShaderCommon.cpp index cd670c61e3..b436307957 100644 --- a/GPU/Common/DepalettizeShaderCommon.cpp +++ b/GPU/Common/DepalettizeShaderCommon.cpp @@ -15,8 +15,6 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#pragma once - #include #include "Common/Log.h" diff --git a/GPU/Directx9/DepalettizeShaderDX9.cpp b/GPU/Directx9/DepalettizeShaderDX9.cpp index fcf156ae6f..4511391fef 100644 --- a/GPU/Directx9/DepalettizeShaderDX9.cpp +++ b/GPU/Directx9/DepalettizeShaderDX9.cpp @@ -93,10 +93,25 @@ LPDIRECT3DTEXTURE9 DepalShaderCacheDX9::GetClutTexture(const u32 clutID, u32 *ra HRESULT hr = pD3Ddevice->CreateTexture(texturePixels, 1, 1, usage, (D3DFORMAT)D3DFMT(dstFmt), pool, &tex->texture, NULL); if (FAILED(hr)) { - INFO_LOG(G3D, "Failed to create D3D texture for depal"); + ERROR_LOG(G3D, "Failed to create D3D texture for depal"); return nullptr; } + D3DLOCKED_RECT rect; + hr = tex->texture->LockRect(0, &rect, NULL, 0); + if (FAILED(hr)) { + ERROR_LOG(G3D, "Failed to lock D3D texture for depal"); + return nullptr; + } + // Regardless of format, the CLUT should always be 1024 bytes. + memcpy(rect.pBits, rawClut, 1024); + tex->texture->UnlockRect(0); + + pD3Ddevice->SetSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP); + pD3Ddevice->SetSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP); + pD3Ddevice->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_POINT); + pD3Ddevice->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_POINT); + tex->lastFrame = gpuStats.numFlips; texCache_[realClutID] = tex; return tex->texture; diff --git a/GPU/Directx9/FramebufferDX9.h b/GPU/Directx9/FramebufferDX9.h index 888f4af97d..c27a14987d 100644 --- a/GPU/Directx9/FramebufferDX9.h +++ b/GPU/Directx9/FramebufferDX9.h @@ -73,7 +73,7 @@ public: void BlitFramebufferDepth(VirtualFramebuffer *src, VirtualFramebuffer *dst); - void BindFramebufferColor(int stage, VirtualFramebuffer *framebuffer, bool skipCopy); + void BindFramebufferColor(int stage, VirtualFramebuffer *framebuffer, bool skipCopy = false); virtual void ReadFramebufferToMemory(VirtualFramebuffer *vfb, bool sync, int x, int y, int w, int h) override; diff --git a/GPU/Directx9/TextureCacheDX9.cpp b/GPU/Directx9/TextureCacheDX9.cpp index a763caf63f..9f020d297d 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, -1, 0, 0, + 1, -1, -1, 1, 0, + 1, 1, -1, 1, 1, + -1, 1, -1, 0, 1, }; static const u16 indices[4] = { 0, 1, 3, 2 }; @@ -957,7 +957,7 @@ void TextureCacheDX9::SetTextureFramebuffer(TexCacheEntry *entry, VirtualFramebu gstate_c.textureSimpleAlpha = alphaStatus == TexCacheEntry::STATUS_ALPHA_SIMPLE; } else { entry->status &= ~TexCacheEntry::STATUS_DEPALETTIZE; - framebufferManager_->BindFramebufferColor(0, framebuffer, false); + framebufferManager_->BindFramebufferColor(0, framebuffer); gstate_c.textureFullAlpha = gstate.getTextureFormat() == GE_TFMT_5650; gstate_c.textureSimpleAlpha = gstate_c.textureFullAlpha;