@@ -107,8 +107,10 @@ Naga's rules for when `Expression`s are evaluated are as follows:
107
107
[`Atomic`] statement, representing the result of the atomic operation, is
108
108
evaluated when the `Atomic` statement is executed.
109
109
110
- - Similarly, an [`RayQueryProceedResult`] expression, which is a boolean
111
- indicating if the ray query is finished.
110
+ - A [`RayQueryProceedResult`] expression, which is a boolean
111
+ indicating if the ray query is finished, is evaluated when the
112
+ [`RayQuery`] statement whose [`Proceed::result`] points to it is
113
+ executed.
112
114
113
115
- All other expressions are evaluated when the (unique) [`Statement::Emit`]
114
116
statement that covers them is executed.
@@ -184,6 +186,9 @@ tree.
184
186
[`Call`]: Statement::Call
185
187
[`Emit`]: Statement::Emit
186
188
[`Store`]: Statement::Store
189
+ [`RayQuery`]: Statement::RayQuery
190
+
191
+ [`Proceed::result`]: RayQueryFunction::Proceed::result
187
192
188
193
[`Validator::validate`]: valid::Validator::validate
189
194
[`ModuleInfo`]: valid::ModuleInfo
@@ -727,6 +732,7 @@ pub enum TypeInner {
727
732
728
733
/// Opaque object representing an acceleration structure of geometry.
729
734
AccelerationStructure ,
735
+
730
736
/// Locally used handle for ray queries.
731
737
RayQuery ,
732
738
@@ -1445,9 +1451,16 @@ pub enum Expression {
1445
1451
/// This doesn't match the semantics of spirv's `OpArrayLength`, which must be passed
1446
1452
/// a pointer to a structure containing a runtime array in its' last field.
1447
1453
ArrayLength ( Handle < Expression > ) ,
1448
- /// Result of `rayQueryProceed`.
1454
+
1455
+ /// Result of a [`Proceed`] [`RayQuery`] statement.
1456
+ ///
1457
+ /// [`Proceed`]: RayQueryFunction::Proceed
1458
+ /// [`RayQuery`]: Statement::RayQuery
1449
1459
RayQueryProceedResult ,
1450
- /// Result of `rayQueryGet*Intersection`.
1460
+
1461
+ /// Return an intersection found by `query`.
1462
+ ///
1463
+ /// If `committed` is true, return the committed result available when
1451
1464
RayQueryGetIntersection {
1452
1465
query : Handle < Expression > ,
1453
1466
committed : bool ,
@@ -1484,18 +1497,45 @@ pub struct SwitchCase {
1484
1497
pub fall_through : bool ,
1485
1498
}
1486
1499
1500
+ /// An operation that a [`RayQuery` statement] applies to its [`query`] operand.
1501
+ ///
1502
+ /// [`RayQuery` statement]: Statement::RayQuery
1503
+ /// [`query`]: Statement::RayQuery::query
1487
1504
#[ derive( Clone , Debug ) ]
1488
1505
#[ cfg_attr( feature = "serialize" , derive( Serialize ) ) ]
1489
1506
#[ cfg_attr( feature = "deserialize" , derive( Deserialize ) ) ]
1490
1507
#[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
1491
1508
pub enum RayQueryFunction {
1509
+ /// Initialize the `RayQuery` object.
1492
1510
Initialize {
1511
+ /// The acceleration structure within which this query should search for hits.
1512
+ ///
1513
+ /// The expression must be an [`AccelerationStructure`].
1514
+ ///
1515
+ /// [`AccelerationStructure`]: TypeInner::AccelerationStructure
1493
1516
acceleration_structure : Handle < Expression > ,
1517
+
1518
+ #[ allow( rustdoc:: private_intra_doc_links) ]
1519
+ /// A struct of detailed parameters for the ray query.
1520
+ ///
1521
+ /// This expression should have the struct type given in
1522
+ /// [`SpecialTypes::ray_desc`]. This is available in the WGSL
1523
+ /// front end as the `RayDesc` type.
1494
1524
descriptor : Handle < Expression > ,
1495
1525
} ,
1526
+
1527
+ /// Start or continue the query given by the statement's [`query`] operand.
1528
+ ///
1529
+ /// After executing this statement, the `result` expression is a
1530
+ /// [`Bool`] scalar indicating whether there are more intersection
1531
+ /// candidates to consider.
1532
+ ///
1533
+ /// [`query`]: Statement::RayQuery::query
1534
+ /// [`Bool`]: ScalarKind::Bool
1496
1535
Proceed {
1497
1536
result : Handle < Expression > ,
1498
1537
} ,
1538
+
1499
1539
Terminate ,
1500
1540
}
1501
1541
@@ -1673,7 +1713,12 @@ pub enum Statement {
1673
1713
result : Option < Handle < Expression > > ,
1674
1714
} ,
1675
1715
RayQuery {
1716
+ /// The [`RayQuery`] object this statement operates on.
1717
+ ///
1718
+ /// [`RayQuery`]: TypeInner::RayQuery
1676
1719
query : Handle < Expression > ,
1720
+
1721
+ /// The specific operation we're performing on `query`.
1677
1722
fun : RayQueryFunction ,
1678
1723
} ,
1679
1724
}
@@ -1800,8 +1845,15 @@ pub struct EntryPoint {
1800
1845
#[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
1801
1846
pub struct SpecialTypes {
1802
1847
/// Type for `RayDesc`.
1848
+ ///
1849
+ /// Call [`Module::generate_ray_desc_type`] to populate this if
1850
+ /// needed and return the handle.
1803
1851
ray_desc : Option < Handle < Type > > ,
1852
+
1804
1853
/// Type for `RayIntersection`.
1854
+ ///
1855
+ /// Call [`Module::generate_ray_intersection_type`] to populate
1856
+ /// this if needed and return the handle.
1805
1857
ray_intersection : Option < Handle < Type > > ,
1806
1858
}
1807
1859
0 commit comments