1 /*
2 * Copyright © 2024 Intel Corporation
3 *
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:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24 #ifndef GENX_CMD_DRAW_GENERATED_FLUSH_H
25 #define GENX_CMD_DRAW_GENERATED_FLUSH_H
26
27 #include <assert.h>
28 #include <stdbool.h>
29
30 #include "util/macros.h"
31
32 #include "common/intel_genX_state_brw.h"
33
34 #include "anv_private.h"
35
36 static void
genX(cmd_buffer_flush_generated_draws)37 genX(cmd_buffer_flush_generated_draws)(struct anv_cmd_buffer *cmd_buffer)
38 {
39 if (!anv_cmd_buffer_is_render_queue(cmd_buffer))
40 return;
41
42 /* No return address setup means we don't have to do anything */
43 if (anv_address_is_null(cmd_buffer->generation.return_addr))
44 return;
45
46 struct anv_batch *batch = &cmd_buffer->generation.batch;
47
48 /* Wait for all the generation vertex shader to generate the commands. */
49 genX(emit_apply_pipe_flushes)(batch,
50 cmd_buffer->device,
51 _3D,
52 #if GFX_VER == 9
53 ANV_PIPE_VF_CACHE_INVALIDATE_BIT |
54 #endif
55 ANV_PIPE_DATA_CACHE_FLUSH_BIT |
56 ANV_PIPE_CS_STALL_BIT,
57 NULL /* emitted_bits */);
58
59 #if GFX_VER >= 12
60 anv_batch_emit(batch, GENX(MI_ARB_CHECK), arb) {
61 arb.PreParserDisableMask = true;
62 arb.PreParserDisable = true;
63 }
64 #else
65 /* Prior to Gfx12 we cannot disable the CS prefetch but it doesn't matter
66 * as the prefetch shouldn't follow the MI_BATCH_BUFFER_START.
67 */
68 #endif
69
70 /* Return to the main batch. */
71 anv_batch_emit(batch, GENX(MI_BATCH_BUFFER_START), bbs) {
72 bbs.AddressSpaceIndicator = ASI_PPGTT;
73 bbs.BatchBufferStartAddress = cmd_buffer->generation.return_addr;
74 }
75
76 cmd_buffer->generation.return_addr = ANV_NULL_ADDRESS;
77 }
78
79 #endif /* GENX_CMD_DRAW_GENERATED_FLUSH_H */
80