more work on peek_Z this fix sms and zww sun flare
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4355 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
025d68ba11
commit
0170e61bfc
|
@ -222,31 +222,19 @@ void ClearScreen(const BPCmd &bp, const EFBRectangle &rc)
|
||||||
|
|
||||||
// it seems that the GC is able to alpha blend on color-fill
|
// it seems that the GC is able to alpha blend on color-fill
|
||||||
// we cant do that so if alpha is != 255 we skip it
|
// we cant do that so if alpha is != 255 we skip it
|
||||||
|
|
||||||
VertexShaderManager::SetViewportChanged();
|
VertexShaderManager::SetViewportChanged();
|
||||||
|
|
||||||
// Since clear operations use the source rectangle, we have to do
|
bool colorEnable = bpmem.blendmode.colorupdate;
|
||||||
// regular renders
|
bool alphaEnable = (bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24 && bpmem.blendmode.alphaupdate);
|
||||||
DWORD clearflags = 0;
|
bool zEnable = bpmem.zmode.updateenable;
|
||||||
D3DCOLOR col = 0;
|
|
||||||
float clearZ = 0;
|
|
||||||
|
|
||||||
if (bpmem.blendmode.colorupdate || bpmem.blendmode.alphaupdate)
|
if (colorEnable || alphaEnable || zEnable)
|
||||||
{
|
{
|
||||||
col = (bpmem.clearcolorAR << 16) | bpmem.clearcolorGB;
|
u32 color = (bpmem.clearcolorAR << 16) | bpmem.clearcolorGB;
|
||||||
clearflags |= D3DCLEAR_TARGET; // set to break animal crossing :p ??
|
u32 z = bpmem.clearZValue;
|
||||||
}
|
|
||||||
|
|
||||||
// clear z-buffer
|
Renderer::ClearScreen(rc, colorEnable, alphaEnable, zEnable, color, z);
|
||||||
if (bpmem.zmode.updateenable)
|
|
||||||
{
|
|
||||||
clearZ = (float)(bpmem.clearZValue & 0xFFFFFF) / float(0xFFFFFF);
|
|
||||||
if (clearZ > 1.0f) clearZ = 1.0f;
|
|
||||||
if (clearZ < 0.0f) clearZ = 0.0f;
|
|
||||||
clearflags |= D3DCLEAR_ZBUFFER;//removed stencil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D::dev->Clear(0, NULL, clearflags, col, clearZ, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RestoreRenderState(const BPCmd &bp)
|
void RestoreRenderState(const BPCmd &bp)
|
||||||
|
|
|
@ -148,7 +148,7 @@ bool Renderer::Init()
|
||||||
D3D::dev->SetRenderTarget(0, FBManager::GetEFBColorRTSurface());
|
D3D::dev->SetRenderTarget(0, FBManager::GetEFBColorRTSurface());
|
||||||
D3D::dev->SetDepthStencilSurface(FBManager::GetEFBDepthRTSurface());
|
D3D::dev->SetDepthStencilSurface(FBManager::GetEFBDepthRTSurface());
|
||||||
|
|
||||||
D3D::dev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER , 0x0, 1.0f, 0);//| D3DCLEAR_STENCIL
|
D3D::dev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x0, 1.0f, 0);
|
||||||
|
|
||||||
D3D::BeginFrame();
|
D3D::BeginFrame();
|
||||||
return true;
|
return true;
|
||||||
|
@ -493,12 +493,12 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
|
||||||
pZBuffer->UnlockRect();
|
pZBuffer->UnlockRect();
|
||||||
|
|
||||||
// [0.0, 1.0] ==> [0, 0xFFFFFFFF]
|
// [0.0, 1.0] ==> [0, 0xFFFFFFFF]
|
||||||
z = val * 0xFFFFFFFF;
|
z =((u32)(val * 0xffffff));// 0xFFFFFFFF;
|
||||||
|
|
||||||
// Scale the 32-bit value returned by glReadPixels to a 24-bit
|
// Scale the 32-bit value returned by glReadPixels to a 24-bit
|
||||||
// value (GC uses a 24-bit Z-buffer).
|
// value (GC uses a 24-bit Z-buffer).
|
||||||
// TODO: in RE0 this value is often off by one, which causes lighting to disappear
|
// TODO: in RE0 this value is often off by one, which causes lighting to disappear
|
||||||
return z >> 8;
|
return z;//z >> 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
case POKE_Z:
|
case POKE_Z:
|
||||||
|
@ -575,6 +575,46 @@ void UpdateViewport()
|
||||||
D3D::dev->SetViewport(&vp);
|
D3D::dev->SetViewport(&vp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z)
|
||||||
|
{
|
||||||
|
// Update the view port for clearing the picture
|
||||||
|
D3DVIEWPORT9 vp;
|
||||||
|
vp.X = 0;
|
||||||
|
vp.Y = 0;
|
||||||
|
vp.Width = Renderer::GetTargetWidth();
|
||||||
|
vp.Height = Renderer::GetTargetHeight();
|
||||||
|
vp.MinZ = 0.0;
|
||||||
|
vp.MaxZ = 1.0;
|
||||||
|
D3D::dev->SetViewport(&vp);
|
||||||
|
|
||||||
|
TargetRectangle targetRc = Renderer::ConvertEFBRectangle(rc);
|
||||||
|
|
||||||
|
// Always set the scissor in case it was set by the game and has not been reset
|
||||||
|
RECT sirc;
|
||||||
|
sirc.left = targetRc.left;
|
||||||
|
sirc.top = targetRc.top;
|
||||||
|
sirc.right = targetRc.right;
|
||||||
|
sirc.bottom = targetRc.bottom;
|
||||||
|
D3D::dev->SetScissorRect(&sirc);
|
||||||
|
|
||||||
|
VertexShaderManager::SetViewportChanged();
|
||||||
|
|
||||||
|
DWORD clearflags = 0;
|
||||||
|
if(colorEnable)
|
||||||
|
{
|
||||||
|
clearflags |= D3DCLEAR_TARGET;
|
||||||
|
}
|
||||||
|
if (zEnable)
|
||||||
|
{
|
||||||
|
clearflags |= D3DCLEAR_ZBUFFER;
|
||||||
|
}
|
||||||
|
|
||||||
|
D3D::dev->Clear(0, NULL, clearflags, color,(z & 0xFFFFFF) / float(0xFFFFFF), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
||||||
{
|
{
|
||||||
// this function is called after the XFB field is changed, not after
|
// this function is called after the XFB field is changed, not after
|
||||||
|
|
Loading…
Reference in New Issue