summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/util/u_simple_shaders.c
diff options
context:
space:
mode:
authorRob Clark <robdclark@gmail.com>2015-10-17 13:34:24 -0400
committerRob Clark <robclark@freedesktop.org>2016-05-11 12:20:11 -0400
commit425dc4c4b3663c619634de9f9f00c7765e7d0320 (patch)
tree3053cbc43904815fe895d625e554bcf48235aac8 /src/gallium/auxiliary/util/u_simple_shaders.c
parent4500d17245d0c4bd0b52bf444cf1d90bab932794 (diff)
gallium: refactor pipe_shader_state to support multiple IR's
The goal is to allow the pipe driver to request something other than TGSI, but detect whether what is getting is TGSI vs what it requested. The pipe drivers will always have to support TGSI (and convert that into whatever it is that they prefer), but in some cases we should be able to skip the TGSI intermediate step (such as glsl->nir vs glsl->tgsi->nir). I think pipe_compute_state should get similar treatment. Currently, afaict, it has one user and one consumer, which has allowed it to be sloppy wrt. supporting alternative IR's. Signed-off-by: Rob Clark <robclark@freedesktop.org> Reviewed-by: Roland Scheidegger <sroland@vmware.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Diffstat (limited to 'src/gallium/auxiliary/util/u_simple_shaders.c')
-rw-r--r--src/gallium/auxiliary/util/u_simple_shaders.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c b/src/gallium/auxiliary/util/u_simple_shaders.c
index 5b5c8512470..1220e187eac 100644
--- a/src/gallium/auxiliary/util/u_simple_shaders.c
+++ b/src/gallium/auxiliary/util/u_simple_shaders.c
@@ -121,12 +121,13 @@ void *util_make_layered_clear_vertex_shader(struct pipe_context *pipe)
"MOV OUT[2], SV[0]\n"
"END\n";
struct tgsi_token tokens[1000];
- struct pipe_shader_state state = {tokens};
+ struct pipe_shader_state state;
if (!tgsi_text_translate(text, tokens, ARRAY_SIZE(tokens))) {
assert(0);
return NULL;
}
+ pipe_shader_state_from_tgsi(&state, tokens);
return pipe->create_vs_state(pipe, &state);
}
@@ -149,12 +150,13 @@ void *util_make_layered_clear_helper_vertex_shader(struct pipe_context *pipe)
"MOV OUT[2].x, SV[0].xxxx\n"
"END\n";
struct tgsi_token tokens[1000];
- struct pipe_shader_state state = {tokens};
+ struct pipe_shader_state state;
if (!tgsi_text_translate(text, tokens, ARRAY_SIZE(tokens))) {
assert(0);
return NULL;
}
+ pipe_shader_state_from_tgsi(&state, tokens);
return pipe->create_vs_state(pipe, &state);
}
@@ -192,12 +194,13 @@ void *util_make_layered_clear_geometry_shader(struct pipe_context *pipe)
"EMIT IMM[0].xxxx\n"
"END\n";
struct tgsi_token tokens[1000];
- struct pipe_shader_state state = {tokens};
+ struct pipe_shader_state state;
if (!tgsi_text_translate(text, tokens, ARRAY_SIZE(tokens))) {
assert(0);
return NULL;
}
+ pipe_shader_state_from_tgsi(&state, tokens);
return pipe->create_gs_state(pipe, &state);
}
@@ -471,7 +474,7 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe,
char text[sizeof(shader_templ)+100];
struct tgsi_token tokens[1000];
- struct pipe_shader_state state = {tokens};
+ struct pipe_shader_state state;
sprintf(text, shader_templ,
write_all_cbufs ? "PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1\n" : "",
@@ -482,6 +485,7 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe,
assert(0);
return NULL;
}
+ pipe_shader_state_from_tgsi(&state, tokens);
#if 0
tgsi_dump(state.tokens, 0);
#endif
@@ -558,7 +562,7 @@ util_make_fs_blit_msaa_gen(struct pipe_context *pipe,
const char *type = tgsi_texture_names[tgsi_tex];
char text[sizeof(shader_templ)+100];
struct tgsi_token tokens[1000];
- struct pipe_shader_state state = {tokens};
+ struct pipe_shader_state state;
assert(tgsi_tex == TGSI_TEXTURE_2D_MSAA ||
tgsi_tex == TGSI_TEXTURE_2D_ARRAY_MSAA);
@@ -571,6 +575,7 @@ util_make_fs_blit_msaa_gen(struct pipe_context *pipe,
assert(0);
return NULL;
}
+ pipe_shader_state_from_tgsi(&state, tokens);
#if 0
tgsi_dump(state.tokens, 0);
#endif
@@ -659,7 +664,7 @@ util_make_fs_blit_msaa_depthstencil(struct pipe_context *pipe,
const char *type = tgsi_texture_names[tgsi_tex];
char text[sizeof(shader_templ)+100];
struct tgsi_token tokens[1000];
- struct pipe_shader_state state = {tokens};
+ struct pipe_shader_state state;
assert(tgsi_tex == TGSI_TEXTURE_2D_MSAA ||
tgsi_tex == TGSI_TEXTURE_2D_ARRAY_MSAA);
@@ -670,6 +675,7 @@ util_make_fs_blit_msaa_depthstencil(struct pipe_context *pipe,
assert(0);
return NULL;
}
+ pipe_shader_state_from_tgsi(&state, tokens);
#if 0
tgsi_dump(state.tokens, 0);
#endif