mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-19 22:11:01 +01:00
[wgsl in and IR] naga ray tracing pipelines (#8570)
This commit is contained in:
1 parent
c0c7aafe1b
commit
8a37e0f56a
90 files changed
+1986
-88
No files matched your search
@@ -62,6 +62,7 @@ Bottom level categories:
|
||||
|
||||
#### naga
|
||||
|
||||
- Initial wgsl-in ray tracing pipelines. By @Vecvec in [#8570](https://github.com/gfx-rs/wgpu/pull/8570).
|
||||
- Allow parsing shaders which make use of `SPV_KHR_non_semantic_info` for debug info. Also removes `naga::front::spv::SUPPORTED_EXT_SETS`. By @inner-daemons in #8827.
|
||||
|
||||
### Changes
|
||||
|
||||
@@ -93,10 +93,12 @@ fn render(/*whatever args you need to render*/) {
|
||||
|
||||
## `naga`'s raytracing API:
|
||||
|
||||
`naga` supports ray queries (also known as inline raytracing) only. To enable basic ray query functions you must add
|
||||
`naga` supports ray queries (also known as inline raytracing). To enable basic ray query functions you must add
|
||||
`enable wgpu_ray_query` to the shader, ray queries and acceleration structures also support tags which require extra
|
||||
`enable` extensions (see Acceleration structure tags for more info). Ray tracing pipelines
|
||||
are currently unsupported. Naming is mostly taken from vulkan.
|
||||
`enable` extensions (see Acceleration structure tags for more info). Ray tracing pipelines are currently in
|
||||
development. Naming is mostly taken from vulkan.
|
||||
|
||||
### Ray Queries
|
||||
|
||||
```wgsl
|
||||
// - Initializes the `ray_query` to check where (if anywhere) the ray defined by `ray_desc` hits in `acceleration_structure`
|
||||
@@ -148,7 +150,7 @@ getCandidateHitVertexPositions(rq: ptr<function, ray_query<vertex_return>>) -> a
|
||||
|
||||
> [!CAUTION]
|
||||
>
|
||||
> ### ⚠️Undefined behavior ⚠️:
|
||||
> #### ⚠️Undefined behavior ⚠️:
|
||||
> - Calling `rayQueryGetCommittedIntersection` or `rayQueryGetCandidateIntersection` when `rayQueryProceed` has not been
|
||||
> called on this ray query since it was initialized (or if the ray query has not been previously initialized).
|
||||
> - Calling `rayQueryGetCommittedIntersection` when `rayQueryProceed`'s latest return on this ray query is considered
|
||||
@@ -272,6 +274,39 @@ const RAY_QUERY_INTERSECTION_GENERATED = 2;
|
||||
const RAY_QUERY_INTERSECTION_AABB = 3;
|
||||
```
|
||||
|
||||
### Ray Tracing Pipelines
|
||||
|
||||
Functions
|
||||
```wgsl
|
||||
// Begins to check where (if anywhere) the ray defined by `ray_desc` hits in `acceleration_structure` calling through the `any_hit` shaders and `closest_hit` shader if something was hit or the `miss` shader if no hit was found
|
||||
traceRay<T>(acceleration_structure: acceleration_structure, ray_desc: RayDesc, payload: ptr<ray_payload, T>)
|
||||
```
|
||||
|
||||
> [!CAUTION]
|
||||
>
|
||||
> #### ⚠️Undefined behavior ⚠️:
|
||||
> Calling `traceRay` inside another `traceRay` more than `max_recursion_depth` times
|
||||
>
|
||||
> *this is only known undefined behaviour, and will be worked around in the future.
|
||||
|
||||
New shader stages
|
||||
```wgsl
|
||||
// First stage to be called, allowed to call `traceRay`
|
||||
@ray_generation
|
||||
fn rg() {}
|
||||
|
||||
// Stage called on any hit that is not opaque, not allowed to call `traceRay`
|
||||
@any_hit
|
||||
fn ah() {}
|
||||
|
||||
// Stage called on the closest hit, allowed to call `traceRay`
|
||||
@closest_hit
|
||||
fn ch() {}
|
||||
|
||||
// Stage call if there was never a hit, allowed to call `traceRay`
|
||||
@miss
|
||||
fn miss() {}
|
||||
```
|
||||
### Acceleration structure tags
|
||||
|
||||
These are tags that can be added to a acceleration structure (`acceleration_structure` ->
|
||||
|
||||
@@ -413,6 +413,22 @@ impl StatementGraph {
|
||||
"CoopStore"
|
||||
}
|
||||
}
|
||||
S::RayPipelineFunction(func) => match func {
|
||||
crate::RayPipelineFunction::TraceRay {
|
||||
acceleration_structure,
|
||||
descriptor,
|
||||
payload,
|
||||
} => {
|
||||
self.dependencies.push((
|
||||
id,
|
||||
acceleration_structure,
|
||||
"acceleration_structure",
|
||||
));
|
||||
self.dependencies.push((id, descriptor, "descriptor"));
|
||||
self.dependencies.push((id, payload, "payload"));
|
||||
"TraceRay"
|
||||
}
|
||||
},
|
||||
};
|
||||
// Set the last node to the merge node
|
||||
last_node = merge_id;
|
||||
|
||||
@@ -126,7 +126,20 @@ pub(in crate::back::glsl) const fn glsl_built_in(
|
||||
| Bi::VertexCount
|
||||
| Bi::PrimitiveCount
|
||||
| Bi::Vertices
|
||||
| Bi::Primitives => {
|
||||
| Bi::Primitives
|
||||
| Bi::RayInvocationId
|
||||
| Bi::NumRayInvocations
|
||||
| Bi::InstanceCustomData
|
||||
| Bi::GeometryIndex
|
||||
| Bi::WorldRayOrigin
|
||||
| Bi::WorldRayDirection
|
||||
| Bi::ObjectRayOrigin
|
||||
| Bi::ObjectRayDirection
|
||||
| Bi::RayTmin
|
||||
| Bi::RayTCurrentMax
|
||||
| Bi::ObjectToWorld
|
||||
| Bi::WorldToObject
|
||||
| Bi::HitKind => {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
@@ -146,7 +159,7 @@ pub(in crate::back::glsl) const fn glsl_storage_qualifier(
|
||||
As::Handle => Some("uniform"),
|
||||
As::WorkGroup => Some("shared"),
|
||||
As::Immediate => Some("uniform"),
|
||||
As::TaskPayload => unreachable!(),
|
||||
As::TaskPayload | As::RayPayload | As::IncomingRayPayload => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -146,6 +146,10 @@ impl crate::AddressSpace {
|
||||
| crate::AddressSpace::Handle
|
||||
| crate::AddressSpace::Immediate
|
||||
| crate::AddressSpace::TaskPayload => false,
|
||||
|
||||
crate::AddressSpace::RayPayload | crate::AddressSpace::IncomingRayPayload => {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -509,7 +513,15 @@ impl fmt::Display for VaryingName<'_> {
|
||||
(ShaderStage::Vertex, true) | (ShaderStage::Fragment, false) => "vs2fs",
|
||||
// fragment to pipeline
|
||||
(ShaderStage::Fragment, true) => "fs2p",
|
||||
(ShaderStage::Task | ShaderStage::Mesh, _) => unreachable!(),
|
||||
(
|
||||
ShaderStage::Task
|
||||
| ShaderStage::Mesh
|
||||
| ShaderStage::RayGeneration
|
||||
| ShaderStage::AnyHit
|
||||
| ShaderStage::ClosestHit
|
||||
| ShaderStage::Miss,
|
||||
_,
|
||||
) => unreachable!(),
|
||||
};
|
||||
write!(f, "_{prefix}_location{location}",)
|
||||
}
|
||||
@@ -526,7 +538,12 @@ impl ShaderStage {
|
||||
ShaderStage::Compute => "cs",
|
||||
ShaderStage::Fragment => "fs",
|
||||
ShaderStage::Vertex => "vs",
|
||||
ShaderStage::Task | ShaderStage::Mesh => unreachable!(),
|
||||
ShaderStage::Task
|
||||
| ShaderStage::Mesh
|
||||
| ShaderStage::RayGeneration
|
||||
| ShaderStage::AnyHit
|
||||
| ShaderStage::ClosestHit
|
||||
| ShaderStage::Miss => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -729,6 +729,10 @@ impl<'a, W: Write> Writer<'a, W> {
|
||||
crate::AddressSpace::Function => unreachable!(),
|
||||
// Textures and samplers are handled directly in `Writer::write`.
|
||||
crate::AddressSpace::Handle => unreachable!(),
|
||||
// ray tracing pipelines unsupported
|
||||
crate::AddressSpace::RayPayload | crate::AddressSpace::IncomingRayPayload => {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -1095,7 +1099,12 @@ impl<'a, W: Write> Writer<'a, W> {
|
||||
ShaderStage::Vertex => output,
|
||||
ShaderStage::Fragment => !output,
|
||||
ShaderStage::Compute => false,
|
||||
ShaderStage::Task | ShaderStage::Mesh => unreachable!(),
|
||||
ShaderStage::Task
|
||||
| ShaderStage::Mesh
|
||||
| ShaderStage::RayGeneration
|
||||
| ShaderStage::AnyHit
|
||||
| ShaderStage::ClosestHit
|
||||
| ShaderStage::Miss => unreachable!(),
|
||||
};
|
||||
|
||||
// Write the I/O locations, if allowed
|
||||
@@ -2231,6 +2240,7 @@ impl<'a, W: Write> Writer<'a, W> {
|
||||
writeln!(self.out, ");")?;
|
||||
}
|
||||
Statement::CooperativeStore { .. } => unimplemented!(),
|
||||
Statement::RayPipelineFunction(_) => unimplemented!(),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -192,6 +192,19 @@ impl crate::BuiltIn {
|
||||
| Self::PrimitiveCount
|
||||
| Self::Vertices
|
||||
| Self::Primitives => unreachable!(),
|
||||
Self::RayInvocationId
|
||||
| Self::NumRayInvocations
|
||||
| Self::InstanceCustomData
|
||||
| Self::GeometryIndex
|
||||
| Self::WorldRayOrigin
|
||||
| Self::WorldRayDirection
|
||||
| Self::ObjectRayOrigin
|
||||
| Self::ObjectRayDirection
|
||||
| Self::RayTmin
|
||||
| Self::RayTCurrentMax
|
||||
| Self::ObjectToWorld
|
||||
| Self::WorldToObject
|
||||
| Self::HitKind => unreachable!(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,6 +283,7 @@ impl crate::ShaderStage {
|
||||
Self::Compute => "cs",
|
||||
Self::Task => "as",
|
||||
Self::Mesh => "ms",
|
||||
Self::RayGeneration | Self::AnyHit | Self::ClosestHit | Self::Miss => "lib",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1015,6 +1015,9 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
|
||||
write!(self.out, "ConstantBuffer<")?;
|
||||
"b"
|
||||
}
|
||||
crate::AddressSpace::RayPayload | crate::AddressSpace::IncomingRayPayload => {
|
||||
unimplemented!()
|
||||
}
|
||||
};
|
||||
|
||||
// If the global is a immediate data write the type now because it will be a
|
||||
@@ -2802,6 +2805,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
|
||||
writeln!(self.out, ");")?;
|
||||
}
|
||||
Statement::CooperativeStore { .. } => unimplemented!(),
|
||||
Statement::RayPipelineFunction(_) => unreachable!(),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -3132,7 +3136,9 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
|
||||
| crate::AddressSpace::Private
|
||||
| crate::AddressSpace::WorkGroup
|
||||
| crate::AddressSpace::Immediate
|
||||
| crate::AddressSpace::TaskPayload,
|
||||
| crate::AddressSpace::TaskPayload
|
||||
| crate::AddressSpace::RayPayload
|
||||
| crate::AddressSpace::IncomingRayPayload,
|
||||
)
|
||||
| None => true,
|
||||
Some(crate::AddressSpace::Uniform) => {
|
||||
|
||||
@@ -723,7 +723,20 @@ impl ResolvedBinding {
|
||||
| Bi::VertexCount
|
||||
| Bi::PrimitiveCount
|
||||
| Bi::Vertices
|
||||
| Bi::Primitives => unreachable!(),
|
||||
| Bi::Primitives
|
||||
| Bi::RayInvocationId
|
||||
| Bi::NumRayInvocations
|
||||
| Bi::InstanceCustomData
|
||||
| Bi::GeometryIndex
|
||||
| Bi::WorldRayOrigin
|
||||
| Bi::WorldRayDirection
|
||||
| Bi::ObjectRayOrigin
|
||||
| Bi::ObjectRayDirection
|
||||
| Bi::RayTmin
|
||||
| Bi::RayTCurrentMax
|
||||
| Bi::ObjectToWorld
|
||||
| Bi::WorldToObject
|
||||
| Bi::HitKind => unreachable!(),
|
||||
};
|
||||
write!(out, "{name}")?;
|
||||
}
|
||||
|
||||
@@ -628,6 +628,7 @@ impl crate::AddressSpace {
|
||||
| Self::Handle
|
||||
| Self::TaskPayload => true,
|
||||
Self::Function => false,
|
||||
Self::RayPayload | Self::IncomingRayPayload => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -639,7 +640,7 @@ impl crate::AddressSpace {
|
||||
// may end up with "const" even if the binding is read-write,
|
||||
// and that should be OK.
|
||||
Self::Storage { .. } => true,
|
||||
Self::TaskPayload => unimplemented!(),
|
||||
Self::TaskPayload | Self::RayPayload | Self::IncomingRayPayload => unimplemented!(),
|
||||
// These should always be read-write.
|
||||
Self::Private | Self::WorkGroup => false,
|
||||
// These translate to `constant` address space, no need for qualifiers.
|
||||
@@ -654,9 +655,13 @@ impl crate::AddressSpace {
|
||||
Self::Handle => None,
|
||||
Self::Uniform | Self::Immediate => Some("constant"),
|
||||
Self::Storage { .. } => Some("device"),
|
||||
Self::Private | Self::Function => Some("thread"),
|
||||
// note for `RayPayload`, this probably needs to be emulated as a
|
||||
// private variable, as metal has essentially an inout input
|
||||
// for where it is passed.
|
||||
Self::Private | Self::Function | Self::RayPayload => Some("thread"),
|
||||
Self::WorkGroup => Some("threadgroup"),
|
||||
Self::TaskPayload => Some("object_data"),
|
||||
Self::IncomingRayPayload => Some("ray_data"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4279,6 +4284,7 @@ impl<W: Write> Writer<W> {
|
||||
}
|
||||
writeln!(self.out, ");")?;
|
||||
}
|
||||
crate::Statement::RayPipelineFunction(_) => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6875,6 +6881,10 @@ template <typename A>
|
||||
false,
|
||||
),
|
||||
crate::ShaderStage::Task | crate::ShaderStage::Mesh => unimplemented!(),
|
||||
crate::ShaderStage::RayGeneration
|
||||
| crate::ShaderStage::AnyHit
|
||||
| crate::ShaderStage::ClosestHit
|
||||
| crate::ShaderStage::Miss => unimplemented!(),
|
||||
};
|
||||
|
||||
// Should this entry point be modified to do vertex pulling?
|
||||
@@ -6947,6 +6957,8 @@ template <typename A>
|
||||
crate::AddressSpace::Function
|
||||
| crate::AddressSpace::Private
|
||||
| crate::AddressSpace::WorkGroup => {}
|
||||
crate::AddressSpace::RayPayload
|
||||
| crate::AddressSpace::IncomingRayPayload => unimplemented!(),
|
||||
}
|
||||
}
|
||||
if needs_buffer_sizes {
|
||||
|
||||
@@ -882,6 +882,17 @@ fn adjust_stmt(new_pos: &HandleVec<Expression, Handle<Expression>>, stmt: &mut S
|
||||
adjust(&mut data.pointer);
|
||||
adjust(&mut data.stride);
|
||||
}
|
||||
Statement::RayPipelineFunction(ref mut func) => match *func {
|
||||
crate::RayPipelineFunction::TraceRay {
|
||||
ref mut acceleration_structure,
|
||||
ref mut descriptor,
|
||||
ref mut payload,
|
||||
} => {
|
||||
adjust(acceleration_structure);
|
||||
adjust(descriptor);
|
||||
adjust(payload);
|
||||
}
|
||||
},
|
||||
Statement::Break
|
||||
| Statement::Continue
|
||||
| Statement::Kill
|
||||
|
||||
@@ -4194,6 +4194,7 @@ impl BlockContext<'_> {
|
||||
}
|
||||
};
|
||||
}
|
||||
Statement::RayPipelineFunction(_) => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ pub(super) const fn map_storage_class(space: crate::AddressSpace) -> spirv::Stor
|
||||
crate::AddressSpace::WorkGroup => spirv::StorageClass::Workgroup,
|
||||
crate::AddressSpace::Immediate => spirv::StorageClass::PushConstant,
|
||||
crate::AddressSpace::TaskPayload => spirv::StorageClass::TaskPayloadWorkgroupEXT,
|
||||
crate::AddressSpace::IncomingRayPayload | crate::AddressSpace::RayPayload => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1819,6 +1819,10 @@ impl Writer {
|
||||
.to_words(&mut self.logical_layout.execution_modes);
|
||||
spirv::ExecutionModel::MeshEXT
|
||||
}
|
||||
crate::ShaderStage::RayGeneration
|
||||
| crate::ShaderStage::AnyHit
|
||||
| crate::ShaderStage::ClosestHit
|
||||
| crate::ShaderStage::Miss => unreachable!(),
|
||||
};
|
||||
//self.check(exec_model.required_capabilities())?;
|
||||
|
||||
@@ -3174,6 +3178,19 @@ impl Writer {
|
||||
Bi::VertexCount | Bi::Vertices | Bi::PrimitiveCount | Bi::Primitives => {
|
||||
unreachable!()
|
||||
}
|
||||
Bi::RayInvocationId
|
||||
| Bi::NumRayInvocations
|
||||
| Bi::InstanceCustomData
|
||||
| Bi::GeometryIndex
|
||||
| Bi::WorldRayOrigin
|
||||
| Bi::WorldRayDirection
|
||||
| Bi::ObjectRayOrigin
|
||||
| Bi::ObjectRayDirection
|
||||
| Bi::RayTmin
|
||||
| Bi::RayTCurrentMax
|
||||
| Bi::ObjectToWorld
|
||||
| Bi::WorldToObject
|
||||
| Bi::HitKind => unreachable!(),
|
||||
};
|
||||
|
||||
use crate::ScalarKind as Sk;
|
||||
|
||||
@@ -243,6 +243,10 @@ impl<W: Write> Writer<W> {
|
||||
Attribute::WorkGroupSize(ep.workgroup_size),
|
||||
]
|
||||
}
|
||||
ShaderStage::RayGeneration
|
||||
| ShaderStage::AnyHit
|
||||
| ShaderStage::ClosestHit
|
||||
| ShaderStage::Miss => unreachable!(),
|
||||
};
|
||||
self.write_attributes(&attributes)?;
|
||||
// Add a newline after attribute
|
||||
@@ -488,6 +492,10 @@ impl<W: Write> Writer<W> {
|
||||
ShaderStage::Task => "task",
|
||||
//Handled by another variant in the Attribute enum, so this code should never be hit.
|
||||
ShaderStage::Mesh => unreachable!(),
|
||||
ShaderStage::RayGeneration
|
||||
| ShaderStage::AnyHit
|
||||
| ShaderStage::ClosestHit
|
||||
| ShaderStage::Miss => unreachable!(),
|
||||
};
|
||||
|
||||
write!(self.out, "@{stage_str} ")?;
|
||||
@@ -1086,6 +1094,7 @@ impl<W: Write> Writer<W> {
|
||||
self.write_expr(module, data.stride, func_ctx)?;
|
||||
writeln!(self.out, ");")?
|
||||
}
|
||||
Statement::RayPipelineFunction(_) => unreachable!(),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -200,7 +200,20 @@ impl TryToWgsl for crate::BuiltIn {
|
||||
| Bi::PointSize
|
||||
| Bi::DrawID
|
||||
| Bi::PointCoord
|
||||
| Bi::WorkGroupSize => return None,
|
||||
| Bi::WorkGroupSize
|
||||
| Bi::RayInvocationId
|
||||
| Bi::NumRayInvocations
|
||||
| Bi::InstanceCustomData
|
||||
| Bi::GeometryIndex
|
||||
| Bi::WorldRayOrigin
|
||||
| Bi::WorldRayDirection
|
||||
| Bi::ObjectRayOrigin
|
||||
| Bi::ObjectRayDirection
|
||||
| Bi::RayTmin
|
||||
| Bi::RayTCurrentMax
|
||||
| Bi::ObjectToWorld
|
||||
| Bi::WorldToObject
|
||||
| Bi::HitKind => return None,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -374,6 +387,7 @@ pub const fn address_space_str(
|
||||
As::Handle => return (None, None),
|
||||
As::Function => "function",
|
||||
As::TaskPayload => "task_payload",
|
||||
As::IncomingRayPayload | As::RayPayload => return (None, None),
|
||||
}),
|
||||
None,
|
||||
)
|
||||
|
||||
@@ -157,6 +157,17 @@ impl FunctionTracer<'_> {
|
||||
self.expressions_used.insert(data.pointer);
|
||||
self.expressions_used.insert(data.stride);
|
||||
}
|
||||
St::RayPipelineFunction(func) => match func {
|
||||
crate::RayPipelineFunction::TraceRay {
|
||||
acceleration_structure,
|
||||
descriptor,
|
||||
payload,
|
||||
} => {
|
||||
self.expressions_used.insert(acceleration_structure);
|
||||
self.expressions_used.insert(descriptor);
|
||||
self.expressions_used.insert(payload);
|
||||
}
|
||||
},
|
||||
|
||||
// Trivial statements.
|
||||
St::Break
|
||||
@@ -384,6 +395,17 @@ impl FunctionMap {
|
||||
adjust(&mut data.pointer);
|
||||
adjust(&mut data.stride);
|
||||
}
|
||||
St::RayPipelineFunction(ref mut func) => match *func {
|
||||
crate::RayPipelineFunction::TraceRay {
|
||||
ref mut acceleration_structure,
|
||||
ref mut descriptor,
|
||||
ref mut payload,
|
||||
} => {
|
||||
adjust(acceleration_structure);
|
||||
adjust(descriptor);
|
||||
adjust(payload);
|
||||
}
|
||||
},
|
||||
|
||||
// Trivial statements.
|
||||
St::Break
|
||||
|
||||
@@ -1377,6 +1377,7 @@ impl Frontend {
|
||||
},
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
});
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -610,6 +610,7 @@ impl<I: Iterator<Item = u32>> super::Frontend<I> {
|
||||
function,
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
});
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -1612,7 +1612,8 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
|
||||
| S::RayQuery { .. }
|
||||
| S::SubgroupBallot { .. }
|
||||
| S::SubgroupCollectiveOperation { .. }
|
||||
| S::SubgroupGather { .. } => {}
|
||||
| S::SubgroupGather { .. }
|
||||
| S::RayPipelineFunction(..) => {}
|
||||
S::Call {
|
||||
function: ref mut callee,
|
||||
ref arguments,
|
||||
|
||||
@@ -434,6 +434,7 @@ pub(crate) enum Error<'a> {
|
||||
description: &'static str,
|
||||
},
|
||||
UnexpectedExprForTypeExpression(Span),
|
||||
MissingIncomingPayload(Span),
|
||||
}
|
||||
|
||||
impl From<ConflictingDiagnosticRuleError> for Error<'_> {
|
||||
@@ -1473,7 +1474,15 @@ impl<'a> Error<'a> {
|
||||
message: "unexpected expression".to_string(),
|
||||
labels: vec![(expr_span, "needs to be an identifier resolving to a type declaration (alias or struct) or predeclared type(-generator)".into())],
|
||||
notes: vec![],
|
||||
}
|
||||
},
|
||||
Error::MissingIncomingPayload(span) => ParseError {
|
||||
message: "incoming payload is missing on a `closest_hit`, `any_hit` or `miss` shader entry point".to_string(),
|
||||
labels: vec![(
|
||||
span,
|
||||
"must be paired with a `@incoming_payload` attribute".into(),
|
||||
)],
|
||||
notes: vec![],
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1701,6 +1701,21 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {
|
||||
None
|
||||
};
|
||||
|
||||
let incoming_ray_payload =
|
||||
if let Some((var_name, var_span)) = entry.ray_incoming_payload {
|
||||
Some(match ctx.globals.get(var_name) {
|
||||
Some(&LoweredGlobalDecl::Var(handle)) => handle,
|
||||
Some(_) => {
|
||||
return Err(Box::new(Error::ExpectedGlobalVariable {
|
||||
name_span: var_span,
|
||||
}))
|
||||
}
|
||||
None => return Err(Box::new(Error::UnknownIdent(var_span, var_name))),
|
||||
})
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
ctx.module.entry_points.push(ir::EntryPoint {
|
||||
name: f.name.name.to_string(),
|
||||
stage: entry.stage,
|
||||
@@ -1710,6 +1725,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {
|
||||
function,
|
||||
mesh_info,
|
||||
task_payload,
|
||||
incoming_ray_payload,
|
||||
});
|
||||
Ok(LoweredGlobalDecl::EntryPoint(
|
||||
ctx.module.entry_points.len() - 1,
|
||||
@@ -3687,6 +3703,28 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {
|
||||
|
||||
ir::Expression::CooperativeMultiplyAdd { a, b, c }
|
||||
}
|
||||
"traceRay" => {
|
||||
let mut args = ctx.prepare_args(arguments, 3, function_span);
|
||||
let acceleration_structure = self.expression(args.next()?, ctx)?;
|
||||
let descriptor = self.expression(args.next()?, ctx)?;
|
||||
let payload = self.expression(args.next()?, ctx)?;
|
||||
args.finish()?;
|
||||
|
||||
let _ = ctx.module.generate_ray_desc_type();
|
||||
let fun = ir::RayPipelineFunction::TraceRay {
|
||||
acceleration_structure,
|
||||
descriptor,
|
||||
payload,
|
||||
};
|
||||
|
||||
let rctx = ctx.runtime_expression_ctx(function_span)?;
|
||||
rctx.block
|
||||
.extend(rctx.emitter.finish(&rctx.function.expressions));
|
||||
rctx.emitter.start(&rctx.function.expressions);
|
||||
rctx.block
|
||||
.push(ir::Statement::RayPipelineFunction(fun), function_span);
|
||||
return Ok(None);
|
||||
}
|
||||
_ => return Err(Box::new(Error::UnknownIdent(function_span, function_name))),
|
||||
}
|
||||
};
|
||||
|
||||
@@ -220,6 +220,7 @@ pub struct EntryPoint<'a> {
|
||||
pub workgroup_size: Option<[Option<Handle<Expression<'a>>>; 3]>,
|
||||
pub mesh_output_variable: Option<(&'a str, Span)>,
|
||||
pub task_payload: Option<(&'a str, Span)>,
|
||||
pub ray_incoming_payload: Option<(&'a str, Span)>,
|
||||
}
|
||||
|
||||
#[cfg(doc)]
|
||||
|
||||
@@ -30,6 +30,26 @@ pub fn map_address_space<'a>(
|
||||
}))
|
||||
}
|
||||
}
|
||||
"ray_payload" => {
|
||||
if enable_extensions.contains(ImplementedEnableExtension::WgpuRayTracingPipeline) {
|
||||
Ok(crate::AddressSpace::RayPayload)
|
||||
} else {
|
||||
Err(Box::new(Error::EnableExtensionNotEnabled {
|
||||
span,
|
||||
kind: ImplementedEnableExtension::WgpuRayTracingPipeline.into(),
|
||||
}))
|
||||
}
|
||||
}
|
||||
"incoming_ray_payload" => {
|
||||
if enable_extensions.contains(ImplementedEnableExtension::WgpuRayTracingPipeline) {
|
||||
Ok(crate::AddressSpace::IncomingRayPayload)
|
||||
} else {
|
||||
Err(Box::new(Error::EnableExtensionNotEnabled {
|
||||
span,
|
||||
kind: ImplementedEnableExtension::WgpuRayTracingPipeline.into(),
|
||||
}))
|
||||
}
|
||||
}
|
||||
_ => Err(Box::new(Error::UnknownAddressSpace(span))),
|
||||
}
|
||||
}
|
||||
@@ -116,6 +136,20 @@ pub fn map_built_in(
|
||||
"vertices" => crate::BuiltIn::Vertices,
|
||||
"primitive_count" => crate::BuiltIn::PrimitiveCount,
|
||||
"primitives" => crate::BuiltIn::Primitives,
|
||||
// ray tracing pipeline
|
||||
"ray_invocation_id" => crate::BuiltIn::RayInvocationId,
|
||||
"num_ray_invocations" => crate::BuiltIn::NumRayInvocations,
|
||||
"instance_custom_data" => crate::BuiltIn::InstanceCustomData,
|
||||
"geometry_index" => crate::BuiltIn::GeometryIndex,
|
||||
"world_ray_origin" => crate::BuiltIn::WorldRayOrigin,
|
||||
"world_ray_direction" => crate::BuiltIn::WorldRayDirection,
|
||||
"object_ray_origin" => crate::BuiltIn::ObjectRayOrigin,
|
||||
"object_ray_direction" => crate::BuiltIn::ObjectRayDirection,
|
||||
"ray_t_min" => crate::BuiltIn::RayTmin,
|
||||
"ray_t_current_max" => crate::BuiltIn::RayTCurrentMax,
|
||||
"object_to_world" => crate::BuiltIn::ObjectToWorld,
|
||||
"world_to_object" => crate::BuiltIn::WorldToObject,
|
||||
"hit_kind" => crate::BuiltIn::HitKind,
|
||||
_ => return Err(Box::new(Error::UnknownBuiltin(span))),
|
||||
};
|
||||
match built_in {
|
||||
@@ -536,26 +570,34 @@ pub fn map_predeclared_type(
|
||||
};
|
||||
|
||||
// Check for the enable extension required to use this type, if any.
|
||||
let extension_needed = match ty {
|
||||
// Slice should be at least len one otherwise extension_needed should be None.
|
||||
let extensions_needed: Option<&[_]> = match ty {
|
||||
PredeclaredType::TypeInner(ref ty) if ty.scalar() == Some(Sc::F16) => {
|
||||
Some(ImplementedEnableExtension::F16)
|
||||
Some(&[ImplementedEnableExtension::F16])
|
||||
}
|
||||
PredeclaredType::RayDesc
|
||||
| PredeclaredType::RayIntersection
|
||||
| PredeclaredType::TypeGenerator(TypeGenerator::AccelerationStructure)
|
||||
| PredeclaredType::TypeGenerator(TypeGenerator::RayQuery) => {
|
||||
Some(ImplementedEnableExtension::WgpuRayQuery)
|
||||
}
|
||||
| PredeclaredType::TypeGenerator(TypeGenerator::RayQuery) => Some(&[
|
||||
ImplementedEnableExtension::WgpuRayQuery,
|
||||
ImplementedEnableExtension::WgpuRayTracingPipeline,
|
||||
]),
|
||||
PredeclaredType::TypeGenerator(TypeGenerator::CooperativeMatrix { .. }) => {
|
||||
Some(ImplementedEnableExtension::WgpuCooperativeMatrix)
|
||||
Some(&[ImplementedEnableExtension::WgpuCooperativeMatrix])
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
if let Some(extension_needed) = extension_needed {
|
||||
if !enable_extensions.contains(extension_needed) {
|
||||
if let Some(extensions_needed) = extensions_needed {
|
||||
let mut any_extension_enabled = false;
|
||||
for extension_needed in extensions_needed {
|
||||
if enable_extensions.contains(*extension_needed) {
|
||||
any_extension_enabled = true;
|
||||
}
|
||||
}
|
||||
if !any_extension_enabled {
|
||||
return Err(Box::new(Error::EnableExtensionNotEnabled {
|
||||
span,
|
||||
kind: extension_needed.into(),
|
||||
kind: extensions_needed[0].into(),
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ pub(crate) struct EnableExtensions {
|
||||
wgpu_mesh_shader: bool,
|
||||
wgpu_ray_query: bool,
|
||||
wgpu_ray_query_vertex_return: bool,
|
||||
wgpu_ray_tracing_pipelines: bool,
|
||||
dual_source_blending: bool,
|
||||
/// Whether `enable f16;` was written earlier in the shader module.
|
||||
f16: bool,
|
||||
@@ -26,6 +27,7 @@ impl EnableExtensions {
|
||||
wgpu_mesh_shader: false,
|
||||
wgpu_ray_query: false,
|
||||
wgpu_ray_query_vertex_return: false,
|
||||
wgpu_ray_tracing_pipelines: false,
|
||||
f16: false,
|
||||
dual_source_blending: false,
|
||||
clip_distances: false,
|
||||
@@ -41,6 +43,9 @@ impl EnableExtensions {
|
||||
ImplementedEnableExtension::WgpuRayQueryVertexReturn => {
|
||||
&mut self.wgpu_ray_query_vertex_return
|
||||
}
|
||||
ImplementedEnableExtension::WgpuRayTracingPipeline => {
|
||||
&mut self.wgpu_ray_tracing_pipelines
|
||||
}
|
||||
ImplementedEnableExtension::DualSourceBlending => &mut self.dual_source_blending,
|
||||
ImplementedEnableExtension::F16 => &mut self.f16,
|
||||
ImplementedEnableExtension::ClipDistances => &mut self.clip_distances,
|
||||
@@ -57,6 +62,7 @@ impl EnableExtensions {
|
||||
ImplementedEnableExtension::WgpuRayQueryVertexReturn => {
|
||||
self.wgpu_ray_query_vertex_return
|
||||
}
|
||||
ImplementedEnableExtension::WgpuRayTracingPipeline => self.wgpu_ray_tracing_pipelines,
|
||||
ImplementedEnableExtension::DualSourceBlending => self.dual_source_blending,
|
||||
ImplementedEnableExtension::F16 => self.f16,
|
||||
ImplementedEnableExtension::ClipDistances => self.clip_distances,
|
||||
@@ -93,6 +99,7 @@ impl EnableExtension {
|
||||
const MESH_SHADER: &'static str = "wgpu_mesh_shader";
|
||||
const RAY_QUERY: &'static str = "wgpu_ray_query";
|
||||
const RAY_QUERY_VERTEX_RETURN: &'static str = "wgpu_ray_query_vertex_return";
|
||||
const RAY_TRACING_PIPELINE: &'static str = "wgpu_ray_tracing_pipeline";
|
||||
const COOPERATIVE_MATRIX: &'static str = "wgpu_cooperative_matrix";
|
||||
const SUBGROUPS: &'static str = "subgroups";
|
||||
const PRIMITIVE_INDEX: &'static str = "primitive_index";
|
||||
@@ -110,6 +117,9 @@ impl EnableExtension {
|
||||
Self::RAY_QUERY_VERTEX_RETURN => {
|
||||
Self::Implemented(ImplementedEnableExtension::WgpuRayQueryVertexReturn)
|
||||
}
|
||||
Self::RAY_TRACING_PIPELINE => {
|
||||
Self::Implemented(ImplementedEnableExtension::WgpuRayTracingPipeline)
|
||||
}
|
||||
Self::COOPERATIVE_MATRIX => {
|
||||
Self::Implemented(ImplementedEnableExtension::WgpuCooperativeMatrix)
|
||||
}
|
||||
@@ -134,6 +144,7 @@ impl EnableExtension {
|
||||
ImplementedEnableExtension::DualSourceBlending => Self::DUAL_SOURCE_BLENDING,
|
||||
ImplementedEnableExtension::F16 => Self::F16,
|
||||
ImplementedEnableExtension::ClipDistances => Self::CLIP_DISTANCES,
|
||||
ImplementedEnableExtension::WgpuRayTracingPipeline => Self::RAY_TRACING_PIPELINE,
|
||||
},
|
||||
Self::Unimplemented(kind) => match kind {
|
||||
UnimplementedEnableExtension::Subgroups => Self::SUBGROUPS,
|
||||
@@ -170,6 +181,8 @@ pub enum ImplementedEnableExtension {
|
||||
WgpuRayQuery,
|
||||
/// Enables the `wgpu_ray_query_vertex_return` extension, native only.
|
||||
WgpuRayQueryVertexReturn,
|
||||
/// Enables the `wgpu_ray_tracing_pipeline` extension, native only.
|
||||
WgpuRayTracingPipeline,
|
||||
/// Enables the `wgpu_cooperative_matrix` extension, native only.
|
||||
WgpuCooperativeMatrix,
|
||||
}
|
||||
|
||||
@@ -1821,13 +1821,18 @@ impl Parser {
|
||||
// read attributes
|
||||
let mut binding = None;
|
||||
let mut stage = ParsedAttribute::default();
|
||||
let mut compute_like_span = Span::new(0, 0);
|
||||
// Span in case we need to report an error for a shader stage missing something (e.g. its workgroup size).
|
||||
// Doesn't need to be set in the vertex and fragment stages because they don't have errors like that.
|
||||
let mut shader_stage_error_span = Span::new(0, 0);
|
||||
let mut workgroup_size = ParsedAttribute::default();
|
||||
let mut early_depth_test = ParsedAttribute::default();
|
||||
let (mut bind_index, mut bind_group) =
|
||||
(ParsedAttribute::default(), ParsedAttribute::default());
|
||||
let mut id = ParsedAttribute::default();
|
||||
// the payload variable for a mesh shader
|
||||
let mut payload = ParsedAttribute::default();
|
||||
// the incoming payload from a traceRay call
|
||||
let mut incoming_payload = ParsedAttribute::default();
|
||||
let mut mesh_output = ParsedAttribute::default();
|
||||
|
||||
let mut must_use: ParsedAttribute<Span> = ParsedAttribute::default();
|
||||
@@ -1886,7 +1891,7 @@ impl Parser {
|
||||
}
|
||||
"compute" => {
|
||||
stage.set(ShaderStage::Compute, name_span)?;
|
||||
compute_like_span = name_span;
|
||||
shader_stage_error_span = name_span;
|
||||
}
|
||||
"task" => {
|
||||
lexer.require_enable_extension(
|
||||
@@ -1894,7 +1899,7 @@ impl Parser {
|
||||
name_span,
|
||||
)?;
|
||||
stage.set(ShaderStage::Task, name_span)?;
|
||||
compute_like_span = name_span;
|
||||
shader_stage_error_span = name_span;
|
||||
}
|
||||
"mesh" => {
|
||||
lexer.require_enable_extension(
|
||||
@@ -1902,12 +1907,44 @@ impl Parser {
|
||||
name_span,
|
||||
)?;
|
||||
stage.set(ShaderStage::Mesh, name_span)?;
|
||||
compute_like_span = name_span;
|
||||
shader_stage_error_span = name_span;
|
||||
|
||||
lexer.expect(Token::Paren('('))?;
|
||||
mesh_output.set(lexer.next_ident_with_span()?, name_span)?;
|
||||
lexer.expect(Token::Paren(')'))?;
|
||||
}
|
||||
"ray_generation" => {
|
||||
lexer.require_enable_extension(
|
||||
ImplementedEnableExtension::WgpuRayTracingPipeline,
|
||||
name_span,
|
||||
)?;
|
||||
stage.set(ShaderStage::RayGeneration, name_span)?;
|
||||
shader_stage_error_span = name_span;
|
||||
}
|
||||
"any_hit" => {
|
||||
lexer.require_enable_extension(
|
||||
ImplementedEnableExtension::WgpuRayTracingPipeline,
|
||||
name_span,
|
||||
)?;
|
||||
stage.set(ShaderStage::AnyHit, name_span)?;
|
||||
shader_stage_error_span = name_span;
|
||||
}
|
||||
"closest_hit" => {
|
||||
lexer.require_enable_extension(
|
||||
ImplementedEnableExtension::WgpuRayTracingPipeline,
|
||||
name_span,
|
||||
)?;
|
||||
stage.set(ShaderStage::ClosestHit, name_span)?;
|
||||
shader_stage_error_span = name_span;
|
||||
}
|
||||
"miss" => {
|
||||
lexer.require_enable_extension(
|
||||
ImplementedEnableExtension::WgpuRayTracingPipeline,
|
||||
name_span,
|
||||
)?;
|
||||
stage.set(ShaderStage::Miss, name_span)?;
|
||||
shader_stage_error_span = name_span;
|
||||
}
|
||||
"payload" => {
|
||||
lexer.require_enable_extension(
|
||||
ImplementedEnableExtension::WgpuMeshShader,
|
||||
@@ -1917,6 +1954,15 @@ impl Parser {
|
||||
payload.set(lexer.next_ident_with_span()?, name_span)?;
|
||||
lexer.expect(Token::Paren(')'))?;
|
||||
}
|
||||
"incoming_payload" => {
|
||||
lexer.require_enable_extension(
|
||||
ImplementedEnableExtension::WgpuRayTracingPipeline,
|
||||
name_span,
|
||||
)?;
|
||||
lexer.expect(Token::Paren('('))?;
|
||||
incoming_payload.set(lexer.next_ident_with_span()?, name_span)?;
|
||||
lexer.expect(Token::Paren(')'))?;
|
||||
}
|
||||
"workgroup_size" => {
|
||||
lexer.expect(Token::Paren('('))?;
|
||||
let mut new_workgroup_size = [None; 3];
|
||||
@@ -2069,7 +2115,20 @@ impl Parser {
|
||||
Some(ast::GlobalDeclKind::Fn(ast::Function {
|
||||
entry_point: if let Some(stage) = stage.value {
|
||||
if stage.compute_like() && workgroup_size.value.is_none() {
|
||||
return Err(Box::new(Error::MissingWorkgroupSize(compute_like_span)));
|
||||
return Err(Box::new(Error::MissingWorkgroupSize(
|
||||
shader_stage_error_span,
|
||||
)));
|
||||
}
|
||||
|
||||
match stage {
|
||||
ShaderStage::AnyHit | ShaderStage::ClosestHit | ShaderStage::Miss => {
|
||||
if incoming_payload.value.is_none() {
|
||||
return Err(Box::new(Error::MissingIncomingPayload(
|
||||
shader_stage_error_span,
|
||||
)));
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
Some(ast::EntryPoint {
|
||||
@@ -2078,6 +2137,7 @@ impl Parser {
|
||||
workgroup_size: workgroup_size.value,
|
||||
mesh_output_variable: mesh_output.value,
|
||||
task_payload: payload.value,
|
||||
ray_incoming_payload: incoming_payload.value,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
|
||||
+97
-2
@@ -335,6 +335,18 @@ pub enum ShaderStage {
|
||||
|
||||
/// Compute pipeline shader.
|
||||
Compute,
|
||||
|
||||
/// A ray generation shader, in a ray tracing pipeline.
|
||||
RayGeneration,
|
||||
|
||||
/// A miss shader, in a ray tracing pipeline.
|
||||
Miss,
|
||||
|
||||
/// A any hit shader, in a ray tracing pipeline.
|
||||
AnyHit,
|
||||
|
||||
/// A closest hit shader, in a ray tracing pipeline.
|
||||
ClosestHit,
|
||||
}
|
||||
|
||||
/// Addressing space of variables.
|
||||
@@ -373,6 +385,14 @@ pub enum AddressSpace {
|
||||
Immediate,
|
||||
/// Task shader to mesh shader payload
|
||||
TaskPayload,
|
||||
|
||||
/// Ray tracing payload, for inputting in TraceRays
|
||||
RayPayload,
|
||||
/// Ray tracing payload, for entrypoints invoked by a TraceRays call
|
||||
///
|
||||
/// Each entrypoint may reference only one variable in this scope, as
|
||||
/// only one may be passed as a payload.
|
||||
IncomingRayPayload,
|
||||
}
|
||||
|
||||
/// Built-in inputs and outputs.
|
||||
@@ -394,7 +414,7 @@ pub enum BuiltIn {
|
||||
ClipDistance,
|
||||
/// Written in vertex & mesh shaders
|
||||
CullDistance,
|
||||
/// Read in vertex shaders
|
||||
/// Read in vertex, any- and closest-hit shaders
|
||||
InstanceIndex,
|
||||
/// Written in vertex & mesh shaders
|
||||
PointSize,
|
||||
@@ -409,7 +429,7 @@ pub enum BuiltIn {
|
||||
PointCoord,
|
||||
/// Read in fragment shaders
|
||||
FrontFacing,
|
||||
/// Read in fragment shaders, written in mesh shaders
|
||||
/// Read in fragment shaders, written in mesh shaders, read in any and closest hit shaders.
|
||||
PrimitiveIndex,
|
||||
/// Read in fragment shaders
|
||||
Barycentric { perspective: bool },
|
||||
@@ -459,6 +479,46 @@ pub enum BuiltIn {
|
||||
PrimitiveCount,
|
||||
/// Written to a workgroup variable in mesh shaders
|
||||
Primitives,
|
||||
|
||||
/// Read in all ray tracing pipeline shaders, the id within the number of
|
||||
/// rays that this current ray is.
|
||||
RayInvocationId,
|
||||
/// Read in all ray tracing pipeline shaders, the number of rays created.
|
||||
NumRayInvocations,
|
||||
/// Read in closest hit and any hit shaders, the custom data in the tlas
|
||||
/// instance
|
||||
InstanceCustomData,
|
||||
/// Read in closest hit and any hit shaders, the index of the geometry in
|
||||
/// the blas.
|
||||
GeometryIndex,
|
||||
/// Read in closest hit, any hit, and miss shaders, the origin of the ray.
|
||||
WorldRayOrigin,
|
||||
/// Read in closest hit, any hit, and miss shaders, the direction of the
|
||||
/// ray.
|
||||
WorldRayDirection,
|
||||
/// Read in closest hit and any hit shaders, the direction of the ray in
|
||||
/// object space.
|
||||
ObjectRayOrigin,
|
||||
/// Read in closest hit and any hit shaders, the direction of the ray in
|
||||
/// object space.
|
||||
ObjectRayDirection,
|
||||
/// Read in closest hit, any hit, and miss shaders, the t min provided by
|
||||
/// in the ray desc.
|
||||
RayTmin,
|
||||
/// Read in closest hit, any hit, and miss shaders, the final bounds at which
|
||||
/// a hit is accepted (the closest committed hit if there is one otherwise, t
|
||||
/// max provided in the ray desc).
|
||||
RayTCurrentMax,
|
||||
/// Read in closest hit and any hit shaders, the matrix for converting from
|
||||
/// object space to world space
|
||||
ObjectToWorld,
|
||||
/// Read in closest hit and any hit shaders, the matrix for converting from
|
||||
/// world space to object space
|
||||
WorldToObject,
|
||||
/// Read in closest hit and any hit shaders, the type of hit as provided by
|
||||
/// the intersection function if any, otherwise this is 254 (0xFE) for a
|
||||
/// front facing triangle and 255 (0xFF) for a back facing triangle
|
||||
HitKind,
|
||||
}
|
||||
|
||||
/// Number of bytes per scalar.
|
||||
@@ -2278,6 +2338,8 @@ pub enum Statement {
|
||||
/// The specific operation we're performing on `query`.
|
||||
fun: RayQueryFunction,
|
||||
},
|
||||
/// A ray tracing pipeline shader intrinsic.
|
||||
RayPipelineFunction(RayPipelineFunction),
|
||||
/// Calculate a bitmask using a boolean from each active thread in the subgroup
|
||||
SubgroupBallot {
|
||||
/// The [`SubgroupBallotResult`] expression representing this load's result.
|
||||
@@ -2462,6 +2524,9 @@ pub struct EntryPoint {
|
||||
pub mesh_info: Option<MeshStageInfo>,
|
||||
/// The unique global variable used as a task payload from task shader to mesh shader
|
||||
pub task_payload: Option<Handle<GlobalVariable>>,
|
||||
/// The unique global variable used as an incoming ray payload going into any hit, closest hit and miss shaders.
|
||||
/// Unlike the outgoing ray payload, an incoming ray payload must be unique
|
||||
pub incoming_ray_payload: Option<Handle<GlobalVariable>>,
|
||||
}
|
||||
|
||||
/// Return types predeclared for the frexp, modf, and atomicCompareExchangeWeak built-in functions.
|
||||
@@ -2677,6 +2742,36 @@ pub struct MeshStageInfo {
|
||||
pub output_variable: Handle<GlobalVariable>,
|
||||
}
|
||||
|
||||
/// Ray tracing pipeline intrinsics
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize))]
|
||||
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
|
||||
#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
|
||||
pub enum RayPipelineFunction {
|
||||
/// Traces a ray through the given acceleration structure
|
||||
TraceRay {
|
||||
/// The acceleration structure within which this ray should search for hits.
|
||||
///
|
||||
/// The expression must be an [`AccelerationStructure`].
|
||||
///
|
||||
/// [`AccelerationStructure`]: TypeInner::AccelerationStructure
|
||||
acceleration_structure: Handle<Expression>,
|
||||
|
||||
#[allow(rustdoc::private_intra_doc_links)]
|
||||
/// A struct of detailed parameters for the ray query.
|
||||
///
|
||||
/// This expression should have the struct type given in
|
||||
/// [`SpecialTypes::ray_desc`]. This is available in the WGSL
|
||||
/// front end as the `RayDesc` type.
|
||||
descriptor: Handle<Expression>,
|
||||
|
||||
/// A pointer in the ray_payload or incoming_ray_payload address spaces
|
||||
payload: Handle<Expression>,
|
||||
// Do we want miss index? What about sbt offset and sbt stride (could be hard to validate)?
|
||||
// https://github.com/gfx-rs/wgpu/issues/8894
|
||||
},
|
||||
}
|
||||
|
||||
/// Shader module.
|
||||
///
|
||||
/// A module is a set of constants, global variables and functions, as well as
|
||||
|
||||
@@ -212,6 +212,9 @@ impl super::AddressSpace {
|
||||
// TaskPayload isn't always writable, but this is checked for elsewhere,
|
||||
// when not using multiple payloads and matching the entry payload is checked.
|
||||
crate::AddressSpace::TaskPayload => Sa::LOAD | Sa::STORE,
|
||||
crate::AddressSpace::RayPayload | crate::AddressSpace::IncomingRayPayload => {
|
||||
Sa::LOAD | Sa::STORE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -662,6 +665,7 @@ impl super::ShaderStage {
|
||||
match self {
|
||||
Self::Vertex | Self::Fragment => false,
|
||||
Self::Compute | Self::Task | Self::Mesh => true,
|
||||
Self::RayGeneration | Self::AnyHit | Self::ClosestHit | Self::Miss => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,7 +262,12 @@ impl Namer {
|
||||
crate::ShaderStage::Vertex => "VertexOutput",
|
||||
crate::ShaderStage::Fragment => "FragmentOutput",
|
||||
crate::ShaderStage::Compute => "ComputeOutput",
|
||||
crate::ShaderStage::Task | crate::ShaderStage::Mesh => unreachable!(),
|
||||
crate::ShaderStage::Task
|
||||
| crate::ShaderStage::Mesh
|
||||
| crate::ShaderStage::RayGeneration
|
||||
| crate::ShaderStage::ClosestHit
|
||||
| crate::ShaderStage::AnyHit
|
||||
| crate::ShaderStage::Miss => unreachable!(),
|
||||
};
|
||||
entrypoint_type_fallbacks.insert(result.ty, label);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,8 @@ pub fn ensure_block_returns(block: &mut crate::Block) {
|
||||
| S::SubgroupGather { .. }
|
||||
| S::ControlBarrier(_)
|
||||
| S::MemoryBarrier(_)
|
||||
| S::CooperativeStore { .. }),
|
||||
| S::CooperativeStore { .. }
|
||||
| S::RayPipelineFunction(_)),
|
||||
)
|
||||
| None => block.push(S::Return { value: None }, Default::default()),
|
||||
}
|
||||
|
||||
@@ -653,7 +653,7 @@ impl FunctionInfo {
|
||||
let var = &resolve_context.global_vars[gh];
|
||||
let uniform = match var.space {
|
||||
// local data is non-uniform
|
||||
As::Function | As::Private => false,
|
||||
As::Function | As::Private | As::RayPayload | As::IncomingRayPayload => false,
|
||||
// workgroup memory is exclusively accessed by the group
|
||||
// task payload memory is very similar to workgroup memory
|
||||
As::WorkGroup | As::TaskPayload => true,
|
||||
@@ -1190,6 +1190,20 @@ impl FunctionInfo {
|
||||
},
|
||||
exit: ExitFlags::empty(),
|
||||
},
|
||||
S::RayPipelineFunction(ref fun) => {
|
||||
match *fun {
|
||||
crate::RayPipelineFunction::TraceRay {
|
||||
acceleration_structure,
|
||||
descriptor,
|
||||
payload,
|
||||
} => {
|
||||
let _ = self.add_ref(acceleration_structure);
|
||||
let _ = self.add_ref(descriptor);
|
||||
let _ = self.add_ref(payload);
|
||||
}
|
||||
}
|
||||
FunctionUniformity::new()
|
||||
}
|
||||
};
|
||||
|
||||
disruptor = disruptor.or(uniformity.exit_disruptor());
|
||||
|
||||
@@ -228,6 +228,12 @@ pub enum FunctionError {
|
||||
ConflictingTaskPayloadVariables(Handle<crate::Expression>, Handle<crate::Expression>),
|
||||
#[error("Mesh shader output at {0:?} is not a user-defined struct")]
|
||||
InvalidMeshShaderOutputType(Handle<crate::Expression>),
|
||||
#[error("The payload type passed to `traceRay` must be a pointer")]
|
||||
InvalidPayloadType,
|
||||
#[error("The payload type passed to `traceRay` must be a pointer with an address space of `ray_payload` or `incoming_ray_payload`, instead got {0:?}")]
|
||||
InvalidPayloadAddressSpace(crate::AddressSpace),
|
||||
#[error("The payload type ({0:?}) passed to `traceRay` does not match the previous one {1:?}")]
|
||||
MismatchedPayloadType(Handle<crate::Type>, Handle<crate::Type>),
|
||||
}
|
||||
|
||||
bitflags::bitflags! {
|
||||
@@ -1678,6 +1684,81 @@ impl super::Validator {
|
||||
));
|
||||
}
|
||||
}
|
||||
S::RayPipelineFunction(ref fun) => match *fun {
|
||||
crate::RayPipelineFunction::TraceRay {
|
||||
acceleration_structure,
|
||||
descriptor,
|
||||
payload,
|
||||
} => {
|
||||
match *context.resolve_type_inner(
|
||||
acceleration_structure,
|
||||
&self.valid_expression_set,
|
||||
)? {
|
||||
crate::TypeInner::AccelerationStructure { vertex_return } => {
|
||||
if !vertex_return {
|
||||
self.trace_rays_vertex_return =
|
||||
super::TraceRayVertexReturnState::NoVertexReturn(span);
|
||||
} else if let super::TraceRayVertexReturnState::NoTraceRays =
|
||||
self.trace_rays_vertex_return
|
||||
{
|
||||
self.trace_rays_vertex_return =
|
||||
super::TraceRayVertexReturnState::VertexReturn;
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
return Err(FunctionError::InvalidAccelerationStructure(
|
||||
acceleration_structure,
|
||||
)
|
||||
.with_span_handle(acceleration_structure, context.expressions))
|
||||
}
|
||||
}
|
||||
|
||||
let current_payload_ty = match *context
|
||||
.resolve_type_inner(payload, &self.valid_expression_set)?
|
||||
{
|
||||
crate::TypeInner::Pointer { base, space } => {
|
||||
match space {
|
||||
AddressSpace::RayPayload | AddressSpace::IncomingRayPayload => {
|
||||
}
|
||||
space => {
|
||||
return Err(FunctionError::InvalidPayloadAddressSpace(
|
||||
space,
|
||||
)
|
||||
.with_span_handle(payload, context.expressions))
|
||||
}
|
||||
}
|
||||
base
|
||||
}
|
||||
_ => {
|
||||
return Err(FunctionError::InvalidPayloadType
|
||||
.with_span_handle(payload, context.expressions))
|
||||
}
|
||||
};
|
||||
|
||||
let ty = *self
|
||||
.trace_rays_payload_type
|
||||
.get_or_insert(current_payload_ty);
|
||||
|
||||
if ty != current_payload_ty {
|
||||
return Err(FunctionError::MismatchedPayloadType(
|
||||
current_payload_ty,
|
||||
ty,
|
||||
)
|
||||
.with_span_handle(ty, context.types));
|
||||
}
|
||||
|
||||
let desc_ty_given =
|
||||
context.resolve_type_inner(descriptor, &self.valid_expression_set)?;
|
||||
let desc_ty_expected = context
|
||||
.special_types
|
||||
.ray_desc
|
||||
.map(|handle| &context.types[handle].inner);
|
||||
if Some(desc_ty_given) != desc_ty_expected {
|
||||
return Err(FunctionError::InvalidRayDescriptor(descriptor)
|
||||
.with_span_static(span, "invalid ray descriptor"));
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
Ok(BlockInfo { stages })
|
||||
|
||||
@@ -863,6 +863,18 @@ impl super::Validator {
|
||||
validate_expr(data.stride)?;
|
||||
Ok(())
|
||||
}
|
||||
crate::Statement::RayPipelineFunction(fun) => match fun {
|
||||
crate::RayPipelineFunction::TraceRay {
|
||||
acceleration_structure,
|
||||
descriptor,
|
||||
payload,
|
||||
} => {
|
||||
validate_expr(acceleration_structure)?;
|
||||
validate_expr(descriptor)?;
|
||||
validate_expr(payload)?;
|
||||
Ok(())
|
||||
}
|
||||
},
|
||||
crate::Statement::Break
|
||||
| crate::Statement::Continue
|
||||
| crate::Statement::Kill
|
||||
|
||||
+283
-13
@@ -170,6 +170,10 @@ pub enum EntryPointError {
|
||||
WrongMeshOutputAddressSpace,
|
||||
#[error("Task payload must be at least 4 bytes, but is {0} bytes")]
|
||||
TaskPayloadTooSmall(u32),
|
||||
#[error("Only the `ray_generation`, `closest_hit`, and `any_hit` shader stages can access a global variable in the `ray_payload` address space")]
|
||||
RayPayloadInInvalidStage(crate::ShaderStage),
|
||||
#[error("Only the `closest_hit`, `any_hit`, and `miss` shader stages can access a global variable in the `incoming_ray_payload` address space")]
|
||||
IncomingRayPayloadInInvalidStage(crate::ShaderStage),
|
||||
}
|
||||
|
||||
fn storage_usage(access: crate::StorageAccess) -> GlobalUse {
|
||||
@@ -239,7 +243,10 @@ impl VaryingContext<'_> {
|
||||
let required = match built_in {
|
||||
Bi::ClipDistance => Capabilities::CLIP_DISTANCE,
|
||||
Bi::CullDistance => Capabilities::CULL_DISTANCE,
|
||||
Bi::PrimitiveIndex => Capabilities::PRIMITIVE_INDEX,
|
||||
// Primitive index is allowed w/o any other extensions in any- and closest-hit shaders
|
||||
Bi::PrimitiveIndex if !matches!(ep.stage, St::AnyHit | St::ClosestHit) => {
|
||||
Capabilities::PRIMITIVE_INDEX
|
||||
}
|
||||
Bi::Barycentric { .. } => Capabilities::SHADER_BARYCENTRICS,
|
||||
Bi::ViewIndex => Capabilities::MULTIVIEW,
|
||||
Bi::SampleIndex => Capabilities::MULTISAMPLED_SHADING,
|
||||
@@ -262,10 +269,15 @@ impl VaryingContext<'_> {
|
||||
}
|
||||
|
||||
let (visible, type_good) = match built_in {
|
||||
Bi::BaseInstance | Bi::BaseVertex | Bi::InstanceIndex | Bi::VertexIndex => (
|
||||
Bi::BaseInstance | Bi::BaseVertex | Bi::VertexIndex => (
|
||||
self.stage == St::Vertex && !self.output,
|
||||
*ty_inner == Ti::Scalar(crate::Scalar::U32),
|
||||
),
|
||||
Bi::InstanceIndex => (
|
||||
matches!(self.stage, St::Vertex | St::AnyHit | St::ClosestHit)
|
||||
&& !self.output,
|
||||
*ty_inner == Ti::Scalar(crate::Scalar::U32),
|
||||
),
|
||||
Bi::DrawID => (
|
||||
// Always allowed in task/vertex stage. Allowed in mesh stage if there is no task stage in the pipeline.
|
||||
(self.stage == St::Vertex
|
||||
@@ -304,6 +316,7 @@ impl VaryingContext<'_> {
|
||||
St::Vertex | St::Mesh => self.output,
|
||||
St::Fragment => !self.output,
|
||||
St::Compute | St::Task => false,
|
||||
St::RayGeneration | St::AnyHit | St::ClosestHit | St::Miss => false,
|
||||
},
|
||||
*ty_inner
|
||||
== Ti::Vector {
|
||||
@@ -314,7 +327,11 @@ impl VaryingContext<'_> {
|
||||
Bi::ViewIndex => (
|
||||
match self.stage {
|
||||
St::Vertex | St::Fragment | St::Task | St::Mesh => !self.output,
|
||||
St::Compute => false,
|
||||
St::Compute
|
||||
| St::RayGeneration
|
||||
| St::AnyHit
|
||||
| St::ClosestHit
|
||||
| St::Miss => false,
|
||||
},
|
||||
*ty_inner == Ti::Scalar(crate::Scalar::U32),
|
||||
),
|
||||
@@ -327,7 +344,8 @@ impl VaryingContext<'_> {
|
||||
*ty_inner == Ti::Scalar(crate::Scalar::BOOL),
|
||||
),
|
||||
Bi::PrimitiveIndex => (
|
||||
(self.stage == St::Fragment && !self.output)
|
||||
(matches!(self.stage, St::Fragment | St::AnyHit | St::ClosestHit)
|
||||
&& !self.output)
|
||||
|| (self.stage == St::Mesh
|
||||
&& self.output
|
||||
&& self.mesh_output_type == MeshOutputType::PrimitiveOutput),
|
||||
@@ -371,7 +389,14 @@ impl VaryingContext<'_> {
|
||||
),
|
||||
Bi::SubgroupSize | Bi::SubgroupInvocationId => (
|
||||
match self.stage {
|
||||
St::Compute | St::Fragment | St::Task | St::Mesh => !self.output,
|
||||
St::Compute
|
||||
| St::Fragment
|
||||
| St::Task
|
||||
| St::Mesh
|
||||
| St::RayGeneration
|
||||
| St::AnyHit
|
||||
| St::ClosestHit
|
||||
| St::Miss => !self.output,
|
||||
St::Vertex => false,
|
||||
},
|
||||
*ty_inner == Ti::Scalar(crate::Scalar::U32),
|
||||
@@ -408,6 +433,193 @@ impl VaryingContext<'_> {
|
||||
scalar: crate::Scalar::U32,
|
||||
},
|
||||
),
|
||||
Bi::RayInvocationId => (
|
||||
match self.stage {
|
||||
St::Vertex | St::Fragment | St::Compute | St::Mesh | St::Task => false,
|
||||
St::RayGeneration | St::AnyHit | St::ClosestHit | St::Miss => true,
|
||||
},
|
||||
*ty_inner
|
||||
== Ti::Vector {
|
||||
size: Vs::Tri,
|
||||
scalar: crate::Scalar::U32,
|
||||
},
|
||||
),
|
||||
Bi::NumRayInvocations => (
|
||||
match self.stage {
|
||||
St::Vertex | St::Fragment | St::Compute | St::Mesh | St::Task => false,
|
||||
St::RayGeneration | St::AnyHit | St::ClosestHit | St::Miss => true,
|
||||
},
|
||||
*ty_inner
|
||||
== Ti::Vector {
|
||||
size: Vs::Tri,
|
||||
scalar: crate::Scalar::U32,
|
||||
},
|
||||
),
|
||||
Bi::InstanceCustomData => (
|
||||
match self.stage {
|
||||
St::RayGeneration
|
||||
| St::Miss
|
||||
| St::Vertex
|
||||
| St::Fragment
|
||||
| St::Compute
|
||||
| St::Mesh
|
||||
| St::Task => false,
|
||||
St::AnyHit | St::ClosestHit => true,
|
||||
},
|
||||
*ty_inner == Ti::Scalar(crate::Scalar::U32),
|
||||
),
|
||||
Bi::GeometryIndex => (
|
||||
match self.stage {
|
||||
St::RayGeneration
|
||||
| St::Miss
|
||||
| St::Vertex
|
||||
| St::Fragment
|
||||
| St::Compute
|
||||
| St::Mesh
|
||||
| St::Task => false,
|
||||
St::AnyHit | St::ClosestHit => true,
|
||||
},
|
||||
*ty_inner == Ti::Scalar(crate::Scalar::U32),
|
||||
),
|
||||
Bi::WorldRayOrigin => (
|
||||
match self.stage {
|
||||
St::RayGeneration
|
||||
| St::Vertex
|
||||
| St::Fragment
|
||||
| St::Compute
|
||||
| St::Mesh
|
||||
| St::Task => false,
|
||||
St::AnyHit | St::ClosestHit | St::Miss => true,
|
||||
},
|
||||
*ty_inner
|
||||
== Ti::Vector {
|
||||
size: Vs::Tri,
|
||||
scalar: crate::Scalar::F32,
|
||||
},
|
||||
),
|
||||
Bi::WorldRayDirection => (
|
||||
match self.stage {
|
||||
St::RayGeneration
|
||||
| St::Vertex
|
||||
| St::Fragment
|
||||
| St::Compute
|
||||
| St::Mesh
|
||||
| St::Task => false,
|
||||
St::AnyHit | St::ClosestHit | St::Miss => true,
|
||||
},
|
||||
*ty_inner
|
||||
== Ti::Vector {
|
||||
size: Vs::Tri,
|
||||
scalar: crate::Scalar::F32,
|
||||
},
|
||||
),
|
||||
Bi::ObjectRayOrigin => (
|
||||
match self.stage {
|
||||
St::RayGeneration
|
||||
| St::Miss
|
||||
| St::Vertex
|
||||
| St::Fragment
|
||||
| St::Compute
|
||||
| St::Mesh
|
||||
| St::Task => false,
|
||||
St::AnyHit | St::ClosestHit => true,
|
||||
},
|
||||
*ty_inner
|
||||
== Ti::Vector {
|
||||
size: Vs::Tri,
|
||||
scalar: crate::Scalar::F32,
|
||||
},
|
||||
),
|
||||
Bi::ObjectRayDirection => (
|
||||
match self.stage {
|
||||
St::RayGeneration
|
||||
| St::Miss
|
||||
| St::Vertex
|
||||
| St::Fragment
|
||||
| St::Compute
|
||||
| St::Mesh
|
||||
| St::Task => false,
|
||||
St::AnyHit | St::ClosestHit => true,
|
||||
},
|
||||
*ty_inner
|
||||
== Ti::Vector {
|
||||
size: Vs::Tri,
|
||||
scalar: crate::Scalar::F32,
|
||||
},
|
||||
),
|
||||
Bi::RayTmin => (
|
||||
match self.stage {
|
||||
St::RayGeneration
|
||||
| St::Vertex
|
||||
| St::Fragment
|
||||
| St::Compute
|
||||
| St::Mesh
|
||||
| St::Task => false,
|
||||
St::AnyHit | St::ClosestHit | St::Miss => true,
|
||||
},
|
||||
*ty_inner == Ti::Scalar(crate::Scalar::F32),
|
||||
),
|
||||
Bi::RayTCurrentMax => (
|
||||
match self.stage {
|
||||
St::RayGeneration
|
||||
| St::Vertex
|
||||
| St::Fragment
|
||||
| St::Compute
|
||||
| St::Mesh
|
||||
| St::Task => false,
|
||||
St::AnyHit | St::ClosestHit | St::Miss => true,
|
||||
},
|
||||
*ty_inner == Ti::Scalar(crate::Scalar::F32),
|
||||
),
|
||||
Bi::ObjectToWorld => (
|
||||
match self.stage {
|
||||
St::RayGeneration
|
||||
| St::Miss
|
||||
| St::Vertex
|
||||
| St::Fragment
|
||||
| St::Compute
|
||||
| St::Mesh
|
||||
| St::Task => false,
|
||||
St::AnyHit | St::ClosestHit => true,
|
||||
},
|
||||
*ty_inner
|
||||
== Ti::Matrix {
|
||||
columns: crate::VectorSize::Quad,
|
||||
rows: crate::VectorSize::Tri,
|
||||
scalar: crate::Scalar::F32,
|
||||
},
|
||||
),
|
||||
Bi::WorldToObject => (
|
||||
match self.stage {
|
||||
St::RayGeneration
|
||||
| St::Miss
|
||||
| St::Vertex
|
||||
| St::Fragment
|
||||
| St::Compute
|
||||
| St::Mesh
|
||||
| St::Task => false,
|
||||
St::AnyHit | St::ClosestHit => true,
|
||||
},
|
||||
*ty_inner
|
||||
== Ti::Matrix {
|
||||
columns: crate::VectorSize::Quad,
|
||||
rows: crate::VectorSize::Tri,
|
||||
scalar: crate::Scalar::F32,
|
||||
},
|
||||
),
|
||||
Bi::HitKind => (
|
||||
match self.stage {
|
||||
St::RayGeneration
|
||||
| St::Miss
|
||||
| St::Vertex
|
||||
| St::Fragment
|
||||
| St::Compute
|
||||
| St::Mesh
|
||||
| St::Task => false,
|
||||
St::AnyHit | St::ClosestHit => true,
|
||||
},
|
||||
*ty_inner == Ti::Scalar(crate::Scalar::U32),
|
||||
),
|
||||
// Validated elsewhere, shouldn't be here
|
||||
Bi::VertexCount | Bi::PrimitiveCount | Bi::Vertices | Bi::Primitives => {
|
||||
(false, true)
|
||||
@@ -568,7 +780,12 @@ impl VaryingContext<'_> {
|
||||
let needs_interpolation = match self.stage {
|
||||
crate::ShaderStage::Vertex => self.output,
|
||||
crate::ShaderStage::Fragment => !self.output && !per_primitive,
|
||||
crate::ShaderStage::Compute | crate::ShaderStage::Task => false,
|
||||
crate::ShaderStage::Compute
|
||||
| crate::ShaderStage::Task
|
||||
| crate::ShaderStage::RayGeneration
|
||||
| crate::ShaderStage::AnyHit
|
||||
| crate::ShaderStage::ClosestHit
|
||||
| crate::ShaderStage::Miss => false,
|
||||
crate::ShaderStage::Mesh => self.output,
|
||||
};
|
||||
|
||||
@@ -868,6 +1085,17 @@ impl super::Validator {
|
||||
false,
|
||||
)
|
||||
}
|
||||
crate::AddressSpace::RayPayload | crate::AddressSpace::IncomingRayPayload => {
|
||||
if !self
|
||||
.capabilities
|
||||
.contains(Capabilities::RAY_TRACING_PIPELINE)
|
||||
{
|
||||
return Err(GlobalVariableError::UnsupportedCapability(
|
||||
Capabilities::RAY_TRACING_PIPELINE,
|
||||
));
|
||||
}
|
||||
(TypeFlags::DATA | TypeFlags::SIZED, false)
|
||||
}
|
||||
};
|
||||
|
||||
if !type_info.flags.contains(required_type_flags) {
|
||||
@@ -973,14 +1201,28 @@ impl super::Validator {
|
||||
module: &crate::Module,
|
||||
mod_info: &ModuleInfo,
|
||||
) -> Result<FunctionInfo, WithSpan<EntryPointError>> {
|
||||
if matches!(
|
||||
ep.stage,
|
||||
match ep.stage {
|
||||
crate::ShaderStage::Task | crate::ShaderStage::Mesh
|
||||
) && !self.capabilities.contains(Capabilities::MESH_SHADER)
|
||||
{
|
||||
return Err(
|
||||
EntryPointError::UnsupportedCapability(Capabilities::MESH_SHADER).with_span(),
|
||||
);
|
||||
if !self.capabilities.contains(Capabilities::MESH_SHADER) =>
|
||||
{
|
||||
return Err(
|
||||
EntryPointError::UnsupportedCapability(Capabilities::MESH_SHADER).with_span(),
|
||||
);
|
||||
}
|
||||
crate::ShaderStage::RayGeneration
|
||||
| crate::ShaderStage::AnyHit
|
||||
| crate::ShaderStage::ClosestHit
|
||||
| crate::ShaderStage::Miss
|
||||
if !self
|
||||
.capabilities
|
||||
.contains(Capabilities::RAY_TRACING_PIPELINE) =>
|
||||
{
|
||||
return Err(EntryPointError::UnsupportedCapability(
|
||||
Capabilities::RAY_TRACING_PIPELINE,
|
||||
)
|
||||
.with_span());
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
if ep.early_depth_test.is_some() {
|
||||
let required = Capabilities::EARLY_DEPTH_TEST;
|
||||
@@ -1069,6 +1311,10 @@ impl super::Validator {
|
||||
crate::ShaderStage::Compute => ShaderStages::COMPUTE,
|
||||
crate::ShaderStage::Mesh => ShaderStages::MESH,
|
||||
crate::ShaderStage::Task => ShaderStages::TASK,
|
||||
crate::ShaderStage::RayGeneration => ShaderStages::RAY_GENERATION,
|
||||
crate::ShaderStage::AnyHit => ShaderStages::ANY_HIT,
|
||||
crate::ShaderStage::ClosestHit => ShaderStages::CLOSEST_HIT,
|
||||
crate::ShaderStage::Miss => ShaderStages::MISS,
|
||||
};
|
||||
|
||||
if !info.available_stages.contains(stage_bit) {
|
||||
@@ -1206,6 +1452,30 @@ impl super::Validator {
|
||||
}
|
||||
}
|
||||
crate::AddressSpace::Immediate => GlobalUse::READ,
|
||||
crate::AddressSpace::RayPayload => {
|
||||
if !matches!(
|
||||
ep.stage,
|
||||
crate::ShaderStage::RayGeneration
|
||||
| crate::ShaderStage::ClosestHit
|
||||
| crate::ShaderStage::Miss
|
||||
) {
|
||||
return Err(EntryPointError::RayPayloadInInvalidStage(ep.stage)
|
||||
.with_span_handle(var_handle, &module.global_variables));
|
||||
}
|
||||
GlobalUse::READ | GlobalUse::QUERY | GlobalUse::WRITE
|
||||
}
|
||||
crate::AddressSpace::IncomingRayPayload => {
|
||||
if !matches!(
|
||||
ep.stage,
|
||||
crate::ShaderStage::AnyHit
|
||||
| crate::ShaderStage::ClosestHit
|
||||
| crate::ShaderStage::Miss
|
||||
) {
|
||||
return Err(EntryPointError::IncomingRayPayloadInInvalidStage(ep.stage)
|
||||
.with_span_handle(var_handle, &module.global_variables));
|
||||
}
|
||||
GlobalUse::READ | GlobalUse::QUERY | GlobalUse::WRITE
|
||||
}
|
||||
};
|
||||
if !allowed_usage.contains(usage) {
|
||||
log::warn!("\tUsage error for: {var:?}");
|
||||
|
||||
+36
-1
@@ -205,6 +205,8 @@ bitflags::bitflags! {
|
||||
const COOPERATIVE_MATRIX = 1 << 36;
|
||||
/// Support for per-vertex fragment input.
|
||||
const PER_VERTEX = 1 << 37;
|
||||
/// Support for ray generation, any hit, closest hit, and miss shaders.
|
||||
const RAY_TRACING_PIPELINE = 1 << 38;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,6 +227,7 @@ impl Capabilities {
|
||||
Self::RAY_QUERY => Some(Ext::WgpuRayQuery),
|
||||
Self::RAY_HIT_VERTEX_POSITION => Some(Ext::WgpuRayQueryVertexReturn),
|
||||
Self::COOPERATIVE_MATRIX => Some(Ext::WgpuCooperativeMatrix),
|
||||
Self::RAY_TRACING_PIPELINE => Some(Ext::WgpuRayTracingPipeline),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -297,12 +300,16 @@ bitflags::bitflags! {
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
|
||||
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub struct ShaderStages: u8 {
|
||||
pub struct ShaderStages: u16 {
|
||||
const VERTEX = 0x1;
|
||||
const FRAGMENT = 0x2;
|
||||
const COMPUTE = 0x4;
|
||||
const MESH = 0x8;
|
||||
const TASK = 0x10;
|
||||
const RAY_GENERATION = 0x20;
|
||||
const ANY_HIT = 0x40;
|
||||
const CLOSEST_HIT = 0x80;
|
||||
const MISS = 0x100;
|
||||
const COMPUTE_LIKE = Self::COMPUTE.bits() | Self::TASK.bits() | Self::MESH.bits();
|
||||
}
|
||||
}
|
||||
@@ -377,6 +384,32 @@ pub struct Validator {
|
||||
/// [`Expression`]: crate::Expression
|
||||
/// [`Statement`]: crate::Statement
|
||||
needs_visit: HandleSet<crate::Expression>,
|
||||
|
||||
/// Whether any trace rays call is called, and whether all have vertex return.
|
||||
/// If one call doesn't use vertex ruturn, builtins for triangle vertex positions
|
||||
/// (not yet implemented) are not allowed.
|
||||
trace_rays_vertex_return: TraceRayVertexReturnState,
|
||||
|
||||
/// The type of the ray payload, this must always be the same type in a particular
|
||||
/// entrypoint
|
||||
trace_rays_payload_type: Option<Handle<crate::Type>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum TraceRayVertexReturnState {
|
||||
/// No trace ray calls yet have been found.
|
||||
NoTraceRays,
|
||||
/// Trace ray calls have been found, at least
|
||||
/// one uses an acceleration structure that
|
||||
/// does not have the flag enabling vertex return.
|
||||
// Don't yet have vertex return builtins to return.
|
||||
// this error for.
|
||||
#[expect(unused)]
|
||||
NoVertexReturn(crate::Span),
|
||||
/// Trace ray calls have been found, all
|
||||
/// acceleration structures have the flag enabling
|
||||
/// vertex return.
|
||||
VertexReturn,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, thiserror::Error)]
|
||||
@@ -576,6 +609,8 @@ impl Validator {
|
||||
override_ids: FastHashSet::default(),
|
||||
overrides_resolved: false,
|
||||
needs_visit: HandleSet::new(),
|
||||
trace_rays_vertex_return: TraceRayVertexReturnState::NoTraceRays,
|
||||
trace_rays_payload_type: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@ fn check_member_layout(
|
||||
const fn ptr_space_argument_flag(space: crate::AddressSpace) -> TypeFlags {
|
||||
use crate::AddressSpace as As;
|
||||
match space {
|
||||
As::Function | As::Private => TypeFlags::ARGUMENT,
|
||||
As::Function | As::Private | As::RayPayload | As::IncomingRayPayload => TypeFlags::ARGUMENT,
|
||||
As::Uniform
|
||||
| As::Storage { .. }
|
||||
| As::Handle
|
||||
@@ -800,7 +800,8 @@ impl super::Validator {
|
||||
Alignment::ONE,
|
||||
),
|
||||
Ti::AccelerationStructure { vertex_return } => {
|
||||
self.require_type_capability(Capabilities::RAY_QUERY)?;
|
||||
self.require_type_capability(Capabilities::RAY_TRACING_PIPELINE)
|
||||
.or_else(|_| self.require_type_capability(Capabilities::RAY_QUERY))?;
|
||||
if vertex_return {
|
||||
self.require_type_capability(Capabilities::RAY_HIT_VERTEX_POSITION)?;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
capabilities = "RAY_TRACING_PIPELINE"
|
||||
targets = "IR"
|
||||
@@ -0,0 +1,34 @@
|
||||
enable wgpu_ray_tracing_pipeline;
|
||||
|
||||
struct HitCounters {
|
||||
hit_num: u32,
|
||||
selected_hit: u32,
|
||||
}
|
||||
|
||||
var<ray_payload> hit_num: HitCounters;
|
||||
|
||||
@group(0) @binding(0)
|
||||
var acc_struct: acceleration_structure;
|
||||
|
||||
@ray_generation
|
||||
fn ray_gen_main() {
|
||||
hit_num = HitCounters();
|
||||
traceRay(acc_struct, RayDesc(RAY_FLAG_NONE, 0xff, 0.01, 100.0, vec3(0.0), vec3(0.0, 1.0, 0.0)), &hit_num);
|
||||
}
|
||||
|
||||
var<incoming_ray_payload> incoming_hit_num: HitCounters;
|
||||
|
||||
@miss
|
||||
@incoming_payload(incoming_hit_num)
|
||||
fn miss() {}
|
||||
|
||||
@any_hit
|
||||
@incoming_payload(incoming_hit_num)
|
||||
fn any_hit_main() {
|
||||
incoming_hit_num.hit_num++;
|
||||
incoming_hit_num.selected_hit = incoming_hit_num.hit_num;
|
||||
}
|
||||
|
||||
@closest_hit
|
||||
@incoming_payload(incoming_hit_num)
|
||||
fn closest_hit_main() {}
|
||||
@@ -335,7 +335,12 @@ fn write_output_hlsl(
|
||||
naga::ShaderStage::Vertex => &mut config.vertex,
|
||||
naga::ShaderStage::Fragment => &mut config.fragment,
|
||||
naga::ShaderStage::Compute => &mut config.compute,
|
||||
naga::ShaderStage::Task | naga::ShaderStage::Mesh => unreachable!(),
|
||||
naga::ShaderStage::Task
|
||||
| naga::ShaderStage::Mesh
|
||||
| naga::ShaderStage::RayGeneration
|
||||
| naga::ShaderStage::AnyHit
|
||||
| naga::ShaderStage::ClosestHit
|
||||
| naga::ShaderStage::Miss => unreachable!(),
|
||||
}
|
||||
.push(hlsl_snapshots::ConfigItem {
|
||||
entry_point: name.clone(),
|
||||
|
||||
@@ -1273,6 +1273,7 @@ fn unexpected_task_payload() {
|
||||
function: ir::Function::default(),
|
||||
mesh_info: None,
|
||||
task_payload: Some(payload_handle), // invalid for compute stage
|
||||
incoming_ray_payload: None,
|
||||
};
|
||||
module.entry_points.push(entry_point);
|
||||
|
||||
|
||||
@@ -1049,8 +1049,17 @@ macro_rules! check_one_validation {
|
||||
///
|
||||
/// NOTE: The only reason we don't use a function for this is because we need to syntactically
|
||||
/// re-use `$val_err_pat`.
|
||||
///
|
||||
/// The optional $other_caps argument at the end specifies capabilities that
|
||||
/// allow, the shader or would change the error message if enabled, but do not
|
||||
/// get enabled by the specified enable extension. This is only currently the
|
||||
/// case for `acceleration_structures` which are enabled by both ray queries
|
||||
/// and ray tracing pipelines.
|
||||
macro_rules! check_extension_validation {
|
||||
( $caps:expr, $source:expr, $parse_err:expr, $val_err_pat:pat ) => {
|
||||
( $caps:expr, $source:expr, $parse_err:expr, $val_err_pat:pat $(, $other_caps:expr)? ) => {
|
||||
#[allow(unused_mut, unused_assignments)]
|
||||
let mut other_caps = naga::valid::Capabilities::empty();
|
||||
$(other_caps = $other_caps;)?
|
||||
let caps = $caps;
|
||||
let source = $source;
|
||||
let mut ext = None;
|
||||
@@ -1102,7 +1111,9 @@ macro_rules! check_extension_validation {
|
||||
};
|
||||
|
||||
// Second check, for the expected validation error when the capability is not present
|
||||
let error = naga::valid::Validator::new(naga::valid::ValidationFlags::all(), !caps)
|
||||
// Don't check with explicitly allowed caps, as certain things (currently just
|
||||
// `acceleration_structure`s) can be enabled by multiple extensions
|
||||
let error = naga::valid::Validator::new(naga::valid::ValidationFlags::all(), !(caps | other_caps))
|
||||
.validate(&module)
|
||||
.map_err(|e| e.into_inner()); // TODO(https://github.com/gfx-rs/wgpu/issues/8153): Add tests for spans
|
||||
#[allow(clippy::redundant_pattern_matching)]
|
||||
@@ -4359,7 +4370,7 @@ fn enumerant_with_template_parameters() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ray_query_enable_extension() {
|
||||
fn ray_types_enable_extension() {
|
||||
check_extension_validation!(
|
||||
Capabilities::RAY_QUERY,
|
||||
r#"fn foo() {
|
||||
@@ -4381,6 +4392,7 @@ fn ray_query_enable_extension() {
|
||||
})
|
||||
);
|
||||
|
||||
// can be enabled by either of these extensions
|
||||
check_extension_validation!(
|
||||
Capabilities::RAY_QUERY,
|
||||
r#"@group(0) @binding(0)
|
||||
@@ -4398,7 +4410,28 @@ fn ray_query_enable_extension() {
|
||||
Err(naga::valid::ValidationError::Type {
|
||||
source: naga::valid::TypeError::MissingCapability(Capabilities::RAY_QUERY),
|
||||
..
|
||||
})
|
||||
}),
|
||||
Capabilities::RAY_TRACING_PIPELINE
|
||||
);
|
||||
check_extension_validation!(
|
||||
Capabilities::RAY_TRACING_PIPELINE,
|
||||
r#"@group(0) @binding(0)
|
||||
var acc_struct: acceleration_structure;
|
||||
"#,
|
||||
r#"error: the `wgpu_ray_query` enable extension is not enabled
|
||||
┌─ wgsl:2:25
|
||||
│
|
||||
2 │ var acc_struct: acceleration_structure;
|
||||
│ ^^^^^^^^^^^^^^^^^^^^^^ the `wgpu_ray_query` "Enable Extension" is needed for this functionality, but it is not currently enabled.
|
||||
│
|
||||
= note: You can enable this extension by adding `enable wgpu_ray_query;` at the top of the shader, before any other items.
|
||||
|
||||
"#,
|
||||
Err(naga::valid::ValidationError::Type {
|
||||
source: naga::valid::TypeError::MissingCapability(Capabilities::RAY_QUERY),
|
||||
..
|
||||
}),
|
||||
Capabilities::RAY_QUERY
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4739,3 +4772,139 @@ fn mesh_shader_enable_extension() {
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/// Checks that every ray tracing pipeline binding in naga is invalid in other stages.
|
||||
#[test]
|
||||
fn check_ray_tracing_pipeline_bindings() {
|
||||
for (builtin, ty) in [
|
||||
("ray_invocation_id", "vec3<u32>"),
|
||||
("num_ray_invocations", "vec3<u32>"),
|
||||
("instance_custom_data", "u32"),
|
||||
("geometry_index", "u32"),
|
||||
("world_ray_origin", "vec3<f32>"),
|
||||
("world_ray_direction", "vec3<f32>"),
|
||||
("object_ray_origin", "vec3<f32>"),
|
||||
("object_ray_direction", "vec3<f32>"),
|
||||
("ray_t_min", "f32"),
|
||||
("ray_t_current_max", "f32"),
|
||||
("object_to_world", "mat4x3<f32>"),
|
||||
("world_to_object", "mat4x3<f32>"),
|
||||
("hit_kind", "u32"),
|
||||
] {
|
||||
for stage in ["@compute @workgroup_size(1)", " @vertex", "@fragment"] {
|
||||
check_one_validation!(
|
||||
&format!(
|
||||
"{stage}
|
||||
fn main(@builtin({builtin}) v: {ty}) {{}}
|
||||
"
|
||||
),
|
||||
Err(naga::valid::ValidationError::EntryPoint {
|
||||
source: naga::valid::EntryPointError::Argument(
|
||||
0,
|
||||
naga::valid::VaryingError::InvalidBuiltInStage(_),
|
||||
),
|
||||
..
|
||||
},)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks ray generation stage is invalid without enable extension (other stages require `@incoming_payload` which forces a ray payload which is checked in [`check_ray_tracing_pipeline_payload`])
|
||||
#[test]
|
||||
fn check_ray_tracing_pipeline_ray_generation() {
|
||||
check_extension_validation!(
|
||||
Capabilities::RAY_TRACING_PIPELINE,
|
||||
"@ray_generation
|
||||
fn main() {{}}",
|
||||
"error: the `wgpu_ray_tracing_pipeline` enable extension is not enabled
|
||||
┌─ wgsl:1:2
|
||||
│
|
||||
1 │ @ray_generation
|
||||
│ ^^^^^^^^^^^^^^ the `wgpu_ray_tracing_pipeline` \"Enable Extension\" is needed for this functionality, but it is not currently enabled.
|
||||
│
|
||||
= note: You can enable this extension by adding `enable wgpu_ray_tracing_pipeline;` at the top of the shader, before any other items.
|
||||
|
||||
",
|
||||
Err(naga::valid::ValidationError::EntryPoint {
|
||||
source: naga::valid::EntryPointError::UnsupportedCapability(naga::valid::Capabilities::RAY_TRACING_PIPELINE),
|
||||
..
|
||||
},)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_ray_tracing_pipeline_payload() {
|
||||
for space in ["ray_payload", "incoming_ray_payload"] {
|
||||
// ascii is a byte per char so length is fine
|
||||
let space_arrows = "^".to_string().repeat(space.len());
|
||||
check_extension_validation!(
|
||||
Capabilities::RAY_TRACING_PIPELINE,
|
||||
&format!("var<{space}> payload: u32;"),
|
||||
&format!("error: the `wgpu_ray_tracing_pipeline` enable extension is not enabled
|
||||
┌─ wgsl:1:5
|
||||
│
|
||||
1 │ var<{space}> payload: u32;
|
||||
│ {space_arrows} the `wgpu_ray_tracing_pipeline` \"Enable Extension\" is needed for this functionality, but it is not currently enabled.
|
||||
│
|
||||
= note: You can enable this extension by adding `enable wgpu_ray_tracing_pipeline;` at the top of the shader, before any other items.
|
||||
|
||||
"),
|
||||
Err(naga::valid::ValidationError::GlobalVariable {
|
||||
source: naga::valid::GlobalVariableError::UnsupportedCapability(naga::valid::Capabilities::RAY_TRACING_PIPELINE),
|
||||
..
|
||||
},)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_ray_tracing_pipeline_incoming_payload_required() {
|
||||
for stage in ["any_hit", "closest_hit", "miss"] {
|
||||
// ascii is a byte per char so length is fine
|
||||
let stage_arrows = "^".to_string().repeat(stage.len());
|
||||
check(
|
||||
&format!("enable wgpu_ray_tracing_pipeline; @{stage} fn main() {{}}"),
|
||||
&format!("error: incoming payload is missing on a `closest_hit`, `any_hit` or `miss` shader entry point
|
||||
┌─ wgsl:1:36
|
||||
│
|
||||
1 │ enable wgpu_ray_tracing_pipeline; @{stage} fn main() {{}}
|
||||
│ {stage_arrows} must be paired with a `@incoming_payload` attribute
|
||||
|
||||
"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_ray_tracing_pipeline_payload_disallowed() {
|
||||
for (stage, output, stmt) in [
|
||||
(
|
||||
"var<incoming_ray_payload> incoming: u32; @any_hit @incoming_payload(incoming)",
|
||||
"",
|
||||
"",
|
||||
),
|
||||
("@compute @workgroup_size(1)", "", ""),
|
||||
(
|
||||
"@vertex",
|
||||
" -> @builtin(position) vec4<f32>",
|
||||
"return vec4();",
|
||||
),
|
||||
("@fragment", "", ""),
|
||||
] {
|
||||
check_one_validation!(
|
||||
&format!(
|
||||
"enable wgpu_ray_tracing_pipeline;
|
||||
@group(0) @binding(0) var acc_struct: acceleration_structure;
|
||||
var<ray_payload> payload: u32;
|
||||
|
||||
{stage} fn main() {output} {{_ = payload; {stmt}}}"
|
||||
),
|
||||
Err(naga::valid::ValidationError::EntryPoint {
|
||||
source: naga::valid::EntryPointError::RayPayloadInInvalidStage(_),
|
||||
..
|
||||
},),
|
||||
Capabilities::RAY_TRACING_PIPELINE
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
functions: [
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: Some(1),
|
||||
requirements: (""),
|
||||
@@ -416,7 +416,7 @@
|
||||
),
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: Some(1),
|
||||
requirements: (""),
|
||||
@@ -1596,7 +1596,7 @@
|
||||
entry_points: [
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: Some(1),
|
||||
requirements: (""),
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
functions: [
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: None,
|
||||
requirements: (""),
|
||||
@@ -1200,7 +1200,7 @@
|
||||
),
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: None,
|
||||
requirements: (""),
|
||||
@@ -2526,7 +2526,7 @@
|
||||
),
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: Some(0),
|
||||
requirements: (""),
|
||||
@@ -2566,7 +2566,7 @@
|
||||
),
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: Some(0),
|
||||
requirements: (""),
|
||||
@@ -2615,7 +2615,7 @@
|
||||
),
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: None,
|
||||
requirements: (""),
|
||||
@@ -2658,7 +2658,7 @@
|
||||
),
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: None,
|
||||
requirements: (""),
|
||||
@@ -2752,7 +2752,7 @@
|
||||
),
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: None,
|
||||
requirements: (""),
|
||||
@@ -2873,7 +2873,7 @@
|
||||
),
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: Some(0),
|
||||
requirements: (""),
|
||||
@@ -2925,7 +2925,7 @@
|
||||
),
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: None,
|
||||
requirements: (""),
|
||||
@@ -2980,7 +2980,7 @@
|
||||
),
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: Some(0),
|
||||
requirements: (""),
|
||||
@@ -3032,7 +3032,7 @@
|
||||
),
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: None,
|
||||
requirements: (""),
|
||||
@@ -3087,7 +3087,7 @@
|
||||
),
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: Some(0),
|
||||
requirements: (""),
|
||||
@@ -3151,7 +3151,7 @@
|
||||
),
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: Some(2),
|
||||
requirements: (""),
|
||||
@@ -3224,7 +3224,7 @@
|
||||
),
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: Some(2),
|
||||
requirements: (""),
|
||||
@@ -3300,7 +3300,7 @@
|
||||
),
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: None,
|
||||
requirements: (""),
|
||||
@@ -3400,7 +3400,7 @@
|
||||
),
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: Some(1),
|
||||
requirements: (""),
|
||||
@@ -3598,7 +3598,7 @@
|
||||
entry_points: [
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: Some(0),
|
||||
requirements: (""),
|
||||
@@ -4293,7 +4293,7 @@
|
||||
),
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: None,
|
||||
requirements: (""),
|
||||
@@ -4745,7 +4745,7 @@
|
||||
),
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: Some(0),
|
||||
requirements: (""),
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
functions: [
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: Some(3),
|
||||
requirements: (""),
|
||||
@@ -280,7 +280,7 @@
|
||||
entry_points: [
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: Some(3),
|
||||
requirements: (""),
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
entry_points: [
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: None,
|
||||
requirements: (""),
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
entry_points: [
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: None,
|
||||
requirements: (""),
|
||||
@@ -187,7 +187,7 @@
|
||||
),
|
||||
(
|
||||
flags: ("EXPRESSIONS | BLOCKS | CONTROL_FLOW_UNIFORMITY | STRUCT_LAYOUTS | CONSTANTS | BINDINGS"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK"),
|
||||
available_stages: ("VERTEX | FRAGMENT | COMPUTE | MESH | TASK | RAY_GENERATION | ANY_HIT | CLOSEST_HIT | MISS"),
|
||||
uniformity: (
|
||||
non_uniform_result: None,
|
||||
requirements: (""),
|
||||
|
||||
@@ -198,6 +198,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -268,6 +268,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -1037,6 +1037,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -1315,6 +1315,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -619,6 +619,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -725,6 +725,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -2657,6 +2657,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
(
|
||||
name: "foo_frag",
|
||||
@@ -2853,6 +2854,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
(
|
||||
name: "foo_compute",
|
||||
@@ -2914,6 +2916,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -2657,6 +2657,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
(
|
||||
name: "foo_frag",
|
||||
@@ -2853,6 +2854,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
(
|
||||
name: "foo_compute",
|
||||
@@ -2914,6 +2916,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -336,6 +336,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -336,6 +336,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [
|
||||
|
||||
@@ -467,6 +467,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -467,6 +467,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -102,6 +102,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -102,6 +102,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -203,6 +203,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -203,6 +203,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -130,6 +130,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -130,6 +130,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -265,6 +265,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -265,6 +265,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -223,6 +223,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -223,6 +223,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -0,0 +1,350 @@
|
||||
(
|
||||
types: [
|
||||
(
|
||||
name: None,
|
||||
inner: Scalar((
|
||||
kind: Uint,
|
||||
width: 4,
|
||||
)),
|
||||
),
|
||||
(
|
||||
name: Some("HitCounters"),
|
||||
inner: Struct(
|
||||
members: [
|
||||
(
|
||||
name: Some("hit_num"),
|
||||
ty: 0,
|
||||
binding: None,
|
||||
offset: 0,
|
||||
),
|
||||
(
|
||||
name: Some("selected_hit"),
|
||||
ty: 0,
|
||||
binding: None,
|
||||
offset: 4,
|
||||
),
|
||||
],
|
||||
span: 8,
|
||||
),
|
||||
),
|
||||
(
|
||||
name: None,
|
||||
inner: AccelerationStructure(
|
||||
vertex_return: false,
|
||||
),
|
||||
),
|
||||
(
|
||||
name: None,
|
||||
inner: Scalar((
|
||||
kind: Float,
|
||||
width: 4,
|
||||
)),
|
||||
),
|
||||
(
|
||||
name: None,
|
||||
inner: Vector(
|
||||
size: Tri,
|
||||
scalar: (
|
||||
kind: Float,
|
||||
width: 4,
|
||||
),
|
||||
),
|
||||
),
|
||||
(
|
||||
name: Some("RayDesc"),
|
||||
inner: Struct(
|
||||
members: [
|
||||
(
|
||||
name: Some("flags"),
|
||||
ty: 0,
|
||||
binding: None,
|
||||
offset: 0,
|
||||
),
|
||||
(
|
||||
name: Some("cull_mask"),
|
||||
ty: 0,
|
||||
binding: None,
|
||||
offset: 4,
|
||||
),
|
||||
(
|
||||
name: Some("tmin"),
|
||||
ty: 3,
|
||||
binding: None,
|
||||
offset: 8,
|
||||
),
|
||||
(
|
||||
name: Some("tmax"),
|
||||
ty: 3,
|
||||
binding: None,
|
||||
offset: 12,
|
||||
),
|
||||
(
|
||||
name: Some("origin"),
|
||||
ty: 4,
|
||||
binding: None,
|
||||
offset: 16,
|
||||
),
|
||||
(
|
||||
name: Some("dir"),
|
||||
ty: 4,
|
||||
binding: None,
|
||||
offset: 32,
|
||||
),
|
||||
],
|
||||
span: 48,
|
||||
),
|
||||
),
|
||||
],
|
||||
special_types: (
|
||||
ray_desc: Some(5),
|
||||
ray_intersection: None,
|
||||
ray_vertex_return: None,
|
||||
external_texture_params: None,
|
||||
external_texture_transfer_function: None,
|
||||
predeclared_types: {},
|
||||
),
|
||||
constants: [],
|
||||
overrides: [],
|
||||
global_variables: [
|
||||
(
|
||||
name: Some("hit_num"),
|
||||
space: RayPayload,
|
||||
binding: None,
|
||||
ty: 1,
|
||||
init: None,
|
||||
),
|
||||
(
|
||||
name: Some("acc_struct"),
|
||||
space: Handle,
|
||||
binding: Some((
|
||||
group: 0,
|
||||
binding: 0,
|
||||
)),
|
||||
ty: 2,
|
||||
init: None,
|
||||
),
|
||||
(
|
||||
name: Some("incoming_hit_num"),
|
||||
space: IncomingRayPayload,
|
||||
binding: None,
|
||||
ty: 1,
|
||||
init: None,
|
||||
),
|
||||
],
|
||||
global_expressions: [],
|
||||
functions: [],
|
||||
entry_points: [
|
||||
(
|
||||
name: "ray_gen_main",
|
||||
stage: RayGeneration,
|
||||
early_depth_test: None,
|
||||
workgroup_size: (0, 0, 0),
|
||||
workgroup_size_overrides: None,
|
||||
function: (
|
||||
name: Some("ray_gen_main"),
|
||||
arguments: [],
|
||||
result: None,
|
||||
local_variables: [],
|
||||
expressions: [
|
||||
GlobalVariable(0),
|
||||
ZeroValue(1),
|
||||
GlobalVariable(1),
|
||||
Literal(U32(0)),
|
||||
Literal(U32(255)),
|
||||
Literal(F32(0.01)),
|
||||
Literal(F32(100.0)),
|
||||
Literal(F32(0.0)),
|
||||
Splat(
|
||||
size: Tri,
|
||||
value: 7,
|
||||
),
|
||||
Literal(F32(0.0)),
|
||||
Literal(F32(1.0)),
|
||||
Literal(F32(0.0)),
|
||||
Compose(
|
||||
ty: 4,
|
||||
components: [
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
],
|
||||
),
|
||||
Compose(
|
||||
ty: 5,
|
||||
components: [
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
8,
|
||||
12,
|
||||
],
|
||||
),
|
||||
GlobalVariable(0),
|
||||
],
|
||||
named_expressions: {},
|
||||
body: [
|
||||
Store(
|
||||
pointer: 0,
|
||||
value: 1,
|
||||
),
|
||||
Emit((
|
||||
start: 0,
|
||||
end: 0,
|
||||
)),
|
||||
Emit((
|
||||
start: 0,
|
||||
end: 0,
|
||||
)),
|
||||
Emit((
|
||||
start: 8,
|
||||
end: 9,
|
||||
)),
|
||||
Emit((
|
||||
start: 12,
|
||||
end: 14,
|
||||
)),
|
||||
RayPipelineFunction(TraceRay(
|
||||
acceleration_structure: 2,
|
||||
descriptor: 13,
|
||||
payload: 14,
|
||||
)),
|
||||
Return(
|
||||
value: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filter_leaf: None,
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
(
|
||||
name: "miss",
|
||||
stage: Miss,
|
||||
early_depth_test: None,
|
||||
workgroup_size: (0, 0, 0),
|
||||
workgroup_size_overrides: None,
|
||||
function: (
|
||||
name: Some("miss"),
|
||||
arguments: [],
|
||||
result: None,
|
||||
local_variables: [],
|
||||
expressions: [],
|
||||
named_expressions: {},
|
||||
body: [
|
||||
Return(
|
||||
value: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filter_leaf: None,
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: Some(2),
|
||||
),
|
||||
(
|
||||
name: "any_hit_main",
|
||||
stage: AnyHit,
|
||||
early_depth_test: None,
|
||||
workgroup_size: (0, 0, 0),
|
||||
workgroup_size_overrides: None,
|
||||
function: (
|
||||
name: Some("any_hit_main"),
|
||||
arguments: [],
|
||||
result: None,
|
||||
local_variables: [],
|
||||
expressions: [
|
||||
GlobalVariable(2),
|
||||
AccessIndex(
|
||||
base: 0,
|
||||
index: 0,
|
||||
),
|
||||
Literal(U32(1)),
|
||||
Load(
|
||||
pointer: 1,
|
||||
),
|
||||
Binary(
|
||||
op: Add,
|
||||
left: 3,
|
||||
right: 2,
|
||||
),
|
||||
GlobalVariable(2),
|
||||
AccessIndex(
|
||||
base: 5,
|
||||
index: 1,
|
||||
),
|
||||
GlobalVariable(2),
|
||||
AccessIndex(
|
||||
base: 7,
|
||||
index: 0,
|
||||
),
|
||||
Load(
|
||||
pointer: 8,
|
||||
),
|
||||
],
|
||||
named_expressions: {},
|
||||
body: [
|
||||
Emit((
|
||||
start: 1,
|
||||
end: 2,
|
||||
)),
|
||||
Emit((
|
||||
start: 3,
|
||||
end: 5,
|
||||
)),
|
||||
Store(
|
||||
pointer: 1,
|
||||
value: 4,
|
||||
),
|
||||
Emit((
|
||||
start: 6,
|
||||
end: 7,
|
||||
)),
|
||||
Emit((
|
||||
start: 8,
|
||||
end: 10,
|
||||
)),
|
||||
Store(
|
||||
pointer: 6,
|
||||
value: 9,
|
||||
),
|
||||
Return(
|
||||
value: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filter_leaf: None,
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: Some(2),
|
||||
),
|
||||
(
|
||||
name: "closest_hit_main",
|
||||
stage: ClosestHit,
|
||||
early_depth_test: None,
|
||||
workgroup_size: (0, 0, 0),
|
||||
workgroup_size_overrides: None,
|
||||
function: (
|
||||
name: Some("closest_hit_main"),
|
||||
arguments: [],
|
||||
result: None,
|
||||
local_variables: [],
|
||||
expressions: [],
|
||||
named_expressions: {},
|
||||
body: [
|
||||
Return(
|
||||
value: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filter_leaf: None,
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: Some(2),
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
diagnostic_filter_leaf: None,
|
||||
doc_comments: None,
|
||||
)
|
||||
@@ -0,0 +1,350 @@
|
||||
(
|
||||
types: [
|
||||
(
|
||||
name: None,
|
||||
inner: Scalar((
|
||||
kind: Uint,
|
||||
width: 4,
|
||||
)),
|
||||
),
|
||||
(
|
||||
name: Some("HitCounters"),
|
||||
inner: Struct(
|
||||
members: [
|
||||
(
|
||||
name: Some("hit_num"),
|
||||
ty: 0,
|
||||
binding: None,
|
||||
offset: 0,
|
||||
),
|
||||
(
|
||||
name: Some("selected_hit"),
|
||||
ty: 0,
|
||||
binding: None,
|
||||
offset: 4,
|
||||
),
|
||||
],
|
||||
span: 8,
|
||||
),
|
||||
),
|
||||
(
|
||||
name: None,
|
||||
inner: AccelerationStructure(
|
||||
vertex_return: false,
|
||||
),
|
||||
),
|
||||
(
|
||||
name: None,
|
||||
inner: Scalar((
|
||||
kind: Float,
|
||||
width: 4,
|
||||
)),
|
||||
),
|
||||
(
|
||||
name: None,
|
||||
inner: Vector(
|
||||
size: Tri,
|
||||
scalar: (
|
||||
kind: Float,
|
||||
width: 4,
|
||||
),
|
||||
),
|
||||
),
|
||||
(
|
||||
name: Some("RayDesc"),
|
||||
inner: Struct(
|
||||
members: [
|
||||
(
|
||||
name: Some("flags"),
|
||||
ty: 0,
|
||||
binding: None,
|
||||
offset: 0,
|
||||
),
|
||||
(
|
||||
name: Some("cull_mask"),
|
||||
ty: 0,
|
||||
binding: None,
|
||||
offset: 4,
|
||||
),
|
||||
(
|
||||
name: Some("tmin"),
|
||||
ty: 3,
|
||||
binding: None,
|
||||
offset: 8,
|
||||
),
|
||||
(
|
||||
name: Some("tmax"),
|
||||
ty: 3,
|
||||
binding: None,
|
||||
offset: 12,
|
||||
),
|
||||
(
|
||||
name: Some("origin"),
|
||||
ty: 4,
|
||||
binding: None,
|
||||
offset: 16,
|
||||
),
|
||||
(
|
||||
name: Some("dir"),
|
||||
ty: 4,
|
||||
binding: None,
|
||||
offset: 32,
|
||||
),
|
||||
],
|
||||
span: 48,
|
||||
),
|
||||
),
|
||||
],
|
||||
special_types: (
|
||||
ray_desc: Some(5),
|
||||
ray_intersection: None,
|
||||
ray_vertex_return: None,
|
||||
external_texture_params: None,
|
||||
external_texture_transfer_function: None,
|
||||
predeclared_types: {},
|
||||
),
|
||||
constants: [],
|
||||
overrides: [],
|
||||
global_variables: [
|
||||
(
|
||||
name: Some("hit_num"),
|
||||
space: RayPayload,
|
||||
binding: None,
|
||||
ty: 1,
|
||||
init: None,
|
||||
),
|
||||
(
|
||||
name: Some("acc_struct"),
|
||||
space: Handle,
|
||||
binding: Some((
|
||||
group: 0,
|
||||
binding: 0,
|
||||
)),
|
||||
ty: 2,
|
||||
init: None,
|
||||
),
|
||||
(
|
||||
name: Some("incoming_hit_num"),
|
||||
space: IncomingRayPayload,
|
||||
binding: None,
|
||||
ty: 1,
|
||||
init: None,
|
||||
),
|
||||
],
|
||||
global_expressions: [],
|
||||
functions: [],
|
||||
entry_points: [
|
||||
(
|
||||
name: "ray_gen_main",
|
||||
stage: RayGeneration,
|
||||
early_depth_test: None,
|
||||
workgroup_size: (0, 0, 0),
|
||||
workgroup_size_overrides: None,
|
||||
function: (
|
||||
name: Some("ray_gen_main"),
|
||||
arguments: [],
|
||||
result: None,
|
||||
local_variables: [],
|
||||
expressions: [
|
||||
GlobalVariable(0),
|
||||
ZeroValue(1),
|
||||
GlobalVariable(1),
|
||||
Literal(U32(0)),
|
||||
Literal(U32(255)),
|
||||
Literal(F32(0.01)),
|
||||
Literal(F32(100.0)),
|
||||
Literal(F32(0.0)),
|
||||
Splat(
|
||||
size: Tri,
|
||||
value: 7,
|
||||
),
|
||||
Literal(F32(0.0)),
|
||||
Literal(F32(1.0)),
|
||||
Literal(F32(0.0)),
|
||||
Compose(
|
||||
ty: 4,
|
||||
components: [
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
],
|
||||
),
|
||||
Compose(
|
||||
ty: 5,
|
||||
components: [
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
8,
|
||||
12,
|
||||
],
|
||||
),
|
||||
GlobalVariable(0),
|
||||
],
|
||||
named_expressions: {},
|
||||
body: [
|
||||
Store(
|
||||
pointer: 0,
|
||||
value: 1,
|
||||
),
|
||||
Emit((
|
||||
start: 0,
|
||||
end: 0,
|
||||
)),
|
||||
Emit((
|
||||
start: 0,
|
||||
end: 0,
|
||||
)),
|
||||
Emit((
|
||||
start: 8,
|
||||
end: 9,
|
||||
)),
|
||||
Emit((
|
||||
start: 12,
|
||||
end: 14,
|
||||
)),
|
||||
RayPipelineFunction(TraceRay(
|
||||
acceleration_structure: 2,
|
||||
descriptor: 13,
|
||||
payload: 14,
|
||||
)),
|
||||
Return(
|
||||
value: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filter_leaf: None,
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
(
|
||||
name: "miss",
|
||||
stage: Miss,
|
||||
early_depth_test: None,
|
||||
workgroup_size: (0, 0, 0),
|
||||
workgroup_size_overrides: None,
|
||||
function: (
|
||||
name: Some("miss"),
|
||||
arguments: [],
|
||||
result: None,
|
||||
local_variables: [],
|
||||
expressions: [],
|
||||
named_expressions: {},
|
||||
body: [
|
||||
Return(
|
||||
value: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filter_leaf: None,
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: Some(2),
|
||||
),
|
||||
(
|
||||
name: "any_hit_main",
|
||||
stage: AnyHit,
|
||||
early_depth_test: None,
|
||||
workgroup_size: (0, 0, 0),
|
||||
workgroup_size_overrides: None,
|
||||
function: (
|
||||
name: Some("any_hit_main"),
|
||||
arguments: [],
|
||||
result: None,
|
||||
local_variables: [],
|
||||
expressions: [
|
||||
GlobalVariable(2),
|
||||
AccessIndex(
|
||||
base: 0,
|
||||
index: 0,
|
||||
),
|
||||
Literal(U32(1)),
|
||||
Load(
|
||||
pointer: 1,
|
||||
),
|
||||
Binary(
|
||||
op: Add,
|
||||
left: 3,
|
||||
right: 2,
|
||||
),
|
||||
GlobalVariable(2),
|
||||
AccessIndex(
|
||||
base: 5,
|
||||
index: 1,
|
||||
),
|
||||
GlobalVariable(2),
|
||||
AccessIndex(
|
||||
base: 7,
|
||||
index: 0,
|
||||
),
|
||||
Load(
|
||||
pointer: 8,
|
||||
),
|
||||
],
|
||||
named_expressions: {},
|
||||
body: [
|
||||
Emit((
|
||||
start: 1,
|
||||
end: 2,
|
||||
)),
|
||||
Emit((
|
||||
start: 3,
|
||||
end: 5,
|
||||
)),
|
||||
Store(
|
||||
pointer: 1,
|
||||
value: 4,
|
||||
),
|
||||
Emit((
|
||||
start: 6,
|
||||
end: 7,
|
||||
)),
|
||||
Emit((
|
||||
start: 8,
|
||||
end: 10,
|
||||
)),
|
||||
Store(
|
||||
pointer: 6,
|
||||
value: 9,
|
||||
),
|
||||
Return(
|
||||
value: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filter_leaf: None,
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: Some(2),
|
||||
),
|
||||
(
|
||||
name: "closest_hit_main",
|
||||
stage: ClosestHit,
|
||||
early_depth_test: None,
|
||||
workgroup_size: (0, 0, 0),
|
||||
workgroup_size_overrides: None,
|
||||
function: (
|
||||
name: Some("closest_hit_main"),
|
||||
arguments: [],
|
||||
result: None,
|
||||
local_variables: [],
|
||||
expressions: [],
|
||||
named_expressions: {},
|
||||
body: [
|
||||
Return(
|
||||
value: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filter_leaf: None,
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: Some(2),
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
diagnostic_filter_leaf: None,
|
||||
doc_comments: None,
|
||||
)
|
||||
@@ -220,6 +220,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
(
|
||||
name: "csStore",
|
||||
@@ -319,6 +320,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -220,6 +220,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
(
|
||||
name: "csStore",
|
||||
@@ -319,6 +320,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -192,6 +192,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -192,6 +192,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -419,6 +419,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
(
|
||||
name: "vertex_main",
|
||||
@@ -457,6 +458,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
(
|
||||
name: "compute_main",
|
||||
@@ -490,6 +492,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -419,6 +419,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
(
|
||||
name: "vertex_main",
|
||||
@@ -457,6 +458,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
(
|
||||
name: "compute_main",
|
||||
@@ -490,6 +492,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -118,6 +118,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -174,6 +174,7 @@
|
||||
),
|
||||
mesh_info: None,
|
||||
task_payload: None,
|
||||
incoming_ray_payload: None,
|
||||
),
|
||||
],
|
||||
diagnostic_filters: [],
|
||||
|
||||
@@ -1454,6 +1454,12 @@ impl Interface {
|
||||
naga::ShaderStage::Compute
|
||||
| naga::ShaderStage::Task
|
||||
| naga::ShaderStage::Mesh => (false, false),
|
||||
naga::ShaderStage::RayGeneration
|
||||
| naga::ShaderStage::AnyHit
|
||||
| naga::ShaderStage::ClosestHit
|
||||
| naga::ShaderStage::Miss => {
|
||||
unreachable!()
|
||||
}
|
||||
};
|
||||
if !compatible {
|
||||
return Err(InputError::WrongType(provided.ty));
|
||||
|
||||
@@ -65,11 +65,9 @@ impl MaxFragmentShaderInputDeduction {
|
||||
BuiltIn::PrimitiveIndex => InterStageBuiltIn::PrimitiveIndex,
|
||||
BuiltIn::SubgroupSize => InterStageBuiltIn::SubgroupSize,
|
||||
BuiltIn::SubgroupInvocationId => InterStageBuiltIn::SubgroupInvocationId,
|
||||
|
||||
BuiltIn::PointCoord => InterStageBuiltIn::PointCoord,
|
||||
BuiltIn::Barycentric { .. } => InterStageBuiltIn::Barycentric,
|
||||
BuiltIn::ViewIndex => InterStageBuiltIn::ViewIndex,
|
||||
|
||||
BuiltIn::BaseInstance
|
||||
| BuiltIn::BaseVertex
|
||||
| BuiltIn::ClipDistance
|
||||
@@ -95,7 +93,20 @@ impl MaxFragmentShaderInputDeduction {
|
||||
| BuiltIn::VertexCount
|
||||
| BuiltIn::Vertices
|
||||
| BuiltIn::PrimitiveCount
|
||||
| BuiltIn::Primitives => return None,
|
||||
| BuiltIn::Primitives
|
||||
| BuiltIn::RayInvocationId
|
||||
| BuiltIn::NumRayInvocations
|
||||
| BuiltIn::InstanceCustomData
|
||||
| BuiltIn::GeometryIndex
|
||||
| BuiltIn::WorldRayOrigin
|
||||
| BuiltIn::WorldRayDirection
|
||||
| BuiltIn::ObjectRayOrigin
|
||||
| BuiltIn::ObjectRayDirection
|
||||
| BuiltIn::RayTmin
|
||||
| BuiltIn::RayTCurrentMax
|
||||
| BuiltIn::ObjectToWorld
|
||||
| BuiltIn::WorldToObject
|
||||
| BuiltIn::HitKind => return None,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +62,10 @@ pub fn map_naga_stage(stage: naga::ShaderStage) -> wgt::ShaderStages {
|
||||
naga::ShaderStage::Compute => wgt::ShaderStages::COMPUTE,
|
||||
naga::ShaderStage::Task => wgt::ShaderStages::TASK,
|
||||
naga::ShaderStage::Mesh => wgt::ShaderStages::MESH,
|
||||
naga::ShaderStage::RayGeneration => wgt::ShaderStages::RAY_GENERATION,
|
||||
naga::ShaderStage::AnyHit => wgt::ShaderStages::ANY_HIT,
|
||||
naga::ShaderStage::ClosestHit => wgt::ShaderStages::CLOSEST_HIT,
|
||||
naga::ShaderStage::Miss => wgt::ShaderStages::MISS,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,12 @@ impl CompilationContext<'_> {
|
||||
unsafe { gl.bind_frag_data_location(program, location.location, &name) }
|
||||
}
|
||||
naga::ShaderStage::Compute => {}
|
||||
naga::ShaderStage::Task | naga::ShaderStage::Mesh => unreachable!(),
|
||||
naga::ShaderStage::Task
|
||||
| naga::ShaderStage::Mesh
|
||||
| naga::ShaderStage::RayGeneration
|
||||
| naga::ShaderStage::AnyHit
|
||||
| naga::ShaderStage::ClosestHit
|
||||
| naga::ShaderStage::Miss => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +180,12 @@ impl super::Device {
|
||||
naga::ShaderStage::Vertex => glow::VERTEX_SHADER,
|
||||
naga::ShaderStage::Fragment => glow::FRAGMENT_SHADER,
|
||||
naga::ShaderStage::Compute => glow::COMPUTE_SHADER,
|
||||
naga::ShaderStage::Task | naga::ShaderStage::Mesh => unreachable!(),
|
||||
naga::ShaderStage::Task
|
||||
| naga::ShaderStage::Mesh
|
||||
| naga::ShaderStage::RayGeneration
|
||||
| naga::ShaderStage::AnyHit
|
||||
| naga::ShaderStage::ClosestHit
|
||||
| naga::ShaderStage::Miss => unreachable!(),
|
||||
};
|
||||
|
||||
let raw = unsafe { gl.create_shader(target) }.unwrap();
|
||||
|
||||
@@ -260,6 +260,7 @@ impl super::CommandEncoder {
|
||||
S::Task => &bg_info.base_resource_indices.ts,
|
||||
S::Mesh => &bg_info.base_resource_indices.ms,
|
||||
S::Compute => &bg_info.base_resource_indices.cs,
|
||||
S::RayGeneration | S::AnyHit | S::ClosestHit | S::Miss => unimplemented!(),
|
||||
};
|
||||
let buffers = match encoder.stage() {
|
||||
S::Vertex => group.counters.vs.buffers,
|
||||
@@ -267,6 +268,7 @@ impl super::CommandEncoder {
|
||||
S::Task => group.counters.ts.buffers,
|
||||
S::Mesh => group.counters.ms.buffers,
|
||||
S::Compute => group.counters.cs.buffers,
|
||||
S::RayGeneration | S::AnyHit | S::ClosestHit | S::Miss => unimplemented!(),
|
||||
};
|
||||
let mut changes_sizes_buffer = false;
|
||||
for index in 0..buffers {
|
||||
@@ -304,6 +306,7 @@ impl super::CommandEncoder {
|
||||
S::Task => group.counters.ts.samplers,
|
||||
S::Mesh => group.counters.ms.samplers,
|
||||
S::Compute => group.counters.cs.samplers,
|
||||
S::RayGeneration | S::AnyHit | S::ClosestHit | S::Miss => unimplemented!(),
|
||||
};
|
||||
for index in 0..samplers {
|
||||
let res = group.samplers[(index_base.samplers + index) as usize];
|
||||
@@ -318,6 +321,7 @@ impl super::CommandEncoder {
|
||||
S::Task => group.counters.ts.textures,
|
||||
S::Mesh => group.counters.ms.textures,
|
||||
S::Compute => group.counters.cs.textures,
|
||||
S::RayGeneration | S::AnyHit | S::ClosestHit | S::Miss => unimplemented!(),
|
||||
};
|
||||
for index in 0..textures {
|
||||
let res = group.textures[(index_base.textures + index) as usize];
|
||||
|
||||
@@ -663,6 +663,10 @@ impl<T> ops::Index<naga::ShaderStage> for MultiStageData<T> {
|
||||
naga::ShaderStage::Compute => &self.cs,
|
||||
naga::ShaderStage::Task => &self.ts,
|
||||
naga::ShaderStage::Mesh => &self.ms,
|
||||
naga::ShaderStage::RayGeneration
|
||||
| naga::ShaderStage::AnyHit
|
||||
| naga::ShaderStage::ClosestHit
|
||||
| naga::ShaderStage::Miss => unimplemented!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,6 +221,14 @@ bitflags::bitflags! {
|
||||
const TASK = 1 << 3;
|
||||
/// Binding is visible from the mesh shader of a mesh pipeline.
|
||||
const MESH = 1 << 4;
|
||||
/// Binding is visible from the ray generation shader of a ray tracing pipeline.
|
||||
const RAY_GENERATION = 1 << 5;
|
||||
/// Binding is visible from the ray any hit shader of a ray tracing pipeline.
|
||||
const ANY_HIT = 1 << 6;
|
||||
/// Binding is visible from the ray closest hit shader of a ray tracing pipeline.
|
||||
const CLOSEST_HIT = 1 << 7;
|
||||
/// Binding is visible from the ray miss shader of a ray tracing pipeline.
|
||||
const MISS = 1 << 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user