Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ vars = {

're2_revision': '972a15cedd008d846f1a39b2e88ce48d7f166cbd',

'spirv_headers_revision': '58006c901d1d5c37dece6b6610e9af87fa951375',
'spirv_headers_revision': 'c07e08097821b2894892fc7a1157c23eccdde657',

'mimalloc_revision': 'fef6b0dd70f9d7fa0750b0d0b9fbb471203b94cd',
}
Expand Down
7 changes: 5 additions & 2 deletions include/spirv-tools/libspirv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions source/operand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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:
Expand Down
39 changes: 30 additions & 9 deletions source/val/validate_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand All @@ -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";
Expand Down Expand Up @@ -908,7 +910,9 @@ bool IsSparse(spv::Op opcode) {
return true;
}

default: { return false; }
default: {
return false;
}
}

return false;
Expand Down Expand Up @@ -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:
Expand All @@ -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 ||
Expand Down Expand Up @@ -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 <id> "
<< _.getIdName(inst->id()) << " as an operand of <id> "
<< _.getIdName(consumer_instr->id()) << ".";
<< "OpTypeSampledImage."
<< " Found result <id> " << _.getIdName(inst->id())
<< " as an operand of <id> " << _.getIdName(consumer_instr->id())
<< ".";
}
}
}
Expand Down Expand Up @@ -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<uint32_t>(4);
const uint32_t component_index_type = _.GetTypeId(component);
if (!_.IsIntScalarType(component_index_type, 32)) {
Expand All @@ -1869,14 +1878,24 @@ spv_result_t ValidateImageGather(ValidationState_t& _,
"environment";
}
}
if (opcode == spv::Op::OpImageGatherQCOM) {
const uint32_t mode = inst->GetOperandAs<uint32_t>(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;
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down
Loading