when an application doesn't update the contents of a descriptor
set object, it contains random values and this might end up with
GPU VM faults if a shader tries to access that descriptor.

The Vulkan spec doesn't state what a driver should do when
a descriptor is unset, but zeroing the contents seems to be
a safe solution.

This fixes a GPU hang with Unity because a pixel shader tries
to access a descriptor that is unset by the application.
Though, maybe that descriptor load should have been DCE'd.

Cc: Pierre-Loup A. Griffais <[email protected]>
Signed-off-by: Samuel Pitoiset <[email protected]>
---
 src/amd/vulkan/radv_descriptor_set.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/amd/vulkan/radv_descriptor_set.c 
b/src/amd/vulkan/radv_descriptor_set.c
index 260bfbc12b..6271f9d06e 100644
--- a/src/amd/vulkan/radv_descriptor_set.c
+++ b/src/amd/vulkan/radv_descriptor_set.c
@@ -327,6 +327,12 @@ radv_descriptor_set_create(struct radv_device *device,
                        list_add(&set->vram_list, prev);
                } else
                        return vk_error(VK_ERROR_OUT_OF_POOL_MEMORY_KHR);
+
+               /* Initialize the descriptor set to zero in order to avoid GPU
+                * VM faults when an application doesn't update the contents of
+                * a descriptor set object.
+                */
+               memset(set->mapped_ptr, 0, layout->size);
        }
 
        for (unsigned i = 0; i < layout->binding_count; ++i) {
-- 
2.14.1

_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to