From 136ff67ce8a626e628dd76aeb7feba8cf9436cd7 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 5 Nov 2010 18:54:02 +0100 Subject: graw: Export graw_save_surface_to_file(). Allows applications to dump surfaces to file without referencing gallium/auxiliary entry points statically. Existing test apps have been modified such that they save the contents of the fronbuffer only when the `-o' option's specified. --- src/gallium/targets/graw-null/graw_util.c | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/gallium/targets') diff --git a/src/gallium/targets/graw-null/graw_util.c b/src/gallium/targets/graw-null/graw_util.c index 531757f145..e5cf526d33 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,41 @@ graw_parse_fragment_shader(struct pipe_context *pipe, return pipe->create_fs_state(pipe, &state); } +static char out_filename[256] = ""; + +PUBLIC boolean +graw_parse_args(int *argi, + int argc, + char *argv[]) +{ + if (strcmp(argv[*argi], "-o") == 0) { + if (*argi + 1 >= argc) { + return FALSE; + } + + strncpy(out_filename, argv[*argi + 1], sizeof(out_filename) - 1); + out_filename[sizeof(out_filename) - 1] = '\0'; + *argi += 2; + return TRUE; + } + + return FALSE; +} + +PUBLIC boolean +graw_save_surface_to_file(struct pipe_context *pipe, + struct pipe_surface *surface, + const char *filename) +{ + if (!filename || !*filename) { + filename = out_filename; + if (!filename || !*filename) { + return FALSE; + } + } + + /* XXX: Make that working in release builds. + */ + debug_dump_surface_bmp(pipe, filename, surface); + return TRUE; +} -- cgit v1.2.3