- re-enable the 'suspected invalid' logic in the texture cache after trying to fix what might have been broken in it, which was a failure to invalidate the cache when tex palettes changed.

- fix a bug which breaks any texture that spans a texture bank. this was only tested for 4bpp textures but applies to all but 4x4 and 16bpp
- I believe we were sending the 3d vblank end signal on the wrong scanline
This commit is contained in:
zeromus 2009-01-02 06:32:09 +00:00
parent 08e8a91daf
commit c0e351339f
4 changed files with 33 additions and 37 deletions

View File

@ -3,6 +3,8 @@ Graphics:
bug: Fix some errors in rendering 512 tall BG [zeromus,CrazyMax] (still not fully resolved)
bug: 3d compositing integrated into GPU engine (more precision and speed in cases where no compositing needed) [luigi__]
bug: Add optional fragment shading pipeline (more precision) [luigi__]
bug: fix texture mapping across texture banks [zeromus]
enh: dont memcmp for texcache validity when the texture banks arent unmapping [zeromus]
0.8 -> 0.9
There have been so many changes that this list can hardly be considered complete.

View File

@ -648,12 +648,14 @@ static inline void MMU_VRAMmapControl(u8 block, u8 VRAMBankCnt)
ARM9Mem.texPalSlot[1] = LCD_addr+0x2000;
ARM9Mem.texPalSlot[2] = LCD_addr+0x4000;
ARM9Mem.texPalSlot[3] = LCD_addr+0x6000;
gpu3D->NDS_3D_VramReconfigureSignal();
break;
case 5: // F
case 6: // G
{
u8 tmp_slot = ((VRAMBankCnt >> 3) & 0x01) + (((VRAMBankCnt >> 4) & 0x01)*4);
ARM9Mem.texPalSlot[tmp_slot] = LCD_addr;
gpu3D->NDS_3D_VramReconfigureSignal();
}
break;
case 9: // I Engine B, OBJ

View File

@ -1167,7 +1167,7 @@ u32 NDS_exec(s32 nb)
if(MMU.DMAStartTime[1][3] == 1)
MMU_doDMA(1, 3);
}
else if(nds.VCount==214) {
else if(nds.VCount==215) {
gfx3d_VBlankEndSignal();
}
else if(nds.VCount==263)

View File

@ -500,7 +500,7 @@ static void OGLClose()
ENDGL();
}
//zero 9/7/08 - changed *adr= to adr= while changing from c++. was that a bug?
#define CHECKSLOT txt_slot_current_size--;\
if (txt_slot_current_size<=0)\
{\
@ -615,7 +615,7 @@ static void setTexture(unsigned int format, unsigned int texpal)
!memcmp(texcache[i].palette, pal, texcache[i].palSize) )
{
//TODO - this doesnt correctly span bank boundaries. in fact, it seems quite dangerous.
if (!memcmp(adr, texcache[i].texture, std::min((size_t)imageSize,sizeof(texcache[i].texture))) )
if (!texcache[i].suspectedInvalid || !memcmp(adr, texcache[i].texture, std::min((size_t)imageSize,sizeof(texcache[i].texture))) )
{
texcache[i].suspectedInvalid = false;
texcache_count=i;
@ -630,22 +630,6 @@ static void setTexture(unsigned int format, unsigned int texpal)
return;
}
}
#if 0
if (!texcache[i].suspectedInvalid)
{
texcache[i].suspectedInvalid = false;
texcache_count=i;
if(lastTexture == -1 || (int)i != lastTexture)
{
lastTexture = i;
glBindTexture(GL_TEXTURE_2D,texcache[i].id);
glMatrixMode (GL_TEXTURE);
glLoadIdentity ();
glScaled (texcache[i].invSizeX, texcache[i].invSizeY, 1.0f);
}
return;
}
#endif
}
i++;
if (i>MAX_TEXTURE)
@ -702,9 +686,10 @@ static void setTexture(unsigned int format, unsigned int texpal)
{
for(x = 0; x < imageSize; x++, dst += 4)
{
u16 c = pal[adr[x]&31];
u8 alpha = adr[x]>>5;
u16 c = pal[*adr&31];
u8 alpha = *adr>>5;
*dwdst++ = RGB15TO32(c,material_3bit_to_8bit[alpha]);
adr++;
CHECKSLOT;
}
break;
@ -713,33 +698,35 @@ static void setTexture(unsigned int format, unsigned int texpal)
{
for(x = 0; x < imageSize>>2; ++x)
{
unsigned short c = pal[(adr[x])&0x3];
unsigned short c = pal[(*adr)&0x3];
dst[0] = ((c & 0x1F)<<3);
dst[1] = ((c & 0x3E0)>>2);
dst[2] = ((c & 0x7C00)>>7);
dst[3] = ((adr[x]&3) == 0) ? palZeroTransparent : 255;//(c>>15)*255;
dst[3] = ((*adr&3) == 0) ? palZeroTransparent : 255;//(c>>15)*255;
dst += 4;
c = pal[((adr[x])>>2)&0x3];
c = pal[((*adr)>>2)&0x3];
dst[0] = ((c & 0x1F)<<3);
dst[1] = ((c & 0x3E0)>>2);
dst[2] = ((c & 0x7C00)>>7);
dst[3] = (((adr[x]>>2)&3) == 0) ? palZeroTransparent : 255;//(c>>15)*255;
dst[3] = (((*adr>>2)&3) == 0) ? palZeroTransparent : 255;//(c>>15)*255;
dst += 4;
c = pal[((adr[x])>>4)&0x3];
c = pal[((*adr)>>4)&0x3];
dst[0] = ((c & 0x1F)<<3);
dst[1] = ((c & 0x3E0)>>2);
dst[2] = ((c & 0x7C00)>>7);
dst[3] = (((adr[x]>>4)&3) == 0) ? palZeroTransparent : 255;//(c>>15)*255;
dst[3] = (((*adr>>4)&3) == 0) ? palZeroTransparent : 255;//(c>>15)*255;
dst += 4;
c = pal[(adr[x])>>6];
c = pal[(*adr)>>6];
dst[0] = ((c & 0x1F)<<3);
dst[1] = ((c & 0x3E0)>>2);
dst[2] = ((c & 0x7C00)>>7);
dst[3] = (((adr[x]>>6)&3) == 0) ? palZeroTransparent : 255;//(c>>15)*255;
dst[3] = (((*adr>>6)&3) == 0) ? palZeroTransparent : 255;//(c>>15)*255;
dst += 4;
adr++;
CHECKSLOT;
}
break;
@ -748,19 +735,22 @@ static void setTexture(unsigned int format, unsigned int texpal)
{
for(x = 0; x < (imageSize>>1); x++)
{
unsigned short c = pal[adr[x]&0xF];
unsigned short c = pal[*adr&0xF];
dst[0] = ((c & 0x1F)<<3);
dst[1] = ((c & 0x3E0)>>2);
dst[2] = ((c & 0x7C00)>>7);
dst[3] = (((adr[x])&0xF) == 0) ? palZeroTransparent : 255;//(c>>15)*255;
dst[3] = (((*adr)&0xF) == 0) ? palZeroTransparent : 255;//(c>>15)*255;
dst += 4;
c = pal[((adr[x])>>4)];
c = pal[((*adr)>>4)];
dst[0] = ((c & 0x1F)<<3);
dst[1] = ((c & 0x3E0)>>2);
dst[2] = ((c & 0x7C00)>>7);
dst[3] = (((adr[x]>>4)&0xF) == 0) ? palZeroTransparent : 255;//(c>>15)*255;
dst[3] = (((*adr>>4)&0xF) == 0) ? palZeroTransparent : 255;//(c>>15)*255;
dst += 4;
adr++;
CHECKSLOT;
}
break;
@ -769,8 +759,9 @@ static void setTexture(unsigned int format, unsigned int texpal)
{
for(x = 0; x < imageSize; ++x)
{
u16 c = pal[adr[x]];
*dwdst++ = RGB15TO32(c,(adr[x] == 0) ? palZeroTransparent : 255);
u16 c = pal[*adr];
*dwdst++ = RGB15TO32(c,(*adr == 0) ? palZeroTransparent : 255);
adr++;
CHECKSLOT;
}
}
@ -883,9 +874,10 @@ static void setTexture(unsigned int format, unsigned int texpal)
{
for(x = 0; x < imageSize; x++)
{
u16 c = pal[adr[x]&0x07];
u8 alpha = (adr[x]>>3);
u16 c = pal[*adr&0x07];
u8 alpha = (*adr>>3);
*dwdst++ = RGB15TO32(c,material_5bit_to_8bit[alpha]);
adr++;
CHECKSLOT;
}
break;