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

vulkan backend implementation 6: some optimization #1861

Merged
merged 1 commit into from
Aug 17, 2019

Conversation

rinthel
Copy link
Contributor

@rinthel rinthel commented Aug 17, 2019

Hello! This is the 6th PR of my Vulkan backend implementation (#274)

Changes

Refactoring & optimizing descriptor set binding

  • Uniform buffer objects which are set by setUniform() or predefined are now using dynamic uniform buffer.
  • Thus descriptor set can be reused if renderBind information or pipeline layout is not changed.
  • Allocating and writing descriptor sets is refactored into a function.
  • I also tried to cache descriptor set like d3d12 implementation (using something like bindLru in the d3d12 backend), but failed. Maybe descriptor sets are already in a descriptor pool, so allocation and free is fast enough to be in a frame.
  • After this optimization, example-17 now start to work, and active scissor rect drawing in example-21 also works. Perhaps the main reason that these examples don't work is the lack of descriptor sets (1024 for each frame)

Some minor change & bug fix

  • Supports to indirect compute call (for enabling example-24 indirect call option)
  • Image layout is reinitialized when texture is released. This fixes example-16 crash when switching a light source.
  • Get / set device features when creating logical device, and check independent blending feature. This fixes example-19 crash when switching MRT-independent option.
  • Create depth view for depth/stencil texture.

Thank you!

- add support to indirect compute call
- use dynamic uniform buffer instead of uniform
- create depth view for depth/stencil texture
- fix dynamic uniform buffer bug, apply it to compute shader
- refactor descriptor set allocation / setting
- fix image layout reinit
- get and set device feature / fix independent blending
- cleanup
@@ -1345,7 +1348,7 @@ VK_IMPORT_INSTANCE
dci.ppEnabledLayerNames = enabledLayerNames;
dci.enabledExtensionCount = numEnabledExtensions;
dci.ppEnabledExtensionNames = enabledExtension;
dci.pEnabledFeatures = NULL;
dci.pEnabledFeatures = &m_deviceFeatures;
Copy link

@cforfang cforfang Aug 17, 2019

Choose a reason for hiding this comment

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

Passing the output of vkGetPhysicalDeviceFeatures directly like this will unnecessary enable e.g. robustBufferAccess if available, which has a performance impact. I'd consider turning that off explicitly here (or only enable the features you actually want). :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cforfang Then how about this on line 1160?

VkPhysicalDeviceFeatures deviceFeatures;
vkGetPhysicalDeviceFeatures(m_physicalDevice, &deviceFeatures);
bx::memSet(&m_deviceFeatures, 0, sizeof(VkPhysicalDeviceFeatures));
m_deviceFeatures.independentBlend = deviceFeatures.independentBlend;

Choose a reason for hiding this comment

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

While I think that would work, I'm not 100% if not enabling things like textureCompressionETC2 / textureCompressionASTC_LDR / textureCompressionBC might either (a) literally turn off support in the drivers, or (b) cause validation layers to complain.

It might be simpler to just enable everything available except robustBufferAccess as I don't know of any other features with a performance impact.

@bkaradzic bkaradzic merged commit 4342db8 into bkaradzic:master Aug 17, 2019
@rinthel rinthel deleted the vulkan-support-06-optimization branch August 17, 2019 18:54
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.

3 participants