swappy
jackun 3 years ago
parent 868894e773
commit 922b541f52
No known key found for this signature in database
GPG Key ID: 119DB3F1D05A9ED3

@ -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<std::chrono::nanoseconds> (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
};

@ -104,7 +104,7 @@ void NoChoreographerThread::onSettingsChanged() {
Settings::getInstance()->getDisplayTimings();
std::lock_guard<std::mutex> lock(mWaitingMutex);
mRefreshPeriod = displayTimings.refreshPeriod;
ALOGV("onSettingsChanged(): refreshPeriod=%lld",
ALOGV("onSettingsChanged(): refreshPeriod={}",
(long long)displayTimings.refreshPeriod.count());
}

@ -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<long>(ONE_S_IN_NS / refreshRateHz);

@ -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;

Loading…
Cancel
Save