You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: naga/src/back/spv/ray.rs
+19-2Lines changed: 19 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -697,7 +697,9 @@ impl Writer {
697
697
698
698
let valid_id = self.ray_query_initialization_tracking.then(||{
699
699
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).
701
703
block.body.push(Instruction::binary(
702
704
spirv::Op::FOrdLessThanEqual,
703
705
bool_type_id,
@@ -706,6 +708,9 @@ impl Writer {
706
708
tmax_id,
707
709
));
708
710
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).
709
714
let tmin_ge_zero_id = self.id_gen.next();
710
715
let zero_id = self.get_constant_scalar(crate::Literal::F32(0.0));
711
716
block.body.push(Instruction::binary(
@@ -716,6 +721,7 @@ impl Writer {
716
721
zero_id,
717
722
));
718
723
724
+
// Check that ray origin is finite (https://docs.vulkan.org/spec/latest/appendices/spirvenv.html#VUID-RuntimeSpirv-OpRayQueryInitializeKHR-06348)
719
725
let ray_origin_infinite_id = self.id_gen.next();
720
726
block.body.push(Instruction::unary(
721
727
spirv::Op::IsInf,
@@ -763,6 +769,7 @@ impl Writer {
763
769
ray_origin_not_finite_id,
764
770
));
765
771
772
+
// Check that ray direction is finite (https://docs.vulkan.org/spec/latest/appendices/spirvenv.html#VUID-RuntimeSpirv-OpRayQueryInitializeKHR-06348)
766
773
let ray_dir_infinite_id = self.id_gen.next();
767
774
block.body.push(Instruction::unary(
768
775
spirv::Op::IsInf,
@@ -855,6 +862,8 @@ impl Writer {
855
862
less_than_two_id
856
863
}
857
864
865
+
// Check that at most one of skip triangles and skip AABBs is
// 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)
877
888
let contains_cull_back = write_ray_flags_contains_flags(
878
889
self,
879
890
&mut block,
@@ -897,6 +908,8 @@ impl Writer {
897
908
],
898
909
);
899
910
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)
900
913
let contains_opaque = write_ray_flags_contains_flags(
901
914
self,
902
915
&mut block,
@@ -933,6 +946,7 @@ impl Writer {
933
946
],
934
947
);
935
948
949
+
// Combine all checks into a single flag saying whether the call is valid or not.
936
950
self.write_reduce_and(
937
951
&mut block,
938
952
vec![
@@ -950,7 +964,7 @@ impl Writer {
950
964
let merge_label_id = self.id_gen.next();
951
965
let merge_block = Block::new(merge_label_id);
952
966
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.
0 commit comments