diff --git a/Source/Core/Common/Src/LinearDiskCache.h b/Source/Core/Common/Src/LinearDiskCache.h index 50181f2b5a..252713d2c3 100644 --- a/Source/Core/Common/Src/LinearDiskCache.h +++ b/Source/Core/Common/Src/LinearDiskCache.h @@ -26,7 +26,7 @@ // shader cache for every revision, graphics-related or not, which is simply annoying. enum { - LINEAR_DISKCACHE_VER = 6463 + LINEAR_DISKCACHE_VER = 6473 }; // On disk format: diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index 4860fc10d8..44964acc61 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -540,13 +540,22 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType for (int i = 0; i < numTexgen; ++i) WRITE(p, ",\n in float3 uv%d : TEXCOORD%d", i, i); WRITE(p, ",\n in float4 clipPos : TEXCOORD%d", numTexgen); - WRITE(p, ",\n in float4 Normal : TEXCOORD%d", numTexgen + 1); + if(g_ActiveConfig.bEnablePixelLigting) + WRITE(p, ",\n in float4 Normal : TEXCOORD%d", numTexgen + 1); } else { // wpos is in w of first 4 texcoords - for (int i = 0; i < 8; ++i) - WRITE(p, ",\n in float4 uv%d : TEXCOORD%d", i, i); + if(g_ActiveConfig.bEnablePixelLigting) + { + for (int i = 0; i < 8; ++i) + WRITE(p, ",\n in float4 uv%d : TEXCOORD%d", i, i); + } + else + { + for (int i = 0; i < xfregs.numTexGens; ++i) + WRITE(p, ",\n in float%d uv%d : TEXCOORD%d", i < 4 ? 4 : 3 , i, i); + } } WRITE(p, " ) {\n"); diff --git a/Source/Core/VideoCommon/Src/TextureCacheBase.cpp b/Source/Core/VideoCommon/Src/TextureCacheBase.cpp index 5cd164866d..a22571bf1a 100644 --- a/Source/Core/VideoCommon/Src/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/Src/TextureCacheBase.cpp @@ -356,7 +356,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage, entry->hash = *(u32*)ptr = (u32)(((double)rand() / RAND_MAX) * 0xFFFFFFFF); // load texture - entry->Load(width, height, expandedWidth, 0); + entry->Load(width, height, expandedWidth, 0, (texLevels == 0)); // load mips if (texLevels > 1 && pcfmt != PC_TEX_FMT_NONE) diff --git a/Source/Core/VideoCommon/Src/TextureCacheBase.h b/Source/Core/VideoCommon/Src/TextureCacheBase.h index 8ba959342e..cea7c258b5 100644 --- a/Source/Core/VideoCommon/Src/TextureCacheBase.h +++ b/Source/Core/VideoCommon/Src/TextureCacheBase.h @@ -61,7 +61,7 @@ public: virtual bool Save(const char filename[]) = 0; virtual void Load(unsigned int width, unsigned int height, - unsigned int expanded_width, unsigned int level) = 0; + unsigned int expanded_width, unsigned int level, bool autogen_mips = false) = 0; virtual void FromRenderTarget(bool bFromZBuffer, bool bScaleByHalf, unsigned int cbufid, const float *colmat, const EFBRectangle &source_rect, bool bIsIntensityFmt, u32 copyfmt) = 0; diff --git a/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.cpp index dafdbec132..9411ecec7c 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.cpp @@ -61,12 +61,12 @@ bool TextureCache::TCacheEntry::Save(const char filename[]) } void TextureCache::TCacheEntry::Load(unsigned int width, unsigned int height, - unsigned int expanded_width, unsigned int level) + unsigned int expanded_width, unsigned int level, bool autogen_mips) { - // TODO: remove hax - if (level != 0) return; - D3D::ReplaceRGBATexture2D(texture->GetTex(), TextureCache::temp, width, height, expanded_width, level, usage); + + if (autogen_mips) + PD3DX11FilterTexture(D3D::context, texture->GetTex(), 0, D3DX11_DEFAULT); } TextureCache::TCacheEntryBase* TextureCache::CreateTexture(unsigned int width, @@ -77,18 +77,15 @@ TextureCache::TCacheEntryBase* TextureCache::CreateTexture(unsigned int width, D3D11_CPU_ACCESS_FLAG cpu_access = (D3D11_CPU_ACCESS_FLAG)0; D3D11_SUBRESOURCE_DATA srdata, *data = NULL; - // TODO: remove hax - tex_levels = 1; - - if (1 == tex_levels) + if (tex_levels == 1) { usage = D3D11_USAGE_DYNAMIC; cpu_access = D3D11_CPU_ACCESS_WRITE; srdata.pSysMem = TextureCache::temp; srdata.SysMemPitch = 4 * expanded_width; - // testing - //data = &srdata; + + data = &srdata; } const D3D11_TEXTURE2D_DESC texdesc = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_R8G8B8A8_UNORM, @@ -107,9 +104,6 @@ TextureCache::TCacheEntryBase* TextureCache::CreateTexture(unsigned int width, SAFE_RELEASE(pTexture); - if (0 == tex_levels) - PD3DX11FilterTexture(D3D::context, entry->texture->GetTex(), 0, D3DX11_DEFAULT); - return entry; } diff --git a/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.h b/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.h index 3980485a5f..ab0fa48083 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.h +++ b/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.h @@ -46,7 +46,7 @@ private: ~TCacheEntry(); void Load(unsigned int width, unsigned int height, - unsigned int expanded_width, unsigned int levels); + unsigned int expanded_width, unsigned int levels, bool autogen_mips = false); void FromRenderTarget(bool bFromZBuffer, bool bScaleByHalf, unsigned int cbufid, const float* colmat, const EFBRectangle &source_rect, diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DTexture.cpp b/Source/Plugins/Plugin_VideoDX9/Src/D3DTexture.cpp index 4ddc7950fa..06f28a05dd 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DTexture.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DTexture.cpp @@ -36,8 +36,6 @@ LPDIRECT3DTEXTURE9 CreateTexture2D(const u8* buffer, const int width, const int } HRESULT hr; - // TODO(ector): Allow mipmaps for non-pow textures on newer cards? - // TODO(ector): Use the game-specified mipmaps? if (levels > 0) hr = dev->CreateTexture(width, height, levels, 0, fmt, D3DPOOL_MANAGED, &pTexture, NULL); else diff --git a/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp index 5c009a2d8c..a70476a0d8 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp @@ -64,9 +64,10 @@ bool TextureCache::TCacheEntry::Save(const char filename[]) } void TextureCache::TCacheEntry::Load(unsigned int width, unsigned int height, - unsigned int expanded_width, unsigned int level) + unsigned int expanded_width, unsigned int level, bool autogen_mips) { D3D::ReplaceTexture2D(texture, temp, width, height, expanded_width, d3d_fmt, swap_r_b, level); + // D3D9 will automatically generate mip maps if necessary } void TextureCache::TCacheEntry::FromRenderTarget(bool bFromZBuffer, bool bScaleByHalf, diff --git a/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.h b/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.h index 23b6382f1b..ef8cacfb9d 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.h @@ -44,7 +44,7 @@ private: ~TCacheEntry(); void Load(unsigned int width, unsigned int height, - unsigned int expanded_width, unsigned int levels); + unsigned int expanded_width, unsigned int levels, bool autogen_mips = false); void FromRenderTarget(bool bFromZBuffer, bool bScaleByHalf, unsigned int cbufid, const float* colmat, const EFBRectangle &source_rect, diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp index c8013ef027..001c67b785 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp @@ -199,7 +199,7 @@ TextureCache::TCacheEntryBase* TextureCache::CreateTexture(unsigned int width, } void TextureCache::TCacheEntry::Load(unsigned int width, unsigned int height, - unsigned int expanded_width, unsigned int level) + unsigned int expanded_width, unsigned int level, bool autogen_mips) { //glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture); @@ -210,7 +210,7 @@ void TextureCache::TCacheEntry::Load(unsigned int width, unsigned int height, if (expanded_width != width) glPixelStorei(GL_UNPACK_ROW_LENGTH, expanded_width); - if (bHaveMipMaps && 0 == level) + if (bHaveMipMaps && autogen_mips) { glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); glTexImage2D(GL_TEXTURE_2D, level, gl_iformat, width, height, 0, gl_format, gl_type, temp); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.h b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.h index 7b37cc88f1..a842d1f1ec 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.h @@ -54,7 +54,7 @@ private: ~TCacheEntry(); void Load(unsigned int width, unsigned int height, - unsigned int expanded_width, unsigned int level); + unsigned int expanded_width, unsigned int level, bool autogen_mips = false); void FromRenderTarget(bool bFromZBuffer, bool bScaleByHalf, unsigned int cbufid, const float colmat[], const EFBRectangle &source_rect,