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

Port to the new swapchain model #210

Merged
merged 6 commits into from
Aug 5, 2020
Merged

Port to the new swapchain model #210

merged 6 commits into from
Aug 5, 2020

Conversation

kvark
Copy link
Member

@kvark kvark commented Apr 3, 2020

Closes #208
Fixes #212
Also has general fixes to:

  • push constant offsets in gfxCreatePipelineLayout
  • destination subresources in gfxCmdResolveImage

The PR is inviting for discussion: @grovesNL @msiglreith
I'm not 100% sure what to do yet.

The Good:

  1. Being able to remove the old swapchain from gfx-rs COMPLETELY. It was hacky on all the backends other than Vulkan, quite complicated on Metal, and didn't work very in general.
  2. Fullscreen support! It's not ideal yet (occasional hitches), but it was pretty much non-functional before. In general, stuff that runs is more robust this change.

The Bad:

  1. Portability implementation is a bit more complex now, but not extraordinary so. In general, I think it's a win if we move some complication out of gfx-rs into gfx-portability, since gfx-rs has more users, it's more important to keep clean.
  2. We can't support recording a render pass that uses a swapchain image if either:
    - the image is not acquired at the moment of recording
    - the command buffer is re-usable. We expect the users to strictly acquire-record-submit-present.

The Ugly:

  1. Our KHR swapchain implementation is more limited: no support for any usage other than COLOR_ATTACHMENT. This is technically valid in Vulkan, but for some reason many apps expect to transfer to/from swapchain images. So this is fine for the matter of CTS and VkPI, but can introduce some friction in real world testing.
  2. The new swapchain model itself needs to be evolved a bit more, according to Soundness with new swapchain model on Vulkan gfx#3184 . We don't know how exactly: there is both a risk (that we'll need to redo something here) and an opportunity (that we'll support other usages, for example).

@kvark
Copy link
Member Author

kvark commented Apr 3, 2020

Compatibility list:

app status changes needed
LunarG cube non-acquired use of swapchain
dota2 ValveSoftware/Dota-2-Vulkan#335
FPS Infinite non-acquired use of swapchain
gzDoom
vkQuake1
vkQuake2 kondrak/vkQuake2#90
vkQuake3 🚧 suijingfeng/vkQuake3#8
filament google/filament#2342
VSand Ealrann/VSand#21
Diligent engine gfx-rs/gfx#3206 gfx-rs/gfx#3207
RPCS3 🚧 many features missing
Dolphin

@msiglreith
Copy link
Collaborator

How does this interact with present modes? In particular, out of order presentation and acquiring multiple swapchain images?

@kvark
Copy link
Member Author

kvark commented Apr 4, 2020

out of order presentation

Should be unaffected.

acquiring multiple swapchain images

multiple images of the same swapchain - not supported by this path

@kvark
Copy link
Member Author

kvark commented Apr 7, 2020

Given the amount of testing I'm doing right now, will be confident to release portability-0.8 right after this merges, if we proceed 😄

Copy link

@monocodus monocodus bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is autogenerated code-style review, only first 25 of 73 new suggestions are shown

maxPerStageDescriptorStorageBuffers: limits.max_per_stage_descriptor_storage_buffers as _,
maxPerStageDescriptorSampledImages: limits.max_per_stage_descriptor_sampled_images as _,
maxPerStageDescriptorStorageImages: limits.max_per_stage_descriptor_storage_images as _,
maxPerStageDescriptorInputAttachments: limits.max_per_stage_descriptor_input_attachments as _,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
maxPerStageDescriptorInputAttachments: limits.max_per_stage_descriptor_input_attachments as _,
maxPerStageDescriptorInputAttachments: limits.max_per_stage_descriptor_input_attachments
as _,

This comment was generated by: rustfmt

// Warning: spec violation
// "The x/y rectangle of the viewport must lie entirely within the current attachment size."
viewportBoundsRange: [0.0, viewport_size as f32],
maxDescriptorSetUniformBuffersDynamic: limits.max_descriptor_set_uniform_buffers_dynamic.max(1) as _,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
maxDescriptorSetUniformBuffersDynamic: limits.max_descriptor_set_uniform_buffers_dynamic.max(1) as _,
maxDescriptorSetUniformBuffersDynamic: limits
.max_descriptor_set_uniform_buffers_dynamic
.max(1) as _,

This comment was generated by: rustfmt

viewportBoundsRange: [0.0, viewport_size as f32],
maxDescriptorSetUniformBuffersDynamic: limits.max_descriptor_set_uniform_buffers_dynamic.max(1) as _,
maxDescriptorSetStorageBuffers: limits.max_descriptor_set_storage_buffers as _,
maxDescriptorSetStorageBuffersDynamic: limits.max_descriptor_set_storage_buffers_dynamic.max(1) as _,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
maxDescriptorSetStorageBuffersDynamic: limits.max_descriptor_set_storage_buffers_dynamic.max(1) as _,
maxDescriptorSetStorageBuffersDynamic: limits
.max_descriptor_set_storage_buffers_dynamic
.max(1) as _,

This comment was generated by: rustfmt

pointSizeGranularity: 0.0,
lineWidthGranularity: 0.0,
strictLines: 0,
standardSampleLocations: if limits.standard_sample_locations { VK_TRUE } else { VK_FALSE },
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
standardSampleLocations: if limits.standard_sample_locations { VK_TRUE } else { VK_FALSE },
standardSampleLocations: if limits.standard_sample_locations {
VK_TRUE
} else {
VK_FALSE
},

This comment was generated by: rustfmt

@@ -6,21 +6,19 @@ use hal::{
pool::CommandPool as _,
pso::DescriptorPool,
queue::{CommandQueue as _, QueueFamily},
window::{PresentMode, Surface, Swapchain as _},
window::{PresentMode, PresentationSurface as _, Surface as _},
{command as com, memory, pass, pso, queue},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{command as com, memory, pass, pso, queue},
{command as com, memory, pass, pso, queue}, {Features, Instance},

This comment was generated by: rustfmt

@@ -1546,7 +1586,7 @@ pub extern "C" fn gfxCreateSemaphore(
pSemaphore: *mut VkSemaphore,
) -> VkResult {
let semaphore = match gpu.device.create_semaphore() {
Ok(s) => s,
Ok(raw) => Semaphore { raw, is_fake: false },
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Ok(raw) => Semaphore { raw, is_fake: false },
Ok(raw) => Semaphore {
raw,
is_fake: false,
},

This comment was generated by: rustfmt

@@ -1847,19 +1888,30 @@ pub extern "C" fn gfxCreateImageView(
pView: *mut VkImageView,
) -> VkResult {
let info = unsafe { &*pCreateInfo };
if let Image::SwapchainFrame { swapchain, frame } = *info.image {
unsafe {
*pView = Handle::new(ImageView::SwapchainFrame {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*pView = Handle::new(ImageView::SwapchainFrame {
*pView = Handle::new(ImageView::SwapchainFrame { swapchain, frame });

This comment was generated by: rustfmt

if let Image::SwapchainFrame { swapchain, frame } = *info.image {
unsafe {
*pView = Handle::new(ImageView::SwapchainFrame {
swapchain,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
swapchain,

This comment was generated by: rustfmt

unsafe {
*pView = Handle::new(ImageView::SwapchainFrame {
swapchain,
frame,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
frame,

This comment was generated by: rustfmt

*pView = Handle::new(ImageView::SwapchainFrame {
swapchain,
frame,
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
});

This comment was generated by: rustfmt

Copy link

@monocodus monocodus bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is autogenerated code-style review, no new suggestions, fix old one

@kvark kvark mentioned this pull request Jun 4, 2020
@kvark
Copy link
Member Author

kvark commented Aug 5, 2020

We can't hold this off forever.
bors r+

bors bot added a commit that referenced this pull request Aug 5, 2020
210: Port to the new swapchain model r=kvark a=kvark

Closes #208
Fixes #212 
Also has general fixes to:
  - push constant offsets in `gfxCreatePipelineLayout`
  - destination subresources in `gfxCmdResolveImage`

The PR is inviting for discussion: @grovesNL @msiglreith 
I'm not 100% sure what to do yet.

The Good:
  1. Being able to remove the old swapchain from gfx-rs COMPLETELY. It was hacky on all the backends other than Vulkan, quite complicated on Metal, and didn't work very in general.
  2. Fullscreen support! It's not ideal yet (occasional hitches), but it was pretty much non-functional before. In general, stuff that runs is more robust this change.

The Bad:
  1. Portability implementation is a bit more complex now, but not extraordinary so. In general, I think it's a win if we move some complication out of gfx-rs into gfx-portability, since gfx-rs has more users, it's more important to keep clean.
  2. We can't support recording a render pass that uses a swapchain image if either:
    - the image is not acquired at the moment of recording
    - the command buffer is re-usable. We expect the users to strictly acquire-record-submit-present.

The Ugly:
  1. Our KHR swapchain implementation is more limited: no support for any usage other than COLOR_ATTACHMENT. This is technically valid in Vulkan, but for some reason many apps expect to transfer to/from swapchain images. So this is fine for the matter of CTS and VkPI, but can introduce some friction in real world testing.
  2. The new swapchain model itself needs to be evolved a bit more, according to gfx-rs/gfx#3184 . We don't know how exactly: there is both a risk (that we'll need to redo something here) and an opportunity (that we'll support other usages, for example).


Co-authored-by: Dzmitry Malyshau <[email protected]>
@bors
Copy link
Contributor

bors bot commented Aug 5, 2020

Timed out.

@kvark
Copy link
Member Author

kvark commented Aug 5, 2020

bors retry

bors bot added a commit that referenced this pull request Aug 5, 2020
210: Port to the new swapchain model r=kvark a=kvark

Closes #208
Fixes #212 
Also has general fixes to:
  - push constant offsets in `gfxCreatePipelineLayout`
  - destination subresources in `gfxCmdResolveImage`

The PR is inviting for discussion: @grovesNL @msiglreith 
I'm not 100% sure what to do yet.

The Good:
  1. Being able to remove the old swapchain from gfx-rs COMPLETELY. It was hacky on all the backends other than Vulkan, quite complicated on Metal, and didn't work very in general.
  2. Fullscreen support! It's not ideal yet (occasional hitches), but it was pretty much non-functional before. In general, stuff that runs is more robust this change.

The Bad:
  1. Portability implementation is a bit more complex now, but not extraordinary so. In general, I think it's a win if we move some complication out of gfx-rs into gfx-portability, since gfx-rs has more users, it's more important to keep clean.
  2. We can't support recording a render pass that uses a swapchain image if either:
    - the image is not acquired at the moment of recording
    - the command buffer is re-usable. We expect the users to strictly acquire-record-submit-present.

The Ugly:
  1. Our KHR swapchain implementation is more limited: no support for any usage other than COLOR_ATTACHMENT. This is technically valid in Vulkan, but for some reason many apps expect to transfer to/from swapchain images. So this is fine for the matter of CTS and VkPI, but can introduce some friction in real world testing.
  2. The new swapchain model itself needs to be evolved a bit more, according to gfx-rs/gfx#3184 . We don't know how exactly: there is both a risk (that we'll need to redo something here) and an opportunity (that we'll support other usages, for example).


Co-authored-by: Dzmitry Malyshau <[email protected]>
@bors
Copy link
Contributor

bors bot commented Aug 5, 2020

Timed out.

@kvark kvark merged commit 3c68e62 into gfx-rs:master Aug 5, 2020
@kvark kvark deleted the swapchain branch August 5, 2020 17:08
@kvark kvark mentioned this pull request Aug 23, 2020
75 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support VK_KHR_get_surface_capabilities2 Support the new gfx-hal swapchain model
2 participants