Merge "[frameworks][native][libs]{math|ui} fix -Wimplicit-int-float-conversion"
diff --git a/libs/android_runtime_lazy/Android.bp b/libs/android_runtime_lazy/Android.bp
index 2d6292c..09a5f39 100644
--- a/libs/android_runtime_lazy/Android.bp
+++ b/libs/android_runtime_lazy/Android.bp
@@ -52,10 +52,6 @@
"libutils",
],
- required: [
- "libandroid_runtime",
- ],
-
export_include_dirs: [
"include",
],
diff --git a/libs/binder/Android.bp b/libs/binder/Android.bp
index e5646ef..643a956 100644
--- a/libs/binder/Android.bp
+++ b/libs/binder/Android.bp
@@ -73,7 +73,6 @@
// or dessert updates. Instead, apex users should use libbinder_ndk.
apex_available: [
"//apex_available:platform",
- "com.android.vndk.current",
// TODO(b/139016109) remove these three
"com.android.media.swcodec",
"test_com.android.media.swcodec",
diff --git a/libs/binder/BpBinder.cpp b/libs/binder/BpBinder.cpp
index 50c7053..238c9dc 100644
--- a/libs/binder/BpBinder.cpp
+++ b/libs/binder/BpBinder.cpp
@@ -214,16 +214,21 @@
{
// Once a binder has died, it will never come back to life.
if (mAlive) {
+ bool privateVendor = flags & FLAG_PRIVATE_VENDOR;
+ // don't send userspace flags to the kernel
+ flags = flags & ~FLAG_PRIVATE_VENDOR;
+
// user transactions require a given stability level
if (code >= FIRST_CALL_TRANSACTION && code <= LAST_CALL_TRANSACTION) {
using android::internal::Stability;
auto stability = Stability::get(this);
+ auto required = privateVendor ? Stability::VENDOR : Stability::kLocalStability;
- if (CC_UNLIKELY(!Stability::check(stability, Stability::kLocalStability))) {
+ if (CC_UNLIKELY(!Stability::check(stability, required))) {
ALOGE("Cannot do a user transaction on a %s binder in a %s context.",
Stability::stabilityString(stability).c_str(),
- Stability::stabilityString(Stability::kLocalStability).c_str());
+ Stability::stabilityString(required).c_str());
return BAD_TYPE;
}
}
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index 9b47f80..6345640 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -505,7 +505,7 @@
}
}
-#if defined(__ANDROID_APEX_COM_ANDROID_VNDK_CURRENT__) || (defined(__ANDROID_VNDK__) && !defined(__ANDROID_APEX__))
+#if defined(__ANDROID_VNDK__) && !defined(__ANDROID_APEX__)
constexpr int32_t kHeader = B_PACK_CHARS('V', 'N', 'D', 'R');
#else
constexpr int32_t kHeader = B_PACK_CHARS('S', 'Y', 'S', 'T');
diff --git a/libs/binder/TEST_MAPPING b/libs/binder/TEST_MAPPING
index 136bdb0..b3afd81 100644
--- a/libs/binder/TEST_MAPPING
+++ b/libs/binder/TEST_MAPPING
@@ -4,6 +4,9 @@
"name": "binderSafeInterfaceTest"
},
{
+ "name": "binderVendorDoubleLoadTest"
+ },
+ {
"name": "binderDriverInterfaceTest"
},
{
@@ -14,6 +17,9 @@
},
{
"name": "binderStabilityTest"
+ },
+ {
+ "name": "CtsNdkBinderTestCases"
}
]
}
diff --git a/libs/binder/include/binder/IBinder.h b/libs/binder/include/binder/IBinder.h
index 64f3052..64604b7 100644
--- a/libs/binder/include/binder/IBinder.h
+++ b/libs/binder/include/binder/IBinder.h
@@ -62,7 +62,11 @@
DEBUG_PID_TRANSACTION = B_PACK_CHARS('_', 'P', 'I', 'D'),
// Corresponds to TF_ONE_WAY -- an asynchronous call.
- FLAG_ONEWAY = 0x00000001
+ FLAG_ONEWAY = 0x00000001,
+
+ // Private userspace flag for transaction which is being requested from
+ // a vendor context.
+ FLAG_PRIVATE_VENDOR = 0x10000000,
};
IBinder();
diff --git a/libs/binder/include/binder/Stability.h b/libs/binder/include/binder/Stability.h
index b2f51d3..2894482 100644
--- a/libs/binder/include/binder/Stability.h
+++ b/libs/binder/include/binder/Stability.h
@@ -81,7 +81,7 @@
VINTF = 0b111111,
};
-#if defined(__ANDROID_APEX_COM_ANDROID_VNDK_CURRENT__) || (defined(__ANDROID_VNDK__) && !defined(__ANDROID_APEX__))
+#if defined(__ANDROID_VNDK__) && !defined(__ANDROID_APEX__)
static constexpr Level kLocalStability = Level::VENDOR;
#else
static constexpr Level kLocalStability = Level::SYSTEM;
diff --git a/libs/binder/ndk/ibinder.cpp b/libs/binder/ndk/ibinder.cpp
index b06ca86..e752c45 100644
--- a/libs/binder/ndk/ibinder.cpp
+++ b/libs/binder/ndk/ibinder.cpp
@@ -17,6 +17,7 @@
#include <android/binder_ibinder.h>
#include "ibinder_internal.h"
+#include <android/binder_stability.h>
#include <android/binder_status.h>
#include "parcel_internal.h"
#include "status_internal.h"
@@ -542,7 +543,8 @@
return STATUS_UNKNOWN_TRANSACTION;
}
- if ((flags & ~FLAG_ONEWAY) != 0) {
+ constexpr binder_flags_t kAllFlags = FLAG_PRIVATE_VENDOR | FLAG_ONEWAY;
+ if ((flags & ~kAllFlags) != 0) {
LOG(ERROR) << __func__ << ": Unrecognized flags sent: " << flags;
return STATUS_BAD_VALUE;
}
diff --git a/libs/binder/ndk/include_ndk/android/binder_auto_utils.h b/libs/binder/ndk/include_ndk/android/binder_auto_utils.h
index c6868b0..dc3c8d2 100644
--- a/libs/binder/ndk/include_ndk/android/binder_auto_utils.h
+++ b/libs/binder/ndk/include_ndk/android/binder_auto_utils.h
@@ -201,7 +201,22 @@
/**
* See AStatus_isOk.
*/
- bool isOk() { return get() != nullptr && AStatus_isOk(get()); }
+ bool isOk() const { return get() != nullptr && AStatus_isOk(get()); }
+
+ /**
+ * See AStatus_getExceptionCode
+ */
+ binder_exception_t getExceptionCode() const { return AStatus_getExceptionCode(get()); }
+
+ /**
+ * See AStatus_getServiceSpecificError
+ */
+ int32_t getServiceSpecificError() const { return AStatus_getServiceSpecificError(get()); }
+
+ /**
+ * See AStatus_getStatus
+ */
+ binder_status_t getStatus() const { return AStatus_getStatus(get()); }
/**
* Convenience method for okay status.
diff --git a/libs/binder/ndk/include_platform/android/binder_stability.h b/libs/binder/ndk/include_platform/android/binder_stability.h
index 924812e..e1a8cfd 100644
--- a/libs/binder/ndk/include_platform/android/binder_stability.h
+++ b/libs/binder/ndk/include_platform/android/binder_stability.h
@@ -20,8 +20,21 @@
__BEGIN_DECLS
-#if defined(__ANDROID_APEX_COM_ANDROID_VNDK_CURRENT__) || \
- (defined(__ANDROID_VNDK__) && !defined(__ANDROID_APEX__))
+/**
+ * Private addition to binder_flag_t.
+ */
+enum {
+ /**
+ * Indicates that this transaction is coupled w/ vendor.img
+ */
+ FLAG_PRIVATE_VENDOR = 0x10000000,
+};
+
+#if (defined(__ANDROID_VNDK__) && !defined(__ANDROID_APEX__))
+
+enum {
+ FLAG_PRIVATE_LOCAL = FLAG_PRIVATE_VENDOR,
+};
/**
* This interface has the stability of the vendor image.
@@ -32,8 +45,11 @@
AIBinder_markVendorStability(binder);
}
-#else // defined(__ANDROID_APEX_COM_ANDROID_VNDK_CURRENT__) || (defined(__ANDROID_VNDK__) &&
- // !defined(__ANDROID_APEX__))
+#else // defined(__ANDROID_VNDK__) && !defined(__ANDROID_APEX__)
+
+enum {
+ FLAG_PRIVATE_LOCAL = 0,
+};
/**
* This interface has the stability of the system image.
@@ -44,8 +60,7 @@
AIBinder_markSystemStability(binder);
}
-#endif // defined(__ANDROID_APEX_COM_ANDROID_VNDK_CURRENT__) || (defined(__ANDROID_VNDK__) &&
- // !defined(__ANDROID_APEX__))
+#endif // defined(__ANDROID_VNDK__) && !defined(__ANDROID_APEX__)
/**
* This interface has system<->vendor stability
diff --git a/libs/binder/ndk/test/Android.bp b/libs/binder/ndk/test/Android.bp
index bb1fe2f..1c5dba3 100644
--- a/libs/binder/ndk/test/Android.bp
+++ b/libs/binder/ndk/test/Android.bp
@@ -67,3 +67,31 @@
srcs: ["main_server.cpp"],
gtest: false,
}
+
+cc_test {
+ name: "binderVendorDoubleLoadTest",
+ vendor: true,
+ srcs: [
+ "binderVendorDoubleLoadTest.cpp",
+ ],
+ static_libs: [
+ "IBinderVendorDoubleLoadTest-cpp",
+ "IBinderVendorDoubleLoadTest-ndk_platform",
+ ],
+ shared_libs: [
+ "libbase",
+ "libbinder",
+ "libbinder_ndk",
+ "libutils",
+ ],
+ test_suites: ["device-tests"],
+}
+
+aidl_interface {
+ name: "IBinderVendorDoubleLoadTest",
+ // TODO(b/119771576): only vendor is needed
+ vendor_available: true,
+ srcs: [
+ "IBinderVendorDoubleLoadTest.aidl",
+ ],
+}
diff --git a/libs/binder/ndk/test/AndroidTest.xml b/libs/binder/ndk/test/AndroidTest.xml
new file mode 100644
index 0000000..89646f7
--- /dev/null
+++ b/libs/binder/ndk/test/AndroidTest.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 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.
+-->
+<configuration description="Runs binderVendorDoubleLoadTest.">
+ <option name="test-suite-tag" value="apct" />
+ <option name="test-suite-tag" value="apct-native" />
+
+ <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/>
+
+ <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
+ <option name="cleanup" value="true" />
+ <option name="push" value="binderVendorDoubleLoadTest->/data/nativetest/vendor/binderVendorDoubleLoadTest" />
+ </target_preparer>
+
+ <test class="com.android.tradefed.testtype.GTest" >
+ <option name="native-test-device-path" value="/data/nativetest/vendor" />
+ <option name="module-name" value="binderVendorDoubleLoadTest" />
+ </test>
+</configuration>
+
diff --git a/libs/binder/ndk/test/IBinderVendorDoubleLoadTest.aidl b/libs/binder/ndk/test/IBinderVendorDoubleLoadTest.aidl
new file mode 100644
index 0000000..3a5bd9c
--- /dev/null
+++ b/libs/binder/ndk/test/IBinderVendorDoubleLoadTest.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+interface IBinderVendorDoubleLoadTest {
+ @utf8InCpp String RepeatString(@utf8InCpp String toRepeat);
+}
diff --git a/libs/binder/ndk/test/binderVendorDoubleLoadTest.cpp b/libs/binder/ndk/test/binderVendorDoubleLoadTest.cpp
new file mode 100644
index 0000000..f72dc36
--- /dev/null
+++ b/libs/binder/ndk/test/binderVendorDoubleLoadTest.cpp
@@ -0,0 +1,149 @@
+/*
+ * Copyright (C) 2019 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 <BnBinderVendorDoubleLoadTest.h>
+#include <aidl/BnBinderVendorDoubleLoadTest.h>
+#include <android-base/logging.h>
+#include <android-base/properties.h>
+#include <android-base/strings.h>
+#include <android/binder_ibinder.h>
+#include <android/binder_manager.h>
+#include <android/binder_process.h>
+#include <android/binder_stability.h>
+#include <binder/IPCThreadState.h>
+#include <binder/IServiceManager.h>
+#include <binder/ProcessState.h>
+#include <binder/Stability.h>
+#include <binder/Status.h>
+#include <gtest/gtest.h>
+
+#include <sys/prctl.h>
+
+using namespace android;
+using ::android::base::EndsWith;
+using ::android::base::GetProperty;
+using ::android::base::Split;
+using ::android::binder::Status;
+using ::android::internal::Stability;
+using ::ndk::ScopedAStatus;
+using ::ndk::SharedRefBase;
+using ::ndk::SpAIBinder;
+
+static const std::string kLocalNdkServerName = "NdkServer-local-IBinderVendorDoubleLoadTest";
+static const std::string kRemoteNdkServerName = "NdkServer-remote-IBinderVendorDoubleLoadTest";
+
+class NdkServer : public aidl::BnBinderVendorDoubleLoadTest {
+ ScopedAStatus RepeatString(const std::string& in, std::string* out) override {
+ *out = in;
+ return ScopedAStatus::ok();
+ }
+};
+class CppServer : public BnBinderVendorDoubleLoadTest {
+ Status RepeatString(const std::string& in, std::string* out) override {
+ *out = in;
+ return Status::ok();
+ }
+};
+
+TEST(DoubleBinder, VendorCppCantCallIntoSystem) {
+ Vector<String16> services = defaultServiceManager()->listServices();
+ EXPECT_TRUE(services.empty());
+}
+
+TEST(DoubleBinder, VendorCppCantRegisterService) {
+ sp<CppServer> cppServer = new CppServer;
+ status_t status = defaultServiceManager()->addService(String16("anything"), cppServer);
+ EXPECT_EQ(EX_TRANSACTION_FAILED, status);
+}
+
+TEST(DoubleBinder, CppVendorCantManuallyMarkVintfStability) {
+ // this test also implies that stability logic is turned on in vendor
+ ASSERT_DEATH(
+ {
+ sp<IBinder> binder = new CppServer();
+ Stability::markVintf(binder.get());
+ },
+ "Should only mark known object.");
+}
+
+TEST(DoubleBinder, NdkVendorCantManuallyMarkVintfStability) {
+ // this test also implies that stability logic is turned on in vendor
+ ASSERT_DEATH(
+ {
+ std::shared_ptr<NdkServer> ndkServer = SharedRefBase::make<NdkServer>();
+ AIBinder_markVintfStability(ndkServer->asBinder().get());
+ },
+ "Should only mark known object.");
+}
+
+TEST(DoubleBinder, CallIntoNdk) {
+ for (const std::string& serviceName : {kLocalNdkServerName, kRemoteNdkServerName}) {
+ SpAIBinder binder = SpAIBinder(AServiceManager_checkService(serviceName.c_str()));
+ ASSERT_NE(nullptr, binder.get()) << serviceName;
+ EXPECT_EQ(STATUS_OK, AIBinder_ping(binder.get())) << serviceName;
+
+ std::shared_ptr<aidl::IBinderVendorDoubleLoadTest> server =
+ aidl::IBinderVendorDoubleLoadTest::fromBinder(binder);
+
+ ASSERT_NE(nullptr, server.get()) << serviceName;
+
+ EXPECT_EQ(STATUS_OK, AIBinder_ping(server->asBinder().get()));
+
+ std::string outString;
+ ScopedAStatus status = server->RepeatString("foo", &outString);
+ EXPECT_EQ(STATUS_OK, AStatus_getExceptionCode(status.get())) << serviceName;
+ EXPECT_EQ("foo", outString) << serviceName;
+ }
+}
+
+void initDrivers() {
+ // Explicitly instantiated with the same driver that system would use.
+ // __ANDROID_VNDK__ right now uses /dev/vndbinder by default.
+ ProcessState::initWithDriver("/dev/binder");
+ ProcessState::self()->startThreadPool();
+ ABinderProcess_startThreadPool();
+}
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+
+ if (fork() == 0) {
+ // child process
+
+ prctl(PR_SET_PDEATHSIG, SIGHUP);
+
+ initDrivers();
+
+ // REMOTE SERVERS
+ std::shared_ptr<NdkServer> ndkServer = SharedRefBase::make<NdkServer>();
+ CHECK(STATUS_OK == AServiceManager_addService(ndkServer->asBinder().get(),
+ kRemoteNdkServerName.c_str()));
+
+ // OR sleep forever or whatever, it doesn't matter
+ IPCThreadState::self()->joinThreadPool(true);
+ exit(1); // should not reach
+ }
+
+ sleep(1);
+
+ initDrivers();
+
+ // LOCAL SERVERS
+ std::shared_ptr<NdkServer> ndkServer = SharedRefBase::make<NdkServer>();
+ AServiceManager_addService(ndkServer->asBinder().get(), kLocalNdkServerName.c_str());
+
+ return RUN_ALL_TESTS();
+}
diff --git a/libs/nativewindow/AHardwareBuffer.cpp b/libs/nativewindow/AHardwareBuffer.cpp
index 9bd3095..1ec73ce 100644
--- a/libs/nativewindow/AHardwareBuffer.cpp
+++ b/libs/nativewindow/AHardwareBuffer.cpp
@@ -266,10 +266,10 @@
char buf[CMSG_SPACE(kFdBufferSize)];
struct msghdr msg = {
- .msg_control = buf,
- .msg_controllen = sizeof(buf),
.msg_iov = &iov[0],
.msg_iovlen = 1,
+ .msg_control = buf,
+ .msg_controllen = sizeof(buf),
};
struct cmsghdr* cmsg = CMSG_FIRSTHDR(&msg);
@@ -306,10 +306,10 @@
iov[0].iov_len = kMessageBufferSize;
struct msghdr msg = {
- .msg_control = fdBuf,
- .msg_controllen = sizeof(fdBuf),
.msg_iov = &iov[0],
.msg_iovlen = 1,
+ .msg_control = fdBuf,
+ .msg_controllen = sizeof(fdBuf),
};
int result;
diff --git a/services/inputflinger/host/InputDriver.cpp b/services/inputflinger/host/InputDriver.cpp
index 2f046c3..683c05d 100644
--- a/services/inputflinger/host/InputDriver.cpp
+++ b/services/inputflinger/host/InputDriver.cpp
@@ -127,10 +127,10 @@
input_bus_t bus, const char* uniqueId) {
auto identifier = new ::input_device_identifier {
.name = name,
- .productId = productId,
- .vendorId = vendorId,
- .bus = bus,
.uniqueId = uniqueId,
+ .bus = bus,
+ .vendorId = vendorId,
+ .productId = productId,
};
// TODO: store this identifier somewhere
return identifier;
diff --git a/vulkan/libvulkan/api.cpp b/vulkan/libvulkan/api.cpp
index 71048db..3d56656 100644
--- a/vulkan/libvulkan/api.cpp
+++ b/vulkan/libvulkan/api.cpp
@@ -519,7 +519,11 @@
get_device_proc_addr_(nullptr),
driver_extensions_(nullptr),
driver_extension_count_(0) {
- enabled_extensions_.set(driver::ProcHook::EXTENSION_CORE);
+ // advertise the loader supported core Vulkan API version at vulkan::api
+ for (uint32_t i = driver::ProcHook::EXTENSION_CORE_1_0;
+ i != driver::ProcHook::EXTENSION_COUNT; ++i) {
+ enabled_extensions_.set(i);
+ }
}
LayerChain::~LayerChain() {
diff --git a/vulkan/libvulkan/code-generator.tmpl b/vulkan/libvulkan/code-generator.tmpl
index bdd3573..a5a0405 100644
--- a/vulkan/libvulkan/code-generator.tmpl
+++ b/vulkan/libvulkan/code-generator.tmpl
@@ -765,6 +765,19 @@
{{end}}
+
+{{/*
+------------------------------------------------------------------------------
+ Emits the ProcHook enum for core Vulkan API verions.
+------------------------------------------------------------------------------
+*/}}
+{{define "driver.GetProcHookEnum"}}
+ {{if GetAnnotation $ "vulkan1_1"}}ProcHook::EXTENSION_CORE_1_1
+ {{else}}ProcHook::EXTENSION_CORE_1_0
+ {{end}}
+{{end}}
+
+
{{/*
------------------------------------------------------------------------------
Emits true if a function needs a ProcHook stub.
@@ -778,6 +791,8 @@
{{if $ext}}
{{if not (Macro "IsExtensionInternal" $ext)}}true{{end}}
{{end}}
+
+ {{if GetAnnotation $ "vulkan1_1"}}true{{end}}
{{end}}
{{end}}
@@ -801,7 +816,8 @@
{{TrimPrefix "VK_" $e}},
{{end}}
¶
- EXTENSION_CORE, // valid bit
+ EXTENSION_CORE_1_0,
+ EXTENSION_CORE_1_1,
EXTENSION_COUNT,
EXTENSION_UNKNOWN,
};
@@ -838,14 +854,21 @@
{{AssertType $ "Function"}}
{{if (Macro "driver.NeedProcHookStub" $)}}
+ {{$ext_name := Strings ("")}}
+ {{$ext_hook := Strings ("")}}
{{$ext := GetAnnotation $ "extension"}}
- {{$ext_name := index $ext.Arguments 0}}
+ {{if $ext}}
+ {{$ext_name = index $ext.Arguments 0}}
+ {{$ext_hook = Strings ("ProcHook::") (Macro "BaseName" $ext)}}
+ {{else}}
+ {{$ext_name = Strings ("VK_VERSION_1_0")}}
+ {{$ext_hook = (Macro "driver.GetProcHookEnum" $)}}
+ {{end}}
{{$base := (Macro "BaseName" $)}}
VKAPI_ATTR {{Node "Type" $.Return}} checked{{$base}}({{Macro "Parameters" $}}) {
{{$p0 := index $.CallParameters 0}}
- {{$ext_hook := Strings ("ProcHook::") (Macro "BaseName" $ext)}}
if (GetData({{$p0.Name}}).hook_extensions[{{$ext_hook}}]) {
{{if not (IsVoid $.Return.Type)}}return §{{end}}
@@ -878,7 +901,7 @@
{
"{{$.Name}}",
ProcHook::GLOBAL,
- ProcHook::EXTENSION_CORE,
+ {{Macro "driver.GetProcHookEnum" $}},
reinterpret_cast<PFN_vkVoidFunction>({{$base}}),
nullptr,
},
@@ -911,7 +934,7 @@
nullptr,
{{end}}
{{else}}
- ProcHook::EXTENSION_CORE,
+ {{Macro "driver.GetProcHookEnum" $}},
reinterpret_cast<PFN_vkVoidFunction>({{$base}}),
nullptr,
{{end}}
@@ -934,18 +957,23 @@
ProcHook::DEVICE,
{{$ext := GetAnnotation $ "extension"}}
- {{if $ext}}
- ProcHook::{{Macro "BaseName" $ext}},
-
- {{if (Macro "IsExtensionInternal" $ext)}}
- nullptr,
- nullptr,
+ {{if or $ext (GetAnnotation $ "vulkan1_1")}}
+ {{if $ext}}
+ ProcHook::{{Macro "BaseName" $ext}},
+ {{if Macro "IsExtensionInternal" $ext}}
+ nullptr,
+ nullptr,
+ {{else}}
+ reinterpret_cast<PFN_vkVoidFunction>({{$base}}),
+ reinterpret_cast<PFN_vkVoidFunction>(checked{{$base}}),
+ {{end}}
{{else}}
+ {{Macro "driver.GetProcHookEnum" $}},
reinterpret_cast<PFN_vkVoidFunction>({{$base}}),
reinterpret_cast<PFN_vkVoidFunction>(checked{{$base}}),
{{end}}
{{else}}
- ProcHook::EXTENSION_CORE,
+ {{Macro "driver.GetProcHookEnum" $}},
reinterpret_cast<PFN_vkVoidFunction>({{$base}}),
nullptr,
{{end}}
diff --git a/vulkan/libvulkan/driver.cpp b/vulkan/libvulkan/driver.cpp
index 23506ba..c77fa06 100644
--- a/vulkan/libvulkan/driver.cpp
+++ b/vulkan/libvulkan/driver.cpp
@@ -104,6 +104,7 @@
VkResult Validate();
void DowngradeApiVersion();
+ void UpgradeDeviceCoreApiVersion(uint32_t api_version);
const std::bitset<ProcHook::EXTENSION_COUNT>& GetHookExtensions() const;
const std::bitset<ProcHook::EXTENSION_COUNT>& GetHalExtensions() const;
@@ -333,8 +334,12 @@
physical_dev_(VK_NULL_HANDLE),
instance_info_(create_info),
extension_filter_() {
- hook_extensions_.set(ProcHook::EXTENSION_CORE);
- hal_extensions_.set(ProcHook::EXTENSION_CORE);
+ // instance core versions need to match the loader api version
+ for (uint32_t i = ProcHook::EXTENSION_CORE_1_0;
+ i != ProcHook::EXTENSION_COUNT; ++i) {
+ hook_extensions_.set(i);
+ hal_extensions_.set(i);
+ }
}
CreateInfoWrapper::CreateInfoWrapper(VkPhysicalDevice physical_dev,
@@ -345,8 +350,9 @@
physical_dev_(physical_dev),
dev_info_(create_info),
extension_filter_() {
- hook_extensions_.set(ProcHook::EXTENSION_CORE);
- hal_extensions_.set(ProcHook::EXTENSION_CORE);
+ // initialize with baseline core API version
+ hook_extensions_.set(ProcHook::EXTENSION_CORE_1_0);
+ hal_extensions_.set(ProcHook::EXTENSION_CORE_1_0);
}
CreateInfoWrapper::~CreateInfoWrapper() {
@@ -545,7 +551,8 @@
case ProcHook::ANDROID_external_memory_android_hardware_buffer:
case ProcHook::ANDROID_native_buffer:
case ProcHook::GOOGLE_display_timing:
- case ProcHook::EXTENSION_CORE:
+ case ProcHook::EXTENSION_CORE_1_0:
+ case ProcHook::EXTENSION_CORE_1_1:
case ProcHook::EXTENSION_COUNT:
// Device and meta extensions. If we ever get here it's a bug in
// our code. But enumerating them lets us avoid having a default
@@ -593,7 +600,8 @@
case ProcHook::EXT_debug_report:
case ProcHook::EXT_swapchain_colorspace:
case ProcHook::ANDROID_native_buffer:
- case ProcHook::EXTENSION_CORE:
+ case ProcHook::EXTENSION_CORE_1_0:
+ case ProcHook::EXTENSION_CORE_1_1:
case ProcHook::EXTENSION_COUNT:
// Instance and meta extensions. If we ever get here it's a bug
// in our code. But enumerating them lets us avoid having a
@@ -641,6 +649,28 @@
}
}
+void CreateInfoWrapper::UpgradeDeviceCoreApiVersion(uint32_t api_version) {
+ ALOG_ASSERT(!is_instance_, "Device only API called by instance wrapper.");
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wold-style-cast"
+ api_version ^= VK_VERSION_PATCH(api_version);
+#pragma clang diagnostic pop
+ // cap the API version to the loader supported highest version
+ if (api_version > VK_API_VERSION_1_1)
+ api_version = VK_API_VERSION_1_1;
+ switch (api_version) {
+ case VK_API_VERSION_1_1:
+ hook_extensions_.set(ProcHook::EXTENSION_CORE_1_1);
+ hal_extensions_.set(ProcHook::EXTENSION_CORE_1_1);
+ [[clang::fallthrough]];
+ case VK_API_VERSION_1_0:
+ break;
+ default:
+ ALOGD("Unknown upgrade API version[%u]", api_version);
+ break;
+ }
+}
+
VKAPI_ATTR void* DefaultAllocate(void*,
size_t size,
size_t alignment,
@@ -776,7 +806,7 @@
: nullptr;
break;
case ProcHook::DEVICE:
- proc = (hook->extension == ProcHook::EXTENSION_CORE)
+ proc = (hook->extension == ProcHook::EXTENSION_CORE_1_0)
? hook->proc
: hook->checked_proc;
break;
@@ -1124,6 +1154,13 @@
if (!data)
return VK_ERROR_OUT_OF_HOST_MEMORY;
+ VkPhysicalDeviceProperties properties;
+ ATRACE_BEGIN("driver.GetPhysicalDeviceProperties");
+ instance_data.driver.GetPhysicalDeviceProperties(physicalDevice,
+ &properties);
+ ATRACE_END();
+
+ wrapper.UpgradeDeviceCoreApiVersion(properties.apiVersion);
data->hook_extensions |= wrapper.GetHookExtensions();
// call into the driver
@@ -1168,12 +1205,6 @@
return VK_ERROR_INCOMPATIBLE_DRIVER;
}
- VkPhysicalDeviceProperties properties;
- ATRACE_BEGIN("driver.GetPhysicalDeviceProperties");
- instance_data.driver.GetPhysicalDeviceProperties(physicalDevice,
- &properties);
- ATRACE_END();
-
if (properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU) {
// Log that the app is hitting software Vulkan implementation
android::GraphicsEnv::getInstance().setCpuVulkanInUse();
diff --git a/vulkan/libvulkan/driver.h b/vulkan/libvulkan/driver.h
index 57c956d..047a27a 100644
--- a/vulkan/libvulkan/driver.h
+++ b/vulkan/libvulkan/driver.h
@@ -67,9 +67,7 @@
: opaque_api_data(),
allocator(alloc),
driver(),
- get_device_proc_addr(nullptr) {
- hook_extensions.set(ProcHook::EXTENSION_CORE);
- }
+ get_device_proc_addr(nullptr) {}
api::InstanceData opaque_api_data;
@@ -89,9 +87,7 @@
: opaque_api_data(),
allocator(alloc),
debug_report_callbacks(debug_report_callbacks_),
- driver() {
- hook_extensions.set(ProcHook::EXTENSION_CORE);
- }
+ driver() {}
api::DeviceData opaque_api_data;
diff --git a/vulkan/libvulkan/driver_gen.cpp b/vulkan/libvulkan/driver_gen.cpp
index 574c327..aa31735 100644
--- a/vulkan/libvulkan/driver_gen.cpp
+++ b/vulkan/libvulkan/driver_gen.cpp
@@ -31,6 +31,23 @@
// clang-format off
+VKAPI_ATTR VkResult checkedBindImageMemory2(VkDevice device, uint32_t bindInfoCount, const VkBindImageMemoryInfo* pBindInfos) {
+ if (GetData(device).hook_extensions[ProcHook::EXTENSION_CORE_1_1]) {
+ return BindImageMemory2(device, bindInfoCount, pBindInfos);
+ } else {
+ Logger(device).Err(device, "VK_VERSION_1_0 not enabled. vkBindImageMemory2 not executed.");
+ return VK_SUCCESS;
+ }
+}
+
+VKAPI_ATTR void checkedGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2* pQueueInfo, VkQueue* pQueue) {
+ if (GetData(device).hook_extensions[ProcHook::EXTENSION_CORE_1_1]) {
+ GetDeviceQueue2(device, pQueueInfo, pQueue);
+ } else {
+ Logger(device).Err(device, "VK_VERSION_1_0 not enabled. vkGetDeviceQueue2 not executed.");
+ }
+}
+
VKAPI_ATTR VkResult checkedCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchain) {
if (GetData(device).hook_extensions[ProcHook::KHR_swapchain]) {
return CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain);
@@ -174,16 +191,16 @@
{
"vkAllocateCommandBuffers",
ProcHook::DEVICE,
- ProcHook::EXTENSION_CORE,
+ ProcHook::EXTENSION_CORE_1_0,
reinterpret_cast<PFN_vkVoidFunction>(AllocateCommandBuffers),
nullptr,
},
{
"vkBindImageMemory2",
ProcHook::DEVICE,
- ProcHook::EXTENSION_CORE,
+ ProcHook::EXTENSION_CORE_1_1,
reinterpret_cast<PFN_vkVoidFunction>(BindImageMemory2),
- nullptr,
+ reinterpret_cast<PFN_vkVoidFunction>(checkedBindImageMemory2),
},
{
"vkBindImageMemory2KHR",
@@ -209,14 +226,14 @@
{
"vkCreateDevice",
ProcHook::INSTANCE,
- ProcHook::EXTENSION_CORE,
+ ProcHook::EXTENSION_CORE_1_0,
reinterpret_cast<PFN_vkVoidFunction>(CreateDevice),
nullptr,
},
{
"vkCreateInstance",
ProcHook::GLOBAL,
- ProcHook::EXTENSION_CORE,
+ ProcHook::EXTENSION_CORE_1_0,
reinterpret_cast<PFN_vkVoidFunction>(CreateInstance),
nullptr,
},
@@ -244,14 +261,14 @@
{
"vkDestroyDevice",
ProcHook::DEVICE,
- ProcHook::EXTENSION_CORE,
+ ProcHook::EXTENSION_CORE_1_0,
reinterpret_cast<PFN_vkVoidFunction>(DestroyDevice),
nullptr,
},
{
"vkDestroyInstance",
ProcHook::INSTANCE,
- ProcHook::EXTENSION_CORE,
+ ProcHook::EXTENSION_CORE_1_0,
reinterpret_cast<PFN_vkVoidFunction>(DestroyInstance),
nullptr,
},
@@ -272,28 +289,28 @@
{
"vkEnumerateDeviceExtensionProperties",
ProcHook::INSTANCE,
- ProcHook::EXTENSION_CORE,
+ ProcHook::EXTENSION_CORE_1_0,
reinterpret_cast<PFN_vkVoidFunction>(EnumerateDeviceExtensionProperties),
nullptr,
},
{
"vkEnumerateInstanceExtensionProperties",
ProcHook::GLOBAL,
- ProcHook::EXTENSION_CORE,
+ ProcHook::EXTENSION_CORE_1_0,
reinterpret_cast<PFN_vkVoidFunction>(EnumerateInstanceExtensionProperties),
nullptr,
},
{
"vkEnumeratePhysicalDeviceGroups",
ProcHook::INSTANCE,
- ProcHook::EXTENSION_CORE,
+ ProcHook::EXTENSION_CORE_1_1,
reinterpret_cast<PFN_vkVoidFunction>(EnumeratePhysicalDeviceGroups),
nullptr,
},
{
"vkEnumeratePhysicalDevices",
ProcHook::INSTANCE,
- ProcHook::EXTENSION_CORE,
+ ProcHook::EXTENSION_CORE_1_0,
reinterpret_cast<PFN_vkVoidFunction>(EnumeratePhysicalDevices),
nullptr,
},
@@ -314,28 +331,28 @@
{
"vkGetDeviceProcAddr",
ProcHook::DEVICE,
- ProcHook::EXTENSION_CORE,
+ ProcHook::EXTENSION_CORE_1_0,
reinterpret_cast<PFN_vkVoidFunction>(GetDeviceProcAddr),
nullptr,
},
{
"vkGetDeviceQueue",
ProcHook::DEVICE,
- ProcHook::EXTENSION_CORE,
+ ProcHook::EXTENSION_CORE_1_0,
reinterpret_cast<PFN_vkVoidFunction>(GetDeviceQueue),
nullptr,
},
{
"vkGetDeviceQueue2",
ProcHook::DEVICE,
- ProcHook::EXTENSION_CORE,
+ ProcHook::EXTENSION_CORE_1_1,
reinterpret_cast<PFN_vkVoidFunction>(GetDeviceQueue2),
- nullptr,
+ reinterpret_cast<PFN_vkVoidFunction>(checkedGetDeviceQueue2),
},
{
"vkGetInstanceProcAddr",
ProcHook::INSTANCE,
- ProcHook::EXTENSION_CORE,
+ ProcHook::EXTENSION_CORE_1_0,
reinterpret_cast<PFN_vkVoidFunction>(GetInstanceProcAddr),
nullptr,
},
diff --git a/vulkan/libvulkan/driver_gen.h b/vulkan/libvulkan/driver_gen.h
index 3faf6c0..831efb7 100644
--- a/vulkan/libvulkan/driver_gen.h
+++ b/vulkan/libvulkan/driver_gen.h
@@ -48,7 +48,8 @@
ANDROID_external_memory_android_hardware_buffer,
KHR_bind_memory2,
- EXTENSION_CORE, // valid bit
+ EXTENSION_CORE_1_0,
+ EXTENSION_CORE_1_1,
EXTENSION_COUNT,
EXTENSION_UNKNOWN,
};