Implement shader barycentrics (#8320)

This commit is contained in:
atlv authored and GitHub committed 2025-10-29 13:15:21 -04:00
1 parent 54beef8aca
commit ddcd89fd69
34 files changed
+422 -4

No files matched your search

+40
View File
@@ -128,6 +128,9 @@ pub struct PhysicalDeviceFeatures {
/// Features provided by `VK_KHR_shader_integer_dot_product`, promoted to Vulkan 1.3.
shader_integer_dot_product:
Option<vk::PhysicalDeviceShaderIntegerDotProductFeaturesKHR<'static>>,
/// Features provided by `VK_KHR_fragment_shader_barycentric`
shader_barycentrics: Option<vk::PhysicalDeviceFragmentShaderBarycentricFeaturesKHR<'static>>,
}
impl PhysicalDeviceFeatures {
@@ -201,6 +204,9 @@ impl PhysicalDeviceFeatures {
if let Some(ref mut feature) = self.shader_integer_dot_product {
info = info.push_next(feature);
}
if let Some(ref mut feature) = self.shader_barycentrics {
info = info.push_next(feature);
}
info
}
@@ -535,6 +541,17 @@ impl PhysicalDeviceFeatures {
} else {
None
},
shader_barycentrics: if enabled_extensions
.contains(&khr::fragment_shader_barycentric::NAME)
{
let needed = requested_features.intersects(wgt::Features::SHADER_BARYCENTRICS);
Some(
vk::PhysicalDeviceFragmentShaderBarycentricFeaturesKHR::default()
.fragment_shader_barycentric(needed),
)
} else {
None
},
}
}
@@ -669,6 +686,13 @@ impl PhysicalDeviceFeatures {
);
}
if let Some(ref shader_barycentrics) = self.shader_barycentrics {
features.set(
F::SHADER_BARYCENTRICS,
shader_barycentrics.fragment_shader_barycentric != 0,
);
}
//if caps.supports_extension(khr::sampler_mirror_clamp_to_edge::NAME) {
//if caps.supports_extension(ext::sampler_filter_minmax::NAME) {
features.set(
@@ -1184,6 +1208,11 @@ impl PhysicalDeviceProperties {
extensions.push(ext::mesh_shader::NAME);
}
// Require `VK_KHR_fragment_shader_barycentric` if the associated feature was requested
if requested_features.intersects(wgt::Features::SHADER_BARYCENTRICS) {
extensions.push(khr::fragment_shader_barycentric::NAME);
}
extensions
}
@@ -1638,6 +1667,13 @@ impl super::InstanceShared {
features2 = features2.push_next(next);
}
if capabilities.supports_extension(khr::fragment_shader_barycentric::NAME) {
let next = features
.shader_barycentrics
.insert(vk::PhysicalDeviceFragmentShaderBarycentricFeaturesKHR::default());
features2 = features2.push_next(next);
}
unsafe { get_device_properties.get_physical_device_features2(phd, &mut features2) };
features2.features
} else {
@@ -2135,6 +2171,10 @@ impl super::Adapter {
capabilities.push(spv::Capability::ClipDistance);
}
if features.intersects(wgt::Features::SHADER_BARYCENTRICS) {
capabilities.push(spv::Capability::FragmentBarycentricKHR);
}
let mut flags = spv::WriterFlags::empty();
flags.set(
spv::WriterFlags::DEBUG,