opengles emulator: Workaround Cordy (Unity) bug with intel driver.
Uniform locations are 32-bit values which the application queries from the driver after a shader program is linked. It seems that Cordy game (possibly all Unity based apps) store the returned location as 16-bit value. Intel driver returns location values in the upper 16-bit range :( This is a workaround for this issue, when a program is linked we check the locations of all uniforms, if all locations are within the upper 16-bit range (as with Intel driver) we shift the location value before returning to the application. Also override all functions which take a location parameter and do the reverse shift before sending a location value to the host. Change-Id: I234aaafe3313774b5da79eb1dac713b89b10ad60
This commit is contained in:
committed by
David 'Digit' Turner
parent
f7e07ec9ea
commit
52829d82ab
@@ -11,7 +11,9 @@ BufferData::BufferData(GLsizeiptr size, void * data) : m_size(size)
|
||||
}
|
||||
|
||||
/**** ProgramData ****/
|
||||
ProgramData::ProgramData() : m_numIndexes(0), m_initialized(false)
|
||||
ProgramData::ProgramData() : m_numIndexes(0),
|
||||
m_initialized(false),
|
||||
m_locShiftWAR(false)
|
||||
{
|
||||
m_Indexes = NULL;
|
||||
}
|
||||
@@ -22,6 +24,7 @@ void ProgramData::initProgramData(GLuint numIndexes)
|
||||
m_numIndexes = numIndexes;
|
||||
delete[] m_Indexes;
|
||||
m_Indexes = new IndexInfo[numIndexes];
|
||||
m_locShiftWAR = false;
|
||||
}
|
||||
|
||||
bool ProgramData::isInitialized()
|
||||
@@ -66,6 +69,30 @@ GLenum ProgramData::getTypeForLocation(GLint location)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ProgramData::setupLocationShiftWAR()
|
||||
{
|
||||
m_locShiftWAR = false;
|
||||
for (int i=0; i<m_numIndexes; i++) {
|
||||
if (0 != (m_Indexes[i].base & 0xffff)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_locShiftWAR = true;
|
||||
}
|
||||
|
||||
GLint ProgramData::locationWARHostToApp(GLint hostLoc)
|
||||
{
|
||||
if (m_locShiftWAR) return hostLoc>>16;
|
||||
else return hostLoc;
|
||||
}
|
||||
|
||||
GLint ProgramData::locationWARAppToHost(GLint appLoc)
|
||||
{
|
||||
if (m_locShiftWAR) return appLoc<<16;
|
||||
else return appLoc;
|
||||
}
|
||||
|
||||
|
||||
/***** GLSharedGroup ****/
|
||||
|
||||
GLSharedGroup::GLSharedGroup() :
|
||||
@@ -188,6 +215,29 @@ bool GLSharedGroup::isProgram(GLuint program)
|
||||
return (pData!=NULL);
|
||||
}
|
||||
|
||||
void GLSharedGroup::setupLocationShiftWAR(GLuint program)
|
||||
{
|
||||
android::AutoMutex _lock(m_lock);
|
||||
ProgramData* pData = m_programs.valueFor(program);
|
||||
if (pData) pData->setupLocationShiftWAR();
|
||||
}
|
||||
|
||||
GLint GLSharedGroup::locationWARHostToApp(GLuint program, GLint hostLoc)
|
||||
{
|
||||
android::AutoMutex _lock(m_lock);
|
||||
ProgramData* pData = m_programs.valueFor(program);
|
||||
if (pData) return pData->locationWARHostToApp(hostLoc);
|
||||
else return hostLoc;
|
||||
}
|
||||
|
||||
GLint GLSharedGroup::locationWARAppToHost(GLuint program, GLint appLoc)
|
||||
{
|
||||
android::AutoMutex _lock(m_lock);
|
||||
ProgramData* pData = m_programs.valueFor(program);
|
||||
if (pData) return pData->locationWARAppToHost(appLoc);
|
||||
else return appLoc;
|
||||
}
|
||||
|
||||
|
||||
void GLSharedGroup::addShaderData(GLuint shader)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user