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.
| 41 | // Returns the operand index for the "image operands". |
| 42 | // Returns -1 if the instruction does not have image operands. |
| 43 | int32_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|. |
| 80 | uint32_t ElementWidth(const analysis::Type* type) { |
no test coverage detected