diff --git a/src/vulkan.cpp b/src/vulkan.cpp index 1f1997f0..96850952 100644 --- a/src/vulkan.cpp +++ b/src/vulkan.cpp @@ -1554,10 +1554,11 @@ static VkResult overlay_CreateSwapchainKHR( get_device_name(prop.vendorID, prop.deviceID, swapchain_data->sw_stats); #endif swappy::SwappyVk& swappy = swappy::SwappyVk::getInstance(); - uint64_t refreshDuration = std::chrono::duration_cast (1s / 100).count(); + uint64_t refreshDuration = 0; swappy.GetRefreshCycleDuration(device_data->physical_device, device_data->device, *pSwapchain, &refreshDuration); - swappy.SetSwapDuration(device_data->device, *pSwapchain, 10000000L);//SWAPPY_SWAP_30FPS); + swappy.SetSwapDuration(device_data->device, *pSwapchain, fps_limit_stats.targetFrameTime.count());//SWAPPY_SWAP_30FPS); + swappy.SetAutoSwapInterval(true); } if(driverProps.driverID == VK_DRIVER_ID_NVIDIA_PROPRIETARY){ @@ -2023,7 +2024,6 @@ static VkResult overlay_CreateInstance( swappy::SwappyVk& swappy = swappy::SwappyVk::getInstance(); swappy.SetFunctionProvider(&c); - } instance_data->api_version = pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0; @@ -2045,6 +2045,16 @@ static void overlay_DestroyInstance( destroy_instance_data(instance_data); } +void overlay_DestroyImage( + VkDevice device, + VkImage image, + const VkAllocationCallbacks* pAllocator) +{ + struct device_data *device_data = FIND(struct device_data, device); + device_data->vtable.DestroyImage(device, image, pAllocator); +} + + extern "C" VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL overlay_GetDeviceProcAddr(VkDevice dev, const char *funcName); static const struct { @@ -2072,6 +2082,9 @@ static const struct { ADD_HOOK(CreateInstance), ADD_HOOK(DestroyInstance), + + //memory crap + ADD_HOOK(DestroyImage), #undef ADD_HOOK }; diff --git a/subprojects/swappy/common/ChoreographerThread.cpp b/subprojects/swappy/common/ChoreographerThread.cpp index cb62e62c..0764fa52 100644 --- a/subprojects/swappy/common/ChoreographerThread.cpp +++ b/subprojects/swappy/common/ChoreographerThread.cpp @@ -104,7 +104,7 @@ void NoChoreographerThread::onSettingsChanged() { Settings::getInstance()->getDisplayTimings(); std::lock_guard lock(mWaitingMutex); mRefreshPeriod = displayTimings.refreshPeriod; - ALOGV("onSettingsChanged(): refreshPeriod=%lld", + ALOGV("onSettingsChanged(): refreshPeriod={}", (long long)displayTimings.refreshPeriod.count()); } diff --git a/subprojects/swappy/common/SwappyCommon.cpp b/subprojects/swappy/common/SwappyCommon.cpp index 60f70538..9b5eb94f 100644 --- a/subprojects/swappy/common/SwappyCommon.cpp +++ b/subprojects/swappy/common/SwappyCommon.cpp @@ -120,8 +120,8 @@ bool SwappyCommonSettings::getFromApp(//JNIEnv* env, jobject jactivity, // random hard coded crap auto appVsyncOffsetNanos = 0; - auto vsyncPresentationDeadlineNanos = ONE_S_IN_NS / 100; - const auto refreshRateHz = 100; + const auto refreshRateHz = 144; + auto vsyncPresentationDeadlineNanos = ONE_S_IN_NS / refreshRateHz; const long vsyncPeriodNanos = static_cast(ONE_S_IN_NS / refreshRateHz); diff --git a/subprojects/swappy/vulkan/SwappyVkBase.cpp b/subprojects/swappy/vulkan/SwappyVkBase.cpp index ae0c8983..24cd6e21 100644 --- a/subprojects/swappy/vulkan/SwappyVkBase.cpp +++ b/subprojects/swappy/vulkan/SwappyVkBase.cpp @@ -145,7 +145,7 @@ VkResult SwappyVkBase::initializeVkSyncObjects(VkQueue queue, VkResult res = vkCreateCommandPool(mDevice, &cmd_pool_info, NULL, &mCommandPool[queue]); if (res) { - ALOGE("vkCreateCommandPool failed %d", res); + ALOGE("vkCreateCommandPool failed {}", res); return res; } const VkCommandBufferAllocateInfo present_cmd_info = { @@ -163,7 +163,7 @@ VkResult SwappyVkBase::initializeVkSyncObjects(VkQueue queue, .flags = VK_FENCE_CREATE_SIGNALED_BIT}; res = vkCreateFence(mDevice, &fence_ci, NULL, &sync.fence); if (res) { - ALOGE("failed to create fence: %d", res); + ALOGE("failed to create fence: {}", res); return res; } @@ -173,14 +173,14 @@ VkResult SwappyVkBase::initializeVkSyncObjects(VkQueue queue, .flags = 0}; res = vkCreateSemaphore(mDevice, &semaphore_ci, NULL, &sync.semaphore); if (res) { - ALOGE("failed to create semaphore: %d", res); + ALOGE("failed to create semaphore: {}", res); return res; } res = vkAllocateCommandBuffers(mDevice, &present_cmd_info, &sync.command); if (res) { - ALOGE("vkAllocateCommandBuffers failed %d", res); + ALOGE("vkAllocateCommandBuffers failed {}", res); return res; } @@ -192,7 +192,7 @@ VkResult SwappyVkBase::initializeVkSyncObjects(VkQueue queue, }; res = vkBeginCommandBuffer(sync.command, &cmd_buf_info); if (res) { - ALOGE("vkAllocateCommandBuffers failed %d", res); + ALOGE("vkAllocateCommandBuffers failed {}", res); return res; } @@ -203,7 +203,7 @@ VkResult SwappyVkBase::initializeVkSyncObjects(VkQueue queue, }; res = vkCreateEvent(mDevice, &event_info, NULL, &sync.event); if (res) { - ALOGE("vkCreateEvent failed %d", res); + ALOGE("vkCreateEvent failed {}", res); return res; } @@ -212,7 +212,7 @@ VkResult SwappyVkBase::initializeVkSyncObjects(VkQueue queue, res = vkEndCommandBuffer(sync.command); if (res) { - ALOGE("vkCreateEvent failed %d", res); + ALOGE("vkCreateEvent failed {}", res); return res; } @@ -390,7 +390,7 @@ void SwappyVkBase::waitForFenceThreadMain(ThreadContext& thread) { vkWaitForFences(mDevice, 1, &sync.fence, VK_TRUE, mCommonBase.getFenceTimeout().count()); if (result) { - ALOGE("Failed to wait for fence %d", result); + ALOGE("Failed to wait for fence {}", result); } mLastFenceTime = std::chrono::steady_clock::now() - startTime;