Merge changes Ie828d9b4,I5ddd6323 into pi-dev
* changes:
SF TimeStats: move dumpStats into TimeStatsHelper
SF TimeStats: update build file and some cleanups
diff --git a/services/surfaceflinger/TimeStats/TimeStats.cpp b/services/surfaceflinger/TimeStats/TimeStats.cpp
index cd64da0..d4f1e29 100644
--- a/services/surfaceflinger/TimeStats/TimeStats.cpp
+++ b/services/surfaceflinger/TimeStats/TimeStats.cpp
@@ -168,7 +168,7 @@
LayerRecord& layerRecord = timeStatsTracker[layerName];
TimeRecord& prevTimeRecord = layerRecord.prevTimeRecord;
- std::vector<TimeRecord>& timeRecords = layerRecord.timeRecords;
+ std::deque<TimeRecord>& timeRecords = layerRecord.timeRecords;
while (!timeRecords.empty()) {
if (!recordReadyLocked(layerName, &timeRecords[0])) break;
ALOGV("[%s]-[%" PRIu64 "]-presentFenceTime[%" PRId64 "]", layerName.c_str(),
@@ -216,8 +216,7 @@
timeStats.stats[layerName].statsEnd = static_cast<int64_t>(std::time(0));
}
prevTimeRecord = timeRecords[0];
- // TODO(zzyiwei): change timeRecords to use std::deque
- timeRecords.erase(timeRecords.begin());
+ timeRecords.pop_front();
layerRecord.waitData--;
}
}
diff --git a/services/surfaceflinger/TimeStats/TimeStats.h b/services/surfaceflinger/TimeStats/TimeStats.h
index b9016a1..8318210 100644
--- a/services/surfaceflinger/TimeStats/TimeStats.h
+++ b/services/surfaceflinger/TimeStats/TimeStats.h
@@ -25,10 +25,10 @@
#include <utils/String8.h>
#include <utils/Vector.h>
+#include <deque>
#include <mutex>
#include <optional>
#include <unordered_map>
-#include <vector>
using namespace android::surfaceflinger;
@@ -58,7 +58,7 @@
// fences to signal, but rather waiting to receive those fences/timestamps.
int32_t waitData = -1;
TimeRecord prevTimeRecord;
- std::vector<TimeRecord> timeRecords;
+ std::deque<TimeRecord> timeRecords;
};
public:
diff --git a/vulkan/libvulkan/swapchain.cpp b/vulkan/libvulkan/swapchain.cpp
index 6fb3351..c42e811 100644
--- a/vulkan/libvulkan/swapchain.cpp
+++ b/vulkan/libvulkan/swapchain.cpp
@@ -185,6 +185,7 @@
struct Surface {
android::sp<ANativeWindow> window;
VkSwapchainKHR swapchain_handle;
+ uint64_t consumer_usage;
};
VkSurfaceKHR HandleFromSurface(Surface* surface) {
@@ -496,9 +497,18 @@
surface->window = pCreateInfo->window;
surface->swapchain_handle = VK_NULL_HANDLE;
+ int err = native_window_get_consumer_usage(surface->window.get(),
+ &surface->consumer_usage);
+ if (err != android::NO_ERROR) {
+ ALOGE("native_window_get_consumer_usage() failed: %s (%d)",
+ strerror(-err), err);
+ surface->~Surface();
+ allocator->pfnFree(allocator->pUserData, surface);
+ return VK_ERROR_INITIALIZATION_FAILED;
+ }
// TODO(jessehall): Create and use NATIVE_WINDOW_API_VULKAN.
- int err =
+ err =
native_window_api_connect(surface->window.get(), NATIVE_WINDOW_API_EGL);
if (err != 0) {
// TODO(jessehall): Improve error reporting. Can we enumerate possible
@@ -536,9 +546,45 @@
VKAPI_ATTR
VkResult GetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice /*pdev*/,
uint32_t /*queue_family*/,
- VkSurfaceKHR /*surface*/,
+ VkSurfaceKHR surface_handle,
VkBool32* supported) {
- *supported = VK_TRUE;
+ const Surface* surface = SurfaceFromHandle(surface_handle);
+ if (!surface) {
+ return VK_ERROR_SURFACE_LOST_KHR;
+ }
+ const ANativeWindow* window = surface->window.get();
+
+ int query_value;
+ int err = window->query(window, NATIVE_WINDOW_FORMAT, &query_value);
+ if (err != 0 || query_value < 0) {
+ ALOGE("NATIVE_WINDOW_FORMAT query failed: %s (%d) value=%d",
+ strerror(-err), err, query_value);
+ return VK_ERROR_SURFACE_LOST_KHR;
+ }
+
+ android_pixel_format native_format =
+ static_cast<android_pixel_format>(query_value);
+
+ bool format_supported = false;
+ switch (native_format) {
+ case HAL_PIXEL_FORMAT_RGBA_8888:
+ case HAL_PIXEL_FORMAT_RGB_565:
+ format_supported = true;
+ break;
+ default:
+ break;
+ }
+
+ // USAGE_CPU_READ_MASK 0xFUL
+ // USAGE_CPU_WRITE_MASK (0xFUL << 4)
+ // The currently used bits are as below:
+ // USAGE_CPU_READ_RARELY = 2UL
+ // USAGE_CPU_READ_OFTEN = 3UL
+ // USAGE_CPU_WRITE_RARELY = (2UL << 4)
+ // USAGE_CPU_WRITE_OFTEN = (3UL << 4)
+ *supported = static_cast<VkBool32>(format_supported ||
+ (surface->consumer_usage & 0xFFUL) == 0);
+
return VK_SUCCESS;
}