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

Method collapseAccessChain

SPIRV/SpvBuilder.cpp:4926–4965  ·  view source on GitHub ↗

Turn the described access chain in 'accessChain' into an instruction(s) computing its address. This *cannot* include complex swizzles, which must be handled after this is called. Can generate code.

Source from the content-addressed store, hash-verified

4924//
4925// Can generate code.
4926Id Builder::collapseAccessChain()
4927{
4928 assert(accessChain.isRValue == false);
4929
4930 // did we already emit an access chain for this?
4931 if (accessChain.instr != NoResult)
4932 return accessChain.instr;
4933
4934 // If we have a dynamic component, we can still transfer
4935 // that into a final operand to the access chain. We need to remap the
4936 // dynamic component through the swizzle to get a new dynamic component to
4937 // update.
4938 //
4939 // This was not done in transferAccessChainSwizzle() because it might
4940 // generate code.
4941 remapDynamicSwizzle();
4942 if (accessChain.component != NoResult) {
4943 // transfer the dynamic component to the access chain
4944 accessChain.indexChain.push_back(accessChain.component);
4945 accessChain.component = NoResult;
4946 }
4947
4948 // note that non-trivial swizzling is left pending
4949
4950 // do we have an access chain?
4951 if (accessChain.indexChain.size() == 0)
4952 return accessChain.base;
4953
4954 // emit the access chain
4955 StorageClass storageClass = (StorageClass)module.getStorageClass(getTypeId(accessChain.base));
4956 // when descHeap info is set, use another access chain process.
4957 if ((isUntypedPointer(accessChain.base) || accessChain.descHeapInfo.structRsrcTyOffsetCount!= 0) &&
4958 accessChain.descHeapInfo.descHeapStorageClass != StorageClass::Max) {
4959 accessChain.instr = createDescHeapAccessChain();
4960 } else {
4961 accessChain.instr = createAccessChain(storageClass, accessChain.base, accessChain.indexChain);
4962 }
4963
4964 return accessChain.instr;
4965}
4966
4967// For a dynamic component selection of a swizzle.
4968//

Callers

nothing calls this directly

Calls 3

push_backMethod · 0.45
sizeMethod · 0.45
getStorageClassMethod · 0.45

Tested by

no test coverage detected