src/third_party/angle/src/tests/gl_tests/ActiveTextureCacheTest.cpp
// Regression test for a bug that causes the ActiveTexturesCache to get out of sync with the
// currently bound textures when changing program uniforms in such a way that the program becomes
// invalid.
Regression test for a bug that causes the ActiveTexturesCache to get out of sync with the
currently bound textures when changing program uniforms in such a way that the program becomes
invalid.
Regression test for a bug that causes the ActiveTexturesCache to get out of sync with the currently bound textures when changing program uniforms in such a way that the program becomes invalid .
TEST_P(ActiveTextureCacheTest, UniformChangeUpdatesActiveTextureCache)
{
    glUseProgram(mProgram);
    GLuint tex0 = 0;
    glGenTextures(1, &tex0);
    glBindTexture(GL_TEXTURE_2D, tex0);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
    GLuint tex1 = 0;
    glGenTextures(1, &tex1);
    glBindTexture(GL_TEXTURE_2D, tex1);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
    glBindTexture(GL_TEXTURE_2D, 0);
    glActiveTexture(GL_TEXTURE1);
    glBindTexture(GL_TEXTURE_2D, tex0);
    glUniform1i(m2DTextureLocation, 1);
    glUniform1i(mCubeTextureLocation, 1);
    glBindTexture(GL_TEXTURE_2D, tex1);
    glDeleteTextures(1, &tex0);
}
TEST_P ( ActiveTextureCacheTest , UniformChangeUpdatesActiveTextureCache ) { glUseProgram ( mProgram ) ; GLuint tex0 = 0 ; glGenTextures ( 1 , & tex0 ) ; glBindTexture ( GL_TEXTURE_2D , tex0 ) ; glTexImage2D ( GL_TEXTURE_2D , 0 , GL_RGBA , 1 , 1 , 0 , GL_RGBA , GL_UNSIGNED_BYTE , nullptr ) ; GLuint tex1 = 0 ; glGenTextures ( 1 , & tex1 ) ; glBindTexture ( GL_TEXTURE_2D , tex1 ) ; glTexImage2D ( GL_TEXTURE_2D , 0 , GL_RGBA , 1 , 1 , 0 , GL_RGBA , GL_UNSIGNED_BYTE , nullptr ) ; glBindTexture ( GL_TEXTURE_2D , 0 ) ; glActiveTexture ( GL_TEXTURE1 ) ; glBindTexture ( GL_TEXTURE_2D , tex0 ) ; glUniform1i ( m2DTextureLocation , 1 ) ; glUniform1i ( mCubeTextureLocation , 1 ) ; glBindTexture ( GL_TEXTURE_2D , tex1 ) ; glDeleteTextures ( 1 , & tex0 ) ; }
Regression test for a bug that causes the ActiveTexturesCache to get out of sync with the
currently bound textures when changing program uniforms in such a way that the program becomes
invalid.
Regression test for a bug that causes the ActiveTexturesCache to get out of sync with the currently bound textures when changing program uniforms in such a way that the program becomes invalid .
// Generate two textures and reset the texture binding // Set the active texture to 1 and bind tex0. // Point the program's 2D sampler at texture binding 1. The texture will be added to the // ActiveTexturesCache because it matches the program's sampler type for this texture binding. // Point the program's cube sampler to texture binding 1 as well. This causes the program's // samplers become invalid and the ActiveTexturesCache is NOT updated. // Bind tex1. ActiveTexturesCache is NOT updated (still contains tex0). The current texture // bindings do not match ActiveTexturesCache's state. // Delete tex0. The ActiveTexturesCache entry that points to tex0 is not cleared because tex0 is // not currently bound. // Use-after-free occurs during context destruction when the ActiveTexturesCache is cleared.