struct si_shader;
+/* State of the context creating the shader object. */
+struct si_compiler_ctx_state {
+ /* Should only be used by si_init_shader_selector_async and
+ * si_build_shader_variant if thread_index == -1 (non-threaded). */
+ LLVMTargetMachineRef tm;
+
+ /* Used if thread_index == -1 or if debug.async is true. */
+ struct pipe_debug_callback debug;
+
+ /* Used for creating the log string for gallium/ddebug. */
+ bool is_debug_context;
+};
+
/* A shader selector is a gallium CSO and contains shader variants and
* binaries for one TGSI program. This can be shared by multiple contexts.
*/
struct si_shader_selector {
struct si_screen *screen;
struct util_queue_fence ready;
-
- /* Should only be used by si_init_shader_selector_async
- * if thread_index == -1 (non-threaded). */
- LLVMTargetMachineRef tm;
- struct pipe_debug_callback debug;
- bool is_debug_context;
+ struct si_compiler_ctx_state compiler_ctx_state;
pipe_mutex mutex;
struct si_shader *first_variant; /* immutable after the first variant */
struct si_shader_selector *sel = shader->selector;
struct si_screen *sscreen = sel->screen;
LLVMTargetMachineRef tm;
- struct pipe_debug_callback *debug = &sel->debug;
+ struct pipe_debug_callback *debug = &sel->compiler_ctx_state.debug;
int r;
if (thread_index >= 0) {
if (!debug->async)
debug = NULL;
} else {
- tm = sel->tm;
+ tm = sel->compiler_ctx_state.tm;
}
r = si_shader_create(sscreen, tm, shader, debug);
return;
}
- if (sel->is_debug_context) {
+ if (sel->compiler_ctx_state.is_debug_context) {
FILE *f = open_memstream(&shader->shader_log,
&shader->shader_log_size);
if (f) {
struct si_shader_selector *sel = (struct si_shader_selector *)job;
struct si_screen *sscreen = sel->screen;
LLVMTargetMachineRef tm;
- struct pipe_debug_callback *debug = &sel->debug;
+ struct pipe_debug_callback *debug = &sel->compiler_ctx_state.debug;
unsigned i;
if (thread_index >= 0) {
if (!debug->async)
debug = NULL;
} else {
- tm = sel->tm;
+ tm = sel->compiler_ctx_state.tm;
}
/* Compile the main shader part for use with a prolog and/or epilog.
return NULL;
sel->screen = sscreen;
- sel->tm = sctx->tm;
- sel->debug = sctx->b.debug;
- sel->is_debug_context = sctx->is_debug;
+ sel->compiler_ctx_state.tm = sctx->tm;
+ sel->compiler_ctx_state.debug = sctx->b.debug;
+ sel->compiler_ctx_state.is_debug_context = sctx->is_debug;
sel->tokens = tgsi_dup_tokens(state->tokens);
if (!sel->tokens) {
FREE(sel);