Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/drivers/llvmpipe/lp_setup_context.h
4570 views
1
/**************************************************************************
2
*
3
* Copyright 2007-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
/**
30
* The setup code is concerned with point/line/triangle setup and
31
* putting commands/data into the bins.
32
*/
33
34
35
#ifndef LP_SETUP_CONTEXT_H
36
#define LP_SETUP_CONTEXT_H
37
38
#include "lp_setup.h"
39
#include "lp_rast.h"
40
#include "lp_scene.h"
41
#include "lp_bld_interp.h" /* for struct lp_shader_input */
42
43
#include "draw/draw_vbuf.h"
44
#include "util/u_rect.h"
45
#include "util/u_pack_color.h"
46
47
#define LP_SETUP_NEW_FS 0x01
48
#define LP_SETUP_NEW_CONSTANTS 0x02
49
#define LP_SETUP_NEW_BLEND_COLOR 0x04
50
#define LP_SETUP_NEW_SCISSOR 0x08
51
#define LP_SETUP_NEW_VIEWPORTS 0x10
52
#define LP_SETUP_NEW_SSBOS 0x20
53
54
struct lp_setup_variant;
55
56
57
/** Max number of scenes */
58
/* XXX: make multiple scenes per context work, see lp_setup_rasterize_scene */
59
#define MAX_SCENES 1
60
61
62
63
/**
64
* Point/line/triangle setup context.
65
* Note: "stored" below indicates data which is stored in the bins,
66
* not arbitrary malloc'd memory.
67
*
68
*
69
* Subclass of vbuf_render, plugged directly into the draw module as
70
* the rendering backend.
71
*/
72
struct lp_setup_context
73
{
74
struct vbuf_render base;
75
76
struct pipe_context *pipe;
77
struct vertex_info *vertex_info;
78
uint view_index;
79
uint prim;
80
uint vertex_size;
81
uint nr_vertices;
82
uint sprite_coord_enable, sprite_coord_origin;
83
uint vertex_buffer_size;
84
void *vertex_buffer;
85
86
/* Final pipeline stage for draw module. Draw module should
87
* create/install this itself now.
88
*/
89
struct draw_stage *vbuf;
90
unsigned num_threads;
91
unsigned scene_idx;
92
struct lp_scene *scenes[MAX_SCENES]; /**< all the scenes */
93
struct lp_scene *scene; /**< current scene being built */
94
95
struct lp_fence *last_fence;
96
struct llvmpipe_query *active_queries[LP_MAX_ACTIVE_BINNED_QUERIES];
97
unsigned active_binned_queries;
98
99
boolean flatshade_first;
100
boolean ccw_is_frontface;
101
boolean scissor_test;
102
boolean point_size_per_vertex;
103
boolean legacy_points;
104
boolean rasterizer_discard;
105
boolean multisample;
106
boolean rectangular_lines;
107
unsigned cullmode;
108
unsigned bottom_edge_rule;
109
float pixel_offset;
110
float line_width;
111
float point_size;
112
int8_t psize_slot;
113
int8_t viewport_index_slot;
114
int8_t layer_slot;
115
int8_t face_slot;
116
117
struct pipe_framebuffer_state fb;
118
struct u_rect framebuffer;
119
struct u_rect scissors[PIPE_MAX_VIEWPORTS];
120
struct u_rect draw_regions[PIPE_MAX_VIEWPORTS]; /* intersection of fb & scissor */
121
struct lp_jit_viewport viewports[PIPE_MAX_VIEWPORTS];
122
123
struct {
124
unsigned flags;
125
union util_color color_val[PIPE_MAX_COLOR_BUFS];
126
uint64_t zsmask;
127
uint64_t zsvalue; /**< lp_rast_clear_zstencil() cmd */
128
} clear;
129
130
enum setup_state {
131
SETUP_FLUSHED, /**< scene is null */
132
SETUP_CLEARED, /**< scene exists but has only clears */
133
SETUP_ACTIVE /**< scene exists and has at least one draw/query */
134
} state;
135
136
struct {
137
const struct lp_rast_state *stored; /**< what's in the scene */
138
struct lp_rast_state current; /**< currently set state */
139
struct pipe_resource *current_tex[PIPE_MAX_SHADER_SAMPLER_VIEWS];
140
unsigned current_tex_num;
141
} fs;
142
143
/** fragment shader constants */
144
struct {
145
struct pipe_constant_buffer current;
146
unsigned stored_size;
147
const void *stored_data;
148
} constants[LP_MAX_TGSI_CONST_BUFFERS];
149
150
/** fragment shader buffers */
151
struct {
152
struct pipe_shader_buffer current;
153
} ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
154
155
struct {
156
struct pipe_image_view current;
157
} images[LP_MAX_TGSI_SHADER_IMAGES];
158
159
struct {
160
struct pipe_blend_color current;
161
uint8_t *stored;
162
} blend_color;
163
164
165
struct {
166
const struct lp_setup_variant *variant;
167
} setup;
168
169
unsigned dirty; /**< bitmask of LP_SETUP_NEW_x bits */
170
171
void (*point)( struct lp_setup_context *,
172
const float (*v0)[4]);
173
174
void (*line)( struct lp_setup_context *,
175
const float (*v0)[4],
176
const float (*v1)[4]);
177
178
void (*triangle)( struct lp_setup_context *,
179
const float (*v0)[4],
180
const float (*v1)[4],
181
const float (*v2)[4]);
182
};
183
184
static inline void
185
scissor_planes_needed(boolean scis_planes[4], const struct u_rect *bbox,
186
const struct u_rect *scissor)
187
{
188
/* left */
189
scis_planes[0] = (bbox->x0 < scissor->x0);
190
/* right */
191
scis_planes[1] = (bbox->x1 > scissor->x1);
192
/* top */
193
scis_planes[2] = (bbox->y0 < scissor->y0);
194
/* bottom */
195
scis_planes[3] = (bbox->y1 > scissor->y1);
196
}
197
198
199
void lp_setup_choose_triangle( struct lp_setup_context *setup );
200
void lp_setup_choose_line( struct lp_setup_context *setup );
201
void lp_setup_choose_point( struct lp_setup_context *setup );
202
203
void lp_setup_init_vbuf(struct lp_setup_context *setup);
204
205
boolean lp_setup_update_state( struct lp_setup_context *setup,
206
boolean update_scene);
207
208
void lp_setup_destroy( struct lp_setup_context *setup );
209
210
boolean lp_setup_flush_and_restart(struct lp_setup_context *setup);
211
212
void
213
lp_setup_print_triangle(struct lp_setup_context *setup,
214
const float (*v0)[4],
215
const float (*v1)[4],
216
const float (*v2)[4]);
217
218
void
219
lp_setup_print_vertex(struct lp_setup_context *setup,
220
const char *name,
221
const float (*v)[4]);
222
223
224
struct lp_rast_triangle *
225
lp_setup_alloc_triangle(struct lp_scene *scene,
226
unsigned num_inputs,
227
unsigned nr_planes,
228
unsigned *tri_size);
229
230
boolean
231
lp_setup_bin_triangle(struct lp_setup_context *setup,
232
struct lp_rast_triangle *tri,
233
const struct u_rect *bboxorig,
234
const struct u_rect *bbox,
235
int nr_planes,
236
unsigned scissor_index);
237
238
#endif
239
240