[2/3] WineD3D: Store the stream number in the strided structure

Stefan Dösinger stefan at codeweavers.com
Tue Jan 16 16:58:29 CST 2007


The next patch will need it to handle per stream offsets properly, and it will 
be needed later too to access instancing settings which are given per stream.

For ddraw it is all stream 0. The change to dlls/ddraw/device.c makes sure 
that the the new members are set to 0 for all attributes. (Technically it is 
a NOP move because a d3d7 fvf without position mask doesn't make any sense 
anyway). The new position is the technically correct one.

-------------- next part --------------
From 115d642856b9435882da8b32c36d609bee065ebd Mon Sep 17 00:00:00 2001
From: Stefan Doesinger <stefan at codeweavers.com>
Date: Sat, 13 Jan 2007 14:18:16 +0100
Subject: [PATCH] WineD3D: Store the stream number in the strided data

---
 dlls/ddraw/device.c            |    2 +-
 dlls/wined3d/device.c          |    2 +-
 dlls/wined3d/drawprim.c        |   15 ++++++++++++---
 dlls/wined3d/wined3d_private.h |    3 ++-
 include/wine/wined3d_types.h   |    1 +
 5 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c
index 62cfa50..d0f81f3 100644
--- a/dlls/ddraw/device.c
+++ b/dlls/ddraw/device.c
@@ -3281,6 +3281,7 @@ IDirect3DDeviceImpl_7_DrawPrimitiveStrided(IDirect3DDevice7 *iface,
 
     TRACE("(%p)->(%08x,%08x,%p,%08x,%08x): stub!\n", This, PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Flags);
 
+    memset(&WineD3DStrided, 0, sizeof(WineD3DStrided));
     /* Get the strided data right. the wined3d structure is a bit bigger
      * Watch out: The contents of the strided data are determined by the fvf,
      * not by the members set in D3DDrawPrimStrideData. So it's valid
@@ -3289,7 +3290,6 @@ IDirect3DDeviceImpl_7_DrawPrimitiveStrided(IDirect3DDevice7 *iface,
      */
     if(VertexType & D3DFVF_POSITION_MASK)
     {
-        memset(&WineD3DStrided, 0, sizeof(WineD3DStrided));
         WineD3DStrided.u.s.position.lpData = D3DDrawPrimStrideData->position.lpvData;
         WineD3DStrided.u.s.position.dwStride = D3DDrawPrimStrideData->position.dwStride;
         WineD3DStrided.u.s.position.dwType = WINED3DDECLTYPE_FLOAT3;
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index a77ccdc..bc4b2f2 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -4098,7 +4098,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ProcessVertices(IWineD3DDevice *iface,
     }
 
     memset(&strided, 0, sizeof(strided));
-    primitiveConvertFVFtoOffset(SrcImpl->fvf, get_flexible_vertex_size(SrcImpl->fvf), SrcImpl->resource.allocatedMemory + get_flexible_vertex_size(SrcImpl->fvf) * SrcStartIndex, &strided, 0);
+    primitiveConvertFVFtoOffset(SrcImpl->fvf, get_flexible_vertex_size(SrcImpl->fvf), SrcImpl->resource.allocatedMemory + get_flexible_vertex_size(SrcImpl->fvf) * SrcStartIndex, &strided, 0, 0);
 
     return process_vertices_strided(This, DestIndex, VertexCount, &strided, SrcImpl->fvf, (IWineD3DVertexBufferImpl *) pDestBuffer, Flags);
 }
diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c
index f7df49c..400ffb5 100644
--- a/dlls/wined3d/drawprim.c
+++ b/dlls/wined3d/drawprim.c
@@ -223,6 +223,7 @@ void primitiveDeclarationConvertToStridedData(
            strided->u.input[idx].dwType = element->Type;
            strided->u.input[idx].dwStride = stride;
            strided->u.input[idx].VBO = streamVBO;
+           strided->u.input[idx].streamNo = element->Stream;
            if (!useVertexShaderFunction) {
                if (element->Usage == D3DDECLUSAGE_POSITION)
                    strided->u.s.position_transformed = FALSE;
@@ -244,7 +245,7 @@ void primitiveDeclarationConvertToStridedData(
     }
 }
 
-void primitiveConvertFVFtoOffset(DWORD thisFVF, DWORD stride, BYTE *data, WineDirect3DVertexStridedData *strided, GLint streamVBO) {
+void primitiveConvertFVFtoOffset(DWORD thisFVF, DWORD stride, BYTE *data, WineDirect3DVertexStridedData *strided, GLint streamVBO, UINT streamNo) {
     int           numBlends;
     int           numTextures;
     int           textureNo;
@@ -259,6 +260,7 @@ void primitiveConvertFVFtoOffset(DWORD thisFVF, DWORD stride, BYTE *data, WineDi
         strided->u.s.position.dwType    = WINED3DDECLTYPE_FLOAT3;
         strided->u.s.position.dwStride  = stride;
         strided->u.s.position.VBO       = streamVBO;
+        strided->u.s.position.streamNo  = streamNo;
         data += 3 * sizeof(float);
         if (thisFVF & WINED3DFVF_XYZRHW) {
             strided->u.s.position.dwType = WINED3DDECLTYPE_FLOAT4;
@@ -279,6 +281,7 @@ void primitiveConvertFVFtoOffset(DWORD thisFVF, DWORD stride, BYTE *data, WineDi
         strided->u.s.blendWeights.dwType    = WINED3DDECLTYPE_FLOAT1 + numBlends - 1;
         strided->u.s.blendWeights.dwStride  = stride;
         strided->u.s.blendWeights.VBO       = streamVBO;
+        strided->u.s.blendWeights.streamNo  = streamNo;
         data += numBlends * sizeof(FLOAT);
 
         if (thisFVF & WINED3DFVF_LASTBETA_UBYTE4) {
@@ -286,6 +289,7 @@ void primitiveConvertFVFtoOffset(DWORD thisFVF, DWORD stride, BYTE *data, WineDi
             strided->u.s.blendMatrixIndices.dwType  = WINED3DDECLTYPE_UBYTE4;
             strided->u.s.blendMatrixIndices.dwStride= stride;
             strided->u.s.blendMatrixIndices.VBO     = streamVBO;
+            strided->u.s.blendMatrixIndices.streamNo= streamNo;
             data += sizeof(DWORD);
         }
     }
@@ -295,7 +299,8 @@ void primitiveConvertFVFtoOffset(DWORD thisFVF, DWORD stride, BYTE *data, WineDi
         strided->u.s.normal.lpData    = data;
         strided->u.s.normal.dwType    = WINED3DDECLTYPE_FLOAT3;
         strided->u.s.normal.dwStride  = stride;
-        strided->u.s.normal.VBO     = streamVBO;
+        strided->u.s.normal.VBO       = streamVBO;
+        strided->u.s.normal.streamNo  = streamNo;
         data += 3 * sizeof(FLOAT);
     }
 
@@ -305,6 +310,7 @@ void primitiveConvertFVFtoOffset(DWORD thisFVF, DWORD stride, BYTE *data, WineDi
         strided->u.s.pSize.dwType    = WINED3DDECLTYPE_FLOAT1;
         strided->u.s.pSize.dwStride  = stride;
         strided->u.s.pSize.VBO       = streamVBO;
+        strided->u.s.pSize.streamNo  = streamNo;
         data += sizeof(FLOAT);
     }
 
@@ -314,6 +320,7 @@ void primitiveConvertFVFtoOffset(DWORD thisFVF, DWORD stride, BYTE *data, WineDi
         strided->u.s.diffuse.dwType    = WINED3DDECLTYPE_SHORT4;
         strided->u.s.diffuse.dwStride  = stride;
         strided->u.s.diffuse.VBO       = streamVBO;
+        strided->u.s.diffuse.streamNo  = streamNo;
         data += sizeof(DWORD);
     }
 
@@ -323,6 +330,7 @@ void primitiveConvertFVFtoOffset(DWORD thisFVF, DWORD stride, BYTE *data, WineDi
         strided->u.s.specular.dwType    = WINED3DDECLTYPE_SHORT4;
         strided->u.s.specular.dwStride  = stride;
         strided->u.s.specular.VBO       = streamVBO;
+        strided->u.s.specular.streamNo  = streamNo;
         data += sizeof(DWORD);
     }
 
@@ -343,6 +351,7 @@ void primitiveConvertFVFtoOffset(DWORD thisFVF, DWORD stride, BYTE *data, WineDi
         strided->u.s.texCoords[textureNo].dwType    = WINED3DDECLTYPE_FLOAT1;
         strided->u.s.texCoords[textureNo].dwStride  = stride;
         strided->u.s.texCoords[textureNo].VBO       = streamVBO;
+        strided->u.s.texCoords[textureNo].streamNo  = streamNo;
         numCoords[textureNo] = coordIdxInfo & 0x03;
 
         /* Always one set */
@@ -420,7 +429,7 @@ void primitiveConvertToStridedData(IWineD3DDevice *iface, WineDirect3DVertexStri
         if (thisFVF == 0) continue;
 
         /* Now convert the stream into pointers */
-        primitiveConvertFVFtoOffset(thisFVF, stride, data, strided, streamVBO);
+        primitiveConvertFVFtoOffset(thisFVF, stride, data, strided, streamVBO, nStream);
     }
     /* Now call PreLoad on all the vertex buffers. In the very rare case
      * that the buffers stopps converting PreLoad will dirtify the VDECL again.
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 6b4c42a..529bada 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -396,7 +396,8 @@ void primitiveConvertFVFtoOffset(DWORD thisFVF,
                                  DWORD stride,
                                  BYTE *data,
                                  WineDirect3DVertexStridedData *strided,
-                                 GLint streamVBO);
+                                 GLint streamVBO,
+                                 UINT streamNo);
 
 DWORD get_flexible_vertex_size(DWORD d3dvtVertexType);
 
diff --git a/include/wine/wined3d_types.h b/include/wine/wined3d_types.h
index 2f75be6..a75c4d4 100644
--- a/include/wine/wined3d_types.h
+++ b/include/wine/wined3d_types.h
@@ -1252,6 +1252,7 @@ typedef struct WineDirect3DStridedData {
     DWORD     dwStride;      /* Stride between occurances of this data */
     DWORD     dwType;        /* Type (as in D3DVSDT_TYPE)              */
     int       VBO;           /* Vertex buffer object this data is in   */
+    UINT      streamNo;      /* D3D stream number                      */
 } WineDirect3DStridedData;
 
 typedef struct WineDirect3DVertexStridedData {
-- 
1.4.4.3



More information about the wine-patches mailing list