2 * Copyright 2013 Advanced Micro Devices, Inc.
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 (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
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 FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * This file contains common screen and context structures and functions
26 * for r600g and radeonsi.
29 #ifndef R600_PIPE_COMMON_H
30 #define R600_PIPE_COMMON_H
34 #include "amd/common/ac_binary.h"
36 #include "radeon/radeon_winsys.h"
38 #include "util/disk_cache.h"
39 #include "util/u_blitter.h"
40 #include "util/list.h"
41 #include "util/u_range.h"
42 #include "util/slab.h"
43 #include "util/u_suballoc.h"
44 #include "util/u_transfer.h"
45 #include "util/u_threaded_context.h"
49 #define R600_RESOURCE_FLAG_TRANSFER (PIPE_RESOURCE_FLAG_DRV_PRIV << 0)
50 #define R600_RESOURCE_FLAG_FLUSHED_DEPTH (PIPE_RESOURCE_FLAG_DRV_PRIV << 1)
51 #define R600_RESOURCE_FLAG_FORCE_TILING (PIPE_RESOURCE_FLAG_DRV_PRIV << 2)
52 #define R600_RESOURCE_FLAG_DISABLE_DCC (PIPE_RESOURCE_FLAG_DRV_PRIV << 3)
53 #define R600_RESOURCE_FLAG_UNMAPPABLE (PIPE_RESOURCE_FLAG_DRV_PRIV << 4)
57 /* Shader logging options: */
58 DBG_VS
= PIPE_SHADER_VERTEX
,
59 DBG_PS
= PIPE_SHADER_FRAGMENT
,
60 DBG_GS
= PIPE_SHADER_GEOMETRY
,
61 DBG_TCS
= PIPE_SHADER_TESS_CTRL
,
62 DBG_TES
= PIPE_SHADER_TESS_EVAL
,
63 DBG_CS
= PIPE_SHADER_COMPUTE
,
69 /* Shader compiler options the shader cache should be aware of: */
70 DBG_FS_CORRECT_DERIVS_AFTER_KILL
,
74 /* Shader compiler options (with no effect on the shader cache): */
78 DBG_MONOLITHIC_SHADERS
,
81 /* Information logging options: */
94 /* 3D engine options: */
114 DBG_TEST_VMFAULT_SDMA
,
115 DBG_TEST_VMFAULT_SHADER
,
118 #define DBG_ALL_SHADERS (((1 << (DBG_CS + 1)) - 1))
119 #define DBG(name) (1ull << DBG_##name)
121 #define R600_MAP_BUFFER_ALIGNMENT 64
123 #define SI_MAX_VARIABLE_THREADS_PER_BLOCK 1024
125 struct r600_common_context
;
126 struct r600_perfcounters
;
127 struct tgsi_shader_info
;
128 struct r600_qbo_state
;
130 /* Only 32-bit buffer allocations are supported, gallium doesn't support more
133 struct r600_resource
{
134 struct threaded_resource b
;
136 /* Winsys objects. */
137 struct pb_buffer
*buf
;
138 uint64_t gpu_address
;
139 /* Memory usage if the buffer placement is optimal. */
143 /* Resource properties. */
145 unsigned bo_alignment
;
146 enum radeon_bo_domain domains
;
147 enum radeon_bo_flag flags
;
148 unsigned bind_history
;
149 int max_forced_staging_uploads
;
151 /* The buffer range which is initialized (with a write transfer,
152 * streamout, DMA, or as a random access target). The rest of
153 * the buffer is considered invalid and can be mapped unsynchronized.
155 * This allows unsychronized mapping of a buffer range which hasn't
156 * been used yet. It's for applications which forget to use
157 * the unsynchronized map flag and expect the driver to figure it out.
159 struct util_range valid_buffer_range
;
161 /* For buffers only. This indicates that a write operation has been
162 * performed by TC L2, but the cache hasn't been flushed.
163 * Any hw block which doesn't use or bypasses TC L2 should check this
164 * flag and flush the cache before using the buffer.
166 * For example, TC L2 must be flushed if a buffer which has been
167 * modified by a shader store instruction is about to be used as
168 * an index buffer. The reason is that VGT DMA index fetching doesn't
173 /* Whether the resource has been exported via resource_get_handle. */
174 unsigned external_usage
; /* PIPE_HANDLE_USAGE_* */
176 /* Whether this resource is referenced by bindless handles. */
177 bool texture_handle_allocated
;
178 bool image_handle_allocated
;
181 struct r600_transfer
{
182 struct threaded_transfer b
;
183 struct r600_resource
*staging
;
187 struct r600_fmask_info
{
191 unsigned pitch_in_pixels
;
192 unsigned bank_height
;
193 unsigned slice_tile_max
;
194 unsigned tile_mode_index
;
195 unsigned tile_swizzle
;
198 struct r600_cmask_info
{
202 unsigned slice_tile_max
;
203 uint64_t base_address_reg
;
206 struct r600_texture
{
207 struct r600_resource resource
;
209 struct radeon_surf surface
;
211 struct r600_texture
*flushed_depth_texture
;
213 /* Colorbuffer compression and fast clear. */
214 struct r600_fmask_info fmask
;
215 struct r600_cmask_info cmask
;
216 struct r600_resource
*cmask_buffer
;
217 uint64_t dcc_offset
; /* 0 = disabled */
218 unsigned cb_color_info
; /* fast clear enable bit */
219 unsigned color_clear_value
[2];
220 unsigned last_msaa_resolve_target_micro_mode
;
221 unsigned num_level0_transfers
;
223 /* Depth buffer compression and fast clear. */
224 uint64_t htile_offset
;
225 float depth_clear_value
;
226 uint16_t dirty_level_mask
; /* each bit says if that mipmap is compressed */
227 uint16_t stencil_dirty_level_mask
; /* each bit says if that mipmap is compressed */
228 enum pipe_format db_render_format
:16;
229 uint8_t stencil_clear_value
;
230 bool tc_compatible_htile
:1;
231 bool depth_cleared
:1; /* if it was cleared at least once */
232 bool stencil_cleared
:1; /* if it was cleared at least once */
233 bool upgraded_depth
:1; /* upgraded from unorm to Z32_FLOAT */
235 bool db_compatible
:1;
239 /* We need to track DCC dirtiness, because st/dri usually calls
240 * flush_resource twice per frame (not a bug) and we don't wanna
241 * decompress DCC twice. Also, the dirty tracking must be done even
242 * if DCC isn't used, because it's required by the DCC usage analysis
243 * for a possible future enablement.
245 bool separate_dcc_dirty
:1;
246 /* Statistics gathering for the DCC enablement heuristic. */
247 bool dcc_gather_statistics
:1;
248 /* Counter that should be non-zero if the texture is bound to a
251 unsigned framebuffers_bound
;
252 /* Whether the texture is a displayable back buffer and needs DCC
253 * decompression, which is expensive. Therefore, it's enabled only
254 * if statistics suggest that it will pay off and it's allocated
255 * separately. It can't be bound as a sampler by apps. Limited to
256 * target == 2D and last_level == 0. If enabled, dcc_offset contains
257 * the absolute GPUVM address, not the relative one.
259 struct r600_resource
*dcc_separate_buffer
;
260 /* When DCC is temporarily disabled, the separate buffer is here. */
261 struct r600_resource
*last_dcc_separate_buffer
;
262 /* Estimate of how much this color buffer is written to in units of
263 * full-screen draws: ps_invocations / (width * height)
264 * Shader kills, late Z, and blending with trivial discards make it
265 * inaccurate (we need to count CB updates, not PS invocations).
267 unsigned ps_draw_ratio
;
268 /* The number of clears since the last DCC usage analysis. */
269 unsigned num_slow_clears
;
272 struct r600_surface
{
273 struct pipe_surface base
;
275 /* These can vary with block-compressed textures. */
279 bool color_initialized
:1;
280 bool depth_initialized
:1;
282 /* Misc. color flags. */
283 bool color_is_int8
:1;
284 bool color_is_int10
:1;
285 bool dcc_incompatible
:1;
287 /* Color registers. */
288 unsigned cb_color_info
;
289 unsigned cb_color_view
;
290 unsigned cb_color_attrib
;
291 unsigned cb_color_attrib2
; /* GFX9 and later */
292 unsigned cb_dcc_control
; /* VI and later */
293 unsigned spi_shader_col_format
:8; /* no blending, no alpha-to-coverage. */
294 unsigned spi_shader_col_format_alpha
:8; /* alpha-to-coverage */
295 unsigned spi_shader_col_format_blend
:8; /* blending without alpha. */
296 unsigned spi_shader_col_format_blend_alpha
:8; /* blending with alpha. */
299 uint64_t db_depth_base
; /* DB_Z_READ/WRITE_BASE */
300 uint64_t db_stencil_base
;
301 uint64_t db_htile_data_base
;
302 unsigned db_depth_info
;
304 unsigned db_z_info2
; /* GFX9+ */
305 unsigned db_depth_view
;
306 unsigned db_depth_size
;
307 unsigned db_depth_slice
;
308 unsigned db_stencil_info
;
309 unsigned db_stencil_info2
; /* GFX9+ */
310 unsigned db_htile_surface
;
313 struct r600_mmio_counter
{
318 union r600_mmio_counters
{
320 /* For global GPU load including SDMA. */
321 struct r600_mmio_counter gpu
;
324 struct r600_mmio_counter spi
;
325 struct r600_mmio_counter gui
;
326 struct r600_mmio_counter ta
;
327 struct r600_mmio_counter gds
;
328 struct r600_mmio_counter vgt
;
329 struct r600_mmio_counter ia
;
330 struct r600_mmio_counter sx
;
331 struct r600_mmio_counter wd
;
332 struct r600_mmio_counter bci
;
333 struct r600_mmio_counter sc
;
334 struct r600_mmio_counter pa
;
335 struct r600_mmio_counter db
;
336 struct r600_mmio_counter cp
;
337 struct r600_mmio_counter cb
;
340 struct r600_mmio_counter sdma
;
343 struct r600_mmio_counter pfp
;
344 struct r600_mmio_counter meq
;
345 struct r600_mmio_counter me
;
346 struct r600_mmio_counter surf_sync
;
347 struct r600_mmio_counter cp_dma
;
348 struct r600_mmio_counter scratch_ram
;
353 struct r600_memory_object
{
354 struct pipe_memory_object b
;
355 struct pb_buffer
*buf
;
360 struct r600_common_screen
{
361 struct pipe_screen b
;
362 struct radeon_winsys
*ws
;
363 enum radeon_family family
;
364 enum chip_class chip_class
;
365 struct radeon_info info
;
366 uint64_t debug_flags
;
367 bool has_rbplus
; /* if RB+ registers exist */
368 bool rbplus_allowed
; /* if RB+ is allowed */
369 bool dcc_msaa_allowed
;
371 struct disk_cache
*disk_shader_cache
;
373 struct slab_parent_pool pool_transfers
;
375 /* Texture filter settings. */
376 int force_aniso
; /* -1 = disabled */
378 /* Auxiliary context. Mainly used to initialize resources.
379 * It must be locked prior to using and flushed before unlocking. */
380 struct pipe_context
*aux_context
;
381 mtx_t aux_context_lock
;
383 /* This must be in the screen, because UE4 uses one context for
384 * compilation and another one for rendering.
386 unsigned num_compilations
;
387 /* Along with ST_DEBUG=precompile, this should show if applications
388 * are loading shaders on demand. This is a monotonic counter.
390 unsigned num_shaders_created
;
391 unsigned num_shader_cache_hits
;
393 /* GPU load thread. */
394 mtx_t gpu_load_mutex
;
395 thrd_t gpu_load_thread
;
396 union r600_mmio_counters mmio_counters
;
397 volatile unsigned gpu_load_stop_thread
; /* bool */
399 char renderer_string
[100];
401 /* Performance counters. */
402 struct r600_perfcounters
*perfcounters
;
404 /* If pipe_screen wants to recompute and re-emit the framebuffer,
405 * sampler, and image states of all contexts, it should atomically
408 * Each context will compare this with its own last known value of
409 * the counter before drawing and re-emit the states accordingly.
411 unsigned dirty_tex_counter
;
413 /* Atomically increment this counter when an existing texture's
414 * metadata is enabled or disabled in a way that requires changing
415 * contexts' compressed texture binding masks.
417 unsigned compressed_colortex_counter
;
420 /* Context flags to set so that all writes from earlier jobs
421 * in the CP are seen by L2 clients.
425 /* Context flags to set so that all writes from earlier jobs
426 * that end in L2 are seen by CP.
430 /* Context flags to set so that all writes from earlier
431 * compute jobs are seen by L2 clients.
433 unsigned compute_to_L2
;
436 void (*query_opaque_metadata
)(struct r600_common_screen
*rscreen
,
437 struct r600_texture
*rtex
,
438 struct radeon_bo_metadata
*md
);
440 void (*apply_opaque_metadata
)(struct r600_common_screen
*rscreen
,
441 struct r600_texture
*rtex
,
442 struct radeon_bo_metadata
*md
);
445 /* This encapsulates a state or an operation which can emitted into the GPU
448 void (*emit
)(struct r600_common_context
*ctx
, struct r600_atom
*state
);
453 struct radeon_winsys_cs
*cs
;
454 void (*flush
)(void *ctx
, unsigned flags
,
455 struct pipe_fence_handle
**fence
);
458 /* Saved CS data for debugging features. */
459 struct radeon_saved_cs
{
463 struct radeon_bo_list_item
*bo_list
;
467 struct r600_common_context
{
468 struct pipe_context b
; /* base class */
470 struct r600_common_screen
*screen
;
471 struct radeon_winsys
*ws
;
472 struct radeon_winsys_ctx
*ctx
;
473 enum radeon_family family
;
474 enum chip_class chip_class
;
475 struct r600_ring gfx
;
476 struct r600_ring dma
;
477 struct pipe_fence_handle
*last_gfx_fence
;
478 struct pipe_fence_handle
*last_sdma_fence
;
479 struct r600_resource
*eop_bug_scratch
;
480 unsigned num_gfx_cs_flushes
;
481 unsigned initial_gfx_cs_size
;
482 unsigned gpu_reset_counter
;
483 unsigned last_dirty_tex_counter
;
484 unsigned last_compressed_colortex_counter
;
485 unsigned last_num_draw_calls
;
487 struct threaded_context
*tc
;
488 struct u_suballocator
*allocator_zeroed_memory
;
489 struct slab_child_pool pool_transfers
;
490 struct slab_child_pool pool_transfers_unsync
; /* for threaded_context */
492 /* Current unaccounted memory usage. */
496 /* Additional context states. */
497 unsigned flags
; /* flush flags */
500 /* Maintain the list of active queries for pausing between IBs. */
501 int num_occlusion_queries
;
502 int num_perfect_occlusion_queries
;
503 struct list_head active_queries
;
504 unsigned num_cs_dw_queries_suspend
;
506 unsigned num_draw_calls
;
507 unsigned num_decompress_calls
;
508 unsigned num_mrt_draw_calls
;
509 unsigned num_prim_restart_calls
;
510 unsigned num_spill_draw_calls
;
511 unsigned num_compute_calls
;
512 unsigned num_spill_compute_calls
;
513 unsigned num_dma_calls
;
514 unsigned num_cp_dma_calls
;
515 unsigned num_vs_flushes
;
516 unsigned num_ps_flushes
;
517 unsigned num_cs_flushes
;
518 unsigned num_cb_cache_flushes
;
519 unsigned num_db_cache_flushes
;
520 unsigned num_L2_invalidates
;
521 unsigned num_L2_writebacks
;
522 unsigned num_resident_handles
;
523 uint64_t num_alloc_tex_transfer_bytes
;
524 unsigned last_tex_ps_draw_ratio
; /* for query */
526 /* Render condition. */
527 struct r600_atom render_cond_atom
;
528 struct pipe_query
*render_cond
;
529 unsigned render_cond_mode
;
530 bool render_cond_invert
;
531 bool render_cond_force_off
; /* for u_blitter */
533 /* Statistics gathering for the DCC enablement heuristic. It can't be
534 * in r600_texture because r600_texture can be shared by multiple
535 * contexts. This is for back buffers only. We shouldn't get too many
538 * X11 DRI3 rotates among a finite set of back buffers. They should
539 * all fit in this array. If they don't, separate DCC might never be
540 * enabled by DCC stat gathering.
543 struct r600_texture
*tex
;
544 /* Query queue: 0 = usually active, 1 = waiting, 2 = readback. */
545 struct pipe_query
*ps_stats
[3];
546 /* If all slots are used and another slot is needed,
547 * the least recently used slot is evicted based on this. */
548 int64_t last_use_timestamp
;
552 struct pipe_device_reset_callback device_reset_callback
;
553 struct u_log_context
*log
;
555 void *query_result_shader
;
557 /* Copy one resource to another using async DMA. */
558 void (*dma_copy
)(struct pipe_context
*ctx
,
559 struct pipe_resource
*dst
,
561 unsigned dst_x
, unsigned dst_y
, unsigned dst_z
,
562 struct pipe_resource
*src
,
564 const struct pipe_box
*src_box
);
566 void (*dma_clear_buffer
)(struct pipe_context
*ctx
, struct pipe_resource
*dst
,
567 uint64_t offset
, uint64_t size
, unsigned value
);
569 void (*blit_decompress_depth
)(struct pipe_context
*ctx
,
570 struct r600_texture
*texture
,
571 struct r600_texture
*staging
,
572 unsigned first_level
, unsigned last_level
,
573 unsigned first_layer
, unsigned last_layer
,
574 unsigned first_sample
, unsigned last_sample
);
576 void (*decompress_dcc
)(struct pipe_context
*ctx
,
577 struct r600_texture
*rtex
);
579 /* Reallocate the buffer and update all resource bindings where
580 * the buffer is bound, including all resource descriptors. */
581 void (*invalidate_buffer
)(struct pipe_context
*ctx
, struct pipe_resource
*buf
);
583 /* Update all resource bindings where the buffer is bound, including
584 * all resource descriptors. This is invalidate_buffer without
585 * the invalidation. */
586 void (*rebind_buffer
)(struct pipe_context
*ctx
, struct pipe_resource
*buf
,
587 uint64_t old_gpu_address
);
589 /* Enable or disable occlusion queries. */
590 void (*set_occlusion_query_state
)(struct pipe_context
*ctx
,
592 bool old_perfect_enable
);
594 void (*save_qbo_state
)(struct pipe_context
*ctx
, struct r600_qbo_state
*st
);
596 /* This ensures there is enough space in the command stream. */
597 void (*need_gfx_cs_space
)(struct pipe_context
*ctx
, unsigned num_dw
,
598 bool include_draw_vbo
);
600 void (*set_atom_dirty
)(struct r600_common_context
*ctx
,
601 struct r600_atom
*atom
, bool dirty
);
603 void (*check_vm_faults
)(struct r600_common_context
*ctx
,
604 struct radeon_saved_cs
*saved
,
605 enum ring_type ring
);
608 /* r600_buffer_common.c */
609 bool si_rings_is_buffer_referenced(struct r600_common_context
*ctx
,
610 struct pb_buffer
*buf
,
611 enum radeon_bo_usage usage
);
612 void *si_buffer_map_sync_with_rings(struct r600_common_context
*ctx
,
613 struct r600_resource
*resource
,
615 void si_buffer_subdata(struct pipe_context
*ctx
,
616 struct pipe_resource
*buffer
,
617 unsigned usage
, unsigned offset
,
618 unsigned size
, const void *data
);
619 void si_init_resource_fields(struct r600_common_screen
*rscreen
,
620 struct r600_resource
*res
,
621 uint64_t size
, unsigned alignment
);
622 bool si_alloc_resource(struct r600_common_screen
*rscreen
,
623 struct r600_resource
*res
);
624 struct pipe_resource
*si_buffer_create(struct pipe_screen
*screen
,
625 const struct pipe_resource
*templ
,
627 struct pipe_resource
*si_aligned_buffer_create(struct pipe_screen
*screen
,
632 struct pipe_resource
*
633 si_buffer_from_user_memory(struct pipe_screen
*screen
,
634 const struct pipe_resource
*templ
,
636 void si_invalidate_resource(struct pipe_context
*ctx
,
637 struct pipe_resource
*resource
);
638 void si_replace_buffer_storage(struct pipe_context
*ctx
,
639 struct pipe_resource
*dst
,
640 struct pipe_resource
*src
);
642 /* r600_common_pipe.c */
643 void si_gfx_write_event_eop(struct r600_common_context
*ctx
,
644 unsigned event
, unsigned event_flags
,
646 struct r600_resource
*buf
, uint64_t va
,
647 uint32_t new_fence
, unsigned query_type
);
648 unsigned si_gfx_write_fence_dwords(struct r600_common_screen
*screen
);
649 void si_gfx_wait_fence(struct r600_common_context
*ctx
,
650 uint64_t va
, uint32_t ref
, uint32_t mask
);
651 bool si_common_screen_init(struct r600_common_screen
*rscreen
,
652 struct radeon_winsys
*ws
);
653 void si_destroy_common_screen(struct r600_common_screen
*rscreen
);
654 bool si_common_context_init(struct r600_common_context
*rctx
,
655 struct r600_common_screen
*rscreen
,
656 unsigned context_flags
);
657 void si_common_context_cleanup(struct r600_common_context
*rctx
);
658 bool si_can_dump_shader(struct r600_common_screen
*rscreen
,
660 bool si_extra_shader_checks(struct r600_common_screen
*rscreen
,
662 void si_screen_clear_buffer(struct r600_common_screen
*rscreen
, struct pipe_resource
*dst
,
663 uint64_t offset
, uint64_t size
, unsigned value
);
664 struct pipe_resource
*si_resource_create_common(struct pipe_screen
*screen
,
665 const struct pipe_resource
*templ
);
666 void si_need_dma_space(struct r600_common_context
*ctx
, unsigned num_dw
,
667 struct r600_resource
*dst
, struct r600_resource
*src
);
668 void si_save_cs(struct radeon_winsys
*ws
, struct radeon_winsys_cs
*cs
,
669 struct radeon_saved_cs
*saved
, bool get_buffer_list
);
670 void si_clear_saved_cs(struct radeon_saved_cs
*saved
);
671 bool si_check_device_reset(struct r600_common_context
*rctx
);
673 /* r600_gpu_load.c */
674 void si_gpu_load_kill_thread(struct r600_common_screen
*rscreen
);
675 uint64_t si_begin_counter(struct r600_common_screen
*rscreen
, unsigned type
);
676 unsigned si_end_counter(struct r600_common_screen
*rscreen
, unsigned type
,
679 /* r600_perfcounters.c */
680 void si_perfcounters_destroy(struct r600_common_screen
*rscreen
);
683 void si_init_screen_query_functions(struct r600_common_screen
*rscreen
);
684 void si_init_query_functions(struct r600_common_context
*rctx
);
685 void si_suspend_queries(struct r600_common_context
*ctx
);
686 void si_resume_queries(struct r600_common_context
*ctx
);
689 bool si_prepare_for_dma_blit(struct r600_common_context
*rctx
,
690 struct r600_texture
*rdst
,
691 unsigned dst_level
, unsigned dstx
,
692 unsigned dsty
, unsigned dstz
,
693 struct r600_texture
*rsrc
,
695 const struct pipe_box
*src_box
);
696 void si_texture_get_fmask_info(struct r600_common_screen
*rscreen
,
697 struct r600_texture
*rtex
,
699 struct r600_fmask_info
*out
);
700 void si_texture_get_cmask_info(struct r600_common_screen
*rscreen
,
701 struct r600_texture
*rtex
,
702 struct r600_cmask_info
*out
);
703 bool si_init_flushed_depth_texture(struct pipe_context
*ctx
,
704 struct pipe_resource
*texture
,
705 struct r600_texture
**staging
);
706 void si_print_texture_info(struct r600_common_screen
*rscreen
,
707 struct r600_texture
*rtex
, struct u_log_context
*log
);
708 struct pipe_resource
*si_texture_create(struct pipe_screen
*screen
,
709 const struct pipe_resource
*templ
);
710 bool vi_dcc_formats_compatible(enum pipe_format format1
,
711 enum pipe_format format2
);
712 bool vi_dcc_formats_are_incompatible(struct pipe_resource
*tex
,
714 enum pipe_format view_format
);
715 void vi_disable_dcc_if_incompatible_format(struct r600_common_context
*rctx
,
716 struct pipe_resource
*tex
,
718 enum pipe_format view_format
);
719 struct pipe_surface
*si_create_surface_custom(struct pipe_context
*pipe
,
720 struct pipe_resource
*texture
,
721 const struct pipe_surface
*templ
,
722 unsigned width0
, unsigned height0
,
723 unsigned width
, unsigned height
);
724 unsigned si_translate_colorswap(enum pipe_format format
, bool do_endian_swap
);
725 void vi_separate_dcc_try_enable(struct r600_common_context
*rctx
,
726 struct r600_texture
*tex
);
727 void vi_separate_dcc_start_query(struct pipe_context
*ctx
,
728 struct r600_texture
*tex
);
729 void vi_separate_dcc_stop_query(struct pipe_context
*ctx
,
730 struct r600_texture
*tex
);
731 void vi_separate_dcc_process_and_reset_stats(struct pipe_context
*ctx
,
732 struct r600_texture
*tex
);
733 bool si_texture_disable_dcc(struct r600_common_context
*rctx
,
734 struct r600_texture
*rtex
);
735 void si_init_screen_texture_functions(struct r600_common_screen
*rscreen
);
736 void si_init_context_texture_functions(struct r600_common_context
*rctx
);
739 /* Inline helpers. */
741 static inline struct r600_resource
*r600_resource(struct pipe_resource
*r
)
743 return (struct r600_resource
*)r
;
747 r600_resource_reference(struct r600_resource
**ptr
, struct r600_resource
*res
)
749 pipe_resource_reference((struct pipe_resource
**)ptr
,
750 (struct pipe_resource
*)res
);
754 r600_texture_reference(struct r600_texture
**ptr
, struct r600_texture
*res
)
756 pipe_resource_reference((struct pipe_resource
**)ptr
, &res
->resource
.b
.b
);
760 vi_dcc_enabled(struct r600_texture
*tex
, unsigned level
)
762 return tex
->dcc_offset
&& level
< tex
->surface
.num_dcc_levels
;
765 #define R600_ERR(fmt, args...) \
766 fprintf(stderr, "EE %s:%d %s - " fmt, __FILE__, __LINE__, __func__, ##args)