1 /* 2 * Copyright 2010 Ben Skeggs 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 */ 22 23 #ifndef __NV50_PROG_H__ 24 #define __NV50_PROG_H__ 25 26 struct nv50_context; 27 struct nir_shader; 28 29 #include "pipe/p_state.h" 30 31 struct nv50_varying { 32 uint8_t id; /* tgsi index */ 33 uint8_t hw; /* hw index, nv50 wants flat FP inputs last */ 34 35 unsigned mask : 4; 36 unsigned linear : 1; 37 unsigned pad : 3; 38 39 uint8_t sn; /* semantic name */ 40 uint8_t si; /* semantic index */ 41 }; 42 43 struct nv50_stream_output_state 44 { 45 uint32_t ctrl; 46 uint16_t stride[4]; 47 uint8_t num_attribs[4]; 48 uint8_t map_size; 49 uint8_t map[128]; 50 }; 51 52 struct nv50_gmem_state { 53 unsigned valid : 1; /* whether there's something there */ 54 unsigned image : 1; /* buffer or image */ 55 unsigned slot : 6; /* slot in the relevant resource arrays */ 56 }; 57 58 struct nv50_program { 59 struct nir_shader *nir; 60 struct pipe_stream_output_info stream_output; 61 62 uint8_t type; 63 bool translated; 64 65 uint32_t *code; 66 unsigned code_size; 67 unsigned code_base; 68 uint32_t *immd; 69 unsigned parm_size; /* size limit of uniform buffer */ 70 uint32_t tls_space; /* required local memory per thread */ 71 72 uint8_t max_gpr; /* REG_ALLOC_TEMP */ 73 uint8_t max_out; /* REG_ALLOC_RESULT or FP_RESULT_COUNT */ 74 75 uint8_t in_nr; 76 uint8_t out_nr; 77 struct nv50_varying in[16]; 78 struct nv50_varying out[16]; 79 80 struct { 81 uint32_t attrs[3]; /* VP_ATTR_EN_0,1 and VP_GP_BUILTIN_ATTR_EN */ 82 uint8_t psiz; /* output slot of point size */ 83 uint8_t bfc[2]; /* indices into varying for FFC (FP) or BFC (VP) */ 84 uint8_t edgeflag; 85 uint8_t clpd[2]; /* output slot of clip distance[i]'s 1st component */ 86 uint8_t clpd_nr; 87 bool need_vertex_id; 88 uint32_t clip_mode; 89 uint8_t clip_enable; /* mask of defined clip planes */ 90 uint8_t cull_enable; /* mask of defined cull distances */ 91 } vp; 92 93 struct { 94 uint32_t flags[2]; /* 0x19a8, 196c */ 95 uint32_t interp; /* 0x1988 */ 96 uint32_t colors; /* 0x1904 */ 97 uint8_t has_samplemask; 98 uint8_t force_persample_interp; 99 uint8_t alphatest; 100 } fp; 101 102 struct { 103 uint32_t vert_count; 104 uint8_t prim_type; /* point, line strip or tri strip */ 105 uint8_t has_layer; 106 uint8_t layerid; /* hw value of layer output */ 107 uint8_t has_viewport; 108 uint8_t viewportid; /* hw value of viewport index output */ 109 } gp; 110 111 struct { 112 uint32_t smem_size; /* shared memory (TGSI LOCAL resource) size */ 113 struct nv50_gmem_state gmem[NV50_MAX_GLOBALS]; 114 } cp; 115 116 bool mul_zero_wins; 117 118 void *relocs; /* relocation records */ 119 void *fixups; /* interpolation records */ 120 121 struct nouveau_heap *mem; 122 123 struct nv50_stream_output_state *so; 124 }; 125 126 bool nv50_program_translate(struct nv50_program *, uint16_t chipset, 127 struct util_debug_callback *); 128 bool nv50_program_upload_code(struct nv50_context *, struct nv50_program *); 129 void nv50_program_destroy(struct nv50_context *, struct nv50_program *); 130 131 #endif /* __NV50_PROG_H__ */ 132