summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2018-02-26 11:16:38 -0800
committerKeith Packard <keithp@keithp.com>2018-02-26 11:16:38 -0800
commitb32591b010fb9f9263c1b479e61873988d184b47 (patch)
tree8884d87a60f07ce8f81bce61e675cefda07d1b68
parentbdef448d5295cf3b63391e8478cd7996dda5b118 (diff)
local hacks
-rw-r--r--cube.c21
-rw-r--r--gettime.h6
2 files changed, 21 insertions, 6 deletions
diff --git a/cube.c b/cube.c
index 255db56..ddb1515 100644
--- a/cube.c
+++ b/cube.c
@@ -875,6 +875,15 @@ void DemoUpdateTargetIPD(struct demo *demo) {
bool late = false;
bool calibrate_next = false;
for (uint32_t i = 0 ; i < count ; i++) {
+
+ printf("%d: desired %f actual %f earliest %f gap %f\n",
+ i,
+ past[i].desiredPresentTime / 1e9,
+ past[i].actualPresentTime / 1e9,
+ past[i].earliestPresentTime / 1e9,
+ past[i].actualPresentTime / 1e9 - past[i].earliestPresentTime / 1e9);
+
+
if (!demo->syncd_with_actual_presents) {
// This is the first time that we've received an
// actualPresentTime for this swapchain. In order to not
@@ -1111,7 +1120,7 @@ static void demo_draw(struct demo *demo) {
// takes. Let's make a grossly-simplified assumption that the
// desiredPresentTime should be half way between now and
// now+target_IPD. We will adjust over time.
- uint64_t curtime = 0 & getTimeInNanoseconds();
+ uint64_t curtime = getTimeInNanoseconds();
if (curtime == 0) {
// Since we didn't find out the current time, don't give a
// desiredPresentTime:
@@ -1123,6 +1132,11 @@ static void demo_draw(struct demo *demo) {
ptime.desiredPresentTime = (demo->prev_desired_present_time +
demo->target_IPD);
}
+
+ printf("\tdesired present time %f delta %f\n",
+ ptime.desiredPresentTime / 1e9,
+ ptime.desiredPresentTime / 1e9 - demo->prev_desired_present_time / 1e9);
+
ptime.presentID = demo->next_present_id++;
demo->prev_desired_present_time = ptime.desiredPresentTime;
@@ -1330,6 +1344,7 @@ static void demo_prepare_buffers(struct demo *demo) {
// AMD driver times out waiting on fences used in AcquireNextImage on
// a swapchain that is subsequently destroyed before the wait.
vkWaitForFences(demo->device, FRAME_LAG, demo->fences, VK_TRUE, UINT64_MAX);
+// vkResetFences(demo->device, FRAME_LAG, demo->fences);
demo->fpDestroySwapchainKHR(demo->device, oldSwapchain, NULL);
}
@@ -3886,7 +3901,7 @@ static void demo_init_vk_swapchain(struct demo *demo) {
// Create semaphores to synchronize acquiring presentable buffers before
// rendering and waiting for drawing to be complete before presenting
- VkSemaphoreCreateInfo semaphoreCreateInfo = {
+ const VkSemaphoreCreateInfo semaphoreCreateInfo = {
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO,
.pNext = NULL,
.flags = 0,
@@ -3894,7 +3909,7 @@ static void demo_init_vk_swapchain(struct demo *demo) {
// Create fences that we can use to throttle if we get too far
// ahead of the image presents
- VkFenceCreateInfo fence_ci = {
+ const VkFenceCreateInfo fence_ci = {
.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
.pNext = NULL,
.flags = VK_FENCE_CREATE_SIGNALED_BIT
diff --git a/gettime.h b/gettime.h
index a4265cd..eb8e5dd 100644
--- a/gettime.h
+++ b/gettime.h
@@ -55,18 +55,18 @@ uint64_t getTimeInNanoseconds(void) {
#elif defined(__unix__) || defined(__linux) || defined(__linux__) || defined(__ANDROID__) || defined(__QNX__)
struct timespec currTime;
clock_gettime(CLOCK_MONOTONIC, &currTime);
- return (uint64_t)currTime.tv_sec * 1000000 + ((uint64_t)currTime.tv_nsec / 1000);
+ return (uint64_t)currTime.tv_sec * 1000000000 + ((uint64_t)currTime.tv_nsec);
#elif defined(__EPOC32__)
struct timespec currTime;
/* Symbian supports only realtime clock for clock_gettime. */
clock_gettime(CLOCK_REALTIME, &currTime);
- return (uint64_t)currTime.tv_sec * 1000000 + ((uint64_t)currTime.tv_nsec / 1000);
+ return (uint64_t)currTime.tv_sec * 1000000000 + ((uint64_t)currTime.tv_nsec);
#elif defined(__APPLE__)
struct timeval currTime;
gettimeofday(&currTime, NULL);
- return (uint64_t)currTime.tv_sec * 1000000 + (uint64_t)currTime.tv_usec;
+ return (uint64_t)currTime.tv_sec * 1000000000 + (uint64_t)currTime.tv_usec * 1000;
#else
#error "Not implemented for target OS"