Mir

Merge lp:~vanvugt/mir/full-gl into lp:mir

Proposed by Daniel van Vugt
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 3513
Proposed branch: lp:~vanvugt/mir/full-gl
Merge into: lp:mir
Diff against target: 954 lines (+153/-53)
46 files modified
CMakeLists.txt (+34/-0)
debian/control (+1/-0)
examples/CMakeLists.txt (+3/-2)
examples/graphics_utils.cpp (+2/-0)
examples/image_renderer.cpp (+2/-0)
examples/server_example_adorning_compositor.cpp (+4/-2)
include/test/mir/test/doubles/mock_egl.h (+2/-0)
playground/demo-shell/demo_renderer.cpp (+4/-0)
playground/demo-shell/typo/CMakeLists.txt (+1/-3)
playground/demo-shell/typo/typo_glcache.cpp (+1/-1)
src/gl/program.cpp (+2/-0)
src/include/gl/mir/gl/primitive.h (+1/-1)
src/include/gl/mir/gl/program.h (+1/-1)
src/include/gl/mir/gl/texture.h (+1/-1)
src/include/platform/mir/graphics/egl_extensions.h (+2/-3)
src/platform/CMakeLists.txt (+1/-1)
src/platform/graphics/CMakeLists.txt (+1/-1)
src/platform/graphics/egl_extensions.cpp (+7/-0)
src/platforms/android/include/egl_sync_extensions.h (+2/-0)
src/platforms/android/server/buffer.h (+2/-0)
src/platforms/android/server/hwc_fallback_gl_renderer.cpp (+2/-0)
src/platforms/common/server/CMakeLists.txt (+2/-2)
src/platforms/common/server/shm_buffer.cpp (+5/-3)
src/platforms/mesa/server/buffer_allocator.cpp (+4/-2)
src/platforms/mesa/server/display_helpers.cpp (+15/-3)
src/platforms/mesa/server/kms/CMakeLists.txt (+2/-2)
src/platforms/mesa/server/kms/display_buffer.cpp (+1/-1)
src/platforms/mesa/server/x11/CMakeLists.txt (+1/-1)
src/platforms/mesa/server/x11/graphics/CMakeLists.txt (+1/-1)
src/platforms/mesa/server/x11/graphics/display.cpp (+5/-1)
src/renderers/gl/program_family.cpp (+2/-1)
src/renderers/gl/program_family.h (+1/-1)
src/renderers/gl/renderer.cpp (+5/-0)
src/renderers/gl/renderer.h (+1/-1)
src/server/CMakeLists.txt (+2/-2)
src/server/compositor/screencast_display_buffer.h (+2/-1)
src/server/graphics/CMakeLists.txt (+1/-1)
src/server/graphics/nested/display.cpp (+9/-4)
src/server/graphics/nested/display.h (+1/-1)
src/server/graphics/nested/display_buffer.cpp (+1/-1)
src/server/graphics/offscreen/display.cpp (+2/-0)
src/server/graphics/offscreen/display_buffer.cpp (+4/-2)
src/server/graphics/surfaceless_egl_context.cpp (+5/-1)
src/server/scene/gl_pixel_buffer.cpp (+2/-2)
src/server/scene/gl_pixel_buffer.h (+1/-1)
tests/unit-tests/graphics/test_shm_buffer.cpp (+2/-2)
To merge this branch: bzr merge lp:~vanvugt/mir/full-gl
Reviewer Review Type Date Requested Status
Cemil Azizoglu (community) Approve
Mir CI Bot continuous-integration Approve
Review via email: mp+294609@code.launchpad.net

Commit message

Introducing full desktop GL support for Mir servers (LP: #1420581)

It works well with Mesa, but is disabled by default due to one
remaining "TODO" you will find.

Note the new eglBindAPI calls. Without those, EGL makes all new
threads default to ES. And then eglMakeContext/eglGetCurrent*
functions will randomly fail. So we need to be sure any thread
that touches EGL will call eglBindAPI with the correct value
first.

To post a comment you must log in.
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Hmm that TODO may not be required. Seems GL_OES_EGL_image is a standard feature provided by Mesa even in non-ES full OpenGL. And with some Googling, AMD even seems to claim they support it in full OpenGL too. That only leaves a question mark over NVIDIA...

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3528
https://mir-jenkins.ubuntu.com/job/mir-ci/983/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/1065
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/1112
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/1103
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/1103
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/1075
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/1075/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/1075
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/1075/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/1075
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/1075/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/1075
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/1075/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/1075
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/1075/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/983/rebuild

review: Approve (continuous-integration)
Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

* Needs discussion *

I am not quite sure about this. The right way to achieve GL-based compositing should not be this invasive. In my mind, it should go more or less like the following :

1- Finish the work that alf started abstracting the renderer. There should not be any renderer specific code outside the renderer (e.g. no EGL/GL/GLES calls).

2- This should give us a proper (default) renderer with GLESv2. Going one step further, since GL/GLES would probably be desired by many shells potentially, we should have multiple flavors of a default set of renderers already implemented in Mir (e.g. A GL based renderer, a GLESv2 renderer, a GLESv3 renderer).

3- The shells should also be able to override that functionality with their own renderer (say vulkan based), or blitter based renderer). (I believe we already have some form of this but not sure how complete).

4- Also the renderer should be able to be chosen at run-time dynamically and replaced on the fly if needed, though this can be done at a later time (e.g. use blitter based rendering instead of GL for power reasons etc).

review: Needs Information
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

As discussed in the hangout today, I agree and I think we all agree that dynamic renderer selection is where we want to be in future.

However this work is a necessary stepping stone on that path. You can't make progress toward dynamic renderer selection without this work.

Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

Isolating renderers and dynamically selecting them is a long term goal. Given that Qtmir needs GL today, it is more correct to support GL rather than GLES.

So lgtm.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2016-05-03 04:36:33 +0000
+++ CMakeLists.txt 2016-05-13 09:11:33 +0000
@@ -199,6 +199,40 @@
199include_directories (SYSTEM ${EGL_INCLUDE_DIRS})199include_directories (SYSTEM ${EGL_INCLUDE_DIRS})
200include_directories (SYSTEM ${GLM_INCLUDE_DIRS})200include_directories (SYSTEM ${GLM_INCLUDE_DIRS})
201201
202#
203# Full OpenGL support works with Mesa. Although it probably should not, and
204# is expected to fail in proprietary drivers due to one remaining "TODO" in:
205# src/platform/graphics/egl_extensions.cpp
206#
207#if (TARGET_ARCH STREQUAL "x86_64-linux-gnu" OR
208# TARGET_ARCH STREQUAL "i386-linux-gnu")
209# set(DEFAULT_LIBGL "libGL")
210#else()
211 set(DEFAULT_LIBGL "libGLESv2")
212#endif()
213set(MIR_SERVER_LIBGL ${DEFAULT_LIBGL} CACHE STRING "OpenGL library to use in Mir servers {libGL,libGLESv2}")
214
215if (MIR_SERVER_LIBGL STREQUAL "libGL")
216 pkg_check_modules(GL REQUIRED gl)
217 add_definitions(
218 -DGL_GLEXT_PROTOTYPES
219 -DMIR_SERVER_GL_H=<GL/gl.h>
220 -DMIR_SERVER_GLEXT_H=<GL/glext.h>
221 -DMIR_SERVER_EGL_OPENGL_BIT=EGL_OPENGL_BIT
222 -DMIR_SERVER_EGL_OPENGL_API=EGL_OPENGL_API
223 )
224elseif (MIR_SERVER_LIBGL STREQUAL "libGLESv2")
225 pkg_check_modules(GL REQUIRED glesv2)
226 add_definitions(
227 -DMIR_SERVER_GL_H=<GLES2/gl2.h>
228 -DMIR_SERVER_GLEXT_H=<GLES2/gl2ext.h>
229 -DMIR_SERVER_EGL_OPENGL_BIT=EGL_OPENGL_ES2_BIT
230 -DMIR_SERVER_EGL_OPENGL_API=EGL_OPENGL_ES_API
231 )
232else()
233 message(FATAL_ERROR "Invalid MIR_SERVER_LIBGL value ${MIR_SERVER_LIBGL}")
234endif()
235
202if (MIR_BUILD_PLATFORM_ANDROID)236if (MIR_BUILD_PLATFORM_ANDROID)
203 find_package(AndroidProperties REQUIRED)237 find_package(AndroidProperties REQUIRED)
204 find_package(LibHardware REQUIRED)238 find_package(LibHardware REQUIRED)
205239
=== modified file 'debian/control'
--- debian/control 2016-05-03 04:36:33 +0000
+++ debian/control 2016-05-13 09:11:33 +0000
@@ -19,6 +19,7 @@
19 libdrm-dev,19 libdrm-dev,
20 libegl1-mesa-dev,20 libegl1-mesa-dev,
21 libgles2-mesa-dev,21 libgles2-mesa-dev,
22 libgl1-mesa-dev [amd64 i386],
22 libgbm-dev,23 libgbm-dev,
23 libglm-dev,24 libglm-dev,
24 libprotobuf-dev,25 libprotobuf-dev,
2526
=== modified file 'examples/CMakeLists.txt'
--- examples/CMakeLists.txt 2016-05-09 14:27:58 +0000
+++ examples/CMakeLists.txt 2016-05-13 09:11:33 +0000
@@ -167,20 +167,20 @@
167target_link_libraries(mir_demo_client_scroll167target_link_libraries(mir_demo_client_scroll
168 eglapp168 eglapp
169 mirdraw169 mirdraw
170 ${GLESv2_LIBRARIES}
170)171)
171172
172mir_add_wrapped_executable(mir_demo_client_prompt_session prompt_session.c)173mir_add_wrapped_executable(mir_demo_client_prompt_session prompt_session.c)
173target_link_libraries(mir_demo_client_prompt_session mirclient)174target_link_libraries(mir_demo_client_prompt_session mirclient)
174175
175add_library(mirdraw STATIC graphics_utils.cpp)176add_library(mirdraw STATIC graphics_utils.cpp)
176target_link_libraries(mirdraw ${GLESv2_LIBRARIES})
177177
178include_directories(178include_directories(
179 ${PROJECT_SOURCE_DIR}/include/server179 ${PROJECT_SOURCE_DIR}/include/server
180 ${PROJECT_SOURCE_DIR}/include/client180 ${PROJECT_SOURCE_DIR}/include/client
181 ${PROJECT_SOURCE_DIR}/include/platform181 ${PROJECT_SOURCE_DIR}/include/platform
182 ${PROJECT_SOURCE_DIR}/include/renderers/gl182 ${PROJECT_SOURCE_DIR}/include/renderers/gl
183 ${GLESv2_INCLUDE_DIRS}183 ${GL_INCLUDE_DIRS}
184)184)
185185
186mir_add_wrapped_executable(mir_demo_standalone_render_to_fb186mir_add_wrapped_executable(mir_demo_standalone_render_to_fb
@@ -190,6 +190,7 @@
190target_link_libraries(mir_demo_standalone_render_to_fb190target_link_libraries(mir_demo_standalone_render_to_fb
191 mirserver191 mirserver
192 mirdraw192 mirdraw
193 ${GL_LIBRARIES}
193 ${Boost_LIBRARIES}194 ${Boost_LIBRARIES}
194)195)
195196
196197
=== modified file 'examples/graphics_utils.cpp'
--- examples/graphics_utils.cpp 2013-04-24 05:22:20 +0000
+++ examples/graphics_utils.cpp 2016-05-13 09:11:33 +0000
@@ -38,7 +38,9 @@
3838
39static const GLchar *frag_shader_src =39static const GLchar *frag_shader_src =
40{40{
41 "#ifdef GL_ES\n"
41 "precision mediump float;\n"42 "precision mediump float;\n"
43 "#endif\n"
42 "uniform sampler2D tex;\n"44 "uniform sampler2D tex;\n"
43 "varying vec2 texcoord;\n"45 "varying vec2 texcoord;\n"
44 "void main() {\n"46 "void main() {\n"
4547
=== modified file 'examples/image_renderer.cpp'
--- examples/image_renderer.cpp 2015-07-16 07:03:19 +0000
+++ examples/image_renderer.cpp 2016-05-13 09:11:33 +0000
@@ -49,7 +49,9 @@
4949
50const GLchar* fragment_shader_src =50const GLchar* fragment_shader_src =
51{51{
52 "#ifdef GL_ES\n"
52 "precision mediump float;\n"53 "precision mediump float;\n"
54 "#endif\n"
53 "uniform sampler2D tex;\n"55 "uniform sampler2D tex;\n"
54 "varying vec2 v_texcoord;\n"56 "varying vec2 v_texcoord;\n"
55 "void main() {\n"57 "void main() {\n"
5658
=== modified file 'examples/server_example_adorning_compositor.cpp'
--- examples/server_example_adorning_compositor.cpp 2016-03-29 07:30:50 +0000
+++ examples/server_example_adorning_compositor.cpp 2016-05-13 09:11:33 +0000
@@ -29,7 +29,7 @@
29#include <stdexcept>29#include <stdexcept>
30#include <boost/throw_exception.hpp>30#include <boost/throw_exception.hpp>
3131
32#include <GLES2/gl2.h>32#include MIR_SERVER_GL_H
3333
34namespace me = mir::examples;34namespace me = mir::examples;
35namespace mg = mir::graphics;35namespace mg = mir::graphics;
@@ -85,7 +85,9 @@
85 "}"85 "}"
86 },86 },
87 frag_shader_src{87 frag_shader_src{
88 "precision mediump float;"88 "#ifdef GL_ES\n"
89 "precision mediump float;\n"
90 "#endif\n"
89 "varying vec2 texcoord;"91 "varying vec2 texcoord;"
90 "uniform sampler2D tex;"92 "uniform sampler2D tex;"
91 "uniform float alpha;"93 "uniform float alpha;"
9294
=== modified file 'include/test/mir/test/doubles/mock_egl.h'
--- include/test/mir/test/doubles/mock_egl.h 2016-01-29 08:18:22 +0000
+++ include/test/mir/test/doubles/mock_egl.h 2016-05-13 09:11:33 +0000
@@ -25,7 +25,9 @@
25#include <thread>25#include <thread>
26#include <unordered_map>26#include <unordered_map>
2727
28#ifndef GL_GLEXT_PROTOTYPES
28#define GL_GLEXT_PROTOTYPES29#define GL_GLEXT_PROTOTYPES
30#endif
29#define EGL_EGLEXT_PROTOTYPES31#define EGL_EGLEXT_PROTOTYPES
30#include <EGL/egl.h>32#include <EGL/egl.h>
31#include <EGL/eglext.h>33#include <EGL/eglext.h>
3234
=== modified file 'playground/demo-shell/demo_renderer.cpp'
--- playground/demo-shell/demo_renderer.cpp 2016-01-29 08:18:22 +0000
+++ playground/demo-shell/demo_renderer.cpp 2016-05-13 09:11:33 +0000
@@ -152,7 +152,9 @@
152152
153static const GLchar inverse_fshader[] =153static const GLchar inverse_fshader[] =
154{154{
155 "#ifdef GL_ES\n"
155 "precision mediump float;\n"156 "precision mediump float;\n"
157 "#endif\n"
156 "uniform sampler2D tex;\n"158 "uniform sampler2D tex;\n"
157 "uniform float alpha;\n"159 "uniform float alpha;\n"
158 "varying vec2 v_texcoord;\n"160 "varying vec2 v_texcoord;\n"
@@ -164,7 +166,9 @@
164};166};
165static const GLchar contrast_fshader[] =167static const GLchar contrast_fshader[] =
166{168{
169 "#ifdef GL_ES\n"
167 "precision mediump float;\n"170 "precision mediump float;\n"
171 "#endif\n"
168 "uniform sampler2D tex;\n"172 "uniform sampler2D tex;\n"
169 "uniform float alpha;\n"173 "uniform float alpha;\n"
170 "varying vec2 v_texcoord;\n"174 "varying vec2 v_texcoord;\n"
171175
=== modified file 'playground/demo-shell/typo/CMakeLists.txt'
--- playground/demo-shell/typo/CMakeLists.txt 2015-02-19 09:30:02 +0000
+++ playground/demo-shell/typo/CMakeLists.txt 2016-05-13 09:11:33 +0000
@@ -1,4 +1,3 @@
1find_package(GLESv2 REQUIRED)
2find_package(PkgConfig)1find_package(PkgConfig)
32
4pkg_search_module(FREETYPE freetype2)3pkg_search_module(FREETYPE freetype2)
@@ -13,8 +12,7 @@
13 ${OPTIONAL_SRCS}12 ${OPTIONAL_SRCS}
14)13)
1514
16target_link_libraries(typo ${GLESv2_LIBRARIES})15target_link_libraries(typo ${GL_LIBRARIES})
17include_directories(${GLESv2_INCLUDE_DIRS})
18target_include_directories(typo PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})16target_include_directories(typo PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
1917
20if (FREETYPE_FOUND)18if (FREETYPE_FOUND)
2119
=== modified file 'playground/demo-shell/typo/typo_glcache.cpp'
--- playground/demo-shell/typo/typo_glcache.cpp 2015-07-16 07:03:19 +0000
+++ playground/demo-shell/typo/typo_glcache.cpp 2016-05-13 09:11:33 +0000
@@ -17,7 +17,7 @@
17 */17 */
1818
19#include "typo_glcache.h"19#include "typo_glcache.h"
20#include <GLES2/gl2.h> // TODO: Support plain OpenGL too20#include MIR_SERVER_GL_H
2121
22using namespace mir::examples::typo;22using namespace mir::examples::typo;
2323
2424
=== modified file 'src/gl/program.cpp'
--- src/gl/program.cpp 2016-01-29 08:18:22 +0000
+++ src/gl/program.cpp 2016-05-13 09:11:33 +0000
@@ -19,6 +19,8 @@
19#include "mir/gl/program.h"19#include "mir/gl/program.h"
20#include <boost/throw_exception.hpp>20#include <boost/throw_exception.hpp>
21#include <stdexcept>21#include <stdexcept>
22#include MIR_SERVER_GL_H
23#include MIR_SERVER_GLEXT_H
2224
23namespace mgl = mir::gl;25namespace mgl = mir::gl;
2426
2527
=== modified file 'src/include/gl/mir/gl/primitive.h'
--- src/include/gl/mir/gl/primitive.h 2016-01-29 08:18:22 +0000
+++ src/include/gl/mir/gl/primitive.h 2016-05-13 09:11:33 +0000
@@ -20,7 +20,7 @@
20#ifndef MIR_GL_PRIMITIVE_H_20#ifndef MIR_GL_PRIMITIVE_H_
21#define MIR_GL_PRIMITIVE_H_21#define MIR_GL_PRIMITIVE_H_
2222
23#include <GLES2/gl2.h>23#include MIR_SERVER_GL_H
2424
25namespace mir25namespace mir
26{26{
2727
=== modified file 'src/include/gl/mir/gl/program.h'
--- src/include/gl/mir/gl/program.h 2015-10-05 08:19:39 +0000
+++ src/include/gl/mir/gl/program.h 2016-05-13 09:11:33 +0000
@@ -19,7 +19,7 @@
19#ifndef MIR_GL_PROGRAM_H_19#ifndef MIR_GL_PROGRAM_H_
20#define MIR_GL_PROGRAM_H_20#define MIR_GL_PROGRAM_H_
2121
22#include <GLES2/gl2.h>22#include MIR_SERVER_GL_H
2323
24namespace mir24namespace mir
25{25{
2626
=== modified file 'src/include/gl/mir/gl/texture.h'
--- src/include/gl/mir/gl/texture.h 2016-01-29 08:18:22 +0000
+++ src/include/gl/mir/gl/texture.h 2016-05-13 09:11:33 +0000
@@ -19,7 +19,7 @@
19#ifndef MIR_GL_TEXTURE_H_19#ifndef MIR_GL_TEXTURE_H_
20#define MIR_GL_TEXTURE_H_20#define MIR_GL_TEXTURE_H_
2121
22#include <GLES2/gl2.h>22#include MIR_SERVER_GL_H
2323
24namespace mir24namespace mir
25{25{
2626
=== modified file 'src/include/platform/mir/graphics/egl_extensions.h'
--- src/include/platform/mir/graphics/egl_extensions.h 2016-03-29 07:30:50 +0000
+++ src/include/platform/mir/graphics/egl_extensions.h 2016-05-13 09:11:33 +0000
@@ -19,12 +19,11 @@
19#ifndef MIR_GRAPHICS_EGL_EXTENSIONS_H_19#ifndef MIR_GRAPHICS_EGL_EXTENSIONS_H_
20#define MIR_GRAPHICS_EGL_EXTENSIONS_H_20#define MIR_GRAPHICS_EGL_EXTENSIONS_H_
2121
22#define GL_GLEXT_PROTOTYPES
23#define EGL_EGLEXT_PROTOTYPES22#define EGL_EGLEXT_PROTOTYPES
24#include <EGL/egl.h>23#include <EGL/egl.h>
25#include <EGL/eglext.h>24#include <EGL/eglext.h>
26#include <GLES2/gl2.h>25#include MIR_SERVER_GL_H
27#include <GLES2/gl2ext.h>26#include MIR_SERVER_GLEXT_H
2827
29namespace mir28namespace mir
30{29{
3130
=== modified file 'src/platform/CMakeLists.txt'
--- src/platform/CMakeLists.txt 2016-05-04 05:48:28 +0000
+++ src/platform/CMakeLists.txt 2016-05-13 09:11:33 +0000
@@ -18,7 +18,7 @@
1818
19set(MIR_PLATFORM_REFERENCES19set(MIR_PLATFORM_REFERENCES
20 ${EGL_LDFLAGS} ${EGL_LIBRARIES}20 ${EGL_LDFLAGS} ${EGL_LIBRARIES}
21 ${GLESv2_LDFLAGS} ${GLESv2_LIBRARIES}21 ${GL_LDFLAGS} ${GL_LIBRARIES}
22)22)
2323
24add_subdirectory(graphics/)24add_subdirectory(graphics/)
2525
=== modified file 'src/platform/graphics/CMakeLists.txt'
--- src/platform/graphics/CMakeLists.txt 2016-03-29 07:30:50 +0000
+++ src/platform/graphics/CMakeLists.txt 2016-05-13 09:11:33 +0000
@@ -1,4 +1,4 @@
1include_directories(${GLESv2_INCLUDE_DIRS})1include_directories(${GL_INCLUDE_DIRS})
22
3set(3set(
4 GRAPHICS_SOURCES4 GRAPHICS_SOURCES
55
=== modified file 'src/platform/graphics/egl_extensions.cpp'
--- src/platform/graphics/egl_extensions.cpp 2016-03-29 07:30:50 +0000
+++ src/platform/graphics/egl_extensions.cpp 2016-05-13 09:11:33 +0000
@@ -28,6 +28,13 @@
28 reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress("eglCreateImageKHR"))},28 reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress("eglCreateImageKHR"))},
29 eglDestroyImageKHR{29 eglDestroyImageKHR{
30 reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress("eglDestroyImageKHR"))},30 reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress("eglDestroyImageKHR"))},
31
32 /*
33 * TODO: Find a non-ES GL equivalent for glEGLImageTargetTexture2DOES
34 * It's the LAST remaining ES-specific function. Although Mesa lets you use
35 * it in full GL, it theoretically should not work. Mesa just lets you
36 * mix ES and GL code. But other drivers won't be so lenient.
37 */
31 glEGLImageTargetTexture2DOES{38 glEGLImageTargetTexture2DOES{
32 reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>(eglGetProcAddress("glEGLImageTargetTexture2DOES"))}39 reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>(eglGetProcAddress("glEGLImageTargetTexture2DOES"))}
33{40{
3441
=== modified file 'src/platforms/android/include/egl_sync_extensions.h'
--- src/platforms/android/include/egl_sync_extensions.h 2016-01-29 13:10:01 +0000
+++ src/platforms/android/include/egl_sync_extensions.h 2016-05-13 09:11:33 +0000
@@ -19,7 +19,9 @@
19#ifndef MIR_GRAPHICS_EGL_SYNC_EXTENSIONS_H_19#ifndef MIR_GRAPHICS_EGL_SYNC_EXTENSIONS_H_
20#define MIR_GRAPHICS_EGL_SYNC_EXTENSIONS_H_20#define MIR_GRAPHICS_EGL_SYNC_EXTENSIONS_H_
2121
22#ifndef GL_GLEXT_PROTOTYPES
22#define GL_GLEXT_PROTOTYPES23#define GL_GLEXT_PROTOTYPES
24#endif
23#define EGL_EGLEXT_PROTOTYPES25#define EGL_EGLEXT_PROTOTYPES
2426
25//Xenial egl has started needing a header (android/native_window.h)27//Xenial egl has started needing a header (android/native_window.h)
2628
=== modified file 'src/platforms/android/server/buffer.h'
--- src/platforms/android/server/buffer.h 2016-03-29 07:30:50 +0000
+++ src/platforms/android/server/buffer.h 2016-05-13 09:11:33 +0000
@@ -29,7 +29,9 @@
29#include <condition_variable>29#include <condition_variable>
30#include <map>30#include <map>
3131
32#ifndef GL_GLEXT_PROTOTYPES
32#define GL_GLEXT_PROTOTYPES33#define GL_GLEXT_PROTOTYPES
34#endif
33#define EGL_EGLEXT_PROTOTYPES35#define EGL_EGLEXT_PROTOTYPES
34#include <EGL/egl.h>36#include <EGL/egl.h>
35#include <EGL/eglext.h>37#include <EGL/eglext.h>
3638
=== modified file 'src/platforms/android/server/hwc_fallback_gl_renderer.cpp'
--- src/platforms/android/server/hwc_fallback_gl_renderer.cpp 2016-01-29 08:18:22 +0000
+++ src/platforms/android/server/hwc_fallback_gl_renderer.cpp 2016-05-13 09:11:33 +0000
@@ -30,6 +30,8 @@
30#include <glm/gtc/matrix_transform.hpp>30#include <glm/gtc/matrix_transform.hpp>
31#include <glm/gtc/type_ptr.hpp>31#include <glm/gtc/type_ptr.hpp>
3232
33#include <GLES2/gl2.h>
34
33namespace mg = mir::graphics;35namespace mg = mir::graphics;
34namespace mgl = mir::gl;36namespace mgl = mir::gl;
35namespace mga = mir::graphics::android;37namespace mga = mir::graphics::android;
3638
=== modified file 'src/platforms/common/server/CMakeLists.txt'
--- src/platforms/common/server/CMakeLists.txt 2016-04-21 07:01:58 +0000
+++ src/platforms/common/server/CMakeLists.txt 2016-05-13 09:11:33 +0000
@@ -1,6 +1,6 @@
1include_directories(1include_directories(
2 ${server_common_include_dirs}2 ${server_common_include_dirs}
3 ${GLESv2_INCLUDE_DIRS}3 ${GL_INCLUDE_DIRS}
4)4)
55
6add_library(server_platform_common STATIC6add_library(server_platform_common STATIC
@@ -13,5 +13,5 @@
13 server_platform_common13 server_platform_common
1414
15 ${Boost_SYSTEM_LIBRARY}15 ${Boost_SYSTEM_LIBRARY}
16 ${GLESv2_LDFLAGS} ${GLESv2_LIBRARIES}16 ${GL_LDFLAGS} ${GL_LIBRARIES}
17)17)
1818
=== modified file 'src/platforms/common/server/shm_buffer.cpp'
--- src/platforms/common/server/shm_buffer.cpp 2016-05-03 04:36:33 +0000
+++ src/platforms/common/server/shm_buffer.cpp 2016-05-13 09:11:33 +0000
@@ -20,8 +20,8 @@
20#include "shm_file.h"20#include "shm_file.h"
21#include "shm_buffer.h"21#include "shm_buffer.h"
22#include "buffer_texture_binder.h"22#include "buffer_texture_binder.h"
23#include <GLES2/gl2.h>23#include MIR_SERVER_GL_H
24#include <GLES2/gl2ext.h>24#include MIR_SERVER_GLEXT_H
2525
26#include <boost/throw_exception.hpp>26#include <boost/throw_exception.hpp>
2727
@@ -138,7 +138,9 @@
138 */138 */
139 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);139 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
140140
141 glTexImage2D(GL_TEXTURE_2D, 0, format,141 auto internal_format = (format == GL_BGRA_EXT) ? GL_RGBA : format;
142
143 glTexImage2D(GL_TEXTURE_2D, 0, internal_format,
142 size_.width.as_int(), size_.height.as_int(),144 size_.width.as_int(), size_.height.as_int(),
143 0, format, type, pixels);145 0, format, type, pixels);
144 }146 }
145147
=== modified file 'src/platforms/mesa/server/buffer_allocator.cpp'
--- src/platforms/mesa/server/buffer_allocator.cpp 2016-05-04 09:06:26 +0000
+++ src/platforms/mesa/server/buffer_allocator.cpp 2016-05-13 09:11:33 +0000
@@ -31,8 +31,8 @@
3131
32#include <EGL/egl.h>32#include <EGL/egl.h>
33#include <EGL/eglext.h>33#include <EGL/eglext.h>
34#include <GLES2/gl2.h>34#include MIR_SERVER_GL_H
35#include <GLES2/gl2ext.h>35#include MIR_SERVER_GLEXT_H
3636
37#include <algorithm>37#include <algorithm>
38#include <stdexcept>38#include <stdexcept>
@@ -97,6 +97,7 @@
97 {97 {
98 if (egl_image == EGL_NO_IMAGE_KHR)98 if (egl_image == EGL_NO_IMAGE_KHR)
99 {99 {
100 eglBindAPI(MIR_SERVER_EGL_OPENGL_API);
100 egl_display = eglGetCurrentDisplay();101 egl_display = eglGetCurrentDisplay();
101 gbm_bo* bo_raw{bo.get()};102 gbm_bo* bo_raw{bo.get()};
102103
@@ -131,6 +132,7 @@
131 {132 {
132 if (egl_image == EGL_NO_IMAGE_KHR)133 if (egl_image == EGL_NO_IMAGE_KHR)
133 {134 {
135 eglBindAPI(MIR_SERVER_EGL_OPENGL_API);
134 egl_display = eglGetCurrentDisplay();136 egl_display = eglGetCurrentDisplay();
135 gbm_bo* bo_raw{bo.get()};137 gbm_bo* bo_raw{bo.get()};
136138
137139
=== modified file 'src/platforms/mesa/server/display_helpers.cpp'
--- src/platforms/mesa/server/display_helpers.cpp 2016-05-04 09:06:26 +0000
+++ src/platforms/mesa/server/display_helpers.cpp 2016-05-13 09:11:33 +0000
@@ -321,8 +321,12 @@
321321
322void mgmh::EGLHelper::setup(GBMHelper const& gbm)322void mgmh::EGLHelper::setup(GBMHelper const& gbm)
323{323{
324 eglBindAPI(MIR_SERVER_EGL_OPENGL_API);
325
324 static const EGLint context_attr[] = {326 static const EGLint context_attr[] = {
327#if MIR_SERVER_EGL_OPENGL_BIT == EGL_OPENGL_ES2_BIT
325 EGL_CONTEXT_CLIENT_VERSION, 2,328 EGL_CONTEXT_CLIENT_VERSION, 2,
329#endif
326 EGL_NONE330 EGL_NONE
327 };331 };
328332
@@ -335,8 +339,12 @@
335339
336void mgmh::EGLHelper::setup(GBMHelper const& gbm, EGLContext shared_context)340void mgmh::EGLHelper::setup(GBMHelper const& gbm, EGLContext shared_context)
337{341{
342 eglBindAPI(MIR_SERVER_EGL_OPENGL_API);
343
338 static const EGLint context_attr[] = {344 static const EGLint context_attr[] = {
345#if MIR_SERVER_EGL_OPENGL_BIT == EGL_OPENGL_ES2_BIT
339 EGL_CONTEXT_CLIENT_VERSION, 2,346 EGL_CONTEXT_CLIENT_VERSION, 2,
347#endif
340 EGL_NONE348 EGL_NONE
341 };349 };
342350
@@ -350,8 +358,12 @@
350void mgmh::EGLHelper::setup(GBMHelper const& gbm, gbm_surface* surface_gbm,358void mgmh::EGLHelper::setup(GBMHelper const& gbm, gbm_surface* surface_gbm,
351 EGLContext shared_context)359 EGLContext shared_context)
352{360{
361 eglBindAPI(MIR_SERVER_EGL_OPENGL_API);
362
353 static const EGLint context_attr[] = {363 static const EGLint context_attr[] = {
364#if MIR_SERVER_EGL_OPENGL_BIT == EGL_OPENGL_ES2_BIT
354 EGL_CONTEXT_CLIENT_VERSION, 2,365 EGL_CONTEXT_CLIENT_VERSION, 2,
366#endif
355 EGL_NONE367 EGL_NONE
356 };368 };
357369
@@ -371,6 +383,7 @@
371 if (egl_display != EGL_NO_DISPLAY) {383 if (egl_display != EGL_NO_DISPLAY) {
372 if (egl_context != EGL_NO_CONTEXT)384 if (egl_context != EGL_NO_CONTEXT)
373 {385 {
386 eglBindAPI(MIR_SERVER_EGL_OPENGL_API);
374 if (eglGetCurrentContext() == egl_context)387 if (eglGetCurrentContext() == egl_context)
375 eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);388 eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
376 eglDestroyContext(egl_display, egl_context);389 eglDestroyContext(egl_display, egl_context);
@@ -391,6 +404,7 @@
391bool mgmh::EGLHelper::make_current() const404bool mgmh::EGLHelper::make_current() const
392{405{
393 auto ret = eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context);406 auto ret = eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context);
407 eglBindAPI(MIR_SERVER_EGL_OPENGL_API);
394 return (ret == EGL_TRUE);408 return (ret == EGL_TRUE);
395}409}
396410
@@ -410,7 +424,7 @@
410 EGL_ALPHA_SIZE, 0,424 EGL_ALPHA_SIZE, 0,
411 EGL_DEPTH_SIZE, depth_buffer_bits,425 EGL_DEPTH_SIZE, depth_buffer_bits,
412 EGL_STENCIL_SIZE, stencil_buffer_bits,426 EGL_STENCIL_SIZE, stencil_buffer_bits,
413 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,427 EGL_RENDERABLE_TYPE, MIR_SERVER_EGL_OPENGL_BIT,
414 EGL_NONE428 EGL_NONE
415 };429 };
416430
@@ -440,8 +454,6 @@
440 should_terminate_egl = true;454 should_terminate_egl = true;
441 }455 }
442456
443 eglBindAPI(EGL_OPENGL_ES_API);
444
445 if (eglChooseConfig(egl_display, config_attr, &egl_config, 1, &num_egl_configs) == EGL_FALSE ||457 if (eglChooseConfig(egl_display, config_attr, &egl_config, 1, &num_egl_configs) == EGL_FALSE ||
446 num_egl_configs != 1)458 num_egl_configs != 1)
447 {459 {
448460
=== modified file 'src/platforms/mesa/server/kms/CMakeLists.txt'
--- src/platforms/mesa/server/kms/CMakeLists.txt 2016-05-09 10:03:10 +0000
+++ src/platforms/mesa/server/kms/CMakeLists.txt 2016-05-13 09:11:33 +0000
@@ -7,7 +7,7 @@
7 ${DRM_INCLUDE_DIRS}7 ${DRM_INCLUDE_DIRS}
8 ${GBM_INCLUDE_DIRS}8 ${GBM_INCLUDE_DIRS}
9 ${EGL_INCLUDE_DIRS}9 ${EGL_INCLUDE_DIRS}
10 ${GLESv2_INCLUDE_DIRS}10 ${GL_INCLUDE_DIRS}
11 ${UDEV_INCLUDE_DIRS}11 ${UDEV_INCLUDE_DIRS}
12)12)
1313
@@ -59,7 +59,7 @@
59 ${DRM_LDFLAGS} ${DRM_LIBRARIES}59 ${DRM_LDFLAGS} ${DRM_LIBRARIES}
60 ${GBM_LDFLAGS} ${GBM_LIBRARIES}60 ${GBM_LDFLAGS} ${GBM_LIBRARIES}
61 ${EGL_LDFLAGS} ${EGL_LIBRARIES}61 ${EGL_LDFLAGS} ${EGL_LIBRARIES}
62 ${GLESv2_LDFLAGS} ${GLESv2_LIBRARIES}62 ${GL_LDFLAGS} ${GL_LIBRARIES}
63)63)
6464
65set_target_properties(65set_target_properties(
6666
=== modified file 'src/platforms/mesa/server/kms/display_buffer.cpp'
--- src/platforms/mesa/server/kms/display_buffer.cpp 2016-05-03 04:36:33 +0000
+++ src/platforms/mesa/server/kms/display_buffer.cpp 2016-05-13 09:11:33 +0000
@@ -24,7 +24,7 @@
24#include "mir/fatal.h"24#include "mir/fatal.h"
2525
26#include <boost/throw_exception.hpp>26#include <boost/throw_exception.hpp>
27#include <GLES2/gl2.h>27#include MIR_SERVER_GL_H
2828
29#include <stdexcept>29#include <stdexcept>
30#include <chrono>30#include <chrono>
3131
=== modified file 'src/platforms/mesa/server/x11/CMakeLists.txt'
--- src/platforms/mesa/server/x11/CMakeLists.txt 2016-01-29 08:18:22 +0000
+++ src/platforms/mesa/server/x11/CMakeLists.txt 2016-05-13 09:11:33 +0000
@@ -26,7 +26,7 @@
26 PRIVATE26 PRIVATE
27 mirplatform27 mirplatform
28 EGL28 EGL
29 GLESv229 ${GL_LDFLAGS} ${GL_LIBRARIES}
30 X1130 X11
31 mirsharedmesaservercommon-static31 mirsharedmesaservercommon-static
32 ${Boost_PROGRAM_OPTIONS_LIBRARY}32 ${Boost_PROGRAM_OPTIONS_LIBRARY}
3333
=== modified file 'src/platforms/mesa/server/x11/graphics/CMakeLists.txt'
--- src/platforms/mesa/server/x11/graphics/CMakeLists.txt 2016-05-04 09:06:26 +0000
+++ src/platforms/mesa/server/x11/graphics/CMakeLists.txt 2016-05-13 09:11:33 +0000
@@ -9,7 +9,7 @@
9 ${DRM_INCLUDE_DIRS}9 ${DRM_INCLUDE_DIRS}
10 ${GBM_INCLUDE_DIRS}10 ${GBM_INCLUDE_DIRS}
11 ${EGL_INCLUDE_DIRS}11 ${EGL_INCLUDE_DIRS}
12 ${GLESv2_INCLUDE_DIRS}12 ${GL_INCLUDE_DIRS}
13 ${UDEV_INCLUDE_DIRS}13 ${UDEV_INCLUDE_DIRS}
14)14)
1515
1616
=== modified file 'src/platforms/mesa/server/x11/graphics/display.cpp'
--- src/platforms/mesa/server/x11/graphics/display.cpp 2016-04-28 13:23:32 +0000
+++ src/platforms/mesa/server/x11/graphics/display.cpp 2016-05-13 09:11:33 +0000
@@ -71,7 +71,7 @@
71 EGL_ALPHA_SIZE, 8,71 EGL_ALPHA_SIZE, 8,
72 EGL_DEPTH_SIZE, 0,72 EGL_DEPTH_SIZE, 0,
73 EGL_STENCIL_SIZE, 0,73 EGL_STENCIL_SIZE, 0,
74 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,74 EGL_RENDERABLE_TYPE, MIR_SERVER_EGL_OPENGL_BIT,
75 EGL_NONE75 EGL_NONE
76 };76 };
7777
@@ -202,8 +202,12 @@
202mgx::X11EGLContext::X11EGLContext(EGLDisplay egl_dpy, EGLConfig config)202mgx::X11EGLContext::X11EGLContext(EGLDisplay egl_dpy, EGLConfig config)
203 : egl_dpy{egl_dpy}203 : egl_dpy{egl_dpy}
204{204{
205 eglBindAPI(MIR_SERVER_EGL_OPENGL_API);
206
205 static const EGLint ctx_attribs[] = {207 static const EGLint ctx_attribs[] = {
208#if MIR_SERVER_EGL_OPENGL_BIT == EGL_OPENGL_ES2_BIT
206 EGL_CONTEXT_CLIENT_VERSION, 2,209 EGL_CONTEXT_CLIENT_VERSION, 2,
210#endif
207 EGL_NONE };211 EGL_NONE };
208212
209 egl_ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs);213 egl_ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs);
210214
=== modified file 'src/renderers/gl/program_family.cpp'
--- src/renderers/gl/program_family.cpp 2016-01-29 08:18:22 +0000
+++ src/renderers/gl/program_family.cpp 2016-05-13 09:11:33 +0000
@@ -17,7 +17,8 @@
17 */17 */
1818
19#include "program_family.h"19#include "program_family.h"
2020#include MIR_SERVER_GL_H
21#include MIR_SERVER_GLEXT_H
21#include <mutex>22#include <mutex>
2223
23namespace mir24namespace mir
2425
=== modified file 'src/renderers/gl/program_family.h'
--- src/renderers/gl/program_family.h 2016-01-29 08:18:22 +0000
+++ src/renderers/gl/program_family.h 2016-05-13 09:11:33 +0000
@@ -19,7 +19,7 @@
19#ifndef MIR_RENDERER_GL_PROGRAM_FAMILY_H_19#ifndef MIR_RENDERER_GL_PROGRAM_FAMILY_H_
20#define MIR_RENDERER_GL_PROGRAM_FAMILY_H_20#define MIR_RENDERER_GL_PROGRAM_FAMILY_H_
2121
22#include <GLES2/gl2.h>22#include MIR_SERVER_GL_H
23#include <utility>23#include <utility>
24#include <map>24#include <map>
25#include <unordered_map>25#include <unordered_map>
2626
=== modified file 'src/renderers/gl/renderer.cpp'
--- src/renderers/gl/renderer.cpp 2016-05-03 04:36:33 +0000
+++ src/renderers/gl/renderer.cpp 2016-05-13 09:11:33 +0000
@@ -127,7 +127,9 @@
127127
128const GLchar* const mrg::Renderer::alpha_fshader =128const GLchar* const mrg::Renderer::alpha_fshader =
129{129{
130 "#ifdef GL_ES\n"
130 "precision mediump float;\n"131 "precision mediump float;\n"
132 "#endif\n"
131 "uniform sampler2D tex;\n"133 "uniform sampler2D tex;\n"
132 "uniform float alpha;\n"134 "uniform float alpha;\n"
133 "varying vec2 v_texcoord;\n"135 "varying vec2 v_texcoord;\n"
@@ -139,7 +141,9 @@
139141
140const GLchar* const mrg::Renderer::default_fshader =142const GLchar* const mrg::Renderer::default_fshader =
141{ // This is the fastest fragment shader. Use it when you can.143{ // This is the fastest fragment shader. Use it when you can.
144 "#ifdef GL_ES\n"
142 "precision mediump float;\n"145 "precision mediump float;\n"
146 "#endif\n"
143 "uniform sampler2D tex;\n"147 "uniform sampler2D tex;\n"
144 "varying vec2 v_texcoord;\n"148 "varying vec2 v_texcoord;\n"
145 "void main() {\n"149 "void main() {\n"
@@ -169,6 +173,7 @@
169 orientation(mir_orientation_normal),173 orientation(mir_orientation_normal),
170 mirror_mode(mir_mirror_mode_none)174 mirror_mode(mir_mirror_mode_none)
171{175{
176 eglBindAPI(MIR_SERVER_EGL_OPENGL_API);
172 EGLDisplay disp = eglGetCurrentDisplay();177 EGLDisplay disp = eglGetCurrentDisplay();
173 if (disp != EGL_NO_DISPLAY)178 if (disp != EGL_NO_DISPLAY)
174 {179 {
175180
=== modified file 'src/renderers/gl/renderer.h'
--- src/renderers/gl/renderer.h 2016-05-03 04:36:33 +0000
+++ src/renderers/gl/renderer.h 2016-05-13 09:11:33 +0000
@@ -28,7 +28,7 @@
28#include <mir/gl/primitive.h>28#include <mir/gl/primitive.h>
29#include "mir/renderer/gl/render_target.h"29#include "mir/renderer/gl/render_target.h"
3030
31#include <GLES2/gl2.h>31#include MIR_SERVER_GL_H
32#include <unordered_map>32#include <unordered_map>
33#include <unordered_set>33#include <unordered_set>
34#include <vector>34#include <vector>
3535
=== modified file 'src/server/CMakeLists.txt'
--- src/server/CMakeLists.txt 2016-05-03 04:36:33 +0000
+++ src/server/CMakeLists.txt 2016-05-13 09:11:33 +0000
@@ -84,7 +84,7 @@
8484
85set(MIR_SERVER_REFERENCES85set(MIR_SERVER_REFERENCES
86 ${EGL_LDFLAGS} ${EGL_LIBRARIES}86 ${EGL_LDFLAGS} ${EGL_LIBRARIES}
87 ${GLESv2_LDFLAGS} ${GLESv2_LIBRARIES}87 ${GL_LDFLAGS} ${GL_LIBRARIES}
88 ${UDEV_LDFLAGS} ${UDEV_LIBRARIES}88 ${UDEV_LDFLAGS} ${UDEV_LIBRARIES}
89 ${GLIB_LDFLAGS} ${GLIB_LIBRARIES}89 ${GLIB_LDFLAGS} ${GLIB_LIBRARIES}
90 ${UUID_LDFLAGS} ${UUID_LIBRARIES}90 ${UUID_LDFLAGS} ${UUID_LIBRARIES}
@@ -109,7 +109,7 @@
109 ${GLog_LIBRARY}109 ${GLog_LIBRARY}
110 ${GFlags_LIBRARY}110 ${GFlags_LIBRARY}
111 ${EGL_LDFLAGS} ${EGL_LIBRARIES}111 ${EGL_LDFLAGS} ${EGL_LIBRARIES}
112 ${GLESv2_LDFLAGS} ${GLESv2_LIBRARIES}112 ${GL_LDFLAGS} ${GL_LIBRARIES}
113 ${UDEV_LDFLAGS} ${UDEV_LIBRARIES}113 ${UDEV_LDFLAGS} ${UDEV_LIBRARIES}
114 ${GLIB_LDFLAGS} ${GLIB_LIBRARIES}114 ${GLIB_LDFLAGS} ${GLIB_LIBRARIES}
115 ${UUID_LDFLAGS} ${UUID_LIBRARIES}115 ${UUID_LDFLAGS} ${UUID_LIBRARIES}
116116
=== modified file 'src/server/compositor/screencast_display_buffer.h'
--- src/server/compositor/screencast_display_buffer.h 2016-05-03 04:36:33 +0000
+++ src/server/compositor/screencast_display_buffer.h 2016-05-13 09:11:33 +0000
@@ -22,7 +22,8 @@
22#include "mir/graphics/display_buffer.h"22#include "mir/graphics/display_buffer.h"
23#include "mir/renderer/gl/render_target.h"23#include "mir/renderer/gl/render_target.h"
2424
25#include <GLES2/gl2.h>25#include MIR_SERVER_GL_H
26#include MIR_SERVER_GLEXT_H
2627
27namespace mir28namespace mir
28{29{
2930
=== modified file 'src/server/graphics/CMakeLists.txt'
--- src/server/graphics/CMakeLists.txt 2016-01-29 08:18:22 +0000
+++ src/server/graphics/CMakeLists.txt 2016-05-13 09:11:33 +0000
@@ -1,4 +1,4 @@
1include_directories(${GLESv2_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR})1include_directories(${GL_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR})
22
3add_library(3add_library(
4 mirgraphics OBJECT4 mirgraphics OBJECT
55
=== modified file 'src/server/graphics/nested/display.cpp'
--- src/server/graphics/nested/display.cpp 2016-02-01 22:53:06 +0000
+++ src/server/graphics/nested/display.cpp 2016-05-13 09:11:33 +0000
@@ -44,7 +44,9 @@
4444
45EGLint const mgn::detail::nested_egl_context_attribs[] =45EGLint const mgn::detail::nested_egl_context_attribs[] =
46{46{
47#if MIR_SERVER_EGL_OPENGL_BIT == EGL_OPENGL_ES2_BIT
47 EGL_CONTEXT_CLIENT_VERSION, 2,48 EGL_CONTEXT_CLIENT_VERSION, 2,
49#endif
48 EGL_NONE50 EGL_NONE
49};51};
5052
@@ -86,14 +88,15 @@
86 BOOST_THROW_EXCEPTION(mg::egl_error("Nested Mir Display Error: Failed to initialize EGL."));88 BOOST_THROW_EXCEPTION(mg::egl_error("Nested Mir Display Error: Failed to initialize EGL."));
87 }89 }
8890
91 eglBindAPI(MIR_SERVER_EGL_OPENGL_API);
89 pixel_format = format;92 pixel_format = format;
90 egl_context_ = eglCreateContext(egl_display, choose_windowed_es_config(format), EGL_NO_CONTEXT, detail::nested_egl_context_attribs);93 egl_context_ = eglCreateContext(egl_display, choose_windowed_config(format), EGL_NO_CONTEXT, detail::nested_egl_context_attribs);
9194
92 if (egl_context_ == EGL_NO_CONTEXT)95 if (egl_context_ == EGL_NO_CONTEXT)
93 BOOST_THROW_EXCEPTION(mg::egl_error("Failed to create shared EGL context"));96 BOOST_THROW_EXCEPTION(mg::egl_error("Failed to create shared EGL context"));
94}97}
9598
96EGLConfig mgn::detail::EGLDisplayHandle::choose_windowed_es_config(MirPixelFormat format) const99EGLConfig mgn::detail::EGLDisplayHandle::choose_windowed_config(MirPixelFormat format) const
97{100{
98 EGLint const nested_egl_config_attribs[] =101 EGLint const nested_egl_config_attribs[] =
99 {102 {
@@ -104,7 +107,7 @@
104 EGL_ALPHA_SIZE, mg::alpha_channel_depth(format),107 EGL_ALPHA_SIZE, mg::alpha_channel_depth(format),
105 EGL_DEPTH_SIZE, gl_config->depth_buffer_bits(),108 EGL_DEPTH_SIZE, gl_config->depth_buffer_bits(),
106 EGL_STENCIL_SIZE, gl_config->stencil_buffer_bits(),109 EGL_STENCIL_SIZE, gl_config->stencil_buffer_bits(),
107 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,110 EGL_RENDERABLE_TYPE, MIR_SERVER_EGL_OPENGL_BIT,
108 EGL_NONE111 EGL_NONE
109 };112 };
110 EGLConfig result;113 EGLConfig result;
@@ -133,7 +136,7 @@
133 EGL_ALPHA_SIZE, mg::alpha_channel_depth(pixel_format),136 EGL_ALPHA_SIZE, mg::alpha_channel_depth(pixel_format),
134 EGL_DEPTH_SIZE, gl_config->depth_buffer_bits(),137 EGL_DEPTH_SIZE, gl_config->depth_buffer_bits(),
135 EGL_STENCIL_SIZE, gl_config->stencil_buffer_bits(),138 EGL_STENCIL_SIZE, gl_config->stencil_buffer_bits(),
136 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,139 EGL_RENDERABLE_TYPE, MIR_SERVER_EGL_OPENGL_BIT,
137 EGL_NONE140 EGL_NONE
138 };141 };
139 return std::make_unique<SurfacelessEGLContext>(egl_display, attribs, EGL_NO_CONTEXT);142 return std::make_unique<SurfacelessEGLContext>(egl_display, attribs, EGL_NO_CONTEXT);
@@ -205,6 +208,7 @@
205208
206mgn::Display::~Display() noexcept209mgn::Display::~Display() noexcept
207{210{
211 eglBindAPI(MIR_SERVER_EGL_OPENGL_API);
208 if (eglGetCurrentContext() == egl_display.egl_context())212 if (eglGetCurrentContext() == egl_display.egl_context())
209 eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);213 eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
210}214}
@@ -311,6 +315,7 @@
311 mir_buffer_usage_hardware,315 mir_buffer_usage_hardware,
312 static_cast<uint32_t>(best_output.id.as_value()));316 static_cast<uint32_t>(best_output.id.as_value()));
313317
318 eglBindAPI(MIR_SERVER_EGL_OPENGL_API);
314 display_buffer = std::make_shared<mgn::detail::DisplaySyncGroup>(319 display_buffer = std::make_shared<mgn::detail::DisplaySyncGroup>(
315 std::make_shared<mgn::detail::DisplayBuffer>(320 std::make_shared<mgn::detail::DisplayBuffer>(
316 egl_display,321 egl_display,
317322
=== modified file 'src/server/graphics/nested/display.h'
--- src/server/graphics/nested/display.h 2016-02-01 22:53:06 +0000
+++ src/server/graphics/nested/display.h 2016-05-13 09:11:33 +0000
@@ -78,7 +78,7 @@
78 ~EGLDisplayHandle() noexcept;78 ~EGLDisplayHandle() noexcept;
7979
80 void initialize(MirPixelFormat format);80 void initialize(MirPixelFormat format);
81 EGLConfig choose_windowed_es_config(MirPixelFormat format) const;81 EGLConfig choose_windowed_config(MirPixelFormat format) const;
82 EGLContext egl_context() const;82 EGLContext egl_context() const;
83 std::unique_ptr<graphics::GLContext> create_gl_context();83 std::unique_ptr<graphics::GLContext> create_gl_context();
8484
8585
=== modified file 'src/server/graphics/nested/display_buffer.cpp'
--- src/server/graphics/nested/display_buffer.cpp 2016-05-03 04:36:33 +0000
+++ src/server/graphics/nested/display_buffer.cpp 2016-05-13 09:11:33 +0000
@@ -42,7 +42,7 @@
42 MirPixelFormat preferred_format) :42 MirPixelFormat preferred_format) :
43 egl_display(egl_display),43 egl_display(egl_display),
44 host_surface{host_surface},44 host_surface{host_surface},
45 egl_config{egl_display.choose_windowed_es_config(preferred_format)},45 egl_config{egl_display.choose_windowed_config(preferred_format)},
46 egl_context{egl_display, eglCreateContext(egl_display, egl_config, egl_display.egl_context(), nested_egl_context_attribs)},46 egl_context{egl_display, eglCreateContext(egl_display, egl_config, egl_display.egl_context(), nested_egl_context_attribs)},
47 area{area.top_left, area.size},47 area{area.top_left, area.size},
48 dispatcher{dispatcher},48 dispatcher{dispatcher},
4949
=== modified file 'src/server/graphics/offscreen/display.cpp'
--- src/server/graphics/offscreen/display.cpp 2016-01-27 16:09:11 +0000
+++ src/server/graphics/offscreen/display.cpp 2016-05-13 09:11:33 +0000
@@ -150,6 +150,7 @@
150 {150 {
151 if (output.connected && output.preferred_mode_index < output.modes.size())151 if (output.connected && output.preferred_mode_index < output.modes.size())
152 {152 {
153 eglBindAPI(MIR_SERVER_EGL_OPENGL_API);
153 auto raw_db = new mgo::DisplayBuffer{154 auto raw_db = new mgo::DisplayBuffer{
154 SurfacelessEGLContext{egl_display, egl_context_shared},155 SurfacelessEGLContext{egl_display, egl_context_shared},
155 output.extents()};156 output.extents()};
@@ -188,6 +189,7 @@
188189
189std::unique_ptr<mg::GLContext> mgo::Display::create_gl_context()190std::unique_ptr<mg::GLContext> mgo::Display::create_gl_context()
190{191{
192 eglBindAPI(MIR_SERVER_EGL_OPENGL_API);
191 return std::make_unique<SurfacelessEGLContext>(egl_display, egl_context_shared);193 return std::make_unique<SurfacelessEGLContext>(egl_display, egl_context_shared);
192}194}
193195
194196
=== modified file 'src/server/graphics/offscreen/display_buffer.cpp'
--- src/server/graphics/offscreen/display_buffer.cpp 2016-05-03 04:36:33 +0000
+++ src/server/graphics/offscreen/display_buffer.cpp 2016-05-13 09:11:33 +0000
@@ -23,8 +23,8 @@
23#include <boost/throw_exception.hpp>23#include <boost/throw_exception.hpp>
24#include <stdexcept>24#include <stdexcept>
2525
26#include <GLES2/gl2.h>26#include MIR_SERVER_GL_H
27#include <GLES2/gl2ext.h>27#include MIR_SERVER_GLEXT_H
2828
29namespace mg = mir::graphics;29namespace mg = mir::graphics;
30namespace mgo = mg::offscreen;30namespace mgo = mg::offscreen;
@@ -57,11 +57,13 @@
57 GLenum gl_color_format{GL_RGBA4};57 GLenum gl_color_format{GL_RGBA4};
58 GLenum const gl_depth_format{GL_DEPTH_COMPONENT16};58 GLenum const gl_depth_format{GL_DEPTH_COMPONENT16};
5959
60#ifdef GL_RGBA8_OES
60 if (extensions.support("GL_ARM_rgba8") ||61 if (extensions.support("GL_ARM_rgba8") ||
61 extensions.support("GL_OES_rgb8_rgba8"))62 extensions.support("GL_OES_rgb8_rgba8"))
62 {63 {
63 gl_color_format = GL_RGBA8_OES;64 gl_color_format = GL_RGBA8_OES;
64 }65 }
66#endif
6567
66 /* Create a renderbuffer for the color attachment */68 /* Create a renderbuffer for the color attachment */
67 glGenRenderbuffers(1, &color_renderbuffer);69 glGenRenderbuffers(1, &color_renderbuffer);
6870
=== modified file 'src/server/graphics/surfaceless_egl_context.cpp'
--- src/server/graphics/surfaceless_egl_context.cpp 2015-06-17 05:20:42 +0000
+++ src/server/graphics/surfaceless_egl_context.cpp 2016-05-13 09:11:33 +0000
@@ -120,7 +120,9 @@
120120
121EGLint const default_egl_context_attr[] =121EGLint const default_egl_context_attr[] =
122{122{
123#if MIR_SERVER_EGL_OPENGL_BIT == EGL_OPENGL_ES2_BIT
123 EGL_CONTEXT_CLIENT_VERSION, 2,124 EGL_CONTEXT_CLIENT_VERSION, 2,
125#endif
124 EGL_NONE126 EGL_NONE
125};127};
126128
@@ -131,7 +133,7 @@
131 EGL_GREEN_SIZE, 8,133 EGL_GREEN_SIZE, 8,
132 EGL_BLUE_SIZE, 8,134 EGL_BLUE_SIZE, 8,
133 EGL_ALPHA_SIZE, 0,135 EGL_ALPHA_SIZE, 0,
134 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,136 EGL_RENDERABLE_TYPE, MIR_SERVER_EGL_OPENGL_BIT,
135 EGL_NONE137 EGL_NONE
136};138};
137139
@@ -180,6 +182,7 @@
180182
181void mg::SurfacelessEGLContext::make_current() const183void mg::SurfacelessEGLContext::make_current() const
182{184{
185 eglBindAPI(MIR_SERVER_EGL_OPENGL_API);
183 if (eglGetCurrentContext() == egl_context)186 if (eglGetCurrentContext() == egl_context)
184 return;187 return;
185188
@@ -193,6 +196,7 @@
193196
194void mg::SurfacelessEGLContext::release_current() const197void mg::SurfacelessEGLContext::release_current() const
195{198{
199 eglBindAPI(MIR_SERVER_EGL_OPENGL_API);
196 if (egl_context != EGL_NO_CONTEXT && eglGetCurrentContext() == egl_context)200 if (egl_context != EGL_NO_CONTEXT && eglGetCurrentContext() == egl_context)
197 eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);201 eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
198}202}
199203
=== modified file 'src/server/scene/gl_pixel_buffer.cpp'
--- src/server/scene/gl_pixel_buffer.cpp 2016-01-29 08:18:22 +0000
+++ src/server/scene/gl_pixel_buffer.cpp 2016-05-13 09:11:33 +0000
@@ -23,8 +23,8 @@
2323
24#include <stdexcept>24#include <stdexcept>
25#include <boost/throw_exception.hpp>25#include <boost/throw_exception.hpp>
2626#include MIR_SERVER_GL_H
27#include <GLES2/gl2ext.h>27#include MIR_SERVER_GLEXT_H
2828
29namespace mg = mir::graphics;29namespace mg = mir::graphics;
30namespace ms = mir::scene;30namespace ms = mir::scene;
3131
=== modified file 'src/server/scene/gl_pixel_buffer.h'
--- src/server/scene/gl_pixel_buffer.h 2014-03-06 06:05:17 +0000
+++ src/server/scene/gl_pixel_buffer.h 2016-05-13 09:11:33 +0000
@@ -24,7 +24,7 @@
24#include <memory>24#include <memory>
25#include <vector>25#include <vector>
2626
27#include <GLES2/gl2.h>27#include MIR_SERVER_GL_H
2828
29namespace mir29namespace mir
30{30{
3131
=== modified file 'tests/unit-tests/graphics/test_shm_buffer.cpp'
--- tests/unit-tests/graphics/test_shm_buffer.cpp 2016-04-01 06:57:58 +0000
+++ tests/unit-tests/graphics/test_shm_buffer.cpp 2016-05-13 09:11:33 +0000
@@ -162,7 +162,7 @@
162TEST_F(ShmBufferTest, uploads_xrgb_8888_correctly)162TEST_F(ShmBufferTest, uploads_xrgb_8888_correctly)
163{163{
164#if __BYTE_ORDER == __LITTLE_ENDIAN164#if __BYTE_ORDER == __LITTLE_ENDIAN
165 EXPECT_CALL(mock_gl, glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,165 EXPECT_CALL(mock_gl, glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
166 size.width.as_int(), size.height.as_int(),166 size.width.as_int(), size.height.as_int(),
167 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE,167 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE,
168 stub_shm_file->fake_mapping));168 stub_shm_file->fake_mapping));
@@ -174,7 +174,7 @@
174TEST_F(ShmBufferTest, uploads_argb_8888_correctly)174TEST_F(ShmBufferTest, uploads_argb_8888_correctly)
175{175{
176#if __BYTE_ORDER == __LITTLE_ENDIAN176#if __BYTE_ORDER == __LITTLE_ENDIAN
177 EXPECT_CALL(mock_gl, glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,177 EXPECT_CALL(mock_gl, glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
178 size.width.as_int(), size.height.as_int(),178 size.width.as_int(), size.height.as_int(),
179 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE,179 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE,
180 stub_shm_file->fake_mapping));180 stub_shm_file->fake_mapping));

Subscribers

People subscribed via source and target branches