Skip to content

Commit fc50128

Browse files
committed
Allow some previously available builtins
1 parent d4574d5 commit fc50128

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

naga/src/ir/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ pub enum BuiltIn {
414414
ClipDistance,
415415
/// Written in vertex & mesh shaders
416416
CullDistance,
417-
/// Read in vertex shaders
417+
/// Read in vertex, any- and closest-hit shaders
418418
InstanceIndex,
419419
/// Written in vertex & mesh shaders
420420
PointSize,
@@ -429,7 +429,7 @@ pub enum BuiltIn {
429429
PointCoord,
430430
/// Read in fragment shaders
431431
FrontFacing,
432-
/// Read in fragment shaders, written in mesh shaders
432+
/// Read in fragment shaders, written in mesh shaders, read in any and closest hit shaders.
433433
PrimitiveIndex,
434434
/// Read in fragment shaders
435435
Barycentric,

naga/src/valid/interface.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,10 @@ impl VaryingContext<'_> {
233233
let required = match built_in {
234234
Bi::ClipDistance => Capabilities::CLIP_DISTANCE,
235235
Bi::CullDistance => Capabilities::CULL_DISTANCE,
236-
Bi::PrimitiveIndex => Capabilities::PRIMITIVE_INDEX,
236+
// Primitive index is allowed w/o any other extensions in any- and closest-hit shaders
237+
Bi::PrimitiveIndex if !matches!(ep.stage, St::AnyHit | St::ClosestHit) => {
238+
Capabilities::PRIMITIVE_INDEX
239+
}
237240
Bi::Barycentric => Capabilities::SHADER_BARYCENTRICS,
238241
Bi::ViewIndex => Capabilities::MULTIVIEW,
239242
Bi::SampleIndex => Capabilities::MULTISAMPLED_SHADING,
@@ -256,10 +259,15 @@ impl VaryingContext<'_> {
256259
}
257260

258261
let (visible, type_good) = match built_in {
259-
Bi::BaseInstance | Bi::BaseVertex | Bi::InstanceIndex | Bi::VertexIndex => (
262+
Bi::BaseInstance | Bi::BaseVertex | Bi::VertexIndex => (
260263
self.stage == St::Vertex && !self.output,
261264
*ty_inner == Ti::Scalar(crate::Scalar::U32),
262265
),
266+
Bi::InstanceIndex => (
267+
matches!(self.stage, St::Vertex | St::AnyHit | St::ClosestHit)
268+
&& !self.output,
269+
*ty_inner == Ti::Scalar(crate::Scalar::U32),
270+
),
263271
Bi::DrawID => (
264272
// Always allowed in task/vertex stage. Allowed in mesh stage if there is no task stage in the pipeline.
265273
(self.stage == St::Vertex
@@ -326,7 +334,8 @@ impl VaryingContext<'_> {
326334
*ty_inner == Ti::Scalar(crate::Scalar::BOOL),
327335
),
328336
Bi::PrimitiveIndex => (
329-
(self.stage == St::Fragment && !self.output)
337+
(matches!(self.stage, St::Fragment | St::AnyHit | St::ClosestHit)
338+
&& !self.output)
330339
|| (self.stage == St::Mesh
331340
&& self.output
332341
&& self.mesh_output_type == MeshOutputType::PrimitiveOutput),

0 commit comments

Comments
 (0)