Lines Matching refs:sctx
44 void si_blitter_begin(struct si_context *sctx, enum si_blitter_op op)
46 util_blitter_save_vertex_shader(sctx->blitter, sctx->shader.vs.cso);
47 util_blitter_save_tessctrl_shader(sctx->blitter, sctx->shader.tcs.cso);
48 util_blitter_save_tesseval_shader(sctx->blitter, sctx->shader.tes.cso);
49 util_blitter_save_geometry_shader(sctx->blitter, sctx->shader.gs.cso);
50 util_blitter_save_so_targets(sctx->blitter, sctx->streamout.num_targets,
51 (struct pipe_stream_output_target **)sctx->streamout.targets);
52 util_blitter_save_rasterizer(sctx->blitter, sctx->queued.named.rasterizer);
56 si_get_pipe_constant_buffer(sctx, PIPE_SHADER_FRAGMENT, 0, &fs_cb);
57 util_blitter_save_fragment_constant_buffer_slot(sctx->blitter, &fs_cb);
59 util_blitter_save_blend(sctx->blitter, sctx->queued.named.blend);
60 util_blitter_save_depth_stencil_alpha(sctx->blitter, sctx->queued.named.dsa);
61 util_blitter_save_stencil_ref(sctx->blitter, &sctx->stencil_ref.state);
62 util_blitter_save_fragment_shader(sctx->blitter, sctx->shader.ps.cso);
63 util_blitter_save_sample_mask(sctx->blitter, sctx->sample_mask, sctx->ps_iter_samples);
64 util_blitter_save_scissor(sctx->blitter, &sctx->scissors[0]);
65 util_blitter_save_window_rectangles(sctx->blitter, sctx->window_rectangles_include,
66 sctx->num_window_rectangles, sctx->window_rectangles);
70 util_blitter_save_framebuffer(sctx->blitter, &sctx->framebuffer.state);
74 sctx->blitter, 2, (void **)sctx->samplers[PIPE_SHADER_FRAGMENT].sampler_states);
76 util_blitter_save_fragment_sampler_views(sctx->blitter, 2,
77 sctx->samplers[PIPE_SHADER_FRAGMENT].views);
81 sctx->render_cond_enabled = false;
83 if (sctx->screen->dpbb_allowed) {
84 sctx->dpbb_force_off = true;
85 si_mark_atom_dirty(sctx, &sctx->atoms.s.dpbb_state);
88 sctx->blitter_running = true;
91 void si_blitter_end(struct si_context *sctx)
93 sctx->blitter_running = false;
95 if (sctx->screen->dpbb_allowed) {
96 sctx->dpbb_force_off = false;
97 si_mark_atom_dirty(sctx, &sctx->atoms.s.dpbb_state);
100 sctx->render_cond_enabled = sctx->render_cond;
104 sctx->shader_pointers_dirty |= SI_DESCS_SHADER_MASK(VERTEX);
106 if (sctx->gfx_level >= GFX11)
107 sctx->gs_attribute_ring_pointer_dirty = true;
110 if (sctx->screen->use_ngg_culling)
111 si_mark_atom_dirty(sctx, &sctx->atoms.s.ngg_cull_state);
113 unsigned num_vbos_in_user_sgprs = si_num_vbos_in_user_sgprs(sctx->screen);
114 sctx->vertex_buffer_pointer_dirty = sctx->vb_descriptors_buffer != NULL &&
115 sctx->num_vertex_elements >
117 sctx->vertex_buffer_user_sgprs_dirty = sctx->num_vertex_elements > 0 &&
119 si_mark_atom_dirty(sctx, &sctx->atoms.s.shader_pointers);
127 static unsigned si_blit_dbcb_copy(struct si_context *sctx, struct si_texture *src,
137 sctx->dbcb_depth_copy_enabled = true;
139 sctx->dbcb_stencil_copy_enabled = true;
140 si_mark_atom_dirty(sctx, &sctx->atoms.s.db_render_state);
142 assert(sctx->dbcb_depth_copy_enabled || sctx->dbcb_stencil_copy_enabled);
144 sctx->decompression_enabled = true;
163 zsurf = sctx->b.create_surface(&sctx->b, &src->buffer.b.b, &surf_tmpl);
166 cbsurf = sctx->b.create_surface(&sctx->b, &dst->buffer.b.b, &surf_tmpl);
169 if (sample != sctx->dbcb_copy_sample) {
170 sctx->dbcb_copy_sample = sample;
171 si_mark_atom_dirty(sctx, &sctx->atoms.s.db_render_state);
174 si_blitter_begin(sctx, SI_DECOMPRESS);
175 util_blitter_custom_depth_stencil(sctx->blitter, zsurf, cbsurf, 1 << sample,
176 sctx->custom_dsa_flush, 1.0f);
177 si_blitter_end(sctx);
189 sctx->decompression_enabled = false;
190 sctx->dbcb_depth_copy_enabled = false;
191 sctx->dbcb_stencil_copy_enabled = false;
192 si_mark_atom_dirty(sctx, &sctx->atoms.s.db_render_state);
199 static void si_blit_decompress_zs_planes_in_place(struct si_context *sctx,
212 sctx->db_flush_stencil_inplace = true;
214 sctx->db_flush_depth_inplace = true;
215 si_mark_atom_dirty(sctx, &sctx->atoms.s.db_render_state);
219 sctx->decompression_enabled = true;
235 zsurf = sctx->b.create_surface(&sctx->b, &texture->buffer.b.b, &surf_tmpl);
237 si_blitter_begin(sctx, SI_DECOMPRESS);
238 util_blitter_custom_depth_stencil(sctx->blitter, zsurf, NULL, ~0, sctx->custom_dsa_flush,
240 si_blitter_end(sctx);
257 sctx->decompression_enabled = false;
258 sctx->db_flush_depth_inplace = false;
259 sctx->db_flush_stencil_inplace = false;
260 si_mark_atom_dirty(sctx, &sctx->atoms.s.db_render_state);
266 static void si_blit_decompress_zs_in_place(struct si_context *sctx, struct si_texture *texture,
274 si_blit_decompress_zs_planes_in_place(sctx, texture, PIPE_MASK_Z | PIPE_MASK_S, both,
282 si_blit_decompress_zs_planes_in_place(sctx, texture, PIPE_MASK_Z, levels_z, first_layer,
287 si_blit_decompress_zs_planes_in_place(sctx, texture, PIPE_MASK_S, levels_s, first_layer,
292 static void si_decompress_depth(struct si_context *sctx, struct si_texture *tex,
323 if (unlikely(sctx->log))
324 u_log_printf(sctx->log,
333 (tex->flushed_depth_texture || si_init_flushed_depth_texture(&sctx->b, &tex->buffer.b.b))) {
352 fully_copied_levels = si_blit_dbcb_copy(sctx, tex, dst, copy_planes, levels, first_layer,
368 si_blit_decompress_zs_in_place(sctx, tex, levels_z, levels_s, first_layer, last_layer);
399 si_make_DB_shader_coherent(sctx, tex->buffer.b.b.nr_samples, inplace_planes & PIPE_MASK_S,
406 si_make_CB_shader_coherent(sctx, tex->buffer.b.b.nr_samples, false, true /* no DCC */);
409 static bool si_decompress_sampler_depth_textures(struct si_context *sctx,
430 si_decompress_depth(sctx, tex, sview->is_stencil_sampler ? PIPE_MASK_S : PIPE_MASK_Z,
443 static void si_blit_decompress_color(struct si_context *sctx, struct si_texture *tex,
458 assert(sctx->gfx_level < GFX11 || need_dcc_decompress);
460 if (unlikely(sctx->log))
461 u_log_printf(sctx->log,
467 custom_blend = sctx->custom_blend_dcc_decompress;
477 custom_blend = sctx->custom_blend_fmask_decompress;
479 custom_blend = sctx->custom_blend_eliminate_fastclear;
482 sctx->decompression_enabled = true;
499 cbsurf = sctx->b.create_surface(&sctx->b, &tex->buffer.b.b, &surf_tmpl);
502 if (custom_blend == sctx->custom_blend_fmask_decompress ||
503 custom_blend == sctx->custom_blend_dcc_decompress)
504 sctx->flags |= SI_CONTEXT_FLUSH_AND_INV_CB;
506 si_blitter_begin(sctx, SI_DECOMPRESS);
507 util_blitter_custom_color(sctx->blitter, cbsurf, custom_blend);
508 si_blitter_end(sctx);
510 if (custom_blend == sctx->custom_blend_fmask_decompress ||
511 custom_blend == sctx->custom_blend_dcc_decompress)
512 sctx->flags |= SI_CONTEXT_FLUSH_AND_INV_CB;
522 if (sctx->screen->allow_dcc_msaa_clear_to_reg_for_bpp[util_logbase2(tex->surface.bpe)] &&
523 custom_blend == sctx->custom_blend_fmask_decompress &&
525 si_blitter_begin(sctx, SI_DECOMPRESS);
526 util_blitter_custom_color(sctx->blitter, cbsurf, sctx->custom_blend_eliminate_fastclear);
527 si_blitter_end(sctx);
540 sctx->decompression_enabled = false;
541 si_make_CB_shader_coherent(sctx, tex->buffer.b.b.nr_samples, vi_dcc_enabled(tex, first_level),
546 assert(sctx->gfx_level < GFX11); /* no FMASK on gfx11 */
547 si_compute_expand_fmask(&sctx->b, &tex->buffer.b.b);
552 static void si_decompress_color_texture(struct si_context *sctx, struct si_texture *tex,
561 si_blit_decompress_color(sctx, tex, first_level, last_level, 0,
566 static void si_decompress_sampler_color_textures(struct si_context *sctx,
583 si_decompress_color_texture(sctx, tex, view->u.tex.first_level, view->u.tex.last_level,
588 static void si_decompress_image_color_textures(struct si_context *sctx, struct si_images *images)
604 si_decompress_color_texture(sctx, tex, view->u.tex.level, view->u.tex.level,
609 static void si_check_render_feedback_texture(struct si_context *sctx, struct si_texture *tex,
618 for (unsigned j = 0; j < sctx->framebuffer.state.nr_cbufs; ++j) {
621 if (!sctx->framebuffer.state.cbufs[j])
624 surf = (struct si_surface *)sctx->framebuffer.state.cbufs[j];
635 si_texture_disable_dcc(sctx, tex);
638 static void si_check_render_feedback_textures(struct si_context *sctx, struct si_samplers *textures,
655 si_check_render_feedback_texture(sctx, tex, view->u.tex.first_level, view->u.tex.last_level,
660 static void si_check_render_feedback_images(struct si_context *sctx, struct si_images *images,
677 si_check_render_feedback_texture(sctx, tex, view->u.tex.level, view->u.tex.level,
682 static void si_check_render_feedback_resident_textures(struct si_context *sctx)
684 util_dynarray_foreach (&sctx->resident_tex_handles, struct si_texture_handle *, tex_handle) {
694 si_check_render_feedback_texture(sctx, tex, view->u.tex.first_level, view->u.tex.last_level,
699 static void si_check_render_feedback_resident_images(struct si_context *sctx)
701 util_dynarray_foreach (&sctx->resident_img_handles, struct si_image_handle *, img_handle) {
711 si_check_render_feedback_texture(sctx, tex, view->u.tex.level, view->u.tex.level,
716 static void si_check_render_feedback(struct si_context *sctx)
718 if (!sctx->need_check_render_feedback)
724 if (!si_get_total_colormask(sctx))
728 if (!sctx->shaders[i].cso)
731 struct si_shader_info *info = &sctx->shaders[i].cso->info;
732 si_check_render_feedback_images(sctx, &sctx->images[i],
734 si_check_render_feedback_textures(sctx, &sctx->samplers[i],
738 si_check_render_feedback_resident_images(sctx);
739 si_check_render_feedback_resident_textures(sctx);
741 sctx->need_check_render_feedback = false;
744 static void si_decompress_resident_textures(struct si_context *sctx)
746 util_dynarray_foreach (&sctx->resident_tex_needs_color_decompress, struct si_texture_handle *,
751 si_decompress_color_texture(sctx, tex, view->u.tex.first_level, view->u.tex.last_level,
755 util_dynarray_foreach (&sctx->resident_tex_needs_depth_decompress, struct si_texture_handle *,
761 si_decompress_depth(sctx, tex, sview->is_stencil_sampler ? PIPE_MASK_S : PIPE_MASK_Z,
767 static void si_decompress_resident_images(struct si_context *sctx)
769 util_dynarray_foreach (&sctx->resident_img_needs_color_decompress, struct si_image_handle *,
774 si_decompress_color_texture(sctx, tex, view->u.tex.level, view->u.tex.level,
779 void si_decompress_textures(struct si_context *sctx, unsigned shader_mask)
784 if (sctx->blitter_running)
788 compressed_colortex_counter = p_atomic_read(&sctx->screen->compressed_colortex_counter);
789 if (compressed_colortex_counter != sctx->last_compressed_colortex_counter) {
790 sctx->last_compressed_colortex_counter = compressed_colortex_counter;
791 si_update_needs_color_decompress_masks(sctx);
795 mask = sctx->shader_needs_decompress_mask & shader_mask;
799 if (sctx->samplers[i].needs_depth_decompress_mask) {
800 need_flush |= si_decompress_sampler_depth_textures(sctx, &sctx->samplers[i]);
802 if (sctx->samplers[i].needs_color_decompress_mask) {
803 si_decompress_sampler_color_textures(sctx, &sctx->samplers[i]);
805 if (sctx->images[i].needs_color_decompress_mask) {
806 si_decompress_image_color_textures(sctx, &sctx->images[i]);
810 if (sctx->gfx_level == GFX10_3 && need_flush) {
817 sctx->b.flush(&sctx->b, NULL, RADEON_FLUSH_ASYNC_START_NEXT_GFX_IB_NOW);
821 if (sctx->uses_bindless_samplers)
822 si_decompress_resident_textures(sctx);
823 if (sctx->uses_bindless_images)
824 si_decompress_resident_images(sctx);
826 if (sctx->ps_uses_fbfetch) {
827 struct pipe_surface *cb0 = sctx->framebuffer.state.cbufs[0];
828 si_decompress_color_texture(sctx, (struct si_texture *)cb0->texture,
832 si_check_render_feedback(sctx);
834 if (sctx->cs_shader_state.program->sel.info.uses_bindless_samplers)
835 si_decompress_resident_textures(sctx);
836 if (sctx->cs_shader_state.program->sel.info.uses_bindless_images)
837 si_decompress_resident_images(sctx);
849 struct si_context *sctx = (struct si_context *)ctx;
862 if (sctx->framebuffer.state.zsbuf && sctx->framebuffer.state.zsbuf->u.tex.level == level &&
863 sctx->framebuffer.state.zsbuf->texture == tex)
864 si_update_fb_dirtiness_after_rendering(sctx);
866 si_decompress_depth(sctx, stex, planes, level, level, first_layer, last_layer);
873 for (unsigned i = 0; i < sctx->framebuffer.state.nr_cbufs; i++) {
874 if (sctx->framebuffer.state.cbufs[i] &&
875 sctx->framebuffer.state.cbufs[i]->u.tex.level == level &&
876 sctx->framebuffer.state.cbufs[i]->texture == tex) {
877 si_update_fb_dirtiness_after_rendering(sctx);
882 si_blit_decompress_color(sctx, stex, level, level, first_layer, last_layer, false,
902 struct si_context *sctx = (struct si_context *)ctx;
910 si_copy_buffer(sctx, dst, src, dstx, src_box->x, src_box->width, SI_OP_SYNC_BEFORE_AFTER);
914 if (si_compute_copy_image(sctx, dst, dst_level, src, src_level, dstx, dsty, dstz,
926 util_blitter_default_src_texture(sctx->blitter, &src_templ, src, src_level);
931 if (!util_blitter_is_copy_supported(sctx->blitter, dst, src)) {
967 vi_disable_dcc_if_incompatible_format(sctx, dst, dst_level, dst_templ.format);
968 vi_disable_dcc_if_incompatible_format(sctx, src, src_level, src_templ.format);
980 si_blitter_begin(sctx, SI_COPY);
981 util_blitter_blit_generic(sctx->blitter, dst_view, &dstbox, src_view, src_box, src->width0,
984 si_blitter_end(sctx);
990 static void si_do_CB_resolve(struct si_context *sctx, const struct pipe_blit_info *info,
995 sctx->flags |= SI_CONTEXT_FLUSH_AND_INV_CB;
998 sctx, SI_COLOR_RESOLVE | (info->render_condition_enable ? 0 : SI_DISABLE_RENDER_COND));
999 util_blitter_custom_resolve_color(sctx->blitter, dst, dst_level, dst_z, info->src.resource,
1000 info->src.box.z, ~0, sctx->custom_blend_resolve, format);
1001 si_blitter_end(sctx);
1004 si_make_CB_shader_coherent(sctx, 1, false, true /* no DCC */);
1031 struct si_context *sctx = (struct si_context *)ctx;
1034 if (sctx->gfx_level >= GFX11)
1047 if (sctx->gfx_level >= GFX11)
1105 if (!vi_dcc_get_clear_info(sctx, dst, info->dst.level, DCC_UNCOMPRESSED, &clear_info))
1108 si_execute_clears(sctx, &clear_info, 1, SI_CLEAR_TYPE_DCC);
1113 si_do_CB_resolve(sctx, info, info->dst.resource, info->dst.level, info->dst.box.z, format);
1134 if (sctx->gfx_level <= GFX8 && src->surface.micro_tile_mode == RADEON_MICRO_MODE_DISPLAY)
1150 si_do_CB_resolve(sctx, info, tmp, 0, 0, format);
1165 struct si_context *sctx = (struct si_context *)ctx;
1168 if (sctx->gfx_level >= GFX7 &&
1177 util_can_blit_via_copy_region(info, true, sctx->render_cond != NULL)) {
1181 if (si_sdma_copy_image(sctx, sdst, ssrc))
1185 struct si_screen *sscreen = sctx->screen;
1192 si_compute_copy_image((struct si_context*)sctx->screen->async_compute_context,
1195 si_flush_gfx_cs((struct si_context*)sctx->screen->async_compute_context, 0, NULL);
1203 if (unlikely(sctx->thread_trace_enabled))
1204 sctx->sqtt_next_event = EventCmdResolveImage;
1209 if (unlikely(sctx->thread_trace_enabled))
1210 sctx->sqtt_next_event = EventCmdCopyImage;
1215 if (util_can_blit_via_copy_region(info, false, sctx->render_cond != NULL)) {
1227 struct si_context *sctx = (struct si_context *)ctx;
1229 assert(util_blitter_is_blit_supported(sctx->blitter, info));
1233 vi_disable_dcc_if_incompatible_format(sctx, info->src.resource, info->src.level,
1235 vi_disable_dcc_if_incompatible_format(sctx, info->dst.resource, info->dst.level,
1241 if (unlikely(sctx->thread_trace_enabled))
1242 sctx->sqtt_next_event = EventCmdBlitImage;
1244 si_blitter_begin(sctx, SI_BLIT | (info->render_condition_enable ? 0 : SI_DISABLE_RENDER_COND));
1245 util_blitter_blit(sctx->blitter, info);
1246 si_blitter_end(sctx);
1253 struct si_context *sctx = (struct si_context *)ctx;
1256 if (!util_blitter_is_copy_supported(sctx->blitter, tex, tex))
1261 vi_disable_dcc_if_incompatible_format(sctx, tex, base_level, format);
1269 sctx->generate_mipmap_for_depth = stex->is_depth;
1271 si_blitter_begin(sctx, SI_BLIT | SI_DISABLE_RENDER_COND);
1272 util_blitter_generate_mipmap(sctx->blitter, tex, format, base_level, last_level, first_layer,
1274 si_blitter_end(sctx);
1276 sctx->generate_mipmap_for_depth = false;
1282 struct si_context *sctx = (struct si_context *)ctx;
1289 si_blit_decompress_color(sctx, tex, 0, res->last_level, 0, util_max_layer(res, 0),
1293 si_retile_dcc(sctx, tex);
1299 void si_flush_implicit_resources(struct si_context *sctx)
1301 hash_table_foreach(sctx->dirty_implicit_resources, entry) {
1302 si_flush_resource(&sctx->b, entry->data);
1305 _mesa_hash_table_clear(sctx->dirty_implicit_resources, NULL);
1308 void si_decompress_dcc(struct si_context *sctx, struct si_texture *tex)
1315 if (!tex->surface.meta_offset || !sctx->has_graphics)
1318 si_blit_decompress_color(sctx, tex, 0, tex->buffer.b.b.last_level, 0,
1322 void si_init_blit_functions(struct si_context *sctx)
1324 sctx->b.resource_copy_region = si_resource_copy_region;
1326 if (sctx->has_graphics) {
1327 sctx->b.blit = si_blit;
1328 sctx->b.flush_resource = si_flush_resource;
1329 sctx->b.generate_mipmap = si_generate_mipmap;