OSDN Git Service

SpirvRoutine: Verify create functions are called once per id
authorBen Clayton <bclayton@google.com>
Thu, 4 Apr 2019 14:53:04 +0000 (15:53 +0100)
committerBen Clayton <bclayton@google.com>
Thu, 4 Apr 2019 22:09:26 +0000 (22:09 +0000)
Just a safety belt that we're not doing stupid things.

Change-Id: I092b0755d151a559f793e1a9f30b17ef52626d10
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28389
Presubmit-Ready: Ben Clayton <bclayton@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

src/Pipeline/SpirvShader.hpp

index 0314d0a..f3602cd 100644 (file)
@@ -667,7 +667,8 @@ namespace sw
 
                void createLvalue(SpirvShader::Object::ID id, uint32_t size)
                {
-                       lvalues.emplace(id, Value(size));
+                       bool added = lvalues.emplace(id, Value(size)).second;
+                       ASSERT_MSG(added, "Value %d created twice", id.value());
                }
 
                Intermediate& createIntermediate(SpirvShader::Object::ID id, uint32_t size)
@@ -675,6 +676,7 @@ namespace sw
                        auto it = intermediates.emplace(std::piecewise_construct,
                                        std::forward_as_tuple(id),
                                        std::forward_as_tuple(size));
+                       ASSERT_MSG(it.second, "Intermediate %d created twice", id.value());
                        return it.first->second;
                }