Commit 70583fac by Nicolas Capens

Fix texture coordinate transformations on OpenGL.

Add a texture coordinate generation mode to always use 4-component homogeneous texture coordinates on OpenGL. Bug 21187909 Change-Id: I58714404002102f4138add454cf5a8c0aecfb062 Reviewed-on: https://swiftshader-review.googlesource.com/3145Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarMaxime Grégoire <mgregoire@google.com> Tested-by: 's avatarMaxime Grégoire <mgregoire@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Tested-by: 's avatarGreg Hartman <ghartman@google.com> Reviewed-by: 's avatarGreg Hartman <ghartman@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 57aac607
...@@ -2485,6 +2485,8 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count) ...@@ -2485,6 +2485,8 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count)
device->setTextureMatrix(1, texture[1].current()); device->setTextureMatrix(1, texture[1].current());
device->setTextureTransform(0, texture[0].isIdentity() ? 0 : 4, false); device->setTextureTransform(0, texture[0].isIdentity() ? 0 : 4, false);
device->setTextureTransform(1, texture[1].isIdentity() ? 0 : 4, false); device->setTextureTransform(1, texture[1].isIdentity() ? 0 : 4, false);
device->setTexGen(0, sw::TEXGEN_NONE);
device->setTexGen(1, sw::TEXGEN_NONE);
} }
PrimitiveType primitiveType; PrimitiveType primitiveType;
......
...@@ -1718,6 +1718,8 @@ void Context::applyState(GLenum drawMode) ...@@ -1718,6 +1718,8 @@ void Context::applyState(GLenum drawMode)
device->setTextureMatrix(1, textureStack1.current()); device->setTextureMatrix(1, textureStack1.current());
device->setTextureTransform(0, textureStack0.isIdentity() ? 0 : 4, false); device->setTextureTransform(0, textureStack0.isIdentity() ? 0 : 4, false);
device->setTextureTransform(1, textureStack1.isIdentity() ? 0 : 4, false); device->setTextureTransform(1, textureStack1.isIdentity() ? 0 : 4, false);
device->setTexGen(0, sw::TEXGEN_NONE);
device->setTexGen(1, sw::TEXGEN_NONE);
} }
GLenum Context::applyVertexBuffer(GLint base, GLint first, GLsizei count) GLenum Context::applyVertexBuffer(GLint base, GLint first, GLsizei count)
......
...@@ -3728,4 +3728,4 @@ extern "C" __eglMustCastToProperFunctionPointerType es1GetProcAddress(const char ...@@ -3728,4 +3728,4 @@ extern "C" __eglMustCastToProperFunctionPointerType es1GetProcAddress(const char
} }
return NULL; return NULL;
} }
...@@ -535,6 +535,9 @@ namespace sw ...@@ -535,6 +535,9 @@ namespace sw
{ {
switch(texGen[coordinate]) switch(texGen[coordinate])
{ {
case TEXGEN_NONE:
hasTexture = true;
break;
case TEXGEN_PASSTHRU: case TEXGEN_PASSTHRU:
hasTexture = hasTexture || (component < input[TexCoord0 + textureStage[coordinate].texCoordIndex].count); hasTexture = hasTexture || (component < input[TexCoord0 + textureStage[coordinate].texCoordIndex].count);
break; break;
......
...@@ -231,8 +231,9 @@ namespace sw ...@@ -231,8 +231,9 @@ namespace sw
TEXGEN_POSITION, TEXGEN_POSITION,
TEXGEN_REFLECTION, TEXGEN_REFLECTION,
TEXGEN_SPHEREMAP, TEXGEN_SPHEREMAP,
TEXGEN_NONE,
TEXGEN_LAST = TEXGEN_SPHEREMAP TEXGEN_LAST = TEXGEN_NONE
}; };
enum TransparencyAntialiasing : unsigned int enum TransparencyAntialiasing : unsigned int
......
...@@ -542,6 +542,16 @@ namespace sw ...@@ -542,6 +542,16 @@ namespace sw
switch(state.textureState[stage].texGenActive) switch(state.textureState[stage].texGenActive)
{ {
case TEXGEN_NONE:
{
Vector4f v = r.v[TexCoord0 + i];
r.o[T0 + stage].x = v.x;
r.o[T0 + stage].y = v.y;
r.o[T0 + stage].z = v.z;
r.o[T0 + stage].w = v.w;
}
break;
case TEXGEN_PASSTHRU: case TEXGEN_PASSTHRU:
{ {
Vector4f v = r.v[TexCoord0 + i]; Vector4f v = r.v[TexCoord0 + i];
......
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