tgsi_exec.h revision 9aa089eac05ebefafb6610b4a7e209b2fd1e93f6
15d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner/************************************************************************** 25d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * 35d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * Copyright 2007-2008 Tungsten Graphics, Inc., Cedar Park, Texas. 45d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * All Rights Reserved. 55d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * Copyright 2009-2010 VMware, Inc. All rights Reserved. 65d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * 75d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * Permission is hereby granted, free of charge, to any person obtaining a 85d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * copy of this software and associated documentation files (the 95d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * "Software"), to deal in the Software without restriction, including 1034c48ff1e3ad5cd2084ca40188754d45f423750bDavid 'Digit' Turner * without limitation the rights to use, copy, modify, merge, publish, 11e1e03df288d5a44bfbffbd86588395c7cbbc27dfDavid 'Digit' Turner * distribute, sub license, and/or sell copies of the Software, and to 125d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * permit persons to whom the Software is furnished to do so, subject to 135d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * the following conditions: 145d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * 15aa8236dc1b1ea300ab18716db5b8fab42aca3ca7David 'Digit' Turner * The above copyright notice and this permission notice (including the 165d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * next paragraph) shall be included in all copies or substantial portions 175d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * of the Software. 185d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * 195d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 205d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21bcde1092aca184dbd7860078af020de7d1e4e22fDavid 'Digit' Turner * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 22bcde1092aca184dbd7860078af020de7d1e4e22fDavid 'Digit' Turner * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 235d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 245d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 255d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26aa8236dc1b1ea300ab18716db5b8fab42aca3ca7David 'Digit' Turner * 275d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner **************************************************************************/ 285d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 295d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#ifndef TGSI_EXEC_H 305d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_H 315d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 325d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#include "pipe/p_compiler.h" 335d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#include "pipe/p_state.h" 345d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 355d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#if defined __cplusplus 36aa8236dc1b1ea300ab18716db5b8fab42aca3ca7David 'Digit' Turnerextern "C" { 375d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#endif 385d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 395d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 405d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define NUM_CHANNELS 4 /* R,G,B,A */ 415d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define QUAD_SIZE 4 /* 4 pixel/quad */ 425d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 435d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 445d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner/** 455d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * Registers may be treated as float, signed int or unsigned int. 465d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner */ 47bcde1092aca184dbd7860078af020de7d1e4e22fDavid 'Digit' Turnerunion tgsi_exec_channel 485d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner{ 495d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner float f[QUAD_SIZE]; 505d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner int i[QUAD_SIZE]; 515d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner unsigned u[QUAD_SIZE]; 525d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner}; 535d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 545d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner/** 555d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * A vector[RGBA] of channels[4 pixels] 565d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner */ 575d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turnerstruct tgsi_exec_vector 585d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner{ 595d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner union tgsi_exec_channel xyzw[NUM_CHANNELS]; 605d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner}; 615d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 625d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner/** 635d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * For fragment programs, information for computing fragment input 645d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * values from plane equation of the triangle/line. 655d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner */ 665d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turnerstruct tgsi_interp_coef 675d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner{ 685d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner float a0[NUM_CHANNELS]; /* in an xyzw layout */ 695d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner float dadx[NUM_CHANNELS]; 705d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner float dady[NUM_CHANNELS]; 715d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner}; 725d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 735d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turnerenum tgsi_sampler_control { 745d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner tgsi_sampler_lod_bias, 755d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner tgsi_sampler_lod_explicit 765d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner}; 775d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 785d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner/** 795d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * Information for sampling textures, which must be implemented 805d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * by code outside the TGSI executor. 815d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner */ 825d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turnerstruct tgsi_sampler 835d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner{ 845d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner /** Get samples for four fragments in a quad */ 85bcde1092aca184dbd7860078af020de7d1e4e22fDavid 'Digit' Turner void (*get_samples)(struct tgsi_sampler *sampler, 865d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner const float s[QUAD_SIZE], 875d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner const float t[QUAD_SIZE], 885d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner const float p[QUAD_SIZE], 895d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner const float c0[QUAD_SIZE], 905d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner enum tgsi_sampler_control control, 915d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner float rgba[NUM_CHANNELS][QUAD_SIZE]); 925d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner}; 935d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 945d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_NUM_TEMPS 128 955d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_NUM_IMMEDIATES 256 965d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_NUM_TEMP_ARRAYS 8 975d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 985d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner/* 995d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * Locations of various utility registers (_I = Index, _C = Channel) 1005d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner */ 1015d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_00000000_I (TGSI_EXEC_NUM_TEMPS + 0) 1025d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_00000000_C 0 1035d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1045d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_7FFFFFFF_I (TGSI_EXEC_NUM_TEMPS + 0) 1055d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_7FFFFFFF_C 1 1065d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1075d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_80000000_I (TGSI_EXEC_NUM_TEMPS + 0) 1085d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_80000000_C 2 1095d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1105d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_FFFFFFFF_I (TGSI_EXEC_NUM_TEMPS + 0) 1115d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_FFFFFFFF_C 3 1125d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1135d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_ONE_I (TGSI_EXEC_NUM_TEMPS + 1) 1145d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_ONE_C 0 1155d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1165d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_TWO_I (TGSI_EXEC_NUM_TEMPS + 1) 1175d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_TWO_C 1 1185d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1195d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_128_I (TGSI_EXEC_NUM_TEMPS + 1) 1205d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_128_C 2 1215d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1225d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_MINUS_128_I (TGSI_EXEC_NUM_TEMPS + 1) 1235d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_MINUS_128_C 3 1245d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1255d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_KILMASK_I (TGSI_EXEC_NUM_TEMPS + 2) 1265d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_KILMASK_C 0 1275d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1285d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_OUTPUT_I (TGSI_EXEC_NUM_TEMPS + 2) 1295d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_OUTPUT_C 1 1305d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1315d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_PRIMITIVE_I (TGSI_EXEC_NUM_TEMPS + 2) 1325d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_PRIMITIVE_C 2 1335d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1345d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_THREE_I (TGSI_EXEC_NUM_TEMPS + 2) 1355d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_THREE_C 3 1365d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1375d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_HALF_I (TGSI_EXEC_NUM_TEMPS + 3) 1385d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_HALF_C 0 1395d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1405d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner/* execution mask, each value is either 0 or ~0 */ 1415d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_MASK_I (TGSI_EXEC_NUM_TEMPS + 3) 1425d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_MASK_C 1 1435d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1445d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner/* 4 register buffer for various purposes */ 1455d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_R0 (TGSI_EXEC_NUM_TEMPS + 4) 1465d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_NUM_TEMP_R 4 1475d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1485d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_ADDR (TGSI_EXEC_NUM_TEMPS + 8) 1495d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_NUM_ADDRS 1 1505d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1515d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner/* predicate register */ 1525d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_TEMP_P0 (TGSI_EXEC_NUM_TEMPS + 9) 1535d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_NUM_PREDS 1 1545d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1555d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_NUM_TEMP_EXTRAS 10 1565d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1575d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1585d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1595d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_MAX_NESTING 32 1605d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_MAX_COND_NESTING TGSI_EXEC_MAX_NESTING 1615d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_MAX_LOOP_NESTING TGSI_EXEC_MAX_NESTING 1625d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_MAX_SWITCH_NESTING TGSI_EXEC_MAX_NESTING 1635d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_MAX_CALL_NESTING TGSI_EXEC_MAX_NESTING 1645d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1655d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner/* The maximum number of input attributes per vertex. For 2D 1665d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * input register files, this is the stride between two 1D 1675d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner * arrays. 1685d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner */ 1695d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_MAX_INPUT_ATTRIBS 17 1705d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1715d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner/* The maximum number of constant vectors per constant buffer. 1725d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner */ 1735d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_EXEC_MAX_CONST_BUFFER 4096 1745d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1755d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner/* The maximum number of vertices per primitive */ 1765d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_MAX_PRIM_VERTICES 6 1775d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1785d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner/* The maximum number of primitives to be generated */ 1795d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_MAX_PRIMITIVES 64 1805d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1815d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner/* The maximum total number of vertices */ 1825d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define TGSI_MAX_TOTAL_VERTICES (TGSI_MAX_PRIM_VERTICES * TGSI_MAX_PRIMITIVES * PIPE_MAX_ATTRIBS) 1835d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner 1845d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner/** function call/activation record */ 185struct tgsi_call_record 186{ 187 uint CondStackTop; 188 uint LoopStackTop; 189 uint ContStackTop; 190 int SwitchStackTop; 191 int BreakStackTop; 192 uint ReturnAddr; 193}; 194 195 196/* Switch-case block state. */ 197struct tgsi_switch_record { 198 uint mask; /**< execution mask */ 199 union tgsi_exec_channel selector; /**< a value case statements are compared to */ 200 uint defaultMask; /**< non-execute mask for default case */ 201}; 202 203 204enum tgsi_break_type { 205 TGSI_EXEC_BREAK_INSIDE_LOOP, 206 TGSI_EXEC_BREAK_INSIDE_SWITCH 207}; 208 209 210#define TGSI_EXEC_MAX_BREAK_STACK (TGSI_EXEC_MAX_LOOP_NESTING + TGSI_EXEC_MAX_SWITCH_NESTING) 211 212 213/** 214 * Run-time virtual machine state for executing TGSI shader. 215 */ 216struct tgsi_exec_machine 217{ 218 /* Total = program temporaries + internal temporaries 219 */ 220 struct tgsi_exec_vector Temps[TGSI_EXEC_NUM_TEMPS + 221 TGSI_EXEC_NUM_TEMP_EXTRAS]; 222 struct tgsi_exec_vector TempArray[TGSI_EXEC_NUM_TEMP_ARRAYS][TGSI_EXEC_NUM_TEMPS]; 223 224 float Imms[TGSI_EXEC_NUM_IMMEDIATES][4]; 225 226 float ImmArray[TGSI_EXEC_NUM_IMMEDIATES][4]; 227 228 struct tgsi_exec_vector Inputs[TGSI_MAX_PRIM_VERTICES * PIPE_MAX_ATTRIBS]; 229 struct tgsi_exec_vector Outputs[TGSI_MAX_TOTAL_VERTICES]; 230 231 struct tgsi_exec_vector *Addrs; 232 struct tgsi_exec_vector *Predicates; 233 234 struct tgsi_sampler **Samplers; 235 236 unsigned ImmLimit; 237 238 const void *Consts[PIPE_MAX_CONSTANT_BUFFERS]; 239 unsigned ConstsSize[PIPE_MAX_CONSTANT_BUFFERS]; 240 241 const struct tgsi_token *Tokens; /**< Declarations, instructions */ 242 unsigned Processor; /**< TGSI_PROCESSOR_x */ 243 244 /* GEOMETRY processor only. */ 245 unsigned *Primitives; 246 unsigned NumOutputs; 247 unsigned MaxGeometryShaderOutputs; 248 249 /* FRAGMENT processor only. */ 250 const struct tgsi_interp_coef *InterpCoefs; 251 struct tgsi_exec_vector QuadPos; 252 float Face; /**< +1 if front facing, -1 if back facing */ 253 254 /* Conditional execution masks */ 255 uint CondMask; /**< For IF/ELSE/ENDIF */ 256 uint LoopMask; /**< For BGNLOOP/ENDLOOP */ 257 uint ContMask; /**< For loop CONT statements */ 258 uint FuncMask; /**< For function calls */ 259 uint ExecMask; /**< = CondMask & LoopMask */ 260 261 /* Current switch-case state. */ 262 struct tgsi_switch_record Switch; 263 264 /* Current break type. */ 265 enum tgsi_break_type BreakType; 266 267 /** Condition mask stack (for nested conditionals) */ 268 uint CondStack[TGSI_EXEC_MAX_COND_NESTING]; 269 int CondStackTop; 270 271 /** Loop mask stack (for nested loops) */ 272 uint LoopStack[TGSI_EXEC_MAX_LOOP_NESTING]; 273 int LoopStackTop; 274 275 /** Loop label stack */ 276 uint LoopLabelStack[TGSI_EXEC_MAX_LOOP_NESTING]; 277 int LoopLabelStackTop; 278 279 /** Loop continue mask stack (see comments in tgsi_exec.c) */ 280 uint ContStack[TGSI_EXEC_MAX_LOOP_NESTING]; 281 int ContStackTop; 282 283 /** Switch case stack */ 284 struct tgsi_switch_record SwitchStack[TGSI_EXEC_MAX_SWITCH_NESTING]; 285 int SwitchStackTop; 286 287 enum tgsi_break_type BreakStack[TGSI_EXEC_MAX_BREAK_STACK]; 288 int BreakStackTop; 289 290 /** Function execution mask stack (for executing subroutine code) */ 291 uint FuncStack[TGSI_EXEC_MAX_CALL_NESTING]; 292 int FuncStackTop; 293 294 /** Function call stack for saving/restoring the program counter */ 295 struct tgsi_call_record CallStack[TGSI_EXEC_MAX_CALL_NESTING]; 296 int CallStackTop; 297 298 struct tgsi_full_instruction *Instructions; 299 uint NumInstructions; 300 301 struct tgsi_full_declaration *Declarations; 302 uint NumDeclarations; 303 304}; 305 306struct tgsi_exec_machine * 307tgsi_exec_machine_create( void ); 308 309void 310tgsi_exec_machine_destroy(struct tgsi_exec_machine *mach); 311 312 313void 314tgsi_exec_machine_bind_shader( 315 struct tgsi_exec_machine *mach, 316 const struct tgsi_token *tokens, 317 uint numSamplers, 318 struct tgsi_sampler **samplers); 319 320uint 321tgsi_exec_machine_run( 322 struct tgsi_exec_machine *mach ); 323 324 325void 326tgsi_exec_machine_free_data(struct tgsi_exec_machine *mach); 327 328 329boolean 330tgsi_check_soa_dependencies(const struct tgsi_full_instruction *inst); 331 332 333static INLINE void 334tgsi_set_kill_mask(struct tgsi_exec_machine *mach, unsigned mask) 335{ 336 mach->Temps[TGSI_EXEC_TEMP_KILMASK_I].xyzw[TGSI_EXEC_TEMP_KILMASK_C].u[0] = 337 mask; 338} 339 340 341/** Set execution mask values prior to executing the shader */ 342static INLINE void 343tgsi_set_exec_mask(struct tgsi_exec_machine *mach, 344 boolean ch0, boolean ch1, boolean ch2, boolean ch3) 345{ 346 int *mask = mach->Temps[TGSI_EXEC_MASK_I].xyzw[TGSI_EXEC_MASK_C].i; 347 mask[0] = ch0 ? ~0 : 0; 348 mask[1] = ch1 ? ~0 : 0; 349 mask[2] = ch2 ? ~0 : 0; 350 mask[3] = ch3 ? ~0 : 0; 351} 352 353 354extern void 355tgsi_exec_set_constant_buffers(struct tgsi_exec_machine *mach, 356 unsigned num_bufs, 357 const void **bufs, 358 const unsigned *buf_sizes); 359 360 361static INLINE int 362tgsi_exec_get_shader_param(enum pipe_shader_cap param) 363{ 364 switch(param) { 365 case PIPE_SHADER_CAP_MAX_INSTRUCTIONS: 366 case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS: 367 case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS: 368 case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS: 369 return INT_MAX; 370 case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH: 371 return TGSI_EXEC_MAX_NESTING; 372 case PIPE_SHADER_CAP_MAX_INPUTS: 373 return TGSI_EXEC_MAX_INPUT_ATTRIBS; 374 case PIPE_SHADER_CAP_MAX_CONSTS: 375 return TGSI_EXEC_MAX_CONST_BUFFER; 376 case PIPE_SHADER_CAP_MAX_CONST_BUFFERS: 377 return PIPE_MAX_CONSTANT_BUFFERS; 378 case PIPE_SHADER_CAP_MAX_TEMPS: 379 return TGSI_EXEC_NUM_TEMPS; 380 case PIPE_SHADER_CAP_MAX_ADDRS: 381 return TGSI_EXEC_NUM_ADDRS; 382 case PIPE_SHADER_CAP_MAX_PREDS: 383 return TGSI_EXEC_NUM_PREDS; 384 case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED: 385 return 1; 386 case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR: 387 case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR: 388 case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR: 389 case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR: 390 return 1; 391 case PIPE_SHADER_CAP_SUBROUTINES: 392 return 1; 393 default: 394 return 0; 395 } 396} 397 398#if defined __cplusplus 399} /* extern "C" */ 400#endif 401 402#endif /* TGSI_EXEC_H */ 403