[Mesa-dev] [PATCH 2/2] draw: replace assert(0) with debug_warn_once()

Brian Paul brianp at vmware.com
Thu Jan 5 14:19:46 PST 2012


If the assertion was hit, it probably meant that we were unable to allocate
or map a vertex buffer.  Instead of dying in a debug build, issue a warning
and continue.
---
 src/gallium/auxiliary/draw/draw_pt_emit.c          |    4 ++--
 src/gallium/auxiliary/draw/draw_pt_fetch_emit.c    |    4 ++--
 .../auxiliary/draw/draw_pt_fetch_shade_emit.c      |    4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_pt_emit.c b/src/gallium/auxiliary/draw/draw_pt_emit.c
index fbbaa81..942ddc4 100644
--- a/src/gallium/auxiliary/draw/draw_pt_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_emit.c
@@ -150,7 +150,7 @@ draw_pt_emit(struct pt_emit *emit,
 
    hw_verts = render->map_vertices( render );
    if (!hw_verts) {
-      assert(0);
+      debug_warn_once("map of vertex buffer failed (out of memory?)");
       return;
    }
 
@@ -262,7 +262,7 @@ draw_pt_emit_linear(struct pt_emit *emit,
    return;
 
 fail:
-   assert(0);
+   debug_warn_once("allocate or map of vertex buffer failed (out of memory?)");
    return;
 }
 
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
index 8485081..f30db13 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
@@ -201,7 +201,7 @@ static void fetch_emit_run( struct draw_pt_middle_end *middle,
 
    hw_verts = draw->render->map_vertices( draw->render );
    if (!hw_verts) {
-      assert(0);
+      debug_warn_once("vertex buffer allocation failed (out of memory?)");
       return;
    }
 
@@ -292,7 +292,7 @@ static void fetch_emit_run_linear( struct draw_pt_middle_end *middle,
    return;
 
 fail:
-   assert(0);
+   debug_warn_once("allocate or map of vertex buffer failed (out of memory?)");
    return;
 }
 
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c
index b875f64..870b23b 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c
@@ -236,7 +236,7 @@ fse_run_linear(struct draw_pt_middle_end *middle,
    return;
 
 fail:
-   assert(0);
+   debug_warn_once("allocate or map of vertex buffer failed (out of memory?)");
    return;
 }
 
@@ -293,7 +293,7 @@ fse_run(struct draw_pt_middle_end *middle,
    return;
 
 fail:
-   assert(0);
+   debug_warn_once("allocate or map of vertex buffer failed (out of memory?)");
    return;
 }
 
-- 
1.7.3.4



More information about the mesa-dev mailing list