Fix zero texture application.
Patch https://chromium-review.googlesource.com/#/c/227711/ would
allow NULL Textures sometimes from State::getSamplerTexture. Fix
this by always setting the zero "Default" textures instead of NULL
in the State.
This was breaking the ES2-CTS test 'framebuffer_objects' on Windows.
BUG=angle:826
Change-Id: Ie08a89cff0555f21c769759e0c0ed73456a2f91c
Reviewed-on: https://chromium-review.googlesource.com/228275
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
diff --git a/src/libGLESv2/State.cpp b/src/libGLESv2/State.cpp
index 054027e..fa3bbd6 100644
--- a/src/libGLESv2/State.cpp
+++ b/src/libGLESv2/State.cpp
@@ -621,7 +621,7 @@
return mSamplerTextures.at(type)[sampler].id();
}
-void State::detachTexture(GLuint texture)
+void State::detachTexture(const TextureMap &zeroTextures, GLuint texture)
{
// Textures have a detach method on State rather than a simple
// removeBinding, because the zero/null texture objects are managed
@@ -634,13 +634,15 @@
for (TextureBindingMap::iterator bindingVec = mSamplerTextures.begin(); bindingVec != mSamplerTextures.end(); bindingVec++)
{
+ GLenum textureType = bindingVec->first;
TextureBindingVector &textureVector = bindingVec->second;
for (size_t textureIdx = 0; textureIdx < textureVector.size(); textureIdx++)
{
BindingPointer<Texture> &binding = textureVector[textureIdx];
if (binding.id() == texture)
{
- binding.set(NULL);
+ // Zero textures are the "default" textures instead of NULL
+ binding.set(zeroTextures.at(textureType).get());
}
}
}
@@ -661,6 +663,19 @@
}
}
+void State::initializeZeroTextures(const TextureMap &zeroTextures)
+{
+ for (const auto &zeroTexture : zeroTextures)
+ {
+ auto &samplerTextureArray = mSamplerTextures[zeroTexture.first];
+
+ for (size_t textureUnit = 0; textureUnit < samplerTextureArray.size(); ++textureUnit)
+ {
+ samplerTextureArray[textureUnit].set(zeroTexture.second.get());
+ }
+ }
+}
+
void State::setSamplerBinding(GLuint textureUnit, Sampler *sampler)
{
mSamplers[textureUnit].set(sampler);