[4/6] WineD3D: Better tracking of vertex buffer assignments

Stefan Dösinger stefan at codeweavers.com
Fri Jan 12 12:01:59 CST 2007


With reading the decoded declaration from the device it is no longer necessary 
to know the stream the buffer is bound to.

A 1/0 flag is not enought to keep track of assignments, because a vb can be 
assigned to 2 streams. Thus use a counter.
-------------- next part --------------
From 1bef514c07eeda660aa40e00bbf43ad1a3e19fb6 Mon Sep 17 00:00:00 2001
From: Stefan Doesinger <stefan at codeweavers.com>
Date: Fri, 12 Jan 2007 18:33:21 +0100
Subject: [PATCH] WineD3D: Better tracking of vertex buffer assignments

---
 dlls/wined3d/device.c          |    8 ++------
 dlls/wined3d/vertexbuffer.c    |    2 +-
 dlls/wined3d/wined3d_private.h |    7 +++----
 3 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 45c0eda..752c3a9 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -2243,14 +2243,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetStreamSource(IWineD3DDevice *iface,
     so for now, just count internally   */
     if (pStreamData != NULL) {
         IWineD3DVertexBufferImpl *vbImpl = (IWineD3DVertexBufferImpl *) pStreamData;
-        if( (vbImpl->Flags & VBFLAG_STREAM) && vbImpl->stream != StreamNumber) {
-            WARN("Assigning a Vertex Buffer to stream %d which is already assigned to stream %d\n", StreamNumber, vbImpl->stream);
-        }
-        vbImpl->stream = StreamNumber;
-        vbImpl->Flags |= VBFLAG_STREAM;
+        InterlockedIncrement(&vbImpl->bindCount);
     }
     if (oldSrc != NULL) {
-        ((IWineD3DVertexBufferImpl *) oldSrc)->Flags &= ~VBFLAG_STREAM;
+        InterlockedDecrement(&((IWineD3DVertexBufferImpl *) oldSrc)->bindCount);
     }
 
     IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC);
diff --git a/dlls/wined3d/vertexbuffer.c b/dlls/wined3d/vertexbuffer.c
index c7a8a97..6ef7533 100644
--- a/dlls/wined3d/vertexbuffer.c
+++ b/dlls/wined3d/vertexbuffer.c
@@ -266,7 +266,7 @@ static void     WINAPI IWineD3DVertexBufferImpl_PreLoad(IWineD3DVertexBuffer *if
     }
 
     /* 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) {
+    if(This->resource.wineD3DDevice->isInDraw && This->bindCount > 0) {
         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
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 6d99657..3611f87 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -751,7 +751,7 @@ typedef struct IWineD3DVertexBufferImpl
     /* Vertex buffer object support */
     GLuint                    vbo;
     BYTE                      Flags;
-    UINT                      stream;
+    LONG                      bindCount;
 
     UINT                      dirtystart, dirtyend;
     LONG                      lockcount;
@@ -766,9 +766,8 @@ extern const IWineD3DVertexBufferVtbl IWineD3DVertexBuffer_Vtbl;
 #define VBFLAG_LOAD           0x01    /* Data is written from allocatedMemory to the VBO */
 #define VBFLAG_OPTIMIZED      0x02    /* Optimize has been called for the VB */
 #define VBFLAG_DIRTY          0x04    /* Buffer data has been modified */
-#define VBFLAG_STREAM         0x08    /* The vertex buffer is in a stream */
-#define VBFLAG_HASDESC        0x10    /* A vertex description has been found */
-#define VBFLAG_VBOCREATEFAIL  0x20    /* An attempt to create a vbo has failed */
+#define VBFLAG_HASDESC        0x08    /* A vertex description has been found */
+#define VBFLAG_VBOCREATEFAIL  0x10    /* An attempt to create a vbo has failed */
 
 /*****************************************************************************
  * IWineD3DIndexBuffer implementation structure (extends IWineD3DResourceImpl)
-- 
1.4.4.3



More information about the wine-patches mailing list