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 16 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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,
SupaMaggie70Incorporated marked this conversation as resolved.
Show resolved Hide resolved
phd_features: adapter::PhysicalDeviceFeatures,
downlevel_flags: wgt::DownlevelFlags,
private_caps: PrivateCapabilities,
workarounds: Workarounds,
Expand Down