radv: add initial trap handler support with RADV_TRAP_HANDLER=1
[mesa.git] / src / amd / vulkan / radv_private.h
index 22235e530c11593000b279afbac12f5bc8d5434f..e8383c910b2e5ce6b1fc42c474fc17a30e1c12c7 100644 (file)
@@ -847,12 +847,34 @@ struct radv_device {
        uint32_t thread_trace_buffer_size;
        int thread_trace_start_frame;
 
+       /* Trap handler. */
+       struct radv_shader_variant *trap_handler_shader;
+       struct radeon_winsys_bo *tma_bo; /* Trap Memory Address */
+       uint32_t *tma_ptr;
+
        /* Overallocation. */
        bool overallocation_disallowed;
        uint64_t allocated_memory_size[VK_MAX_MEMORY_HEAPS];
        mtx_t overallocation_mutex;
+
+       /* Track the number of device loss occurs. */
+       int lost;
 };
 
+VkResult _radv_device_set_lost(struct radv_device *device,
+                              const char *file, int line,
+                              const char *msg, ...)
+       radv_printflike(4, 5);
+
+#define radv_device_set_lost(dev, ...) \
+       _radv_device_set_lost(dev, __FILE__, __LINE__, __VA_ARGS__)
+
+static inline bool
+radv_device_is_lost(const struct radv_device *device)
+{
+       return unlikely(p_atomic_read(&device->lost));
+}
+
 struct radv_device_memory {
        struct vk_object_base                        base;
        struct radeon_winsys_bo                      *bo;