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.
15 graw_parse_geometry_shader(struct pipe_context
*pipe
,
18 struct tgsi_token tokens
[1024];
19 struct pipe_shader_state state
;
21 if (!tgsi_text_translate(text
, tokens
, Elements(tokens
)))
24 memset(&state
, 0, sizeof state
);
25 state
.tokens
= tokens
;
26 return pipe
->create_gs_state(pipe
, &state
);
30 graw_parse_vertex_shader(struct pipe_context
*pipe
,
33 struct tgsi_token tokens
[1024];
34 struct pipe_shader_state state
;
36 if (!tgsi_text_translate(text
, tokens
, Elements(tokens
)))
39 memset(&state
, 0, sizeof state
);
40 state
.tokens
= tokens
;
41 return pipe
->create_vs_state(pipe
, &state
);
45 graw_parse_fragment_shader(struct pipe_context
*pipe
,
48 struct tgsi_token tokens
[1024];
49 struct pipe_shader_state state
;
51 if (!tgsi_text_translate(text
, tokens
, Elements(tokens
)))
54 memset(&state
, 0, sizeof state
);
55 state
.tokens
= tokens
;
56 return pipe
->create_fs_state(pipe
, &state
);
59 static char out_filename
[256] = "";
62 graw_parse_args(int *argi
,
66 if (strcmp(argv
[*argi
], "-o") == 0) {
67 if (*argi
+ 1 >= argc
) {
71 strncpy(out_filename
, argv
[*argi
+ 1], sizeof(out_filename
) - 1);
72 out_filename
[sizeof(out_filename
) - 1] = '\0';
81 graw_save_surface_to_file(struct pipe_context
*pipe
,
82 struct pipe_surface
*surface
,
85 if (!filename
|| !*filename
) {
86 filename
= out_filename
;
87 if (!filename
|| !*filename
) {
92 /* XXX: Make that working in release builds.
94 debug_dump_surface_bmp(pipe
, filename
, surface
);