2 * Mesa 3-D graphics library
5 * Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 #if !defined SLANG_ASSEMBLE_H
26 #define SLANG_ASSEMBLE_H
28 #include "slang_utility.h"
30 #if defined __cplusplus
34 struct slang_operation_
;
36 typedef enum slang_assembly_type_
43 slang_asm_float_deref
,
45 slang_asm_float_multiply
,
46 slang_asm_float_divide
,
47 slang_asm_float_negate
,
49 slang_asm_float_equal_exp
,
50 slang_asm_float_equal_int
,
51 slang_asm_float_to_int
,
53 slang_asm_float_arcsine
,
54 slang_asm_float_arctan
,
55 slang_asm_float_power
,
57 slang_asm_float_floor
,
59 slang_asm_float_noise1
,
60 slang_asm_float_noise2
,
61 slang_asm_float_noise3
,
62 slang_asm_float_noise4
,
67 slang_asm_int_to_float
,
68 slang_asm_int_to_addr
,
77 slang_asm_addr_multiply
,
81 slang_asm_vec4_texcube
,
82 slang_asm_vec4_shad1d
,
83 slang_asm_vec4_shad2d
,
85 slang_asm_jump_if_zero
,
88 slang_asm_local_alloc
,
91 slang_asm_global_addr
,
96 /* GL_MESA_shader_debug */
97 slang_asm_float_print
,
101 slang_asm_float_to_vec4
,
103 slang_asm_vec4_subtract
,
104 slang_asm_vec4_multiply
,
105 slang_asm_vec4_divide
,
106 slang_asm_vec4_negate
,
109 slang_asm_vec4_deref
,
110 slang_asm_vec4_equal_int
,
111 /* not a real assembly instruction */
113 } slang_assembly_type
;
115 typedef struct slang_assembly_
117 slang_assembly_type type
;
122 typedef struct slang_assembly_file_
124 slang_assembly
*code
;
127 } slang_assembly_file
;
130 _slang_assembly_file_ctr (slang_assembly_file
*);
132 GLvoid
slang_assembly_file_destruct (slang_assembly_file
*);
133 GLboolean
slang_assembly_file_push (slang_assembly_file
*, slang_assembly_type
);
134 GLboolean
slang_assembly_file_push_label (slang_assembly_file
*, slang_assembly_type
, GLuint
);
135 GLboolean
slang_assembly_file_push_label2 (slang_assembly_file
*, slang_assembly_type
, GLuint
, GLuint
);
136 GLboolean
slang_assembly_file_push_literal (slang_assembly_file
*, slang_assembly_type
, GLfloat
);
138 typedef struct slang_assembly_file_restore_point_
141 } slang_assembly_file_restore_point
;
143 GLboolean
slang_assembly_file_restore_point_save (slang_assembly_file
*,
144 slang_assembly_file_restore_point
*);
145 GLboolean
slang_assembly_file_restore_point_load (slang_assembly_file
*,
146 slang_assembly_file_restore_point
*);
148 typedef struct slang_assembly_flow_control_
150 GLuint loop_start
; /* for "continue" statement */
151 GLuint loop_end
; /* for "break" statement */
152 GLuint function_end
; /* for "return" statement */
153 } slang_assembly_flow_control
;
155 typedef struct slang_assembly_local_info_
160 } slang_assembly_local_info
;
166 slang_ref_freelance*/
170 * Holds a complete information about vector swizzle - the <swizzle> array contains
171 * vector component source indices, where 0 is "x", 1 is "y", 2 is "z" and 3 is "w".
172 * Example: "xwz" --> { 3, { 0, 3, 2, not used } }.
174 typedef struct slang_swizzle_
176 GLuint num_components
;
180 typedef struct slang_assembly_name_space_
182 struct slang_function_scope_
*funcs
;
183 struct slang_struct_scope_
*structs
;
184 struct slang_variable_scope_
*vars
;
185 } slang_assembly_name_space
;
187 typedef struct slang_assemble_ctx_
189 slang_assembly_file
*file
;
190 struct slang_machine_
*mach
;
191 slang_atom_pool
*atoms
;
192 slang_assembly_name_space space
;
193 slang_assembly_flow_control flow
;
194 slang_assembly_local_info local
;
197 } slang_assemble_ctx
;
199 struct slang_function_
*_slang_locate_function (struct slang_function_scope_
*funcs
, slang_atom name
,
200 struct slang_operation_
*params
, GLuint num_params
, slang_assembly_name_space
*space
,
203 GLboolean
_slang_assemble_function (slang_assemble_ctx
*, struct slang_function_
*);
205 GLboolean
_slang_cleanup_stack (slang_assemble_ctx
*, struct slang_operation_
*);
207 GLboolean
_slang_dereference (slang_assemble_ctx
*, struct slang_operation_
*);
209 GLboolean
_slang_assemble_function_call (slang_assemble_ctx
*, struct slang_function_
*,
210 struct slang_operation_
*, GLuint
, GLboolean
);
212 GLboolean
_slang_assemble_function_call_name (slang_assemble_ctx
*, const char *,
213 struct slang_operation_
*, GLuint
, GLboolean
);
215 GLboolean
_slang_assemble_operation (slang_assemble_ctx
*, struct slang_operation_
*,
222 #include "slang_assemble_assignment.h"
223 #include "slang_assemble_typeinfo.h"
224 #include "slang_assemble_constructor.h"
225 #include "slang_assemble_conditional.h"