diff --git a/.travis.yml b/.travis.yml index a2b807aa71..220056ff60 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,7 +41,7 @@ addons: - sparse - uuid-dev - libsdl2-dev - - libglew-dev + - libepoxy-dev git: # we want to do this ourselves @@ -49,7 +49,7 @@ git: before_install: - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update ; fi - - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install libffi gettext glib pixman pkg-config autoconf pixman sdl2 glew; fi + - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install libffi gettext glib pixman pkg-config autoconf pixman sdl2 libepoxy; fi script: - if [ "$TRAVIS_OS_NAME" == "osx" ]; then ./build_macos.sh ; fi diff --git a/appveyor.bat b/appveyor.bat index 4fa41273b2..15ad18d780 100644 --- a/appveyor.bat +++ b/appveyor.bat @@ -24,9 +24,9 @@ bash -xlc "pacman --noconfirm -S --needed automake-wrapper" bash -xlc "pacman --noconfirm -S --needed mingw-w64-x86_64-libtool" bash -xlc "pacman --noconfirm -S --needed mingw-w64-x86_64-pkg-config" bash -xlc "pacman --noconfirm -S --needed mingw-w64-x86_64-glib2" -bash -xlc "pacman --noconfirm -S --needed mingw-w64-x86_64-glew" bash -xlc "pacman --noconfirm -S --needed mingw-w64-x86_64-SDL2" bash -xlc "pacman --noconfirm -S --needed mingw-w64-x86_64-pixman" +bash -xlc "pacman --noconfirm -S --needed mingw-w64-x86_64-libepoxy" rem Invoke subsequent bash in the build tree cd %APPVEYOR_BUILD_FOLDER% diff --git a/configure b/configure index 1c1d8232a9..e0f801018a 100755 --- a/configure +++ b/configure @@ -848,7 +848,7 @@ if test "$mingw32" = "yes" ; then QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS" # MinGW needs -mthreads for TLS and macro _MT. QEMU_CFLAGS="-mthreads $QEMU_CFLAGS" - LIBS="-lwinmm -lws2_32 -liphlpapi -lopengl32 -lglew32 -lgdi32 $LIBS" + LIBS="-lwinmm -lws2_32 -liphlpapi -lopengl32 -lepoxy -lgdi32 $LIBS" write_c_skeleton; if compile_prog "" "-liberty" ; then LIBS="-liberty $LIBS" @@ -2948,7 +2948,7 @@ fi # Xbox hack to include ogl framework if test "$darwin" = "yes" ; then - sdl_libs="$sdl_libs -framework OpenGL" + sdl_libs="$sdl_libs -framework OpenGL -lepoxy" # cat > $TMPC << EOF # #include # #include @@ -2958,7 +2958,7 @@ if test "$darwin" = "yes" ; then fi if test "$linux" = "yes" ; then - sdl_libs="$sdl_libs -lGLEW -lGLU -lGL" + sdl_libs="$sdl_libs -lepoxy -lGLU -lGL" fi ########################################## diff --git a/hw/xbox/nv2a/gl/Makefile.objs b/hw/xbox/nv2a/gl/Makefile.objs index ee83992056..561b0651ae 100644 --- a/hw/xbox/nv2a/gl/Makefile.objs +++ b/hw/xbox/nv2a/gl/Makefile.objs @@ -1,4 +1,4 @@ -obj-y += gloffscreen_common.o glextensions.o +obj-y += gloffscreen_common.o obj-$(CONFIG_WIN32) += gloffscreen_wgl.o obj-$(CONFIG_DARWIN) += gloffscreen_cgl.o obj-$(CONFIG_LINUX) += gloffscreen_glx.o diff --git a/hw/xbox/nv2a/gl/glextensions.c b/hw/xbox/nv2a/gl/glextensions.c deleted file mode 100644 index 06463fcf4c..0000000000 --- a/hw/xbox/nv2a/gl/glextensions.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * QEMU OpenGL extensions - * - * Copyright (c) 2015 espes - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 or - * (at your option) version 3 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ -#include "gloffscreen.h" -#include "glextensions.h" - -#ifdef __APPLE__ -void (*glFrameTerminatorGREMEDY)(void); - -void (*glDebugMessageInsert) (GLenum source, GLenum type, GLuint id, - GLenum severity, GLsizei length, - const GLchar *buf); -void (*glPushDebugGroup)(GLenum source, GLuint id, GLsizei length, - const GLchar *message); -void (*glPopDebugGroup)(void); -void (*glObjectLabel)(GLenum identifier, GLuint name, GLsizei length, - const GLchar *label); - -#endif - -void glextensions_init(void) -{ -#ifdef __APPLE__ - glFrameTerminatorGREMEDY = - glo_get_extension_proc("glFrameTerminatorGREMEDY"); - glDebugMessageInsert = glo_get_extension_proc("glDebugMessageInsert"); - glPushDebugGroup = glo_get_extension_proc("glPushDebugGroup"); - glPopDebugGroup = glo_get_extension_proc("glPopDebugGroup"); - glObjectLabel = glo_get_extension_proc("glObjectLabel"); -#endif -} diff --git a/hw/xbox/nv2a/gl/glextensions.h b/hw/xbox/nv2a/gl/glextensions.h deleted file mode 100644 index 8f303d5d02..0000000000 --- a/hw/xbox/nv2a/gl/glextensions.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * QEMU OpenGL extensions - * - * Copyright (c) 2015 espes - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 or - * (at your option) version 3 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ -#ifndef GLEXTEENSIONS_H_ -#define GLEXTEENSIONS_H_ - -#ifdef __APPLE__ -#include "gloffscreen.h" -extern void (*glFrameTerminatorGREMEDY)(void); - -#define GL_DEBUG_SOURCE_APPLICATION 0x824A -#define GL_DEBUG_TYPE_MARKER 0x8268 -#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B -#define GL_DEBUG_OUTPUT 0x92E0 - -extern void (*glDebugMessageInsert) (GLenum source, GLenum type, GLuint id, - GLenum severity, GLsizei length, - const GLchar *buf); -extern void (*glPushDebugGroup)(GLenum source, GLuint id, GLsizei length, - const GLchar *message); -extern void (*glPopDebugGroup)(void); -extern void (*glObjectLabel)(GLenum identifier, GLuint name, GLsizei length, - const GLchar *label); - -#endif - -void glextensions_init(void); - -#endif diff --git a/hw/xbox/nv2a/gl/gloffscreen.h b/hw/xbox/nv2a/gl/gloffscreen.h index e9649606b4..11ab64b3f7 100644 --- a/hw/xbox/nv2a/gl/gloffscreen.h +++ b/hw/xbox/nv2a/gl/gloffscreen.h @@ -31,20 +31,16 @@ #include +#include + #if defined(__APPLE__) /* macOS-Specific GL Includes */ #include #include #include #elif defined(_WIN32) /* Windows-Specific GL Includes */ -#include -#include -#include -#include +#include #else /* Assume GLX */ -#include -#include -#include -#include +#include #endif /* Used to hold data for the OpenGL context */ @@ -56,7 +52,6 @@ void glo_set_current(GloContext *context); /* Check GL Extensions */ bool glo_check_extension(const char* ext_name); -void* glo_get_extension_proc(const char* extProc); /* Create an OpenGL context */ GloContext *glo_context_create(void); diff --git a/hw/xbox/nv2a/gl/gloffscreen_common.c b/hw/xbox/nv2a/gl/gloffscreen_common.c index 59bff2a842..6091239267 100644 --- a/hw/xbox/nv2a/gl/gloffscreen_common.c +++ b/hw/xbox/nv2a/gl/gloffscreen_common.c @@ -77,15 +77,7 @@ void glo_readpixels(GLenum gl_format, GLenum gl_type, glPixelStorei(GL_PACK_ALIGNMENT, pa); } - bool glo_check_extension(const char* ext_name) { - int i; - int num_extensions = GL_NUM_EXTENSIONS; - for (i=0; iglx_context == NULL) return NULL; glo_set_current(context); - if (!initialized) { - /* Initialize glew */ - glewExperimental = GL_TRUE; - if (GLEW_OK != glewInit()) { - /* GLEW failed! */ - fprintf(stderr,"GLEW init failed.\n"); - exit(EXIT_FAILURE); - } - - /* Get rid of GLEW errors */ - while(glGetError() != GL_NO_ERROR); - } + /* Get rid of possible errors from within GL wrapper or glo */ + while(glGetError() != GL_NO_ERROR); initialized = true; return context; } -void* glo_get_extension_proc(const char* ext_proc) -{ - return glXGetProcAddress((const GLubyte *)ext_proc); -} - /* Set current context */ void glo_set_current(GloContext *context) { diff --git a/hw/xbox/nv2a/gl/gloffscreen_wgl.c b/hw/xbox/nv2a/gl/gloffscreen_wgl.c index 385f146883..71bedd7e0d 100644 --- a/hw/xbox/nv2a/gl/gloffscreen_wgl.c +++ b/hw/xbox/nv2a/gl/gloffscreen_wgl.c @@ -126,15 +126,9 @@ static void glo_init(void) { } wglMakeCurrent(glo.hDC, glo.hContext); - /* Initialize glew */ - if (glewInit() != GLEW_OK) { - fprintf(stderr, "Glew init failed.\n"); - abort(); - } - - if (!WGLEW_ARB_create_context - || !WGLEW_ARB_pixel_format - || !WGLEW_ARB_pbuffer) { + if (!epoxy_has_wgl_extension(glo.hDC, "ARB_create_context") + || !epoxy_has_wgl_extension(glo.hDC, "ARB_pixel_format") + || !epoxy_has_wgl_extension(glo.hDC, "ARB_pbuffer")) { fprintf(stderr, "Unable to load the required WGL extensions\n"); abort(); } @@ -187,8 +181,9 @@ GloContext *glo_context_create(void) { } /* Set current context */ -void glo_set_current(GloContext *context) { - +void glo_set_current(GloContext *context) +{ + epoxy_handle_external_wglMakeCurrent(); if (context == NULL) { wglMakeCurrent(NULL, NULL); } else { diff --git a/hw/xbox/nv2a/nv2a.h b/hw/xbox/nv2a/nv2a.h index fc517e6ddd..c2c51beec0 100644 --- a/hw/xbox/nv2a/nv2a.h +++ b/hw/xbox/nv2a/nv2a.h @@ -40,7 +40,6 @@ #include "nv2a_int.h" #include "gl/gloffscreen.h" -#include "gl/glextensions.h" #define USE_TEXTURE_CACHE diff --git a/hw/xbox/nv2a/nv2a_debug.c b/hw/xbox/nv2a/nv2a_debug.c index f16b539776..28aa261978 100644 --- a/hw/xbox/nv2a/nv2a_debug.c +++ b/hw/xbox/nv2a/nv2a_debug.c @@ -29,6 +29,14 @@ #include "nv2a_debug.h" #include "gl/glextensions.h" + +void gl_debug_initialize(void) +{ + if (glo_check_extension("GL_KHR_debug")) { + glEnable(GL_DEBUG_OUTPUT); + } +} + void gl_debug_message(bool cc, const char *fmt, ...) { size_t n; diff --git a/hw/xbox/nv2a/nv2a_pgraph.c b/hw/xbox/nv2a/nv2a_pgraph.c index c2cefa9bfb..c45b68e26f 100644 --- a/hw/xbox/nv2a/nv2a_pgraph.c +++ b/hw/xbox/nv2a/nv2a_pgraph.c @@ -2641,11 +2641,9 @@ void pgraph_init(NV2AState *d) assert(pg->gl_context); #ifdef DEBUG_NV2A_GL - glEnable(GL_DEBUG_OUTPUT); + gl_debug_initialize(); #endif - glextensions_init(); - /* DXT textures */ assert(glo_check_extension("GL_EXT_texture_compression_s3tc")); /* Internal RGB565 texture format */