[PATCH 4/4] d3dx9_36: Get rid of FILL_INDEX_BUFFER.

Stefan Dösinger stefan at codeweavers.com
Tue Feb 18 03:46:16 CST 2014


The macro uses an incorrect type for first_index in the DWORD case. While
this could be fixed by passing the destination type to the macro, I think
it's better to just replicate the code.
---
 dlls/d3dx9_36/mesh.c | 49 +++++++++++++++++++++++++++++++------------------
 1 file changed, 31 insertions(+), 18 deletions(-)

diff --git a/dlls/d3dx9_36/mesh.c b/dlls/d3dx9_36/mesh.c
index 0a8061f..38f016f 100644
--- a/dlls/d3dx9_36/mesh.c
+++ b/dlls/d3dx9_36/mesh.c
@@ -3562,27 +3562,40 @@ HRESULT WINAPI D3DXLoadSkinMeshFromXof(struct ID3DXFileData *filedata, DWORD opt
     if (FAILED(hr)) goto cleanup;
 
     index_in_ptr = mesh_data.indices;
-#define FILL_INDEX_BUFFER(indices_var) \
-        for (i = 0; i < mesh_data.num_poly_faces; i++) \
-        { \
-            DWORD count = mesh_data.num_tri_per_face[i]; \
-            WORD first_index = *index_in_ptr++; \
-            while (count--) { \
-                *indices_var++ = first_index; \
-                *indices_var++ = *index_in_ptr; \
-                index_in_ptr++; \
-                *indices_var++ = *index_in_ptr; \
-            } \
-            index_in_ptr++; \
-        }
-    if (options & D3DXMESH_32BIT) {
+    if (options & D3DXMESH_32BIT)
+    {
         DWORD *dword_indices = indices;
-        FILL_INDEX_BUFFER(dword_indices)
-    } else {
+        for (i = 0; i < mesh_data.num_poly_faces; i++)
+        {
+            DWORD count = mesh_data.num_tri_per_face[i];
+            DWORD first_index = *index_in_ptr++;
+            while (count--)
+            {
+                *dword_indices++ = first_index;
+                *dword_indices++ = *index_in_ptr;
+                 index_in_ptr++;
+                *dword_indices++ = *index_in_ptr;
+            }
+            index_in_ptr++;
+        }
+    }
+    else
+    {
         WORD *word_indices = indices;
-        FILL_INDEX_BUFFER(word_indices)
+        for (i = 0; i < mesh_data.num_poly_faces; i++)
+        {
+            DWORD count = mesh_data.num_tri_per_face[i];
+            WORD first_index = (WORD)*index_in_ptr++;
+            while (count--)
+            {
+                *word_indices++ = first_index;
+                *word_indices++ = (WORD)*index_in_ptr;
+                index_in_ptr++;
+                *word_indices++ = (WORD)*index_in_ptr;
+            }
+            index_in_ptr++;
+        }
     }
-#undef FILL_INDEX_BUFFER
     d3dxmesh->lpVtbl->UnlockIndexBuffer(d3dxmesh);
 
     if (mesh_data.material_indices) {
-- 
1.8.3.2




More information about the wine-patches mailing list