[WINED3D 1/9] Add D3DFVF codes to the WINED3D namespace.

Ivan Gyurdiev ivg231 at gmail.com
Tue Oct 31 02:16:08 CST 2006


Arguably there shouldn't be any FVF functionality in wined3d - it's a 
legacy technology, being phased out. Until someone gets rid of it, 
however, at least move the constants in our namespace.

-------------- next part --------------
---
 dlls/wined3d/device.c        |   26 +++++++++++++-------------
 dlls/wined3d/drawprim.c      |   34 +++++++++++++++++-----------------
 dlls/wined3d/utils.c         |   18 +++++++++---------
 include/wine/wined3d_types.h |   39 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 78 insertions(+), 39 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 7e2d859..a1aaff6 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -666,7 +666,7 @@ static void CreateVBO(IWineD3DVertexBuff
       * usage assume DYNAMIC usage and print a warning. The app will have to update
       * the vertices regularily for them to be useful
       */
-    if(((object->fvf & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW) &&
+    if(((object->fvf & WINED3DFVF_POSITION_MASK) == WINED3DFVF_XYZRHW) &&
         !(vboUsage & WINED3DUSAGE_DYNAMIC)) {
         WARN("Application creates a vertex buffer holding transformed vertices which doesn't specify dynamic usage\n");
         vboUsage |= WINED3DUSAGE_DYNAMIC;
@@ -753,7 +753,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl
      * There is a IDirect3DVertexBuffer7::Optimize call after which the buffer can't be locked any
      * more. In this call we can convert dx7 buffers too.
      */
-    conv = ((FVF & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW ) || (FVF & (D3DFVF_DIFFUSE | D3DFVF_SPECULAR));
+    conv = ((FVF & WINED3DFVF_POSITION_MASK) == WINED3DFVF_XYZRHW ) || (FVF & (WINED3DFVF_DIFFUSE | WINED3DFVF_SPECULAR));
     if( GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT) && Pool != WINED3DPOOL_SYSTEMMEM && !(Usage & WINED3DUSAGE_DYNAMIC) && 
         (dxVersion > 7 || !conv) ) {
         CreateVBO(object);
@@ -5092,11 +5092,11 @@ process_vertices_strided(IWineD3DDeviceI
     BOOL doClip;
     int numTextures;
 
-    if (SrcFVF & D3DFVF_NORMAL) {
+    if (SrcFVF & WINED3DFVF_NORMAL) {
         WARN(" lighting state not saved yet... Some strange stuff may happen !\n");
     }
 
-    if ( (SrcFVF & D3DFVF_POSITION_MASK) != D3DFVF_XYZ) {
+    if ( (SrcFVF & WINED3DFVF_POSITION_MASK) != WINED3DFVF_XYZ) {
         ERR("Source has no position mask\n");
         return WINED3DERR_INVALIDCALL;
     }
@@ -5204,13 +5204,13 @@ process_vertices_strided(IWineD3DDeviceI
     multiply_matrix(&mat,&view_mat,&world_mat);
     multiply_matrix(&mat,&proj_mat,&mat);
 
-    numTextures = (DestFVF & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
+    numTextures = (DestFVF & WINED3DFVF_TEXCOUNT_MASK) >> WINED3DFVF_TEXCOUNT_SHIFT;
 
     for (i = 0; i < dwCount; i+= 1) {
         unsigned int tex_index;
 
-        if ( ((DestFVF & D3DFVF_POSITION_MASK) == D3DFVF_XYZ ) ||
-             ((DestFVF & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW ) ) {
+        if ( ((DestFVF & WINED3DFVF_POSITION_MASK) == WINED3DFVF_XYZ ) ||
+             ((DestFVF & WINED3DFVF_POSITION_MASK) == WINED3DFVF_XYZRHW ) ) {
             /* The position first */
             float *p =
               (float *) (((char *) lpStrideData->u.s.position.lpData) + i * lpStrideData->u.s.position.dwStride);
@@ -5306,7 +5306,7 @@ process_vertices_strided(IWineD3DDeviceI
 
             dest_ptr += 3 * sizeof(float);
 
-            if((DestFVF & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW) {
+            if((DestFVF & WINED3DFVF_POSITION_MASK) == WINED3DFVF_XYZRHW) {
                 dest_ptr += sizeof(float);
             }
 
@@ -5319,16 +5319,16 @@ process_vertices_strided(IWineD3DDeviceI
 
                 dest_conv += 3 * sizeof(float);
 
-                if((DestFVF & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW) {
+                if((DestFVF & WINED3DFVF_POSITION_MASK) == WINED3DFVF_XYZRHW) {
                     dest_conv += sizeof(float);
                 }
             }
         }
-        if (DestFVF & D3DFVF_PSIZE) {
+        if (DestFVF & WINED3DFVF_PSIZE) {
             dest_ptr += sizeof(DWORD);
             if(dest_conv) dest_conv += sizeof(DWORD);
         }
-        if (DestFVF & D3DFVF_NORMAL) {
+        if (DestFVF & WINED3DFVF_NORMAL) {
             float *normal =
               (float *) (((float *) lpStrideData->u.s.normal.lpData) + i * lpStrideData->u.s.normal.dwStride);
             /* AFAIK this should go into the lighting information */
@@ -5339,7 +5339,7 @@ process_vertices_strided(IWineD3DDeviceI
             }
         }
 
-        if (DestFVF & D3DFVF_DIFFUSE) {
+        if (DestFVF & WINED3DFVF_DIFFUSE) {
             DWORD *color_d = 
               (DWORD *) (((char *) lpStrideData->u.s.diffuse.lpData) + i * lpStrideData->u.s.diffuse.dwStride);
             if(!color_d) {
@@ -5369,7 +5369,7 @@ process_vertices_strided(IWineD3DDeviceI
             }
         }
 
-        if (DestFVF & D3DFVF_SPECULAR) { 
+        if (DestFVF & WINED3DFVF_SPECULAR) { 
             /* What's the color value in the feedback buffer? */
             DWORD *color_s = 
               (DWORD *) (((char *) lpStrideData->u.s.specular.lpData) + i * lpStrideData->u.s.specular.dwStride);
diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c
index a5bf5eb..1bedda4 100644
--- a/dlls/wined3d/drawprim.c
+++ b/dlls/wined3d/drawprim.c
@@ -487,18 +487,18 @@ void primitiveConvertFVFtoOffset(DWORD t
     int           numTextures;
     int           textureNo;
     int           coordIdxInfo = 0x00;    /* Information on number of coords supplied */
-    int           numCoords[8];           /* Holding place for D3DFVF_TEXTUREFORMATx  */
+    int           numCoords[8];           /* Holding place for WINED3DFVF_TEXTUREFORMATx  */
 
     /* Either 3 or 4 floats depending on the FVF */
     /* FIXME: Can blending data be in a different stream to the position data?
           and if so using the fixed pipeline how do we handle it               */
-    if (thisFVF & D3DFVF_POSITION_MASK) {
+    if (thisFVF & WINED3DFVF_POSITION_MASK) {
         strided->u.s.position.lpData    = data;
         strided->u.s.position.dwType    = WINED3DDECLTYPE_FLOAT3;
         strided->u.s.position.dwStride  = stride;
         strided->u.s.position.VBO       = streamVBO;
         data += 3 * sizeof(float);
-        if (thisFVF & D3DFVF_XYZRHW) {
+        if (thisFVF & WINED3DFVF_XYZRHW) {
             strided->u.s.position.dwType = WINED3DDECLTYPE_FLOAT4;
             strided->u.s.position_transformed = TRUE;
             data += sizeof(float);
@@ -508,10 +508,10 @@ void primitiveConvertFVFtoOffset(DWORD t
 
     /* Blending is numBlends * FLOATs followed by a DWORD for UBYTE4 */
     /** do we have to Check This->stateBlock->renderState[D3DRS_INDEXEDVERTEXBLENDENABLE] ? */
-    numBlends = 1 + (((thisFVF & D3DFVF_XYZB5) - D3DFVF_XYZB1) >> 1);
-    if(thisFVF & D3DFVF_LASTBETA_UBYTE4) numBlends--;
+    numBlends = 1 + (((thisFVF & WINED3DFVF_XYZB5) - WINED3DFVF_XYZB1) >> 1);
+    if(thisFVF & WINED3DFVF_LASTBETA_UBYTE4) numBlends--;
 
-    if ((thisFVF & D3DFVF_XYZB5 ) > D3DFVF_XYZRHW) {
+    if ((thisFVF & WINED3DFVF_XYZB5 ) > WINED3DFVF_XYZRHW) {
         TRACE("Setting blend Weights to %p\n", data);
         strided->u.s.blendWeights.lpData    = data;
         strided->u.s.blendWeights.dwType    = WINED3DDECLTYPE_FLOAT1 + numBlends - 1;
@@ -519,7 +519,7 @@ void primitiveConvertFVFtoOffset(DWORD t
         strided->u.s.blendWeights.VBO       = streamVBO;
         data += numBlends * sizeof(FLOAT);
 
-        if (thisFVF & D3DFVF_LASTBETA_UBYTE4) {
+        if (thisFVF & WINED3DFVF_LASTBETA_UBYTE4) {
             strided->u.s.blendMatrixIndices.lpData = data;
             strided->u.s.blendMatrixIndices.dwType  = WINED3DDECLTYPE_UBYTE4;
             strided->u.s.blendMatrixIndices.dwStride= stride;
@@ -529,7 +529,7 @@ void primitiveConvertFVFtoOffset(DWORD t
     }
 
     /* Normal is always 3 floats */
-    if (thisFVF & D3DFVF_NORMAL) {
+    if (thisFVF & WINED3DFVF_NORMAL) {
         strided->u.s.normal.lpData    = data;
         strided->u.s.normal.dwType    = WINED3DDECLTYPE_FLOAT3;
         strided->u.s.normal.dwStride  = stride;
@@ -538,7 +538,7 @@ void primitiveConvertFVFtoOffset(DWORD t
     }
 
     /* Pointsize is a single float */
-    if (thisFVF & D3DFVF_PSIZE) {
+    if (thisFVF & WINED3DFVF_PSIZE) {
         strided->u.s.pSize.lpData    = data;
         strided->u.s.pSize.dwType    = WINED3DDECLTYPE_FLOAT1;
         strided->u.s.pSize.dwStride  = stride;
@@ -547,7 +547,7 @@ void primitiveConvertFVFtoOffset(DWORD t
     }
 
     /* Diffuse is 4 unsigned bytes */
-    if (thisFVF & D3DFVF_DIFFUSE) {
+    if (thisFVF & WINED3DFVF_DIFFUSE) {
         strided->u.s.diffuse.lpData    = data;
         strided->u.s.diffuse.dwType    = WINED3DDECLTYPE_SHORT4;
         strided->u.s.diffuse.dwStride  = stride;
@@ -556,7 +556,7 @@ void primitiveConvertFVFtoOffset(DWORD t
     }
 
     /* Specular is 4 unsigned bytes */
-    if (thisFVF & D3DFVF_SPECULAR) {
+    if (thisFVF & WINED3DFVF_SPECULAR) {
         strided->u.s.specular.lpData    = data;
         strided->u.s.specular.dwType    = WINED3DDECLTYPE_SHORT4;
         strided->u.s.specular.dwStride  = stride;
@@ -565,14 +565,14 @@ void primitiveConvertFVFtoOffset(DWORD t
     }
 
     /* Texture coords */
-    numTextures   = (thisFVF & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
-    coordIdxInfo  = (thisFVF & 0x00FF0000) >> 16; /* 16 is from definition of D3DFVF_TEXCOORDSIZE1, and is 8 (0-7 stages) * 2bits long */
+    numTextures   = (thisFVF & WINED3DFVF_TEXCOUNT_MASK) >> WINED3DFVF_TEXCOUNT_SHIFT;
+    coordIdxInfo  = (thisFVF & 0x00FF0000) >> 16; /* 16 is from definition of WINED3DFVF_TEXCOORDSIZE1, and is 8 (0-7 stages) * 2bits long */
 
     /* numTextures indicates the number of texture coordinates supplied */
     /* However, the first set may not be for stage 0 texture - it all   */
     /*   depends on WINED3DTSS_TEXCOORDINDEX.                           */
     /* The number of bytes for each coordinate set is based off         */
-    /*   D3DFVF_TEXCOORDSIZEn, which are the bottom 2 bits              */
+    /*   WINED3DFVF_TEXCOORDSIZEn, which are the bottom 2 bits              */
 
     /* So, for each supplied texture extract the coords */
     for (textureNo = 0; textureNo < numTextures; ++textureNo) {
@@ -585,13 +585,13 @@ void primitiveConvertFVFtoOffset(DWORD t
 
         /* Always one set */
         data += sizeof(float);
-        if (numCoords[textureNo] != D3DFVF_TEXTUREFORMAT1) {
+        if (numCoords[textureNo] != WINED3DFVF_TEXTUREFORMAT1) {
             strided->u.s.texCoords[textureNo].dwType = WINED3DDECLTYPE_FLOAT2;
             data += sizeof(float);
-            if (numCoords[textureNo] != D3DFVF_TEXTUREFORMAT2) {
+            if (numCoords[textureNo] != WINED3DFVF_TEXTUREFORMAT2) {
                 strided->u.s.texCoords[textureNo].dwType = WINED3DDECLTYPE_FLOAT3;
                 data += sizeof(float);
-                if (numCoords[textureNo] != D3DFVF_TEXTUREFORMAT3) {
+                if (numCoords[textureNo] != WINED3DFVF_TEXTUREFORMAT3) {
                     strided->u.s.texCoords[textureNo].dwType = WINED3DDECLTYPE_FLOAT4;
                     data += sizeof(float);
                 }
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 398f37d..1ccff17 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -2482,15 +2482,15 @@ void multiply_matrix(WINED3DMATRIX *dest
 DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) {
     DWORD size = 0;
     int i;
-    int numTextures = (d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
-
-    if (d3dvtVertexType & D3DFVF_NORMAL) size += 3 * sizeof(float);
-    if (d3dvtVertexType & D3DFVF_DIFFUSE) size += sizeof(DWORD);
-    if (d3dvtVertexType & D3DFVF_SPECULAR) size += sizeof(DWORD);
-    if (d3dvtVertexType & D3DFVF_PSIZE) size += sizeof(DWORD);
-    switch (d3dvtVertexType & D3DFVF_POSITION_MASK) {
-        case D3DFVF_XYZ: size += 3 * sizeof(float); break;
-        case D3DFVF_XYZRHW: size += 4 * sizeof(float); break;
+    int numTextures = (d3dvtVertexType & WINED3DFVF_TEXCOUNT_MASK) >> WINED3DFVF_TEXCOUNT_SHIFT;
+
+    if (d3dvtVertexType & WINED3DFVF_NORMAL) size += 3 * sizeof(float);
+    if (d3dvtVertexType & WINED3DFVF_DIFFUSE) size += sizeof(DWORD);
+    if (d3dvtVertexType & WINED3DFVF_SPECULAR) size += sizeof(DWORD);
+    if (d3dvtVertexType & WINED3DFVF_PSIZE) size += sizeof(DWORD);
+    switch (d3dvtVertexType & WINED3DFVF_POSITION_MASK) {
+        case WINED3DFVF_XYZ: size += 3 * sizeof(float); break;
+        case WINED3DFVF_XYZRHW: size += 4 * sizeof(float); break;
         default: TRACE(" matrix weighting not handled yet...\n");
     }
     for (i = 0; i < numTextures; i++) {
diff --git a/include/wine/wined3d_types.h b/include/wine/wined3d_types.h
index 50189a7..d1b15df 100644
--- a/include/wine/wined3d_types.h
+++ b/include/wine/wined3d_types.h
@@ -1478,4 +1478,43 @@ #define WINED3DCLIPPLANE3              (
 #define WINED3DCLIPPLANE4              (1 << 4)
 #define WINED3DCLIPPLANE5              (1 << 5)
 
+/* FVF (Flexible Vertex Format) codes */
+#define WINED3DFVF_RESERVED0           0x0001
+#define WINED3DFVF_POSITION_MASK       0x000E
+#define WINED3DFVF_XYZ                 0x0002
+#define WINED3DFVF_XYZRHW              0x0004
+#define WINED3DFVF_XYZB1               0x0006
+#define WINED3DFVF_XYZB2               0x0008
+#define WINED3DFVF_XYZB3               0x000a
+#define WINED3DFVF_XYZB4               0x000c
+#define WINED3DFVF_XYZB5               0x000e
+#define WINED3DFVF_XYZW                0x4002
+#define WINED3DFVF_NORMAL              0x0010
+#define WINED3DFVF_PSIZE               0x0020
+#define WINED3DFVF_DIFFUSE             0x0040
+#define WINED3DFVF_SPECULAR            0x0080
+#define WINED3DFVF_TEXCOUNT_MASK       0x0f00
+#define WINED3DFVF_TEXCOUNT_SHIFT           8
+#define WINED3DFVF_TEX0                0x0000
+#define WINED3DFVF_TEX1                0x0100
+#define WINED3DFVF_TEX2                0x0200
+#define WINED3DFVF_TEX3                0x0300
+#define WINED3DFVF_TEX4                0x0400
+#define WINED3DFVF_TEX5                0x0500
+#define WINED3DFVF_TEX6                0x0600
+#define WINED3DFVF_TEX7                0x0700
+#define WINED3DFVF_TEX8                0x0800
+#define WINED3DFVF_LASTBETA_UBYTE4     0x1000
+#define WINED3DFVF_LASTBETA_D3DCOLOR   0x8000
+#define WINED3DFVF_RESERVED2           0x6000
+
+#define WINED3DFVF_TEXTUREFORMAT1 3
+#define WINED3DFVF_TEXTUREFORMAT2 0
+#define WINED3DFVF_TEXTUREFORMAT3 1
+#define WINED3DFVF_TEXTUREFORMAT4 2
+#define WINED3DFVF_TEXCOORDSIZE1(CoordIndex) (WINED3DFVF_TEXTUREFORMAT1 << (CoordIndex*2 + 16))
+#define WINED3DFVF_TEXCOORDSIZE2(CoordIndex) (WINED3DFVF_TEXTUREFORMAT2)
+#define WINED3DFVF_TEXCOORDSIZE3(CoordIndex) (WINED3DFVF_TEXTUREFORMAT3 << (CoordIndex*2 + 16))
+#define WINED3DFVF_TEXCOORDSIZE4(CoordIndex) (WINED3DFVF_TEXTUREFORMAT4 << (CoordIndex*2 + 16))
+
 #endif
-- 
1.4.2.4



More information about the wine-patches mailing list