am 3fa3021e: am fb8c84d8: Merge "opengles emulator: Workaround Cordy (Unity) bug with intel driver."

* commit '3fa3021e55d624cc05a67a49c88e4dac36961457':
  opengles emulator: Workaround Cordy (Unity) bug with intel driver.
This commit is contained in:
David Turner
2011-08-10 02:09:36 -07:00
committed by Android Git Automerger
6 changed files with 287 additions and 7 deletions

View File

@@ -50,6 +50,7 @@ GLClientState::GLClientState(int nLocations)
m_states[MATRIXINDEX_LOCATION].glConst = GL_MATRIX_INDEX_ARRAY_OES; m_states[MATRIXINDEX_LOCATION].glConst = GL_MATRIX_INDEX_ARRAY_OES;
m_states[WEIGHT_LOCATION].glConst = GL_WEIGHT_ARRAY_OES; m_states[WEIGHT_LOCATION].glConst = GL_WEIGHT_ARRAY_OES;
m_activeTexture = 0; m_activeTexture = 0;
m_currentProgram = 0;
m_pixelStore.unpack_alignment = 4; m_pixelStore.unpack_alignment = 4;
m_pixelStore.pack_alignment = 4; m_pixelStore.pack_alignment = 4;

View File

@@ -120,6 +120,9 @@ public:
} }
size_t pixelDataSize(GLsizei width, GLsizei height, GLenum format, GLenum type, int pack) const; size_t pixelDataSize(GLsizei width, GLsizei height, GLenum format, GLenum type, int pack) const;
void setCurrentProgram(GLint program) { m_currentProgram = program; }
GLint currentProgram() const { return m_currentProgram; }
private: private:
PixelStoreState m_pixelStore; PixelStoreState m_pixelStore;
VertexAttribState *m_states; VertexAttribState *m_states;
@@ -127,7 +130,7 @@ private:
GLuint m_currentArrayVbo; GLuint m_currentArrayVbo;
GLuint m_currentIndexVbo; GLuint m_currentIndexVbo;
int m_activeTexture; int m_activeTexture;
GLint m_currentProgram;
bool validLocation(int location) { return (location >= 0 && location < m_nLocations); } bool validLocation(int location) { return (location >= 0 && location < m_nLocations); }
public: public:

View File

@@ -11,7 +11,9 @@ BufferData::BufferData(GLsizeiptr size, void * data) : m_size(size)
} }
/**** ProgramData ****/ /**** ProgramData ****/
ProgramData::ProgramData() : m_numIndexes(0), m_initialized(false) ProgramData::ProgramData() : m_numIndexes(0),
m_initialized(false),
m_locShiftWAR(false)
{ {
m_Indexes = NULL; m_Indexes = NULL;
} }
@@ -22,6 +24,7 @@ void ProgramData::initProgramData(GLuint numIndexes)
m_numIndexes = numIndexes; m_numIndexes = numIndexes;
delete[] m_Indexes; delete[] m_Indexes;
m_Indexes = new IndexInfo[numIndexes]; m_Indexes = new IndexInfo[numIndexes];
m_locShiftWAR = false;
} }
bool ProgramData::isInitialized() bool ProgramData::isInitialized()
@@ -66,6 +69,30 @@ GLenum ProgramData::getTypeForLocation(GLint location)
return 0; 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::GLSharedGroup() : GLSharedGroup::GLSharedGroup() :
@@ -188,6 +215,29 @@ bool GLSharedGroup::isProgram(GLuint program)
return (pData!=NULL); 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) void GLSharedGroup::addShaderData(GLuint shader)
{ {

View File

@@ -54,6 +54,7 @@ private:
GLuint m_numIndexes; GLuint m_numIndexes;
IndexInfo* m_Indexes; IndexInfo* m_Indexes;
bool m_initialized; bool m_initialized;
bool m_locShiftWAR;
public: public:
ProgramData(); ProgramData();
void initProgramData(GLuint numIndexes); void initProgramData(GLuint numIndexes);
@@ -62,6 +63,11 @@ public:
void setIndexInfo(GLuint index, GLint base, GLint size, GLenum type); void setIndexInfo(GLuint index, GLint base, GLint size, GLenum type);
GLuint getIndexForLocation(GLint location); GLuint getIndexForLocation(GLint location);
GLenum getTypeForLocation(GLint location); GLenum getTypeForLocation(GLint location);
void setupLocationShiftWAR();
GLint locationWARHostToApp(GLint hostLoc);
GLint locationWARAppToHost(GLint appLoc);
}; };
class GLSharedGroup { class GLSharedGroup {
@@ -86,6 +92,9 @@ public:
void deleteProgramData(GLuint program); void deleteProgramData(GLuint program);
void setProgramIndexInfo(GLuint program, GLuint index, GLint base, GLint size, GLenum type); void setProgramIndexInfo(GLuint program, GLuint index, GLint base, GLint size, GLenum type);
GLenum getProgramUniformType(GLuint program, GLint location); GLenum getProgramUniformType(GLuint program, GLint location);
void setupLocationShiftWAR(GLuint program);
GLint locationWARHostToApp(GLuint program, GLint hostLoc);
GLint locationWARAppToHost(GLuint program, GLint appLoc);
void addShaderData(GLuint shader); void addShaderData(GLuint shader);
bool isShader(GLuint shader); bool isShader(GLuint shader);

View File

@@ -54,6 +54,28 @@ GL2Encoder::GL2Encoder(IOStream *stream) : gl2_encoder_context_t(stream)
m_glCreateProgram_enc = set_glCreateProgram(s_glCreateProgram); m_glCreateProgram_enc = set_glCreateProgram(s_glCreateProgram);
m_glCreateShader_enc = set_glCreateShader(s_glCreateShader); m_glCreateShader_enc = set_glCreateShader(s_glCreateShader);
m_glDeleteShader_enc = set_glDeleteShader(s_glDeleteShader); m_glDeleteShader_enc = set_glDeleteShader(s_glDeleteShader);
m_glGetUniformLocation_enc = set_glGetUniformLocation(s_glGetUniformLocation);
m_glUseProgram_enc = set_glUseProgram(s_glUseProgram);
m_glUniform1f_enc = set_glUniform1f(s_glUniform1f);
m_glUniform1fv_enc = set_glUniform1fv(s_glUniform1fv);
m_glUniform1i_enc = set_glUniform1i(s_glUniform1i);
m_glUniform1iv_enc = set_glUniform1iv(s_glUniform1iv);
m_glUniform2f_enc = set_glUniform2f(s_glUniform2f);
m_glUniform2fv_enc = set_glUniform2fv(s_glUniform2fv);
m_glUniform2i_enc = set_glUniform2i(s_glUniform2i);
m_glUniform2iv_enc = set_glUniform2iv(s_glUniform2iv);
m_glUniform3f_enc = set_glUniform3f(s_glUniform3f);
m_glUniform3fv_enc = set_glUniform3fv(s_glUniform3fv);
m_glUniform3i_enc = set_glUniform3i(s_glUniform3i);
m_glUniform3iv_enc = set_glUniform3iv(s_glUniform3iv);
m_glUniform4f_enc = set_glUniform4f(s_glUniform4f);
m_glUniform4fv_enc = set_glUniform4fv(s_glUniform4fv);
m_glUniform4i_enc = set_glUniform4i(s_glUniform4i);
m_glUniform4iv_enc = set_glUniform4iv(s_glUniform4iv);
m_glUniformMatrix2fv_enc = set_glUniformMatrix2fv(s_glUniformMatrix2fv);
m_glUniformMatrix3fv_enc = set_glUniformMatrix3fv(s_glUniformMatrix3fv);
m_glUniformMatrix4fv_enc = set_glUniformMatrix4fv(s_glUniformMatrix4fv);
} }
GL2Encoder::~GL2Encoder() GL2Encoder::~GL2Encoder()
@@ -450,9 +472,10 @@ void GL2Encoder::s_glLinkProgram(void * self, GLuint program)
for (GLint i=0 ; i<numUniforms ; ++i) for (GLint i=0 ; i<numUniforms ; ++i)
{ {
ctx->glGetActiveUniform(self, program, i, maxLength, NULL, &size, &type, name); ctx->glGetActiveUniform(self, program, i, maxLength, NULL, &size, &type, name);
location = ctx->glGetUniformLocation(self, program, name); location = ctx->m_glGetUniformLocation_enc(self, program, name);
ctx->m_shared->setProgramIndexInfo(program, i, location, size, type); ctx->m_shared->setProgramIndexInfo(program, i, location, size, type);
} }
ctx->m_shared->setupLocationShiftWAR(program);
delete[] name; delete[] name;
} }
@@ -470,16 +493,18 @@ void GL2Encoder::s_glGetUniformiv(void *self, GLuint program, GLint location, GL
GL2Encoder *ctx = (GL2Encoder*)self; GL2Encoder *ctx = (GL2Encoder*)self;
SET_ERROR_IF(!(ctx->m_shared->isProgram(program) || ctx->m_shared->isShader(program)), GL_INVALID_VALUE); SET_ERROR_IF(!(ctx->m_shared->isProgram(program) || ctx->m_shared->isShader(program)), GL_INVALID_VALUE);
SET_ERROR_IF(!ctx->m_shared->isProgramInitialized(program), GL_INVALID_OPERATION); SET_ERROR_IF(!ctx->m_shared->isProgramInitialized(program), GL_INVALID_OPERATION);
SET_ERROR_IF(ctx->m_shared->getProgramUniformType(program,location)==0, GL_INVALID_OPERATION); GLint hostLoc = ctx->m_shared->locationWARAppToHost(program, location);
ctx->m_glGetUniformiv_enc(self, program, location, params); SET_ERROR_IF(ctx->m_shared->getProgramUniformType(program,hostLoc)==0, GL_INVALID_OPERATION);
ctx->m_glGetUniformiv_enc(self, program, hostLoc, params);
} }
void GL2Encoder::s_glGetUniformfv(void *self, GLuint program, GLint location, GLfloat* params) void GL2Encoder::s_glGetUniformfv(void *self, GLuint program, GLint location, GLfloat* params)
{ {
GL2Encoder *ctx = (GL2Encoder*)self; GL2Encoder *ctx = (GL2Encoder*)self;
SET_ERROR_IF(!(ctx->m_shared->isProgram(program) || ctx->m_shared->isShader(program)), GL_INVALID_VALUE); SET_ERROR_IF(!(ctx->m_shared->isProgram(program) || ctx->m_shared->isShader(program)), GL_INVALID_VALUE);
SET_ERROR_IF(!ctx->m_shared->isProgramInitialized(program), GL_INVALID_OPERATION); SET_ERROR_IF(!ctx->m_shared->isProgramInitialized(program), GL_INVALID_OPERATION);
SET_ERROR_IF(ctx->m_shared->getProgramUniformType(program,location)==0, GL_INVALID_OPERATION); GLint hostLoc = ctx->m_shared->locationWARAppToHost(program,location);
ctx->m_glGetUniformfv_enc(self, program, location, params); SET_ERROR_IF(ctx->m_shared->getProgramUniformType(program,hostLoc)==0, GL_INVALID_OPERATION);
ctx->m_glGetUniformfv_enc(self, program, hostLoc, params);
} }
GLuint GL2Encoder::s_glCreateProgram(void * self) GLuint GL2Encoder::s_glCreateProgram(void * self)
@@ -506,3 +531,151 @@ void GL2Encoder::s_glDeleteShader(void *self, GLenum shader)
ctx->m_glDeleteShader_enc(self,shader); ctx->m_glDeleteShader_enc(self,shader);
ctx->m_shared->deleteShaderData(shader); ctx->m_shared->deleteShaderData(shader);
} }
int GL2Encoder::s_glGetUniformLocation(void *self, GLuint program, const GLchar *name)
{
GL2Encoder *ctx = (GL2Encoder*)self;
int hostLoc = ctx->m_glGetUniformLocation_enc(self, program, name);
return ctx->m_shared->locationWARHostToApp(program, hostLoc);
}
void GL2Encoder::s_glUseProgram(void *self, GLuint program)
{
GL2Encoder *ctx = (GL2Encoder*)self;
ctx->m_glUseProgram_enc(self, program);
ctx->m_state->setCurrentProgram(program);
}
void GL2Encoder::s_glUniform1f(void *self , GLint location, GLfloat x)
{
GL2Encoder *ctx = (GL2Encoder*)self;
GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
ctx->m_glUniform1f_enc(self, hostLoc, x);
}
void GL2Encoder::s_glUniform1fv(void *self , GLint location, GLsizei count, const GLfloat* v)
{
GL2Encoder *ctx = (GL2Encoder*)self;
GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
ctx->m_glUniform1fv_enc(self, hostLoc, count, v);
}
void GL2Encoder::s_glUniform1i(void *self , GLint location, GLint x)
{
GL2Encoder *ctx = (GL2Encoder*)self;
GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
ctx->m_glUniform1i_enc(self, hostLoc, x);
}
void GL2Encoder::s_glUniform1iv(void *self , GLint location, GLsizei count, const GLint* v)
{
GL2Encoder *ctx = (GL2Encoder*)self;
GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
ctx->m_glUniform1iv_enc(self, hostLoc, count, v);
}
void GL2Encoder::s_glUniform2f(void *self , GLint location, GLfloat x, GLfloat y)
{
GL2Encoder *ctx = (GL2Encoder*)self;
GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
ctx->m_glUniform2f_enc(self, hostLoc, x, y);
}
void GL2Encoder::s_glUniform2fv(void *self , GLint location, GLsizei count, const GLfloat* v)
{
GL2Encoder *ctx = (GL2Encoder*)self;
GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
ctx->m_glUniform2fv_enc(self, hostLoc, count, v);
}
void GL2Encoder::s_glUniform2i(void *self , GLint location, GLint x, GLint y)
{
GL2Encoder *ctx = (GL2Encoder*)self;
GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
ctx->m_glUniform2i_enc(self, hostLoc, x, y);
}
void GL2Encoder::s_glUniform2iv(void *self , GLint location, GLsizei count, const GLint* v)
{
GL2Encoder *ctx = (GL2Encoder*)self;
GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
ctx->m_glUniform2iv_enc(self, hostLoc, count, v);
}
void GL2Encoder::s_glUniform3f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z)
{
GL2Encoder *ctx = (GL2Encoder*)self;
GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
ctx->m_glUniform3f_enc(self, hostLoc, x, y, z);
}
void GL2Encoder::s_glUniform3fv(void *self , GLint location, GLsizei count, const GLfloat* v)
{
GL2Encoder *ctx = (GL2Encoder*)self;
GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
ctx->m_glUniform3fv_enc(self, hostLoc, count, v);
}
void GL2Encoder::s_glUniform3i(void *self , GLint location, GLint x, GLint y, GLint z)
{
GL2Encoder *ctx = (GL2Encoder*)self;
GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
ctx->m_glUniform3i_enc(self, hostLoc, x, y, z);
}
void GL2Encoder::s_glUniform3iv(void *self , GLint location, GLsizei count, const GLint* v)
{
GL2Encoder *ctx = (GL2Encoder*)self;
GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
ctx->m_glUniform3iv_enc(self, hostLoc, count, v);
}
void GL2Encoder::s_glUniform4f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
{
GL2Encoder *ctx = (GL2Encoder*)self;
GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
ctx->m_glUniform4f_enc(self, hostLoc, x, y, z, w);
}
void GL2Encoder::s_glUniform4fv(void *self , GLint location, GLsizei count, const GLfloat* v)
{
GL2Encoder *ctx = (GL2Encoder*)self;
GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
ctx->m_glUniform4fv_enc(self, hostLoc, count, v);
}
void GL2Encoder::s_glUniform4i(void *self , GLint location, GLint x, GLint y, GLint z, GLint w)
{
GL2Encoder *ctx = (GL2Encoder*)self;
GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
ctx->m_glUniform4i_enc(self, hostLoc, x, y, z, w);
}
void GL2Encoder::s_glUniform4iv(void *self , GLint location, GLsizei count, const GLint* v)
{
GL2Encoder *ctx = (GL2Encoder*)self;
GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
ctx->m_glUniform4iv_enc(self, hostLoc, count, v);
}
void GL2Encoder::s_glUniformMatrix2fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
{
GL2Encoder *ctx = (GL2Encoder*)self;
GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
ctx->m_glUniformMatrix2fv_enc(self, hostLoc, count, transpose, value);
}
void GL2Encoder::s_glUniformMatrix3fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
{
GL2Encoder *ctx = (GL2Encoder*)self;
GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
ctx->m_glUniformMatrix3fv_enc(self, hostLoc, count, transpose, value);
}
void GL2Encoder::s_glUniformMatrix4fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
{
GL2Encoder *ctx = (GL2Encoder*)self;
GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
ctx->m_glUniformMatrix4fv_enc(self, hostLoc, count, transpose, value);
}

View File

@@ -141,5 +141,49 @@ private:
glDeleteShader_client_proc_t m_glDeleteShader_enc; glDeleteShader_client_proc_t m_glDeleteShader_enc;
static void s_glDeleteShader(void *self, GLuint shader); static void s_glDeleteShader(void *self, GLuint shader);
glGetUniformLocation_client_proc_t m_glGetUniformLocation_enc;
static int s_glGetUniformLocation(void *self, GLuint program, const GLchar *name);
glUseProgram_client_proc_t m_glUseProgram_enc;
glUniform1f_client_proc_t m_glUniform1f_enc;
glUniform1fv_client_proc_t m_glUniform1fv_enc;
glUniform1i_client_proc_t m_glUniform1i_enc;
glUniform1iv_client_proc_t m_glUniform1iv_enc;
glUniform2f_client_proc_t m_glUniform2f_enc;
glUniform2fv_client_proc_t m_glUniform2fv_enc;
glUniform2i_client_proc_t m_glUniform2i_enc;
glUniform2iv_client_proc_t m_glUniform2iv_enc;
glUniform3f_client_proc_t m_glUniform3f_enc;
glUniform3fv_client_proc_t m_glUniform3fv_enc;
glUniform3i_client_proc_t m_glUniform3i_enc;
glUniform3iv_client_proc_t m_glUniform3iv_enc;
glUniform4f_client_proc_t m_glUniform4f_enc;
glUniform4fv_client_proc_t m_glUniform4fv_enc;
glUniform4i_client_proc_t m_glUniform4i_enc;
glUniform4iv_client_proc_t m_glUniform4iv_enc;
glUniformMatrix2fv_client_proc_t m_glUniformMatrix2fv_enc;
glUniformMatrix3fv_client_proc_t m_glUniformMatrix3fv_enc;
glUniformMatrix4fv_client_proc_t m_glUniformMatrix4fv_enc;
static void s_glUseProgram(void *self, GLuint program);
static void s_glUniform1f(void *self , GLint location, GLfloat x);
static void s_glUniform1fv(void *self , GLint location, GLsizei count, const GLfloat* v);
static void s_glUniform1i(void *self , GLint location, GLint x);
static void s_glUniform1iv(void *self , GLint location, GLsizei count, const GLint* v);
static void s_glUniform2f(void *self , GLint location, GLfloat x, GLfloat y);
static void s_glUniform2fv(void *self , GLint location, GLsizei count, const GLfloat* v);
static void s_glUniform2i(void *self , GLint location, GLint x, GLint y);
static void s_glUniform2iv(void *self , GLint location, GLsizei count, const GLint* v);
static void s_glUniform3f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z);
static void s_glUniform3fv(void *self , GLint location, GLsizei count, const GLfloat* v);
static void s_glUniform3i(void *self , GLint location, GLint x, GLint y, GLint z);
static void s_glUniform3iv(void *self , GLint location, GLsizei count, const GLint* v);
static void s_glUniform4f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
static void s_glUniform4fv(void *self , GLint location, GLsizei count, const GLfloat* v);
static void s_glUniform4i(void *self , GLint location, GLint x, GLint y, GLint z, GLint w);
static void s_glUniform4iv(void *self , GLint location, GLsizei count, const GLint* v);
static void s_glUniformMatrix2fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
static void s_glUniformMatrix3fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
static void s_glUniformMatrix4fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
}; };
#endif #endif