SpirvShaderDebugger: Handle None sizes for composite types

The spec states that opaque types can have a None size instead of a constant integer size.

Bug: b/148401179
Change-Id: I52eeabe2336775643787599890857169825f3230
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/45353
Tested-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
diff --git a/src/Pipeline/SpirvShaderDebugger.cpp b/src/Pipeline/SpirvShaderDebugger.cpp
index 065c548..a456ef1 100644
--- a/src/Pipeline/SpirvShaderDebugger.cpp
+++ b/src/Pipeline/SpirvShaderDebugger.cpp
@@ -513,6 +513,10 @@
 	// addNone() registers given id as a None value or type.
 	void addNone(debug::Object::ID id);
 
+	// isNone() returns true if the given id was registered as none with
+	// addNone().
+	bool isNone(debug::Object::ID id) const;
+
 	// get() returns the debug object with the given id.
 	// The object must exist and be of type (or derive from type) T.
 	// A returned nullptr represents a None value or type.
@@ -976,7 +980,7 @@
 				type->column = insn.word(9);
 				type->parent = get(debug::Object::ID(insn.word(10)));
 				type->linkage = shader->getString(insn.word(11));
-				type->size = shader->GetConstScalarInt(insn.word(12));
+				type->size = isNone(insn.word(12)) ? 0 : shader->GetConstScalarInt(insn.word(12));
 				type->flags = insn.word(13);
 				for(uint32_t i = 14; i < insn.wordCount(); i++)
 				{
@@ -1218,6 +1222,13 @@
 	ASSERT_MSG(added, "Debug object with %d already exists", id.value());
 }
 
+bool SpirvShader::Impl::Debugger::isNone(debug::Object::ID id) const
+{
+	auto it = objects.find(debug::Object::ID(id.value()));
+	if(it == objects.end()) { return false; }
+	return it->second.get() == nullptr;
+}
+
 template<typename T>
 T *SpirvShader::Impl::Debugger::get(SpirvID<T> id) const
 {