anv: set MOCS for protected memory when needed

We were missing setting the EncryptedData bit in the MOCS field when
emitting the surface states for protected buffer/images. How this works
on ADL remains a mystery to me.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11313

Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30097>
This commit is contained in:
Iván Briano 2024-07-08 11:37:57 -07:00 committed by Marge Bot
parent ece7abb599
commit c8d64860ec
4 changed files with 21 additions and 1 deletions

View file

@ -2470,6 +2470,8 @@ anv_descriptor_set_write_buffer(struct anv_device *device,
enum isl_format format =
anv_isl_format_for_descriptor_type(device, desc->type);
if (bind_addr.bo && bind_addr.bo->alloc_flags & ANV_BO_ALLOC_PROTECTED)
usage |= ISL_SURF_USAGE_PROTECTED_BIT;
isl_buffer_fill_state(&device->isl_dev, desc_map,
.address = anv_address_physical(bind_addr),
.mocs = isl_mocs(&device->isl_dev, usage,

View file

@ -5352,6 +5352,8 @@ anv_fill_buffer_surface_state(struct anv_device *device,
struct anv_address address,
uint32_t range, uint32_t stride)
{
if (address.bo && address.bo->alloc_flags & ANV_BO_ALLOC_PROTECTED)
usage |= ISL_SURF_USAGE_PROTECTED_BIT;
isl_buffer_fill_state(&device->isl_dev, surface_state_ptr,
.address = anv_address_physical(address),
.mocs = isl_mocs(&device->isl_dev, usage,

View file

@ -3349,6 +3349,9 @@ anv_image_fill_surface_state(struct anv_device *device,
}
state_inout->clear_address = clear_address;
if (image->vk.create_flags & VK_IMAGE_CREATE_PROTECTED_BIT)
view_usage |= ISL_SURF_USAGE_PROTECTED_BIT;
isl_surf_fill_state(&device->isl_dev, surface_state_map,
.surf = isl_surf,
.view = &view,

View file

@ -107,7 +107,20 @@ fill_state_base_addr(struct anv_cmd_buffer *cmd_buffer,
sba->GeneralStateBaseAddressModifyEnable = true;
sba->GeneralStateBufferSizeModifyEnable = true;
sba->StatelessDataPortAccessMOCS = mocs;
#if GFX_VERx10 == 120
/* Since DG2, scratch surfaces have their own surface state with its own
* MOCS setting, but prior to that, the MOCS for scratch accesses are
* governed by SBA.StatelessDataPortAccessMOCS.
*/
const isl_surf_usage_flags_t protected_usage =
cmd_buffer->vk.pool->flags & VK_COMMAND_POOL_CREATE_PROTECTED_BIT ?
ISL_SURF_USAGE_PROTECTED_BIT : 0;
const uint32_t stateless_mocs = isl_mocs(&device->isl_dev, protected_usage, false);
#else
const uint32_t stateless_mocs = mocs;
#endif
sba->StatelessDataPortAccessMOCS = stateless_mocs;
#if GFX_VERx10 >= 125
sba->SurfaceStateBaseAddress =