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

Function ImageOperandsMaskInOperandIndex

source/opt/folding_rules.cpp:43–77  ·  view source on GitHub ↗

Some image instructions may contain an "image operands" argument. Returns the operand index for the "image operands". Returns -1 if the instruction does not have image operands.

Source from the content-addressed store, hash-verified

41// Returns the operand index for the "image operands".
42// Returns -1 if the instruction does not have image operands.
43int32_t ImageOperandsMaskInOperandIndex(Instruction* inst) {
44 const auto opcode = inst->opcode();
45 switch (opcode) {
46 case spv::Op::OpImageSampleImplicitLod:
47 case spv::Op::OpImageSampleExplicitLod:
48 case spv::Op::OpImageSampleProjImplicitLod:
49 case spv::Op::OpImageSampleProjExplicitLod:
50 case spv::Op::OpImageFetch:
51 case spv::Op::OpImageRead:
52 case spv::Op::OpImageSparseSampleImplicitLod:
53 case spv::Op::OpImageSparseSampleExplicitLod:
54 case spv::Op::OpImageSparseSampleProjImplicitLod:
55 case spv::Op::OpImageSparseSampleProjExplicitLod:
56 case spv::Op::OpImageSparseFetch:
57 case spv::Op::OpImageSparseRead:
58 return inst->NumOperands() > 4 ? 2 : -1;
59 case spv::Op::OpImageSampleDrefImplicitLod:
60 case spv::Op::OpImageSampleDrefExplicitLod:
61 case spv::Op::OpImageSampleProjDrefImplicitLod:
62 case spv::Op::OpImageSampleProjDrefExplicitLod:
63 case spv::Op::OpImageGather:
64 case spv::Op::OpImageDrefGather:
65 case spv::Op::OpImageSparseSampleDrefImplicitLod:
66 case spv::Op::OpImageSparseSampleDrefExplicitLod:
67 case spv::Op::OpImageSparseSampleProjDrefImplicitLod:
68 case spv::Op::OpImageSparseSampleProjDrefExplicitLod:
69 case spv::Op::OpImageSparseGather:
70 case spv::Op::OpImageSparseDrefGather:
71 return inst->NumOperands() > 5 ? 3 : -1;
72 case spv::Op::OpImageWrite:
73 return inst->NumOperands() > 3 ? 3 : -1;
74 default:
75 return -1;
76 }
77}
78
79// Returns the element width of |type|.
80uint32_t ElementWidth(const analysis::Type* type) {

Callers 1

UpdateImageOperandsFunction · 0.85

Calls 2

NumOperandsMethod · 0.80
opcodeMethod · 0.45

Tested by

no test coverage detected