jabo: revise ReadScreen to reduce impact on weirdly slow systems
This commit is contained in:
parent
e07f143e88
commit
3a4102571f
|
@ -131,6 +131,10 @@ extern "C"
|
||||||
D3D8Base::IDirect3DDevice8* base_device = NULL;
|
D3D8Base::IDirect3DDevice8* base_device = NULL;
|
||||||
|
|
||||||
HRESULT hr = m_pD3D->CreateDevice(Adapter,DeviceType,hFocusWindow,BehaviorFlags,pPresentationParameters,&base_device);
|
HRESULT hr = m_pD3D->CreateDevice(Adapter,DeviceType,hFocusWindow,BehaviorFlags,pPresentationParameters,&base_device);
|
||||||
|
if(FAILED(hr))
|
||||||
|
{
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
// Wrap the real object
|
// Wrap the real object
|
||||||
D3D8Wrapper::IDirect3DDevice8* f = D3D8Wrapper::IDirect3DDevice8::GetDirect3DDevice(base_device);
|
D3D8Wrapper::IDirect3DDevice8* f = D3D8Wrapper::IDirect3DDevice8::GetDirect3DDevice(base_device);
|
||||||
|
|
|
@ -91,15 +91,18 @@ extern "C"
|
||||||
D3D8Base::D3DLOCKED_RECT locked;
|
D3D8Base::D3DLOCKED_RECT locked;
|
||||||
HRESULT hr = D3D8Wrapper::render_surface->LockRect(&locked,&entire_buffer,D3DLOCK_READONLY);
|
HRESULT hr = D3D8Wrapper::render_surface->LockRect(&locked,&entire_buffer,D3DLOCK_READONLY);
|
||||||
|
|
||||||
// read out pBits from the LOCKED_RECT
|
//UNACCEPTABLE CODE: hardcode a buffer for doing one memcpy from vram
|
||||||
int from_row = desc.Height - 1;
|
//this prevents irregular access and speeds up the copying on some systems
|
||||||
for (int dest_row = 0; dest_row < desc.Height; dest_row++)
|
static char buffer[1024*1024*4];
|
||||||
|
memcpy(buffer,(char*)locked.pBits,locked.Pitch * desc.Height);
|
||||||
|
|
||||||
|
//this loop was reversed from the original.
|
||||||
|
//it should be faster anyway if anything since the reading can be prefetched forwardly.
|
||||||
|
int dest_row = desc.Height - 1;
|
||||||
|
for (int from_row = 0; from_row < desc.Height; from_row++)
|
||||||
{
|
{
|
||||||
for (int col = 0; col < desc.Width*4; col++)
|
memcpy((char*)dest + (dest_row * desc.Width*4),(char*)buffer + from_row * locked.Pitch, desc.Width*4);
|
||||||
{
|
dest_row--;
|
||||||
((char *)dest)[dest_row * desc.Width * 4 + col] = ((char *)locked.pBits)[from_row * desc.Width * 4 + col];
|
|
||||||
}
|
|
||||||
from_row--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// unlock rect
|
// unlock rect
|
||||||
|
|
Loading…
Reference in New Issue