svga: change svga hud defines to enums
[mesa.git] / src / gallium / drivers / svga / svga_context.h
1 /**********************************************************
2 * Copyright 2008-2009 VMware, Inc. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use, copy,
8 * modify, merge, publish, distribute, sublicense, and/or sell copies
9 * of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 *
24 **********************************************************/
25
26 #ifndef SVGA_CONTEXT_H
27 #define SVGA_CONTEXT_H
28
29
30 #include "pipe/p_context.h"
31 #include "pipe/p_defines.h"
32 #include "pipe/p_state.h"
33
34 #include "os/os_time.h"
35
36 #include "util/u_blitter.h"
37 #include "util/list.h"
38
39 #include "tgsi/tgsi_scan.h"
40
41 #include "svga_screen.h"
42 #include "svga_state.h"
43 #include "svga_winsys.h"
44 #include "svga_hw_reg.h"
45 #include "svga3d_shaderdefs.h"
46
47
48 /** Non-GPU queries for gallium HUD */
49 enum svga_hud {
50 /* per-frame counters */
51 SVGA_QUERY_NUM_DRAW_CALLS = PIPE_QUERY_DRIVER_SPECIFIC,
52 SVGA_QUERY_NUM_FALLBACKS,
53 SVGA_QUERY_NUM_FLUSHES,
54 SVGA_QUERY_NUM_VALIDATIONS,
55 SVGA_QUERY_MAP_BUFFER_TIME,
56 SVGA_QUERY_NUM_RESOURCES_MAPPED,
57 SVGA_QUERY_NUM_BYTES_UPLOADED,
58 SVGA_QUERY_COMMAND_BUFFER_SIZE,
59 SVGA_QUERY_FLUSH_TIME,
60 SVGA_QUERY_SURFACE_WRITE_FLUSHES,
61 SVGA_QUERY_NUM_READBACKS,
62 SVGA_QUERY_NUM_RESOURCE_UPDATES,
63 SVGA_QUERY_NUM_BUFFER_UPLOADS,
64 SVGA_QUERY_NUM_CONST_BUF_UPDATES,
65 SVGA_QUERY_NUM_CONST_UPDATES,
66
67 /* running total counters */
68 SVGA_QUERY_MEMORY_USED,
69 SVGA_QUERY_NUM_SHADERS,
70 SVGA_QUERY_NUM_RESOURCES,
71 SVGA_QUERY_NUM_STATE_OBJECTS,
72 SVGA_QUERY_NUM_SURFACE_VIEWS,
73 SVGA_QUERY_NUM_GENERATE_MIPMAP,
74
75 /*SVGA_QUERY_MAX has to be last because it is size of an array*/
76 SVGA_QUERY_MAX
77 };
78
79 /**
80 * Maximum supported number of constant buffers per shader
81 */
82 #define SVGA_MAX_CONST_BUFS 14
83
84 /**
85 * Maximum constant buffer size that can be set in the
86 * DXSetSingleConstantBuffer command is
87 * DX10 constant buffer element count * 4 4-bytes components
88 */
89 #define SVGA_MAX_CONST_BUF_SIZE (4096 * 4 * sizeof(int))
90
91 #define CONST0_UPLOAD_ALIGNMENT 256
92
93 struct draw_vertex_shader;
94 struct draw_fragment_shader;
95 struct svga_shader_variant;
96 struct SVGACmdMemory;
97 struct util_bitmask;
98
99
100 struct svga_cache_context;
101 struct svga_tracked_state;
102
103 struct svga_blend_state {
104 unsigned need_white_fragments:1;
105 unsigned independent_blend_enable:1;
106 unsigned alpha_to_coverage:1;
107 unsigned blend_color_alpha:1; /**< set blend color to alpha value */
108
109 /** Per-render target state */
110 struct {
111 uint8_t writemask;
112
113 boolean blend_enable;
114 uint8_t srcblend;
115 uint8_t dstblend;
116 uint8_t blendeq;
117
118 boolean separate_alpha_blend_enable;
119 uint8_t srcblend_alpha;
120 uint8_t dstblend_alpha;
121 uint8_t blendeq_alpha;
122 } rt[PIPE_MAX_COLOR_BUFS];
123
124 SVGA3dBlendStateId id; /**< vgpu10 */
125 };
126
127 struct svga_depth_stencil_state {
128 unsigned zfunc:8;
129 unsigned zenable:1;
130 unsigned zwriteenable:1;
131
132 unsigned alphatestenable:1;
133 unsigned alphafunc:8;
134
135 struct {
136 unsigned enabled:1;
137 unsigned func:8;
138 unsigned fail:8;
139 unsigned zfail:8;
140 unsigned pass:8;
141 } stencil[2];
142
143 /* SVGA3D has one ref/mask/writemask triple shared between front &
144 * back face stencil. We really need two:
145 */
146 unsigned stencil_mask:8;
147 unsigned stencil_writemask:8;
148
149 float alpharef;
150
151 SVGA3dDepthStencilStateId id; /**< vgpu10 */
152 };
153
154 #define SVGA_UNFILLED_DISABLE 0
155 #define SVGA_UNFILLED_LINE 1
156 #define SVGA_UNFILLED_POINT 2
157
158 #define SVGA_PIPELINE_FLAG_POINTS (1<<PIPE_PRIM_POINTS)
159 #define SVGA_PIPELINE_FLAG_LINES (1<<PIPE_PRIM_LINES)
160 #define SVGA_PIPELINE_FLAG_TRIS (1<<PIPE_PRIM_TRIANGLES)
161
162 struct svga_rasterizer_state {
163 struct pipe_rasterizer_state templ; /* needed for draw module */
164
165 unsigned shademode:8;
166 unsigned cullmode:8;
167 unsigned scissortestenable:1;
168 unsigned multisampleantialias:1;
169 unsigned antialiasedlineenable:1;
170 unsigned lastpixel:1;
171 unsigned pointsprite:1;
172
173 unsigned linepattern;
174
175 float slopescaledepthbias;
176 float depthbias;
177 float pointsize;
178 float linewidth;
179
180 unsigned hw_fillmode:2; /* PIPE_POLYGON_MODE_x */
181
182 /** Which prims do we need help for? Bitmask of (1 << PIPE_PRIM_x) flags */
183 unsigned need_pipeline:16;
184
185 SVGA3dRasterizerStateId id; /**< vgpu10 */
186
187 /** For debugging: */
188 const char* need_pipeline_tris_str;
189 const char* need_pipeline_lines_str;
190 const char* need_pipeline_points_str;
191 };
192
193 struct svga_sampler_state {
194 unsigned mipfilter;
195 unsigned magfilter;
196 unsigned minfilter;
197 unsigned aniso_level;
198 float lod_bias;
199 unsigned addressu;
200 unsigned addressv;
201 unsigned addressw;
202 unsigned bordercolor;
203 unsigned normalized_coords:1;
204 unsigned compare_mode:1;
205 unsigned compare_func:3;
206
207 unsigned min_lod;
208 unsigned view_min_lod;
209 unsigned view_max_lod;
210
211 SVGA3dSamplerId id;
212 };
213
214
215 struct svga_pipe_sampler_view
216 {
217 struct pipe_sampler_view base;
218
219 SVGA3dShaderResourceViewId id;
220 };
221
222
223 static inline struct svga_pipe_sampler_view *
224 svga_pipe_sampler_view(struct pipe_sampler_view *v)
225 {
226 return (struct svga_pipe_sampler_view *) v;
227 }
228
229
230 struct svga_velems_state {
231 unsigned count;
232 struct pipe_vertex_element velem[PIPE_MAX_ATTRIBS];
233 SVGA3dDeclType decl_type[PIPE_MAX_ATTRIBS]; /**< vertex attrib formats */
234
235 /** Bitmasks indicating which attributes need format conversion */
236 unsigned adjust_attrib_range; /**< range adjustment */
237 unsigned attrib_is_pure_int; /**< pure int */
238 unsigned adjust_attrib_w_1; /**< set w = 1 */
239 unsigned adjust_attrib_itof; /**< int->float */
240 unsigned adjust_attrib_utof; /**< uint->float */
241 unsigned attrib_is_bgra; /**< R / B swizzling */
242 unsigned attrib_puint_to_snorm; /**< 10_10_10_2 packed uint -> snorm */
243 unsigned attrib_puint_to_uscaled; /**< 10_10_10_2 packed uint -> uscaled */
244 unsigned attrib_puint_to_sscaled; /**< 10_10_10_2 packed uint -> sscaled */
245
246 boolean need_swvfetch;
247
248 SVGA3dElementLayoutId id; /**< VGPU10 */
249 };
250
251 /* Use to calculate differences between state emitted to hardware and
252 * current driver-calculated state.
253 */
254 struct svga_state
255 {
256 const struct svga_blend_state *blend;
257 const struct svga_depth_stencil_state *depth;
258 const struct svga_rasterizer_state *rast;
259 const struct svga_sampler_state *sampler[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
260 const struct svga_velems_state *velems;
261
262 struct pipe_sampler_view *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS]; /* or texture ID's? */
263 struct svga_fragment_shader *fs;
264 struct svga_vertex_shader *vs;
265 struct svga_geometry_shader *user_gs; /* user-specified GS */
266 struct svga_geometry_shader *gs; /* derived GS */
267
268 struct pipe_vertex_buffer vb[PIPE_MAX_ATTRIBS];
269 struct pipe_index_buffer ib;
270 /** Constant buffers for each shader.
271 * The size should probably always match with that of
272 * svga_shader_emitter_v10.num_shader_consts.
273 */
274 struct pipe_constant_buffer constbufs[PIPE_SHADER_TYPES][SVGA_MAX_CONST_BUFS];
275
276 struct pipe_framebuffer_state framebuffer;
277 float depthscale;
278
279 /* Hack to limit the number of different render targets between
280 * flushes. Helps avoid blowing out our surface cache in EXA.
281 */
282 int nr_fbs;
283
284 struct pipe_poly_stipple poly_stipple;
285 struct pipe_scissor_state scissor;
286 struct pipe_blend_color blend_color;
287 struct pipe_stencil_ref stencil_ref;
288 struct pipe_clip_state clip;
289 struct pipe_viewport_state viewport;
290
291 unsigned num_samplers[PIPE_SHADER_TYPES];
292 unsigned num_sampler_views[PIPE_SHADER_TYPES];
293 unsigned num_vertex_buffers;
294 unsigned reduced_prim;
295
296 struct {
297 unsigned flag_1d;
298 unsigned flag_srgb;
299 unsigned flag_rect; /* sampler views with rectangular texture target */
300 unsigned flag_buf; /* sampler views with texture buffer target */
301 } tex_flags;
302
303 unsigned sample_mask;
304 };
305
306 struct svga_prescale {
307 float translate[4];
308 float scale[4];
309 boolean enabled;
310 };
311
312
313 /* Updated by calling svga_update_state( SVGA_STATE_HW_CLEAR )
314 */
315 struct svga_hw_clear_state
316 {
317 SVGA3dRect viewport;
318
319 struct {
320 float zmin, zmax;
321 } depthrange;
322
323 struct pipe_framebuffer_state framebuffer;
324 struct svga_prescale prescale;
325 };
326
327 struct svga_hw_view_state
328 {
329 struct pipe_resource *texture;
330 struct svga_sampler_view *v;
331 unsigned min_lod;
332 unsigned max_lod;
333 boolean dirty;
334 };
335
336 /* Updated by calling svga_update_state( SVGA_STATE_HW_DRAW )
337 */
338 struct svga_hw_draw_state
339 {
340 /** VGPU9 rasterization state */
341 unsigned rs[SVGA3D_RS_MAX];
342 /** VGPU9 texture sampler and bindings state */
343 unsigned ts[SVGA3D_PIXEL_SAMPLERREG_MAX][SVGA3D_TS_MAX];
344 /** VGPU9 texture views */
345 unsigned num_views;
346 struct svga_hw_view_state views[PIPE_MAX_SAMPLERS];
347 /** VGPU9 constant buffer values */
348 float cb[PIPE_SHADER_TYPES][SVGA3D_CONSTREG_MAX][4];
349
350 /** Currently bound shaders */
351 struct svga_shader_variant *fs;
352 struct svga_shader_variant *vs;
353 struct svga_shader_variant *gs;
354
355 /** Currently bound constant buffer, per shader stage */
356 struct pipe_resource *constbuf[PIPE_SHADER_TYPES];
357
358 /** Bitmask of enabled constant buffers */
359 unsigned enabled_constbufs[PIPE_SHADER_TYPES];
360
361 /**
362 * These are used to reduce the number of times we call u_upload_unmap()
363 * while updating the zero-th/default VGPU10 constant buffer.
364 */
365 struct pipe_resource *const0_buffer;
366 struct svga_winsys_surface *const0_handle;
367
368 /** VGPU10 HW state (used to prevent emitting redundant state) */
369 SVGA3dDepthStencilStateId depth_stencil_id;
370 unsigned stencil_ref;
371 SVGA3dBlendStateId blend_id;
372 float blend_factor[4];
373 unsigned blend_sample_mask;
374 SVGA3dRasterizerStateId rasterizer_id;
375 SVGA3dElementLayoutId layout_id;
376 SVGA3dPrimitiveType topology;
377
378 /** Vertex buffer state */
379 SVGA3dVertexBuffer vbuffer_attrs[PIPE_MAX_ATTRIBS];
380 struct pipe_resource *vbuffers[PIPE_MAX_ATTRIBS];
381 unsigned num_vbuffers;
382
383 struct pipe_resource *ib; /**< index buffer for drawing */
384 SVGA3dSurfaceFormat ib_format;
385 unsigned ib_offset;
386
387 unsigned num_samplers[PIPE_SHADER_TYPES];
388 SVGA3dSamplerId samplers[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
389
390 unsigned num_sampler_views[PIPE_SHADER_TYPES];
391 struct pipe_sampler_view
392 *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
393
394 unsigned num_rendertargets;
395 struct pipe_surface *rtv[SVGA3D_MAX_RENDER_TARGETS];
396 struct pipe_surface *dsv;
397
398 /* used for rebinding */
399 unsigned default_constbuf_size[PIPE_SHADER_TYPES];
400 };
401
402
403 /* Updated by calling svga_update_state( SVGA_STATE_NEED_SWTNL )
404 */
405 struct svga_sw_state
406 {
407 /* which parts we need */
408 boolean need_swvfetch;
409 boolean need_pipeline;
410 boolean need_swtnl;
411
412 /* Flag to make sure that need sw is on while
413 * updating state within a swtnl call.
414 */
415 boolean in_swtnl_draw;
416 };
417
418
419 /* Queue some state updates (like rss) and submit them to hardware in
420 * a single packet.
421 */
422 struct svga_hw_queue;
423
424 struct svga_query;
425 struct svga_qmem_alloc_entry;
426
427 struct svga_context
428 {
429 struct pipe_context pipe;
430 struct svga_winsys_context *swc;
431 struct blitter_context *blitter;
432 struct u_upload_mgr *const0_upload;
433
434 struct {
435 boolean no_swtnl;
436 boolean force_swtnl;
437 boolean use_min_mipmap;
438
439 /* incremented for each shader */
440 unsigned shader_id;
441
442 unsigned disable_shader;
443
444 boolean no_line_width;
445 boolean force_hw_line_stipple;
446
447 /** To report perf/conformance/etc issues to the state tracker */
448 struct pipe_debug_callback callback;
449 } debug;
450
451 struct {
452 struct draw_context *draw;
453 struct vbuf_render *backend;
454 unsigned hw_prim;
455 boolean new_vbuf;
456 boolean new_vdecl;
457 } swtnl;
458
459 /* Bitmask of blend state objects IDs */
460 struct util_bitmask *blend_object_id_bm;
461
462 /* Bitmask of depth/stencil state objects IDs */
463 struct util_bitmask *ds_object_id_bm;
464
465 /* Bitmaks of input element object IDs */
466 struct util_bitmask *input_element_object_id_bm;
467
468 /* Bitmask of rasterizer object IDs */
469 struct util_bitmask *rast_object_id_bm;
470
471 /* Bitmask of sampler state objects IDs */
472 struct util_bitmask *sampler_object_id_bm;
473
474 /* Bitmask of sampler view IDs */
475 struct util_bitmask *sampler_view_id_bm;
476
477 /* Bitmask of used shader IDs */
478 struct util_bitmask *shader_id_bm;
479
480 /* Bitmask of used surface view IDs */
481 struct util_bitmask *surface_view_id_bm;
482
483 /* Bitmask of used stream output IDs */
484 struct util_bitmask *stream_output_id_bm;
485
486 /* Bitmask of used query IDs */
487 struct util_bitmask *query_id_bm;
488
489 struct {
490 unsigned dirty[SVGA_STATE_MAX];
491
492 /** bitmasks of which const buffers are changed */
493 unsigned dirty_constbufs[PIPE_SHADER_TYPES];
494
495 unsigned texture_timestamp;
496
497 /*
498 */
499 struct svga_sw_state sw;
500 struct svga_hw_draw_state hw_draw;
501 struct svga_hw_clear_state hw_clear;
502 } state;
503
504 struct svga_state curr; /* state from the state tracker */
505 unsigned dirty; /* statechanges since last update_state() */
506
507 union {
508 struct {
509 unsigned rendertargets:1;
510 unsigned texture_samplers:1;
511 unsigned constbufs:1;
512 unsigned vs:1;
513 unsigned fs:1;
514 unsigned gs:1;
515 unsigned query:1;
516 } flags;
517 unsigned val;
518 } rebind;
519
520 struct svga_hwtnl *hwtnl;
521
522 /** Queries states */
523 struct svga_winsys_gb_query *gb_query; /**< gb query object, one per context */
524 unsigned gb_query_len; /**< gb query object size */
525 struct util_bitmask *gb_query_alloc_mask; /**< gb query object allocation mask */
526 struct svga_qmem_alloc_entry *gb_query_map[SVGA_QUERY_MAX];
527 /**< query mem block mapping */
528 struct svga_query *sq[SVGA_QUERY_MAX]; /**< queries currently in progress */
529
530 /** List of buffers with queued transfers */
531 struct list_head dirty_buffers;
532
533 /** performance / info queries for HUD */
534 struct {
535 uint64_t num_draw_calls; /**< SVGA_QUERY_DRAW_CALLS */
536 uint64_t num_fallbacks; /**< SVGA_QUERY_NUM_FALLBACKS */
537 uint64_t num_flushes; /**< SVGA_QUERY_NUM_FLUSHES */
538 uint64_t num_validations; /**< SVGA_QUERY_NUM_VALIDATIONS */
539 uint64_t map_buffer_time; /**< SVGA_QUERY_MAP_BUFFER_TIME */
540 uint64_t num_resources_mapped; /**< SVGA_QUERY_NUM_RESOURCES_MAPPED */
541 uint64_t command_buffer_size; /**< SVGA_QUERY_COMMAND_BUFFER_SIZE */
542 uint64_t flush_time; /**< SVGA_QUERY_FLUSH_TIME */
543 uint64_t surface_write_flushes; /**< SVGA_QUERY_SURFACE_WRITE_FLUSHES */
544 uint64_t num_readbacks; /**< SVGA_QUERY_NUM_READBACKS */
545 uint64_t num_resource_updates; /**< SVGA_QUERY_NUM_RESOURCE_UPDATES */
546 uint64_t num_buffer_uploads; /**< SVGA_QUERY_NUM_BUFFER_UPLOADS */
547 uint64_t num_const_buf_updates; /**< SVGA_QUERY_NUM_CONST_BUF_UPDATES */
548 uint64_t num_const_updates; /**< SVGA_QUERY_NUM_CONST_UPDATES */
549 uint64_t num_shaders; /**< SVGA_QUERY_NUM_SHADERS */
550
551 /** The following are summed for SVGA_QUERY_NUM_STATE_OBJECTS */
552 uint64_t num_blend_objects;
553 uint64_t num_depthstencil_objects;
554 uint64_t num_rasterizer_objects;
555 uint64_t num_sampler_objects;
556 uint64_t num_samplerview_objects;
557 uint64_t num_vertexelement_objects;
558
559 uint64_t num_surface_views; /**< SVGA_QUERY_NUM_SURFACE_VIEWS */
560 uint64_t num_bytes_uploaded; /**< SVGA_QUERY_NUM_BYTES_UPLOADED */
561 uint64_t num_generate_mipmap; /**< SVGA_QUERY_NUM_GENERATE_MIPMAP */
562
563 boolean uses_time; /**< os_time_get() calls needed? */
564 } hud;
565
566 /** The currently bound stream output targets */
567 unsigned num_so_targets;
568 struct svga_winsys_surface *so_surfaces[SVGA3D_DX_MAX_SOTARGETS];
569 struct pipe_stream_output_target *so_targets[SVGA3D_DX_MAX_SOTARGETS];
570 struct svga_stream_output *current_so;
571
572 /** A blend state with blending disabled, for falling back to when blending
573 * is illegal (e.g. an integer texture is bound)
574 */
575 struct svga_blend_state *noop_blend;
576
577 struct {
578 struct pipe_resource *texture;
579 struct svga_pipe_sampler_view *sampler_view;
580 void *sampler;
581 } polygon_stipple;
582
583 /** Alternate rasterizer states created for point sprite */
584 struct svga_rasterizer_state *rasterizer_no_cull[2];
585 };
586
587 /* A flag for each state_tracker state object:
588 */
589 #define SVGA_NEW_BLEND 0x1
590 #define SVGA_NEW_DEPTH_STENCIL_ALPHA 0x2
591 #define SVGA_NEW_RAST 0x4
592 #define SVGA_NEW_SAMPLER 0x8
593 #define SVGA_NEW_TEXTURE 0x10
594 #define SVGA_NEW_VBUFFER 0x20
595 #define SVGA_NEW_VELEMENT 0x40
596 #define SVGA_NEW_FS 0x80
597 #define SVGA_NEW_VS 0x100
598 #define SVGA_NEW_FS_CONST_BUFFER 0x200
599 #define SVGA_NEW_VS_CONST_BUFFER 0x400
600 #define SVGA_NEW_FRAME_BUFFER 0x800
601 #define SVGA_NEW_STIPPLE 0x1000
602 #define SVGA_NEW_SCISSOR 0x2000
603 #define SVGA_NEW_BLEND_COLOR 0x4000
604 #define SVGA_NEW_CLIP 0x8000
605 #define SVGA_NEW_VIEWPORT 0x10000
606 #define SVGA_NEW_PRESCALE 0x20000
607 #define SVGA_NEW_REDUCED_PRIMITIVE 0x40000
608 #define SVGA_NEW_TEXTURE_BINDING 0x80000
609 #define SVGA_NEW_NEED_PIPELINE 0x100000
610 #define SVGA_NEW_NEED_SWVFETCH 0x200000
611 #define SVGA_NEW_NEED_SWTNL 0x400000
612 #define SVGA_NEW_FS_VARIANT 0x800000
613 #define SVGA_NEW_VS_VARIANT 0x1000000
614 #define SVGA_NEW_TEXTURE_FLAGS 0x4000000
615 #define SVGA_NEW_STENCIL_REF 0x8000000
616 #define SVGA_NEW_GS 0x10000000
617 #define SVGA_NEW_GS_CONST_BUFFER 0x20000000
618 #define SVGA_NEW_GS_VARIANT 0x40000000
619 #define SVGA_NEW_TEXTURE_CONSTS 0x80000000
620
621
622
623
624
625 /***********************************************************************
626 * svga_screen_texture.c:
627 */
628 void svga_mark_surfaces_dirty(struct svga_context *svga);
629
630
631
632
633 void svga_init_state_functions( struct svga_context *svga );
634 void svga_init_flush_functions( struct svga_context *svga );
635 void svga_init_string_functions( struct svga_context *svga );
636 void svga_init_blit_functions(struct svga_context *svga);
637
638 void svga_init_blend_functions( struct svga_context *svga );
639 void svga_init_depth_stencil_functions( struct svga_context *svga );
640 void svga_init_misc_functions( struct svga_context *svga );
641 void svga_init_rasterizer_functions( struct svga_context *svga );
642 void svga_init_sampler_functions( struct svga_context *svga );
643 void svga_init_fs_functions( struct svga_context *svga );
644 void svga_init_vs_functions( struct svga_context *svga );
645 void svga_init_gs_functions( struct svga_context *svga );
646 void svga_init_vertex_functions( struct svga_context *svga );
647 void svga_init_constbuffer_functions( struct svga_context *svga );
648 void svga_init_draw_functions( struct svga_context *svga );
649 void svga_init_query_functions( struct svga_context *svga );
650 void svga_init_surface_functions(struct svga_context *svga);
651 void svga_init_stream_output_functions( struct svga_context *svga );
652 void svga_init_clear_functions( struct svga_context *svga );
653
654 void svga_cleanup_vertex_state( struct svga_context *svga );
655 void svga_cleanup_sampler_state( struct svga_context *svga );
656 void svga_cleanup_tss_binding( struct svga_context *svga );
657 void svga_cleanup_framebuffer( struct svga_context *svga );
658
659 void svga_context_flush( struct svga_context *svga,
660 struct pipe_fence_handle **pfence );
661
662 void svga_context_finish(struct svga_context *svga);
663
664 void svga_hwtnl_flush_retry( struct svga_context *svga );
665 void svga_hwtnl_flush_buffer( struct svga_context *svga,
666 struct pipe_resource *buffer );
667
668 void svga_surfaces_flush(struct svga_context *svga);
669
670 struct pipe_context *
671 svga_context_create(struct pipe_screen *screen,
672 void *priv, unsigned flags);
673
674
675 /***********************************************************************
676 * Inline conversion functions. These are better-typed than the
677 * macros used previously:
678 */
679 static inline struct svga_context *
680 svga_context( struct pipe_context *pipe )
681 {
682 return (struct svga_context *)pipe;
683 }
684
685 static inline struct svga_winsys_screen *
686 svga_sws(struct svga_context *svga)
687 {
688 return svga_screen(svga->pipe.screen)->sws;
689 }
690
691 static inline boolean
692 svga_have_gb_objects(const struct svga_context *svga)
693 {
694 return svga_screen(svga->pipe.screen)->sws->have_gb_objects;
695 }
696
697 static inline boolean
698 svga_have_gb_dma(const struct svga_context *svga)
699 {
700 return svga_screen(svga->pipe.screen)->sws->have_gb_dma;
701 }
702
703 static inline boolean
704 svga_have_vgpu10(const struct svga_context *svga)
705 {
706 return svga_screen(svga->pipe.screen)->sws->have_vgpu10;
707 }
708
709 static inline boolean
710 svga_need_to_rebind_resources(const struct svga_context *svga)
711 {
712 return svga_screen(svga->pipe.screen)->sws->need_to_rebind_resources;
713 }
714
715 static inline boolean
716 svga_rects_equal(const SVGA3dRect *r1, const SVGA3dRect *r2)
717 {
718 return memcmp(r1, r2, sizeof(*r1)) == 0;
719 }
720
721 /**
722 * If the Gallium HUD is enabled, this will return the current time.
723 * Otherwise, just return zero.
724 */
725 static inline int64_t
726 svga_get_time(struct svga_context *svga)
727 {
728 return svga->hud.uses_time ? os_time_get() : 0;
729 }
730
731
732 #endif