aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-06-21 23:01:30 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-06-21 23:01:30 +0000
commit9101591b57f478be8227823d4cc5ac65186e26d7 (patch)
treec461919dbeed324789255ef1a343aff72766e7f6
parent4fb1612449136be68c637359824884b22aad7eb9 (diff)
parent63dd02e53bee711a72f741b46adae887276c8827 (diff)
downloadgoldfish-opengl-android14-tests-release.tar.gz
Change-Id: I11bbbc9a3af01140c007e36b1244fd6c589f3b5d
-rw-r--r--system/codecs/c2/decoders/avcdec/Android.bp1
-rw-r--r--system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.cpp11
-rw-r--r--system/codecs/c2/decoders/base/Android.bp1
-rw-r--r--system/codecs/c2/decoders/base/color_buffer_utils.cpp17
-rw-r--r--system/codecs/c2/decoders/base/include/color_buffer_utils.h2
-rw-r--r--system/codecs/c2/decoders/hevcdec/C2GoldfishHevcDec.cpp11
-rw-r--r--system/codecs/c2/decoders/vpxdec/C2GoldfishVpxDec.cpp11
-rw-r--r--system/hals/Android.bp38
8 files changed, 86 insertions, 6 deletions
diff --git a/system/codecs/c2/decoders/avcdec/Android.bp b/system/codecs/c2/decoders/avcdec/Android.bp
index 5d840b05..672a80f1 100644
--- a/system/codecs/c2/decoders/avcdec/Android.bp
+++ b/system/codecs/c2/decoders/avcdec/Android.bp
@@ -27,6 +27,7 @@ cc_library_shared {
header_libs: [
"libgralloc_cb.ranchu",
+ "libgralloc_cb3.ranchu",
],
static_libs: ["libavcdec",
diff --git a/system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.cpp b/system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.cpp
index 74d971f2..4a89613a 100644
--- a/system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.cpp
+++ b/system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.cpp
@@ -748,8 +748,15 @@ void C2GoldfishAvcDec::checkMode(const std::shared_ptr<C2BlockPool> &pool) {
const bool isGraphic = (pool->getAllocatorId() & C2Allocator::GRAPHIC);
DDD("buffer pool allocator id %x", (int)(pool->getAllocatorId()));
if (isGraphic) {
- DDD("decoding to host color buffer");
- mEnableAndroidNativeBuffers = true;
+ uint64_t client_usage = getClientUsage(pool);
+ DDD("client has usage as 0x%llx", client_usage);
+ if (client_usage & BufferUsage::CPU_READ_MASK) {
+ DDD("decoding to guest byte buffer as client has read usage");
+ mEnableAndroidNativeBuffers = false;
+ } else {
+ DDD("decoding to host color buffer");
+ mEnableAndroidNativeBuffers = true;
+ }
} else {
DDD("decoding to guest byte buffer");
mEnableAndroidNativeBuffers = false;
diff --git a/system/codecs/c2/decoders/base/Android.bp b/system/codecs/c2/decoders/base/Android.bp
index 348334bd..8dc15964 100644
--- a/system/codecs/c2/decoders/base/Android.bp
+++ b/system/codecs/c2/decoders/base/Android.bp
@@ -47,6 +47,7 @@ cc_library_shared {
header_libs: [
"libgralloc_cb.ranchu",
+ "libgralloc_cb3.ranchu",
],
sanitize: {
diff --git a/system/codecs/c2/decoders/base/color_buffer_utils.cpp b/system/codecs/c2/decoders/base/color_buffer_utils.cpp
index a36ba323..99563f49 100644
--- a/system/codecs/c2/decoders/base/color_buffer_utils.cpp
+++ b/system/codecs/c2/decoders/base/color_buffer_utils.cpp
@@ -19,8 +19,11 @@
#include <android-base/strings.h>
#include <log/log.h>
#include <gralloc_cb_bp.h>
+#include <cb_handle_30.h>
#include <xf86drm.h>
+#include <C2AllocatorGralloc.h>
+
#include "cros_gralloc_handle.h"
#include "virtgpu_drm.h"
@@ -114,3 +117,17 @@ static ColorBufferUtilsGlobalState* getGlobals() {
uint32_t getColorBufferHandle(native_handle_t const* handle) {
return getGlobals()->getColorBufferHandle(handle);
}
+
+uint64_t getClientUsage(const std::shared_ptr<C2BlockPool> &pool) {
+ std::shared_ptr<C2GraphicBlock> myOutBlock;
+ const C2MemoryUsage usage = {0, 0};
+ const uint32_t format = HAL_PIXEL_FORMAT_YCBCR_420_888;
+ pool->fetchGraphicBlock(2, 2, format, usage, &myOutBlock);
+ auto myc2Handle = myOutBlock->handle();
+ native_handle_t *mygrallocHandle =
+ android::UnwrapNativeCodec2GrallocHandle(myc2Handle);
+ cb_handle_30_t* mycb = (cb_handle_30_t*)(mygrallocHandle);
+ ALOGV("%s %s %d: client usage 0x%x", __FILE__, __func__, __LINE__, mycb->usage);
+ return mycb->usage;
+}
+
diff --git a/system/codecs/c2/decoders/base/include/color_buffer_utils.h b/system/codecs/c2/decoders/base/include/color_buffer_utils.h
index d0a78762..ebb8527c 100644
--- a/system/codecs/c2/decoders/base/include/color_buffer_utils.h
+++ b/system/codecs/c2/decoders/base/include/color_buffer_utils.h
@@ -14,5 +14,7 @@
* limitations under the License.
*/
#include <cutils/native_handle.h>
+#include <SimpleC2Interface.h>
uint32_t getColorBufferHandle(native_handle_t const* handle);
+uint64_t getClientUsage(const std::shared_ptr<C2BlockPool> &pool);
diff --git a/system/codecs/c2/decoders/hevcdec/C2GoldfishHevcDec.cpp b/system/codecs/c2/decoders/hevcdec/C2GoldfishHevcDec.cpp
index c60138b0..14eed1f6 100644
--- a/system/codecs/c2/decoders/hevcdec/C2GoldfishHevcDec.cpp
+++ b/system/codecs/c2/decoders/hevcdec/C2GoldfishHevcDec.cpp
@@ -696,8 +696,15 @@ void C2GoldfishHevcDec::checkMode(const std::shared_ptr<C2BlockPool> &pool) {
const bool isGraphic = (pool->getAllocatorId() & C2Allocator::GRAPHIC);
DDD("buffer pool allocator id %x", (int)(pool->getAllocatorId()));
if (isGraphic) {
- DDD("decoding to host color buffer");
- mEnableAndroidNativeBuffers = true;
+ uint64_t client_usage = getClientUsage(pool);
+ DDD("client has usage as 0x%llx", client_usage);
+ if (client_usage & BufferUsage::CPU_READ_MASK) {
+ DDD("decoding to guest byte buffer as client has read usage");
+ mEnableAndroidNativeBuffers = false;
+ } else {
+ DDD("decoding to host color buffer");
+ mEnableAndroidNativeBuffers = true;
+ }
} else {
DDD("decoding to guest byte buffer");
mEnableAndroidNativeBuffers = false;
diff --git a/system/codecs/c2/decoders/vpxdec/C2GoldfishVpxDec.cpp b/system/codecs/c2/decoders/vpxdec/C2GoldfishVpxDec.cpp
index 59030d40..16551388 100644
--- a/system/codecs/c2/decoders/vpxdec/C2GoldfishVpxDec.cpp
+++ b/system/codecs/c2/decoders/vpxdec/C2GoldfishVpxDec.cpp
@@ -499,8 +499,15 @@ void C2GoldfishVpxDec::checkContext(const std::shared_ptr<C2BlockPool> &pool) {
const bool isGraphic = (pool->getAllocatorId() & C2Allocator::GRAPHIC);
DDD("buffer pool allocator id %x", (int)(pool->getAllocatorId()));
if (isGraphic) {
- DDD("decoding to host color buffer");
- mEnableAndroidNativeBuffers = true;
+ uint64_t client_usage = getClientUsage(pool);
+ DDD("client has usage as 0x%llx", client_usage);
+ if (client_usage & BufferUsage::CPU_READ_MASK) {
+ DDD("decoding to guest byte buffer as client has read usage");
+ mEnableAndroidNativeBuffers = false;
+ } else {
+ DDD("decoding to host color buffer");
+ mEnableAndroidNativeBuffers = true;
+ }
} else {
DDD("decoding to guest byte buffer");
mEnableAndroidNativeBuffers = false;
diff --git a/system/hals/Android.bp b/system/hals/Android.bp
new file mode 100644
index 00000000..cec9efb3
--- /dev/null
+++ b/system/hals/Android.bp
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+
+package {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "device_generic_goldfish-opengl_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["device_generic_goldfish-opengl_license"],
+}
+
+cc_library_headers {
+ name: "libgralloc_cb3.ranchu",
+ vendor_available: true,
+ export_include_dirs: ["."],
+ header_libs: [
+ "libcutils_headers",
+ "libqemupipe-types.ranchu",
+ ],
+ export_header_lib_headers: [
+ "libcutils_headers",
+ "libqemupipe-types.ranchu"
+ ],
+}