uint32_t i;
vk_icd_t *icd = vk_get_icd();
VkResult res = VK_SUCCESS;
+ VkPresentRegionsKHR *region_info = NULL;
+ const VkPresentRegionKHR *regions = NULL;
for (i = 0; i < info->swapchainCount; i++) {
int sync_fd = -1;
if (res != VK_SUCCESS)
VK_ERROR("Failed to queue_signal_release_image. res(%d)", res);
+
+ region_info = info->pNext;
+ if (region_info) {
+ if (VK_STRUCTURE_TYPE_PRESENT_REGIONS_KHR != region_info->sType || region_info->swapchainCount <= 0) {
+ VK_ERROR("issue in using extension (%s)", VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
+ res = VK_ERROR_DEVICE_LOST;//TODO return proper error code
+ }
+
+ if (VK_SUCCESS == res) {
+ regions = region_info->pRegions;
+ }
+
+ }
res = chain->present_image(queue, chain,
- chain->buffers[info->pImageIndices[i]].tbm, sync_fd);
+ chain->buffers[info->pImageIndices[i]].tbm, sync_fd, regions ? regions->rectangleCount : 0, regions ? regions->pRectangles : NULL);
if (info->pResults != NULL)
info->pResults[i] = res;
tbm_surface_h *buffers;
};
+struct swap_region
+{
+ int num_rects;
+ int *rects;
+};
static VkResult
swapchain_tpl_queue_present_image(VkQueue queue,
vk_swapchain_t *chain,
tbm_surface_h tbm_surface,
- int sync_fd)
+ int sync_fd,
+ int num_rects,
+ const VkRectLayerKHR *rects)
{
tpl_result_t res;
vk_swapchain_tpl_t *swapchain_tpl = chain->backend_data;
+ struct swap_region *region = NULL;
if (chain->is_retired == VK_TRUE) {
res = tpl_surface_cancel_dequeued_buffer(swapchain_tpl->tpl_surface, tbm_surface);
return VK_ERROR_OUT_OF_DATE_KHR;
}
+ if (num_rects >= 1) {
+ region = (struct swap_region *)malloc(sizeof(struct swap_region));
+ if (!region)
+ {
+ VK_ERROR("Failed to allocate swap_region");
+ return VK_ERROR_DEVICE_LOST;
+ }
+
+ region->num_rects = num_rects;
+
+ region->rects = (int *)malloc(sizeof(int) * 4 * num_rects);
+ if (!region->rects)
+ {
+ VK_ERROR("Failed to allocate swap_region->rects.");
+ free(region);
+ return VK_ERROR_DEVICE_LOST;
+ }
+
+ for (int i = 0; i < num_rects; i++) {
+ VkRectLayerKHR *pRects = &rects[i];
+ //copy first 4 ints from VkRectLayerKHR
+ memcpy((char *)region->rects + sizeof(int)*4*i, (char *)pRects, sizeof(int) * 4);
+ }
+
+ }
res = tpl_surface_enqueue_buffer_with_damage_and_sync(swapchain_tpl->tpl_surface,
- tbm_surface, 0, NULL, sync_fd);
+ tbm_surface, region ? region->num_rects : 0, region ? region->rects : NULL, sync_fd);
if (res == TPL_ERROR_NONE && chain->oldSwapchain != VK_NULL_HANDLE) {
chain->oldSwapchain->is_retired = VK_TRUE;
chain->oldSwapchain = VK_NULL_HANDLE;
}
+ if (region) {
+ if (region->rects) free(region->rects);
+
+ free(region);
+ }
return res == TPL_ERROR_NONE ? VK_SUCCESS : VK_ERROR_DEVICE_LOST;
}