Handle D3D buffer locking failures more gracefully. Patch from JosepMa.

This commit is contained in:
SarahW 2017-07-09 18:51:39 +01:00
commit d8a94b22e6
2 changed files with 17 additions and 10 deletions

View file

@ -291,14 +291,20 @@ static void d3d_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h)
lock_rect.bottom = y2;
lock_rect.right = 2047;
if (FAILED(d3dTexture->LockRect(0, &dr, &lock_rect, 0)))
fatal("LockRect failed\n");
for (yy = y1; yy < y2; yy++)
memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4);
hr = d3dTexture->LockRect(0, &dr, &lock_rect, 0);
if (hr == D3D_OK)
{
for (yy = y1; yy < y2; yy++)
memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4);
video_blit_complete();
d3dTexture->UnlockRect(0);
video_blit_complete();
d3dTexture->UnlockRect(0);
}
else
{
video_blit_complete();
return;
}
}
else
video_blit_complete();

View file

@ -221,11 +221,9 @@ void d3d_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h)
r.bottom = y2;
r.right = 2047;
hr = d3dTexture->LockRect(0, &dr, &r, 0);
if (hr == D3D_OK)
{
if (FAILED(d3dTexture->LockRect(0, &dr, &r, 0)))
fatal("LockRect failed\n");
for (yy = y1; yy < y2; yy++)
{
if ((y + yy) >= 0 && (y + yy) < buffer32->h)
@ -236,7 +234,10 @@ void d3d_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h)
d3dTexture->UnlockRect(0);
}
else
{
video_blit_complete();
return;
}
d3d_verts[0].tu = d3d_verts[2].tu = d3d_verts[3].tu = 0;//0.5 / 2048.0;
d3d_verts[0].tv = d3d_verts[3].tv = d3d_verts[4].tv = 0;//0.5 / 2048.0;