aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoey-lunarg <joey@lunarg.com>2016-11-02 14:36:19 -0600
committerjoey-lunarg <joey@lunarg.com>2016-11-18 15:22:30 -0700
commit216f853b1d82d5b978ec6b246661dee323a62066 (patch)
treecd2d73c9d9fa8e8a2ade01015c2ba1a3674ec993
parent27f072e43e43e1ec0183aed674406d1984a950d8 (diff)
downloadusermoji-216f853b1d82d5b978ec6b246661dee323a62066.tar.xz
vulkaninfo: Add surface present modes
Change-Id: Icb6c30a81743cf5854fd7ecc974d87e814be856d
-rw-r--r--demos/vulkaninfo.c48
1 files changed, 43 insertions, 5 deletions
diff --git a/demos/vulkaninfo.c b/demos/vulkaninfo.c
index cd0a2b05..3c82073e 100644
--- a/demos/vulkaninfo.c
+++ b/demos/vulkaninfo.c
@@ -426,6 +426,21 @@ static const char *vk_format_string(VkFormat fmt) {
}
}
+static const char *vk_present_mode_string(VkPresentModeKHR mode) {
+ switch (mode) {
+#define STR(r) \
+ case VK_PRESENT_MODE_##r: \
+ return #r
+ STR(IMMEDIATE_KHR);
+ STR(MAILBOX_KHR);
+ STR(FIFO_KHR);
+ STR(FIFO_RELAXED_KHR);
+#undef STR
+ default:
+ return "UNKNOWN_FORMAT";
+ }
+}
+
static void app_dev_init_formats(struct app_dev *dev) {
VkFormat f;
@@ -962,15 +977,34 @@ static int app_dump_surface_formats(struct app_instance *inst, struct app_gpu *g
VkSurfaceFormatKHR *surfFormats = (VkSurfaceFormatKHR *)malloc(formatCount * sizeof(VkSurfaceFormatKHR));
err = inst->vkGetPhysicalDeviceSurfaceFormatsKHR(gpu->obj, inst->surface, &formatCount, surfFormats);
assert(!err);
- printf("Format count = %d\n",formatCount);
+ printf("Formats:\t\tcount = %d\n",formatCount);
for (uint32_t i = 0; i < formatCount; i++) {
printf("\t%s\n", vk_format_string(surfFormats[i].format));
}
- printf("\n");
fflush(stdout);
return formatCount;
}
+
+static int app_dump_surface_present_modes(struct app_instance *inst, struct app_gpu *gpu) {
+ // Get the list of VkPresentMode's that are supported:
+ VkResult U_ASSERT_ONLY err;
+ uint32_t presentModeCount = 0;
+ err = inst->vkGetPhysicalDeviceSurfacePresentModesKHR(gpu->obj, inst->surface, &presentModeCount, NULL);
+ assert(!err);
+
+ VkPresentModeKHR *surfPresentModes = (VkPresentModeKHR *)malloc(presentModeCount * sizeof(VkPresentInfoKHR));
+ err = inst->vkGetPhysicalDeviceSurfacePresentModesKHR(gpu->obj, inst->surface, &presentModeCount, surfPresentModes);
+ assert(!err);
+ printf("Present Modes:\t\tcount = %d\n", presentModeCount);
+
+ for (uint32_t i = 0; i < presentModeCount; i++) {
+ printf("\t%s\n", vk_present_mode_string(surfPresentModes[i]));
+ }
+ printf("\n");
+ fflush(stdout);
+ return presentModeCount;
+}
#endif
static void app_dev_dump_format_props(const struct app_dev *dev, VkFormat fmt)
@@ -1493,11 +1527,12 @@ int main(int argc, char **argv) {
fflush(stdout);
//-----------------------------
- printf("Presentable Surface formats:\n");
- printf("============================\n");
+ printf("Presentable Surfaces:\n");
+ printf("=====================\n");
inst.width = 256;
inst.height = 256;
int formatCount = 0;
+ int presentModeCount = 0;
//--WIN32--
#ifdef VK_USE_PLATFORM_WIN32_KHR
@@ -1509,6 +1544,7 @@ int main(int argc, char **argv) {
printf("GPU id : %u (%s)\n", i, gpus[i].props.deviceName);
printf("Surface type : %s\n", VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
formatCount += app_dump_surface_formats(&inst, &gpus[i]);
+ presentModeCount += app_dump_surface_present_modes(&inst, &gpus[i]);
app_destroy_surface(&inst);
}
app_destroy_win32_window(&inst);
@@ -1531,6 +1567,7 @@ int main(int argc, char **argv) {
printf("GPU id : %u (%s)\n", i, gpus[i].props.deviceName);
printf("Surface type : %s\n", VK_KHR_XCB_SURFACE_EXTENSION_NAME);
formatCount += app_dump_surface_formats(&inst, &gpus[i]);
+ presentModeCount += app_dump_surface_present_modes(&inst, &gpus[i]);
app_destroy_surface(&inst);
}
app_destroy_xcb_window(&inst);
@@ -1546,13 +1583,14 @@ int main(int argc, char **argv) {
printf("GPU id : %u (%s)\n", i, gpus[i].props.deviceName);
printf("Surface type : %s\n", VK_KHR_XLIB_SURFACE_EXTENSION_NAME);
formatCount += app_dump_surface_formats(&inst, &gpus[i]);
+ presentModeCount += app_dump_surface_present_modes(&inst, &gpus[i]);
app_destroy_surface(&inst);
}
app_destroy_xlib_window(&inst);
}
#endif
// TODO: Android / Wayland / MIR
- if (!formatCount)
+ if (!formatCount && !presentModeCount)
printf("None found\n");
//---------