Commit 51df9314 authored by Lionel Ulmer's avatar Lionel Ulmer Committed by Alexandre Julliard

- fix FPS computation

- some TRACEing fixes - optimize BltFast locking rectangles
parent ae02c5d3
...@@ -212,8 +212,8 @@ inline static Drawable get_drawable( HDC hdc ) ...@@ -212,8 +212,8 @@ inline static Drawable get_drawable( HDC hdc )
#ifdef COMPUTE_FPS #ifdef COMPUTE_FPS
#define MEASUREMENT_WINDOW 20 #define MEASUREMENT_WINDOW 5
#define NUMBER_OF_WINDOWS 4 #define NUMBER_OF_WINDOWS 10
static LONGLONG perf_freq; static LONGLONG perf_freq;
static LONGLONG perf_storage[NUMBER_OF_WINDOWS]; static LONGLONG perf_storage[NUMBER_OF_WINDOWS];
...@@ -279,6 +279,7 @@ static BOOL opengl_flip( LPVOID dev, LPVOID drawable) ...@@ -279,6 +279,7 @@ static BOOL opengl_flip( LPVOID dev, LPVOID drawable)
current_window = 0; current_window = 0;
} }
perf_storage[current_window] = 0; perf_storage[current_window] = 0;
measurements_in_window = 0;
} }
} else { } else {
prev_time = current_time; prev_time = current_time;
......
...@@ -816,7 +816,7 @@ DIB_DirectDrawSurface_BltFast(LPDIRECTDRAWSURFACE7 iface, DWORD dstx, ...@@ -816,7 +816,7 @@ DIB_DirectDrawSurface_BltFast(LPDIRECTDRAWSURFACE7 iface, DWORD dstx,
HRESULT ret = DD_OK; HRESULT ret = DD_OK;
LPBYTE sbuf, dbuf; LPBYTE sbuf, dbuf;
RECT rsrc2; RECT rsrc2;
RECT lock_src, lock_dst;
if (TRACE_ON(ddraw)) { if (TRACE_ON(ddraw)) {
TRACE("(%p)->(%ld,%ld,%p,%p,%08lx)\n", TRACE("(%p)->(%ld,%ld,%p,%p,%08lx)\n",
...@@ -836,11 +836,9 @@ DIB_DirectDrawSurface_BltFast(LPDIRECTDRAWSURFACE7 iface, DWORD dstx, ...@@ -836,11 +836,9 @@ DIB_DirectDrawSurface_BltFast(LPDIRECTDRAWSURFACE7 iface, DWORD dstx,
if (This->aux_bltfast(This, dstx, dsty, src, rsrc, trans) == DD_OK) return DD_OK; if (This->aux_bltfast(This, dstx, dsty, src, rsrc, trans) == DD_OK) return DD_OK;
} }
/* We need to lock the surfaces, or we won't get refreshes when done. */ /* Get the surface description without locking to first compute the width / height */
sdesc.dwSize = sizeof(sdesc); ddesc = This->surface_desc;
IDirectDrawSurface7_Lock(src, NULL,&sdesc,DDLOCK_READONLY, 0); sdesc = (ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, src))->surface_desc;
ddesc.dwSize = sizeof(ddesc);
IDirectDrawSurface7_Lock(iface,NULL,&ddesc,DDLOCK_WRITEONLY,0);
if (!rsrc) { if (!rsrc) {
WARN("rsrc is NULL!\n"); WARN("rsrc is NULL!\n");
...@@ -850,20 +848,36 @@ DIB_DirectDrawSurface_BltFast(LPDIRECTDRAWSURFACE7 iface, DWORD dstx, ...@@ -850,20 +848,36 @@ DIB_DirectDrawSurface_BltFast(LPDIRECTDRAWSURFACE7 iface, DWORD dstx,
rsrc->bottom = sdesc.dwHeight; rsrc->bottom = sdesc.dwHeight;
} }
bpp = GET_BPP(This->surface_desc);
sbuf = (BYTE *)sdesc.lpSurface+(rsrc->top*sdesc.u1.lPitch)+rsrc->left*bpp;
dbuf = (BYTE *)ddesc.lpSurface+(dsty*ddesc.u1.lPitch)+dstx* bpp;
h=rsrc->bottom-rsrc->top; h=rsrc->bottom-rsrc->top;
if (h>ddesc.dwHeight-dsty) h=ddesc.dwHeight-dsty; if (h>ddesc.dwHeight-dsty) h=ddesc.dwHeight-dsty;
if (h>sdesc.dwHeight-rsrc->top) h=sdesc.dwHeight-rsrc->top; if (h>sdesc.dwHeight-rsrc->top) h=sdesc.dwHeight-rsrc->top;
if (h<0) h=0; if (h<=0) return DDERR_INVALIDRECT;
w=rsrc->right-rsrc->left; w=rsrc->right-rsrc->left;
if (w>ddesc.dwWidth-dstx) w=ddesc.dwWidth-dstx; if (w>ddesc.dwWidth-dstx) w=ddesc.dwWidth-dstx;
if (w>sdesc.dwWidth-rsrc->left) w=sdesc.dwWidth-rsrc->left; if (w>sdesc.dwWidth-rsrc->left) w=sdesc.dwWidth-rsrc->left;
if (w<0) w=0; if (w<=0) return DDERR_INVALIDRECT;
/* Now compute the locking rectangle... */
lock_src.left = rsrc->left;
lock_src.top = rsrc->top;
lock_src.right = lock_src.left + w;
lock_src.bottom = lock_src.top + h;
lock_dst.left = dstx;
lock_dst.top = dsty;
lock_dst.right = dstx + w;
lock_dst.bottom = dsty + h;
/* We need to lock the surfaces, or we won't get refreshes when done. */
sdesc.dwSize = sizeof(sdesc);
IDirectDrawSurface7_Lock(src, &lock_src, &sdesc, DDLOCK_READONLY, 0);
ddesc.dwSize = sizeof(ddesc);
IDirectDrawSurface7_Lock(iface, &lock_dst, &ddesc, DDLOCK_WRITEONLY, 0);
bpp = GET_BPP(This->surface_desc);
sbuf = (BYTE *) sdesc.lpSurface;
dbuf = (BYTE *) ddesc.lpSurface;
if (trans & (DDBLTFAST_SRCCOLORKEY | DDBLTFAST_DESTCOLORKEY)) { if (trans & (DDBLTFAST_SRCCOLORKEY | DDBLTFAST_DESTCOLORKEY)) {
DWORD keylow, keyhigh; DWORD keylow, keyhigh;
...@@ -878,9 +892,9 @@ DIB_DirectDrawSurface_BltFast(LPDIRECTDRAWSURFACE7 iface, DWORD dstx, ...@@ -878,9 +892,9 @@ DIB_DirectDrawSurface_BltFast(LPDIRECTDRAWSURFACE7 iface, DWORD dstx,
} }
#define COPYBOX_COLORKEY(type) { \ #define COPYBOX_COLORKEY(type) { \
type *d = (type *)dbuf, *s = (type *)sbuf, tmp; \ type *d, *s, tmp; \
s = (type *) ((BYTE *) sdesc.lpSurface + (rsrc->top * sdesc.u1.lPitch) + rsrc->left * bpp); \ s = (type *) sdesc.lpSurface; \
d = (type *) ((BYTE *) ddesc.lpSurface + (dsty * ddesc.u1.lPitch) + dstx * bpp); \ d = (type *) ddesc.lpSurface; \
for (y = 0; y < h; y++) { \ for (y = 0; y < h; y++) { \
for (x = 0; x < w; x++) { \ for (x = 0; x < w; x++) { \
tmp = s[x]; \ tmp = s[x]; \
...@@ -890,7 +904,7 @@ DIB_DirectDrawSurface_BltFast(LPDIRECTDRAWSURFACE7 iface, DWORD dstx, ...@@ -890,7 +904,7 @@ DIB_DirectDrawSurface_BltFast(LPDIRECTDRAWSURFACE7 iface, DWORD dstx,
(LPBYTE)d += ddesc.u1.lPitch; \ (LPBYTE)d += ddesc.u1.lPitch; \
} \ } \
break; \ break; \
} }
switch (bpp) { switch (bpp) {
case 1: COPYBOX_COLORKEY(BYTE) case 1: COPYBOX_COLORKEY(BYTE)
...@@ -911,9 +925,10 @@ DIB_DirectDrawSurface_BltFast(LPDIRECTDRAWSURFACE7 iface, DWORD dstx, ...@@ -911,9 +925,10 @@ DIB_DirectDrawSurface_BltFast(LPDIRECTDRAWSURFACE7 iface, DWORD dstx,
dbuf += ddesc.u1.lPitch; dbuf += ddesc.u1.lPitch;
} }
} }
error: error:
IDirectDrawSurface7_Unlock(iface, NULL); IDirectDrawSurface7_Unlock(iface, &lock_dst);
IDirectDrawSurface7_Unlock(src, NULL); IDirectDrawSurface7_Unlock(src, &lock_src);
return ret; return ret;
} }
......
...@@ -1015,7 +1015,7 @@ Main_DirectDrawSurface_Lock(LPDIRECTDRAWSURFACE7 iface, LPRECT prect, ...@@ -1015,7 +1015,7 @@ Main_DirectDrawSurface_Lock(LPDIRECTDRAWSURFACE7 iface, LPRECT prect,
* (Not documented.) */ * (Not documented.) */
if (prect != NULL) { if (prect != NULL) {
TRACE(" lprect: %ldx%ld-%ldx%ld\n", TRACE(" lprect: %ldx%ld-%ldx%ld\n",
prect->top,prect->left,prect->bottom,prect->right); prect->left,prect->top,prect->right,prect->bottom);
/* First do some sanity checkings on the rectangle we receive. /* First do some sanity checkings on the rectangle we receive.
DungeonSiege seems to gives us once a very bad rectangle for example */ DungeonSiege seems to gives us once a very bad rectangle for example */
if ((prect->top < 0) || if ((prect->top < 0) ||
......
...@@ -107,6 +107,11 @@ void set_render_state(IDirect3DDeviceImpl* This, ...@@ -107,6 +107,11 @@ void set_render_state(IDirect3DDeviceImpl* This,
ICOM_INTERFACE(tex, IDirectDrawSurface7)); ICOM_INTERFACE(tex, IDirectDrawSurface7));
} break; } break;
case D3DRENDERSTATE_ANTIALIAS: /* 2 */
if (dwRenderState)
ERR("D3DRENDERSTATE_ANTIALIAS not supported yet !\n");
break;
case D3DRENDERSTATE_TEXTUREADDRESSU: /* 44 */ case D3DRENDERSTATE_TEXTUREADDRESSU: /* 44 */
case D3DRENDERSTATE_TEXTUREADDRESSV: /* 45 */ case D3DRENDERSTATE_TEXTUREADDRESSV: /* 45 */
case D3DRENDERSTATE_TEXTUREADDRESS: { /* 3 */ case D3DRENDERSTATE_TEXTUREADDRESS: { /* 3 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment