Commit 27654c25 by Corentin Wallez Committed by Nicolas Capens

Make SwiftShader compile on Mac (with unimplemented functions)

Change-Id: Iaef054314fb27632513397412ca9dc22b67a70ce Reviewed-on: https://swiftshader-review.googlesource.com/4380Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent dd0d3389
...@@ -74,7 +74,7 @@ macro(set_target_export_map TARGET DIR) ...@@ -74,7 +74,7 @@ macro(set_target_export_map TARGET DIR)
endif() endif()
if(MSVC) if(MSVC)
set_target_properties(${TARGET} PROPERTIES LINK_FLAGS "/DEF:\"${DIR}/${TARGET}.def\"") set_target_properties(${TARGET} PROPERTIES LINK_FLAGS "/DEF:\"${DIR}/${TARGET}.def\"")
else() elseif(LINUX)
# Both hash-style are needed, because we want both gold and # Both hash-style are needed, because we want both gold and
# GNU ld to be able to read our libraries (maybe?). # GNU ld to be able to read our libraries (maybe?).
# The version script only exports the API functions and # The version script only exports the API functions and
...@@ -354,6 +354,14 @@ elseif(LINUX) ...@@ -354,6 +354,14 @@ elseif(LINUX)
list(APPEND OPENGL_COMPILER_LIST list(APPEND OPENGL_COMPILER_LIST
${OPENGL_COMPILER_DIR}/ossource_posix.cpp ${OPENGL_COMPILER_DIR}/ossource_posix.cpp
) )
elseif(APPLE)
list(APPEND SWIFTSHADER_LIST
${SOURCE_DIR}/Main/FrameBufferOSX.mm
${SOURCE_DIR}/Main/FrameBufferOSX.hpp
)
list(APPEND OPENGL_COMPILER_LIST
${OPENGL_COMPILER_DIR}/ossource_posix.cpp
)
endif() endif()
if(WIN32) if(WIN32)
......
...@@ -119,8 +119,6 @@ namespace sw ...@@ -119,8 +119,6 @@ namespace sw
{ {
#if defined(_WIN32) #if defined(_WIN32)
Sleep(milliseconds); Sleep(milliseconds);
#elif defined(__APPLE__)
nap(milliseconds);
#else #else
usleep(1000 * milliseconds); usleep(1000 * milliseconds);
#endif #endif
......
#ifndef sw_FrameBufferOSX_hpp
#define sw_FrameBufferOSX_hpp
#include "Main/FrameBuffer.hpp"
@class CALayer;
namespace sw
{
class FrameBufferOSX : public FrameBuffer
{
public:
FrameBufferOSX(CALayer *window, int width, int height) : FrameBuffer(width, height, false, false) {};
~FrameBufferOSX() override {};
void flip(void *source, Format sourceFormat, size_t sourceStride) override;
void blit(void *source, const Rect *sourceRect, const Rect *destRect, Format sourceFormat, size_t sourceStride) override {};
void *lock() override {return nullptr;};
void unlock() override {};
};
}
#endif // sw_FrameBufferOSX
#include "FrameBufferOSX.hpp"
namespace sw
{
void FrameBufferOSX::flip(void *source, Format sourceFormat, size_t sourceStride)
{
blit(source, 0, 0, sourceFormat, sourceStride);
}
}
sw::FrameBuffer *createFrameBuffer(void *display, CALayer *layer, int width, int height)
{
return new sw::FrameBufferOSX(layer, width, height);
}
...@@ -544,7 +544,7 @@ bool Display::isValidWindow(EGLNativeWindowType window) ...@@ -544,7 +544,7 @@ bool Display::isValidWindow(EGLNativeWindowType window)
return false; return false;
} }
return true; return true;
#else #elif defined(__linux__)
if(platform == EGL_PLATFORM_X11_EXT) if(platform == EGL_PLATFORM_X11_EXT)
{ {
XWindowAttributes windowAttributes; XWindowAttributes windowAttributes;
...@@ -552,6 +552,10 @@ bool Display::isValidWindow(EGLNativeWindowType window) ...@@ -552,6 +552,10 @@ bool Display::isValidWindow(EGLNativeWindowType window)
return status == True; return status == True;
} }
#elif defined(__APPLE__)
return true;
#else
#error "Display::isValidWindow unimplemented for this platform"
#endif #endif
return false; return false;
...@@ -664,7 +668,7 @@ sw::Format Display::getDisplayFormat() const ...@@ -664,7 +668,7 @@ sw::Format Display::getDisplayFormat() const
// No framebuffer device found, or we're in user space // No framebuffer device found, or we're in user space
return sw::FORMAT_X8B8G8R8; return sw::FORMAT_X8B8G8R8;
#else #elif defined(__linux__)
if(platform == EGL_PLATFORM_X11_EXT) if(platform == EGL_PLATFORM_X11_EXT)
{ {
Screen *screen = libX11->XDefaultScreenOfDisplay((::Display*)nativeDisplay); Screen *screen = libX11->XDefaultScreenOfDisplay((::Display*)nativeDisplay);
...@@ -683,6 +687,10 @@ sw::Format Display::getDisplayFormat() const ...@@ -683,6 +687,10 @@ sw::Format Display::getDisplayFormat() const
return sw::FORMAT_X8R8G8B8; return sw::FORMAT_X8R8G8B8;
} }
else UNREACHABLE(platform); else UNREACHABLE(platform);
#elif defined(__APPLE__)
return sw::FORMAT_X8R8G8B8;
#else
#error "Display::isValidWindow unimplemented for this platform"
#endif #endif
return sw::FORMAT_X8R8G8B8; return sw::FORMAT_X8R8G8B8;
......
...@@ -244,11 +244,15 @@ bool WindowSurface::initialize() ...@@ -244,11 +244,15 @@ bool WindowSurface::initialize()
int height; window->query(window, NATIVE_WINDOW_HEIGHT, &height); int height; window->query(window, NATIVE_WINDOW_HEIGHT, &height);
return reset(width, height); return reset(width, height);
#else #elif defined(__linux__)
XWindowAttributes windowAttributes; XWindowAttributes windowAttributes;
libX11->XGetWindowAttributes((::Display*)display->getNativeDisplay(), window, &windowAttributes); libX11->XGetWindowAttributes((::Display*)display->getNativeDisplay(), window, &windowAttributes);
return reset(windowAttributes.width, windowAttributes.height); return reset(windowAttributes.width, windowAttributes.height);
#elif defined(__APPLE__)
return true;
#else
#error "WindowSurface::initialize unimplemented for this platform"
#endif #endif
} }
...@@ -284,12 +288,18 @@ bool WindowSurface::checkForResize() ...@@ -284,12 +288,18 @@ bool WindowSurface::checkForResize()
#elif defined(__ANDROID__) #elif defined(__ANDROID__)
int clientWidth; window->query(window, NATIVE_WINDOW_WIDTH, &clientWidth); int clientWidth; window->query(window, NATIVE_WINDOW_WIDTH, &clientWidth);
int clientHeight; window->query(window, NATIVE_WINDOW_HEIGHT, &clientHeight); int clientHeight; window->query(window, NATIVE_WINDOW_HEIGHT, &clientHeight);
#else #elif defined(__linux__)
XWindowAttributes windowAttributes; XWindowAttributes windowAttributes;
libX11->XGetWindowAttributes((::Display*)display->getNativeDisplay(), window, &windowAttributes); libX11->XGetWindowAttributes((::Display*)display->getNativeDisplay(), window, &windowAttributes);
int clientWidth = windowAttributes.width; int clientWidth = windowAttributes.width;
int clientHeight = windowAttributes.height; int clientHeight = windowAttributes.height;
#elif defined(__APPLE__)
int clientWidth = 0;
int clientHeight = 0;
return true;
#else
#error "WindowSurface::checkForResize unimplemented for this platform"
#endif #endif
bool sizeDirty = (clientWidth != width) || (clientHeight != height); bool sizeDirty = (clientWidth != width) || (clientHeight != height);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment