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

Method accessChainStore

SPIRV/SpvBuilder.cpp:4652–4713  ·  view source on GitHub ↗

Comments in header

Source from the content-addressed store, hash-verified

4650
4651// Comments in header
4652void Builder::accessChainStore(Id rvalue, Decoration nonUniform, spv::MemoryAccessMask memoryAccess, spv::Scope scope, unsigned int alignment)
4653{
4654 assert(accessChain.isRValue == false);
4655
4656 transferAccessChainSwizzle(true);
4657
4658 // MeshShadingEXT outputs don't support loads, so split swizzled stores
4659 bool isMeshOutput = getStorageClass(accessChain.base) == StorageClass::Output &&
4660 capabilities.find(spv::Capability::MeshShadingEXT) != capabilities.end();
4661
4662 // If a swizzle exists and is not full and is not dynamic, then the swizzle will be broken into individual stores.
4663 if (accessChain.swizzle.size() > 0 &&
4664 ((getNumTypeComponents(getResultingAccessChainType()) != accessChain.swizzle.size() && accessChain.component == NoResult) || isMeshOutput)) {
4665 for (unsigned int i = 0; i < accessChain.swizzle.size(); ++i) {
4666 accessChain.indexChain.push_back(makeUintConstant(accessChain.swizzle[i]));
4667 accessChain.instr = NoResult;
4668
4669 Id base = collapseAccessChain();
4670 addDecoration(base, nonUniform);
4671
4672 accessChain.indexChain.pop_back();
4673 accessChain.instr = NoResult;
4674
4675 // dynamic component should be gone
4676 assert(accessChain.component == NoResult);
4677
4678 Id source = createCompositeExtract(rvalue, getContainedTypeId(getTypeId(rvalue)), i);
4679
4680 // take LSB of alignment
4681 alignment = alignment & ~(alignment & (alignment-1));
4682 if (getStorageClass(base) == StorageClass::PhysicalStorageBufferEXT) {
4683 memoryAccess = (spv::MemoryAccessMask)(memoryAccess | spv::MemoryAccessMask::Aligned);
4684 }
4685
4686 createStore(source, base, memoryAccess, scope, alignment);
4687 }
4688 }
4689 else {
4690 Id base = collapseAccessChain();
4691 addDecoration(base, nonUniform);
4692
4693 Id source = rvalue;
4694
4695 // dynamic component should be gone
4696 assert(accessChain.component == NoResult);
4697
4698 // If swizzle still exists, it may be out-of-order, we must load the target vector,
4699 // extract and insert elements to perform writeMask and/or swizzle.
4700 if (accessChain.swizzle.size() > 0) {
4701 Id tempBaseId = createLoad(base, spv::NoPrecision);
4702 source = createLvalueSwizzle(getTypeId(tempBaseId), tempBaseId, source, accessChain.swizzle);
4703 }
4704
4705 // take LSB of alignment
4706 alignment = alignment & ~(alignment & (alignment-1));
4707 if (getStorageClass(base) == StorageClass::PhysicalStorageBufferEXT) {
4708 memoryAccess = (spv::MemoryAccessMask)(memoryAccess | spv::MemoryAccessMask::Aligned);
4709 }

Callers

nothing calls this directly

Calls 5

endMethod · 0.80
pop_backMethod · 0.80
findMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected