Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/ODIN_WORKAROUNDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
15 changes: 10 additions & 5 deletions rhi/vulkan_device.odin
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions rhi/vulkan_resources.odin
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Loading