Commit 75611d09 by Nicolas Capens

Fix texture unit enable/disable and binding prioritization.

Bug 21194513 Change-Id: I487a7e07aa936b8613200fae319fe09b86e81cb1 Reviewed-on: https://swiftshader-review.googlesource.com/3148Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent 70583fac
...@@ -164,7 +164,13 @@ Context::Context(const egl::Config *config, const Context *shareContext) ...@@ -164,7 +164,13 @@ Context::Context(const egl::Config *config, const Context *shareContext)
materialEmission = {0.0f, 0.0f, 0.0f, 1.0f}; materialEmission = {0.0f, 0.0f, 0.0f, 1.0f};
matrixMode = GL_MODELVIEW; matrixMode = GL_MODELVIEW;
texture2D = false;
for(int i = 0; i < MAX_TEXTURE_UNITS; i++)
{
texture2Denabled[i] = false;
textureExternalEnabled[i] = false;
}
clientTexture = GL_TEXTURE0; clientTexture = GL_TEXTURE0;
setVertexAttrib(sw::Color0, 1.0f, 1.0f, 1.0f, 1.0f); setVertexAttrib(sw::Color0, 1.0f, 1.0f, 1.0f, 1.0f);
...@@ -619,9 +625,14 @@ void Context::setFogColor(float r, float g, float b, float a) ...@@ -619,9 +625,14 @@ void Context::setFogColor(float r, float g, float b, float a)
device->setFogColor(sw::Color<float>(r, g, b, a)); device->setFogColor(sw::Color<float>(r, g, b, a));
} }
void Context::setTexture2D(bool enable) void Context::setTexture2Denabled(bool enable)
{ {
texture2D = enable; texture2Denabled[mState.activeSampler] = enable;
}
void Context::setTextureExternalEnabled(bool enable)
{
textureExternalEnabled[mState.activeSampler] = enable;
} }
void Context::setLineWidth(GLfloat width) void Context::setLineWidth(GLfloat width)
...@@ -1774,9 +1785,18 @@ void Context::applyTextures() ...@@ -1774,9 +1785,18 @@ void Context::applyTextures()
for(int samplerIndex = 0; samplerIndex < MAX_TEXTURE_UNITS; samplerIndex++) for(int samplerIndex = 0; samplerIndex < MAX_TEXTURE_UNITS; samplerIndex++)
{ {
Texture *texture = getSamplerTexture(samplerIndex, TEXTURE_2D); Texture *texture = nullptr;
if(textureExternalEnabled[samplerIndex])
{
texture = getSamplerTexture(samplerIndex, TEXTURE_EXTERNAL);
}
else if(texture2Denabled[samplerIndex])
{
texture = getSamplerTexture(samplerIndex, TEXTURE_2D);
}
if(texture2D && texture->isSamplerComplete()) if(texture && texture->isSamplerComplete())
{ {
GLenum wrapS = texture->getWrapS(); GLenum wrapS = texture->getWrapS();
GLenum wrapT = texture->getWrapT(); GLenum wrapT = texture->getWrapT();
......
...@@ -322,7 +322,8 @@ public: ...@@ -322,7 +322,8 @@ public:
void setFogEnd(float fogEnd); void setFogEnd(float fogEnd);
void setFogColor(float r, float g, float b, float a); void setFogColor(float r, float g, float b, float a);
void setTexture2D(bool enabled); void setTexture2Denabled(bool enabled);
void setTextureExternalEnabled(bool enabled);
void clientActiveTexture(GLenum texture); void clientActiveTexture(GLenum texture);
GLenum getClientActiveTexture() const; GLenum getClientActiveTexture() const;
unsigned int getActiveTexture() const; unsigned int getActiveTexture() const;
...@@ -513,7 +514,8 @@ private: ...@@ -513,7 +514,8 @@ private:
sw::MatrixStack textureStack0; sw::MatrixStack textureStack0;
sw::MatrixStack textureStack1; sw::MatrixStack textureStack1;
bool texture2D; bool texture2Denabled[MAX_TEXTURE_UNITS];
bool textureExternalEnabled[MAX_TEXTURE_UNITS];
GLenum clientTexture; GLenum clientTexture;
Device *device; Device *device;
......
...@@ -1228,7 +1228,8 @@ void Disable(GLenum cap) ...@@ -1228,7 +1228,8 @@ void Disable(GLenum cap)
case GL_LIGHT6: context->setLight(6, false); break; case GL_LIGHT6: context->setLight(6, false); break;
case GL_LIGHT7: context->setLight(7, false); break; case GL_LIGHT7: context->setLight(7, false); break;
case GL_FOG: context->setFog(false); break; case GL_FOG: context->setFog(false); break;
case GL_TEXTURE_2D: context->setTexture2D(false); break; case GL_TEXTURE_2D: context->setTexture2Denabled(false); break;
case GL_TEXTURE_EXTERNAL_OES: context->setTextureExternalEnabled(false); break;
case GL_ALPHA_TEST: UNIMPLEMENTED(); break; case GL_ALPHA_TEST: UNIMPLEMENTED(); break;
case GL_COLOR_LOGIC_OP: UNIMPLEMENTED(); break; case GL_COLOR_LOGIC_OP: UNIMPLEMENTED(); break;
case GL_POINT_SMOOTH: UNIMPLEMENTED(); break; case GL_POINT_SMOOTH: UNIMPLEMENTED(); break;
...@@ -1343,7 +1344,8 @@ void Enable(GLenum cap) ...@@ -1343,7 +1344,8 @@ void Enable(GLenum cap)
case GL_LIGHT6: context->setLight(6, true); break; case GL_LIGHT6: context->setLight(6, true); break;
case GL_LIGHT7: context->setLight(7, true); break; case GL_LIGHT7: context->setLight(7, true); break;
case GL_FOG: context->setFog(true); break; case GL_FOG: context->setFog(true); break;
case GL_TEXTURE_2D: context->setTexture2D(true); break; case GL_TEXTURE_2D: context->setTexture2Denabled(true); break;
case GL_TEXTURE_EXTERNAL_OES: context->setTextureExternalEnabled(true); break;
case GL_ALPHA_TEST: UNIMPLEMENTED(); break; case GL_ALPHA_TEST: UNIMPLEMENTED(); break;
case GL_COLOR_LOGIC_OP: UNIMPLEMENTED(); break; case GL_COLOR_LOGIC_OP: UNIMPLEMENTED(); break;
case GL_POINT_SMOOTH: UNIMPLEMENTED(); break; case GL_POINT_SMOOTH: UNIMPLEMENTED(); break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment