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 state
.tokens
= tokens
;
25 return pipe
->create_gs_state(pipe
, &state
);
29 graw_parse_vertex_shader(struct pipe_context
*pipe
,
32 struct tgsi_token tokens
[1024];
33 struct pipe_shader_state state
;
35 if (!tgsi_text_translate(text
, tokens
, Elements(tokens
)))
38 state
.tokens
= tokens
;
39 return pipe
->create_vs_state(pipe
, &state
);
43 graw_parse_fragment_shader(struct pipe_context
*pipe
,
46 struct tgsi_token tokens
[1024];
47 struct pipe_shader_state state
;
49 if (!tgsi_text_translate(text
, tokens
, Elements(tokens
)))
52 state
.tokens
= tokens
;
53 return pipe
->create_fs_state(pipe
, &state
);
56 static char out_filename
[256] = "";
59 graw_parse_args(int *argi
,
63 if (strcmp(argv
[*argi
], "-o") == 0) {
64 if (*argi
+ 1 >= argc
) {
68 strncpy(out_filename
, argv
[*argi
+ 1], sizeof(out_filename
) - 1);
69 out_filename
[sizeof(out_filename
) - 1] = '\0';
78 graw_save_surface_to_file(struct pipe_context
*pipe
,
79 struct pipe_surface
*surface
,
82 if (!filename
|| !*filename
) {
83 filename
= out_filename
;
84 if (!filename
|| !*filename
) {
89 /* XXX: Make that working in release builds.
91 debug_dump_surface_bmp(pipe
, filename
, surface
);