SpirvShader: Make value names more consistent Rename Object::Kind::Value to Object::Kind::Intermediate. Rename SpirvRoutine::Value to SpirvRoutine::Variable. Change-Id: I1dba30687cbf979d80b0deeca7a96e64a88c94db Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28393 Presubmit-Ready: Ben Clayton <bclayton@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: Ben Clayton <bclayton@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Pipeline/ComputeProgram.cpp b/src/Pipeline/ComputeProgram.cpp index 293655a..fbaa2ac 100644 --- a/src/Pipeline/ComputeProgram.cpp +++ b/src/Pipeline/ComputeProgram.cpp
@@ -167,8 +167,7 @@ if (it != shader->inputBuiltins.end()) { const auto& builtin = it->second; - auto &value = routine.getValue(builtin.Id); - cb(builtin, value); + cb(builtin, routine.getVariable(builtin.Id)); } }
diff --git a/src/Pipeline/SpirvShader.cpp b/src/Pipeline/SpirvShader.cpp index 9a91e16..7a06ec2 100644 --- a/src/Pipeline/SpirvShader.cpp +++ b/src/Pipeline/SpirvShader.cpp
@@ -444,7 +444,7 @@ Object::ID resultId = insn.word(2); auto &object = defs[resultId]; object.type = typeId; - object.kind = Object::Kind::Value; + object.kind = Object::Kind::Intermediate; object.definition = insn; if (insn.opcode() == spv::OpAccessChain || insn.opcode() == spv::OpInBoundsAccessChain) @@ -829,7 +829,7 @@ // The <base> operand is an intermediate value itself, ie produced by a previous OpAccessChain. // Start with its offset and build from there. - if (baseObject.kind == Object::Kind::Value) + if (baseObject.kind == Object::Kind::Intermediate) { dynamicOffset += routine->getIntermediate(id).Int(0); } @@ -905,7 +905,7 @@ // The <base> operand is an intermediate value itself, ie produced by a previous OpAccessChain. // Start with its offset and build from there. - if (baseObject.kind == Object::Kind::Value) + if (baseObject.kind == Object::Kind::Intermediate) { dynamicOffset += routine->getIntermediate(id).Int(0); } @@ -1155,7 +1155,7 @@ if(pointeeType.sizeInComponents > 0) // TODO: what to do about zero-slot objects? { Object::ID resultId = insn.word(2); - routine->createLvalue(resultId, pointeeType.sizeInComponents); + routine->createVariable(resultId, pointeeType.sizeInComponents); } break; } @@ -1705,7 +1705,7 @@ { if (object.kind == Object::Kind::InterfaceVariable) { - auto &dst = routine->getValue(resultId); + auto &dst = routine->getVariable(resultId); int offset = 0; VisitInterface(resultId, [&](Decorations const &d, AttribType type) { @@ -1792,7 +1792,7 @@ } else { - ptrBase = &routine->getValue(pointer.pointerBase)[0]; + ptrBase = &routine->getVariable(pointer.pointerBase)[0]; } bool interleavedByLane = IsStorageInterleavedByLane(pointerBaseTy.storageClass); @@ -1800,10 +1800,10 @@ auto load = std::unique_ptr<SIMD::Float[]>(new SIMD::Float[resultTy.sizeInComponents]); - If(pointer.kind == Object::Kind::Value || anyInactiveLanes) + If(pointer.kind == Object::Kind::Intermediate || anyInactiveLanes) { // Divergent offsets or masked lanes. - auto offsets = pointer.kind == Object::Kind::Value ? + auto offsets = pointer.kind == Object::Kind::Intermediate ? As<SIMD::Int>(routine->getIntermediate(pointerId).Int(0)) : RValue<SIMD::Int>(SIMD::Int(0)); for (auto i = 0u; i < resultTy.sizeInComponents; i++) @@ -1886,7 +1886,7 @@ } else { - ptrBase = &routine->getValue(pointer.pointerBase)[0]; + ptrBase = &routine->getVariable(pointer.pointerBase)[0]; } bool interleavedByLane = IsStorageInterleavedByLane(pointerBaseTy.storageClass); @@ -1896,10 +1896,10 @@ { // Constant source data. auto src = reinterpret_cast<float *>(object.constantValue.get()); - If(pointer.kind == Object::Kind::Value || anyInactiveLanes) + If(pointer.kind == Object::Kind::Intermediate || anyInactiveLanes) { // Divergent offsets or masked lanes. - auto offsets = pointer.kind == Object::Kind::Value ? + auto offsets = pointer.kind == Object::Kind::Intermediate ? As<SIMD::Int>(routine->getIntermediate(pointerId).Int(0)) : RValue<SIMD::Int>(SIMD::Int(0)); for (auto i = 0u; i < elementTy.sizeInComponents; i++) @@ -1930,10 +1930,10 @@ { // Intermediate source data. auto &src = routine->getIntermediate(objectId); - If(pointer.kind == Object::Kind::Value || anyInactiveLanes) + If(pointer.kind == Object::Kind::Intermediate || anyInactiveLanes) { // Divergent offsets or masked lanes. - auto offsets = pointer.kind == Object::Kind::Value ? + auto offsets = pointer.kind == Object::Kind::Intermediate ? As<SIMD::Int>(routine->getIntermediate(pointerId).Int(0)) : RValue<SIMD::Int>(SIMD::Int(0)); for (auto i = 0u; i < elementTy.sizeInComponents; i++) @@ -3103,7 +3103,7 @@ auto &objectTy = getType(object.type); if (object.kind == Object::Kind::InterfaceVariable && objectTy.storageClass == spv::StorageClassOutput) { - auto &dst = routine->getValue(resultId); + auto &dst = routine->getVariable(resultId); int offset = 0; VisitInterface(resultId, [&](Decorations const &d, AttribType type) {
diff --git a/src/Pipeline/SpirvShader.hpp b/src/Pipeline/SpirvShader.hpp index f3602cd..0dda3d9 100644 --- a/src/Pipeline/SpirvShader.hpp +++ b/src/Pipeline/SpirvShader.hpp
@@ -242,7 +242,7 @@ Variable, // TODO: Document InterfaceVariable, // TODO: Document Constant, // Values held by Object::constantValue - Value, // Values held by SpirvRoutine::intermediates + Intermediate, // Values held by SpirvRoutine::intermediates PhysicalPointer, // Pointer held by SpirvRoutine::physicalPointers } kind = Kind::Unknown; }; @@ -647,28 +647,28 @@ public: SpirvRoutine(vk::PipelineLayout const *pipelineLayout); - using Value = Array<SIMD::Float>; + using Variable = Array<SIMD::Float>; vk::PipelineLayout const * const pipelineLayout; - std::unordered_map<SpirvShader::Object::ID, Value> lvalues; + std::unordered_map<SpirvShader::Object::ID, Variable> variables; std::unordered_map<SpirvShader::Object::ID, Intermediate> intermediates; std::unordered_map<SpirvShader::Object::ID, Pointer<Byte> > physicalPointers; - Value inputs = Value{MAX_INTERFACE_COMPONENTS}; - Value outputs = Value{MAX_INTERFACE_COMPONENTS}; + Variable inputs = Variable{MAX_INTERFACE_COMPONENTS}; + Variable outputs = Variable{MAX_INTERFACE_COMPONENTS}; Pointer<Pointer<Byte>> descriptorSets; Pointer<Int> descriptorDynamicOffsets; Pointer<Byte> pushConstants; Int killMask = Int{0}; - void createLvalue(SpirvShader::Object::ID id, uint32_t size) + void createVariable(SpirvShader::Object::ID id, uint32_t size) { - bool added = lvalues.emplace(id, Value(size)).second; - ASSERT_MSG(added, "Value %d created twice", id.value()); + bool added = variables.emplace(id, Variable(size)).second; + ASSERT_MSG(added, "Variable %d created twice", id.value()); } Intermediate& createIntermediate(SpirvShader::Object::ID id, uint32_t size) @@ -680,10 +680,10 @@ return it.first->second; } - Value& getValue(SpirvShader::Object::ID id) + Variable& getVariable(SpirvShader::Object::ID id) { - auto it = lvalues.find(id); - ASSERT_MSG(it != lvalues.end(), "Unknown value %d", id.value()); + auto it = variables.find(id); + ASSERT_MSG(it != variables.end(), "Unknown variables %d", id.value()); return it->second; } @@ -715,7 +715,7 @@ public: GenericValue(SpirvShader const *shader, SpirvRoutine const *routine, SpirvShader::Object::ID objId) : obj(shader->getObject(objId)), - intermediate(obj.kind == SpirvShader::Object::Kind::Value ? &routine->getIntermediate(objId) : nullptr) {} + intermediate(obj.kind == SpirvShader::Object::Kind::Intermediate ? &routine->getIntermediate(objId) : nullptr) {} RValue<SIMD::Float> Float(uint32_t i) const {
diff --git a/src/Pipeline/VertexProgram.cpp b/src/Pipeline/VertexProgram.cpp index a11c80b..f5ea229 100644 --- a/src/Pipeline/VertexProgram.cpp +++ b/src/Pipeline/VertexProgram.cpp
@@ -42,7 +42,7 @@ { // TODO: we could do better here; we know InstanceIndex is uniform across all lanes assert(it->second.SizeInComponents == 1); - routine.getValue(it->second.Id)[it->second.FirstComponent] = + routine.getVariable(it->second.Id)[it->second.FirstComponent] = As<Float4>(Int4((*Pointer<Int>(data + OFFSET(DrawData, instanceID))))); } @@ -65,7 +65,7 @@ if (it != spirvShader->inputBuiltins.end()) { assert(it->second.SizeInComponents == 1); - routine.getValue(it->second.Id)[it->second.FirstComponent] = + routine.getVariable(it->second.Id)[it->second.FirstComponent] = As<Float4>(Int4(index) + Int4(0, 1, 2, 3)); }
diff --git a/src/Pipeline/VertexRoutine.cpp b/src/Pipeline/VertexRoutine.cpp index df2c813..396b319 100644 --- a/src/Pipeline/VertexRoutine.cpp +++ b/src/Pipeline/VertexRoutine.cpp
@@ -109,7 +109,7 @@ auto it = spirvShader->outputBuiltins.find(spv::BuiltInPosition); assert(it != spirvShader->outputBuiltins.end()); assert(it->second.SizeInComponents == 4); - auto &pos = routine.getValue(it->second.Id); + auto &pos = routine.getVariable(it->second.Id); auto posX = pos[it->second.FirstComponent]; auto posY = pos[it->second.FirstComponent + 1]; auto posZ = pos[it->second.FirstComponent + 2]; @@ -525,7 +525,7 @@ auto it = spirvShader->outputBuiltins.find(spv::BuiltInPosition); assert(it != spirvShader->outputBuiltins.end()); assert(it->second.SizeInComponents == 4); - auto &pos = routine.getValue(it->second.Id); + auto &pos = routine.getVariable(it->second.Id); auto posX = pos[it->second.FirstComponent]; auto posY = pos[it->second.FirstComponent + 1]; auto posZ = pos[it->second.FirstComponent + 2]; @@ -564,7 +564,7 @@ if (it != spirvShader->outputBuiltins.end()) { assert(it->second.SizeInComponents == 1); - auto psize = routine.getValue(it->second.Id)[it->second.FirstComponent]; + auto psize = routine.getVariable(it->second.Id)[it->second.FirstComponent]; *Pointer<Float>(cacheLine + OFFSET(Vertex,builtins.pointSize) + sizeof(Vertex) * 0) = Extract(psize, 0); *Pointer<Float>(cacheLine + OFFSET(Vertex,builtins.pointSize) + sizeof(Vertex) * 1) = Extract(psize, 1); *Pointer<Float>(cacheLine + OFFSET(Vertex,builtins.pointSize) + sizeof(Vertex) * 2) = Extract(psize, 2);