Merge branch 'mesa_7_5_branch'
[mesa.git] / src / mesa / drivers / dri / r300 / compiler / radeon_compiler.h
1 /*
2 * Copyright 2009 Nicolai Hähnle <nhaehnle@gmail.com>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE. */
22
23 #ifndef RADEON_COMPILER_H
24 #define RADEON_COMPILER_H
25
26 #include "main/mtypes.h"
27 #include "shader/prog_instruction.h"
28
29 #include "memory_pool.h"
30 #include "radeon_code.h"
31
32
33 struct rc_instruction {
34 struct rc_instruction * Prev;
35 struct rc_instruction * Next;
36 struct prog_instruction I;
37 };
38
39 struct rc_program {
40 /**
41 * Instructions.Next points to the first instruction,
42 * Instructions.Prev points to the last instruction.
43 */
44 struct rc_instruction Instructions;
45
46 /* Long term, we should probably remove InputsRead & OutputsWritten,
47 * since updating dependent state can be fragile, and they aren't
48 * actually used very often. */
49 uint32_t InputsRead;
50 uint32_t OutputsWritten;
51 uint32_t ShadowSamplers; /**< Texture units used for shadow sampling. */
52
53 struct rc_constant_list Constants;
54 };
55
56 struct radeon_compiler {
57 struct memory_pool Pool;
58 struct rc_program Program;
59 unsigned Debug:1;
60 unsigned Error:1;
61 char * ErrorMsg;
62 };
63
64 void rc_init(struct radeon_compiler * c);
65 void rc_destroy(struct radeon_compiler * c);
66
67 void rc_debug(struct radeon_compiler * c, const char * fmt, ...);
68 void rc_error(struct radeon_compiler * c, const char * fmt, ...);
69
70 void rc_mesa_to_rc_program(struct radeon_compiler * c, struct gl_program * program);
71
72 void rc_calculate_inputs_outputs(struct radeon_compiler * c);
73
74 void rc_move_input(struct radeon_compiler * c, unsigned input, struct prog_src_register new_input);
75 void rc_move_output(struct radeon_compiler * c, unsigned output, unsigned new_output, unsigned writemask);
76 void rc_copy_output(struct radeon_compiler * c, unsigned output, unsigned dup_output);
77 void rc_transform_fragment_wpos(struct radeon_compiler * c, unsigned wpos, unsigned new_input);
78
79 struct r300_fragment_program_compiler {
80 struct radeon_compiler Base;
81 struct rX00_fragment_program_code *code;
82 struct r300_fragment_program_external_state state;
83 unsigned is_r500;
84 unsigned OutputDepth;
85 unsigned OutputColor;
86
87 void * UserData;
88 void (*AllocateHwInputs)(
89 struct r300_fragment_program_compiler * c,
90 void (*allocate)(void * data, unsigned input, unsigned hwreg),
91 void * mydata);
92 };
93
94 void r3xx_compile_fragment_program(struct r300_fragment_program_compiler* c);
95
96
97 struct r300_vertex_program_compiler {
98 struct radeon_compiler Base;
99 struct r300_vertex_program_code *code;
100 GLbitfield RequiredOutputs;
101
102 void * UserData;
103 void (*SetHwInputOutput)(struct r300_vertex_program_compiler * c);
104 };
105
106 void r3xx_compile_vertex_program(struct r300_vertex_program_compiler* c);
107
108 #endif /* RADEON_COMPILER_H */