gallium: move pipe_shader_state TGSI tokens into union

This commit is contained in:
ljh 2026-02-28 10:35:50 +09:00 committed by yserrr
parent f694b2ac6f
commit 9b16f9216e
57 changed files with 170 additions and 172 deletions

View file

@ -48,7 +48,7 @@ draw_create_fragment_shader(struct draw_context *draw,
if (dfs) {
dfs->base = *shader;
if (shader->type == PIPE_SHADER_IR_TGSI)
tgsi_scan_shader(shader->tokens, &dfs->info);
tgsi_scan_shader(shader->ir.tokens, &dfs->info);
else
nir_tgsi_scan_shader(shader->ir.nir, &dfs->info, true);
}

View file

@ -735,9 +735,9 @@ draw_geometry_shader_prepare(struct draw_geometry_shader *shader,
{
bool use_llvm = draw->llvm != NULL;
if (!use_llvm &&
shader && shader->machine->Tokens != shader->state.tokens) {
shader && shader->machine->Tokens != shader->state.ir.tokens) {
tgsi_exec_machine_bind_shader(shader->machine,
shader->state.tokens,
shader->state.ir.tokens,
draw->gs.tgsi.sampler,
draw->gs.tgsi.image,
draw->gs.tgsi.buffer);
@ -819,13 +819,13 @@ draw_create_geometry_shader(struct draw_context *draw,
gs->state = *state;
if (state->type == PIPE_SHADER_IR_TGSI) {
gs->state.tokens = tgsi_dup_tokens(state->tokens);
if (!gs->state.tokens) {
gs->state.ir.tokens = tgsi_dup_tokens(state->ir.tokens);
if (!gs->state.ir.tokens) {
FREE(gs);
return NULL;
}
tgsi_scan_shader(state->tokens, &gs->info);
tgsi_scan_shader(state->ir.tokens, &gs->info);
gs->num_vertex_streams = 1;
for (unsigned i = 0; i < gs->state.stream_output.num_outputs; i++) {
if (gs->state.stream_output.output[i].stream >= gs->num_vertex_streams)
@ -988,7 +988,7 @@ draw_delete_geometry_shader(struct draw_context *draw,
}
#endif
if (draw->gs.tgsi.machine && draw->gs.tgsi.machine->Tokens == dgs->state.tokens)
if (draw->gs.tgsi.machine && draw->gs.tgsi.machine->Tokens == dgs->state.ir.tokens)
draw->gs.tgsi.machine->Tokens = NULL;
for (unsigned i = 0; i < TGSI_MAX_VERTEX_STREAMS; i++)
@ -996,7 +996,7 @@ draw_delete_geometry_shader(struct draw_context *draw,
if (dgs->state.type == PIPE_SHADER_IR_NIR && dgs->state.ir.nir)
ralloc_free(dgs->state.ir.nir);
FREE((void*) dgs->state.tokens);
FREE((void*) dgs->state.ir.tokens);
FREE(dgs);
}

View file

@ -511,7 +511,7 @@ draw_llvm_create_variant(struct draw_llvm *llvm,
if (gallivm_debug & (GALLIVM_DEBUG_TGSI | GALLIVM_DEBUG_IR)) {
if (llvm->draw->vs.vertex_shader->state.type == PIPE_SHADER_IR_TGSI)
tgsi_dump(llvm->draw->vs.vertex_shader->state.tokens, 0);
tgsi_dump(llvm->draw->vs.vertex_shader->state.ir.tokens, 0);
else
nir_print_shader(llvm->draw->vs.vertex_shader->state.ir.nir, stderr);
draw_llvm_dump_variant_key(&variant->key);
@ -586,7 +586,7 @@ generate_vs(struct draw_llvm_variant *variant,
struct lp_build_mask_context *bld_mask)
{
struct draw_llvm *llvm = variant->llvm;
const struct tgsi_token *tokens = llvm->draw->vs.vertex_shader->state.tokens;
const struct tgsi_token *tokens = llvm->draw->vs.vertex_shader->state.ir.tokens;
LLVMValueRef consts_ptr =
lp_jit_resources_constants(variant->gallivm, variant->resources_type, resources_ptr);
LLVMValueRef ssbos_ptr =
@ -2331,7 +2331,7 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,
char func_name[64];
struct lp_type gs_type;
struct draw_gs_llvm_iface gs_iface;
const struct tgsi_token *tokens = variant->shader->base.state.tokens;
const struct tgsi_token *tokens = variant->shader->base.state.ir.tokens;
LLVMValueRef consts_ptr;
LLVMValueRef ssbos_ptr;
LLVMValueRef outputs[PIPE_MAX_SHADER_OUTPUTS][TGSI_NUM_CHANNELS];

View file

@ -314,7 +314,7 @@ generate_aaline_fs(struct aaline_stage *aaline)
const struct pipe_shader_state *orig_fs = &aaline->fs->state;
struct pipe_shader_state aaline_fs;
struct aa_transform_context transform;
const unsigned newLen = tgsi_num_tokens(orig_fs->tokens) + NUM_NEW_TOKENS;
const unsigned newLen = tgsi_num_tokens(orig_fs->ir.tokens) + NUM_NEW_TOKENS;
aaline_fs = *orig_fs; /* copy to init */
@ -330,8 +330,8 @@ generate_aaline_fs(struct aaline_stage *aaline)
transform.base.transform_declaration = aa_transform_decl;
transform.base.transform_immediate = aa_immediate;
aaline_fs.tokens = tgsi_transform_shader(orig_fs->tokens, newLen, &transform.base);
if (!aaline_fs.tokens)
aaline_fs.ir.tokens = tgsi_transform_shader(orig_fs->ir.tokens, newLen, &transform.base);
if (!aaline_fs.ir.tokens)
return false;
#if 0 /* debug */
@ -345,7 +345,7 @@ generate_aaline_fs(struct aaline_stage *aaline)
if (aaline->fs->aaline_fs != NULL)
aaline->fs->generic_attrib = transform.maxGeneric + 1;
FREE((void *)aaline_fs.tokens);
FREE((void *)aaline_fs.ir.tokens);
return aaline->fs->aaline_fs != NULL;
}
@ -650,7 +650,7 @@ aaline_create_fs_state(struct pipe_context *pipe,
aafs->state.type = fs->type;
if (fs->type == PIPE_SHADER_IR_TGSI)
aafs->state.tokens = tgsi_dup_tokens(fs->tokens);
aafs->state.ir.tokens = tgsi_dup_tokens(fs->ir.tokens);
else
aafs->state.ir.nir = nir_shader_clone(NULL, fs->ir.nir);
@ -697,7 +697,7 @@ aaline_delete_fs_state(struct pipe_context *pipe, void *fs)
}
if (aafs->state.type == PIPE_SHADER_IR_TGSI)
FREE((void*)aafs->state.tokens);
FREE((void*)aafs->state.ir.tokens);
else
ralloc_free(aafs->state.ir.nir);
FREE(aafs);

View file

@ -365,7 +365,7 @@ generate_aapoint_fs(struct aapoint_stage *aapoint)
const struct pipe_shader_state *orig_fs = &aapoint->fs->state;
struct pipe_shader_state aapoint_fs;
struct aa_transform_context transform;
const unsigned newLen = tgsi_num_tokens(orig_fs->tokens) + NUM_NEW_TOKENS;
const unsigned newLen = tgsi_num_tokens(orig_fs->ir.tokens) + NUM_NEW_TOKENS;
struct pipe_context *pipe = aapoint->stage.draw->pipe;
aapoint_fs = *orig_fs; /* copy to init */
@ -383,8 +383,8 @@ generate_aapoint_fs(struct aapoint_stage *aapoint)
transform.base.transform_instruction = aa_transform_inst;
transform.base.transform_declaration = aa_transform_decl;
aapoint_fs.tokens = tgsi_transform_shader(orig_fs->tokens, newLen, &transform.base);
if (!aapoint_fs.tokens)
aapoint_fs.ir.tokens = tgsi_transform_shader(orig_fs->ir.tokens, newLen, &transform.base);
if (!aapoint_fs.ir.tokens)
return false;
#if 0 /* debug */
@ -400,11 +400,11 @@ generate_aapoint_fs(struct aapoint_stage *aapoint)
goto fail;
aapoint->fs->generic_attrib = transform.maxGeneric + 1;
FREE((void *)aapoint_fs.tokens);
FREE((void *)aapoint_fs.ir.tokens);
return true;
fail:
FREE((void *)aapoint_fs.tokens);
FREE((void *)aapoint_fs.ir.tokens);
return false;
}
@ -746,7 +746,7 @@ aapoint_create_fs_state(struct pipe_context *pipe,
aafs->state.type = fs->type;
if (fs->type == PIPE_SHADER_IR_TGSI)
aafs->state.tokens = tgsi_dup_tokens(fs->tokens);
aafs->state.ir.tokens = tgsi_dup_tokens(fs->ir.tokens);
else
aafs->state.ir.nir = nir_shader_clone(NULL, fs->ir.nir);
/* pass-through */
@ -782,7 +782,7 @@ aapoint_delete_fs_state(struct pipe_context *pipe, void *fs)
aapoint->driver_delete_fs_state(pipe, aafs->aapoint_fs);
if (aafs->state.type == PIPE_SHADER_IR_TGSI)
FREE((void*)aafs->state.tokens);
FREE((void*)aafs->state.ir.tokens);
else
ralloc_free(aafs->state.ir.nir);

View file

@ -137,11 +137,11 @@ generate_pstip_fs(struct pstip_stage *pstip)
pstip_fs = *orig_fs; /* copy to init */
if (orig_fs->type == PIPE_SHADER_IR_TGSI) {
pstip_fs.tokens = util_pstipple_create_fragment_shader(orig_fs->tokens,
pstip_fs.ir.tokens = util_pstipple_create_fragment_shader(orig_fs->ir.tokens,
&pstip->fs->sampler_unit,
0,
wincoord_file);
if (pstip_fs.tokens == NULL)
if (pstip_fs.ir.tokens == NULL)
return false;
} else {
pstip_fs.ir.nir = nir_shader_clone(NULL, orig_fs->ir.nir);
@ -154,7 +154,7 @@ generate_pstip_fs(struct pstip_stage *pstip)
pstip->fs->pstip_fs = pstip->driver_create_fs_state(pipe, &pstip_fs);
FREE((void *)pstip_fs.tokens);
FREE((void *)pstip_fs.ir.tokens);
if (!pstip->fs->pstip_fs)
return false;
@ -343,7 +343,7 @@ pstip_create_fs_state(struct pipe_context *pipe,
if (pstipfs) {
pstipfs->state.type = fs->type;
if (fs->type == PIPE_SHADER_IR_TGSI)
pstipfs->state.tokens = tgsi_dup_tokens(fs->tokens);
pstipfs->state.ir.tokens = tgsi_dup_tokens(fs->ir.tokens);
else
pstipfs->state.ir.nir = nir_shader_clone(NULL, fs->ir.nir);
@ -380,7 +380,7 @@ pstip_delete_fs_state(struct pipe_context *pipe, void *fs)
pstip->driver_delete_fs_state(pstip->pipe, pstipfs->pstip_fs);
if (pstipfs->state.type == PIPE_SHADER_IR_TGSI)
FREE((void*)pstipfs->state.tokens);
FREE((void*)pstipfs->state.ir.tokens);
else
ralloc_free(pstipfs->state.ir.nir);
FREE(pstipfs);

View file

@ -559,7 +559,7 @@ draw_vbo(struct draw_context *draw,
}
if (0)
tgsi_dump(draw->vs.vertex_shader->state.tokens, 0);
tgsi_dump(draw->vs.vertex_shader->state.ir.tokens, 0);
if (0) {
debug_printf("Elements:\n");

View file

@ -62,7 +62,7 @@ draw_create_vertex_shader(struct draw_context *draw,
struct pipe_shader_state state = *shader;
if (draw->dump_vs) {
tgsi_dump(shader->tokens, 0);
tgsi_dump(shader->ir.tokens, 0);
}
#if DRAW_LLVM_AVAILABLE
@ -72,7 +72,7 @@ draw_create_vertex_shader(struct draw_context *draw,
if (shader->type == PIPE_SHADER_IR_NIR &&
!screen->shader_caps[MESA_SHADER_VERTEX].integers) {
state.type = PIPE_SHADER_IR_TGSI;
state.tokens = nir_to_tgsi(shader->ir.nir, screen);
state.ir.tokens = nir_to_tgsi(shader->ir.nir, screen);
is_allocated = true;
}
vs = draw_create_vs_llvm(draw, &state);
@ -85,7 +85,7 @@ draw_create_vertex_shader(struct draw_context *draw,
#if DRAW_LLVM_AVAILABLE
if (is_allocated) {
ureg_free_tokens(state.tokens);
ureg_free_tokens(state.ir.tokens);
}
#endif

View file

@ -72,9 +72,9 @@ vs_exec_prepare(struct draw_vertex_shader *shader,
/* Specify the vertex program to interpret/execute.
* Avoid rebinding when possible.
*/
if (evs->machine->Tokens != shader->state.tokens) {
if (evs->machine->Tokens != shader->state.ir.tokens) {
tgsi_exec_machine_bind_shader(evs->machine,
shader->state.tokens,
shader->state.ir.tokens,
draw->vs.tgsi.sampler,
draw->vs.tgsi.image,
draw->vs.tgsi.buffer);
@ -209,7 +209,7 @@ vs_exec_run_linear(struct draw_vertex_shader *shader,
static void
vs_exec_delete(struct draw_vertex_shader *dvs)
{
FREE((void*) dvs->state.tokens);
FREE((void*) dvs->state.ir.tokens);
FREE(dvs);
}
@ -225,20 +225,20 @@ draw_create_vs_exec(struct draw_context *draw,
if (state->type == PIPE_SHADER_IR_NIR) {
vs->base.state.type = PIPE_SHADER_IR_TGSI;
vs->base.state.tokens = nir_to_tgsi(state->ir.nir, draw->pipe->screen);
vs->base.state.ir.tokens = nir_to_tgsi(state->ir.nir, draw->pipe->screen);
} else {
assert(state->type == PIPE_SHADER_IR_TGSI);
vs->base.state.type = state->type;
/* we need to keep a local copy of the tokens */
vs->base.state.tokens = tgsi_dup_tokens(state->tokens);
if (!vs->base.state.tokens) {
vs->base.state.ir.tokens = tgsi_dup_tokens(state->ir.tokens);
if (!vs->base.state.ir.tokens) {
FREE(vs);
return NULL;
}
}
tgsi_scan_shader(vs->base.state.tokens, &vs->base.info);
tgsi_scan_shader(vs->base.state.ir.tokens, &vs->base.info);
vs->base.state.stream_output = state->stream_output;
vs->base.draw = draw;

View file

@ -77,7 +77,7 @@ vs_llvm_delete(struct draw_vertex_shader *dvs)
assert(shader->variants_cached == 0);
ralloc_free(dvs->state.ir.nir);
FREE((void*) dvs->state.tokens);
FREE((void*) dvs->state.ir.tokens);
FREE(dvs);
}
@ -99,13 +99,13 @@ draw_create_vs_llvm(struct draw_context *draw,
nir_tgsi_scan_shader(state->ir.nir, &vs->base.info, true);
} else {
/* we make a private copy of the tokens */
vs->base.state.tokens = tgsi_dup_tokens(state->tokens);
if (!vs->base.state.tokens) {
vs->base.state.ir.tokens = tgsi_dup_tokens(state->ir.tokens);
if (!vs->base.state.ir.tokens) {
FREE(vs);
return NULL;
}
tgsi_scan_shader(state->tokens, &vs->base.info);
tgsi_scan_shader(state->ir.tokens, &vs->base.info);
}
vs->variant_key_size =

View file

@ -284,7 +284,7 @@ DD_CSO_DELETE(vertex_elements)
\
pipe->delete_##name##_state(pipe, hstate->cso); \
if (hstate->state.shader.type == PIPE_SHADER_IR_TGSI) \
tgsi_free_tokens(hstate->state.shader.tokens); \
tgsi_free_tokens(hstate->state.shader.ir.tokens); \
FREE(hstate); \
}
@ -301,7 +301,7 @@ DD_CSO_DELETE(vertex_elements)
hstate->cso = pipe->create_##name##_state(pipe, state); \
hstate->state.shader = *state; \
if (hstate->state.shader.type == PIPE_SHADER_IR_TGSI) \
hstate->state.shader.tokens = tgsi_dup_tokens(state->tokens); \
hstate->state.shader.ir.tokens = tgsi_dup_tokens(state->ir.tokens); \
return hstate; \
} \
\
@ -329,7 +329,7 @@ dd_context_create_compute_state(struct pipe_context *_pipe,
hstate->state.shader.type = state->ir_type;
if (state->ir_type == PIPE_SHADER_IR_TGSI)
hstate->state.shader.tokens = tgsi_dup_tokens(state->prog);
hstate->state.shader.ir.tokens = tgsi_dup_tokens(state->prog);
return hstate;
}

View file

@ -157,11 +157,11 @@ dd_num_active_viewports(struct dd_draw_state *dstate)
const struct tgsi_token *tokens;
if (dstate->shaders[MESA_SHADER_GEOMETRY])
tokens = dstate->shaders[MESA_SHADER_GEOMETRY]->state.shader.tokens;
tokens = dstate->shaders[MESA_SHADER_GEOMETRY]->state.shader.ir.tokens;
else if (dstate->shaders[MESA_SHADER_TESS_EVAL])
tokens = dstate->shaders[MESA_SHADER_TESS_EVAL]->state.shader.tokens;
tokens = dstate->shaders[MESA_SHADER_TESS_EVAL]->state.shader.ir.tokens;
else if (dstate->shaders[MESA_SHADER_VERTEX])
tokens = dstate->shaders[MESA_SHADER_VERTEX]->state.shader.tokens;
tokens = dstate->shaders[MESA_SHADER_VERTEX]->state.shader.ir.tokens;
else
return 1;
@ -871,7 +871,7 @@ dd_unreference_copy_of_draw_state(struct dd_draw_state_copy *state)
for (i = 0; i < MESA_SHADER_MESH_STAGES; i++) {
if (dst->shaders[i])
tgsi_free_tokens(dst->shaders[i]->state.shader.tokens);
tgsi_free_tokens(dst->shaders[i]->state.shader.ir.tokens);
for (j = 0; j < PIPE_MAX_CONSTANT_BUFFERS; j++)
pipe_resource_reference(&dst->constant_buffers[i][j].buffer, NULL);
@ -917,9 +917,9 @@ dd_copy_draw_state(struct dd_draw_state *dst, struct dd_draw_state *src)
if (src->shaders[i]) {
dst->shaders[i]->state.shader = src->shaders[i]->state.shader;
if (src->shaders[i]->state.shader.tokens) {
dst->shaders[i]->state.shader.tokens =
tgsi_dup_tokens(src->shaders[i]->state.shader.tokens);
if (src->shaders[i]->state.shader.ir.tokens) {
dst->shaders[i]->state.shader.ir.tokens =
tgsi_dup_tokens(src->shaders[i]->state.shader.ir.tokens);
} else {
dst->shaders[i]->state.shader.ir.nir = NULL;
}

View file

@ -344,9 +344,9 @@ void trace_dump_shader_state(const struct pipe_shader_state *state)
trace_dump_member(uint, state, type);
trace_dump_member_begin("tokens");
if (state->tokens) {
if (state->ir.tokens) {
static char str[64 * 1024];
tgsi_dump_str(state->tokens, 0, str, sizeof(str));
tgsi_dump_str(state->ir.tokens, 0, str, sizeof(str));
trace_dump_string(str);
} else {
trace_dump_null();

View file

@ -4097,6 +4097,6 @@ pipe_shader_state_to_tgsi_tokens(struct pipe_screen *screen,
} else {
assert(cso->type == PIPE_SHADER_IR_TGSI);
/* we need to keep a local copy of the tokens */
return tgsi_dup_tokens(cso->tokens);
return tgsi_dup_tokens(cso->ir.tokens);
}
}

View file

@ -2172,7 +2172,7 @@ void *ureg_create_shader( struct ureg_program *ureg,
struct pipe_shader_state state = {0};
pipe_shader_state_from_tgsi(&state, ureg_finalize(ureg));
if(!state.tokens)
if(!state.ir.tokens)
return NULL;
if (so)

View file

@ -517,7 +517,7 @@ util_dump_shader_state(FILE *stream, const struct pipe_shader_state *state)
if (state->type == PIPE_SHADER_IR_TGSI) {
util_dump_member_begin(stream, "tokens");
fprintf(stream, "\"\n");
tgsi_dump_to_file(state->tokens, 0, stream);
tgsi_dump_to_file(state->ir.tokens, 0, stream);
fprintf(stream, "\"");
util_dump_member_end(stream);
}

View file

@ -82,10 +82,10 @@ util_live_shader_cache_get(struct pipe_context *ctx,
/* Get the shader binary and shader stage. */
if (state->type == PIPE_SHADER_IR_TGSI) {
ir_binary = state->tokens;
ir_size = tgsi_num_tokens(state->tokens) *
ir_binary = state->ir.tokens;
ir_size = tgsi_num_tokens(state->ir.tokens) *
sizeof(struct tgsi_token);
stage = tgsi_get_processor_type(state->tokens);
stage = tgsi_get_processor_type(state->ir.tokens);
} else if (state->type == PIPE_SHADER_IR_NIR) {
blob_init(&blob);
nir_serialize(&blob, state->ir.nir, true);

View file

@ -1875,7 +1875,7 @@ agx_create_shader_state(struct pipe_context *pctx,
nir_shader *nir = cso->type == PIPE_SHADER_IR_NIR
? cso->ir.nir
: tgsi_to_nir(cso->tokens, pctx->screen, false);
: tgsi_to_nir(cso->ir.tokens, pctx->screen, false);
if (nir->info.stage == MESA_SHADER_VERTEX ||
nir->info.stage == MESA_SHADER_TESS_EVAL) {

View file

@ -2725,7 +2725,7 @@ crocus_create_shader_state(struct pipe_context *ctx,
struct nir_shader *nir;
if (state->type == PIPE_SHADER_IR_TGSI)
nir = tgsi_to_nir(state->tokens, ctx->screen, false);
nir = tgsi_to_nir(state->ir.tokens, ctx->screen, false);
else
nir = state->ir.nir;

View file

@ -1411,7 +1411,7 @@ d3d12_create_shader(struct d3d12_context *ctx,
nir = (nir_shader *)shader->ir.nir;
} else {
assert(shader->type == PIPE_SHADER_IR_TGSI);
nir = tgsi_to_nir(shader->tokens, ctx->base.screen, false);
nir = tgsi_to_nir(shader->ir.tokens, ctx->base.screen, false);
}
nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));

View file

@ -550,7 +550,7 @@ etna_create_shader_state(struct pipe_context *pctx,
util_queue_fence_init(&shader->ready);
shader->nir = (pss->type == PIPE_SHADER_IR_NIR) ? pss->ir.nir :
tgsi_to_nir(pss->tokens, pctx->screen, false);
tgsi_to_nir(pss->ir.tokens, pctx->screen, false);
etna_disk_cache_init_shader_key(compiler, shader);

View file

@ -71,7 +71,7 @@ fd2_shader_state_create(struct pipe_context *pctx,
so->nir = (cso->type == PIPE_SHADER_IR_NIR)
? cso->ir.nir
: tgsi_to_nir(cso->tokens, pctx->screen, false);
: tgsi_to_nir(cso->ir.tokens, pctx->screen, false);
so->type = so->nir->info.stage;
so->is_a20x = is_a20x(fd_context(pctx)->screen);

View file

@ -130,7 +130,7 @@ assemble_tgsi(struct pipe_context *pctx, const char *src, bool frag)
{
struct tgsi_token toks[32];
struct pipe_shader_state cso = {
.tokens = toks,
.ir.tokens = toks,
};
bool ret = tgsi_text_translate(src, toks, ARRAY_SIZE(toks));

View file

@ -309,9 +309,9 @@ ir3_shader_state_create(struct pipe_context *pctx,
} else {
assert(cso->type == PIPE_SHADER_IR_TGSI);
if (ir3_shader_debug & IR3_DBG_DISASM) {
tgsi_dump(cso->tokens, 0);
tgsi_dump(cso->ir.tokens, 0);
}
nir = tgsi_to_nir(cso->tokens, pctx->screen, false);
nir = tgsi_to_nir(cso->ir.tokens, pctx->screen, false);
}
if (ctx->screen->gen >= 6)

View file

@ -1078,7 +1078,7 @@ i915_translate_fragment_program(struct i915_context *i915,
struct i915_fragment_shader *fs)
{
struct i915_fp_compile *p;
const struct tgsi_token *tokens = fs->state.tokens;
const struct tgsi_token *tokens = fs->state.ir.tokens;
struct i915_token_list *i_tokens;
bool debug =
I915_DBG_ON(DBG_FS) && (!fs->internal || NIR_DEBUG(PRINT_INTERNAL));

View file

@ -595,17 +595,17 @@ i915_create_fs_state(struct pipe_context *pipe,
}
}
ifs->state.tokens = nir_to_tgsi_options(s, pipe->screen, &ntt_options);
ifs->state.ir.tokens = nir_to_tgsi_options(s, pipe->screen, &ntt_options);
} else {
assert(templ->type == PIPE_SHADER_IR_TGSI);
/* we need to keep a local copy of the tokens */
ifs->state.tokens = tgsi_dup_tokens(templ->tokens);
ifs->state.ir.tokens = tgsi_dup_tokens(templ->ir.tokens);
ifs->internal = i915->no_log_program_errors;
}
ifs->state.type = PIPE_SHADER_IR_TGSI;
tgsi_scan_shader(ifs->state.tokens, &ifs->info);
tgsi_scan_shader(ifs->state.ir.tokens, &ifs->info);
/* The shader's compiled to i915 instructions here */
i915_translate_fragment_program(i915, ifs);
@ -647,8 +647,8 @@ i915_delete_fs_state(struct pipe_context *pipe, void *shader)
ralloc_free(ifs->error);
FREE(ifs->program);
ifs->program = NULL;
FREE((struct tgsi_token *)ifs->state.tokens);
ifs->state.tokens = NULL;
FREE((struct tgsi_token *)ifs->state.ir.tokens);
ifs->state.ir.tokens = NULL;
if (ifs->draw_data) {
if (likely(i915))
@ -680,13 +680,13 @@ i915_create_vs_state(struct pipe_context *pipe,
* per-stage, and i915 FS can't do native integers. So, convert to TGSI,
* where the draw path *does* support non-native-integers.
*/
from_nir.tokens = nir_to_tgsi(s, pipe->screen);
from_nir.ir.tokens = nir_to_tgsi(s, pipe->screen);
templ = &from_nir;
}
vertex_shader = draw_create_vertex_shader(i915->draw, templ);
FREE((void *)from_nir.tokens);
FREE((void *)from_nir.ir.tokens);
return vertex_shader;
}

View file

@ -3557,7 +3557,7 @@ iris_create_shader_state(struct pipe_context *ctx,
struct nir_shader *nir;
if (state->type == PIPE_SHADER_IR_TGSI)
nir = tgsi_to_nir(state->tokens, ctx->screen, false);
nir = tgsi_to_nir(state->ir.tokens, ctx->screen, false);
else
nir = state->ir.nir;

View file

@ -453,7 +453,7 @@ lima_create_fs_state(struct pipe_context *pctx,
else {
assert(cso->type == PIPE_SHADER_IR_TGSI);
nir = tgsi_to_nir(cso->tokens, pctx->screen, false);
nir = tgsi_to_nir(cso->ir.tokens, pctx->screen, false);
}
so->base.type = PIPE_SHADER_IR_NIR;
@ -706,7 +706,7 @@ lima_create_vs_state(struct pipe_context *pctx,
else {
assert(cso->type == PIPE_SHADER_IR_TGSI);
nir = tgsi_to_nir(cso->tokens, pctx->screen, false);
nir = tgsi_to_nir(cso->ir.tokens, pctx->screen, false);
}
so->base.type = PIPE_SHADER_IR_NIR;

View file

@ -4105,7 +4105,7 @@ llvmpipe_create_fs_state(struct pipe_context *pipe,
shader->base.type = PIPE_SHADER_IR_NIR;
if (templ->type == PIPE_SHADER_IR_TGSI) {
shader->base.ir.nir = tgsi_to_nir(templ->tokens, pipe->screen, false);
shader->base.ir.nir = tgsi_to_nir(templ->ir.tokens, pipe->screen, false);
} else {
shader->base.ir.nir = templ->ir.nir;
}

View file

@ -54,17 +54,17 @@ llvmpipe_create_gs_state(struct pipe_context *pipe,
/* debug */
if (LP_DEBUG & DEBUG_TGSI && templ->type == PIPE_SHADER_IR_TGSI) {
debug_printf("llvmpipe: Create geometry shader %p:\n", (void *)state);
tgsi_dump(templ->tokens, 0);
tgsi_dump(templ->ir.tokens, 0);
}
/* copy stream output info */
if (templ->type == PIPE_SHADER_IR_TGSI)
state->no_tokens = !templ->tokens;
state->no_tokens = !templ->ir.tokens;
else
state->no_tokens = false;
memcpy(&state->stream_output, &templ->stream_output, sizeof state->stream_output);
if (templ->tokens || templ->type == PIPE_SHADER_IR_NIR) {
if (templ->ir.tokens || templ->type == PIPE_SHADER_IR_NIR) {
state->dgs = draw_create_geometry_shader(llvmpipe->draw, templ);
if (state->dgs == NULL) {
goto no_dgs;

View file

@ -52,14 +52,14 @@ llvmpipe_create_tcs_state(struct pipe_context *pipe,
/* debug */
if (LP_DEBUG & DEBUG_TGSI && templ->type == PIPE_SHADER_IR_TGSI) {
debug_printf("llvmpipe: Create tess ctrl shader %p:\n", (void *)state);
tgsi_dump(templ->tokens, 0);
tgsi_dump(templ->ir.tokens, 0);
}
/* copy stream output info */
state->no_tokens = !templ->tokens;
state->no_tokens = !templ->ir.tokens;
memcpy(&state->stream_output, &templ->stream_output, sizeof state->stream_output);
if (templ->tokens || templ->type == PIPE_SHADER_IR_NIR) {
if (templ->ir.tokens || templ->type == PIPE_SHADER_IR_NIR) {
state->dtcs = draw_create_tess_ctrl_shader(llvmpipe->draw, templ);
if (state->dtcs == NULL) {
goto no_dgs;
@ -122,14 +122,14 @@ llvmpipe_create_tes_state(struct pipe_context *pipe,
/* debug */
if (LP_DEBUG & DEBUG_TGSI) {
debug_printf("llvmpipe: Create tess eval shader %p:\n", (void *)state);
tgsi_dump(templ->tokens, 0);
tgsi_dump(templ->ir.tokens, 0);
}
/* copy stream output info */
state->no_tokens = !templ->tokens;
state->no_tokens = !templ->ir.tokens;
memcpy(&state->stream_output, &templ->stream_output, sizeof state->stream_output);
if (templ->tokens || templ->type == PIPE_SHADER_IR_NIR) {
if (templ->ir.tokens || templ->type == PIPE_SHADER_IR_NIR) {
state->dtes = draw_create_tess_eval_shader(llvmpipe->draw, templ);
if (state->dtes == NULL) {
goto no_dgs;

View file

@ -54,7 +54,7 @@ llvmpipe_create_vs_state(struct pipe_context *pipe,
if (LP_DEBUG & DEBUG_TGSI && templ->type == PIPE_SHADER_IR_TGSI) {
debug_printf("llvmpipe: Create vertex shader %p:\n", (void *) vs);
tgsi_dump(templ->tokens, 0);
tgsi_dump(templ->ir.tokens, 0);
}
return vs;

View file

@ -143,14 +143,14 @@ nv30_fp_state_create(struct pipe_context *pipe,
return NULL;
if (cso->type == PIPE_SHADER_IR_NIR) {
fp->pipe.tokens = nir_to_tgsi(cso->ir.nir, pipe->screen);
fp->pipe.ir.tokens = nir_to_tgsi(cso->ir.nir, pipe->screen);
} else {
assert(cso->type == PIPE_SHADER_IR_TGSI);
/* we need to keep a local copy of the tokens */
fp->pipe.tokens = tgsi_dup_tokens(cso->tokens);
fp->pipe.ir.tokens = tgsi_dup_tokens(cso->ir.tokens);
}
tgsi_scan_shader(fp->pipe.tokens, &fp->info);
tgsi_scan_shader(fp->pipe.ir.tokens, &fp->info);
return fp;
}
@ -164,7 +164,7 @@ nv30_fp_state_delete(struct pipe_context *pipe, void *hwcso)
if (fp->draw)
draw_delete_fragment_shader(nv30_context(pipe)->draw, fp->draw);
FREE((void *)fp->pipe.tokens);
FREE((void *)fp->pipe.ir.tokens);
FREE(fp->insn);
FREE(fp->consts);
FREE(fp);

View file

@ -229,14 +229,14 @@ nv30_vp_state_create(struct pipe_context *pipe,
return NULL;
if (cso->type == PIPE_SHADER_IR_NIR) {
vp->pipe.tokens = nir_to_tgsi(cso->ir.nir, pipe->screen);
vp->pipe.ir.tokens = nir_to_tgsi(cso->ir.nir, pipe->screen);
} else {
assert(cso->type == PIPE_SHADER_IR_TGSI);
/* we need to keep a local copy of the tokens */
vp->pipe.tokens = tgsi_dup_tokens(cso->tokens);
vp->pipe.ir.tokens = tgsi_dup_tokens(cso->ir.tokens);
}
tgsi_scan_shader(vp->pipe.tokens, &vp->info);
tgsi_scan_shader(vp->pipe.ir.tokens, &vp->info);
return vp;
}
@ -251,7 +251,7 @@ nv30_vp_state_delete(struct pipe_context *pipe, void *hwcso)
if (vp->draw)
draw_delete_vertex_shader(nv30_context(pipe)->draw, vp->draw);
FREE((void *)vp->pipe.tokens);
FREE((void *)vp->pipe.ir.tokens);
FREE(vp);
}

View file

@ -970,7 +970,7 @@ nvfx_fragprog_prepare(struct nvfx_fpc *fpc)
fpc->r_imm = CALLOC(fpc->fp->info.immediate_count, sizeof(struct nvfx_reg));
tgsi_parse_init(&p, fpc->fp->pipe.tokens);
tgsi_parse_init(&p, fpc->fp->pipe.ir.tokens);
while (!tgsi_parse_end_of_tokens(&p)) {
const union tgsi_full_token *tok = &p.FullToken;
@ -1017,7 +1017,7 @@ nvfx_fragprog_prepare(struct nvfx_fpc *fpc)
}
tgsi_parse_free(&p);
tgsi_parse_init(&p, fpc->fp->pipe.tokens);
tgsi_parse_init(&p, fpc->fp->pipe.ir.tokens);
while (!tgsi_parse_end_of_tokens(&p)) {
const struct tgsi_full_declaration *fdec;
tgsi_parse_token(&p);
@ -1089,7 +1089,7 @@ _nvfx_fragprog_translate(uint16_t oclass, struct nv30_fragprog *fp)
if (!nvfx_fragprog_prepare(fpc))
goto out_err;
tgsi_parse_init(&parse, fp->pipe.tokens);
tgsi_parse_init(&parse, fp->pipe.ir.tokens);
insns = UTIL_DYNARRAY_INIT;
while (!tgsi_parse_end_of_tokens(&parse)) {
@ -1139,7 +1139,7 @@ _nvfx_fragprog_translate(uint16_t oclass, struct nv30_fragprog *fp)
if(debug_get_option_nvfx_dump_fp())
{
debug_printf("\n");
tgsi_dump(fp->pipe.tokens, 0);
tgsi_dump(fp->pipe.ir.tokens, 0);
debug_printf("\n%s fragment program:\n", fpc->is_nv4x ? "nv4x" : "nv3x");
for (unsigned i = 0; i < fp->insn_len; i += 4)
@ -1166,6 +1166,6 @@ out:
out_err:
_debug_printf("Error: failed to compile this fragment program:\n");
tgsi_dump(fp->pipe.tokens, 0);
tgsi_dump(fp->pipe.ir.tokens, 0);
goto out;
}

View file

@ -875,7 +875,7 @@ nvfx_vertprog_prepare(struct nvfx_vpc *vpc)
struct tgsi_parse_context p;
int high_const = -1, high_temp = -1, high_addr = -1, nr_imm = 0, i;
tgsi_parse_init(&p, vpc->pipe.tokens);
tgsi_parse_init(&p, vpc->pipe.ir.tokens);
while (!tgsi_parse_end_of_tokens(&p)) {
const union tgsi_full_token *tok = &p.FullToken;
@ -991,7 +991,7 @@ _nvfx_vertprog_translate(uint16_t oclass, struct nv30_vertprog *vp)
insns = UTIL_DYNARRAY_INIT;
tgsi_parse_init(&parse, vp->pipe.tokens);
tgsi_parse_init(&parse, vp->pipe.ir.tokens);
while (!tgsi_parse_end_of_tokens(&parse)) {
tgsi_parse_token(&parse);
@ -1086,7 +1086,7 @@ _nvfx_vertprog_translate(uint16_t oclass, struct nv30_vertprog *vp)
if(debug_get_option_nvfx_dump_vp())
{
debug_printf("\n");
tgsi_dump(vpc->pipe.tokens, 0);
tgsi_dump(vpc->pipe.ir.tokens, 0);
debug_printf("\n%s vertex program:\n", vpc->is_nv4x ? "nv4x" : "nv3x");
for (i = 0; i < vp->nr_insns; i++)

View file

@ -743,7 +743,7 @@ nv50_sp_state_create(struct pipe_context *pipe,
switch (cso->type) {
case PIPE_SHADER_IR_TGSI:
prog->nir = tgsi_to_nir(cso->tokens, pipe->screen, false);
prog->nir = tgsi_to_nir(cso->ir.tokens, pipe->screen, false);
break;
case PIPE_SHADER_IR_NIR:
prog->nir = cso->ir.nir;

View file

@ -599,7 +599,7 @@ nvc0_sp_state_create(struct pipe_context *pipe,
switch(cso->type) {
case PIPE_SHADER_IR_TGSI:
prog->nir = tgsi_to_nir(cso->tokens, pipe->screen, false);
prog->nir = tgsi_to_nir(cso->ir.tokens, pipe->screen, false);
break;
case PIPE_SHADER_IR_NIR:
prog->nir = cso->ir.nir;

View file

@ -477,7 +477,7 @@ panfrost_create_shader_state(struct pipe_context *pctx,
PAN_TRACE_FUNC(PAN_TRACE_GL_SHADER);
nir_shader *nir = (cso->type == PIPE_SHADER_IR_TGSI)
? tgsi_to_nir(cso->tokens, pctx->screen, false)
? tgsi_to_nir(cso->ir.tokens, pctx->screen, false)
: cso->ir.nir;
struct panfrost_uncompiled_shader *so = panfrost_alloc_shader(nir);

View file

@ -211,7 +211,7 @@ static void r300_dummy_fragment_shader(
ureg_MOV(ureg, out, imm);
ureg_END(ureg);
state.tokens = ureg_finalize(ureg);
state.ir.tokens = ureg_finalize(ureg);
shader->dummy = true;
r300_translate_fragment_shader(r300, shader, state);
@ -410,10 +410,10 @@ static void r300_translate_fragment_shader(
if (state.type == PIPE_SHADER_IR_NIR) {
nir_shader *clone = nir_shader_clone(NULL, state.ir.nir);
state.tokens = nir_to_rc(clone, (struct pipe_screen *)r300->screen, shader->compare_state);
state.ir.tokens = nir_to_rc(clone, (struct pipe_screen *)r300->screen, shader->compare_state);
}
tgsi_scan_shader(state.tokens, &shader->info);
tgsi_scan_shader(state.ir.tokens, &shader->info);
r300_shader_read_fs_inputs(&shader->info, &shader->inputs);
wpos = shader->inputs.wpos;
@ -451,17 +451,17 @@ static void r300_translate_fragment_shader(
if (compiler.Base.Debug & RC_DBG_LOG) {
DBG(r300, DBG_FP, "r300: Initial fragment program\n");
tgsi_dump(state.tokens, 0);
tgsi_dump(state.ir.tokens, 0);
}
/* Translate TGSI to our internal representation */
ttr.compiler = &compiler.Base;
ttr.info = &shader->info;
r300_tgsi_to_rc(&ttr, state.tokens);
r300_tgsi_to_rc(&ttr, state.ir.tokens);
if (state.type == PIPE_SHADER_IR_NIR) {
FREE((void*)state.tokens);
FREE((void*)state.ir.tokens);
}
if (ttr.error) {

View file

@ -1233,7 +1233,7 @@ static void* r300_create_fs_state(struct pipe_context* pipe,
} else {
assert(fs->state.type == PIPE_SHADER_IR_TGSI);
/* we need to keep a local copy of the tokens */
fs->state.tokens = tgsi_dup_tokens(fs->state.tokens);
fs->state.ir.tokens = tgsi_dup_tokens(fs->state.ir.tokens);
}
/* Precompile the fragment shader at creation time to avoid jank at runtime.
@ -1335,7 +1335,7 @@ static void r300_delete_fs_state(struct pipe_context* pipe, void* shader)
if (fs->state.type == PIPE_SHADER_IR_NIR) {
ralloc_free(fs->state.ir.nir);
} else {
FREE((void*)fs->state.tokens);
FREE((void*)fs->state.ir.tokens);
}
FREE(shader);
}
@ -2181,11 +2181,11 @@ static void* r300_create_vs_state(struct pipe_context* pipe,
}
struct r300_fragment_program_external_state state = {};
vs->state.tokens = nir_to_rc(shader->ir.nir, pipe->screen, state);
vs->state.ir.tokens = nir_to_rc(shader->ir.nir, pipe->screen, state);
} else {
assert(vs->state.type == PIPE_SHADER_IR_TGSI);
/* we need to keep a local copy of the tokens */
vs->state.tokens = tgsi_dup_tokens(vs->state.tokens);
vs->state.ir.tokens = tgsi_dup_tokens(vs->state.ir.tokens);
}
if (!vs->first)
@ -2277,7 +2277,7 @@ static void r300_delete_vs_state(struct pipe_context* pipe, void* shader)
(struct draw_vertex_shader*)vs->draw_vs);
}
FREE((void*)vs->state.tokens);
FREE((void*)vs->state.ir.tokens);
FREE(shader);
}

View file

@ -155,7 +155,7 @@ static void set_vertex_inputs_outputs(struct r300_vertex_program_compiler * c)
void r300_init_vs_outputs(struct r300_context *r300,
struct r300_vertex_shader *vs)
{
tgsi_scan_shader(vs->state.tokens, &vs->shader->info);
tgsi_scan_shader(vs->state.ir.tokens, &vs->shader->info);
r300_shader_read_vs_outputs(r300, &vs->shader->info, &vs->shader->outputs);
}
@ -201,14 +201,14 @@ void r300_translate_vertex_shader(struct r300_context *r300,
if (compiler.Base.Debug & RC_DBG_LOG) {
DBG(r300, DBG_VP, "r300: Initial vertex program\n");
tgsi_dump(shader->state.tokens, 0);
tgsi_dump(shader->state.ir.tokens, 0);
}
/* Translate TGSI to our internal representation */
ttr.compiler = &compiler.Base;
ttr.info = &vs->info;
r300_tgsi_to_rc(&ttr, shader->state.tokens);
r300_tgsi_to_rc(&ttr, shader->state.ir.tokens);
if (ttr.error) {
vs->error = strdup("Cannot translate shader from TGSI");

View file

@ -293,14 +293,14 @@ void r300_draw_init_vertex_shader(struct r300_context *r300,
struct draw_context *draw = r300->draw;
struct tgsi_shader_info info;
struct vs_transform_context transform;
const uint newLen = tgsi_num_tokens(vs->state.tokens) + 100;
const uint newLen = tgsi_num_tokens(vs->state.ir.tokens) + 100;
struct pipe_shader_state new_vs = {
.type = PIPE_SHADER_IR_TGSI,
.tokens = tgsi_alloc_tokens(newLen)
.ir.tokens = tgsi_alloc_tokens(newLen)
};
unsigned i;
tgsi_scan_shader(vs->state.tokens, &info);
tgsi_scan_shader(vs->state.ir.tokens, &info);
memset(&transform, 0, sizeof(transform));
for (i = 0; i < ARRAY_SIZE(transform.out_remap); i++) {
@ -326,8 +326,8 @@ void r300_draw_init_vertex_shader(struct r300_context *r300,
}
}
new_vs.tokens = tgsi_transform_shader(vs->state.tokens, newLen, &transform.base);
if (!new_vs.tokens)
new_vs.ir.tokens = tgsi_transform_shader(vs->state.ir.tokens, newLen, &transform.base);
if (!new_vs.ir.tokens)
return;
#if 0
@ -339,12 +339,12 @@ void r300_draw_init_vertex_shader(struct r300_context *r300,
#endif
/* Free old tokens. */
FREE((void*)vs->state.tokens);
FREE((void*)vs->state.ir.tokens);
vs->draw_vs = draw_create_vertex_shader(draw, &new_vs);
/* Instead of duplicating and freeing the tokens, copy the pointer directly. */
vs->state.tokens = new_vs.tokens;
vs->state.ir.tokens = new_vs.ir.tokens;
/* Init the VS output table for the rasterizer. */
r300_init_vs_outputs(r300, vs);

View file

@ -951,7 +951,7 @@ static void *r600_create_shader_state(struct pipe_context *ctx,
struct r600_pipe_shader_selector *sel;
if (state->type == PIPE_SHADER_IR_TGSI)
sel = r600_create_shader_state_tokens(ctx, state->tokens, state->type, mesa_shader_stage);
sel = r600_create_shader_state_tokens(ctx, state->ir.tokens, state->type, mesa_shader_stage);
else if (state->type == PIPE_SHADER_IR_NIR) {
sel = r600_create_shader_state_tokens(ctx, state->ir.nir, state->type, mesa_shader_stage);
} else

View file

@ -3474,7 +3474,7 @@ static void *si_create_shader_selector(struct pipe_context *ctx,
realloc(NULL, sel->variants_max_count * sizeof(struct si_shader *));
if (state->type == PIPE_SHADER_IR_TGSI) {
sel->nir = tgsi_to_nir(state->tokens, ctx->screen, true);
sel->nir = tgsi_to_nir(state->ir.tokens, ctx->screen, true);
} else {
assert(state->type == PIPE_SHADER_IR_NIR);
sel->nir = state->ir.nir;

View file

@ -130,7 +130,7 @@ softpipe_draw_vbo(struct pipe_context *pipe,
sp->sampler_views[MESA_SHADER_GEOMETRY]);
}
if (sp->gs && !sp->gs->shader.tokens) {
if (sp->gs && !sp->gs->shader.ir.tokens) {
/* we have an empty geometry shader with stream output, so
attach the stream output info to the current vertex shader */
if (sp->vs) {

View file

@ -64,7 +64,7 @@ create_fs_variant(struct softpipe_context *softpipe,
if (var) {
var->key = *key;
var->tokens = tgsi_dup_tokens(curfs->tokens);
var->tokens = tgsi_dup_tokens(curfs->ir.tokens);
tgsi_scan_shader(var->tokens, &var->info);
@ -130,11 +130,11 @@ softpipe_create_shader_state(struct pipe_context *pipe,
if (debug)
nir_print_shader(templ->ir.nir, stderr);
shader->tokens = nir_to_tgsi(templ->ir.nir, pipe->screen);
shader->ir.tokens = nir_to_tgsi(templ->ir.nir, pipe->screen);
} else {
assert(templ->type == PIPE_SHADER_IR_TGSI);
/* we need to keep a local copy of the tokens */
shader->tokens = tgsi_dup_tokens(templ->tokens);
shader->ir.tokens = tgsi_dup_tokens(templ->ir.tokens);
}
shader->type = PIPE_SHADER_IR_TGSI;
@ -142,9 +142,9 @@ softpipe_create_shader_state(struct pipe_context *pipe,
shader->stream_output = templ->stream_output;
if (debug)
tgsi_dump(shader->tokens, 0);
tgsi_dump(shader->ir.tokens, 0);
softpipe_shader_db(pipe, shader->tokens);
softpipe_shader_db(pipe, shader->ir.tokens);
}
static void *
@ -161,7 +161,7 @@ softpipe_create_fs_state(struct pipe_context *pipe,
state->draw_shader = draw_create_fragment_shader(softpipe->draw,
&state->shader);
if (!state->draw_shader) {
tgsi_free_tokens(state->shader.tokens);
tgsi_free_tokens(state->shader.ir.tokens);
FREE(state);
return NULL;
}
@ -223,7 +223,7 @@ softpipe_delete_fs_state(struct pipe_context *pipe, void *fs)
draw_delete_fragment_shader(softpipe->draw, state->draw_shader);
tgsi_free_tokens(state->shader.tokens);
tgsi_free_tokens(state->shader.ir.tokens);
FREE(state);
}
@ -241,7 +241,7 @@ softpipe_create_vs_state(struct pipe_context *pipe,
softpipe_create_shader_state(pipe, &state->shader, templ,
sp_debug & SP_DBG_VS);
if (!state->shader.tokens)
if (!state->shader.ir.tokens)
goto fail;
state->draw_data = draw_create_vertex_shader(softpipe->draw, &state->shader);
@ -254,7 +254,7 @@ softpipe_create_vs_state(struct pipe_context *pipe,
fail:
if (state) {
tgsi_free_tokens(state->shader.tokens);
tgsi_free_tokens(state->shader.ir.tokens);
FREE( state->draw_data );
FREE( state );
}
@ -284,7 +284,7 @@ softpipe_delete_vs_state(struct pipe_context *pipe, void *vs)
struct sp_vertex_shader *state = (struct sp_vertex_shader *) vs;
draw_delete_vertex_shader(softpipe->draw, state->draw_data);
tgsi_free_tokens(state->shader.tokens);
tgsi_free_tokens(state->shader.ir.tokens);
FREE( state );
}
@ -303,7 +303,7 @@ softpipe_create_gs_state(struct pipe_context *pipe,
softpipe_create_shader_state(pipe, &state->shader, templ,
sp_debug & SP_DBG_GS);
if (state->shader.tokens) {
if (state->shader.ir.tokens) {
state->draw_data = draw_create_geometry_shader(softpipe->draw,
&state->shader);
if (state->draw_data == NULL)
@ -316,7 +316,7 @@ softpipe_create_gs_state(struct pipe_context *pipe,
fail:
if (state) {
tgsi_free_tokens(state->shader.tokens);
tgsi_free_tokens(state->shader.ir.tokens);
FREE( state->draw_data );
FREE( state );
}
@ -349,7 +349,7 @@ softpipe_delete_gs_state(struct pipe_context *pipe, void *gs)
draw_delete_geometry_shader(softpipe->draw,
(state) ? state->draw_data : 0);
tgsi_free_tokens(state->shader.tokens);
tgsi_free_tokens(state->shader.ir.tokens);
FREE(state);
}

View file

@ -40,7 +40,7 @@ svga_create_fs_state(struct pipe_context *pipe,
*/
struct pipe_shader_state tmp = *templ;
tmp.type = PIPE_SHADER_IR_TGSI;
tmp.tokens = fs->base.tokens;
tmp.ir.tokens = fs->base.tokens;
fs->generic_inputs = svga_get_generic_inputs_mask(&fs->base.tgsi_info);

View file

@ -39,7 +39,7 @@ svga_create_gs_state(struct pipe_context *pipe,
*/
struct pipe_shader_state tmp = *templ;
tmp.type = PIPE_SHADER_IR_TGSI;
tmp.tokens = gs->base.tokens;
tmp.ir.tokens = gs->base.tokens;
gs->base.get_dummy_shader = svga_get_compiled_dummy_geometry_shader;
gs->draw_shader = draw_create_geometry_shader(svga->swtnl.draw, &tmp);

View file

@ -45,7 +45,7 @@ svga_create_vs_state(struct pipe_context *pipe,
/* shader IR has been converted to tgsi */
tmp2.type = PIPE_SHADER_IR_TGSI;
tmp2.tokens = vs->base.tokens;
tmp2.ir.tokens = vs->base.tokens;
vs->draw_shader = draw_create_vertex_shader(svga->swtnl.draw, &tmp2);
}

View file

@ -446,7 +446,7 @@ v3d_shader_state_create(struct pipe_context *pctx,
v3d_uncompiled_shader_create(pctx,
cso->type,
(cso->type == PIPE_SHADER_IR_TGSI ?
(void *)cso->tokens :
(void *)cso->ir.tokens :
cso->ir.nir));
v3d_set_transform_feedback_outputs(so, &cso->stream_output);

View file

@ -2491,9 +2491,8 @@ vc4_shader_state_create(struct pipe_context *pctx,
if (VC4_DBG(TGSI)) {
mesa_logd("prog %d TGSI:", so->program_id);
tgsi_dump(cso->tokens, 0);
}
s = tgsi_to_nir(cso->tokens, pctx->screen, false);
tgsi_dump(cso->ir.tokens, 0);
s = tgsi_to_nir(cso->ir.tokens, pctx->screen, false);
}
if (s->info.stage == MESA_SHADER_VERTEX)

View file

@ -744,7 +744,7 @@ static void *virgl_shader_encoder(struct pipe_context *ctx,
is_separable = s->info.separate_shader && !s->info.internal && keep_separable_flags;
ntt_tokens = tokens = nir_to_tgsi_options(s, vctx->base.screen, &options); /* takes ownership */
} else {
tokens = shader->tokens;
tokens = shader->ir.tokens;
}
new_tokens = virgl_tgsi_transform(rs, tokens, is_separable);

View file

@ -2624,7 +2624,7 @@ zink_create_gfx_shader_state(struct pipe_context *pctx, const struct pipe_shader
struct zink_screen *screen = zink_screen(pctx->screen);
nir_shader *nir;
if (shader->type != PIPE_SHADER_IR_NIR)
nir = zink_tgsi_to_nir(pctx->screen, shader->tokens);
nir = zink_tgsi_to_nir(pctx->screen, shader->ir.tokens);
else
nir = (struct nir_shader *)shader->ir.nir;

View file

@ -80,7 +80,7 @@ static void
ResolveState(Device *pDevice)
{
if (pDevice->bound_empty_gs && pDevice->bound_vs &&
pDevice->bound_vs->state.tokens) {
pDevice->bound_vs->state.ir.tokens) {
Shader *gs = pDevice->bound_empty_gs;
Shader *vs = pDevice->bound_vs;
bool remapped = false;

View file

@ -82,7 +82,7 @@ CreateEmptyShader(Device *pDevice,
struct pipe_shader_state state;
memset(&state, 0, sizeof state);
state.tokens = tokens;
state.ir.tokens = tokens;
void *handle;
switch (processor) {
@ -313,8 +313,8 @@ DestroyShader(D3D10DDI_HDEVICE hDevice, // IN
}
}
if (pShader->state.tokens) {
ureg_free_tokens(pShader->state.tokens);
if (pShader->state.ir.tokens) {
ureg_free_tokens(pShader->state.ir.tokens);
}
}
@ -547,7 +547,7 @@ CreateVertexShader(D3D10DDI_HDEVICE hDevice, //
pShader->output_resolved = true;
memset(&pShader->state, 0, sizeof pShader->state);
pShader->state.tokens = Shader_tgsi_translate(pCode, pShader->output_mapping);
pShader->state.ir.tokens = Shader_tgsi_translate(pCode, pShader->output_mapping);
pShader->handle = pipe->create_vs_state(pipe, &pShader->state);
@ -683,7 +683,7 @@ CreateGeometryShader(D3D10DDI_HDEVICE hDevice, //
pShader->output_resolved = true;
memset(&pShader->state, 0, sizeof pShader->state);
pShader->state.tokens = Shader_tgsi_translate(pShaderCode, pShader->output_mapping);
pShader->state.ir.tokens = Shader_tgsi_translate(pShaderCode, pShader->output_mapping);
pShader->handle = pipe->create_gs_state(pipe, &pShader->state);
}
@ -713,7 +713,7 @@ GsSetShader(D3D10DDI_HDEVICE hDevice, // IN
assert(pipe->bind_gs_state);
if (pShader && !pShader->state.tokens) {
if (pShader && !pShader->state.ir.tokens) {
pDevice->bound_empty_gs = pShader;
} else {
pDevice->bound_empty_gs = NULL;
@ -847,10 +847,10 @@ CreateGeometryShaderWithStreamOutput(
memset(&pShader->state, 0, sizeof pShader->state);
if (pData->pShaderCode) {
pShader->state.tokens = Shader_tgsi_translate(pData->pShaderCode,
pShader->state.ir.tokens = Shader_tgsi_translate(pData->pShaderCode,
pShader->output_mapping);
}
pShader->output_resolved = (pShader->state.tokens != NULL);
pShader->output_resolved = (pShader->state.ir.tokens != NULL);
for (unsigned i = 0; i < pData->NumEntries; ++i) {
CONST D3D10DDIARG_STREAM_OUTPUT_DECLARATION_ENTRY* pOutputStreamDecl =
@ -999,7 +999,7 @@ CreatePixelShader(D3D10DDI_HDEVICE hDevice, // IN
pShader->output_resolved = true;
memset(&pShader->state, 0, sizeof pShader->state);
pShader->state.tokens = Shader_tgsi_translate(pShaderCode,
pShader->state.ir.tokens = Shader_tgsi_translate(pShaderCode,
pShader->output_mapping);
pShader->handle = pipe->create_fs_state(pipe, &pShader->state);
@ -1404,7 +1404,7 @@ GenMips(D3D10DDI_HDEVICE hDevice, // IN
unsigned
ShaderFindOutputMapping(Shader *shader, unsigned registerIndex)
{
if (!shader || !shader->state.tokens)
if (!shader || !shader->state.ir.tokens)
return registerIndex;
for (unsigned i = 0; i < PIPE_MAX_SHADER_OUTPUTS; ++i) {

View file

@ -306,9 +306,8 @@ struct pipe_stream_output_info
struct pipe_shader_state
{
enum pipe_shader_ir type;
/* TODO move tokens into union. */
const struct tgsi_token *tokens;
union {
struct{
const struct tgsi_token *tokens;
struct nir_shader *nir;
} ir;
struct pipe_stream_output_info stream_output;
@ -327,7 +326,7 @@ pipe_shader_state_from_tgsi(struct pipe_shader_state *state,
const struct tgsi_token *tokens)
{
state->type = PIPE_SHADER_IR_TGSI;
state->tokens = tokens;
state->ir.tokens = tokens;
memset(&state->stream_output, 0, sizeof(state->stream_output));
}