MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / RayQueryPass

Function RayQueryPass

source/val/validate_ray_query.cpp:80–382  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78} // namespace
79
80spv_result_t RayQueryPass(ValidationState_t& _, const Instruction* inst) {
81 const spv::Op opcode = inst->opcode();
82 const uint32_t result_type = inst->type_id();
83
84 switch (opcode) {
85 case spv::Op::OpRayQueryInitializeKHR: {
86 if (auto error = ValidateRayQueryPointer(_, inst, 0)) return error;
87
88 if (_.GetIdOpcode(_.GetOperandTypeId(inst, 1)) !=
89 spv::Op::OpTypeAccelerationStructureKHR) {
90 return _.diag(SPV_ERROR_INVALID_DATA, inst)
91 << "Expected Acceleration Structure to be of type "
92 "OpTypeAccelerationStructureKHR";
93 }
94
95 const uint32_t ray_flags = _.GetOperandTypeId(inst, 2);
96 if (!_.IsIntScalarType(ray_flags, 32)) {
97 return _.diag(SPV_ERROR_INVALID_DATA, inst)
98 << "Ray Flags must be a 32-bit int scalar";
99 }
100
101 const uint32_t cull_mask = _.GetOperandTypeId(inst, 3);
102 if (!_.IsIntScalarType(cull_mask, 32)) {
103 return _.diag(SPV_ERROR_INVALID_DATA, inst)
104 << "Cull Mask must be a 32-bit int scalar";
105 }
106
107 const uint32_t ray_origin = _.GetOperandTypeId(inst, 4);
108 if (!_.IsFloatVectorType(ray_origin) || _.GetDimension(ray_origin) != 3 ||
109 _.GetBitWidth(ray_origin) != 32) {
110 return _.diag(SPV_ERROR_INVALID_DATA, inst)
111 << "Ray Origin must be a 32-bit float 3-component vector";
112 }
113
114 const uint32_t ray_tmin = _.GetOperandTypeId(inst, 5);
115 if (!_.IsFloatScalarType(ray_tmin, 32)) {
116 return _.diag(SPV_ERROR_INVALID_DATA, inst)
117 << "Ray TMin must be a 32-bit float scalar";
118 }
119
120 const uint32_t ray_direction = _.GetOperandTypeId(inst, 6);
121 if (!_.IsFloatVectorType(ray_direction) ||
122 _.GetDimension(ray_direction) != 3 ||
123 _.GetBitWidth(ray_direction) != 32) {
124 return _.diag(SPV_ERROR_INVALID_DATA, inst)
125 << "Ray Direction must be a 32-bit float 3-component vector";
126 }
127
128 const uint32_t ray_tmax = _.GetOperandTypeId(inst, 7);
129 if (!_.IsFloatScalarType(ray_tmax, 32)) {
130 return _.diag(SPV_ERROR_INVALID_DATA, inst)
131 << "Ray TMax must be a 32-bit float scalar";
132 }
133 break;
134 }
135
136 case spv::Op::OpRayQueryTerminateKHR:
137 case spv::Op::OpRayQueryConfirmIntersectionKHR: {

Calls 15

ValidateIntersectionIdFunction · 0.85
spvOpcodeStringFunction · 0.85
GetIdOpcodeMethod · 0.80
GetOperandTypeIdMethod · 0.80
diagMethod · 0.80
IsIntScalarTypeMethod · 0.80
IsFloatVectorTypeMethod · 0.80
GetDimensionMethod · 0.80
GetBitWidthMethod · 0.80
IsFloatScalarTypeMethod · 0.80
IsBoolScalarTypeMethod · 0.80
GetMatrixTypeInfoMethod · 0.80

Tested by

no test coverage detected