Clone of mesa.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

si_state_draw.c 31KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890
  1. /*
  2. * Copyright 2012 Advanced Micro Devices, Inc.
  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. * on the rights to use, copy, modify, merge, publish, distribute, sub
  8. * license, and/or sell copies of the Software, and to permit persons to whom
  9. * the 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 NON-INFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
  19. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  20. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  21. * USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. *
  23. * Authors:
  24. * Christian König <christian.koenig@amd.com>
  25. */
  26. #include "si_pipe.h"
  27. #include "si_shader.h"
  28. #include "radeon/r600_cs.h"
  29. #include "sid.h"
  30. #include "util/u_index_modify.h"
  31. #include "util/u_upload_mgr.h"
  32. #include "util/u_prim.h"
  33. static void si_decompress_textures(struct si_context *sctx)
  34. {
  35. if (!sctx->blitter->running) {
  36. /* Flush depth textures which need to be flushed. */
  37. for (int i = 0; i < SI_NUM_SHADERS; i++) {
  38. if (sctx->samplers[i].depth_texture_mask) {
  39. si_flush_depth_textures(sctx, &sctx->samplers[i]);
  40. }
  41. if (sctx->samplers[i].compressed_colortex_mask) {
  42. si_decompress_color_textures(sctx, &sctx->samplers[i]);
  43. }
  44. }
  45. }
  46. }
  47. static unsigned si_conv_pipe_prim(unsigned mode)
  48. {
  49. static const unsigned prim_conv[] = {
  50. [PIPE_PRIM_POINTS] = V_008958_DI_PT_POINTLIST,
  51. [PIPE_PRIM_LINES] = V_008958_DI_PT_LINELIST,
  52. [PIPE_PRIM_LINE_LOOP] = V_008958_DI_PT_LINELOOP,
  53. [PIPE_PRIM_LINE_STRIP] = V_008958_DI_PT_LINESTRIP,
  54. [PIPE_PRIM_TRIANGLES] = V_008958_DI_PT_TRILIST,
  55. [PIPE_PRIM_TRIANGLE_STRIP] = V_008958_DI_PT_TRISTRIP,
  56. [PIPE_PRIM_TRIANGLE_FAN] = V_008958_DI_PT_TRIFAN,
  57. [PIPE_PRIM_QUADS] = V_008958_DI_PT_QUADLIST,
  58. [PIPE_PRIM_QUAD_STRIP] = V_008958_DI_PT_QUADSTRIP,
  59. [PIPE_PRIM_POLYGON] = V_008958_DI_PT_POLYGON,
  60. [PIPE_PRIM_LINES_ADJACENCY] = V_008958_DI_PT_LINELIST_ADJ,
  61. [PIPE_PRIM_LINE_STRIP_ADJACENCY] = V_008958_DI_PT_LINESTRIP_ADJ,
  62. [PIPE_PRIM_TRIANGLES_ADJACENCY] = V_008958_DI_PT_TRILIST_ADJ,
  63. [PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY] = V_008958_DI_PT_TRISTRIP_ADJ,
  64. [PIPE_PRIM_PATCHES] = V_008958_DI_PT_PATCH,
  65. [R600_PRIM_RECTANGLE_LIST] = V_008958_DI_PT_RECTLIST
  66. };
  67. assert(mode < Elements(prim_conv));
  68. return prim_conv[mode];
  69. }
  70. static unsigned si_conv_prim_to_gs_out(unsigned mode)
  71. {
  72. static const int prim_conv[] = {
  73. [PIPE_PRIM_POINTS] = V_028A6C_OUTPRIM_TYPE_POINTLIST,
  74. [PIPE_PRIM_LINES] = V_028A6C_OUTPRIM_TYPE_LINESTRIP,
  75. [PIPE_PRIM_LINE_LOOP] = V_028A6C_OUTPRIM_TYPE_LINESTRIP,
  76. [PIPE_PRIM_LINE_STRIP] = V_028A6C_OUTPRIM_TYPE_LINESTRIP,
  77. [PIPE_PRIM_TRIANGLES] = V_028A6C_OUTPRIM_TYPE_TRISTRIP,
  78. [PIPE_PRIM_TRIANGLE_STRIP] = V_028A6C_OUTPRIM_TYPE_TRISTRIP,
  79. [PIPE_PRIM_TRIANGLE_FAN] = V_028A6C_OUTPRIM_TYPE_TRISTRIP,
  80. [PIPE_PRIM_QUADS] = V_028A6C_OUTPRIM_TYPE_TRISTRIP,
  81. [PIPE_PRIM_QUAD_STRIP] = V_028A6C_OUTPRIM_TYPE_TRISTRIP,
  82. [PIPE_PRIM_POLYGON] = V_028A6C_OUTPRIM_TYPE_TRISTRIP,
  83. [PIPE_PRIM_LINES_ADJACENCY] = V_028A6C_OUTPRIM_TYPE_LINESTRIP,
  84. [PIPE_PRIM_LINE_STRIP_ADJACENCY] = V_028A6C_OUTPRIM_TYPE_LINESTRIP,
  85. [PIPE_PRIM_TRIANGLES_ADJACENCY] = V_028A6C_OUTPRIM_TYPE_TRISTRIP,
  86. [PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY] = V_028A6C_OUTPRIM_TYPE_TRISTRIP,
  87. [PIPE_PRIM_PATCHES] = V_028A6C_OUTPRIM_TYPE_POINTLIST,
  88. [R600_PRIM_RECTANGLE_LIST] = V_028A6C_OUTPRIM_TYPE_TRISTRIP
  89. };
  90. assert(mode < Elements(prim_conv));
  91. return prim_conv[mode];
  92. }
  93. /**
  94. * This calculates the LDS size for tessellation shaders (VS, TCS, TES).
  95. * LS.LDS_SIZE is shared by all 3 shader stages.
  96. *
  97. * The information about LDS and other non-compile-time parameters is then
  98. * written to userdata SGPRs.
  99. */
  100. static void si_emit_derived_tess_state(struct si_context *sctx,
  101. const struct pipe_draw_info *info,
  102. unsigned *num_patches)
  103. {
  104. struct radeon_winsys_cs *cs = sctx->b.rings.gfx.cs;
  105. struct si_shader_selector *ls = sctx->vs_shader;
  106. /* The TES pointer will only be used for sctx->last_tcs.
  107. * It would be wrong to think that TCS = TES. */
  108. struct si_shader_selector *tcs =
  109. sctx->tcs_shader ? sctx->tcs_shader : sctx->tes_shader;
  110. unsigned tes_sh_base = sctx->shader_userdata.sh_base[PIPE_SHADER_TESS_EVAL];
  111. unsigned num_tcs_input_cp = info->vertices_per_patch;
  112. unsigned num_tcs_output_cp, num_tcs_inputs, num_tcs_outputs;
  113. unsigned num_tcs_patch_outputs;
  114. unsigned input_vertex_size, output_vertex_size, pervertex_output_patch_size;
  115. unsigned input_patch_size, output_patch_size, output_patch0_offset;
  116. unsigned perpatch_output_offset, lds_size, ls_rsrc2;
  117. unsigned tcs_in_layout, tcs_out_layout, tcs_out_offsets;
  118. *num_patches = 1; /* TODO: calculate this */
  119. if (sctx->last_ls == ls->current &&
  120. sctx->last_tcs == tcs &&
  121. sctx->last_tes_sh_base == tes_sh_base &&
  122. sctx->last_num_tcs_input_cp == num_tcs_input_cp)
  123. return;
  124. sctx->last_ls = ls->current;
  125. sctx->last_tcs = tcs;
  126. sctx->last_tes_sh_base = tes_sh_base;
  127. sctx->last_num_tcs_input_cp = num_tcs_input_cp;
  128. /* This calculates how shader inputs and outputs among VS, TCS, and TES
  129. * are laid out in LDS. */
  130. num_tcs_inputs = util_last_bit64(ls->outputs_written);
  131. if (sctx->tcs_shader) {
  132. num_tcs_outputs = util_last_bit64(tcs->outputs_written);
  133. num_tcs_output_cp = tcs->info.properties[TGSI_PROPERTY_TCS_VERTICES_OUT];
  134. num_tcs_patch_outputs = util_last_bit64(tcs->patch_outputs_written);
  135. } else {
  136. /* No TCS. Route varyings from LS to TES. */
  137. num_tcs_outputs = num_tcs_inputs;
  138. num_tcs_output_cp = num_tcs_input_cp;
  139. num_tcs_patch_outputs = 2; /* TESSINNER + TESSOUTER */
  140. }
  141. input_vertex_size = num_tcs_inputs * 16;
  142. output_vertex_size = num_tcs_outputs * 16;
  143. input_patch_size = num_tcs_input_cp * input_vertex_size;
  144. pervertex_output_patch_size = num_tcs_output_cp * output_vertex_size;
  145. output_patch_size = pervertex_output_patch_size + num_tcs_patch_outputs * 16;
  146. output_patch0_offset = sctx->tcs_shader ? input_patch_size * *num_patches : 0;
  147. perpatch_output_offset = output_patch0_offset + pervertex_output_patch_size;
  148. lds_size = output_patch0_offset + output_patch_size * *num_patches;
  149. ls_rsrc2 = ls->current->ls_rsrc2;
  150. if (sctx->b.chip_class >= CIK) {
  151. assert(lds_size <= 65536);
  152. ls_rsrc2 |= S_00B52C_LDS_SIZE(align(lds_size, 512) / 512);
  153. } else {
  154. assert(lds_size <= 32768);
  155. ls_rsrc2 |= S_00B52C_LDS_SIZE(align(lds_size, 256) / 256);
  156. }
  157. /* Due to a hw bug, RSRC2_LS must be written twice with another
  158. * LS register written in between. */
  159. if (sctx->b.chip_class == CIK && sctx->b.family != CHIP_HAWAII)
  160. radeon_set_sh_reg(cs, R_00B52C_SPI_SHADER_PGM_RSRC2_LS, ls_rsrc2);
  161. radeon_set_sh_reg_seq(cs, R_00B528_SPI_SHADER_PGM_RSRC1_LS, 2);
  162. radeon_emit(cs, ls->current->ls_rsrc1);
  163. radeon_emit(cs, ls_rsrc2);
  164. /* Compute userdata SGPRs. */
  165. assert(((input_vertex_size / 4) & ~0xff) == 0);
  166. assert(((output_vertex_size / 4) & ~0xff) == 0);
  167. assert(((input_patch_size / 4) & ~0x1fff) == 0);
  168. assert(((output_patch_size / 4) & ~0x1fff) == 0);
  169. assert(((output_patch0_offset / 16) & ~0xffff) == 0);
  170. assert(((perpatch_output_offset / 16) & ~0xffff) == 0);
  171. assert(num_tcs_input_cp <= 32);
  172. assert(num_tcs_output_cp <= 32);
  173. tcs_in_layout = (input_patch_size / 4) |
  174. ((input_vertex_size / 4) << 13);
  175. tcs_out_layout = (output_patch_size / 4) |
  176. ((output_vertex_size / 4) << 13);
  177. tcs_out_offsets = (output_patch0_offset / 16) |
  178. ((perpatch_output_offset / 16) << 16);
  179. /* Set them for LS. */
  180. radeon_set_sh_reg(cs,
  181. R_00B530_SPI_SHADER_USER_DATA_LS_0 + SI_SGPR_LS_OUT_LAYOUT * 4,
  182. tcs_in_layout);
  183. /* Set them for TCS. */
  184. radeon_set_sh_reg_seq(cs,
  185. R_00B430_SPI_SHADER_USER_DATA_HS_0 + SI_SGPR_TCS_OUT_OFFSETS * 4, 3);
  186. radeon_emit(cs, tcs_out_offsets);
  187. radeon_emit(cs, tcs_out_layout | (num_tcs_input_cp << 26));
  188. radeon_emit(cs, tcs_in_layout);
  189. /* Set them for TES. */
  190. radeon_set_sh_reg_seq(cs, tes_sh_base + SI_SGPR_TCS_OUT_OFFSETS * 4, 2);
  191. radeon_emit(cs, tcs_out_offsets);
  192. radeon_emit(cs, tcs_out_layout | (num_tcs_output_cp << 26));
  193. }
  194. static unsigned si_get_ia_multi_vgt_param(struct si_context *sctx,
  195. const struct pipe_draw_info *info,
  196. unsigned num_patches)
  197. {
  198. struct si_state_rasterizer *rs = sctx->queued.named.rasterizer;
  199. unsigned prim = info->mode;
  200. unsigned primgroup_size = 128; /* recommended without a GS */
  201. /* SWITCH_ON_EOP(0) is always preferable. */
  202. bool wd_switch_on_eop = false;
  203. bool ia_switch_on_eop = false;
  204. bool ia_switch_on_eoi = false;
  205. bool partial_vs_wave = false;
  206. bool partial_es_wave = false;
  207. if (sctx->gs_shader)
  208. primgroup_size = 64; /* recommended with a GS */
  209. if (sctx->tes_shader) {
  210. unsigned num_cp_out =
  211. sctx->tcs_shader ?
  212. sctx->tcs_shader->info.properties[TGSI_PROPERTY_TCS_VERTICES_OUT] :
  213. info->vertices_per_patch;
  214. unsigned max_size = 256 / MAX2(info->vertices_per_patch, num_cp_out);
  215. primgroup_size = MIN2(primgroup_size, max_size);
  216. /* primgroup_size must be set to a multiple of NUM_PATCHES */
  217. primgroup_size = (primgroup_size / num_patches) * num_patches;
  218. /* SWITCH_ON_EOI must be set if PrimID is used.
  219. * If SWITCH_ON_EOI is set, PARTIAL_ES_WAVE must be set too. */
  220. if ((sctx->tcs_shader && sctx->tcs_shader->info.uses_primid) ||
  221. sctx->tes_shader->info.uses_primid) {
  222. ia_switch_on_eoi = true;
  223. partial_es_wave = true;
  224. }
  225. /* Bug with tessellation and GS on Bonaire and older 2 SE chips. */
  226. if ((sctx->b.family == CHIP_TAHITI ||
  227. sctx->b.family == CHIP_PITCAIRN ||
  228. sctx->b.family == CHIP_BONAIRE) &&
  229. sctx->gs_shader)
  230. partial_vs_wave = true;
  231. }
  232. /* This is a hardware requirement. */
  233. if ((rs && rs->line_stipple_enable) ||
  234. (sctx->b.screen->debug_flags & DBG_SWITCH_ON_EOP)) {
  235. ia_switch_on_eop = true;
  236. wd_switch_on_eop = true;
  237. }
  238. if (sctx->b.streamout.streamout_enabled ||
  239. sctx->b.streamout.prims_gen_query_enabled)
  240. partial_vs_wave = true;
  241. if (sctx->b.chip_class >= CIK) {
  242. /* WD_SWITCH_ON_EOP has no effect on GPUs with less than
  243. * 4 shader engines. Set 1 to pass the assertion below.
  244. * The other cases are hardware requirements. */
  245. if (sctx->b.screen->info.max_se < 4 ||
  246. prim == PIPE_PRIM_POLYGON ||
  247. prim == PIPE_PRIM_LINE_LOOP ||
  248. prim == PIPE_PRIM_TRIANGLE_FAN ||
  249. prim == PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY ||
  250. info->primitive_restart)
  251. wd_switch_on_eop = true;
  252. /* Hawaii hangs if instancing is enabled and WD_SWITCH_ON_EOP is 0.
  253. * We don't know that for indirect drawing, so treat it as
  254. * always problematic. */
  255. if (sctx->b.family == CHIP_HAWAII &&
  256. (info->indirect || info->instance_count > 1))
  257. wd_switch_on_eop = true;
  258. /* USE_OPAQUE doesn't work when WD_SWITCH_ON_EOP is 0. */
  259. if (info->count_from_stream_output)
  260. wd_switch_on_eop = true;
  261. /* If the WD switch is false, the IA switch must be false too. */
  262. assert(wd_switch_on_eop || !ia_switch_on_eop);
  263. }
  264. /* Hw bug with single-primitive instances and SWITCH_ON_EOI
  265. * on multi-SE chips. */
  266. if (sctx->b.screen->info.max_se >= 2 && ia_switch_on_eoi &&
  267. (info->indirect ||
  268. (info->instance_count > 1 &&
  269. u_prims_for_vertices(info->mode, info->count) <= 1)))
  270. sctx->b.flags |= SI_CONTEXT_VGT_FLUSH;
  271. /* Instancing bug on 2 SE chips. */
  272. if (sctx->b.screen->info.max_se == 2 && ia_switch_on_eoi &&
  273. (info->indirect || info->instance_count > 1))
  274. partial_vs_wave = true;
  275. return S_028AA8_SWITCH_ON_EOP(ia_switch_on_eop) |
  276. S_028AA8_SWITCH_ON_EOI(ia_switch_on_eoi) |
  277. S_028AA8_PARTIAL_VS_WAVE_ON(partial_vs_wave) |
  278. S_028AA8_PARTIAL_ES_WAVE_ON(partial_es_wave) |
  279. S_028AA8_PRIMGROUP_SIZE(primgroup_size - 1) |
  280. S_028AA8_WD_SWITCH_ON_EOP(sctx->b.chip_class >= CIK ? wd_switch_on_eop : 0) |
  281. S_028AA8_MAX_PRIMGRP_IN_WAVE(sctx->b.chip_class >= VI ? 2 : 0);
  282. }
  283. static unsigned si_get_ls_hs_config(struct si_context *sctx,
  284. const struct pipe_draw_info *info,
  285. unsigned num_patches)
  286. {
  287. unsigned num_output_cp;
  288. if (!sctx->tes_shader)
  289. return 0;
  290. num_output_cp = sctx->tcs_shader ?
  291. sctx->tcs_shader->info.properties[TGSI_PROPERTY_TCS_VERTICES_OUT] :
  292. info->vertices_per_patch;
  293. return S_028B58_NUM_PATCHES(num_patches) |
  294. S_028B58_HS_NUM_INPUT_CP(info->vertices_per_patch) |
  295. S_028B58_HS_NUM_OUTPUT_CP(num_output_cp);
  296. }
  297. static void si_emit_scratch_reloc(struct si_context *sctx)
  298. {
  299. struct radeon_winsys_cs *cs = sctx->b.rings.gfx.cs;
  300. if (!sctx->emit_scratch_reloc)
  301. return;
  302. radeon_set_context_reg(cs, R_0286E8_SPI_TMPRING_SIZE,
  303. sctx->spi_tmpring_size);
  304. if (sctx->scratch_buffer) {
  305. radeon_add_to_buffer_list(&sctx->b, &sctx->b.rings.gfx,
  306. sctx->scratch_buffer, RADEON_USAGE_READWRITE,
  307. RADEON_PRIO_SHADER_RESOURCE_RW);
  308. }
  309. sctx->emit_scratch_reloc = false;
  310. }
  311. /* rast_prim is the primitive type after GS. */
  312. static void si_emit_rasterizer_prim_state(struct si_context *sctx)
  313. {
  314. struct radeon_winsys_cs *cs = sctx->b.rings.gfx.cs;
  315. unsigned rast_prim = sctx->current_rast_prim;
  316. struct si_state_rasterizer *rs = sctx->emitted.named.rasterizer;
  317. /* Skip this if not rendering lines. */
  318. if (rast_prim != PIPE_PRIM_LINES &&
  319. rast_prim != PIPE_PRIM_LINE_LOOP &&
  320. rast_prim != PIPE_PRIM_LINE_STRIP &&
  321. rast_prim != PIPE_PRIM_LINES_ADJACENCY &&
  322. rast_prim != PIPE_PRIM_LINE_STRIP_ADJACENCY)
  323. return;
  324. if (rast_prim == sctx->last_rast_prim &&
  325. rs->pa_sc_line_stipple == sctx->last_sc_line_stipple)
  326. return;
  327. radeon_set_context_reg(cs, R_028A0C_PA_SC_LINE_STIPPLE,
  328. rs->pa_sc_line_stipple |
  329. S_028A0C_AUTO_RESET_CNTL(rast_prim == PIPE_PRIM_LINES ? 1 :
  330. rast_prim == PIPE_PRIM_LINE_STRIP ? 2 : 0));
  331. sctx->last_rast_prim = rast_prim;
  332. sctx->last_sc_line_stipple = rs->pa_sc_line_stipple;
  333. }
  334. static void si_emit_draw_registers(struct si_context *sctx,
  335. const struct pipe_draw_info *info)
  336. {
  337. struct radeon_winsys_cs *cs = sctx->b.rings.gfx.cs;
  338. unsigned prim = si_conv_pipe_prim(info->mode);
  339. unsigned gs_out_prim = si_conv_prim_to_gs_out(sctx->current_rast_prim);
  340. unsigned ia_multi_vgt_param, ls_hs_config, num_patches = 0;
  341. if (sctx->tes_shader)
  342. si_emit_derived_tess_state(sctx, info, &num_patches);
  343. ia_multi_vgt_param = si_get_ia_multi_vgt_param(sctx, info, num_patches);
  344. ls_hs_config = si_get_ls_hs_config(sctx, info, num_patches);
  345. /* Draw state. */
  346. if (prim != sctx->last_prim ||
  347. ia_multi_vgt_param != sctx->last_multi_vgt_param ||
  348. ls_hs_config != sctx->last_ls_hs_config) {
  349. if (sctx->b.chip_class >= CIK) {
  350. radeon_emit(cs, PKT3(PKT3_DRAW_PREAMBLE, 2, 0));
  351. radeon_emit(cs, prim); /* VGT_PRIMITIVE_TYPE */
  352. radeon_emit(cs, ia_multi_vgt_param); /* IA_MULTI_VGT_PARAM */
  353. radeon_emit(cs, ls_hs_config); /* VGT_LS_HS_CONFIG */
  354. } else {
  355. radeon_set_config_reg(cs, R_008958_VGT_PRIMITIVE_TYPE, prim);
  356. radeon_set_context_reg(cs, R_028AA8_IA_MULTI_VGT_PARAM, ia_multi_vgt_param);
  357. radeon_set_context_reg(cs, R_028B58_VGT_LS_HS_CONFIG, ls_hs_config);
  358. }
  359. sctx->last_prim = prim;
  360. sctx->last_multi_vgt_param = ia_multi_vgt_param;
  361. sctx->last_ls_hs_config = ls_hs_config;
  362. }
  363. if (gs_out_prim != sctx->last_gs_out_prim) {
  364. radeon_set_context_reg(cs, R_028A6C_VGT_GS_OUT_PRIM_TYPE, gs_out_prim);
  365. sctx->last_gs_out_prim = gs_out_prim;
  366. }
  367. /* Primitive restart. */
  368. if (info->primitive_restart != sctx->last_primitive_restart_en) {
  369. radeon_set_context_reg(cs, R_028A94_VGT_MULTI_PRIM_IB_RESET_EN, info->primitive_restart);
  370. sctx->last_primitive_restart_en = info->primitive_restart;
  371. if (info->primitive_restart &&
  372. (info->restart_index != sctx->last_restart_index ||
  373. sctx->last_restart_index == SI_RESTART_INDEX_UNKNOWN)) {
  374. radeon_set_context_reg(cs, R_02840C_VGT_MULTI_PRIM_IB_RESET_INDX,
  375. info->restart_index);
  376. sctx->last_restart_index = info->restart_index;
  377. }
  378. }
  379. }
  380. static void si_emit_draw_packets(struct si_context *sctx,
  381. const struct pipe_draw_info *info,
  382. const struct pipe_index_buffer *ib)
  383. {
  384. struct radeon_winsys_cs *cs = sctx->b.rings.gfx.cs;
  385. unsigned sh_base_reg = sctx->shader_userdata.sh_base[PIPE_SHADER_VERTEX];
  386. if (info->count_from_stream_output) {
  387. struct r600_so_target *t =
  388. (struct r600_so_target*)info->count_from_stream_output;
  389. uint64_t va = t->buf_filled_size->gpu_address +
  390. t->buf_filled_size_offset;
  391. radeon_set_context_reg(cs, R_028B30_VGT_STRMOUT_DRAW_OPAQUE_VERTEX_STRIDE,
  392. t->stride_in_dw);
  393. radeon_emit(cs, PKT3(PKT3_COPY_DATA, 4, 0));
  394. radeon_emit(cs, COPY_DATA_SRC_SEL(COPY_DATA_MEM) |
  395. COPY_DATA_DST_SEL(COPY_DATA_REG) |
  396. COPY_DATA_WR_CONFIRM);
  397. radeon_emit(cs, va); /* src address lo */
  398. radeon_emit(cs, va >> 32); /* src address hi */
  399. radeon_emit(cs, R_028B2C_VGT_STRMOUT_DRAW_OPAQUE_BUFFER_FILLED_SIZE >> 2);
  400. radeon_emit(cs, 0); /* unused */
  401. radeon_add_to_buffer_list(&sctx->b, &sctx->b.rings.gfx,
  402. t->buf_filled_size, RADEON_USAGE_READ,
  403. RADEON_PRIO_MIN);
  404. }
  405. /* draw packet */
  406. if (info->indexed) {
  407. radeon_emit(cs, PKT3(PKT3_INDEX_TYPE, 0, 0));
  408. /* index type */
  409. switch (ib->index_size) {
  410. case 1:
  411. radeon_emit(cs, V_028A7C_VGT_INDEX_8);
  412. break;
  413. case 2:
  414. radeon_emit(cs, V_028A7C_VGT_INDEX_16 |
  415. (SI_BIG_ENDIAN && sctx->b.chip_class <= CIK ?
  416. V_028A7C_VGT_DMA_SWAP_16_BIT : 0));
  417. break;
  418. case 4:
  419. radeon_emit(cs, V_028A7C_VGT_INDEX_32 |
  420. (SI_BIG_ENDIAN && sctx->b.chip_class <= CIK ?
  421. V_028A7C_VGT_DMA_SWAP_32_BIT : 0));
  422. break;
  423. default:
  424. assert(!"unreachable");
  425. return;
  426. }
  427. }
  428. if (!info->indirect) {
  429. int base_vertex;
  430. radeon_emit(cs, PKT3(PKT3_NUM_INSTANCES, 0, 0));
  431. radeon_emit(cs, info->instance_count);
  432. /* Base vertex and start instance. */
  433. base_vertex = info->indexed ? info->index_bias : info->start;
  434. if (base_vertex != sctx->last_base_vertex ||
  435. sctx->last_base_vertex == SI_BASE_VERTEX_UNKNOWN ||
  436. info->start_instance != sctx->last_start_instance ||
  437. sh_base_reg != sctx->last_sh_base_reg) {
  438. radeon_set_sh_reg_seq(cs, sh_base_reg + SI_SGPR_BASE_VERTEX * 4, 2);
  439. radeon_emit(cs, base_vertex);
  440. radeon_emit(cs, info->start_instance);
  441. sctx->last_base_vertex = base_vertex;
  442. sctx->last_start_instance = info->start_instance;
  443. sctx->last_sh_base_reg = sh_base_reg;
  444. }
  445. } else {
  446. si_invalidate_draw_sh_constants(sctx);
  447. radeon_add_to_buffer_list(&sctx->b, &sctx->b.rings.gfx,
  448. (struct r600_resource *)info->indirect,
  449. RADEON_USAGE_READ, RADEON_PRIO_MIN);
  450. }
  451. if (info->indexed) {
  452. uint32_t index_max_size = (ib->buffer->width0 - ib->offset) /
  453. ib->index_size;
  454. uint64_t index_va = r600_resource(ib->buffer)->gpu_address + ib->offset;
  455. radeon_add_to_buffer_list(&sctx->b, &sctx->b.rings.gfx,
  456. (struct r600_resource *)ib->buffer,
  457. RADEON_USAGE_READ, RADEON_PRIO_MIN);
  458. if (info->indirect) {
  459. uint64_t indirect_va = r600_resource(info->indirect)->gpu_address;
  460. assert(indirect_va % 8 == 0);
  461. assert(index_va % 2 == 0);
  462. assert(info->indirect_offset % 4 == 0);
  463. radeon_emit(cs, PKT3(PKT3_SET_BASE, 2, 0));
  464. radeon_emit(cs, 1);
  465. radeon_emit(cs, indirect_va);
  466. radeon_emit(cs, indirect_va >> 32);
  467. radeon_emit(cs, PKT3(PKT3_INDEX_BASE, 1, 0));
  468. radeon_emit(cs, index_va);
  469. radeon_emit(cs, index_va >> 32);
  470. radeon_emit(cs, PKT3(PKT3_INDEX_BUFFER_SIZE, 0, 0));
  471. radeon_emit(cs, index_max_size);
  472. radeon_emit(cs, PKT3(PKT3_DRAW_INDEX_INDIRECT, 3, sctx->b.predicate_drawing));
  473. radeon_emit(cs, info->indirect_offset);
  474. radeon_emit(cs, (sh_base_reg + SI_SGPR_BASE_VERTEX * 4 - SI_SH_REG_OFFSET) >> 2);
  475. radeon_emit(cs, (sh_base_reg + SI_SGPR_START_INSTANCE * 4 - SI_SH_REG_OFFSET) >> 2);
  476. radeon_emit(cs, V_0287F0_DI_SRC_SEL_DMA);
  477. } else {
  478. index_va += info->start * ib->index_size;
  479. radeon_emit(cs, PKT3(PKT3_DRAW_INDEX_2, 4, sctx->b.predicate_drawing));
  480. radeon_emit(cs, index_max_size);
  481. radeon_emit(cs, index_va);
  482. radeon_emit(cs, (index_va >> 32UL) & 0xFF);
  483. radeon_emit(cs, info->count);
  484. radeon_emit(cs, V_0287F0_DI_SRC_SEL_DMA);
  485. }
  486. } else {
  487. if (info->indirect) {
  488. uint64_t indirect_va = r600_resource(info->indirect)->gpu_address;
  489. assert(indirect_va % 8 == 0);
  490. assert(info->indirect_offset % 4 == 0);
  491. radeon_emit(cs, PKT3(PKT3_SET_BASE, 2, 0));
  492. radeon_emit(cs, 1);
  493. radeon_emit(cs, indirect_va);
  494. radeon_emit(cs, indirect_va >> 32);
  495. radeon_emit(cs, PKT3(PKT3_DRAW_INDIRECT, 3, sctx->b.predicate_drawing));
  496. radeon_emit(cs, info->indirect_offset);
  497. radeon_emit(cs, (sh_base_reg + SI_SGPR_BASE_VERTEX * 4 - SI_SH_REG_OFFSET) >> 2);
  498. radeon_emit(cs, (sh_base_reg + SI_SGPR_START_INSTANCE * 4 - SI_SH_REG_OFFSET) >> 2);
  499. radeon_emit(cs, V_0287F0_DI_SRC_SEL_AUTO_INDEX);
  500. } else {
  501. radeon_emit(cs, PKT3(PKT3_DRAW_INDEX_AUTO, 1, sctx->b.predicate_drawing));
  502. radeon_emit(cs, info->count);
  503. radeon_emit(cs, V_0287F0_DI_SRC_SEL_AUTO_INDEX |
  504. S_0287F0_USE_OPAQUE(!!info->count_from_stream_output));
  505. }
  506. }
  507. }
  508. #define BOTH_ICACHE_KCACHE (SI_CONTEXT_INV_ICACHE | SI_CONTEXT_INV_KCACHE)
  509. void si_emit_cache_flush(struct si_context *si_ctx, struct r600_atom *atom)
  510. {
  511. struct r600_common_context *sctx = &si_ctx->b;
  512. struct radeon_winsys_cs *cs = sctx->rings.gfx.cs;
  513. uint32_t cp_coher_cntl = 0;
  514. uint32_t compute =
  515. PKT3_SHADER_TYPE_S(!!(sctx->flags & SI_CONTEXT_FLAG_COMPUTE));
  516. /* SI has a bug that it always flushes ICACHE and KCACHE if either
  517. * bit is set. An alternative way is to write SQC_CACHES, but that
  518. * doesn't seem to work reliably. Since the bug doesn't affect
  519. * correctness (it only does more work than necessary) and
  520. * the performance impact is likely negligible, there is no plan
  521. * to fix it.
  522. */
  523. if (sctx->flags & SI_CONTEXT_INV_ICACHE)
  524. cp_coher_cntl |= S_0085F0_SH_ICACHE_ACTION_ENA(1);
  525. if (sctx->flags & SI_CONTEXT_INV_KCACHE)
  526. cp_coher_cntl |= S_0085F0_SH_KCACHE_ACTION_ENA(1);
  527. if (sctx->flags & SI_CONTEXT_INV_TC_L1)
  528. cp_coher_cntl |= S_0085F0_TCL1_ACTION_ENA(1);
  529. if (sctx->flags & SI_CONTEXT_INV_TC_L2) {
  530. cp_coher_cntl |= S_0085F0_TC_ACTION_ENA(1);
  531. /* TODO: this might not be needed. */
  532. if (sctx->chip_class >= VI)
  533. cp_coher_cntl |= S_0301F0_TC_WB_ACTION_ENA(1);
  534. }
  535. if (sctx->flags & SI_CONTEXT_FLUSH_AND_INV_CB) {
  536. cp_coher_cntl |= S_0085F0_CB_ACTION_ENA(1) |
  537. S_0085F0_CB0_DEST_BASE_ENA(1) |
  538. S_0085F0_CB1_DEST_BASE_ENA(1) |
  539. S_0085F0_CB2_DEST_BASE_ENA(1) |
  540. S_0085F0_CB3_DEST_BASE_ENA(1) |
  541. S_0085F0_CB4_DEST_BASE_ENA(1) |
  542. S_0085F0_CB5_DEST_BASE_ENA(1) |
  543. S_0085F0_CB6_DEST_BASE_ENA(1) |
  544. S_0085F0_CB7_DEST_BASE_ENA(1);
  545. }
  546. if (sctx->flags & SI_CONTEXT_FLUSH_AND_INV_DB) {
  547. cp_coher_cntl |= S_0085F0_DB_ACTION_ENA(1) |
  548. S_0085F0_DB_DEST_BASE_ENA(1);
  549. }
  550. if (sctx->flags & SI_CONTEXT_FLUSH_AND_INV_CB_META) {
  551. radeon_emit(cs, PKT3(PKT3_EVENT_WRITE, 0, 0) | compute);
  552. radeon_emit(cs, EVENT_TYPE(V_028A90_FLUSH_AND_INV_CB_META) | EVENT_INDEX(0));
  553. }
  554. if (sctx->flags & SI_CONTEXT_FLUSH_AND_INV_DB_META) {
  555. radeon_emit(cs, PKT3(PKT3_EVENT_WRITE, 0, 0) | compute);
  556. radeon_emit(cs, EVENT_TYPE(V_028A90_FLUSH_AND_INV_DB_META) | EVENT_INDEX(0));
  557. }
  558. if (sctx->flags & SI_CONTEXT_FLUSH_WITH_INV_L2) {
  559. radeon_emit(cs, PKT3(PKT3_EVENT_WRITE, 0, 0) | compute);
  560. radeon_emit(cs, EVENT_TYPE(EVENT_TYPE_CACHE_FLUSH) | EVENT_INDEX(7) |
  561. EVENT_WRITE_INV_L2);
  562. }
  563. /* FLUSH_AND_INV events must be emitted before PS_PARTIAL_FLUSH.
  564. * Otherwise, clearing CMASK (CB meta) with CP DMA isn't reliable.
  565. *
  566. * I think the reason is that FLUSH_AND_INV is only added to a queue
  567. * and it is PS_PARTIAL_FLUSH that waits for it to complete.
  568. */
  569. if (sctx->flags & SI_CONTEXT_PS_PARTIAL_FLUSH) {
  570. radeon_emit(cs, PKT3(PKT3_EVENT_WRITE, 0, 0) | compute);
  571. radeon_emit(cs, EVENT_TYPE(V_028A90_PS_PARTIAL_FLUSH) | EVENT_INDEX(4));
  572. } else if (sctx->flags & SI_CONTEXT_VS_PARTIAL_FLUSH) {
  573. radeon_emit(cs, PKT3(PKT3_EVENT_WRITE, 0, 0) | compute);
  574. radeon_emit(cs, EVENT_TYPE(V_028A90_VS_PARTIAL_FLUSH) | EVENT_INDEX(4));
  575. }
  576. if (sctx->flags & SI_CONTEXT_CS_PARTIAL_FLUSH) {
  577. radeon_emit(cs, PKT3(PKT3_EVENT_WRITE, 0, 0) | compute);
  578. radeon_emit(cs, EVENT_TYPE(V_028A90_CS_PARTIAL_FLUSH | EVENT_INDEX(4)));
  579. }
  580. if (sctx->flags & SI_CONTEXT_VGT_FLUSH) {
  581. radeon_emit(cs, PKT3(PKT3_EVENT_WRITE, 0, 0) | compute);
  582. radeon_emit(cs, EVENT_TYPE(V_028A90_VGT_FLUSH) | EVENT_INDEX(0));
  583. }
  584. if (sctx->flags & SI_CONTEXT_VGT_STREAMOUT_SYNC) {
  585. radeon_emit(cs, PKT3(PKT3_EVENT_WRITE, 0, 0) | compute);
  586. radeon_emit(cs, EVENT_TYPE(V_028A90_VGT_STREAMOUT_SYNC) | EVENT_INDEX(0));
  587. }
  588. /* SURFACE_SYNC must be emitted after partial flushes.
  589. * It looks like SURFACE_SYNC flushes caches immediately and doesn't
  590. * wait for any engines. This should be last.
  591. */
  592. if (cp_coher_cntl) {
  593. if (sctx->chip_class >= CIK) {
  594. radeon_emit(cs, PKT3(PKT3_ACQUIRE_MEM, 5, 0) | compute);
  595. radeon_emit(cs, cp_coher_cntl); /* CP_COHER_CNTL */
  596. radeon_emit(cs, 0xffffffff); /* CP_COHER_SIZE */
  597. radeon_emit(cs, 0xff); /* CP_COHER_SIZE_HI */
  598. radeon_emit(cs, 0); /* CP_COHER_BASE */
  599. radeon_emit(cs, 0); /* CP_COHER_BASE_HI */
  600. radeon_emit(cs, 0x0000000A); /* POLL_INTERVAL */
  601. } else {
  602. radeon_emit(cs, PKT3(PKT3_SURFACE_SYNC, 3, 0) | compute);
  603. radeon_emit(cs, cp_coher_cntl); /* CP_COHER_CNTL */
  604. radeon_emit(cs, 0xffffffff); /* CP_COHER_SIZE */
  605. radeon_emit(cs, 0); /* CP_COHER_BASE */
  606. radeon_emit(cs, 0x0000000A); /* POLL_INTERVAL */
  607. }
  608. }
  609. sctx->flags = 0;
  610. }
  611. static void si_get_draw_start_count(struct si_context *sctx,
  612. const struct pipe_draw_info *info,
  613. unsigned *start, unsigned *count)
  614. {
  615. if (info->indirect) {
  616. struct r600_resource *indirect =
  617. (struct r600_resource*)info->indirect;
  618. int *data = r600_buffer_map_sync_with_rings(&sctx->b,
  619. indirect, PIPE_TRANSFER_READ);
  620. data += info->indirect_offset/sizeof(int);
  621. *start = data[2];
  622. *count = data[0];
  623. } else {
  624. *start = info->start;
  625. *count = info->count;
  626. }
  627. }
  628. void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
  629. {
  630. struct si_context *sctx = (struct si_context *)ctx;
  631. struct pipe_index_buffer ib = {};
  632. unsigned mask;
  633. if (!info->count && !info->indirect &&
  634. (info->indexed || !info->count_from_stream_output))
  635. return;
  636. if (!sctx->ps_shader || !sctx->vs_shader) {
  637. assert(0);
  638. return;
  639. }
  640. if (!!sctx->tes_shader != (info->mode == PIPE_PRIM_PATCHES)) {
  641. assert(0);
  642. return;
  643. }
  644. si_decompress_textures(sctx);
  645. /* Set the rasterization primitive type.
  646. *
  647. * This must be done after si_decompress_textures, which can call
  648. * draw_vbo recursively, and before si_update_shaders, which uses
  649. * current_rast_prim for this draw_vbo call. */
  650. if (sctx->gs_shader)
  651. sctx->current_rast_prim = sctx->gs_shader->gs_output_prim;
  652. else if (sctx->tes_shader)
  653. sctx->current_rast_prim =
  654. sctx->tes_shader->info.properties[TGSI_PROPERTY_TES_PRIM_MODE];
  655. else
  656. sctx->current_rast_prim = info->mode;
  657. si_update_shaders(sctx);
  658. if (!si_upload_shader_descriptors(sctx))
  659. return;
  660. if (info->indexed) {
  661. /* Initialize the index buffer struct. */
  662. pipe_resource_reference(&ib.buffer, sctx->index_buffer.buffer);
  663. ib.user_buffer = sctx->index_buffer.user_buffer;
  664. ib.index_size = sctx->index_buffer.index_size;
  665. ib.offset = sctx->index_buffer.offset;
  666. /* Translate or upload, if needed. */
  667. /* 8-bit indices are supported on VI. */
  668. if (sctx->b.chip_class <= CIK && ib.index_size == 1) {
  669. struct pipe_resource *out_buffer = NULL;
  670. unsigned out_offset, start, count, start_offset;
  671. void *ptr;
  672. si_get_draw_start_count(sctx, info, &start, &count);
  673. start_offset = start * ib.index_size;
  674. u_upload_alloc(sctx->b.uploader, start_offset, count * 2,
  675. &out_offset, &out_buffer, &ptr);
  676. util_shorten_ubyte_elts_to_userptr(&sctx->b.b, &ib, 0,
  677. ib.offset + start_offset,
  678. count, ptr);
  679. pipe_resource_reference(&ib.buffer, NULL);
  680. ib.user_buffer = NULL;
  681. ib.buffer = out_buffer;
  682. /* info->start will be added by the drawing code */
  683. ib.offset = out_offset - start_offset;
  684. ib.index_size = 2;
  685. } else if (ib.user_buffer && !ib.buffer) {
  686. unsigned start, count, start_offset;
  687. si_get_draw_start_count(sctx, info, &start, &count);
  688. start_offset = start * ib.index_size;
  689. u_upload_data(sctx->b.uploader, start_offset, count * ib.index_size,
  690. (char*)ib.user_buffer + start_offset,
  691. &ib.offset, &ib.buffer);
  692. /* info->start will be added by the drawing code */
  693. ib.offset -= start_offset;
  694. }
  695. }
  696. /* TODO: VI should read index buffers through TC, so this shouldn't be
  697. * needed on VI. */
  698. if (info->indexed && r600_resource(ib.buffer)->TC_L2_dirty) {
  699. sctx->b.flags |= SI_CONTEXT_INV_TC_L2;
  700. r600_resource(ib.buffer)->TC_L2_dirty = false;
  701. }
  702. /* Check flush flags. */
  703. if (sctx->b.flags)
  704. si_mark_atom_dirty(sctx, sctx->atoms.s.cache_flush);
  705. si_need_cs_space(sctx);
  706. /* Emit states. */
  707. mask = sctx->dirty_atoms;
  708. while (mask) {
  709. struct r600_atom *atom = sctx->atoms.array[u_bit_scan(&mask)];
  710. atom->emit(&sctx->b, atom);
  711. }
  712. sctx->dirty_atoms = 0;
  713. si_pm4_emit_dirty(sctx);
  714. si_emit_scratch_reloc(sctx);
  715. si_emit_rasterizer_prim_state(sctx);
  716. si_emit_draw_registers(sctx, info);
  717. si_emit_draw_packets(sctx, info, &ib);
  718. if (sctx->trace_buf)
  719. si_trace_emit(sctx);
  720. /* Workaround for a VGT hang when streamout is enabled.
  721. * It must be done after drawing. */
  722. if ((sctx->b.family == CHIP_HAWAII || sctx->b.family == CHIP_TONGA) &&
  723. (sctx->b.streamout.streamout_enabled ||
  724. sctx->b.streamout.prims_gen_query_enabled)) {
  725. sctx->b.flags |= SI_CONTEXT_VGT_STREAMOUT_SYNC;
  726. }
  727. /* Set the depth buffer as dirty. */
  728. if (sctx->framebuffer.state.zsbuf) {
  729. struct pipe_surface *surf = sctx->framebuffer.state.zsbuf;
  730. struct r600_texture *rtex = (struct r600_texture *)surf->texture;
  731. rtex->dirty_level_mask |= 1 << surf->u.tex.level;
  732. }
  733. if (sctx->framebuffer.compressed_cb_mask) {
  734. struct pipe_surface *surf;
  735. struct r600_texture *rtex;
  736. unsigned mask = sctx->framebuffer.compressed_cb_mask;
  737. do {
  738. unsigned i = u_bit_scan(&mask);
  739. surf = sctx->framebuffer.state.cbufs[i];
  740. rtex = (struct r600_texture*)surf->texture;
  741. rtex->dirty_level_mask |= 1 << surf->u.tex.level;
  742. } while (mask);
  743. }
  744. pipe_resource_reference(&ib.buffer, NULL);
  745. sctx->b.num_draw_calls++;
  746. }
  747. void si_trace_emit(struct si_context *sctx)
  748. {
  749. struct radeon_winsys_cs *cs = sctx->b.rings.gfx.cs;
  750. sctx->trace_id++;
  751. radeon_add_to_buffer_list(&sctx->b, &sctx->b.rings.gfx, sctx->trace_buf,
  752. RADEON_USAGE_READWRITE, RADEON_PRIO_MIN);
  753. radeon_emit(cs, PKT3(PKT3_WRITE_DATA, 3, 0));
  754. radeon_emit(cs, S_370_DST_SEL(V_370_MEMORY_SYNC) |
  755. S_370_WR_CONFIRM(1) |
  756. S_370_ENGINE_SEL(V_370_ME));
  757. radeon_emit(cs, sctx->trace_buf->gpu_address);
  758. radeon_emit(cs, sctx->trace_buf->gpu_address >> 32);
  759. radeon_emit(cs, sctx->trace_id);
  760. radeon_emit(cs, PKT3(PKT3_NOP, 0, 0));
  761. radeon_emit(cs, SI_ENCODE_TRACE_POINT(sctx->trace_id));
  762. }