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
40 #include "lp_tile_soa.h" /* for TILE_SIZE */
43 #include "draw/draw_vbuf.h"
44 #include "util/u_rect.h"
46 #define LP_SETUP_NEW_FS 0x01
47 #define LP_SETUP_NEW_CONSTANTS 0x02
48 #define LP_SETUP_NEW_BLEND_COLOR 0x04
49 #define LP_SETUP_NEW_SCISSOR 0x08
53 /** Max number of scenes */
59 * Point/line/triangle setup context.
60 * Note: "stored" below indicates data which is stored in the bins,
61 * not arbitrary malloc'd memory.
64 * Subclass of vbuf_render, plugged directly into the draw module as
65 * the rendering backend.
67 struct lp_setup_context
69 struct vbuf_render base
;
71 struct pipe_context
*pipe
;
72 struct vertex_info
*vertex_info
;
77 uint vertex_buffer_size
;
80 /* Final pipeline stage for draw module. Draw module should
81 * create/install this itself now.
83 struct draw_stage
*vbuf
;
86 struct lp_scene
*scenes
[MAX_SCENES
]; /**< all the scenes */
87 struct lp_scene
*scene
; /**< current scene being built */
89 struct lp_fence
*last_fence
;
90 struct llvmpipe_query
*active_query
;
92 boolean flatshade_first
;
93 boolean ccw_is_frontface
;
95 boolean point_size_per_vertex
;
102 struct pipe_framebuffer_state fb
;
103 struct u_rect framebuffer
;
104 struct u_rect scissor
;
105 struct u_rect draw_region
; /* intersection of fb & scissor */
109 union lp_rast_cmd_arg color
; /**< lp_rast_clear_color() cmd */
111 unsigned zsvalue
; /**< lp_rast_clear_zstencil() cmd */
115 SETUP_FLUSHED
, /**< scene is null */
116 SETUP_CLEARED
, /**< scene exists but has only clears */
117 SETUP_ACTIVE
/**< scene exists and has at least one draw/query */
121 struct lp_shader_input input
[PIPE_MAX_ATTRIBS
];
124 const struct lp_rast_state
*stored
; /**< what's in the scene */
125 struct lp_rast_state current
; /**< currently set state */
126 struct pipe_resource
*current_tex
[PIPE_MAX_SAMPLERS
];
129 /** fragment shader constants */
131 struct pipe_resource
*current
;
132 unsigned stored_size
;
133 const void *stored_data
;
137 struct pipe_blend_color current
;
142 unsigned dirty
; /**< bitmask of LP_SETUP_NEW_x bits */
144 void (*point
)( struct lp_setup_context
*,
145 const float (*v0
)[4]);
147 void (*line
)( struct lp_setup_context
*,
148 const float (*v0
)[4],
149 const float (*v1
)[4]);
151 void (*triangle
)( struct lp_setup_context
*,
152 const float (*v0
)[4],
153 const float (*v1
)[4],
154 const float (*v2
)[4]);
157 void lp_setup_choose_triangle( struct lp_setup_context
*setup
);
158 void lp_setup_choose_line( struct lp_setup_context
*setup
);
159 void lp_setup_choose_point( struct lp_setup_context
*setup
);
161 void lp_setup_init_vbuf(struct lp_setup_context
*setup
);
163 void lp_setup_update_state( struct lp_setup_context
*setup
,
164 boolean update_scene
);
166 void lp_setup_destroy( struct lp_setup_context
*setup
);
168 void lp_setup_flush_and_restart(struct lp_setup_context
*setup
);
171 lp_setup_print_triangle(struct lp_setup_context
*setup
,
172 const float (*v0
)[4],
173 const float (*v1
)[4],
174 const float (*v2
)[4]);
177 lp_setup_print_vertex(struct lp_setup_context
*setup
,
179 const float (*v
)[4]);
182 struct lp_rast_triangle
*
183 lp_setup_alloc_triangle(struct lp_scene
*scene
,
189 lp_setup_bin_triangle( struct lp_setup_context
*setup
,
190 struct lp_rast_triangle
*tri
,
191 const struct u_rect
*bbox
,
194 void lp_setup_flush_and_restart(struct lp_setup_context
*setup
);