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>
set_cpp_flag("-march=x86-64")
set_cpp_flag("-mtune=generic")
endif()
+ if(LINUX)
+ set_cpp_flag("-DUSE_X11=1")
+ endif()
# Use -g3 to have even more debug info
set_cpp_flag("-g -g3" DEBUG)
# See the License for the specific language governing permissions and
# limitations under the License.
-import("//ui/ozone/ozone.gni")
+import("//build/config/ui.gni")
import("../swiftshader.gni")
# Need a separate config to ensure the warnings are added to the end.
if (use_ozone && !is_win) {
sources += [ "FrameBufferOzone.cpp" ]
} else if (is_linux) {
- sources += [
- "FrameBufferX11.cpp",
- "libX11.cpp",
- ]
+ if (use_x11) {
+ sources += [
+ "FrameBufferX11.cpp",
+ "libX11.cpp",
+ ]
+ }
} else if (is_mac) {
sources += [ "FrameBufferOSX.mm" ]
} else if (is_win) {
# See the License for the specific language governing permissions and
# limitations under the License.
+import("//build/config/ui.gni")
import("../../swiftshader.gni")
# Need a separate config to ensure the warnings are added to the end.
} else if (is_win) {
ldflags = [ "/DEF:" + rebase_path("libGLESv2.def", root_build_dir) ]
} else if (is_linux) {
- sources += [ "../../Main/libX11.cpp" ]
+ if (use_x11) {
+ sources += [ "../../Main/libX11.cpp" ]
+ }
ldflags =
[ "-Wl,--version-script=" + rebase_path("libEGL.lds", root_build_dir) ]
}
#include <sys/ioctl.h>
#include <linux/fb.h>
#include <fcntl.h>
-#elif defined(__linux__)
+#elif defined(USE_X11)
#include "Main/libX11.hpp"
#elif defined(__APPLE__)
#include "OSXUtils.hpp"
static void *nativeDisplay = nullptr;
- #if defined(__linux__) && !defined(__ANDROID__)
+ #if defined(USE_X11)
// Even if the application provides a native display handle, we open (and close) our own connection
if(!nativeDisplay && dpy != HEADLESS_DISPLAY && libX11 && libX11->XOpenDisplay)
{
{
terminate();
- #if defined(__linux__) && !defined(__ANDROID__)
+ #if defined(USE_X11)
if(nativeDisplay && libX11->XCloseDisplay)
{
libX11->XCloseDisplay((::Display*)nativeDisplay);
return false;
}
return true;
- #elif defined(__linux__)
+ #elif defined(USE_X11)
if(nativeDisplay)
{
XWindowAttributes windowAttributes;
return status != 0;
}
return false;
+ #elif defined(__linux__)
+ return false; // Non X11 linux is headless only
#elif defined(__APPLE__)
return sw::OSX::IsValidWindow(window);
#elif defined(__Fuchsia__)
// No framebuffer device found, or we're in user space
return sw::FORMAT_X8B8G8R8;
- #elif defined(__linux__)
+ #elif defined(USE_X11)
if(nativeDisplay)
{
Screen *screen = libX11->XDefaultScreenOfDisplay((::Display*)nativeDisplay);
{
return sw::FORMAT_X8R8G8B8;
}
+ #elif defined(__linux__) // Non X11 linux is headless only
+ return sw::FORMAT_A8B8G8R8;
#elif defined(__APPLE__)
return sw::FORMAT_A8B8G8R8;
#elif defined(__Fuchsia__)
#include "common/debug.h"
#include "Main/FrameBuffer.hpp"
-#if defined(__linux__) && !defined(__ANDROID__)
+#if defined(USE_X11)
#include "Main/libX11.hpp"
#elif defined(_WIN32)
#include <tchar.h>
#elif defined(__ANDROID__)
int windowWidth; window->query(window, NATIVE_WINDOW_WIDTH, &windowWidth);
int windowHeight; window->query(window, NATIVE_WINDOW_HEIGHT, &windowHeight);
- #elif defined(__linux__)
+ #elif defined(USE_X11)
XWindowAttributes windowAttributes;
Status status = libX11->XGetWindowAttributes((::Display*)display->getNativeDisplay(), window, &windowAttributes);
int windowWidth = windowAttributes.width;
int windowHeight = windowAttributes.height;
+ #elif defined(__linux__)
+ // Non X11 linux is headless only
+ int windowWidth = 100;
+ int windowHeight = 100;
#elif defined(__APPLE__)
int windowWidth;
int windowHeight;
#if defined(__ANDROID__)
#include <system/window.h>
-#elif defined(__linux__)
+#elif defined(USE_X11)
#include "Main/libX11.hpp"
#endif
}
#if defined(__linux__) && !defined(__ANDROID__)
+ #if defined(USE_X11)
if(!libX11)
+ #endif // Non X11 linux is headless only
{
return success(HEADLESS_DISPLAY);
}
"EGL_KHR_client_get_all_proc_addresses "
#if defined(__linux__) && !defined(__ANDROID__)
"EGL_KHR_platform_gbm "
+#endif
+#if defined(USE_X11)
"EGL_KHR_platform_x11 "
#endif
"EGL_EXT_client_extensions "
if(context)
{
- #if defined(__linux__) && !defined(__ANDROID__)
+ #if defined(USE_X11)
egl::Display *display = context->getDisplay();
if(!display)
#if defined(__linux__) && !defined(__ANDROID__)
switch(platform)
{
+ #if defined(USE_X11)
case EGL_PLATFORM_X11_EXT: break;
+ #endif
case EGL_PLATFORM_GBM_KHR: break;
default:
return error(EGL_BAD_PARAMETER, EGL_NO_DISPLAY);
}
- if(platform == EGL_PLATFORM_X11_EXT)
+ if(platform == EGL_PLATFORM_GBM_KHR)
{
- if(!libX11)
- {
- return error(EGL_BAD_ATTRIBUTE, EGL_NO_DISPLAY);
- }
-
if(native_display != (void*)EGL_DEFAULT_DISPLAY || attrib_list != NULL)
{
return error(EGL_BAD_ATTRIBUTE, EGL_NO_DISPLAY); // Unimplemented
}
+
+ return success(HEADLESS_DISPLAY);
}
- else if(platform == EGL_PLATFORM_GBM_KHR)
+ #if defined(USE_X11)
+ else if(platform == EGL_PLATFORM_X11_EXT)
{
+ if(!libX11)
+ {
+ return error(EGL_BAD_ATTRIBUTE, EGL_NO_DISPLAY);
+ }
+
if(native_display != (void*)EGL_DEFAULT_DISPLAY || attrib_list != NULL)
{
return error(EGL_BAD_ATTRIBUTE, EGL_NO_DISPLAY); // Unimplemented
}
-
- return success(HEADLESS_DISPLAY);
}
+ #endif
return success(PRIMARY_DISPLAY); // We only support the default display
#else