Stefan Dösinger : wined3d: Do not try to read the vertex decl when the stateblock isn't finalized.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jan 8 14:44:26 CST 2007


Module: wine
Branch: master
Commit: 9f2e0fa2e09345a93fbdee852b933937c6ef98f2
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=9f2e0fa2e09345a93fbdee852b933937c6ef98f2

Author: Stefan Dösinger <stefan at codeweavers.com>
Date:   Sat Jan  6 18:41:43 2007 +0100

wined3d: Do not try to read the vertex decl when the stateblock isn't finalized.

---

 dlls/wined3d/drawprim.c        |    6 ++++++
 dlls/wined3d/vertexbuffer.c    |   15 ++++++++++++++-
 dlls/wined3d/wined3d_private.h |    1 +
 3 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c
index 129c42e..cf47106 100644
--- a/dlls/wined3d/drawprim.c
+++ b/dlls/wined3d/drawprim.c
@@ -1247,6 +1247,9 @@ void drawPrimitive(IWineD3DDevice *iface
     DWORD                         dirtyState, idx;
     BYTE                          shift;
 
+    /* Signals other modules that a drawing is in progress and the stateblock finalized */
+    This->isInDraw = TRUE;
+
     /* Invalidate the back buffer memory so LockRect will read it the next time */
     for(i = 0; i < IWineD3DDevice_GetNumberOfSwapChains(iface); i++) {
         IWineD3DDevice_GetSwapChain(iface, i, (IWineD3DSwapChain **) &swapchain);
@@ -1340,4 +1343,7 @@ void drawPrimitive(IWineD3DDevice *iface
         ++primCounter;
     }
 #endif
+
+    /* Control goes back to the device, stateblock values may change again */
+    This->isInDraw = FALSE;
 }
diff --git a/dlls/wined3d/vertexbuffer.c b/dlls/wined3d/vertexbuffer.c
index b89d922..181c244 100644
--- a/dlls/wined3d/vertexbuffer.c
+++ b/dlls/wined3d/vertexbuffer.c
@@ -258,7 +258,20 @@ static void     WINAPI IWineD3DVertexBuf
         return; /* Not doing any conversion */
     }
 
-    declChanged = IWineD3DVertexBufferImpl_FindDecl(This);
+    /* Reading the declaration makes only sense if the stateblock is finalized and the buffer bound to a stream */
+    if(This->resource.wineD3DDevice->isInDraw && This->Flags & VBFLAG_STREAM) {
+        declChanged = IWineD3DVertexBufferImpl_FindDecl(This);
+    } else if(This->Flags & VBFLAG_HASDESC) {
+        /* Reuse the declaration stored in the buffer. It will most likely not change, and if it does
+         * the stream source state handler will call PreLoad again and the change will be cought
+         */
+    } else {
+        /* Cannot get a declaration, and no declaration is stored in the buffer. It is pointless to preload
+         * now. When the buffer is used, PreLoad will be called by the stream source state handler and a valid
+         * declaration for the buffer can be found
+         */
+        return;
+    }
 
     /* If applications change the declaration over and over, reconverting all the time is a huge
      * performance hit. So count the declaration changes and release the VBO if there are too much
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index e8b60de..f50182a 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -588,6 +588,7 @@ typedef struct IWineD3DDeviceImpl
     BOOL                    isRecordingState;
     IWineD3DStateBlockImpl *stateBlock;
     IWineD3DStateBlockImpl *updateStateBlock;
+    BOOL                   isInDraw;
 
     /* Internal use fields  */
     WINED3DDEVICE_CREATION_PARAMETERS createParms;




More information about the wine-cvs mailing list