};
struct tgsi_token tokens[1000];
- struct pipe_shader_state state = {tokens};
+ struct pipe_shader_state state;
if (!tgsi_text_translate(fragment_shader_text, tokens, ARRAY_SIZE(tokens))) {
assert(0);
FREE(hud);
return NULL;
}
-
+ pipe_shader_state_from_tgsi(&state, tokens);
hud->fs_text = pipe->create_fs_state(pipe, &state);
}
};
struct tgsi_token tokens[1000];
- struct pipe_shader_state state = {tokens};
-
+ struct pipe_shader_state state;
if (!tgsi_text_translate(vertex_shader_text, tokens, ARRAY_SIZE(tokens))) {
assert(0);
pipe_resource_reference(&hud->font.texture, NULL);
FREE(hud);
return NULL;
}
-
+ pipe_shader_state_from_tgsi(&state, tokens);
hud->vs = pipe->create_vs_state(pipe, &state);
}
return NULL;
}
- state.tokens = tokens;
- memset(&state.stream_output, 0, sizeof(state.stream_output));
+ pipe_shader_state_from_tgsi(&state, tokens);
if (isvs) {
ret_state = pipe->create_vs_state(pipe, &state);
{
struct pipe_shader_state state;
- state.tokens = ureg_finalize(ureg);
+ pipe_shader_state_from_tgsi(&state, ureg_finalize(ureg));
if(!state.tokens)
return NULL;
if (so)
state.stream_output = *so;
- else
- memset(&state.stream_output, 0, sizeof(state.stream_output));
switch (ureg->processor) {
case PIPE_SHADER_VERTEX:
"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);
}
"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);
}
"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);
}
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" : "",
assert(0);
return NULL;
}
+ pipe_shader_state_from_tgsi(&state, tokens);
#if 0
tgsi_dump(state.tokens, 0);
#endif
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);
assert(0);
return NULL;
}
+ pipe_shader_state_from_tgsi(&state, tokens);
#if 0
tgsi_dump(state.tokens, 0);
#endif
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);
assert(0);
return NULL;
}
+ pipe_shader_state_from_tgsi(&state, tokens);
#if 0
tgsi_dump(state.tokens, 0);
#endif
"MOV OUT[0], CONST[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))) {
puts("Can't compile a fragment shader.");
util_report_result(FAIL);
return;
}
+ pipe_shader_state_from_tgsi(&state, tokens);
fs = ctx->create_fs_state(ctx, &state);
cso_set_fragment_shader_handle(cso, fs);
}
/**
* 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,
};
/**
} 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
{