| 2249 | } |
| 2250 | |
| 2251 | spv_result_t ValidateImageQueryLod(ValidationState_t& _, |
| 2252 | const Instruction* inst) { |
| 2253 | _.function(inst->function()->id()) |
| 2254 | ->RegisterExecutionModelLimitation( |
| 2255 | [&](spv::ExecutionModel model, std::string* message) { |
| 2256 | if (model != spv::ExecutionModel::Fragment && |
| 2257 | model != spv::ExecutionModel::GLCompute && |
| 2258 | model != spv::ExecutionModel::MeshEXT && |
| 2259 | model != spv::ExecutionModel::TaskEXT) { |
| 2260 | if (message) { |
| 2261 | *message = std::string( |
| 2262 | "OpImageQueryLod requires Fragment, GLCompute, MeshEXT or " |
| 2263 | "TaskEXT execution model"); |
| 2264 | } |
| 2265 | return false; |
| 2266 | } |
| 2267 | return true; |
| 2268 | }); |
| 2269 | _.function(inst->function()->id()) |
| 2270 | ->RegisterLimitation([](const ValidationState_t& state, |
| 2271 | const Function* entry_point, |
| 2272 | std::string* message) { |
| 2273 | const auto* models = state.GetExecutionModels(entry_point->id()); |
| 2274 | const auto* modes = state.GetExecutionModes(entry_point->id()); |
| 2275 | if (models && |
| 2276 | (models->find(spv::ExecutionModel::GLCompute) != models->end() || |
| 2277 | models->find(spv::ExecutionModel::MeshEXT) != models->end() || |
| 2278 | models->find(spv::ExecutionModel::TaskEXT) != models->end()) && |
| 2279 | (!modes || |
| 2280 | (modes->find(spv::ExecutionMode::DerivativeGroupLinearKHR) == |
| 2281 | modes->end() && |
| 2282 | modes->find(spv::ExecutionMode::DerivativeGroupQuadsKHR) == |
| 2283 | modes->end()))) { |
| 2284 | if (message) { |
| 2285 | *message = std::string( |
| 2286 | "OpImageQueryLod requires DerivativeGroupQuadsKHR " |
| 2287 | "or DerivativeGroupLinearKHR execution mode for GLCompute, " |
| 2288 | "MeshEXT or TaskEXT execution model"); |
| 2289 | } |
| 2290 | return false; |
| 2291 | } |
| 2292 | return true; |
| 2293 | }); |
| 2294 | |
| 2295 | const uint32_t result_type = inst->type_id(); |
| 2296 | if (!_.IsFloatVectorType(result_type)) { |
| 2297 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 2298 | << "Expected Result Type to be float vector type"; |
| 2299 | } |
| 2300 | |
| 2301 | if (_.GetDimension(result_type) != 2) { |
| 2302 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 2303 | << "Expected Result Type to have 2 components"; |
| 2304 | } |
| 2305 | |
| 2306 | const uint32_t image_type = _.GetOperandTypeId(inst, 2); |
| 2307 | if (_.GetIdOpcode(image_type) != spv::Op::OpTypeSampledImage) { |
| 2308 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
no test coverage detected