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