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:
88 swizzle(int reg
, int x
, int y
, int z
, int w
)
90 return ((reg
& ~UREG_XYZW_CHANNEL_MASK
) |
91 CHANNEL_SRC(GET_CHANNEL_SRC(reg
, x
), 0) |
92 CHANNEL_SRC(GET_CHANNEL_SRC(reg
, y
), 1) |
93 CHANNEL_SRC(GET_CHANNEL_SRC(reg
, z
), 2) |
94 CHANNEL_SRC(GET_CHANNEL_SRC(reg
, w
), 3));
97 /* Another neat thing about the UREG representation:
100 negate(int reg
, int x
, int y
, int z
, int w
)
102 return reg
^ (((x
& 1) << UREG_CHANNEL_X_NEGATE_SHIFT
) |
103 ((y
& 1) << UREG_CHANNEL_Y_NEGATE_SHIFT
) |
104 ((z
& 1) << UREG_CHANNEL_Z_NEGATE_SHIFT
) |
105 ((w
& 1) << UREG_CHANNEL_W_NEGATE_SHIFT
));
109 extern GLuint
i915_get_temp(struct i915_fragment_program
*p
);
110 extern GLuint
i915_get_utemp(struct i915_fragment_program
*p
);
111 extern void i915_release_utemps(struct i915_fragment_program
*p
);
114 extern GLuint
i915_emit_texld(struct i915_fragment_program
*p
,
118 GLuint sampler
, GLuint coord
, GLuint op
);
120 extern GLuint
i915_emit_arith(struct i915_fragment_program
*p
,
125 GLuint src0
, GLuint src1
, GLuint src2
);
127 extern GLuint
i915_emit_decl(struct i915_fragment_program
*p
,
128 GLuint type
, GLuint nr
, GLuint d0_flags
);
131 extern GLuint
i915_emit_const1f(struct i915_fragment_program
*p
, GLfloat c0
);
133 extern GLuint
i915_emit_const2f(struct i915_fragment_program
*p
,
134 GLfloat c0
, GLfloat c1
);
136 extern GLuint
i915_emit_const4fv(struct i915_fragment_program
*p
,
139 extern GLuint
i915_emit_const4f(struct i915_fragment_program
*p
,
140 GLfloat c0
, GLfloat c1
,
141 GLfloat c2
, GLfloat c3
);
144 extern GLuint
i915_emit_param4fv(struct i915_fragment_program
*p
,
145 const GLfloat
* values
);
147 extern void i915_program_error(struct i915_fragment_program
*p
,
148 const char *fmt
, ...);
150 extern void i915_init_program(struct i915_context
*i915
,
151 struct i915_fragment_program
*p
);
153 extern void i915_upload_program(struct i915_context
*i915
,
154 struct i915_fragment_program
*p
);
156 extern void i915_fini_program(struct i915_fragment_program
*p
);
158 extern void i915_update_program(struct gl_context
*ctx
);