Merge remote branch 'origin/master' into nv50-compiler
[mesa.git] / src / gallium / targets / graw-xlib / graw_util.c
1
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_memory.h"
7 #include "state_tracker/graw.h"
8
9
10 /* Helper functions. These are the same for all graw implementations.
11 */
12 void *graw_parse_geometry_shader(struct pipe_context *pipe,
13 const char *text)
14 {
15 struct tgsi_token tokens[1024];
16 struct pipe_shader_state state;
17
18 if (!tgsi_text_translate(text, tokens, Elements(tokens)))
19 return NULL;
20
21 state.tokens = tokens;
22 return pipe->create_gs_state(pipe, &state);
23 }
24
25 void *graw_parse_vertex_shader(struct pipe_context *pipe,
26 const char *text)
27 {
28 struct tgsi_token tokens[1024];
29 struct pipe_shader_state state;
30
31 if (!tgsi_text_translate(text, tokens, Elements(tokens)))
32 return NULL;
33
34 state.tokens = tokens;
35 return pipe->create_vs_state(pipe, &state);
36 }
37
38 void *graw_parse_fragment_shader(struct pipe_context *pipe,
39 const char *text)
40 {
41 struct tgsi_token tokens[1024];
42 struct pipe_shader_state state;
43
44 if (!tgsi_text_translate(text, tokens, Elements(tokens)))
45 return NULL;
46
47 state.tokens = tokens;
48 return pipe->create_fs_state(pipe, &state);
49 }
50