g3dvl: Use sobel filter for chroma interpolation
[mesa/nouveau-pmpeg.git] / src / gallium / targets / graw-null / graw_util.c
blob09cba895d2a8f334cc5345c4acba6dd4830b848f
2 #include "pipe/p_compiler.h"
3 #include "pipe/p_context.h"
4 #include "pipe/p_shader_tokens.h"
5 #include "pipe/p_state.h"
6 #include "tgsi/tgsi_text.h"
7 #include "util/u_debug.h"
8 #include "util/u_memory.h"
9 #include "state_tracker/graw.h"
12 /* Helper functions. These are the same for all graw implementations.
14 PUBLIC void *
15 graw_parse_geometry_shader(struct pipe_context *pipe,
16 const char *text)
18 struct tgsi_token tokens[1024];
19 struct pipe_shader_state state;
21 if (!tgsi_text_translate(text, tokens, Elements(tokens)))
22 return NULL;
24 state.tokens = tokens;
25 return pipe->create_gs_state(pipe, &state);
28 PUBLIC void *
29 graw_parse_vertex_shader(struct pipe_context *pipe,
30 const char *text)
32 struct tgsi_token tokens[1024];
33 struct pipe_shader_state state;
35 if (!tgsi_text_translate(text, tokens, Elements(tokens)))
36 return NULL;
38 state.tokens = tokens;
39 return pipe->create_vs_state(pipe, &state);
42 PUBLIC void *
43 graw_parse_fragment_shader(struct pipe_context *pipe,
44 const char *text)
46 struct tgsi_token tokens[1024];
47 struct pipe_shader_state state;
49 if (!tgsi_text_translate(text, tokens, Elements(tokens)))
50 return NULL;
52 state.tokens = tokens;
53 return pipe->create_fs_state(pipe, &state);
56 static char out_filename[256] = "";
58 PUBLIC boolean
59 graw_parse_args(int *argi,
60 int argc,
61 char *argv[])
63 if (strcmp(argv[*argi], "-o") == 0) {
64 if (*argi + 1 >= argc) {
65 return FALSE;
68 strncpy(out_filename, argv[*argi + 1], sizeof(out_filename) - 1);
69 out_filename[sizeof(out_filename) - 1] = '\0';
70 *argi += 2;
71 return TRUE;
74 return FALSE;
77 PUBLIC boolean
78 graw_save_surface_to_file(struct pipe_context *pipe,
79 struct pipe_surface *surface,
80 const char *filename)
82 if (!filename || !*filename) {
83 filename = out_filename;
84 if (!filename || !*filename) {
85 return FALSE;
89 /* XXX: Make that working in release builds.
91 debug_dump_surface_bmp(pipe, filename, surface);
92 return TRUE;