mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-02-17 01:12:41 +00:00
Merge #1676
1676: Add `Feature::SHADER_PRIMITIVE_INDEX` to support `builtin(primitive_index)` in fragment shaders r=kvark a=initial-algebra **Connections** https://github.com/gfx-rs/wgpu/issues/1669 https://github.com/gfx-rs/naga/pull/1097 **Description** Allows fragment shaders to access the index of the current primitive via a new builtin variable. **Testing** Works on my machine. - passes the capability to my fork of `naga` for basic validation and translation - enables the `geometryShader` feature for Vulkan - is refused by DX12 Needs to be implemented and tested for OpenGL, DirectX and Metal. Co-authored-by: initial-algebra <67286231+initial-algebra@users.noreply.github.com>
This commit is contained in:
commit
4e7c7a3b77
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1051,7 +1051,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "naga"
|
name = "naga"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
source = "git+https://github.com/gfx-rs/naga?rev=458db0b#458db0b5228854dc417283f4b9742e03f25bc492"
|
source = "git+https://github.com/gfx-rs/naga?rev=8f71a36#8f71a368eff3a18fd348ab6193cb183df0f49f95"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bit-set",
|
"bit-set",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
|
@ -36,7 +36,7 @@ thiserror = "1"
|
|||||||
|
|
||||||
[dependencies.naga]
|
[dependencies.naga]
|
||||||
git = "https://github.com/gfx-rs/naga"
|
git = "https://github.com/gfx-rs/naga"
|
||||||
rev = "458db0b"
|
rev = "8f71a36"
|
||||||
features = ["wgsl-in"]
|
features = ["wgsl-in"]
|
||||||
|
|
||||||
[dependencies.wgt]
|
[dependencies.wgt]
|
||||||
|
@ -898,6 +898,11 @@ impl<A: HalApi> Device<A> {
|
|||||||
Caps::FLOAT64,
|
Caps::FLOAT64,
|
||||||
self.features.contains(wgt::Features::SHADER_FLOAT64),
|
self.features.contains(wgt::Features::SHADER_FLOAT64),
|
||||||
);
|
);
|
||||||
|
caps.set(
|
||||||
|
Caps::PRIMITIVE_INDEX,
|
||||||
|
self.features
|
||||||
|
.contains(wgt::Features::SHADER_PRIMITIVE_INDEX),
|
||||||
|
);
|
||||||
let info = naga::valid::Validator::new(naga::valid::ValidationFlags::all(), caps)
|
let info = naga::valid::Validator::new(naga::valid::ValidationFlags::all(), caps)
|
||||||
.validate(&module)?;
|
.validate(&module)?;
|
||||||
let interface = validation::Interface::new(&module, &info, self.features);
|
let interface = validation::Interface::new(&module, &info, self.features);
|
||||||
|
@ -65,11 +65,11 @@ core-graphics-types = "0.1"
|
|||||||
|
|
||||||
[dependencies.naga]
|
[dependencies.naga]
|
||||||
git = "https://github.com/gfx-rs/naga"
|
git = "https://github.com/gfx-rs/naga"
|
||||||
rev = "458db0b"
|
rev = "8f71a36"
|
||||||
|
|
||||||
[dev-dependencies.naga]
|
[dev-dependencies.naga]
|
||||||
git = "https://github.com/gfx-rs/naga"
|
git = "https://github.com/gfx-rs/naga"
|
||||||
rev = "458db0b"
|
rev = "8f71a36"
|
||||||
features = ["wgsl-in"]
|
features = ["wgsl-in"]
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
@ -125,6 +125,7 @@ impl PhysicalDeviceFeatures {
|
|||||||
//.shader_int64(requested_features.contains(wgt::Features::SHADER_INT64))
|
//.shader_int64(requested_features.contains(wgt::Features::SHADER_INT64))
|
||||||
//.shader_int16(requested_features.contains(wgt::Features::SHADER_INT16))
|
//.shader_int16(requested_features.contains(wgt::Features::SHADER_INT16))
|
||||||
//.shader_resource_residency(requested_features.contains(wgt::Features::SHADER_RESOURCE_RESIDENCY))
|
//.shader_resource_residency(requested_features.contains(wgt::Features::SHADER_RESOURCE_RESIDENCY))
|
||||||
|
.geometry_shader(requested_features.contains(wgt::Features::SHADER_PRIMITIVE_INDEX))
|
||||||
.build(),
|
.build(),
|
||||||
vulkan_1_2: if api_version >= vk::API_VERSION_1_2 {
|
vulkan_1_2: if api_version >= vk::API_VERSION_1_2 {
|
||||||
Some(
|
Some(
|
||||||
@ -290,6 +291,7 @@ impl PhysicalDeviceFeatures {
|
|||||||
F::TEXTURE_BINDING_ARRAY,
|
F::TEXTURE_BINDING_ARRAY,
|
||||||
self.core.shader_sampled_image_array_dynamic_indexing != 0,
|
self.core.shader_sampled_image_array_dynamic_indexing != 0,
|
||||||
);
|
);
|
||||||
|
features.set(F::SHADER_PRIMITIVE_INDEX, self.core.geometry_shader != 0);
|
||||||
if Self::all_features_supported(
|
if Self::all_features_supported(
|
||||||
&features,
|
&features,
|
||||||
&[
|
&[
|
||||||
|
@ -479,6 +479,17 @@ bitflags::bitflags! {
|
|||||||
///
|
///
|
||||||
/// This is a native only feature.
|
/// This is a native only feature.
|
||||||
const SPIRV_SHADER_PASSTHROUGH = 0x0000_0800_0000_0000;
|
const SPIRV_SHADER_PASSTHROUGH = 0x0000_0800_0000_0000;
|
||||||
|
/// Enables `builtin(primitive_index)` in fragment shaders.
|
||||||
|
///
|
||||||
|
/// Note: enables geometry processing for pipelines using the builtin.
|
||||||
|
/// This may come with a significant performance impact on some hardware.
|
||||||
|
/// Other pipelines are not affected.
|
||||||
|
///
|
||||||
|
/// Supported platforms:
|
||||||
|
/// - Vulkan
|
||||||
|
///
|
||||||
|
/// This is a native only feature.
|
||||||
|
const SHADER_PRIMITIVE_INDEX = 0x0000_1000_0000_0000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,13 +73,13 @@ env_logger = "0.8"
|
|||||||
|
|
||||||
[dependencies.naga]
|
[dependencies.naga]
|
||||||
git = "https://github.com/gfx-rs/naga"
|
git = "https://github.com/gfx-rs/naga"
|
||||||
rev = "458db0b"
|
rev = "8f71a36"
|
||||||
optional = true
|
optional = true
|
||||||
|
|
||||||
# used to test all the example shaders
|
# used to test all the example shaders
|
||||||
[dev-dependencies.naga]
|
[dev-dependencies.naga]
|
||||||
git = "https://github.com/gfx-rs/naga"
|
git = "https://github.com/gfx-rs/naga"
|
||||||
rev = "458db0b"
|
rev = "8f71a36"
|
||||||
features = ["wgsl-in"]
|
features = ["wgsl-in"]
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
|
Loading…
Reference in New Issue
Block a user