Fix: Crash when using Vulkan backend.

Command buffer was not availble at the time dummy buffers are
initialized. Resulting in undefined behavior.
This commit is contained in:
Jeroen Bakker
2023-08-22 13:46:48 +02:00
parent 4ebd7d84d1
commit d9ae608c87
3 changed files with 7 additions and 2 deletions

View File

@@ -135,7 +135,6 @@ Context *VKBackend::context_alloc(void *ghost_window, void *ghost_context)
VKContext *context = new VKContext(ghost_window, ghost_context);
device_.context_register(*context);
device_.init_dummy_buffer(*context);
return context;
}

View File

@@ -78,6 +78,7 @@ void VKContext::sync_backbuffer()
command_buffer_.init(device.device_get(), device.queue_get(), command_buffer);
command_buffer_.begin_recording();
device.descriptor_pools_get().reset();
device.init_dummy_buffer(*this);
}
}

View File

@@ -127,6 +127,12 @@ class VKDevice : public NonCopyable {
bool is_initialized() const;
void init(void *ghost_context);
/**
* Initialize a dummy buffer that can be bound for missing attributes.
*
* Dummy buffer can only be initialized after the command buffer of the context is retrieved.
*/
void init_dummy_buffer(VKContext &context);
void deinit();
eGPUDeviceType device_type() const;
@@ -159,7 +165,6 @@ class VKDevice : public NonCopyable {
void init_debug_callbacks();
void init_memory_allocator();
void init_descriptor_pools();
void init_dummy_buffer(VKContext &context);
/* During initialization the backend requires access to update the workarounds. */
friend VKBackend;