Some patches
Jarmo <[email protected]>
| Newsgroups | gmane.comp.emulators.winex.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, Here is some patches. The first patch will add ComputeSphereVisibility function it is a stub but it should provide full compatibility but less efficient. Next patch will fix some crashes from BltFast function. It seems that MS implementation doesn't provide clipping. How ever current CVS version have a partial clipper code in this patch that code is commented out. There is also new clipper that will provide full clipping at all edges. That code is with in this patch but it is not in use. Code without clipper may have better compatibility with original DirectDraw but clippers could provide better graphics in a cases where original code fails. So How should WineX deal with this ? DDraw::Blt function does support clip-lists. I could try to implement clipper code in that function. I don't have much games. I was tryin Civ3 but it refuces to install. Currently I have tested this code only with Orbiter http://www.orbitersim.com game works without HW acceleration. Is there any testing applications created ? ------------------------------------------------------------ Hi Ove Kaaven, I have tested the patch you mailed and it did fix the second bug that I was tracking. Thanks, Jarmo Nikkanen
BltFastPatch.diff
(text/x-diff, 3.7 KB)
Common subdirectories: wine/dlls/ddraw/dsurface/CVS and wine_patch/dlls/ddraw/dsurface/CVS
diff -u wine/dlls/ddraw/dsurface/dib.c wine_patch/dlls/ddraw/dsurface/dib.c
--- wine/dlls/ddraw/dsurface/dib.c 2003-06-17 12:55:56.000000000 +0000
+++ wine_patch/dlls/ddraw/dsurface/dib.c 2003-06-18 09:12:35.000000000 +0000
@@ -721,29 +721,77 @@
}
goto release;
}
-
+
if (!rsrc) {
- WARN("rsrc is NULL!\n");
rsrc = &rsrc2;
rsrc->left = rsrc->top = 0;
rsrc->right = sdesc.dwWidth;
rsrc->bottom = sdesc.dwHeight;
}
+
+ h=rsrc->bottom-rsrc->top;
+ w=rsrc->right-rsrc->left;
+
+ /* Check that rect is valid */
+ if (h<0 || w<0) { ret=DDERR_INVALIDRECT; goto error; }
+
+ /* Check that params are valid. Incorrect parameters must not cause a crash */
+ /* dstx, dstx+w, dsty, dsty+h all must be checked evenif those are unsigned !!! */
+ if (dstx>ddesc.dwWidth || dsty>ddesc.dwHeight || dstx+w>ddesc.dwWidth || dsty+h>ddesc.dwHeight ||
+ rsrc->left<0 || rsrc->top<0 || rsrc->right>sdesc.dwWidth || rsrc->bottom>sdesc.dwHeight) {
+ ret=DDERR_INVALIDPARAMS;
+ WARN("Invalid operation. Out of bounds\n");
+ goto error;
+ }
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;
+ /* It seems that MS implementation doesn't provide cliping with BltFast */
+ /* To enable this code remove 'dstx+w>ddesc.dwWidth || dsty+h>ddesc.dwHeight ||' and */
+ /* '|| rsrc->right>sdesc.dwWidth || rsrc->bottom>sdesc.dwHeight' above. Otherwice this has no effect. */
+ /* OLD CLIPPING CODE
if (h>ddesc.dwHeight-dsty) h=ddesc.dwHeight-dsty;
if (h>sdesc.dwHeight-rsrc->top) h=sdesc.dwHeight-rsrc->top;
- if (h<0) h=0;
-
- w=rsrc->right-rsrc->left;
+
if (w>ddesc.dwWidth-dstx) w=ddesc.dwWidth-dstx;
if (w>sdesc.dwWidth-rsrc->left) w=sdesc.dwWidth-rsrc->left;
- if (w<0) w=0;
+ if (w<=0 || h<=0) goto release;
+ */
+
+ /* NEW CLIPING CODE for source and destination. Everyting is cliped */
+ /* Code is optimized for blits those not require clipping. */
+ /* When using this clipper, Params check section 'if (dstx>dde...' above must be removed */
+ /* new values initialized in w, h, dstx ,dsty and rsrc. */
+ /* int sw,sh,dw,dh,sx,sy,dx,dy,uni;
+ uni=sx=sy=dx=dy=0;
+ sw=dw=w;
+ sh=dh=h;
+
+ if (rsrc->left<0) sx=-rsrc->left, uni=1;
+ if (rsrc->top<0) sy=-rsrc->top, uni=1;
+ if ((rsrc->left+w)>sdesc.dwWidth) sw=sdesc.dwWidth-rsrc->left, uni=1;
+ if ((rsrc->top+h)>sdesc.dwHeight) sh=sdesc.dwHeight-rsrc->top, uni=1;
+ if ((int)dstx<0) dx=-(int)dstx, uni=1;
+ if ((int)dsty<0) dy=-(int)dsty, uni=1;
+ if ((dstx+w)>ddesc.dwWidth) dw=ddesc.dwWidth-dstx, uni=1;
+ if ((dsty+h)>ddesc.dwHeight) dh=ddesc.dwHeight-dsty, uni=1;
+
+ if (uni) {
+ x=max(sx,dx);
+ y=max(sy,dy);
+ w=min(sw-x,dw-x);
+ h=min(sh-y,dh-y);
+ if (w<=0 || h<=0) goto release; // Nothing to blit
+ rsrc->left+=x; dstx+=x;
+ rsrc->top-=y; dsty-=y;
+ rsrc->right=rsrc->left+w;
+ rsrc->bottom=rsrc->top+h;
+ } */
+
+
if (trans & (DDBLTFAST_SRCCOLORKEY | DDBLTFAST_DESTCOLORKEY)) {
DWORD keylow, keyhigh;
@@ -757,6 +805,8 @@
keyhigh = ddesc.ddckCKDestBlt.dwColorSpaceHighValue;
}
+/* I think that key values should be compared differently for every R,G,B-component */
+/* This may not work unless low and high keys are the same (in most cases thay are) */
#define COPYBOX_COLORKEY(type) { \
type *d = (type *)dbuf, *s = (type *)sbuf, tmp; \
s = (type *) ((BYTE *) sdesc.lpSurface + (rsrc->top * sdesc.u1.lPitch) + rsrc->left * bpp); \
SpherePatch.diff
(text/x-diff, 3.2 KB)
Common subdirectories: wine/dlls/ddraw/d3ddevice/CVS and wine_patch/dlls/ddraw/d3ddevice/CVS
diff -u wine/dlls/ddraw/d3ddevice/main.c wine_patch/dlls/ddraw/d3ddevice/main.c
--- wine/dlls/ddraw/d3ddevice/main.c 2003-06-17 12:55:02.000000000 +0000
+++ wine_patch/dlls/ddraw/d3ddevice/main.c 2003-06-17 22:09:13.000000000 +0000
@@ -1387,6 +1387,29 @@
return D3D_OK;
}
+
+HRESULT WINAPI
+Main_Direct3DDevice_ComputeSphereVisibility(LPDIRECT3DDEVICE7 iface, LPD3DVECTOR lpCenters,
+ LPD3DVALUE lpRadius, DWORD dwSpheres, DWORD dwFlags,LPDWORD lpdwReturnValues)
+{
+ /* This is quick implementation. All spheres are fully visible. */
+ /* Should be computed more accurately to improve performance */
+
+ /* Will be called very often, must limit fixme calls */
+ if (TRACE_ON(ddraw)) FIXME("Call not fully implemented\n");
+
+ if (lpdwReturnValues)
+ while(dwSpheres) {
+ dwSpheres--;
+ lpdwReturnValues[dwSpheres] = D3DVIS_INSIDE_FRUSTUM;
+ }
+
+ return D3D_OK;
+}
+
+
+
+
HRESULT WINAPI
Main_Direct3DDevice_GetTexture(LPDIRECT3DDEVICE7 iface,
DWORD dwStage,
@@ -1732,7 +1755,7 @@
Main_Direct3DDevice_DrawIndexedPrimitiveStrided,
Main_Direct3DDevice_DrawPrimitiveVB,
Main_Direct3DDevice_DrawIndexedPrimitiveVB,
- 0xdead001E, /* ComputeSphereVisibility */
+ Main_Direct3DDevice_ComputeSphereVisibility,
Main_Direct3DDevice_GetTexture,
Main_Direct3DDevice_SetTexture,
Main_Direct3DDevice_GetTextureStageState,
@@ -2273,6 +2296,15 @@
#undef CONVERTVB7
static HRESULT WINAPI
+Main_Direct3DDevice3_ComputeSphereVisibility(LPDIRECT3DDEVICE3 iface, LPD3DVECTOR lpCenters,
+ LPD3DVALUE lpRadius, DWORD dwSpheres, DWORD dwFlags,LPDWORD lpdwReturnValues)
+{
+ return IDirect3DDevice7_ComputeSphereVisibility(CONVERT7(iface),lpCenters,
+ lpRadius,dwSpheres,dwFlags,lpdwReturnValues);
+}
+
+
+static HRESULT WINAPI
Main_Direct3DDevice3_GetTexture(LPDIRECT3DDEVICE3 iface,
DWORD dwStage,
LPDIRECT3DTEXTURE2 *lplpTexture)
@@ -2368,7 +2400,7 @@
Main_Direct3DDevice3_DrawIndexedPrimitiveStrided,
Main_Direct3DDevice3_DrawPrimitiveVB,
Main_Direct3DDevice3_DrawIndexedPrimitiveVB,
- 0xdead1021, /* ComputeSphereVisibility */
+ Main_Direct3DDevice3_ComputeSphereVisibility,
Main_Direct3DDevice3_GetTexture,
Main_Direct3DDevice3_SetTexture,
Main_Direct3DDevice3_GetTextureStageState,
diff -u wine/dlls/ddraw/d3ddevice/main.h wine_patch/dlls/ddraw/d3ddevice/main.h
--- wine/dlls/ddraw/d3ddevice/main.h 2003-06-17 12:57:16.000000000 +0000
+++ wine_patch/dlls/ddraw/d3ddevice/main.h 2003-06-17 13:51:23.000000000 +0000
@@ -190,7 +190,12 @@
HRESULT WINAPI
Main_Direct3DDevice_GetClipStatus(LPDIRECT3DDEVICE7 iface,
LPD3DCLIPSTATUS lpD3DClipStatus);
+
HRESULT WINAPI
+Main_Direct3DDevice_ComputeSphereVisibility(LPDIRECT3DDEVICE7 iface, LPD3DVECTOR lpCenters,
+ LPD3DVALUE lpRadius, DWORD dwSpheres, DWORD dwFlags,LPDWORD lpdwReturnValues);
+
+HRESULT WINAPI
Main_Direct3DDevice_GetTexture(LPDIRECT3DDEVICE7 iface,
DWORD dwStage,
LPDIRECTDRAWSURFACE7* lplpTexture);