Lines Matching refs:sctx
192 struct si_context *sctx = (struct si_context *)context;
202 si_release_all_descriptors(sctx);
204 if (sctx->gfx_level >= GFX10 && sctx->has_graphics)
205 gfx10_destroy_query(sctx);
207 if (sctx->thread_trace)
208 si_destroy_thread_trace(sctx);
210 pipe_resource_reference(&sctx->esgs_ring, NULL);
211 pipe_resource_reference(&sctx->gsvs_ring, NULL);
212 pipe_resource_reference(&sctx->tess_rings, NULL);
213 pipe_resource_reference(&sctx->tess_rings_tmz, NULL);
214 pipe_resource_reference(&sctx->null_const_buf.buffer, NULL);
215 pipe_resource_reference(&sctx->sample_pos_buffer, NULL);
216 si_resource_reference(&sctx->border_color_buffer, NULL);
217 free(sctx->border_color_table);
218 si_resource_reference(&sctx->scratch_buffer, NULL);
219 si_resource_reference(&sctx->compute_scratch_buffer, NULL);
220 si_resource_reference(&sctx->wait_mem_scratch, NULL);
221 si_resource_reference(&sctx->wait_mem_scratch_tmz, NULL);
222 si_resource_reference(&sctx->small_prim_cull_info_buf, NULL);
223 si_resource_reference(&sctx->pipeline_stats_query_buf, NULL);
225 if (sctx->cs_preamble_state)
226 si_pm4_free_state(sctx, sctx->cs_preamble_state, ~0);
227 if (sctx->cs_preamble_state_tmz)
228 si_pm4_free_state(sctx, sctx->cs_preamble_state_tmz, ~0);
230 for (i = 0; i < ARRAY_SIZE(sctx->vgt_shader_config); i++)
231 si_pm4_free_state(sctx, sctx->vgt_shader_config[i], SI_STATE_IDX(vgt_shader_config));
233 if (sctx->fixed_func_tcs_shader_cache) {
234 hash_table_foreach(sctx->fixed_func_tcs_shader_cache, entry) {
235 sctx->b.delete_tcs_state(&sctx->b, entry->data);
237 _mesa_hash_table_destroy(sctx->fixed_func_tcs_shader_cache, NULL);
240 if (sctx->custom_dsa_flush)
241 sctx->b.delete_depth_stencil_alpha_state(&sctx->b, sctx->custom_dsa_flush);
242 if (sctx->custom_blend_resolve)
243 sctx->b.delete_blend_state(&sctx->b, sctx->custom_blend_resolve);
244 if (sctx->custom_blend_fmask_decompress)
245 sctx->b.delete_blend_state(&sctx->b, sctx->custom_blend_fmask_decompress);
246 if (sctx->custom_blend_eliminate_fastclear)
247 sctx->b.delete_blend_state(&sctx->b, sctx->custom_blend_eliminate_fastclear);
248 if (sctx->custom_blend_dcc_decompress)
249 sctx->b.delete_blend_state(&sctx->b, sctx->custom_blend_dcc_decompress);
250 if (sctx->vs_blit_pos)
251 sctx->b.delete_vs_state(&sctx->b, sctx->vs_blit_pos);
252 if (sctx->vs_blit_pos_layered)
253 sctx->b.delete_vs_state(&sctx->b, sctx->vs_blit_pos_layered);
254 if (sctx->vs_blit_color)
255 sctx->b.delete_vs_state(&sctx->b, sctx->vs_blit_color);
256 if (sctx->vs_blit_color_layered)
257 sctx->b.delete_vs_state(&sctx->b, sctx->vs_blit_color_layered);
258 if (sctx->vs_blit_texcoord)
259 sctx->b.delete_vs_state(&sctx->b, sctx->vs_blit_texcoord);
260 if (sctx->cs_clear_buffer)
261 sctx->b.delete_compute_state(&sctx->b, sctx->cs_clear_buffer);
262 if (sctx->cs_clear_buffer_rmw)
263 sctx->b.delete_compute_state(&sctx->b, sctx->cs_clear_buffer_rmw);
264 if (sctx->cs_copy_buffer)
265 sctx->b.delete_compute_state(&sctx->b, sctx->cs_copy_buffer);
266 for (unsigned i = 0; i < ARRAY_SIZE(sctx->cs_copy_image); i++) {
267 for (unsigned j = 0; j < ARRAY_SIZE(sctx->cs_copy_image[i]); j++) {
268 if (sctx->cs_copy_image[i][j])
269 sctx->b.delete_compute_state(&sctx->b, sctx->cs_copy_image[i][j]);
272 if (sctx->cs_clear_render_target)
273 sctx->b.delete_compute_state(&sctx->b, sctx->cs_clear_render_target);
274 if (sctx->cs_clear_render_target_1d_array)
275 sctx->b.delete_compute_state(&sctx->b, sctx->cs_clear_render_target_1d_array);
276 if (sctx->cs_clear_12bytes_buffer)
277 sctx->b.delete_compute_state(&sctx->b, sctx->cs_clear_12bytes_buffer);
278 for (unsigned i = 0; i < ARRAY_SIZE(sctx->cs_dcc_retile); i++) {
279 if (sctx->cs_dcc_retile[i])
280 sctx->b.delete_compute_state(&sctx->b, sctx->cs_dcc_retile[i]);
282 if (sctx->no_velems_state)
283 sctx->b.delete_vertex_elements_state(&sctx->b, sctx->no_velems_state);
285 for (unsigned i = 0; i < ARRAY_SIZE(sctx->cs_fmask_expand); i++) {
286 for (unsigned j = 0; j < ARRAY_SIZE(sctx->cs_fmask_expand[i]); j++) {
287 if (sctx->cs_fmask_expand[i][j]) {
288 sctx->b.delete_compute_state(&sctx->b, sctx->cs_fmask_expand[i][j]);
293 for (unsigned i = 0; i < ARRAY_SIZE(sctx->cs_clear_dcc_msaa); i++) {
294 for (unsigned j = 0; j < ARRAY_SIZE(sctx->cs_clear_dcc_msaa[i]); j++) {
295 for (unsigned k = 0; k < ARRAY_SIZE(sctx->cs_clear_dcc_msaa[i][j]); k++) {
296 for (unsigned l = 0; l < ARRAY_SIZE(sctx->cs_clear_dcc_msaa[i][j][k]); l++) {
297 for (unsigned m = 0; m < ARRAY_SIZE(sctx->cs_clear_dcc_msaa[i][j][k][l]); m++) {
298 if (sctx->cs_clear_dcc_msaa[i][j][k][l][m])
299 sctx->b.delete_compute_state(&sctx->b, sctx->cs_clear_dcc_msaa[i][j][k][l][m]);
306 if (sctx->blitter)
307 util_blitter_destroy(sctx->blitter);
309 if (sctx->query_result_shader)
310 sctx->b.delete_compute_state(&sctx->b, sctx->query_result_shader);
311 if (sctx->sh_query_result_shader)
312 sctx->b.delete_compute_state(&sctx->b, sctx->sh_query_result_shader);
314 sctx->ws->cs_destroy(&sctx->gfx_cs);
315 if (sctx->ctx)
316 sctx->ws->ctx_destroy(sctx->ctx);
317 if (sctx->sdma_cs) {
318 sctx->ws->cs_destroy(sctx->sdma_cs);
319 free(sctx->sdma_cs);
322 if (sctx->dirty_implicit_resources)
323 _mesa_hash_table_destroy(sctx->dirty_implicit_resources,
326 if (sctx->b.stream_uploader)
327 u_upload_destroy(sctx->b.stream_uploader);
328 if (sctx->b.const_uploader && sctx->b.const_uploader != sctx->b.stream_uploader)
329 u_upload_destroy(sctx->b.const_uploader);
330 if (sctx->cached_gtt_allocator)
331 u_upload_destroy(sctx->cached_gtt_allocator);
333 slab_destroy_child(&sctx->pool_transfers);
334 slab_destroy_child(&sctx->pool_transfers_unsync);
336 u_suballocator_destroy(&sctx->allocator_zeroed_memory);
338 sctx->ws->fence_reference(&sctx->last_gfx_fence, NULL);
339 si_resource_reference(&sctx->eop_bug_scratch, NULL);
340 si_resource_reference(&sctx->eop_bug_scratch_tmz, NULL);
341 si_resource_reference(&sctx->shadowed_regs, NULL);
343 si_destroy_compiler(&sctx->compiler);
345 si_saved_cs_reference(&sctx->current_saved_cs, NULL);
347 _mesa_hash_table_destroy(sctx->tex_handles, NULL);
348 _mesa_hash_table_destroy(sctx->img_handles, NULL);
350 util_dynarray_fini(&sctx->resident_tex_handles);
351 util_dynarray_fini(&sctx->resident_img_handles);
352 util_dynarray_fini(&sctx->resident_tex_needs_color_decompress);
353 util_dynarray_fini(&sctx->resident_img_needs_color_decompress);
354 util_dynarray_fini(&sctx->resident_tex_needs_depth_decompress);
356 if (!(sctx->context_flags & SI_CONTEXT_FLAG_AUX))
359 FREE(sctx);
364 struct si_context *sctx = (struct si_context *)ctx;
365 if (sctx->context_flags & SI_CONTEXT_FLAG_AUX)
369 enum pipe_reset_status status = sctx->ws->ctx_query_reset_status(sctx->ctx, false, &needs_reset);
371 if (status != PIPE_NO_RESET && needs_reset && !(sctx->context_flags & SI_CONTEXT_FLAG_AUX)) {
373 if (sctx->device_reset_callback.reset) {
374 sctx->device_reset_callback.reset(sctx->device_reset_callback.data, status);
383 struct si_context *sctx = (struct si_context *)ctx;
386 sctx->device_reset_callback = *cb;
388 memset(&sctx->device_reset_callback, 0, sizeof(sctx->device_reset_callback));
401 struct si_context *sctx = (struct si_context *)ctx;
403 dd_parse_apitrace_marker(string, len, &sctx->apitrace_call_number);
405 if (sctx->thread_trace_enabled)
406 si_write_user_event(sctx, &sctx->gfx_cs, UserEventTrigger, string, len);
408 if (sctx->log)
409 u_log_printf(sctx->log, "\nString marker: %*s\n", len, string);
414 struct si_context *sctx = (struct si_context *)ctx;
415 struct si_screen *screen = sctx->screen;
421 sctx->debug = *cb;
423 memset(&sctx->debug, 0, sizeof(sctx->debug));
428 struct si_context *sctx = (struct si_context *)ctx;
429 sctx->log = log;
432 u_log_add_auto_logger(log, si_auto_log_cs, sctx);
450 struct si_context *sctx = (struct si_context *)ctx;
453 sctx->is_noop = enable;
467 struct si_context *sctx = CALLOC_STRUCT(si_context);
473 if (!sctx) {
478 sctx->has_graphics = sscreen->info.gfx_level == GFX6 || !(flags & PIPE_CONTEXT_COMPUTE_ONLY);
483 sctx->b.screen = screen; /* this must be set first */
484 sctx->b.priv = NULL;
485 sctx->b.destroy = si_destroy_context;
486 sctx->screen = sscreen; /* Easy accessing of screen/winsys. */
487 sctx->is_debug = (flags & PIPE_CONTEXT_DEBUG) != 0;
488 sctx->context_flags = flags;
490 slab_create_child(&sctx->pool_transfers, &sscreen->pool_transfers);
491 slab_create_child(&sctx->pool_transfers_unsync, &sscreen->pool_transfers);
493 sctx->ws = sscreen->ws;
494 sctx->family = sscreen->info.family;
495 sctx->gfx_level = sscreen->info.gfx_level;
497 if (sctx->gfx_level == GFX7 || sctx->gfx_level == GFX8 || sctx->gfx_level == GFX9) {
498 sctx->eop_bug_scratch = si_aligned_buffer_create(
501 if (!sctx->eop_bug_scratch) {
516 sctx->ctx = sctx->ws->ctx_create(sctx->ws, priority);
517 if (!sctx->ctx && priority != RADEON_CTX_PRIORITY_MEDIUM) {
524 sctx->ctx = sctx->ws->ctx_create(sctx->ws, priority);
526 if (!sctx->ctx) {
531 ws->cs_create(&sctx->gfx_cs, sctx->ctx, sctx->has_graphics ? AMD_IP_GFX : AMD_IP_COMPUTE,
532 (void *)si_flush_gfx_cs, sctx, stop_exec_on_failure);
535 u_suballocator_init(&sctx->allocator_zeroed_memory, &sctx->b, 128 * 1024, 0,
539 sctx->cached_gtt_allocator = u_upload_create(&sctx->b, 16 * 1024, 0, PIPE_USAGE_STAGING, 0);
540 if (!sctx->cached_gtt_allocator) {
553 sctx->b.stream_uploader =
554 u_upload_create(&sctx->b, 1024 * 1024, 0,
557 if (!sctx->b.stream_uploader) {
563 sctx->b.const_uploader = sctx->b.stream_uploader;
565 sctx->b.const_uploader =
566 u_upload_create(&sctx->b, 256 * 1024, 0, PIPE_USAGE_DEFAULT,
568 if (!sctx->b.const_uploader) {
576 sctx->border_color_table = malloc(SI_MAX_BORDER_COLORS * sizeof(*sctx->border_color_table));
577 if (!sctx->border_color_table) {
582 sctx->border_color_buffer = si_resource(pipe_buffer_create(
583 screen, 0, PIPE_USAGE_DEFAULT, SI_MAX_BORDER_COLORS * sizeof(*sctx->border_color_table)));
584 if (!sctx->border_color_buffer) {
589 sctx->border_color_map =
590 ws->buffer_map(ws, sctx->border_color_buffer->buf, NULL, PIPE_MAP_WRITE);
591 if (!sctx->border_color_map) {
597 sctx->ngg = sscreen->use_ngg;
598 si_shader_change_notify(sctx);
601 if (sctx->gfx_level >= GFX10)
602 sctx->emit_cache_flush = gfx10_emit_cache_flush;
604 sctx->emit_cache_flush = si_emit_cache_flush;
606 sctx->b.emit_string_marker = si_emit_string_marker;
607 sctx->b.set_debug_callback = si_set_debug_callback;
608 sctx->b.set_log_context = si_set_log_context;
609 sctx->b.set_context_param = si_set_context_param;
610 sctx->b.get_device_reset_status = si_get_reset_status;
611 sctx->b.set_device_reset_callback = si_set_device_reset_callback;
612 sctx->b.set_frontend_noop = si_set_frontend_noop;
614 si_init_all_descriptors(sctx);
615 si_init_buffer_functions(sctx);
616 si_init_clear_functions(sctx);
617 si_init_blit_functions(sctx);
618 si_init_compute_functions(sctx);
619 si_init_compute_blit_functions(sctx);
620 si_init_debug_functions(sctx);
621 si_init_fence_functions(sctx);
622 si_init_query_functions(sctx);
623 si_init_state_compute_functions(sctx);
624 si_init_context_texture_functions(sctx);
627 if (sctx->has_graphics) {
628 if (sctx->gfx_level >= GFX10)
629 gfx10_init_query(sctx);
630 si_init_msaa_functions(sctx);
631 si_init_shader_functions(sctx);
632 si_init_state_functions(sctx);
633 si_init_streamout_functions(sctx);
634 si_init_viewport_functions(sctx);
635 si_init_spi_map_functions(sctx);
637 sctx->blitter = util_blitter_create(&sctx->b);
638 if (sctx->blitter == NULL) {
642 sctx->blitter->skip_viewport_restore = true;
645 sctx->noop_blend = util_blitter_get_noop_blend_state(sctx->blitter);
646 sctx->queued.named.blend = sctx->noop_blend;
648 sctx->noop_dsa = util_blitter_get_noop_dsa_state(sctx->blitter);
649 sctx->queued.named.dsa = sctx->noop_dsa;
651 sctx->no_velems_state = sctx->b.create_vertex_elements_state(&sctx->b, 0, NULL);
652 sctx->vertex_elements = sctx->no_velems_state;
654 sctx->discard_rasterizer_state = util_blitter_get_discard_rasterizer_state(sctx->blitter);
655 sctx->queued.named.rasterizer = sctx->discard_rasterizer_state;
657 switch (sctx->gfx_level) {
659 si_init_draw_functions_GFX6(sctx);
662 si_init_draw_functions_GFX7(sctx);
665 si_init_draw_functions_GFX8(sctx);
668 si_init_draw_functions_GFX9(sctx);
671 si_init_draw_functions_GFX10(sctx);
674 si_init_draw_functions_GFX10_3(sctx);
677 si_init_draw_functions_GFX11(sctx);
684 sctx->sample_mask = 0xffff;
690 sctx->b.create_video_codec = si_uvd_create_decoder;
691 sctx->b.create_video_buffer = si_video_buffer_create;
693 sctx->b.create_video_buffer_with_modifiers = si_video_buffer_create_with_modifiers;
695 sctx->b.create_video_codec = vl_create_decoder;
696 sctx->b.create_video_buffer = vl_video_buffer_create;
701 if (sctx->gfx_level == GFX7) {
702 sctx->null_const_buf.buffer =
707 sctx->screen->info.tcc_cache_line_size);
708 if (!sctx->null_const_buf.buffer) {
712 sctx->null_const_buf.buffer_size = sctx->null_const_buf.buffer->width0;
714 unsigned start_shader = sctx->has_graphics ? 0 : PIPE_SHADER_COMPUTE;
717 sctx->b.set_constant_buffer(&sctx->b, shader, i, false, &sctx->null_const_buf);
721 si_set_internal_const_buffer(sctx, SI_HS_CONST_DEFAULT_TESS_LEVELS, &sctx->null_const_buf);
722 si_set_internal_const_buffer(sctx, SI_VS_CONST_INSTANCE_DIVISORS, &sctx->null_const_buf);
723 si_set_internal_const_buffer(sctx, SI_VS_CONST_CLIP_PLANES, &sctx->null_const_buf);
724 si_set_internal_const_buffer(sctx, SI_PS_CONST_POLY_STIPPLE, &sctx->null_const_buf);
725 si_set_internal_const_buffer(sctx, SI_PS_CONST_SAMPLE_POSITIONS, &sctx->null_const_buf);
729 sctx->tex_handles = _mesa_hash_table_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal);
730 sctx->img_handles = _mesa_hash_table_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal);
732 util_dynarray_init(&sctx->resident_tex_handles, NULL);
733 util_dynarray_init(&sctx->resident_img_handles, NULL);
734 util_dynarray_init(&sctx->resident_tex_needs_color_decompress, NULL);
735 util_dynarray_init(&sctx->resident_img_needs_color_decompress, NULL);
736 util_dynarray_init(&sctx->resident_tex_needs_depth_decompress, NULL);
738 sctx->dirty_implicit_resources = _mesa_pointer_hash_table_create(NULL);
739 if (!sctx->dirty_implicit_resources) {
745 assert(sctx->gfx_cs.current.cdw == 0);
747 if (sctx->has_graphics) {
748 si_init_cp_reg_shadowing(sctx);
752 if (sctx->gfx_level >= GFX9) {
762 sctx->shader.tcs.key.ge.opt.prefer_mono = 1;
765 sctx->shader.gs.key.ge.opt.prefer_mono = 1;
768 si_begin_new_gfx_cs(sctx, true);
769 assert(sctx->gfx_cs.current.cdw == sctx->initial_gfx_cs_size);
771 if (sctx->gfx_level >= GFX9 && sctx->gfx_level < GFX11) {
772 sctx->wait_mem_scratch =
778 if (!sctx->wait_mem_scratch) {
783 si_cp_write_data(sctx, sctx->wait_mem_scratch, 0, 4, V_370_MEM, V_370_ME,
784 &sctx->wait_mem_number);
787 if (sctx->gfx_level == GFX7) {
793 si_clear_buffer(sctx, sctx->null_const_buf.buffer, 0, sctx->null_const_buf.buffer->width0,
804 enum pipe_reset_status status = sctx->ws->ctx_query_reset_status(
829 sctx->initial_gfx_cs_size = sctx->gfx_cs.current.cdw;
830 return &sctx->b;
833 si_destroy_context(&sctx->b);
999 struct si_context *sctx = (struct si_context *)ctx;
1010 si_cp_dma_copy_buffer(sctx, buf, buf, 0, 4, 4, SI_OP_SYNC_BEFORE_AFTER,
1022 static void si_test_gds_memory_management(struct si_context *sctx, unsigned alloc_size,
1025 struct radeon_winsys *ws = sctx->ws;
1030 ws->cs_create(&cs[i], sctx->ctx, AMD_IP_COMPUTE, NULL, NULL, false);
1043 sctx, &cs[i], NULL, 0, alloc_size, 0,