radv: rework VM_ALWAYS_VALID handling

Instead of assuming that VM_ALWAYS_VALID is always available,
make its use conditionnal on its support.

This allows to remove the virtio nctx special case (where
VM_ALWAYS_VALID is only possible with virtio for buffers that
also have the NO_CPU_ACCESS flag since CPU access is implemented
through dmabuf on the host).

Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Acked-by: Rob Clark <robdclark@chromium.org>
Acked-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34470>
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2025-03-17 11:48:02 +01:00 committed by Marge Bot
parent 8c529ba58c
commit df1224c8b2
3 changed files with 20 additions and 17 deletions

View file

@ -874,7 +874,7 @@ radv_physical_device_get_features(const struct radv_physical_device *pdev, struc
pdev->info.has_packed_math_16bit || (pdev->info.gfx_level == GFX8 && instance->drirc.expose_float16_gfx8),
.shaderInt8 = true,
.descriptorIndexing = true,
.descriptorIndexing = pdev->info.has_vm_always_valid,
.shaderInputAttachmentArrayDynamicIndexing = true,
.shaderUniformTexelBufferArrayDynamicIndexing = true,
.shaderStorageTexelBufferArrayDynamicIndexing = true,
@ -885,14 +885,14 @@ radv_physical_device_get_features(const struct radv_physical_device *pdev, struc
.shaderInputAttachmentArrayNonUniformIndexing = true,
.shaderUniformTexelBufferArrayNonUniformIndexing = true,
.shaderStorageTexelBufferArrayNonUniformIndexing = true,
.descriptorBindingUniformBufferUpdateAfterBind = true,
.descriptorBindingSampledImageUpdateAfterBind = true,
.descriptorBindingStorageImageUpdateAfterBind = true,
.descriptorBindingStorageBufferUpdateAfterBind = true,
.descriptorBindingUniformTexelBufferUpdateAfterBind = true,
.descriptorBindingStorageTexelBufferUpdateAfterBind = true,
.descriptorBindingUpdateUnusedWhilePending = true,
.descriptorBindingPartiallyBound = true,
.descriptorBindingUniformBufferUpdateAfterBind = pdev->info.has_vm_always_valid,
.descriptorBindingSampledImageUpdateAfterBind = pdev->info.has_vm_always_valid,
.descriptorBindingStorageImageUpdateAfterBind = pdev->info.has_vm_always_valid,
.descriptorBindingStorageBufferUpdateAfterBind = pdev->info.has_vm_always_valid,
.descriptorBindingUniformTexelBufferUpdateAfterBind = pdev->info.has_vm_always_valid,
.descriptorBindingStorageTexelBufferUpdateAfterBind = pdev->info.has_vm_always_valid,
.descriptorBindingUpdateUnusedWhilePending = pdev->info.has_vm_always_valid,
.descriptorBindingPartiallyBound = pdev->info.has_vm_always_valid,
.descriptorBindingVariableDescriptorCount = true,
.runtimeDescriptorArray = true,
@ -904,7 +904,7 @@ radv_physical_device_get_features(const struct radv_physical_device *pdev, struc
.separateDepthStencilLayouts = true,
.hostQueryReset = true,
.timelineSemaphore = pdev->info.has_timeline_syncobj,
.bufferDeviceAddress = true,
.bufferDeviceAddress = pdev->info.has_vm_always_valid,
.bufferDeviceAddressCaptureReplay = true,
.bufferDeviceAddressMultiDevice = false,
.vulkanMemoryModel = true,

View file

@ -493,13 +493,9 @@ radv_amdgpu_winsys_bo_create(struct radeon_winsys *_ws, uint64_t size, unsigned
request.flags |= AMDGPU_GEM_CREATE_EXPLICIT_SYNC;
if ((initial_domain & RADEON_DOMAIN_VRAM_GTT) && (flags & RADEON_FLAG_NO_INTERPROCESS_SHARING) &&
((ws->perftest & RADV_PERFTEST_LOCAL_BOS) || (flags & RADEON_FLAG_PREFER_LOCAL_BO))) {
/* virtio needs to be able to create a dmabuf if CPU access is required but a
* dmabuf cannot be created if VM_ALWAYS_VALID is used.
*/
if (!ws->info.is_virtio || (request.flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)) {
bo->base.is_local = true;
request.flags |= AMDGPU_GEM_CREATE_VM_ALWAYS_VALID;
}
assert(ws->info.has_vm_always_valid);
bo->base.is_local = true;
request.flags |= AMDGPU_GEM_CREATE_VM_ALWAYS_VALID;
}
/* Set AMDGPU_GEM_CREATE_VIRTIO_SHARED if the driver didn't disable buffer sharing. */
if (ws->info.is_virtio && (initial_domain & RADEON_DOMAIN_VRAM_GTT) &&

View file

@ -211,6 +211,13 @@ radv_amdgpu_winsys_create(int fd, uint64_t debug_flags, uint64_t perftest_flags,
++ws->refcount;
}
if (is_virtio &&
(perftest_flags & (RADV_PERFTEST_BO_LIST | RADV_PERFTEST_LOCAL_BOS))) {
/* virtio doesn't support VM_ALWAYS_VALID, so disable options that requires it. */
fprintf(stderr, "localbos and bolist options are not supported values for RADV_PERFTEST with virtio.\n");
return VK_ERROR_INITIALIZATION_FAILED;
}
if (ws) {
simple_mtx_unlock(&winsys_creation_mutex);
ac_drm_device_deinitialize(dev);