mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 02:30:12 +01:00
anv: Inline can_fast_clear_with_non_zero_color
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31374>
This commit is contained in:
parent
5549cb921d
commit
35f02d8f36
3 changed files with 27 additions and 26 deletions
|
|
@ -1928,14 +1928,6 @@ anv_image_init(struct anv_device *device, struct anv_image *image,
|
|||
if (r != VK_SUCCESS)
|
||||
goto fail;
|
||||
|
||||
/* Once we have all the bindings, determine whether we can do non 0 fast
|
||||
* clears for each plane.
|
||||
*/
|
||||
for (uint32_t p = 0; p < image->n_planes; p++) {
|
||||
image->planes[p].can_non_zero_fast_clear =
|
||||
can_fast_clear_with_non_zero_color(device->info, image, p, fmt_list);
|
||||
}
|
||||
|
||||
if (anv_image_is_sparse(image)) {
|
||||
r = anv_image_init_sparse_bindings(image, create_info);
|
||||
if (r != VK_SUCCESS)
|
||||
|
|
@ -3411,6 +3403,10 @@ anv_layout_to_fast_clear_type(const struct intel_device_info * const devinfo,
|
|||
const VkImageUsageFlags layout_usage =
|
||||
vk_image_layout_to_usage_flags(layout, aspect) & image->vk.usage;
|
||||
|
||||
const struct isl_drm_modifier_info *isl_mod_info =
|
||||
image->vk.tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT ?
|
||||
isl_drm_modifier_get_info(image->vk.drm_format_mod) : NULL;
|
||||
|
||||
switch (aux_state) {
|
||||
case ISL_AUX_STATE_CLEAR:
|
||||
unreachable("We never use this state");
|
||||
|
|
@ -3418,7 +3414,28 @@ anv_layout_to_fast_clear_type(const struct intel_device_info * const devinfo,
|
|||
case ISL_AUX_STATE_PARTIAL_CLEAR:
|
||||
case ISL_AUX_STATE_COMPRESSED_CLEAR:
|
||||
|
||||
if (!image->planes[plane].can_non_zero_fast_clear)
|
||||
/* Generally, enabling non-zero fast-clears is dependent on knowing which
|
||||
* formats will be used with the surface. So, disable them if we lack
|
||||
* this knowledge.
|
||||
*
|
||||
* For dmabufs with clear color modifiers, we already restrict
|
||||
* problematic accesses for the clear color during the negotiation
|
||||
* phase. So, don't restrict clear color support in this case.
|
||||
*/
|
||||
if (anv_image_view_formats_incomplete(image) &&
|
||||
!(isl_mod_info && isl_mod_info->supports_clear_color)) {
|
||||
return ANV_FAST_CLEAR_DEFAULT_VALUE;
|
||||
}
|
||||
|
||||
/* On TGL (< C0), if a block of fragment shader outputs match the
|
||||
* surface's clear color, the HW may convert them to fast-clears (see
|
||||
* HSD 1607794140). This can lead to rendering corruptions if not
|
||||
* handled properly. We restrict the clear color to zero to avoid issues
|
||||
* that can occur with:
|
||||
* - Texture view rendering (including blorp_copy calls)
|
||||
* - Images with multiple levels or array layers
|
||||
*/
|
||||
if (image->planes[plane].aux_usage == ISL_AUX_USAGE_FCV_CCS_E)
|
||||
return ANV_FAST_CLEAR_DEFAULT_VALUE;
|
||||
|
||||
/* On gfx9, we only load clear colors for attachments and for BLORP
|
||||
|
|
|
|||
|
|
@ -5497,22 +5497,6 @@ struct anv_image {
|
|||
/** Location of the fast clear state. */
|
||||
struct anv_image_memory_range fast_clear_memory_range;
|
||||
|
||||
/**
|
||||
* Whether this image can be fast cleared with non-zero clear colors.
|
||||
* This can happen with mutable images when formats of different bit
|
||||
* sizes per components are used.
|
||||
*
|
||||
* On Gfx9+, because the clear colors are stored as a 4 components 32bit
|
||||
* values, we can clear in R16G16_UNORM (store 2 16bit values in the
|
||||
* components 0 & 1 of the clear color) and then draw in R32_UINT which
|
||||
* would interpret the clear color as a single component value, using
|
||||
* only the first 16bit component of the previous written clear color.
|
||||
*
|
||||
* On Gfx7/7.5/8, only CC_ZERO/CC_ONE clear colors are supported, this
|
||||
* boolean will prevent the usage of CC_ONE.
|
||||
*/
|
||||
bool can_non_zero_fast_clear;
|
||||
|
||||
struct {
|
||||
/** Whether the image has CCS data mapped through AUX-TT. */
|
||||
bool mapped;
|
||||
|
|
|
|||
|
|
@ -1242,7 +1242,7 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
|
|||
|
||||
if (must_init_fast_clear_state) {
|
||||
if (image->planes[plane].aux_usage == ISL_AUX_USAGE_FCV_CCS_E) {
|
||||
assert(!image->planes[plane].can_non_zero_fast_clear);
|
||||
/* Ensure the raw and converted clear colors are in sync. */
|
||||
const uint32_t zero_pixel[4] = {};
|
||||
set_image_clear_color(cmd_buffer, image, aspect, zero_pixel);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue