aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/targets
diff options
context:
space:
mode:
authorMichal Krol <[email protected]>2010-11-05 18:54:02 +0100
committerMichal Krol <[email protected]>2010-11-08 17:24:11 +0100
commit136ff67ce8a626e628dd76aeb7feba8cf9436cd7 (patch)
tree52c319f96639d8ce4a867d16b34010f8c97ad144 /src/gallium/targets
parent9e7132b52debd3d592391ce89d3582027cb0e161 (diff)
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.
Diffstat (limited to 'src/gallium/targets')
-rw-r--r--src/gallium/targets/graw-null/graw_util.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/gallium/targets/graw-null/graw_util.c b/src/gallium/targets/graw-null/graw_util.c
index 531757f1457..e5cf526d33a 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;
+}