diff options
author | Rob Clark <[email protected]> | 2015-10-17 13:34:24 -0400 |
---|---|---|
committer | Rob Clark <[email protected]> | 2016-05-11 12:20:11 -0400 |
commit | 425dc4c4b3663c619634de9f9f00c7765e7d0320 (patch) | |
tree | 3053cbc43904815fe895d625e554bcf48235aac8 /src/gallium/include/pipe | |
parent | 4500d17245d0c4bd0b52bf444cf1d90bab932794 (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 <[email protected]>
Reviewed-by: Roland Scheidegger <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/gallium/include/pipe')
-rw-r--r-- | src/gallium/include/pipe/p_defines.h | 12 | ||||
-rw-r--r-- | src/gallium/include/pipe/p_state.h | 26 |
2 files changed, 35 insertions, 3 deletions
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index bd02a79f19c..2f481091858 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -799,12 +799,20 @@ enum pipe_shader_cap /** * Shader intermediate representation. + * + * Note that if the driver requests something other than TGSI, it must + * always be prepared to receive TGSI in addition to its preferred IR. + * If the driver requests TGSI as its preferred IR, it will *always* + * get TGSI. + * + * Note that PIPE_SHADER_IR_TGSI should be zero for backwards compat with + * state trackers that only understand TGSI. */ enum pipe_shader_ir { - PIPE_SHADER_IR_TGSI, + PIPE_SHADER_IR_TGSI = 0, PIPE_SHADER_IR_LLVM, - PIPE_SHADER_IR_NATIVE + PIPE_SHADER_IR_NATIVE, }; /** diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index 9e466cefd8c..3f14e41dff1 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -211,13 +211,37 @@ struct pipe_stream_output_info } output[PIPE_MAX_SO_OUTPUTS]; }; - +/** + * The 'type' parameter identifies whether the shader state contains TGSI + * tokens, etc. If the driver returns 'PIPE_SHADER_IR_TGSI' for the + * 'PIPE_SHADER_CAP_PREFERRED_IR' shader param, the ir will *always* be + * 'PIPE_SHADER_IR_TGSI' and the tokens ptr will be valid. If the driver + * requests a different 'pipe_shader_ir' type, then it must check the 'type' + * enum to see if it is getting TGSI tokens or its preferred IR. + * + * TODO pipe_compute_state should probably get similar treatment to handle + * multiple IR's in a cleaner way.. + */ struct pipe_shader_state { + enum pipe_shader_ir type; + /* TODO move tokens into union. */ const struct tgsi_token *tokens; + union { + void *llvm; + void *native; + } ir; struct pipe_stream_output_info stream_output; }; +static inline void +pipe_shader_state_from_tgsi(struct pipe_shader_state *state, + const struct tgsi_token *tokens) +{ + state->type = PIPE_SHADER_IR_TGSI; + state->tokens = tokens; + memset(&state->stream_output, 0, sizeof(state->stream_output)); +} struct pipe_depth_state { |