diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-07-03 14:05:12 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-07-12 14:48:22 -0700 |
commit | c61041b44cd9181641db2351f4657cc356300226 (patch) | |
tree | 6a5d115c1796a52d4270ca48fbb1a0e1ce3a2ad4 /test | |
parent | fedfaa2f6e582e87b190f5d423302f9f95d147d9 (diff) | |
download | qtlocation-mapboxgl-c61041b44cd9181641db2351f4657cc356300226.tar.gz |
[core] Rework attribute binding (again)
These changes are necessary for programs whose set of active attributes is not fixed at compile time by a template parameter pack, but rather varies based on the generated shader text at runtime. In such cases, the attribute location of a given named attribute may vary between instances of the same Program.
Previously, attribute bindings were implicitly associated with a location based on template parameter order, and -1 was used to indicate an inactive attribute. This left us unable to disable the appropriate attribute when it went from active to inactive. Now, the state tracker for bindings explicitly associates locations and state, and an empty optional is used to indicate an inactive attribute.
In addition, a gl::VertexArray class is now exposed, allowing more flexibility in the relationship between Programs, Segments, and attribute bindings. In this commit, that relationship does not change, but the subsequent commit adjusts it to match gl-js, reduce rebinds, and work around buggy VAO implementations.
VertexArray uses a pimpl idiom in order to support implementations that lack the VAO extension. In that case, all VertexArrays share global binding state, reflecting the platform reality in the absence of VAOs, while still providing a uniform API.
Diffstat (limited to 'test')
-rw-r--r-- | test/programs/binary_program.test.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/test/programs/binary_program.test.cpp b/test/programs/binary_program.test.cpp index ce544e7652..a5cf7b6e39 100644 --- a/test/programs/binary_program.test.cpp +++ b/test/programs/binary_program.test.cpp @@ -14,12 +14,12 @@ TEST(BinaryProgram, ObtainValues) { EXPECT_EQ(42u, binaryProgram.format()); EXPECT_EQ("binary code", binaryProgram.code()); EXPECT_EQ("identifier", binaryProgram.identifier()); - EXPECT_EQ(1, binaryProgram.attributeLocation("a_pos")); - EXPECT_EQ(0, binaryProgram.attributeLocation("u_world")); - EXPECT_EQ(4, binaryProgram.attributeLocation("a_data")); + EXPECT_EQ(1u, binaryProgram.attributeLocation("a_pos")); + EXPECT_FALSE(binaryProgram.attributeLocation("u_world")); + EXPECT_EQ(4u, binaryProgram.attributeLocation("a_data")); EXPECT_EQ(1, binaryProgram.uniformLocation("u_world")); EXPECT_EQ(3, binaryProgram.uniformLocation("u_ratio")); - EXPECT_EQ(0, binaryProgram.uniformLocation("a_data")); + EXPECT_EQ(-1, binaryProgram.uniformLocation("a_data")); auto serialized = binaryProgram.serialize(); @@ -28,12 +28,12 @@ TEST(BinaryProgram, ObtainValues) { EXPECT_EQ(42u, binaryProgram2.format()); EXPECT_EQ("binary code", binaryProgram2.code()); EXPECT_EQ("identifier", binaryProgram2.identifier()); - EXPECT_EQ(1, binaryProgram2.attributeLocation("a_pos")); - EXPECT_EQ(0, binaryProgram2.attributeLocation("u_world")); - EXPECT_EQ(4, binaryProgram2.attributeLocation("a_data")); + EXPECT_EQ(1u, binaryProgram2.attributeLocation("a_pos")); + EXPECT_FALSE(binaryProgram2.attributeLocation("u_world")); + EXPECT_EQ(4u, binaryProgram2.attributeLocation("a_data")); EXPECT_EQ(1, binaryProgram2.uniformLocation("u_world")); EXPECT_EQ(3, binaryProgram2.uniformLocation("u_ratio")); - EXPECT_EQ(0, binaryProgram2.uniformLocation("a_data")); + EXPECT_EQ(-1, binaryProgram2.uniformLocation("a_data")); EXPECT_THROW(BinaryProgram(""), std::runtime_error); } |