diff --git a/DEPS b/DEPS index c4e876edb7..cc8a0dc0db 100644 --- a/DEPS +++ b/DEPS @@ -14,7 +14,7 @@ vars = { 're2_revision': '972a15cedd008d846f1a39b2e88ce48d7f166cbd', - 'spirv_headers_revision': '58006c901d1d5c37dece6b6610e9af87fa951375', + 'spirv_headers_revision': 'c07e08097821b2894892fc7a1157c23eccdde657', 'mimalloc_revision': 'fef6b0dd70f9d7fa0750b0d0b9fbb471203b94cd', } diff --git a/include/spirv-tools/libspirv.h b/include/spirv-tools/libspirv.h index 28fd916534..cb672cb9ee 100644 --- a/include/spirv-tools/libspirv.h +++ b/include/spirv-tools/libspirv.h @@ -337,6 +337,9 @@ typedef enum spv_operand_type_t { SPV_OPERAND_TYPE_OPTIONAL_CAPABILITY, SPV_OPERAND_TYPE_VARIABLE_CAPABILITY, + // Enum type from SPV_QCOM_image_processing3 + SPV_OPERAND_TYPE_GATHER_MODES, + // This is a sentinel value, and does not represent an operand type. // It should come last. SPV_OPERAND_TYPE_NUM_OPERAND_TYPES, @@ -1007,8 +1010,8 @@ SPIRV_TOOLS_EXPORT spv_result_t spvBinaryParse( // The optimizer interface. // A pointer to a function that accepts a log message from an optimizer. -typedef void (*spv_message_consumer)( - spv_message_level_t, const char*, const spv_position_t*, const char*); +typedef void (*spv_message_consumer)(spv_message_level_t, const char*, + const spv_position_t*, const char*); // Creates and returns an optimizer object. This object must be passed to // optimizer APIs below and is valid until passed to spvOptimizerDestroy. diff --git a/source/operand.cpp b/source/operand.cpp index 3bb800fd15..596621d3aa 100644 --- a/source/operand.cpp +++ b/source/operand.cpp @@ -207,6 +207,8 @@ const char* spvOperandTypeStr(spv_operand_type_t type) { return "cooperative vector matrix layout"; case SPV_OPERAND_TYPE_COMPONENT_TYPE: return "component type"; + case SPV_OPERAND_TYPE_GATHER_MODES: + return "gather modes"; case SPV_OPERAND_TYPE_KERNEL_PROPERTY_FLAGS: return "kernel property flags"; @@ -339,6 +341,7 @@ bool spvOperandIsConcrete(spv_operand_type_t type) { case SPV_OPERAND_TYPE_TENSOR_CLAMP_MODE: case SPV_OPERAND_TYPE_COOPERATIVE_VECTOR_MATRIX_LAYOUT: case SPV_OPERAND_TYPE_COMPONENT_TYPE: + case SPV_OPERAND_TYPE_GATHER_MODES: case SPV_OPERAND_TYPE_KERNEL_PROPERTY_FLAGS: case SPV_OPERAND_TYPE_SHDEBUG100_BUILD_IDENTIFIER_FLAGS: case SPV_OPERAND_TYPE_SHDEBUG100_DEBUG_BASE_TYPE_ATTRIBUTE_ENCODING: diff --git a/source/val/validate_image.cpp b/source/val/validate_image.cpp index 68d80569c6..e8239a2a1c 100644 --- a/source/val/validate_image.cpp +++ b/source/val/validate_image.cpp @@ -637,7 +637,8 @@ spv_result_t ValidateImageOperands(ValidationState_t& _, if (opcode != spv::Op::OpImageGather && opcode != spv::Op::OpImageDrefGather && opcode != spv::Op::OpImageSparseGather && - opcode != spv::Op::OpImageSparseDrefGather) { + opcode != spv::Op::OpImageSparseDrefGather && + opcode != spv::Op::OpImageGatherQCOM) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << _.VkErrorID(10213) << "Image Operand Offset can only be used with " @@ -652,7 +653,8 @@ spv_result_t ValidateImageOperands(ValidationState_t& _, if (opcode != spv::Op::OpImageGather && opcode != spv::Op::OpImageDrefGather && opcode != spv::Op::OpImageSparseGather && - opcode != spv::Op::OpImageSparseDrefGather) { + opcode != spv::Op::OpImageSparseDrefGather && + opcode != spv::Op::OpImageGatherQCOM) { return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Image Operand ConstOffsets can only be used with " "OpImageGather and OpImageDrefGather"; @@ -908,7 +910,9 @@ bool IsSparse(spv::Op opcode) { return true; } - default: { return false; } + default: { + return false; + } } return false; @@ -1199,6 +1203,7 @@ bool IsAllowedSampledImageOperand(spv::Op opcode, ValidationState_t& _) { case spv::Op::OpImageBlockMatchWindowSSDQCOM: case spv::Op::OpImageBlockMatchGatherSADQCOM: case spv::Op::OpImageBlockMatchGatherSSDQCOM: + case spv::Op::OpImageGatherQCOM: case spv::Op::OpImageSampleFootprintNV: return true; case spv::Op::OpStore: @@ -1225,6 +1230,7 @@ spv_result_t ValidateImageCoordinate(ValidationState_t& _, opcode == spv::Op::OpImageSampleProjDrefImplicitLod || opcode == spv::Op::OpImageSampleProjDrefExplicitLod || opcode == spv::Op::OpImageGather || + opcode == spv::Op::OpImageGatherQCOM || opcode == spv::Op::OpImageDrefGather || opcode == spv::Op::OpImageQueryLod || opcode == spv::Op::OpImageSparseSampleImplicitLod || @@ -1418,9 +1424,10 @@ spv_result_t ValidateSampledImage(ValidationState_t& _, "as operand for Op" << spvOpcodeString(consumer_opcode) << ", since it is not specified as taking an " - << "OpTypeSampledImage." << " Found result " - << _.getIdName(inst->id()) << " as an operand of " - << _.getIdName(consumer_instr->id()) << "."; + << "OpTypeSampledImage." + << " Found result " << _.getIdName(inst->id()) + << " as an operand of " << _.getIdName(consumer_instr->id()) + << "."; } } } @@ -1853,8 +1860,10 @@ spv_result_t ValidateImageGather(ValidationState_t& _, ValidateImageCoordinate(_, inst, info, /* word_index = */ 3)) return result; + unsigned n_additional_operands = 0; if (opcode == spv::Op::OpImageGather || - opcode == spv::Op::OpImageSparseGather) { + opcode == spv::Op::OpImageSparseGather || + opcode == spv::Op::OpImageGatherQCOM) { const uint32_t component = inst->GetOperandAs(4); const uint32_t component_index_type = _.GetTypeId(component); if (!_.IsIntScalarType(component_index_type, 32)) { @@ -1869,14 +1878,24 @@ spv_result_t ValidateImageGather(ValidationState_t& _, "environment"; } } + if (opcode == spv::Op::OpImageGatherQCOM) { + const uint32_t mode = inst->GetOperandAs(5); + const uint32_t mode_index_type = _.GetTypeId(mode); + if (!_.IsIntScalarType(mode_index_type) || + _.GetBitWidth(mode_index_type) != 32) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << "Expected Mode to be 32-bit int scalar"; + } + n_additional_operands += 1; + } } else { assert(opcode == spv::Op::OpImageDrefGather || opcode == spv::Op::OpImageSparseDrefGather); if (spv_result_t result = ValidateImageDref(_, inst, info)) return result; } - if (spv_result_t result = - ValidateImageOperands(_, inst, info, /* word_index = */ 7)) + if (spv_result_t result = ValidateImageOperands( + _, inst, info, /* word_index = */ (7 + n_additional_operands))) return result; return SPV_SUCCESS; @@ -2689,6 +2708,7 @@ spv_result_t ImagePass(ValidationState_t& _, const Instruction* inst) { case spv::Op::OpImageDrefGather: case spv::Op::OpImageSparseGather: case spv::Op::OpImageSparseDrefGather: + case spv::Op::OpImageGatherQCOM: return ValidateImageGather(_, inst); case spv::Op::OpImageRead: @@ -2794,6 +2814,7 @@ bool IsImageInstruction(const spv::Op opcode) { case spv::Op::OpImageBlockMatchWindowSSDQCOM: case spv::Op::OpImageBlockMatchGatherSADQCOM: case spv::Op::OpImageBlockMatchGatherSSDQCOM: + case spv::Op::OpImageGatherQCOM: return true; default: break;