2 * Mesa 3-D graphics library
4 * Copyright (C) 2012-2013 LunarG, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
25 * Chia-I Wu <olv@lunarg.com>
28 #include "util/u_prim.h"
29 #include "intel_winsys.h"
31 #include "ilo_3d_pipeline.h"
33 #include "ilo_context.h"
35 #include "ilo_query.h"
36 #include "ilo_shader.h"
37 #include "ilo_state.h"
41 process_query_for_occlusion_counter(struct ilo_3d
*hw3d
,
44 uint64_t *vals
, depth_count
= 0;
48 assert(q
->reg_read
% 2 == 0);
50 vals
= intel_bo_map(q
->bo
, false);
51 for (i
= 1; i
< q
->reg_read
; i
+= 2)
52 depth_count
+= vals
[i
] - vals
[i
- 1];
53 intel_bo_unmap(q
->bo
);
55 /* accumulate so that the query can be resumed if wanted */
56 q
->data
.u64
+= depth_count
;
61 timestamp_to_ns(uint64_t timestamp
)
63 /* see ilo_get_timestamp() */
64 return (timestamp
& 0xffffffff) * 80;
68 process_query_for_timestamp(struct ilo_3d
*hw3d
, struct ilo_query
*q
)
70 uint64_t *vals
, timestamp
;
72 assert(q
->reg_read
== 1);
74 vals
= intel_bo_map(q
->bo
, false);
76 intel_bo_unmap(q
->bo
);
78 q
->data
.u64
= timestamp_to_ns(timestamp
);
83 process_query_for_time_elapsed(struct ilo_3d
*hw3d
, struct ilo_query
*q
)
85 uint64_t *vals
, elapsed
= 0;
89 assert(q
->reg_read
% 2 == 0);
91 vals
= intel_bo_map(q
->bo
, false);
93 for (i
= 1; i
< q
->reg_read
; i
+= 2)
94 elapsed
+= vals
[i
] - vals
[i
- 1];
96 intel_bo_unmap(q
->bo
);
98 /* accumulate so that the query can be resumed if wanted */
99 q
->data
.u64
+= timestamp_to_ns(elapsed
);
104 process_query_for_pipeline_statistics(struct ilo_3d
*hw3d
,
107 const uint64_t *vals
;
110 assert(q
->reg_read
% 22 == 0);
112 vals
= intel_bo_map(q
->bo
, false);
114 for (i
= 0; i
< q
->reg_read
; i
+= 22) {
115 struct pipe_query_data_pipeline_statistics
*stats
=
116 &q
->data
.pipeline_statistics
;
117 const uint64_t *begin
= vals
+ i
;
118 const uint64_t *end
= begin
+ 11;
120 stats
->ia_vertices
+= end
[0] - begin
[0];
121 stats
->ia_primitives
+= end
[1] - begin
[1];
122 stats
->vs_invocations
+= end
[2] - begin
[2];
123 stats
->gs_invocations
+= end
[3] - begin
[3];
124 stats
->gs_primitives
+= end
[4] - begin
[4];
125 stats
->c_invocations
+= end
[5] - begin
[5];
126 stats
->c_primitives
+= end
[6] - begin
[6];
127 stats
->ps_invocations
+= end
[7] - begin
[7];
128 stats
->hs_invocations
+= end
[8] - begin
[8];
129 stats
->ds_invocations
+= end
[9] - begin
[9];
130 stats
->cs_invocations
+= end
[10] - begin
[10];
133 intel_bo_unmap(q
->bo
);
139 ilo_3d_resume_queries(struct ilo_3d
*hw3d
)
143 /* resume occlusion queries */
144 LIST_FOR_EACH_ENTRY(q
, &hw3d
->occlusion_queries
, list
) {
145 /* accumulate the result if the bo is alreay full */
146 if (q
->reg_read
>= q
->reg_total
)
147 process_query_for_occlusion_counter(hw3d
, q
);
149 ilo_3d_pipeline_emit_write_depth_count(hw3d
->pipeline
,
150 q
->bo
, q
->reg_read
++);
153 /* resume timer queries */
154 LIST_FOR_EACH_ENTRY(q
, &hw3d
->time_elapsed_queries
, list
) {
155 /* accumulate the result if the bo is alreay full */
156 if (q
->reg_read
>= q
->reg_total
)
157 process_query_for_time_elapsed(hw3d
, q
);
159 ilo_3d_pipeline_emit_write_timestamp(hw3d
->pipeline
,
160 q
->bo
, q
->reg_read
++);
163 /* resume pipeline statistics queries */
164 LIST_FOR_EACH_ENTRY(q
, &hw3d
->pipeline_statistics_queries
, list
) {
165 /* accumulate the result if the bo is alreay full */
166 if (q
->reg_read
>= q
->reg_total
)
167 process_query_for_pipeline_statistics(hw3d
, q
);
169 ilo_3d_pipeline_emit_write_statistics(hw3d
->pipeline
,
176 ilo_3d_pause_queries(struct ilo_3d
*hw3d
)
180 /* pause occlusion queries */
181 LIST_FOR_EACH_ENTRY(q
, &hw3d
->occlusion_queries
, list
) {
182 assert(q
->reg_read
< q
->reg_total
);
183 ilo_3d_pipeline_emit_write_depth_count(hw3d
->pipeline
,
184 q
->bo
, q
->reg_read
++);
187 /* pause timer queries */
188 LIST_FOR_EACH_ENTRY(q
, &hw3d
->time_elapsed_queries
, list
) {
189 assert(q
->reg_read
< q
->reg_total
);
190 ilo_3d_pipeline_emit_write_timestamp(hw3d
->pipeline
,
191 q
->bo
, q
->reg_read
++);
194 /* pause pipeline statistics queries */
195 LIST_FOR_EACH_ENTRY(q
, &hw3d
->pipeline_statistics_queries
, list
) {
196 assert(q
->reg_read
< q
->reg_total
);
197 ilo_3d_pipeline_emit_write_statistics(hw3d
->pipeline
,
204 ilo_3d_release_render_ring(struct ilo_cp
*cp
, void *data
)
206 struct ilo_3d
*hw3d
= data
;
208 ilo_3d_pause_queries(hw3d
);
212 ilo_3d_own_render_ring(struct ilo_3d
*hw3d
)
214 ilo_cp_set_ring(hw3d
->cp
, INTEL_RING_RENDER
);
216 if (ilo_cp_set_owner(hw3d
->cp
, &hw3d
->owner
, hw3d
->owner_reserve
))
217 ilo_3d_resume_queries(hw3d
);
224 ilo_3d_begin_query(struct ilo_context
*ilo
, struct ilo_query
*q
)
226 struct ilo_3d
*hw3d
= ilo
->hw3d
;
228 ilo_3d_own_render_ring(hw3d
);
231 case PIPE_QUERY_OCCLUSION_COUNTER
:
232 /* reserve some space for pausing the query */
233 q
->reg_cmd_size
= ilo_3d_pipeline_estimate_size(hw3d
->pipeline
,
234 ILO_3D_PIPELINE_WRITE_DEPTH_COUNT
, NULL
);
235 hw3d
->owner_reserve
+= q
->reg_cmd_size
;
236 ilo_cp_set_owner(hw3d
->cp
, &hw3d
->owner
, hw3d
->owner_reserve
);
240 if (ilo_query_alloc_bo(q
, 2, -1, hw3d
->cp
->winsys
)) {
241 /* XXX we should check the aperture size */
242 if (q
->reg_cmd_size
> ilo_cp_space(hw3d
->cp
)) {
243 ilo_cp_flush(hw3d
->cp
, "out of space");
244 assert(q
->reg_cmd_size
<= ilo_cp_space(hw3d
->cp
));
247 ilo_3d_pipeline_emit_write_depth_count(hw3d
->pipeline
,
248 q
->bo
, q
->reg_read
++);
250 list_add(&q
->list
, &hw3d
->occlusion_queries
);
253 case PIPE_QUERY_TIMESTAMP
:
256 case PIPE_QUERY_TIME_ELAPSED
:
257 /* reserve some space for pausing the query */
258 q
->reg_cmd_size
= ilo_3d_pipeline_estimate_size(hw3d
->pipeline
,
259 ILO_3D_PIPELINE_WRITE_TIMESTAMP
, NULL
);
260 hw3d
->owner_reserve
+= q
->reg_cmd_size
;
261 ilo_cp_set_owner(hw3d
->cp
, &hw3d
->owner
, hw3d
->owner_reserve
);
265 if (ilo_query_alloc_bo(q
, 2, -1, hw3d
->cp
->winsys
)) {
266 /* XXX we should check the aperture size */
267 if (q
->reg_cmd_size
> ilo_cp_space(hw3d
->cp
)) {
268 ilo_cp_flush(hw3d
->cp
, "out of space");
269 assert(q
->reg_cmd_size
<= ilo_cp_space(hw3d
->cp
));
272 ilo_3d_pipeline_emit_write_timestamp(hw3d
->pipeline
,
273 q
->bo
, q
->reg_read
++);
275 list_add(&q
->list
, &hw3d
->time_elapsed_queries
);
278 case PIPE_QUERY_PRIMITIVES_GENERATED
:
280 list_add(&q
->list
, &hw3d
->prim_generated_queries
);
282 case PIPE_QUERY_PRIMITIVES_EMITTED
:
284 list_add(&q
->list
, &hw3d
->prim_emitted_queries
);
286 case PIPE_QUERY_PIPELINE_STATISTICS
:
287 /* reserve some space for pausing the query */
288 q
->reg_cmd_size
= ilo_3d_pipeline_estimate_size(hw3d
->pipeline
,
289 ILO_3D_PIPELINE_WRITE_STATISTICS
, NULL
);
290 hw3d
->owner_reserve
+= q
->reg_cmd_size
;
291 ilo_cp_set_owner(hw3d
->cp
, &hw3d
->owner
, hw3d
->owner_reserve
);
293 memset(&q
->data
.pipeline_statistics
, 0,
294 sizeof(q
->data
.pipeline_statistics
));
296 if (ilo_query_alloc_bo(q
, 11 * 2, -1, hw3d
->cp
->winsys
)) {
297 /* XXX we should check the aperture size */
298 if (q
->reg_cmd_size
> ilo_cp_space(hw3d
->cp
)) {
299 ilo_cp_flush(hw3d
->cp
, "out of space");
300 assert(q
->reg_cmd_size
<= ilo_cp_space(hw3d
->cp
));
303 ilo_3d_pipeline_emit_write_statistics(hw3d
->pipeline
,
307 list_add(&q
->list
, &hw3d
->pipeline_statistics_queries
);
311 assert(!"unknown query type");
320 ilo_3d_end_query(struct ilo_context
*ilo
, struct ilo_query
*q
)
322 struct ilo_3d
*hw3d
= ilo
->hw3d
;
324 ilo_3d_own_render_ring(hw3d
);
327 case PIPE_QUERY_OCCLUSION_COUNTER
:
330 assert(q
->reg_read
< q
->reg_total
);
331 hw3d
->owner_reserve
-= q
->reg_cmd_size
;
332 ilo_cp_set_owner(hw3d
->cp
, &hw3d
->owner
, hw3d
->owner_reserve
);
333 ilo_3d_pipeline_emit_write_depth_count(hw3d
->pipeline
,
334 q
->bo
, q
->reg_read
++);
336 case PIPE_QUERY_TIMESTAMP
:
339 if (ilo_query_alloc_bo(q
, 1, 1, hw3d
->cp
->winsys
)) {
340 ilo_3d_pipeline_emit_write_timestamp(hw3d
->pipeline
,
341 q
->bo
, q
->reg_read
++);
344 case PIPE_QUERY_TIME_ELAPSED
:
347 assert(q
->reg_read
< q
->reg_total
);
348 hw3d
->owner_reserve
-= q
->reg_cmd_size
;
349 ilo_cp_set_owner(hw3d
->cp
, &hw3d
->owner
, hw3d
->owner_reserve
);
350 ilo_3d_pipeline_emit_write_timestamp(hw3d
->pipeline
,
351 q
->bo
, q
->reg_read
++);
353 case PIPE_QUERY_PRIMITIVES_GENERATED
:
354 case PIPE_QUERY_PRIMITIVES_EMITTED
:
357 case PIPE_QUERY_PIPELINE_STATISTICS
:
360 assert(q
->reg_read
+ 11 <= q
->reg_total
);
361 hw3d
->owner_reserve
-= q
->reg_cmd_size
;
362 ilo_cp_set_owner(hw3d
->cp
, &hw3d
->owner
, hw3d
->owner_reserve
);
363 ilo_3d_pipeline_emit_write_statistics(hw3d
->pipeline
,
368 assert(!"unknown query type");
374 * Process the raw query data.
377 ilo_3d_process_query(struct ilo_context
*ilo
, struct ilo_query
*q
)
379 struct ilo_3d
*hw3d
= ilo
->hw3d
;
382 case PIPE_QUERY_OCCLUSION_COUNTER
:
384 process_query_for_occlusion_counter(hw3d
, q
);
386 case PIPE_QUERY_TIMESTAMP
:
388 process_query_for_timestamp(hw3d
, q
);
390 case PIPE_QUERY_TIME_ELAPSED
:
392 process_query_for_time_elapsed(hw3d
, q
);
394 case PIPE_QUERY_PRIMITIVES_GENERATED
:
395 case PIPE_QUERY_PRIMITIVES_EMITTED
:
397 case PIPE_QUERY_PIPELINE_STATISTICS
:
399 process_query_for_pipeline_statistics(hw3d
, q
);
402 assert(!"unknown query type");
408 * Hook for CP new-batch.
411 ilo_3d_cp_flushed(struct ilo_3d
*hw3d
)
413 if (ilo_debug
& ILO_DEBUG_3D
)
414 ilo_builder_decode(&hw3d
->cp
->builder
);
416 /* invalidate the pipeline */
417 ilo_3d_pipeline_invalidate(hw3d
->pipeline
,
418 ILO_3D_PIPELINE_INVALIDATE_BATCH_BO
|
419 ILO_3D_PIPELINE_INVALIDATE_STATE_BO
|
420 ILO_3D_PIPELINE_INVALIDATE_KERNEL_BO
);
422 hw3d
->new_batch
= true;
426 * Create a 3D context.
429 ilo_3d_create(struct ilo_cp
*cp
, const struct ilo_dev_info
*dev
)
433 hw3d
= CALLOC_STRUCT(ilo_3d
);
438 hw3d
->owner
.release_callback
= ilo_3d_release_render_ring
;
439 hw3d
->owner
.release_data
= hw3d
;
441 hw3d
->new_batch
= true;
443 list_inithead(&hw3d
->occlusion_queries
);
444 list_inithead(&hw3d
->time_elapsed_queries
);
445 list_inithead(&hw3d
->prim_generated_queries
);
446 list_inithead(&hw3d
->prim_emitted_queries
);
447 list_inithead(&hw3d
->pipeline_statistics_queries
);
449 hw3d
->pipeline
= ilo_3d_pipeline_create(cp
, dev
);
450 if (!hw3d
->pipeline
) {
459 * Destroy a 3D context.
462 ilo_3d_destroy(struct ilo_3d
*hw3d
)
464 ilo_3d_pipeline_destroy(hw3d
->pipeline
);
469 draw_vbo(struct ilo_3d
*hw3d
, const struct ilo_context
*ilo
,
470 int *prim_generated
, int *prim_emitted
)
472 bool need_flush
= false;
475 ilo_3d_own_render_ring(hw3d
);
477 if (!hw3d
->new_batch
) {
479 * Without a better tracking mechanism, when the framebuffer changes, we
480 * have to assume that the old framebuffer may be sampled from. If that
481 * happens in the middle of a batch buffer, we need to insert manual
484 need_flush
= (ilo
->dirty
& ILO_DIRTY_FB
);
486 /* same to SO target changes */
487 need_flush
|= (ilo
->dirty
& ILO_DIRTY_SO
);
490 /* make sure there is enough room first */
491 max_len
= ilo_3d_pipeline_estimate_size(hw3d
->pipeline
,
492 ILO_3D_PIPELINE_DRAW
, ilo
);
494 max_len
+= ilo_3d_pipeline_estimate_size(hw3d
->pipeline
,
495 ILO_3D_PIPELINE_FLUSH
, NULL
);
498 if (max_len
> ilo_cp_space(hw3d
->cp
)) {
499 ilo_cp_flush(hw3d
->cp
, "out of space");
501 assert(max_len
<= ilo_cp_space(hw3d
->cp
));
505 ilo_3d_pipeline_emit_flush(hw3d
->pipeline
);
507 return ilo_3d_pipeline_emit_draw(hw3d
->pipeline
, ilo
,
508 prim_generated
, prim_emitted
);
512 update_prim_count(struct ilo_3d
*hw3d
, int generated
, int emitted
)
516 LIST_FOR_EACH_ENTRY(q
, &hw3d
->prim_generated_queries
, list
)
517 q
->data
.u64
+= generated
;
519 LIST_FOR_EACH_ENTRY(q
, &hw3d
->prim_emitted_queries
, list
)
520 q
->data
.u64
+= emitted
;
524 ilo_3d_pass_render_condition(struct ilo_context
*ilo
)
526 struct ilo_3d
*hw3d
= ilo
->hw3d
;
530 if (!hw3d
->render_condition
.query
)
533 switch (hw3d
->render_condition
.mode
) {
534 case PIPE_RENDER_COND_WAIT
:
535 case PIPE_RENDER_COND_BY_REGION_WAIT
:
538 case PIPE_RENDER_COND_NO_WAIT
:
539 case PIPE_RENDER_COND_BY_REGION_NO_WAIT
:
545 if (ilo
->base
.get_query_result(&ilo
->base
, hw3d
->render_condition
.query
,
546 wait
, (union pipe_query_result
*) &result
))
547 return (!result
== hw3d
->render_condition
.cond
);
552 #define UPDATE_MIN2(a, b) (a) = MIN2((a), (b))
553 #define UPDATE_MAX2(a, b) (a) = MAX2((a), (b))
556 * \see find_sub_primitives() from core mesa
559 ilo_find_sub_primitives(const void *elements
, unsigned element_size
,
560 const struct pipe_draw_info
*orig_info
,
561 struct pipe_draw_info
*info
)
563 const unsigned max_prims
= orig_info
->count
- orig_info
->start
;
564 unsigned i
, cur_start
, cur_count
;
568 cur_start
= orig_info
->start
;
572 #define IB_INDEX_READ(TYPE, INDEX) (((const TYPE *) elements)[INDEX])
574 #define SCAN_ELEMENTS(TYPE) \
575 info[scan_num] = *orig_info; \
576 info[scan_num].primitive_restart = false; \
577 for (i = orig_info->start; i < orig_info->count; i++) { \
578 scan_index = IB_INDEX_READ(TYPE, i); \
579 if (scan_index == orig_info->restart_index) { \
580 if (cur_count > 0) { \
581 assert(scan_num < max_prims); \
582 info[scan_num].start = cur_start; \
583 info[scan_num].count = cur_count; \
585 info[scan_num] = *orig_info; \
586 info[scan_num].primitive_restart = false; \
592 UPDATE_MIN2(info[scan_num].min_index, scan_index); \
593 UPDATE_MAX2(info[scan_num].max_index, scan_index); \
597 if (cur_count > 0) { \
598 assert(scan_num < max_prims); \
599 info[scan_num].start = cur_start; \
600 info[scan_num].count = cur_count; \
604 switch (element_size
) {
606 SCAN_ELEMENTS(uint8_t);
609 SCAN_ELEMENTS(uint16_t);
612 SCAN_ELEMENTS(uint32_t);
615 assert(0 && "bad index_size in find_sub_primitives()");
624 ilo_check_restart_index(const struct ilo_context
*ilo
, unsigned restart_index
)
627 * Haswell (GEN(7.5)) supports an arbitrary cut index, check everything
630 if (ilo_dev_gen(ilo
->dev
) >= ILO_GEN(7.5))
633 /* Note: indices must be unsigned byte, unsigned short or unsigned int */
634 switch (ilo
->ib
.index_size
) {
636 return ((restart_index
& 0xff) == 0xff);
639 return ((restart_index
& 0xffff) == 0xffff);
642 return (restart_index
== 0xffffffff);
649 ilo_check_restart_prim_type(const struct ilo_context
*ilo
, unsigned prim
)
652 case PIPE_PRIM_POINTS
:
653 case PIPE_PRIM_LINES
:
654 case PIPE_PRIM_LINE_STRIP
:
655 case PIPE_PRIM_TRIANGLES
:
656 case PIPE_PRIM_TRIANGLE_STRIP
:
657 /* All 965 GEN graphics support a cut index for these primitive types */
661 case PIPE_PRIM_LINE_LOOP
:
662 case PIPE_PRIM_POLYGON
:
663 case PIPE_PRIM_QUAD_STRIP
:
664 case PIPE_PRIM_QUADS
:
665 case PIPE_PRIM_TRIANGLE_FAN
:
666 if (ilo_dev_gen(ilo
->dev
) >= ILO_GEN(7.5)) {
667 /* Haswell and newer parts can handle these prim types. */
677 * Handle VBOs using primitive restart.
678 * Verify that restart index and primitive type can be handled by the HW.
679 * Return true if this routine did the rendering
680 * Return false if this routine did NOT render because restart can be handled
684 ilo_draw_vbo_with_sw_restart(struct pipe_context
*pipe
,
685 const struct pipe_draw_info
*info
)
687 struct ilo_context
*ilo
= ilo_context(pipe
);
688 struct pipe_draw_info
*restart_info
= NULL
;
689 int sub_prim_count
= 1;
692 * We have to break up the primitive into chunks manually
693 * Worst case, every other index could be a restart index so
694 * need to have space for that many primitives
696 restart_info
= MALLOC(((info
->count
+ 1) / 2) * sizeof(*info
));
697 if (NULL
== restart_info
) {
698 /* If we can't get memory for this, bail out */
699 ilo_err("%s:%d - Out of memory", __FILE__
, __LINE__
);
703 if (ilo
->ib
.buffer
) {
704 struct pipe_transfer
*transfer
;
707 map
= pipe_buffer_map(pipe
, ilo
->ib
.buffer
,
708 PIPE_TRANSFER_READ
, &transfer
);
710 sub_prim_count
= ilo_find_sub_primitives(map
+ ilo
->ib
.offset
,
711 ilo
->ib
.index_size
, info
, restart_info
);
713 pipe_buffer_unmap(pipe
, transfer
);
716 sub_prim_count
= ilo_find_sub_primitives(ilo
->ib
.user_buffer
,
717 ilo
->ib
.index_size
, info
, restart_info
);
722 while (sub_prim_count
> 0) {
723 pipe
->draw_vbo(pipe
, info
);
733 ilo_draw_vbo(struct pipe_context
*pipe
, const struct pipe_draw_info
*info
)
735 struct ilo_context
*ilo
= ilo_context(pipe
);
736 struct ilo_3d
*hw3d
= ilo
->hw3d
;
737 int prim_generated
, prim_emitted
;
739 if (ilo_debug
& ILO_DEBUG_DRAW
) {
741 ilo_printf("indexed draw %s: "
742 "index start %d, count %d, vertex range [%d, %d]\n",
743 u_prim_name(info
->mode
), info
->start
, info
->count
,
744 info
->min_index
, info
->max_index
);
747 ilo_printf("draw %s: vertex start %d, count %d\n",
748 u_prim_name(info
->mode
), info
->start
, info
->count
);
751 ilo_dump_dirty_flags(ilo
->dirty
);
754 if (!ilo_3d_pass_render_condition(ilo
))
757 if (info
->primitive_restart
&& info
->indexed
) {
759 * Want to draw an indexed primitive using primitive restart
760 * Check that HW can handle the request and fall to SW if not.
762 if (!ilo_check_restart_index(ilo
, info
->restart_index
) ||
763 !ilo_check_restart_prim_type(ilo
, info
->mode
)) {
764 ilo_draw_vbo_with_sw_restart(pipe
, info
);
769 ilo_finalize_3d_states(ilo
, info
);
771 ilo_shader_cache_upload(ilo
->shader_cache
, &hw3d
->cp
->builder
);
773 ilo_blit_resolve_framebuffer(ilo
);
775 /* If draw_vbo ever fails, return immediately. */
776 if (!draw_vbo(hw3d
, ilo
, &prim_generated
, &prim_emitted
))
779 /* clear dirty status */
781 hw3d
->new_batch
= false;
783 /* avoid dangling pointer reference */
786 update_prim_count(hw3d
, prim_generated
, prim_emitted
);
788 if (ilo_debug
& ILO_DEBUG_NOCACHE
)
789 ilo_3d_pipeline_emit_flush(hw3d
->pipeline
);
793 ilo_render_condition(struct pipe_context
*pipe
,
794 struct pipe_query
*query
,
798 struct ilo_context
*ilo
= ilo_context(pipe
);
799 struct ilo_3d
*hw3d
= ilo
->hw3d
;
801 /* reference count? */
802 hw3d
->render_condition
.query
= query
;
803 hw3d
->render_condition
.mode
= mode
;
804 hw3d
->render_condition
.cond
= condition
;
808 ilo_texture_barrier(struct pipe_context
*pipe
)
810 struct ilo_context
*ilo
= ilo_context(pipe
);
811 struct ilo_3d
*hw3d
= ilo
->hw3d
;
813 if (ilo
->cp
->ring
!= INTEL_RING_RENDER
)
816 ilo_3d_pipeline_emit_flush(hw3d
->pipeline
);
819 if (ilo_dev_gen(ilo
->dev
) >= ILO_GEN(7))
820 ilo_cp_flush(hw3d
->cp
, "texture barrier");
824 ilo_get_sample_position(struct pipe_context
*pipe
,
825 unsigned sample_count
,
826 unsigned sample_index
,
829 struct ilo_context
*ilo
= ilo_context(pipe
);
830 struct ilo_3d
*hw3d
= ilo
->hw3d
;
832 ilo_3d_pipeline_get_sample_position(hw3d
->pipeline
,
833 sample_count
, sample_index
,
834 &out_value
[0], &out_value
[1]);
838 * Initialize 3D-related functions.
841 ilo_init_3d_functions(struct ilo_context
*ilo
)
843 ilo
->base
.draw_vbo
= ilo_draw_vbo
;
844 ilo
->base
.render_condition
= ilo_render_condition
;
845 ilo
->base
.texture_barrier
= ilo_texture_barrier
;
846 ilo
->base
.get_sample_position
= ilo_get_sample_position
;