Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

external-swiftshader: Commit

external/swiftshader


Commit MetaInfo

Revisión20eea3cd3b2d64e1b8f9811824cb41cacd09389c (tree)
Tiempo2018-06-21 00:50:48
AutorAlexis Hetu <sugoi@goog...>
CommiterAlexis Hétu

Log Message

Allow Linux build without X11 dependency

ChromeOS runs tests on some bots which run on Linux, but do not support X11.
In order to allow SwiftShader to successfully build on these bots, all X11
dependencies are #ifdefed behind the USE_X11 flag, which is already supplied
by the Chromium build system.

Change-Id: I6b914b1e662d9fbf101eb7caea7ac59e43cc7b56
Reviewed-on: https://swiftshader-review.googlesource.com/19488
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>

Cambiar Resumen

Diferencia incremental

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -174,6 +174,9 @@ else()
174174 set_cpp_flag("-march=x86-64")
175175 set_cpp_flag("-mtune=generic")
176176 endif()
177+ if(LINUX)
178+ set_cpp_flag("-DUSE_X11=1")
179+ endif()
177180
178181 # Use -g3 to have even more debug info
179182 set_cpp_flag("-g -g3" DEBUG)
--- a/src/Main/BUILD.gn
+++ b/src/Main/BUILD.gn
@@ -12,7 +12,7 @@
1212 # See the License for the specific language governing permissions and
1313 # limitations under the License.
1414
15-import("//ui/ozone/ozone.gni")
15+import("//build/config/ui.gni")
1616 import("../swiftshader.gni")
1717
1818 # Need a separate config to ensure the warnings are added to the end.
@@ -50,10 +50,12 @@ swiftshader_source_set("swiftshader_main") {
5050 if (use_ozone && !is_win) {
5151 sources += [ "FrameBufferOzone.cpp" ]
5252 } else if (is_linux) {
53- sources += [
54- "FrameBufferX11.cpp",
55- "libX11.cpp",
56- ]
53+ if (use_x11) {
54+ sources += [
55+ "FrameBufferX11.cpp",
56+ "libX11.cpp",
57+ ]
58+ }
5759 } else if (is_mac) {
5860 sources += [ "FrameBufferOSX.mm" ]
5961 } else if (is_win) {
--- a/src/OpenGL/libEGL/BUILD.gn
+++ b/src/OpenGL/libEGL/BUILD.gn
@@ -12,6 +12,7 @@
1212 # See the License for the specific language governing permissions and
1313 # limitations under the License.
1414
15+import("//build/config/ui.gni")
1516 import("../../swiftshader.gni")
1617
1718 # Need a separate config to ensure the warnings are added to the end.
@@ -70,7 +71,9 @@ swiftshader_shared_library("swiftshader_libEGL") {
7071 } else if (is_win) {
7172 ldflags = [ "/DEF:" + rebase_path("libGLESv2.def", root_build_dir) ]
7273 } else if (is_linux) {
73- sources += [ "../../Main/libX11.cpp" ]
74+ if (use_x11) {
75+ sources += [ "../../Main/libX11.cpp" ]
76+ }
7477 ldflags =
7578 [ "-Wl,--version-script=" + rebase_path("libEGL.lds", root_build_dir) ]
7679 }
--- a/src/OpenGL/libEGL/Display.cpp
+++ b/src/OpenGL/libEGL/Display.cpp
@@ -30,7 +30,7 @@
3030 #include <sys/ioctl.h>
3131 #include <linux/fb.h>
3232 #include <fcntl.h>
33-#elif defined(__linux__)
33+#elif defined(USE_X11)
3434 #include "Main/libX11.hpp"
3535 #elif defined(__APPLE__)
3636 #include "OSXUtils.hpp"
@@ -66,7 +66,7 @@ Display *Display::get(EGLDisplay dpy)
6666
6767 static void *nativeDisplay = nullptr;
6868
69- #if defined(__linux__) && !defined(__ANDROID__)
69+ #if defined(USE_X11)
7070 // Even if the application provides a native display handle, we open (and close) our own connection
7171 if(!nativeDisplay && dpy != HEADLESS_DISPLAY && libX11 && libX11->XOpenDisplay)
7272 {
@@ -89,7 +89,7 @@ Display::~Display()
8989 {
9090 terminate();
9191
92- #if defined(__linux__) && !defined(__ANDROID__)
92+ #if defined(USE_X11)
9393 if(nativeDisplay && libX11->XCloseDisplay)
9494 {
9595 libX11->XCloseDisplay((::Display*)nativeDisplay);
@@ -677,7 +677,7 @@ bool Display::isValidWindow(EGLNativeWindowType window)
677677 return false;
678678 }
679679 return true;
680- #elif defined(__linux__)
680+ #elif defined(USE_X11)
681681 if(nativeDisplay)
682682 {
683683 XWindowAttributes windowAttributes;
@@ -686,6 +686,8 @@ bool Display::isValidWindow(EGLNativeWindowType window)
686686 return status != 0;
687687 }
688688 return false;
689+ #elif defined(__linux__)
690+ return false; // Non X11 linux is headless only
689691 #elif defined(__APPLE__)
690692 return sw::OSX::IsValidWindow(window);
691693 #elif defined(__Fuchsia__)
@@ -843,7 +845,7 @@ sw::Format Display::getDisplayFormat() const
843845
844846 // No framebuffer device found, or we're in user space
845847 return sw::FORMAT_X8B8G8R8;
846- #elif defined(__linux__)
848+ #elif defined(USE_X11)
847849 if(nativeDisplay)
848850 {
849851 Screen *screen = libX11->XDefaultScreenOfDisplay((::Display*)nativeDisplay);
@@ -861,6 +863,8 @@ sw::Format Display::getDisplayFormat() const
861863 {
862864 return sw::FORMAT_X8R8G8B8;
863865 }
866+ #elif defined(__linux__) // Non X11 linux is headless only
867+ return sw::FORMAT_A8B8G8R8;
864868 #elif defined(__APPLE__)
865869 return sw::FORMAT_A8B8G8R8;
866870 #elif defined(__Fuchsia__)
--- a/src/OpenGL/libEGL/Surface.cpp
+++ b/src/OpenGL/libEGL/Surface.cpp
@@ -26,7 +26,7 @@
2626 #include "common/debug.h"
2727 #include "Main/FrameBuffer.hpp"
2828
29-#if defined(__linux__) && !defined(__ANDROID__)
29+#if defined(USE_X11)
3030 #include "Main/libX11.hpp"
3131 #elif defined(_WIN32)
3232 #include <tchar.h>
@@ -341,7 +341,7 @@ bool WindowSurface::checkForResize()
341341 #elif defined(__ANDROID__)
342342 int windowWidth; window->query(window, NATIVE_WINDOW_WIDTH, &windowWidth);
343343 int windowHeight; window->query(window, NATIVE_WINDOW_HEIGHT, &windowHeight);
344- #elif defined(__linux__)
344+ #elif defined(USE_X11)
345345 XWindowAttributes windowAttributes;
346346 Status status = libX11->XGetWindowAttributes((::Display*)display->getNativeDisplay(), window, &windowAttributes);
347347
@@ -352,6 +352,10 @@ bool WindowSurface::checkForResize()
352352
353353 int windowWidth = windowAttributes.width;
354354 int windowHeight = windowAttributes.height;
355+ #elif defined(__linux__)
356+ // Non X11 linux is headless only
357+ int windowWidth = 100;
358+ int windowHeight = 100;
355359 #elif defined(__APPLE__)
356360 int windowWidth;
357361 int windowHeight;
--- a/src/OpenGL/libEGL/libEGL.cpp
+++ b/src/OpenGL/libEGL/libEGL.cpp
@@ -25,7 +25,7 @@
2525
2626 #if defined(__ANDROID__)
2727 #include <system/window.h>
28-#elif defined(__linux__)
28+#elif defined(USE_X11)
2929 #include "Main/libX11.hpp"
3030 #endif
3131
@@ -120,7 +120,9 @@ EGLDisplay GetDisplay(EGLNativeDisplayType display_id)
120120 }
121121
122122 #if defined(__linux__) && !defined(__ANDROID__)
123+ #if defined(USE_X11)
123124 if(!libX11)
125+ #endif // Non X11 linux is headless only
124126 {
125127 return success(HEADLESS_DISPLAY);
126128 }
@@ -178,6 +180,8 @@ const char *QueryString(EGLDisplay dpy, EGLint name)
178180 "EGL_KHR_client_get_all_proc_addresses "
179181 #if defined(__linux__) && !defined(__ANDROID__)
180182 "EGL_KHR_platform_gbm "
183+#endif
184+#if defined(USE_X11)
181185 "EGL_KHR_platform_x11 "
182186 #endif
183187 "EGL_EXT_client_extensions "
@@ -1002,7 +1006,7 @@ EGLBoolean WaitNative(EGLint engine)
10021006
10031007 if(context)
10041008 {
1005- #if defined(__linux__) && !defined(__ANDROID__)
1009+ #if defined(USE_X11)
10061010 egl::Display *display = context->getDisplay();
10071011
10081012 if(!display)
@@ -1171,33 +1175,37 @@ EGLDisplay GetPlatformDisplayEXT(EGLenum platform, void *native_display, const E
11711175 #if defined(__linux__) && !defined(__ANDROID__)
11721176 switch(platform)
11731177 {
1178+ #if defined(USE_X11)
11741179 case EGL_PLATFORM_X11_EXT: break;
1180+ #endif
11751181 case EGL_PLATFORM_GBM_KHR: break;
11761182 default:
11771183 return error(EGL_BAD_PARAMETER, EGL_NO_DISPLAY);
11781184 }
11791185
1180- if(platform == EGL_PLATFORM_X11_EXT)
1186+ if(platform == EGL_PLATFORM_GBM_KHR)
11811187 {
1182- if(!libX11)
1183- {
1184- return error(EGL_BAD_ATTRIBUTE, EGL_NO_DISPLAY);
1185- }
1186-
11871188 if(native_display != (void*)EGL_DEFAULT_DISPLAY || attrib_list != NULL)
11881189 {
11891190 return error(EGL_BAD_ATTRIBUTE, EGL_NO_DISPLAY); // Unimplemented
11901191 }
1192+
1193+ return success(HEADLESS_DISPLAY);
11911194 }
1192- else if(platform == EGL_PLATFORM_GBM_KHR)
1195+ #if defined(USE_X11)
1196+ else if(platform == EGL_PLATFORM_X11_EXT)
11931197 {
1198+ if(!libX11)
1199+ {
1200+ return error(EGL_BAD_ATTRIBUTE, EGL_NO_DISPLAY);
1201+ }
1202+
11941203 if(native_display != (void*)EGL_DEFAULT_DISPLAY || attrib_list != NULL)
11951204 {
11961205 return error(EGL_BAD_ATTRIBUTE, EGL_NO_DISPLAY); // Unimplemented
11971206 }
1198-
1199- return success(HEADLESS_DISPLAY);
12001207 }
1208+ #endif
12011209
12021210 return success(PRIMARY_DISPLAY); // We only support the default display
12031211 #else
Show on old repository browser