[WINED3D] DrawIndexedPrimitiveUP() - fix index buffer refcount issue

Ivan Gyurdiev ivg2 at cornell.edu
Thu May 4 17:36:48 CDT 2006


MSDN says: "Following any DrawIndexedPrimitiveUP call, the stream 0 
settings, referenced by GetStreamSource, are set to NULL. Also, the 
index buffer setting for SetIndices is set to NULL."

We Release() the stream 0 settings, and set them to NULL.
We only Release() the index buffer setting.

This causes the RollerCoaster.exe shaders demo that I have to segfault 
after doing: SetIndices(), DrawIndexedPrimitiveUP(), 
DrawIndexedPrimitiveUP(), then SetIndices() again with the same buffer [ 
now released due to refcount beind continually decreased down to 0 ]. 
After this change, the demo does not crash anymore.

================

Also cleans up what looks like the result of a patch being applied twice 
- same value is written to on consecutive lines.
-------------- next part --------------
---

 dlls/wined3d/device.c |   13 ++++---------
 1 files changed, 4 insertions(+), 9 deletions(-)

024e79da36429da0cc15491c1362266de02cb755
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index b2497c4..1ee9977 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -5329,10 +5329,8 @@ HRESULT WINAPI IWineD3DDeviceImpl_DrawPr
 
     drawPrimitive(iface, PrimitiveType, PrimitiveCount, 0 /* start vertex */, 0  /* NumVertices */,
                   0 /* indxStart*/, 0 /* indxSize*/, NULL /* indxData */, 0 /* indxMin */);
-    /* stream zero settings set to null at end, as per the msdn
-            http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/graphics/reference/d3d/interfaces/idirect3ddevice9/DrawPrimitiveUP.asp
-    */
-    This->stateBlock->streamStride[0] = 0;
+
+    /* MSDN specifies stream zero settings must be set to NULL */
     This->stateBlock->streamSource[0] = NULL;
 
     /*stream zero settings set to null at end, as per the msdn */
@@ -5372,13 +5370,10 @@ HRESULT WINAPI IWineD3DDeviceImpl_DrawIn
     This->stateBlock->streamStride[0] = VertexStreamZeroStride;
 
     drawPrimitive(iface, PrimitiveType, PrimitiveCount, 0 /* vertexStart */, NumVertices, 0 /* indxStart */, idxStride, pIndexData, MinVertexIndex);
-    /* stream zero settings set to null at end as per the msdn
-    http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/graphics/reference/d3d/interfaces/idirect3ddevice9/DrawPrimitiveUP.asp
-    */
 
-    /* stream zero settings set to null at end as per the msdn */
+    /* MSDN specifies stream zero settings and index buffer must be set to NULL */
     This->stateBlock->streamSource[0] = NULL;
-    This->stateBlock->streamStride[0] = 0;
+    This->stateBlock->pIndexData = NULL;
 
     return WINED3D_OK;
 }
-- 
1.3.0



More information about the wine-patches mailing list