Skip to content

Conversation

cart
Copy link
Member

@cart cart commented Aug 13, 2025

Objective

Currently registering additional required Vulkan features requires either hard-coding them into bevy_render (see the current DLSS proposal), or forcing the plugin to take full manual control over wgpu initialization. Neither is an acceptable or scalable option for a modular engine like Bevy.

Solution

  • Add a new raw_vulkan_init Cargo feature, that when enabled switches to wgpu's raw Vulkan init path, which accepts callbacks that allow checking and requiring additional Vulkan features.
  • Add a new WgpuRawVulkanInitSettings resource, which provides wgpu Vulkan Instance and Device init callbacks, which can be used to detect and register vulkan features.
  • These callbacks can register arbitrary features in the new AdditionalVulkanFeatures resource, which is inserted into the RenderApp at the same time that the RenderDevice is.

This enables plugins to register initialization callbacks, which must happen before RenderPlugin. They can then feed off of AdditionalVulkanFeatures, after the renderer is initialized, to detect if a given feature is supported.

Due to the current lifecycles, this is best accomplished with either:

  • A separate "init plugin" that is registered before RenderPlugin, and a "logic plugin" that does everything else. This should be used if the plugin logic needs Plugin::build() access to render device state, which needs to be registered after RenderPlugin to have access. The proposed DLSS feature needs this pattern.
  • A single "init plugin" that is registered before RenderPlugin and does everything. Use this pattern if you can as it is simpler.

With deferred plugin init, we could remove the need for this split.

@cart cart added this to the 0.17 milestone Aug 13, 2025
@cart cart added C-Feature A new feature, making something new possible A-Rendering Drawing game state to the screen labels Aug 13, 2025
Copy link
Contributor

You added a new feature but didn't update the readme. Please run cargo run -p build-templated-pages -- update features to update it, and commit the file change.

@alice-i-cecile alice-i-cecile added the S-Needs-Review Needs reviewer attention (from anyone!) to move forward label Aug 14, 2025
Copy link
Member

@tychedelia tychedelia left a comment

Choose a reason for hiding this comment

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

Somehow accidentally approved this while reviewing last night, reviewing for real now. :)

Co-authored-by: JMS55 <47158642+JMS55@users.noreply.github.com>
@JMS55 JMS55 added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Aug 15, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Aug 15, 2025
Merged via the queue into bevyengine:main with commit 7a86925 Aug 15, 2025
38 checks passed
Copy link
Member

@tychedelia tychedelia left a comment

Choose a reason for hiding this comment

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

I think to make this pattern more robust, beyond upstream wgpu support for not forcing the instance creation, we need to more closely integrate render init with the ECS.

&mut additional_vulkan_features,
)
.await
.unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

Realize this is explicitly is stated to force the Vulkan instance, but we could fallback to the regular init here with a warning instead of unwrapping.

&device_descriptor.memory_hints,
Some(Box::new(|mut args| {
for callback in &settings.create_device_callbacks {
(callback)(&mut args, &raw_adapter, additional_features);
Copy link
Member

Choose a reason for hiding this comment

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

Long term, we also need access to &mut World here in order to initialize additional resources (additional queues, etc).

github-merge-queue bot pushed a commit that referenced this pull request Aug 31, 2025
#20565 broke compiling with `--all-features` on macos. Add the
`vulkan-portability` feature to `bevy_render` required to make vulkan
compile with wgpu on mac.

Co-authored-by: François Mockers <francois.mockers@vleue.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants