summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorJordan Halase <jordan@halase.me>2019-11-03 19:53:24 -0600
committerJordan Halase <jordan@halase.me>2019-11-03 19:53:24 -0600
commitb490c8973dd5137257a5ec004a2d6dbb0b05020a (patch)
tree7560ab043940d063dd8589ea005624d723f7331d /main.c
parentfaa978ae4e9bfe02758b82895d5b0985093f55f7 (diff)
Update pugl stub usage and verbose logging
Diffstat (limited to 'main.c')
-rw-r--r--main.c55
1 files changed, 41 insertions, 14 deletions
diff --git a/main.c b/main.c
index fc90146..eabe67f 100644
--- a/main.c
+++ b/main.c
@@ -334,7 +334,7 @@ VkResult createVulkanSurface(PuglView *view,
VkXlibSurfaceCreateInfoKHR createInfo = { 0 };
createInfo.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
//createInfo.dpy = ((struct PuglWorldImpl*)world)->impl->display;
- createInfo.dpy = puglGetNativeWorld(view->world);
+ createInfo.dpy = puglGetNativeWorld(puglGetWorld(view));
createInfo.window = puglGetNativeWindow(view);
PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR =
@@ -726,7 +726,7 @@ static bool rvkIsDeviceSuitable(const struct RenderVulkan *const vk,
VkQueueFamilyProperties *queueProperties = malloc(nQueueFamilies * sizeof(*queueProperties));
vk->api->vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &nQueueFamilies, queueProperties);
for (uint32_t i = 0; i < nQueueFamilies; ++i) {
- printf("Queue Family %d queueCount:\t%d\n", i, queueProperties[i].queueCount);
+ printf("Queue family %d queueCount:\t%d\n", i, queueProperties[i].queueCount);
}
for (uint32_t i = 0; i < nQueueFamilies; ++i) {
printf("Queue family %d queueFlags:\t", i);
@@ -766,6 +766,24 @@ static bool rvkIsDeviceSuitable(const struct RenderVulkan *const vk,
return true;
}
+const char *strDeviceType(const VkPhysicalDeviceType deviceType)
+{
+ switch (deviceType) {
+ case VK_PHYSICAL_DEVICE_TYPE_OTHER:
+ return "Other";
+ case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU:
+ return "Integrated GPU";
+ case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU:
+ return "Discrete GPU";
+ case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU:
+ return "Virtual GPU";
+ case VK_PHYSICAL_DEVICE_TYPE_CPU:
+ return "CPU";
+ default:
+ return "Unknown";
+ }
+}
+
/** Selects a physical device
*
* This application will not attempt to find the "most powerful" device on the
@@ -806,23 +824,29 @@ int rvkSelectPhysicalDevice(struct RenderVulkan *vk)
}
}
+ const char *strType;
uint32_t i;
for (i = 0; i < nDevices; ++i) {
vk->api->vkGetPhysicalDeviceProperties(devices[i], &deviceProperties[i]);
- printf("Found physical device:\t\t`%s`\n", deviceProperties[i].deviceName);
+ strType = strDeviceType(deviceProperties[i].deviceType);
+ printf("Found physical device %d/%d:\t`%s`\t(%s)\n",
+ i+1, nDevices, deviceProperties[i].deviceName, strType);
}
for (i = 0; i < nDevices; ++i) {
- printf("Checking suitability for\t`%s`...\n", deviceProperties[i].deviceName);
+ strType = strDeviceType(deviceProperties[i].deviceType);
+ printf("Checking suitability for\t`%s`...\t(%s)\n", deviceProperties[i].deviceName, strType);
uint32_t graphicsIndex;
if (rvkIsDeviceSuitable(vk, devices[i], &graphicsIndex)) {
- printf("Using physical device:\t\t`%s`\n", deviceProperties[i].deviceName);
+ printf("Using physical device:\t\t`%s`\t(%s)\n",
+ deviceProperties[i].deviceName,
+ strDeviceType(deviceProperties[i].deviceType));
vk->deviceProperties = deviceProperties[i];
vk->physicalDevice = devices[i];
vk->graphicsIndex = graphicsIndex;
- printf("Using GRAPHICS family index:\t%d\n", vk->graphicsIndex);
+ printf("Using queue family index:\t%d\tfor\tGRAPHICS\n", vk->graphicsIndex);
goto done;
}
- printf("Device `%s` not suitable\n", deviceProperties[i].deviceName);
+ printf("Device `%s` (%s) not suitable\n", deviceProperties[i].deviceName, strType);
}
if (i >= nDevices) {
rvkSetErrMsg(vk, "No suitable devices found");
@@ -1098,11 +1122,15 @@ static char *strPresentMode(const VkPresentModeKHR presentMode)
static bool isPresentModeSupported(const VkPresentModeKHR *const presentModes,
const uint32_t nPresentModes, const VkPresentModeKHR want)
{
+ const char *const strWant = strPresentMode(want);
+ printf("Checking for present mode:\t`%s`...\n", strWant);
for (uint32_t i = 0; i < nPresentModes; ++i) {
if (presentModes[i] == want) {
return true;
}
}
+ /* The same device on different platforms may not have the same present modes */
+ printf("Present mode `%s` not available for this device or platform\n", strWant);
return false;
}
@@ -1170,7 +1198,7 @@ static int rvkCreateRawSwapchain(struct RenderVulkan *vk, int width, int height)
VkPresentModeKHR presentMode;
for (i = 0; i < nPresentModes; ++i) {
presentMode = presentModes[i];
- printf("Found present mode:\t\t%s\t(%d)\n", strPresentMode(presentMode), presentMode);
+ printf("Found present mode:\t\t`%s`\t(%d)\n", strPresentMode(presentMode), presentMode);
}
if (isPresentModeSupported(presentModes, nPresentModes, VK_PRESENT_MODE_MAILBOX_KHR)) {
@@ -1181,7 +1209,7 @@ static int rvkCreateRawSwapchain(struct RenderVulkan *vk, int width, int height)
presentMode = VK_PRESENT_MODE_FIFO_KHR;
}
free(presentModes);
- printf("Using present mode:\t\t%s\t(%d)\n", strPresentMode(presentMode), presentMode);
+ printf("Using present mode:\t\t`%s`\t(%d)\n", strPresentMode(presentMode), presentMode);
// TODO: Clamp
vk->swapchain.extent.width = width;
@@ -1556,11 +1584,10 @@ PuglStatus onDisplay(PuglView *view)
}
/* If running continuously, Vulkan can blast the queue with rendering
- * work faster than the GPU can get around to doing it, causing RAM
- * usage to grow indefinitely. We use fences to limit the number of
- * submitted frames to the number of swapchain images. These fences will
- * be required later anyway when flushing persistently mapped uniform
- * buffer ranges.
+ * work faster than the GPU can execute it, causing RAM usage to grow
+ * indefinitely. We use fences to limit the number of submitted frames
+ * to the number of swapchain images. These fences will be required
+ * later anyway when flushing persistently mapped uniform buffer ranges.
*/
vk->dev->vkWaitForFences(vk->device,
1, &vk->sync.fence.swapchain[imageIndex],