diff --git a/src/amd/common/ac_surface.c b/src/amd/common/ac_surface.c index ea917135db2..fcccd80cd37 100644 --- a/src/amd/common/ac_surface.c +++ b/src/amd/common/ac_surface.c @@ -3009,6 +3009,7 @@ bool ac_surface_override_offset_stride(const struct radeon_info *info, struct ra if (pitch != surf->u.gfx9.surf_pitch) { unsigned slices = surf->surf_size / surf->u.gfx9.surf_slice_size; + surf->u.gfx9.uses_custom_pitch = true; surf->u.gfx9.surf_pitch = pitch; surf->u.gfx9.epitch = pitch - 1; surf->u.gfx9.pitch[0] = pitch; diff --git a/src/amd/common/ac_surface.h b/src/amd/common/ac_surface.h index 08ce3cb7931..6aa5cdda63d 100644 --- a/src/amd/common/ac_surface.h +++ b/src/amd/common/ac_surface.h @@ -217,6 +217,7 @@ struct gfx9_meta_equation { struct gfx9_surf_layout { uint16_t epitch; /* gfx9 only, not on gfx10 */ uint8_t swizzle_mode; /* color or depth */ + bool uses_custom_pitch; /* only used by gfx10.3+ */ enum gfx9_resource_type resource_type:8; /* 1D, 2D or 3D */ uint16_t surf_pitch; /* in blocks */ diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c index b6193065c12..5acbdfed741 100644 --- a/src/amd/vulkan/radv_image.c +++ b/src/amd/vulkan/radv_image.c @@ -840,15 +840,16 @@ si_set_mutable_tex_desc_fields(struct radv_device *device, struct radv_image *im } /* GFX10.3+ can set a custom pitch for 1D and 2D non-array, but it must be a multiple - * of 256B. Only set it for 2D linear for multi-GPU interop. + * of 256B. * * If an imported image is used with VK_IMAGE_VIEW_TYPE_2D_ARRAY, it may hang due to VM faults * because DEPTH means pitch with 2D, but it means depth with 2D array. */ - if (device->physical_device->rad_info.gfx_level >= GFX10_3 && image->vk.image_type == VK_IMAGE_TYPE_2D && - plane->surface.is_linear && util_is_power_of_two_nonzero(plane->surface.bpe) && - G_00A00C_TYPE(state[3]) == V_008F1C_SQ_RSRC_IMG_2D) { + if (device->physical_device->rad_info.gfx_level >= GFX10_3 && plane->surface.u.gfx9.uses_custom_pitch) { assert((plane->surface.u.gfx9.surf_pitch * plane->surface.bpe) % 256 == 0); + assert(image->vk.image_type == VK_IMAGE_TYPE_2D); + assert(plane->surface.is_linear); + assert(G_00A00C_TYPE(state[3]) == V_008F1C_SQ_RSRC_IMG_2D); unsigned pitch = plane->surface.u.gfx9.surf_pitch; /* Subsampled images have the pitch in the units of blocks. */ diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c index 0edb7c11eb2..95a143c48a3 100644 --- a/src/gallium/drivers/radeonsi/si_descriptors.c +++ b/src/gallium/drivers/radeonsi/si_descriptors.c @@ -327,13 +327,14 @@ void si_set_mutable_tex_desc_fields(struct si_screen *sscreen, struct si_texture } /* GFX10.3+ can set a custom pitch for 1D and 2D non-array, but it must be a multiple - * of 256B. Only set it for 2D linear for multi-GPU interop. + * of 256B. */ - if (sscreen->info.gfx_level >= GFX10_3 && - (tex->buffer.b.b.target == PIPE_TEXTURE_2D || - tex->buffer.b.b.target == PIPE_TEXTURE_RECT) && - tex->surface.is_linear) { - assert((tex->surface.u.gfx9.surf_pitch * tex->surface.bpe) % 256 == 0); + if (sscreen->info.gfx_level >= GFX10_3 && tex->surface.u.gfx9.uses_custom_pitch) { + ASSERTED unsigned min_alignment = 256; + assert((tex->surface.u.gfx9.surf_pitch * tex->surface.bpe) % min_alignment == 0); + assert(tex->buffer.b.b.target == PIPE_TEXTURE_2D || + tex->buffer.b.b.target == PIPE_TEXTURE_RECT); + assert(tex->surface.is_linear); unsigned pitch = tex->surface.u.gfx9.surf_pitch; /* Subsampled images have the pitch in the units of blocks. */ diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index d0076b34761..ea74c37b0ea 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -2505,16 +2505,17 @@ static void si_initialize_color_surface(struct si_context *sctx, struct si_surfa unsigned width0 = surf->width0; - /* GFX10.3+ can set a custom pitch for 1D and 2D non-array, but it must be a multiple - * of 256B. Only set it for 2D linear for multi-GPU interop. + /* GFX10.3+ can set a custom pitch for 1D and 2D non-array, but it must be a multiple of + * 256B. * * We set the pitch in MIP0_WIDTH. */ - if (sctx->gfx_level >= GFX10_3 && - (tex->buffer.b.b.target == PIPE_TEXTURE_2D || - tex->buffer.b.b.target == PIPE_TEXTURE_RECT) && - tex->surface.is_linear) { - assert((tex->surface.u.gfx9.surf_pitch * tex->surface.bpe) % 256 == 0); + if (sctx->gfx_level >= GFX10_3 && tex->surface.u.gfx9.uses_custom_pitch) { + ASSERTED unsigned min_alignment = 256; + assert((tex->surface.u.gfx9.surf_pitch * tex->surface.bpe) % min_alignment == 0); + assert(tex->buffer.b.b.target == PIPE_TEXTURE_2D || + tex->buffer.b.b.target == PIPE_TEXTURE_RECT); + assert(tex->surface.is_linear); width0 = tex->surface.u.gfx9.surf_pitch;