Path: blob/21.2-virgl/src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c
4574 views
#include <float.h>1#include "pipe/p_context.h"2#include "pipe/p_defines.h"3#include "pipe/p_state.h"4#include "util/u_dynarray.h"5#include "util/u_inlines.h"6#include "util/u_debug.h"7#include "util/u_memory.h"89#include "pipe/p_shader_tokens.h"10#include "tgsi/tgsi_parse.h"11#include "tgsi/tgsi_util.h"12#include "tgsi/tgsi_dump.h"13#include "tgsi/tgsi_ureg.h"1415#include "nouveau_debug.h"16#include "nv_object.xml.h"17#include "nv30/nv30-40_3d.xml.h"18#include "nv30/nvfx_shader.h"19#include "nv30/nv30_state.h"2021struct nvfx_fpc {22struct nv30_fragprog *fp;2324unsigned max_temps;25unsigned long long r_temps;26unsigned long long r_temps_discard;27struct nvfx_reg r_result[PIPE_MAX_SHADER_OUTPUTS];28struct nvfx_reg r_input[PIPE_MAX_SHADER_INPUTS];29struct nvfx_reg *r_temp;3031int num_regs;3233unsigned inst_offset;34unsigned have_const;35unsigned is_nv4x;3637struct util_dynarray imm_data;3839struct nvfx_reg* r_imm;40unsigned nr_imm;4142struct util_dynarray if_stack;43//struct util_dynarray loop_stack;44struct util_dynarray label_relocs;45};4647static inline struct nvfx_reg48temp(struct nvfx_fpc *fpc)49{50int idx = __builtin_ctzll(~fpc->r_temps);5152if (idx >= fpc->max_temps) {53NOUVEAU_ERR("out of temps!!\n");54return nvfx_reg(NVFXSR_TEMP, 0);55}5657fpc->r_temps |= (1ULL << idx);58fpc->r_temps_discard |= (1ULL << idx);59return nvfx_reg(NVFXSR_TEMP, idx);60}6162static inline void63release_temps(struct nvfx_fpc *fpc)64{65fpc->r_temps &= ~fpc->r_temps_discard;66fpc->r_temps_discard = 0ULL;67}6869static inline struct nvfx_reg70nvfx_fp_imm(struct nvfx_fpc *fpc, float a, float b, float c, float d)71{72float v[4] = {a, b, c, d};73int idx = fpc->imm_data.size >> 4;7475memcpy(util_dynarray_grow(&fpc->imm_data, float, 4), v, 4 * sizeof(float));76return nvfx_reg(NVFXSR_IMM, idx);77}7879static void80grow_insns(struct nvfx_fpc *fpc, int size)81{82struct nv30_fragprog *fp = fpc->fp;8384fp->insn_len += size;85fp->insn = realloc(fp->insn, sizeof(uint32_t) * fp->insn_len);86}8788static void89emit_src(struct nvfx_fpc *fpc, int pos, struct nvfx_src src)90{91struct nv30_fragprog *fp = fpc->fp;92uint32_t *hw = &fp->insn[fpc->inst_offset];93uint32_t sr = 0;9495switch (src.reg.type) {96case NVFXSR_INPUT:97sr |= (NVFX_FP_REG_TYPE_INPUT << NVFX_FP_REG_TYPE_SHIFT);98hw[0] |= (src.reg.index << NVFX_FP_OP_INPUT_SRC_SHIFT);99break;100case NVFXSR_OUTPUT:101sr |= NVFX_FP_REG_SRC_HALF;102FALLTHROUGH;103case NVFXSR_TEMP:104sr |= (NVFX_FP_REG_TYPE_TEMP << NVFX_FP_REG_TYPE_SHIFT);105sr |= (src.reg.index << NVFX_FP_REG_SRC_SHIFT);106break;107case NVFXSR_IMM:108if (!fpc->have_const) {109grow_insns(fpc, 4);110hw = &fp->insn[fpc->inst_offset];111fpc->have_const = 1;112}113114memcpy(&fp->insn[fpc->inst_offset + 4],115(float*)fpc->imm_data.data + src.reg.index * 4,116sizeof(uint32_t) * 4);117118sr |= (NVFX_FP_REG_TYPE_CONST << NVFX_FP_REG_TYPE_SHIFT);119break;120case NVFXSR_CONST:121if (!fpc->have_const) {122grow_insns(fpc, 4);123hw = &fp->insn[fpc->inst_offset];124fpc->have_const = 1;125}126127{128struct nv30_fragprog_data *fpd;129130fp->consts = realloc(fp->consts, ++fp->nr_consts *131sizeof(*fpd));132fpd = &fp->consts[fp->nr_consts - 1];133fpd->offset = fpc->inst_offset + 4;134fpd->index = src.reg.index;135memset(&fp->insn[fpd->offset], 0, sizeof(uint32_t) * 4);136}137138sr |= (NVFX_FP_REG_TYPE_CONST << NVFX_FP_REG_TYPE_SHIFT);139break;140case NVFXSR_NONE:141sr |= (NVFX_FP_REG_TYPE_INPUT << NVFX_FP_REG_TYPE_SHIFT);142break;143default:144assert(0);145}146147if (src.negate)148sr |= NVFX_FP_REG_NEGATE;149150if (src.abs)151hw[1] |= (1 << (29 + pos));152153sr |= ((src.swz[0] << NVFX_FP_REG_SWZ_X_SHIFT) |154(src.swz[1] << NVFX_FP_REG_SWZ_Y_SHIFT) |155(src.swz[2] << NVFX_FP_REG_SWZ_Z_SHIFT) |156(src.swz[3] << NVFX_FP_REG_SWZ_W_SHIFT));157158hw[pos + 1] |= sr;159}160161static void162emit_dst(struct nvfx_fpc *fpc, struct nvfx_reg dst)163{164struct nv30_fragprog *fp = fpc->fp;165uint32_t *hw = &fp->insn[fpc->inst_offset];166167switch (dst.type) {168case NVFXSR_OUTPUT:169if (dst.index == 1)170fp->fp_control |= 0x0000000e;171else {172hw[0] |= NVFX_FP_OP_OUT_REG_HALF;173dst.index <<= 1;174}175FALLTHROUGH;176case NVFXSR_TEMP:177if (fpc->num_regs < (dst.index + 1))178fpc->num_regs = dst.index + 1;179break;180case NVFXSR_NONE:181hw[0] |= (1 << 30);182break;183default:184assert(0);185}186187hw[0] |= (dst.index << NVFX_FP_OP_OUT_REG_SHIFT);188}189190static void191nvfx_fp_emit(struct nvfx_fpc *fpc, struct nvfx_insn insn)192{193struct nv30_fragprog *fp = fpc->fp;194uint32_t *hw;195196fpc->inst_offset = fp->insn_len;197fpc->have_const = 0;198grow_insns(fpc, 4);199hw = &fp->insn[fpc->inst_offset];200memset(hw, 0, sizeof(uint32_t) * 4);201202if (insn.op == NVFX_FP_OP_OPCODE_KIL)203fp->fp_control |= NV30_3D_FP_CONTROL_USES_KIL;204hw[0] |= (insn.op << NVFX_FP_OP_OPCODE_SHIFT);205hw[0] |= (insn.mask << NVFX_FP_OP_OUTMASK_SHIFT);206hw[2] |= (insn.scale << NVFX_FP_OP_DST_SCALE_SHIFT);207208if (insn.sat)209hw[0] |= NVFX_FP_OP_OUT_SAT;210211if (insn.cc_update)212hw[0] |= NVFX_FP_OP_COND_WRITE_ENABLE;213hw[1] |= (insn.cc_test << NVFX_FP_OP_COND_SHIFT);214hw[1] |= ((insn.cc_swz[0] << NVFX_FP_OP_COND_SWZ_X_SHIFT) |215(insn.cc_swz[1] << NVFX_FP_OP_COND_SWZ_Y_SHIFT) |216(insn.cc_swz[2] << NVFX_FP_OP_COND_SWZ_Z_SHIFT) |217(insn.cc_swz[3] << NVFX_FP_OP_COND_SWZ_W_SHIFT));218219if(insn.unit >= 0)220{221hw[0] |= (insn.unit << NVFX_FP_OP_TEX_UNIT_SHIFT);222}223224emit_dst(fpc, insn.dst);225emit_src(fpc, 0, insn.src[0]);226emit_src(fpc, 1, insn.src[1]);227emit_src(fpc, 2, insn.src[2]);228}229230#define arith(s,o,d,m,s0,s1,s2) \231nvfx_insn((s), NVFX_FP_OP_OPCODE_##o, -1, \232(d), (m), (s0), (s1), (s2))233234#define tex(s,o,u,d,m,s0,s1,s2) \235nvfx_insn((s), NVFX_FP_OP_OPCODE_##o, (u), \236(d), (m), (s0), none, none)237238/* IF src.x != 0, as TGSI specifies */239static void240nv40_fp_if(struct nvfx_fpc *fpc, struct nvfx_src src)241{242const struct nvfx_src none = nvfx_src(nvfx_reg(NVFXSR_NONE, 0));243struct nvfx_insn insn = arith(0, MOV, none.reg, NVFX_FP_MASK_X, src, none, none);244uint32_t *hw;245insn.cc_update = 1;246nvfx_fp_emit(fpc, insn);247248fpc->inst_offset = fpc->fp->insn_len;249grow_insns(fpc, 4);250hw = &fpc->fp->insn[fpc->inst_offset];251/* I really wonder why fp16 precision is used. Presumably the hardware ignores it? */252hw[0] = (NV40_FP_OP_BRA_OPCODE_IF << NVFX_FP_OP_OPCODE_SHIFT) |253NV40_FP_OP_OUT_NONE |254(NVFX_FP_PRECISION_FP16 << NVFX_FP_OP_PRECISION_SHIFT);255/* Use .xxxx swizzle so that we check only src[0].x*/256hw[1] = (0 << NVFX_FP_OP_COND_SWZ_X_SHIFT) |257(0 << NVFX_FP_OP_COND_SWZ_Y_SHIFT) |258(0 << NVFX_FP_OP_COND_SWZ_Z_SHIFT) |259(0 << NVFX_FP_OP_COND_SWZ_W_SHIFT) |260(NVFX_FP_OP_COND_NE << NVFX_FP_OP_COND_SHIFT);261hw[2] = 0; /* | NV40_FP_OP_OPCODE_IS_BRANCH | else_offset */262hw[3] = 0; /* | endif_offset */263util_dynarray_append(&fpc->if_stack, unsigned, fpc->inst_offset);264}265266/* IF src.x != 0, as TGSI specifies */267static void268nv40_fp_cal(struct nvfx_fpc *fpc, unsigned target)269{270struct nvfx_relocation reloc;271uint32_t *hw;272fpc->inst_offset = fpc->fp->insn_len;273grow_insns(fpc, 4);274hw = &fpc->fp->insn[fpc->inst_offset];275/* I really wonder why fp16 precision is used. Presumably the hardware ignores it? */276hw[0] = (NV40_FP_OP_BRA_OPCODE_CAL << NVFX_FP_OP_OPCODE_SHIFT);277/* Use .xxxx swizzle so that we check only src[0].x*/278hw[1] = (NVFX_SWZ_IDENTITY << NVFX_FP_OP_COND_SWZ_ALL_SHIFT) |279(NVFX_FP_OP_COND_TR << NVFX_FP_OP_COND_SHIFT);280hw[2] = NV40_FP_OP_OPCODE_IS_BRANCH; /* | call_offset */281hw[3] = 0;282reloc.target = target;283reloc.location = fpc->inst_offset + 2;284util_dynarray_append(&fpc->label_relocs, struct nvfx_relocation, reloc);285}286287static void288nv40_fp_ret(struct nvfx_fpc *fpc)289{290uint32_t *hw;291fpc->inst_offset = fpc->fp->insn_len;292grow_insns(fpc, 4);293hw = &fpc->fp->insn[fpc->inst_offset];294/* I really wonder why fp16 precision is used. Presumably the hardware ignores it? */295hw[0] = (NV40_FP_OP_BRA_OPCODE_RET << NVFX_FP_OP_OPCODE_SHIFT);296/* Use .xxxx swizzle so that we check only src[0].x*/297hw[1] = (NVFX_SWZ_IDENTITY << NVFX_FP_OP_COND_SWZ_ALL_SHIFT) |298(NVFX_FP_OP_COND_TR << NVFX_FP_OP_COND_SHIFT);299hw[2] = NV40_FP_OP_OPCODE_IS_BRANCH; /* | call_offset */300hw[3] = 0;301}302303static void304nv40_fp_rep(struct nvfx_fpc *fpc, unsigned count, unsigned target)305{306struct nvfx_relocation reloc;307uint32_t *hw;308fpc->inst_offset = fpc->fp->insn_len;309grow_insns(fpc, 4);310hw = &fpc->fp->insn[fpc->inst_offset];311/* I really wonder why fp16 precision is used. Presumably the hardware ignores it? */312hw[0] = (NV40_FP_OP_BRA_OPCODE_REP << NVFX_FP_OP_OPCODE_SHIFT) |313NV40_FP_OP_OUT_NONE |314(NVFX_FP_PRECISION_FP16 << NVFX_FP_OP_PRECISION_SHIFT);315/* Use .xxxx swizzle so that we check only src[0].x*/316hw[1] = (NVFX_SWZ_IDENTITY << NVFX_FP_OP_COND_SWZ_ALL_SHIFT) |317(NVFX_FP_OP_COND_TR << NVFX_FP_OP_COND_SHIFT);318hw[2] = NV40_FP_OP_OPCODE_IS_BRANCH |319(count << NV40_FP_OP_REP_COUNT1_SHIFT) |320(count << NV40_FP_OP_REP_COUNT2_SHIFT) |321(count << NV40_FP_OP_REP_COUNT3_SHIFT);322hw[3] = 0; /* | end_offset */323reloc.target = target;324reloc.location = fpc->inst_offset + 3;325util_dynarray_append(&fpc->label_relocs, struct nvfx_relocation, reloc);326//util_dynarray_append(&fpc->loop_stack, unsigned, target);327}328329#if 0330/* documentation only */331/* warning: this only works forward, and probably only if not inside any IF */332static void333nv40_fp_bra(struct nvfx_fpc *fpc, unsigned target)334{335struct nvfx_relocation reloc;336uint32_t *hw;337fpc->inst_offset = fpc->fp->insn_len;338grow_insns(fpc, 4);339hw = &fpc->fp->insn[fpc->inst_offset];340/* I really wonder why fp16 precision is used. Presumably the hardware ignores it? */341hw[0] = (NV40_FP_OP_BRA_OPCODE_IF << NVFX_FP_OP_OPCODE_SHIFT) |342NV40_FP_OP_OUT_NONE |343(NVFX_FP_PRECISION_FP16 << NVFX_FP_OP_PRECISION_SHIFT);344/* Use .xxxx swizzle so that we check only src[0].x*/345hw[1] = (NVFX_SWZ_IDENTITY << NVFX_FP_OP_COND_SWZ_X_SHIFT) |346(NVFX_FP_OP_COND_FL << NVFX_FP_OP_COND_SHIFT);347hw[2] = NV40_FP_OP_OPCODE_IS_BRANCH; /* | else_offset */348hw[3] = 0; /* | endif_offset */349reloc.target = target;350reloc.location = fpc->inst_offset + 2;351util_dynarray_append(&fpc->label_relocs, struct nvfx_relocation, reloc);352reloc.target = target;353reloc.location = fpc->inst_offset + 3;354util_dynarray_append(&fpc->label_relocs, struct nvfx_relocation, reloc);355}356#endif357358static void359nv40_fp_brk(struct nvfx_fpc *fpc)360{361uint32_t *hw;362fpc->inst_offset = fpc->fp->insn_len;363grow_insns(fpc, 4);364hw = &fpc->fp->insn[fpc->inst_offset];365/* I really wonder why fp16 precision is used. Presumably the hardware ignores it? */366hw[0] = (NV40_FP_OP_BRA_OPCODE_BRK << NVFX_FP_OP_OPCODE_SHIFT) |367NV40_FP_OP_OUT_NONE;368/* Use .xxxx swizzle so that we check only src[0].x*/369hw[1] = (NVFX_SWZ_IDENTITY << NVFX_FP_OP_COND_SWZ_X_SHIFT) |370(NVFX_FP_OP_COND_TR << NVFX_FP_OP_COND_SHIFT);371hw[2] = NV40_FP_OP_OPCODE_IS_BRANCH;372hw[3] = 0;373}374375static inline struct nvfx_src376tgsi_src(struct nvfx_fpc *fpc, const struct tgsi_full_src_register *fsrc)377{378struct nvfx_src src;379380switch (fsrc->Register.File) {381case TGSI_FILE_INPUT:382src.reg = fpc->r_input[fsrc->Register.Index];383break;384case TGSI_FILE_CONSTANT:385src.reg = nvfx_reg(NVFXSR_CONST, fsrc->Register.Index);386break;387case TGSI_FILE_IMMEDIATE:388assert(fsrc->Register.Index < fpc->nr_imm);389src.reg = fpc->r_imm[fsrc->Register.Index];390break;391case TGSI_FILE_TEMPORARY:392src.reg = fpc->r_temp[fsrc->Register.Index];393break;394/* NV40 fragprog result regs are just temps, so this is simple */395case TGSI_FILE_OUTPUT:396src.reg = fpc->r_result[fsrc->Register.Index];397break;398default:399NOUVEAU_ERR("bad src file\n");400src.reg.index = 0;401src.reg.type = 0;402break;403}404405src.abs = fsrc->Register.Absolute;406src.negate = fsrc->Register.Negate;407src.swz[0] = fsrc->Register.SwizzleX;408src.swz[1] = fsrc->Register.SwizzleY;409src.swz[2] = fsrc->Register.SwizzleZ;410src.swz[3] = fsrc->Register.SwizzleW;411src.indirect = 0;412src.indirect_reg = 0;413src.indirect_swz = 0;414return src;415}416417static inline struct nvfx_reg418tgsi_dst(struct nvfx_fpc *fpc, const struct tgsi_full_dst_register *fdst) {419switch (fdst->Register.File) {420case TGSI_FILE_OUTPUT:421return fpc->r_result[fdst->Register.Index];422case TGSI_FILE_TEMPORARY:423return fpc->r_temp[fdst->Register.Index];424case TGSI_FILE_NULL:425return nvfx_reg(NVFXSR_NONE, 0);426default:427NOUVEAU_ERR("bad dst file %d\n", fdst->Register.File);428return nvfx_reg(NVFXSR_NONE, 0);429}430}431432static inline int433tgsi_mask(uint tgsi)434{435int mask = 0;436437if (tgsi & TGSI_WRITEMASK_X) mask |= NVFX_FP_MASK_X;438if (tgsi & TGSI_WRITEMASK_Y) mask |= NVFX_FP_MASK_Y;439if (tgsi & TGSI_WRITEMASK_Z) mask |= NVFX_FP_MASK_Z;440if (tgsi & TGSI_WRITEMASK_W) mask |= NVFX_FP_MASK_W;441return mask;442}443444static bool445nvfx_fragprog_parse_instruction(struct nvfx_fpc *fpc,446const struct tgsi_full_instruction *finst)447{448const struct nvfx_src none = nvfx_src(nvfx_reg(NVFXSR_NONE, 0));449struct nvfx_insn insn;450struct nvfx_src src[3], tmp;451struct nvfx_reg dst;452int mask, sat, unit = 0;453int ai = -1, ci = -1, ii = -1;454int i;455456if (finst->Instruction.Opcode == TGSI_OPCODE_END)457return true;458459for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {460const struct tgsi_full_src_register *fsrc;461462fsrc = &finst->Src[i];463if (fsrc->Register.File == TGSI_FILE_TEMPORARY) {464src[i] = tgsi_src(fpc, fsrc);465}466}467468for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {469const struct tgsi_full_src_register *fsrc;470471fsrc = &finst->Src[i];472473switch (fsrc->Register.File) {474case TGSI_FILE_INPUT:475if(fpc->fp->info.input_semantic_name[fsrc->Register.Index] == TGSI_SEMANTIC_FOG && (0476|| fsrc->Register.SwizzleX == PIPE_SWIZZLE_W477|| fsrc->Register.SwizzleY == PIPE_SWIZZLE_W478|| fsrc->Register.SwizzleZ == PIPE_SWIZZLE_W479|| fsrc->Register.SwizzleW == PIPE_SWIZZLE_W480)) {481/* hardware puts 0 in fogcoord.w, but GL/Gallium want 1 there */482struct nvfx_src addend = nvfx_src(nvfx_fp_imm(fpc, 0, 0, 0, 1));483addend.swz[0] = fsrc->Register.SwizzleX;484addend.swz[1] = fsrc->Register.SwizzleY;485addend.swz[2] = fsrc->Register.SwizzleZ;486addend.swz[3] = fsrc->Register.SwizzleW;487src[i] = nvfx_src(temp(fpc));488nvfx_fp_emit(fpc, arith(0, ADD, src[i].reg, NVFX_FP_MASK_ALL, tgsi_src(fpc, fsrc), addend, none));489} else if (ai == -1 || ai == fsrc->Register.Index) {490ai = fsrc->Register.Index;491src[i] = tgsi_src(fpc, fsrc);492} else {493src[i] = nvfx_src(temp(fpc));494nvfx_fp_emit(fpc, arith(0, MOV, src[i].reg, NVFX_FP_MASK_ALL, tgsi_src(fpc, fsrc), none, none));495}496break;497case TGSI_FILE_CONSTANT:498if ((ci == -1 && ii == -1) ||499ci == fsrc->Register.Index) {500ci = fsrc->Register.Index;501src[i] = tgsi_src(fpc, fsrc);502} else {503src[i] = nvfx_src(temp(fpc));504nvfx_fp_emit(fpc, arith(0, MOV, src[i].reg, NVFX_FP_MASK_ALL, tgsi_src(fpc, fsrc), none, none));505}506break;507case TGSI_FILE_IMMEDIATE:508if ((ci == -1 && ii == -1) ||509ii == fsrc->Register.Index) {510ii = fsrc->Register.Index;511src[i] = tgsi_src(fpc, fsrc);512} else {513src[i] = nvfx_src(temp(fpc));514nvfx_fp_emit(fpc, arith(0, MOV, src[i].reg, NVFX_FP_MASK_ALL, tgsi_src(fpc, fsrc), none, none));515}516break;517case TGSI_FILE_TEMPORARY:518/* handled above */519break;520case TGSI_FILE_SAMPLER:521unit = fsrc->Register.Index;522break;523case TGSI_FILE_OUTPUT:524break;525default:526NOUVEAU_ERR("bad src file\n");527return false;528}529}530531dst = tgsi_dst(fpc, &finst->Dst[0]);532mask = tgsi_mask(finst->Dst[0].Register.WriteMask);533sat = finst->Instruction.Saturate;534535switch (finst->Instruction.Opcode) {536case TGSI_OPCODE_ADD:537nvfx_fp_emit(fpc, arith(sat, ADD, dst, mask, src[0], src[1], none));538break;539case TGSI_OPCODE_CEIL:540tmp = nvfx_src(temp(fpc));541nvfx_fp_emit(fpc, arith(0, FLR, tmp.reg, mask, neg(src[0]), none, none));542nvfx_fp_emit(fpc, arith(sat, MOV, dst, mask, neg(tmp), none, none));543break;544case TGSI_OPCODE_CMP:545insn = arith(0, MOV, none.reg, mask, src[0], none, none);546insn.cc_update = 1;547nvfx_fp_emit(fpc, insn);548549insn = arith(sat, MOV, dst, mask, src[2], none, none);550insn.cc_test = NVFX_COND_GE;551nvfx_fp_emit(fpc, insn);552553insn = arith(sat, MOV, dst, mask, src[1], none, none);554insn.cc_test = NVFX_COND_LT;555nvfx_fp_emit(fpc, insn);556break;557case TGSI_OPCODE_COS:558nvfx_fp_emit(fpc, arith(sat, COS, dst, mask, src[0], none, none));559break;560case TGSI_OPCODE_DDX:561if (mask & (NVFX_FP_MASK_Z | NVFX_FP_MASK_W)) {562tmp = nvfx_src(temp(fpc));563nvfx_fp_emit(fpc, arith(sat, DDX, tmp.reg, NVFX_FP_MASK_X | NVFX_FP_MASK_Y, swz(src[0], Z, W, Z, W), none, none));564nvfx_fp_emit(fpc, arith(0, MOV, tmp.reg, NVFX_FP_MASK_Z | NVFX_FP_MASK_W, swz(tmp, X, Y, X, Y), none, none));565nvfx_fp_emit(fpc, arith(sat, DDX, tmp.reg, NVFX_FP_MASK_X | NVFX_FP_MASK_Y, src[0], none, none));566nvfx_fp_emit(fpc, arith(0, MOV, dst, mask, tmp, none, none));567} else {568nvfx_fp_emit(fpc, arith(sat, DDX, dst, mask, src[0], none, none));569}570break;571case TGSI_OPCODE_DDY:572if (mask & (NVFX_FP_MASK_Z | NVFX_FP_MASK_W)) {573tmp = nvfx_src(temp(fpc));574nvfx_fp_emit(fpc, arith(sat, DDY, tmp.reg, NVFX_FP_MASK_X | NVFX_FP_MASK_Y, swz(src[0], Z, W, Z, W), none, none));575nvfx_fp_emit(fpc, arith(0, MOV, tmp.reg, NVFX_FP_MASK_Z | NVFX_FP_MASK_W, swz(tmp, X, Y, X, Y), none, none));576nvfx_fp_emit(fpc, arith(sat, DDY, tmp.reg, NVFX_FP_MASK_X | NVFX_FP_MASK_Y, src[0], none, none));577nvfx_fp_emit(fpc, arith(0, MOV, dst, mask, tmp, none, none));578} else {579nvfx_fp_emit(fpc, arith(sat, DDY, dst, mask, src[0], none, none));580}581break;582case TGSI_OPCODE_DP2:583tmp = nvfx_src(temp(fpc));584nvfx_fp_emit(fpc, arith(0, MUL, tmp.reg, NVFX_FP_MASK_X | NVFX_FP_MASK_Y, src[0], src[1], none));585nvfx_fp_emit(fpc, arith(0, ADD, dst, mask, swz(tmp, X, X, X, X), swz(tmp, Y, Y, Y, Y), none));586break;587case TGSI_OPCODE_DP3:588nvfx_fp_emit(fpc, arith(sat, DP3, dst, mask, src[0], src[1], none));589break;590case TGSI_OPCODE_DP4:591nvfx_fp_emit(fpc, arith(sat, DP4, dst, mask, src[0], src[1], none));592break;593case TGSI_OPCODE_DST:594nvfx_fp_emit(fpc, arith(sat, DST, dst, mask, src[0], src[1], none));595break;596case TGSI_OPCODE_EX2:597nvfx_fp_emit(fpc, arith(sat, EX2, dst, mask, src[0], none, none));598break;599case TGSI_OPCODE_FLR:600nvfx_fp_emit(fpc, arith(sat, FLR, dst, mask, src[0], none, none));601break;602case TGSI_OPCODE_FRC:603nvfx_fp_emit(fpc, arith(sat, FRC, dst, mask, src[0], none, none));604break;605case TGSI_OPCODE_KILL:606nvfx_fp_emit(fpc, arith(0, KIL, none.reg, 0, none, none, none));607break;608case TGSI_OPCODE_KILL_IF:609insn = arith(0, MOV, none.reg, NVFX_FP_MASK_ALL, src[0], none, none);610insn.cc_update = 1;611nvfx_fp_emit(fpc, insn);612613insn = arith(0, KIL, none.reg, 0, none, none, none);614insn.cc_test = NVFX_COND_LT;615nvfx_fp_emit(fpc, insn);616break;617case TGSI_OPCODE_LG2:618nvfx_fp_emit(fpc, arith(sat, LG2, dst, mask, src[0], none, none));619break;620case TGSI_OPCODE_LIT:621if(!fpc->is_nv4x)622nvfx_fp_emit(fpc, arith(sat, LIT_NV30, dst, mask, src[0], none, none));623else {624/* we use FLT_MIN, so that log2 never gives -infinity, and thus multiplication by625* specular 0 always gives 0, so that ex2 gives 1, to satisfy the 0^0 = 1 requirement626*627* NOTE: if we start using half precision, we might need an fp16 FLT_MIN here instead628*/629struct nvfx_src maxs = nvfx_src(nvfx_fp_imm(fpc, 0, FLT_MIN, 0, 0));630tmp = nvfx_src(temp(fpc));631if (ci>= 0 || ii >= 0) {632nvfx_fp_emit(fpc, arith(0, MOV, tmp.reg, NVFX_FP_MASK_X | NVFX_FP_MASK_Y, maxs, none, none));633maxs = tmp;634}635nvfx_fp_emit(fpc, arith(0, MAX, tmp.reg, NVFX_FP_MASK_Y | NVFX_FP_MASK_W, swz(src[0], X, X, X, Y), swz(maxs, X, X, Y, Y), none));636nvfx_fp_emit(fpc, arith(0, LG2, tmp.reg, NVFX_FP_MASK_W, swz(tmp, W, W, W, W), none, none));637nvfx_fp_emit(fpc, arith(0, MUL, tmp.reg, NVFX_FP_MASK_W, swz(tmp, W, W, W, W), swz(src[0], W, W, W, W), none));638nvfx_fp_emit(fpc, arith(sat, LITEX2_NV40, dst, mask, swz(tmp, Y, Y, W, W), none, none));639}640break;641case TGSI_OPCODE_LRP:642if(!fpc->is_nv4x)643nvfx_fp_emit(fpc, arith(sat, LRP_NV30, dst, mask, src[0], src[1], src[2]));644else {645tmp = nvfx_src(temp(fpc));646nvfx_fp_emit(fpc, arith(0, MAD, tmp.reg, mask, neg(src[0]), src[2], src[2]));647nvfx_fp_emit(fpc, arith(sat, MAD, dst, mask, src[0], src[1], tmp));648}649break;650case TGSI_OPCODE_MAD:651nvfx_fp_emit(fpc, arith(sat, MAD, dst, mask, src[0], src[1], src[2]));652break;653case TGSI_OPCODE_MAX:654nvfx_fp_emit(fpc, arith(sat, MAX, dst, mask, src[0], src[1], none));655break;656case TGSI_OPCODE_MIN:657nvfx_fp_emit(fpc, arith(sat, MIN, dst, mask, src[0], src[1], none));658break;659case TGSI_OPCODE_MOV:660nvfx_fp_emit(fpc, arith(sat, MOV, dst, mask, src[0], none, none));661break;662case TGSI_OPCODE_MUL:663nvfx_fp_emit(fpc, arith(sat, MUL, dst, mask, src[0], src[1], none));664break;665case TGSI_OPCODE_NOP:666break;667case TGSI_OPCODE_POW:668if(!fpc->is_nv4x)669nvfx_fp_emit(fpc, arith(sat, POW_NV30, dst, mask, src[0], src[1], none));670else {671tmp = nvfx_src(temp(fpc));672nvfx_fp_emit(fpc, arith(0, LG2, tmp.reg, NVFX_FP_MASK_X, swz(src[0], X, X, X, X), none, none));673nvfx_fp_emit(fpc, arith(0, MUL, tmp.reg, NVFX_FP_MASK_X, swz(tmp, X, X, X, X), swz(src[1], X, X, X, X), none));674nvfx_fp_emit(fpc, arith(sat, EX2, dst, mask, swz(tmp, X, X, X, X), none, none));675}676break;677case TGSI_OPCODE_RCP:678nvfx_fp_emit(fpc, arith(sat, RCP, dst, mask, src[0], none, none));679break;680case TGSI_OPCODE_RSQ:681if(!fpc->is_nv4x)682nvfx_fp_emit(fpc, arith(sat, RSQ_NV30, dst, mask, abs(swz(src[0], X, X, X, X)), none, none));683else {684tmp = nvfx_src(temp(fpc));685insn = arith(0, LG2, tmp.reg, NVFX_FP_MASK_X, abs(swz(src[0], X, X, X, X)), none, none);686insn.scale = NVFX_FP_OP_DST_SCALE_INV_2X;687nvfx_fp_emit(fpc, insn);688nvfx_fp_emit(fpc, arith(sat, EX2, dst, mask, neg(swz(tmp, X, X, X, X)), none, none));689}690break;691case TGSI_OPCODE_SEQ:692nvfx_fp_emit(fpc, arith(sat, SEQ, dst, mask, src[0], src[1], none));693break;694case TGSI_OPCODE_SGE:695nvfx_fp_emit(fpc, arith(sat, SGE, dst, mask, src[0], src[1], none));696break;697case TGSI_OPCODE_SGT:698nvfx_fp_emit(fpc, arith(sat, SGT, dst, mask, src[0], src[1], none));699break;700case TGSI_OPCODE_SIN:701nvfx_fp_emit(fpc, arith(sat, SIN, dst, mask, src[0], none, none));702break;703case TGSI_OPCODE_SLE:704nvfx_fp_emit(fpc, arith(sat, SLE, dst, mask, src[0], src[1], none));705break;706case TGSI_OPCODE_SLT:707nvfx_fp_emit(fpc, arith(sat, SLT, dst, mask, src[0], src[1], none));708break;709case TGSI_OPCODE_SNE:710nvfx_fp_emit(fpc, arith(sat, SNE, dst, mask, src[0], src[1], none));711break;712case TGSI_OPCODE_SSG:713{714struct nvfx_src minones = swz(nvfx_src(nvfx_fp_imm(fpc, -1, -1, -1, -1)), X, X, X, X);715716insn = arith(sat, MOV, dst, mask, src[0], none, none);717insn.cc_update = 1;718nvfx_fp_emit(fpc, insn);719720insn = arith(0, STR, dst, mask, none, none, none);721insn.cc_test = NVFX_COND_GT;722nvfx_fp_emit(fpc, insn);723724if(!sat) {725insn = arith(0, MOV, dst, mask, minones, none, none);726insn.cc_test = NVFX_COND_LT;727nvfx_fp_emit(fpc, insn);728}729break;730}731case TGSI_OPCODE_TEX:732nvfx_fp_emit(fpc, tex(sat, TEX, unit, dst, mask, src[0], none, none));733break;734case TGSI_OPCODE_TRUNC:735tmp = nvfx_src(temp(fpc));736insn = arith(0, MOV, none.reg, mask, src[0], none, none);737insn.cc_update = 1;738nvfx_fp_emit(fpc, insn);739740nvfx_fp_emit(fpc, arith(0, FLR, tmp.reg, mask, abs(src[0]), none, none));741nvfx_fp_emit(fpc, arith(sat, MOV, dst, mask, tmp, none, none));742743insn = arith(sat, MOV, dst, mask, neg(tmp), none, none);744insn.cc_test = NVFX_COND_LT;745nvfx_fp_emit(fpc, insn);746break;747case TGSI_OPCODE_TXB:748nvfx_fp_emit(fpc, tex(sat, TXB, unit, dst, mask, src[0], none, none));749break;750case TGSI_OPCODE_TXL:751if(fpc->is_nv4x)752nvfx_fp_emit(fpc, tex(sat, TXL_NV40, unit, dst, mask, src[0], none, none));753else /* unsupported on nv30, use TEX and hope they like it */754nvfx_fp_emit(fpc, tex(sat, TEX, unit, dst, mask, src[0], none, none));755break;756case TGSI_OPCODE_TXP:757nvfx_fp_emit(fpc, tex(sat, TXP, unit, dst, mask, src[0], none, none));758break;759760case TGSI_OPCODE_IF:761// MOVRC0 R31 (TR0.xyzw), R<src>:762// IF (NE.xxxx) ELSE <else> END <end>763if(!fpc->is_nv4x)764goto nv3x_cflow;765nv40_fp_if(fpc, src[0]);766break;767768case TGSI_OPCODE_ELSE:769{770uint32_t *hw;771if(!fpc->is_nv4x)772goto nv3x_cflow;773assert(util_dynarray_contains(&fpc->if_stack, unsigned));774hw = &fpc->fp->insn[util_dynarray_top(&fpc->if_stack, unsigned)];775hw[2] = NV40_FP_OP_OPCODE_IS_BRANCH | fpc->fp->insn_len;776break;777}778779case TGSI_OPCODE_ENDIF:780{781uint32_t *hw;782if(!fpc->is_nv4x)783goto nv3x_cflow;784assert(util_dynarray_contains(&fpc->if_stack, unsigned));785hw = &fpc->fp->insn[util_dynarray_pop(&fpc->if_stack, unsigned)];786if(!hw[2])787hw[2] = NV40_FP_OP_OPCODE_IS_BRANCH | fpc->fp->insn_len;788hw[3] = fpc->fp->insn_len;789break;790}791792case TGSI_OPCODE_BGNSUB:793case TGSI_OPCODE_ENDSUB:794/* nothing to do here */795break;796797case TGSI_OPCODE_CAL:798if(!fpc->is_nv4x)799goto nv3x_cflow;800nv40_fp_cal(fpc, finst->Label.Label);801break;802803case TGSI_OPCODE_RET:804if(!fpc->is_nv4x)805goto nv3x_cflow;806nv40_fp_ret(fpc);807break;808809case TGSI_OPCODE_BGNLOOP:810if(!fpc->is_nv4x)811goto nv3x_cflow;812/* TODO: we should support using two nested REPs to allow a > 255 iteration count */813nv40_fp_rep(fpc, 255, finst->Label.Label);814break;815816case TGSI_OPCODE_ENDLOOP:817break;818819case TGSI_OPCODE_BRK:820if(!fpc->is_nv4x)821goto nv3x_cflow;822nv40_fp_brk(fpc);823break;824825case TGSI_OPCODE_CONT:826{827static int warned = 0;828if(!warned) {829NOUVEAU_ERR("Sorry, the continue keyword is not implemented: ignoring it.\n");830warned = 1;831}832break;833}834835default:836NOUVEAU_ERR("invalid opcode %d\n", finst->Instruction.Opcode);837return false;838}839840out:841release_temps(fpc);842return true;843nv3x_cflow:844{845static int warned = 0;846if(!warned) {847NOUVEAU_ERR(848"Sorry, control flow instructions are not supported in hardware on nv3x: ignoring them\n"849"If rendering is incorrect, try to disable GLSL support in the application.\n");850warned = 1;851}852}853goto out;854}855856static bool857nvfx_fragprog_parse_decl_input(struct nvfx_fpc *fpc,858const struct tgsi_full_declaration *fdec)859{860unsigned idx = fdec->Range.First;861unsigned hw;862863switch (fdec->Semantic.Name) {864case TGSI_SEMANTIC_POSITION:865hw = NVFX_FP_OP_INPUT_SRC_POSITION;866break;867case TGSI_SEMANTIC_COLOR:868hw = NVFX_FP_OP_INPUT_SRC_COL0 + fdec->Semantic.Index;869break;870case TGSI_SEMANTIC_FOG:871hw = NVFX_FP_OP_INPUT_SRC_FOGC;872break;873case TGSI_SEMANTIC_FACE:874hw = NV40_FP_OP_INPUT_SRC_FACING;875break;876case TGSI_SEMANTIC_TEXCOORD:877assert(fdec->Semantic.Index < 8);878fpc->fp->texcoord[fdec->Semantic.Index] = fdec->Semantic.Index;879fpc->fp->texcoords |= (1 << fdec->Semantic.Index);880fpc->fp->vp_or |= (0x00004000 << fdec->Semantic.Index);881hw = NVFX_FP_OP_INPUT_SRC_TC(fdec->Semantic.Index);882break;883case TGSI_SEMANTIC_GENERIC:884case TGSI_SEMANTIC_PCOORD:885/* will be assigned to remaining TC slots later */886return true;887default:888assert(0);889return false;890}891892fpc->r_input[idx] = nvfx_reg(NVFXSR_INPUT, hw);893return true;894}895896static bool897nvfx_fragprog_assign_generic(struct nvfx_fpc *fpc,898const struct tgsi_full_declaration *fdec)899{900unsigned num_texcoords = fpc->is_nv4x ? 10 : 8;901unsigned idx = fdec->Range.First;902unsigned hw;903904switch (fdec->Semantic.Name) {905case TGSI_SEMANTIC_GENERIC:906case TGSI_SEMANTIC_PCOORD:907for (hw = 0; hw < num_texcoords; hw++) {908if (fpc->fp->texcoord[hw] == 0xffff) {909if (hw <= 7) {910fpc->fp->texcoords |= (0x1 << hw);911fpc->fp->vp_or |= (0x00004000 << hw);912} else {913fpc->fp->vp_or |= (0x00001000 << (hw - 8));914}915if (fdec->Semantic.Name == TGSI_SEMANTIC_PCOORD) {916fpc->fp->texcoord[hw] = 0xfffe;917fpc->fp->point_sprite_control |= (0x00000100 << hw);918} else {919fpc->fp->texcoord[hw] = fdec->Semantic.Index + 8;920}921hw = NVFX_FP_OP_INPUT_SRC_TC(hw);922fpc->r_input[idx] = nvfx_reg(NVFXSR_INPUT, hw);923return true;924}925}926return false;927default:928return true;929}930}931932static bool933nvfx_fragprog_parse_decl_output(struct nvfx_fpc *fpc,934const struct tgsi_full_declaration *fdec)935{936unsigned idx = fdec->Range.First;937unsigned hw;938939switch (fdec->Semantic.Name) {940case TGSI_SEMANTIC_POSITION:941hw = 1;942break;943case TGSI_SEMANTIC_COLOR:944hw = ~0;945switch (fdec->Semantic.Index) {946case 0: hw = 0; break;947case 1: hw = 2; break;948case 2: hw = 3; break;949case 3: hw = 4; break;950}951if(hw > ((fpc->is_nv4x) ? 4 : 2)) {952NOUVEAU_ERR("bad rcol index\n");953return false;954}955break;956default:957NOUVEAU_ERR("bad output semantic\n");958return false;959}960961fpc->r_result[idx] = nvfx_reg(NVFXSR_OUTPUT, hw);962fpc->r_temps |= (1ULL << hw);963return true;964}965966static bool967nvfx_fragprog_prepare(struct nvfx_fpc *fpc)968{969struct tgsi_parse_context p;970int high_temp = -1, i;971972fpc->r_imm = CALLOC(fpc->fp->info.immediate_count, sizeof(struct nvfx_reg));973974tgsi_parse_init(&p, fpc->fp->pipe.tokens);975while (!tgsi_parse_end_of_tokens(&p)) {976const union tgsi_full_token *tok = &p.FullToken;977978tgsi_parse_token(&p);979switch(tok->Token.Type) {980case TGSI_TOKEN_TYPE_DECLARATION:981{982const struct tgsi_full_declaration *fdec;983fdec = &p.FullToken.FullDeclaration;984switch (fdec->Declaration.File) {985case TGSI_FILE_INPUT:986if (!nvfx_fragprog_parse_decl_input(fpc, fdec))987goto out_err;988break;989case TGSI_FILE_OUTPUT:990if (!nvfx_fragprog_parse_decl_output(fpc, fdec))991goto out_err;992break;993case TGSI_FILE_TEMPORARY:994if (fdec->Range.Last > high_temp) {995high_temp =996fdec->Range.Last;997}998break;999default:1000break;1001}1002}1003break;1004case TGSI_TOKEN_TYPE_IMMEDIATE:1005{1006struct tgsi_full_immediate *imm;10071008imm = &p.FullToken.FullImmediate;1009assert(imm->Immediate.DataType == TGSI_IMM_FLOAT32);1010assert(fpc->nr_imm < fpc->fp->info.immediate_count);10111012fpc->r_imm[fpc->nr_imm++] = nvfx_fp_imm(fpc, imm->u[0].Float, imm->u[1].Float, imm->u[2].Float, imm->u[3].Float);1013break;1014}1015default:1016break;1017}1018}1019tgsi_parse_free(&p);10201021tgsi_parse_init(&p, fpc->fp->pipe.tokens);1022while (!tgsi_parse_end_of_tokens(&p)) {1023const struct tgsi_full_declaration *fdec;1024tgsi_parse_token(&p);1025switch(p.FullToken.Token.Type) {1026case TGSI_TOKEN_TYPE_DECLARATION:1027fdec = &p.FullToken.FullDeclaration;1028switch (fdec->Declaration.File) {1029case TGSI_FILE_INPUT:1030if (!nvfx_fragprog_assign_generic(fpc, fdec))1031goto out_err;1032break;1033default:1034break;1035}1036break;1037default:1038break;1039}1040}1041tgsi_parse_free(&p);10421043if (++high_temp) {1044fpc->r_temp = CALLOC(high_temp, sizeof(struct nvfx_reg));1045for (i = 0; i < high_temp; i++)1046fpc->r_temp[i] = temp(fpc);1047fpc->r_temps_discard = 0ULL;1048}10491050return true;10511052out_err:1053FREE(fpc->r_temp);1054fpc->r_temp = NULL;10551056tgsi_parse_free(&p);1057return false;1058}10591060DEBUG_GET_ONCE_BOOL_OPTION(nvfx_dump_fp, "NVFX_DUMP_FP", false)10611062void1063_nvfx_fragprog_translate(uint16_t oclass, struct nv30_fragprog *fp)1064{1065struct tgsi_parse_context parse;1066struct nvfx_fpc *fpc = NULL;1067struct util_dynarray insns;10681069fp->translated = false;1070fp->point_sprite_control = 0;1071fp->vp_or = 0;10721073fpc = CALLOC_STRUCT(nvfx_fpc);1074if (!fpc)1075goto out_err;10761077fpc->is_nv4x = (oclass >= NV40_3D_CLASS) ? ~0 : 0;1078fpc->max_temps = fpc->is_nv4x ? 48 : 32;1079fpc->fp = fp;1080fpc->num_regs = 2;1081memset(fp->texcoord, 0xff, sizeof(fp->texcoord));10821083if (fp->info.properties[TGSI_PROPERTY_FS_COORD_ORIGIN])1084fp->coord_conventions |= NV30_3D_COORD_CONVENTIONS_ORIGIN_INVERTED;1085if (fp->info.properties[TGSI_PROPERTY_FS_COORD_PIXEL_CENTER])1086fp->coord_conventions |= NV30_3D_COORD_CONVENTIONS_CENTER_INTEGER;1087if (fp->info.properties[TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS])1088fp->rt_enable |= NV30_3D_RT_ENABLE_MRT;10891090if (!nvfx_fragprog_prepare(fpc))1091goto out_err;10921093tgsi_parse_init(&parse, fp->pipe.tokens);1094util_dynarray_init(&insns, NULL);10951096while (!tgsi_parse_end_of_tokens(&parse)) {1097tgsi_parse_token(&parse);10981099switch (parse.FullToken.Token.Type) {1100case TGSI_TOKEN_TYPE_INSTRUCTION:1101{1102const struct tgsi_full_instruction *finst;11031104util_dynarray_append(&insns, unsigned, fp->insn_len);1105finst = &parse.FullToken.FullInstruction;1106if (!nvfx_fragprog_parse_instruction(fpc, finst))1107goto out_err;1108}1109break;1110default:1111break;1112}1113}1114util_dynarray_append(&insns, unsigned, fp->insn_len);11151116for(unsigned i = 0; i < fpc->label_relocs.size; i += sizeof(struct nvfx_relocation))1117{1118struct nvfx_relocation* label_reloc = (struct nvfx_relocation*)((char*)fpc->label_relocs.data + i);1119fp->insn[label_reloc->location] |= ((unsigned*)insns.data)[label_reloc->target];1120}1121util_dynarray_fini(&insns);11221123if(!fpc->is_nv4x)1124fp->fp_control |= (fpc->num_regs-1)/2;1125else1126fp->fp_control |= fpc->num_regs << NV40_3D_FP_CONTROL_TEMP_COUNT__SHIFT;11271128/* Terminate final instruction */1129if(fp->insn)1130fp->insn[fpc->inst_offset] |= 0x00000001;11311132/* Append NOP + END instruction for branches to the end of the program */1133fpc->inst_offset = fp->insn_len;1134grow_insns(fpc, 4);1135fp->insn[fpc->inst_offset + 0] = 0x00000001;1136fp->insn[fpc->inst_offset + 1] = 0x00000000;1137fp->insn[fpc->inst_offset + 2] = 0x00000000;1138fp->insn[fpc->inst_offset + 3] = 0x00000000;11391140if(debug_get_option_nvfx_dump_fp())1141{1142debug_printf("\n");1143tgsi_dump(fp->pipe.tokens, 0);11441145debug_printf("\n%s fragment program:\n", fpc->is_nv4x ? "nv4x" : "nv3x");1146for (unsigned i = 0; i < fp->insn_len; i += 4)1147debug_printf("%3u: %08x %08x %08x %08x\n", i >> 2, fp->insn[i], fp->insn[i + 1], fp->insn[i + 2], fp->insn[i + 3]);1148debug_printf("\n");1149}11501151fp->translated = true;11521153out:1154tgsi_parse_free(&parse);1155if (fpc)1156{1157FREE(fpc->r_temp);1158FREE(fpc->r_imm);1159util_dynarray_fini(&fpc->if_stack);1160util_dynarray_fini(&fpc->label_relocs);1161util_dynarray_fini(&fpc->imm_data);1162//util_dynarray_fini(&fpc->loop_stack);1163FREE(fpc);1164}11651166return;11671168out_err:1169_debug_printf("Error: failed to compile this fragment program:\n");1170tgsi_dump(fp->pipe.tokens, 0);1171goto out;1172}117311741175