Add top-level dirty bits for texture and samplers.
These will have to be fleshed out in the back-ends.
Also currently uses a single bit for all the bindings, and we can
extend this to more fine-grained updates in the future.
This patch implements top-level updates for texture completeness.
Sampler completeness caches are removed from the Texture class, and
replaced by a cache in the gl::State class. The State class also
keeps a channel binding to the bound textures so it can be notified
when textures might change from complete <-> incomplete.
In future CLs we skip updating back-ends if texture state doesn't
change.
BUG=angleproject:1387
Change-Id: If580b4851303c86f3240e62891f5f6047eefb6a2
Reviewed-on: https://chromium-review.googlesource.com/648053
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/tests/gl_tests/IncompleteTextureTest.cpp b/src/tests/gl_tests/IncompleteTextureTest.cpp
index d7a1139..c835676 100644
--- a/src/tests/gl_tests/IncompleteTextureTest.cpp
+++ b/src/tests/gl_tests/IncompleteTextureTest.cpp
@@ -7,6 +7,7 @@
#include "test_utils/ANGLETest.h"
#include <vector>
+#include "test_utils/gl_raii.h"
using namespace angle;
@@ -86,42 +87,44 @@
TEST_P(IncompleteTextureTest, IncompleteTexture2D)
{
- GLuint tex;
- glGenTextures(1, &tex);
+ GLTexture tex;
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, tex);
glUseProgram(mProgram);
glUniform1i(mTextureUniformLocation, 0);
- const GLsizei textureWidth = 2;
- const GLsizei textureHeight = 2;
- std::vector<GLubyte> textureData(textureWidth * textureHeight * 4);
- fillTextureData(textureData, 255, 0, 0, 255);
+ constexpr GLsizei kTextureSize = 2;
+ std::vector<GLColor> textureData(kTextureSize * kTextureSize, GLColor::red);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, textureWidth, textureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, &textureData[0]);
+ // Make a complete texture.
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kTextureSize, kTextureSize, 0, GL_RGBA,
+ GL_UNSIGNED_BYTE, textureData.data());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ // Should be complete - expect red.
drawQuad(mProgram, "position", 0.5f);
- EXPECT_PIXEL_EQ(0, 0, 255, 0, 0, 255);
+ EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
+ // Make texture incomplete.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+ // Should be incomplete - expect black.
drawQuad(mProgram, "position", 0.5f);
- EXPECT_PIXEL_EQ(0, 0, 0, 0, 0, 255);
+ EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::black);
- glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, textureWidth >> 1, textureHeight >> 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &textureData[0]);
+ // Make texture complete by defining the second mip.
+ glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, kTextureSize >> 1, kTextureSize >> 1, 0, GL_RGBA,
+ GL_UNSIGNED_BYTE, textureData.data());
+ // Should be complete - expect red.
drawQuad(mProgram, "position", 0.5f);
- EXPECT_PIXEL_EQ(0, 0, 255, 0, 0, 255);
-
- glDeleteTextures(1, &tex);
+ EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
}
TEST_P(IncompleteTextureTest, UpdateTexture)
{
- GLuint tex;
- glGenTextures(1, &tex);
+ GLTexture tex;
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, tex);
@@ -158,8 +161,6 @@
drawQuad(mProgram, "position", 0.5f);
EXPECT_PIXEL_EQ(getWindowWidth() - greenTextureWidth, getWindowHeight() - greenTextureWidth, 0, 255, 0, 255);
-
- glDeleteTextures(1, &tex);
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.