summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXuelian Bai <xuelian.bai@samsung.com>2021-07-26 15:31:39 +0800
committerTianhao Ni <tianhao.ni@samsung.com>2022-01-24 09:18:06 +0800
commit87dd42945a9ee5bed8c3b1e05cae5ab3ece19fea (patch)
tree4e2efaf457eb9476b39a81e8b9cd32ec4923b2bf
parent6389cb9a2c88f8bdad019d2dda2008d88e720134 (diff)
downloadvulkan-wsi-layer-87dd42945a9ee5bed8c3b1e05cae5ab3ece19fea.tar.gz
vulkan-wsi-layer-87dd42945a9ee5bed8c3b1e05cae5ab3ece19fea.tar.bz2
vulkan-wsi-layer-87dd42945a9ee5bed8c3b1e05cae5ab3ece19fea.zip
Add support for VK_KHR_incremental_present
Read region information from VkPresentRegionsKHR. Change-Id: I60668599de5331108066a5ba8630867684cea92e Signed-Off-by: Xuelian Bai <xuelian.bai@samsung.com>
-rw-r--r--layer/VkLayer_window_system_integration.json3
-rw-r--r--layer/swapchain_api.cpp16
-rw-r--r--wsi/swapchain_base_tizen.cpp4
-rw-r--r--wsi/swapchain_base_tizen.hpp4
-rw-r--r--wsi/tizen/swapchain.cpp22
-rw-r--r--wsi/tizen/swapchain.hpp2
6 files changed, 42 insertions, 9 deletions
diff --git a/layer/VkLayer_window_system_integration.json b/layer/VkLayer_window_system_integration.json
index 2608168..4390b10 100644
--- a/layer/VkLayer_window_system_integration.json
+++ b/layer/VkLayer_window_system_integration.json
@@ -30,7 +30,8 @@
"vkGetDeviceGroupSurfacePresentModesKHR",
"vkGetPhysicalDevicePresentRectanglesKHR"
]
- }
+ },
+ {"name" : "VK_KHR_incremental_present", "spec_version" : "1"}
],
"disable_environment": {
"DISABLE_WSI_LAYER": "1"
diff --git a/layer/swapchain_api.cpp b/layer/swapchain_api.cpp
index b7c495f..096bbb6 100644
--- a/layer/swapchain_api.cpp
+++ b/layer/swapchain_api.cpp
@@ -205,14 +205,28 @@ wsi_layer_vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo)
}
VkResult ret = VK_SUCCESS;
+ const VkPresentRegionsKHR *regions = NULL;
+ VkBaseOutStructure *s;
+ for (s = (struct VkBaseOutStructure *)((void *)(pPresentInfo->pNext));s; s = s->pNext)
+ {
+ if (s->sType == VK_STRUCTURE_TYPE_PRESENT_REGIONS_KHR)
+ {
+ regions = (const VkPresentRegionsKHR *)s;
+ break;
+ }
+ }
for (uint32_t i = 0; i < pPresentInfo->swapchainCount; ++i)
{
VkSwapchainKHR swapc = pPresentInfo->pSwapchains[i];
+ const VkPresentRegionKHR *region = NULL;
auto *sc = reinterpret_cast<wsi::swapchain_base *>(swapc);
assert(sc != nullptr);
- res = sc->queue_present(queue, present_info, pPresentInfo->pImageIndices[i]);
+ if (regions && regions->pRegions)
+ region = &regions->pRegions[i];
+
+ res = sc->queue_present(queue, pPresentInfo, pPresentInfo->pImageIndices[i], region);
if (pPresentInfo->pResults != nullptr)
{
diff --git a/wsi/swapchain_base_tizen.cpp b/wsi/swapchain_base_tizen.cpp
index 76ece53..d74b7e9 100644
--- a/wsi/swapchain_base_tizen.cpp
+++ b/wsi/swapchain_base_tizen.cpp
@@ -164,7 +164,7 @@ VkResult swapchain_base::get_swapchain_images(uint32_t *swapchain_image_count, V
}
}
-VkResult swapchain_base::queue_present(VkQueue queue, const VkPresentInfoKHR *present_info, const uint32_t image_index)
+VkResult swapchain_base::queue_present(VkQueue queue, const VkPresentInfoKHR *present_info, const uint32_t image_index, const VkPresentRegionKHR *region)
{
VkResult result;
@@ -196,7 +196,7 @@ VkResult swapchain_base::queue_present(VkQueue queue, const VkPresentInfoKHR *pr
return result;
}
- present_image(image_index);
+ present_image(image_index, region);
return VK_SUCCESS;
}
diff --git a/wsi/swapchain_base_tizen.hpp b/wsi/swapchain_base_tizen.hpp
index 9c6ff27..9e62bf4 100644
--- a/wsi/swapchain_base_tizen.hpp
+++ b/wsi/swapchain_base_tizen.hpp
@@ -87,7 +87,7 @@ public:
* swapchain has a descendant who started presenting returns VK_ERROR_OUT_OF_DATE_KHR,
* otherwise returns VK_SUCCESS.
*/
- VkResult queue_present(VkQueue queue, const VkPresentInfoKHR *present_info, const uint32_t image_index);
+ VkResult queue_present(VkQueue queue, const VkPresentInfoKHR *present_info, const uint32_t image_index, const VkPresentRegionKHR *region);
protected:
@@ -212,7 +212,7 @@ protected:
* @param pending_index Index of the pending image to be presented.
*
*/
- virtual void present_image(uint32_t pending_index) = 0;
+ virtual void present_image(uint32_t pending_index, const VkPresentRegionKHR *region) = 0;
/**
* @brief Transition a presented image to free.
diff --git a/wsi/tizen/swapchain.cpp b/wsi/tizen/swapchain.cpp
index e21efa7..3785caf 100644
--- a/wsi/tizen/swapchain.cpp
+++ b/wsi/tizen/swapchain.cpp
@@ -356,10 +356,28 @@ VkResult swapchain::acquire_image(uint32_t *image_index)
return VK_ERROR_SURFACE_LOST_KHR;
}
-void swapchain::present_image(uint32_t pendingIndex)
+void swapchain::present_image(uint32_t pendingIndex, const VkPresentRegionKHR *region)
{
tizen_image_data *image_data = reinterpret_cast<tizen_image_data *>(m_swapchain_images[pendingIndex].data);
- tpl_surface_enqueue_buffer_with_damage_and_sync(m_tpl_surface, image_data->tbm_buffer, 0, NULL, -1);
+ int *rects = NULL;
+ int rect_count = 0;
+
+ if (region)
+ {
+ rect_count = region->rectangleCount;
+ rects = new int[rect_count*4];
+ for (int i = 0; i < rect_count*4; i+=4)
+ {
+ rects[i] = region->pRectangles->offset.x;
+ rects[i+1] = region->pRectangles->offset.y;
+ rects[i+2] = region->pRectangles->extent.width;
+ rects[i+3] = region->pRectangles->extent.height;
+ }
+ }
+
+ tpl_surface_enqueue_buffer_with_damage_and_sync(m_tpl_surface, image_data->tbm_buffer, rect_count, rects, -1);
+ if (rects)
+ delete rects;
}
void swapchain::destroy_image(void)
diff --git a/wsi/tizen/swapchain.hpp b/wsi/tizen/swapchain.hpp
index 3a6e41a..d2c277c 100644
--- a/wsi/tizen/swapchain.hpp
+++ b/wsi/tizen/swapchain.hpp
@@ -70,7 +70,7 @@ protected:
*
* @param pendingIndex Index of the pending image to be presented.
*/
- void present_image(uint32_t pendingIndex) override;
+ void present_image(uint32_t pendingIndex, const VkPresentRegionKHR *region) override;
/**
* @brief Method to release a swapchain image