MCPcopy Create free account
hub / github.com/KhronosGroup/glslang / makeImageType

Method makeImageType

SPIRV/SpvBuilder.cpp:825–912  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

823}
824
825Id Builder::makeImageType(Id sampledType, Dim dim, bool depth, bool arrayed, bool ms, unsigned sampled,
826 ImageFormat format, const char* debugName)
827{
828 assert(sampled == 1 || sampled == 2);
829
830 // try to find it
831 Instruction* type;
832 for (int t = 0; t < (int)groupedTypes[enumCast(Op::OpTypeImage)].size(); ++t) {
833 type = groupedTypes[enumCast(Op::OpTypeImage)][t];
834 if (type->getIdOperand(0) == sampledType &&
835 type->getImmediateOperand(1) == (unsigned int)dim &&
836 type->getImmediateOperand(2) == ( depth ? 1u : 0u) &&
837 type->getImmediateOperand(3) == (arrayed ? 1u : 0u) &&
838 type->getImmediateOperand(4) == ( ms ? 1u : 0u) &&
839 type->getImmediateOperand(5) == sampled &&
840 type->getImmediateOperand(6) == (unsigned int)format)
841 return type->getResultId();
842 }
843
844 // not found, make it
845 type = new Instruction(getUniqueId(), NoType, Op::OpTypeImage);
846 type->reserveOperands(7);
847 type->addIdOperand(sampledType);
848 type->addImmediateOperand( dim);
849 type->addImmediateOperand( depth ? 1 : 0);
850 type->addImmediateOperand(arrayed ? 1 : 0);
851 type->addImmediateOperand( ms ? 1 : 0);
852 type->addImmediateOperand(sampled);
853 type->addImmediateOperand((unsigned int)format);
854
855 groupedTypes[enumCast(Op::OpTypeImage)].push_back(type);
856 constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
857 module.mapInstruction(type);
858
859 // deal with capabilities
860 switch (dim) {
861 case Dim::Buffer:
862 if (sampled == 1)
863 addCapability(Capability::SampledBuffer);
864 else
865 addCapability(Capability::ImageBuffer);
866 break;
867 case Dim::Dim1D:
868 if (sampled == 1)
869 addCapability(Capability::Sampled1D);
870 else
871 addCapability(Capability::Image1D);
872 break;
873 case Dim::Cube:
874 if (arrayed) {
875 if (sampled == 1)
876 addCapability(Capability::SampledCubeArray);
877 else
878 addCapability(Capability::ImageCubeArray);
879 }
880 break;
881 case Dim::Rect:
882 if (sampled == 1)

Callers 1

Calls 10

enumCastFunction · 0.85
getImmediateOperandMethod · 0.80
getResultIdMethod · 0.80
reserveOperandsMethod · 0.80
addIdOperandMethod · 0.80
addImmediateOperandMethod · 0.80
mapInstructionMethod · 0.80
sizeMethod · 0.45
getIdOperandMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected