Fix handling of pointer sizes; we want them to be 1

Bug: b/124388146
Change-Id: Id528368106eb0d09930ff4fccbe94704b585a531
Reviewed-on: https://swiftshader-review.googlesource.com/c/24599
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
diff --git a/src/Pipeline/SpirvShader.cpp b/src/Pipeline/SpirvShader.cpp
index 368cf32..f4cad7d 100644
--- a/src/Pipeline/SpirvShader.cpp
+++ b/src/Pipeline/SpirvShader.cpp
@@ -161,8 +161,10 @@
 				object.storageClass = storageClass;
 
 				auto &type = getType(typeId);
+				auto &pointeeType = getType(type.definition.word(3));
 
-				object.sizeInComponents = type.sizeInComponents;
+				// OpVariable's "size" is the size of the allocation required (the size of the pointee)
+				object.sizeInComponents = pointeeType.sizeInComponents;
 				object.isBuiltInBlock = type.isBuiltInBlock;
 
 				// Register builtins
@@ -379,9 +381,9 @@
 		}
 
 		case spv::OpTypePointer:
-			// Pointer 'size' is just pointee size
-			// TODO: this isn't really correct. we should look through pointers as appropriate.
-			return getType(insn.word(3)).sizeInComponents;
+			// Runtime representation of a pointer is a per-lane index.
+			// Note: clients are expected to look through the pointer if they want the pointee size instead.
+			return 1;
 
 		default:
 			// Some other random insn.