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

Mesh shaders - initial wgpu hal changes #7089

Open
wants to merge 17 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
f7e6e18
Initial(untested commit), vulkan and gles only supported
SupaMaggie70Incorporated Jan 17, 2025
4e5772b
Maybe fixed compiles for metal and dx12
SupaMaggie70Incorporated Jan 18, 2025
a5f8909
Merge branch 'gfx-rs:trunk' into mesh-shading/wgpu-hal
SupaMaggie70Incorporated Jan 18, 2025
ab83fa7
Hopefully fixed compiles for other backends and updated to functional…
SupaMaggie70Incorporated Jan 18, 2025
0b2bb72
I don't get git
SupaMaggie70Incorporated Jan 18, 2025
06d3f52
Fixed the clippy warning
SupaMaggie70Incorporated Jan 18, 2025
1939260
Merge recent changes, most significantly features type overhaul
SupaMaggie70Incorporated Feb 8, 2025
5a66eab
Fixed silly documentation mistake
SupaMaggie70Incorporated Feb 9, 2025
4840189
Fixed issue with multiview feature
SupaMaggie70Incorporated Feb 13, 2025
6c2c9ac
Dummy commit for dummy CI
SupaMaggie70Incorporated Feb 13, 2025
8c07665
Merge branch 'trunk' into mesh-shading/wgpu-hal
SupaMaggie70Incorporated Feb 13, 2025
fd54843
Merge branch 'trunk' into mesh-shading/wgpu-hal
SupaMaggie70Incorporated Feb 14, 2025
d145778
Re trigger CI checks, to avoid #7126
SupaMaggie70Incorporated Feb 14, 2025
e67c399
Merge branch 'trunk' into mesh-shading/wgpu-hal
SupaMaggie70Incorporated Feb 14, 2025
d34935e
Merge branch 'trunk' into mesh-shading/wgpu-hal
SupaMaggie70Incorporated Feb 14, 2025
bd9fa21
Merge branch 'trunk' into mesh-shading/wgpu-hal
SupaMaggie70Incorporated Feb 14, 2025
34cc46a
Merge branch 'trunk' into mesh-shading/wgpu-hal
SupaMaggie70Incorporated Feb 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions wgpu-hal/src/vulkan/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,12 @@ pub struct PhysicalDeviceFeatures {

/// Features provided by `VK_EXT_subgroup_size_control`, promoted to Vulkan 1.3.
subgroup_size_control: Option<vk::PhysicalDeviceSubgroupSizeControlFeatures<'static>>,
mesh_shader: Option<vk::PhysicalDeviceMeshShaderFeaturesEXT<'static>>,

/// Features proved by `VK_KHR_maintenance4`, needed for mesh shaders
maintenance4: Option<vk::PhysicalDeviceMaintenance4FeaturesKHR<'static>>,

/// Features proved by `VK_EXT_mesh_shader`
mesh_shader: Option<vk::PhysicalDeviceMeshShaderFeaturesEXT<'static>>,
}

impl PhysicalDeviceFeatures {
Expand All @@ -143,6 +147,9 @@ impl PhysicalDeviceFeatures {
if let Some(ref mut feature) = self.robustness2 {
info = info.push_next(feature);
}
if let Some(ref mut feature) = self.multiview {

Choose a reason for hiding this comment

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

This was missing for some reason, I spent quite a lot of time very confused.

info = info.push_next(feature);
}
if let Some(ref mut feature) = self.astc_hdr {
info = info.push_next(feature);
}
Expand Down Expand Up @@ -174,10 +181,10 @@ impl PhysicalDeviceFeatures {
if let Some(ref mut feature) = self.subgroup_size_control {
info = info.push_next(feature);
}
if let Some(ref mut feature) = self.mesh_shader {
if let Some(ref mut feature) = self.maintenance4 {
info = info.push_next(feature);
}
if let Some(ref mut feature) = self.maintenance4 {
if let Some(ref mut feature) = self.mesh_shader {
info = info.push_next(feature);
}
info
Expand Down Expand Up @@ -210,12 +217,14 @@ impl PhysicalDeviceFeatures {
/// [`add_to_device_create`]: PhysicalDeviceFeatures::add_to_device_create
/// [`Adapter::required_device_extensions`]: super::Adapter::required_device_extensions
fn from_extensions_and_requested_features(
device_api_version: u32,
phd_capabilities: &PhysicalDeviceProperties,
phd_features: &PhysicalDeviceFeatures,
enabled_extensions: &[&'static CStr],
requested_features: wgt::Features,
downlevel_flags: wgt::DownlevelFlags,
private_caps: &super::PrivateCapabilities,
) -> Self {
let device_api_version = phd_capabilities.device_api_version;
let needs_sampled_image_non_uniform = requested_features.contains(
wgt::Features::TEXTURE_BINDING_ARRAY
| wgt::Features::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING,
Expand Down Expand Up @@ -496,7 +505,11 @@ impl PhysicalDeviceFeatures {
vk::PhysicalDeviceMeshShaderFeaturesEXT::default()
.mesh_shader(needed)
.task_shader(needed)
.multiview_mesh_shader(needed && multiview),
.multiview_mesh_shader(
needed
&& multiview
&& phd_features.mesh_shader.unwrap().multiview_mesh_shader == 1,

Choose a reason for hiding this comment

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

Not sure if this is the best way to do this. I had to change stuff around so that whether this was supported was visible in this context. Worst comes to worst, we can forget multiview in mesh shaders for now. The main problem is that apparently llvmpipe supports mesh shaders and multiview but not multiview in mesh shaders.

),
)
} else {
None
Expand Down Expand Up @@ -836,12 +849,10 @@ impl PhysicalDeviceFeatures {
F::VULKAN_EXTERNAL_MEMORY_WIN32,
caps.supports_extension(khr::external_memory_win32::NAME),
);

features.set(
F::MESH_SHADER,
caps.supports_extension(ext::mesh_shader::NAME),
);

(features, dl_flags)
}
}
Expand Down Expand Up @@ -1539,7 +1550,6 @@ impl super::Instance {
},
backend: wgt::Backend::Vulkan,
};

let (available_features, downlevel_flags) =
phd_features.to_wgpu(&self.shared.raw, phd, &phd_capabilities);
let mut workarounds = super::Workarounds::empty();
Expand Down Expand Up @@ -1694,7 +1704,7 @@ impl super::Instance {
| vk::MemoryPropertyFlags::HOST_CACHED
| vk::MemoryPropertyFlags::LAZILY_ALLOCATED,
phd_capabilities,
//phd_features,
phd_features,
downlevel_flags,
private_caps,
workarounds,
Expand Down Expand Up @@ -1759,7 +1769,8 @@ impl super::Adapter {
features: wgt::Features,
) -> PhysicalDeviceFeatures {
PhysicalDeviceFeatures::from_extensions_and_requested_features(
self.phd_capabilities.device_api_version,
&self.phd_capabilities,
&self.phd_features,
enabled_extensions,
features,
self.downlevel_flags,
Expand Down
2 changes: 1 addition & 1 deletion wgpu-hal/src/vulkan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ pub struct Adapter {
//queue_families: Vec<vk::QueueFamilyProperties>,
known_memory_flags: vk::MemoryPropertyFlags,
phd_capabilities: adapter::PhysicalDeviceProperties,
//phd_features: adapter::PhysicalDeviceFeatures,
phd_features: adapter::PhysicalDeviceFeatures,
downlevel_flags: wgt::DownlevelFlags,
private_caps: PrivateCapabilities,
workarounds: Workarounds,
Expand Down