Creating multiple command pools per thread in Vulkan
I am trying to set up a multi-threaded renderer with Vulkan and I have a question about command pools.
Here https://on-demand.gputechconf.com/siggraph/2016/video/sig1625-tristan-lorach-vulkan-nvidia-essentials.mp4 at 13 minutes, they talk about how you should make 1 command pool per FRAME and cycle them in a ring buffer.
Why allocate 3 command pools per thread(one for each frame in a 3-frame ring buffer) instead of having just one command pool per thread and having 3 command buffers from it?
c++ multithreading vulkan
add a comment |
I am trying to set up a multi-threaded renderer with Vulkan and I have a question about command pools.
Here https://on-demand.gputechconf.com/siggraph/2016/video/sig1625-tristan-lorach-vulkan-nvidia-essentials.mp4 at 13 minutes, they talk about how you should make 1 command pool per FRAME and cycle them in a ring buffer.
Why allocate 3 command pools per thread(one for each frame in a 3-frame ring buffer) instead of having just one command pool per thread and having 3 command buffers from it?
c++ multithreading vulkan
add a comment |
I am trying to set up a multi-threaded renderer with Vulkan and I have a question about command pools.
Here https://on-demand.gputechconf.com/siggraph/2016/video/sig1625-tristan-lorach-vulkan-nvidia-essentials.mp4 at 13 minutes, they talk about how you should make 1 command pool per FRAME and cycle them in a ring buffer.
Why allocate 3 command pools per thread(one for each frame in a 3-frame ring buffer) instead of having just one command pool per thread and having 3 command buffers from it?
c++ multithreading vulkan
I am trying to set up a multi-threaded renderer with Vulkan and I have a question about command pools.
Here https://on-demand.gputechconf.com/siggraph/2016/video/sig1625-tristan-lorach-vulkan-nvidia-essentials.mp4 at 13 minutes, they talk about how you should make 1 command pool per FRAME and cycle them in a ring buffer.
Why allocate 3 command pools per thread(one for each frame in a 3-frame ring buffer) instead of having just one command pool per thread and having 3 command buffers from it?
c++ multithreading vulkan
c++ multithreading vulkan
asked Nov 22 at 22:32
ulak blade
54521244
54521244
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
It's basically about limiting how much synchronization and state tracking you have to do. If you have one Command pool per frame per thread then you just need to track a single event for completion and then reset the entire Command pool, no matter how many Command buffers you created in it for that frame.
From an engine point of view this can be quite nice for command buffers you don't intend to reuse multiple times - they become stateless fire and forget entities and you just need to persistently track the pool.
Exact trade offs are going to vary here from application to application, and driver to driver, so YMMV in terms of what works best.
I see, and I suppose '3' is an arbitrary number - if frames take more to complete, I may need a bigger ring buffer
– ulak blade
Nov 22 at 23:01
1
You don't want to have a frame queue that is too deep in your swapchain - latency from user input to something showing on screen becomes too high. Usually 2 or 3 is fine. 2 can cause issues with vsync locking, which 3 avoids, but there is not really any performance benefit to going above triple buffering and it just causes latency issues.
– solidpixel
Nov 22 at 23:04
Oh I see, so the number of command pools in the ring buffer should match the buffer count in the swap chain?
– ulak blade
Nov 22 at 23:09
I don't think so. Number of images in a swapchain may vary on different hardware vendors or even driver versions - even with the same creation parameters. You specify the minimal required number of images, but driver may give You more. So matching the size of the ring buffer with the number of swapchain images is not the best idea. Have a look here: software.intel.com/en-us/articles/…
– Ekzuzy
Nov 23 at 14:39
add a comment |
I think the premise here is that vkResetCommandPool
is better than resetting individual command buffers. Which also requires VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT
flag, whose existence is a little hint by the Specification itself that the ability to reset individual cmdbuffers may not be for free.
Actually the speaker says so if you do not just read slides but get the full presentation.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53438692%2fcreating-multiple-command-pools-per-thread-in-vulkan%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
It's basically about limiting how much synchronization and state tracking you have to do. If you have one Command pool per frame per thread then you just need to track a single event for completion and then reset the entire Command pool, no matter how many Command buffers you created in it for that frame.
From an engine point of view this can be quite nice for command buffers you don't intend to reuse multiple times - they become stateless fire and forget entities and you just need to persistently track the pool.
Exact trade offs are going to vary here from application to application, and driver to driver, so YMMV in terms of what works best.
I see, and I suppose '3' is an arbitrary number - if frames take more to complete, I may need a bigger ring buffer
– ulak blade
Nov 22 at 23:01
1
You don't want to have a frame queue that is too deep in your swapchain - latency from user input to something showing on screen becomes too high. Usually 2 or 3 is fine. 2 can cause issues with vsync locking, which 3 avoids, but there is not really any performance benefit to going above triple buffering and it just causes latency issues.
– solidpixel
Nov 22 at 23:04
Oh I see, so the number of command pools in the ring buffer should match the buffer count in the swap chain?
– ulak blade
Nov 22 at 23:09
I don't think so. Number of images in a swapchain may vary on different hardware vendors or even driver versions - even with the same creation parameters. You specify the minimal required number of images, but driver may give You more. So matching the size of the ring buffer with the number of swapchain images is not the best idea. Have a look here: software.intel.com/en-us/articles/…
– Ekzuzy
Nov 23 at 14:39
add a comment |
It's basically about limiting how much synchronization and state tracking you have to do. If you have one Command pool per frame per thread then you just need to track a single event for completion and then reset the entire Command pool, no matter how many Command buffers you created in it for that frame.
From an engine point of view this can be quite nice for command buffers you don't intend to reuse multiple times - they become stateless fire and forget entities and you just need to persistently track the pool.
Exact trade offs are going to vary here from application to application, and driver to driver, so YMMV in terms of what works best.
I see, and I suppose '3' is an arbitrary number - if frames take more to complete, I may need a bigger ring buffer
– ulak blade
Nov 22 at 23:01
1
You don't want to have a frame queue that is too deep in your swapchain - latency from user input to something showing on screen becomes too high. Usually 2 or 3 is fine. 2 can cause issues with vsync locking, which 3 avoids, but there is not really any performance benefit to going above triple buffering and it just causes latency issues.
– solidpixel
Nov 22 at 23:04
Oh I see, so the number of command pools in the ring buffer should match the buffer count in the swap chain?
– ulak blade
Nov 22 at 23:09
I don't think so. Number of images in a swapchain may vary on different hardware vendors or even driver versions - even with the same creation parameters. You specify the minimal required number of images, but driver may give You more. So matching the size of the ring buffer with the number of swapchain images is not the best idea. Have a look here: software.intel.com/en-us/articles/…
– Ekzuzy
Nov 23 at 14:39
add a comment |
It's basically about limiting how much synchronization and state tracking you have to do. If you have one Command pool per frame per thread then you just need to track a single event for completion and then reset the entire Command pool, no matter how many Command buffers you created in it for that frame.
From an engine point of view this can be quite nice for command buffers you don't intend to reuse multiple times - they become stateless fire and forget entities and you just need to persistently track the pool.
Exact trade offs are going to vary here from application to application, and driver to driver, so YMMV in terms of what works best.
It's basically about limiting how much synchronization and state tracking you have to do. If you have one Command pool per frame per thread then you just need to track a single event for completion and then reset the entire Command pool, no matter how many Command buffers you created in it for that frame.
From an engine point of view this can be quite nice for command buffers you don't intend to reuse multiple times - they become stateless fire and forget entities and you just need to persistently track the pool.
Exact trade offs are going to vary here from application to application, and driver to driver, so YMMV in terms of what works best.
answered Nov 22 at 22:56
solidpixel
4,91611121
4,91611121
I see, and I suppose '3' is an arbitrary number - if frames take more to complete, I may need a bigger ring buffer
– ulak blade
Nov 22 at 23:01
1
You don't want to have a frame queue that is too deep in your swapchain - latency from user input to something showing on screen becomes too high. Usually 2 or 3 is fine. 2 can cause issues with vsync locking, which 3 avoids, but there is not really any performance benefit to going above triple buffering and it just causes latency issues.
– solidpixel
Nov 22 at 23:04
Oh I see, so the number of command pools in the ring buffer should match the buffer count in the swap chain?
– ulak blade
Nov 22 at 23:09
I don't think so. Number of images in a swapchain may vary on different hardware vendors or even driver versions - even with the same creation parameters. You specify the minimal required number of images, but driver may give You more. So matching the size of the ring buffer with the number of swapchain images is not the best idea. Have a look here: software.intel.com/en-us/articles/…
– Ekzuzy
Nov 23 at 14:39
add a comment |
I see, and I suppose '3' is an arbitrary number - if frames take more to complete, I may need a bigger ring buffer
– ulak blade
Nov 22 at 23:01
1
You don't want to have a frame queue that is too deep in your swapchain - latency from user input to something showing on screen becomes too high. Usually 2 or 3 is fine. 2 can cause issues with vsync locking, which 3 avoids, but there is not really any performance benefit to going above triple buffering and it just causes latency issues.
– solidpixel
Nov 22 at 23:04
Oh I see, so the number of command pools in the ring buffer should match the buffer count in the swap chain?
– ulak blade
Nov 22 at 23:09
I don't think so. Number of images in a swapchain may vary on different hardware vendors or even driver versions - even with the same creation parameters. You specify the minimal required number of images, but driver may give You more. So matching the size of the ring buffer with the number of swapchain images is not the best idea. Have a look here: software.intel.com/en-us/articles/…
– Ekzuzy
Nov 23 at 14:39
I see, and I suppose '3' is an arbitrary number - if frames take more to complete, I may need a bigger ring buffer
– ulak blade
Nov 22 at 23:01
I see, and I suppose '3' is an arbitrary number - if frames take more to complete, I may need a bigger ring buffer
– ulak blade
Nov 22 at 23:01
1
1
You don't want to have a frame queue that is too deep in your swapchain - latency from user input to something showing on screen becomes too high. Usually 2 or 3 is fine. 2 can cause issues with vsync locking, which 3 avoids, but there is not really any performance benefit to going above triple buffering and it just causes latency issues.
– solidpixel
Nov 22 at 23:04
You don't want to have a frame queue that is too deep in your swapchain - latency from user input to something showing on screen becomes too high. Usually 2 or 3 is fine. 2 can cause issues with vsync locking, which 3 avoids, but there is not really any performance benefit to going above triple buffering and it just causes latency issues.
– solidpixel
Nov 22 at 23:04
Oh I see, so the number of command pools in the ring buffer should match the buffer count in the swap chain?
– ulak blade
Nov 22 at 23:09
Oh I see, so the number of command pools in the ring buffer should match the buffer count in the swap chain?
– ulak blade
Nov 22 at 23:09
I don't think so. Number of images in a swapchain may vary on different hardware vendors or even driver versions - even with the same creation parameters. You specify the minimal required number of images, but driver may give You more. So matching the size of the ring buffer with the number of swapchain images is not the best idea. Have a look here: software.intel.com/en-us/articles/…
– Ekzuzy
Nov 23 at 14:39
I don't think so. Number of images in a swapchain may vary on different hardware vendors or even driver versions - even with the same creation parameters. You specify the minimal required number of images, but driver may give You more. So matching the size of the ring buffer with the number of swapchain images is not the best idea. Have a look here: software.intel.com/en-us/articles/…
– Ekzuzy
Nov 23 at 14:39
add a comment |
I think the premise here is that vkResetCommandPool
is better than resetting individual command buffers. Which also requires VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT
flag, whose existence is a little hint by the Specification itself that the ability to reset individual cmdbuffers may not be for free.
Actually the speaker says so if you do not just read slides but get the full presentation.
add a comment |
I think the premise here is that vkResetCommandPool
is better than resetting individual command buffers. Which also requires VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT
flag, whose existence is a little hint by the Specification itself that the ability to reset individual cmdbuffers may not be for free.
Actually the speaker says so if you do not just read slides but get the full presentation.
add a comment |
I think the premise here is that vkResetCommandPool
is better than resetting individual command buffers. Which also requires VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT
flag, whose existence is a little hint by the Specification itself that the ability to reset individual cmdbuffers may not be for free.
Actually the speaker says so if you do not just read slides but get the full presentation.
I think the premise here is that vkResetCommandPool
is better than resetting individual command buffers. Which also requires VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT
flag, whose existence is a little hint by the Specification itself that the ability to reset individual cmdbuffers may not be for free.
Actually the speaker says so if you do not just read slides but get the full presentation.
edited Nov 23 at 17:48
answered Nov 23 at 13:06
krOoze
3,8901921
3,8901921
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53438692%2fcreating-multiple-command-pools-per-thread-in-vulkan%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown