mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 13:27:45 -07:00
Fix Z Read precision on DirectX9 plugin, this fixes some stuff in Killer7 such as the one hit kill, and the bullets effect.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6805 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
83eed62449
commit
795a22559b
@ -80,12 +80,8 @@ FramebufferManager::FramebufferManager()
|
||||
|
||||
// Render buffer for AccessEFB (depth data)
|
||||
D3DFORMAT DepthTexFormats[2];
|
||||
// TODO: why is D3DFMT_D24X8 singled out here? why not D3DFMT_D24X4S4/D24S8/D24FS8/D32/D16/D15S1 too, or none of them?
|
||||
if (s_efb.depth_surface_Format == FOURCC_RAWZ || s_efb.depth_surface_Format == D3DFMT_D24X8)
|
||||
DepthTexFormats[0] = D3DFMT_A8R8G8B8;
|
||||
else
|
||||
DepthTexFormats[0] = D3DFMT_R32F;
|
||||
|
||||
DepthTexFormats[0] = D3DFMT_D24X8;
|
||||
// This is expected to work on all hardware
|
||||
DepthTexFormats[1] = D3DFMT_A8R8G8B8;
|
||||
|
||||
for (int i = 0; i < 2; ++i)
|
||||
|
@ -638,38 +638,14 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data)
|
||||
// EFB data successfully retrieved, now get the pixel data
|
||||
D3DLOCKED_RECT drect;
|
||||
pSystemBuf->LockRect(&drect, &RectToLock, D3DLOCK_READONLY);
|
||||
|
||||
float val = 0.0f;
|
||||
u32 z = 0;
|
||||
|
||||
switch (FramebufferManager::GetEFBDepthReadSurfaceFormat())
|
||||
{
|
||||
case D3DFMT_R32F:
|
||||
val = ((float*)drect.pBits)[6];
|
||||
break;
|
||||
default:
|
||||
float ffrac = 1.0f/255.0f;
|
||||
z = ((u32*)drect.pBits)[6];
|
||||
val = ((float)((z>>16) & 0xFF)) * ffrac;
|
||||
ffrac*= 1 / 255.0f;
|
||||
val += ((float)((z>>8) & 0xFF)) * ffrac;
|
||||
ffrac*= 1 / 255.0f;
|
||||
val += ((float)(z & 0xFF)) * ffrac;
|
||||
break;
|
||||
};
|
||||
|
||||
|
||||
u32 z = ((u32*)drect.pBits)[6]; // 24 bit depth value
|
||||
pSystemBuf->UnlockRect();
|
||||
// TODO: in RE0 this value is often off by one, which causes lighting to disappear
|
||||
if(bpmem.zcontrol.pixel_format == PIXELFMT_RGB565_Z16)
|
||||
{
|
||||
// if Z is in 16 bit format you must return a 16 bit integer
|
||||
z = ((u32)(val * 0xffff));
|
||||
}
|
||||
else
|
||||
{
|
||||
z = ((u32)(val * 0xffffff));
|
||||
|
||||
// if Z is in 16 bit format you must return a 16 bit integer
|
||||
if(bpmem.zcontrol.pixel_format == PIXELFMT_RGB565_Z16) {
|
||||
z >>= 8;
|
||||
}
|
||||
|
||||
return z;
|
||||
}
|
||||
else if(type == PEEK_COLOR)
|
||||
@ -683,15 +659,16 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data)
|
||||
RectToLock.left = 0;
|
||||
RectToLock.right = 1;
|
||||
RectToLock.top = 0;
|
||||
|
||||
D3DLOCKED_RECT drect;
|
||||
pSystemBuf->LockRect(&drect, &RectToLock, D3DLOCK_READONLY);
|
||||
|
||||
u32 ret = ((u32*)drect.pBits)[0];
|
||||
pSystemBuf->UnlockRect();
|
||||
|
||||
// check what to do with the alpha channel (GX_PokeAlphaRead)
|
||||
PixelEngine::UPEAlphaReadReg alpha_read_mode;
|
||||
PixelEngine::Read16((u16&)alpha_read_mode, PE_ALPHAREAD);
|
||||
|
||||
if (bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24)
|
||||
{
|
||||
ret = RGBA8ToRGBA6ToRGBA8(ret);
|
||||
@ -704,6 +681,7 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data)
|
||||
{
|
||||
ret |= 0xFF000000;
|
||||
}
|
||||
|
||||
if(alpha_read_mode.ReadMode == 2) return ret; // GX_READ_NONE
|
||||
else if(alpha_read_mode.ReadMode == 1) return (ret | 0xFF000000); // GX_READ_FF
|
||||
else return (ret & 0x00FFFFFF); // GX_READ_00
|
||||
|
Loading…
Reference in New Issue
Block a user