SpirvShader: Consider OpEntryPoint interface IDs

Bug: swiftshader:161
Change-Id: Ib26cb1f6edb2549fc42420e7cc1579ce4ae36952
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/55148
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Pipeline/SpirvShader.cpp b/src/Pipeline/SpirvShader.cpp
index f82f1e8..58c7ca5 100644
--- a/src/Pipeline/SpirvShader.cpp
+++ b/src/Pipeline/SpirvShader.cpp
@@ -61,8 +61,8 @@
 		}
 	}
 
-	// Simplifying assumptions (to be satisfied by earlier transformations)
-	// - The only input/output OpVariables present are those used by the entrypoint
+	// The identifiers of all OpVariables that define the entry point's IO variables.
+	std::unordered_set<Object::ID> interfaceIds;
 
 	Function::ID currentFunction;
 	Block::ID currentBlock;
@@ -84,6 +84,12 @@
 				{
 					ASSERT_MSG(entryPoint == 0, "Duplicate entry point with name '%s' and stage %d", name, int(stage));
 					entryPoint = id;
+
+					auto interfaceIdsOffset = 3 + insn.stringSizeInWords(3);
+					for(uint32_t i = interfaceIdsOffset; i < insn.wordCount(); i++)
+					{
+						interfaceIds.emplace(insn.word(i));
+					}
 				}
 			}
 			break;
@@ -271,7 +277,10 @@
 				{
 				case spv::StorageClassInput:
 				case spv::StorageClassOutput:
-					ProcessInterfaceVariable(object);
+					if(interfaceIds.count(resultId))
+					{
+						ProcessInterfaceVariable(object);
+					}
 					break;
 
 				case spv::StorageClassUniform: