Commit e205d343 by Ben Clayton

SpirvShader: Split objects from types.

Change-Id: Ifbcb30da30b912a1a60f5799717869c8d56cd90b Reviewed-on: https://swiftshader-review.googlesource.com/c/25018 Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com>
parent 93317ec8
......@@ -117,10 +117,9 @@ namespace sw
case spv::OpTypeFunction:
{
auto resultId = insn.word(1);
auto &object = types[resultId];
object.kind = Object::Kind::Type;
object.definition = insn;
object.sizeInComponents = ComputeTypeSize(insn);
auto &type = types[resultId];
type.definition = insn;
type.sizeInComponents = ComputeTypeSize(insn);
// A structure is a builtin block if it has a builtin
// member. All members of such a structure are builtins.
......@@ -133,7 +132,7 @@ namespace sw
{
if (m.HasBuiltIn)
{
object.isBuiltInBlock = true;
type.isBuiltInBlock = true;
break;
}
}
......@@ -142,7 +141,7 @@ namespace sw
else if (insn.opcode() == spv::OpTypePointer)
{
auto pointeeType = insn.word(3);
object.isBuiltInBlock = getType(pointeeType).isBuiltInBlock;
type.isBuiltInBlock = getType(pointeeType).isBuiltInBlock;
}
break;
}
......
......@@ -128,6 +128,15 @@ namespace sw
return InsnIterator{insns.cend()};
}
class Type
{
public:
InsnIterator definition;
spv::StorageClass storageClass;
uint32_t sizeInComponents = 0;
bool isBuiltInBlock = false;
};
class Object
{
public:
......@@ -140,7 +149,6 @@ namespace sw
enum class Kind
{
Unknown, /* for paranoia -- if we get left with an object in this state, the module was broken */
Type,
Variable,
InterfaceVariable,
Constant,
......@@ -252,7 +260,7 @@ namespace sw
std::unordered_map<spv::BuiltIn, BuiltinMapping, BuiltInHash> inputBuiltins;
std::unordered_map<spv::BuiltIn, BuiltinMapping, BuiltInHash> outputBuiltins;
Object const &getType(uint32_t id) const
Type const &getType(uint32_t id) const
{
auto it = types.find(id);
assert(it != types.end());
......@@ -270,7 +278,7 @@ namespace sw
const int serialID;
static volatile int serialCounter;
Modes modes;
std::unordered_map<uint32_t, Object> types;
std::unordered_map<uint32_t, Type> types;
std::unordered_map<uint32_t, Object> defs;
void ProcessExecutionMode(InsnIterator it);
......
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