mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 14:55:05 +00:00
[naga] added DrawID (#6325)
This commit is contained in:
parent
c0fa1bcce5
commit
43cb730d58
@ -107,6 +107,7 @@ By @bradwerth [#6216](https://github.com/gfx-rs/wgpu/pull/6216).
|
|||||||
- Fix type parameters to vec/mat type constructors to also support aliases. By @sagudev in [#6189](https://github.com/gfx-rs/wgpu/pull/6189).
|
- Fix type parameters to vec/mat type constructors to also support aliases. By @sagudev in [#6189](https://github.com/gfx-rs/wgpu/pull/6189).
|
||||||
- Accept global `var`s without explicit type. By @sagudev in [#6199](https://github.com/gfx-rs/wgpu/pull/6199).
|
- Accept global `var`s without explicit type. By @sagudev in [#6199](https://github.com/gfx-rs/wgpu/pull/6199).
|
||||||
- Fix handling of phony statements, so they are actually emitted. By @sagudev in [#6328](https://github.com/gfx-rs/wgpu/pull/6328).
|
- Fix handling of phony statements, so they are actually emitted. By @sagudev in [#6328](https://github.com/gfx-rs/wgpu/pull/6328).
|
||||||
|
- Added `gl_DrawID` to glsl and `DrawIndex` to spv. By @ChosenName in [#6325](https://github.com/gfx-rs/wgpu/pull/6325).
|
||||||
|
|
||||||
#### General
|
#### General
|
||||||
|
|
||||||
|
@ -579,7 +579,7 @@ impl<'a, W> Writer<'a, W> {
|
|||||||
crate::BuiltIn::ViewIndex => {
|
crate::BuiltIn::ViewIndex => {
|
||||||
self.features.request(Features::MULTI_VIEW)
|
self.features.request(Features::MULTI_VIEW)
|
||||||
}
|
}
|
||||||
crate::BuiltIn::InstanceIndex => {
|
crate::BuiltIn::InstanceIndex | crate::BuiltIn::DrawID => {
|
||||||
self.features.request(Features::INSTANCE_INDEX)
|
self.features.request(Features::INSTANCE_INDEX)
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -238,7 +238,7 @@ bitflags::bitflags! {
|
|||||||
/// additional functions on shadows and arrays of shadows.
|
/// additional functions on shadows and arrays of shadows.
|
||||||
const TEXTURE_SHADOW_LOD = 0x2;
|
const TEXTURE_SHADOW_LOD = 0x2;
|
||||||
/// Supports ARB_shader_draw_parameters on the host, which provides
|
/// Supports ARB_shader_draw_parameters on the host, which provides
|
||||||
/// support for `gl_BaseInstanceARB`, `gl_BaseVertexARB`, and `gl_DrawIDARB`.
|
/// support for `gl_BaseInstanceARB`, `gl_BaseVertexARB`, `gl_DrawIDARB`, and `gl_DrawID`.
|
||||||
const DRAW_PARAMETERS = 0x4;
|
const DRAW_PARAMETERS = 0x4;
|
||||||
/// Include unused global variables, constants and functions. By default the output will exclude
|
/// Include unused global variables, constants and functions. By default the output will exclude
|
||||||
/// global variables that are not used in the specified entrypoint (including indirect use),
|
/// global variables that are not used in the specified entrypoint (including indirect use),
|
||||||
@ -4719,6 +4719,7 @@ const fn glsl_built_in(built_in: crate::BuiltIn, options: VaryingOptions) -> &'s
|
|||||||
}
|
}
|
||||||
Bi::PointSize => "gl_PointSize",
|
Bi::PointSize => "gl_PointSize",
|
||||||
Bi::VertexIndex => "uint(gl_VertexID)",
|
Bi::VertexIndex => "uint(gl_VertexID)",
|
||||||
|
Bi::DrawID => "gl_DrawID",
|
||||||
// fragment
|
// fragment
|
||||||
Bi::FragDepth => "gl_FragDepth",
|
Bi::FragDepth => "gl_FragDepth",
|
||||||
Bi::PointCoord => "gl_PointCoord",
|
Bi::PointCoord => "gl_PointCoord",
|
||||||
|
@ -178,7 +178,7 @@ impl crate::BuiltIn {
|
|||||||
Self::BaseInstance | Self::BaseVertex | Self::WorkGroupSize => {
|
Self::BaseInstance | Self::BaseVertex | Self::WorkGroupSize => {
|
||||||
return Err(Error::Unimplemented(format!("builtin {self:?}")))
|
return Err(Error::Unimplemented(format!("builtin {self:?}")))
|
||||||
}
|
}
|
||||||
Self::PointSize | Self::ViewIndex | Self::PointCoord => {
|
Self::PointSize | Self::ViewIndex | Self::PointCoord | Self::DrawID => {
|
||||||
return Err(Error::Custom(format!("Unsupported builtin {self:?}")))
|
return Err(Error::Custom(format!("Unsupported builtin {self:?}")))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -568,7 +568,7 @@ impl ResolvedBinding {
|
|||||||
Bi::SubgroupId => "simdgroup_index_in_threadgroup",
|
Bi::SubgroupId => "simdgroup_index_in_threadgroup",
|
||||||
Bi::SubgroupSize => "threads_per_simdgroup",
|
Bi::SubgroupSize => "threads_per_simdgroup",
|
||||||
Bi::SubgroupInvocationId => "thread_index_in_simdgroup",
|
Bi::SubgroupInvocationId => "thread_index_in_simdgroup",
|
||||||
Bi::CullDistance | Bi::ViewIndex => {
|
Bi::CullDistance | Bi::ViewIndex | Bi::DrawID => {
|
||||||
return Err(Error::UnsupportedBuiltIn(built_in))
|
return Err(Error::UnsupportedBuiltIn(built_in))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1618,6 +1618,7 @@ impl Writer {
|
|||||||
Bi::InstanceIndex => BuiltIn::InstanceIndex,
|
Bi::InstanceIndex => BuiltIn::InstanceIndex,
|
||||||
Bi::PointSize => BuiltIn::PointSize,
|
Bi::PointSize => BuiltIn::PointSize,
|
||||||
Bi::VertexIndex => BuiltIn::VertexIndex,
|
Bi::VertexIndex => BuiltIn::VertexIndex,
|
||||||
|
Bi::DrawID => BuiltIn::DrawIndex,
|
||||||
// fragment
|
// fragment
|
||||||
Bi::FragDepth => BuiltIn::FragDepth,
|
Bi::FragDepth => BuiltIn::FragDepth,
|
||||||
Bi::PointCoord => BuiltIn::PointCoord,
|
Bi::PointCoord => BuiltIn::PointCoord,
|
||||||
|
@ -1941,9 +1941,8 @@ fn builtin_str(built_in: crate::BuiltIn) -> Result<&'static str, Error> {
|
|||||||
| Bi::CullDistance
|
| Bi::CullDistance
|
||||||
| Bi::PointSize
|
| Bi::PointSize
|
||||||
| Bi::PointCoord
|
| Bi::PointCoord
|
||||||
| Bi::WorkGroupSize => {
|
| Bi::WorkGroupSize
|
||||||
return Err(Error::Custom(format!("Unsupported builtin {built_in:?}")))
|
| Bi::DrawID => return Err(Error::Custom(format!("Unsupported builtin {built_in:?}"))),
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,6 +202,7 @@ impl Frontend {
|
|||||||
"gl_VertexIndex" => BuiltIn::VertexIndex,
|
"gl_VertexIndex" => BuiltIn::VertexIndex,
|
||||||
"gl_SampleID" => BuiltIn::SampleIndex,
|
"gl_SampleID" => BuiltIn::SampleIndex,
|
||||||
"gl_LocalInvocationIndex" => BuiltIn::LocalInvocationIndex,
|
"gl_LocalInvocationIndex" => BuiltIn::LocalInvocationIndex,
|
||||||
|
"gl_DrawID" => BuiltIn::DrawID,
|
||||||
_ => return Ok(None),
|
_ => return Ok(None),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -139,6 +139,7 @@ pub(super) fn map_builtin(word: spirv::Word, invariant: bool) -> Result<crate::B
|
|||||||
Some(Bi::InstanceIndex) => crate::BuiltIn::InstanceIndex,
|
Some(Bi::InstanceIndex) => crate::BuiltIn::InstanceIndex,
|
||||||
Some(Bi::PointSize) => crate::BuiltIn::PointSize,
|
Some(Bi::PointSize) => crate::BuiltIn::PointSize,
|
||||||
Some(Bi::VertexIndex) => crate::BuiltIn::VertexIndex,
|
Some(Bi::VertexIndex) => crate::BuiltIn::VertexIndex,
|
||||||
|
Some(Bi::DrawIndex) => crate::BuiltIn::DrawID,
|
||||||
// fragment
|
// fragment
|
||||||
Some(Bi::FragDepth) => crate::BuiltIn::FragDepth,
|
Some(Bi::FragDepth) => crate::BuiltIn::FragDepth,
|
||||||
Some(Bi::PointCoord) => crate::BuiltIn::PointCoord,
|
Some(Bi::PointCoord) => crate::BuiltIn::PointCoord,
|
||||||
|
@ -400,6 +400,7 @@ pub enum BuiltIn {
|
|||||||
InstanceIndex,
|
InstanceIndex,
|
||||||
PointSize,
|
PointSize,
|
||||||
VertexIndex,
|
VertexIndex,
|
||||||
|
DrawID,
|
||||||
// fragment
|
// fragment
|
||||||
FragDepth,
|
FragDepth,
|
||||||
PointCoord,
|
PointCoord,
|
||||||
|
@ -194,7 +194,11 @@ impl VaryingContext<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let (visible, type_good) = match built_in {
|
let (visible, type_good) = match built_in {
|
||||||
Bi::BaseInstance | Bi::BaseVertex | Bi::InstanceIndex | Bi::VertexIndex => (
|
Bi::BaseInstance
|
||||||
|
| Bi::BaseVertex
|
||||||
|
| Bi::InstanceIndex
|
||||||
|
| Bi::VertexIndex
|
||||||
|
| Bi::DrawID => (
|
||||||
self.stage == St::Vertex && !self.output,
|
self.stage == St::Vertex && !self.output,
|
||||||
*ty_inner == Ti::Scalar(crate::Scalar::U32),
|
*ty_inner == Ti::Scalar(crate::Scalar::U32),
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user