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

Method addImageFunctions

glslang/MachineIndependent/Initialize.cpp:7613–7835  ·  view source on GitHub ↗

Helper function for add2ndGenerationSamplingImaging(), when adding context-independent built-in functions. Add all the image access functions for the given type.

Source from the content-addressed store, hash-verified

7611// Add all the image access functions for the given type.
7612//
7613void TBuiltIns::addImageFunctions(TSampler sampler, const TString& typeName, int version, EProfile profile)
7614{
7615 int dims = dimMap[sampler.dim];
7616 // most things with an array add a dimension, except for cubemaps
7617 if (sampler.arrayed && sampler.dim != EsdCube)
7618 ++dims;
7619
7620 TString imageParams = typeName;
7621 if (dims == 1)
7622 imageParams.append(", int");
7623 else {
7624 imageParams.append(", ivec");
7625 imageParams.append(postfixes[dims]);
7626 }
7627 if (sampler.isMultiSample())
7628 imageParams.append(", int");
7629
7630 if (profile == EEsProfile)
7631 commonBuiltins.append("highp ");
7632 commonBuiltins.append(prefixes[sampler.type]);
7633 commonBuiltins.append("vec4 imageLoad(readonly volatile coherent nontemporal ");
7634 commonBuiltins.append(imageParams);
7635 commonBuiltins.append(");\n");
7636
7637 commonBuiltins.append("void imageStore(writeonly volatile coherent nontemporal ");
7638 commonBuiltins.append(imageParams);
7639 commonBuiltins.append(", ");
7640 commonBuiltins.append(prefixes[sampler.type]);
7641 commonBuiltins.append("vec4);\n");
7642
7643 if (! sampler.is1D() && ! sampler.isBuffer() && profile != EEsProfile && version >= 450) {
7644 commonBuiltins.append("int sparseImageLoadARB(readonly volatile coherent nontemporal ");
7645 commonBuiltins.append(imageParams);
7646 commonBuiltins.append(", out ");
7647 commonBuiltins.append(prefixes[sampler.type]);
7648 commonBuiltins.append("vec4");
7649 commonBuiltins.append(");\n");
7650 }
7651
7652 if ( profile != EEsProfile ||
7653 (profile == EEsProfile && version >= 310)) {
7654 if (sampler.type == EbtInt || sampler.type == EbtUint || sampler.type == EbtInt64 || sampler.type == EbtUint64 ) {
7655
7656 const char* dataType;
7657 switch (sampler.type) {
7658 case(EbtInt): dataType = "highp int"; break;
7659 case(EbtUint): dataType = "highp uint"; break;
7660 case(EbtInt64): dataType = "highp int64_t"; break;
7661 case(EbtUint64): dataType = "highp uint64_t"; break;
7662 default: dataType = "";
7663 }
7664
7665 const int numBuiltins = 7;
7666
7667 static const char* atomicFunc[numBuiltins] = {
7668 " imageAtomicAdd(volatile coherent nontemporal ",
7669 " imageAtomicMin(volatile coherent nontemporal ",
7670 " imageAtomicMax(volatile coherent nontemporal ",

Callers

nothing calls this directly

Calls 4

appendMethod · 0.80
isMultiSampleMethod · 0.80
is1DMethod · 0.80
isBufferMethod · 0.80

Tested by

no test coverage detected