Merge "TYPE_DYNAMIC_SENSOR_META type should be wake up sensor"
diff --git a/vulkan/libvulkan/swapchain.cpp b/vulkan/libvulkan/swapchain.cpp
index 66e1b0f..8427d90 100644
--- a/vulkan/libvulkan/swapchain.cpp
+++ b/vulkan/libvulkan/swapchain.cpp
@@ -378,6 +378,9 @@
VkPresentModeKHR* modes) {
const VkPresentModeKHR kModes[] = {
VK_PRESENT_MODE_MAILBOX_KHR, VK_PRESENT_MODE_FIFO_KHR,
+ // TODO(chrisforbes): should only expose this if the driver can.
+ VK_PRESENT_MODE_FRONT_BUFFERED_DEMAND_REFRESH_KHR,
+ VK_PRESENT_MODE_FRONT_BUFFERED_CONTINUOUS_REFRESH_KHR,
};
const uint32_t kNumModes = sizeof(kModes) / sizeof(kModes[0]);
@@ -425,7 +428,9 @@
"swapchain preTransform=%#x not supported",
create_info->preTransform);
ALOGV_IF(!(create_info->presentMode == VK_PRESENT_MODE_FIFO_KHR ||
- create_info->presentMode == VK_PRESENT_MODE_MAILBOX_KHR),
+ create_info->presentMode == VK_PRESENT_MODE_MAILBOX_KHR ||
+ create_info->presentMode == VK_PRESENT_MODE_FRONT_BUFFERED_DEMAND_REFRESH_KHR ||
+ create_info->presentMode == VK_PRESENT_MODE_FRONT_BUFFERED_CONTINUOUS_REFRESH_KHR),
"swapchain presentMode=%u not supported",
create_info->presentMode);
@@ -479,6 +484,20 @@
return VK_ERROR_INITIALIZATION_FAILED;
}
+ err = native_window_set_shared_buffer_mode(surface.window.get(), false);
+ if (err != 0) {
+ ALOGE("native_window_set_shared_buffer_mode(false) failed: %s (%d)",
+ strerror(-err), err);
+ return VK_ERROR_INITIALIZATION_FAILED;
+ }
+
+ err = native_window_set_auto_refresh(surface.window.get(), false);
+ if (err != 0) {
+ ALOGE("native_window_set_auto_refresh(false) failed: %s (%d)",
+ strerror(-err), err);
+ return VK_ERROR_INITIALIZATION_FAILED;
+ }
+
// -- Configure the native window --
const auto& dispatch = GetData(device).driver;
@@ -587,6 +606,25 @@
}
VkSwapchainImageUsageFlagsANDROID swapchain_image_usage = 0;
+ if (create_info->presentMode == VK_PRESENT_MODE_FRONT_BUFFERED_DEMAND_REFRESH_KHR ||
+ create_info->presentMode == VK_PRESENT_MODE_FRONT_BUFFERED_CONTINUOUS_REFRESH_KHR) {
+ swapchain_image_usage |= VK_SWAPCHAIN_IMAGE_USAGE_FRONT_BUFFER_BIT_ANDROID;
+
+ err = native_window_set_shared_buffer_mode(surface.window.get(), true);
+ if (err != 0) {
+ ALOGE("native_window_set_shared_buffer_mode failed: %s (%d)", strerror(-err), err);
+ return VK_ERROR_INITIALIZATION_FAILED;
+ }
+ }
+
+ if (create_info->presentMode == VK_PRESENT_MODE_FRONT_BUFFERED_CONTINUOUS_REFRESH_KHR) {
+ err = native_window_set_auto_refresh(surface.window.get(), true);
+ if (err != 0) {
+ ALOGE("native_window_set_auto_refresh failed: %s (%d)", strerror(-err), err);
+ return VK_ERROR_INITIALIZATION_FAILED;
+ }
+ }
+
int gralloc_usage = 0;
if (dispatch.GetSwapchainGrallocUsage2ANDROID) {
result = dispatch.GetSwapchainGrallocUsage2ANDROID(