Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RenderingDevice::get_driver_resource(DRIVER_RESOURCE_COMMAND_QUEUE) crashes with Vulkan #89979

Closed
MrJul opened this issue Mar 28, 2024 · 0 comments · Fixed by #90011
Closed

Comments

@MrJul
Copy link

MrJul commented Mar 28, 2024

Tested versions

Reproducible in v4.3.dev5.mono.official [89f70e9]
Works in 4.2 (using VULKAN_QUEUE_FAMILY_INDEX and VULKAN_QUEUE)

System information

Godot v4.3.dev5.mono - Windows 10.0.22631 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4080 (NVIDIA; 31.0.15.3734) - AMD Ryzen 5 7600X 6-Core Processor (12 Threads)

Issue description

With the Forward+ Vulkan renderer:

Calling RenderingDevice::get_driver_resource(DRIVER_RESOURCE_COMMAND_QUEUE) crashes Godot with an access violation exception.
Calling RenderingDevice::get_driver_resource(DRIVER_RESOURCE_QUEUE_FAMILY) incorrectly returns 4294967295 (-1 unsigned).

This is probably caused by #83452.

The following code seems wrong:

uint64_t driver_id = 0;
switch (p_resource) {
case DRIVER_RESOURCE_LOGICAL_DEVICE:
case DRIVER_RESOURCE_PHYSICAL_DEVICE:
case DRIVER_RESOURCE_TOPMOST_OBJECT:
case DRIVER_RESOURCE_COMMAND_QUEUE:
case DRIVER_RESOURCE_QUEUE_FAMILY:
break;

driver_id is zero here for COMMAND_QUEUE and QUEUE_FAMILY, whereas it should probably be taken from the fields main_queue and main_queue_family before being passed to the driver->get_resource_native_handle() call.

This results in RenderingDriverVulkan dereferencing a null pointer for COMMAND_QUEUE and always returning -1 for QUEUE_FAMILY:

case DRIVER_RESOURCE_COMMAND_QUEUE: {
const CommandQueue *queue_info = (const CommandQueue *)p_driver_id.id;
return (uint64_t)queue_families[queue_info->queue_family][queue_info->queue_index].queue;
}
case DRIVER_RESOURCE_QUEUE_FAMILY: {
return uint32_t(p_driver_id.id) - 1;
}

Steps to reproduce

  1. Add the following script to any node:
func _ready() -> void:
    var index = RenderingServer.get_rendering_device().get_driver_resource(RenderingDevice.DRIVER_RESOURCE_QUEUE_FAMILY, RID(), 0)
    var queue = RenderingServer.get_rendering_device().get_driver_resource(RenderingDevice.DRIVER_RESOURCE_COMMAND_QUEUE, RID(), 0)
  1. Run the project.
  2. Observe the crash.

Minimal reproduction project (MRP)

driver-resource-bug.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants