OSDN Git Service

Fixes for JBMR0 compile (API 16)
authorGreg Hartman <ghartman@google.com>
Wed, 2 Dec 2015 04:07:21 +0000 (20:07 -0800)
committerNicolas Capens <capn@google.com>
Mon, 7 Dec 2015 15:09:16 +0000 (15:09 +0000)
Change-Id: Ibb2ebd66116f3dfd0008217153006bd6c7a49b9e
Reviewed-on: https://swiftshader-review.googlesource.com/4322
Reviewed-by: Greg Hartman <ghartman@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
src/Android.mk
src/LLVM/Android.mk
src/Main/FrameBufferAndroid.cpp
src/OpenGL/common/AndroidCommon.cpp
src/OpenGL/compiler/Android.mk
src/OpenGL/libEGL/Android.mk
src/OpenGL/libEGL/Surface.cpp
src/OpenGL/libGLES_CM/Android.mk
src/OpenGL/libGLESv2/Android.mk

index 58bfe1a..9a74930 100644 (file)
@@ -82,12 +82,28 @@ COMMON_SRC_FILES += \
        OpenGL/common/Object.cpp \
        OpenGL/common/MatrixStack.cpp \
 
-COMMON_CFLAGS := -DLOG_TAG=\"swiftshader\" -Wno-unused-parameter -Wno-implicit-exception-spec-mismatch -Wno-overloaded-virtual -fno-operator-names -msse2 -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -std=c++11 -Xclang -fuse-init-array
+COMMON_CFLAGS := \
+       -DLOG_TAG=\"swiftshader\" \
+       -Wno-unused-parameter \
+       -Wno-implicit-exception-spec-mismatch \
+       -Wno-overloaded-virtual \
+       -fno-operator-names \
+       -msse2 \
+       -D__STDC_CONSTANT_MACROS \
+       -D__STDC_LIMIT_MACROS \
+       -DANDROID_PLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION) \
+       -std=c++11
 
 ifneq ($(filter gce_x86 gce calypso, $(TARGET_DEVICE)),)
 COMMON_CFLAGS += -DDISPLAY_LOGO=0
 endif
 
+ifneq (16,${PLATFORM_SDK_VERSION})
+COMMON_CFLAGS += -Xclang -fuse-init-array
+else
+COMMON_CFLAGS += -D__STDC_INT64__
+endif
+
 include $(CLEAR_VARS)
 LOCAL_CLANG := true
 LOCAL_MODULE := swiftshader_top_release
index e573f11..8f2ec86 100644 (file)
@@ -399,8 +399,13 @@ LOCAL_SRC_FILES += \
 LOCAL_CFLAGS += -DLOG_TAG=\"libLLVM_swiftshader\" \
        -Wno-unused-parameter \
        -Wno-implicit-exception-spec-mismatch \
-       -Wno-overloaded-virtual \
-       -Xclang -fuse-init-array
+       -Wno-overloaded-virtual
+
+ifneq (16,${PLATFORM_SDK_VERSION})
+LOCAL_CFLAGS += -Xclang -fuse-init-array
+else
+LOCAL_CFLAGS += -D__STDC_INT64__
+endif
 
 LOCAL_CFLAGS += -fomit-frame-pointer -Os -ffunction-sections -fdata-sections
 LOCAL_CFLAGS += -fno-operator-names -msse2 -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS
index ff1148b..9d20ac6 100644 (file)
@@ -1,10 +1,36 @@
 #include "FrameBufferAndroid.hpp"
 
 #include <cutils/log.h>
-#include <ui/Fence.h>
 
 namespace sw
 {
+       inline int dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer)
+       {
+               #if ANDROID_PLATFORM_SDK_VERSION > 16
+                       return native_window_dequeue_buffer_and_wait(window, buffer);
+               #else
+                       return window->dequeueBuffer(window, buffer);
+               #endif
+       }
+
+       inline int queueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd)
+       {
+               #if ANDROID_PLATFORM_SDK_VERSION > 16
+                       return window->queueBuffer(window, buffer, fenceFd);
+               #else
+                       return window->queueBuffer(window, buffer);
+               #endif
+       }
+
+       inline int cancelBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd)
+       {
+               #if ANDROID_PLATFORM_SDK_VERSION > 16
+                       return window->cancelBuffer(window, buffer, fenceFd);
+               #else
+                       return window->cancelBuffer(window, buffer);
+               #endif
+       }
+
     FrameBufferAndroid::FrameBufferAndroid(ANativeWindow* window, int width, int height)
                        : FrameBuffer(width, height, false, false),
                          nativeWindow(window), buffer(0), gralloc(0)
@@ -22,7 +48,7 @@ namespace sw
         if (buffer)
         {
             // Probably doesn't have to cancel assuming a success queueing earlier
-            nativeWindow->cancelBuffer(nativeWindow, buffer, -1);
+            cancelBuffer(nativeWindow, buffer, -1);
             buffer = 0;
         }
         nativeWindow->common.decRef(&nativeWindow->common);
@@ -33,7 +59,7 @@ namespace sw
         copy(source, sourceFormat, sourceStride);
                if (buffer)
                {
-                       nativeWindow->queueBuffer(nativeWindow, buffer, -1);
+                       queueBuffer(nativeWindow, buffer, -1);
                        if (locked)
                        {
                                locked = 0;
@@ -45,16 +71,8 @@ namespace sw
 
     void* FrameBufferAndroid::lock()
     {
-        int fenceFd = -1;
-        if (nativeWindow->dequeueBuffer(nativeWindow, &buffer, &fenceFd) != android::NO_ERROR)
-        {
-            return NULL;
-        }
-
-        android::sp<android::Fence> fence(new android::Fence(fenceFd));
-        if (fence->wait(android::Fence::TIMEOUT_NEVER) != android::NO_ERROR)
+        if (dequeueBuffer(nativeWindow, &buffer) != 0)
         {
-            nativeWindow->cancelBuffer(nativeWindow, buffer, fenceFd);
             return NULL;
         }
 
@@ -63,8 +81,7 @@ namespace sw
         if (gralloc->lock(
                                gralloc, buffer->handle,
                                GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN,
-                               0, 0, buffer->width, buffer->height, &locked)
-                       != android::NO_ERROR)
+                               0, 0, buffer->width, buffer->height, &locked) != 0)
         {
             ALOGE("%s failed to lock buffer %p", __FUNCTION__, buffer);
             return NULL;
@@ -99,7 +116,7 @@ namespace sw
                        return;
                }
                locked = 0;
-        if (gralloc->unlock(gralloc, buffer->handle) != android::NO_ERROR)
+        if (gralloc->unlock(gralloc, buffer->handle) != 0)
                {
                        ALOGE("%s: badness unlock failed", __FUNCTION__);
                }
index 861cf91..0d11ce6 100644 (file)
@@ -26,8 +26,6 @@ GLenum GLPixelFormatFromAndroid(int halFormat)
                return GL_RGB565;
        case HAL_PIXEL_FORMAT_YV12:
                return SW_YV12_BT601;
-       case HAL_PIXEL_FORMAT_BLOB:
-       case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
        default:
                ALOGE("%s badness unsupported HAL format=%x", __FUNCTION__, halFormat);
        }
@@ -48,8 +46,6 @@ GLenum GLPixelTypeFromAndroid(int halFormat)
                return GL_UNSIGNED_SHORT_5_6_5;
        case HAL_PIXEL_FORMAT_YV12:
                return GL_UNSIGNED_BYTE;
-       case HAL_PIXEL_FORMAT_BLOB:
-       case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
        default:
                ALOGE("%s badness unsupported HAL format=%x", __FUNCTION__, halFormat);
        }
index 65bfb0b..612dcfe 100644 (file)
@@ -24,8 +24,13 @@ COMMON_CFLAGS := \
        -msse2 \
        -D__STDC_CONSTANT_MACROS \
        -D__STDC_LIMIT_MACROS \
-       -std=c++11 \
-       -Xclang -fuse-init-array
+       -std=c++11
+
+ifneq (16,${PLATFORM_SDK_VERSION})
+COMMON_CFLAGS += -Xclang -fuse-init-array
+else
+COMMON_CFLAGS += -D__STDC_INT64__
+endif
 
 COMMON_SRC_FILES := \
        preprocessor/Diagnostics.cpp \
index 73faaed..301b171 100644 (file)
@@ -7,8 +7,13 @@ COMMON_CFLAGS := \
        -DEGL_EGLEXT_PROTOTYPES \
        -Wno-unused-parameter \
        -Wno-implicit-exception-spec-mismatch \
-       -Wno-overloaded-virtual \
-       -Xclang -fuse-init-array
+       -Wno-overloaded-virtual
+
+ifneq (16,${PLATFORM_SDK_VERSION})
+COMMON_CFLAGS += -Xclang -fuse-init-array
+else
+COMMON_CFLAGS += -D__STDC_INT64__
+endif
 
 COMMON_SRC_FILES := \
        Config.cpp \
index c4dfeeb..3db1db2 100644 (file)
@@ -257,7 +257,7 @@ void WindowSurface::swap()
        if(backBuffer && frameBuffer)\r
     {\r
                void *source = backBuffer->lockInternal(0, 0, 0, sw::LOCK_READONLY, sw::PUBLIC);\r
-               frameBuffer->flip(source, backBuffer->Surface::getInternalFormat(), backBuffer->getInternalPitchB());\r
+               frameBuffer->flip(source, backBuffer->sw::Surface::getInternalFormat(), backBuffer->getInternalPitchB());\r
                backBuffer->unlockInternal();\r
 \r
         checkForResize();\r
index f005853..4183d36 100644 (file)
@@ -13,8 +13,13 @@ COMMON_CFLAGS := \
        -DGL_GLEXT_PROTOTYPES \
        -Wno-unused-parameter \
        -Wno-implicit-exception-spec-mismatch \
-       -Wno-overloaded-virtual \
-       -Xclang -fuse-init-array
+       -Wno-overloaded-virtual
+
+ifneq (16,${PLATFORM_SDK_VERSION})
+COMMON_CFLAGS += -Xclang -fuse-init-array
+else
+COMMON_CFLAGS += -D__STDC_INT64__
+endif
 
 
 COMMON_SRC_FILES := \
index 3f2cb1e..b538e74 100644 (file)
@@ -12,8 +12,13 @@ COMMON_CFLAGS := \
        -DGL_GLEXT_PROTOTYPES \
        -Wno-unused-parameter \
        -Wno-implicit-exception-spec-mismatch \
-       -Wno-overloaded-virtual \
-       -Xclang -fuse-init-array
+       -Wno-overloaded-virtual
+
+ifneq (16,${PLATFORM_SDK_VERSION})
+COMMON_CFLAGS += -Xclang -fuse-init-array
+else
+COMMON_CFLAGS += -D__STDC_INT64__
+endif
 
 COMMON_SRC_FILES := \
        Buffer.cpp \