1 /**************************************************************************
3 * Copyright 2003 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 **************************************************************************/
29 #ifndef I915_PROGRAM_H
30 #define I915_PROGRAM_H
32 #include "i915_context.h"
37 /* Having zero and one in here makes the definition of swizzle a lot
40 #define UREG_TYPE_SHIFT 29
41 #define UREG_NR_SHIFT 24
42 #define UREG_CHANNEL_X_NEGATE_SHIFT 23
43 #define UREG_CHANNEL_X_SHIFT 20
44 #define UREG_CHANNEL_Y_NEGATE_SHIFT 19
45 #define UREG_CHANNEL_Y_SHIFT 16
46 #define UREG_CHANNEL_Z_NEGATE_SHIFT 15
47 #define UREG_CHANNEL_Z_SHIFT 12
48 #define UREG_CHANNEL_W_NEGATE_SHIFT 11
49 #define UREG_CHANNEL_W_SHIFT 8
50 #define UREG_CHANNEL_ZERO_NEGATE_MBZ 5
51 #define UREG_CHANNEL_ZERO_SHIFT 4
52 #define UREG_CHANNEL_ONE_NEGATE_MBZ 1
53 #define UREG_CHANNEL_ONE_SHIFT 0
55 #define UREG_BAD 0xffffffff /* not a valid ureg */
66 #define UREG( type, nr ) (((type)<< UREG_TYPE_SHIFT) | \
67 ((nr) << UREG_NR_SHIFT) | \
68 (X << UREG_CHANNEL_X_SHIFT) | \
69 (Y << UREG_CHANNEL_Y_SHIFT) | \
70 (Z << UREG_CHANNEL_Z_SHIFT) | \
71 (W << UREG_CHANNEL_W_SHIFT) | \
72 (ZERO << UREG_CHANNEL_ZERO_SHIFT) | \
73 (ONE << UREG_CHANNEL_ONE_SHIFT))
75 #define GET_CHANNEL_SRC( reg, channel ) ((reg<<(channel*4)) & (0xf<<20))
76 #define CHANNEL_SRC( src, channel ) (src>>(channel*4))
78 #define GET_UREG_TYPE(reg) (((reg)>>UREG_TYPE_SHIFT)®_TYPE_MASK)
79 #define GET_UREG_NR(reg) (((reg)>>UREG_NR_SHIFT)®_NR_MASK)
83 #define UREG_XYZW_CHANNEL_MASK 0x00ffff00
85 /* One neat thing about the UREG representation:
87 static __inline
int swizzle( int reg
, int x
, int y
, int z
, int w
)
89 return ((reg
& ~UREG_XYZW_CHANNEL_MASK
) |
90 CHANNEL_SRC( GET_CHANNEL_SRC( reg
, x
), 0 ) |
91 CHANNEL_SRC( GET_CHANNEL_SRC( reg
, y
), 1 ) |
92 CHANNEL_SRC( GET_CHANNEL_SRC( reg
, z
), 2 ) |
93 CHANNEL_SRC( GET_CHANNEL_SRC( reg
, w
), 3 ));
96 /* Another neat thing about the UREG representation:
98 static __inline
int negate( int reg
, int x
, int y
, int z
, int w
)
100 return reg
^ (((x
&1)<<UREG_CHANNEL_X_NEGATE_SHIFT
)|
101 ((y
&1)<<UREG_CHANNEL_Y_NEGATE_SHIFT
)|
102 ((z
&1)<<UREG_CHANNEL_Z_NEGATE_SHIFT
)|
103 ((w
&1)<<UREG_CHANNEL_W_NEGATE_SHIFT
));
107 extern GLuint
i915_get_temp( struct i915_fragment_program
*p
);
108 extern GLuint
i915_get_utemp( struct i915_fragment_program
*p
);
109 extern void i915_release_utemps( struct i915_fragment_program
*p
);
112 extern GLuint
i915_emit_texld( struct i915_fragment_program
*p
,
119 extern GLuint
i915_emit_arith( struct i915_fragment_program
*p
,
128 extern GLuint
i915_emit_decl( struct i915_fragment_program
*p
,
129 GLuint type
, GLuint nr
, GLuint d0_flags
);
132 extern GLuint
i915_emit_const1f( struct i915_fragment_program
*p
,
135 extern GLuint
i915_emit_const2f( struct i915_fragment_program
*p
,
136 GLfloat c0
, GLfloat c1
);
138 extern GLuint
i915_emit_const4fv( struct i915_fragment_program
*p
,
141 extern GLuint
i915_emit_const4f( struct i915_fragment_program
*p
,
142 GLfloat c0
, GLfloat c1
,
143 GLfloat c2
, GLfloat c3
);
146 extern GLuint
i915_emit_param4fv( struct i915_fragment_program
*p
,
147 const GLfloat
*values
);
149 extern void i915_program_error( struct i915_fragment_program
*p
,
150 const GLubyte
*msg
);
152 extern void i915_init_program( i915ContextPtr i915
,
153 struct i915_fragment_program
*p
);
155 extern void i915_upload_program( i915ContextPtr i915
,
156 struct i915_fragment_program
*p
);
158 extern void i915_fini_program( struct i915_fragment_program
*p
);