summaryrefslogtreecommitdiffstats
path: root/opengl/libagl
diff options
context:
space:
mode:
Diffstat (limited to 'opengl/libagl')
-rw-r--r--opengl/libagl/Android.mk14
-rw-r--r--opengl/libagl/arch-mips/fixed_asm.S61
-rw-r--r--opengl/libagl/egl.cpp30
-rw-r--r--opengl/libagl/fp.cpp2
-rw-r--r--opengl/libagl/light.cpp7
-rw-r--r--opengl/libagl/matrix.h44
6 files changed, 139 insertions, 19 deletions
diff --git a/opengl/libagl/Android.mk b/opengl/libagl/Android.mk
index 15e58f2..9b8d3fe 100644
--- a/opengl/libagl/Android.mk
+++ b/opengl/libagl/Android.mk
@@ -26,7 +26,7 @@ LOCAL_CFLAGS += -DLOG_TAG=\"libagl\"
LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
LOCAL_CFLAGS += -fvisibility=hidden
-LOCAL_SHARED_LIBRARIES := libcutils libhardware libutils libpixelflinger libETC1
+LOCAL_SHARED_LIBRARIES := libcutils libhardware libutils libpixelflinger libETC1 libui
LOCAL_LDLIBS := -lpthread -ldl
ifeq ($(TARGET_ARCH),arm)
@@ -34,16 +34,14 @@ ifeq ($(TARGET_ARCH),arm)
LOCAL_CFLAGS += -fstrict-aliasing
endif
-ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true)
- LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER
+ifeq ($(TARGET_ARCH),mips)
+ LOCAL_SRC_FILES += arch-$(TARGET_ARCH)/fixed_asm.S
+ LOCAL_CFLAGS += -fstrict-aliasing
+ # The graphics code can generate division by zero
+ LOCAL_CFLAGS += -mno-check-zero-division
endif
# we need to access the private Bionic header <bionic_tls.h>
-# on ARM platforms, we need to mirror the ARCH_ARM_HAVE_TLS_REGISTER
-# behavior from the bionic Android.mk file
-ifeq ($(TARGET_ARCH)-$(ARCH_ARM_HAVE_TLS_REGISTER),arm-true)
- LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER
-endif
LOCAL_C_INCLUDES += bionic/libc/private
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/egl
diff --git a/opengl/libagl/arch-mips/fixed_asm.S b/opengl/libagl/arch-mips/fixed_asm.S
new file mode 100644
index 0000000..e1a53bc
--- /dev/null
+++ b/opengl/libagl/arch-mips/fixed_asm.S
@@ -0,0 +1,61 @@
+/* libs/opengles/arch-mips/fixed_asm.S
+**
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+
+ .text
+ .align
+
+/*
+ * this version rounds-to-nearest and saturates numbers
+ * outside the range (but not NaNs).
+ */
+
+ .global gglFloatToFixed
+ .ent gglFloatToFixed
+ .type gglFloatToFixed, @function
+gglFloatToFixed:
+#if !defined(__mips_soft_float)
+ mfc1 $a0,$f12
+#endif
+ srl $t0,$a0,31 /* t0 <- sign bit */
+ srl $t1,$a0,23
+ andi $t1,$t1,0xff /* get the e */
+ li $t2,0x8e
+ subu $t1,$t2,$t1 /* t1=127+15-e */
+ blez $t1,0f /* t1<=0? */
+ sll $t2,$a0,8 /* mantissa<<8 */
+ lui $t3,0x8000
+ or $t2,$t2,$t3 /* add the missing 1 */
+ subu $t1,$t1,1
+ srl $v0,$t2,$t1
+ sltiu $t3,$t1,32 /* t3=1 if t1<32, else t3=0. t1>=32 means the float value is too small. */
+ andi $t4,$v0,0x1
+ srl $v0,$v0,1 /* scale to 16.16 */
+ addu $v0,$v0,$t4 /* round-to-nearest */
+ subu $t2,$zero,$v0
+ movn $v0,$t2,$t0 /* if negative? */
+ or $t1,$a0,$zero /* a0=0? */
+ movz $v0,$zero,$t1
+ movz $v0,$zero,$t3 /* t3=0 then res=0 */
+ jr $ra
+0:
+ lui $t1,0x8000
+ and $v0,$a0,$t1 /* keep only the sign bit */
+ li $t1,0x7fffffff
+ movz $v0,$t1,$t0 /* positive, maximum value */
+ jr $ra
+ .end gglFloatToFixed
diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp
index c31aebf..172ef95 100644
--- a/opengl/libagl/egl.cpp
+++ b/opengl/libagl/egl.cpp
@@ -31,6 +31,7 @@
#include <utils/threads.h>
#include <ui/ANativeObjectBase.h>
+#include <ui/Fence.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
@@ -372,7 +373,16 @@ EGLBoolean egl_window_surface_v2_t::connect()
GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN);
// dequeue a buffer
- if (nativeWindow->dequeueBuffer(nativeWindow, &buffer) != NO_ERROR) {
+ int fenceFd = -1;
+ if (nativeWindow->dequeueBuffer(nativeWindow, &buffer,
+ &fenceFd) != NO_ERROR) {
+ return setError(EGL_BAD_ALLOC, EGL_FALSE);
+ }
+
+ // wait for the buffer
+ sp<Fence> fence(new Fence(fenceFd));
+ if (fence->wait(Fence::TIMEOUT_NEVER) != NO_ERROR) {
+ nativeWindow->cancelBuffer(nativeWindow, buffer, fenceFd);
return setError(EGL_BAD_ALLOC, EGL_FALSE);
}
@@ -392,8 +402,6 @@ EGLBoolean egl_window_surface_v2_t::connect()
// keep a reference on the buffer
buffer->common.incRef(&buffer->common);
- // Lock the buffer
- nativeWindow->lockBuffer(nativeWindow, buffer);
// pin the buffer down
if (lock(buffer, GRALLOC_USAGE_SW_READ_OFTEN |
GRALLOC_USAGE_SW_WRITE_OFTEN, &bits) != NO_ERROR) {
@@ -412,7 +420,7 @@ void egl_window_surface_v2_t::disconnect()
unlock(buffer);
}
// enqueue the last frame
- nativeWindow->queueBuffer(nativeWindow, buffer);
+ nativeWindow->queueBuffer(nativeWindow, buffer, -1);
if (buffer) {
buffer->common.decRef(&buffer->common);
buffer = 0;
@@ -517,15 +525,17 @@ EGLBoolean egl_window_surface_v2_t::swapBuffers()
unlock(buffer);
previousBuffer = buffer;
- nativeWindow->queueBuffer(nativeWindow, buffer);
+ nativeWindow->queueBuffer(nativeWindow, buffer, -1);
buffer = 0;
// dequeue a new buffer
- if (nativeWindow->dequeueBuffer(nativeWindow, &buffer) == NO_ERROR) {
-
- // TODO: lockBuffer should rather be executed when the very first
- // direct rendering occurs.
- nativeWindow->lockBuffer(nativeWindow, buffer);
+ int fenceFd = -1;
+ if (nativeWindow->dequeueBuffer(nativeWindow, &buffer, &fenceFd) == NO_ERROR) {
+ sp<Fence> fence(new Fence(fenceFd));
+ if (fence->wait(Fence::TIMEOUT_NEVER)) {
+ nativeWindow->cancelBuffer(nativeWindow, buffer, fenceFd);
+ return setError(EGL_BAD_ALLOC, EGL_FALSE);
+ }
// reallocate the depth-buffer if needed
if ((width != buffer->width) || (height != buffer->height)) {
diff --git a/opengl/libagl/fp.cpp b/opengl/libagl/fp.cpp
index ae5f1fe..aea4449 100644
--- a/opengl/libagl/fp.cpp
+++ b/opengl/libagl/fp.cpp
@@ -19,7 +19,7 @@
// ----------------------------------------------------------------------------
-#if !defined(__arm__)
+#if !defined(__arm__) && !defined(__mips__)
GGLfixed gglFloatToFixed(float v) {
return GGLfixed(floorf(v * 65536.0f + 0.5f));
}
diff --git a/opengl/libagl/light.cpp b/opengl/libagl/light.cpp
index ca715db..fafec3f 100644
--- a/opengl/libagl/light.cpp
+++ b/opengl/libagl/light.cpp
@@ -381,7 +381,14 @@ void lightVertex(ogles_context_t* c, vertex_t* v)
// compute vertex-to-light vector
if (ggl_unlikely(l.position.w)) {
// lightPos/1.0 - vertex/vertex.w == lightPos*vertex.w - vertex
+#if !OBJECT_SPACE_LIGHTING
+ vec4_t o;
+ const transform_t& mv = c->transforms.modelview.transform;
+ mv.point4(&mv, &o, &v->obj);
+ vss3(d.v, l.objPosition.v, o.w, o.v);
+#else
vss3(d.v, l.objPosition.v, v->obj.w, v->obj.v);
+#endif
sqDist = dot3(d.v, d.v);
vscale3(d.v, d.v, gglSqrtRecipx(sqDist));
} else {
diff --git a/opengl/libagl/matrix.h b/opengl/libagl/matrix.h
index c9a38a9..5bd717a 100644
--- a/opengl/libagl/matrix.h
+++ b/opengl/libagl/matrix.h
@@ -74,6 +74,30 @@ GLfixed vsquare3(GLfixed a, GLfixed b, GLfixed c)
);
return r;
+#elif defined(__mips__)
+
+ GLfixed res;
+ int32_t t1,t2,t3;
+ asm(
+ "mult %[a], %[a] \r\n"
+ "li %[res],0x8000 \r\n"
+ "madd %[b],%[b] \r\n"
+ "move %[t3],$zero \r\n"
+ "madd %[c],%[c] \r\n"
+ "mflo %[t1]\r\n"
+ "mfhi %[t2]\r\n"
+ "addu %[t1],%[res],%[t1]\r\n" /*add 0x8000*/
+ "sltu %[t3],%[t1],%[res]\r\n"
+ "addu %[t2],%[t2],%[t3]\r\n"
+ "srl %[res],%[t1],16\r\n"
+ "sll %[t2],%[t2],16\r\n"
+ "or %[res],%[res],%[t2]\r\n"
+ : [res]"=&r"(res),[t1]"=&r"(t1),[t2]"=&r"(t2),[t3]"=&r"(t3)
+ : [a] "r" (a),[b] "r" (b),[c] "r" (c)
+ : "%hi","%lo"
+ );
+ return res;
+
#else
return (( int64_t(a)*a +
@@ -136,6 +160,26 @@ static inline GLfixed mla3a( GLfixed a0, GLfixed b0,
);
return r;
+#elif defined(__mips__)
+
+ GLfixed res;
+ int32_t t1,t2;
+ asm(
+ "mult %[a0],%[b0] \r\n"
+ "madd %[a1],%[b1] \r\n"
+ "madd %[a2],%[b2] \r\n"
+ "mflo %[t2]\r\n"
+ "mfhi %[t1]\r\n"
+ "srl %[t2],%[t2],16\r\n"
+ "sll %[t1],%[t1],16\r\n"
+ "or %[t2],%[t2],%[t1]\r\n"
+ "addu %[res],%[t2],%[c]"
+ : [res]"=&r"(res),[t1]"=&r"(t1),[t2]"=&r"(t2)
+ : [a0] "r" (a0),[b0] "r" (b0),[a1] "r" (a1),[b1] "r" (b1),[a2] "r" (a2),[b2] "r" (b2),[c] "r" (c)
+ : "%hi","%lo"
+ );
+ return res;
+
#else
return (( int64_t(a0)*b0 +