static void vs_lower_opcode_tgsi_sv(struct vs_compile_context *vcc, struct toy_dst dst, int dim, int idx) { struct toy_compiler *tc = &vcc->tc; const struct toy_tgsi *tgsi = &vcc->tgsi; int slot; assert(!dim); slot = toy_tgsi_find_system_value(tgsi, idx); if (slot < 0) return; switch (tgsi->system_values[slot].semantic_name) { case TGSI_SEMANTIC_INSTANCEID: case TGSI_SEMANTIC_VERTEXID: /* * In 3DSTATE_VERTEX_ELEMENTS, we prepend an extra vertex element for * the generated IDs, with VID in the X channel and IID in the Y * channel. */ { const int grf = vcc->first_vue_grf; const struct toy_src src = tsrc(TOY_FILE_GRF, grf, 0); const enum toy_swizzle swizzle = (tgsi->system_values[slot].semantic_name == TGSI_SEMANTIC_INSTANCEID) ? TOY_SWIZZLE_Y : TOY_SWIZZLE_X; tc_MOV(tc, tdst_d(dst), tsrc_d(tsrc_swizzle1(src, swizzle))); } break; case TGSI_SEMANTIC_PRIMID: default: tc_fail(tc, "unhandled system value"); tc_MOV(tc, dst, tsrc_imm_d(0)); break; } }
static void fs_lower_opcode_tgsi_sv(struct fs_compile_context *fcc, struct toy_dst dst, int dim, int idx) { struct toy_compiler *tc = &fcc->tc; const struct toy_tgsi *tgsi = &fcc->tgsi; int slot; assert(!dim); slot = toy_tgsi_find_system_value(tgsi, idx); if (slot < 0) return; switch (tgsi->system_values[slot].semantic_name) { case TGSI_SEMANTIC_PRIMID: case TGSI_SEMANTIC_INSTANCEID: case TGSI_SEMANTIC_VERTEXID: default: tc_fail(tc, "unhandled system value"); tc_MOV(tc, dst, tsrc_imm_d(0)); break; } }