summaryrefslogtreecommitdiff
path: root/tools/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp
diff options
context:
space:
mode:
authorGuy Zadickario <guy@graphtech.co.il>2011-08-10 08:39:53 +0300
committerGuy Zadickario <guy@graphtech.co.il>2011-08-11 17:36:03 +0300
commit7944edcdb28d6924f782fb04464526165447c1e6 (patch)
treef3e6f35fac5432ee88caab4b7ec0edfae5353316 /tools/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp
parentea7f72a6c761352fb4c246b3c08737d1fd58203c (diff)
opengles emulator: fix the uniform location WAR for intel platforms
Fixed the location shift WAR to work for arrays that starts at location 0. Fixed conformance regressions made by this workaround. The conversion should be smarter than just shifting 16-bits back and forth, it should take into account if array element is being accessed. Change-Id: Icb746c67e16edfacb8264a1e687fd24ac6e868e7
Diffstat (limited to 'tools/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp')
-rw-r--r--tools/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp71
1 files changed, 55 insertions, 16 deletions
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp b/tools/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp
index f46889b3d..ff48c9d6a 100644
--- a/tools/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp
@@ -45,19 +45,30 @@ void ProgramData::setIndexInfo(GLuint index, GLint base, GLint size, GLenum type
m_Indexes[index].base = base;
m_Indexes[index].size = size;
m_Indexes[index].type = type;
+ if (index > 0) {
+ m_Indexes[index].appBase = m_Indexes[index-1].appBase +
+ m_Indexes[index-1].size;
+ }
+ else {
+ m_Indexes[index].appBase = 0;
+ }
+ m_Indexes[index].hostLocsPerElement = 1;
}
GLuint ProgramData::getIndexForLocation(GLint location)
{
- GLuint i=0;
- for (i=0;i<m_numIndexes;++i)
+ GLuint index = m_numIndexes;
+ GLint minDist = -1;
+ for (GLuint i=0;i<m_numIndexes;++i)
{
- GLint low = m_Indexes[i].base;;
- GLint high = low + m_Indexes[i].size;
- if (location >= low && location < high)
- break;
+ GLint dist = location - m_Indexes[i].base;
+ if (dist >= 0 &&
+ (minDist < 0 || dist < minDist)) {
+ index = i;
+ minDist = dist;
+ }
}
- return i;
+ return index;
}
GLenum ProgramData::getTypeForLocation(GLint location)
@@ -72,24 +83,44 @@ GLenum ProgramData::getTypeForLocation(GLint location)
void ProgramData::setupLocationShiftWAR()
{
m_locShiftWAR = false;
- for (int i=0; i<m_numIndexes; i++) {
+ for (GLuint i=0; i<m_numIndexes; i++) {
if (0 != (m_Indexes[i].base & 0xffff)) {
return;
}
}
- m_locShiftWAR = true;
+ // if we have one uniform at location 0, we do not need the WAR.
+ if (m_numIndexes > 1) {
+ m_locShiftWAR = true;
+ }
}
-GLint ProgramData::locationWARHostToApp(GLint hostLoc)
+GLint ProgramData::locationWARHostToApp(GLint hostLoc, GLint arrIndex)
{
- if (m_locShiftWAR && hostLoc>0) return hostLoc>>16;
- else return hostLoc;
+ if (!m_locShiftWAR) return hostLoc;
+
+ GLuint index = getIndexForLocation(hostLoc);
+ if (index<m_numIndexes) {
+ if (arrIndex > 0) {
+ m_Indexes[index].hostLocsPerElement =
+ (hostLoc - m_Indexes[index].base) / arrIndex;
+ }
+ return m_Indexes[index].appBase + arrIndex;
+ }
+ return -1;
}
GLint ProgramData::locationWARAppToHost(GLint appLoc)
{
- if (m_locShiftWAR && appLoc>0) return appLoc<<16;
- else return appLoc;
+ if (!m_locShiftWAR) return appLoc;
+
+ for(GLuint i=0; i<m_numIndexes; i++) {
+ GLint elemIndex = appLoc - m_Indexes[i].appBase;
+ if (elemIndex >= 0 && elemIndex < m_Indexes[i].size) {
+ return m_Indexes[i].base +
+ elemIndex * m_Indexes[i].hostLocsPerElement;
+ }
+ }
+ return -1;
}
@@ -222,11 +253,11 @@ void GLSharedGroup::setupLocationShiftWAR(GLuint program)
if (pData) pData->setupLocationShiftWAR();
}
-GLint GLSharedGroup::locationWARHostToApp(GLuint program, GLint hostLoc)
+GLint GLSharedGroup::locationWARHostToApp(GLuint program, GLint hostLoc, GLint arrIndex)
{
android::AutoMutex _lock(m_lock);
ProgramData* pData = m_programs.valueFor(program);
- if (pData) return pData->locationWARHostToApp(hostLoc);
+ if (pData) return pData->locationWARHostToApp(hostLoc, arrIndex);
else return hostLoc;
}
@@ -238,6 +269,14 @@ GLint GLSharedGroup::locationWARAppToHost(GLuint program, GLint appLoc)
else return appLoc;
}
+bool GLSharedGroup::needUniformLocationWAR(GLuint program)
+{
+ android::AutoMutex _lock(m_lock);
+ ProgramData* pData = m_programs.valueFor(program);
+ if (pData) return pData->needUniformLocationWAR();
+ return false;
+}
+
void GLSharedGroup::addShaderData(GLuint shader)
{