Called for each instruction that resides in a block.
| 247 | |
| 248 | // Called for each instruction that resides in a block. |
| 249 | void Builder::postProcess(Instruction& inst) |
| 250 | { |
| 251 | // Add capabilities based simply on the opcode. |
| 252 | switch (inst.getOpCode()) { |
| 253 | case Op::OpExtInst: |
| 254 | switch (inst.getImmediateOperand(1)) { |
| 255 | case GLSLstd450InterpolateAtCentroid: |
| 256 | case GLSLstd450InterpolateAtSample: |
| 257 | case GLSLstd450InterpolateAtOffset: |
| 258 | addCapability(Capability::InterpolationFunction); |
| 259 | break; |
| 260 | default: |
| 261 | break; |
| 262 | } |
| 263 | break; |
| 264 | case Op::OpDPdxFine: |
| 265 | case Op::OpDPdyFine: |
| 266 | case Op::OpFwidthFine: |
| 267 | case Op::OpDPdxCoarse: |
| 268 | case Op::OpDPdyCoarse: |
| 269 | case Op::OpFwidthCoarse: |
| 270 | addCapability(Capability::DerivativeControl); |
| 271 | break; |
| 272 | |
| 273 | case Op::OpImageQueryLod: |
| 274 | case Op::OpImageQuerySize: |
| 275 | case Op::OpImageQuerySizeLod: |
| 276 | case Op::OpImageQuerySamples: |
| 277 | case Op::OpImageQueryLevels: |
| 278 | addCapability(Capability::ImageQuery); |
| 279 | break; |
| 280 | |
| 281 | case Op::OpGroupNonUniformPartitionNV: |
| 282 | addExtension(E_SPV_NV_shader_subgroup_partitioned); |
| 283 | addCapability(Capability::GroupNonUniformPartitionedNV); |
| 284 | break; |
| 285 | |
| 286 | case Op::OpLoad: |
| 287 | case Op::OpStore: |
| 288 | { |
| 289 | // For any load/store to a PhysicalStorageBufferEXT, walk the accesschain |
| 290 | // index list to compute the misalignment. The pre-existing alignment value |
| 291 | // (set via Builder::AccessChain::alignment) only accounts for the base of |
| 292 | // the reference type and any scalar component selection in the accesschain, |
| 293 | // and this function computes the rest from the SPIR-V Offset decorations. |
| 294 | Instruction *accessChain = module.getInstruction(inst.getIdOperand(0)); |
| 295 | if (accessChain->getOpCode() == Op::OpAccessChain) { |
| 296 | const Instruction* base = module.getInstruction(accessChain->getIdOperand(0)); |
| 297 | // Get the type of the base of the access chain. It must be a pointer type. |
| 298 | Id typeId = base->getTypeId(); |
| 299 | Instruction *type = module.getInstruction(typeId); |
| 300 | assert(type->getOpCode() == Op::OpTypePointer); |
| 301 | if (type->getImmediateOperand(0) != StorageClass::PhysicalStorageBuffer) { |
| 302 | break; |
| 303 | } |
| 304 | // Get the pointee type. |
| 305 | typeId = type->getIdOperand(1); |
| 306 | type = module.getInstruction(typeId); |
no test coverage detected