Can `vkCommandPool` be allocated from the main thread and the moved to other threads?

佐手、 提交于 2019-12-24 01:55:19

问题


Is it possible, to allocate vkCommandPool from the main thread and then move them into a new thread, where it is used exclusively?

Pseudo code:

// Pool for creating secondary buffers
threaded_command_pool = new CommandPool();

// Thread for filling secondary buffers
// threaded_command_poolzd is used only here
thread_handle = new Thread(move(command_pool))

thread_handle.join()

// Pool for merging secondary buffers
command_pool = new CommandPool() 
primary_command_buffer = command_pool.create_buffer()

// fill primary_command_buffer with secondary buffers from thread

In all examples and presentation I have found, the command_pool is created in the thread, not in the main thread, but I couldn't find this requirement in the specs.


回答1:


Nothing in vulkan is bound to a specific thread.

You are free to call any vulkan function from any thread as long as you obey the externally synchronized requirements.

If two commands operate on the same object and at least one of the commands declares the object to be externally synchronized, then the caller must guarantee not only that the commands do not execute simultaneously, but also that the two commands are separated by an appropriate memory barrier (if needed).

In other APIs when an object is bound to a thread it is very clearly documented.

In this case only 1 thread at a time can access a command_pool however successive commands to the same command pool can be from different threads.



来源:https://stackoverflow.com/questions/49275741/can-vkcommandpool-be-allocated-from-the-main-thread-and-the-moved-to-other-thr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!