am 8066f12a: Merge "opengles emulator: code cleanup removing dead code"
* commit '8066f12a07b050809c62fda1bdae5296e81a4c11': opengles emulator: code cleanup removing dead code
This commit is contained in:
@@ -87,88 +87,22 @@ InitConfigStatus FBConfig::initConfigList(FrameBuffer *fb)
|
|||||||
s_egl.eglGetConfigs(dpy, configs, nConfigs, &nConfigs);
|
s_egl.eglGetConfigs(dpy, configs, nConfigs, &nConfigs);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Find number of usable configs which support pbuffer rendering
|
// copy the config attributes, filter out
|
||||||
// for each ES and ES2 as well as number of configs supporting
|
// configs we do not want to support.
|
||||||
// EGL_BIND_TO_TEXTURE_RGBA for each of ES and ES2.
|
|
||||||
//
|
//
|
||||||
const int GL = 0;
|
|
||||||
const int GL1 = 1;
|
|
||||||
const int GL2 = 2;
|
|
||||||
int numPbuf[3] = {0, 0, 0};
|
|
||||||
int numBindToTexture[3] = {0, 0, 0};
|
|
||||||
for (int i=0; i<nConfigs; i++) {
|
|
||||||
GLint depthSize, stencilSize;
|
|
||||||
GLint renderType, surfaceType;
|
|
||||||
GLint bindToTexture;
|
|
||||||
|
|
||||||
s_egl.eglGetConfigAttrib(dpy, configs[i], EGL_DEPTH_SIZE, &depthSize);
|
|
||||||
s_egl.eglGetConfigAttrib(dpy, configs[i], EGL_STENCIL_SIZE, &stencilSize);
|
|
||||||
s_egl.eglGetConfigAttrib(dpy, configs[i], EGL_RENDERABLE_TYPE, &renderType);
|
|
||||||
s_egl.eglGetConfigAttrib(dpy, configs[i], EGL_SURFACE_TYPE, &surfaceType);
|
|
||||||
if (depthSize > 0 && stencilSize > 0 &&
|
|
||||||
(surfaceType & EGL_PBUFFER_BIT) != 0) {
|
|
||||||
|
|
||||||
numPbuf[GL]++;
|
|
||||||
|
|
||||||
if ((renderType & EGL_OPENGL_ES_BIT) != 0) {
|
|
||||||
numPbuf[GL1]++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((renderType & EGL_OPENGL_ES2_BIT) != 0) {
|
|
||||||
numPbuf[GL2]++;
|
|
||||||
}
|
|
||||||
|
|
||||||
s_egl.eglGetConfigAttrib(dpy, configs[i],
|
|
||||||
EGL_BIND_TO_TEXTURE_RGBA, &bindToTexture);
|
|
||||||
if (bindToTexture) {
|
|
||||||
numBindToTexture[GL]++;
|
|
||||||
if ((renderType & EGL_OPENGL_ES_BIT) != 0) {
|
|
||||||
numBindToTexture[GL1]++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((renderType & EGL_OPENGL_ES2_BIT) != 0) {
|
|
||||||
numBindToTexture[GL2]++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool useOnlyPbuf = false;
|
|
||||||
bool useOnlyBindToTexture = false;
|
|
||||||
int numConfigs = nConfigs;
|
|
||||||
if ( numPbuf[GL1] > 0 &&
|
|
||||||
(!caps.hasGL2 || numPbuf[GL2] > 0)) {
|
|
||||||
useOnlyPbuf = true;
|
|
||||||
numConfigs = numPbuf[GL];
|
|
||||||
}
|
|
||||||
if (useOnlyPbuf &&
|
|
||||||
!(caps.has_eglimage_texture_2d &&
|
|
||||||
caps.has_eglimage_renderbuffer) &&
|
|
||||||
numBindToTexture[GL1] > 0 &&
|
|
||||||
(!caps.hasGL2 || numBindToTexture[GL2] > 0)) {
|
|
||||||
useOnlyBindToTexture = true;
|
|
||||||
numConfigs = numBindToTexture[GL];
|
|
||||||
ret = INIT_CONFIG_HAS_BIND_TO_TEXTURE;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ret = INIT_CONFIG_PASSED;
|
|
||||||
}
|
|
||||||
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
s_fbConfigs = new FBConfig*[nConfigs];
|
s_fbConfigs = new FBConfig*[nConfigs];
|
||||||
for (int i=0; i<nConfigs; i++) {
|
for (int i=0; i<nConfigs; i++) {
|
||||||
if (useOnlyBindToTexture) {
|
|
||||||
EGLint bindToTexture;
|
//
|
||||||
s_egl.eglGetConfigAttrib(dpy, configs[i],
|
// filter out configs which does not support pbuffers.
|
||||||
EGL_BIND_TO_TEXTURE_RGBA, &bindToTexture);
|
// we only support pbuffer configs since we use a pbuffer
|
||||||
if (!bindToTexture) continue;
|
// handle to bind a guest created window object.
|
||||||
}
|
//
|
||||||
else if (useOnlyPbuf) {
|
EGLint surfaceType;
|
||||||
EGLint surfaceType;
|
s_egl.eglGetConfigAttrib(dpy, configs[i],
|
||||||
s_egl.eglGetConfigAttrib(dpy, configs[i],
|
EGL_SURFACE_TYPE, &surfaceType);
|
||||||
EGL_SURFACE_TYPE, &surfaceType);
|
if (!(surfaceType & EGL_PBUFFER_BIT)) continue;
|
||||||
if (!(surfaceType & EGL_PBUFFER_BIT)) continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Filter out not RGB configs
|
// Filter out not RGB configs
|
||||||
@@ -184,7 +118,8 @@ InitConfigStatus FBConfig::initConfigList(FrameBuffer *fb)
|
|||||||
s_numConfigs = j;
|
s_numConfigs = j;
|
||||||
|
|
||||||
delete[] configs;
|
delete[] configs;
|
||||||
return ret;
|
|
||||||
|
return s_numConfigs > 0 ? INIT_CONFIG_PASSED : INIT_CONFIG_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FBConfig *FBConfig::get(int p_config)
|
const FBConfig *FBConfig::get(int p_config)
|
||||||
|
|||||||
@@ -23,8 +23,7 @@ class FrameBuffer;
|
|||||||
|
|
||||||
enum InitConfigStatus {
|
enum InitConfigStatus {
|
||||||
INIT_CONFIG_FAILED = 0,
|
INIT_CONFIG_FAILED = 0,
|
||||||
INIT_CONFIG_PASSED = 1,
|
INIT_CONFIG_PASSED = 1
|
||||||
INIT_CONFIG_HAS_BIND_TO_TEXTURE = 2
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class FBConfig
|
class FBConfig
|
||||||
|
|||||||
@@ -275,6 +275,18 @@ bool FrameBuffer::initialize(int width, int height)
|
|||||||
fb->m_caps.has_eglimage_renderbuffer = false;
|
fb->m_caps.has_eglimage_renderbuffer = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Fail initialization if not all of the following extensions
|
||||||
|
// exist:
|
||||||
|
// EGL_KHR_gl_texture_2d_image
|
||||||
|
// GL_OES_EGL_IMAGE (by both GLES implementations [1 and 2])
|
||||||
|
//
|
||||||
|
if (!fb->m_caps.has_eglimage_texture_2d) {
|
||||||
|
ERR("Failed: Missing egl_image related extension(s)\n");
|
||||||
|
delete fb;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Initialize set of configs
|
// Initialize set of configs
|
||||||
//
|
//
|
||||||
@@ -316,13 +328,6 @@ bool FrameBuffer::initialize(int width, int height)
|
|||||||
fb->m_caps.hasGL2 = false;
|
fb->m_caps.hasGL2 = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// update Pbuffer bind to texture capability based on configs
|
|
||||||
//
|
|
||||||
fb->m_caps.has_BindToTexture =
|
|
||||||
(configStatus == INIT_CONFIG_HAS_BIND_TO_TEXTURE);
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Initialize some GL state
|
// Initialize some GL state
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ struct FrameBufferCaps
|
|||||||
bool hasGL2;
|
bool hasGL2;
|
||||||
bool has_eglimage_texture_2d;
|
bool has_eglimage_texture_2d;
|
||||||
bool has_eglimage_renderbuffer;
|
bool has_eglimage_renderbuffer;
|
||||||
bool has_BindToTexture;
|
|
||||||
EGLint eglMajor;
|
EGLint eglMajor;
|
||||||
EGLint eglMinor;
|
EGLint eglMinor;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -35,9 +35,7 @@ WindowSurface::WindowSurface() :
|
|||||||
m_width(0),
|
m_width(0),
|
||||||
m_height(0),
|
m_height(0),
|
||||||
m_pbufWidth(0),
|
m_pbufWidth(0),
|
||||||
m_pbufHeight(0),
|
m_pbufHeight(0)
|
||||||
m_useEGLImage(false),
|
|
||||||
m_useBindToTexture(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,31 +62,10 @@ WindowSurface *WindowSurface::create(int p_config, int p_width, int p_height)
|
|||||||
const FrameBufferCaps &caps = fb->getCaps();
|
const FrameBufferCaps &caps = fb->getCaps();
|
||||||
|
|
||||||
//
|
//
|
||||||
// We can use eglimage and prevent copies if:
|
// Create a pbuffer to be used as the egl surface
|
||||||
// GL_KHR_gl_texture_2D_image is present.
|
// for that window.
|
||||||
// and either there is no need for depth or stencil buffer
|
|
||||||
// or GL_KHR_gl_renderbuffer_image present.
|
|
||||||
//
|
//
|
||||||
#if 0
|
if (!win->resizePbuffer(p_width, p_height)) {
|
||||||
//XXX: This path should be implemented
|
|
||||||
win->m_useEGLImage =
|
|
||||||
(caps.has_eglimage_texture_2d &&
|
|
||||||
(caps.has_eglimage_renderbuffer ||
|
|
||||||
(fbconf->getDepthSize() + fbconf->getStencilSize() == 0)) );
|
|
||||||
#else
|
|
||||||
win->m_useEGLImage = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (win->m_useEGLImage) {
|
|
||||||
}
|
|
||||||
else if (0 != (fbconf->getSurfaceType() & EGL_PBUFFER_BIT)) {
|
|
||||||
if (!win->resizePbuffer(p_width, p_height)) {
|
|
||||||
delete win;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// no EGLImage support and not Pbuffer support - fail
|
|
||||||
delete win;
|
delete win;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -108,20 +85,8 @@ void WindowSurface::flushColorBuffer()
|
|||||||
{
|
{
|
||||||
if (m_attachedColorBuffer.Ptr() != NULL) {
|
if (m_attachedColorBuffer.Ptr() != NULL) {
|
||||||
|
|
||||||
if (!m_useEGLImage) {
|
//copyToColorBuffer();
|
||||||
bool copied = false;
|
blitToColorBuffer();
|
||||||
if (m_useBindToTexture) {
|
|
||||||
copied = m_attachedColorBuffer->blitFromPbuffer(m_eglSurface);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!copied) {
|
|
||||||
//copyToColorBuffer();
|
|
||||||
blitToColorBuffer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
//TODO: EGLImage
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,9 +140,6 @@ void WindowSurface::bind(RenderContextPtr p_ctx, SurfaceBindType p_bindType)
|
|||||||
return; // bad param
|
return; // bad param
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_useEGLImage) {
|
|
||||||
// XXX: should be implemented
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowSurface::copyToColorBuffer()
|
void WindowSurface::copyToColorBuffer()
|
||||||
@@ -323,27 +285,14 @@ bool WindowSurface::resizePbuffer(unsigned int p_width, unsigned int p_height)
|
|||||||
const FrameBufferCaps &caps = fb->getCaps();
|
const FrameBufferCaps &caps = fb->getCaps();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create pbuffer surface, if possible
|
// Create pbuffer surface.
|
||||||
// set it such that it will be able to be bound to a texture
|
|
||||||
// later to prevent readback.
|
|
||||||
//
|
//
|
||||||
EGLint pbufAttribs[12];
|
EGLint pbufAttribs[5];
|
||||||
pbufAttribs[0] = EGL_WIDTH;
|
pbufAttribs[0] = EGL_WIDTH;
|
||||||
pbufAttribs[1] = p_width;
|
pbufAttribs[1] = p_width;
|
||||||
pbufAttribs[2] = EGL_HEIGHT;
|
pbufAttribs[2] = EGL_HEIGHT;
|
||||||
pbufAttribs[3] = p_height;
|
pbufAttribs[3] = p_height;
|
||||||
|
pbufAttribs[4] = EGL_NONE;
|
||||||
if (caps.has_BindToTexture) {
|
|
||||||
pbufAttribs[4] = EGL_TEXTURE_FORMAT;
|
|
||||||
pbufAttribs[5] = EGL_TEXTURE_RGBA;
|
|
||||||
pbufAttribs[6] = EGL_TEXTURE_TARGET;
|
|
||||||
pbufAttribs[7] = EGL_TEXTURE_2D;
|
|
||||||
pbufAttribs[8] = EGL_NONE;
|
|
||||||
m_useBindToTexture = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
pbufAttribs[4] = EGL_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_eglSurface = s_egl.eglCreatePbufferSurface(fb->getDisplay(),
|
m_eglSurface = s_egl.eglCreatePbufferSurface(fb->getDisplay(),
|
||||||
m_fbconf->getEGLConfig(),
|
m_fbconf->getEGLConfig(),
|
||||||
|
|||||||
Reference in New Issue
Block a user