summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmain.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/main.c b/main.c
index 317f30c..9da546d 100755
--- a/main.c
+++ b/main.c
@@ -43,6 +43,7 @@ PERFORMANCE OF THIS SOFTWARE.
#else
#include <X11/Xlib.h> // XXX Pugl: to implement puglCreateVulkanSurface() on X11
#include <vulkan/vulkan_xlib.h> // XXX Pugl: to implement puglCreateVulkanSurface() on X11
+#include <unistd.h> // for usleep(), sleep()
#endif
#include "test/test_utils.h" // for printEvent()
@@ -1771,6 +1772,12 @@ struct Arguments args;
uint32_t framesDrawn;
+VkResult hackSemaphore(struct RenderVulkan *vk, VkSemaphore *pSemaphore)
+{
+ VkSemaphoreCreateInfo createInfo = { VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO };
+ return vk->dev->vkCreateSemaphore(vk->device, &createInfo, ALLOC_VK, pSemaphore);
+}
+
PuglStatus onDisplay(PuglView *view)
{
struct RenderVulkan *vk = puglGetHandle(view);
@@ -1794,13 +1801,6 @@ PuglStatus onDisplay(PuglView *view)
dummyInfo.pSignalSemaphores = &vk->sync.semaphore.dummyFinished;
static uint32_t dummy = 0;
-#if 0
- if (dummy == 1) {
- for (uint32_t i = 0; i < 10000000; ++i) {
- uint32_t j = i/2;
- }
- }
-#endif
if (!dummy) {
printf("%d: Submitting dummy buffer...\n", dummy);
if ((result = vk->dev->vkQueueSubmit(vk->graphicsQueue,
@@ -1813,6 +1813,8 @@ PuglStatus onDisplay(PuglView *view)
}
printf("%d: Dummy buffer submitted\n", dummy);
} else if (dummy == vk->swapchain.nImages-1) {
+ usleep(500000);
+ // TODO: set breakpoint
result = vk->dev->vkGetEventStatus(vk->device, vk->sync.event.normal);
if (result == VK_EVENT_SET) {
printf("%d: ERROR: Queue already executed\n", dummy);
@@ -1825,12 +1827,22 @@ PuglStatus onDisplay(PuglView *view)
vk->dev->vkSetEvent(vk->device, vk->sync.event.dummy);
}
+#if 0
+ VkSemaphore freshSemaphore;
+ if ((result = hackSemaphore(vk, &freshSemaphore))) {
+ fprintf(stderr, "Could not make fresh semaphore\n");
+ running = 0;
+ return PUGL_FAILURE;
+ }
+#else
+ VkSemaphore freshSemaphore = vk->sync.semaphore.presentComplete;
+#endif
const VkSemaphore waits[] = {
- vk->sync.semaphore.presentComplete,
+ //vk->sync.semaphore.presentComplete,
+ freshSemaphore,
vk->sync.semaphore.dummyFinished
};
uint32_t imageIndex;
-
// TODO: Swapchain recreation when rezing, minimizing, etc.
// TODO: Possibly use unique semaphores per in-flight image?
if (dummy < vk->swapchain.nImages-1) {
@@ -1840,7 +1852,8 @@ PuglStatus onDisplay(PuglView *view)
vk->device,
vk->swapchain.rawSwapchain,
UINT64_MAX,
- vk->sync.semaphore.presentComplete,
+ //vk->sync.semaphore.presentComplete,
+ freshSemaphore,
VK_NULL_HANDLE,
&imageIndex))) {
rvkSetErrMsg(vk, "Could not acquire swapchain image: %d", result);
@@ -1880,7 +1893,8 @@ PuglStatus onDisplay(PuglView *view)
1, &submitInfo,
vk->sync.fence.swapchain[imageIndex]
))) {
- rvkSetErrMsg(vk, "Could not submit to queue: %d", result);
+ //rvkSetErrMsg(vk, "Could not submit to queue: %d", result);
+ fprintf(stderr, "Could not submit to queue: %d", result);
running = 0;
return PUGL_FAILURE;
}