Android-x86
Fork
Faire un don

  • R/O
  • HTTP
  • SSH
  • HTTPS

device-generic-goldfish-opengl: Commit

device/generic/goldfish-opengl


Commit MetaInfo

Révision02ffda0b2b93cdabaa11ab6d49199ef5987b9b8f (tree)
l'heure2017-09-21 12:40:58
Auteurbohu <bohu@goog...>
CommiterChih-Wei Huang

Message de Log

goldfish-opengl: update to 4153dd9ab6a14

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

Change Summary

Modification

--- a/Android.mk
+++ b/Android.mk
@@ -32,6 +32,10 @@ ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 25 && echo isApi26OrHigher),isApi
3232 EMUGL_COMMON_CFLAGS += -DGOLDFISH_HIDL_GRALLOC
3333 endif
3434
35+ifdef IS_AT_LEAST_PPD1
36+ EMUGL_COMMON_CFLAGS += -DEMULATOR_OPENGL_POST_O=1
37+endif
38+
3539 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 18 && echo PreJellyBeanMr2),PreJellyBeanMr2)
3640 ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true)
3741 EMUGL_COMMON_CFLAGS += -DHAVE_ARM_TLS_REGISTER
@@ -81,7 +85,6 @@ include $(EMUGL_PATH)/system/GLESv1/Android.mk
8185 include $(EMUGL_PATH)/system/GLESv2/Android.mk
8286
8387 include $(EMUGL_PATH)/system/gralloc/Android.mk
84-include $(EMUGL_PATH)/system/surfaceInterface/Android.mk
8588 include $(EMUGL_PATH)/system/egl/Android.mk
8689
8790 endif # BUILD_EMULATOR_OPENGL == true
--- a/common.mk
+++ b/common.mk
@@ -38,6 +38,10 @@ emugl-begin-module = \
3838 $(eval _EMUGL_INCLUDE_TYPE := $(BUILD_$2)) \
3939 $(call _emugl-init-module,$1,$2,$3)
4040
41+ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26 && echo TREBLE),TREBLE)
42+ emugl-begin-module += $(eval LOCAL_VENDOR_MODULE := true)
43+endif
44+
4145 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23 && echo PreMarshmallow),PreMarshmallow)
4246 emugl-begin-module += $(eval include external/stlport/libstlport.mk)
4347 endif
@@ -102,6 +106,10 @@ EMUGL_EXPORT_TYPES := \
102106 STATIC_LIBRARIES \
103107 ADDITIONAL_DEPENDENCIES
104108
109+ifdef IS_AT_LEAST_PPD1
110+EMUGL_EXPORT_TYPES += HEADER_LIBRARIES
111+endif
112+
105113 # Initialize a module in our database
106114 # $1: Module name
107115 # $2: Module type
--- a/system/GLESv2_enc/GL2Encoder.cpp
+++ b/system/GLESv2_enc/GL2Encoder.cpp
@@ -285,6 +285,8 @@ GL2Encoder::GL2Encoder(IOStream *stream, ChecksumCalculator *protocol)
285285
286286 OVERRIDE(glGetIntegeri_v);
287287 OVERRIDE(glGetInteger64i_v);
288+ OVERRIDE(glGetInteger64v);
289+ OVERRIDE(glGetBooleani_v);
288290
289291 OVERRIDE(glGetShaderiv);
290292
@@ -356,12 +358,112 @@ GLenum GL2Encoder::s_glGetError(void * self)
356358 GL2Encoder *ctx = (GL2Encoder *)self;
357359 GLenum err = ctx->getError();
358360 if(err != GL_NO_ERROR) {
361+ ctx->m_glGetError_enc(ctx); // also clear host error
359362 ctx->setError(GL_NO_ERROR);
360363 return err;
361364 }
362365
363366 return ctx->m_glGetError_enc(self);
367+}
368+
369+class GL2Encoder::ErrorUpdater {
370+public:
371+ ErrorUpdater(GL2Encoder* ctx) :
372+ mCtx(ctx),
373+ guest_error(ctx->getError()),
374+ host_error(ctx->m_glGetError_enc(ctx)) {
375+ // Preserve any existing GL error in the guest:
376+ // OpenGL ES 3.0.5 spec:
377+ // The command enum GetError( void ); is used to obtain error information.
378+ // Each detectable error is assigned a numeric code. When an error is
379+ // detected, a flag is set and the code is recorded. Further errors, if
380+ // they occur, do not affect this recorded code. When GetError is called,
381+ // the code is returned and the flag is cleared, so that a further error
382+ // will again record its code. If a call to GetError returns NO_ERROR, then
383+ // there has been no detectable error since the last call to GetError (or
384+ // since the GL was initialized).
385+ if (guest_error == GL_NO_ERROR) {
386+ guest_error = host_error;
387+ }
388+ }
389+
390+ GLenum getHostErrorAndUpdate() {
391+ host_error = mCtx->m_glGetError_enc(mCtx);
392+ if (guest_error == GL_NO_ERROR) {
393+ guest_error = host_error;
394+ }
395+ return host_error;
396+ }
397+
398+ void updateGuestErrorState() {
399+ mCtx->setError(guest_error);
400+ }
401+
402+private:
403+ GL2Encoder* mCtx;
404+ GLenum guest_error;
405+ GLenum host_error;
406+};
407+
408+template<class T>
409+class GL2Encoder::ScopedQueryUpdate {
410+public:
411+ ScopedQueryUpdate(GL2Encoder* ctx, uint32_t bytes, T* target) :
412+ mCtx(ctx),
413+ mBuf(bytes, 0),
414+ mTarget(target),
415+ mErrorUpdater(ctx) {
416+ }
417+ T* hostStagingBuffer() {
418+ return (T*)&mBuf[0];
419+ }
420+ ~ScopedQueryUpdate() {
421+ GLint hostError = mErrorUpdater.getHostErrorAndUpdate();
422+ if (hostError == GL_NO_ERROR) {
423+ memcpy(mTarget, &mBuf[0], mBuf.size());
424+ }
425+ mErrorUpdater.updateGuestErrorState();
426+ }
427+private:
428+ GL2Encoder* mCtx;
429+ std::vector<char> mBuf;
430+ T* mTarget;
431+ ErrorUpdater mErrorUpdater;
432+};
433+
434+void GL2Encoder::safe_glGetBooleanv(GLenum param, GLboolean* val) {
435+ ScopedQueryUpdate<GLboolean> query(this, glUtilsParamSize(param) * sizeof(GLboolean), val);
436+ m_glGetBooleanv_enc(this, param, query.hostStagingBuffer());
437+}
438+
439+void GL2Encoder::safe_glGetFloatv(GLenum param, GLfloat* val) {
440+ ScopedQueryUpdate<GLfloat> query(this, glUtilsParamSize(param) * sizeof(GLfloat), val);
441+ m_glGetFloatv_enc(this, param, query.hostStagingBuffer());
442+}
443+
444+void GL2Encoder::safe_glGetIntegerv(GLenum param, GLint* val) {
445+ ScopedQueryUpdate<GLint> query(this, glUtilsParamSize(param) * sizeof(GLint), val);
446+ m_glGetIntegerv_enc(this, param, query.hostStagingBuffer());
447+}
364448
449+void GL2Encoder::safe_glGetInteger64v(GLenum param, GLint64* val) {
450+ ScopedQueryUpdate<GLint64> query(this, glUtilsParamSize(param) * sizeof(GLint64), val);
451+ m_glGetInteger64v_enc(this, param, query.hostStagingBuffer());
452+}
453+
454+void GL2Encoder::safe_glGetIntegeri_v(GLenum param, GLuint index, GLint* val) {
455+ ScopedQueryUpdate<GLint> query(this, sizeof(GLint), val);
456+ m_glGetIntegeri_v_enc(this, param, index, query.hostStagingBuffer());
457+}
458+
459+void GL2Encoder::safe_glGetInteger64i_v(GLenum param, GLuint index, GLint64* val) {
460+ ScopedQueryUpdate<GLint64> query(this, sizeof(GLint64), val);
461+ m_glGetInteger64i_v_enc(this, param, index, query.hostStagingBuffer());
462+}
463+
464+void GL2Encoder::safe_glGetBooleani_v(GLenum param, GLuint index, GLboolean* val) {
465+ ScopedQueryUpdate<GLboolean> query(this, sizeof(GLboolean), val);
466+ m_glGetBooleani_v_enc(this, param, index, query.hostStagingBuffer());
365467 }
366468
367469 void GL2Encoder::s_glFlush(void *self)
@@ -553,7 +655,7 @@ void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr)
553655 case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
554656 case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS:
555657 case GL_MAX_TEXTURE_IMAGE_UNITS:
556- ctx->m_glGetIntegerv_enc(self, param, ptr);
658+ ctx->safe_glGetIntegerv(param, ptr);
557659 *ptr = MIN(*ptr, GLClientState::MAX_TEXTURE_UNITS);
558660 break;
559661
@@ -566,7 +668,7 @@ void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr)
566668
567669 case GL_MAX_VERTEX_ATTRIBS:
568670 if (!ctx->m_state->getClientStateParameter<GLint>(param, ptr)) {
569- ctx->m_glGetIntegerv_enc(self, param, ptr);
671+ ctx->safe_glGetIntegerv(param, ptr);
570672 ctx->m_state->setMaxVertexAttribs(*ptr);
571673 }
572674 break;
@@ -574,7 +676,7 @@ void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr)
574676 if (ctx->m_max_vertexAttribStride != 0) {
575677 *ptr = ctx->m_max_vertexAttribStride;
576678 } else {
577- ctx->m_glGetIntegerv_enc(self, param, ptr);
679+ ctx->safe_glGetIntegerv(param, ptr);
578680 ctx->m_max_vertexAttribStride = *ptr;
579681 }
580682 break;
@@ -582,7 +684,7 @@ void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr)
582684 if (ctx->m_max_cubeMapTextureSize != 0) {
583685 *ptr = ctx->m_max_cubeMapTextureSize;
584686 } else {
585- ctx->m_glGetIntegerv_enc(self, param, ptr);
687+ ctx->safe_glGetIntegerv(param, ptr);
586688 ctx->m_max_cubeMapTextureSize = *ptr;
587689 }
588690 break;
@@ -590,7 +692,7 @@ void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr)
590692 if (ctx->m_max_renderBufferSize != 0) {
591693 *ptr = ctx->m_max_renderBufferSize;
592694 } else {
593- ctx->m_glGetIntegerv_enc(self, param, ptr);
695+ ctx->safe_glGetIntegerv(param, ptr);
594696 ctx->m_max_renderBufferSize = *ptr;
595697 }
596698 break;
@@ -598,7 +700,7 @@ void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr)
598700 if (ctx->m_max_textureSize != 0) {
599701 *ptr = ctx->m_max_textureSize;
600702 } else {
601- ctx->m_glGetIntegerv_enc(self, param, ptr);
703+ ctx->safe_glGetIntegerv(param, ptr);
602704 ctx->m_max_textureSize = *ptr;
603705 }
604706 break;
@@ -606,7 +708,7 @@ void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr)
606708 if (ctx->m_max_3d_textureSize != 0) {
607709 *ptr = ctx->m_max_3d_textureSize;
608710 } else {
609- ctx->m_glGetIntegerv_enc(self, param, ptr);
711+ ctx->safe_glGetIntegerv(param, ptr);
610712 ctx->m_max_3d_textureSize = *ptr;
611713 }
612714 break;
@@ -614,7 +716,7 @@ void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr)
614716 if (ctx->m_ssbo_offset_align != 0) {
615717 *ptr = ctx->m_ssbo_offset_align;
616718 } else {
617- ctx->m_glGetIntegerv_enc(self, param, ptr);
719+ ctx->safe_glGetIntegerv(param, ptr);
618720 ctx->m_ssbo_offset_align = *ptr;
619721 }
620722 break;
@@ -622,7 +724,7 @@ void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr)
622724 if (ctx->m_ubo_offset_align != 0) {
623725 *ptr = ctx->m_ubo_offset_align;
624726 } else {
625- ctx->m_glGetIntegerv_enc(self, param, ptr);
727+ ctx->safe_glGetIntegerv(param, ptr);
626728 ctx->m_ubo_offset_align = *ptr;
627729 }
628730 break;
@@ -634,9 +736,31 @@ void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr)
634736 case GL_MAX_DEPTH_TEXTURE_SAMPLES:
635737 *ptr = 4;
636738 break;
739+ // Checks for version-incompatible enums.
740+ // Not allowed in vanilla ES 2.0.
741+ case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS:
742+ case GL_MAX_UNIFORM_BUFFER_BINDINGS:
743+ SET_ERROR_IF(ctx->majorVersion() < 3, GL_INVALID_ENUM);
744+ ctx->safe_glGetIntegerv(param, ptr);
745+ break;
746+ case GL_MAX_COLOR_ATTACHMENTS:
747+ case GL_MAX_DRAW_BUFFERS:
748+ SET_ERROR_IF(ctx->majorVersion() < 3 &&
749+ !ctx->hasExtension("GL_EXT_draw_buffers"), GL_INVALID_ENUM);
750+ ctx->safe_glGetIntegerv(param, ptr);
751+ break;
752+ // Not allowed in ES 3.0.
753+ case GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS:
754+ case GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS:
755+ case GL_MAX_VERTEX_ATTRIB_BINDINGS:
756+ SET_ERROR_IF(ctx->majorVersion() < 3 ||
757+ (ctx->majorVersion() == 3 &&
758+ ctx->minorVersion() == 0), GL_INVALID_ENUM);
759+ ctx->safe_glGetIntegerv(param, ptr);
760+ break;
637761 default:
638762 if (!ctx->m_state->getClientStateParameter<GLint>(param, ptr)) {
639- ctx->m_glGetIntegerv_enc(self, param, ptr);
763+ ctx->safe_glGetIntegerv(param, ptr);
640764 }
641765 break;
642766 }
@@ -671,7 +795,7 @@ void GL2Encoder::s_glGetFloatv(void *self, GLenum param, GLfloat *ptr)
671795 case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
672796 case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS:
673797 case GL_MAX_TEXTURE_IMAGE_UNITS:
674- ctx->m_glGetFloatv_enc(self, param, ptr);
798+ ctx->safe_glGetFloatv(param, ptr);
675799 *ptr = MIN(*ptr, (GLfloat)GLClientState::MAX_TEXTURE_UNITS);
676800 break;
677801
@@ -684,7 +808,7 @@ void GL2Encoder::s_glGetFloatv(void *self, GLenum param, GLfloat *ptr)
684808
685809 default:
686810 if (!ctx->m_state->getClientStateParameter<GLfloat>(param, ptr)) {
687- ctx->m_glGetFloatv_enc(self, param, ptr);
811+ ctx->safe_glGetFloatv(param, ptr);
688812 }
689813 break;
690814 }
@@ -726,7 +850,7 @@ void GL2Encoder::s_glGetBooleanv(void *self, GLenum param, GLboolean *ptr)
726850
727851 default:
728852 if (!ctx->m_state->getClientStateParameter<GLboolean>(param, ptr)) {
729- ctx->m_glGetBooleanv_enc(self, param, ptr);
853+ ctx->safe_glGetBooleanv(param, ptr);
730854 }
731855 *ptr = (*ptr != 0) ? GL_TRUE : GL_FALSE;
732856 break;
@@ -1313,7 +1437,7 @@ void GL2Encoder::s_glLinkProgram(void * self, GLuint program)
13131437 ctx->m_glLinkProgram_enc(self, program);
13141438
13151439 GLint linkStatus = 0;
1316- ctx->glGetProgramiv(self,program,GL_LINK_STATUS,&linkStatus);
1440+ ctx->glGetProgramiv(self, program, GL_LINK_STATUS, &linkStatus);
13171441 if (!linkStatus) {
13181442 return;
13191443 }
@@ -2095,9 +2219,16 @@ void GL2Encoder::override2DTextureTarget(GLenum target)
20952219 void GL2Encoder::restore2DTextureTarget(GLenum target)
20962220 {
20972221 if (texture2DNeedsOverride(target)) {
2098- m_glBindTexture_enc(this, GL_TEXTURE_2D,
2222+ GLuint priorityEnabledBoundTexture =
20992223 m_state->getBoundTexture(
2100- m_state->getPriorityEnabledTarget(GL_TEXTURE_2D)));
2224+ m_state->getPriorityEnabledTarget(GL_TEXTURE_2D));
2225+ GLuint texture2DBoundTexture =
2226+ m_state->getBoundTexture(GL_TEXTURE_2D);
2227+ if (!priorityEnabledBoundTexture) {
2228+ m_glBindTexture_enc(this, GL_TEXTURE_2D, texture2DBoundTexture);
2229+ } else {
2230+ m_glBindTexture_enc(this, GL_TEXTURE_2D, priorityEnabledBoundTexture);
2231+ }
21012232 }
21022233 }
21032234
@@ -4133,7 +4264,7 @@ void GL2Encoder::s_glGetIntegeri_v(void* self, GLenum target, GLuint index, GLin
41334264 break;
41344265 }
41354266
4136- ctx->m_glGetIntegeri_v_enc(self, target, index, params);
4267+ ctx->safe_glGetIntegeri_v(target, index, params);
41374268 }
41384269
41394270 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
41824313 break;
41834314 }
41844315
4185- ctx->m_glGetInteger64i_v_enc(self, target, index, params);
4316+ ctx->safe_glGetInteger64i_v(target, index, params);
4317+}
4318+
4319+void GL2Encoder::s_glGetInteger64v(void* self, GLenum param, GLint64* val) {
4320+ GL2Encoder *ctx = (GL2Encoder *)self;
4321+ ctx->safe_glGetInteger64v(param, val);
4322+}
4323+
4324+void GL2Encoder::s_glGetBooleani_v(void* self, GLenum param, GLuint index, GLboolean* val) {
4325+ GL2Encoder *ctx = (GL2Encoder *)self;
4326+ ctx->safe_glGetBooleani_v(param, index, val);
41864327 }
41874328
41884329 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
42534394 ctx->m_shared->associateGLShaderProgram(res, spDataId);
42544395
42554396 GLint numUniforms = 0;
4256- ctx->glGetProgramiv(ctx, res, GL_ACTIVE_UNIFORMS, &numUniforms);
4397+ ctx->glGetProgramiv(self, res, GL_ACTIVE_UNIFORMS, &numUniforms);
42574398 ctx->m_shared->initShaderProgramData(res, numUniforms);
42584399
42594400 GLint maxLength=0;
--- a/system/GLESv2_enc/GL2Encoder.h
+++ b/system/GLESv2_enc/GL2Encoder.h
@@ -30,6 +30,13 @@ public:
3030 void setClientState(GLClientState *state) {
3131 m_state = state;
3232 }
33+ void setVersion(int major, int minor,
34+ int deviceMajor, int deviceMinor) {
35+ m_currMajorVersion = major;
36+ m_currMinorVersion = minor;
37+ m_deviceMajorVersion = deviceMajor;
38+ m_deviceMinorVersion = deviceMinor;
39+ }
3340 void setClientStateMakeCurrent(GLClientState *state,
3441 int majorVersion,
3542 int minorVersion,
@@ -128,6 +135,21 @@ private:
128135 bool isCompleteFbo(GLenum target, const GLClientState* state, GLenum attachment) const;
129136 bool checkFramebufferCompleteness(GLenum target, const GLClientState* state) const;
130137
138+ // Utility classes for safe queries that
139+ // need access to private class members
140+ class ErrorUpdater;
141+ template<class T> class ScopedQueryUpdate;
142+
143+ // General queries
144+ void safe_glGetBooleanv(GLenum param, GLboolean *val);
145+ void safe_glGetFloatv(GLenum param, GLfloat *val);
146+ void safe_glGetIntegerv(GLenum param, GLint *val);
147+ void safe_glGetInteger64v(GLenum param, GLint64 *val);
148+ void safe_glGetIntegeri_v(GLenum param, GLuint index, GLint *val);
149+ void safe_glGetInteger64i_v(GLenum param, GLuint index, GLint64 *val);
150+ void safe_glGetBooleani_v(GLenum param, GLuint index, GLboolean *val);
151+
152+ // API implementation
131153 glGetError_client_proc_t m_glGetError_enc;
132154 static GLenum s_glGetError(void * self);
133155
@@ -161,7 +183,6 @@ private:
161183 glDrawElements_client_proc_t m_glDrawElements_enc;
162184 static void s_glDrawElements(void *self, GLenum mode, GLsizei count, GLenum type, const void *indices);
163185
164-
165186 glGetIntegerv_client_proc_t m_glGetIntegerv_enc;
166187 static void s_glGetIntegerv(void *self, GLenum pname, GLint *ptr);
167188
@@ -171,6 +192,12 @@ private:
171192 glGetBooleanv_client_proc_t m_glGetBooleanv_enc;
172193 static void s_glGetBooleanv(void *self, GLenum pname, GLboolean *ptr);
173194
195+ glGetInteger64v_client_proc_t m_glGetInteger64v_enc;
196+ static void s_glGetInteger64v(void* self, GLenum param, GLint64* val);
197+
198+ glGetBooleani_v_client_proc_t m_glGetBooleani_v_enc;
199+ static void s_glGetBooleani_v(void* self, GLenum param, GLuint index, GLboolean* val);
200+
174201 glVertexAttribPointer_client_proc_t m_glVertexAttribPointer_enc;
175202 static void s_glVertexAttribPointer(void *self, GLuint indx, GLint size, GLenum type,
176203 GLboolean normalized, GLsizei stride, const GLvoid * ptr);
--- a/system/OpenglSystemCommon/Android.mk
+++ b/system/OpenglSystemCommon/Android.mk
@@ -5,13 +5,23 @@ $(call emugl-import,libGLESv1_enc libGLESv2_enc lib_renderControl_enc)
55
66 LOCAL_SRC_FILES := \
77 goldfish_dma.cpp \
8- goldfishHwc2.cpp \
98 FormatConversions.cpp \
109 HostConnection.cpp \
1110 ProcessPipe.cpp \
1211 QemuPipeStream.cpp \
1312 ThreadInfo.cpp
1413
14+ifdef IS_AT_LEAST_PPD1
15+LOCAL_HEADER_LIBRARIES += libnativebase_headers
16+
17+$(call emugl-export,HEADER_LIBRARIES,libnativebase_headers)
18+endif
19+
20+ifdef IS_AT_LEAST_PPD1
21+LOCAL_HEADER_LIBRARIES += libhardware_headers
22+$(call emugl-export,HEADER_LIBRARIES,libhardware_headers)
23+endif
24+
1525 $(call emugl-export,C_INCLUDES,$(LOCAL_PATH) bionic/libc/private)
1626
1727 $(call emugl-end-module)
--- a/system/OpenglSystemCommon/EGLImage.h
+++ b/system/OpenglSystemCommon/EGLImage.h
@@ -21,7 +21,10 @@
2121 #include <GLES/gl.h>
2222
2323 #if PLATFORM_SDK_VERSION >= 16
24-#include <system/window.h>
24+#if EMULATOR_OPENGL_POST_O >= 1
25+#include <nativebase/nativebase.h>
26+#endif
27+#include <cutils/native_handle.h>
2528 #else // PLATFORM_SDK_VERSION >= 16
2629 #include <private/ui/android_natives_priv.h>
2730 #endif // PLATFORM_SDK_VERSION >= 16
--- a/system/OpenglSystemCommon/goldfishHwc2.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
1-/*
2-* Copyright (C) 2017 The Android Open Source Project
3-*
4-* Licensed under the Apache License, Version 2.0 (the "License");
5-* you may not use this file except in compliance with the License.
6-* You may obtain a copy of the License at
7-*
8-* http://www.apache.org/licenses/LICENSE-2.0
9-*
10-* Unless required by applicable law or agreed to in writing, software
11-* distributed under the License is distributed on an "AS IS" BASIS,
12-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-* See the License for the specific language governing permissions and
14-* limitations under the License.
15-*/
16-#include "goldfishHwc2.h"
17-
18-// Stub functions if not using HWC2.
19-#ifndef USE_HWC2
20-extern "C" void surfaceInterface_init() { }
21-extern "C" void surfaceInterface_setAsyncModeForWindow(void* window) { }
22-#endif
--- a/system/OpenglSystemCommon/goldfishHwc2.h
+++ /dev/null
@@ -1,25 +0,0 @@
1-/*
2-* Copyright (C) 2017 The Android Open Source Project
3-*
4-* Licensed under the Apache License, Version 2.0 (the "License");
5-* you may not use this file except in compliance with the License.
6-* You may obtain a copy of the License at
7-*
8-* http://www.apache.org/licenses/LICENSE-2.0
9-*
10-* Unless required by applicable law or agreed to in writing, software
11-* distributed under the License is distributed on an "AS IS" BASIS,
12-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-* See the License for the specific language governing permissions and
14-* limitations under the License.
15-*/
16-#pragma once
17-
18-// Set of functions that help support HWC2 in the emulator.
19-
20-#ifdef USE_HWC2
21-#include "../surfaceInterface/surfaceInterface.h"
22-#else
23-extern "C" void surfaceInterface_init();
24-extern "C" void surfaceInterface_setAsyncModeForWindow(void* window);
25-#endif
--- a/system/egl/Android.mk
+++ b/system/egl/Android.mk
@@ -13,12 +13,16 @@ LOCAL_SRC_FILES := \
1313 egl.cpp \
1414 ClientAPIExts.cpp
1515
16-ifeq ($(TARGET_USES_HWC2), true)
17- LOCAL_CFLAGS += -DUSE_HWC2
18- LOCAL_STATIC_LIBRARIES += libsurfaceInterface
16+ifdef IS_AT_LEAST_PPD1
17+LOCAL_SHARED_LIBRARIES += libdl libnativewindow
18+else
19+LOCAL_SHARED_LIBRARIES += libdl
20+endif
21+
22+ifdef IS_AT_LEAST_PPD1
23+LOCAL_HEADER_LIBRARIES += libnativebase_headers
1924 endif
2025
21-LOCAL_SHARED_LIBRARIES += libdl
2226 # Used to access the Bionic private OpenGL TLS slot
2327 LOCAL_C_INCLUDES += bionic/libc/private
2428
--- a/system/egl/egl.cpp
+++ b/system/egl/egl.cpp
@@ -29,7 +29,6 @@
2929 #include "eglContext.h"
3030 #include "ClientAPIExts.h"
3131 #include "EGLImage.h"
32-#include "goldfishHwc2.h"
3332 #include "ProcessPipe.h"
3433
3534 #include "GLEncoder.h"
@@ -39,6 +38,10 @@
3938
4039 #include <GLES3/gl31.h>
4140
41+#if PLATFORM_SDK_VERSION < 18
42+#define override
43+#endif
44+
4245 #if PLATFORM_SDK_VERSION >= 16
4346 #include <system/window.h>
4447 #else // PLATFORM_SDK_VERSION >= 16
@@ -171,6 +174,11 @@ const char * eglStrError(EGLint err)
171174 // The one and only supported display object.
172175 static eglDisplay s_display;
173176
177+// Extra defines not in the official EGL spec yet,
178+// but required in Android CTS.
179+
180+#define EGL_TIMESTAMPS_ANDROID 0x314D
181+
174182 EGLContext_t::EGLContext_t(EGLDisplay dpy, EGLConfig config, EGLContext_t* shareCtx, int maj, int min) :
175183 dpy(dpy),
176184 config(config),
@@ -181,7 +189,7 @@ EGLContext_t::EGLContext_t(EGLDisplay dpy, EGLConfig config, EGLContext_t* share
181189 versionString(NULL),
182190 majorVersion(maj),
183191 minorVersion(min),
184- vendorString(NULL),
192+ vendorString(NULL) ,
185193 rendererString(NULL),
186194 shaderVersionString(NULL),
187195 extensionString(NULL),
@@ -272,6 +280,9 @@ struct egl_surface_t {
272280 void setTextureTarget(EGLint _texTarget) { texTarget = _texTarget; }
273281 EGLint getTextureTarget() { return texTarget; }
274282
283+ virtual void setCollectingTimestamps(EGLint collect) { }
284+ virtual EGLint isCollectingTimestamps() const { return EGL_FALSE; }
285+
275286 private:
276287 //
277288 //Surface attributes
@@ -333,6 +344,11 @@ struct egl_window_surface_t : public egl_surface_t {
333344 virtual void setSwapInterval(int interval);
334345 virtual EGLBoolean swapBuffers();
335346
347+ virtual void setCollectingTimestamps(EGLint collect)
348+ override { collectingTimestamps = (collect == EGL_TRUE) ? true : false; }
349+ virtual EGLint isCollectingTimestamps() const override { return collectingTimestamps ? EGL_TRUE : EGL_FALSE; }
350+
351+
336352 private:
337353 egl_window_surface_t(
338354 EGLDisplay dpy, EGLConfig config, EGLint surfType,
@@ -341,6 +357,7 @@ private:
341357
342358 ANativeWindow* nativeWindow;
343359 android_native_buffer_t* buffer;
360+ bool collectingTimestamps;
344361 };
345362
346363 egl_window_surface_t::egl_window_surface_t (
@@ -348,7 +365,8 @@ egl_window_surface_t::egl_window_surface_t (
348365 ANativeWindow* window)
349366 : egl_surface_t(dpy, config, surfType),
350367 nativeWindow(window),
351- buffer(NULL)
368+ buffer(NULL),
369+ collectingTimestamps(false)
352370 {
353371 // keep a reference on the window
354372 nativeWindow->common.incRef(&nativeWindow->common);
@@ -380,8 +398,6 @@ EGLBoolean egl_window_surface_t::init()
380398 rcEnc->rcSetWindowColorBuffer(rcEnc, rcSurface,
381399 ((cb_handle_t*)(buffer->handle))->hostHandle);
382400
383- surfaceInterface_setAsyncModeForWindow((void*)nativeWindow);
384-
385401 return EGL_TRUE;
386402 }
387403
@@ -1097,6 +1113,9 @@ EGLBoolean eglQuerySurface(EGLDisplay dpy, EGLSurface eglSurface, EGLint attribu
10971113 // ignored when creating the surface, return default
10981114 *value = EGL_VG_ALPHA_FORMAT_NONPRE;
10991115 break;
1116+ case EGL_TIMESTAMPS_ANDROID:
1117+ *value = surface->isCollectingTimestamps();
1118+ break;
11001119 //TODO: complete other attributes
11011120 default:
11021121 ALOGE("eglQuerySurface %x EGL_BAD_ATTRIBUTE", attribute);
@@ -1189,7 +1208,6 @@ EGLBoolean eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute
11891208 switch (attribute) {
11901209 case EGL_MIPMAP_LEVEL:
11911210 return true;
1192- break;
11931211 case EGL_MULTISAMPLE_RESOLVE:
11941212 {
11951213 if (value == EGL_MULTISAMPLE_RESOLVE_BOX) {
@@ -1200,7 +1218,6 @@ EGLBoolean eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute
12001218 }
12011219 }
12021220 return true;
1203- break;
12041221 }
12051222 case EGL_SWAP_BEHAVIOR:
12061223 if (value == EGL_BUFFER_PRESERVED) {
@@ -1211,7 +1228,10 @@ EGLBoolean eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute
12111228 }
12121229 }
12131230 return true;
1214- break;
1231+ case EGL_TIMESTAMPS_ANDROID:
1232+ ALOGD("%s: set frame timestamps collecting %d\n", __func__, value);
1233+ p_surface->setCollectingTimestamps(value);
1234+ return true;
12151235 default:
12161236 ALOGW("%s: attr=0x%x not implemented", __FUNCTION__, attribute);
12171237 setErrorReturn(EGL_BAD_ATTRIBUTE, EGL_FALSE);
@@ -1541,6 +1561,13 @@ EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLC
15411561 ClientAPIExts::initClientFuncs(s_display.gles2_iface(), 1);
15421562 }
15431563 if (contextState->needsInitFromCaps()) {
1564+ // Need to set the version first if
1565+ // querying caps, or validation will trip incorrectly.
1566+ hostCon->gl2Encoder()->setVersion(
1567+ context->majorVersion,
1568+ context->minorVersion,
1569+ context->deviceMajorVersion,
1570+ context->deviceMinorVersion);
15441571 // Get caps for indexed buffers from host.
15451572 // Some need a current context.
15461573 int max_transform_feedback_separate_attribs = 0;
@@ -1578,7 +1605,7 @@ EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLC
15781605 max_draw_buffers);
15791606 }
15801607
1581- // set the client state and share group
1608+ // update the client state, share group, and version
15821609 if (context->majorVersion > 1) {
15831610 hostCon->gl2Encoder()->setClientStateMakeCurrent(
15841611 contextState,
--- a/system/egl/eglDisplay.cpp
+++ b/system/egl/eglDisplay.cpp
@@ -15,8 +15,6 @@
1515 */
1616 #include "eglDisplay.h"
1717 #include "HostConnection.h"
18-#include "goldfishHwc2.h"
19-
2018 #include <dlfcn.h>
2119
2220 #include <string>
@@ -72,7 +70,6 @@ eglDisplay::eglDisplay() :
7270 pthread_mutex_init(&m_lock, NULL);
7371 pthread_mutex_init(&m_ctxLock, NULL);
7472 pthread_mutex_init(&m_surfaceLock, NULL);
75- surfaceInterface_init();
7673 }
7774
7875 eglDisplay::~eglDisplay()
@@ -83,6 +80,12 @@ eglDisplay::~eglDisplay()
8380 pthread_mutex_destroy(&m_surfaceLock);
8481 }
8582
83+#if PLATFORM_SDK_VERSION >= 26
84+#define PARTITION "/vendor"
85+#else
86+#define PARTITION "/system"
87+#endif
88+
8689 bool eglDisplay::initialize(EGLClient_eglInterface *eglIface)
8790 {
8891 pthread_mutex_lock(&m_lock);
@@ -92,11 +95,11 @@ bool eglDisplay::initialize(EGLClient_eglInterface *eglIface)
9295 // load GLES client API
9396 //
9497 #if __LP64__
95- m_gles_iface = loadGLESClientAPI("/system/lib64/egl/libGLESv1_CM_emulation.so",
98+ m_gles_iface = loadGLESClientAPI(PARTITION "/lib64/egl/libGLESv1_CM_emulation.so",
9699 eglIface,
97100 &s_gles_lib);
98101 #else
99- m_gles_iface = loadGLESClientAPI("/system/lib/egl/libGLESv1_CM_emulation.so",
102+ m_gles_iface = loadGLESClientAPI(PARTITION "/lib/egl/libGLESv1_CM_emulation.so",
100103 eglIface,
101104 &s_gles_lib);
102105 #endif
@@ -108,11 +111,11 @@ bool eglDisplay::initialize(EGLClient_eglInterface *eglIface)
108111
109112 #ifdef WITH_GLES2
110113 #if __LP64__
111- m_gles2_iface = loadGLESClientAPI("/system/lib64/egl/libGLESv2_emulation.so",
114+ m_gles2_iface = loadGLESClientAPI(PARTITION "/lib64/egl/libGLESv2_emulation.so",
112115 eglIface,
113116 &s_gles2_lib);
114117 #else
115- m_gles2_iface = loadGLESClientAPI("/system/lib/egl/libGLESv2_emulation.so",
118+ m_gles2_iface = loadGLESClientAPI(PARTITION "/lib/egl/libGLESv2_emulation.so",
116119 eglIface,
117120 &s_gles2_lib);
118121 #endif
--- a/system/egl/goldfish_sync.h
+++ b/system/egl/goldfish_sync.h
@@ -18,6 +18,10 @@
1818 #include <linux/ioctl.h>
1919 #include <linux/types.h>
2020 #include <sys/cdefs.h>
21+#ifdef EMULATOR_OPENGL_POST_O
22+#include <sys/ioctl.h>
23+#include <sys/unistd.h>
24+#endif
2125 #include <fcntl.h>
2226
2327 // Make it conflict with ioctls that are not likely to be used
--- a/system/gralloc/gralloc.cpp
+++ b/system/gralloc/gralloc.cpp
@@ -27,6 +27,7 @@
2727 #include "HostConnection.h"
2828 #include "ProcessPipe.h"
2929 #include "glUtils.h"
30+#include <utils/CallStack.h>
3031 #include <cutils/log.h>
3132 #include <cutils/properties.h>
3233
@@ -390,6 +391,15 @@ static void updateHostColorBuffer(cb_handle_t* cb,
390391 if (convertedBuf) delete [] convertedBuf;
391392 }
392393
394+#ifndef GL_RGBA16F
395+#define GL_RGBA16F 0x881A
396+#endif // GL_RGBA16F
397+#ifndef GL_UNSIGNED_INT_10_10_10_2
398+#define GL_UNSIGNED_INT_10_10_10_2 0x8DF6
399+#endif // GL_UNSIGNED_INT_10_10_10_2
400+#ifndef GL_HALF_FLOAT
401+#define GL_HALF_FLOAT 0x140B
402+#endif // GL_HALF_FLOAT
393403 //
394404 // gralloc device functions (alloc interface)
395405 //
@@ -489,6 +499,18 @@ static int gralloc_alloc(alloc_device_t* dev,
489499 glFormat = GL_RGB;
490500 glType = GL_UNSIGNED_SHORT_5_6_5;
491501 break;
502+#if PLATFORM_SDK_VERSION >= 26
503+ case HAL_PIXEL_FORMAT_RGBA_FP16:
504+ bpp = 8;
505+ glFormat = GL_RGBA16F;
506+ glType = GL_HALF_FLOAT;
507+ break;
508+ case HAL_PIXEL_FORMAT_RGBA_1010102:
509+ bpp = 4;
510+ glFormat = GL_RGBA;
511+ glType = GL_UNSIGNED_INT_10_10_10_2;
512+ break;
513+#endif // PLATFORM_SDK_VERSION >= 26
492514 #if PLATFORM_SDK_VERSION >= 21
493515 case HAL_PIXEL_FORMAT_RAW16:
494516 case HAL_PIXEL_FORMAT_Y16:
@@ -508,8 +530,10 @@ static int gralloc_alloc(alloc_device_t* dev,
508530 #if PLATFORM_SDK_VERSION >= 17
509531 case HAL_PIXEL_FORMAT_BLOB:
510532 bpp = 1;
511- if (! (sw_read && hw_cam_write) ) {
533+ if (! (sw_read) ) {
512534 // Blob data cannot be used by HW other than camera emulator
535+ // But there is a CTS test trying to have access to it
536+ // BUG: https://buganizer.corp.google.com/issues/37719518
513537 return -EINVAL;
514538 }
515539 // Not expecting to actually create any GL surfaces for this
@@ -581,7 +605,11 @@ static int gralloc_alloc(alloc_device_t* dev,
581605 }
582606 }
583607
584- if (sw_read || sw_write || hw_cam_write || hw_vid_enc_read) {
608+ // API26 always expect at least one file descriptor is associated with
609+ // one color buffer
610+ // BUG: 37719038
611+ if (PLATFORM_SDK_VERSION >= 26 ||
612+ sw_read || sw_write || hw_cam_write || hw_vid_enc_read) {
585613 // keep space for image on guest memory if SW access is needed
586614 // or if the camera is doing writing
587615 if (yuv_format) {
@@ -1458,6 +1486,15 @@ struct private_module_t HAL_MODULE_INFO_SYM = {
14581486 *
14591487 * If not, then load gralloc.default instead as a fallback.
14601488 */
1489+
1490+#if __LP64__
1491+static const char kGrallocDefaultSystemPath[] = "/system/lib64/hw/gralloc.default.so";
1492+static const char kGrallocDefaultVendorPath[] = "/vendor/lib64/hw/gralloc.default.so";
1493+#else
1494+static const char kGrallocDefaultSystemPath[] = "/system/lib/hw/gralloc.default.so";
1495+static const char kGrallocDefaultVendorPath[] = "/vendor/lib/hw/gralloc.default.so";
1496+#endif
1497+
14611498 static void
14621499 fallback_init(void)
14631500 {
@@ -1471,12 +1508,17 @@ fallback_init(void)
14711508 if (atoi(prop) == 1) {
14721509 return;
14731510 }
1474- ALOGD("Emulator without host-side GPU emulation detected.");
1475-#if __LP64__
1476- module = dlopen("/vendor/lib64/hw/gralloc.default.so", RTLD_LAZY|RTLD_LOCAL);
1477-#else
1478- module = dlopen("/vendor/lib/hw/gralloc.default.so", RTLD_LAZY|RTLD_LOCAL);
1479-#endif
1511+ ALOGD("Emulator without host-side GPU emulation detected. "
1512+ "Loading gralloc.default.so from %s...",
1513+ kGrallocDefaultVendorPath);
1514+ module = dlopen(kGrallocDefaultVendorPath, RTLD_LAZY | RTLD_LOCAL);
1515+ if (!module) {
1516+ // vendor folder didn't work. try system
1517+ ALOGD("gralloc.default.so not found in /vendor. Trying %s...",
1518+ kGrallocDefaultSystemPath);
1519+ module = dlopen(kGrallocDefaultSystemPath, RTLD_LAZY | RTLD_LOCAL);
1520+ }
1521+
14801522 if (module != NULL) {
14811523 sFallback = reinterpret_cast<gralloc_module_t*>(dlsym(module, HAL_MODULE_INFO_SYM_AS_STR));
14821524 if (sFallback == NULL) {
@@ -1484,6 +1526,6 @@ fallback_init(void)
14841526 }
14851527 }
14861528 if (sFallback == NULL) {
1487- ALOGE("Could not find software fallback module!?");
1529+ ALOGE("FATAL: Could not find gralloc.default.so!");
14881530 }
14891531 }
--- a/system/surfaceInterface/Android.mk
+++ /dev/null
@@ -1,17 +0,0 @@
1-ifneq (false,$(BUILD_EMULATOR_OPENGL_DRIVER))
2-
3-ifeq ($(TARGET_USES_HWC2), true)
4-
5-LOCAL_PATH := $(call my-dir)
6-
7-$(call emugl-begin-static-library,libsurfaceInterface)
8-$(call emugl-import,libOpenglSystemCommon)
9-
10-LOCAL_SRC_FILES := surfaceInterface.cpp
11-LOCAL_SHARED_LIBRARIES := libgui
12-
13-$(call emugl-end-module)
14-
15-endif
16-
17-endif # BUILD_EMULATOR_OPENGL_DRIVER != false
--- a/system/surfaceInterface/surfaceInterface.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
1-#include "surfaceInterface.h"
2-
3-#include <cutils/log.h>
4-#include <gui/Surface.h>
5-
6-class SurfaceInterface : public android::ANativeObjectBase<
7- ANativeWindow,
8- android::Surface,
9- android::RefBase> {
10-public:
11- static SurfaceInterface* get();
12- void setAsyncMode(ANativeWindow* anw, bool async) {
13- ALOGD("SurfaceInterface::%s: set async mode %d", __func__, async);
14- window = anw;
15- android::Surface* s = android::Surface::getSelf(window);
16- s->setAsyncMode(async);
17- window = NULL;
18- }
19- ANativeWindow* window;
20-};
21-
22-static SurfaceInterface* sSurfaceInterface = NULL;
23-
24-SurfaceInterface* SurfaceInterface::get() {
25- if (!sSurfaceInterface)
26- sSurfaceInterface = new SurfaceInterface;
27- return sSurfaceInterface;
28-}
29-
30-extern "C" void surfaceInterface_init() {
31- SurfaceInterface::get();
32-}
33-
34-extern "C" void surfaceInterface_setAsyncModeForWindow(void* window) {
35- SurfaceInterface::get()->setAsyncMode((ANativeWindow*)window, true);
36-}
--- a/system/surfaceInterface/surfaceInterface.h
+++ /dev/null
@@ -1,25 +0,0 @@
1-/*
2-* Copyright (C) 2017 The Android Open Source Project
3-*
4-* Licensed under the Apache License, Version 2.0 (the "License");
5-* you may not use this file except in compliance with the License.
6-* You may obtain a copy of the License at
7-*
8-* http://www.apache.org/licenses/LICENSE-2.0
9-*
10-* Unless required by applicable law or agreed to in writing, software
11-* distributed under the License is distributed on an "AS IS" BASIS,
12-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-* See the License for the specific language governing permissions and
14-* limitations under the License.
15-*/
16-#pragma once
17-
18-#if PLATFORM_SDK_VERSION >= 16
19-#include <system/window.h>
20-#else // PLATFORM_SDK_VERSION >= 16
21-#include <private/ui/android_natives_priv.h>
22-#endif // PLATFORM_SDK_VERSION >= 16
23-
24-extern "C" void surfaceInterface_init();
25-extern "C" void surfaceInterface_setAsyncModeForWindow(void* window);
Afficher sur ancien navigateur de dépôt.