1
/**************************************************************************
3
* Copyright 2007-2009 VMware, Inc.
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:
14
* The above copyright notice and this permission notice (including the
15
* next paragraph) shall be included in all copies or substantial portions
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.
26
**************************************************************************/
30
* The setup code is concerned with point/line/triangle setup and
31
* putting commands/data into the bins.
35
#ifndef LP_SETUP_CONTEXT_H
36
#define LP_SETUP_CONTEXT_H
41
#include "lp_bld_interp.h" /* for struct lp_shader_input */
43
#include "draw/draw_vbuf.h"
44
#include "util/u_rect.h"
45
#include "util/u_pack_color.h"
46
#include "util/slab.h"
48
#define LP_SETUP_NEW_FS 0x01
49
#define LP_SETUP_NEW_CONSTANTS 0x02
50
#define LP_SETUP_NEW_BLEND_COLOR 0x04
51
#define LP_SETUP_NEW_SCISSOR 0x08
52
#define LP_SETUP_NEW_VIEWPORTS 0x10
53
#define LP_SETUP_NEW_SSBOS 0x20
55
struct lp_setup_variant;
58
/** Max number of scenes */
59
#define INITIAL_SCENES 4
65
* Point/line/triangle setup context.
66
* Note: "stored" below indicates data which is stored in the bins,
67
* not arbitrary malloc'd memory.
70
* Subclass of vbuf_render, plugged directly into the draw module as
71
* the rendering backend.
73
struct lp_setup_context
75
struct vbuf_render base;
77
struct pipe_context *pipe;
78
struct vertex_info *vertex_info;
83
uint sprite_coord_enable, sprite_coord_origin;
84
uint vertex_buffer_size;
87
/* Final pipeline stage for draw module. Draw module should
88
* create/install this itself now.
90
struct draw_stage *vbuf;
94
struct slab_mempool scene_slab;
95
int num_active_scenes;
96
struct lp_scene *scenes[MAX_SCENES]; /**< all the scenes */
97
struct lp_scene *scene; /**< current scene being built */
99
struct lp_fence *last_fence;
100
struct llvmpipe_query *active_queries[LP_MAX_ACTIVE_BINNED_QUERIES];
101
unsigned active_binned_queries;
103
unsigned flatshade_first:1;
104
unsigned ccw_is_frontface:1;
105
unsigned scissor_test:1;
106
unsigned point_tri_clip:1;
107
unsigned point_size_per_vertex:1;
108
unsigned legacy_points:1;
109
unsigned rasterizer_discard:1;
110
unsigned permit_linear_rasterizer:1;
111
unsigned multisample:1;
112
unsigned rectangular_lines:1;
113
unsigned cullmode:2; /**< PIPE_FACE_x */
114
unsigned bottom_edge_rule;
119
int8_t viewport_index_slot;
123
struct pipe_framebuffer_state fb;
124
struct u_rect framebuffer;
125
struct u_rect scissors[PIPE_MAX_VIEWPORTS];
127
struct u_rect draw_regions[PIPE_MAX_VIEWPORTS]; /* intersection of fb & scissor */
128
struct lp_jit_viewport viewports[PIPE_MAX_VIEWPORTS];
132
union util_color color_val[PIPE_MAX_COLOR_BUFS];
134
uint64_t zsvalue; /**< lp_rast_clear_zstencil() cmd */
138
SETUP_FLUSHED, /**< scene is null */
139
SETUP_CLEARED, /**< scene exists but has only clears */
140
SETUP_ACTIVE /**< scene exists and has at least one draw/query */
144
const struct lp_rast_state *stored; /**< what's in the scene */
145
struct lp_rast_state current; /**< currently set state */
146
struct pipe_resource *current_tex[PIPE_MAX_SHADER_SAMPLER_VIEWS];
147
unsigned current_tex_num;
150
/** fragment shader constants */
152
struct pipe_constant_buffer current;
153
unsigned stored_size;
154
const void *stored_data;
155
} constants[LP_MAX_TGSI_CONST_BUFFERS];
157
/** fragment shader buffers */
159
struct pipe_shader_buffer current;
160
} ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
161
uint32_t ssbo_write_mask;
164
struct pipe_image_view current;
165
} images[LP_MAX_TGSI_SHADER_IMAGES];
168
struct pipe_blend_color current;
174
const struct lp_setup_variant *variant;
177
unsigned dirty; /**< bitmask of LP_SETUP_NEW_x bits */
179
void (*point)( struct lp_setup_context *,
180
const float (*v0)[4]);
182
void (*line)( struct lp_setup_context *,
183
const float (*v0)[4],
184
const float (*v1)[4]);
186
void (*triangle)( struct lp_setup_context *,
187
const float (*v0)[4],
188
const float (*v1)[4],
189
const float (*v2)[4]);
192
(*rect)( struct lp_setup_context *,
193
const float (*v0)[4],
194
const float (*v1)[4],
195
const float (*v2)[4],
196
const float (*v3)[4],
197
const float (*v4)[4],
198
const float (*v5)[4]);
202
scissor_planes_needed(boolean scis_planes[4], const struct u_rect *bbox,
203
const struct u_rect *scissor)
206
scis_planes[0] = (bbox->x0 < scissor->x0);
208
scis_planes[1] = (bbox->x1 > scissor->x1);
210
scis_planes[2] = (bbox->y0 < scissor->y0);
212
scis_planes[3] = (bbox->y1 > scissor->y1);
216
lp_setup_add_scissor_planes(const struct u_rect *scissor,
217
struct lp_rast_plane *plane_s,
218
boolean s_planes[4], bool multisample);
220
void lp_setup_choose_triangle( struct lp_setup_context *setup );
221
void lp_setup_choose_line( struct lp_setup_context *setup );
222
void lp_setup_choose_point( struct lp_setup_context *setup );
223
void lp_setup_choose_rect( struct lp_setup_context *setup );
225
void lp_setup_init_vbuf(struct lp_setup_context *setup);
227
boolean lp_setup_update_state( struct lp_setup_context *setup,
228
boolean update_scene);
230
void lp_setup_destroy( struct lp_setup_context *setup );
232
boolean lp_setup_flush_and_restart(struct lp_setup_context *setup);
235
lp_setup_whole_tile(struct lp_setup_context *setup,
236
const struct lp_rast_shader_inputs *inputs,
237
int tx, int ty, boolean opaque);
240
lp_setup_is_blit(const struct lp_setup_context *setup,
241
const struct lp_rast_shader_inputs *inputs);
244
lp_setup_print_triangle(struct lp_setup_context *setup,
245
const float (*v0)[4],
246
const float (*v1)[4],
247
const float (*v2)[4]);
250
lp_setup_print_vertex(struct lp_setup_context *setup,
252
const float (*v)[4]);
255
lp_rect_cw(struct lp_setup_context *setup,
256
const float (*v0)[4],
257
const float (*v1)[4],
258
const float (*v2)[4],
259
boolean frontfacing);
262
lp_setup_triangle_ccw( struct lp_setup_context *setup,
263
const float (*v0)[4],
264
const float (*v1)[4],
265
const float (*v2)[4],
268
struct lp_rast_triangle *
269
lp_setup_alloc_triangle(struct lp_scene *scene,
274
struct lp_rast_rectangle *
275
lp_setup_alloc_rectangle(struct lp_scene *scene,
279
lp_setup_analyse_triangles(struct lp_setup_context *setup,
285
lp_setup_bin_triangle(struct lp_setup_context *setup,
286
struct lp_rast_triangle *tri,
289
const struct u_rect *bbox,
291
unsigned scissor_index);
294
lp_setup_bin_rectangle(struct lp_setup_context *setup,
295
struct lp_rast_rectangle *rect,