Merge commit 'origin/gallium-winsys-handle-rebased'
[mesa.git] / src / gallium / drivers / llvmpipe / lp_jit.h
1 /**************************************************************************
2 *
3 * Copyright 2009 VMware, Inc.
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 VMWARE 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 * @file
30 * C - JIT interfaces
31 *
32 * @author Jose Fonseca <jfonseca@vmware.com>
33 */
34
35 #ifndef LP_JIT_H
36 #define LP_JIT_H
37
38
39 #include "gallivm/lp_bld_struct.h"
40
41 #include "pipe/p_state.h"
42
43
44 struct llvmpipe_screen;
45
46
47 struct lp_jit_texture
48 {
49 uint32_t width;
50 uint32_t height;
51 uint32_t depth;
52 uint32_t last_level;
53 uint32_t stride;
54 const void *data;
55 };
56
57
58 enum {
59 LP_JIT_TEXTURE_WIDTH = 0,
60 LP_JIT_TEXTURE_HEIGHT,
61 LP_JIT_TEXTURE_DEPTH,
62 LP_JIT_TEXTURE_LAST_LEVEL,
63 LP_JIT_TEXTURE_STRIDE,
64 LP_JIT_TEXTURE_DATA
65 };
66
67
68
69 /**
70 * This structure is passed directly to the generated fragment shader.
71 *
72 * It contains the derived state.
73 *
74 * Changes here must be reflected in the lp_jit_context_* macros and
75 * lp_jit_init_types function. Changes to the ordering should be avoided.
76 *
77 * Only use types with a clear size and padding here, in particular prefer the
78 * stdint.h types to the basic integer types.
79 */
80 struct lp_jit_context
81 {
82 const float *constants;
83
84 float alpha_ref_value;
85
86 /** floats, not ints */
87 float scissor_xmin, scissor_ymin, scissor_xmax, scissor_ymax;
88
89 /* FIXME: store (also?) in floats */
90 uint8_t *blend_color;
91
92 struct lp_jit_texture textures[PIPE_MAX_SAMPLERS];
93 };
94
95
96 #define lp_jit_context_constants(_builder, _ptr) \
97 lp_build_struct_get(_builder, _ptr, 0, "constants")
98
99 #define lp_jit_context_alpha_ref_value(_builder, _ptr) \
100 lp_build_struct_get(_builder, _ptr, 1, "alpha_ref_value")
101
102 #define lp_jit_context_scissor_xmin_value(_builder, _ptr) \
103 lp_build_struct_get(_builder, _ptr, 2, "scissor_xmin")
104
105 #define lp_jit_context_scissor_ymin_value(_builder, _ptr) \
106 lp_build_struct_get(_builder, _ptr, 3, "scissor_ymin")
107
108 #define lp_jit_context_scissor_xmax_value(_builder, _ptr) \
109 lp_build_struct_get(_builder, _ptr, 4, "scissor_xmax")
110
111 #define lp_jit_context_scissor_ymax_value(_builder, _ptr) \
112 lp_build_struct_get(_builder, _ptr, 5, "scissor_ymax")
113
114 #define lp_jit_context_blend_color(_builder, _ptr) \
115 lp_build_struct_get(_builder, _ptr, 6, "blend_color")
116
117 #define LP_JIT_CONTEXT_TEXTURES_INDEX 7
118
119 #define lp_jit_context_textures(_builder, _ptr) \
120 lp_build_struct_get_ptr(_builder, _ptr, LP_JIT_CONTEXT_TEXTURES_INDEX, "textures")
121
122
123 typedef void
124 (*lp_jit_frag_func)(const struct lp_jit_context *context,
125 uint32_t x,
126 uint32_t y,
127 const void *a0,
128 const void *dadx,
129 const void *dady,
130 uint8_t **color,
131 void *depth,
132 const int32_t c1,
133 const int32_t c2,
134 const int32_t c3,
135 const int32_t *step1,
136 const int32_t *step2,
137 const int32_t *step3);
138
139
140 void
141 lp_jit_screen_cleanup(struct llvmpipe_screen *screen);
142
143
144 void
145 lp_jit_screen_init(struct llvmpipe_screen *screen);
146
147
148 #endif /* LP_JIT_H */