mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
softgpu: Fix some stencil testing related bugs.
This commit is contained in:
parent
67f95d38e5
commit
d0c05b78d6
1 changed files with 19 additions and 6 deletions
|
@ -261,14 +261,25 @@ static inline void SetPixelDepth(int x, int y, u16 value)
|
||||||
|
|
||||||
static inline u8 GetPixelStencil(int x, int y)
|
static inline u8 GetPixelStencil(int x, int y)
|
||||||
{
|
{
|
||||||
// TODO: Fix for other pixel formats ?
|
if (gstate.FrameBufFormat() == GE_FORMAT_565) {
|
||||||
return (((*(u32*)&fb[4*x + 4*y*gstate.FrameBufStride()]) & 0x80000000) != 0) ? 0xFF : 0;
|
// TODO: Should we return 0xFF instead here?
|
||||||
|
return 0;
|
||||||
|
} else if (gstate.FrameBufFormat() != GE_FORMAT_8888) {
|
||||||
|
return (((*(u16*)&fb[2*x + 2*y*gstate.FrameBufStride()]) & 0x8000) != 0) ? 0xFF : 0;
|
||||||
|
} else {
|
||||||
|
return (((*(u32*)&fb[4*x + 4*y*gstate.FrameBufStride()]) & 0x80000000) != 0) ? 0xFF : 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void SetPixelStencil(int x, int y, u8 value)
|
static inline void SetPixelStencil(int x, int y, u8 value)
|
||||||
{
|
{
|
||||||
// TODO: Fix for other pixel formats ?
|
if (gstate.FrameBufFormat() == GE_FORMAT_565) {
|
||||||
*(u32*)&fb[4*x + 4*y*gstate.FrameBufStride()] = (*(u32*)&fb[4*x + 4*y*gstate.FrameBufStride()] & ~0x80000000) | ((value&0x80)<<24);
|
// Do nothing
|
||||||
|
} else if (gstate.FrameBufFormat() != GE_FORMAT_8888) {
|
||||||
|
*(u16*)&fb[2*x + 2*y*gstate.FrameBufStride()] = (*(u16*)&fb[2*x + 2*y*gstate.FrameBufStride()] & ~0x8000) | ((value&0x80)<<8);
|
||||||
|
} else {
|
||||||
|
*(u32*)&fb[4*x + 4*y*gstate.FrameBufStride()] = (*(u32*)&fb[4*x + 4*y*gstate.FrameBufStride()] & ~0x80000000) | ((value&0x80)<<24);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool DepthTestPassed(int x, int y, u16 z)
|
static inline bool DepthTestPassed(int x, int y, u16 z)
|
||||||
|
@ -374,12 +385,14 @@ static inline void ApplyStencilOp(int op, int x, int y)
|
||||||
|
|
||||||
case GE_STENCILOP_INCR:
|
case GE_STENCILOP_INCR:
|
||||||
// TODO: Does this overflow?
|
// TODO: Does this overflow?
|
||||||
SetPixelStencil(x, y, old_stencil+1);
|
if (old_stencil != 0xFF)
|
||||||
|
SetPixelStencil(x, y, old_stencil+1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GE_STENCILOP_DECR:
|
case GE_STENCILOP_DECR:
|
||||||
// TODO: Does this underflow?
|
// TODO: Does this underflow?
|
||||||
SetPixelStencil(x, y, old_stencil-1);
|
if (old_stencil != 0)
|
||||||
|
SetPixelStencil(x, y, old_stencil-1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue