Merge branch 'upstream-gallium-0.1' into nouveau-gallium-0.1
[mesa.git] / src / gallium / auxiliary / gallivm / gallivm.h
1 /**************************************************************************
2 *
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
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:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
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.
25 *
26 **************************************************************************/
27
28 /*
29 * Authors:
30 * Zack Rusin zack@tungstengraphics.com
31 */
32
33 #ifndef GALLIVM_H
34 #define GALLIVM_H
35
36 #if defined __cplusplus
37 extern "C" {
38 #endif
39
40 #include "pipe/p_state.h"
41
42 #ifdef MESA_LLVM
43
44 struct tgsi_token;
45
46 struct gallivm_ir;
47 struct gallivm_prog;
48 struct gallivm_cpu_engine;
49 struct tgsi_interp_coef;
50 struct tgsi_sampler;
51 struct tgsi_exec_vector;
52
53 enum gallivm_shader_type {
54 GALLIVM_VS,
55 GALLIVM_FS
56 };
57
58 enum gallivm_vector_layout {
59 GALLIVM_AOS,
60 GALLIVM_SOA
61 };
62
63 struct gallivm_ir *gallivm_ir_new(enum gallivm_shader_type type);
64 void gallivm_ir_set_layout(struct gallivm_ir *ir,
65 enum gallivm_vector_layout layout);
66 void gallivm_ir_set_components(struct gallivm_ir *ir, int num);
67 void gallivm_ir_fill_from_tgsi(struct gallivm_ir *ir,
68 const struct tgsi_token *tokens);
69 void gallivm_ir_delete(struct gallivm_ir *ir);
70
71
72 struct gallivm_prog *gallivm_ir_compile(struct gallivm_ir *ir);
73
74 void gallivm_prog_inputs_interpolate(struct gallivm_prog *prog,
75 float (*inputs)[PIPE_MAX_SHADER_INPUTS][4],
76 const struct tgsi_interp_coef *coefs);
77 void gallivm_prog_dump(struct gallivm_prog *prog, const char *file_prefix);
78
79
80 struct gallivm_cpu_engine *gallivm_cpu_engine_create(struct gallivm_prog *prog);
81 struct gallivm_cpu_engine *gallivm_global_cpu_engine();
82 int gallivm_cpu_vs_exec(struct gallivm_prog *prog,
83 struct tgsi_exec_vector *inputs,
84 struct tgsi_exec_vector *dests,
85 float (*consts)[4],
86 struct tgsi_exec_vector *temps);
87 int gallivm_cpu_fs_exec(struct gallivm_prog *prog,
88 float x, float y,
89 float (*dests)[PIPE_MAX_SHADER_INPUTS][4],
90 float (*inputs)[PIPE_MAX_SHADER_INPUTS][4],
91 float (*consts)[4],
92 struct tgsi_sampler *samplers);
93 void gallivm_cpu_jit_compile(struct gallivm_cpu_engine *ee, struct gallivm_prog *prog);
94 void gallivm_cpu_engine_delete(struct gallivm_cpu_engine *ee);
95
96
97 #endif /* MESA_LLVM */
98
99 #if defined __cplusplus
100 } // extern "C"
101 #endif
102
103 #endif