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

Method createTextureCall

SPIRV/SpvBuilder.cpp:3772–3989  ·  view source on GitHub ↗

Accept all parameters needed to create a texture instruction. Create the correct instruction based on the inputs, and make the call.

Source from the content-addressed store, hash-verified

3770// Accept all parameters needed to create a texture instruction.
3771// Create the correct instruction based on the inputs, and make the call.
3772Id Builder::createTextureCall(Decoration precision, Id resultType, bool sparse, bool fetch, bool proj, bool gather,
3773 bool noImplicitLod, const TextureParameters& parameters, ImageOperandsMask signExtensionMask)
3774{
3775 std::vector<Id> texArgs;
3776
3777 //
3778 // Set up the fixed arguments
3779 //
3780 bool explicitLod = false;
3781 texArgs.push_back(parameters.sampler);
3782 texArgs.push_back(parameters.coords);
3783 if (parameters.Dref != NoResult)
3784 texArgs.push_back(parameters.Dref);
3785 if (parameters.component != NoResult)
3786 texArgs.push_back(parameters.component);
3787
3788 if (parameters.granularity != NoResult)
3789 texArgs.push_back(parameters.granularity);
3790 if (parameters.coarse != NoResult)
3791 texArgs.push_back(parameters.coarse);
3792
3793 //
3794 // Set up the optional arguments
3795 //
3796 size_t optArgNum = texArgs.size(); // the position of the mask for the optional arguments, if any.
3797 ImageOperandsMask mask = ImageOperandsMask::MaskNone; // the mask operand
3798 if (parameters.bias) {
3799 mask = (ImageOperandsMask)(mask | ImageOperandsMask::Bias);
3800 texArgs.push_back(parameters.bias);
3801 }
3802 if (parameters.lod) {
3803 mask = (ImageOperandsMask)(mask | ImageOperandsMask::Lod);
3804 texArgs.push_back(parameters.lod);
3805 explicitLod = true;
3806 } else if (parameters.gradX) {
3807 mask = (ImageOperandsMask)(mask | ImageOperandsMask::Grad);
3808 texArgs.push_back(parameters.gradX);
3809 texArgs.push_back(parameters.gradY);
3810 explicitLod = true;
3811 } else if (noImplicitLod && ! fetch && ! gather) {
3812 // have to explicitly use lod of 0 if not allowed to have them be implicit, and
3813 // we would otherwise be about to issue an implicit instruction
3814 mask = (ImageOperandsMask)(mask | ImageOperandsMask::Lod);
3815 texArgs.push_back(makeFloatConstant(0.0));
3816 explicitLod = true;
3817 }
3818 if (parameters.offset) {
3819 if (isConstant(parameters.offset))
3820 mask = (ImageOperandsMask)(mask | ImageOperandsMask::ConstOffset);
3821 else {
3822 addCapability(Capability::ImageGatherExtended);
3823 mask = (ImageOperandsMask)(mask | ImageOperandsMask::Offset);
3824 }
3825 texArgs.push_back(parameters.offset);
3826 }
3827 if (parameters.offsets) {
3828 if (!isConstant(parameters.offsets) && sourceLang == spv::SourceLanguage::GLSL) {
3829 mask = (ImageOperandsMask)(mask | ImageOperandsMask::Offsets);

Callers 1

Calls 8

beginMethod · 0.80
reserveOperandsMethod · 0.80
addIdOperandMethod · 0.80
addImmediateOperandMethod · 0.80
getResultIdMethod · 0.80
push_backMethod · 0.45
sizeMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected