[4/16] WineD3D: Put the decoded strided data structure into the device

Stefan Dösinger stefandoesinger at gmx.at
Mon Jan 1 17:21:26 CST 2007


The idea behind that is that IWineD3DVertexBuffer::PreLoad needs this  
information. This will allow the preload function to reuse the  
information(Not yet, more changes are needed for that). The other  
need for that is that later on the function for the stream source  
state will decode and set the gl sources, but drawStridedSlow will  
have to access the structure too.

-------------- next part --------------
From 26fa0a938ca5c0ce57b4e540e4cb43d0f74792a6 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Stefan_D=C3=B6singer?= <stefan at imac.local>
Date: Tue, 26 Dec 2006 23:10:46 +0100
Subject: [PATCH] WineD3D: Put the strided stream information into the device implementation

---
 dlls/wined3d/drawprim.c        |   31 ++++++++++---------------------
 dlls/wined3d/wined3d_private.h |    3 +++
 2 files changed, 13 insertions(+), 21 deletions(-)

diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c
index 7e897f1..da555bc 100644
--- a/dlls/wined3d/drawprim.c
+++ b/dlls/wined3d/drawprim.c
@@ -1947,7 +1947,6 @@ void drawPrimitive(IWineD3DDevice *iface
     IWineD3DDeviceImpl           *This = (IWineD3DDeviceImpl *)iface;
     BOOL                          useVertexShaderFunction = FALSE;
     BOOL                          usePixelShaderFunction = FALSE;
-    WineDirect3DVertexStridedData *dataLocations;
     IWineD3DSwapChainImpl         *swapchain;
     int                           i;
     BOOL                          fixup = FALSE;
@@ -2002,8 +2001,8 @@ void drawPrimitive(IWineD3DDevice *iface
         /* Note: this is a ddraw fixed-function code path */
 
         TRACE("================ Strided Input ===================\n");
-        dataLocations = DrawPrimStrideData;
-        drawPrimitiveTraceDataLocations(dataLocations);
+		memcpy(&This->strided_streams, DrawPrimStrideData, sizeof(This->strided_streams));
+        drawPrimitiveTraceDataLocations(&This->strided_streams);
         fixup = FALSE;
     }
 
@@ -2015,17 +2014,13 @@ void drawPrimitive(IWineD3DDevice *iface
          * don't set any declaration at all */
 
         TRACE("================ Vertex Declaration  ===================\n");
-        dataLocations = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*dataLocations));
-        if(!dataLocations) {
-            ERR("Out of memory!\n");
-            return;
-        }
+        memset(&This->strided_streams, 0, sizeof(This->strided_streams));
 
         if (This->stateBlock->vertexDecl != NULL ||
             ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->vertexDeclaration != NULL)            
 
             primitiveDeclarationConvertToStridedData(iface, useVertexShaderFunction, 
-                dataLocations, StartVertexIndex, &fixup);
+                &This->strided_streams, StartVertexIndex, &fixup);
 
     } else {
 
@@ -2034,20 +2029,16 @@ void drawPrimitive(IWineD3DDevice *iface
          * It will not work properly for shaders. */
 
         TRACE("================ FVF ===================\n");
-        dataLocations = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*dataLocations));
-        if(!dataLocations) {
-            ERR("Out of memory!\n");
-            return;
-        }
-        primitiveConvertToStridedData(iface, dataLocations, StartVertexIndex, &fixup);
-        drawPrimitiveTraceDataLocations(dataLocations);
+        memset(&This->strided_streams, 0, sizeof(This->strided_streams));
+        primitiveConvertToStridedData(iface, &This->strided_streams, StartVertexIndex, &fixup);
+        drawPrimitiveTraceDataLocations(&This->strided_streams);
     }
 
     /* Setup transform matrices and sort out */
-    primitiveInitState(iface, dataLocations, useVertexShaderFunction, &lighting_changed, &lighting_original);
+    primitiveInitState(iface, &This->strided_streams, useVertexShaderFunction, &lighting_changed, &lighting_original);
 
     /* Now initialize the materials state */
-    init_materials(iface, (dataLocations->u.s.diffuse.lpData != NULL || dataLocations->u.s.diffuse.VBO != 0));
+    init_materials(iface, (This->strided_streams.u.s.diffuse.lpData != NULL || This->strided_streams.u.s.diffuse.VBO != 0));
 
     {
         GLenum glPrimType;
@@ -2058,12 +2049,10 @@ void drawPrimitive(IWineD3DDevice *iface
             numberOfVertices = calculatedNumberOfindices;
 
         drawPrimitiveDrawStrided(iface, useVertexShaderFunction, usePixelShaderFunction,
-            dataLocations, numberOfVertices, calculatedNumberOfindices, glPrimType,
+            &This->strided_streams, numberOfVertices, calculatedNumberOfindices, glPrimType,
             idxData, idxSize, minIndex, StartIdx, fixup);
     }
 
-    if(!DrawPrimStrideData) HeapFree(GetProcessHeap(), 0, dataLocations);
-
     /* If vertex shaders or no normals, restore previous lighting state */
     if (lighting_changed) {
         if (lighting_original) glEnable(GL_LIGHTING);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index dce5e08..99d70c9 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -658,6 +658,9 @@ #define                         NEEDS_DI
     /* With register combiners we can skip junk texture stages */
     DWORD                     texUnitMap[MAX_SAMPLERS];
     BOOL                      oneToOneTexUnitMap;
+	
+    /* Stream source management */
+    WineDirect3DVertexStridedData strided_streams;
 
 } IWineD3DDeviceImpl;
 
-- 
1.4.2.4

-------------- next part --------------



More information about the wine-patches mailing list