One step closer to fixing D3D. Now textures are set properly.

Still, memory leak exists for some unknown reason (we don't allocate more pages and we release every texture)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2601 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
XTra.KrazzY
2009-03-07 18:05:29 +00:00
parent 7455361ed2
commit 7419475959
7 changed files with 97 additions and 61 deletions

View File

@ -31,6 +31,7 @@
#include "Utils.h"
#include "NativeVertexFormat.h"
#include "NativeVertexWriter.h"
#include "TextureCache.h"
#include "BPStructs.h"
#include "XFStructs.h"
@ -181,7 +182,54 @@ void Flush()
DVSTARTPROFILE();
if (collection != C_NOTHING)
{
ActivateTextures();
u32 usedtextures = 0;
for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages + 1; ++i) {
if (bpmem.tevorders[i/2].getEnable(i & 1))
usedtextures |= 1 << bpmem.tevorders[i/2].getTexMap(i & 1);
}
if (bpmem.genMode.numindstages > 0) {
for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages + 1; ++i) {
if (bpmem.tevind[i].IsActive() && bpmem.tevind[i].bt < bpmem.genMode.numindstages) {
usedtextures |= 1 << bpmem.tevindref.getTexMap(bpmem.tevind[i].bt);
}
}
}
u32 nonpow2tex = 0;
for (int i = 0; i < 8; i++)
{
// if (usedtextures & (1 << i)) {
{
FourTexUnits &tex = bpmem.tex[i >> 2];
TextureCache::TCacheEntry* tentry = TextureCache::Load(i,
(tex.texImage3[i&3].image_base/* & 0x1FFFFF*/) << 5,
tex.texImage0[i&3].width+1, tex.texImage0[i&3].height+1,
tex.texImage0[i&3].format, tex.texTlut[i&3].tmem_offset<<9,
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);
}
}
else
ERROR_LOG(VIDEO, "error loading texture");
}
}
PixelShaderManager::SetTexturesUsed(nonpow2tex);
int numVertices = indexGen.GetNumVerts();
if (numVertices)
{