On Sat, Aug 6, 2011 at 7:59 PM, Stefan Dösinger <stefandoesin...@gmx.at> wrote:
>> Btw. those FIXMEs might produce a lot of messages (one per vertex). Is
>> there good way to limit the number of messages?
> A common way is something like this
>
> {
>    static BOOL once = false;
>    if (!once)
>    {
>        FIXME("Report this bug to my aunt Tilda please\n");
>        once = TRUE;
>    }
> }
>
> I think there was once a discussion about a FIXME_ONCE macro that took care 
> of this. not sure what happened with that idea.

I've sorta followed Dan's suggestion to use Alexandre's style, except
that I have multiple fixme_once variables. Any idea if this would be
acceptable?

Another solution could be to check the vertex declaration before
running the welding algorithm and print the FIXMEs there. But that
would decouple the location of where the problem is from the printout,
which could be confusing during debugging.
From 6a0828e29d94de8407aedab07e3d271496d668fc Mon Sep 17 00:00:00 2001
From: Michael Mc Donnell <mich...@mcdonnell.dk>
Date: Sun, 7 Aug 2011 11:59:28 +0200
Subject: d3dx9: Only print noisy FIXMEs once in D3DXWeldVertices.

---
 dlls/d3dx9_36/mesh.c |   35 +++++++++++++++++++++++++++--------
 1 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/dlls/d3dx9_36/mesh.c b/dlls/d3dx9_36/mesh.c
index a8139cb..0a46d1b 100644
--- a/dlls/d3dx9_36/mesh.c
+++ b/dlls/d3dx9_36/mesh.c
@@ -5901,6 +5901,10 @@ static BOOL weld_float16_4(void *to, void *from, FLOAT epsilon)
 /* Sets the vertex components to the same value if they are within epsilon. */
 static BOOL weld_component(void *to, void *from, D3DDECLTYPE type, FLOAT epsilon)
 {
+    /* Quite FIXMEs as this is in a loop with potentially thousand of iterations. */
+    BOOL fixme_once_unused = FALSE;
+    BOOL fixme_once_unknown = FALSE;
+
     switch (type)
     {
         case D3DDECLTYPE_FLOAT1:
@@ -5955,11 +5959,13 @@ static BOOL weld_component(void *to, void *from, D3DDECLTYPE type, FLOAT epsilon
             return weld_float16_4(to, from, epsilon);
 
         case D3DDECLTYPE_UNUSED:
-            FIXME("D3DDECLTYPE_UNUSED welding not implemented.\n");
+            if (!fixme_once_unused++)
+                FIXME("D3DDECLTYPE_UNUSED welding not implemented.\n");
             break;
 
         default:
-            FIXME("Welding of unknown declaration type %d is not implemented.\n", type);
+            if (!fixme_once_unknown++)
+                FIXME("Welding of unknown declaration type %d is not implemented.\n", type);
             break;
     }
 
@@ -5969,6 +5975,13 @@ static BOOL weld_component(void *to, void *from, D3DDECLTYPE type, FLOAT epsilon
 static FLOAT get_component_epsilon(const D3DVERTEXELEMENT9 *decl_ptr, const D3DXWELDEPSILONS *epsilons)
 {
     FLOAT epsilon = 0.0f;
+    /* Quite FIXMEs as this is in a loop with potentially thousand of iterations. */
+    static BOOL fixme_once_blendindices = FALSE;
+    static BOOL fixme_once_positiont = FALSE;
+    static BOOL fixme_once_fog = FALSE;
+    static BOOL fixme_once_depth = FALSE;
+    static BOOL fixme_once_sample = FALSE;
+    static BOOL fixme_once_unknown = FALSE;
 
     switch (decl_ptr->Usage)
     {
@@ -6010,22 +6023,28 @@ static FLOAT get_component_epsilon(const D3DVERTEXELEMENT9 *decl_ptr, const D3DX
                 epsilon = 1e-6f;
             break;
         case D3DDECLUSAGE_BLENDINDICES:
-            FIXME("D3DDECLUSAGE_BLENDINDICES welding not implemented.\n");
+            if (!fixme_once_blendindices++)
+                FIXME("D3DDECLUSAGE_BLENDINDICES welding not implemented.\n");
             break;
         case D3DDECLUSAGE_POSITIONT:
-            FIXME("D3DDECLUSAGE_POSITIONT welding not implemented.\n");
+            if (!fixme_once_positiont++)
+                FIXME("D3DDECLUSAGE_POSITIONT welding not implemented.\n");
             break;
         case D3DDECLUSAGE_FOG:
-            FIXME("D3DDECLUSAGE_FOG welding not implemented.\n");
+            if (!fixme_once_fog++)
+                FIXME("D3DDECLUSAGE_FOG welding not implemented.\n");
             break;
         case D3DDECLUSAGE_DEPTH:
-            FIXME("D3DDECLUSAGE_DEPTH welding not implemented.\n");
+            if (!fixme_once_depth++)
+                FIXME("D3DDECLUSAGE_DEPTH welding not implemented.\n");
             break;
         case D3DDECLUSAGE_SAMPLE:
-            FIXME("D3DDECLUSAGE_SAMPLE welding not implemented.\n");
+            if (!fixme_once_sample++)
+                FIXME("D3DDECLUSAGE_SAMPLE welding not implemented.\n");
             break;
         default:
-            ERR("Unknown usage %x\n", decl_ptr->Usage);
+            if (!fixme_once_unknown++)
+                FIXME("Unknown usage %x\n", decl_ptr->Usage);
             break;
     }
 
-- 
1.7.6



Reply via email to