diff --git a/docs/ODIN_WORKAROUNDS.md b/docs/ODIN_WORKAROUNDS.md index 041604f6e..5aec52d93 100644 --- a/docs/ODIN_WORKAROUNDS.md +++ b/docs/ODIN_WORKAROUNDS.md @@ -44,3 +44,4 @@ Defects of GPU drivers that the GPU tests reach. | Marker in code | Upstream | Remove when | | --- | --- | --- | | `keep_one` (`rhi/shared_device/shared_device.odin`): the GPU tests of a process keep one device alive from the first `hold` to the end; the NVIDIA Windows driver 616.92 (`nvoglv64.dll`) frees the context of the worker threads of the last device of a process while they still run, and one of them then calls through freed memory (0xC0000005) | none | without `keep_one`, `mirai test rhi/tests rhi_devices_are_created_and_destroyed_in_turn_and_on_several_threads` passes 20 runs in a row under `MIRAI_VALIDATION=1` on that driver's successor | +| `fault_query_unqueued` (`rhi/vulkan_device.odin`): with the validation layer on, `vk_lost` asks no fault description of a loss that pipeline creation reported; the layer counts a device as lost only once a submission or a wait reported it, and flags `vkGetDeviceFaultInfoEXT` after any other `VK_ERROR_DEVICE_LOST` (VUID-vkGetDeviceFaultInfoEXT-device-07336) | none | the layer takes a loss from any call: `vk_lost` asks on every loss, and a run under validation that loses the device in `vkCreateComputePipelines` has no validation message | diff --git a/rhi/vulkan_device.odin b/rhi/vulkan_device.odin index d67b347ff..428fe5f66 100644 --- a/rhi/vulkan_device.odin +++ b/rhi/vulkan_device.odin @@ -267,6 +267,7 @@ Device :: struct { failure_text: string, failure_buffer: [FAILURE_TEXT_BYTES]u8, fault_info: bool, // VK_EXT_device_fault: the driver describes a loss + validation_layer: bool, // VK_LAYER_KHRONOS_validation is enabled memory_budget: bool, // VK_EXT_memory_budget: the driver says what memory the process holds and may hold waited_out: bool, // a wait passed GPU_WAIT_LIMIT_NS: the GPU may still run that work lose_asked: bool, // device_lose @@ -287,20 +288,23 @@ set_error :: proc(d: ^Device, format: string, args: ..any) { } @(private) -vk_check :: proc(d: ^Device, result: vk.Result, what: string) -> bool { +vk_check :: proc(d: ^Device, result: vk.Result, what: string, queued := true) -> bool { if result == .SUCCESS {return true} - if vk_lost(d, result, what) {return false} + if vk_lost(d, result, what, queued) {return false} set_error(d, "%s failed: %v", what, result) return false } // Whether a result reports the device lost, which marks it with what the -// driver says of the fault; other results are the caller's. +// driver says of the fault; other results are the caller's. queued false: a +// call other than a submission or a wait reported it (pipeline creation). @(private) -vk_lost :: proc(d: ^Device, result: vk.Result, what: string) -> bool { +vk_lost :: proc(d: ^Device, result: vk.Result, what: string, queued := true) -> bool { if result != .ERROR_DEVICE_LOST {return false} description: string - if d.fault_info && !d.lose_provoked { + // fault_query_unqueued: the validation layer takes a loss only from a submission or a wait, + // and reports vkGetDeviceFaultInfoEXT after any other as made on a device that is not lost. + if d.fault_info && !d.lose_provoked && (queued || !d.validation_layer) { // No arrays asked for: the description alone, with INCOMPLETE. counts := vk.DeviceFaultCountsEXT{sType = .DEVICE_FAULT_COUNTS_EXT} info := vk.DeviceFaultInfoEXT{sType = .DEVICE_FAULT_INFO_EXT} @@ -499,6 +503,7 @@ vk_create_instance_and_device :: proc(d: ^Device, desc: Device_Desc) -> bool { if d.debug_utils {append(&extensions, "VK_EXT_debug_utils")} enabled_layers := make([dynamic]cstring, 0, 2, context.temp_allocator) if validation {append(&enabled_layers, "VK_LAYER_KHRONOS_validation")} + d.validation_layer = validation app := vk.ApplicationInfo{ sType = .APPLICATION_INFO, diff --git a/rhi/vulkan_resources.odin b/rhi/vulkan_resources.odin index 667ee20b0..60b216952 100644 --- a/rhi/vulkan_resources.odin +++ b/rhi/vulkan_resources.odin @@ -681,7 +681,7 @@ pipeline_create_compute :: proc(d: ^Device, desc: Compute_Pipeline_Desc) -> Pipe } key := pipeline_key_compute(desc) cache := vk_pipeline_cache_open(d, key) - created := vk_check(d, d.dvk.CreateComputePipelines(d.handle, cache, 1, &info, nil, &p.handle), desc.name) + created := vk_check(d, d.dvk.CreateComputePipelines(d.handle, cache, 1, &info, nil, &p.handle), desc.name, queued = false) vk_pipeline_cache_close(d, key, cache, feedback, created) if !created {vk_release_pipeline(d, &p); return 0} vk_set_name(d, .PIPELINE, u64(p.handle), desc.name) @@ -783,7 +783,7 @@ pipeline_create_graphics :: proc(d: ^Device, desc: Graphics_Pipeline_Desc) -> Pi } key := pipeline_key_graphics(desc) cache := vk_pipeline_cache_open(d, key) - created := vk_check(d, d.dvk.CreateGraphicsPipelines(d.handle, cache, 1, &info, nil, &p.handle), desc.name) + created := vk_check(d, d.dvk.CreateGraphicsPipelines(d.handle, cache, 1, &info, nil, &p.handle), desc.name, queued = false) vk_pipeline_cache_close(d, key, cache, feedback, created) if !created {vk_release_pipeline(d, &p); return 0} vk_set_name(d, .PIPELINE, u64(p.handle), desc.name)