aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbohu <bohu@google.com>2017-08-29 12:29:02 -0700
committerbohu <bohu@google.com>2017-08-31 12:23:25 -0700
commit9b2d1c3cee91b7ce39e22c47b58843037ebb78fc (patch)
tree975005f099a556599975f099829c48d916bd6082
parent8ca67b0ba92a87a89c39f3587e9d49529ababb7c (diff)
downloadgoldfish-opengl-9b2d1c3cee91b7ce39e22c47b58843037ebb78fc.tar.gz
goldfish-opengl: update to 4153dd9ab6a14android-o-mr1-preview-2android-o-mr1-preview-1
commit 4153dd9ab6a14a263e97c40faeab237b66c9f67b Author: bohu <bohu@google.com> Date: Tue Aug 1 17:05:26 2017 -0700 get emulator iamge on oc-mr1-dev work with treble Need to remove libui dependency otherwise, libEGL wont load because it is looking for it; but it does not seem to need it BUG: 64401460 Change-Id: I81a77c85307524c2b075d430a84c73556f64524e Merged-In: I6b435afce04164308767daef3586358b04021cbd
-rw-r--r--Android.mk5
-rw-r--r--common.mk8
-rwxr-xr-xsystem/GLESv2_enc/GL2Encoder.cpp179
-rw-r--r--system/GLESv2_enc/GL2Encoder.h29
-rw-r--r--system/OpenglSystemCommon/Android.mk12
-rw-r--r--system/OpenglSystemCommon/EGLImage.h5
-rw-r--r--system/OpenglSystemCommon/goldfishHwc2.cpp22
-rw-r--r--system/OpenglSystemCommon/goldfishHwc2.h25
-rw-r--r--system/egl/Android.mk12
-rw-r--r--system/egl/egl.cpp45
-rw-r--r--system/egl/eglDisplay.cpp17
-rw-r--r--system/egl/goldfish_sync.h4
-rw-r--r--system/gralloc/gralloc.cpp60
-rw-r--r--system/surfaceInterface/Android.mk17
-rw-r--r--system/surfaceInterface/surfaceInterface.cpp36
-rw-r--r--system/surfaceInterface/surfaceInterface.h25
16 files changed, 324 insertions, 177 deletions
diff --git a/Android.mk b/Android.mk
index 3ab6a6c6..ae2ae523 100644
--- a/Android.mk
+++ b/Android.mk
@@ -32,6 +32,10 @@ ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 25 && echo isApi26OrHigher),isApi
EMUGL_COMMON_CFLAGS += -DGOLDFISH_HIDL_GRALLOC
endif
+ifdef IS_AT_LEAST_PPD1
+ EMUGL_COMMON_CFLAGS += -DEMULATOR_OPENGL_POST_O=1
+endif
+
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 18 && echo PreJellyBeanMr2),PreJellyBeanMr2)
ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true)
EMUGL_COMMON_CFLAGS += -DHAVE_ARM_TLS_REGISTER
@@ -81,7 +85,6 @@ include $(EMUGL_PATH)/system/GLESv1/Android.mk
include $(EMUGL_PATH)/system/GLESv2/Android.mk
include $(EMUGL_PATH)/system/gralloc/Android.mk
-include $(EMUGL_PATH)/system/surfaceInterface/Android.mk
include $(EMUGL_PATH)/system/egl/Android.mk
endif # BUILD_EMULATOR_OPENGL == true
diff --git a/common.mk b/common.mk
index 67e92846..2583a13f 100644
--- a/common.mk
+++ b/common.mk
@@ -38,6 +38,10 @@ emugl-begin-module = \
$(eval _EMUGL_INCLUDE_TYPE := $(BUILD_$2)) \
$(call _emugl-init-module,$1,$2,$3)
+ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26 && echo TREBLE),TREBLE)
+ emugl-begin-module += $(eval LOCAL_VENDOR_MODULE := true)
+endif
+
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23 && echo PreMarshmallow),PreMarshmallow)
emugl-begin-module += $(eval include external/stlport/libstlport.mk)
endif
@@ -102,6 +106,10 @@ EMUGL_EXPORT_TYPES := \
STATIC_LIBRARIES \
ADDITIONAL_DEPENDENCIES
+ifdef IS_AT_LEAST_PPD1
+EMUGL_EXPORT_TYPES += HEADER_LIBRARIES
+endif
+
# Initialize a module in our database
# $1: Module name
# $2: Module type
diff --git a/system/GLESv2_enc/GL2Encoder.cpp b/system/GLESv2_enc/GL2Encoder.cpp
index 66b9e192..39e4cdaf 100755
--- a/system/GLESv2_enc/GL2Encoder.cpp
+++ b/system/GLESv2_enc/GL2Encoder.cpp
@@ -285,6 +285,8 @@ GL2Encoder::GL2Encoder(IOStream *stream, ChecksumCalculator *protocol)
OVERRIDE(glGetIntegeri_v);
OVERRIDE(glGetInteger64i_v);
+ OVERRIDE(glGetInteger64v);
+ OVERRIDE(glGetBooleani_v);
OVERRIDE(glGetShaderiv);
@@ -356,12 +358,112 @@ GLenum GL2Encoder::s_glGetError(void * self)
GL2Encoder *ctx = (GL2Encoder *)self;
GLenum err = ctx->getError();
if(err != GL_NO_ERROR) {
+ ctx->m_glGetError_enc(ctx); // also clear host error
ctx->setError(GL_NO_ERROR);
return err;
}
return ctx->m_glGetError_enc(self);
+}
+
+class GL2Encoder::ErrorUpdater {
+public:
+ ErrorUpdater(GL2Encoder* ctx) :
+ mCtx(ctx),
+ guest_error(ctx->getError()),
+ host_error(ctx->m_glGetError_enc(ctx)) {
+ // Preserve any existing GL error in the guest:
+ // OpenGL ES 3.0.5 spec:
+ // The command enum GetError( void ); is used to obtain error information.
+ // Each detectable error is assigned a numeric code. When an error is
+ // detected, a flag is set and the code is recorded. Further errors, if
+ // they occur, do not affect this recorded code. When GetError is called,
+ // the code is returned and the flag is cleared, so that a further error
+ // will again record its code. If a call to GetError returns NO_ERROR, then
+ // there has been no detectable error since the last call to GetError (or
+ // since the GL was initialized).
+ if (guest_error == GL_NO_ERROR) {
+ guest_error = host_error;
+ }
+ }
+
+ GLenum getHostErrorAndUpdate() {
+ host_error = mCtx->m_glGetError_enc(mCtx);
+ if (guest_error == GL_NO_ERROR) {
+ guest_error = host_error;
+ }
+ return host_error;
+ }
+
+ void updateGuestErrorState() {
+ mCtx->setError(guest_error);
+ }
+
+private:
+ GL2Encoder* mCtx;
+ GLenum guest_error;
+ GLenum host_error;
+};
+
+template<class T>
+class GL2Encoder::ScopedQueryUpdate {
+public:
+ ScopedQueryUpdate(GL2Encoder* ctx, uint32_t bytes, T* target) :
+ mCtx(ctx),
+ mBuf(bytes, 0),
+ mTarget(target),
+ mErrorUpdater(ctx) {
+ }
+ T* hostStagingBuffer() {
+ return (T*)&mBuf[0];
+ }
+ ~ScopedQueryUpdate() {
+ GLint hostError = mErrorUpdater.getHostErrorAndUpdate();
+ if (hostError == GL_NO_ERROR) {
+ memcpy(mTarget, &mBuf[0], mBuf.size());
+ }
+ mErrorUpdater.updateGuestErrorState();
+ }
+private:
+ GL2Encoder* mCtx;
+ std::vector<char> mBuf;
+ T* mTarget;
+ ErrorUpdater mErrorUpdater;
+};
+
+void GL2Encoder::safe_glGetBooleanv(GLenum param, GLboolean* val) {
+ ScopedQueryUpdate<GLboolean> query(this, glUtilsParamSize(param) * sizeof(GLboolean), val);
+ m_glGetBooleanv_enc(this, param, query.hostStagingBuffer());
+}
+
+void GL2Encoder::safe_glGetFloatv(GLenum param, GLfloat* val) {
+ ScopedQueryUpdate<GLfloat> query(this, glUtilsParamSize(param) * sizeof(GLfloat), val);
+ m_glGetFloatv_enc(this, param, query.hostStagingBuffer());
+}
+
+void GL2Encoder::safe_glGetIntegerv(GLenum param, GLint* val) {
+ ScopedQueryUpdate<GLint> query(this, glUtilsParamSize(param) * sizeof(GLint), val);
+ m_glGetIntegerv_enc(this, param, query.hostStagingBuffer());
+}
+void GL2Encoder::safe_glGetInteger64v(GLenum param, GLint64* val) {
+ ScopedQueryUpdate<GLint64> query(this, glUtilsParamSize(param) * sizeof(GLint64), val);
+ m_glGetInteger64v_enc(this, param, query.hostStagingBuffer());
+}
+
+void GL2Encoder::safe_glGetIntegeri_v(GLenum param, GLuint index, GLint* val) {
+ ScopedQueryUpdate<GLint> query(this, sizeof(GLint), val);
+ m_glGetIntegeri_v_enc(this, param, index, query.hostStagingBuffer());
+}
+
+void GL2Encoder::safe_glGetInteger64i_v(GLenum param, GLuint index, GLint64* val) {
+ ScopedQueryUpdate<GLint64> query(this, sizeof(GLint64), val);
+ m_glGetInteger64i_v_enc(this, param, index, query.hostStagingBuffer());
+}
+
+void GL2Encoder::safe_glGetBooleani_v(GLenum param, GLuint index, GLboolean* val) {
+ ScopedQueryUpdate<GLboolean> query(this, sizeof(GLboolean), val);
+ m_glGetBooleani_v_enc(this, param, index, query.hostStagingBuffer());
}
void GL2Encoder::s_glFlush(void *self)
@@ -553,7 +655,7 @@ void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr)
case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS:
case GL_MAX_TEXTURE_IMAGE_UNITS:
- ctx->m_glGetIntegerv_enc(self, param, ptr);
+ ctx->safe_glGetIntegerv(param, ptr);
*ptr = MIN(*ptr, GLClientState::MAX_TEXTURE_UNITS);
break;
@@ -566,7 +668,7 @@ void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr)
case GL_MAX_VERTEX_ATTRIBS:
if (!ctx->m_state->getClientStateParameter<GLint>(param, ptr)) {
- ctx->m_glGetIntegerv_enc(self, param, ptr);
+ ctx->safe_glGetIntegerv(param, ptr);
ctx->m_state->setMaxVertexAttribs(*ptr);
}
break;
@@ -574,7 +676,7 @@ void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr)
if (ctx->m_max_vertexAttribStride != 0) {
*ptr = ctx->m_max_vertexAttribStride;
} else {
- ctx->m_glGetIntegerv_enc(self, param, ptr);
+ ctx->safe_glGetIntegerv(param, ptr);
ctx->m_max_vertexAttribStride = *ptr;
}
break;
@@ -582,7 +684,7 @@ void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr)
if (ctx->m_max_cubeMapTextureSize != 0) {
*ptr = ctx->m_max_cubeMapTextureSize;
} else {
- ctx->m_glGetIntegerv_enc(self, param, ptr);
+ ctx->safe_glGetIntegerv(param, ptr);
ctx->m_max_cubeMapTextureSize = *ptr;
}
break;
@@ -590,7 +692,7 @@ void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr)
if (ctx->m_max_renderBufferSize != 0) {
*ptr = ctx->m_max_renderBufferSize;
} else {
- ctx->m_glGetIntegerv_enc(self, param, ptr);
+ ctx->safe_glGetIntegerv(param, ptr);
ctx->m_max_renderBufferSize = *ptr;
}
break;
@@ -598,7 +700,7 @@ void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr)
if (ctx->m_max_textureSize != 0) {
*ptr = ctx->m_max_textureSize;
} else {
- ctx->m_glGetIntegerv_enc(self, param, ptr);
+ ctx->safe_glGetIntegerv(param, ptr);
ctx->m_max_textureSize = *ptr;
}
break;
@@ -606,7 +708,7 @@ void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr)
if (ctx->m_max_3d_textureSize != 0) {
*ptr = ctx->m_max_3d_textureSize;
} else {
- ctx->m_glGetIntegerv_enc(self, param, ptr);
+ ctx->safe_glGetIntegerv(param, ptr);
ctx->m_max_3d_textureSize = *ptr;
}
break;
@@ -614,7 +716,7 @@ void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr)
if (ctx->m_ssbo_offset_align != 0) {
*ptr = ctx->m_ssbo_offset_align;
} else {
- ctx->m_glGetIntegerv_enc(self, param, ptr);
+ ctx->safe_glGetIntegerv(param, ptr);
ctx->m_ssbo_offset_align = *ptr;
}
break;
@@ -622,7 +724,7 @@ void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr)
if (ctx->m_ubo_offset_align != 0) {
*ptr = ctx->m_ubo_offset_align;
} else {
- ctx->m_glGetIntegerv_enc(self, param, ptr);
+ ctx->safe_glGetIntegerv(param, ptr);
ctx->m_ubo_offset_align = *ptr;
}
break;
@@ -634,9 +736,31 @@ void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr)
case GL_MAX_DEPTH_TEXTURE_SAMPLES:
*ptr = 4;
break;
+ // Checks for version-incompatible enums.
+ // Not allowed in vanilla ES 2.0.
+ case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS:
+ case GL_MAX_UNIFORM_BUFFER_BINDINGS:
+ SET_ERROR_IF(ctx->majorVersion() < 3, GL_INVALID_ENUM);
+ ctx->safe_glGetIntegerv(param, ptr);
+ break;
+ case GL_MAX_COLOR_ATTACHMENTS:
+ case GL_MAX_DRAW_BUFFERS:
+ SET_ERROR_IF(ctx->majorVersion() < 3 &&
+ !ctx->hasExtension("GL_EXT_draw_buffers"), GL_INVALID_ENUM);
+ ctx->safe_glGetIntegerv(param, ptr);
+ break;
+ // Not allowed in ES 3.0.
+ case GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS:
+ case GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS:
+ case GL_MAX_VERTEX_ATTRIB_BINDINGS:
+ SET_ERROR_IF(ctx->majorVersion() < 3 ||
+ (ctx->majorVersion() == 3 &&
+ ctx->minorVersion() == 0), GL_INVALID_ENUM);
+ ctx->safe_glGetIntegerv(param, ptr);
+ break;
default:
if (!ctx->m_state->getClientStateParameter<GLint>(param, ptr)) {
- ctx->m_glGetIntegerv_enc(self, param, ptr);
+ ctx->safe_glGetIntegerv(param, ptr);
}
break;
}
@@ -671,7 +795,7 @@ void GL2Encoder::s_glGetFloatv(void *self, GLenum param, GLfloat *ptr)
case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS:
case GL_MAX_TEXTURE_IMAGE_UNITS:
- ctx->m_glGetFloatv_enc(self, param, ptr);
+ ctx->safe_glGetFloatv(param, ptr);
*ptr = MIN(*ptr, (GLfloat)GLClientState::MAX_TEXTURE_UNITS);
break;
@@ -684,7 +808,7 @@ void GL2Encoder::s_glGetFloatv(void *self, GLenum param, GLfloat *ptr)
default:
if (!ctx->m_state->getClientStateParameter<GLfloat>(param, ptr)) {
- ctx->m_glGetFloatv_enc(self, param, ptr);
+ ctx->safe_glGetFloatv(param, ptr);
}
break;
}
@@ -726,7 +850,7 @@ void GL2Encoder::s_glGetBooleanv(void *self, GLenum param, GLboolean *ptr)
default:
if (!ctx->m_state->getClientStateParameter<GLboolean>(param, ptr)) {
- ctx->m_glGetBooleanv_enc(self, param, ptr);
+ ctx->safe_glGetBooleanv(param, ptr);
}
*ptr = (*ptr != 0) ? GL_TRUE : GL_FALSE;
break;
@@ -1313,7 +1437,7 @@ void GL2Encoder::s_glLinkProgram(void * self, GLuint program)
ctx->m_glLinkProgram_enc(self, program);
GLint linkStatus = 0;
- ctx->glGetProgramiv(self,program,GL_LINK_STATUS,&linkStatus);
+ ctx->glGetProgramiv(self, program, GL_LINK_STATUS, &linkStatus);
if (!linkStatus) {
return;
}
@@ -2095,9 +2219,16 @@ void GL2Encoder::override2DTextureTarget(GLenum target)
void GL2Encoder::restore2DTextureTarget(GLenum target)
{
if (texture2DNeedsOverride(target)) {
- m_glBindTexture_enc(this, GL_TEXTURE_2D,
+ GLuint priorityEnabledBoundTexture =
m_state->getBoundTexture(
- m_state->getPriorityEnabledTarget(GL_TEXTURE_2D)));
+ m_state->getPriorityEnabledTarget(GL_TEXTURE_2D));
+ GLuint texture2DBoundTexture =
+ m_state->getBoundTexture(GL_TEXTURE_2D);
+ if (!priorityEnabledBoundTexture) {
+ m_glBindTexture_enc(this, GL_TEXTURE_2D, texture2DBoundTexture);
+ } else {
+ m_glBindTexture_enc(this, GL_TEXTURE_2D, priorityEnabledBoundTexture);
+ }
}
}
@@ -4133,7 +4264,7 @@ void GL2Encoder::s_glGetIntegeri_v(void* self, GLenum target, GLuint index, GLin
break;
}
- ctx->m_glGetIntegeri_v_enc(self, target, index, params);
+ ctx->safe_glGetIntegeri_v(target, index, params);
}
void GL2Encoder::s_glGetInteger64i_v(void* self, GLenum target, GLuint index, GLint64* params) {
@@ -4182,7 +4313,17 @@ void GL2Encoder::s_glGetInteger64i_v(void* self, GLenum target, GLuint index, GL
break;
}
- ctx->m_glGetInteger64i_v_enc(self, target, index, params);
+ ctx->safe_glGetInteger64i_v(target, index, params);
+}
+
+void GL2Encoder::s_glGetInteger64v(void* self, GLenum param, GLint64* val) {
+ GL2Encoder *ctx = (GL2Encoder *)self;
+ ctx->safe_glGetInteger64v(param, val);
+}
+
+void GL2Encoder::s_glGetBooleani_v(void* self, GLenum param, GLuint index, GLboolean* val) {
+ GL2Encoder *ctx = (GL2Encoder *)self;
+ ctx->safe_glGetBooleani_v(param, index, val);
}
void GL2Encoder::s_glGetShaderiv(void* self, GLuint shader, GLenum pname, GLint* params) {
@@ -4253,7 +4394,7 @@ GLuint GL2Encoder::s_glCreateShaderProgramv(void* self, GLenum type, GLsizei cou
ctx->m_shared->associateGLShaderProgram(res, spDataId);
GLint numUniforms = 0;
- ctx->glGetProgramiv(ctx, res, GL_ACTIVE_UNIFORMS, &numUniforms);
+ ctx->glGetProgramiv(self, res, GL_ACTIVE_UNIFORMS, &numUniforms);
ctx->m_shared->initShaderProgramData(res, numUniforms);
GLint maxLength=0;
diff --git a/system/GLESv2_enc/GL2Encoder.h b/system/GLESv2_enc/GL2Encoder.h
index 11162ee6..3084713e 100644
--- a/system/GLESv2_enc/GL2Encoder.h
+++ b/system/GLESv2_enc/GL2Encoder.h
@@ -30,6 +30,13 @@ public:
void setClientState(GLClientState *state) {
m_state = state;
}
+ void setVersion(int major, int minor,
+ int deviceMajor, int deviceMinor) {
+ m_currMajorVersion = major;
+ m_currMinorVersion = minor;
+ m_deviceMajorVersion = deviceMajor;
+ m_deviceMinorVersion = deviceMinor;
+ }
void setClientStateMakeCurrent(GLClientState *state,
int majorVersion,
int minorVersion,
@@ -128,6 +135,21 @@ private:
bool isCompleteFbo(GLenum target, const GLClientState* state, GLenum attachment) const;
bool checkFramebufferCompleteness(GLenum target, const GLClientState* state) const;
+ // Utility classes for safe queries that
+ // need access to private class members
+ class ErrorUpdater;
+ template<class T> class ScopedQueryUpdate;
+
+ // General queries
+ void safe_glGetBooleanv(GLenum param, GLboolean *val);
+ void safe_glGetFloatv(GLenum param, GLfloat *val);
+ void safe_glGetIntegerv(GLenum param, GLint *val);
+ void safe_glGetInteger64v(GLenum param, GLint64 *val);
+ void safe_glGetIntegeri_v(GLenum param, GLuint index, GLint *val);
+ void safe_glGetInteger64i_v(GLenum param, GLuint index, GLint64 *val);
+ void safe_glGetBooleani_v(GLenum param, GLuint index, GLboolean *val);
+
+ // API implementation
glGetError_client_proc_t m_glGetError_enc;
static GLenum s_glGetError(void * self);
@@ -161,7 +183,6 @@ private:
glDrawElements_client_proc_t m_glDrawElements_enc;
static void s_glDrawElements(void *self, GLenum mode, GLsizei count, GLenum type, const void *indices);
-
glGetIntegerv_client_proc_t m_glGetIntegerv_enc;
static void s_glGetIntegerv(void *self, GLenum pname, GLint *ptr);
@@ -171,6 +192,12 @@ private:
glGetBooleanv_client_proc_t m_glGetBooleanv_enc;
static void s_glGetBooleanv(void *self, GLenum pname, GLboolean *ptr);
+ glGetInteger64v_client_proc_t m_glGetInteger64v_enc;
+ static void s_glGetInteger64v(void* self, GLenum param, GLint64* val);
+
+ glGetBooleani_v_client_proc_t m_glGetBooleani_v_enc;
+ static void s_glGetBooleani_v(void* self, GLenum param, GLuint index, GLboolean* val);
+
glVertexAttribPointer_client_proc_t m_glVertexAttribPointer_enc;
static void s_glVertexAttribPointer(void *self, GLuint indx, GLint size, GLenum type,
GLboolean normalized, GLsizei stride, const GLvoid * ptr);
diff --git a/system/OpenglSystemCommon/Android.mk b/system/OpenglSystemCommon/Android.mk
index b585971d..45b37a25 100644
--- a/system/OpenglSystemCommon/Android.mk
+++ b/system/OpenglSystemCommon/Android.mk
@@ -5,13 +5,23 @@ $(call emugl-import,libGLESv1_enc libGLESv2_enc lib_renderControl_enc)
LOCAL_SRC_FILES := \
goldfish_dma.cpp \
- goldfishHwc2.cpp \
FormatConversions.cpp \
HostConnection.cpp \
ProcessPipe.cpp \
QemuPipeStream.cpp \
ThreadInfo.cpp
+ifdef IS_AT_LEAST_PPD1
+LOCAL_HEADER_LIBRARIES += libnativebase_headers
+
+$(call emugl-export,HEADER_LIBRARIES,libnativebase_headers)
+endif
+
+ifdef IS_AT_LEAST_PPD1
+LOCAL_HEADER_LIBRARIES += libhardware_headers
+$(call emugl-export,HEADER_LIBRARIES,libhardware_headers)
+endif
+
$(call emugl-export,C_INCLUDES,$(LOCAL_PATH) bionic/libc/private)
$(call emugl-end-module)
diff --git a/system/OpenglSystemCommon/EGLImage.h b/system/OpenglSystemCommon/EGLImage.h
index 9f8f9014..6cb74318 100644
--- a/system/OpenglSystemCommon/EGLImage.h
+++ b/system/OpenglSystemCommon/EGLImage.h
@@ -21,7 +21,10 @@
#include <GLES/gl.h>
#if PLATFORM_SDK_VERSION >= 16
-#include <system/window.h>
+#if EMULATOR_OPENGL_POST_O >= 1
+#include <nativebase/nativebase.h>
+#endif
+#include <cutils/native_handle.h>
#else // PLATFORM_SDK_VERSION >= 16
#include <private/ui/android_natives_priv.h>
#endif // PLATFORM_SDK_VERSION >= 16
diff --git a/system/OpenglSystemCommon/goldfishHwc2.cpp b/system/OpenglSystemCommon/goldfishHwc2.cpp
deleted file mode 100644
index 888ba896..00000000
--- a/system/OpenglSystemCommon/goldfishHwc2.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-* Copyright (C) 2017 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.
-*/
-#include "goldfishHwc2.h"
-
-// Stub functions if not using HWC2.
-#ifndef USE_HWC2
-extern "C" void surfaceInterface_init() { }
-extern "C" void surfaceInterface_setAsyncModeForWindow(void* window) { }
-#endif
diff --git a/system/OpenglSystemCommon/goldfishHwc2.h b/system/OpenglSystemCommon/goldfishHwc2.h
deleted file mode 100644
index cb1a3969..00000000
--- a/system/OpenglSystemCommon/goldfishHwc2.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-* Copyright (C) 2017 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.
-*/
-#pragma once
-
-// Set of functions that help support HWC2 in the emulator.
-
-#ifdef USE_HWC2
-#include "../surfaceInterface/surfaceInterface.h"
-#else
-extern "C" void surfaceInterface_init();
-extern "C" void surfaceInterface_setAsyncModeForWindow(void* window);
-#endif
diff --git a/system/egl/Android.mk b/system/egl/Android.mk
index 37aadd75..bafc310f 100644
--- a/system/egl/Android.mk
+++ b/system/egl/Android.mk
@@ -13,12 +13,16 @@ LOCAL_SRC_FILES := \
egl.cpp \
ClientAPIExts.cpp
-ifeq ($(TARGET_USES_HWC2), true)
- LOCAL_CFLAGS += -DUSE_HWC2
- LOCAL_STATIC_LIBRARIES += libsurfaceInterface
+ifdef IS_AT_LEAST_PPD1
+LOCAL_SHARED_LIBRARIES += libdl libnativewindow
+else
+LOCAL_SHARED_LIBRARIES += libdl
+endif
+
+ifdef IS_AT_LEAST_PPD1
+LOCAL_HEADER_LIBRARIES += libnativebase_headers
endif
-LOCAL_SHARED_LIBRARIES += libdl
# Used to access the Bionic private OpenGL TLS slot
LOCAL_C_INCLUDES += bionic/libc/private
diff --git a/system/egl/egl.cpp b/system/egl/egl.cpp
index b22e1162..185fbc94 100644
--- a/system/egl/egl.cpp
+++ b/system/egl/egl.cpp
@@ -29,7 +29,6 @@
#include "eglContext.h"
#include "ClientAPIExts.h"
#include "EGLImage.h"
-#include "goldfishHwc2.h"
#include "ProcessPipe.h"
#include "GLEncoder.h"
@@ -39,6 +38,10 @@
#include <GLES3/gl31.h>
+#if PLATFORM_SDK_VERSION < 18
+#define override
+#endif
+
#if PLATFORM_SDK_VERSION >= 16
#include <system/window.h>
#else // PLATFORM_SDK_VERSION >= 16
@@ -171,6 +174,11 @@ const char * eglStrError(EGLint err)
// The one and only supported display object.
static eglDisplay s_display;
+// Extra defines not in the official EGL spec yet,
+// but required in Android CTS.
+
+#define EGL_TIMESTAMPS_ANDROID 0x314D
+
EGLContext_t::EGLContext_t(EGLDisplay dpy, EGLConfig config, EGLContext_t* shareCtx, int maj, int min) :
dpy(dpy),
config(config),
@@ -181,7 +189,7 @@ EGLContext_t::EGLContext_t(EGLDisplay dpy, EGLConfig config, EGLContext_t* share
versionString(NULL),
majorVersion(maj),
minorVersion(min),
- vendorString(NULL),
+ vendorString(NULL) ,
rendererString(NULL),
shaderVersionString(NULL),
extensionString(NULL),
@@ -272,6 +280,9 @@ struct egl_surface_t {
void setTextureTarget(EGLint _texTarget) { texTarget = _texTarget; }
EGLint getTextureTarget() { return texTarget; }
+ virtual void setCollectingTimestamps(EGLint collect) { }
+ virtual EGLint isCollectingTimestamps() const { return EGL_FALSE; }
+
private:
//
//Surface attributes
@@ -333,6 +344,11 @@ struct egl_window_surface_t : public egl_surface_t {
virtual void setSwapInterval(int interval);
virtual EGLBoolean swapBuffers();
+ virtual void setCollectingTimestamps(EGLint collect)
+ override { collectingTimestamps = (collect == EGL_TRUE) ? true : false; }
+ virtual EGLint isCollectingTimestamps() const override { return collectingTimestamps ? EGL_TRUE : EGL_FALSE; }
+
+
private:
egl_window_surface_t(
EGLDisplay dpy, EGLConfig config, EGLint surfType,
@@ -341,6 +357,7 @@ private:
ANativeWindow* nativeWindow;
android_native_buffer_t* buffer;
+ bool collectingTimestamps;
};
egl_window_surface_t::egl_window_surface_t (
@@ -348,7 +365,8 @@ egl_window_surface_t::egl_window_surface_t (
ANativeWindow* window)
: egl_surface_t(dpy, config, surfType),
nativeWindow(window),
- buffer(NULL)
+ buffer(NULL),
+ collectingTimestamps(false)
{
// keep a reference on the window
nativeWindow->common.incRef(&nativeWindow->common);
@@ -380,8 +398,6 @@ EGLBoolean egl_window_surface_t::init()
rcEnc->rcSetWindowColorBuffer(rcEnc, rcSurface,
((cb_handle_t*)(buffer->handle))->hostHandle);
- surfaceInterface_setAsyncModeForWindow((void*)nativeWindow);
-
return EGL_TRUE;
}
@@ -1097,6 +1113,9 @@ EGLBoolean eglQuerySurface(EGLDisplay dpy, EGLSurface eglSurface, EGLint attribu
// ignored when creating the surface, return default
*value = EGL_VG_ALPHA_FORMAT_NONPRE;
break;
+ case EGL_TIMESTAMPS_ANDROID:
+ *value = surface->isCollectingTimestamps();
+ break;
//TODO: complete other attributes
default:
ALOGE("eglQuerySurface %x EGL_BAD_ATTRIBUTE", attribute);
@@ -1189,7 +1208,6 @@ EGLBoolean eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute
switch (attribute) {
case EGL_MIPMAP_LEVEL:
return true;
- break;
case EGL_MULTISAMPLE_RESOLVE:
{
if (value == EGL_MULTISAMPLE_RESOLVE_BOX) {
@@ -1200,7 +1218,6 @@ EGLBoolean eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute
}
}
return true;
- break;
}
case EGL_SWAP_BEHAVIOR:
if (value == EGL_BUFFER_PRESERVED) {
@@ -1211,7 +1228,10 @@ EGLBoolean eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute
}
}
return true;
- break;
+ case EGL_TIMESTAMPS_ANDROID:
+ ALOGD("%s: set frame timestamps collecting %d\n", __func__, value);
+ p_surface->setCollectingTimestamps(value);
+ return true;
default:
ALOGW("%s: attr=0x%x not implemented", __FUNCTION__, attribute);
setErrorReturn(EGL_BAD_ATTRIBUTE, EGL_FALSE);
@@ -1541,6 +1561,13 @@ EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLC
ClientAPIExts::initClientFuncs(s_display.gles2_iface(), 1);
}
if (contextState->needsInitFromCaps()) {
+ // Need to set the version first if
+ // querying caps, or validation will trip incorrectly.
+ hostCon->gl2Encoder()->setVersion(
+ context->majorVersion,
+ context->minorVersion,
+ context->deviceMajorVersion,
+ context->deviceMinorVersion);
// Get caps for indexed buffers from host.
// Some need a current context.
int max_transform_feedback_separate_attribs = 0;
@@ -1578,7 +1605,7 @@ EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLC
max_draw_buffers);
}
- // set the client state and share group
+ // update the client state, share group, and version
if (context->majorVersion > 1) {
hostCon->gl2Encoder()->setClientStateMakeCurrent(
contextState,
diff --git a/system/egl/eglDisplay.cpp b/system/egl/eglDisplay.cpp
index 890eb509..c7ff1791 100644
--- a/system/egl/eglDisplay.cpp
+++ b/system/egl/eglDisplay.cpp
@@ -15,8 +15,6 @@
*/
#include "eglDisplay.h"
#include "HostConnection.h"
-#include "goldfishHwc2.h"
-
#include <dlfcn.h>
#include <string>
@@ -72,7 +70,6 @@ eglDisplay::eglDisplay() :
pthread_mutex_init(&m_lock, NULL);
pthread_mutex_init(&m_ctxLock, NULL);
pthread_mutex_init(&m_surfaceLock, NULL);
- surfaceInterface_init();
}
eglDisplay::~eglDisplay()
@@ -83,6 +80,12 @@ eglDisplay::~eglDisplay()
pthread_mutex_destroy(&m_surfaceLock);
}
+#if PLATFORM_SDK_VERSION >= 26
+#define PARTITION "/vendor"
+#else
+#define PARTITION "/system"
+#endif
+
bool eglDisplay::initialize(EGLClient_eglInterface *eglIface)
{
pthread_mutex_lock(&m_lock);
@@ -92,11 +95,11 @@ bool eglDisplay::initialize(EGLClient_eglInterface *eglIface)
// load GLES client API
//
#if __LP64__
- m_gles_iface = loadGLESClientAPI("/system/lib64/egl/libGLESv1_CM_emulation.so",
+ m_gles_iface = loadGLESClientAPI(PARTITION "/lib64/egl/libGLESv1_CM_emulation.so",
eglIface,
&s_gles_lib);
#else
- m_gles_iface = loadGLESClientAPI("/system/lib/egl/libGLESv1_CM_emulation.so",
+ m_gles_iface = loadGLESClientAPI(PARTITION "/lib/egl/libGLESv1_CM_emulation.so",
eglIface,
&s_gles_lib);
#endif
@@ -108,11 +111,11 @@ bool eglDisplay::initialize(EGLClient_eglInterface *eglIface)
#ifdef WITH_GLES2
#if __LP64__
- m_gles2_iface = loadGLESClientAPI("/system/lib64/egl/libGLESv2_emulation.so",
+ m_gles2_iface = loadGLESClientAPI(PARTITION "/lib64/egl/libGLESv2_emulation.so",
eglIface,
&s_gles2_lib);
#else
- m_gles2_iface = loadGLESClientAPI("/system/lib/egl/libGLESv2_emulation.so",
+ m_gles2_iface = loadGLESClientAPI(PARTITION "/lib/egl/libGLESv2_emulation.so",
eglIface,
&s_gles2_lib);
#endif
diff --git a/system/egl/goldfish_sync.h b/system/egl/goldfish_sync.h
index 4667a776..6b30fe5b 100644
--- a/system/egl/goldfish_sync.h
+++ b/system/egl/goldfish_sync.h
@@ -18,6 +18,10 @@
#include <linux/ioctl.h>
#include <linux/types.h>
#include <sys/cdefs.h>
+#ifdef EMULATOR_OPENGL_POST_O
+#include <sys/ioctl.h>
+#include <sys/unistd.h>
+#endif
#include <fcntl.h>
// Make it conflict with ioctls that are not likely to be used
diff --git a/system/gralloc/gralloc.cpp b/system/gralloc/gralloc.cpp
index 429f3026..7c51667d 100644
--- a/system/gralloc/gralloc.cpp
+++ b/system/gralloc/gralloc.cpp
@@ -27,6 +27,7 @@
#include "HostConnection.h"
#include "ProcessPipe.h"
#include "glUtils.h"
+#include <utils/CallStack.h>
#include <cutils/log.h>
#include <cutils/properties.h>
@@ -390,6 +391,15 @@ static void updateHostColorBuffer(cb_handle_t* cb,
if (convertedBuf) delete [] convertedBuf;
}
+#ifndef GL_RGBA16F
+#define GL_RGBA16F 0x881A
+#endif // GL_RGBA16F
+#ifndef GL_UNSIGNED_INT_10_10_10_2
+#define GL_UNSIGNED_INT_10_10_10_2 0x8DF6
+#endif // GL_UNSIGNED_INT_10_10_10_2
+#ifndef GL_HALF_FLOAT
+#define GL_HALF_FLOAT 0x140B
+#endif // GL_HALF_FLOAT
//
// gralloc device functions (alloc interface)
//
@@ -489,6 +499,18 @@ static int gralloc_alloc(alloc_device_t* dev,
glFormat = GL_RGB;
glType = GL_UNSIGNED_SHORT_5_6_5;
break;
+#if PLATFORM_SDK_VERSION >= 26
+ case HAL_PIXEL_FORMAT_RGBA_FP16:
+ bpp = 8;
+ glFormat = GL_RGBA16F;
+ glType = GL_HALF_FLOAT;
+ break;
+ case HAL_PIXEL_FORMAT_RGBA_1010102:
+ bpp = 4;
+ glFormat = GL_RGBA;
+ glType = GL_UNSIGNED_INT_10_10_10_2;
+ break;
+#endif // PLATFORM_SDK_VERSION >= 26
#if PLATFORM_SDK_VERSION >= 21
case HAL_PIXEL_FORMAT_RAW16:
case HAL_PIXEL_FORMAT_Y16:
@@ -508,8 +530,10 @@ static int gralloc_alloc(alloc_device_t* dev,
#if PLATFORM_SDK_VERSION >= 17
case HAL_PIXEL_FORMAT_BLOB:
bpp = 1;
- if (! (sw_read && hw_cam_write) ) {
+ if (! (sw_read) ) {
// Blob data cannot be used by HW other than camera emulator
+ // But there is a CTS test trying to have access to it
+ // BUG: https://buganizer.corp.google.com/issues/37719518
return -EINVAL;
}
// Not expecting to actually create any GL surfaces for this
@@ -581,7 +605,11 @@ static int gralloc_alloc(alloc_device_t* dev,
}
}
- if (sw_read || sw_write || hw_cam_write || hw_vid_enc_read) {
+ // API26 always expect at least one file descriptor is associated with
+ // one color buffer
+ // BUG: 37719038
+ if (PLATFORM_SDK_VERSION >= 26 ||
+ sw_read || sw_write || hw_cam_write || hw_vid_enc_read) {
// keep space for image on guest memory if SW access is needed
// or if the camera is doing writing
if (yuv_format) {
@@ -1458,6 +1486,15 @@ struct private_module_t HAL_MODULE_INFO_SYM = {
*
* If not, then load gralloc.default instead as a fallback.
*/
+
+#if __LP64__
+static const char kGrallocDefaultSystemPath[] = "/system/lib64/hw/gralloc.default.so";
+static const char kGrallocDefaultVendorPath[] = "/vendor/lib64/hw/gralloc.default.so";
+#else
+static const char kGrallocDefaultSystemPath[] = "/system/lib/hw/gralloc.default.so";
+static const char kGrallocDefaultVendorPath[] = "/vendor/lib/hw/gralloc.default.so";
+#endif
+
static void
fallback_init(void)
{
@@ -1471,12 +1508,17 @@ fallback_init(void)
if (atoi(prop) == 1) {
return;
}
- ALOGD("Emulator without host-side GPU emulation detected.");
-#if __LP64__
- module = dlopen("/vendor/lib64/hw/gralloc.default.so", RTLD_LAZY|RTLD_LOCAL);
-#else
- module = dlopen("/vendor/lib/hw/gralloc.default.so", RTLD_LAZY|RTLD_LOCAL);
-#endif
+ ALOGD("Emulator without host-side GPU emulation detected. "
+ "Loading gralloc.default.so from %s...",
+ kGrallocDefaultVendorPath);
+ module = dlopen(kGrallocDefaultVendorPath, RTLD_LAZY | RTLD_LOCAL);
+ if (!module) {
+ // vendor folder didn't work. try system
+ ALOGD("gralloc.default.so not found in /vendor. Trying %s...",
+ kGrallocDefaultSystemPath);
+ module = dlopen(kGrallocDefaultSystemPath, RTLD_LAZY | RTLD_LOCAL);
+ }
+
if (module != NULL) {
sFallback = reinterpret_cast<gralloc_module_t*>(dlsym(module, HAL_MODULE_INFO_SYM_AS_STR));
if (sFallback == NULL) {
@@ -1484,6 +1526,6 @@ fallback_init(void)
}
}
if (sFallback == NULL) {
- ALOGE("Could not find software fallback module!?");
+ ALOGE("FATAL: Could not find gralloc.default.so!");
}
}
diff --git a/system/surfaceInterface/Android.mk b/system/surfaceInterface/Android.mk
deleted file mode 100644
index db62d414..00000000
--- a/system/surfaceInterface/Android.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-ifneq (false,$(BUILD_EMULATOR_OPENGL_DRIVER))
-
-ifeq ($(TARGET_USES_HWC2), true)
-
-LOCAL_PATH := $(call my-dir)
-
-$(call emugl-begin-static-library,libsurfaceInterface)
-$(call emugl-import,libOpenglSystemCommon)
-
-LOCAL_SRC_FILES := surfaceInterface.cpp
-LOCAL_SHARED_LIBRARIES := libgui
-
-$(call emugl-end-module)
-
-endif
-
-endif # BUILD_EMULATOR_OPENGL_DRIVER != false
diff --git a/system/surfaceInterface/surfaceInterface.cpp b/system/surfaceInterface/surfaceInterface.cpp
deleted file mode 100644
index 68f9110c..00000000
--- a/system/surfaceInterface/surfaceInterface.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-#include "surfaceInterface.h"
-
-#include <cutils/log.h>
-#include <gui/Surface.h>
-
-class SurfaceInterface : public android::ANativeObjectBase<
- ANativeWindow,
- android::Surface,
- android::RefBase> {
-public:
- static SurfaceInterface* get();
- void setAsyncMode(ANativeWindow* anw, bool async) {
- ALOGD("SurfaceInterface::%s: set async mode %d", __func__, async);
- window = anw;
- android::Surface* s = android::Surface::getSelf(window);
- s->setAsyncMode(async);
- window = NULL;
- }
- ANativeWindow* window;
-};
-
-static SurfaceInterface* sSurfaceInterface = NULL;
-
-SurfaceInterface* SurfaceInterface::get() {
- if (!sSurfaceInterface)
- sSurfaceInterface = new SurfaceInterface;
- return sSurfaceInterface;
-}
-
-extern "C" void surfaceInterface_init() {
- SurfaceInterface::get();
-}
-
-extern "C" void surfaceInterface_setAsyncModeForWindow(void* window) {
- SurfaceInterface::get()->setAsyncMode((ANativeWindow*)window, true);
-}
diff --git a/system/surfaceInterface/surfaceInterface.h b/system/surfaceInterface/surfaceInterface.h
deleted file mode 100644
index 6890847e..00000000
--- a/system/surfaceInterface/surfaceInterface.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-* Copyright (C) 2017 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.
-*/
-#pragma once
-
-#if PLATFORM_SDK_VERSION >= 16
-#include <system/window.h>
-#else // PLATFORM_SDK_VERSION >= 16
-#include <private/ui/android_natives_priv.h>
-#endif // PLATFORM_SDK_VERSION >= 16
-
-extern "C" void surfaceInterface_init();
-extern "C" void surfaceInterface_setAsyncModeForWindow(void* window);