nv50_program.c revision 74559abbef5e5bcd3dbe1b8bbb8a39391a8a8671
1857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs/* 2633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller * Copyright 2010 Chrsitoph Bumiller 3857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * 4857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * Permission is hereby granted, free of charge, to any person obtaining a 5857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * copy of this software and associated documentation files (the "Software"), 6857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * to deal in the Software without restriction, including without limitation 7857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * and/or sell copies of the Software, and to permit persons to whom the 9857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * Software is furnished to do so, subject to the following conditions: 10857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * 11857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * The above copyright notice and this permission notice shall be included in 12857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * all copies or substantial portions of the Software. 13857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * 14857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 19857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs * SOFTWARE. 21857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs */ 22857a3294a959015bf893241199f7fd7f7882a6abBen Skeggs 23633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller#include "nv50_program.h" 24633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller#include "nv50_pc.h" 25633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller#include "nv50_context.h" 26f722fd937db2f3cacf1947d538c66528fd16eb89Ben Skeggs 27f722fd937db2f3cacf1947d538c66528fd16eb89Ben Skeggs#include "pipe/p_shader_tokens.h" 28fda01b584715c05696a0e6768fda669ef1eb5f3bBen Skeggs#include "tgsi/tgsi_parse.h" 29fda01b584715c05696a0e6768fda669ef1eb5f3bBen Skeggs#include "tgsi/tgsi_util.h" 303a68fcfb6b406cf864afbf200e436fc384fd0865Christoph Bumiller#include "tgsi/tgsi_dump.h" 31f722fd937db2f3cacf1947d538c66528fd16eb89Ben Skeggs 326516594c8eec1088ee59e7c3254b2fdced2ff04bChristoph Bumillerstatic INLINE unsigned 33633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumillerbitcount4(const uint32_t val) 34170cdb4507683fb9042620f7ab2ad96e57787d6cChristoph Bumiller{ 35633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller static const unsigned cnt[16] 36633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; 37633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller return cnt[val & 0xf]; 38170cdb4507683fb9042620f7ab2ad96e57787d6cChristoph Bumiller} 39170cdb4507683fb9042620f7ab2ad96e57787d6cChristoph Bumiller 40633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumillerstatic unsigned 41633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumillernv50_tgsi_src_mask(const struct tgsi_full_instruction *inst, int c) 42633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller{ 43633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller unsigned mask = inst->Dst[0].Register.WriteMask; 44633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 45633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller switch (inst->Instruction.Opcode) { 46633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_OPCODE_COS: 47633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_OPCODE_SIN: 48633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller return (mask & 0x8) | ((mask & 0x7) ? 0x1 : 0x0); 49633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_OPCODE_DP3: 50633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller return 0x7; 51633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_OPCODE_DP4: 52633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_OPCODE_DPH: 53633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_OPCODE_KIL: /* WriteMask ignored */ 54633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller return 0xf; 55633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_OPCODE_DST: 56633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller return mask & (c ? 0xa : 0x6); 57633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_OPCODE_EX2: 58633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_OPCODE_EXP: 59633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_OPCODE_LG2: 60633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_OPCODE_LOG: 61633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_OPCODE_POW: 62633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_OPCODE_RCP: 63633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_OPCODE_RSQ: 64633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_OPCODE_SCS: 65633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller return 0x1; 66633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_OPCODE_IF: 67633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller return 0x1; 68633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_OPCODE_LIT: 69633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller return 0xb; 70633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_OPCODE_TEX: 71633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_OPCODE_TXB: 72633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_OPCODE_TXL: 73633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_OPCODE_TXP: 74633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller { 75633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller const struct tgsi_instruction_texture *tex; 76633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 77633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller assert(inst->Instruction.Texture); 78633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller tex = &inst->Texture; 79633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 80633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller mask = 0x7; 81633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (inst->Instruction.Opcode != TGSI_OPCODE_TEX && 82633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller inst->Instruction.Opcode != TGSI_OPCODE_TXD) 83633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller mask |= 0x8; /* bias, lod or proj */ 84633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 85633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller switch (tex->Texture) { 86633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_TEXTURE_1D: 87633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller mask &= 0x9; 88633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 89633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_TEXTURE_SHADOW1D: 90633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller mask &= 0x5; 91633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 92633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_TEXTURE_2D: 93633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller mask &= 0xb; 94633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 95633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller default: 96633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 97633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 98633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 99633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller return mask; 100633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_OPCODE_XPD: 101633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller { 102633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller unsigned x = 0; 103633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (mask & 1) x |= 0x6; 104633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (mask & 2) x |= 0x5; 105633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (mask & 4) x |= 0x3; 106633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller return x; 107633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 108633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller default: 109633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 110633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 111633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 112633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller return mask; 113633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller} 114633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 115633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumillerstatic void 116633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumillernv50_indirect_inputs(struct nv50_translation_info *ti, int id) 117633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller{ 118633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller int i, c; 119633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 120633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller for (i = 0; i < PIPE_MAX_SHADER_INPUTS; ++i) 121633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller for (c = 0; c < 4; ++c) 122633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->input_access[i][c] = id; 123633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 124633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->indirect_inputs = TRUE; 125633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller} 126633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 127633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumillerstatic void 128633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumillernv50_indirect_outputs(struct nv50_translation_info *ti, int id) 129633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller{ 130633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller int i, c; 131633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 132633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller for (i = 0; i < PIPE_MAX_SHADER_OUTPUTS; ++i) 133633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller for (c = 0; c < 4; ++c) 134633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->output_access[i][c] = id; 135633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 136633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->indirect_outputs = TRUE; 137633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller} 138633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 139633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumillerstatic void 140633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumillerprog_inst(struct nv50_translation_info *ti, 141633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller const struct tgsi_full_instruction *inst, int id) 142633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller{ 143633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller const struct tgsi_dst_register *dst; 144633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller const struct tgsi_src_register *src; 145633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller int s, c, k; 146633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller unsigned mask; 147633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 148d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller if (inst->Instruction.Opcode == TGSI_OPCODE_BGNSUB) { 149d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller ti->subr[ti->subr_nr].pos = id - 1; 150d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller ti->subr[ti->subr_nr].id = ti->subr_nr + 1; /* id 0 is main program */ 151d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller ++ti->subr_nr; 152d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller } 153d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller 154633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (inst->Dst[0].Register.File == TGSI_FILE_OUTPUT) { 155d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller dst = &inst->Dst[0].Register; 156d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller 157633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller for (c = 0; c < 4; ++c) { 158d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller if (dst->Indirect) 159633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller nv50_indirect_outputs(ti, id); 160633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (!(dst->WriteMask & (1 << c))) 161633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller continue; 162633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->output_access[dst->Index][c] = id; 163633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 164633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 165633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (inst->Instruction.Opcode == TGSI_OPCODE_MOV && 166633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller inst->Src[0].Register.File == TGSI_FILE_INPUT && 167633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller dst->Index == ti->edgeflag_out) 168633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->p->vp.edgeflag = inst->Src[0].Register.Index; 169f30810cb68a53c4fef360778a230126ed0ee0ee3Christoph Bumiller } else 170f30810cb68a53c4fef360778a230126ed0ee0ee3Christoph Bumiller if (inst->Dst[0].Register.File == TGSI_FILE_TEMPORARY) { 171f30810cb68a53c4fef360778a230126ed0ee0ee3Christoph Bumiller if (inst->Dst[0].Register.Indirect) 172f30810cb68a53c4fef360778a230126ed0ee0ee3Christoph Bumiller ti->store_to_memory = TRUE; 173633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 174f722fd937db2f3cacf1947d538c66528fd16eb89Ben Skeggs 175633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller for (s = 0; s < inst->Instruction.NumSrcRegs; ++s) { 176633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller src = &inst->Src[s].Register; 177f30810cb68a53c4fef360778a230126ed0ee0ee3Christoph Bumiller if (src->File == TGSI_FILE_TEMPORARY) 178f30810cb68a53c4fef360778a230126ed0ee0ee3Christoph Bumiller if (inst->Src[s].Register.Indirect) 179f30810cb68a53c4fef360778a230126ed0ee0ee3Christoph Bumiller ti->store_to_memory = TRUE; 180633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (src->File != TGSI_FILE_INPUT) 181633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller continue; 182633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller mask = nv50_tgsi_src_mask(inst, s); 183f722fd937db2f3cacf1947d538c66528fd16eb89Ben Skeggs 184633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (inst->Src[s].Register.Indirect) 185633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller nv50_indirect_inputs(ti, id); 186f722fd937db2f3cacf1947d538c66528fd16eb89Ben Skeggs 187633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller for (c = 0; c < 4; ++c) { 188633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (!(mask & (1 << c))) 189633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller continue; 190633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller k = tgsi_util_get_full_src_register_swizzle(&inst->Src[s], c); 191633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (k <= TGSI_SWIZZLE_W) 192633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->input_access[src->Index][k] = id; 193633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 194633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 195f722fd937db2f3cacf1947d538c66528fd16eb89Ben Skeggs} 196f722fd937db2f3cacf1947d538c66528fd16eb89Ben Skeggs 197d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller/* Probably should introduce something like struct tgsi_function_declaration 198d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller * instead of trying to guess inputs/outputs. 199d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller */ 200d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumillerstatic void 201d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumillerprog_subroutine_inst(struct nv50_subroutine *subr, 202d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller const struct tgsi_full_instruction *inst) 203d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller{ 204d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller const struct tgsi_dst_register *dst; 205d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller const struct tgsi_src_register *src; 206d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller int s, c, k; 207d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller unsigned mask; 208d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller 209d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller for (s = 0; s < inst->Instruction.NumSrcRegs; ++s) { 210d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller src = &inst->Src[s].Register; 211d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller if (src->File != TGSI_FILE_TEMPORARY) 212d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller continue; 213d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller mask = nv50_tgsi_src_mask(inst, s); 214d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller 215d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller assert(!inst->Src[s].Register.Indirect); 216d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller 217d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller for (c = 0; c < 4; ++c) { 218d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller k = tgsi_util_get_full_src_register_swizzle(&inst->Src[s], c); 219d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller 220d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller if ((mask & (1 << c)) && k < TGSI_SWIZZLE_W) 221d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller if (!(subr->retv[src->Index / 32][k] & (1 << (src->Index % 32)))) 222d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller subr->argv[src->Index / 32][k] |= 1 << (src->Index % 32); 223d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller } 224d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller } 225d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller 226d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller if (inst->Dst[0].Register.File == TGSI_FILE_TEMPORARY) { 227d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller dst = &inst->Dst[0].Register; 228d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller 229d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller for (c = 0; c < 4; ++c) 230d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller if (dst->WriteMask & (1 << c)) 231d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller subr->retv[dst->Index / 32][c] |= 1 << (dst->Index % 32); 232d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller } 233d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller} 234d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller 2357ab96f4f733437de693b9578c3649b56069e6f24Christoph Bumillerstatic void 236633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumillerprog_immediate(struct nv50_translation_info *ti, 237633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller const struct tgsi_full_immediate *imm) 2387ab96f4f733437de693b9578c3649b56069e6f24Christoph Bumiller{ 239633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller int c; 240e08f70a41d1012a0270468866614485a3415168eChristoph Bumiller unsigned n = ti->immd32_nr++; 2417ab96f4f733437de693b9578c3649b56069e6f24Christoph Bumiller 242e08f70a41d1012a0270468866614485a3415168eChristoph Bumiller assert(ti->immd32_nr <= ti->scan.immediate_count); 2437ab96f4f733437de693b9578c3649b56069e6f24Christoph Bumiller 244633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller for (c = 0; c < 4; ++c) 245e08f70a41d1012a0270468866614485a3415168eChristoph Bumiller ti->immd32[n * 4 + c] = imm->u[c].Uint; 246e08f70a41d1012a0270468866614485a3415168eChristoph Bumiller 247e08f70a41d1012a0270468866614485a3415168eChristoph Bumiller ti->immd32_ty[n] = imm->Immediate.DataType; 2487ab96f4f733437de693b9578c3649b56069e6f24Christoph Bumiller} 2497ab96f4f733437de693b9578c3649b56069e6f24Christoph Bumiller 250633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumillerstatic INLINE unsigned 251633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumillertranslate_interpolate(const struct tgsi_full_declaration *decl) 252633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller{ 253633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller unsigned mode; 254633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 255633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (decl->Declaration.Interpolate == TGSI_INTERPOLATE_CONSTANT) 256633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller mode = NV50_INTERP_FLAT; 257633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller else 258633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (decl->Declaration.Interpolate == TGSI_INTERPOLATE_PERSPECTIVE) 259633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller mode = 0; 260633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller else 261633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller mode = NV50_INTERP_LINEAR; 262633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 263633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (decl->Declaration.Centroid) 264633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller mode |= NV50_INTERP_CENTROID; 265633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 266633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller return mode; 267633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller} 268633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 269633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumillerstatic void 270633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumillerprog_decl(struct nv50_translation_info *ti, 271633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller const struct tgsi_full_declaration *decl) 272633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller{ 273633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller unsigned i, first, last, sn = 0, si = 0; 274633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 275633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller first = decl->Range.First; 276633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller last = decl->Range.Last; 277633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 278633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (decl->Declaration.Semantic) { 279633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller sn = decl->Semantic.Name; 280633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller si = decl->Semantic.Index; 281633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 282633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 283633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller switch (decl->Declaration.File) { 284633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_FILE_INPUT: 285633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller for (i = first; i <= last; ++i) 286633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->interp_mode[i] = translate_interpolate(decl); 287633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 288633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (!decl->Declaration.Semantic) 289633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 290633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 291633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller for (i = first; i <= last; ++i) { 292633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->p->in[i].sn = sn; 293633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->p->in[i].si = si; 294633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 295633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 296633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller switch (sn) { 297633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_SEMANTIC_FACE: 298633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 299633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_SEMANTIC_COLOR: 300633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (ti->p->type == PIPE_SHADER_FRAGMENT) 301633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->p->vp.bfc[si] = first; 302633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 303633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 304633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 305633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_FILE_OUTPUT: 306633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (!decl->Declaration.Semantic) 307633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 308633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 309633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller for (i = first; i <= last; ++i) { 310633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->p->out[i].sn = sn; 311633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->p->out[i].si = si; 312633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 313633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 314633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller switch (sn) { 315633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_SEMANTIC_BCOLOR: 316633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->p->vp.bfc[si] = first; 317633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 318633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_SEMANTIC_PSIZE: 319633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->p->vp.psiz = first; 320633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 321633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_SEMANTIC_EDGEFLAG: 322633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->edgeflag_out = first; 323633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 324633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller default: 325633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 326633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 327633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 328633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_FILE_SYSTEM_VALUE: 329533bf171d4c926e4ab6fcd0d51396b195b9e024fChristoph Bumiller /* For VP/GP inputs, they are put in s[] after the last normal input. 330533bf171d4c926e4ab6fcd0d51396b195b9e024fChristoph Bumiller * Let sysval_map reflect the order of the sysvals in s[] and fixup later. 331533bf171d4c926e4ab6fcd0d51396b195b9e024fChristoph Bumiller */ 332633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller switch (decl->Semantic.Name) { 333633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_SEMANTIC_FACE: 334633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 335633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_SEMANTIC_INSTANCEID: 336533bf171d4c926e4ab6fcd0d51396b195b9e024fChristoph Bumiller ti->p->vp.attrs[2] |= NV50_3D_VP_GP_BUILTIN_ATTR_EN_INSTANCE_ID; 337533bf171d4c926e4ab6fcd0d51396b195b9e024fChristoph Bumiller ti->sysval_map[first] = 2; 338633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 339633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_SEMANTIC_PRIMID: 340633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 341633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller /* 342633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_SEMANTIC_PRIMIDIN: 343633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 344633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_SEMANTIC_VERTEXID: 345633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 346633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller */ 347633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller default: 348633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 349633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 350633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 351633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_FILE_CONSTANT: 352633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->p->parm_size = MAX2(ti->p->parm_size, (last + 1) * 16); 353633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 354633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_FILE_ADDRESS: 355633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_FILE_SAMPLER: 356633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_FILE_TEMPORARY: 357633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 358633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller default: 359633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller assert(0); 360633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 361633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 362f722fd937db2f3cacf1947d538c66528fd16eb89Ben Skeggs} 363f722fd937db2f3cacf1947d538c66528fd16eb89Ben Skeggs 3643f66b72fdb4834c5211305698d22806eac80aa35Ben Skeggsstatic int 365633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumillernv50_vertprog_prepare(struct nv50_translation_info *ti) 3663f66b72fdb4834c5211305698d22806eac80aa35Ben Skeggs{ 367633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller struct nv50_program *p = ti->p; 368633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller int i, c; 369633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller unsigned num_inputs = 0; 3703f66b72fdb4834c5211305698d22806eac80aa35Ben Skeggs 371633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->input_file = NV_FILE_MEM_S; 372633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->output_file = NV_FILE_OUT; 3733f66b72fdb4834c5211305698d22806eac80aa35Ben Skeggs 374633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller for (i = 0; i <= ti->scan.file_max[TGSI_FILE_INPUT]; ++i) { 375633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->in[i].id = i; 376633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->in[i].hw = num_inputs; 3773f66b72fdb4834c5211305698d22806eac80aa35Ben Skeggs 378633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller for (c = 0; c < 4; ++c) { 379633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (!ti->input_access[i][c]) 380633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller continue; 381633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->input_map[i][c] = num_inputs++; 382633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->vp.attrs[(4 * i + c) / 32] |= 1 << ((i * 4 + c) % 32); 383633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 384633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 3853f66b72fdb4834c5211305698d22806eac80aa35Ben Skeggs 386633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller for (i = 0; i <= ti->scan.file_max[TGSI_FILE_OUTPUT]; ++i) { 387633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->out[i].id = i; 388633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->out[i].hw = p->max_out; 3892a1fb44d75364f2492a1ae5d232218a92b8ca807Ben Skeggs 390633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller for (c = 0; c < 4; ++c) { 391633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (!ti->output_access[i][c]) 392633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller continue; 393633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->output_map[i][c] = p->max_out++; 394633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->out[i].mask |= 1 << c; 395633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 396633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 3972a1fb44d75364f2492a1ae5d232218a92b8ca807Ben Skeggs 398533bf171d4c926e4ab6fcd0d51396b195b9e024fChristoph Bumiller for (i = 0; i < TGSI_SEMANTIC_COUNT; ++i) { 399533bf171d4c926e4ab6fcd0d51396b195b9e024fChristoph Bumiller switch (ti->sysval_map[i]) { 400533bf171d4c926e4ab6fcd0d51396b195b9e024fChristoph Bumiller case 2: 401533bf171d4c926e4ab6fcd0d51396b195b9e024fChristoph Bumiller if (!(ti->p->vp.attrs[2] & NV50_3D_VP_GP_BUILTIN_ATTR_EN_VERTEX_ID)) 402533bf171d4c926e4ab6fcd0d51396b195b9e024fChristoph Bumiller ti->sysval_map[i] = 1; 403533bf171d4c926e4ab6fcd0d51396b195b9e024fChristoph Bumiller ti->sysval_map[i] = (ti->sysval_map[i] - 1) + num_inputs; 404533bf171d4c926e4ab6fcd0d51396b195b9e024fChristoph Bumiller break; 405533bf171d4c926e4ab6fcd0d51396b195b9e024fChristoph Bumiller default: 406533bf171d4c926e4ab6fcd0d51396b195b9e024fChristoph Bumiller break; 407533bf171d4c926e4ab6fcd0d51396b195b9e024fChristoph Bumiller } 408533bf171d4c926e4ab6fcd0d51396b195b9e024fChristoph Bumiller } 409533bf171d4c926e4ab6fcd0d51396b195b9e024fChristoph Bumiller 410633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (p->vp.psiz < 0x40) 411633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->vp.psiz = p->out[p->vp.psiz].hw; 412d4d880199ead954e79cad141f7a29f7dd17fe7fcPatrice Mandin 413633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller return 0; 4142a1fb44d75364f2492a1ae5d232218a92b8ca807Ben Skeggs} 4152a1fb44d75364f2492a1ae5d232218a92b8ca807Ben Skeggs 41633e4d30d50344be26398a51365bea1be37487403Ben Skeggsstatic int 417633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumillernv50_fragprog_prepare(struct nv50_translation_info *ti) 418633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller{ 419633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller struct nv50_program *p = ti->p; 420633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller int i, j, c; 421633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller unsigned nvary, nintp, depr; 422633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller unsigned n = 0, m = 0, skip = 0; 423633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ubyte sn[16], si[16]; 424633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 425633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller /* FP flags */ 426633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 427633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (ti->scan.writes_z) { 428633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->fp.flags[1] = 0x11; 429f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller p->fp.flags[0] |= NV50_3D_FP_CONTROL_EXPORTS_Z; 430633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 431633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 432633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (ti->scan.uses_kill) 433f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller p->fp.flags[0] |= NV50_3D_FP_CONTROL_USES_KIL; 434633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 435633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller /* FP inputs */ 436633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 437633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->input_file = NV_FILE_MEM_V; 438633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->output_file = NV_FILE_GPR; 439633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 440633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller /* count non-flat inputs, save semantic info */ 441633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller for (i = 0; i < p->in_nr; ++i) { 442633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller m += (ti->interp_mode[i] & NV50_INTERP_FLAT) ? 0 : 1; 443633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller sn[i] = p->in[i].sn; 444633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller si[i] = p->in[i].si; 445633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 446633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 447633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller /* reorder p->in[] so that non-flat inputs are first and 448633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller * kick out special inputs that don't use VP/GP_RESULT_MAP 449633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller */ 450633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller nintp = 0; 451633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller for (i = 0; i < p->in_nr; ++i) { 452633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (sn[i] == TGSI_SEMANTIC_POSITION) { 453633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller for (c = 0; c < 4; ++c) { 454633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->input_map[i][c] = nintp; 455633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (ti->input_access[i][c]) { 456633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->fp.interp |= 1 << (24 + c); 457633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ++nintp; 458633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 459633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 460633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller skip++; 461633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller continue; 462633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } else 463633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (sn[i] == TGSI_SEMANTIC_FACE) { 464633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->input_map[i][0] = 255; 465633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller skip++; 466633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller continue; 467633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 468633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 469633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller j = (ti->interp_mode[i] & NV50_INTERP_FLAT) ? m++ : n++; 470633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 471633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (sn[i] == TGSI_SEMANTIC_COLOR) 472633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->vp.bfc[si[i]] = j; 473633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 474633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->in[j].linear = (ti->interp_mode[i] & NV50_INTERP_LINEAR) ? 1 : 0; 475633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->in[j].id = i; 476633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->in[j].sn = sn[i]; 477633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->in[j].si = si[i]; 478633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 479633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller assert(n <= m); 480633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->in_nr -= skip; 481633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 482633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (!(p->fp.interp & (8 << 24))) { 483633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->fp.interp |= (8 << 24); 484633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ++nintp; 485633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 486633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 4878f060df60d1f5ad63a341e39f2ec5a0c3c452cf5Christoph Bumiller p->fp.colors = 4 << NV50_3D_MAP_SEMANTIC_0_FFC0_ID__SHIFT; /* after HPOS */ 488633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 489633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller for (i = 0; i < p->in_nr; ++i) { 490633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller int j = p->in[i].id; 491633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->in[i].hw = nintp; 492633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 493633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller for (c = 0; c < 4; ++c) { 494633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (!ti->input_access[j][c]) 495633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller continue; 496633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->in[i].mask |= 1 << c; 497633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->input_map[j][c] = nintp++; 498633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 499633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller /* count color inputs */ 500633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (i == p->vp.bfc[0] || i == p->vp.bfc[1]) 501633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->fp.colors += bitcount4(p->in[i].mask) << 16; 502633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 503633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller nintp -= bitcount4(p->fp.interp >> 24); /* subtract position inputs */ 504633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller nvary = nintp; 505633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (n < m) 506633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller nvary -= p->in[n].hw; 507633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 508f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller p->fp.interp |= nvary << NV50_3D_FP_INTERPOLANT_CTRL_COUNT_NONFLAT__SHIFT; 509f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller p->fp.interp |= nintp << NV50_3D_FP_INTERPOLANT_CTRL_COUNT__SHIFT; 510633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 511633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller /* FP outputs */ 512633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 513633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (p->out_nr > (1 + (ti->scan.writes_z ? 1 : 0))) 514f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller p->fp.flags[0] |= NV50_3D_FP_CONTROL_MULTIPLE_RESULTS; 515633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 516633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller depr = p->out_nr; 517633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller for (i = 0; i < p->out_nr; ++i) { 518633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->out[i].id = i; 519633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (p->out[i].sn == TGSI_SEMANTIC_POSITION) { 520633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller depr = i; 521633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller continue; 522633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 523633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->out[i].hw = p->max_out; 524633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->out[i].mask = 0xf; 525633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 526633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller for (c = 0; c < 4; ++c) 527633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->output_map[i][c] = p->max_out++; 528633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 529633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (depr < p->out_nr) { 530633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->out[depr].mask = 0x4; 5313844c365947082550565accefd996c10fbb15cc4Christoph Bumiller p->out[depr].hw = ti->output_map[depr][2] = p->max_out++; 53284d170bbcef8e26017ac8e2f3bacbaeb20f889d3Christoph Bumiller } else { 53384d170bbcef8e26017ac8e2f3bacbaeb20f889d3Christoph Bumiller /* allowed values are 1, 4, 5, 8, 9, ... */ 53484d170bbcef8e26017ac8e2f3bacbaeb20f889d3Christoph Bumiller p->max_out = MAX2(4, p->max_out); 535633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 536633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 537633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller return 0; 53855b2fe1047b37d0d86641a252e1c745111030393Ben Skeggs} 53955b2fe1047b37d0d86641a252e1c745111030393Ben Skeggs 540633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumillerstatic int 541633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumillernv50_geomprog_prepare(struct nv50_translation_info *ti) 54244d8c9add2f095fc365ede751253d9fb7fc5c6e1Christoph Bumiller{ 543633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->input_file = NV_FILE_MEM_S; 544633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->output_file = NV_FILE_OUT; 54544d8c9add2f095fc365ede751253d9fb7fc5c6e1Christoph Bumiller 546633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller assert(0); 547633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller return 1; 54844d8c9add2f095fc365ede751253d9fb7fc5c6e1Christoph Bumiller} 54944d8c9add2f095fc365ede751253d9fb7fc5c6e1Christoph Bumiller 550633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumillerstatic int 551633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumillernv50_prog_scan(struct nv50_translation_info *ti) 552633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller{ 553633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller struct nv50_program *p = ti->p; 554633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller struct tgsi_parse_context parse; 555d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller int ret, i; 556633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 5571bbbc8e0c8230d33cb1eae89cc47b5296edefc10Christoph Bumiller p->vp.edgeflag = 0x40; 558633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->vp.psiz = 0x40; 559633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->vp.bfc[0] = 0x40; 560633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->vp.bfc[1] = 0x40; 561633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->gp.primid = 0x80; 562633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 563633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller tgsi_scan_shader(p->pipe.tokens, &ti->scan); 564633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 56574559abbef5e5bcd3dbe1b8bbb8a39391a8a8671Christoph Bumiller#if NV50_DEBUG & NV50_DEBUG_SHADER 566d90502b2b468732e2a42985580bbbe9d9fdfd14eChristoph Bumiller tgsi_dump(p->pipe.tokens, 0); 567d90502b2b468732e2a42985580bbbe9d9fdfd14eChristoph Bumiller#endif 568d90502b2b468732e2a42985580bbbe9d9fdfd14eChristoph Bumiller 569d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller ti->subr = 570d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller CALLOC(ti->scan.opcode_count[TGSI_OPCODE_BGNSUB], sizeof(ti->subr[0])); 571d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller 572e08f70a41d1012a0270468866614485a3415168eChristoph Bumiller ti->immd32 = (uint32_t *)MALLOC(ti->scan.immediate_count * 16); 573e08f70a41d1012a0270468866614485a3415168eChristoph Bumiller ti->immd32_ty = (ubyte *)MALLOC(ti->scan.immediate_count * sizeof(ubyte)); 574e08f70a41d1012a0270468866614485a3415168eChristoph Bumiller 575217542a061ef31150b1b04f1b45b6099bcc153feChristoph Bumiller ti->insns = MALLOC(ti->scan.num_instructions * sizeof(ti->insns[0])); 576217542a061ef31150b1b04f1b45b6099bcc153feChristoph Bumiller 577633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller tgsi_parse_init(&parse, p->pipe.tokens); 578633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller while (!tgsi_parse_end_of_tokens(&parse)) { 579633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller tgsi_parse_token(&parse); 580633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 581633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller switch (parse.FullToken.Token.Type) { 582633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_TOKEN_TYPE_IMMEDIATE: 583633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller prog_immediate(ti, &parse.FullToken.FullImmediate); 584633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 585633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_TOKEN_TYPE_DECLARATION: 586633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller prog_decl(ti, &parse.FullToken.FullDeclaration); 587633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 588633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case TGSI_TOKEN_TYPE_INSTRUCTION: 589217542a061ef31150b1b04f1b45b6099bcc153feChristoph Bumiller ti->insns[ti->inst_nr] = parse.FullToken.FullInstruction; 590633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller prog_inst(ti, &parse.FullToken.FullInstruction, ++ti->inst_nr); 591633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 592633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 593633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 594633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 595d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller /* Scan to determine which registers are inputs/outputs of a subroutine. */ 596d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller for (i = 0; i < ti->subr_nr; ++i) { 597d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller int pc = ti->subr[i].id; 598d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller while (ti->insns[pc].Instruction.Opcode != TGSI_OPCODE_ENDSUB) 599d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller prog_subroutine_inst(&ti->subr[i], &ti->insns[pc++]); 600d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller } 601d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller 602633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->in_nr = ti->scan.file_max[TGSI_FILE_INPUT] + 1; 603633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->out_nr = ti->scan.file_max[TGSI_FILE_OUTPUT] + 1; 604633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 605633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller switch (p->type) { 606633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case PIPE_SHADER_VERTEX: 607633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ret = nv50_vertprog_prepare(ti); 608633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 609633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case PIPE_SHADER_FRAGMENT: 610633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ret = nv50_fragprog_prepare(ti); 611633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 612633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller case PIPE_SHADER_GEOMETRY: 613633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ret = nv50_geomprog_prepare(ti); 614633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 615633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller default: 616633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller assert(!"unsupported program type"); 617633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ret = -1; 618633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller break; 619633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 620633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 621633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller assert(!ret); 622633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller return ret; 623633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller} 624633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller 625633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumillerboolean 626f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumillernv50_program_translate(struct nv50_program *p) 62744d8c9add2f095fc365ede751253d9fb7fc5c6e1Christoph Bumiller{ 628633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller struct nv50_translation_info *ti; 629633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller int ret; 63044d8c9add2f095fc365ede751253d9fb7fc5c6e1Christoph Bumiller 631633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti = CALLOC_STRUCT(nv50_translation_info); 632633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->p = p; 6332a1fb44d75364f2492a1ae5d232218a92b8ca807Ben Skeggs 634633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ti->edgeflag_out = PIPE_MAX_SHADER_OUTPUTS; 6352a1fb44d75364f2492a1ae5d232218a92b8ca807Ben Skeggs 636633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ret = nv50_prog_scan(ti); 637633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (ret) { 638633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller NOUVEAU_ERR("unsupported shader program\n"); 639633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller goto out; 640633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 641708c711f8361ea82c1217e2614914ae047bc5bdfChristoph Bumiller 642633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller ret = nv50_generate_code(ti); 643633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (ret) { 644633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller NOUVEAU_ERR("error during shader translation\n"); 645633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller goto out; 646633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller } 6472a1fb44d75364f2492a1ae5d232218a92b8ca807Ben Skeggs 648633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumillerout: 649633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (ti->immd32) 650633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller FREE(ti->immd32); 651e08f70a41d1012a0270468866614485a3415168eChristoph Bumiller if (ti->immd32_ty) 652e08f70a41d1012a0270468866614485a3415168eChristoph Bumiller FREE(ti->immd32_ty); 653217542a061ef31150b1b04f1b45b6099bcc153feChristoph Bumiller if (ti->insns) 654217542a061ef31150b1b04f1b45b6099bcc153feChristoph Bumiller FREE(ti->insns); 655d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller if (ti->subr) 656d91b8865ec2bb41f9b58ad5ce2df7f6f48f98281Christoph Bumiller FREE(ti->subr); 657633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller FREE(ti); 658633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller return ret ? FALSE : TRUE; 6592a1fb44d75364f2492a1ae5d232218a92b8ca807Ben Skeggs} 6602a1fb44d75364f2492a1ae5d232218a92b8ca807Ben Skeggs 661633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumillervoid 662633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumillernv50_program_destroy(struct nv50_context *nv50, struct nv50_program *p) 6632a1fb44d75364f2492a1ae5d232218a92b8ca807Ben Skeggs{ 664f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller if (p->res) 665f80c03e1875fe96ff2f4c022e3cb76357828140dChristoph Bumiller nouveau_resource_free(&p->res); 666f722fd937db2f3cacf1947d538c66528fd16eb89Ben Skeggs 667633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller if (p->code) 668633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller FREE(p->code); 6697c745de74997e859d7e2640092bda9ad900e28a9Ben Skeggs 6703a62365f402b1159afd526fb4b510cdb51de1365Christoph Bumiller if (p->fixups) 6713a62365f402b1159afd526fb4b510cdb51de1365Christoph Bumiller FREE(p->fixups); 6723a62365f402b1159afd526fb4b510cdb51de1365Christoph Bumiller 673633f5ac6124b1b57152c09becba92d176e905ae9Christoph Bumiller p->translated = FALSE; 674f722fd937db2f3cacf1947d538c66528fd16eb89Ben Skeggs} 675