external/swiftshader
Revisión | 20eea3cd3b2d64e1b8f9811824cb41cacd09389c (tree) |
---|---|
Tiempo | 2018-06-21 00:50:48 |
Autor | Alexis Hetu <sugoi@goog...> |
Commiter | Alexis Hétu |
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>
@@ -174,6 +174,9 @@ else() | ||
174 | 174 | set_cpp_flag("-march=x86-64") |
175 | 175 | set_cpp_flag("-mtune=generic") |
176 | 176 | endif() |
177 | + if(LINUX) | |
178 | + set_cpp_flag("-DUSE_X11=1") | |
179 | + endif() | |
177 | 180 | |
178 | 181 | # Use -g3 to have even more debug info |
179 | 182 | set_cpp_flag("-g -g3" DEBUG) |
@@ -12,7 +12,7 @@ | ||
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 | |
15 | -import("//ui/ozone/ozone.gni") | |
15 | +import("//build/config/ui.gni") | |
16 | 16 | import("../swiftshader.gni") |
17 | 17 | |
18 | 18 | # Need a separate config to ensure the warnings are added to the end. |
@@ -50,10 +50,12 @@ swiftshader_source_set("swiftshader_main") { | ||
50 | 50 | if (use_ozone && !is_win) { |
51 | 51 | sources += [ "FrameBufferOzone.cpp" ] |
52 | 52 | } 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 | + } | |
57 | 59 | } else if (is_mac) { |
58 | 60 | sources += [ "FrameBufferOSX.mm" ] |
59 | 61 | } else if (is_win) { |
@@ -12,6 +12,7 @@ | ||
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 | |
15 | +import("//build/config/ui.gni") | |
15 | 16 | import("../../swiftshader.gni") |
16 | 17 | |
17 | 18 | # Need a separate config to ensure the warnings are added to the end. |
@@ -70,7 +71,9 @@ swiftshader_shared_library("swiftshader_libEGL") { | ||
70 | 71 | } else if (is_win) { |
71 | 72 | ldflags = [ "/DEF:" + rebase_path("libGLESv2.def", root_build_dir) ] |
72 | 73 | } else if (is_linux) { |
73 | - sources += [ "../../Main/libX11.cpp" ] | |
74 | + if (use_x11) { | |
75 | + sources += [ "../../Main/libX11.cpp" ] | |
76 | + } | |
74 | 77 | ldflags = |
75 | 78 | [ "-Wl,--version-script=" + rebase_path("libEGL.lds", root_build_dir) ] |
76 | 79 | } |
@@ -30,7 +30,7 @@ | ||
30 | 30 | #include <sys/ioctl.h> |
31 | 31 | #include <linux/fb.h> |
32 | 32 | #include <fcntl.h> |
33 | -#elif defined(__linux__) | |
33 | +#elif defined(USE_X11) | |
34 | 34 | #include "Main/libX11.hpp" |
35 | 35 | #elif defined(__APPLE__) |
36 | 36 | #include "OSXUtils.hpp" |
@@ -66,7 +66,7 @@ Display *Display::get(EGLDisplay dpy) | ||
66 | 66 | |
67 | 67 | static void *nativeDisplay = nullptr; |
68 | 68 | |
69 | - #if defined(__linux__) && !defined(__ANDROID__) | |
69 | + #if defined(USE_X11) | |
70 | 70 | // Even if the application provides a native display handle, we open (and close) our own connection |
71 | 71 | if(!nativeDisplay && dpy != HEADLESS_DISPLAY && libX11 && libX11->XOpenDisplay) |
72 | 72 | { |
@@ -89,7 +89,7 @@ Display::~Display() | ||
89 | 89 | { |
90 | 90 | terminate(); |
91 | 91 | |
92 | - #if defined(__linux__) && !defined(__ANDROID__) | |
92 | + #if defined(USE_X11) | |
93 | 93 | if(nativeDisplay && libX11->XCloseDisplay) |
94 | 94 | { |
95 | 95 | libX11->XCloseDisplay((::Display*)nativeDisplay); |
@@ -677,7 +677,7 @@ bool Display::isValidWindow(EGLNativeWindowType window) | ||
677 | 677 | return false; |
678 | 678 | } |
679 | 679 | return true; |
680 | - #elif defined(__linux__) | |
680 | + #elif defined(USE_X11) | |
681 | 681 | if(nativeDisplay) |
682 | 682 | { |
683 | 683 | XWindowAttributes windowAttributes; |
@@ -686,6 +686,8 @@ bool Display::isValidWindow(EGLNativeWindowType window) | ||
686 | 686 | return status != 0; |
687 | 687 | } |
688 | 688 | return false; |
689 | + #elif defined(__linux__) | |
690 | + return false; // Non X11 linux is headless only | |
689 | 691 | #elif defined(__APPLE__) |
690 | 692 | return sw::OSX::IsValidWindow(window); |
691 | 693 | #elif defined(__Fuchsia__) |
@@ -843,7 +845,7 @@ sw::Format Display::getDisplayFormat() const | ||
843 | 845 | |
844 | 846 | // No framebuffer device found, or we're in user space |
845 | 847 | return sw::FORMAT_X8B8G8R8; |
846 | - #elif defined(__linux__) | |
848 | + #elif defined(USE_X11) | |
847 | 849 | if(nativeDisplay) |
848 | 850 | { |
849 | 851 | Screen *screen = libX11->XDefaultScreenOfDisplay((::Display*)nativeDisplay); |
@@ -861,6 +863,8 @@ sw::Format Display::getDisplayFormat() const | ||
861 | 863 | { |
862 | 864 | return sw::FORMAT_X8R8G8B8; |
863 | 865 | } |
866 | + #elif defined(__linux__) // Non X11 linux is headless only | |
867 | + return sw::FORMAT_A8B8G8R8; | |
864 | 868 | #elif defined(__APPLE__) |
865 | 869 | return sw::FORMAT_A8B8G8R8; |
866 | 870 | #elif defined(__Fuchsia__) |
@@ -26,7 +26,7 @@ | ||
26 | 26 | #include "common/debug.h" |
27 | 27 | #include "Main/FrameBuffer.hpp" |
28 | 28 | |
29 | -#if defined(__linux__) && !defined(__ANDROID__) | |
29 | +#if defined(USE_X11) | |
30 | 30 | #include "Main/libX11.hpp" |
31 | 31 | #elif defined(_WIN32) |
32 | 32 | #include <tchar.h> |
@@ -341,7 +341,7 @@ bool WindowSurface::checkForResize() | ||
341 | 341 | #elif defined(__ANDROID__) |
342 | 342 | int windowWidth; window->query(window, NATIVE_WINDOW_WIDTH, &windowWidth); |
343 | 343 | int windowHeight; window->query(window, NATIVE_WINDOW_HEIGHT, &windowHeight); |
344 | - #elif defined(__linux__) | |
344 | + #elif defined(USE_X11) | |
345 | 345 | XWindowAttributes windowAttributes; |
346 | 346 | Status status = libX11->XGetWindowAttributes((::Display*)display->getNativeDisplay(), window, &windowAttributes); |
347 | 347 |
@@ -352,6 +352,10 @@ bool WindowSurface::checkForResize() | ||
352 | 352 | |
353 | 353 | int windowWidth = windowAttributes.width; |
354 | 354 | int windowHeight = windowAttributes.height; |
355 | + #elif defined(__linux__) | |
356 | + // Non X11 linux is headless only | |
357 | + int windowWidth = 100; | |
358 | + int windowHeight = 100; | |
355 | 359 | #elif defined(__APPLE__) |
356 | 360 | int windowWidth; |
357 | 361 | int windowHeight; |
@@ -25,7 +25,7 @@ | ||
25 | 25 | |
26 | 26 | #if defined(__ANDROID__) |
27 | 27 | #include <system/window.h> |
28 | -#elif defined(__linux__) | |
28 | +#elif defined(USE_X11) | |
29 | 29 | #include "Main/libX11.hpp" |
30 | 30 | #endif |
31 | 31 |
@@ -120,7 +120,9 @@ EGLDisplay GetDisplay(EGLNativeDisplayType display_id) | ||
120 | 120 | } |
121 | 121 | |
122 | 122 | #if defined(__linux__) && !defined(__ANDROID__) |
123 | + #if defined(USE_X11) | |
123 | 124 | if(!libX11) |
125 | + #endif // Non X11 linux is headless only | |
124 | 126 | { |
125 | 127 | return success(HEADLESS_DISPLAY); |
126 | 128 | } |
@@ -178,6 +180,8 @@ const char *QueryString(EGLDisplay dpy, EGLint name) | ||
178 | 180 | "EGL_KHR_client_get_all_proc_addresses " |
179 | 181 | #if defined(__linux__) && !defined(__ANDROID__) |
180 | 182 | "EGL_KHR_platform_gbm " |
183 | +#endif | |
184 | +#if defined(USE_X11) | |
181 | 185 | "EGL_KHR_platform_x11 " |
182 | 186 | #endif |
183 | 187 | "EGL_EXT_client_extensions " |
@@ -1002,7 +1006,7 @@ EGLBoolean WaitNative(EGLint engine) | ||
1002 | 1006 | |
1003 | 1007 | if(context) |
1004 | 1008 | { |
1005 | - #if defined(__linux__) && !defined(__ANDROID__) | |
1009 | + #if defined(USE_X11) | |
1006 | 1010 | egl::Display *display = context->getDisplay(); |
1007 | 1011 | |
1008 | 1012 | if(!display) |
@@ -1171,33 +1175,37 @@ EGLDisplay GetPlatformDisplayEXT(EGLenum platform, void *native_display, const E | ||
1171 | 1175 | #if defined(__linux__) && !defined(__ANDROID__) |
1172 | 1176 | switch(platform) |
1173 | 1177 | { |
1178 | + #if defined(USE_X11) | |
1174 | 1179 | case EGL_PLATFORM_X11_EXT: break; |
1180 | + #endif | |
1175 | 1181 | case EGL_PLATFORM_GBM_KHR: break; |
1176 | 1182 | default: |
1177 | 1183 | return error(EGL_BAD_PARAMETER, EGL_NO_DISPLAY); |
1178 | 1184 | } |
1179 | 1185 | |
1180 | - if(platform == EGL_PLATFORM_X11_EXT) | |
1186 | + if(platform == EGL_PLATFORM_GBM_KHR) | |
1181 | 1187 | { |
1182 | - if(!libX11) | |
1183 | - { | |
1184 | - return error(EGL_BAD_ATTRIBUTE, EGL_NO_DISPLAY); | |
1185 | - } | |
1186 | - | |
1187 | 1188 | if(native_display != (void*)EGL_DEFAULT_DISPLAY || attrib_list != NULL) |
1188 | 1189 | { |
1189 | 1190 | return error(EGL_BAD_ATTRIBUTE, EGL_NO_DISPLAY); // Unimplemented |
1190 | 1191 | } |
1192 | + | |
1193 | + return success(HEADLESS_DISPLAY); | |
1191 | 1194 | } |
1192 | - else if(platform == EGL_PLATFORM_GBM_KHR) | |
1195 | + #if defined(USE_X11) | |
1196 | + else if(platform == EGL_PLATFORM_X11_EXT) | |
1193 | 1197 | { |
1198 | + if(!libX11) | |
1199 | + { | |
1200 | + return error(EGL_BAD_ATTRIBUTE, EGL_NO_DISPLAY); | |
1201 | + } | |
1202 | + | |
1194 | 1203 | if(native_display != (void*)EGL_DEFAULT_DISPLAY || attrib_list != NULL) |
1195 | 1204 | { |
1196 | 1205 | return error(EGL_BAD_ATTRIBUTE, EGL_NO_DISPLAY); // Unimplemented |
1197 | 1206 | } |
1198 | - | |
1199 | - return success(HEADLESS_DISPLAY); | |
1200 | 1207 | } |
1208 | + #endif | |
1201 | 1209 | |
1202 | 1210 | return success(PRIMARY_DISPLAY); // We only support the default display |
1203 | 1211 | #else |