~mmach/netext73/mesa-haswell

« back to all changes in this revision

Viewing changes to src/gallium/drivers/llvmpipe/lp_setup_context.h

  • Committer: mmach
  • Date: 2022-09-22 19:56:13 UTC
  • Revision ID: netbit73@gmail.com-20220922195613-wtik9mmy20tmor0i
2022-09-22 21:17:09

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
#include "util/slab.h"
47
 
 
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
54
 
 
55
 
struct lp_setup_variant;
56
 
 
57
 
 
58
 
/** Max number of scenes */
59
 
#define INITIAL_SCENES 4
60
 
#define MAX_SCENES 64
61
 
 
62
 
 
63
 
 
64
 
/**
65
 
 * Point/line/triangle setup context.
66
 
 * Note: "stored" below indicates data which is stored in the bins,
67
 
 * not arbitrary malloc'd memory.
68
 
 *
69
 
 *
70
 
 * Subclass of vbuf_render, plugged directly into the draw module as
71
 
 * the rendering backend.
72
 
 */
73
 
struct lp_setup_context
74
 
{
75
 
   struct vbuf_render base;
76
 
 
77
 
   struct pipe_context *pipe;
78
 
   struct vertex_info *vertex_info;
79
 
   uint view_index;
80
 
   uint prim;
81
 
   uint vertex_size;
82
 
   uint nr_vertices;
83
 
   uint sprite_coord_enable, sprite_coord_origin;
84
 
   uint vertex_buffer_size;
85
 
   void *vertex_buffer;
86
 
 
87
 
   /* Final pipeline stage for draw module.  Draw module should
88
 
    * create/install this itself now.
89
 
    */
90
 
   struct draw_stage *vbuf;
91
 
   unsigned num_threads;
92
 
   unsigned scene_idx;
93
 
 
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 */
98
 
 
99
 
   struct lp_fence *last_fence;
100
 
   struct llvmpipe_query *active_queries[LP_MAX_ACTIVE_BINNED_QUERIES];
101
 
   unsigned active_binned_queries;
102
 
 
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;
115
 
   float pixel_offset;
116
 
   float line_width;
117
 
   float point_size;
118
 
   int8_t psize_slot;
119
 
   int8_t viewport_index_slot;
120
 
   int8_t layer_slot;
121
 
   int8_t face_slot;
122
 
 
123
 
   struct pipe_framebuffer_state fb;
124
 
   struct u_rect framebuffer;
125
 
   struct u_rect scissors[PIPE_MAX_VIEWPORTS];
126
 
   struct u_rect vpwh;
127
 
   struct u_rect draw_regions[PIPE_MAX_VIEWPORTS];   /* intersection of fb & scissor */
128
 
   struct lp_jit_viewport viewports[PIPE_MAX_VIEWPORTS];
129
 
 
130
 
   struct {
131
 
      unsigned flags;
132
 
      union util_color color_val[PIPE_MAX_COLOR_BUFS];
133
 
      uint64_t zsmask;
134
 
      uint64_t zsvalue;               /**< lp_rast_clear_zstencil() cmd */
135
 
   } clear;
136
 
 
137
 
   enum setup_state {
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 */
141
 
   } state;
142
 
   
143
 
   struct {
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;
148
 
   } fs;
149
 
 
150
 
   /** fragment shader constants */
151
 
   struct {
152
 
      struct pipe_constant_buffer current;
153
 
      unsigned stored_size;
154
 
      const void *stored_data;
155
 
   } constants[LP_MAX_TGSI_CONST_BUFFERS];
156
 
 
157
 
   /** fragment shader buffers */
158
 
   struct {
159
 
      struct pipe_shader_buffer current;
160
 
   } ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
161
 
   uint32_t ssbo_write_mask;
162
 
 
163
 
   struct {
164
 
      struct pipe_image_view current;
165
 
   } images[LP_MAX_TGSI_SHADER_IMAGES];
166
 
 
167
 
   struct {
168
 
      struct pipe_blend_color current;
169
 
      uint8_t *stored;
170
 
   } blend_color;
171
 
 
172
 
 
173
 
   struct {
174
 
      const struct lp_setup_variant *variant;
175
 
   } setup;
176
 
 
177
 
   unsigned dirty;   /**< bitmask of LP_SETUP_NEW_x bits */
178
 
 
179
 
   void (*point)( struct lp_setup_context *,
180
 
                  const float (*v0)[4]);
181
 
 
182
 
   void (*line)( struct lp_setup_context *,
183
 
                 const float (*v0)[4],
184
 
                 const float (*v1)[4]);
185
 
 
186
 
   void (*triangle)( struct lp_setup_context *,
187
 
                     const float (*v0)[4],
188
 
                     const float (*v1)[4],
189
 
                     const float (*v2)[4]);
190
 
 
191
 
   boolean
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]);
199
 
};
200
 
 
201
 
static inline void
202
 
scissor_planes_needed(boolean scis_planes[4], const struct u_rect *bbox,
203
 
                      const struct u_rect *scissor)
204
 
{
205
 
   /* left */
206
 
   scis_planes[0] = (bbox->x0 < scissor->x0);
207
 
   /* right */
208
 
   scis_planes[1] = (bbox->x1 > scissor->x1);
209
 
   /* top */
210
 
   scis_planes[2] = (bbox->y0 < scissor->y0);
211
 
   /* bottom */
212
 
   scis_planes[3] = (bbox->y1 > scissor->y1);
213
 
}
214
 
 
215
 
void
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);
219
 
 
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 );
224
 
 
225
 
void lp_setup_init_vbuf(struct lp_setup_context *setup);
226
 
 
227
 
boolean lp_setup_update_state( struct lp_setup_context *setup,
228
 
                            boolean update_scene);
229
 
 
230
 
void lp_setup_destroy( struct lp_setup_context *setup );
231
 
 
232
 
boolean lp_setup_flush_and_restart(struct lp_setup_context *setup);
233
 
 
234
 
boolean
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);
238
 
 
239
 
boolean
240
 
lp_setup_is_blit(const struct lp_setup_context *setup,
241
 
                 const struct lp_rast_shader_inputs *inputs);
242
 
 
243
 
void
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]);
248
 
 
249
 
void
250
 
lp_setup_print_vertex(struct lp_setup_context *setup,
251
 
                      const char *name,
252
 
                      const float (*v)[4]);
253
 
 
254
 
void
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);
260
 
 
261
 
void 
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],
266
 
                       boolean front );
267
 
 
268
 
struct lp_rast_triangle *
269
 
lp_setup_alloc_triangle(struct lp_scene *scene,
270
 
                        unsigned num_inputs,
271
 
                        unsigned nr_planes,
272
 
                        unsigned *tri_size);
273
 
 
274
 
struct lp_rast_rectangle *
275
 
lp_setup_alloc_rectangle(struct lp_scene *scene,
276
 
                         unsigned nr_inputs);
277
 
 
278
 
boolean
279
 
lp_setup_analyse_triangles(struct lp_setup_context *setup,
280
 
                           const void *vb,
281
 
                           int stride,
282
 
                           int nr);
283
 
 
284
 
boolean
285
 
lp_setup_bin_triangle(struct lp_setup_context *setup,
286
 
                      struct lp_rast_triangle *tri,
287
 
                      boolean use_32bits,
288
 
                      boolean opaque,
289
 
                      const struct u_rect *bbox,
290
 
                      int nr_planes,
291
 
                      unsigned scissor_index);
292
 
 
293
 
boolean
294
 
lp_setup_bin_rectangle(struct lp_setup_context *setup,
295
 
                       struct lp_rast_rectangle *rect,
296
 
                       boolean opaque);
297
 
 
298
 
 
299
 
#endif