added a more "correct" Color peeking, you can't lock the drawing surface so the correct way is to use and offscreen surface and use StretchRect to copy the data, then lock the offscreen surface and read the data. this is experimental so please test it a lot. the bad news is you can do this only for the color surface, the z-fuffer remain slow to read and only from lockable formats. the good news are the same code should work for mltisampled surfaced.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4384 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Rodolfo Osvaldo Bogado
2009-10-08 00:35:47 +00:00
parent 04c13d5560
commit 41cc224ca1
3 changed files with 42 additions and 11 deletions

View File

@ -444,6 +444,10 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
//Get the working buffer and it's format
LPDIRECT3DSURFACE9 pBuffer = (type == PEEK_Z || type == POKE_Z) ?
FBManager::GetEFBDepthRTSurface() : FBManager::GetEFBColorRTSurface();
LPDIRECT3DSURFACE9 pOffScreenBuffer = (type == PEEK_Z || type == POKE_Z) ?
FBManager::GetEFBDepthRTSurface() : FBManager::GetEFBColorOffScreenRTSurface();
D3DLOCKED_RECT drect;
D3DFORMAT BufferFormat = (type == PEEK_Z || type == POKE_Z) ?
@ -469,10 +473,6 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
TargetRectangle targetPixelRc = Renderer::ConvertEFBRectangle(efbPixelRc);
// Sample from the center of the target region.
int srcX = (targetPixelRc.left + targetPixelRc.right) / 2;
int srcY = (targetPixelRc.top + targetPixelRc.bottom) / 2;
u32 z = 0;
float val = 0.0f;
HRESULT hr;
@ -483,7 +483,18 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
RectToLock.top = targetPixelRc.top;
//lock the buffer
if((hr = pBuffer->LockRect(&drect, &RectToLock, D3DLOCK_READONLY)) != D3D_OK)
if(!(type == PEEK_Z || type == POKE_Z))
{
hr = D3D::dev->StretchRect(pBuffer,&RectToLock,pOffScreenBuffer,&RectToLock, D3DTEXF_NONE);
if(FAILED(hr))
{
PanicAlert("Unable to copy data to mem buffer");
return 0;
}
}
if((hr = pOffScreenBuffer->LockRect(&drect, &RectToLock, D3DLOCK_READONLY)) != D3D_OK)
PanicAlert("ERROR: %s", hr == D3DERR_WASSTILLDRAWING ? "Still drawing" :
hr == D3DERR_INVALIDCALL ? "Invalid call" : "w00t");