Merge "Remove HIGH connectivity from dump test"
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 635a1ce..f553697 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -2908,6 +2908,10 @@
// own activity pushes out interesting data from the trace ring buffer.
// The trace file is added to the zip by MaybeAddSystemTraceToZip().
MaybeSnapshotSystemTrace();
+
+ // If a winscope trace is running, snapshot it now. It will be pulled into bugreport later
+ // from WMTRACE_DATA_DIR.
+ MaybeSnapshotWinTrace();
}
onUiIntensiveBugreportDumpsFinished(calling_uid);
MaybeCheckUserConsent(calling_uid, calling_package);
@@ -3019,6 +3023,14 @@
// file in the later stages.
}
+void Dumpstate::MaybeSnapshotWinTrace() {
+ RunCommand(
+ // Empty name because it's not intended to be classified as a bugreport section.
+ // Actual tracing files can be found in "/data/misc/wmtrace/" in the bugreport.
+ "", {"cmd", "window", "tracing", "save-for-bugreport"},
+ CommandOptions::WithTimeout(10).Always().DropRoot().RedirectStderr().Build());
+}
+
void Dumpstate::onUiIntensiveBugreportDumpsFinished(int32_t calling_uid) {
if (calling_uid == AID_SHELL || !CalledByApi()) {
return;
diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h
index f83968b..83e6787 100644
--- a/cmds/dumpstate/dumpstate.h
+++ b/cmds/dumpstate/dumpstate.h
@@ -549,6 +549,7 @@
void MaybeTakeEarlyScreenshot();
void MaybeSnapshotSystemTrace();
+ void MaybeSnapshotWinTrace();
void onUiIntensiveBugreportDumpsFinished(int32_t calling_uid);
diff --git a/cmds/installd/otapreopt.cpp b/cmds/installd/otapreopt.cpp
index cefcf64..ed31ad9 100644
--- a/cmds/installd/otapreopt.cpp
+++ b/cmds/installd/otapreopt.cpp
@@ -349,9 +349,6 @@
}
}
- // Clear cached artifacts.
- ClearDirectory(isa_path);
-
// Check whether we have a boot image.
// TODO: check that the files are correct wrt/ jars.
std::string preopted_boot_art_path =
@@ -395,37 +392,6 @@
return false;
}
- static void ClearDirectory(const std::string& dir) {
- DIR* c_dir = opendir(dir.c_str());
- if (c_dir == nullptr) {
- PLOG(WARNING) << "Unable to open " << dir << " to delete it's contents";
- return;
- }
-
- for (struct dirent* de = readdir(c_dir); de != nullptr; de = readdir(c_dir)) {
- const char* name = de->d_name;
- if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0) {
- continue;
- }
- // We only want to delete regular files and symbolic links.
- std::string file = StringPrintf("%s/%s", dir.c_str(), name);
- if (de->d_type != DT_REG && de->d_type != DT_LNK) {
- LOG(WARNING) << "Unexpected file "
- << file
- << " of type "
- << std::hex
- << de->d_type
- << " encountered.";
- } else {
- // Try to unlink the file.
- if (unlink(file.c_str()) != 0) {
- PLOG(ERROR) << "Unable to unlink " << file;
- }
- }
- }
- CHECK_EQ(0, closedir(c_dir)) << "Unable to close directory.";
- }
-
static const char* ParseNull(const char* arg) {
return (strcmp(arg, "!") == 0) ? nullptr : arg;
}
diff --git a/cmds/installd/otapreopt_chroot.cpp b/cmds/installd/otapreopt_chroot.cpp
index fb07840..379cf92 100644
--- a/cmds/installd/otapreopt_chroot.cpp
+++ b/cmds/installd/otapreopt_chroot.cpp
@@ -20,15 +20,19 @@
#include <sys/stat.h>
#include <sys/wait.h>
+#include <fstream>
#include <sstream>
+#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/macros.h>
#include <android-base/stringprintf.h>
+#include <android-base/unique_fd.h>
#include <libdm/dm.h>
#include <selinux/android.h>
#include <apex_file_repository.h>
+#include <apex_constants.h>
#include <apexd.h>
#include "installd_constants.h"
@@ -77,6 +81,22 @@
return apex::GetActivePackages();
}
+static void CreateApexInfoList(const std::vector<apex::ApexFile>& apex_files) {
+ // Setup the apex-info-list.xml file
+ const std::string apex_info_file = std::string(apex::kApexRoot) + "/" + apex::kApexInfoList;
+ std::fstream xml(apex_info_file.c_str(), std::ios::out | std::ios::trunc);
+ if (!xml.is_open()) {
+ PLOG(ERROR) << "Failed to open " << apex_info_file;
+ exit(216);
+ }
+
+ // we do not care about inactive apexs
+ std::vector<apex::ApexFile> inactive;
+ apex::CollectApexInfoList(xml, apex_files, inactive);
+ xml.flush();
+ xml.close();
+}
+
static void DeactivateApexPackages(const std::vector<apex::ApexFile>& active_packages) {
for (const apex::ApexFile& apex_file : active_packages) {
const std::string& package_path = apex_file.GetPath();
@@ -185,6 +205,13 @@
// want it for product APKs. Same notes as vendor above.
TryExtraMount("product", arg[2], "/postinstall/product");
+ constexpr const char* kPostInstallLinkerconfig = "/postinstall/linkerconfig";
+ // Try to mount /postinstall/linkerconfig. we will set it up after performing the chroot
+ if (mount("tmpfs", kPostInstallLinkerconfig, "tmpfs", 0, nullptr) != 0) {
+ PLOG(ERROR) << "Failed to mount a tmpfs for " << kPostInstallLinkerconfig;
+ exit(215);
+ }
+
// Setup APEX mount point and its security context.
static constexpr const char* kPostinstallApexDir = "/postinstall/apex";
// The following logic is similar to the one in system/core/rootdir/init.rc:
@@ -243,17 +270,37 @@
// Try to mount APEX packages in "/apex" in the chroot dir. We need at least
// the ART APEX, as it is required by otapreopt to run dex2oat.
std::vector<apex::ApexFile> active_packages = ActivateApexPackages();
+ CreateApexInfoList(active_packages);
// Check that an ART APEX has been activated; clean up and exit
// early otherwise.
- if (std::none_of(active_packages.begin(),
- active_packages.end(),
- [](const apex::ApexFile& package){
- return package.GetManifest().name() == "com.android.art";
- })) {
- LOG(FATAL_WITHOUT_ABORT) << "No activated com.android.art APEX package.";
- DeactivateApexPackages(active_packages);
- exit(217);
+ static constexpr const std::string_view kRequiredApexs[] = {
+ "com.android.art",
+ "com.android.runtime",
+ };
+ for (std::string_view apex : kRequiredApexs) {
+ if (std::none_of(active_packages.begin(), active_packages.end(),
+ [&](const apex::ApexFile& package) {
+ return package.GetManifest().name() == apex;
+ })) {
+ LOG(FATAL_WITHOUT_ABORT) << "No activated " << apex << " APEX package.";
+ DeactivateApexPackages(active_packages);
+ exit(217);
+ }
+ }
+
+ // Setup /linkerconfig. Doing it after the chroot means it doesn't need its own category
+ if (selinux_android_restorecon("/linkerconfig", 0) < 0) {
+ PLOG(ERROR) << "Failed to restorecon /linkerconfig";
+ exit(219);
+ }
+ std::vector<std::string> linkerconfig_cmd{"/apex/com.android.runtime/bin/linkerconfig",
+ "--target", "/linkerconfig"};
+ std::string linkerconfig_error_msg;
+ bool linkerconfig_exec_result = Exec(linkerconfig_cmd, &linkerconfig_error_msg);
+ if (!linkerconfig_exec_result) {
+ LOG(ERROR) << "Running linkerconfig failed: " << linkerconfig_error_msg;
+ exit(218);
}
// Now go on and run otapreopt.
diff --git a/libs/binder/Android.bp b/libs/binder/Android.bp
index 776d594..098d915 100644
--- a/libs/binder/Android.bp
+++ b/libs/binder/Android.bp
@@ -216,6 +216,7 @@
"-misc-redundant-expression",
"-misc-unused-using-decls",
"performance*",
+ "-performance-no-int-to-ptr",
"portability*",
],
diff --git a/libs/binder/BufferedTextOutput.cpp b/libs/binder/BufferedTextOutput.cpp
index 88c85bf..349658e 100644
--- a/libs/binder/BufferedTextOutput.cpp
+++ b/libs/binder/BufferedTextOutput.cpp
@@ -15,7 +15,6 @@
*/
#include "BufferedTextOutput.h"
-#include <binder/Debug.h>
#include <cutils/atomic.h>
#include <utils/Log.h>
@@ -26,6 +25,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include "Debug.h"
#include "Static.h"
// ---------------------------------------------------------------------------
diff --git a/libs/binder/Debug.cpp b/libs/binder/Debug.cpp
index 3a62059..e4ac4b4 100644
--- a/libs/binder/Debug.cpp
+++ b/libs/binder/Debug.cpp
@@ -14,7 +14,8 @@
* limitations under the License.
*/
-#include <binder/Debug.h>
+#include "Debug.h"
+
#include <binder/ProcessState.h>
#include <utils/misc.h>
diff --git a/libs/binder/include/binder/Debug.h b/libs/binder/Debug.h
similarity index 100%
rename from libs/binder/include/binder/Debug.h
rename to libs/binder/Debug.h
diff --git a/libs/binder/TextOutput.cpp b/libs/binder/TextOutput.cpp
index 684a7dc..a0ade50 100644
--- a/libs/binder/TextOutput.cpp
+++ b/libs/binder/TextOutput.cpp
@@ -16,7 +16,7 @@
#include <binder/TextOutput.h>
-#include <binder/Debug.h>
+#include "Debug.h"
#include <utils/String8.h>
#include <utils/String16.h>
diff --git a/libs/binder/rust/src/error.rs b/libs/binder/rust/src/error.rs
index 4492cf7..2598ebc 100644
--- a/libs/binder/rust/src/error.rs
+++ b/libs/binder/rust/src/error.rs
@@ -77,9 +77,7 @@
e if e == ExceptionCode::ILLEGAL_ARGUMENT as i32 => ExceptionCode::ILLEGAL_ARGUMENT,
e if e == ExceptionCode::NULL_POINTER as i32 => ExceptionCode::NULL_POINTER,
e if e == ExceptionCode::ILLEGAL_STATE as i32 => ExceptionCode::ILLEGAL_STATE,
- e if e == ExceptionCode::NETWORK_MAIN_THREAD as i32 => {
- ExceptionCode::NETWORK_MAIN_THREAD
- }
+ e if e == ExceptionCode::NETWORK_MAIN_THREAD as i32 => ExceptionCode::NETWORK_MAIN_THREAD,
e if e == ExceptionCode::UNSUPPORTED_OPERATION as i32 => {
ExceptionCode::UNSUPPORTED_OPERATION
}
@@ -96,6 +94,16 @@
/// Used in AIDL transactions to represent failed transactions.
pub struct Status(*mut sys::AStatus);
+// Safety: The `AStatus` that the `Status` points to must have an entirely thread-safe API for the
+// duration of the `Status` object's lifetime. We ensure this by not allowing mutation of a `Status`
+// in Rust, and the NDK API says we're the owner of our `AStatus` objects so outside code should not
+// be mutating them underneath us.
+unsafe impl Sync for Status {}
+
+// Safety: `Status` always contains an owning pointer to a global, immutable, interned `AStatus`.
+// A thread-local `AStatus` would not be valid.
+unsafe impl Send for Status {}
+
impl Status {
/// Create a status object representing a successful transaction.
pub fn ok() -> Self {
diff --git a/libs/binder/tests/binderTextOutputTest.cpp b/libs/binder/tests/binderTextOutputTest.cpp
index ce99f59..b37030e 100644
--- a/libs/binder/tests/binderTextOutputTest.cpp
+++ b/libs/binder/tests/binderTextOutputTest.cpp
@@ -26,7 +26,6 @@
#include <binder/Parcel.h>
#include <binder/TextOutput.h>
-#include <binder/Debug.h>
static void CheckMessage(CapturedStderr& cap,
const char* expected,
diff --git a/libs/binder/tests/fuzzers/TextOutputFuzz.cpp b/libs/binder/tests/fuzzers/TextOutputFuzz.cpp
index c950020..5e3502a 100644
--- a/libs/binder/tests/fuzzers/TextOutputFuzz.cpp
+++ b/libs/binder/tests/fuzzers/TextOutputFuzz.cpp
@@ -16,7 +16,6 @@
#include <fuzzer/FuzzedDataProvider.h>
-#include <binder/Debug.h>
#include <binder/Parcel.h>
#include <binder/TextOutput.h>
#include "android-base/file.h"
diff --git a/libs/graphicsenv/OWNERS b/libs/graphicsenv/OWNERS
index c0bb75f..8c28464 100644
--- a/libs/graphicsenv/OWNERS
+++ b/libs/graphicsenv/OWNERS
@@ -1,6 +1,4 @@
chrisforbes@google.com
cnorthrop@google.com
-courtneygo@google.com
lpy@google.com
timvp@google.com
-zzyiwei@google.com
diff --git a/opengl/OWNERS b/opengl/OWNERS
index b505712..a9bd4bb 100644
--- a/opengl/OWNERS
+++ b/opengl/OWNERS
@@ -1,7 +1,6 @@
chrisforbes@google.com
cnorthrop@google.com
-courtneygo@google.com
ianelliott@google.com
jessehall@google.com
lpy@google.com
-zzyiwei@google.com
+timvp@google.com
diff --git a/services/gpuservice/OWNERS b/services/gpuservice/OWNERS
index 5d02839..ac300d0 100644
--- a/services/gpuservice/OWNERS
+++ b/services/gpuservice/OWNERS
@@ -1,3 +1,2 @@
chrisforbes@google.com
lpy@google.com
-zzyiwei@google.com
diff --git a/services/sensorservice/SensorDevice.cpp b/services/sensorservice/SensorDevice.cpp
index e355594..4d4cac5 100644
--- a/services/sensorservice/SensorDevice.cpp
+++ b/services/sensorservice/SensorDevice.cpp
@@ -689,9 +689,9 @@
ALOGD_IF(DEBUG_CONNECTIONS, "enable index=%zd", info.batchParams.indexOfKey(ident));
if (isClientDisabledLocked(ident)) {
- ALOGE("SensorDevice::activate, isClientDisabledLocked(%p):true, handle:%d",
+ ALOGW("SensorDevice::activate, isClientDisabledLocked(%p):true, handle:%d",
ident, handle);
- return INVALID_OPERATION;
+ return NO_ERROR;
}
if (info.batchParams.indexOfKey(ident) >= 0) {
diff --git a/services/surfaceflinger/TimeStats/OWNERS b/services/surfaceflinger/TimeStats/OWNERS
index 1441f91..ded3ebb 100644
--- a/services/surfaceflinger/TimeStats/OWNERS
+++ b/services/surfaceflinger/TimeStats/OWNERS
@@ -1,2 +1 @@
alecmouri@google.com
-zzyiwei@google.com
diff --git a/vulkan/libvulkan/swapchain.cpp b/vulkan/libvulkan/swapchain.cpp
index da28052..4b69bec 100644
--- a/vulkan/libvulkan/swapchain.cpp
+++ b/vulkan/libvulkan/swapchain.cpp
@@ -1095,13 +1095,6 @@
return VK_ERROR_SURFACE_LOST_KHR;
}
- err = native_window_set_buffer_count(window, 0);
- if (err != android::OK) {
- ALOGE("native_window_set_buffer_count(0) failed: %s (%d)",
- strerror(-err), err);
- return VK_ERROR_SURFACE_LOST_KHR;
- }
-
int swap_interval =
create_info->presentMode == VK_PRESENT_MODE_MAILBOX_KHR ? 0 : 1;
err = window->setSwapInterval(window, swap_interval);
@@ -1709,7 +1702,7 @@
if (err != android::OK) {
ALOGE("queueBuffer failed: %s (%d)", strerror(-err), err);
swapchain_result = WorstPresentResult(
- swapchain_result, VK_ERROR_OUT_OF_DATE_KHR);
+ swapchain_result, VK_ERROR_SURFACE_LOST_KHR);
} else {
if (img.dequeue_fence >= 0) {
close(img.dequeue_fence);
diff --git a/vulkan/vkjson/vkjson_info.cc b/vulkan/vkjson/vkjson_info.cc
deleted file mode 100644
index 3c4b08b..0000000
--- a/vulkan/vkjson/vkjson_info.cc
+++ /dev/null
@@ -1,184 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-// Copyright (c) 2015-2016 The Khronos Group Inc.
-// Copyright (c) 2015-2016 Valve Corporation
-// Copyright (c) 2015-2016 LunarG, Inc.
-// Copyright (c) 2015-2016 Google, Inc.
-//
-// 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 VK_PROTOTYPES
-#define VK_PROTOTYPES
-#endif
-
-#include "vkjson.h"
-
-#include <assert.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <iostream>
-#include <vector>
-
-const uint32_t unsignedNegOne = (uint32_t)(-1);
-
-struct Options {
- bool instance = false;
- uint32_t device_index = unsignedNegOne;
- std::string device_name;
- std::string output_file;
-};
-
-bool ParseOptions(int argc, char* argv[], Options* options) {
- for (int i = 1; i < argc; ++i) {
- std::string arg(argv[i]);
- if (arg == "--instance" || arg == "-i") {
- options->instance = true;
- } else if (arg == "--first" || arg == "-f") {
- options->device_index = 0;
- } else {
- ++i;
- if (i >= argc) {
- std::cerr << "Missing parameter after: " << arg << std::endl;
- return false;
- }
- std::string arg2(argv[i]);
- if (arg == "--device-index" || arg == "-d") {
- int result = sscanf(arg2.c_str(), "%u", &options->device_index);
- if (result != 1) {
- options->device_index = static_cast<uint32_t>(-1);
- std::cerr << "Unable to parse index: " << arg2 << std::endl;
- return false;
- }
- } else if (arg == "--device-name" || arg == "-n") {
- options->device_name = arg2;
- } else if (arg == "--output" || arg == "-o") {
- options->output_file = arg2;
- } else {
- std::cerr << "Unknown argument: " << arg << std::endl;
- return false;
- }
- }
- }
- if (options->instance && (options->device_index != unsignedNegOne ||
- !options->device_name.empty())) {
- std::cerr << "Specifying a specific device is incompatible with dumping "
- "the whole instance." << std::endl;
- return false;
- }
- if (options->device_index != unsignedNegOne && !options->device_name.empty()) {
- std::cerr << "Must specify only one of device index and device name."
- << std::endl;
- return false;
- }
- if (options->instance && options->output_file.empty()) {
- std::cerr << "Must specify an output file when dumping the whole instance."
- << std::endl;
- return false;
- }
- if (!options->output_file.empty() && !options->instance &&
- options->device_index == unsignedNegOne && options->device_name.empty()) {
- std::cerr << "Must specify instance, device index, or device name when "
- "specifying "
- "output file." << std::endl;
- return false;
- }
- return true;
-}
-
-bool Dump(const VkJsonInstance& instance, const Options& options) {
- const VkJsonDevice* out_device = nullptr;
- if (options.device_index != unsignedNegOne) {
- if (static_cast<uint32_t>(options.device_index) >=
- instance.devices.size()) {
- std::cerr << "Error: device " << options.device_index
- << " requested but only " << instance.devices.size()
- << " devices found." << std::endl;
- return false;
- }
- out_device = &instance.devices[options.device_index];
- } else if (!options.device_name.empty()) {
- for (const auto& device : instance.devices) {
- if (device.properties.deviceName == options.device_name) {
- out_device = &device;
- }
- }
- if (!out_device) {
- std::cerr << "Error: device '" << options.device_name
- << "' requested but not found." << std::endl;
- return false;
- }
- }
-
- std::string output_file;
- if (options.output_file.empty()) {
- assert(out_device);
-#if defined(ANDROID)
- output_file.assign("/sdcard/Android/" + std::string(out_device->properties.deviceName));
-#else
- output_file.assign(out_device->properties.deviceName);
-#endif
- output_file.append(".json");
- } else {
- output_file = options.output_file;
- }
- FILE* file = nullptr;
- if (output_file == "-") {
- file = stdout;
- } else {
- file = fopen(output_file.c_str(), "w");
- if (!file) {
- std::cerr << "Unable to open file " << output_file << "." << std::endl;
- return false;
- }
- }
-
- std::string json = out_device ? VkJsonDeviceToJson(*out_device)
- : VkJsonInstanceToJson(instance);
- fwrite(json.data(), 1, json.size(), file);
- fputc('\n', file);
-
- if (output_file != "-") {
- fclose(file);
- std::cout << "Wrote file " << output_file;
- if (out_device)
- std::cout << " for device " << out_device->properties.deviceName;
- std::cout << "." << std::endl;
- }
- return true;
-}
-
-int main(int argc, char* argv[]) {
-#if defined(ANDROID)
- int vulkanSupport = InitVulkan();
- if (vulkanSupport == 0)
- return 1;
-#endif
- Options options;
- if (!ParseOptions(argc, argv, &options))
- return 1;
-
- VkJsonInstance instance = VkJsonGetInstance();
- if (options.instance || options.device_index != unsignedNegOne ||
- !options.device_name.empty()) {
- Dump(instance, options);
- } else {
- for (uint32_t i = 0, n = static_cast<uint32_t>(instance.devices.size()); i < n; i++) {
- options.device_index = i;
- Dump(instance, options);
- }
- }
-
- return 0;
-}
diff --git a/vulkan/vkjson/vkjson_unittest.cc b/vulkan/vkjson/vkjson_unittest.cc
deleted file mode 100644
index de765cd..0000000
--- a/vulkan/vkjson/vkjson_unittest.cc
+++ /dev/null
@@ -1,101 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-// Copyright (c) 2015-2016 The Khronos Group Inc.
-// Copyright (c) 2015-2016 Valve Corporation
-// Copyright (c) 2015-2016 LunarG, Inc.
-// Copyright (c) 2015-2016 Google, Inc.
-//
-// 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 "vkjson.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <iostream>
-
-#define EXPECT(X) if (!(X)) \
- ReportFailure(__FILE__, __LINE__, #X);
-
-#define ASSERT(X) if (!(X)) { \
- ReportFailure(__FILE__, __LINE__, #X); \
- return 2; \
-}
-
-int g_failures;
-
-void ReportFailure(const char* file, int line, const char* assertion) {
- std::cout << file << ":" << line << ": \"" << assertion << "\" failed."
- << std::endl;
- ++g_failures;
-}
-
-int main(int argc, char* argv[]) {
- std::string errors;
- bool result = false;
-
- VkJsonInstance instance;
- instance.devices.resize(1);
- VkJsonDevice& device = instance.devices[0];
-
- const char name[] = "Test device";
- memcpy(device.properties.deviceName, name, sizeof(name));
- device.properties.limits.maxImageDimension1D = 3;
- device.properties.limits.maxSamplerLodBias = 3.5f;
- device.properties.limits.bufferImageGranularity = 0x1ffffffffull;
- device.properties.limits.maxViewportDimensions[0] = 1;
- device.properties.limits.maxViewportDimensions[1] = 2;
- VkFormatProperties format_props = {
- VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT,
- VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT,
- VK_FORMAT_FEATURE_BLIT_SRC_BIT | VK_FORMAT_FEATURE_BLIT_DST_BIT};
- device.formats.insert(std::make_pair(VK_FORMAT_R8_UNORM, format_props));
- device.formats.insert(std::make_pair(VK_FORMAT_R8G8_UNORM, format_props));
-
- std::string json = VkJsonInstanceToJson(instance);
- std::cout << json << std::endl;
-
- VkJsonInstance instance2;
- result = VkJsonInstanceFromJson(json, &instance2, &errors);
- EXPECT(result);
- if (!result)
- std::cout << "Error: " << errors << std::endl;
- const VkJsonDevice& device2 = instance2.devices.at(0);
-
- EXPECT(!memcmp(&device.properties, &device2.properties,
- sizeof(device.properties)));
- for (auto& kv : device.formats) {
- auto it = device2.formats.find(kv.first);
- EXPECT(it != device2.formats.end());
- EXPECT(!memcmp(&kv.second, &it->second, sizeof(kv.second)));
- }
-
- VkImageFormatProperties props = {};
- json = VkJsonImageFormatPropertiesToJson(props);
- VkImageFormatProperties props2 = {};
- result = VkJsonImageFormatPropertiesFromJson(json, &props2, &errors);
- EXPECT(result);
- if (!result)
- std::cout << "Error: " << errors << std::endl;
-
- EXPECT(!memcmp(&props, &props2, sizeof(props)));
-
- if (g_failures) {
- std::cout << g_failures << " failures." << std::endl;
- return 1;
- } else {
- std::cout << "Success." << std::endl;
- return 0;
- }
-}