blob: 28578535866db4f22ba446be48c88a2d4f0d571e [file] [log] [blame]
José Fonseca946f4322009-07-26 23:44:38 +01001/**************************************************************************
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/* Authors: Keith Whitwell <keith@tungstengraphics.com>
29 */
30
José Fonsecac9a59302009-07-27 11:36:24 +010031#ifndef LP_STATE_H
32#define LP_STATE_H
José Fonseca946f4322009-07-26 23:44:38 +010033
José Fonseca2d6b39f2009-08-09 23:10:19 +010034#include <llvm-c/Core.h>
35
José Fonseca946f4322009-07-26 23:44:38 +010036#include "pipe/p_state.h"
37#include "tgsi/tgsi_scan.h"
José Fonseca08dd41f2009-08-23 05:52:20 +010038#include "lp_jit.h"
José Fonsecae4c76c02009-09-07 14:52:39 +010039#include "lp_bld_sample.h" /* for struct lp_sampler_static_state */
José Fonseca946f4322009-07-26 23:44:38 +010040
41
José Fonsecac9a59302009-07-27 11:36:24 +010042#define LP_NEW_VIEWPORT 0x1
43#define LP_NEW_RASTERIZER 0x2
44#define LP_NEW_FS 0x4
45#define LP_NEW_BLEND 0x8
46#define LP_NEW_CLIP 0x10
47#define LP_NEW_SCISSOR 0x20
48#define LP_NEW_STIPPLE 0x40
49#define LP_NEW_FRAMEBUFFER 0x80
50#define LP_NEW_DEPTH_STENCIL_ALPHA 0x100
51#define LP_NEW_CONSTANTS 0x200
52#define LP_NEW_SAMPLER 0x400
53#define LP_NEW_TEXTURE 0x800
54#define LP_NEW_VERTEX 0x1000
55#define LP_NEW_VS 0x2000
56#define LP_NEW_QUERY 0x4000
José Fonseca946f4322009-07-26 23:44:38 +010057
58
59struct tgsi_sampler;
José Fonseca946f4322009-07-26 23:44:38 +010060struct vertex_info;
José Fonsecae4c76c02009-09-07 14:52:39 +010061struct pipe_context;
62struct llvmpipe_context;
José Fonseca946f4322009-07-26 23:44:38 +010063
José Fonseca9ae47062009-08-19 20:42:50 +010064struct lp_fragment_shader;
65
66
José Fonsecae3b38e52009-08-21 07:48:04 +010067struct lp_fragment_shader_variant_key
68{
José Fonsecacdbbcdf2009-09-09 21:16:06 +010069 enum pipe_format zsbuf_format;
José Fonsecae3b38e52009-08-21 07:48:04 +010070 struct pipe_depth_state depth;
71 struct pipe_alpha_state alpha;
José Fonseca98971802009-08-22 12:39:44 +010072 struct pipe_blend_state blend;
José Fonsecae4c76c02009-09-07 14:52:39 +010073
74 struct lp_sampler_static_state sampler[PIPE_MAX_SAMPLERS];
José Fonsecae3b38e52009-08-21 07:48:04 +010075};
76
77
José Fonseca9ae47062009-08-19 20:42:50 +010078struct lp_fragment_shader_variant
79{
80 struct lp_fragment_shader *shader;
José Fonsecae3b38e52009-08-21 07:48:04 +010081
82 struct lp_fragment_shader_variant_key key;
José Fonseca9ae47062009-08-19 20:42:50 +010083
84 LLVMValueRef function;
85
José Fonseca08dd41f2009-08-23 05:52:20 +010086 lp_jit_frag_func jit_function;
José Fonseca9ae47062009-08-19 20:42:50 +010087
88 struct lp_fragment_shader_variant *next;
89};
90
91
José Fonseca946f4322009-07-26 23:44:38 +010092/**
93 * Subclass of pipe_shader_state (though it doesn't really need to be).
94 *
95 * This is starting to look an awful lot like a quad pipeline stage...
96 */
José Fonseca73af91e2009-08-14 10:27:32 +010097struct lp_fragment_shader
98{
99 struct pipe_shader_state base;
José Fonseca946f4322009-07-26 23:44:38 +0100100
101 struct tgsi_shader_info info;
102
José Fonseca9ae47062009-08-19 20:42:50 +0100103 struct lp_fragment_shader_variant *variants;
José Fonseca946f4322009-07-26 23:44:38 +0100104
José Fonseca9ae47062009-08-19 20:42:50 +0100105 struct lp_fragment_shader_variant *current;
José Fonseca946f4322009-07-26 23:44:38 +0100106};
107
108
109/** Subclass of pipe_shader_state */
110struct lp_vertex_shader {
111 struct pipe_shader_state shader;
112 struct draw_vertex_shader *draw_data;
113};
114
115
José Fonseca946f4322009-07-26 23:44:38 +0100116
117void *
118llvmpipe_create_blend_state(struct pipe_context *,
119 const struct pipe_blend_state *);
120void llvmpipe_bind_blend_state(struct pipe_context *,
121 void *);
122void llvmpipe_delete_blend_state(struct pipe_context *,
123 void *);
124
125void *
126llvmpipe_create_sampler_state(struct pipe_context *,
127 const struct pipe_sampler_state *);
128void llvmpipe_bind_sampler_states(struct pipe_context *, unsigned, void **);
José Fonsecac0a13bb2009-12-04 21:25:40 +0000129void
130llvmpipe_bind_vertex_sampler_states(struct pipe_context *,
131 unsigned num_samplers,
132 void **samplers);
José Fonseca946f4322009-07-26 23:44:38 +0100133void llvmpipe_delete_sampler_state(struct pipe_context *, void *);
134
135void *
136llvmpipe_create_depth_stencil_state(struct pipe_context *,
137 const struct pipe_depth_stencil_alpha_state *);
138void llvmpipe_bind_depth_stencil_state(struct pipe_context *, void *);
139void llvmpipe_delete_depth_stencil_state(struct pipe_context *, void *);
140
141void *
142llvmpipe_create_rasterizer_state(struct pipe_context *,
143 const struct pipe_rasterizer_state *);
144void llvmpipe_bind_rasterizer_state(struct pipe_context *, void *);
145void llvmpipe_delete_rasterizer_state(struct pipe_context *, void *);
146
147void llvmpipe_set_framebuffer_state( struct pipe_context *,
148 const struct pipe_framebuffer_state * );
149
150void llvmpipe_set_blend_color( struct pipe_context *pipe,
151 const struct pipe_blend_color *blend_color );
152
153void llvmpipe_set_clip_state( struct pipe_context *,
154 const struct pipe_clip_state * );
155
156void llvmpipe_set_constant_buffer(struct pipe_context *,
157 uint shader, uint index,
158 const struct pipe_constant_buffer *buf);
159
160void *llvmpipe_create_fs_state(struct pipe_context *,
161 const struct pipe_shader_state *);
162void llvmpipe_bind_fs_state(struct pipe_context *, void *);
163void llvmpipe_delete_fs_state(struct pipe_context *, void *);
164void *llvmpipe_create_vs_state(struct pipe_context *,
165 const struct pipe_shader_state *);
166void llvmpipe_bind_vs_state(struct pipe_context *, void *);
167void llvmpipe_delete_vs_state(struct pipe_context *, void *);
168
169void llvmpipe_set_polygon_stipple( struct pipe_context *,
170 const struct pipe_poly_stipple * );
171
172void llvmpipe_set_scissor_state( struct pipe_context *,
173 const struct pipe_scissor_state * );
174
Brian Pauld5e59092009-12-02 12:20:15 -0700175void llvmpipe_set_sampler_textures( struct pipe_context *,
176 unsigned num,
177 struct pipe_texture ** );
José Fonseca946f4322009-07-26 23:44:38 +0100178
José Fonsecac0a13bb2009-12-04 21:25:40 +0000179void
180llvmpipe_set_vertex_sampler_textures(struct pipe_context *,
181 unsigned num_textures,
182 struct pipe_texture **);
183
José Fonseca946f4322009-07-26 23:44:38 +0100184void llvmpipe_set_viewport_state( struct pipe_context *,
185 const struct pipe_viewport_state * );
186
187void llvmpipe_set_vertex_elements(struct pipe_context *,
188 unsigned count,
189 const struct pipe_vertex_element *);
190
191void llvmpipe_set_vertex_buffers(struct pipe_context *,
192 unsigned count,
193 const struct pipe_vertex_buffer *);
194
José Fonseca9ae47062009-08-19 20:42:50 +0100195void llvmpipe_update_fs(struct llvmpipe_context *lp);
José Fonseca946f4322009-07-26 23:44:38 +0100196
197void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe );
198
199
Keith Whitwell03f212b2009-12-21 22:47:21 +0000200void llvmpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
José Fonseca946f4322009-07-26 23:44:38 +0100201 unsigned start, unsigned count);
202
Keith Whitwell03f212b2009-12-21 22:47:21 +0000203void llvmpipe_draw_elements(struct pipe_context *pipe,
José Fonseca946f4322009-07-26 23:44:38 +0100204 struct pipe_buffer *indexBuffer,
205 unsigned indexSize,
206 unsigned mode, unsigned start, unsigned count);
Keith Whitwell03f212b2009-12-21 22:47:21 +0000207void
José Fonseca946f4322009-07-26 23:44:38 +0100208llvmpipe_draw_range_elements(struct pipe_context *pipe,
209 struct pipe_buffer *indexBuffer,
210 unsigned indexSize,
211 unsigned min_index,
212 unsigned max_index,
213 unsigned mode, unsigned start, unsigned count);
214
215void
216llvmpipe_set_edgeflags(struct pipe_context *pipe, const unsigned *edgeflags);
217
218
219void
220llvmpipe_map_transfers(struct llvmpipe_context *lp);
221
222void
223llvmpipe_unmap_transfers(struct llvmpipe_context *lp);
224
225void
226llvmpipe_map_texture_surfaces(struct llvmpipe_context *lp);
227
228void
229llvmpipe_unmap_texture_surfaces(struct llvmpipe_context *lp);
230
231
232struct vertex_info *
233llvmpipe_get_vertex_info(struct llvmpipe_context *llvmpipe);
234
235struct vertex_info *
236llvmpipe_get_vbuf_vertex_info(struct llvmpipe_context *llvmpipe);
237
238
239#endif