1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 #if !defined SPU_EXEC_H
31 #include "pipe/p_compiler.h"
33 #include "spu_tgsi_exec.h"
35 #if defined __cplusplus
40 * Registers may be treated as float, signed int or unsigned int.
42 union spu_exec_channel
46 unsigned u[QUAD_SIZE];
51 * A vector[RGBA] of channels[4 pixels]
53 struct spu_exec_vector
55 union spu_exec_channel xyzw[NUM_CHANNELS];
59 * For fragment programs, information for computing fragment input
60 * values from plane equation of the triangle/line.
62 struct spu_interp_coef
64 float a0[NUM_CHANNELS]; /* in an xyzw layout */
65 float dadx[NUM_CHANNELS];
66 float dady[NUM_CHANNELS];
70 struct softpipe_tile_cache; /**< Opaque to TGSI */
73 * Information for sampling textures, which must be implemented
74 * by code outside the TGSI executor.
78 const struct pipe_sampler_state *state;
79 struct pipe_resource *texture;
80 /** Get samples for four fragments in a quad */
81 void (*get_samples)(struct spu_sampler *sampler,
82 const float s[QUAD_SIZE],
83 const float t[QUAD_SIZE],
84 const float p[QUAD_SIZE],
86 float rgba[NUM_CHANNELS][QUAD_SIZE]);
87 void *pipe; /*XXX temporary*/
88 struct softpipe_tile_cache *cache;
93 * Run-time virtual machine state for executing TGSI shader.
95 struct spu_exec_machine
98 * 32 program temporaries
99 * 4 internal temporaries
103 struct spu_exec_vector Temps[TGSI_EXEC_NUM_TEMPS
104 + TGSI_EXEC_NUM_TEMP_EXTRAS + 1];
106 struct spu_exec_vector *Addrs;
108 struct spu_sampler *Samplers;
110 float Imms[TGSI_EXEC_NUM_IMMEDIATES][4];
113 struct spu_exec_vector *Inputs;
114 struct spu_exec_vector *Outputs;
117 /* GEOMETRY processor only. */
118 unsigned *Primitives;
120 /* FRAGMENT processor only. */
121 const struct spu_interp_coef *InterpCoefs;
122 struct spu_exec_vector QuadPos;
124 /* Conditional execution masks */
125 uint CondMask; /**< For IF/ELSE/ENDIF */
126 uint LoopMask; /**< For BGNLOOP/ENDLOOP */
127 uint ContMask; /**< For loop CONT statements */
128 uint FuncMask; /**< For function calls */
129 uint ExecMask; /**< = CondMask & LoopMask */
131 /** Condition mask stack (for nested conditionals) */
132 uint CondStack[TGSI_EXEC_MAX_COND_NESTING];
135 /** Loop mask stack (for nested loops) */
136 uint LoopStack[TGSI_EXEC_MAX_LOOP_NESTING];
139 /** Loop continue mask stack (see comments in tgsi_exec.c) */
140 uint ContStack[TGSI_EXEC_MAX_LOOP_NESTING];
143 /** Function execution mask stack (for executing subroutine code) */
144 uint FuncStack[TGSI_EXEC_MAX_CALL_NESTING];
147 /** Function call stack for saving/restoring the program counter */
148 uint CallStack[TGSI_EXEC_MAX_CALL_NESTING];
151 struct tgsi_full_instruction *Instructions;
152 uint NumInstructions;
154 struct tgsi_full_declaration *Declarations;
155 uint NumDeclarations;
160 spu_exec_machine_init(struct spu_exec_machine *mach,
162 struct spu_sampler *samplers,
166 spu_exec_machine_run( struct spu_exec_machine *mach );
169 #if defined __cplusplus
173 #endif /* SPU_EXEC_H */