aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--emulator/opengl/host/include/libOpenglRender/render_api.h7
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp11
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp7
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp11
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp6
-rw-r--r--emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp42
-rw-r--r--emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h9
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp19
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h10
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/render_api.cpp10
10 files changed, 104 insertions, 28 deletions
diff --git a/emulator/opengl/host/include/libOpenglRender/render_api.h b/emulator/opengl/host/include/libOpenglRender/render_api.h
index 1004932..ebb02eb 100644
--- a/emulator/opengl/host/include/libOpenglRender/render_api.h
+++ b/emulator/opengl/host/include/libOpenglRender/render_api.h
@@ -101,6 +101,13 @@ DECL(int, setStreamMode, (int mode));
DECL(int, initOpenGLRenderer, (int width, int height, int portNum,
OnPostFn onPost, void* onPostContext));
+/* getHardwareStrings - describe the GPU hardware and driver.
+ * The underlying GL's vendor/renderer/version strings are returned to the
+ * caller. The pointers become invalid after a call to stopOpenGLRenderer().
+ */
+DECL(void, getHardwareStrings, (const char** vendor, const char** renderer,
+ const char** version));
+
/* createOpenGLSubwindow -
* Create a native subwindow which is a child of 'window'
* to be used for framebuffer display.
diff --git a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp b/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp
index abf461c..ecf51bb 100644
--- a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp
+++ b/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp
@@ -31,13 +31,10 @@ void GLEScmContext::init() {
m_texCoords = new GLESpointer[s_glSupport.maxTexUnits];
m_map[GL_TEXTURE_COORD_ARRAY] = &m_texCoords[m_clientActiveTexture];
- const char* baseRenderer = (const char*)dispatcher().glGetString(GL_RENDERER);
- size_t baseRendererLen = strlen(baseRenderer);
- s_glRenderer.clear();
- s_glRenderer.reserve(19 + baseRendererLen);
- s_glRenderer.append("OpenGL ES-CM 1.1 (", 18);
- s_glRenderer.append(baseRenderer, baseRendererLen);
- s_glRenderer.append(")", 1);
+ buildStrings((const char*)dispatcher().glGetString(GL_VENDOR),
+ (const char*)dispatcher().glGetString(GL_RENDERER),
+ (const char*)dispatcher().glGetString(GL_VERSION),
+ "OpenGL ES-CM 1.1");
}
m_initialized = true;
}
diff --git a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp b/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
index b78a022..3ae271f 100644
--- a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
+++ b/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
@@ -248,16 +248,13 @@ GL_API GLenum GL_APIENTRY glGetError(void) {
GL_API const GLubyte * GL_APIENTRY glGetString( GLenum name) {
GET_CTX_RET(NULL)
- static const GLubyte VENDOR[] = "Google";
- static const GLubyte VERSION[] = "OpenGL ES-CM 1.1";
-
switch(name) {
case GL_VENDOR:
- return VENDOR;
+ return (const GLubyte*)ctx->getVendorString();
case GL_RENDERER:
return (const GLubyte*)ctx->getRendererString();
case GL_VERSION:
- return VERSION;
+ return (const GLubyte*)ctx->getVersionString();
case GL_EXTENSIONS:
return (const GLubyte*)ctx->getExtensionString();
default:
diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp
index 73acb61..1457cec 100644
--- a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp
+++ b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp
@@ -28,13 +28,10 @@ void GLESv2Context::init() {
}
setAttribute0value(0.0, 0.0, 0.0, 1.0);
- const char* baseRenderer = (const char*)dispatcher().glGetString(GL_RENDERER);
- size_t baseRendererLen = strlen(baseRenderer);
- s_glRenderer.clear();
- s_glRenderer.reserve(16 + baseRendererLen);
- s_glRenderer.append("OpenGL ES 2.0 (", 15);
- s_glRenderer.append(baseRenderer, baseRendererLen);
- s_glRenderer.append(")", 1);
+ buildStrings((const char*)dispatcher().glGetString(GL_VENDOR),
+ (const char*)dispatcher().glGetString(GL_RENDERER),
+ (const char*)dispatcher().glGetString(GL_VERSION),
+ "OpenGL ES 2.0");
}
m_initialized = true;
}
diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
index 412584d..7ae9427 100644
--- a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
+++ b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
@@ -1316,16 +1316,14 @@ GL_APICALL void GL_APIENTRY glGetShaderSource(GLuint shader, GLsizei bufsize, G
GL_APICALL const GLubyte* GL_APIENTRY glGetString(GLenum name){
GET_CTX_RET(NULL)
- static const GLubyte VENDOR[] = "Google";
- static const GLubyte VERSION[] = "OpenGL ES 2.0";
static const GLubyte SHADING[] = "OpenGL ES GLSL ES 1.0.17";
switch(name) {
case GL_VENDOR:
- return VENDOR;
+ return (const GLubyte*)ctx->getVendorString();
case GL_RENDERER:
return (const GLubyte*)ctx->getRendererString();
case GL_VERSION:
- return VERSION;
+ return (const GLubyte*)ctx->getVersionString();
case GL_SHADING_LANGUAGE_VERSION:
return SHADING;
case GL_EXTENSIONS:
diff --git a/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp b/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp
index cff639e..387eb2d 100644
--- a/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp
+++ b/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp
@@ -86,7 +86,9 @@ void GLESConversionArrays::operator++(){
GLDispatch GLEScontext::s_glDispatch;
android::Mutex GLEScontext::s_lock;
std::string* GLEScontext::s_glExtensions= NULL;
+std::string GLEScontext::s_glVendor;
std::string GLEScontext::s_glRenderer;
+std::string GLEScontext::s_glVersion;
GLSupport GLEScontext::s_glSupport;
Version::Version():m_major(0),
@@ -483,10 +485,18 @@ const char * GLEScontext::getExtensionString() {
return ret;
}
+const char * GLEScontext::getVendorString() const {
+ return s_glVendor.c_str();
+}
+
const char * GLEScontext::getRendererString() const {
return s_glRenderer.c_str();
}
+const char * GLEScontext::getVersionString() const {
+ return s_glVersion.c_str();
+}
+
void GLEScontext::getGlobalLock() {
s_lock.lock();
}
@@ -547,6 +557,38 @@ void GLEScontext::initCapsLocked(const GLubyte * extensionString)
}
+void GLEScontext::buildStrings(const char* baseVendor,
+ const char* baseRenderer, const char* baseVersion, const char* version)
+{
+ static const char VENDOR[] = {"Google ("};
+ static const char RENDERER[] = {"Android Emulator OpenGL ES Translator ("};
+ const size_t VENDOR_LEN = sizeof(VENDOR) - 1;
+ const size_t RENDERER_LEN = sizeof(RENDERER) - 1;
+
+ size_t baseVendorLen = strlen(baseVendor);
+ s_glVendor.clear();
+ s_glVendor.reserve(baseVendorLen + VENDOR_LEN + 1);
+ s_glVendor.append(VENDOR, VENDOR_LEN);
+ s_glVendor.append(baseVendor, baseVendorLen);
+ s_glVendor.append(")", 1);
+
+ size_t baseRendererLen = strlen(baseRenderer);
+ s_glRenderer.clear();
+ s_glRenderer.reserve(baseRendererLen + RENDERER_LEN + 1);
+ s_glRenderer.append(RENDERER, RENDERER_LEN);
+ s_glRenderer.append(baseRenderer, baseRendererLen);
+ s_glRenderer.append(")", 1);
+
+ size_t baseVersionLen = strlen(baseVersion);
+ size_t versionLen = strlen(version);
+ s_glVersion.clear();
+ s_glVersion.reserve(baseVersionLen + versionLen + 3);
+ s_glVersion.append(version, versionLen);
+ s_glVersion.append(" (", 2);
+ s_glVersion.append(baseVersion, baseVersionLen);
+ s_glVersion.append(")", 1);
+}
+
bool GLEScontext::isTextureUnitEnabled(GLenum unit) {
for (int i=0;i<NUM_TEXTURE_TARGETS;++i) {
if (m_texState[unit-GL_TEXTURE0][i].enabled)
diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h b/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h
index fbc118f..20509fc 100644
--- a/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h
+++ b/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h
@@ -147,7 +147,9 @@ public:
bool setBufferData(GLenum target,GLsizeiptr size,const GLvoid* data,GLenum usage);
bool setBufferSubData(GLenum target,GLintptr offset,GLsizeiptr size,const GLvoid* data);
const char * getExtensionString();
+ const char * getVendorString() const;
const char * getRendererString() const;
+ const char * getVersionString() const;
void getGlobalLock();
void releaseGlobalLock();
virtual GLSupport* getCaps(){return &s_glSupport;};
@@ -176,6 +178,7 @@ public:
virtual bool glGetFixedv(GLenum pname, GLfixed *params);
protected:
+ static void buildStrings(const char* baseVendor, const char* baseRenderer, const char* baseVersion, const char* version);
virtual bool needConvert(GLESConversionArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct,GLESpointer* p,GLenum array_id) = 0;
void convertDirect(GLESConversionArrays& fArrs,GLint first,GLsizei count,GLenum array_id,GLESpointer* p);
void convertDirectVBO(GLESConversionArrays& fArrs,GLint first,GLsizei count,GLenum array_id,GLESpointer* p);
@@ -183,6 +186,7 @@ protected:
void convertIndirectVBO(GLESConversionArrays& fArrs,GLsizei count,GLenum indices_type,const GLvoid* indices,GLenum array_id,GLESpointer* p);
void initCapsLocked(const GLubyte * extensionString);
virtual void initExtensionString() =0;
+
static android::Mutex s_lock;
static GLDispatch s_glDispatch;
bool m_initialized;
@@ -190,7 +194,6 @@ protected:
GLint m_unpackAlignment;
ArraysMap m_map;
static std::string* s_glExtensions;
- static std::string s_glRenderer;
static GLSupport s_glSupport;
private:
@@ -205,6 +208,10 @@ private:
unsigned int m_elementBuffer;
GLuint m_renderbuffer;
GLuint m_framebuffer;
+
+ static std::string s_glVendor;
+ static std::string s_glRenderer;
+ static std::string s_glVersion;
};
#endif
diff --git a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp b/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp
index b7599ce..fde82a1 100644
--- a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp
+++ b/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp
@@ -345,6 +345,14 @@ bool FrameBuffer::initialize(int width, int height, OnPostFn onPost, void* onPos
}
}
+ //
+ // Cache the GL strings so we don't have to think about threading or
+ // current-context when asked for them.
+ //
+ fb->m_glVendor = (const char*)s_gl.glGetString(GL_VENDOR);
+ fb->m_glRenderer = (const char*)s_gl.glGetString(GL_RENDERER);
+ fb->m_glVersion = (const char*)s_gl.glGetString(GL_VERSION);
+
// release the FB context
fb->unbind_locked();
@@ -366,7 +374,7 @@ FrameBuffer::FrameBuffer(int p_width, int p_height,
m_prevContext(EGL_NO_CONTEXT),
m_prevReadSurf(EGL_NO_SURFACE),
m_prevDrawSurf(EGL_NO_SURFACE),
- m_subWin(NULL),
+ m_subWin((EGLNativeWindowType)0),
m_subWinDisplay(NULL),
m_lastPostedColorBuffer(0),
m_zRot(0.0f),
@@ -375,7 +383,10 @@ FrameBuffer::FrameBuffer(int p_width, int p_height,
m_statsStartTime(0LL),
m_onPost(onPost),
m_onPostContext(onPostContext),
- m_fbImage(NULL)
+ m_fbImage(NULL),
+ m_glVendor(NULL),
+ m_glRenderer(NULL),
+ m_glVersion(NULL)
{
m_fpsStats = getenv("SHOW_FPS_STATS") != NULL;
}
@@ -412,7 +423,7 @@ bool FrameBuffer::setupSubWindow(FBNativeWindowType p_window,
if (fb->m_eglSurface == EGL_NO_SURFACE) {
ERR("Failed to create surface\n");
destroySubWindow(fb->m_subWinDisplay, fb->m_subWin);
- fb->m_subWin = NULL;
+ fb->m_subWin = (EGLNativeWindowType)0;
}
else if (fb->bindSubwin_locked()) {
// Subwin creation was successfull,
@@ -445,7 +456,7 @@ bool FrameBuffer::removeSubWindow()
s_theFrameBuffer->m_subWin);
s_theFrameBuffer->m_eglSurface = EGL_NO_SURFACE;
- s_theFrameBuffer->m_subWin = NULL;
+ s_theFrameBuffer->m_subWin = (EGLNativeWindowType)0;
removed = true;
}
s_theFrameBuffer->m_lock.unlock();
diff --git a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h b/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h
index 343f384..89a708b 100644
--- a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h
+++ b/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h
@@ -59,6 +59,12 @@ public:
int getWidth() const { return m_width; }
int getHeight() const { return m_height; }
+ void getGLStrings(const char** vendor, const char** renderer, const char** version) const {
+ *vendor = m_glVendor;
+ *renderer = m_glRenderer;
+ *version = m_glVersion;
+ }
+
HandleType createRenderContext(int p_config, HandleType p_share, bool p_isGL2 = false);
HandleType createWindowSurface(int p_config, int p_width, int p_height);
HandleType createColorBuffer(int p_width, int p_height, GLenum p_internalFormat);
@@ -133,5 +139,9 @@ private:
OnPostFn m_onPost;
void* m_onPostContext;
unsigned char* m_fbImage;
+
+ const char* m_glVendor;
+ const char* m_glRenderer;
+ const char* m_glVersion;
};
#endif
diff --git a/emulator/opengl/host/libs/libOpenglRender/render_api.cpp b/emulator/opengl/host/libs/libOpenglRender/render_api.cpp
index 00dcd75..7d7a981 100644
--- a/emulator/opengl/host/libs/libOpenglRender/render_api.cpp
+++ b/emulator/opengl/host/libs/libOpenglRender/render_api.cpp
@@ -191,6 +191,16 @@ int initOpenGLRenderer(int width, int height, int portNum,
return true;
}
+void getHardwareStrings(const char** vendor, const char** renderer, const char** version)
+{
+ FrameBuffer* fb = FrameBuffer::getFB();
+ if (fb) {
+ fb->getGLStrings(vendor, renderer, version);
+ } else {
+ *vendor = *renderer = *version = NULL;
+ }
+}
+
int stopOpenGLRenderer(void)
{
bool ret = false;