| 2342 | } |
| 2343 | |
| 2344 | spv_result_t ValidateImageQueryLevelsOrSamples(ValidationState_t& _, |
| 2345 | const Instruction* inst) { |
| 2346 | if (!_.IsIntScalarType(inst->type_id())) { |
| 2347 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 2348 | << "Expected Result Type to be int scalar type"; |
| 2349 | } |
| 2350 | |
| 2351 | const uint32_t image_type = _.GetOperandTypeId(inst, 2); |
| 2352 | if (_.GetIdOpcode(image_type) != spv::Op::OpTypeImage) { |
| 2353 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 2354 | << "Expected Image to be of type OpTypeImage"; |
| 2355 | } |
| 2356 | |
| 2357 | ImageTypeInfo info; |
| 2358 | if (!GetImageTypeInfo(_, image_type, &info)) { |
| 2359 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 2360 | << "Corrupt image type definition"; |
| 2361 | } |
| 2362 | |
| 2363 | const spv::Op opcode = inst->opcode(); |
| 2364 | if (opcode == spv::Op::OpImageQueryLevels) { |
| 2365 | if (info.dim != spv::Dim::Dim1D && info.dim != spv::Dim::Dim2D && |
| 2366 | info.dim != spv::Dim::Dim3D && info.dim != spv::Dim::Cube) { |
| 2367 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 2368 | << "Image 'Dim' must be 1D, 2D, 3D or Cube"; |
| 2369 | } |
| 2370 | const auto target_env = _.context()->target_env; |
| 2371 | if (spvIsVulkanEnv(target_env)) { |
| 2372 | if (info.sampled != 1) { |
| 2373 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 2374 | << _.VkErrorID(4659) |
| 2375 | << "OpImageQueryLevels must only consume an \"Image\" operand " |
| 2376 | "whose type has its \"Sampled\" operand set to 1"; |
| 2377 | } |
| 2378 | } |
| 2379 | } else { |
| 2380 | assert(opcode == spv::Op::OpImageQuerySamples); |
| 2381 | if (info.dim != spv::Dim::Dim2D) { |
| 2382 | return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Image 'Dim' must be 2D"; |
| 2383 | } |
| 2384 | |
| 2385 | if (info.multisampled != 1) { |
| 2386 | return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Image 'MS' must be 1"; |
| 2387 | } |
| 2388 | } |
| 2389 | return SPV_SUCCESS; |
| 2390 | } |
| 2391 | |
| 2392 | spv_result_t ValidateImageSparseTexelsResident(ValidationState_t& _, |
| 2393 | const Instruction* inst) { |
no test coverage detected