Commit 296aa251 by Chris Forbes

Collect type and variable definitions from SPIRV shader

Many other pieces will need an index of spirv-id to defining instruction. Start building that up. Bug: b/120799499 Change-Id: Ief6583f45c49fce02cb5dc40d12c6ba928e48fd7 Reviewed-on: https://swiftshader-review.googlesource.com/c/23428Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarCorentin Wallez <cwallez@google.com>
parent af4ed53d
......@@ -35,6 +35,41 @@ namespace sw
ProcessExecutionMode(insn);
break;
case spv::OpTypeVoid:
case spv::OpTypeBool:
case spv::OpTypeInt:
case spv::OpTypeFloat:
case spv::OpTypeVector:
case spv::OpTypeMatrix:
case spv::OpTypeImage:
case spv::OpTypeSampler:
case spv::OpTypeSampledImage:
case spv::OpTypeArray:
case spv::OpTypeRuntimeArray:
case spv::OpTypeStruct:
case spv::OpTypePointer:
case spv::OpTypeFunction: {
auto resultId = insn.word(1);
auto &object = defs[resultId];
object.kind = Object::Kind::Type;
object.definition = insn;
break;
}
case spv::OpVariable: {
auto typeId = insn.word(1);
auto resultId = insn.word(2);
auto storageClass = static_cast<spv::StorageClass>(insn.word(3));
if (insn.wordCount() > 4)
UNIMPLEMENTED("Variable initializers not yet supported");
auto &object = defs[resultId];
object.kind = Object::Kind::Variable;
object.definition = insn;
object.storageClass = storageClass;
break;
}
default:
break; // This is OK, these passes are intentionally partial
}
......
......@@ -88,6 +88,21 @@ namespace sw
InsnIterator end() const
{ return InsnIterator{insns.cend()}; }
class Object
{
public:
InsnIterator definition;
spv::StorageClass storageClass;
enum class Kind
{
Unknown, /* for paranoia -- if we get left with an object in this state, the module was broken */
Type,
Variable,
Value,
} kind = Kind::Unknown;
};
int getSerialID() const
{ return serialID; }
......@@ -112,6 +127,7 @@ namespace sw
const int serialID;
static volatile int serialCounter;
Modes modes;
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