Skip to content

Commit c6576ff

Browse files
committed
Note the VUIDs that things satisfy
1 parent 339cbdb commit c6576ff

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

naga/src/back/spv/ray.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,9 @@ impl Writer {
697697

698698
let valid_id = self.ray_query_initialization_tracking.then(||{
699699
let tmin_le_tmax_id = self.id_gen.next();
700-
// Because this checks if tmin and tmax are ordered too (i.e: not NaN), there is no need for an additional check.
700+
// Check both that tmin is less than or equal to tmax (https://docs.vulkan.org/spec/latest/appendices/spirvenv.html#VUID-RuntimeSpirv-OpRayQueryInitializeKHR-06350)
701+
// and implicitly that neither tmin or tmax are NaN (https://docs.vulkan.org/spec/latest/appendices/spirvenv.html#VUID-RuntimeSpirv-OpRayQueryInitializeKHR-06351)
702+
// because this checks if tmin and tmax are ordered too (i.e: not NaN).
701703
block.body.push(Instruction::binary(
702704
spirv::Op::FOrdLessThanEqual,
703705
bool_type_id,
@@ -706,6 +708,9 @@ impl Writer {
706708
tmax_id,
707709
));
708710

711+
// Check that tmin is greater than or equal to 0 (and
712+
// therefore also tmax is too because it is greater than
713+
// or equal to tmin) (https://docs.vulkan.org/spec/latest/appendices/spirvenv.html#VUID-RuntimeSpirv-OpRayQueryInitializeKHR-06349).
709714
let tmin_ge_zero_id = self.id_gen.next();
710715
let zero_id = self.get_constant_scalar(crate::Literal::F32(0.0));
711716
block.body.push(Instruction::binary(
@@ -716,6 +721,7 @@ impl Writer {
716721
zero_id,
717722
));
718723

724+
// Check that ray origin is finite (https://docs.vulkan.org/spec/latest/appendices/spirvenv.html#VUID-RuntimeSpirv-OpRayQueryInitializeKHR-06348)
719725
let ray_origin_infinite_id = self.id_gen.next();
720726
block.body.push(Instruction::unary(
721727
spirv::Op::IsInf,
@@ -763,6 +769,7 @@ impl Writer {
763769
ray_origin_not_finite_id,
764770
));
765771

772+
// Check that ray direction is finite (https://docs.vulkan.org/spec/latest/appendices/spirvenv.html#VUID-RuntimeSpirv-OpRayQueryInitializeKHR-06348)
766773
let ray_dir_infinite_id = self.id_gen.next();
767774
block.body.push(Instruction::unary(
768775
spirv::Op::IsInf,
@@ -855,6 +862,8 @@ impl Writer {
855862
less_than_two_id
856863
}
857864

865+
// Check that at most one of skip triangles and skip AABBs is
866+
// present (https://docs.vulkan.org/spec/latest/appendices/spirvenv.html#VUID-RuntimeSpirv-OpRayQueryInitializeKHR-06889)
858867
let contains_skip_triangles = write_ray_flags_contains_flags(
859868
self,
860869
&mut block,
@@ -874,6 +883,8 @@ impl Writer {
874883
vec![contains_skip_triangles, contains_skip_aabbs],
875884
);
876885

886+
// Check that at most one of skip triangles (taken from above check),
887+
// cull back facing, and cull front face is present (https://docs.vulkan.org/spec/latest/appendices/spirvenv.html#VUID-RuntimeSpirv-OpRayQueryInitializeKHR-06890)
877888
let contains_cull_back = write_ray_flags_contains_flags(
878889
self,
879890
&mut block,
@@ -897,6 +908,8 @@ impl Writer {
897908
],
898909
);
899910

911+
// Check that at most one of force opaque, force not opaque, cull opaque,
912+
// and cull not opaque are present (https://docs.vulkan.org/spec/latest/appendices/spirvenv.html#VUID-RuntimeSpirv-OpRayQueryInitializeKHR-06891)
900913
let contains_opaque = write_ray_flags_contains_flags(
901914
self,
902915
&mut block,
@@ -933,6 +946,7 @@ impl Writer {
933946
],
934947
);
935948

949+
// Combine all checks into a single flag saying whether the call is valid or not.
936950
self.write_reduce_and(
937951
&mut block,
938952
vec![
@@ -950,7 +964,7 @@ impl Writer {
950964
let merge_label_id = self.id_gen.next();
951965
let merge_block = Block::new(merge_label_id);
952966

953-
// NOTE: this block will be unreachable if initialization tracking is set to false.
967+
// NOTE: this block will be unreachable if initialization tracking is disabled.
954968
let invalid_label_id = self.id_gen.next();
955969
let mut invalid_block = Block::new(invalid_label_id);
956970

@@ -1274,6 +1288,9 @@ impl Writer {
12741288
candidate_aabb_id,
12751289
));
12761290

1291+
// Check that the provided t value is between t min and the current committed
1292+
// t value, (https://docs.vulkan.org/spec/latest/appendices/spirvenv.html#VUID-RuntimeSpirv-OpRayQueryGenerateIntersectionKHR-06353)
1293+
12771294
// Get the tmin
12781295
let t_min_id = self.id_gen.next();
12791296
valid_block.body.push(Instruction::ray_query_get_t_min(

0 commit comments

Comments
 (0)