2 * Copyright © 2017 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
26 * The main driver hooks for drawing and launching compute shaders.
31 #include "pipe/p_defines.h"
32 #include "pipe/p_state.h"
33 #include "pipe/p_context.h"
34 #include "pipe/p_screen.h"
35 #include "util/u_inlines.h"
36 #include "util/u_transfer.h"
37 #include "intel/compiler/brw_compiler.h"
38 #include "iris_context.h"
41 * Record the current primitive mode and restart information, flagging
42 * related packets as dirty if necessary.
45 iris_update_draw_info(struct iris_context
*ice
,
46 const struct pipe_draw_info
*info
)
48 if (ice
->state
.prim_mode
!= info
->mode
||
49 ice
->state
.vertices_per_patch
!= info
->vertices_per_patch
) {
50 ice
->state
.prim_mode
= info
->mode
;
51 ice
->state
.vertices_per_patch
= info
->vertices_per_patch
;
52 ice
->state
.dirty
|= IRIS_DIRTY_VF_TOPOLOGY
;
55 if (ice
->state
.primitive_restart
!= info
->primitive_restart
||
56 ice
->state
.cut_index
!= info
->restart_index
) {
57 ice
->state
.dirty
|= IRIS_DIRTY_VF
;
58 ice
->state
.primitive_restart
= info
->primitive_restart
;
59 ice
->state
.cut_index
= info
->restart_index
;
64 * The pipe->draw_vbo() driver hook. Performs a draw on the GPU.
67 iris_draw_vbo(struct pipe_context
*ctx
, const struct pipe_draw_info
*info
)
69 struct iris_context
*ice
= (struct iris_context
*) ctx
;
70 struct iris_batch
*batch
= &ice
->render_batch
;
72 if (unlikely(INTEL_DEBUG
& DEBUG_REEMIT
))
73 ice
->state
.dirty
|= ~0ull;
75 iris_batch_maybe_flush(batch
, 1500);
77 iris_update_draw_info(ice
, info
);
78 iris_update_compiled_shaders(ice
);
80 iris_predraw_resolve_inputs(ice
, batch
);
81 iris_predraw_resolve_framebuffer(ice
, batch
);
83 if (iris_binder_is_empty(&batch
->binder
)) {
84 ice
->state
.dirty
|= IRIS_DIRTY_BINDINGS_VS
|
85 IRIS_DIRTY_BINDINGS_TCS
|
86 IRIS_DIRTY_BINDINGS_TES
|
87 IRIS_DIRTY_BINDINGS_GS
|
88 IRIS_DIRTY_BINDINGS_FS
;
91 if (iris_binder_reserve_3d(batch
, ice
)) {
92 ice
->state
.dirty
|= IRIS_DIRTY_BINDINGS_VS
|
93 IRIS_DIRTY_BINDINGS_TCS
|
94 IRIS_DIRTY_BINDINGS_TES
|
95 IRIS_DIRTY_BINDINGS_GS
|
96 IRIS_DIRTY_BINDINGS_FS
;
98 ice
->vtbl
.upload_render_state(ice
, batch
, info
);
100 ice
->state
.dirty
= 0ull;
102 iris_postdraw_update_resolve_tracking(ice
, batch
);