r500: Set Saturate correctly in radeon_program_pair
[mesa.git] / src / mesa / drivers / dri / r300 / radeon_program.h
1 /*
2 * Copyright (C) 2008 Nicolai Haehnle.
3 *
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a 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, sublicense, 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:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial
16 * portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 */
27
28 #ifndef __RADEON_PROGRAM_H_
29 #define __RADEON_PROGRAM_H_
30
31 #include "glheader.h"
32 #include "macros.h"
33 #include "enums.h"
34 #include "shader/program.h"
35 #include "shader/prog_instruction.h"
36
37
38 enum {
39 CLAUSE_MIXED = 0,
40 CLAUSE_ALU,
41 CLAUSE_TEX
42 };
43
44 enum {
45 PROGRAM_BUILTIN = PROGRAM_FILE_MAX /**< not a real register, but a special swizzle constant */
46 };
47
48 enum {
49 OPCODE_REPL_ALPHA = MAX_OPCODE /**< used in paired instructions */
50 };
51
52 #define SWIZZLE_0000 MAKE_SWIZZLE4(SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ZERO)
53 #define SWIZZLE_1111 MAKE_SWIZZLE4(SWIZZLE_ONE, SWIZZLE_ONE, SWIZZLE_ONE, SWIZZLE_ONE)
54
55 /**
56 * Transformation context that is passed to local transformations.
57 *
58 * Care must be taken with some operations during transformation,
59 * e.g. finding new temporary registers must use @ref radeonFindFreeTemporary
60 */
61 struct radeon_transform_context {
62 GLcontext *Ctx;
63 struct gl_program *Program;
64 struct prog_instruction *OldInstructions;
65 GLuint OldNumInstructions;
66 };
67
68 /**
69 * A transformation that can be passed to \ref radeonLocalTransform.
70 *
71 * The function will be called once for each instruction.
72 * It has to either emit the appropriate transformed code for the instruction
73 * and return GL_TRUE, or return GL_FALSE if it doesn't understand the
74 * instruction.
75 *
76 * The function gets passed the userData as last parameter.
77 */
78 struct radeon_program_transformation {
79 GLboolean (*function)(
80 struct radeon_transform_context*,
81 struct prog_instruction*,
82 void*);
83 void *userData;
84 };
85
86 void radeonLocalTransform(
87 GLcontext* ctx,
88 struct gl_program *program,
89 int num_transformations,
90 struct radeon_program_transformation* transformations);
91
92 /**
93 * Find a usable free temporary register during program transformation
94 */
95 GLint radeonFindFreeTemporary(struct radeon_transform_context *ctx);
96
97 struct prog_instruction *radeonAppendInstructions(struct gl_program *program, int count);
98
99 #endif