Commit 9a16248d by Ben Clayton Committed by Ben Clayton

SpirvShader: Decouple SPIR-V type attributes from object representation

StorageClass, sizeInComponents, isBuiltInBlock are all attributes of the Type, not the Object. Add 'type' field to Object so type information can easily be looked up regardless of definition opcode. Add 'element' field to Type, simplifying the likes of WalkAccessChain. Fixes the weird edge case of OpVariable's sizeInComponents being the size of the pointee, not its type (the pointer). Bug: b/126126820 Change-Id: I2d1d93e03ee0253a87f831031c3b2806b1d80de0 Reviewed-on: https://swiftshader-review.googlesource.com/c/25408 Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com>
parent ab51bbfa
......@@ -154,23 +154,30 @@ namespace sw
return InsnIterator{insns.cend()};
}
class Type;
using TypeID = SpirvID<Type>;
class Type
{
public:
InsnIterator definition;
spv::StorageClass storageClass;
spv::StorageClass storageClass = static_cast<spv::StorageClass>(-1);
uint32_t sizeInComponents = 0;
bool isBuiltInBlock = false;
// Inner element type for pointers, arrays, vectors and matrices.
TypeID element;
};
class Object;
using ObjectID = SpirvID<Object>;
class Object
{
public:
InsnIterator definition;
spv::StorageClass storageClass;
uint32_t sizeInComponents = 0;
bool isBuiltInBlock = false;
uint32_t pointerBase = 0;
TypeID type;
ObjectID pointerBase;
std::unique_ptr<uint32_t[]> constantValue = nullptr;
enum class Kind
......@@ -183,9 +190,6 @@ namespace sw
} kind = Kind::Unknown;
};
using TypeID = SpirvID<Type>;
using ObjectID = SpirvID<Object>;
struct TypeOrObject {}; // Dummy struct to represent a Type or Object.
// TypeOrObjectID is an identifier that represents a Type or an Object,
......
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