[PATCH] graw: Export graw_save_surface_to_file().

Michal Krol michal at vmware.com
Thu Nov 4 09:51:14 PDT 2010


Allows applications to dump surfaces to file without
referencing gallium/auxiliary entry points statically.
---
 src/gallium/include/state_tracker/graw.h  |    4 ++++
 src/gallium/targets/graw-null/graw_util.c |   10 ++++++++++
 src/gallium/tests/graw/clear.c            |   14 +-------------
 src/gallium/tests/graw/fs-test.c          |   13 +------------
 src/gallium/tests/graw/gs-test.c          |   13 +------------
 src/gallium/tests/graw/quad-tex.c         |   13 +------------
 src/gallium/tests/graw/shader-leak.c      |    1 -
 src/gallium/tests/graw/tri-gs.c           |    1 -
 src/gallium/tests/graw/tri-instanced.c    |   13 +------------
 src/gallium/tests/graw/tri.c              |   13 +------------
 src/gallium/tests/graw/vs-test.c          |   13 +------------
 11 files changed, 21 insertions(+), 87 deletions(-)

diff --git a/src/gallium/include/state_tracker/graw.h b/src/gallium/include/state_tracker/graw.h
index 6a99b23..51b8399 100644
--- a/src/gallium/include/state_tracker/graw.h
+++ b/src/gallium/include/state_tracker/graw.h
@@ -71,4 +71,8 @@ PUBLIC void *graw_parse_vertex_shader( struct pipe_context *pipe,
 PUBLIC void *graw_parse_fragment_shader( struct pipe_context *pipe,
                                          const char *text );
 
+PUBLIC void graw_save_surface_to_file(struct pipe_context *pipe,
+                                      struct pipe_surface *surface,
+                                      const char *filename);
+
 #endif
diff --git a/src/gallium/targets/graw-null/graw_util.c b/src/gallium/targets/graw-null/graw_util.c
index 531757f..41f65fd 100644
--- a/src/gallium/targets/graw-null/graw_util.c
+++ b/src/gallium/targets/graw-null/graw_util.c
@@ -3,6 +3,7 @@
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
 #include "tgsi/tgsi_text.h"
+#include "util/u_debug.h"
 #include "util/u_memory.h"
 #include "state_tracker/graw.h"
 
@@ -51,3 +52,12 @@ graw_parse_fragment_shader(struct pipe_context *pipe,
    return pipe->create_fs_state(pipe, &state);
 }
 
+PUBLIC void
+graw_save_surface_to_file(struct pipe_context *pipe,
+                          struct pipe_surface *surface,
+                          const char *filename)
+{
+   /* XXX: Make that working in release builds.
+    */
+   debug_dump_surface_bmp(pipe, filename, surface);
+}
diff --git a/src/gallium/tests/graw/clear.c b/src/gallium/tests/graw/clear.c
index ce52a93..2b5cee2 100644
--- a/src/gallium/tests/graw/clear.c
+++ b/src/gallium/tests/graw/clear.c
@@ -8,8 +8,6 @@
 #include "pipe/p_state.h"
 #include "pipe/p_defines.h"
 
-#include "util/u_debug.h"       /* debug_dump_surface_bmp() */
-
 enum pipe_format formats[] = {
    PIPE_FORMAT_R8G8B8A8_UNORM,
    PIPE_FORMAT_B8G8R8A8_UNORM,
@@ -31,17 +29,7 @@ static void draw( void )
    ctx->clear(ctx, PIPE_CLEAR_COLOR, clear_color, 0, 0);
    ctx->flush(ctx, PIPE_FLUSH_RENDER_CACHE, NULL);
 
-#if 0
-   /* At the moment, libgraw leaks out/makes available some of the
-    * symbols from gallium/auxiliary, including these debug helpers.
-    * Will eventually want to bless some of these paths, and lock the
-    * others down so they aren't accessible from test programs.
-    *
-    * This currently just happens to work on debug builds - a release
-    * build will probably fail to link here:
-    */
-   debug_dump_surface_bmp(ctx, "result.bmp", surf);
-#endif
+   graw_save_surface_to_file(ctx, surf, "result.bmp");
 
    screen->flush_frontbuffer(screen, surf, window);
 }
diff --git a/src/gallium/tests/graw/fs-test.c b/src/gallium/tests/graw/fs-test.c
index 53fbb74..333ecc9 100644
--- a/src/gallium/tests/graw/fs-test.c
+++ b/src/gallium/tests/graw/fs-test.c
@@ -10,7 +10,6 @@
 #include "pipe/p_defines.h"
 #include <stdio.h>              /* for fread(), etc */
 
-#include "util/u_debug.h"       /* debug_dump_surface_bmp() */
 #include "util/u_inlines.h"
 #include "util/u_memory.h"      /* Offset() */
 #include "util/u_draw_quad.h"
@@ -279,17 +278,7 @@ static void draw( void )
    util_draw_arrays(ctx, PIPE_PRIM_TRIANGLES, 0, 3);
    ctx->flush(ctx, PIPE_FLUSH_RENDER_CACHE, NULL);
 
-#if 0
-   /* At the moment, libgraw leaks out/makes available some of the
-    * symbols from gallium/auxiliary, including these debug helpers.
-    * Will eventually want to bless some of these paths, and lock the
-    * others down so they aren't accessible from test programs.
-    *
-    * This currently just happens to work on debug builds - a release
-    * build will probably fail to link here:
-    */
-   debug_dump_surface_bmp(ctx, "result.bmp", surf);
-#endif
+   graw_save_surface_to_file(ctx, surf, "result.bmp");
 
    screen->flush_frontbuffer(screen, surf, window);
 }
diff --git a/src/gallium/tests/graw/gs-test.c b/src/gallium/tests/graw/gs-test.c
index 6271490..9bafbfe 100644
--- a/src/gallium/tests/graw/gs-test.c
+++ b/src/gallium/tests/graw/gs-test.c
@@ -10,7 +10,6 @@
 #include "pipe/p_defines.h"
 #include <stdio.h>              /* for fread(), etc */
 
-#include "util/u_debug.h"       /* debug_dump_surface_bmp() */
 #include "util/u_inlines.h"
 #include "util/u_memory.h"      /* Offset() */
 #include "util/u_draw_quad.h"
@@ -343,17 +342,7 @@ static void draw( void )
 
    ctx->flush(ctx, PIPE_FLUSH_RENDER_CACHE, NULL);
 
-#if 0
-   /* At the moment, libgraw leaks out/makes available some of the
-    * symbols from gallium/auxiliary, including these debug helpers.
-    * Will eventually want to bless some of these paths, and lock the
-    * others down so they aren't accessible from test programs.
-    *
-    * This currently just happens to work on debug builds - a release
-    * build will probably fail to link here:
-    */
-   debug_dump_surface_bmp(ctx, "result.bmp", surf);
-#endif
+   graw_save_surface_to_file(ctx, surf, "result.bmp");
 
    screen->flush_frontbuffer(screen, surf, window);
 }
diff --git a/src/gallium/tests/graw/quad-tex.c b/src/gallium/tests/graw/quad-tex.c
index c50ef12..e1e6b19 100644
--- a/src/gallium/tests/graw/quad-tex.c
+++ b/src/gallium/tests/graw/quad-tex.c
@@ -9,7 +9,6 @@
 #include "pipe/p_state.h"
 #include "pipe/p_defines.h"
 
-#include "util/u_debug.h"       /* debug_dump_surface_bmp() */
 #include "util/u_inlines.h"
 #include "util/u_memory.h"      /* Offset() */
 #include "util/u_draw_quad.h"
@@ -150,17 +149,7 @@ static void draw( void )
    util_draw_arrays(ctx, PIPE_PRIM_QUADS, 0, 4);
    ctx->flush(ctx, PIPE_FLUSH_RENDER_CACHE, NULL);
 
-#if 0
-   /* At the moment, libgraw leaks out/makes available some of the
-    * symbols from gallium/auxiliary, including these debug helpers.
-    * Will eventually want to bless some of these paths, and lock the
-    * others down so they aren't accessible from test programs.
-    *
-    * This currently just happens to work on debug builds - a release
-    * build will probably fail to link here:
-    */
-   debug_dump_surface_bmp(ctx, "result.bmp", surf);
-#endif
+   graw_save_surface_to_file(ctx, surf, "result.bmp");
 
    screen->flush_frontbuffer(screen, surf, window);
 }
diff --git a/src/gallium/tests/graw/shader-leak.c b/src/gallium/tests/graw/shader-leak.c
index ec30871..0a6c362 100644
--- a/src/gallium/tests/graw/shader-leak.c
+++ b/src/gallium/tests/graw/shader-leak.c
@@ -9,7 +9,6 @@
 #include "pipe/p_state.h"
 #include "pipe/p_defines.h"
 
-#include "util/u_debug.h"       /* debug_dump_surface_bmp() */
 #include "util/u_memory.h"      /* Offset() */
 #include "util/u_draw_quad.h"
 
diff --git a/src/gallium/tests/graw/tri-gs.c b/src/gallium/tests/graw/tri-gs.c
index 152ae40..731c4e1 100644
--- a/src/gallium/tests/graw/tri-gs.c
+++ b/src/gallium/tests/graw/tri-gs.c
@@ -8,7 +8,6 @@
 #include "pipe/p_state.h"
 #include "pipe/p_defines.h"
 
-#include "util/u_debug.h"       /* debug_dump_surface_bmp() */
 #include "util/u_memory.h"      /* Offset() */
 #include "util/u_draw_quad.h"
 
diff --git a/src/gallium/tests/graw/tri-instanced.c b/src/gallium/tests/graw/tri-instanced.c
index 8859f74..1195a9b 100644
--- a/src/gallium/tests/graw/tri-instanced.c
+++ b/src/gallium/tests/graw/tri-instanced.c
@@ -11,7 +11,6 @@
 #include "pipe/p_state.h"
 #include "pipe/p_defines.h"
 
-#include "util/u_debug.h"       /* debug_dump_surface_bmp() */
 #include "util/u_memory.h"      /* Offset() */
 #include "util/u_draw_quad.h"
 
@@ -215,17 +214,7 @@ static void draw( void )
 
    ctx->flush(ctx, PIPE_FLUSH_RENDER_CACHE, NULL);
 
-#if 0
-   /* At the moment, libgraw leaks out/makes available some of the
-    * symbols from gallium/auxiliary, including these debug helpers.
-    * Will eventually want to bless some of these paths, and lock the
-    * others down so they aren't accessible from test programs.
-    *
-    * This currently just happens to work on debug builds - a release
-    * build will probably fail to link here:
-    */
-   debug_dump_surface_bmp(ctx, "result.bmp", surf);
-#endif
+   graw_save_surface_to_file(ctx, surf, "result.bmp");
 
    screen->flush_frontbuffer(screen, surf, window);
 }
diff --git a/src/gallium/tests/graw/tri.c b/src/gallium/tests/graw/tri.c
index f7e3958..652e0fe 100644
--- a/src/gallium/tests/graw/tri.c
+++ b/src/gallium/tests/graw/tri.c
@@ -10,7 +10,6 @@
 #include "pipe/p_state.h"
 #include "pipe/p_defines.h"
 
-#include "util/u_debug.h"       /* debug_dump_surface_bmp() */
 #include "util/u_memory.h"      /* Offset() */
 #include "util/u_draw_quad.h"
 
@@ -143,17 +142,7 @@ static void draw( void )
    util_draw_arrays(ctx, PIPE_PRIM_TRIANGLES, 0, 3);
    ctx->flush(ctx, PIPE_FLUSH_RENDER_CACHE, NULL);
 
-#if 0
-   /* At the moment, libgraw leaks out/makes available some of the
-    * symbols from gallium/auxiliary, including these debug helpers.
-    * Will eventually want to bless some of these paths, and lock the
-    * others down so they aren't accessible from test programs.
-    *
-    * This currently just happens to work on debug builds - a release
-    * build will probably fail to link here:
-    */
-   debug_dump_surface_bmp(ctx, "result.bmp", surf);
-#endif
+   graw_save_surface_to_file(ctx, surf, "result.bmp");
 
    screen->flush_frontbuffer(screen, surf, window);
 }
diff --git a/src/gallium/tests/graw/vs-test.c b/src/gallium/tests/graw/vs-test.c
index e1cd814..4eeda35 100644
--- a/src/gallium/tests/graw/vs-test.c
+++ b/src/gallium/tests/graw/vs-test.c
@@ -11,7 +11,6 @@
 
 #include <stdio.h>              /* for fread(), etc */
 
-#include "util/u_debug.h"       /* debug_dump_surface_bmp() */
 #include "util/u_inlines.h"
 #include "util/u_memory.h"      /* Offset() */
 #include "util/u_draw_quad.h"
@@ -230,17 +229,7 @@ static void draw( void )
    util_draw_arrays(ctx, PIPE_PRIM_POINTS, 0, Elements(vertices));
    ctx->flush(ctx, PIPE_FLUSH_RENDER_CACHE, NULL);
 
-#if 0
-   /* At the moment, libgraw leaks out/makes available some of the
-    * symbols from gallium/auxiliary, including these debug helpers.
-    * Will eventually want to bless some of these paths, and lock the
-    * others down so they aren't accessible from test programs.
-    *
-    * This currently just happens to work on debug builds - a release
-    * build will probably fail to link here:
-    */
-   debug_dump_surface_bmp(ctx, "result.bmp", surf);
-#endif
+   graw_save_surface_to_file(ctx, surf, "result.bmp");
 
    screen->flush_frontbuffer(screen, surf, window);
 }
-- 
1.7.0.2.msysgit.0



More information about the mesa-dev mailing list