From c64b1ca5dc0615decb6166cbc0f4fffa65ad2429 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Wed, 2 Sep 2009 19:59:41 +0000 Subject: [PATCH] D3D: Fix nonpow2 textures (simply turn off the rect texture stuff since it's not necessary under D3D). some cleanup. Add a TODO (tip from Orphis) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4168 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/VideoCommon/Src/PixelShaderGen.cpp | 8 ++++---- Source/Core/VideoCommon/Src/PixelShaderGen.h | 2 +- Source/Core/VideoCommon/Src/TextureDecoder.cpp | 1 + .../Plugin_VideoDX9/Src/VertexManager.cpp | 17 ++--------------- .../Plugin_VideoDX9/Src/VertexShaderCache.cpp | 2 -- 5 files changed, 8 insertions(+), 22 deletions(-) diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index 0fc5e6edbf..285c18a772 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -28,7 +28,7 @@ // a unique identifier, basically containing all the bits. Yup, it's a lot .... // It would likely be a lot more efficient to build this incrementally as the attributes // are set... -void GetPixelShaderId(PIXELSHADERUID &uid, u32 s_texturemask, u32 dstAlphaEnable) +void GetPixelShaderId(PIXELSHADERUID &uid, u32 texturemask, u32 dstAlphaEnable) { u32 projtexcoords = 0; for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages + 1; i++) @@ -53,7 +53,7 @@ void GetPixelShaderId(PIXELSHADERUID &uid, u32 s_texturemask, u32 dstAlphaEnable for (int i = 0; i < 8; i += 2) ((u8*)&uid.values[1])[i / 2] = (bpmem.tevksel[i].hex & 0xf) | ((bpmem.tevksel[i + 1].hex & 0xf) << 4); - uid.values[2] = s_texturemask; + uid.values[2] = texturemask; uid.values[3] = (u32)bpmem.fog.c_proj_fsel.fsel | ((u32)bpmem.fog.c_proj_fsel.proj << 3); @@ -831,13 +831,13 @@ void SampleTexture(char *&p, const char *destination, const char *texcoords, con if (HLSL) WRITE(p, "%s=tex2D(samp%d,tempcoord.xy).%s;\n", destination, texmap, texswap); else - WRITE(p, "%s=texRECT(samp%d,tempcoord.xy).%s;\n", destination, texmap, texswap); + WRITE(p, "%s=texRECT(samp%d,tempcoord.xy).%s;\n", destination, texmap, texswap); } else { if (HLSL) WRITE(p, "%s=tex2D(samp%d,%s.xy).%s;\n", destination, texmap, texcoords, texswap); else - WRITE(p, "%s=texRECT(samp%d,%s.xy).%s;\n", destination, texmap, texcoords, texswap); + WRITE(p, "%s=texRECT(samp%d,%s.xy).%s;\n", destination, texmap, texcoords, texswap); } } else { diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.h b/Source/Core/VideoCommon/Src/PixelShaderGen.h index f5e414c520..18a8b3b404 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.h +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.h @@ -101,6 +101,6 @@ public: }; const char *GeneratePixelShader(u32 texture_mask, bool dstAlphaEnable, bool HLSL = false); -void GetPixelShaderId(PIXELSHADERUID &, u32 s_texturemask, u32 dstAlphaEnable); +void GetPixelShaderId(PIXELSHADERUID &, u32 texturemask, u32 dstAlphaEnable); #endif // GCOGL_PIXELSHADER_H diff --git a/Source/Core/VideoCommon/Src/TextureDecoder.cpp b/Source/Core/VideoCommon/Src/TextureDecoder.cpp index 578846cda1..660aac3399 100644 --- a/Source/Core/VideoCommon/Src/TextureDecoder.cpp +++ b/Source/Core/VideoCommon/Src/TextureDecoder.cpp @@ -336,6 +336,7 @@ void decodeDXTBlock(u32 *dst, const DXTBlock *src, int pitch) { colors[0] = makecol(red1, green1, blue1, 255); colors[1] = makecol(red2, green2, blue2, 255); + // TODO: use 3/8ths and 5/8ths instead of 3rd and 2/3rds. most hw works like that. colors[2] = makecol(red1 + (red2 - red1) / 3, green1 + (green2 - green1) / 3, blue1 + (blue2 - blue1) / 3, 255); colors[3] = makecol(red2 + (red1 - red2) / 3, green2 + (green1 - green2) / 3, blue2 + (blue1 - blue2) / 3, 255); } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp b/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp index e261725c91..1335f19dba 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp @@ -215,26 +215,13 @@ void Flush() tex.texTlut[i&3].tlut_format); if (tentry) { - // texture loaded fine, set dims for pixel shader - if (tentry->isNonPow2) - { - PixelShaderManager::SetTexDims(i, tentry->w, tentry->h, tentry->mode.wrap_s, tentry->mode.wrap_t); - nonpow2tex |= 1 << i; - if (tentry->mode.wrap_s > 0) nonpow2tex |= 1 << (8 + i); - if (tentry->mode.wrap_t > 0) nonpow2tex |= 1 << (16 + i); - } - // if texture is power of two, set to ones (since don't need scaling) - // (the above seems to have changed - we set the width and height here too. - else - { - PixelShaderManager::SetTexDims(i, tentry->w, tentry->h, 0, 0); - } + PixelShaderManager::SetTexDims(i, tentry->w, tentry->h, 0, 0); } else ERROR_LOG(VIDEO, "error loading texture"); } } - PixelShaderManager::SetTexturesUsed(nonpow2tex); + PixelShaderManager::SetTexturesUsed(0); int numVertices = indexGen.GetNumVerts(); if (numVertices) diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp b/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp index d92907fe15..b67a7fa9ad 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp @@ -109,8 +109,6 @@ void VertexShaderCache::SetShader(u32 components) { PanicAlert("Failed to compile Vertex Shader:\n\n%s", code); } - - D3D::dev->SetFVF(NULL); } void VertexShaderCache::Cleanup()