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"
32 #include "tgsi/tgsi_exec.h"
34 #if defined __cplusplus
39 * Registers may be treated as float, signed int or unsigned int.
41 union spu_exec_channel
45 unsigned u[QUAD_SIZE];
50 * A vector[RGBA] of channels[4 pixels]
52 struct spu_exec_vector
54 union spu_exec_channel xyzw[NUM_CHANNELS];
58 * For fragment programs, information for computing fragment input
59 * values from plane equation of the triangle/line.
61 struct spu_interp_coef
63 float a0[NUM_CHANNELS]; /* in an xyzw layout */
64 float dadx[NUM_CHANNELS];
65 float dady[NUM_CHANNELS];
69 struct softpipe_tile_cache; /**< Opaque to TGSI */
72 * Information for sampling textures, which must be implemented
73 * by code outside the TGSI executor.
77 const struct pipe_sampler_state *state;
78 struct pipe_resource *texture;
79 /** Get samples for four fragments in a quad */
80 void (*get_samples)(struct spu_sampler *sampler,
81 const float s[QUAD_SIZE],
82 const float t[QUAD_SIZE],
83 const float p[QUAD_SIZE],
85 float rgba[NUM_CHANNELS][QUAD_SIZE]);
86 void *pipe; /*XXX temporary*/
87 struct softpipe_tile_cache *cache;
92 * Run-time virtual machine state for executing TGSI shader.
94 struct spu_exec_machine
97 * 32 program temporaries
98 * 4 internal temporaries
102 struct spu_exec_vector Temps[TGSI_EXEC_NUM_TEMPS
103 + TGSI_EXEC_NUM_TEMP_EXTRAS + 1];
105 struct spu_exec_vector *Addrs;
107 struct spu_sampler *Samplers;
109 float Imms[TGSI_EXEC_NUM_IMMEDIATES][4];
112 struct spu_exec_vector *Inputs;
113 struct spu_exec_vector *Outputs;
116 /* GEOMETRY processor only. */
117 unsigned *Primitives;
119 /* FRAGMENT processor only. */
120 const struct spu_interp_coef *InterpCoefs;
121 struct spu_exec_vector QuadPos;
123 /* Conditional execution masks */
124 uint CondMask; /**< For IF/ELSE/ENDIF */
125 uint LoopMask; /**< For BGNLOOP/ENDLOOP */
126 uint ContMask; /**< For loop CONT statements */
127 uint FuncMask; /**< For function calls */
128 uint ExecMask; /**< = CondMask & LoopMask */
130 /** Condition mask stack (for nested conditionals) */
131 uint CondStack[TGSI_EXEC_MAX_COND_NESTING];
134 /** Loop mask stack (for nested loops) */
135 uint LoopStack[TGSI_EXEC_MAX_LOOP_NESTING];
138 /** Loop continue mask stack (see comments in tgsi_exec.c) */
139 uint ContStack[TGSI_EXEC_MAX_LOOP_NESTING];
142 /** Function execution mask stack (for executing subroutine code) */
143 uint FuncStack[TGSI_EXEC_MAX_CALL_NESTING];
146 /** Function call stack for saving/restoring the program counter */
147 uint CallStack[TGSI_EXEC_MAX_CALL_NESTING];
150 struct tgsi_full_instruction *Instructions;
151 uint NumInstructions;
153 struct tgsi_full_declaration *Declarations;
154 uint NumDeclarations;
159 spu_exec_machine_init(struct spu_exec_machine *mach,
161 struct spu_sampler *samplers,
165 spu_exec_machine_run( struct spu_exec_machine *mach );
168 #if defined __cplusplus
172 #endif /* SPU_EXEC_H */