-
Notifications
You must be signed in to change notification settings - Fork 475
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
Does swap chain image count include images required by the driver to implement a given present mode? #909
Comments
I was answering this somewhere already... hmm can't find it. Neither. You have to let driver keep To be precise if
but
and
PS:
Technically the count PS2: PS3: |
Thank you for clarifying, but this seems to be inconsistent with the comments on the |
@Overv Yes, that somewhat relates to PS3 above. Guaranteeing non-blocking behavior, and guaranteeng something is valid in the first place are two different things. |
@krOoze Ah, alright, thanks. |
Then again drivers may report overinflated |
I haven't read this conversation carefully, but want to make sure there are no outstanding questions ... One thing I'll point out from the spec (re: VkSwapchainCreateInfoKHR::minImageCount) is:
You might get more images than minImageCount. Therefore, you need to base your code on what's returned by vkGetSwapchainImagesKHR (I mention this because of seeing code that didn't do that:-). I'll also state what I think you both know: the implementation may create different numbers of images depending on the present mode. For example, on Android, if you ask for 2 images AND MAILBOX, you'll get 3 images. This is as suggested:
A final point is that, for the sake of portability and longevity, you shouldn't assume a compositor (or lack thereof), nor a particular set of semantics. I've seen some implementations change their behavior overtime, or in certain cases (e.g. if they notice your window is the full size of the screen, they may use HW instead of a compositor). Hope this is helpful. I'll try to look to see if there are follow-up questions. |
@ianelliottus Can the number of swapchain images returned by
On Android with:
I'm seeing |
Sorry for not seeing this sooner. Yes, I believe you can see different numbers returned. The Android implementation is supposed to be common, but I believe we changed things at one of the recent dessert releases. I also know that OEMs (e.g. NVIDIA for the Shield) can change things, or may be running a newer/older version of Android than another OEM's device. |
@ianelliottus The spec for
Does this mean in that case, when minImageCount = 2 and the present mode is mailbox, I can actually acquire both images that aren't being displayed? |
In other words, you generally can acquire swapchainImageCount - minImageCount + 1 number of images. If the swapchain has 3+ images, then yes, if it has 2 then no. |
Just to be clear, by |
@plasmacel Yes, |
@krOoze Then, if I'm right, for |
@plasmacel You are making humane assumptions that are not necessarily contained in the dry math. Firstly, you could have trillion images, and yet Vulkan does not give explicit non-blocking guarantees. Secondly, N is a very generic number. Say it is 420. Surely, by frame 420, the frame 1 is long done irrespective of any blocking and stuff. As such it would just be wasteful of memory. I am not entirely convinced N larger than 2 makes sense outside very specific niche usages. Thirdly I am partly as lost as you. That's why I made #1137. Still kinda feel like it is more of a guesswork rather than something you can choose rationally, timelessly, and multiplatformly. |
@krOoze I have the feeling that the First, Also, the definition of Then, the issues of synchronization primitives during swapchain recreation, specifically the potential memory leak which comes from the fact that it is impossible to tell whether the previously used These bug me, since Vulkan was created to be explicit and to avoid the hints and guesses we had to deal with using OpenGL, still such a fundamental extension is broken by design. I hope these will be addressed by Khronos in the close future. I do agree that Thanks for the linked issue though. |
@plasmacel Sometimes, and sometimes the underlying presentation system is the problem. The Vulkan things are just a wrapper for the OS specific stuff, and the OS specific stuff is often not all that great. I mean, I have a Vulkan DXGI swapchain impl for fun. All it tells you is that you should have between two to sixteen buffers. If I try to give it 1, what happens? Who knows. Reading the MS docs I have only the vaguest and ambiguous notions how their presentation engine works. I also read bit of X spec and Mesa implementation, and it is as bad, if not worse.
It is not so bad, because you learn the actual minimum soon enough when creating the swapchain. What is proplematic here is drivers "cheating" and not necessarily giving you the bearest brutalest minimum, but they sometimes hand-hold you and give you the optimum anyway (I think particularly for
That as I recall is e.g. the property of the underlying X. I think the driver itself does not know. What you do is create Pixbufs which are all for the purposes of transfer between the app and the OS. Whether they are used directly or the OS has its own extra scratchpad is largely unspecified. The only information the X volunteers is whether particular image is idle at a particular time, and that's all.
Yea, that is annoying. Khronos' organizational structure might be the problem here. Vulkan is a design by stakeholders, as it should be. But as such it lacks the single and only great property a design-by-dictator has: top-down, longterm, wholistic, and esthetical thinking. Unless some specific issue is not picked up by a specific volunteer or is a painful immediate issue, it has tendency to rot until it becomes a bigger problem. Not sure how to bring up this metaissue without sounding more overbearing than I already am. Feel free to give it a try. Vulkan could use more responsiveness to the more wholistic or forgotten "everyone's and no one's problems", and less frankensteinish solutions that come too late.
Yeah. Architecturally 1 (or something less integery) might even make sense. For something like VR, the input latency is at premium, rather than the raw throughput. Meanwhile 1 is also a degenarate case that could potentially simplify the app architecture a bit. |
Let's say I create a swap chain with
presentMode = VK_PRESENT_MODE_MAILBOX_KHR
andminImageCount = 3
. Which of the following two behaviors will I get?vkAcquireNextImageKHR
simultaneously and the driver has a 2 additional images internally to implement the queue and presentation engine.With my NVIDIA driver I appear to get 2 simultaneously acquirable images in this case, which is yet another scenario inbetween these. Does the spec guarantee certain behavior in this regard or is this an implementation detail and should I assume the worst case (scenario 2)?
The text was updated successfully, but these errors were encountered: