Water effect demo patch...

Nick Burns adger44 at hotmail.com
Sat Jul 16 16:13:44 CDT 2005


I got Water demo working -- whew thats all of my lil demos here (crap gotta 
get some more...)

So heres the deal
Water should have worked with wined3d -- but it was crashing on me due to 
the following...
(the patch is attached -- you may have to use fromdos (for formatting 
newline issues))

...drawprim.c : drawStridedSlow : ~1210...
                int    coordIdx = 
This->stateBlock->textureState[textureNo][D3DTSS_TEXCOORDINDEX];
                float *ptrToCoords = (float 
*)(sd->u.s.texCoords[coordIdx].lpData + (SkipnStrides * 
sd->u.s.texCoords[coordIdx].dwStride)); /*INSTA-CRASH(tm) location*/
                float  s = 0.0, t = 0.0, r = 0.0, q = 0.0;

                if (coordIdx > 7) {
                    VTRACE(("tex: %d - Skip tex coords, as being system 
generated\n", textureNo));
                    continue;
                } else if (sd->u.s.texCoords[coordIdx].lpData == NULL) 
{/*NOTICE pointer validity check here*/
                    TRACE("tex: %d - Skipping tex coords, as no data 
supplied\n", textureNo);
                    continue;
                } else {

/*pointer safety*/
float *ptrToCoords = (float *)(sd->u.s.texCoords[coordIdx].lpData + 
(SkipnStrides * sd->u.s.texCoords[coordIdx].dwStride));

-------------------the fix-use pointer after check(not 
before)------------------

                int    coordIdx = 
This->stateBlock->textureState[textureNo][D3DTSS_TEXCOORDINDEX];
                /*former INSTA-CRASH(tm) location*/
                float  s = 0.0, t = 0.0, r = 0.0, q = 0.0;

                if (coordIdx > 7) {
                    VTRACE(("tex: %d - Skip tex coords, as being system 
generated\n", textureNo));
                    continue;
                } else if (sd->u.s.texCoords[coordIdx].lpData == NULL) 
{/*NOTICE pointer validity check here*/
                    TRACE("tex: %d - Skipping tex coords, as no data 
supplied\n", textureNo);
                    continue;
                } else {

/*pointer safety*/
float *ptrToCoords = (float *)(sd->u.s.texCoords[coordIdx].lpData + 
(SkipnStrides * sd->u.s.texCoords[coordIdx].dwStride));

---------------------------------
patch version -- also attached -- dunno if the below will even format 
correctly
---------------------------------
cvs -z4 diff -u -wb -d -p drawprim.c (in directory 
C:\cvs_stuff\wine\dlls\wined3d\)
Index: drawprim.c
===================================================================
RCS file: /home/wine/wine/dlls/wined3d/drawprim.c,v
retrieving revision 1.16
diff -u -w -b -d -p -r1.16 drawprim.c
--- drawprim.c	14 Jul 2005 12:19:53 -0000	1.16
+++ drawprim.c	16 Jul 2005 21:08:45 -0000
@@ -1207,7 +1207,9 @@ static void drawStridedSlow(IWineD3DDevi
             if (This->stateBlock->textures[textureNo] != NULL) {

                 int    coordIdx = 
This->stateBlock->textureState[textureNo][D3DTSS_TEXCOORDINDEX];
+#if 0
                 float *ptrToCoords = (float 
*)(sd->u.s.texCoords[coordIdx].lpData + (SkipnStrides * 
sd->u.s.texCoords[coordIdx].dwStride));
+#endif
                 float  s = 0.0, t = 0.0, r = 0.0, q = 0.0;

                 if (coordIdx > 7) {
@@ -1218,6 +1220,8 @@ static void drawStridedSlow(IWineD3DDevi
                     continue;
                 } else {

+/*pointer safety*/
+float *ptrToCoords = (float *)(sd->u.s.texCoords[coordIdx].lpData + 
(SkipnStrides * sd->u.s.texCoords[coordIdx].dwStride));
                     int coordsToUse = sd->u.s.texCoords[coordIdx].dwType + 
1; /* 0 == D3DDECLTYPE_FLOAT1 etc */

                     /* The coords to supply depend completely on the fvf / 
vertex shader */

-------------- next part --------------
Index: dlls/wined3d/drawprim.c
===================================================================
RCS file: /home/wine/wine/dlls/wined3d/drawprim.c,v
retrieving revision 1.16
diff -u -w -b -d -p -r1.16 drawprim.c
--- dlls/wined3d/drawprim.c	14 Jul 2005 12:19:53 -0000	1.16
+++ dlls/wined3d/drawprim.c	16 Jul 2005 21:09:58 -0000
@@ -1207,7 +1207,9 @@ static void drawStridedSlow(IWineD3DDevi
             if (This->stateBlock->textures[textureNo] != NULL) {

                 int    coordIdx = 
This->stateBlock->textureState[textureNo][D3DTSS_TEXCOORDINDEX];
+#if 0
                 float *ptrToCoords = (float 
*)(sd->u.s.texCoords[coordIdx].lpData + (SkipnStrides * 
sd->u.s.texCoords[coordIdx].dwStride));
+#endif
                 float  s = 0.0, t = 0.0, r = 0.0, q = 0.0;

                 if (coordIdx > 7) {
@@ -1218,6 +1220,8 @@ static void drawStridedSlow(IWineD3DDevi
                     continue;
                 } else {

+/*pointer safety*/
+float *ptrToCoords = (float *)(sd->u.s.texCoords[coordIdx].lpData + 
(SkipnStrides * sd->u.s.texCoords[coordIdx].dwStride));
                     int coordsToUse = sd->u.s.texCoords[coordIdx].dwType + 
1; /* 0 == D3DDECLTYPE_FLOAT1 etc */

                     /* The coords to supply depend completely on the fvf / 
vertex shader */




More information about the wine-devel mailing list