(reland) Add libqemupipe.ranchu and libgralloc_cb.ranchu am: 5fb783e257 am: ee82d6a8de am: a4b1e868a1

Original change: https://googleplex-android-review.googlesource.com/c/device/generic/goldfish-opengl/+/11416038

Change-Id: I4bba95b12fec430c50c86b23baebd44d692cb332
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..482e5a6
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+soong_namespace {}
diff --git a/Android.mk b/Android.mk
index 41466cb..90d028b 100644
--- a/Android.mk
+++ b/Android.mk
@@ -130,6 +130,9 @@
 # Note that the build system will complain if you try to import a
 # module that hasn't been declared yet anyway.
 #
+include $(GOLDFISH_OPENGL_PATH)/shared/qemupipe/Android.mk
+include $(GOLDFISH_OPENGL_PATH)/shared/gralloc_cb/Android.mk
+include $(GOLDFISH_OPENGL_PATH)/shared/GoldfishAddressSpace/Android.mk
 include $(GOLDFISH_OPENGL_PATH)/shared/OpenglCodecCommon/Android.mk
 
 # Encoder shared libraries
diff --git a/BUILD.gn b/BUILD.gn
index 0e2fea1..62cb990 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -28,14 +28,19 @@
     "android-emu/android/base/threads/AndroidWorkPool.cpp",
     "android-emu/android/base/Tracing.cpp",
     "android-emu/android/base/Tracing.h",
+    "shared/GoldfishAddressSpace/goldfish_address_space.cpp",
+    "shared/GoldfishAddressSpace/goldfish_address_space.h",
     "shared/OpenglCodecCommon/ChecksumCalculator.cpp",
     "shared/OpenglCodecCommon/ChecksumCalculator.h",
     "shared/OpenglCodecCommon/glUtils.cpp",
     "shared/OpenglCodecCommon/glUtils.h",
-    "shared/OpenglCodecCommon/goldfish_address_space.cpp",
-    "shared/OpenglCodecCommon/goldfish_address_space.h",
     "shared/OpenglCodecCommon/goldfish_dma.cpp",
     "shared/OpenglCodecCommon/goldfish_dma.h",
+    "shared/gralloc_cb/include/gralloc_cb_bp.h",
+    "shared/qemupipe/include/qemu_pipe_bp.h",
+    "shared/qemupipe/include-types/qemu_pipe_types_bp.h",
+    "shared/qemupipe/qemu_pipe_common.cpp",
+    "shared/qemupipe/qemu_pipe_guest.cpp",
     "system/OpenglSystemCommon/AddressSpaceStream.cpp",
     "system/OpenglSystemCommon/HostConnection.cpp",
     "system/OpenglSystemCommon/HostConnection.h",
@@ -77,7 +82,11 @@
   include_dirs = [
     "android-emu",
     "host/include/libOpenglRender",
+    "shared/GoldfishAddressSpace/include",
     "shared/OpenglCodecCommon",
+    "shared/gralloc_cb/include",
+    "shared/qemupipe/include",
+    "shared/qemupipe/include-types",
     "system/OpenglSystemCommon",
     "system/renderControl_enc",
     "system/vulkan_enc",
@@ -131,12 +140,12 @@
 
     deps = [
       "//sdk/fidl/fuchsia.hardware.goldfish",
-      "//zircon/system/fidl/fuchsia-sysmem",
-      "//zircon/public/lib/trace-with-static-engine",
-      "//zircon/public/lib/syslog-static",
+      "//sdk/fidl/fuchsia.logger:fuchsia.logger_llcpp",
+      "//sdk/fidl/fuchsia.sysmem",
       "//zircon/public/lib/zx",
       "//zircon/public/lib/zxio",
-      "//zircon/system/fidl/fuchsia-logger:llcpp",
+      "//zircon/system/ulib/syslog:syslog-static",
+      "//zircon/system/ulib/trace:trace-with-static-engine",
     ]
 
     defines += [
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4909c42..80c99c4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,7 +2,10 @@
 # instead run make from .../device/generic/goldfish-opengl
 # which will re-generate this file.
 set(GOLDFISH_DEVICE_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
-android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/./Android.mk" "fa06707a3536204e7a71728c5aca307ff81e7badfefeac790d2fcba19ff59746")
+android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/./Android.mk" "a370ddecca4c7d13811527b2f1f30e2f0ef5153a58edeb36eeb306c41efb9158")
+add_subdirectory(shared/qemupipe)
+add_subdirectory(shared/gralloc_cb)
+add_subdirectory(shared/GoldfishAddressSpace)
 add_subdirectory(shared/OpenglCodecCommon)
 add_subdirectory(system/GLESv1_enc)
 add_subdirectory(system/GLESv2_enc)
diff --git a/android-emu/Android.bp b/android-emu/Android.bp
new file mode 100644
index 0000000..68df03e
--- /dev/null
+++ b/android-emu/Android.bp
@@ -0,0 +1,35 @@
+cc_library_shared {
+    name: "libandroidemu",
+    vendor: true,
+    srcs: [
+        "android/base/AlignedBuf.cpp",
+        "android/base/files/MemStream.cpp",
+        "android/base/files/Stream.cpp",
+        "android/base/files/StreamSerializing.cpp",
+        "android/base/Pool.cpp",
+        "android/base/ring_buffer.c",
+        "android/base/StringFormat.cpp",
+        "android/base/AndroidSubAllocator.cpp",
+        "android/base/synchronization/AndroidMessageChannel.cpp",
+        "android/base/threads/AndroidFunctorThread.cpp",
+        "android/base/threads/AndroidThreadStore.cpp",
+        "android/base/threads/AndroidThread_pthread.cpp",
+        "android/base/threads/AndroidWorkPool.cpp",
+        "android/base/Tracing.cpp",
+        "android/utils/debug.c",
+    ],
+    shared_libs: [
+        "libcutils",
+        "libutils",
+        "liblog",
+    ],
+    export_include_dirs: [
+        ".",
+    ],
+    cflags: [
+        "-DLOG_TAG=\"androidemu\"",
+        "-Wno-missing-field-initializers",
+        "-fvisibility=default",
+        "-fstrict-aliasing",
+    ],
+}
diff --git a/android-emu/Android.mk b/android-emu/Android.mk
index 4be199b..ef67ddc 100644
--- a/android-emu/Android.mk
+++ b/android-emu/Android.mk
@@ -1,3 +1,4 @@
+ifeq (true,$(GOLDFISH_OPENGL_BUILD_FOR_HOST))
 LOCAL_PATH := $(call my-dir)
 
 $(call emugl-begin-shared-library,libandroidemu)
@@ -28,3 +29,4 @@
     android/utils/debug.c \
 
 $(call emugl-end-module)
+endif
diff --git a/android-emu/CMakeLists.txt b/android-emu/CMakeLists.txt
index f490697..cfdf39b 100644
--- a/android-emu/CMakeLists.txt
+++ b/android-emu/CMakeLists.txt
@@ -1,10 +1,10 @@
 # This is an autogenerated file! Do not edit!
 # instead run make from .../device/generic/goldfish-opengl
 # which will re-generate this file.
-android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/android-emu/Android.mk" "e7c9acc2277e7c651d6e722f96705a1fd445441b5ab6bb5b6d5b4c46dddfc702")
+android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/android-emu/Android.mk" "bd7f25228f5fed42d7a66a35c585d88bd77221db773a6aeb42403089703819e9")
 set(androidemu_src android/base/AlignedBuf.cpp android/base/files/MemStream.cpp android/base/files/Stream.cpp android/base/files/StreamSerializing.cpp android/base/Pool.cpp android/base/ring_buffer.c android/base/StringFormat.cpp android/base/AndroidSubAllocator.cpp android/base/synchronization/AndroidMessageChannel.cpp android/base/threads/AndroidFunctorThread.cpp android/base/threads/AndroidThreadStore.cpp android/base/threads/AndroidThread_pthread.cpp android/base/threads/AndroidWorkPool.cpp android/base/Tracing.cpp android/utils/debug.c)
 android_add_library(TARGET androidemu SHARED LICENSE Apache-2.0 SRC android/base/AlignedBuf.cpp android/base/files/MemStream.cpp android/base/files/Stream.cpp android/base/files/StreamSerializing.cpp android/base/Pool.cpp android/base/ring_buffer.c android/base/StringFormat.cpp android/base/AndroidSubAllocator.cpp android/base/synchronization/AndroidMessageChannel.cpp android/base/threads/AndroidFunctorThread.cpp android/base/threads/AndroidThreadStore.cpp android/base/threads/AndroidThread_pthread.cpp android/base/threads/AndroidWorkPool.cpp android/base/Tracing.cpp android/utils/debug.c)
 target_include_directories(androidemu PRIVATE ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
 target_compile_definitions(androidemu PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DGOLDFISH_VULKAN" "-DLOG_TAG=\"androidemu\"")
 target_compile_options(androidemu PRIVATE "-fvisibility=default" "-Wno-unused-parameter" "-Wno-missing-field-initializers" "-fstrict-aliasing")
-target_link_libraries(androidemu PRIVATE cutils utils log OpenglCodecCommon_host android-emu-shared)
\ No newline at end of file
+target_link_libraries(androidemu PRIVATE cutils utils log OpenglCodecCommon_host android-emu-shared PRIVATE qemupipe_host)
\ No newline at end of file
diff --git a/android-emu/android/base/AlignedBuf.h b/android-emu/android/base/AlignedBuf.h
index fc74e32..5955fa1 100644
--- a/android-emu/android/base/AlignedBuf.h
+++ b/android-emu/android/base/AlignedBuf.h
@@ -1,13 +1,16 @@
 // Copyright 2018 The Android Open Source Project
 //
-// This software is licensed under the terms of the GNU General Public
-// License version 2, as published by the Free Software Foundation, and
-// may be copied, distributed, and modified under those terms.
+// 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
 //
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
+// 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
 
diff --git a/android-emu/android/base/Compiler.h b/android-emu/android/base/Compiler.h
index ddfd992..00261b0 100644
--- a/android-emu/android/base/Compiler.h
+++ b/android-emu/android/base/Compiler.h
@@ -1,13 +1,16 @@
 // Copyright 2014 The Android Open Source Project
 //
-// This software is licensed under the terms of the GNU General Public
-// License version 2, as published by the Free Software Foundation, and
-// may be copied, distributed, and modified under those terms.
+// 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
 //
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
+// 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
 
diff --git a/android-emu/android/base/EnumFlags.h b/android-emu/android/base/EnumFlags.h
index fec56b9..1597dda 100644
--- a/android-emu/android/base/EnumFlags.h
+++ b/android-emu/android/base/EnumFlags.h
@@ -1,13 +1,16 @@
 // Copyright 2015 The Android Open Source Project
 //
-// This software is licensed under the terms of the GNU General Public
-// License version 2, as published by the Free Software Foundation, and
-// may be copied, distributed, and modified under those terms.
+// 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
 //
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
+// 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
 
diff --git a/android-emu/android/base/Optional.h b/android-emu/android/base/Optional.h
index c599828..4ed0c39 100644
--- a/android-emu/android/base/Optional.h
+++ b/android-emu/android/base/Optional.h
@@ -1,13 +1,16 @@
 // Copyright 2015-2016 The Android Open Source Project
 //
-// This software is licensed under the terms of the GNU General Public
-// License version 2, as published by the Free Software Foundation, and
-// may be copied, distributed, and modified under those terms.
+// 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
 //
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
+// 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
 
diff --git a/android-emu/android/base/StringFormat.cpp b/android-emu/android/base/StringFormat.cpp
index 73a0e7a..58fb947 100644
--- a/android-emu/android/base/StringFormat.cpp
+++ b/android-emu/android/base/StringFormat.cpp
@@ -1,13 +1,16 @@
 // Copyright 2014 The Android Open Source Project
 //
-// This software is licensed under the terms of the GNU General Public
-// License version 2, as published by the Free Software Foundation, and
-// may be copied, distributed, and modified under those terms.
+// 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
 //
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
+// 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 "android/base/StringFormat.h"
 
diff --git a/android-emu/android/base/StringFormat.h b/android-emu/android/base/StringFormat.h
index 184ee5f..d0fd3df 100644
--- a/android-emu/android/base/StringFormat.h
+++ b/android-emu/android/base/StringFormat.h
@@ -1,13 +1,16 @@
 // Copyright 2014 The Android Open Source Project
 //
-// This software is licensed under the terms of the GNU General Public
-// License version 2, as published by the Free Software Foundation, and
-// may be copied, distributed, and modified under those terms.
+// 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
 //
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
+// 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
 
diff --git a/android-emu/android/base/StringView.h b/android-emu/android/base/StringView.h
index f97ac5f..a6d9a61 100644
--- a/android-emu/android/base/StringView.h
+++ b/android-emu/android/base/StringView.h
@@ -1,13 +1,16 @@
 // Copyright 2014 The Android Open Source Project
 //
-// This software is licensed under the terms of the GNU General Public
-// License version 2, as published by the Free Software Foundation, and
-// may be copied, distributed, and modified under those terms.
+// 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
 //
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
+// 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
 
diff --git a/android-emu/android/base/Tracing.cpp b/android-emu/android/base/Tracing.cpp
index ff72093..a4c097f 100644
--- a/android-emu/android/base/Tracing.cpp
+++ b/android-emu/android/base/Tracing.cpp
@@ -37,7 +37,7 @@
 #elif __Fuchsia__
 
 #ifndef FUCHSIA_NO_TRACE
-#include <trace/event.h>
+#include <lib/trace/event.h>
 #endif
 
 #define VK_TRACE_TAG "gfx"
diff --git a/android-emu/android/base/containers/SmallVector.h b/android-emu/android/base/containers/SmallVector.h
index dc49a70..92e2d27 100644
--- a/android-emu/android/base/containers/SmallVector.h
+++ b/android-emu/android/base/containers/SmallVector.h
@@ -1,13 +1,16 @@
 // Copyright 2016 The Android Open Source Project
 //
-// This software is licensed under the terms of the GNU General Public
-// License version 2, as published by the Free Software Foundation, and
-// may be copied, distributed, and modified under those terms.
+// 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
 //
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
+// 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
 
diff --git a/android-emu/android/base/files/MemStream.cpp b/android-emu/android/base/files/MemStream.cpp
index 4f8291f..f2b0055 100644
--- a/android-emu/android/base/files/MemStream.cpp
+++ b/android-emu/android/base/files/MemStream.cpp
@@ -1,13 +1,16 @@
 // Copyright 2015 The Android Open Source Project
 //
-// This software is licensed under the terms of the GNU General Public
-// License version 2, as published by the Free Software Foundation, and
-// may be copied, distributed, and modified under those terms.
+// 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
 //
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
+// 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 "android/base/files/MemStream.h"
 
diff --git a/android-emu/android/base/files/MemStream.h b/android-emu/android/base/files/MemStream.h
index e256a68..5c5b0f6 100644
--- a/android-emu/android/base/files/MemStream.h
+++ b/android-emu/android/base/files/MemStream.h
@@ -1,13 +1,16 @@
 // Copyright 2015 The Android Open Source Project
 //
-// This software is licensed under the terms of the GNU General Public
-// License version 2, as published by the Free Software Foundation, and
-// may be copied, distributed, and modified under those terms.
+// 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
 //
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
+// 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
 
diff --git a/android-emu/android/base/files/Stream.cpp b/android-emu/android/base/files/Stream.cpp
index dd4c9ef..db34ed3 100644
--- a/android-emu/android/base/files/Stream.cpp
+++ b/android-emu/android/base/files/Stream.cpp
@@ -1,13 +1,16 @@
 // Copyright 2015 The Android Open Source Project
 //
-// This software is licensed under the terms of the GNU General Public
-// License version 2, as published by the Free Software Foundation, and
-// may be copied, distributed, and modified under those terms.
+// 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
 //
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
+// 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 "android/base/files/Stream.h"
 
diff --git a/android-emu/android/base/files/Stream.h b/android-emu/android/base/files/Stream.h
index 8e2b0a0..3a5632e 100644
--- a/android-emu/android/base/files/Stream.h
+++ b/android-emu/android/base/files/Stream.h
@@ -1,13 +1,16 @@
 // Copyright 2015 The Android Open Source Project
 //
-// This software is licensed under the terms of the GNU General Public
-// License version 2, as published by the Free Software Foundation, and
-// may be copied, distributed, and modified under those terms.
+// 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
 //
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
+// 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
 
diff --git a/android-emu/android/base/files/StreamSerializing.cpp b/android-emu/android/base/files/StreamSerializing.cpp
index 2a9d77a..d88a1fc 100644
--- a/android-emu/android/base/files/StreamSerializing.cpp
+++ b/android-emu/android/base/files/StreamSerializing.cpp
@@ -1,13 +1,16 @@
 // Copyright 2017 The Android Open Source Project
 //
-// This software is licensed under the terms of the GNU General Public
-// License version 2, as published by the Free Software Foundation, and
-// may be copied, distributed, and modified under those terms.
+// 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
 //
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
+// 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 "android/base/files/StreamSerializing.h"
 
diff --git a/android-emu/android/base/files/StreamSerializing.h b/android-emu/android/base/files/StreamSerializing.h
index 8e56a6e..56613f5 100644
--- a/android-emu/android/base/files/StreamSerializing.h
+++ b/android-emu/android/base/files/StreamSerializing.h
@@ -1,13 +1,16 @@
 // Copyright 2017 The Android Open Source Project
 //
-// This software is licensed under the terms of the GNU General Public
-// License version 2, as published by the Free Software Foundation, and
-// may be copied, distributed, and modified under those terms.
+// 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
 //
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
+// 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
 
diff --git a/android-emu/android/utils/compiler.h b/android-emu/android/utils/compiler.h
index 0d72fee..fae0918 100644
--- a/android-emu/android/utils/compiler.h
+++ b/android-emu/android/utils/compiler.h
@@ -1,13 +1,16 @@
 // Copyright 2014 The Android Open Source Project
 //
-// This software is licensed under the terms of the GNU General Public
-// License version 2, as published by the Free Software Foundation, and
-// may be copied, distributed, and modified under those terms.
+// 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
 //
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
+// 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
 
diff --git a/android-emu/android/utils/debug.c b/android-emu/android/utils/debug.c
index 238bd87..27ad1d6 100644
--- a/android-emu/android/utils/debug.c
+++ b/android-emu/android/utils/debug.c
@@ -1,14 +1,16 @@
-/* Copyright (C) 2007-2008 The Android Open Source Project
-**
-** This software is licensed under the terms of the GNU General Public
-** License version 2, as published by the Free Software Foundation, and
-** may be copied, distributed, and modified under those terms.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU General Public License for more details.
-*/
+// Copyright 2007-2008 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 "android/utils/debug.h"
 
 #include <fcntl.h>
diff --git a/android-emu/android/utils/debug.h b/android-emu/android/utils/debug.h
index a6cdc02..be1c1b2 100644
--- a/android-emu/android/utils/debug.h
+++ b/android-emu/android/utils/debug.h
@@ -1,14 +1,16 @@
-/* Copyright (C) 2007-2008 The Android Open Source Project
-**
-** This software is licensed under the terms of the GNU General Public
-** License version 2, as published by the Free Software Foundation, and
-** may be copied, distributed, and modified under those terms.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU General Public License for more details.
-*/
+// Copyright 2007-2008 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
 
diff --git a/cmake_transform.py b/cmake_transform.py
index 3583ec8..298e454 100644
--- a/cmake_transform.py
+++ b/cmake_transform.py
@@ -106,7 +106,7 @@
     flags = [escape(d) for d in module['cflags'] if not d.startswith('-D')]
 
     # Make sure we remove the lib prefix from all our dependencies.
-    libs = [remove_lib_prefix(l) for l in module['libs']]
+    libs = [remove_lib_prefix(l) for l in module.get('libs', [])]
     staticlibs = [remove_lib_prefix(l) for l in
                       module.get('staticlibs', [])
                       if l != "libandroidemu"]
diff --git a/host/include/libOpenglRender/IOStream.h b/host/include/libOpenglRender/IOStream.h
index 159da1d..9173d31 100644
--- a/host/include/libOpenglRender/IOStream.h
+++ b/host/include/libOpenglRender/IOStream.h
@@ -93,8 +93,11 @@
         return readFully(buf, len);
     }
 
+    // These two methods are defined and used in GLESv2_enc. Any reference
+    // outside of GLESv2_enc will produce a link error. This is intentional
+    // (technical debt).
     void readbackPixels(void* context, int width, int height, unsigned int format, unsigned int type, void* pixels);
-    void uploadPixels(void* context, int width, int height, unsigned int format, unsigned int type, const void* pixels);
+    void uploadPixels(void* context, int width, int height, int depth, unsigned int format, unsigned int type, const void* pixels);
 
 
 private:
diff --git a/shared/GoldfishAddressSpace/Android.bp b/shared/GoldfishAddressSpace/Android.bp
new file mode 100644
index 0000000..6dcdb56
--- /dev/null
+++ b/shared/GoldfishAddressSpace/Android.bp
@@ -0,0 +1,16 @@
+cc_library_static {
+    name: "libGoldfishAddressSpace",
+    vendor: true,
+    srcs: [
+        "goldfish_address_space.cpp",
+    ],
+    shared_libs: [
+        "liblog",
+    ],
+    export_include_dirs: [
+        "include",
+    ],
+    cflags: [
+        "-DLOG_TAG=\"goldfish-address-space\"",
+    ],
+}
diff --git a/shared/GoldfishAddressSpace/Android.mk b/shared/GoldfishAddressSpace/Android.mk
new file mode 100644
index 0000000..221ea8b
--- /dev/null
+++ b/shared/GoldfishAddressSpace/Android.mk
@@ -0,0 +1,15 @@
+ifeq (true,$(GOLDFISH_OPENGL_BUILD_FOR_HOST))
+
+LOCAL_PATH := $(call my-dir)
+
+$(call emugl-begin-static-library,libGoldfishAddressSpace$(GOLDFISH_OPENGL_LIB_SUFFIX))
+
+LOCAL_SRC_FILES := goldfish_address_space.cpp
+
+LOCAL_CFLAGS += -DLOG_TAG=\"goldfish-address-space\"
+
+$(call emugl-export,SHARED_LIBRARIES,liblog android-emu-shared)
+$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)/include)
+$(call emugl-end-module)
+
+endif
diff --git a/shared/GoldfishAddressSpace/CMakeLists.txt b/shared/GoldfishAddressSpace/CMakeLists.txt
new file mode 100644
index 0000000..c89a436
--- /dev/null
+++ b/shared/GoldfishAddressSpace/CMakeLists.txt
@@ -0,0 +1,10 @@
+# This is an autogenerated file! Do not edit!
+# instead run make from .../device/generic/goldfish-opengl
+# which will re-generate this file.
+android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/shared/GoldfishAddressSpace/Android.mk" "2b12d7f8c4c62c3a909b9771662cf18c9e4d16c58c95a11e225fe2b46432e862")
+set(GoldfishAddressSpace_host_src goldfish_address_space.cpp)
+android_add_library(TARGET GoldfishAddressSpace_host LICENSE Apache-2.0 SRC goldfish_address_space.cpp)
+target_include_directories(GoldfishAddressSpace_host PRIVATE ${GOLDFISH_DEVICE_ROOT}/shared/GoldfishAddressSpace/include ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
+target_compile_definitions(GoldfishAddressSpace_host PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DGOLDFISH_VULKAN" "-DLOG_TAG=\"goldfish-address-space\"")
+target_compile_options(GoldfishAddressSpace_host PRIVATE "-fvisibility=default" "-Wno-unused-parameter")
+target_link_libraries(GoldfishAddressSpace_host PRIVATE log android-emu-shared)
\ No newline at end of file
diff --git a/shared/OpenglCodecCommon/goldfish_address_space.cpp b/shared/GoldfishAddressSpace/goldfish_address_space.cpp
similarity index 100%
rename from shared/OpenglCodecCommon/goldfish_address_space.cpp
rename to shared/GoldfishAddressSpace/goldfish_address_space.cpp
diff --git a/shared/OpenglCodecCommon/goldfish_address_space.h b/shared/GoldfishAddressSpace/include/goldfish_address_space.h
similarity index 89%
rename from shared/OpenglCodecCommon/goldfish_address_space.h
rename to shared/GoldfishAddressSpace/include/goldfish_address_space.h
index 66a2522..044e18a 100644
--- a/shared/OpenglCodecCommon/goldfish_address_space.h
+++ b/shared/GoldfishAddressSpace/include/goldfish_address_space.h
@@ -1,16 +1,16 @@
-/*
- * Copyright (C) 2018 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- */
+// Copyright 2018 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.
 
 #ifndef ANDROID_INCLUDE_HARDWARE_GOLDFISH_ADDRESS_SPACE_H
 #define ANDROID_INCLUDE_HARDWARE_GOLDFISH_ADDRESS_SPACE_H
diff --git a/shared/OpenglCodecCommon/goldfish_address_space_android.impl b/shared/GoldfishAddressSpace/include/goldfish_address_space_android.impl
similarity index 99%
rename from shared/OpenglCodecCommon/goldfish_address_space_android.impl
rename to shared/GoldfishAddressSpace/include/goldfish_address_space_android.impl
index 1ee59f7..8ff7e78 100644
--- a/shared/OpenglCodecCommon/goldfish_address_space_android.impl
+++ b/shared/GoldfishAddressSpace/include/goldfish_address_space_android.impl
@@ -25,11 +25,7 @@
 #include <errno.h>
 #include <memory>
 
-#if PLATFORM_SDK_VERSION < 26
-#include <cutils/log.h>
-#else
 #include <log/log.h>
-#endif
 
 #include "goldfish_address_space.h"
 
diff --git a/shared/OpenglCodecCommon/goldfish_address_space_fuchsia.impl b/shared/GoldfishAddressSpace/include/goldfish_address_space_fuchsia.impl
similarity index 100%
rename from shared/OpenglCodecCommon/goldfish_address_space_fuchsia.impl
rename to shared/GoldfishAddressSpace/include/goldfish_address_space_fuchsia.impl
diff --git a/shared/OpenglCodecCommon/goldfish_address_space_host.impl b/shared/GoldfishAddressSpace/include/goldfish_address_space_host.impl
similarity index 100%
rename from shared/OpenglCodecCommon/goldfish_address_space_host.impl
rename to shared/GoldfishAddressSpace/include/goldfish_address_space_host.impl
diff --git a/shared/OpenglCodecCommon/Android.bp b/shared/OpenglCodecCommon/Android.bp
deleted file mode 100644
index e56dfcd..0000000
--- a/shared/OpenglCodecCommon/Android.bp
+++ /dev/null
@@ -1,5 +0,0 @@
-cc_library_headers {
-    name: "goldfish_pipe_headers",
-    vendor_available: true,
-    export_include_dirs: ["."],
-}
diff --git a/shared/OpenglCodecCommon/Android.mk b/shared/OpenglCodecCommon/Android.mk
index af7c65d..d9970d5 100644
--- a/shared/OpenglCodecCommon/Android.mk
+++ b/shared/OpenglCodecCommon/Android.mk
@@ -13,13 +13,11 @@
         SocketStream.cpp \
         TcpStream.cpp \
         auto_goldfish_dma_context.cpp \
-        goldfish_address_space.cpp \
 
 ifeq (true,$(GOLDFISH_OPENGL_BUILD_FOR_HOST))
 
 commonSources += \
         goldfish_dma_host.cpp \
-        qemu_pipe_host.cpp \
 
 else
 
@@ -31,6 +29,12 @@
 ### CodecCommon  guest ##############################################
 $(call emugl-begin-shared-library,libOpenglCodecCommon$(GOLDFISH_OPENGL_LIB_SUFFIX))
 
+ifeq (true,$(GOLDFISH_OPENGL_BUILD_FOR_HOST))
+$(call emugl-import,libqemupipe$(GOLDFISH_OPENGL_LIB_SUFFIX))
+else
+$(call emugl-export,STATIC_LIBRARIES,libqemupipe.ranchu)
+endif
+
 LOCAL_SRC_FILES := $(commonSources)
 
 LOCAL_CFLAGS += -DLOG_TAG=\"eglCodecCommon\"
diff --git a/shared/OpenglCodecCommon/CMakeLists.txt b/shared/OpenglCodecCommon/CMakeLists.txt
index 4528e13..6a1ac4a 100644
--- a/shared/OpenglCodecCommon/CMakeLists.txt
+++ b/shared/OpenglCodecCommon/CMakeLists.txt
@@ -1,10 +1,10 @@
 # This is an autogenerated file! Do not edit!
 # instead run make from .../device/generic/goldfish-opengl
 # which will re-generate this file.
-android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon/Android.mk" "b93e7098601bba92b0e1b4d4a94cee25d2181a9842c7902d5f339c405c862cea")
-set(OpenglCodecCommon_host_src GLClientState.cpp GLESTextureUtils.cpp ChecksumCalculator.cpp GLSharedGroup.cpp glUtils.cpp IndexRangeCache.cpp SocketStream.cpp TcpStream.cpp auto_goldfish_dma_context.cpp goldfish_address_space.cpp goldfish_dma_host.cpp qemu_pipe_host.cpp)
-android_add_library(TARGET OpenglCodecCommon_host SHARED LICENSE Apache-2.0 SRC GLClientState.cpp GLESTextureUtils.cpp ChecksumCalculator.cpp GLSharedGroup.cpp glUtils.cpp IndexRangeCache.cpp SocketStream.cpp TcpStream.cpp auto_goldfish_dma_context.cpp goldfish_address_space.cpp goldfish_dma_host.cpp qemu_pipe_host.cpp)
-target_include_directories(OpenglCodecCommon_host PRIVATE ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
+android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon/Android.mk" "87f5c2c694647e3a38b4da1b4c653b99cd27d934b60ecd43aff59d3765daabfd")
+set(OpenglCodecCommon_host_src GLClientState.cpp GLESTextureUtils.cpp ChecksumCalculator.cpp GLSharedGroup.cpp glUtils.cpp IndexRangeCache.cpp SocketStream.cpp TcpStream.cpp auto_goldfish_dma_context.cpp goldfish_dma_host.cpp)
+android_add_library(TARGET OpenglCodecCommon_host SHARED LICENSE Apache-2.0 SRC GLClientState.cpp GLESTextureUtils.cpp ChecksumCalculator.cpp GLSharedGroup.cpp glUtils.cpp IndexRangeCache.cpp SocketStream.cpp TcpStream.cpp auto_goldfish_dma_context.cpp goldfish_dma_host.cpp)
+target_include_directories(OpenglCodecCommon_host PRIVATE ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include-types ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
 target_compile_definitions(OpenglCodecCommon_host PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DGOLDFISH_VULKAN" "-DLOG_TAG=\"eglCodecCommon\"")
 target_compile_options(OpenglCodecCommon_host PRIVATE "-fvisibility=default" "-Wno-unused-parameter" "-Wno-unused-private-field")
-target_link_libraries(OpenglCodecCommon_host PRIVATE android-emu-shared cutils utils log)
\ No newline at end of file
+target_link_libraries(OpenglCodecCommon_host PRIVATE android-emu-shared cutils utils log PRIVATE qemupipe_host)
\ No newline at end of file
diff --git a/shared/OpenglCodecCommon/ErrorLog.h b/shared/OpenglCodecCommon/ErrorLog.h
index fa2b0a2..7f693b7 100644
--- a/shared/OpenglCodecCommon/ErrorLog.h
+++ b/shared/OpenglCodecCommon/ErrorLog.h
@@ -17,11 +17,7 @@
 #define _ERROR_LOG_H_
 
 #if defined(__ANDROID__)
-#    if PLATFORM_SDK_VERSION < 26
-#        include <cutils/log.h>
-#    else
-#        include <log/log.h>
-#    endif
+#    include <log/log.h>
 #    define ERR(...)    ALOGE(__VA_ARGS__)
 #    ifdef EMUGL_DEBUG
 #        define DBG(...)    ALOGD(__VA_ARGS__)
@@ -29,7 +25,7 @@
 #        define DBG(...)    ((void)0)
 #    endif
 #else
-#     include <stdio.h>
+#    include <stdio.h>
 #    define ERR(...)    fprintf(stderr, __VA_ARGS__)
 #    ifdef EMUGL_DEBUG
 #        define DBG(...)    fprintf(stderr, __VA_ARGS__)
diff --git a/shared/OpenglCodecCommon/FixedBuffer.h b/shared/OpenglCodecCommon/FixedBuffer.h
deleted file mode 100644
index 8c34749..0000000
--- a/shared/OpenglCodecCommon/FixedBuffer.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
-* Copyright (C) 2011 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.
-*/
-#ifndef _FIXED_BUFFER_H
-#define _FIXED_BUFFER_H
-
-#if PLATFORM_SDK_VERSION < 26
-#include <cutils/log.h>
-#else
-#include <log/log.h>
-#endif
-
-class FixedBuffer {
-public:
-    FixedBuffer(size_t initialSize = 0) {
-        m_buffer = NULL;
-        m_bufferLen = initialSize;
-        alloc(m_bufferLen);
-    }
-
-    ~FixedBuffer() {
-        delete [] m_buffer;
-        m_bufferLen = 0;
-    }
-
-    void * alloc(size_t size) {
-        if (m_bufferLen >= size)
-            return (void *)(m_buffer);
-
-        if (m_buffer != NULL)
-            delete[] m_buffer;
-
-        m_bufferLen = size;
-        m_buffer = new unsigned char[m_bufferLen];
-        if (m_buffer == NULL)
-            m_bufferLen = 0;
-
-        return m_buffer;
-    }
-    void *ptr() { return m_buffer; }
-    size_t len() { return m_bufferLen; }
-private:
-    unsigned char *m_buffer;
-    size_t m_bufferLen;
-};
-
-#endif
diff --git a/shared/OpenglCodecCommon/GLClientState.cpp b/shared/OpenglCodecCommon/GLClientState.cpp
index 3f207b8..a31f697 100644
--- a/shared/OpenglCodecCommon/GLClientState.cpp
+++ b/shared/OpenglCodecCommon/GLClientState.cpp
@@ -852,7 +852,7 @@
     return 1;
 }
 
-void GLClientState::getPackingOffsets2D(GLsizei width, GLsizei height, GLenum format, GLenum type, int* startOffset, int* pixelRowSize, int* totalRowSize, int* skipRows) const
+void GLClientState::getPackingOffsets2D(GLsizei width, GLsizei height, GLenum format, GLenum type, int* bpp, int* startOffset, int* pixelRowSize, int* totalRowSize, int* skipRows) const
 {
     if (width <= 0 || height <= 0) {
         *startOffset = 0;
@@ -868,6 +868,7 @@
             m_pixelStore.pack_row_length,
             m_pixelStore.pack_skip_pixels,
             m_pixelStore.pack_skip_rows,
+            bpp,
             startOffset,
             pixelRowSize,
             totalRowSize);
@@ -875,7 +876,7 @@
     *skipRows = m_pixelStore.pack_skip_rows;
 }
 
-void GLClientState::getUnpackingOffsets2D(GLsizei width, GLsizei height, GLenum format, GLenum type, int* startOffset, int* pixelRowSize, int* totalRowSize, int* skipRows) const
+void GLClientState::getUnpackingOffsets2D(GLsizei width, GLsizei height, GLenum format, GLenum type, int* bpp, int* startOffset, int* pixelRowSize, int* totalRowSize, int* skipRows) const
 {
     if (width <= 0 || height <= 0) {
         *startOffset = 0;
@@ -891,6 +892,7 @@
             m_pixelStore.unpack_row_length,
             m_pixelStore.unpack_skip_pixels,
             m_pixelStore.unpack_skip_rows,
+            bpp,
             startOffset,
             pixelRowSize,
             totalRowSize);
@@ -898,6 +900,35 @@
     *skipRows = m_pixelStore.unpack_skip_rows;
 }
 
+void GLClientState::getUnpackingOffsets3D(GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, int* bpp, int* startOffset, int* pixelRowSize, int* totalRowSize, int* pixelImageSize, int* totalImageSize, int* skipRows, int* skipImages) const
+{
+    if (width <= 0 || height <= 0) {
+        *startOffset = 0;
+        *pixelRowSize = 0;
+        *totalRowSize = 0;
+        return;
+    }
+
+    GLESTextureUtils::computePackingOffsets3D(
+            width, height, depth,
+            format, type,
+            m_pixelStore.unpack_alignment,
+            m_pixelStore.unpack_row_length,
+            m_pixelStore.unpack_image_height,
+            m_pixelStore.unpack_skip_pixels,
+            m_pixelStore.unpack_skip_rows,
+            m_pixelStore.unpack_skip_images,
+            bpp,
+            startOffset,
+            pixelRowSize,
+            totalRowSize,
+            pixelImageSize,
+            totalImageSize);
+
+    *skipRows = m_pixelStore.unpack_skip_rows;
+    *skipImages = m_pixelStore.unpack_skip_images;
+}
+
 void GLClientState::setNumActiveUniformsInUniformBlock(GLuint program, GLuint uniformBlockIndex, GLint numActiveUniforms) {
     UniformBlockInfoKey key;
     key.program = program;
diff --git a/shared/OpenglCodecCommon/GLClientState.h b/shared/OpenglCodecCommon/GLClientState.h
index f9f8ee3..b7f5655 100644
--- a/shared/OpenglCodecCommon/GLClientState.h
+++ b/shared/OpenglCodecCommon/GLClientState.h
@@ -253,8 +253,9 @@
     size_t pixelDataSize(GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, int pack) const;
     size_t pboNeededDataSize(GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, int pack) const;
     size_t clearBufferNumElts(GLenum buffer) const;
-    void getPackingOffsets2D(GLsizei width, GLsizei height, GLenum format, GLenum type, int* startOffset, int* pixelRowSize, int* totalRowSize, int* skipRows) const;
-    void getUnpackingOffsets2D(GLsizei width, GLsizei height, GLenum format, GLenum type, int* startOffset, int* pixelRowSize, int* totalRowSize, int* skipRows) const;
+    void getPackingOffsets2D(GLsizei width, GLsizei height, GLenum format, GLenum type, int* bpp, int* startOffset, int* pixelRowSize, int* totalRowSize, int* skipRows) const;
+    void getUnpackingOffsets2D(GLsizei width, GLsizei height, GLenum format, GLenum type, int* bpp, int* startOffset, int* pixelRowSize, int* totalRowSize, int* skipRows) const;
+    void getUnpackingOffsets3D(GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, int* bpp, int* startOffset, int* pixelRowSize, int* totalRowSize, int* pixelImageSize, int* totalImageSize, int* skipRows, int* skipImages) const;
 
     void setCurrentProgram(GLint program) { m_currentProgram = program; }
     void setCurrentShaderProgram(GLint program) { m_currentShaderProgram = program; }
diff --git a/shared/OpenglCodecCommon/GLESTextureUtils.cpp b/shared/OpenglCodecCommon/GLESTextureUtils.cpp
index 297a862..cedcda8 100644
--- a/shared/OpenglCodecCommon/GLESTextureUtils.cpp
+++ b/shared/OpenglCodecCommon/GLESTextureUtils.cpp
@@ -207,7 +207,9 @@
     GLsizei alignedPitch = computePitch(width, format, type, align);
     int packingOffsetRows =
         (skipImages * height + skipRows);
-    return packingOffsetRows * alignedPitch + skipPixels * computePixelSize(format, type);
+    int res = packingOffsetRows * alignedPitch + skipPixels * computePixelSize(format, type);
+
+    return res;
 }
 
 void computeTextureStartEnd(
@@ -295,6 +297,7 @@
         int packRowLength,
         int packSkipPixels,
         int packSkipRows,
+        int* bpp,
         int* startOffset,
         int* packingPixelRowSize,
         int* packingTotalRowSize) {
@@ -307,10 +310,46 @@
         computePackingOffset(
                 format, type, widthTotal, height, packAlignment, packSkipPixels, packSkipRows, 0 /* skip images = 0 */);
 
+    if (bpp) *bpp = computePixelSize(format, type);
     if (startOffset) *startOffset = packingOffsetStart;
     if (packingPixelRowSize) *packingPixelRowSize = pixelsOnlyRowSize;
     if (packingTotalRowSize) *packingTotalRowSize = totalRowSize;
 }
 
+void computePackingOffsets3D(
+        GLsizei width, GLsizei height, GLsizei depth,
+        GLenum format, GLenum type,
+        int packAlignment,
+        int packRowLength,
+        int packImageHeight,
+        int packSkipPixels,
+        int packSkipRows,
+        int packSkipImages,
+        int* bpp,
+        int* startOffset,
+        int* packingPixelRowSize,
+        int* packingTotalRowSize,
+        int* packingPixelImageSize,
+        int* packingTotalImageSize) {
+
+    int widthTotal = (packRowLength == 0) ? width : packRowLength;
+    int totalRowSize = computePitch(widthTotal, format, type, packAlignment);
+    int pixelsOnlyRowSize = computePitch(width, format, type, packAlignment);
+
+    int heightTotal = packImageHeight == 0 ? height : packImageHeight;
+    int totalImageSize = totalRowSize * heightTotal;
+    int pixelsOnlyImageSize = totalRowSize * height;
+
+    int packingOffsetStart =
+        computePackingOffset(
+                format, type, widthTotal, heightTotal, packAlignment, packSkipPixels, packSkipRows, packSkipImages);
+
+    if (bpp) *bpp = computePixelSize(format, type);
+    if (startOffset) *startOffset = packingOffsetStart;
+    if (packingPixelRowSize) *packingPixelRowSize = pixelsOnlyRowSize;
+    if (packingTotalRowSize) *packingTotalRowSize = totalRowSize;
+    if (packingPixelImageSize) *packingPixelImageSize = pixelsOnlyImageSize;
+    if (packingTotalImageSize) *packingTotalImageSize = totalImageSize;
+}
 
 } // namespace GLESTextureUtils
diff --git a/shared/OpenglCodecCommon/GLESTextureUtils.h b/shared/OpenglCodecCommon/GLESTextureUtils.h
index f623d23..1d26b3a 100644
--- a/shared/OpenglCodecCommon/GLESTextureUtils.h
+++ b/shared/OpenglCodecCommon/GLESTextureUtils.h
@@ -49,9 +49,27 @@
         int packRowLength,
         int packSkipPixels,
         int packSkipRows,
+        int* bpp,
         int* startOffset,
         int* packingPixelRowSize,
         int* packingTotalRowSize);
 
+// For processing 3D textures exactly to the sizes of client buffers.
+void computePackingOffsets3D(
+        GLsizei width, GLsizei height, GLsizei depth,
+        GLenum format, GLenum type,
+        int packAlignment,
+        int packRowLength,
+        int packImageHeight,
+        int packSkipPixels,
+        int packSkipRows,
+        int packSkipImages,
+        int* bpp,
+        int* startOffset,
+        int* packingPixelRowSize,
+        int* packingTotalRowSize,
+        int* packingPixelImageSize,
+        int* packingTotalImageSize);
+
 } // namespace GLESTextureUtils
 #endif
diff --git a/shared/OpenglCodecCommon/GLSharedGroup.cpp b/shared/OpenglCodecCommon/GLSharedGroup.cpp
index 46d94a9..5273e4c 100755
--- a/shared/OpenglCodecCommon/GLSharedGroup.cpp
+++ b/shared/OpenglCodecCommon/GLSharedGroup.cpp
@@ -25,11 +25,13 @@
 BufferData::BufferData(GLsizeiptr size, const void* data) :
     m_size(size), m_usage(0), m_mapped(false) {
 
-    void * buffer = NULL;
+    if (size > 0) {
+        m_fixedBuffer.resize(size);
+    }
 
-    if (size>0) buffer = m_fixedBuffer.alloc(size);
-
-    if (data) memcpy(buffer, data, size);
+    if (data) {
+        memcpy(m_fixedBuffer.data(), data, size);
+    }
 }
 
 /**** ProgramData ****/
@@ -271,7 +273,7 @@
         return GL_INVALID_VALUE;
     }
 
-    memcpy((char*)buf->m_fixedBuffer.ptr() + offset, data, size);
+    memcpy(&buf->m_fixedBuffer[offset], data, size);
 
     buf->m_indexRangeCache.invalidateRange((size_t)offset, (size_t)size);
     return GL_NO_ERROR;
diff --git a/shared/OpenglCodecCommon/GLSharedGroup.h b/shared/OpenglCodecCommon/GLSharedGroup.h
index d471795..bbee27a 100755
--- a/shared/OpenglCodecCommon/GLSharedGroup.h
+++ b/shared/OpenglCodecCommon/GLSharedGroup.h
@@ -37,7 +37,6 @@
 #include <stdlib.h>
 #include "ErrorLog.h"
 #include <utils/threads.h>
-#include "FixedBuffer.h"
 #include "auto_goldfish_dma_context.h"
 #include "IndexRangeCache.h"
 #include "SmartPtr.h"
@@ -58,7 +57,7 @@
     uint64_t m_guest_paddr;
 
     // Internal bookkeeping
-    FixedBuffer m_fixedBuffer; // actual buffer is shadowed here
+    std::vector<char> m_fixedBuffer; // actual buffer is shadowed here
     IndexRangeCache m_indexRangeCache;
 
     // DMA support
diff --git a/shared/OpenglCodecCommon/auto_goldfish_dma_context.cpp b/shared/OpenglCodecCommon/auto_goldfish_dma_context.cpp
index 280262d..c638c2b 100644
--- a/shared/OpenglCodecCommon/auto_goldfish_dma_context.cpp
+++ b/shared/OpenglCodecCommon/auto_goldfish_dma_context.cpp
@@ -1,16 +1,16 @@
-/*
- * Copyright (C) 2018 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- */
+// Copyright 2018 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 "auto_goldfish_dma_context.h"
 
diff --git a/shared/OpenglCodecCommon/auto_goldfish_dma_context.h b/shared/OpenglCodecCommon/auto_goldfish_dma_context.h
index 7d97fc2..c8ee738 100644
--- a/shared/OpenglCodecCommon/auto_goldfish_dma_context.h
+++ b/shared/OpenglCodecCommon/auto_goldfish_dma_context.h
@@ -1,16 +1,16 @@
-/*
- * Copyright (C) 2018 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- */
+// Copyright 2018 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.
 
 #ifndef ANDROID_INCLUDE_HARDWARE_AUTO_GOLDFISH_DMA_CONTEXT_H
 #define ANDROID_INCLUDE_HARDWARE_AUTO_GOLDFISH_DMA_CONTEXT_H
diff --git a/shared/OpenglCodecCommon/glUtils.cpp b/shared/OpenglCodecCommon/glUtils.cpp
index 58ca392..a0ec240 100644
--- a/shared/OpenglCodecCommon/glUtils.cpp
+++ b/shared/OpenglCodecCommon/glUtils.cpp
@@ -417,8 +417,7 @@
         s = 16;
     break;
     default:
-        ERR("glUtilsParamSize: unknow param 0x%08x\n", param);
-        s = 1; // assume 1
+        s = 1; // assume 1 for everything else
     }
     return s;
 }
diff --git a/shared/OpenglCodecCommon/goldfish_dma.cpp b/shared/OpenglCodecCommon/goldfish_dma.cpp
index 4423f51..f3cefec 100644
--- a/shared/OpenglCodecCommon/goldfish_dma.cpp
+++ b/shared/OpenglCodecCommon/goldfish_dma.cpp
@@ -1,21 +1,20 @@
-/*
- * Copyright (C) 2016 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- */
+// Copyright 2016 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 "goldfish_dma.h"
 
-#define ALLOW_DEPRECATED_QEMU_PIPE_HEADERS
-#include <qemu_pipe.h>
+#include <qemu_pipe_bp.h>
 
 #if PLATFORM_SDK_VERSION < 26
 #include <cutils/log.h>
@@ -34,6 +33,7 @@
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 
 /* There is an ioctl associated with goldfish dma driver.
  * Make it conflict with ioctls that are not likely to be used
diff --git a/shared/OpenglCodecCommon/goldfish_dma.h b/shared/OpenglCodecCommon/goldfish_dma.h
index ee3df59..278e035 100644
--- a/shared/OpenglCodecCommon/goldfish_dma.h
+++ b/shared/OpenglCodecCommon/goldfish_dma.h
@@ -1,16 +1,16 @@
-/*
- * Copyright (C) 2016 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- */
+// Copyright 2016 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.
 
 #ifndef ANDROID_INCLUDE_HARDWARE_GOLDFISH_DMA_H
 #define ANDROID_INCLUDE_HARDWARE_GOLDFISH_DMA_H
diff --git a/shared/OpenglCodecCommon/gralloc_cb.h b/shared/OpenglCodecCommon/gralloc_cb.h
deleted file mode 100644
index 5fea355..0000000
--- a/shared/OpenglCodecCommon/gralloc_cb.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
-* Copyright 2011 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.
-*/
-
-#if !(defined(HOST_BUILD) || defined(ALLOW_DEPRECATED_QEMU_PIPE_HEADERS))
-#error include <gralloc_cb_bp.h> instead from libgralloc_cb.ranchu
-#endif
-
-#ifndef __GRALLOC_CB_H__
-#define __GRALLOC_CB_H__
-
-#include <cutils/native_handle.h>
-#define ALLOW_DEPRECATED_QEMU_PIPE_HEADERS
-#include "qemu_pipe.h"
-
-const uint32_t CB_HANDLE_MAGIC_MASK = 0xFFFFFFF0;
-const uint32_t CB_HANDLE_MAGIC_BASE = 0xABFABFA0;
-
-#define CB_HANDLE_NUM_INTS(nfd) \
-    ((sizeof(*this)-sizeof(native_handle_t)-nfd*sizeof(int32_t))/sizeof(int32_t))
-
-struct cb_handle_t : public native_handle_t {
-    cb_handle_t(int32_t p_bufferFd,
-                QEMU_PIPE_HANDLE p_hostHandleRefCountFd,
-                uint32_t p_magic,
-                uint32_t p_hostHandle,
-                int32_t p_usage,
-                int32_t p_width,
-                int32_t p_height,
-                int32_t p_format,
-                int32_t p_glFormat,
-                int32_t p_glType,
-                uint32_t p_bufSize,
-                void* p_bufPtr,
-                uint64_t p_mmapedOffset)
-        : bufferFd(p_bufferFd),
-          hostHandleRefCountFd(p_hostHandleRefCountFd),
-          magic(p_magic),
-          hostHandle(p_hostHandle),
-          usage(p_usage),
-          width(p_width),
-          height(p_height),
-          format(p_format),
-          glFormat(p_glFormat),
-          glType(p_glType),
-          bufferSize(p_bufSize),
-          mmapedOffsetLo(static_cast<uint32_t>(p_mmapedOffset)),
-          mmapedOffsetHi(static_cast<uint32_t>(p_mmapedOffset >> 32)),
-          lockedLeft(0),
-          lockedTop(0),
-          lockedWidth(0),
-          lockedHeight(0) {
-        version = sizeof(native_handle);
-        numFds = ((bufferFd >= 0) ? 1 : 0) + (qemu_pipe_valid(hostHandleRefCountFd) ? 1 : 0);
-        numInts = 0; // has to be overwritten in children classes
-        setBufferPtr(p_bufPtr);
-    }
-
-    void* getBufferPtr() const {
-        const uint64_t addr = (uint64_t(bufferPtrHi) << 32) | bufferPtrLo;
-        return reinterpret_cast<void*>(static_cast<uintptr_t>(addr));
-    }
-
-    void setBufferPtr(void* ptr) {
-        const uint64_t addr = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(ptr));
-        bufferPtrLo = uint32_t(addr);
-        bufferPtrHi = uint32_t(addr >> 32);
-    }
-
-    uint64_t getMmapedOffset() const {
-        return (uint64_t(mmapedOffsetHi) << 32) | mmapedOffsetLo;
-    }
-
-    uint32_t allocatedSize() const {
-        return getBufferPtr() ? bufferSize : 0;
-    }
-
-    bool isValid() const {
-        return (version == sizeof(native_handle))
-               && (magic & CB_HANDLE_MAGIC_MASK) == CB_HANDLE_MAGIC_BASE;
-    }
-
-    static cb_handle_t* from(void* p) {
-        if (!p) { return NULL; }
-        cb_handle_t* cb = static_cast<cb_handle_t*>(p);
-        return cb->isValid() ? cb : NULL;
-    }
-
-    static const cb_handle_t* from(const void* p) {
-        return from(const_cast<void*>(p));
-    }
-
-    static cb_handle_t* from_unconst(const void* p) {
-        return from(const_cast<void*>(p));
-    }
-
-    // fds
-    int32_t bufferFd;       // underlying buffer file handle
-    QEMU_PIPE_HANDLE hostHandleRefCountFd; // guest side refcounter to hostHandle
-
-    // ints
-    uint32_t magic;         // magic number in order to validate a pointer
-    uint32_t hostHandle;    // the host reference to this buffer
-    int32_t  usage;         // usage bits the buffer was created with
-    int32_t  width;         // buffer width
-    int32_t  height;        // buffer height
-    int32_t  format;        // real internal pixel format format
-    int32_t  glFormat;      // OpenGL format enum used for host h/w color buffer
-    int32_t  glType;        // OpenGL type enum used when uploading to host
-    uint32_t bufferSize;    // buffer size and location
-    uint32_t bufferPtrLo;
-    uint32_t bufferPtrHi;
-    uint32_t mmapedOffsetLo;
-    uint32_t mmapedOffsetHi;
-    int32_t  lockedLeft;    // region of buffer locked for s/w write
-    int32_t  lockedTop;
-    int32_t  lockedWidth;
-    int32_t  lockedHeight;
-};
-
-#endif //__GRALLOC_CB_H__
diff --git a/shared/OpenglCodecCommon/qemu_pipe.h b/shared/OpenglCodecCommon/qemu_pipe.h
deleted file mode 100644
index 87014f1..0000000
--- a/shared/OpenglCodecCommon/qemu_pipe.h
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#if !(defined(HOST_BUILD) || defined(ALLOW_DEPRECATED_QEMU_PIPE_HEADERS))
-#error include <qemu_pipe_bp.h> instead from libqemupipe.ranchu
-#endif
-
-#ifndef ANDROID_INCLUDE_HARDWARE_QEMU_PIPE_H
-#define ANDROID_INCLUDE_HARDWARE_QEMU_PIPE_H
-
-#include <sys/types.h>
-#include <stdint.h>
-#include <errno.h>
-
-#define QEMU_PIPE_RETRY(exp) ({ \
-    __typeof__(exp) _rc; \
-    do { \
-        _rc = (exp); \
-    } while (qemu_pipe_try_again(_rc)); \
-    _rc; })
-
-#ifdef HOST_BUILD
-
-typedef void* QEMU_PIPE_HANDLE;
-
-#define QEMU_PIPE_INVALID_HANDLE NULL
-
-QEMU_PIPE_HANDLE qemu_pipe_open(const char* pipeName);
-void qemu_pipe_close(QEMU_PIPE_HANDLE pipe);
-
-ssize_t qemu_pipe_read(QEMU_PIPE_HANDLE pipe, void* buffer, size_t len);
-ssize_t qemu_pipe_write(QEMU_PIPE_HANDLE pipe, const void* buffer, size_t len);
-
-bool qemu_pipe_try_again(int ret);
-bool qemu_pipe_valid(QEMU_PIPE_HANDLE pipe);
-
-void qemu_pipe_print_error(QEMU_PIPE_HANDLE pipe);
-
-#else
-
-typedef int QEMU_PIPE_HANDLE;
-
-#define QEMU_PIPE_INVALID_HANDLE (-1)
-
-#ifndef QEMU_PIPE_PATH
-#define QEMU_PIPE_PATH "/dev/qemu_pipe"
-#endif
-
-#if PLATFORM_SDK_VERSION < 26
-#include <cutils/log.h>
-#else
-#include <log/log.h>
-#endif
-#ifdef __ANDROID__
-#include <sys/cdefs.h>
-#endif
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <pthread.h>  /* for pthread_once() */
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#ifndef D
-#  define  D(...)   do{}while(0)
-#endif
-
-/* Try to open a new Qemu fast-pipe. This function returns a file descriptor
- * that can be used to communicate with a named service managed by the
- * emulator.
- *
- * This file descriptor can be used as a standard pipe/socket descriptor.
- *
- * 'pipeName' is the name of the emulator service you want to connect to.
- * E.g. 'opengles' or 'camera'.
- *
- * On success, return a valid file descriptor
- * Returns -1 on error, and errno gives the error code, e.g.:
- *
- *    EINVAL  -> unknown/unsupported pipeName
- *    ENOSYS  -> fast pipes not available in this system.
- *
- * ENOSYS should never happen, except if you're trying to run within a
- * misconfigured emulator.
- *
- * You should be able to open several pipes to the same pipe service,
- * except for a few special cases (e.g. GSM modem), where EBUSY will be
- * returned if more than one client tries to connect to it.
- */
-
-static __inline__ bool
-qemu_pipe_try_again(int ret) {
-    return (ret < 0) && (errno == EINTR || errno == EAGAIN);
-}
-
-static __inline__ ssize_t
-qemu_pipe_write_fully(QEMU_PIPE_HANDLE pipe, const void* buffer, ssize_t len);
-
-static __inline__ QEMU_PIPE_HANDLE
-qemu_pipe_open_ns(const char* ns, const char* pipeName, int flags) {
-    char  buff[256];
-    int   buffLen;
-    QEMU_PIPE_HANDLE   fd;
-
-    if (pipeName == NULL || pipeName[0] == '\0') {
-        errno = EINVAL;
-        return -1;
-    }
-
-    if (ns) {
-        buffLen = snprintf(buff, sizeof(buff), "pipe:%s:%s", ns, pipeName);
-    } else {
-        buffLen = snprintf(buff, sizeof(buff), "pipe:%s", pipeName);
-    }
-
-    fd = QEMU_PIPE_RETRY(open(QEMU_PIPE_PATH, flags));
-    if (fd < 0 && errno == ENOENT) {
-        fd = QEMU_PIPE_RETRY(open("/dev/goldfish_pipe", flags));
-    }
-    if (fd < 0) {
-        D("%s: Could not open " QEMU_PIPE_PATH ": %s", __FUNCTION__, strerror(errno));
-        //errno = ENOSYS;
-        return -1;
-    }
-
-    if (qemu_pipe_write_fully(fd, buff, buffLen + 1)) {
-        D("%s: Could not connect to %s pipe service: %s", __FUNCTION__, pipeName, strerror(errno));
-        return -1;
-    }
-
-    return fd;
-}
-
-static __inline__ QEMU_PIPE_HANDLE
-qemu_pipe_open(const char* pipeName) {
-    return qemu_pipe_open_ns(NULL, pipeName, O_RDWR | O_NONBLOCK);
-}
-
-static __inline__ void
-qemu_pipe_close(QEMU_PIPE_HANDLE pipe) {
-    close(pipe);
-}
-
-static __inline__ ssize_t
-qemu_pipe_read(QEMU_PIPE_HANDLE pipe, void* buffer, size_t len) {
-    return read(pipe, buffer, len);
-}
-
-static __inline__ ssize_t
-qemu_pipe_write(QEMU_PIPE_HANDLE pipe, const void* buffer, size_t len) {
-    return write(pipe, buffer, len);
-}
-
-static __inline__ bool
-qemu_pipe_valid(QEMU_PIPE_HANDLE pipe) {
-    return pipe >= 0;
-}
-
-static __inline__ void
-qemu_pipe_print_error(QEMU_PIPE_HANDLE pipe) {
-    ALOGE("pipe error: fd %d errno %d", pipe, errno);
-}
-
-
-#endif // !HOST_BUILD
-
-static __inline__ ssize_t
-qemu_pipe_read_fully(QEMU_PIPE_HANDLE pipe, void* buffer, ssize_t len) {
-    char* p = (char*)buffer;
-
-    while (len > 0) {
-      ssize_t n = QEMU_PIPE_RETRY(qemu_pipe_read(pipe, p, len));
-      if (n < 0) return n;
-
-      p += n;
-      len -= n;
-    }
-
-    return 0;
-}
-
-static __inline__ ssize_t
-qemu_pipe_write_fully(QEMU_PIPE_HANDLE pipe, const void* buffer, ssize_t len) {
-    const char* p = (const char*)buffer;
-
-    while (len > 0) {
-      ssize_t n = QEMU_PIPE_RETRY(qemu_pipe_write(pipe, p, len));
-      if (n < 0) return n;
-
-      p += n;
-      len -= n;
-    }
-
-    return 0;
-}
-
-#endif /* ANDROID_INCLUDE_HARDWARE_QEMU_PIPE_H */
diff --git a/shared/gralloc_cb/Android.mk b/shared/gralloc_cb/Android.mk
new file mode 100644
index 0000000..9c1f038
--- /dev/null
+++ b/shared/gralloc_cb/Android.mk
@@ -0,0 +1,10 @@
+ifeq (true,$(GOLDFISH_OPENGL_BUILD_FOR_HOST))
+
+LOCAL_PATH := $(call my-dir)
+
+$(call emugl-begin-static-library,libgralloc_cb$(GOLDFISH_OPENGL_LIB_SUFFIX))
+LOCAL_SRC_FILES := empty.cpp
+$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)/include)
+$(call emugl-end-module)
+
+endif
diff --git a/shared/gralloc_cb/CMakeLists.txt b/shared/gralloc_cb/CMakeLists.txt
new file mode 100644
index 0000000..f9e7b71
--- /dev/null
+++ b/shared/gralloc_cb/CMakeLists.txt
@@ -0,0 +1,10 @@
+# This is an autogenerated file! Do not edit!
+# instead run make from .../device/generic/goldfish-opengl
+# which will re-generate this file.
+android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/shared/gralloc_cb/Android.mk" "8d9adf5ce35036abff985952ba984a3fcefcc2156ff36facfe51ba7d7adaab9d")
+set(gralloc_cb_host_src empty.cpp)
+android_add_library(TARGET gralloc_cb_host LICENSE Apache-2.0 SRC empty.cpp)
+target_include_directories(gralloc_cb_host PRIVATE ${GOLDFISH_DEVICE_ROOT}/shared/gralloc_cb/include ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
+target_compile_definitions(gralloc_cb_host PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DGOLDFISH_VULKAN")
+target_compile_options(gralloc_cb_host PRIVATE "-fvisibility=default" "-Wno-unused-parameter")
+target_link_libraries(gralloc_cb_host PRIVATE android-emu-shared)
\ No newline at end of file
diff --git a/shared/gralloc_cb/empty.cpp b/shared/gralloc_cb/empty.cpp
new file mode 100644
index 0000000..40a8c17
--- /dev/null
+++ b/shared/gralloc_cb/empty.cpp
@@ -0,0 +1 @@
+/* empty */
diff --git a/shared/qemupipe/Android.bp b/shared/qemupipe/Android.bp
index ba8de3b..fe72943 100644
--- a/shared/qemupipe/Android.bp
+++ b/shared/qemupipe/Android.bp
@@ -23,7 +23,10 @@
 cc_library {
     name: "libqemupipe.ranchu",
     vendor_available: true,
-    srcs: ["qemu_pipe.cpp"],
+    srcs: [
+        "qemu_pipe_common.cpp",
+        "qemu_pipe_guest.cpp",
+    ],
     header_libs: ["libqemupipe-types.ranchu"],
     export_header_lib_headers: ["libqemupipe-types.ranchu"],
     shared_libs: ["liblog"],
diff --git a/shared/qemupipe/Android.mk b/shared/qemupipe/Android.mk
new file mode 100644
index 0000000..f665982
--- /dev/null
+++ b/shared/qemupipe/Android.mk
@@ -0,0 +1,16 @@
+ifeq (true,$(GOLDFISH_OPENGL_BUILD_FOR_HOST))
+
+LOCAL_PATH := $(call my-dir)
+
+$(call emugl-begin-static-library,libqemupipe$(GOLDFISH_OPENGL_LIB_SUFFIX))
+
+LOCAL_SRC_FILES := \
+    qemu_pipe_common.cpp \
+    qemu_pipe_host.cpp
+
+$(call emugl-export,SHARED_LIBRARIES,android-emu-shared)
+$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)/include-types)
+$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)/include)
+$(call emugl-end-module)
+
+endif
diff --git a/shared/qemupipe/CMakeLists.txt b/shared/qemupipe/CMakeLists.txt
new file mode 100644
index 0000000..2229681
--- /dev/null
+++ b/shared/qemupipe/CMakeLists.txt
@@ -0,0 +1,10 @@
+# This is an autogenerated file! Do not edit!
+# instead run make from .../device/generic/goldfish-opengl
+# which will re-generate this file.
+android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/Android.mk" "8554a162304f69cc357d5e35cf614ca278135bf4cea3431da69a08b9af234777")
+set(qemupipe_host_src qemu_pipe_common.cpp qemu_pipe_host.cpp)
+android_add_library(TARGET qemupipe_host LICENSE Apache-2.0 SRC qemu_pipe_common.cpp qemu_pipe_host.cpp)
+target_include_directories(qemupipe_host PRIVATE ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include-types ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
+target_compile_definitions(qemupipe_host PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DGOLDFISH_VULKAN")
+target_compile_options(qemupipe_host PRIVATE "-fvisibility=default" "-Wno-unused-parameter")
+target_link_libraries(qemupipe_host PRIVATE android-emu-shared)
\ No newline at end of file
diff --git a/shared/qemupipe/qemu_pipe_common.cpp b/shared/qemupipe/qemu_pipe_common.cpp
new file mode 100644
index 0000000..859bd3f
--- /dev/null
+++ b/shared/qemupipe/qemu_pipe_common.cpp
@@ -0,0 +1,43 @@
+// Copyright 2018 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 <qemu_pipe_bp.h>
+
+int qemu_pipe_read_fully(QEMU_PIPE_HANDLE pipe, void* buffer, int size) {
+    char* p = (char*)buffer;
+
+    while (size > 0) {
+      int n = QEMU_PIPE_RETRY(qemu_pipe_read(pipe, p, size));
+      if (n < 0) return n;
+
+      p += n;
+      size -= n;
+    }
+
+    return 0;
+}
+
+int qemu_pipe_write_fully(QEMU_PIPE_HANDLE pipe, const void* buffer, int size) {
+    const char* p = (const char*)buffer;
+
+    while (size > 0) {
+      int n = QEMU_PIPE_RETRY(qemu_pipe_write(pipe, p, size));
+      if (n < 0) return n;
+
+      p += n;
+      size -= n;
+    }
+
+    return 0;
+}
diff --git a/shared/qemupipe/qemu_pipe.cpp b/shared/qemupipe/qemu_pipe_guest.cpp
similarity index 81%
rename from shared/qemupipe/qemu_pipe.cpp
rename to shared/qemupipe/qemu_pipe_guest.cpp
index 6a07796..1732a51 100644
--- a/shared/qemupipe/qemu_pipe.cpp
+++ b/shared/qemupipe/qemu_pipe_guest.cpp
@@ -74,34 +74,6 @@
     close(pipe);
 }
 
-int qemu_pipe_read_fully(int pipe, void* buffer, int size) {
-    char* p = (char*)buffer;
-
-    while (size > 0) {
-      int n = QEMU_PIPE_RETRY(qemu_pipe_read(pipe, p, size));
-      if (n < 0) return n;
-
-      p += n;
-      size -= n;
-    }
-
-    return 0;
-}
-
-int qemu_pipe_write_fully(int pipe, const void* buffer, int size) {
-    const char* p = (const char*)buffer;
-
-    while (size > 0) {
-      int n = QEMU_PIPE_RETRY(qemu_pipe_write(pipe, p, size));
-      if (n < 0) return n;
-
-      p += n;
-      size -= n;
-    }
-
-    return 0;
-}
-
 int qemu_pipe_read(int pipe, void* buffer, int size) {
     return read(pipe, buffer, size);
 }
diff --git a/shared/OpenglCodecCommon/qemu_pipe_host.cpp b/shared/qemupipe/qemu_pipe_host.cpp
similarity index 83%
rename from shared/OpenglCodecCommon/qemu_pipe_host.cpp
rename to shared/qemupipe/qemu_pipe_host.cpp
index 76e3c92..38f2f63 100644
--- a/shared/OpenglCodecCommon/qemu_pipe_host.cpp
+++ b/shared/qemupipe/qemu_pipe_host.cpp
@@ -11,7 +11,8 @@
 // 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 "qemu_pipe.h"
+
+#include <qemu_pipe_bp.h>
 
 #include "android/emulation/hostdevices/HostGoldfishPipe.h"
 
@@ -33,15 +34,15 @@
     HostGoldfishPipeDevice::get()->close(pipe);
 }
 
-ssize_t qemu_pipe_read(QEMU_PIPE_HANDLE pipe, void* buffer, size_t len) {
+int qemu_pipe_read(QEMU_PIPE_HANDLE pipe, void* buffer, int len) {
     return HostGoldfishPipeDevice::get()->read(pipe, buffer, len);
 }
 
-ssize_t qemu_pipe_write(QEMU_PIPE_HANDLE pipe, const void* buffer, size_t len) {
+int qemu_pipe_write(QEMU_PIPE_HANDLE pipe, const void* buffer, int len) {
     return HostGoldfishPipeDevice::get()->write(pipe, buffer, len);
 }
 
-bool qemu_pipe_try_again(int ret) {
+int qemu_pipe_try_again(int ret) {
     if (ret < 0) {
         int err = HostGoldfishPipeDevice::get()->getErrno();
         return err == EINTR || err == EAGAIN;
@@ -50,10 +51,6 @@
     }
 }
 
-bool qemu_pipe_valid(QEMU_PIPE_HANDLE pipe) {
-    return pipe != NULL;
-}
-
 void qemu_pipe_print_error(QEMU_PIPE_HANDLE pipe) {
     int err = HostGoldfishPipeDevice::get()->getErrno();
     ALOGE("pipe error: pipe %p err %d", pipe, err);
diff --git a/system/GLESv1/CMakeLists.txt b/system/GLESv1/CMakeLists.txt
index a8dc669..5436e5f 100644
--- a/system/GLESv1/CMakeLists.txt
+++ b/system/GLESv1/CMakeLists.txt
@@ -4,7 +4,7 @@
 android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/GLESv1/Android.mk" "e095cb082e3791719749cfc80b90560afd7348eb0d7895449d2509aa129bea75")
 set(GLESv1_CM_emulation_src gl.cpp)
 android_add_library(TARGET GLESv1_CM_emulation SHARED LICENSE Apache-2.0 SRC gl.cpp)
-target_include_directories(GLESv1_CM_emulation PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon/bionic-include ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/bionic/libc/platform ${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
+target_include_directories(GLESv1_CM_emulation PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon/bionic-include ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/bionic/libc/platform ${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/shared/gralloc_cb/include ${GOLDFISH_DEVICE_ROOT}/shared/GoldfishAddressSpace/include ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include-types ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
 target_compile_definitions(GLESv1_CM_emulation PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DGOLDFISH_VULKAN" "-DLOG_TAG=\"GLES_emulation\"")
 target_compile_options(GLESv1_CM_emulation PRIVATE "-fvisibility=default" "-Wno-unused-parameter")
-target_link_libraries(GLESv1_CM_emulation PRIVATE OpenglSystemCommon android-emu-shared vulkan_enc gui androidemu cutils utils log _renderControl_enc GLESv2_enc GLESv1_enc OpenglCodecCommon_host)
\ No newline at end of file
+target_link_libraries(GLESv1_CM_emulation PRIVATE OpenglSystemCommon android-emu-shared vulkan_enc gui androidemu cutils utils log _renderControl_enc GLESv2_enc GLESv1_enc OpenglCodecCommon_host PRIVATE gralloc_cb_host GoldfishAddressSpace_host qemupipe_host)
\ No newline at end of file
diff --git a/system/GLESv1_enc/CMakeLists.txt b/system/GLESv1_enc/CMakeLists.txt
index 8acc4ff..0a9bc52 100644
--- a/system/GLESv1_enc/CMakeLists.txt
+++ b/system/GLESv1_enc/CMakeLists.txt
@@ -4,7 +4,7 @@
 android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc/Android.mk" "953e6b7371d10eed63a4be555f8f1fb6f347338484a78102fa8f55dff96f5d3b")
 set(GLESv1_enc_src GLEncoder.cpp GLEncoderUtils.cpp gl_client_context.cpp gl_enc.cpp gl_entry.cpp)
 android_add_library(TARGET GLESv1_enc SHARED LICENSE Apache-2.0 SRC GLEncoder.cpp GLEncoderUtils.cpp gl_client_context.cpp gl_enc.cpp gl_entry.cpp)
-target_include_directories(GLESv1_enc PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
+target_include_directories(GLESv1_enc PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include-types ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
 target_compile_definitions(GLESv1_enc PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DGOLDFISH_VULKAN" "-DLOG_TAG=\"emuglGLESv1_enc\"")
 target_compile_options(GLESv1_enc PRIVATE "-fvisibility=default" "-Wno-unused-parameter")
-target_link_libraries(GLESv1_enc PRIVATE OpenglCodecCommon_host cutils utils log android-emu-shared)
\ No newline at end of file
+target_link_libraries(GLESv1_enc PRIVATE OpenglCodecCommon_host cutils utils log android-emu-shared PRIVATE qemupipe_host)
\ No newline at end of file
diff --git a/system/GLESv1_enc/GLEncoder.cpp b/system/GLESv1_enc/GLEncoder.cpp
index 1fa0dac..20f2c02 100644
--- a/system/GLESv1_enc/GLEncoder.cpp
+++ b/system/GLESv1_enc/GLEncoder.cpp
@@ -15,15 +15,9 @@
 */
 #include "GLEncoder.h"
 #include "glUtils.h"
-#include "FixedBuffer.h"
-
-#if PLATFORM_SDK_VERSION < 26
-#include <cutils/log.h>
-#else
 #include <log/log.h>
-#endif
-
 #include <assert.h>
+#include <vector>
 
 #ifndef MIN
 #define MIN(a, b) ((a) < (b) ? (a) : (b))
@@ -584,7 +578,7 @@
         } else {
             BufferData * buf = ctx->m_shared->getBufferData(ctx->m_state->currentIndexVbo());
             ctx->m_glBindBuffer_enc(self, GL_ELEMENT_ARRAY_BUFFER, 0);
-            indices = (void*)((GLintptr)buf->m_fixedBuffer.ptr() + (GLintptr)indices);
+            indices = &buf->m_fixedBuffer[(GLintptr)indices];
         }
     }
     if (adjustIndices) {
@@ -596,7 +590,8 @@
         case GL_UNSIGNED_BYTE:
             GLUtils::minmax<unsigned char>((unsigned char *)indices, count, &minIndex, &maxIndex);
             if (minIndex != 0) {
-                adjustedIndices =  ctx->m_fixedBuffer.alloc(glSizeof(type) * count);
+                ctx->m_fixedBuffer.resize(glSizeof(type) * count);
+                adjustedIndices = ctx->m_fixedBuffer.data();
                 GLUtils::shiftIndices<unsigned char>((unsigned char *)indices,
                                                  (unsigned char *)adjustedIndices,
                                                  count, -minIndex);
@@ -606,7 +601,8 @@
         case GL_UNSIGNED_SHORT:
             GLUtils::minmax<unsigned short>((unsigned short *)indices, count, &minIndex, &maxIndex);
             if (minIndex != 0) {
-                adjustedIndices = ctx->m_fixedBuffer.alloc(glSizeof(type) * count);
+                ctx->m_fixedBuffer.resize(glSizeof(type) * count);
+                adjustedIndices = ctx->m_fixedBuffer.data();
                 GLUtils::shiftIndices<unsigned short>((unsigned short *)indices,
                                                  (unsigned short *)adjustedIndices,
                                                  count, -minIndex);
@@ -616,7 +612,8 @@
         case GL_UNSIGNED_INT:
             GLUtils::minmax<unsigned int>((unsigned int *)indices, count, &minIndex, &maxIndex);
             if (minIndex != 0) {
-                adjustedIndices = ctx->m_fixedBuffer.alloc(glSizeof(type) * count);
+                ctx->m_fixedBuffer.resize(glSizeof(type) * count);
+                adjustedIndices = ctx->m_fixedBuffer.data();
                 GLUtils::shiftIndices<unsigned int>((unsigned int *)indices,
                                                  (unsigned int *)adjustedIndices,
                                                  count, -minIndex);
diff --git a/system/GLESv1_enc/GLEncoder.h b/system/GLESv1_enc/GLEncoder.h
index 95537a2..a26636c 100644
--- a/system/GLESv1_enc/GLEncoder.h
+++ b/system/GLESv1_enc/GLEncoder.h
@@ -16,10 +16,11 @@
 #ifndef _GL_ENCODER_H_
 #define _GL_ENCODER_H_
 
+#include <vector>
+
 #include "gl_enc.h"
 #include "GLClientState.h"
 #include "GLSharedGroup.h"
-#include "FixedBuffer.h"
 #include "ChecksumCalculator.h"
 
 class GLEncoder : public gl_encoder_context_t {
@@ -53,7 +54,7 @@
     GLClientState *m_state;
     GLSharedGroupPtr m_shared;
     GLenum  m_error;
-    FixedBuffer m_fixedBuffer;
+    std::vector<char> m_fixedBuffer;
     GLint *m_compressedTextureFormats;
     GLint m_num_compressedTextureFormats;
 
diff --git a/system/GLESv2/CMakeLists.txt b/system/GLESv2/CMakeLists.txt
index e2f5f4e..d90502a 100644
--- a/system/GLESv2/CMakeLists.txt
+++ b/system/GLESv2/CMakeLists.txt
@@ -4,7 +4,7 @@
 android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/GLESv2/Android.mk" "d8f9dda69ec57ad8b7a65f02c3335b16a4724f612dec1d1a2cd793c28c0a10f9")
 set(GLESv2_emulation_src gl2.cpp)
 android_add_library(TARGET GLESv2_emulation SHARED LICENSE Apache-2.0 SRC gl2.cpp)
-target_include_directories(GLESv2_emulation PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon/bionic-include ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/bionic/libc/platform ${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
+target_include_directories(GLESv2_emulation PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon/bionic-include ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/bionic/libc/platform ${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/shared/gralloc_cb/include ${GOLDFISH_DEVICE_ROOT}/shared/GoldfishAddressSpace/include ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include-types ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
 target_compile_definitions(GLESv2_emulation PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DGOLDFISH_VULKAN" "-DLOG_TAG=\"GLESv2_emulation\"")
 target_compile_options(GLESv2_emulation PRIVATE "-fvisibility=default" "-Wno-unused-parameter")
-target_link_libraries(GLESv2_emulation PRIVATE OpenglSystemCommon android-emu-shared vulkan_enc gui androidemu cutils utils log _renderControl_enc GLESv2_enc GLESv1_enc OpenglCodecCommon_host)
\ No newline at end of file
+target_link_libraries(GLESv2_emulation PRIVATE OpenglSystemCommon android-emu-shared vulkan_enc gui androidemu cutils utils log _renderControl_enc GLESv2_enc GLESv1_enc OpenglCodecCommon_host PRIVATE gralloc_cb_host GoldfishAddressSpace_host qemupipe_host)
\ No newline at end of file
diff --git a/system/GLESv2_enc/Android.mk b/system/GLESv2_enc/Android.mk
index af95736..40acfc5 100644
--- a/system/GLESv2_enc/Android.mk
+++ b/system/GLESv2_enc/Android.mk
@@ -10,7 +10,7 @@
     gl2_client_context.cpp \
     gl2_enc.cpp \
     gl2_entry.cpp \
-    ../enc_common/IOStream_common.cpp \
+    IOStream2.cpp \
 
 LOCAL_CFLAGS += -DLOG_TAG=\"emuglGLESv2_enc\"
 LOCAL_CFLAGS += -Wno-unused-private-field
diff --git a/system/GLESv2_enc/CMakeLists.txt b/system/GLESv2_enc/CMakeLists.txt
index 72afa76..39a479f 100644
--- a/system/GLESv2_enc/CMakeLists.txt
+++ b/system/GLESv2_enc/CMakeLists.txt
@@ -1,10 +1,10 @@
 # This is an autogenerated file! Do not edit!
 # instead run make from .../device/generic/goldfish-opengl
 # which will re-generate this file.
-android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc/Android.mk" "d4fc971ccdbafbf971253b27bbc2168682b2994476079f4f81fb7a33c27070e0")
-set(GLESv2_enc_src GL2EncoderUtils.cpp GL2Encoder.cpp GLESv2Validation.cpp gl2_client_context.cpp gl2_enc.cpp gl2_entry.cpp ../enc_common/IOStream_common.cpp)
-android_add_library(TARGET GLESv2_enc SHARED LICENSE Apache-2.0 SRC GL2EncoderUtils.cpp GL2Encoder.cpp GLESv2Validation.cpp gl2_client_context.cpp gl2_enc.cpp gl2_entry.cpp ../enc_common/IOStream_common.cpp)
-target_include_directories(GLESv2_enc PRIVATE ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
+android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc/Android.mk" "df543672d1f36e43fb783b08200aa85dbf3a2e7167f8ecd7e4c01c80e6fd1650")
+set(GLESv2_enc_src GL2EncoderUtils.cpp GL2Encoder.cpp GLESv2Validation.cpp gl2_client_context.cpp gl2_enc.cpp gl2_entry.cpp IOStream2.cpp)
+android_add_library(TARGET GLESv2_enc SHARED LICENSE Apache-2.0 SRC GL2EncoderUtils.cpp GL2Encoder.cpp GLESv2Validation.cpp gl2_client_context.cpp gl2_enc.cpp gl2_entry.cpp IOStream2.cpp)
+target_include_directories(GLESv2_enc PRIVATE ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include-types ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
 target_compile_definitions(GLESv2_enc PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DGOLDFISH_VULKAN" "-DLOG_TAG=\"emuglGLESv2_enc\"")
 target_compile_options(GLESv2_enc PRIVATE "-fvisibility=default" "-Wno-unused-parameter" "-Wno-unused-private-field")
-target_link_libraries(GLESv2_enc PRIVATE OpenglCodecCommon_host cutils utils log android-emu-shared)
\ No newline at end of file
+target_link_libraries(GLESv2_enc PRIVATE OpenglCodecCommon_host cutils utils log android-emu-shared PRIVATE qemupipe_host)
\ No newline at end of file
diff --git a/system/GLESv2_enc/GL2Encoder.cpp b/system/GLESv2_enc/GL2Encoder.cpp
index cc009a9..bafd1b6 100755
--- a/system/GLESv2_enc/GL2Encoder.cpp
+++ b/system/GLESv2_enc/GL2Encoder.cpp
@@ -372,6 +372,9 @@
     OVERRIDE_CUSTOM(glReadnPixelsEXT);
     OVERRIDE_CUSTOM(glGetnUniformfvEXT);
     OVERRIDE_CUSTOM(glGetnUniformivEXT);
+
+    OVERRIDE(glInvalidateFramebuffer);
+    OVERRIDE(glInvalidateSubFramebuffer);
 }
 
 GL2Encoder::~GL2Encoder()
@@ -1119,7 +1122,8 @@
     void* adjustedIndices = (void*)src;
 
     if (minIndex != 0) {
-        adjustedIndices = m_fixedBuffer.alloc(glSizeof(type) * count);
+        m_fixedBuffer.resize(glSizeof(type) * count);
+        adjustedIndices = m_fixedBuffer.data();
         switch(type) {
         case GL_BYTE:
         case GL_UNSIGNED_BYTE:
@@ -1371,7 +1375,7 @@
     if (ctx->m_state->currentIndexVbo() != 0) {
         buf = ctx->m_shared->getBufferData(ctx->m_state->currentIndexVbo());
         offset = (GLintptr)indices;
-        indices = (void*)((GLintptr)buf->m_fixedBuffer.ptr() + (GLintptr)indices);
+        indices = &buf->m_fixedBuffer[offset];
         ctx->getBufferIndexRange(buf,
                                  indices,
                                  type,
@@ -1486,7 +1490,7 @@
         } else {
             buf = ctx->m_shared->getBufferData(ctx->m_state->currentIndexVbo());
             offset = (GLintptr)indices;
-            indices = (void*)((GLintptr)buf->m_fixedBuffer.ptr() + (GLintptr)indices);
+            indices = &buf->m_fixedBuffer[offset];
             ctx->getBufferIndexRange(buf,
                                      indices,
                                      type,
@@ -1901,7 +1905,10 @@
                 break;
             }
         }
-        memcpy(source, returned.substr(0, bufsize - 1).c_str(), bufsize);
+        std::string ret = returned.substr(0, bufsize - 1);
+
+        size_t toCopy = bufsize < (ret.size() + 1) ? bufsize : ret.size() + 1;
+        memcpy(source, ret.c_str(), toCopy);
     }
 }
 
@@ -2937,7 +2944,7 @@
 void* GL2Encoder::s_glMapBufferRangeAEMUImpl(GL2Encoder* ctx, GLenum target,
                                              GLintptr offset, GLsizeiptr length,
                                              GLbitfield access, BufferData* buf) {
-    char* bits = (char*)buf->m_fixedBuffer.ptr() + offset;
+    char* bits = &buf->m_fixedBuffer[offset];
 
     if ((access & GL_MAP_READ_BIT) ||
         ((access & GL_MAP_WRITE_BIT) &&
@@ -3048,7 +3055,7 @@
     GLboolean host_res = GL_TRUE;
 
     if (buf->dma_buffer.get().mapped_addr) {
-        memcpy(static_cast<char*>(buf->m_fixedBuffer.ptr()) + buf->m_mappedOffset,
+        memcpy(&buf->m_fixedBuffer[buf->m_mappedOffset],
                reinterpret_cast<void*>(buf->dma_buffer.get().mapped_addr),
                buf->m_mappedLength);
 
@@ -3066,7 +3073,7 @@
                     buf->m_mappedOffset,
                     buf->m_mappedLength,
                     buf->m_mappedAccess,
-                    (void*)((char*)buf->m_fixedBuffer.ptr() + buf->m_mappedOffset),
+                    &buf->m_fixedBuffer[buf->m_mappedOffset],
                     &host_res);
         } else {
             if (buf->m_mappedAccess & GL_MAP_WRITE_BIT) {
@@ -3075,7 +3082,7 @@
                         buf->m_mappedOffset,
                         buf->m_mappedLength,
                         buf->m_mappedAccess,
-                        (void*)((char*)buf->m_fixedBuffer.ptr() + buf->m_mappedOffset),
+                        &buf->m_fixedBuffer[buf->m_mappedOffset],
                         &host_res);
             }
         }
@@ -3116,14 +3123,14 @@
                 totalOffset,
                 length,
                 buf->m_mappedAccess,
-                (void*)((char*)buf->m_fixedBuffer.ptr() + totalOffset));
+                &buf->m_fixedBuffer[totalOffset]);
     } else {
         ctx->glFlushMappedBufferRangeAEMU(
                 ctx, target,
                 totalOffset,
                 length,
                 buf->m_mappedAccess,
-                (void*)((char*)buf->m_fixedBuffer.ptr() + totalOffset));
+                &buf->m_fixedBuffer[totalOffset]);
     }
 }
 
@@ -3482,7 +3489,7 @@
 
     if (!buf || !buf->m_mapped) { *params = NULL; return; }
 
-    *params = (GLvoid*)((char*)buf->m_fixedBuffer.ptr() + buf->m_mappedOffset);
+    *params = &buf->m_fixedBuffer[buf->m_mappedOffset];
 }
 
 static const char* const kNameDelimiter = ";";
@@ -4122,6 +4129,7 @@
     assert(ctx->m_state != NULL);
     SET_ERROR_IF(!isValidDrawMode(mode), GL_INVALID_ENUM);
     SET_ERROR_IF(count < 0, GL_INVALID_VALUE);
+    SET_ERROR_IF(primcount < 0, GL_INVALID_VALUE);
 
     bool has_client_vertex_arrays = false;
     bool has_indirect_arrays = false;
@@ -4147,6 +4155,7 @@
     assert(ctx->m_state != NULL);
     SET_ERROR_IF(!isValidDrawMode(mode), GL_INVALID_ENUM);
     SET_ERROR_IF(count < 0, GL_INVALID_VALUE);
+    SET_ERROR_IF(primcount < 0, GL_INVALID_VALUE);
     SET_ERROR_IF(!(type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_SHORT || type == GL_UNSIGNED_INT), GL_INVALID_ENUM);
     SET_ERROR_IF(ctx->m_state->getTransformFeedbackActiveUnpaused(), GL_INVALID_OPERATION);
 
@@ -4174,7 +4183,7 @@
     if (ctx->m_state->currentIndexVbo() != 0) {
         buf = ctx->m_shared->getBufferData(ctx->m_state->currentIndexVbo());
         offset = (GLintptr)indices;
-        indices = (void*)((GLintptr)buf->m_fixedBuffer.ptr() + (GLintptr)indices);
+        indices = &buf->m_fixedBuffer[offset];
         ctx->getBufferIndexRange(buf,
                                  indices,
                                  type,
@@ -4264,13 +4273,13 @@
     // caching previous results.
     if (ctx->m_state->currentIndexVbo() != 0) {
         buf = ctx->m_shared->getBufferData(ctx->m_state->currentIndexVbo());
-        ALOGV("%s: current index vbo: %p len %zu count %zu\n", __func__, buf, (size_t)buf->m_fixedBuffer.len(), (size_t)count);
+        ALOGV("%s: current index vbo: %p len %zu count %zu\n", __func__, buf, buf->m_fixedBuffer.size(), (size_t)count);
         offset = (GLintptr)indices;
         void* oldIndices = (void*)indices;
-        indices = (void*)((GLintptr)buf->m_fixedBuffer.ptr() + (GLintptr)indices);
+        indices = &buf->m_fixedBuffer[offset];
         ALOGV("%s: indices arg: %p buffer start: %p indices: %p\n", __func__,
                 (void*)(uintptr_t)(oldIndices),
-                buf->m_fixedBuffer.ptr(),
+                buf->m_fixedBuffer.data(),
                 indices);
         ctx->getBufferIndexRange(buf,
                                  indices,
@@ -5435,3 +5444,17 @@
         location)), GL_INVALID_OPERATION);
     s_glGetUniformiv(self, program, location, params);
 }
+
+void GL2Encoder::s_glInvalidateFramebuffer(void* self, GLenum target, GLsizei numAttachments, const GLenum *attachments) {
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    SET_ERROR_IF(numAttachments < 0, GL_INVALID_VALUE);
+    ctx->m_glInvalidateFramebuffer_enc(ctx, target, numAttachments, attachments);
+}
+
+void GL2Encoder::s_glInvalidateSubFramebuffer(void* self, GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height) {
+    GL2Encoder *ctx = (GL2Encoder*)self;
+    SET_ERROR_IF(numAttachments < 0, GL_INVALID_VALUE);
+    SET_ERROR_IF(width < 0, GL_INVALID_VALUE);
+    SET_ERROR_IF(height < 0, GL_INVALID_VALUE);
+    ctx->m_glInvalidateSubFramebuffer_enc(ctx, target, numAttachments, attachments, x, y, width, height);
+}
diff --git a/system/GLESv2_enc/GL2Encoder.h b/system/GLESv2_enc/GL2Encoder.h
index d016898..0ceb9de 100644
--- a/system/GLESv2_enc/GL2Encoder.h
+++ b/system/GLESv2_enc/GL2Encoder.h
@@ -16,10 +16,11 @@
 #ifndef _GL2_ENCODER_H_
 #define _GL2_ENCODER_H_
 
+#include <vector>
+
 #include "gl2_enc.h"
 #include "GLClientState.h"
 #include "GLSharedGroup.h"
-#include "FixedBuffer.h"
 
 #include <string>
 #include <vector>
@@ -136,7 +137,7 @@
     GLuint m_ssbo_offset_align;
     GLuint m_ubo_offset_align;
 
-    FixedBuffer m_fixedBuffer;
+    std::vector<char> m_fixedBuffer;
 
     uint32_t m_drawCallFlushInterval;
     uint32_t m_drawCallFlushCount;
@@ -760,6 +761,14 @@
             GLsizei bufSize, GLfloat* params);
     static void s_glGetnUniformivEXT(void *self, GLuint program, GLint location,
             GLsizei bufSize, GLint* params);
+
+    // Invalidate framebuffer
+    static void s_glInvalidateFramebuffer(void* self, GLenum target, GLsizei numAttachments, const GLenum *attachments);
+    static void s_glInvalidateSubFramebuffer(void* self, GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height);
+
+    glInvalidateFramebuffer_client_proc_t m_glInvalidateFramebuffer_enc;
+    glInvalidateSubFramebuffer_client_proc_t m_glInvalidateSubFramebuffer_enc;;
+
 public:
     glEGLImageTargetTexture2DOES_client_proc_t m_glEGLImageTargetTexture2DOES_enc;
 
diff --git a/system/GLESv2_enc/IOStream2.cpp b/system/GLESv2_enc/IOStream2.cpp
new file mode 100644
index 0000000..4890852
--- /dev/null
+++ b/system/GLESv2_enc/IOStream2.cpp
@@ -0,0 +1,225 @@
+#include "IOStream.h"
+
+#include "GL2Encoder.h"
+
+#include <GLES3/gl31.h>
+
+#include <vector>
+
+#include <assert.h>
+
+void IOStream::readbackPixels(void* context, int width, int height, unsigned int format, unsigned int type, void* pixels) {
+    GL2Encoder *ctx = (GL2Encoder *)context;
+    assert (ctx->state() != NULL);
+
+    int bpp = 0;
+    int startOffset = 0;
+    int pixelRowSize = 0;
+    int totalRowSize = 0;
+    int skipRows = 0;
+
+    ctx->state()->getPackingOffsets2D(width, height, format, type,
+                                      &bpp,
+                                      &startOffset,
+                                      &pixelRowSize,
+                                      &totalRowSize,
+                                      &skipRows);
+
+    size_t pixelDataSize =
+        ctx->state()->pixelDataSize(
+            width, height, 1, format, type, 1 /* is pack */);
+
+    if (startOffset == 0 &&
+        pixelRowSize == totalRowSize) {
+        // fast path
+        readback(pixels, pixelDataSize);
+    } else if (pixelRowSize == totalRowSize && (pixelRowSize == width * bpp)) {
+        // fast path but with skip in the beginning
+        std::vector<char> paddingToDiscard(startOffset, 0);
+        readback(&paddingToDiscard[0], startOffset);
+        readback((char*)pixels + startOffset, pixelDataSize - startOffset);
+    } else {
+        int totalReadback = 0;
+
+        if (startOffset > 0) {
+            std::vector<char> paddingToDiscard(startOffset, 0);
+            readback(&paddingToDiscard[0], startOffset);
+            totalReadback += startOffset;
+        }
+        // need to read back row by row
+        size_t paddingSize = totalRowSize - pixelRowSize;
+        std::vector<char> paddingToDiscard(paddingSize, 0);
+
+        char* start = (char*)pixels + startOffset;
+
+        for (int i = 0; i < height; i++) {
+            if (pixelRowSize != width * bpp) {
+                size_t rowSlack = pixelRowSize - width * bpp;
+                std::vector<char> rowSlackToDiscard(rowSlack, 0);
+                readback(start, width * bpp);
+                readback(&rowSlackToDiscard[0], rowSlack);
+                totalReadback += pixelRowSize;
+                readback(&paddingToDiscard[0], paddingSize);
+                totalReadback += paddingSize;
+                start += totalRowSize;
+            } else {
+                readback(start, pixelRowSize);
+                totalReadback += pixelRowSize;
+                readback(&paddingToDiscard[0], paddingSize);
+                totalReadback += paddingSize;
+                start += totalRowSize;
+            }
+        }
+    }
+}
+
+void IOStream::uploadPixels(void* context, int width, int height, int depth, unsigned int format, unsigned int type, const void* pixels) {
+    GL2Encoder *ctx = (GL2Encoder *)context;
+    assert (ctx->state() != NULL);
+
+    if (1 == depth) {
+        int bpp = 0;
+        int startOffset = 0;
+        int pixelRowSize = 0;
+        int totalRowSize = 0;
+        int skipRows = 0;
+
+        ctx->state()->getUnpackingOffsets2D(width, height, format, type,
+                &bpp,
+                &startOffset,
+                &pixelRowSize,
+                &totalRowSize,
+                &skipRows);
+
+        size_t pixelDataSize =
+            ctx->state()->pixelDataSize(
+                    width, height, 1, format, type, 0 /* is unpack */);
+
+        if (startOffset == 0 &&
+                pixelRowSize == totalRowSize) {
+            // fast path
+            writeFully(pixels, pixelDataSize);
+        } else if (pixelRowSize == totalRowSize && (pixelRowSize == width * bpp)) {
+            // fast path but with skip in the beginning
+            std::vector<char> paddingToDiscard(startOffset, 0);
+            writeFully(&paddingToDiscard[0], startOffset);
+            writeFully((char*)pixels + startOffset, pixelDataSize - startOffset);
+        } else {
+            int totalReadback = 0;
+
+            if (startOffset > 0) {
+                std::vector<char> paddingToDiscard(startOffset, 0);
+                writeFully(&paddingToDiscard[0], startOffset);
+                totalReadback += startOffset;
+            }
+            // need to upload row by row
+            size_t paddingSize = totalRowSize - pixelRowSize;
+            std::vector<char> paddingToDiscard(paddingSize, 0);
+
+            char* start = (char*)pixels + startOffset;
+
+            for (int i = 0; i < height; i++) {
+                if (pixelRowSize != width * bpp) {
+                    size_t rowSlack = pixelRowSize - width * bpp;
+                    std::vector<char> rowSlackToDiscard(rowSlack, 0);
+                    writeFully(start, width * bpp);
+                    writeFully(&rowSlackToDiscard[0], rowSlack);
+                    totalReadback += pixelRowSize;
+                    writeFully(&paddingToDiscard[0], paddingSize);
+                    totalReadback += paddingSize;
+                    start += totalRowSize;
+                } else {
+                    writeFully(start, pixelRowSize);
+                    totalReadback += pixelRowSize;
+                    writeFully(&paddingToDiscard[0], paddingSize);
+                    totalReadback += paddingSize;
+                    start += totalRowSize;
+                }
+            }
+        }
+    } else {
+        int bpp = 0;
+        int startOffset = 0;
+        int pixelRowSize = 0;
+        int totalRowSize = 0;
+        int pixelImageSize = 0;
+        int totalImageSize = 0;
+        int skipRows = 0;
+        int skipImages = 0;
+
+        ctx->state()->getUnpackingOffsets3D(width, height, depth, format, type,
+                &bpp,
+                &startOffset,
+                &pixelRowSize,
+                &totalRowSize,
+                &pixelImageSize,
+                &totalImageSize,
+                &skipRows,
+                &skipImages);
+
+        size_t pixelDataSize =
+            ctx->state()->pixelDataSize(
+                    width, height, depth, format, type, 0 /* is unpack */);
+
+        size_t sent = 0;
+
+        if (startOffset == 0 &&
+            pixelRowSize == totalRowSize &&
+            pixelImageSize == totalImageSize) {
+            // fast path
+            writeFully(pixels, pixelDataSize);
+            sent += pixelDataSize;
+        } else if (pixelRowSize == totalRowSize &&
+                   pixelImageSize == totalImageSize &&
+                   pixelRowSize == (width * bpp)) {
+            // fast path but with skip in the beginning
+            std::vector<char> paddingToDiscard(startOffset, 0);
+            writeFully(&paddingToDiscard[0], startOffset);
+            writeFully((char*)pixels + startOffset, pixelDataSize - startOffset);
+            sent += pixelDataSize;
+        } else {
+            int totalReadback = 0;
+
+            if (startOffset > 0) {
+                std::vector<char> paddingToDiscard(startOffset, 0);
+                writeFully(&paddingToDiscard[0], startOffset);
+                totalReadback += startOffset;
+            }
+            // need to upload row by row
+            size_t paddingSize = totalRowSize - pixelRowSize;
+            std::vector<char> paddingToDiscard(paddingSize, 0);
+
+            char* start = (char*)pixels + startOffset;
+
+            size_t rowSlack = pixelRowSize - width * bpp;
+            std::vector<char> rowSlackToDiscard(rowSlack, 0);
+
+            size_t imageSlack = totalImageSize - pixelImageSize;
+            std::vector<char> imageSlackToDiscard(imageSlack, 0);
+
+            for (int k = 0; k < depth; ++k) {
+                for (int i = 0; i < height; i++) {
+                    if (pixelRowSize != width * bpp) {
+                        writeFully(start, width * bpp);
+                        writeFully(&rowSlackToDiscard[0], rowSlack);
+                        totalReadback += pixelRowSize;
+                        writeFully(&paddingToDiscard[0], paddingSize);
+                        totalReadback += paddingSize;
+                        start += totalRowSize;
+                    } else {
+                        writeFully(start, pixelRowSize);
+                        totalReadback += pixelRowSize;
+                        writeFully(&paddingToDiscard[0], paddingSize);
+                        totalReadback += paddingSize;
+                        start += totalRowSize;
+                    }
+                }
+                if (imageSlack > 0) {
+                    writeFully(&imageSlackToDiscard[0], imageSlack);
+                    start += imageSlack;
+                    totalReadback += imageSlack;
+                }
+            }
+        }
+    }
+}
diff --git a/system/GLESv2_enc/gl2_enc.cpp b/system/GLESv2_enc/gl2_enc.cpp
index fb70443..814021b 100644
--- a/system/GLESv2_enc/gl2_enc.cpp
+++ b/system/GLESv2_enc/gl2_enc.cpp
@@ -3344,7 +3344,7 @@
 	stream->writeFully(&__size_pixels,4);
 	if (useChecksum) checksumCalculator->addBuffer(&__size_pixels,4);
 	if (pixels != NULL) {
-	    stream->uploadPixels(self, width, height, format, type, pixels);
+		 stream->uploadPixels(self, width, height, 1, format, type, pixels);
 		if (useChecksum) checksumCalculator->addBuffer(pixels, __size_pixels);
 	}
 	buf = stream->alloc(checksumSize);
@@ -3497,7 +3497,7 @@
 	stream->writeFully(&__size_pixels,4);
 	if (useChecksum) checksumCalculator->addBuffer(&__size_pixels,4);
 	if (pixels != NULL) {
-	    stream->uploadPixels(self, width, height, format, type, pixels);
+		 stream->uploadPixels(self, width, height, 1, format, type, pixels);
 		if (useChecksum) checksumCalculator->addBuffer(pixels, __size_pixels);
 	}
 	buf = stream->alloc(checksumSize);
@@ -8489,7 +8489,7 @@
 	stream->writeFully(&__size_data,4);
 	if (useChecksum) checksumCalculator->addBuffer(&__size_data,4);
 	if (data != NULL) {
-		stream->writeFully(data, __size_data);
+		 stream->uploadPixels(self, width, height, depth, format, type, data);
 		if (useChecksum) checksumCalculator->addBuffer(data, __size_data);
 	}
 	buf = stream->alloc(checksumSize);
@@ -8596,7 +8596,7 @@
 	stream->writeFully(&__size_data,4);
 	if (useChecksum) checksumCalculator->addBuffer(&__size_data,4);
 	if (data != NULL) {
-		stream->writeFully(data, __size_data);
+		 stream->uploadPixels(self, width, height, depth, format, type, data);
 		if (useChecksum) checksumCalculator->addBuffer(data, __size_data);
 	}
 	buf = stream->alloc(checksumSize);
diff --git a/system/OpenglSystemCommon/Android.mk b/system/OpenglSystemCommon/Android.mk
index bb9e14f..fa24719 100644
--- a/system/OpenglSystemCommon/Android.mk
+++ b/system/OpenglSystemCommon/Android.mk
@@ -2,6 +2,15 @@
 
 $(call emugl-begin-shared-library,libOpenglSystemCommon)
 $(call emugl-import,libGLESv1_enc libGLESv2_enc lib_renderControl_enc)
+ifeq (true,$(GOLDFISH_OPENGL_BUILD_FOR_HOST))
+$(call emugl-import,libGoldfishAddressSpace$(GOLDFISH_OPENGL_LIB_SUFFIX))
+$(call emugl-import,libqemupipe$(GOLDFISH_OPENGL_LIB_SUFFIX))
+$(call emugl-import,libgralloc_cb$(GOLDFISH_OPENGL_LIB_SUFFIX))
+else
+$(call emugl-export,STATIC_LIBRARIES,libGoldfishAddressSpace)
+$(call emugl-export,STATIC_LIBRARIES,libqemupipe.ranchu)
+$(call emugl-export,HEADER_LIBRARIES,libgralloc_cb.ranchu)
+endif
 
 LOCAL_SRC_FILES := \
     FormatConversions.cpp \
diff --git a/system/OpenglSystemCommon/CMakeLists.txt b/system/OpenglSystemCommon/CMakeLists.txt
index 7feb903..ff4947a 100644
--- a/system/OpenglSystemCommon/CMakeLists.txt
+++ b/system/OpenglSystemCommon/CMakeLists.txt
@@ -1,10 +1,10 @@
 # This is an autogenerated file! Do not edit!
 # instead run make from .../device/generic/goldfish-opengl
 # which will re-generate this file.
-android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon/Android.mk" "6fedb15afaabb2c4e6cd24123f711639d6574b47356b2fa626a668bb497b8977")
+android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon/Android.mk" "1a769e79e22604f569e4345e4f432bb4bd41ca810d479b69887007b5d9bec528")
 set(OpenglSystemCommon_src FormatConversions.cpp HostConnection.cpp QemuPipeStream.cpp ProcessPipe.cpp AddressSpaceStream.cpp ThreadInfo_host.cpp)
 android_add_library(TARGET OpenglSystemCommon SHARED LICENSE Apache-2.0 SRC FormatConversions.cpp HostConnection.cpp QemuPipeStream.cpp ProcessPipe.cpp AddressSpaceStream.cpp ThreadInfo_host.cpp)
-target_include_directories(OpenglSystemCommon PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/platform ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon/bionic-include ${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
+target_include_directories(OpenglSystemCommon PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/platform ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon/bionic-include ${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/shared/gralloc_cb/include ${GOLDFISH_DEVICE_ROOT}/shared/GoldfishAddressSpace/include ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include-types ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
 target_compile_definitions(OpenglSystemCommon PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DGOLDFISH_VULKAN")
 target_compile_options(OpenglSystemCommon PRIVATE "-fvisibility=default" "-Wno-unused-parameter" "-Wno-unused-variable")
-target_link_libraries(OpenglSystemCommon PRIVATE android-emu-shared vulkan_enc gui androidemu cutils utils log _renderControl_enc GLESv2_enc GLESv1_enc OpenglCodecCommon_host)
\ No newline at end of file
+target_link_libraries(OpenglSystemCommon PRIVATE android-emu-shared vulkan_enc gui androidemu cutils utils log _renderControl_enc GLESv2_enc GLESv1_enc OpenglCodecCommon_host PRIVATE gralloc_cb_host GoldfishAddressSpace_host qemupipe_host)
\ No newline at end of file
diff --git a/system/OpenglSystemCommon/FormatConversions.cpp b/system/OpenglSystemCommon/FormatConversions.cpp
index ca4286c..cc976ed 100644
--- a/system/OpenglSystemCommon/FormatConversions.cpp
+++ b/system/OpenglSystemCommon/FormatConversions.cpp
@@ -1,16 +1,16 @@
-/*
- * Copyright (C) 2016 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- */
+// Copyright 2016 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 <hardware/gralloc.h>
 #include "FormatConversions.h"
diff --git a/system/OpenglSystemCommon/FormatConversions.h b/system/OpenglSystemCommon/FormatConversions.h
index f9d7806..51aab6d 100644
--- a/system/OpenglSystemCommon/FormatConversions.h
+++ b/system/OpenglSystemCommon/FormatConversions.h
@@ -1,16 +1,16 @@
-/*
- * Copyright (C) 2016 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- */
+// Copyright 2016 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.
 
 #ifndef __GOLDFISH_FORMATCONVERSIONS_H__
 #define __GOLDFISH_FORMATCONVERSIONS_H__
diff --git a/system/OpenglSystemCommon/HostConnection.cpp b/system/OpenglSystemCommon/HostConnection.cpp
index c5075fc..b9c97c9 100644
--- a/system/OpenglSystemCommon/HostConnection.cpp
+++ b/system/OpenglSystemCommon/HostConnection.cpp
@@ -66,8 +66,7 @@
 #include "QemuPipeStream.h"
 #include "TcpStream.h"
 #include "ThreadInfo.h"
-#define ALLOW_DEPRECATED_QEMU_PIPE_HEADERS
-#include "gralloc_cb.h"
+#include <gralloc_cb_bp.h>
 
 #ifdef VIRTIO_GPU
 
diff --git a/system/OpenglSystemCommon/ProcessPipe.cpp b/system/OpenglSystemCommon/ProcessPipe.cpp
index 56f1e52..84764f4 100644
--- a/system/OpenglSystemCommon/ProcessPipe.cpp
+++ b/system/OpenglSystemCommon/ProcessPipe.cpp
@@ -17,8 +17,7 @@
 #include "ProcessPipe.h"
 #include "renderControl_enc.h"
 
-#define ALLOW_DEPRECATED_QEMU_PIPE_HEADERS
-#include <qemu_pipe.h>
+#include <qemu_pipe_bp.h>
 
 #if PLATFORM_SDK_VERSION < 26
 #include <cutils/log.h>
@@ -100,7 +99,7 @@
         ALOGE("%s: failed write confirm int", __FUNCTION__);
         return;
     }
-    status = pipe->Call(sizeof(confirmInt), 0, sizeof(sProcUID), 0, &status2, &actual);
+    status = pipe->DoCall(sizeof(confirmInt), 0, sizeof(sProcUID), 0, &status2, &actual);
     if (status != ZX_OK || status2 != ZX_OK) {
         ALOGD("%s: failed to get per-process ID: %d:%d", __FUNCTION__,
               status, status2);
diff --git a/system/OpenglSystemCommon/QemuPipeStream.cpp b/system/OpenglSystemCommon/QemuPipeStream.cpp
index 55f5fe8..d5fca2b 100644
--- a/system/OpenglSystemCommon/QemuPipeStream.cpp
+++ b/system/OpenglSystemCommon/QemuPipeStream.cpp
@@ -14,8 +14,7 @@
 * limitations under the License.
 */
 #include "QemuPipeStream.h"
-#define ALLOW_DEPRECATED_QEMU_PIPE_HEADERS
-#include <qemu_pipe.h>
+#include <qemu_pipe_bp.h>
 
 #if PLATFORM_SDK_VERSION < 26
 #include <cutils/log.h>
diff --git a/system/OpenglSystemCommon/QemuPipeStream.h b/system/OpenglSystemCommon/QemuPipeStream.h
index 9ca4459..4e779eb 100644
--- a/system/OpenglSystemCommon/QemuPipeStream.h
+++ b/system/OpenglSystemCommon/QemuPipeStream.h
@@ -23,8 +23,7 @@
 #include <stdlib.h>
 #include "IOStream.h"
 
-#define ALLOW_DEPRECATED_QEMU_PIPE_HEADERS
-#include <qemu_pipe.h>
+#include <qemu_pipe_bp.h>
 
 #ifdef __Fuchsia__
 #include <fuchsia/hardware/goldfish/cpp/fidl.h>
diff --git a/system/OpenglSystemCommon/QemuPipeStreamFuchsia.cpp b/system/OpenglSystemCommon/QemuPipeStreamFuchsia.cpp
index 66dec13..5472f30 100644
--- a/system/OpenglSystemCommon/QemuPipeStreamFuchsia.cpp
+++ b/system/OpenglSystemCommon/QemuPipeStreamFuchsia.cpp
@@ -180,7 +180,7 @@
 
     uint64_t actual = 0;
     zx_status_t status2 = ZX_OK;
-    zx_status_t status = m_pipe->Call(size, kWriteOffset, 0, 0, &status2, &actual);
+    zx_status_t status = m_pipe->DoCall(size, kWriteOffset, 0, 0, &status2, &actual);
     if (status != ZX_OK || status2 != ZX_OK) {
         ALOGD("%s: Pipe call failed: %d:%d", __FUNCTION__, status, status2);
         return -1;
@@ -238,7 +238,7 @@
     size_t maxRead = (m_readLeft || !remaining) ? 0 : kReadSize;
     uint64_t actual = 0;
     zx_status_t status2 = ZX_OK;
-    zx_status_t status = m_pipe->Call(size, kWriteOffset, maxRead, 0, &status2, &actual);
+    zx_status_t status = m_pipe->DoCall(size, kWriteOffset, maxRead, 0, &status2, &actual);
     if (status != ZX_OK) {
         ALOGD("%s: Pipe call failed: %d", __FUNCTION__, status);
         return nullptr;
diff --git a/system/codecs/omx/avcdec/exports.lds b/system/codecs/omx/avcdec/exports.lds
deleted file mode 100644
index e6674f2..0000000
--- a/system/codecs/omx/avcdec/exports.lds
+++ /dev/null
@@ -1,5 +0,0 @@
-{
-    global:
-        _Z26createGoldfishOMXComponentPKcPK16OMX_CALLBACKTYPEPvPP17OMX_COMPONENTTYPE;
-    local: *;
-};
diff --git a/system/codecs/omx/common/Android.mk b/system/codecs/omx/common/Android.mk
index 50ce286..9e233e7 100644
--- a/system/codecs/omx/common/Android.mk
+++ b/system/codecs/omx/common/Android.mk
@@ -28,5 +28,11 @@
 $(call emugl-export,SHARED_LIBRARIES,libcutils libutils liblog)
 
 $(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
-$(call emugl-import,libOpenglSystemCommon)
+
+ifeq (true,$(GOLDFISH_OPENGL_BUILD_FOR_HOST))
+$(call emugl-import,libGoldfishAddressSpace$(GOLDFISH_OPENGL_LIB_SUFFIX))
+else
+$(call emugl-export,STATIC_LIBRARIES,libGoldfishAddressSpace)
+endif
+
 $(call emugl-end-module)
diff --git a/system/codecs/omx/common/goldfish_media_utils.cpp b/system/codecs/omx/common/goldfish_media_utils.cpp
index 36883c2..ac1d1b0 100644
--- a/system/codecs/omx/common/goldfish_media_utils.cpp
+++ b/system/codecs/omx/common/goldfish_media_utils.cpp
@@ -1,16 +1,16 @@
-/*
- * Copyright (C) 2018 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- */
+// Copyright 2018 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 "goldfish_media_utils.h"
 
diff --git a/system/codecs/omx/common/goldfish_media_utils.h b/system/codecs/omx/common/goldfish_media_utils.h
index da57689..d25ee30 100644
--- a/system/codecs/omx/common/goldfish_media_utils.h
+++ b/system/codecs/omx/common/goldfish_media_utils.h
@@ -1,16 +1,16 @@
-/*
- * Copyright (C) 2018 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- */
+// Copyright 2018 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 <linux/types.h>
 #include <stdint.h>
diff --git a/system/codecs/omx/vpxdec/exports.lds b/system/codecs/omx/vpxdec/exports.lds
deleted file mode 100644
index e6674f2..0000000
--- a/system/codecs/omx/vpxdec/exports.lds
+++ /dev/null
@@ -1,5 +0,0 @@
-{
-    global:
-        _Z26createGoldfishOMXComponentPKcPK16OMX_CALLBACKTYPEPvPP17OMX_COMPONENTTYPE;
-    local: *;
-};
diff --git a/system/egl/Android.mk b/system/egl/Android.mk
index 58663e5..6e239b2 100644
--- a/system/egl/Android.mk
+++ b/system/egl/Android.mk
@@ -6,6 +6,12 @@
 $(call emugl-import,libOpenglSystemCommon)
 $(call emugl-set-shared-library-subpath,egl)
 
+ifeq (true,$(GOLDFISH_OPENGL_BUILD_FOR_HOST))
+$(call emugl-import,libqemupipe$(GOLDFISH_OPENGL_LIB_SUFFIX))
+else
+$(call emugl-export,STATIC_LIBRARIES,libqemupipe.ranchu)
+endif
+
 LOCAL_CFLAGS += -DLOG_TAG=\"EGL_emulation\" -DEGL_EGLEXT_PROTOTYPES -DWITH_GLES2
 LOCAL_CFLAGS += -Wno-gnu-designator
 
diff --git a/system/egl/CMakeLists.txt b/system/egl/CMakeLists.txt
index 25b4cdd..08db0c8 100644
--- a/system/egl/CMakeLists.txt
+++ b/system/egl/CMakeLists.txt
@@ -1,10 +1,10 @@
 # This is an autogenerated file! Do not edit!
 # instead run make from .../device/generic/goldfish-opengl
 # which will re-generate this file.
-android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/egl/Android.mk" "53f944775eac93c4fff6cb2b10ec932462422eb0e4ae0fb616f2f16bb0baf4af")
+android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/egl/Android.mk" "597fba46fce0876a62ef3c0bc8f3a0264503214b62b0b0da092ee90fe60f09e1")
 set(EGL_emulation_src eglDisplay.cpp egl.cpp ClientAPIExts.cpp)
 android_add_library(TARGET EGL_emulation SHARED LICENSE Apache-2.0 SRC eglDisplay.cpp egl.cpp ClientAPIExts.cpp)
-target_include_directories(EGL_emulation PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon/bionic-include ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/bionic/libc/platform ${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
+target_include_directories(EGL_emulation PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon/bionic-include ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/bionic/libc/platform ${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/shared/gralloc_cb/include ${GOLDFISH_DEVICE_ROOT}/shared/GoldfishAddressSpace/include ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include-types ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
 target_compile_definitions(EGL_emulation PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DGOLDFISH_VULKAN" "-DLOG_TAG=\"EGL_emulation\"" "-DEGL_EGLEXT_PROTOTYPES")
 target_compile_options(EGL_emulation PRIVATE "-fvisibility=default" "-Wno-unused-parameter" "-Wno-gnu-designator")
-target_link_libraries(EGL_emulation PRIVATE OpenglSystemCommon android-emu-shared vulkan_enc gui androidemu cutils utils log _renderControl_enc GLESv2_enc GLESv1_enc OpenglCodecCommon_host)
\ No newline at end of file
+target_link_libraries(EGL_emulation PRIVATE OpenglSystemCommon android-emu-shared vulkan_enc gui androidemu cutils utils log _renderControl_enc GLESv2_enc GLESv1_enc OpenglCodecCommon_host PRIVATE gralloc_cb_host GoldfishAddressSpace_host qemupipe_host)
\ No newline at end of file
diff --git a/system/egl/egl.cpp b/system/egl/egl.cpp
index 86c2c8e..834207b 100644
--- a/system/egl/egl.cpp
+++ b/system/egl/egl.cpp
@@ -34,8 +34,7 @@
 #include "EGLImage.h"
 #include "ProcessPipe.h"
 
-#define ALLOW_DEPRECATED_QEMU_PIPE_HEADERS
-#include <qemu_pipe.h>
+#include <qemu_pipe_bp.h>
 
 #include "GLEncoder.h"
 #ifdef WITH_GLES2
@@ -122,7 +121,7 @@
 #endif //LOG_EGL_ERRORS
 
 #define VALIDATE_CONFIG(cfg,ret) \
-    if(((intptr_t)(cfg)<0)||((intptr_t)(cfg)>s_display.getNumConfigs())) { \
+    if (!s_display.isValidConfig(cfg)) { \
         RETURN_ERROR(ret,EGL_BAD_CONFIG); \
     }
 
@@ -410,7 +409,7 @@
     setNativeHeight(nativeHeight);
 
     DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
-    rcSurface = rcEnc->rcCreateWindowSurface(rcEnc, (uintptr_t)config,
+    rcSurface = rcEnc->rcCreateWindowSurface(rcEnc, (uintptr_t)s_display.getIndexOfConfig(config),
             getWidth(), getHeight());
 
     if (!rcSurface) {
@@ -670,7 +669,7 @@
 {
     DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
 
-    rcSurface = rcEnc->rcCreateWindowSurface(rcEnc, (uintptr_t)config,
+    rcSurface = rcEnc->rcCreateWindowSurface(rcEnc, (uintptr_t)s_display.getIndexOfConfig(config),
             getWidth(), getHeight());
     if (!rcSurface) {
         ALOGE("rcCreateWindowSurface returned 0");
@@ -947,7 +946,7 @@
 
     EGLint i;
     for (i = 0 ; i < numConfigs && i < config_size ; i++) {
-        *configs++ = (EGLConfig)(uintptr_t)i;
+        *configs++ = (EGLConfig)(uintptr_t)s_display.getConfigAtIndex(i);
     }
     *num_config = i;
     return EGL_TRUE;
@@ -1008,7 +1007,8 @@
     if (configs!=NULL) {
         EGLint i=0;
         for (i=0;i<(*num_config);i++) {
-             *((uintptr_t*)configs+i) = *((uint32_t*)tempConfigs+i);
+            EGLConfig guestConfig = s_display.getConfigAtIndex(*((uint32_t*)tempConfigs+i));
+            configs[i] = guestConfig;
         }
     }
 
@@ -1616,7 +1616,7 @@
     if (majorVersion == 3 && minorVersion == 2) {
         rcMajorVersion = 4;
     }
-    uint32_t rcContext = rcEnc->rcCreateContext(rcEnc, (uintptr_t)config, rcShareCtx, rcMajorVersion);
+    uint32_t rcContext = rcEnc->rcCreateContext(rcEnc, (uintptr_t)s_display.getIndexOfConfig(config), rcShareCtx, rcMajorVersion);
     if (!rcContext) {
         ALOGE("rcCreateContext returned 0");
         setErrorReturn(EGL_BAD_ALLOC, EGL_NO_CONTEXT);
@@ -1715,7 +1715,6 @@
     //Now make the local bind
     if (context) {
 
-        ALOGD("%s: %p: ver %d %d (tinfo %p)", __FUNCTION__, context, context->majorVersion, context->minorVersion, tInfo);
         // This is a nontrivial context.
         // The thread cannot be gralloc-only anymore.
         hostCon->setGrallocOnly(false);
@@ -1732,6 +1731,9 @@
             context->getClientState();
 
         if (!hostCon->gl2Encoder()->isInitialized()) {
+            ALOGD("%s: %p: ver %d %d (tinfo %p) (first time)",
+                  __FUNCTION__,
+                  context, context->majorVersion, context->minorVersion, tInfo);
             s_display.gles2_iface()->init();
             hostCon->gl2Encoder()->setInitialized();
             ClientAPIExts::initClientFuncs(s_display.gles2_iface(), 1);
@@ -1835,6 +1837,9 @@
         }
         else {
             if (!hostCon->glEncoder()->isInitialized()) {
+                ALOGD("%s: %p: ver %d %d (tinfo %p) (first time)",
+                      __FUNCTION__,
+                      context, context->majorVersion, context->minorVersion, tInfo);
                 s_display.gles_iface()->init();
                 hostCon->glEncoder()->setInitialized();
                 ClientAPIExts::initClientFuncs(s_display.gles_iface(), 0);
diff --git a/system/egl/eglDisplay.cpp b/system/egl/eglDisplay.cpp
index 2e18e11..b3f14da 100644
--- a/system/egl/eglDisplay.cpp
+++ b/system/egl/eglDisplay.cpp
@@ -171,7 +171,10 @@
 
         uint32_t nInts = m_numConfigAttribs * (m_numConfigs + 1);
         EGLint tmp_buf[nInts];
+        uint32_t configCount = nInts - m_numConfigAttribs;
+
         m_configs = new EGLint[nInts-m_numConfigAttribs];
+
         if (!m_configs) {
             pthread_mutex_unlock(&m_lock);
             return false;
@@ -204,7 +207,7 @@
 void eglDisplay::processConfigs()
 {
     for (intptr_t i=0; i<m_numConfigs; i++) {
-        EGLConfig config = (EGLConfig)i;
+        EGLConfig config = getConfigAtIndex(i);
         PixelFormat format;
         if (getConfigNativePixelFormat(config, &format)) {
             setConfigAttrib(config, EGL_NATIVE_VISUAL_ID, format);
@@ -443,13 +446,29 @@
         ALOGE("[%s] Bad attribute idx\n", __FUNCTION__);
         return EGL_FALSE;
     }
-    *value = *(m_configs + (intptr_t)config*m_numConfigAttribs + attribIdx);
+    *value = *(m_configs + (intptr_t)(getIndexOfConfig(config))*m_numConfigAttribs + attribIdx);
     return EGL_TRUE;
 }
 
 #define EGL_COLOR_COMPONENT_TYPE_EXT 0x3339
 #define EGL_COLOR_COMPONENT_TYPE_FIXED_EXT 0x333A
 
+EGLConfig eglDisplay::getConfigAtIndex(uint32_t index) const {
+    uintptr_t asPtr = (uintptr_t)index;
+    return (EGLConfig)(asPtr + 1);
+}
+
+uint32_t eglDisplay::getIndexOfConfig(EGLConfig config) const {
+    uintptr_t asInteger = (uintptr_t)config;
+    return (uint32_t)(asInteger - 1);
+}
+
+bool eglDisplay::isValidConfig(EGLConfig cfg) const {
+    uint32_t index = getIndexOfConfig(cfg);
+    intptr_t asInt = (intptr_t)index;
+    return !(asInt < 0 || asInt > m_numConfigs);
+}
+
 EGLBoolean eglDisplay::getConfigAttrib(EGLConfig config, EGLint attrib, EGLint * value)
 {
     if (attrib == EGL_FRAMEBUFFER_TARGET_ANDROID) {
@@ -484,10 +503,10 @@
 void eglDisplay::dumpConfig(EGLConfig config)
 {
     EGLint value = 0;
-    DBG("^^^^^^^^^^ dumpConfig %d ^^^^^^^^^^^^^^^^^^", (int)config);
+    DBG("^^^^^^^^^^ dumpConfig %p ^^^^^^^^^^^^^^^^^^", config);
     for (int i=0; i<m_numConfigAttribs; i++) {
         getAttribValue(config, i, &value);
-        DBG("{%d}[%d] %d\n", (int)config, i, value);
+        DBG("Config %p: {%u}[%d] %d\n", config, getIndexOfConfig(config), i, value);
     }
 }
 
@@ -501,7 +520,7 @@
         ALOGE("[%s] Bad attribute idx\n", __FUNCTION__);
         return EGL_FALSE;
     }
-    *(m_configs + (intptr_t)config*m_numConfigAttribs + attribIdx) = value;
+    *(m_configs + (intptr_t)(getIndexOfConfig(config))*m_numConfigAttribs + attribIdx) = value;
     return EGL_TRUE;
 }
 
diff --git a/system/egl/eglDisplay.h b/system/egl/eglDisplay.h
index 2394da1..951075d 100644
--- a/system/egl/eglDisplay.h
+++ b/system/egl/eglDisplay.h
@@ -56,6 +56,11 @@
     const EGLClient_glesInterface *gles2_iface() const { return m_gles2_iface; }
 
     int     getNumConfigs(){ return m_numConfigs; }
+
+    EGLConfig getConfigAtIndex(uint32_t index) const;
+    uint32_t getIndexOfConfig(EGLConfig config) const;
+    bool isValidConfig(EGLConfig cfg) const;
+
     EGLBoolean  getConfigAttrib(EGLConfig config, EGLint attrib, EGLint * value);
     EGLBoolean  setConfigAttrib(EGLConfig config, EGLint attrib, EGLint value);
     EGLBoolean getConfigGLPixelFormat(EGLConfig config, GLenum * format);
diff --git a/system/egl/goldfish_sync.h b/system/egl/goldfish_sync.h
index 18e3083..bb0cf44 100644
--- a/system/egl/goldfish_sync.h
+++ b/system/egl/goldfish_sync.h
@@ -1,16 +1,16 @@
-/*
- * Copyright (C) 2016 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- */
+// Copyright 2016 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.
 
 #ifndef ANDROID_INCLUDE_HARDWARE_GOLDFISH_SYNC_H
 #define ANDROID_INCLUDE_HARDWARE_GOLDFISH_SYNC_H
diff --git a/system/enc_common/IOStream_common.cpp b/system/enc_common/IOStream_common.cpp
deleted file mode 100644
index 1362d3e..0000000
--- a/system/enc_common/IOStream_common.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-#include "IOStream.h"
-
-#include "GL2Encoder.h"
-
-#include <GLES3/gl31.h>
-
-#include <vector>
-
-#include <assert.h>
-
-void IOStream::readbackPixels(void* context, int width, int height, unsigned int format, unsigned int type, void* pixels) {
-    GL2Encoder *ctx = (GL2Encoder *)context;
-    assert (ctx->state() != NULL);
-
-    int startOffset = 0;
-    int pixelRowSize = 0;
-    int totalRowSize = 0;
-    int skipRows = 0;
-
-    ctx->state()->getPackingOffsets2D(width, height, format, type,
-                                      &startOffset,
-                                      &pixelRowSize,
-                                      &totalRowSize,
-                                      &skipRows);
-
-    size_t pixelDataSize =
-        ctx->state()->pixelDataSize(
-            width, height, 1, format, type, 1 /* is pack */);
-
-    if (startOffset == 0 &&
-        pixelRowSize == totalRowSize) {
-        // fast path
-        readback(pixels, pixelDataSize);
-    } else if (pixelRowSize == totalRowSize) {
-        // fast path but with skip in the beginning
-        std::vector<char> paddingToDiscard(startOffset, 0);
-        readback(&paddingToDiscard[0], startOffset);
-        readback((char*)pixels + startOffset, pixelDataSize - startOffset);
-    } else {
-        int totalReadback = 0;
-
-        if (startOffset > 0) {
-            std::vector<char> paddingToDiscard(startOffset, 0);
-            readback(&paddingToDiscard[0], startOffset);
-            totalReadback += startOffset;
-        }
-        // need to read back row by row
-        size_t paddingSize = totalRowSize - pixelRowSize;
-        std::vector<char> paddingToDiscard(paddingSize, 0);
-
-        char* start = (char*)pixels + startOffset;
-
-        for (int i = 0; i < height; i++) {
-            readback(start, pixelRowSize);
-            totalReadback += pixelRowSize;
-            readback(&paddingToDiscard[0], paddingSize);
-            totalReadback += paddingSize;
-            start += totalRowSize;
-        }
-    }
-}
-
-void IOStream::uploadPixels(void* context, int width, int height, unsigned int format, unsigned int type, const void* pixels) {
-    GL2Encoder *ctx = (GL2Encoder *)context;
-    assert (ctx->state() != NULL);
-
-    int startOffset = 0;
-    int pixelRowSize = 0;
-    int totalRowSize = 0;
-    int skipRows = 0;
-
-    ctx->state()->getUnpackingOffsets2D(width, height, format, type,
-                                        &startOffset,
-                                        &pixelRowSize,
-                                        &totalRowSize,
-                                        &skipRows);
-
-    size_t pixelDataSize =
-        ctx->state()->pixelDataSize(
-            width, height, 1, format, type, 0 /* is unpack */);
-
-    if (startOffset == 0 &&
-        pixelRowSize == totalRowSize) {
-        // fast path
-        writeFully(pixels, pixelDataSize);
-    } else if (pixelRowSize == totalRowSize) {
-        // fast path but with skip in the beginning
-        std::vector<char> paddingToDiscard(startOffset, 0);
-        writeFully(&paddingToDiscard[0], startOffset);
-        writeFully((char*)pixels + startOffset, pixelDataSize - startOffset);
-    } else {
-        int totalReadback = 0;
-
-        if (startOffset > 0) {
-            std::vector<char> paddingToDiscard(startOffset, 0);
-            writeFully(&paddingToDiscard[0], startOffset);
-            totalReadback += startOffset;
-        }
-        // need to upload row by row
-        size_t paddingSize = totalRowSize - pixelRowSize;
-        std::vector<char> paddingToDiscard(paddingSize, 0);
-
-        char* start = (char*)pixels + startOffset;
-
-        for (int i = 0; i < height; i++) {
-            writeFully(start, pixelRowSize);
-            totalReadback += pixelRowSize;
-            writeFully(&paddingToDiscard[0], paddingSize);
-            totalReadback += paddingSize;
-            start += totalRowSize;
-        }
-    }
-}
diff --git a/system/gralloc/CMakeLists.txt b/system/gralloc/CMakeLists.txt
index cf65352..b972006 100644
--- a/system/gralloc/CMakeLists.txt
+++ b/system/gralloc/CMakeLists.txt
@@ -4,17 +4,17 @@
 android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/gralloc/Android.mk" "09618d9293855148fb310e67065028da8c7f6dcf936b02b5695292c82ed4724e")
 set(gralloc.goldfish_src gralloc_old.cpp)
 android_add_library(TARGET gralloc.goldfish SHARED LICENSE Apache-2.0 SRC gralloc_old.cpp)
-target_include_directories(gralloc.goldfish PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon/bionic-include ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/bionic/libc/platform ${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
+target_include_directories(gralloc.goldfish PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon/bionic-include ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/bionic/libc/platform ${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/shared/gralloc_cb/include ${GOLDFISH_DEVICE_ROOT}/shared/GoldfishAddressSpace/include ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include-types ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
 target_compile_definitions(gralloc.goldfish PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DGOLDFISH_VULKAN" "-DLOG_TAG=\"gralloc_goldfish\"")
 target_compile_options(gralloc.goldfish PRIVATE "-fvisibility=default" "-Wno-unused-parameter" "-Wno-missing-field-initializers" "-Wno-gnu-designator")
-target_link_libraries(gralloc.goldfish PRIVATE OpenglSystemCommon android-emu-shared vulkan_enc gui androidemu cutils utils log GLESv2_enc _renderControl_enc GLESv1_enc OpenglCodecCommon_host)
+target_link_libraries(gralloc.goldfish PRIVATE OpenglSystemCommon android-emu-shared vulkan_enc gui androidemu cutils utils log GLESv2_enc _renderControl_enc GLESv1_enc OpenglCodecCommon_host PRIVATE gralloc_cb_host GoldfishAddressSpace_host qemupipe_host)
 # This is an autogenerated file! Do not edit!
 # instead run make from .../device/generic/goldfish-opengl
 # which will re-generate this file.
 android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/gralloc/Android.mk" "09618d9293855148fb310e67065028da8c7f6dcf936b02b5695292c82ed4724e")
 set(gralloc.ranchu_src gralloc_old.cpp)
 android_add_library(TARGET gralloc.ranchu SHARED LICENSE Apache-2.0 SRC gralloc_old.cpp)
-target_include_directories(gralloc.ranchu PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon/bionic-include ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/bionic/libc/platform ${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
+target_include_directories(gralloc.ranchu PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon/bionic-include ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/bionic/libc/platform ${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/shared/gralloc_cb/include ${GOLDFISH_DEVICE_ROOT}/shared/GoldfishAddressSpace/include ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include-types ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
 target_compile_definitions(gralloc.ranchu PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DGOLDFISH_VULKAN" "-DLOG_TAG=\"gralloc_ranchu\"")
 target_compile_options(gralloc.ranchu PRIVATE "-fvisibility=default" "-Wno-unused-parameter" "-Wno-missing-field-initializers" "-Wno-gnu-designator")
-target_link_libraries(gralloc.ranchu PRIVATE OpenglSystemCommon android-emu-shared vulkan_enc gui androidemu cutils utils log GLESv2_enc _renderControl_enc GLESv1_enc OpenglCodecCommon_host)
\ No newline at end of file
+target_link_libraries(gralloc.ranchu PRIVATE OpenglSystemCommon android-emu-shared vulkan_enc gui androidemu cutils utils log GLESv2_enc _renderControl_enc GLESv1_enc OpenglCodecCommon_host PRIVATE gralloc_cb_host GoldfishAddressSpace_host qemupipe_host)
\ No newline at end of file
diff --git a/system/gralloc/gralloc_30.cpp b/system/gralloc/gralloc_30.cpp
index e229921..b67f4c5 100644
--- a/system/gralloc/gralloc_30.cpp
+++ b/system/gralloc/gralloc_30.cpp
@@ -32,13 +32,12 @@
 #include <hardware/hardware.h>
 #include <hardware/gralloc.h>
 
-#define ALLOW_DEPRECATED_QEMU_PIPE_HEADERS
-#include "../../shared/OpenglCodecCommon/gralloc_cb.h"
+#include <gralloc_cb_bp.h>
 #include "gralloc_common.h"
 #include "goldfish_address_space.h"
 #include "HostConnection.h"
 #include "FormatConversions.h"
-#include "qemu_pipe.h"
+#include <qemu_pipe_bp.h>
 
 #define CRASH(MSG) \
     do { \
diff --git a/system/gralloc/gralloc_old.cpp b/system/gralloc/gralloc_old.cpp
index abb51cc..7af9dfe 100644
--- a/system/gralloc/gralloc_old.cpp
+++ b/system/gralloc/gralloc_old.cpp
@@ -23,13 +23,7 @@
 #include <sys/mman.h>
 #include <hardware/gralloc.h>
 
-#define ALLOW_DEPRECATED_QEMU_PIPE_HEADERS
-#if PLATFORM_SDK_VERSION < 28
-#include "gralloc_cb.h"
-#else
-#include "../../shared/OpenglCodecCommon/gralloc_cb.h"
-#endif
-
+#include <gralloc_cb_bp.h>
 #include "gralloc_common.h"
 
 #include "goldfish_dma.h"
@@ -39,7 +33,7 @@
 #include "ProcessPipe.h"
 #include "ThreadInfo.h"
 #include "glUtils.h"
-#include "qemu_pipe.h"
+#include <qemu_pipe_bp.h>
 
 #if PLATFORM_SDK_VERSION < 26
 #include <cutils/log.h>
diff --git a/system/hals/Android.mk b/system/hals/Android.mk
index 3b90bf0..3cdb4bf 100644
--- a/system/hals/Android.mk
+++ b/system/hals/Android.mk
@@ -34,12 +34,13 @@
     liblog \
     libutils
 
-LOCAL_STATIC_LIBRARIES += libqemupipe.ranchu
+LOCAL_STATIC_LIBRARIES += libqemupipe.ranchu libGoldfishAddressSpace$(GOLDFISH_OPENGL_LIB_SUFFIX)
 LOCAL_HEADER_LIBRARIES += libgralloc_cb.ranchu
 
 LOCAL_C_INCLUDES += \
     device/generic/goldfish-opengl/system/include \
     device/generic/goldfish-opengl/system/OpenglSystemCommon \
+    device/generic/goldfish-opengl/shared/GoldfishAddressSpace/include \
     device/generic/goldfish-opengl/shared/OpenglCodecCommon \
     device/generic/goldfish-opengl/host/include/libOpenglRender \
     device/generic/goldfish-opengl/system/renderControl_enc \
@@ -66,12 +67,13 @@
     libutils \
     libsync
 
-LOCAL_STATIC_LIBRARIES += libqemupipe.ranchu
+LOCAL_STATIC_LIBRARIES += libqemupipe.ranchu libGoldfishAddressSpace$(GOLDFISH_OPENGL_LIB_SUFFIX)
 LOCAL_HEADER_LIBRARIES += libgralloc_cb.ranchu
 
 LOCAL_C_INCLUDES += \
     device/generic/goldfish-opengl/system/include \
     device/generic/goldfish-opengl/system/OpenglSystemCommon \
+    device/generic/goldfish-opengl/shared/GoldfishAddressSpace/include \
     device/generic/goldfish-opengl/shared/OpenglCodecCommon \
     device/generic/goldfish-opengl/host/include/libOpenglRender \
     device/generic/goldfish-opengl/system/renderControl_enc \
diff --git a/system/renderControl_enc/CMakeLists.txt b/system/renderControl_enc/CMakeLists.txt
index c874e25..8a42acb 100644
--- a/system/renderControl_enc/CMakeLists.txt
+++ b/system/renderControl_enc/CMakeLists.txt
@@ -4,7 +4,7 @@
 android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc/Android.mk" "780a007ac7a3d2255372ddf40e03aeb10e4c759343d2532f6ddf769f4df73810")
 set(_renderControl_enc_src renderControl_client_context.cpp renderControl_enc.cpp renderControl_entry.cpp)
 android_add_library(TARGET _renderControl_enc SHARED LICENSE Apache-2.0 SRC renderControl_client_context.cpp renderControl_enc.cpp renderControl_entry.cpp)
-target_include_directories(_renderControl_enc PRIVATE ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
+target_include_directories(_renderControl_enc PRIVATE ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include-types ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest)
 target_compile_definitions(_renderControl_enc PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DGOLDFISH_VULKAN")
 target_compile_options(_renderControl_enc PRIVATE "-fvisibility=default" "-Wno-unused-parameter" "-Wno-unused-function")
-target_link_libraries(_renderControl_enc PRIVATE OpenglCodecCommon_host cutils utils log android-emu-shared)
\ No newline at end of file
+target_link_libraries(_renderControl_enc PRIVATE OpenglCodecCommon_host cutils utils log android-emu-shared PRIVATE qemupipe_host)
\ No newline at end of file
diff --git a/system/vulkan/Android.mk b/system/vulkan/Android.mk
index ebaa3c0..2bec494 100644
--- a/system/vulkan/Android.mk
+++ b/system/vulkan/Android.mk
@@ -17,7 +17,7 @@
 
 # Only import androidemu if not building for host.
 # if building for host, we already import android-emu.
-$(call emugl-import,libandroidemu)
+$(call emugl-export,SHARED_LIBRARIES,libandroidemu)
 
 LOCAL_HEADER_LIBRARIES += \
     hwvulkan_headers \
diff --git a/system/vulkan/CMakeLists.txt b/system/vulkan/CMakeLists.txt
index a71c07f..65bc00a 100644
--- a/system/vulkan/CMakeLists.txt
+++ b/system/vulkan/CMakeLists.txt
@@ -1,10 +1,10 @@
 # This is an autogenerated file! Do not edit!
 # instead run make from .../device/generic/goldfish-opengl
 # which will re-generate this file.
-android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/vulkan/Android.mk" "691427017f29de6b082ad25cb73b87443d4072a04b4316897bb92983674ad5bf")
+android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/vulkan/Android.mk" "5cb873c72cc859fac3800961059c1b203ed1abb400ee643178c18e04961d49e8")
 set(vulkan.ranchu_src func_table.cpp goldfish_vulkan.cpp)
 android_add_library(TARGET vulkan.ranchu SHARED LICENSE Apache-2.0 SRC func_table.cpp goldfish_vulkan.cpp)
-target_include_directories(vulkan.ranchu PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon/bionic-include ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/bionic/libc/platform ${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/system/vulkan ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/host/include)
+target_include_directories(vulkan.ranchu PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon/bionic-include ${GOLDFISH_DEVICE_ROOT}/system/OpenglSystemCommon ${GOLDFISH_DEVICE_ROOT}/bionic/libc/private ${GOLDFISH_DEVICE_ROOT}/bionic/libc/platform ${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/shared/gralloc_cb/include ${GOLDFISH_DEVICE_ROOT}/shared/GoldfishAddressSpace/include ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv2_enc ${GOLDFISH_DEVICE_ROOT}/system/GLESv1_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include-types ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include ${GOLDFISH_DEVICE_ROOT}/system/vulkan ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/host/include)
 target_compile_definitions(vulkan.ranchu PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DGOLDFISH_VULKAN" "-DLOG_TAG=\"goldfish_vulkan\"" "-DVK_USE_PLATFORM_ANDROID_KHR" "-DVK_NO_PROTOTYPES")
 target_compile_options(vulkan.ranchu PRIVATE "-fvisibility=default" "-Wno-unused-parameter" "-Wno-missing-field-initializers" "-fvisibility=hidden" "-fstrict-aliasing" "-Wno-unused-function")
-target_link_libraries(vulkan.ranchu PRIVATE OpenglSystemCommon android-emu-shared vulkan_enc gui androidemu cutils utils log _renderControl_enc GLESv2_enc GLESv1_enc OpenglCodecCommon_host)
\ No newline at end of file
+target_link_libraries(vulkan.ranchu PRIVATE OpenglSystemCommon android-emu-shared vulkan_enc gui androidemu cutils utils log _renderControl_enc GLESv2_enc GLESv1_enc OpenglCodecCommon_host PRIVATE gralloc_cb_host GoldfishAddressSpace_host qemupipe_host)
\ No newline at end of file
diff --git a/system/vulkan_enc/Android.mk b/system/vulkan_enc/Android.mk
index 984db7f..e49aac4 100644
--- a/system/vulkan_enc/Android.mk
+++ b/system/vulkan_enc/Android.mk
@@ -1,18 +1,15 @@
-
-# Autogenerated makefile
-# android/android-emugl/host/libs/libOpenglRender/vulkan-registry/xml/genvk.py -registry android/android-emugl/host/libs/libOpenglRender/vulkan-registry/xml/vk.xml cereal -o android/android-emugl/host/libs/libOpenglRender/vulkan/cereal
-# Please do not modify directly;
-# re-run android/scripts/generate-vulkan-sources.sh,
-# or directly from Python by defining:
-# VULKAN_REGISTRY_XML_DIR : Directory containing genvk.py and vk.xml
-# CEREAL_OUTPUT_DIR: Where to put the generated sources.
-# python3 $VULKAN_REGISTRY_XML_DIR/genvk.py -registry $VULKAN_REGISTRY_XML_DIR/vk.xml cereal -o $CEREAL_OUTPUT_DIR
-
 LOCAL_PATH := $(call my-dir)
 
 $(call emugl-begin-shared-library,libvulkan_enc)
 $(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
-$(call emugl-import,libOpenglCodecCommon$(GOLDFISH_OPENGL_LIB_SUFFIX) libandroidemu lib_renderControl_enc)
+$(call emugl-import,libOpenglCodecCommon$(GOLDFISH_OPENGL_LIB_SUFFIX) lib_renderControl_enc)
+ifeq (true,$(GOLDFISH_OPENGL_BUILD_FOR_HOST))
+$(call emugl-import,libandroidemu)
+$(call emugl-import,libGoldfishAddressSpace$(GOLDFISH_OPENGL_LIB_SUFFIX))
+else
+$(call emugl-export,SHARED_LIBRARIES,libandroidemu)
+$(call emugl-export,STATIC_LIBRARIES,libGoldfishAddressSpace)
+endif
 
 # Vulkan include dir
 ifeq (true,$(GOLDFISH_OPENGL_BUILD_FOR_HOST))
@@ -55,12 +52,11 @@
     VulkanHandleMapping.cpp \
     ResourceTracker.cpp \
     VkEncoder.cpp \
-goldfish_vk_extension_structs_guest.cpp \
-goldfish_vk_marshaling_guest.cpp \
-goldfish_vk_deepcopy_guest.cpp \
-goldfish_vk_handlemap_guest.cpp \
-goldfish_vk_transform_guest.cpp \
-
+    goldfish_vk_extension_structs_guest.cpp \
+    goldfish_vk_marshaling_guest.cpp \
+    goldfish_vk_deepcopy_guest.cpp \
+    goldfish_vk_handlemap_guest.cpp \
+    goldfish_vk_transform_guest.cpp \
 
 ifeq (true,$(GOLDFISH_OPENGL_BUILD_FOR_HOST))
 LOCAL_CFLAGS += -D__ANDROID_API__=28
diff --git a/system/vulkan_enc/CMakeLists.txt b/system/vulkan_enc/CMakeLists.txt
index dec0c66..5b97015 100644
--- a/system/vulkan_enc/CMakeLists.txt
+++ b/system/vulkan_enc/CMakeLists.txt
@@ -1,10 +1,10 @@
 # This is an autogenerated file! Do not edit!
 # instead run make from .../device/generic/goldfish-opengl
 # which will re-generate this file.
-android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc/Android.mk" "a4b1fb11cf3e68cc49f055258b6b590798eeecb2d3e6e565c78549a39a341911")
+android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc/Android.mk" "103f3f10c8af73d3d5c4263c4faa5bb70ebdbfbc9ed6f068a338d57344e2aa45")
 set(vulkan_enc_src AndroidHardwareBuffer.cpp HostVisibleMemoryVirtualization.cpp Resources.cpp Validation.cpp VulkanStreamGuest.cpp VulkanHandleMapping.cpp ResourceTracker.cpp VkEncoder.cpp goldfish_vk_extension_structs_guest.cpp goldfish_vk_marshaling_guest.cpp goldfish_vk_deepcopy_guest.cpp goldfish_vk_handlemap_guest.cpp goldfish_vk_transform_guest.cpp)
 android_add_library(TARGET vulkan_enc SHARED LICENSE Apache-2.0 SRC AndroidHardwareBuffer.cpp HostVisibleMemoryVirtualization.cpp Resources.cpp Validation.cpp VulkanStreamGuest.cpp VulkanHandleMapping.cpp ResourceTracker.cpp VkEncoder.cpp goldfish_vk_extension_structs_guest.cpp goldfish_vk_marshaling_guest.cpp goldfish_vk_deepcopy_guest.cpp goldfish_vk_handlemap_guest.cpp goldfish_vk_transform_guest.cpp)
-target_include_directories(vulkan_enc PRIVATE ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/host/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/host/include/vulkan)
+target_include_directories(vulkan_enc PRIVATE ${GOLDFISH_DEVICE_ROOT}/shared/GoldfishAddressSpace/include ${GOLDFISH_DEVICE_ROOT}/android-emu ${GOLDFISH_DEVICE_ROOT}/system/renderControl_enc ${GOLDFISH_DEVICE_ROOT}/shared/OpenglCodecCommon ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include-types ${GOLDFISH_DEVICE_ROOT}/shared/qemupipe/include ${GOLDFISH_DEVICE_ROOT}/system/vulkan_enc ${GOLDFISH_DEVICE_ROOT}/./host/include/libOpenglRender ${GOLDFISH_DEVICE_ROOT}/./system/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/guest ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/host/include ${GOLDFISH_DEVICE_ROOT}/./../../../external/qemu/android/android-emugl/host/include/vulkan)
 target_compile_definitions(vulkan_enc PRIVATE "-DWITH_GLES2" "-DPLATFORM_SDK_VERSION=29" "-DGOLDFISH_HIDL_GRALLOC" "-DEMULATOR_OPENGL_POST_O=1" "-DHOST_BUILD" "-DANDROID" "-DGL_GLEXT_PROTOTYPES" "-DPAGE_SIZE=4096" "-DGOLDFISH_VULKAN" "-DLOG_TAG=\"goldfish_vulkan\"" "-DVK_ANDROID_native_buffer" "-DVK_GOOGLE_address_space" "-DVK_USE_PLATFORM_ANDROID_KHR" "-DVK_NO_PROTOTYPES" "-D__ANDROID_API__=28")
 target_compile_options(vulkan_enc PRIVATE "-fvisibility=default" "-Wno-unused-parameter" "-Wno-missing-field-initializers" "-Werror" "-fstrict-aliasing")
-target_link_libraries(vulkan_enc PRIVATE gui _renderControl_enc androidemu cutils utils log OpenglCodecCommon_host android-emu-shared)
\ No newline at end of file
+target_link_libraries(vulkan_enc PRIVATE gui log android-emu-shared androidemu cutils utils _renderControl_enc OpenglCodecCommon_host PRIVATE GoldfishAddressSpace_host qemupipe_host)
\ No newline at end of file
diff --git a/system/vulkan_enc/ResourceTracker.cpp b/system/vulkan_enc/ResourceTracker.cpp
index 4f513e0..8bd4b20 100644
--- a/system/vulkan_enc/ResourceTracker.cpp
+++ b/system/vulkan_enc/ResourceTracker.cpp
@@ -1845,14 +1845,14 @@
                         (unsigned long long)hvaSizeId[2]);
                 mLock.lock();
 
-                struct drm_virtgpu_resource_create_v2 drm_rc_v2 = { 0 };
-                drm_rc_v2.args = (uint64_t)&hvaSizeId[2];
-                drm_rc_v2.args_size = sizeof(uint64_t);
-                drm_rc_v2.size = hvaSizeId[1];
-                drm_rc_v2.flags = VIRTGPU_RESOURCE_TYPE_HOST;
+                struct drm_virtgpu_resource_create_blob drm_rc_blob = { 0 };
+                drm_rc_blob.blob_mem = VIRTGPU_BLOB_MEM_HOST;
+                drm_rc_blob.blob_flags = VIRTGPU_BLOB_FLAG_MAPPABLE;
+                drm_rc_blob.blob_id = hvaSizeId[2];
+                drm_rc_blob.size = hvaSizeId[1];
 
                 int res = drmIoctl(
-                    mRendernodeFd, DRM_IOCTL_VIRTGPU_RESOURCE_CREATE_V2, &drm_rc_v2);
+                    mRendernodeFd, DRM_IOCTL_VIRTGPU_RESOURCE_CREATE_BLOB, &drm_rc_blob);
 
                 if (res) {
                     ALOGE("%s: Failed to resource create v2: sterror: %s errno: %d\n", __func__,
@@ -1861,7 +1861,7 @@
                 }
 
                 struct drm_virtgpu_map map_info = {
-                    .handle = drm_rc_v2.bo_handle,
+                    .handle = drm_rc_blob.bo_handle,
                 };
 
                 res = drmIoctl(mRendernodeFd, DRM_IOCTL_VIRTGPU_MAP, &map_info);
@@ -2775,7 +2775,7 @@
         VkSamplerCreateInfo localCreateInfo = vk_make_orphan_copy(*pCreateInfo);
         vk_struct_chain_iterator structChainIter = vk_make_chain_iterator(&localCreateInfo);
 
-#ifdef VK_USE_PLATFORM_ANDROID_KHR
+#if defined(VK_USE_PLATFORM_ANDROID_KHR) || defined(VK_USE_PLATFORM_FUCHSIA_KHR)
         VkSamplerYcbcrConversionInfo localVkSamplerYcbcrConversionInfo;
         const VkSamplerYcbcrConversionInfo* samplerYcbcrConversionInfo =
             vk_find_struct<VkSamplerYcbcrConversionInfo>(pCreateInfo);
diff --git a/system/vulkan_enc/VirtioGpuNext.h b/system/vulkan_enc/VirtioGpuNext.h
index 4037973..7da7da2 100644
--- a/system/vulkan_enc/VirtioGpuNext.h
+++ b/system/vulkan_enc/VirtioGpuNext.h
@@ -18,43 +18,37 @@
 #include "drm.h"
 #endif
 
-#define DRM_VIRTGPU_RESOURCE_CREATE_V2 0x0a
+#define DRM_VIRTGPU_RESOURCE_CREATE_BLOB 0x0a
 
-struct drm_virtgpu_resource_create_v2 {
-#define VIRTGPU_RESOURCE_TYPE_MASK       0x0000f
-#define VIRTGPU_RESOURCE_TYPE_DEFAULT_V1 0x00001
-#define VIRTGPU_RESOURCE_TYPE_DEFAULT_V2 0x00002
-#define VIRTGPU_RESOURCE_TYPE_HOST       0x00003
-#define VIRTGPU_RESOURCE_TYPE_GUEST      0x00004
-/*
- * Error cases:
- * HOST_VISIBLE_BIT without VIRTGPU_RESOURCE_TYPE_HOST
- */
-#define VIRTGPU_RESOURCE_HOST_MASK            0x000f0
-#define VIRTGPU_RESOURCE_HOST_VISIBLE_BIT     0x00010
+#define VIRTGPU_PARAM_RESOURCE_BLOB 3 /* DRM_VIRTGPU_RESOURCE_CREATE_BLOB */
+#define VIRTGPU_PARAM_HOST_VISIBLE 4
 
-#define VIRTGPU_RESOURCE_GUEST_MASK                  0x00f00
-#define VIRTGPU_RESOURCE_GUEST_SHARED_BIT            0x00100
-#define VIRTGPU_RESOURCE_GUEST_EMULATED_COHERENT_BIT 0x00200
+struct drm_virtgpu_resource_create_blob {
+#define VIRTGPU_BLOB_MEM_GUEST              0x0001
+#define VIRTGPU_BLOB_MEM_HOST               0x0002
+#define VIRTGPU_BLOB_MEM_HOST_GUEST         0x0003
 
-#define VIRTGPU_RESOURCE_CACHE_MASK      0x0f000
-#define VIRTGPU_RESOURCE_CACHE_CACHED    0x01000
-#define VIRTGPU_RESOURCE_CACHE_UNCACHED  0x02000
-#define VIRTGPU_RESOURCE_CACHE_WC        0x03000
-/*
- * VIRTGPU_RESOURCE_EXPORTABLE_BIT - host resource *can* be exported as an fd.
- */
-#define VIRTGPU_RESOURCE_EXPORT_MASK    0xf0000
-#define VIRTGPU_RESOURCE_EXPORTABLE_BIT 0x10000
-	uint32_t flags;
-	uint32_t args_size;
-	uint64_t size;
-	uint32_t bo_handle;
-	uint32_t res_handle;
-	uint64_t args;
+#define VIRTGPU_BLOB_FLAG_MAPPABLE          0x0001
+#define VIRTGPU_BLOB_FLAG_SHAREABLE         0x0002
+#define VIRTGPU_BLOB_FLAG_CROSS_DEVICE      0x0004
+	/* zero is invalid blob_mem */
+    uint32_t blob_mem;
+    uint32_t blob_flags;
+    uint32_t bo_handle;
+    uint32_t res_handle;
+    uint64_t size;
+
+	/*
+	 * for 3D contexts with VIRTGPU_BLOB_MEM_HOSTGUEST and
+	 * VIRTGPU_BLOB_MEM_HOST otherwise, must be zero.
+	 */
+	uint32_t pad;
+    uint32_t cmd_size;
+    uint64_t cmd;
+    uint64_t blob_id;
 };
 
-#define DRM_IOCTL_VIRTGPU_RESOURCE_CREATE_V2				\
-	DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_RESOURCE_CREATE_V2,	\
-		struct drm_virtgpu_resource_create_v2)
 
+#define DRM_IOCTL_VIRTGPU_RESOURCE_CREATE_BLOB              \
+        DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_RESOURCE_CREATE_BLOB,   \
+                        struct drm_virtgpu_resource_create_blob)
diff --git a/system/vulkan_enc/VulkanHandles.h b/system/vulkan_enc/VulkanHandles.h
index 376f2fc..54699aa 100644
--- a/system/vulkan_enc/VulkanHandles.h
+++ b/system/vulkan_enc/VulkanHandles.h
@@ -26,6 +26,18 @@
     f(VkCommandBuffer) \
     GOLDFISH_VK_LIST_TRIVIAL_DISPATCHABLE_HANDLE_TYPES(f)
 
+#ifdef VK_NVX_device_generated_commands
+
+#define __GOLDFISH_VK_LIST_NON_DISPATCHABLE_HANDLE_TYPES_NVX_DEVICE_GENERATED_COMMANDS(f) \
+    f(VkObjectTableNVX) \
+    f(VkIndirectCommandsLayoutNVX) \
+
+#else
+
+#define __GOLDFISH_VK_LIST_NON_DISPATCHABLE_HANDLE_TYPES_NVX_DEVICE_GENERATED_COMMANDS(f)
+
+#endif // VK_NVX_device_generated_commands
+
 #define GOLDFISH_VK_LIST_TRIVIAL_NON_DISPATCHABLE_HANDLE_TYPES(f) \
     f(VkBufferView) \
     f(VkImageView) \
@@ -44,11 +56,10 @@
     f(VkSwapchainKHR) \
     f(VkDisplayKHR) \
     f(VkDisplayModeKHR) \
-    f(VkObjectTableNVX) \
-    f(VkIndirectCommandsLayoutNVX) \
     f(VkValidationCacheEXT) \
     f(VkDebugReportCallbackEXT) \
     f(VkDebugUtilsMessengerEXT) \
+    __GOLDFISH_VK_LIST_NON_DISPATCHABLE_HANDLE_TYPES_NVX_DEVICE_GENERATED_COMMANDS(f)
 
 #define GOLDFISH_VK_LIST_NON_DISPATCHABLE_HANDLE_TYPES(f) \
     f(VkDeviceMemory) \