Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/auxiliary/draw/draw_context.h
4565 views
1
2
/**************************************************************************
3
*
4
* Copyright 2007 VMware, Inc.
5
* All Rights Reserved.
6
*
7
* Permission is hereby granted, free of charge, to any person obtaining a
8
* copy of this software and associated documentation files (the
9
* "Software"), to deal in the Software without restriction, including
10
* without limitation the rights to use, copy, modify, merge, publish,
11
* distribute, sub license, and/or sell copies of the Software, and to
12
* permit persons to whom the Software is furnished to do so, subject to
13
* the following conditions:
14
*
15
* The above copyright notice and this permission notice (including the
16
* next paragraph) shall be included in all copies or substantial portions
17
* of the Software.
18
*
19
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
23
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
*
27
**************************************************************************/
28
29
/**
30
* \brief Public interface into the drawing module.
31
*/
32
33
/* Authors: Keith Whitwell <[email protected]>
34
*/
35
36
37
#ifndef DRAW_CONTEXT_H
38
#define DRAW_CONTEXT_H
39
40
41
#include "pipe/p_state.h"
42
43
struct pipe_context;
44
struct draw_context;
45
struct draw_stage;
46
struct draw_vertex_shader;
47
struct draw_geometry_shader;
48
struct draw_tess_ctrl_shader;
49
struct draw_tess_eval_shader;
50
struct draw_fragment_shader;
51
struct tgsi_sampler;
52
struct tgsi_image;
53
struct tgsi_buffer;
54
55
/*
56
* structure to contain driver internal information
57
* for stream out support. mapping stores the pointer
58
* to the buffer contents, and internal offset stores
59
* an internal counter to how much of the stream
60
* out buffer is used (in bytes).
61
*/
62
struct draw_so_target {
63
struct pipe_stream_output_target target;
64
void *mapping;
65
int internal_offset;
66
};
67
68
bool draw_has_llvm(void);
69
70
struct draw_context *draw_create( struct pipe_context *pipe );
71
72
#ifdef DRAW_LLVM_AVAILABLE
73
struct draw_context *draw_create_with_llvm_context(struct pipe_context *pipe,
74
void *context);
75
#endif
76
77
struct draw_context *draw_create_no_llvm(struct pipe_context *pipe);
78
79
void draw_destroy( struct draw_context *draw );
80
81
void draw_flush(struct draw_context *draw);
82
83
void draw_set_viewport_states( struct draw_context *draw,
84
unsigned start_slot,
85
unsigned num_viewports,
86
const struct pipe_viewport_state *viewports );
87
88
void draw_set_clip_state( struct draw_context *pipe,
89
const struct pipe_clip_state *clip );
90
91
/**
92
* Sets the rasterization state used by the draw module.
93
* The rast_handle is used to pass the driver specific representation
94
* of the rasterization state. It's going to be used when the
95
* draw module sets the state back on the driver itself using the
96
* pipe::bind_rasterizer_state method.
97
*
98
* NOTE: if you're calling this function from within the pipe's
99
* bind_rasterizer_state you should always call it before binding
100
* the actual state - that's because the draw module can try to
101
* bind its own rasterizer state which would reset your newly
102
* set state. i.e. always do
103
* draw_set_rasterizer_state(driver->draw, state->pipe_state, state);
104
* driver->state.raster = state;
105
*/
106
void draw_set_rasterizer_state( struct draw_context *draw,
107
const struct pipe_rasterizer_state *raster,
108
void *rast_handle );
109
110
void draw_set_rasterize_stage( struct draw_context *draw,
111
struct draw_stage *stage );
112
113
void draw_wide_point_threshold(struct draw_context *draw, float threshold);
114
115
void draw_wide_point_sprites(struct draw_context *draw, boolean draw_sprite);
116
117
void draw_wide_line_threshold(struct draw_context *draw, float threshold);
118
119
void draw_enable_line_stipple(struct draw_context *draw, boolean enable);
120
121
void draw_enable_point_sprites(struct draw_context *draw, boolean enable);
122
123
void draw_set_zs_format(struct draw_context *draw, enum pipe_format format);
124
125
/* for TGSI constants are 4 * sizeof(float), but for NIR they need to be sizeof(float); */
126
void draw_set_constant_buffer_stride(struct draw_context *draw, unsigned num_bytes);
127
128
boolean
129
draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe);
130
131
boolean
132
draw_install_aapoint_stage(struct draw_context *draw, struct pipe_context *pipe);
133
134
boolean
135
draw_install_pstipple_stage(struct draw_context *draw, struct pipe_context *pipe);
136
137
138
struct tgsi_shader_info *
139
draw_get_shader_info(const struct draw_context *draw);
140
141
void
142
draw_prepare_shader_outputs(struct draw_context *draw);
143
144
int
145
draw_find_shader_output(const struct draw_context *draw,
146
uint semantic_name, uint semantic_index);
147
148
boolean
149
draw_will_inject_frontface(const struct draw_context *draw);
150
151
uint
152
draw_num_shader_outputs(const struct draw_context *draw);
153
154
uint
155
draw_total_vs_outputs(const struct draw_context *draw);
156
157
uint
158
draw_total_gs_outputs(const struct draw_context *draw);
159
160
uint
161
draw_total_tcs_outputs(const struct draw_context *draw);
162
163
uint
164
draw_total_tes_outputs(const struct draw_context *draw);
165
166
void
167
draw_texture_sampler(struct draw_context *draw,
168
enum pipe_shader_type shader_type,
169
struct tgsi_sampler *sampler);
170
171
void
172
draw_image(struct draw_context *draw,
173
enum pipe_shader_type shader_type,
174
struct tgsi_image *image);
175
176
void
177
draw_buffer(struct draw_context *draw,
178
enum pipe_shader_type shader_type,
179
struct tgsi_buffer *buffer);
180
181
void
182
draw_set_sampler_views(struct draw_context *draw,
183
enum pipe_shader_type shader_stage,
184
struct pipe_sampler_view **views,
185
unsigned num);
186
void
187
draw_set_samplers(struct draw_context *draw,
188
enum pipe_shader_type shader_stage,
189
struct pipe_sampler_state **samplers,
190
unsigned num);
191
192
void
193
draw_set_images(struct draw_context *draw,
194
enum pipe_shader_type shader_stage,
195
struct pipe_image_view *images,
196
unsigned num);
197
198
void
199
draw_set_mapped_texture(struct draw_context *draw,
200
enum pipe_shader_type shader_stage,
201
unsigned sview_idx,
202
uint32_t width, uint32_t height, uint32_t depth,
203
uint32_t first_level, uint32_t last_level,
204
uint32_t num_samples,
205
uint32_t sample_stride,
206
const void *base,
207
uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS],
208
uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS],
209
uint32_t mip_offsets[PIPE_MAX_TEXTURE_LEVELS]);
210
211
void
212
draw_set_mapped_image(struct draw_context *draw,
213
enum pipe_shader_type shader_stage,
214
unsigned idx,
215
uint32_t width, uint32_t height, uint32_t depth,
216
const void *base_ptr,
217
uint32_t row_stride,
218
uint32_t img_stride,
219
uint32_t num_samples,
220
uint32_t sample_stride);
221
222
/*
223
* Vertex shader functions
224
*/
225
226
struct draw_vertex_shader *
227
draw_create_vertex_shader(struct draw_context *draw,
228
const struct pipe_shader_state *shader);
229
void draw_bind_vertex_shader(struct draw_context *draw,
230
struct draw_vertex_shader *dvs);
231
void draw_delete_vertex_shader(struct draw_context *draw,
232
struct draw_vertex_shader *dvs);
233
void draw_vs_attach_so(struct draw_vertex_shader *dvs,
234
const struct pipe_stream_output_info *info);
235
void draw_vs_reset_so(struct draw_vertex_shader *dvs);
236
237
238
/*
239
* Fragment shader functions
240
*/
241
struct draw_fragment_shader *
242
draw_create_fragment_shader(struct draw_context *draw,
243
const struct pipe_shader_state *shader);
244
void draw_bind_fragment_shader(struct draw_context *draw,
245
struct draw_fragment_shader *dvs);
246
void draw_delete_fragment_shader(struct draw_context *draw,
247
struct draw_fragment_shader *dvs);
248
249
/*
250
* Geometry shader functions
251
*/
252
struct draw_geometry_shader *
253
draw_create_geometry_shader(struct draw_context *draw,
254
const struct pipe_shader_state *shader);
255
void draw_bind_geometry_shader(struct draw_context *draw,
256
struct draw_geometry_shader *dvs);
257
void draw_delete_geometry_shader(struct draw_context *draw,
258
struct draw_geometry_shader *dvs);
259
260
/*
261
* Tess shader functions
262
*/
263
struct draw_tess_ctrl_shader *
264
draw_create_tess_ctrl_shader(struct draw_context *draw,
265
const struct pipe_shader_state *shader);
266
void draw_bind_tess_ctrl_shader(struct draw_context *draw,
267
struct draw_tess_ctrl_shader *dvs);
268
void draw_delete_tess_ctrl_shader(struct draw_context *draw,
269
struct draw_tess_ctrl_shader *dvs);
270
struct draw_tess_eval_shader *
271
draw_create_tess_eval_shader(struct draw_context *draw,
272
const struct pipe_shader_state *shader);
273
void draw_bind_tess_eval_shader(struct draw_context *draw,
274
struct draw_tess_eval_shader *dvs);
275
void draw_delete_tess_eval_shader(struct draw_context *draw,
276
struct draw_tess_eval_shader *dvs);
277
void draw_set_tess_state(struct draw_context *draw,
278
const float default_outer_level[4],
279
const float default_inner_level[2]);
280
281
/*
282
* Vertex data functions
283
*/
284
285
void draw_set_vertex_buffers(struct draw_context *draw,
286
unsigned start_slot, unsigned count,
287
unsigned unbind_num_trailing_slots,
288
const struct pipe_vertex_buffer *buffers);
289
290
void draw_set_vertex_elements(struct draw_context *draw,
291
unsigned count,
292
const struct pipe_vertex_element *elements);
293
294
void draw_set_indexes(struct draw_context *draw,
295
const void *elements, unsigned elem_size,
296
unsigned available_space);
297
298
void draw_set_mapped_vertex_buffer(struct draw_context *draw,
299
unsigned attr, const void *buffer,
300
size_t size);
301
302
void
303
draw_set_mapped_constant_buffer(struct draw_context *draw,
304
enum pipe_shader_type shader_type,
305
unsigned slot,
306
const void *buffer,
307
unsigned size);
308
309
void
310
draw_set_mapped_shader_buffer(struct draw_context *draw,
311
enum pipe_shader_type shader_type,
312
unsigned slot,
313
const void *buffer,
314
unsigned size);
315
316
void
317
draw_set_mapped_so_targets(struct draw_context *draw,
318
int num_targets,
319
struct draw_so_target *targets[PIPE_MAX_SO_BUFFERS]);
320
321
322
/***********************************************************************
323
* draw_pt.c
324
*/
325
326
void draw_vbo(struct draw_context *draw,
327
const struct pipe_draw_info *info,
328
unsigned drawid_offset,
329
const struct pipe_draw_indirect_info *indirect,
330
const struct pipe_draw_start_count_bias *draws,
331
unsigned num_draws);
332
333
334
/*******************************************************************************
335
* Driver backend interface
336
*/
337
struct vbuf_render;
338
void draw_set_render( struct draw_context *draw,
339
struct vbuf_render *render );
340
341
void draw_set_driver_clipping( struct draw_context *draw,
342
boolean bypass_clip_xy,
343
boolean bypass_clip_z,
344
boolean guard_band_xy,
345
boolean bypass_clip_points);
346
347
/*******************************************************************************
348
* Draw statistics
349
*/
350
void draw_collect_pipeline_statistics(struct draw_context *draw,
351
boolean enable);
352
353
void draw_collect_primitives_generated(struct draw_context *draw,
354
bool eanble);
355
356
/*******************************************************************************
357
* Draw pipeline
358
*/
359
boolean draw_need_pipeline(const struct draw_context *draw,
360
const struct pipe_rasterizer_state *rasterizer,
361
unsigned prim );
362
363
int
364
draw_get_shader_param(enum pipe_shader_type shader, enum pipe_shader_cap param);
365
366
int
367
draw_get_shader_param_no_llvm(enum pipe_shader_type shader,
368
enum pipe_shader_cap param);
369
370
boolean
371
draw_get_option_use_llvm(void);
372
373
struct lp_cached_code;
374
void
375
draw_set_disk_cache_callbacks(struct draw_context *draw,
376
void *data_cookie,
377
void (*find_shader)(void *cookie,
378
struct lp_cached_code *cache,
379
unsigned char ir_sha1_cache_key[20]),
380
void (*insert_shader)(void *cookie,
381
struct lp_cached_code *cache,
382
unsigned char ir_sha1_cache_key[20]));
383
#endif /* DRAW_CONTEXT_H */
384
385