2 #include "pipe/p_compiler.h"
3 #include "pipe/p_context.h"
4 #include "pipe/p_state.h"
5 #include "tgsi/tgsi_text.h"
6 #include "util/u_debug.h"
7 #include "util/u_memory.h"
8 #include "state_tracker/graw.h"
11 /* Helper functions. These are the same for all graw implementations.
14 graw_parse_geometry_shader(struct pipe_context
*pipe
,
17 struct tgsi_token tokens
[1024];
18 struct pipe_shader_state state
;
20 if (!tgsi_text_translate(text
, tokens
, Elements(tokens
)))
23 state
.tokens
= tokens
;
24 return pipe
->create_gs_state(pipe
, &state
);
28 graw_parse_vertex_shader(struct pipe_context
*pipe
,
31 struct tgsi_token tokens
[1024];
32 struct pipe_shader_state state
;
34 if (!tgsi_text_translate(text
, tokens
, Elements(tokens
)))
37 state
.tokens
= tokens
;
38 return pipe
->create_vs_state(pipe
, &state
);
42 graw_parse_fragment_shader(struct pipe_context
*pipe
,
45 struct tgsi_token tokens
[1024];
46 struct pipe_shader_state state
;
48 if (!tgsi_text_translate(text
, tokens
, Elements(tokens
)))
51 state
.tokens
= tokens
;
52 return pipe
->create_fs_state(pipe
, &state
);
55 static char out_filename
[256] = "";
58 graw_parse_args(int *argi
,
62 if (strcmp(argv
[*argi
], "-o") == 0) {
63 if (*argi
+ 1 >= argc
) {
67 strncpy(out_filename
, argv
[*argi
+ 1], sizeof(out_filename
) - 1);
68 out_filename
[sizeof(out_filename
) - 1] = '\0';
77 graw_save_surface_to_file(struct pipe_context
*pipe
,
78 struct pipe_surface
*surface
,
81 if (!filename
|| !*filename
) {
82 filename
= out_filename
;
83 if (!filename
|| !*filename
) {
88 /* XXX: Make that working in release builds.
90 debug_dump_surface_bmp(pipe
, filename
, surface
);