gsdx-gles: nvidia driver quick trial (only GLES3.0)

* Fix to create a 3.0 GLES context
* set a default precision to fix most of shader compilation issue
* Crash later because of GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
    => need to test opensource driver
This commit is contained in:
Gregory Hainaut 2014-04-12 12:40:23 +02:00
parent ca8c5b041d
commit ea25d12405
3 changed files with 24 additions and 9 deletions

View File

@ -183,7 +183,9 @@ namespace GLLoader {
const char* vendor = (const char*)glGetString(GL_VENDOR);
fprintf(stderr, "Supported Opengl version: %s on GPU: %s. Vendor: %s\n", s, glGetString(GL_RENDERER), vendor);
#ifndef ENABLE_GLES
fprintf(stderr, "Note: the maximal version supported by GSdx is 3.3 (even if you driver support more)!\n");
#endif
// Name change but driver is still bad!
if (strstr(vendor, "ATI") || strstr(vendor, "Advanced Micro Devices"))
@ -222,10 +224,12 @@ namespace GLLoader {
#else
found_geometry_shader = false;
#endif
#ifndef ENABLE_GLES
if ( (major_gl < major) || ( major_gl == major && minor_gl < minor ) ) {
fprintf(stderr, "OPENGL %d.%d is not supported\n", major, minor);
return false;
}
#endif
return true;
}
@ -234,6 +238,7 @@ namespace GLLoader {
int max_ext = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &max_ext);
#ifndef ENABLE_GLES
if (gl_GetStringi && max_ext) {
for (GLint i = 0; i < max_ext; i++) {
string ext((const char*)gl_GetStringi(GL_EXTENSIONS, i));
@ -279,6 +284,7 @@ namespace GLLoader {
#endif
}
}
#endif
bool status = true;
#ifndef ENABLE_GLES

View File

@ -420,6 +420,7 @@ std::string GSShaderOGL::GenGlslHeader(const std::string& entry, GLenum type, co
// intel linux refuse to define it
#ifdef ENABLE_GLES
header += "#define pGL_ES 1\n";
header += "precision highp float;\n";
#else
header += "#define pGL_ES 0\n";
#endif

View File

@ -32,31 +32,28 @@ GSWndEGL::GSWndEGL()
void GSWndEGL::CreateContext(int major, int minor)
{
EGLConfig eglConfig;
EGLint numConfigs;
EGLint numConfigs = 0;
EGLint contextAttribs[] =
#ifdef ENABLE_GLES
{
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
#else
{
EGL_CONTEXT_MAJOR_VERSION_KHR, major,
EGL_CONTEXT_MINOR_VERSION_KHR, minor,
#ifndef ENABLE_GLES
#ifdef ENABLE_OGL_DEBUG
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR,
#endif
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
#endif
EGL_NONE
};
#endif
EGLint NullContextAttribs[] = { EGL_NONE };
EGLint attrList[] = {
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_DEPTH_SIZE, 24,
#ifndef ENABLE_GLES
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
#endif
EGL_NONE
};
@ -64,7 +61,8 @@ void GSWndEGL::CreateContext(int major, int minor)
eglBindAPI(EGL_OPENGL_API);
#endif
if ( !eglChooseConfig(m_eglDisplay, attrList, &eglConfig, 1, &numConfigs) )
eglChooseConfig(m_eglDisplay, attrList, &eglConfig, 1, &numConfigs);
if ( numConfigs == 0 )
{
fprintf(stderr,"EGL: Failed to get a frame buffer config!\n");
throw GSDXRecoverableError();
@ -137,7 +135,12 @@ bool GSWndEGL::Attach(void* handle, bool managed)
m_NativeDisplay = XOpenDisplay(NULL);
OpenEGLDisplay();
#ifdef ENABLE_GLES
// FIXME: update it to GLES 3.1 when they support it
CreateContext(3, 0);
#else
CreateContext(3, 3);
#endif
AttachContext();
@ -184,7 +187,12 @@ bool GSWndEGL::Create(const string& title, int w, int h)
m_NativeWindow = XCreateSimpleWindow(m_NativeDisplay, DefaultRootWindow(m_NativeDisplay), 0, 0, w, h, 0, 0, 0);
XMapWindow (m_NativeDisplay, m_NativeWindow);
#ifdef ENABLE_GLES
// FIXME: update it to GLES 3.1 when they support it
CreateContext(3, 0);
#else
CreateContext(3, 3);
#endif
AttachContext();