Commit af973b67 by Ben Clayton

SpirvShader: ObjectID -> Object::ID, TypeID -> Type::ID.

Minor bit of refactoring to reduce the number of SpirvShader child typenames. Bug: b/126126820 Change-Id: I0a3ae5f10b34eac2ae648ccf5f4b15c67bca0a13 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/27094 Presubmit-Ready: Ben Clayton <bclayton@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com>
parent 3ebf583c
...@@ -66,7 +66,7 @@ namespace sw ...@@ -66,7 +66,7 @@ namespace sw
case spv::OpMemberDecorate: case spv::OpMemberDecorate:
{ {
TypeID targetId = insn.word(1); Type::ID targetId = insn.word(1);
auto memberIndex = insn.word(2); auto memberIndex = insn.word(2);
auto &d = memberDecorations[targetId]; auto &d = memberDecorations[targetId];
if (memberIndex >= d.size()) if (memberIndex >= d.size())
...@@ -144,8 +144,8 @@ namespace sw ...@@ -144,8 +144,8 @@ namespace sw
case spv::OpVariable: case spv::OpVariable:
{ {
TypeID typeId = insn.word(1); Type::ID typeId = insn.word(1);
ObjectID resultId = insn.word(2); Object::ID resultId = insn.word(2);
auto storageClass = static_cast<spv::StorageClass>(insn.word(3)); auto storageClass = static_cast<spv::StorageClass>(insn.word(3));
if (insn.wordCount() > 4) if (insn.wordCount() > 4)
UNIMPLEMENTED("Variable initializers not yet supported"); UNIMPLEMENTED("Variable initializers not yet supported");
...@@ -341,8 +341,8 @@ namespace sw ...@@ -341,8 +341,8 @@ namespace sw
case spv::OpVectorTimesScalar: case spv::OpVectorTimesScalar:
// Instructions that yield an intermediate value // Instructions that yield an intermediate value
{ {
TypeID typeId = insn.word(1); Type::ID typeId = insn.word(1);
ObjectID resultId = insn.word(2); Object::ID resultId = insn.word(2);
auto &object = defs[resultId]; auto &object = defs[resultId];
object.type = typeId; object.type = typeId;
object.kind = Object::Kind::Value; object.kind = Object::Kind::Value;
...@@ -353,7 +353,7 @@ namespace sw ...@@ -353,7 +353,7 @@ namespace sw
// interior ptr has two parts: // interior ptr has two parts:
// - logical base ptr, common across all lanes and known at compile time // - logical base ptr, common across all lanes and known at compile time
// - per-lane offset // - per-lane offset
ObjectID baseId = insn.word(3); Object::ID baseId = insn.word(3);
object.pointerBase = getObject(baseId).pointerBase; object.pointerBase = getObject(baseId).pointerBase;
} }
break; break;
...@@ -375,7 +375,7 @@ namespace sw ...@@ -375,7 +375,7 @@ namespace sw
void SpirvShader::DeclareType(InsnIterator insn) void SpirvShader::DeclareType(InsnIterator insn)
{ {
TypeID resultId = insn.word(1); Type::ID resultId = insn.word(1);
auto &type = types[resultId]; auto &type = types[resultId];
type.definition = insn; type.definition = insn;
...@@ -403,7 +403,7 @@ namespace sw ...@@ -403,7 +403,7 @@ namespace sw
} }
case spv::OpTypePointer: case spv::OpTypePointer:
{ {
TypeID elementTypeId = insn.word(3); Type::ID elementTypeId = insn.word(3);
type.element = elementTypeId; type.element = elementTypeId;
type.isBuiltInBlock = getType(elementTypeId).isBuiltInBlock; type.isBuiltInBlock = getType(elementTypeId).isBuiltInBlock;
type.storageClass = static_cast<spv::StorageClass>(insn.word(2)); type.storageClass = static_cast<spv::StorageClass>(insn.word(2));
...@@ -414,7 +414,7 @@ namespace sw ...@@ -414,7 +414,7 @@ namespace sw
case spv::OpTypeArray: case spv::OpTypeArray:
case spv::OpTypeRuntimeArray: case spv::OpTypeRuntimeArray:
{ {
TypeID elementTypeId = insn.word(2); Type::ID elementTypeId = insn.word(2);
type.element = elementTypeId; type.element = elementTypeId;
break; break;
} }
...@@ -425,8 +425,8 @@ namespace sw ...@@ -425,8 +425,8 @@ namespace sw
SpirvShader::Object& SpirvShader::CreateConstant(InsnIterator insn) SpirvShader::Object& SpirvShader::CreateConstant(InsnIterator insn)
{ {
TypeID typeId = insn.word(1); Type::ID typeId = insn.word(1);
ObjectID resultId = insn.word(2); Object::ID resultId = insn.word(2);
auto &object = defs[resultId]; auto &object = defs[resultId];
auto &objectTy = getType(typeId); auto &objectTy = getType(typeId);
object.type = typeId; object.type = typeId;
...@@ -448,7 +448,7 @@ namespace sw ...@@ -448,7 +448,7 @@ namespace sw
auto &userDefinedInterface = (objectTy.storageClass == spv::StorageClassInput) ? inputs : outputs; auto &userDefinedInterface = (objectTy.storageClass == spv::StorageClassInput) ? inputs : outputs;
ASSERT(object.definition.opcode() == spv::OpVariable); ASSERT(object.definition.opcode() == spv::OpVariable);
ObjectID resultId = object.definition.word(2); Object::ID resultId = object.definition.word(2);
if (objectTy.isBuiltInBlock) if (objectTy.isBuiltInBlock)
{ {
...@@ -602,7 +602,7 @@ namespace sw ...@@ -602,7 +602,7 @@ namespace sw
} }
template<typename F> template<typename F>
int SpirvShader::VisitInterfaceInner(TypeID id, Decorations d, F f) const int SpirvShader::VisitInterfaceInner(Type::ID id, Decorations d, F f) const
{ {
// Recursively walks variable definition and its type tree, taking into account // Recursively walks variable definition and its type tree, taking into account
// any explicit Location or Component decorations encountered; where explicit // any explicit Location or Component decorations encountered; where explicit
...@@ -673,7 +673,7 @@ namespace sw ...@@ -673,7 +673,7 @@ namespace sw
} }
template<typename F> template<typename F>
void SpirvShader::VisitInterface(ObjectID id, F f) const void SpirvShader::VisitInterface(Object::ID id, F f) const
{ {
// Walk a variable definition and call f for each component in it. // Walk a variable definition and call f for each component in it.
Decorations d{}; Decorations d{};
...@@ -684,7 +684,7 @@ namespace sw ...@@ -684,7 +684,7 @@ namespace sw
VisitInterfaceInner<F>(def.word(1), d, f); VisitInterfaceInner<F>(def.word(1), d, f);
} }
SIMD::Int SpirvShader::WalkAccessChain(ObjectID id, uint32_t numIndexes, uint32_t const *indexIds, SpirvRoutine *routine) const SIMD::Int SpirvShader::WalkAccessChain(Object::ID id, uint32_t numIndexes, uint32_t const *indexIds, SpirvRoutine *routine) const
{ {
// TODO: think about explicit layout (UBO/SSBO) storage classes // TODO: think about explicit layout (UBO/SSBO) storage classes
// TODO: avoid doing per-lane work in some cases if we can? // TODO: avoid doing per-lane work in some cases if we can?
...@@ -692,7 +692,7 @@ namespace sw ...@@ -692,7 +692,7 @@ namespace sw
int constantOffset = 0; int constantOffset = 0;
SIMD::Int dynamicOffset = SIMD::Int(0); SIMD::Int dynamicOffset = SIMD::Int(0);
auto &baseObject = getObject(id); auto &baseObject = getObject(id);
TypeID typeId = getType(baseObject.type).element; Type::ID typeId = getType(baseObject.type).element;
// The <base> operand is an intermediate value itself, ie produced by a previous OpAccessChain. // The <base> operand is an intermediate value itself, ie produced by a previous OpAccessChain.
// Start with its offset and build from there. // Start with its offset and build from there.
...@@ -743,7 +743,7 @@ namespace sw ...@@ -743,7 +743,7 @@ namespace sw
return dynamicOffset + SIMD::Int(constantOffset); return dynamicOffset + SIMD::Int(constantOffset);
} }
uint32_t SpirvShader::WalkLiteralAccessChain(TypeID typeId, uint32_t numIndexes, uint32_t const *indexes) const uint32_t SpirvShader::WalkLiteralAccessChain(Type::ID typeId, uint32_t numIndexes, uint32_t const *indexes) const
{ {
uint32_t constantOffset = 0; uint32_t constantOffset = 0;
...@@ -906,7 +906,7 @@ namespace sw ...@@ -906,7 +906,7 @@ namespace sw
d->Apply(it->second); d->Apply(it->second);
} }
void SpirvShader::ApplyDecorationsForIdMember(Decorations *d, TypeID id, uint32_t member) const void SpirvShader::ApplyDecorationsForIdMember(Decorations *d, Type::ID id, uint32_t member) const
{ {
auto it = memberDecorations.find(id); auto it = memberDecorations.find(id);
if (it != memberDecorations.end() && member < it->second.size()) if (it != memberDecorations.end() && member < it->second.size())
...@@ -915,7 +915,7 @@ namespace sw ...@@ -915,7 +915,7 @@ namespace sw
} }
} }
uint32_t SpirvShader::GetConstantInt(ObjectID id) const uint32_t SpirvShader::GetConstantInt(Object::ID id) const
{ {
// Slightly hackish access to constants very early in translation. // Slightly hackish access to constants very early in translation.
// General consumption of constants by other instructions should // General consumption of constants by other instructions should
...@@ -939,7 +939,7 @@ namespace sw ...@@ -939,7 +939,7 @@ namespace sw
{ {
case spv::OpVariable: case spv::OpVariable:
{ {
ObjectID resultId = insn.word(2); Object::ID resultId = insn.word(2);
auto &object = getObject(resultId); auto &object = getObject(resultId);
auto &objectTy = getType(object.type); auto &objectTy = getType(object.type);
auto &pointeeTy = getType(objectTy.element); auto &pointeeTy = getType(objectTy.element);
...@@ -1140,7 +1140,7 @@ namespace sw ...@@ -1140,7 +1140,7 @@ namespace sw
void SpirvShader::EmitVariable(InsnIterator insn, SpirvRoutine *routine) const void SpirvShader::EmitVariable(InsnIterator insn, SpirvRoutine *routine) const
{ {
ObjectID resultId = insn.word(2); Object::ID resultId = insn.word(2);
auto &object = getObject(resultId); auto &object = getObject(resultId);
auto &objectTy = getType(object.type); auto &objectTy = getType(object.type);
switch (objectTy.storageClass) switch (objectTy.storageClass)
...@@ -1185,8 +1185,8 @@ namespace sw ...@@ -1185,8 +1185,8 @@ namespace sw
void SpirvShader::EmitLoad(InsnIterator insn, SpirvRoutine *routine) const void SpirvShader::EmitLoad(InsnIterator insn, SpirvRoutine *routine) const
{ {
ObjectID objectId = insn.word(2); Object::ID objectId = insn.word(2);
ObjectID pointerId = insn.word(3); Object::ID pointerId = insn.word(3);
auto &object = getObject(objectId); auto &object = getObject(objectId);
auto &objectTy = getType(object.type); auto &objectTy = getType(object.type);
auto &pointer = getObject(pointerId); auto &pointer = getObject(pointerId);
...@@ -1194,7 +1194,7 @@ namespace sw ...@@ -1194,7 +1194,7 @@ namespace sw
auto &pointerBaseTy = getType(pointerBase.type); auto &pointerBaseTy = getType(pointerBase.type);
ASSERT(getType(pointer.type).element == object.type); ASSERT(getType(pointer.type).element == object.type);
ASSERT(TypeID(insn.word(1)) == object.type); ASSERT(Type::ID(insn.word(1)) == object.type);
if (pointerBaseTy.storageClass == spv::StorageClassImage) if (pointerBaseTy.storageClass == spv::StorageClassImage)
{ {
...@@ -1253,9 +1253,9 @@ namespace sw ...@@ -1253,9 +1253,9 @@ namespace sw
void SpirvShader::EmitAccessChain(InsnIterator insn, SpirvRoutine *routine) const void SpirvShader::EmitAccessChain(InsnIterator insn, SpirvRoutine *routine) const
{ {
TypeID typeId = insn.word(1); Type::ID typeId = insn.word(1);
ObjectID objectId = insn.word(2); Object::ID objectId = insn.word(2);
ObjectID baseId = insn.word(3); Object::ID baseId = insn.word(3);
auto &type = getType(typeId); auto &type = getType(typeId);
ASSERT(type.sizeInComponents == 1); ASSERT(type.sizeInComponents == 1);
ASSERT(getObject(baseId).pointerBase == getObject(objectId).pointerBase); ASSERT(getObject(baseId).pointerBase == getObject(objectId).pointerBase);
...@@ -1266,8 +1266,8 @@ namespace sw ...@@ -1266,8 +1266,8 @@ namespace sw
void SpirvShader::EmitStore(InsnIterator insn, SpirvRoutine *routine) const void SpirvShader::EmitStore(InsnIterator insn, SpirvRoutine *routine) const
{ {
ObjectID pointerId = insn.word(1); Object::ID pointerId = insn.word(1);
ObjectID objectId = insn.word(2); Object::ID objectId = insn.word(2);
auto &object = getObject(objectId); auto &object = getObject(objectId);
auto &pointer = getObject(pointerId); auto &pointer = getObject(pointerId);
auto &pointerTy = getType(pointer.type); auto &pointerTy = getType(pointer.type);
...@@ -1367,7 +1367,7 @@ namespace sw ...@@ -1367,7 +1367,7 @@ namespace sw
for (auto i = 0u; i < insn.wordCount() - 3; i++) for (auto i = 0u; i < insn.wordCount() - 3; i++)
{ {
ObjectID srcObjectId = insn.word(3u + i); Object::ID srcObjectId = insn.word(3u + i);
auto & srcObject = getObject(srcObjectId); auto & srcObject = getObject(srcObjectId);
auto & srcObjectTy = getType(srcObject.type); auto & srcObjectTy = getType(srcObject.type);
GenericValue srcObjectAccess(this, routine, srcObjectId); GenericValue srcObjectAccess(this, routine, srcObjectId);
...@@ -1381,7 +1381,7 @@ namespace sw ...@@ -1381,7 +1381,7 @@ namespace sw
void SpirvShader::EmitCompositeInsert(InsnIterator insn, SpirvRoutine *routine) const void SpirvShader::EmitCompositeInsert(InsnIterator insn, SpirvRoutine *routine) const
{ {
TypeID resultTypeId = insn.word(1); Type::ID resultTypeId = insn.word(1);
auto &type = getType(resultTypeId); auto &type = getType(resultTypeId);
auto &dst = routine->createIntermediate(insn.word(2), type.sizeInComponents); auto &dst = routine->createIntermediate(insn.word(2), type.sizeInComponents);
auto &newPartObject = getObject(insn.word(3)); auto &newPartObject = getObject(insn.word(3));
...@@ -1413,7 +1413,7 @@ namespace sw ...@@ -1413,7 +1413,7 @@ namespace sw
auto &type = getType(insn.word(1)); auto &type = getType(insn.word(1));
auto &dst = routine->createIntermediate(insn.word(2), type.sizeInComponents); auto &dst = routine->createIntermediate(insn.word(2), type.sizeInComponents);
auto &compositeObject = getObject(insn.word(3)); auto &compositeObject = getObject(insn.word(3));
TypeID compositeTypeId = compositeObject.definition.word(1); Type::ID compositeTypeId = compositeObject.definition.word(1);
auto firstComponent = WalkLiteralAccessChain(compositeTypeId, insn.wordCount() - 4, insn.wordPointer(4)); auto firstComponent = WalkLiteralAccessChain(compositeTypeId, insn.wordCount() - 4, insn.wordPointer(4));
GenericValue compositeObjectAccess(this, routine, insn.word(3)); GenericValue compositeObjectAccess(this, routine, insn.word(3));
...@@ -2099,7 +2099,7 @@ namespace sw ...@@ -2099,7 +2099,7 @@ namespace sw
{ {
case spv::OpVariable: case spv::OpVariable:
{ {
ObjectID resultId = insn.word(2); Object::ID resultId = insn.word(2);
auto &object = getObject(resultId); auto &object = getObject(resultId);
auto &objectTy = getType(object.type); auto &objectTy = getType(object.type);
if (object.kind == Object::Kind::InterfaceVariable && objectTy.storageClass == spv::StorageClassOutput) if (object.kind == Object::Kind::InterfaceVariable && objectTy.storageClass == spv::StorageClassOutput)
......
...@@ -199,30 +199,28 @@ namespace sw ...@@ -199,30 +199,28 @@ namespace sw
return InsnIterator{insns.cend()}; return InsnIterator{insns.cend()};
} }
class Type;
using TypeID = SpirvID<Type>;
class Type class Type
{ {
public: public:
using ID = SpirvID<Type>;
InsnIterator definition; InsnIterator definition;
spv::StorageClass storageClass = static_cast<spv::StorageClass>(-1); spv::StorageClass storageClass = static_cast<spv::StorageClass>(-1);
uint32_t sizeInComponents = 0; uint32_t sizeInComponents = 0;
bool isBuiltInBlock = false; bool isBuiltInBlock = false;
// Inner element type for pointers, arrays, vectors and matrices. // Inner element type for pointers, arrays, vectors and matrices.
TypeID element; ID element;
}; };
class Object;
using ObjectID = SpirvID<Object>;
class Object class Object
{ {
public: public:
using ID = SpirvID<Object>;
InsnIterator definition; InsnIterator definition;
TypeID type; Type::ID type;
ObjectID pointerBase; ID pointerBase;
std::unique_ptr<uint32_t[]> constantValue = nullptr; std::unique_ptr<uint32_t[]> constantValue = nullptr;
enum class Kind enum class Kind
...@@ -239,17 +237,17 @@ namespace sw ...@@ -239,17 +237,17 @@ namespace sw
struct TypeOrObject {}; // Dummy struct to represent a Type or Object. struct TypeOrObject {}; // Dummy struct to represent a Type or Object.
// TypeOrObjectID is an identifier that represents a Type or an Object, // TypeOrObjectID is an identifier that represents a Type or an Object,
// and supports implicit casting to and from TypeID or ObjectID. // and supports implicit casting to and from Type::ID or Object::ID.
class TypeOrObjectID : public SpirvID<TypeOrObject> class TypeOrObjectID : public SpirvID<TypeOrObject>
{ {
public: public:
using Hash = std::hash<SpirvID<TypeOrObject>>; using Hash = std::hash<SpirvID<TypeOrObject>>;
inline TypeOrObjectID(uint32_t id) : SpirvID(id) {} inline TypeOrObjectID(uint32_t id) : SpirvID(id) {}
inline TypeOrObjectID(TypeID id) : SpirvID(id.value()) {} inline TypeOrObjectID(Type::ID id) : SpirvID(id.value()) {}
inline TypeOrObjectID(ObjectID id) : SpirvID(id.value()) {} inline TypeOrObjectID(Object::ID id) : SpirvID(id.value()) {}
inline operator TypeID() const { return TypeID(value()); } inline operator Type::ID() const { return Type::ID(value()); }
inline operator ObjectID() const { return ObjectID(value()); } inline operator Object::ID() const { return Object::ID(value()); }
}; };
int getSerialID() const int getSerialID() const
...@@ -337,7 +335,7 @@ namespace sw ...@@ -337,7 +335,7 @@ namespace sw
}; };
std::unordered_map<TypeOrObjectID, Decorations, TypeOrObjectID::Hash> decorations; std::unordered_map<TypeOrObjectID, Decorations, TypeOrObjectID::Hash> decorations;
std::unordered_map<TypeID, std::vector<Decorations>> memberDecorations; std::unordered_map<Type::ID, std::vector<Decorations>> memberDecorations;
struct InterfaceComponent struct InterfaceComponent
{ {
...@@ -354,7 +352,7 @@ namespace sw ...@@ -354,7 +352,7 @@ namespace sw
struct BuiltinMapping struct BuiltinMapping
{ {
ObjectID Id; Object::ID Id;
uint32_t FirstComponent; uint32_t FirstComponent;
uint32_t SizeInComponents; uint32_t SizeInComponents;
}; };
...@@ -370,14 +368,14 @@ namespace sw ...@@ -370,14 +368,14 @@ namespace sw
std::unordered_map<spv::BuiltIn, BuiltinMapping, BuiltInHash> inputBuiltins; std::unordered_map<spv::BuiltIn, BuiltinMapping, BuiltInHash> inputBuiltins;
std::unordered_map<spv::BuiltIn, BuiltinMapping, BuiltInHash> outputBuiltins; std::unordered_map<spv::BuiltIn, BuiltinMapping, BuiltInHash> outputBuiltins;
Type const &getType(TypeID id) const Type const &getType(Type::ID id) const
{ {
auto it = types.find(id); auto it = types.find(id);
ASSERT(it != types.end()); ASSERT(it != types.end());
return it->second; return it->second;
} }
Object const &getObject(ObjectID id) const Object const &getObject(Object::ID id) const
{ {
auto it = defs.find(id); auto it = defs.find(id);
ASSERT(it != defs.end()); ASSERT(it != defs.end());
...@@ -399,7 +397,7 @@ namespace sw ...@@ -399,7 +397,7 @@ namespace sw
uint32_t ComputeTypeSize(InsnIterator insn); uint32_t ComputeTypeSize(InsnIterator insn);
void ApplyDecorationsForId(Decorations *d, TypeOrObjectID id) const; void ApplyDecorationsForId(Decorations *d, TypeOrObjectID id) const;
void ApplyDecorationsForIdMember(Decorations *d, TypeID id, uint32_t member) const; void ApplyDecorationsForIdMember(Decorations *d, Type::ID id, uint32_t member) const;
// Returns true if data in the given storage class is word-interleaved // Returns true if data in the given storage class is word-interleaved
// by each SIMD vector lane, otherwise data is linerally stored. // by each SIMD vector lane, otherwise data is linerally stored.
...@@ -430,18 +428,18 @@ namespace sw ...@@ -430,18 +428,18 @@ namespace sw
static bool IsStorageInterleavedByLane(spv::StorageClass storageClass); static bool IsStorageInterleavedByLane(spv::StorageClass storageClass);
template<typename F> template<typename F>
int VisitInterfaceInner(TypeID id, Decorations d, F f) const; int VisitInterfaceInner(Type::ID id, Decorations d, F f) const;
template<typename F> template<typename F>
void VisitInterface(ObjectID id, F f) const; void VisitInterface(Object::ID id, F f) const;
uint32_t GetConstantInt(ObjectID id) const; uint32_t GetConstantInt(Object::ID id) const;
Object& CreateConstant(InsnIterator it); Object& CreateConstant(InsnIterator it);
void ProcessInterfaceVariable(Object &object); void ProcessInterfaceVariable(Object &object);
SIMD::Int WalkAccessChain(ObjectID id, uint32_t numIndexes, uint32_t const *indexIds, SpirvRoutine *routine) const; SIMD::Int WalkAccessChain(Object::ID id, uint32_t numIndexes, uint32_t const *indexIds, SpirvRoutine *routine) const;
uint32_t WalkLiteralAccessChain(TypeID id, uint32_t numIndexes, uint32_t const *indexes) const; uint32_t WalkLiteralAccessChain(Type::ID id, uint32_t numIndexes, uint32_t const *indexes) const;
// Emit pass instructions: // Emit pass instructions:
void EmitVariable(InsnIterator insn, SpirvRoutine *routine) const; void EmitVariable(InsnIterator insn, SpirvRoutine *routine) const;
...@@ -478,23 +476,23 @@ namespace sw ...@@ -478,23 +476,23 @@ namespace sw
vk::PipelineLayout const * const pipelineLayout; vk::PipelineLayout const * const pipelineLayout;
std::unordered_map<SpirvShader::ObjectID, Value> lvalues; std::unordered_map<SpirvShader::Object::ID, Value> lvalues;
std::unordered_map<SpirvShader::ObjectID, Intermediate> intermediates; std::unordered_map<SpirvShader::Object::ID, Intermediate> intermediates;
std::unordered_map<SpirvShader::ObjectID, Pointer<Byte> > physicalPointers; std::unordered_map<SpirvShader::Object::ID, Pointer<Byte> > physicalPointers;
Value inputs = Value{MAX_INTERFACE_COMPONENTS}; Value inputs = Value{MAX_INTERFACE_COMPONENTS};
Value outputs = Value{MAX_INTERFACE_COMPONENTS}; Value outputs = Value{MAX_INTERFACE_COMPONENTS};
std::array<Pointer<Byte>, vk::MAX_BOUND_DESCRIPTOR_SETS> descriptorSets; std::array<Pointer<Byte>, vk::MAX_BOUND_DESCRIPTOR_SETS> descriptorSets;
void createLvalue(SpirvShader::ObjectID id, uint32_t size) void createLvalue(SpirvShader::Object::ID id, uint32_t size)
{ {
lvalues.emplace(id, Value(size)); lvalues.emplace(id, Value(size));
} }
Intermediate& createIntermediate(SpirvShader::ObjectID id, uint32_t size) Intermediate& createIntermediate(SpirvShader::Object::ID id, uint32_t size)
{ {
auto it = intermediates.emplace(std::piecewise_construct, auto it = intermediates.emplace(std::piecewise_construct,
std::forward_as_tuple(id), std::forward_as_tuple(id),
...@@ -502,21 +500,21 @@ namespace sw ...@@ -502,21 +500,21 @@ namespace sw
return it.first->second; return it.first->second;
} }
Value& getValue(SpirvShader::ObjectID id) Value& getValue(SpirvShader::Object::ID id)
{ {
auto it = lvalues.find(id); auto it = lvalues.find(id);
ASSERT(it != lvalues.end()); ASSERT(it != lvalues.end());
return it->second; return it->second;
} }
Intermediate const& getIntermediate(SpirvShader::ObjectID id) const Intermediate const& getIntermediate(SpirvShader::Object::ID id) const
{ {
auto it = intermediates.find(id); auto it = intermediates.find(id);
ASSERT(it != intermediates.end()); ASSERT(it != intermediates.end());
return it->second; return it->second;
} }
Pointer<Byte>& getPhysicalPointer(SpirvShader::ObjectID id) Pointer<Byte>& getPhysicalPointer(SpirvShader::Object::ID id)
{ {
auto it = physicalPointers.find(id); auto it = physicalPointers.find(id);
assert(it != physicalPointers.end()); assert(it != physicalPointers.end());
...@@ -535,7 +533,7 @@ namespace sw ...@@ -535,7 +533,7 @@ namespace sw
Intermediate const *intermediate; Intermediate const *intermediate;
public: public:
GenericValue(SpirvShader const *shader, SpirvRoutine const *routine, SpirvShader::ObjectID objId) : GenericValue(SpirvShader const *shader, SpirvRoutine const *routine, SpirvShader::Object::ID objId) :
obj(shader->getObject(objId)), obj(shader->getObject(objId)),
intermediate(obj.kind == SpirvShader::Object::Kind::Value ? &routine->getIntermediate(objId) : nullptr) {} intermediate(obj.kind == SpirvShader::Object::Kind::Value ? &routine->getIntermediate(objId) : nullptr) {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment